1111
This commit is contained in:
+2
-1
File diff suppressed because one or more lines are too long
-51
@@ -1,51 +0,0 @@
|
||||
"use strict";
|
||||
const uni_modules_svEditor_components_common_config = require("./config.js");
|
||||
function parseHtmlWithVideo(richText) {
|
||||
const imgRegex = /<img\s+([^>]+)>/gi;
|
||||
const customUrlRegex = /\bdata-custom="[^"]*url=([^&"]+)/i;
|
||||
return richText.replace(imgRegex, (match, attrs) => {
|
||||
const urlMatch = attrs.match(customUrlRegex);
|
||||
if (urlMatch) {
|
||||
const videoUrl = urlMatch[1];
|
||||
const attrArray = attrs.split(/\s+/).filter((attr) => attr.trim() !== "");
|
||||
const newAttrs = attrArray.filter((attr) => !attr.startsWith("src=") && !attr.startsWith("data-custom=")).join(" ");
|
||||
return `<video controls ${newAttrs} src="${videoUrl}" width="100%" ></video>`;
|
||||
}
|
||||
return match;
|
||||
});
|
||||
}
|
||||
async function replaceVideoWithImageRender(richText, customCallback) {
|
||||
const videoRegex = /<video\s+([^>]+)>(.*?)<\/video>/gi;
|
||||
const matches = [];
|
||||
let match;
|
||||
while ((match = videoRegex.exec(richText)) !== null) {
|
||||
matches.push(match);
|
||||
}
|
||||
const replacements = await Promise.all(
|
||||
matches.map(async (match2) => {
|
||||
const [fullMatch, attributes, content] = match2;
|
||||
const sourceRegex = /<source\s+[^>]*src="([^">]+)"/i;
|
||||
const matchSource = content.match(sourceRegex);
|
||||
let videoUrl = "";
|
||||
if (matchSource && matchSource.length > 1) {
|
||||
videoUrl = matchSource[1];
|
||||
}
|
||||
let thumbnailRes;
|
||||
if (customCallback)
|
||||
thumbnailRes = await customCallback(videoUrl);
|
||||
if (!thumbnailRes)
|
||||
thumbnailRes = uni_modules_svEditor_components_common_config.config.video_thumbnail;
|
||||
const filteredAttributes = attributes.split(/\s+/).filter((attr) => !attr.startsWith("controls")).join(" ");
|
||||
const imgTag = `<img ${filteredAttributes} src="${thumbnailRes}" data-custom="url=${videoUrl}" />`;
|
||||
return { fullMatch, imgTag };
|
||||
})
|
||||
);
|
||||
let result = richText;
|
||||
for (const { fullMatch, imgTag } of replacements) {
|
||||
result = result.replace(fullMatch, imgTag);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
exports.parseHtmlWithVideo = parseHtmlWithVideo;
|
||||
exports.replaceVideoWithImageRender = replaceVideoWithImageRender;
|
||||
//# sourceMappingURL=../../../../../.sourcemap/mp-weixin/uni_modules/sv-editor/components/common/parse.js.map
|
||||
-58
@@ -1,58 +0,0 @@
|
||||
"use strict";
|
||||
const common_vendor = require("../../../../common/vendor.js");
|
||||
let state = null;
|
||||
state = common_vendor.reactive({
|
||||
curEID: "",
|
||||
formats: {},
|
||||
isReadOnly: false,
|
||||
firstInstanceFlag: ""
|
||||
// 首次实例化标志,禁止手动更改
|
||||
});
|
||||
function getEditor(eid) {
|
||||
return state[`${eid}-ctx`];
|
||||
}
|
||||
function setEditor(eid, ctx) {
|
||||
state[`${eid}-ctx`] = ctx;
|
||||
state[`${eid}-ctx`].id = eid;
|
||||
}
|
||||
function getEID() {
|
||||
return state.curEID;
|
||||
}
|
||||
function setEID(eid) {
|
||||
state.curEID = eid;
|
||||
}
|
||||
function getFormats() {
|
||||
return state.formats;
|
||||
}
|
||||
function setFormats(formats) {
|
||||
state.formats = formats;
|
||||
}
|
||||
function getReadOnly() {
|
||||
return state.isReadOnly;
|
||||
}
|
||||
function setReadOnly(readOnly) {
|
||||
state.isReadOnly = readOnly;
|
||||
}
|
||||
function destroy() {
|
||||
state = {};
|
||||
state.curEID = "";
|
||||
state.formats = {};
|
||||
state.isReadOnly = false;
|
||||
state.firstInstanceFlag = "";
|
||||
}
|
||||
const options = {
|
||||
state,
|
||||
actions: {
|
||||
getEditor,
|
||||
setEditor,
|
||||
getEID,
|
||||
setEID,
|
||||
getFormats,
|
||||
setFormats,
|
||||
getReadOnly,
|
||||
setReadOnly,
|
||||
destroy
|
||||
}
|
||||
};
|
||||
exports.options = options;
|
||||
//# sourceMappingURL=../../../../../.sourcemap/mp-weixin/uni_modules/sv-editor/components/common/store.js.map
|
||||
-203
@@ -1,203 +0,0 @@
|
||||
"use strict";
|
||||
const common_vendor = require("../../../../common/vendor.js");
|
||||
const uni_modules_svEditor_components_common_store = require("./store.js");
|
||||
const id = "sv-editor";
|
||||
const displayName = "基于官方 uni-editor 的富文本编辑器";
|
||||
const version = "1.1.2";
|
||||
const description = "可插入图片、视频、链接、@提及、#话题、Emoji表情包,且优化了聚焦键盘闪烁等问题";
|
||||
const keywords = [
|
||||
"富文本",
|
||||
"编辑器",
|
||||
"editor",
|
||||
"html"
|
||||
];
|
||||
const repository = "https://gitee.com/Sonve/sv-editor";
|
||||
const engines = {
|
||||
HBuilderX: "^3.1.0"
|
||||
};
|
||||
const dcloudext = {
|
||||
type: "component-vue",
|
||||
sale: {
|
||||
regular: {
|
||||
price: "0.00"
|
||||
},
|
||||
sourcecode: {
|
||||
price: "0.00"
|
||||
}
|
||||
},
|
||||
contact: {
|
||||
qq: ""
|
||||
},
|
||||
declaration: {
|
||||
ads: "无",
|
||||
data: "插件不采集任何数据",
|
||||
permissions: "无"
|
||||
},
|
||||
npmurl: ""
|
||||
};
|
||||
const uni_modules = {
|
||||
dependencies: [],
|
||||
encrypt: [],
|
||||
platforms: {
|
||||
cloud: {
|
||||
tcb: "y",
|
||||
aliyun: "y",
|
||||
alipay: "y"
|
||||
},
|
||||
client: {
|
||||
Vue: {
|
||||
vue2: "y",
|
||||
vue3: "y"
|
||||
},
|
||||
App: {
|
||||
"app-vue": "y",
|
||||
"app-nvue": "u",
|
||||
"app-uvue": "u",
|
||||
"app-harmony": "u"
|
||||
},
|
||||
"H5-mobile": {
|
||||
Safari: "y",
|
||||
"Android Browser": "y",
|
||||
"微信浏览器(Android)": "y",
|
||||
"QQ浏览器(Android)": "y"
|
||||
},
|
||||
"H5-pc": {
|
||||
Chrome: "y",
|
||||
IE: "y",
|
||||
Edge: "y",
|
||||
Firefox: "y",
|
||||
Safari: "y"
|
||||
},
|
||||
"小程序": {
|
||||
"微信": "y",
|
||||
"阿里": "u",
|
||||
"百度": "u",
|
||||
"字节跳动": "u",
|
||||
QQ: "u",
|
||||
"钉钉": "u",
|
||||
"快手": "u",
|
||||
"飞书": "u",
|
||||
"京东": "u"
|
||||
},
|
||||
"快应用": {
|
||||
"华为": "u",
|
||||
"联盟": "u"
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
const packageConfig = {
|
||||
id,
|
||||
displayName,
|
||||
version,
|
||||
description,
|
||||
keywords,
|
||||
repository,
|
||||
engines,
|
||||
dcloudext,
|
||||
uni_modules
|
||||
};
|
||||
function addText(word) {
|
||||
const eid = uni_modules_svEditor_components_common_store.options.actions.getEID();
|
||||
const editorCtx = uni_modules_svEditor_components_common_store.options.actions.getEditor(eid);
|
||||
noKeyboardEffect(() => {
|
||||
editorCtx.insertText({ text: "\n" });
|
||||
editorCtx.insertText({ text: "【" + word + "】:" });
|
||||
editorCtx.insertText({ text: "\n" });
|
||||
});
|
||||
}
|
||||
function addImage(imgs, options = {}) {
|
||||
const eid = uni_modules_svEditor_components_common_store.options.actions.getEID();
|
||||
const editorCtx = uni_modules_svEditor_components_common_store.options.actions.getEditor(eid);
|
||||
const upRes = imgs;
|
||||
common_vendor.index.__f__("log", "at uni_modules/sv-editor/components/common/utils.js:41", "upRes");
|
||||
common_vendor.index.__f__("log", "at uni_modules/sv-editor/components/common/utils.js:42", upRes);
|
||||
common_vendor.index.__f__("log", "at uni_modules/sv-editor/components/common/utils.js:43", upRes instanceof Array);
|
||||
common_vendor.index.__f__("log", "at uni_modules/sv-editor/components/common/utils.js:44", upRes.length);
|
||||
if (!upRes || upRes.length == 0)
|
||||
return;
|
||||
noKeyboardEffect(() => {
|
||||
upRes == null ? void 0 : upRes.forEach((item) => {
|
||||
common_vendor.index.__f__("log", "at uni_modules/sv-editor/components/common/utils.js:51", "item");
|
||||
common_vendor.index.__f__("log", "at uni_modules/sv-editor/components/common/utils.js:52", item);
|
||||
editorCtx.insertImage({
|
||||
...options,
|
||||
src: options.srcFiled ? item[options.srcFiled] : item
|
||||
});
|
||||
});
|
||||
});
|
||||
return upRes;
|
||||
}
|
||||
async function addVideo(uploadFunc, options = {}) {
|
||||
const eid = uni_modules_svEditor_components_common_store.options.actions.getEID();
|
||||
const editorCtx = uni_modules_svEditor_components_common_store.options.actions.getEditor(eid);
|
||||
if (!uploadFunc)
|
||||
return;
|
||||
const upRes = await uploadFunc(editorCtx);
|
||||
common_vendor.index.__f__("log", "at uni_modules/sv-editor/components/common/utils.js:86", upRes);
|
||||
if (!upRes || !(upRes == null ? void 0 : upRes.length))
|
||||
return;
|
||||
noKeyboardEffect(() => {
|
||||
upRes == null ? void 0 : upRes.forEach((item) => {
|
||||
editorCtx.insertImage({
|
||||
...options,
|
||||
src: item.videoImg,
|
||||
//item[options.imageFiled || 'imagePath'],
|
||||
data: { url: item.videoUrl }
|
||||
});
|
||||
});
|
||||
});
|
||||
return upRes;
|
||||
}
|
||||
const linkFlag = "🔗添加链接中, 请稍后...🔗";
|
||||
function noKeyboardEffect(callback, options) {
|
||||
let defaultOpt = { delay: 50 };
|
||||
defaultOpt.mode = "loseFocus";
|
||||
const opt = Object.assign(defaultOpt, options);
|
||||
const eid = uni_modules_svEditor_components_common_store.options.actions.getEID();
|
||||
const editorCtx = uni_modules_svEditor_components_common_store.options.actions.getEditor(eid);
|
||||
if (opt.mode == "hideKeyboard") {
|
||||
callback();
|
||||
setTimeout(() => {
|
||||
common_vendor.index.hideKeyboard();
|
||||
}, opt.delay);
|
||||
}
|
||||
if (opt.mode == "loseFocus") {
|
||||
callback();
|
||||
editorCtx.blur();
|
||||
}
|
||||
if (opt.mode == "setReadOnly") {
|
||||
uni_modules_svEditor_components_common_store.options.actions.setReadOnly(true);
|
||||
callback();
|
||||
setTimeout(() => {
|
||||
uni_modules_svEditor_components_common_store.options.actions.setReadOnly(false);
|
||||
}, opt.delay);
|
||||
}
|
||||
if (opt.mode == "setInputMode")
|
||||
;
|
||||
}
|
||||
function copyrightPrint() {
|
||||
const styleTitle1 = `font-size:16px;font-weight:700;color:#ff4500;`;
|
||||
const styleTitle2 = `font-style:oblique;font-size:14px;color:#fb7299;`;
|
||||
const styleContent = `color:#66ccff;`;
|
||||
const title1 = ` 📝 sv-editor v${packageConfig.version} `;
|
||||
const title2 = "by Sonve";
|
||||
const content = `
|
||||
版权声明:
|
||||
1. 本插件免费开源,还望保留此版权声明在控制台输出
|
||||
2. 如需借鉴源码,还望注明出处
|
||||
3. 未经授权您不得以任何形式转载、售卖本插件,或以其他形式侵犯版权及附属权利
|
||||
4. 作者将保留对此插件版权信息的最终解释权
|
||||
🏠 地址: https://ext.dcloud.net.cn/plugin?id=21184
|
||||
😸 Gitee: https://gitee.com/Sonve/sv-editor
|
||||
💬 微信: s1051399604
|
||||
🐧 QQ群: ① 852637893 ② 816646292
|
||||
`;
|
||||
common_vendor.index.__f__("log", "at uni_modules/sv-editor/components/common/utils.js:413", `%c${title1}%c${title2}%c${content}`, styleTitle1, styleTitle2, styleContent);
|
||||
}
|
||||
exports.addImage = addImage;
|
||||
exports.addText = addText;
|
||||
exports.addVideo = addVideo;
|
||||
exports.copyrightPrint = copyrightPrint;
|
||||
exports.linkFlag = linkFlag;
|
||||
//# sourceMappingURL=../../../../../.sourcemap/mp-weixin/uni_modules/sv-editor/components/common/utils.js.map
|
||||
-69
@@ -1,69 +0,0 @@
|
||||
"use strict";
|
||||
const common_vendor = require("../../../../common/vendor.js");
|
||||
const block0 = {};
|
||||
const _sfc_main = {
|
||||
props: {
|
||||
sid: {
|
||||
type: String,
|
||||
default: ""
|
||||
},
|
||||
eid: {
|
||||
type: String,
|
||||
default: ""
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
videoUrl: "",
|
||||
// 视频地址
|
||||
coverUrl: "",
|
||||
// 封面地址
|
||||
coverUrlIOS: "",
|
||||
// ios端封面地址
|
||||
pastemode: "text"
|
||||
// 粘贴模式 text | origin
|
||||
};
|
||||
},
|
||||
mounted() {
|
||||
},
|
||||
methods: {
|
||||
changePasteMode(e) {
|
||||
this.pastemode = e;
|
||||
},
|
||||
editorPaste(e) {
|
||||
this.$emit("epaste", e);
|
||||
},
|
||||
createVideoThumbnail(url) {
|
||||
this.videoUrl = url;
|
||||
},
|
||||
getVideoThumbnail(e) {
|
||||
common_vendor.index.$emit(`E_EDITOR_GET_VIDEO_THUMBNAIL_${e.video}`, e);
|
||||
},
|
||||
createCoverThumbnail(url) {
|
||||
},
|
||||
getCoverThumbnail(e) {
|
||||
common_vendor.index.$emit(`E_EDITOR_GET_COVER_THUMBNAIL_${e.image}`, e);
|
||||
}
|
||||
}
|
||||
};
|
||||
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
||||
return {
|
||||
a: $props.eid,
|
||||
b: _ctx.quillEditor.watchEID,
|
||||
c: $props.sid,
|
||||
d: _ctx.quillEditor.watchStartID,
|
||||
e: $data.videoUrl,
|
||||
f: _ctx.quillEditor.watchPasteMode,
|
||||
g: $data.pastemode,
|
||||
h: _ctx.quillEditor.watchVideoUrl,
|
||||
i: $data.coverUrl,
|
||||
j: _ctx.quillEditor.watchCoverUrl,
|
||||
k: $data.coverUrlIOS,
|
||||
l: _ctx.quillEditor.watchCoverUrlIOS
|
||||
};
|
||||
}
|
||||
if (typeof block0 === "function")
|
||||
block0(_sfc_main);
|
||||
const Component = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render]]);
|
||||
wx.createComponent(Component);
|
||||
//# sourceMappingURL=../../../../../.sourcemap/mp-weixin/uni_modules/sv-editor/components/plugins/sv-editor-plugin.js.map
|
||||
Vendored
-4
@@ -1,4 +0,0 @@
|
||||
{
|
||||
"component": true,
|
||||
"usingComponents": {}
|
||||
}
|
||||
Vendored
-1
@@ -1 +0,0 @@
|
||||
<text eid="{{a}}" change:eid="{{b}}" sid="{{c}}" change:sid="{{d}}" video="{{e}}" change:pastemode="{{f}}" pastemode="{{g}}" change:video="{{h}}" cover="{{i}}" change:cover="{{j}}" coverios="{{k}}" change:coverios="{{l}}"></text>
|
||||
Vendored
Vendored
-125
@@ -1,125 +0,0 @@
|
||||
"use strict";
|
||||
const common_vendor = require("../../../../common/vendor.js");
|
||||
const uni_modules_svEditor_components_common_config = require("../common/config.js");
|
||||
function wxCreateCoverThumbnail(coverImageUrl) {
|
||||
const loadImage = () => {
|
||||
return new Promise((resolve, reject) => {
|
||||
common_vendor.index.getImageInfo({
|
||||
src: coverImageUrl,
|
||||
success: (info) => {
|
||||
resolve(info);
|
||||
},
|
||||
fail: (err) => {
|
||||
reject(err);
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
return new Promise(async (resolve, reject) => {
|
||||
try {
|
||||
const imageInfo = await loadImage();
|
||||
const canvas = common_vendor.index.createOffscreenCanvas({
|
||||
type: "2d",
|
||||
width: imageInfo.width,
|
||||
height: imageInfo.height
|
||||
});
|
||||
const ctx = canvas.getContext("2d");
|
||||
const coverImg = canvas.createImage();
|
||||
await new Promise((resolve2) => {
|
||||
coverImg.onload = resolve2;
|
||||
coverImg.src = coverImageUrl;
|
||||
});
|
||||
ctx.drawImage(coverImg, 0, 0, canvas.width, canvas.height);
|
||||
const playIcon = canvas.createImage();
|
||||
await new Promise((resolve2) => {
|
||||
playIcon.onload = resolve2;
|
||||
playIcon.src = uni_modules_svEditor_components_common_config.config.video_playicon;
|
||||
});
|
||||
const playButtonSize = canvas.width * 0.15;
|
||||
const playButtonX = (canvas.width - playButtonSize) / 2;
|
||||
const playButtonY = (canvas.height - playButtonSize) / 2;
|
||||
const iconAspectRatio = playIcon.width / playIcon.height;
|
||||
const iconWidth = playButtonSize;
|
||||
const iconHeight = iconWidth / iconAspectRatio;
|
||||
ctx.drawImage(playIcon, playButtonX, playButtonY, iconWidth, iconHeight);
|
||||
common_vendor.index.canvasToTempFilePath({
|
||||
canvas,
|
||||
destWidth: canvas.width,
|
||||
destHeight: canvas.height,
|
||||
fileType: "png",
|
||||
success: (res) => {
|
||||
resolve(res.tempFilePath);
|
||||
},
|
||||
fail: (err) => {
|
||||
reject(new Error("Failed to convert canvas to image."));
|
||||
}
|
||||
});
|
||||
} catch (error) {
|
||||
reject(error);
|
||||
}
|
||||
});
|
||||
}
|
||||
function wxCreateVideoThumbnail(coverImageUrl) {
|
||||
const loadVideo = () => {
|
||||
return new Promise((resolve, reject) => {
|
||||
common_vendor.index.getVideoInfo({
|
||||
src: coverImageUrl,
|
||||
success: (info) => {
|
||||
resolve(info);
|
||||
},
|
||||
fail: (err) => {
|
||||
reject(err);
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
return new Promise(async (resolve, reject) => {
|
||||
try {
|
||||
const imageInfo = await loadVideo();
|
||||
const canvas = common_vendor.index.createOffscreenCanvas({
|
||||
type: "2d",
|
||||
width: imageInfo.width,
|
||||
height: imageInfo.height
|
||||
});
|
||||
const ctx = canvas.getContext("2d");
|
||||
const coverImg = canvas.createImage();
|
||||
await new Promise((resolve2) => {
|
||||
coverImg.onload = resolve2;
|
||||
coverImg.src = coverImageUrl;
|
||||
});
|
||||
ctx.drawImage(coverImg, 0, 0, canvas.width, canvas.height);
|
||||
const playIcon = canvas.createImage();
|
||||
await new Promise((resolve2) => {
|
||||
playIcon.onload = resolve2;
|
||||
playIcon.src = uni_modules_svEditor_components_common_config.config.video_playicon;
|
||||
});
|
||||
const playButtonSize = canvas.width * 0.15;
|
||||
const playButtonX = (canvas.width - playButtonSize) / 2;
|
||||
const playButtonY = (canvas.height - playButtonSize) / 2;
|
||||
const iconAspectRatio = playIcon.width / playIcon.height;
|
||||
const iconWidth = playButtonSize;
|
||||
const iconHeight = iconWidth / iconAspectRatio;
|
||||
ctx.drawImage(playIcon, playButtonX, playButtonY, iconWidth, iconHeight);
|
||||
common_vendor.index.canvasToTempFilePath({
|
||||
canvas,
|
||||
destWidth: canvas.width,
|
||||
destHeight: canvas.height,
|
||||
fileType: "png",
|
||||
success: (res) => {
|
||||
resolve(res.tempFilePath);
|
||||
},
|
||||
fail: (err) => {
|
||||
reject(new Error("Failed to convert canvas to image."));
|
||||
}
|
||||
});
|
||||
} catch (error) {
|
||||
reject(error);
|
||||
}
|
||||
});
|
||||
}
|
||||
const wxplugin = {
|
||||
wxCreateCoverThumbnail,
|
||||
wxCreateVideoThumbnail
|
||||
};
|
||||
exports.wxplugin = wxplugin;
|
||||
//# sourceMappingURL=../../../../../.sourcemap/mp-weixin/uni_modules/sv-editor/components/plugins/sv-editor-wxplugin.js.map
|
||||
Vendored
-49
@@ -1,49 +0,0 @@
|
||||
"use strict";
|
||||
const common_vendor = require("../../../../common/vendor.js");
|
||||
const block0 = {};
|
||||
const _sfc_main = {
|
||||
props: {
|
||||
eid: {
|
||||
type: String,
|
||||
default: ""
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
inputmode: "",
|
||||
// none | remove
|
||||
focusFlag: 0,
|
||||
// 主动聚焦标志
|
||||
backspaceFlag: 0
|
||||
// 主动删除标志
|
||||
};
|
||||
},
|
||||
methods: {
|
||||
changeInputMode(mode) {
|
||||
this.inputmode = mode;
|
||||
},
|
||||
focus() {
|
||||
this.focusFlag++;
|
||||
},
|
||||
backspace() {
|
||||
this.backspaceFlag++;
|
||||
}
|
||||
}
|
||||
};
|
||||
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
||||
return {
|
||||
a: $props.eid,
|
||||
b: _ctx.quillEditor.watchEID,
|
||||
c: $data.inputmode,
|
||||
d: _ctx.quillEditor.watchInputMode,
|
||||
e: $data.focusFlag,
|
||||
f: _ctx.quillEditor.watchFocus,
|
||||
g: $data.backspaceFlag,
|
||||
h: _ctx.quillEditor.watchBackSpace
|
||||
};
|
||||
}
|
||||
if (typeof block0 === "function")
|
||||
block0(_sfc_main);
|
||||
const Component = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render]]);
|
||||
wx.createComponent(Component);
|
||||
//# sourceMappingURL=../../../../../.sourcemap/mp-weixin/uni_modules/sv-editor/components/sv-editor/sv-editor-render.js.map
|
||||
Vendored
-4
@@ -1,4 +0,0 @@
|
||||
{
|
||||
"component": true,
|
||||
"usingComponents": {}
|
||||
}
|
||||
Vendored
-1
@@ -1 +0,0 @@
|
||||
<text eid="{{a}}" change:eid="{{b}}" mode="{{c}}" change:mode="{{d}}" focus="{{e}}" change:focus="{{f}}" backspace="{{g}}" change:backspace="{{h}}"></text>
|
||||
Vendored
-228
@@ -1,228 +0,0 @@
|
||||
"use strict";
|
||||
const common_vendor = require("../../../../common/vendor.js");
|
||||
const uni_modules_svEditor_components_common_store = require("../common/store.js");
|
||||
const uni_modules_svEditor_components_common_utils = require("../common/utils.js");
|
||||
const uni_modules_svEditor_components_common_parse = require("../common/parse.js");
|
||||
const uni_modules_svEditor_components_plugins_svEditorWxplugin = require("../plugins/sv-editor-wxplugin.js");
|
||||
const SvEditorRender = () => "./sv-editor-render.js";
|
||||
const SvEditorPlugin = () => "../plugins/sv-editor-plugin.js";
|
||||
const _sfc_main = {
|
||||
// 微信小程序特殊配置
|
||||
options: {
|
||||
addGlobalClass: true,
|
||||
virtualHost: true,
|
||||
styleIsolation: "shared"
|
||||
},
|
||||
components: {
|
||||
SvEditorRender,
|
||||
SvEditorPlugin
|
||||
},
|
||||
props: {
|
||||
// 编辑器id可传入,以便循环组件使用,防止id重复
|
||||
eid: {
|
||||
type: String,
|
||||
default: "sv-editor"
|
||||
// 唯一,禁止重复
|
||||
},
|
||||
placeholder: {
|
||||
type: String,
|
||||
default: "写点什么吧 ~"
|
||||
},
|
||||
// 是否只读
|
||||
readOnly: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
// 最大字数限制,<=0时表示不限
|
||||
maxlength: {
|
||||
type: Number,
|
||||
default: -1
|
||||
},
|
||||
// 是否关闭最大字数显示
|
||||
hideMax: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
// 粘贴模式,可选 text 纯文本(默认) | origin 尽可能保持原格式
|
||||
pasteMode: {
|
||||
type: String,
|
||||
default: "text"
|
||||
}
|
||||
},
|
||||
emits: ["ready", "input", "statuschange", "focus", "blur", "overmax", "epaste"],
|
||||
data() {
|
||||
return {
|
||||
textlength: 0,
|
||||
// 当前字数统计
|
||||
startID: ""
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
editorEID: {
|
||||
set(newVal) {
|
||||
uni_modules_svEditor_components_common_store.options.actions.setEID(newVal);
|
||||
},
|
||||
get() {
|
||||
return uni_modules_svEditor_components_common_store.options.actions.getEID();
|
||||
}
|
||||
},
|
||||
editorCtx: {
|
||||
set(newVal) {
|
||||
uni_modules_svEditor_components_common_store.options.actions.setEditor(newVal.eid, newVal.ctx);
|
||||
},
|
||||
get() {
|
||||
let instance = uni_modules_svEditor_components_common_store.options.actions.getEditor(this.eid);
|
||||
return instance;
|
||||
}
|
||||
},
|
||||
isReadOnly: {
|
||||
set(newVal) {
|
||||
uni_modules_svEditor_components_common_store.options.actions.setReadOnly(newVal);
|
||||
},
|
||||
get() {
|
||||
return uni_modules_svEditor_components_common_store.options.actions.getReadOnly();
|
||||
}
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
readOnly(newVal) {
|
||||
this.isReadOnly = newVal;
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
if (!uni_modules_svEditor_components_common_store.options.state.firstInstanceFlag) {
|
||||
this.editorEID = this.eid;
|
||||
uni_modules_svEditor_components_common_store.options.state.firstInstanceFlag = this.eid;
|
||||
uni_modules_svEditor_components_common_utils.copyrightPrint();
|
||||
}
|
||||
},
|
||||
destroyed() {
|
||||
uni_modules_svEditor_components_common_store.options.actions.destroy();
|
||||
},
|
||||
unmounted() {
|
||||
uni_modules_svEditor_components_common_store.options.actions.destroy();
|
||||
},
|
||||
methods: {
|
||||
onEditorReady() {
|
||||
this.$nextTick(() => {
|
||||
common_vendor.index.createSelectorQuery().in(this).select("#" + this.eid).context((res) => {
|
||||
this.editorCtx = { eid: this.eid, ctx: res.context };
|
||||
this.bindMethods();
|
||||
this.$emit("ready", this.editorCtx);
|
||||
}).exec();
|
||||
});
|
||||
},
|
||||
/**
|
||||
* 挂载实例api
|
||||
*/
|
||||
bindMethods() {
|
||||
var _a;
|
||||
this.editorCtx.createCoverThumbnail = (_a = uni_modules_svEditor_components_plugins_svEditorWxplugin.wxplugin) == null ? void 0 : _a.wxCreateCoverThumbnail;
|
||||
this.editorCtx.changeInput = () => {
|
||||
this.editorCtx.getContents({
|
||||
success: (res) => {
|
||||
this.$emit("input", { ctx: this.editorCtx, html: res.html, text: res.text });
|
||||
}
|
||||
});
|
||||
};
|
||||
this.editorCtx.scrollView = () => {
|
||||
this.editorCtx.scrollIntoView();
|
||||
};
|
||||
this.editorCtx.getLastContent = async () => {
|
||||
return new Promise((resolve) => {
|
||||
this.editorCtx.getContents({
|
||||
success: (res) => {
|
||||
resolve(res);
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
this.editorCtx.initHtml = async (html, customCallback) => {
|
||||
let transHtml = await uni_modules_svEditor_components_common_parse.replaceVideoWithImageRender(html, customCallback);
|
||||
setTimeout(() => {
|
||||
this.editorCtx.setContents({
|
||||
html: transHtml,
|
||||
success: () => {
|
||||
this.editorCtx.changeInput();
|
||||
this.editorCtx.blur();
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
this.editorCtx.exportHtml = (html) => {
|
||||
return uni_modules_svEditor_components_common_parse.parseHtmlWithVideo(html);
|
||||
};
|
||||
},
|
||||
onEditorInput(e) {
|
||||
if (Object.keys(e.detail).length <= 0)
|
||||
return;
|
||||
const { html, text } = e.detail;
|
||||
if (text.indexOf(uni_modules_svEditor_components_common_utils.linkFlag) !== -1)
|
||||
return;
|
||||
const maxlength = parseInt(this.maxlength);
|
||||
const textStr = text.replace(/[ \t\r\n]/g, "");
|
||||
this.textlength = textStr.length;
|
||||
if (this.textlength >= maxlength && maxlength > 0) {
|
||||
this.textlength = maxlength;
|
||||
if (!this.lockHtmlFlag) {
|
||||
this.lockHtml = html;
|
||||
this.lockHtmlFlag = true;
|
||||
this.$emit("input", { ctx: this.editorCtx, html, text });
|
||||
} else {
|
||||
this.$emit("overmax", { ctx: this.editorCtx });
|
||||
}
|
||||
this.editorCtx.setContents({ html: this.lockHtml });
|
||||
} else {
|
||||
this.$emit("input", { ctx: this.editorCtx, html, text });
|
||||
this.lockHtmlFlag = false;
|
||||
}
|
||||
},
|
||||
/**
|
||||
* 样式格式改变时触发
|
||||
* 注意:微信小程序端在多编辑器实例下切换编辑器后可能不会及时触发onStatusChange
|
||||
*/
|
||||
onStatusChange(e) {
|
||||
uni_modules_svEditor_components_common_store.options.actions.setFormats(e.detail);
|
||||
this.$emit("statuschange", { ...e, ctx: this.editorCtx });
|
||||
common_vendor.index.$emit("E_EDITOR_STATUSCHANGE", { ...e, ctx: this.editorCtx });
|
||||
},
|
||||
onEditorFocus(e) {
|
||||
this.editorEID = this.eid;
|
||||
this.$emit("focus", { ...e, ctx: this.editorCtx });
|
||||
},
|
||||
onEditorBlur(e) {
|
||||
this.$emit("blur", { ...e, ctx: this.editorCtx });
|
||||
},
|
||||
ePaste(e) {
|
||||
this.$emit("epaste", { ...e, ctx: this.editorCtx });
|
||||
common_vendor.index.$emit("E_EDITOR_PASTE", { ...e, ctx: this.editorCtx });
|
||||
},
|
||||
/**
|
||||
* 微信小程序官方editor的长按事件有bug,需要重写覆盖,不需做任何逻辑,可见下面小程序社区问题链接
|
||||
* @tutorial https://developers.weixin.qq.com/community/develop/doc/000c04b3e1c1006f660065e4f61000
|
||||
*/
|
||||
eLongpress() {
|
||||
}
|
||||
}
|
||||
};
|
||||
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
||||
return common_vendor.e({
|
||||
a: $props.eid,
|
||||
b: $props.placeholder,
|
||||
c: $options.isReadOnly,
|
||||
d: common_vendor.o((...args) => $options.onStatusChange && $options.onStatusChange(...args)),
|
||||
e: common_vendor.o((...args) => $options.onEditorReady && $options.onEditorReady(...args)),
|
||||
f: common_vendor.o((...args) => $options.onEditorInput && $options.onEditorInput(...args)),
|
||||
g: common_vendor.o((...args) => $options.onEditorFocus && $options.onEditorFocus(...args)),
|
||||
h: common_vendor.o((...args) => $options.onEditorBlur && $options.onEditorBlur(...args)),
|
||||
i: $props.maxlength > 0 && !$props.hideMax
|
||||
}, $props.maxlength > 0 && !$props.hideMax ? {
|
||||
j: common_vendor.t($data.textlength),
|
||||
k: common_vendor.t($props.maxlength)
|
||||
} : {}, {
|
||||
l: common_vendor.o((...args) => $options.eLongpress && $options.eLongpress(...args))
|
||||
});
|
||||
}
|
||||
const Component = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render]]);
|
||||
wx.createComponent(Component);
|
||||
//# sourceMappingURL=../../../../../.sourcemap/mp-weixin/uni_modules/sv-editor/components/sv-editor/sv-editor.js.map
|
||||
-4
@@ -1,4 +0,0 @@
|
||||
{
|
||||
"component": true,
|
||||
"usingComponents": {}
|
||||
}
|
||||
-1
@@ -1 +0,0 @@
|
||||
<view class="sv-editor-wrapper" bindlongpress="{{l}}"><slot name="header"></slot><block wx:if="{{r0}}"><editor id="{{a}}" class="sv-editor-container" show-img-size show-img-toolbar show-img-resize placeholder="{{b}}" read-only="{{c}}" bindstatuschange="{{d}}" bindready="{{e}}" bindinput="{{f}}" bindfocus="{{g}}" bindblur="{{h}}"></editor></block><view wx:if="{{i}}" class="maxlength-tip">{{j}}/{{k}}</view><slot name="footer"></slot></view>
|
||||
-65
@@ -1,65 +0,0 @@
|
||||
/**
|
||||
* 这里是uni-app内置的常用样式变量
|
||||
*
|
||||
* uni-app 官方扩展插件及插件市场(https://ext.dcloud.net.cn)上很多三方插件均使用了这些样式变量
|
||||
* 如果你是插件开发者,建议你使用scss预处理,并在插件代码中直接使用这些变量(无需 import 这个文件),方便用户通过搭积木的方式开发整体风格一致的App
|
||||
*
|
||||
*/
|
||||
/**
|
||||
* 如果你是App开发者(插件使用者),你可以通过修改这些变量来定制自己的插件主题,实现自定义主题功能
|
||||
*
|
||||
* 如果你的项目同样使用了scss预处理,你也可以直接在你的 scss 代码中使用如下变量,同时无需 import 这个文件
|
||||
*/
|
||||
/* 颜色变量 */
|
||||
/* 行为相关颜色 */
|
||||
/* 文字基本颜色 */
|
||||
/* 背景颜色 */
|
||||
/* 边框颜色 */
|
||||
/* 尺寸变量 */
|
||||
/* 文字尺寸 */
|
||||
/* 图片尺寸 */
|
||||
/* Border Radius */
|
||||
/* 水平间距 */
|
||||
/* 垂直间距 */
|
||||
/* 透明度 */
|
||||
/* 文章场景相关 */
|
||||
.sv-editor-wrapper {
|
||||
--maxlength-text-color: #666666;
|
||||
position: relative;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
.sv-editor-wrapper .sv-editor-container {
|
||||
flex: 1;
|
||||
}
|
||||
.sv-editor-wrapper .maxlength-tip {
|
||||
position: absolute;
|
||||
bottom: 0;
|
||||
right: 0;
|
||||
font-size: 24rpx;
|
||||
color: var(--maxlength-text-color);
|
||||
opacity: 0.6;
|
||||
}
|
||||
.sv-editor-container .ql-blank::before {
|
||||
font-style: normal;
|
||||
color: #cccccc;
|
||||
}
|
||||
.ql-container {
|
||||
min-height: unset;
|
||||
}
|
||||
.ql-container .ql-image-overlay {
|
||||
pointer-events: none;
|
||||
}
|
||||
.ql-container .ql-image-overlay .ql-image-size {
|
||||
right: 28px !important;
|
||||
}
|
||||
.ql-container .ql-image-overlay .ql-image-toolbar {
|
||||
pointer-events: auto;
|
||||
}
|
||||
.ql-container .ql-image-overlay .ql-image-handle {
|
||||
width: 30px;
|
||||
height: 30px;
|
||||
pointer-events: auto;
|
||||
}
|
||||
Reference in New Issue
Block a user