This commit is contained in:
zoujiandong
2025-08-03 16:29:54 +08:00
parent 43abd1f3d6
commit 6e320c3944
74 changed files with 1954 additions and 974 deletions
File diff suppressed because one or more lines are too long
@@ -1,5 +1,5 @@
"use strict";
const uni_modules_svEditor_components_common_config = require("./config.js");
const common_vendor = require("../../../../common/vendor.js");
function parseHtmlWithVideo(richText) {
const imgRegex = /<img\s+([^>]+)>/gi;
const customUrlRegex = /\bdata-custom="[^"]*url=([^&"]+)/i;
@@ -15,35 +15,44 @@ function parseHtmlWithVideo(richText) {
});
}
async function replaceVideoWithImageRender(richText, customCallback) {
common_vendor.index.__f__("log", "at uni_modules/sv-editor/components/common/parse.js:52", 1);
const videoRegex = /<video\s+([^>]+)>(.*?)<\/video>/gi;
common_vendor.index.__f__("log", "at uni_modules/sv-editor/components/common/parse.js:55", 2);
const matches = [];
let match;
while ((match = videoRegex.exec(richText)) !== null) {
matches.push(match);
}
common_vendor.index.__f__("log", "at uni_modules/sv-editor/components/common/parse.js:62", 3);
const replacements = await Promise.all(
matches.map(async (match2) => {
common_vendor.index.__f__("log", "at uni_modules/sv-editor/components/common/parse.js:67", 5);
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];
matchSource[1];
}
common_vendor.index.__f__("log", "at uni_modules/sv-editor/components/common/parse.js:80", "5-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}" />`;
common_vendor.index.__f__("log", "at uni_modules/sv-editor/components/common/parse.js:83", "5-2");
common_vendor.index.__f__("log", "at uni_modules/sv-editor/components/common/parse.js:86", "5-3");
thumbnailRes = "https://caseplatform.oss-cn-beijing.aliyuncs.com/prod/static/shipinfengmian.jpg";
const filteredAttributes = attributes.split(/\s+/).filter((attr) => !attr.startsWith("controls")).join(" ").replace("src=", "").replace("").replaceAll('width="100%"', "").replaceAll('"', "").replace(/\s+/g, "");
common_vendor.index.__f__("log", "at uni_modules/sv-editor/components/common/parse.js:93", "5-4");
const imgTag = `<img src="${thumbnailRes}" data-custom="url=${filteredAttributes}">`;
common_vendor.index.__f__("log", "at uni_modules/sv-editor/components/common/parse.js:96", 6);
return { fullMatch, imgTag };
})
);
common_vendor.index.__f__("log", "at uni_modules/sv-editor/components/common/parse.js:99", 7);
let result = richText;
for (const { fullMatch, imgTag } of replacements) {
common_vendor.index.__f__("log", "at uni_modules/sv-editor/components/common/parse.js:103", 8);
result = result.replace(fullMatch, imgTag);
}
common_vendor.index.__f__("log", "at uni_modules/sv-editor/components/common/parse.js:106", "打印结果2");
common_vendor.index.__f__("log", "at uni_modules/sv-editor/components/common/parse.js:107", result);
return result;
}
exports.parseHtmlWithVideo = parseHtmlWithVideo;
@@ -138,13 +138,25 @@ const _sfc_main = {
});
};
this.editorCtx.initHtml = async (html, customCallback) => {
let transHtml = await uni_modules_svEditor_components_common_parse.replaceVideoWithImageRender(html, customCallback);
common_vendor.index.__f__("log", "at uni_modules/sv-editor/components/sv-editor/sv-editor.vue:310", "打印html");
common_vendor.index.__f__("log", "at uni_modules/sv-editor/components/sv-editor/sv-editor.vue:311", html);
let transHtml = await uni_modules_svEditor_components_common_parse.replaceVideoWithImageRender(html);
common_vendor.index.__f__("log", "at uni_modules/sv-editor/components/sv-editor/sv-editor.vue:313", "transHtml");
common_vendor.index.__f__("log", "at uni_modules/sv-editor/components/sv-editor/sv-editor.vue:314", transHtml);
setTimeout(() => {
this.editorCtx.setContents({
html: transHtml,
success: () => {
common_vendor.index.__f__("log", "at uni_modules/sv-editor/components/sv-editor/sv-editor.vue:323", "成功了");
this.editorCtx.changeInput();
this.editorCtx.blur();
},
fail: (err) => {
common_vendor.index.__f__("log", "at uni_modules/sv-editor/components/sv-editor/sv-editor.vue:333", "失败了");
common_vendor.index.showToast({
title: err,
icon: "none"
});
}
});
});