aden-editor-vue 0.1.7 → 0.1.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/index.cjs +43 -9
- package/dist/index.cjs.map +2 -2
- package/dist/index.js +43 -9
- package/dist/index.js.map +2 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -41,7 +41,7 @@ const content = ref('<p>欢迎使用 AdenEditor</p>');
|
|
|
41
41
|
|
|
42
42
|
默认工具栏和样式会自动加载。未传 `options` 时,文字编辑、列表、引用、表格等内置功能仍可直接使用;无需单独导入 CSS,也无需自己处理创建、挂载和卸载。
|
|
43
43
|
|
|
44
|
-
|
|
44
|
+
带 HTML 格式的粘贴会以可编辑的富文本片段导入,尽量保留段落、表格、内联格式和可安全转换的样式;Word 内容不是嵌入的 Word 文档。若剪贴板只提供本机临时图片路径、没有提供图片文件数据,浏览器无法读取该路径,编辑器会提示重新复制图片或配置 `uploadImage`。
|
|
45
45
|
|
|
46
46
|
## 保存内容
|
|
47
47
|
|
package/dist/index.cjs
CHANGED
|
@@ -5974,10 +5974,18 @@ var STYLE_PROPERTIES = /* @__PURE__ */ new Set([
|
|
|
5974
5974
|
"padding-top",
|
|
5975
5975
|
"page-break-after",
|
|
5976
5976
|
"page-break-before",
|
|
5977
|
+
"page-break-inside",
|
|
5978
|
+
"orphans",
|
|
5979
|
+
"widows",
|
|
5980
|
+
"letter-spacing",
|
|
5981
|
+
"word-spacing",
|
|
5982
|
+
"word-break",
|
|
5983
|
+
"overflow-wrap",
|
|
5977
5984
|
"text-align",
|
|
5978
5985
|
"text-decoration",
|
|
5979
5986
|
"text-indent",
|
|
5980
5987
|
"text-transform",
|
|
5988
|
+
"text-justify",
|
|
5981
5989
|
"vertical-align",
|
|
5982
5990
|
"white-space",
|
|
5983
5991
|
"width"
|
|
@@ -6066,7 +6074,7 @@ function inlineOfficeStyles(root) {
|
|
|
6066
6074
|
if (!declarations) continue;
|
|
6067
6075
|
for (const rawSelector of rule[1].split(",")) {
|
|
6068
6076
|
const selector = rawSelector.trim();
|
|
6069
|
-
if (!/^(?:[a-z][\w-]*)?(?:\.[\w-]+)
|
|
6077
|
+
if (!/^(?:[a-z][\w-]*)?(?:\.[\w-]+)*(?:\s+(?:[a-z][\w-]*)?(?:\.[\w-]+)*)*$/i.test(selector)) continue;
|
|
6070
6078
|
try {
|
|
6071
6079
|
for (const element of Array.from(root.querySelectorAll(selector))) {
|
|
6072
6080
|
const current = (_b = element.getAttribute("style")) != null ? _b : "";
|
|
@@ -6086,7 +6094,7 @@ function sanitizeInlineStyle(raw) {
|
|
|
6086
6094
|
if (separator < 1) continue;
|
|
6087
6095
|
const property = declaration.slice(0, separator).trim().toLowerCase();
|
|
6088
6096
|
const value = sanitizeStyleValue(declaration.slice(separator + 1));
|
|
6089
|
-
if (!STYLE_PROPERTIES.has(property) || !value || /url\s*\(|expression\s*\(|javascript:|[{}<>]/i.test(value)) continue;
|
|
6097
|
+
if (!(STYLE_PROPERTIES.has(property) || /^mso-[a-z0-9-]+$/i.test(property)) || !value || /url\s*\(|expression\s*\(|javascript:|[{}<>]/i.test(value)) continue;
|
|
6090
6098
|
if (property === "display" && !/^(inline|inline-block|block|table|table-row|table-cell|table-caption|table-row-group|table-header-group|table-footer-group|list-item)$/i.test(value)) continue;
|
|
6091
6099
|
declarations.push(`${property}:${value}`);
|
|
6092
6100
|
}
|
|
@@ -9648,7 +9656,7 @@ var WebAdapter = class {
|
|
|
9648
9656
|
}
|
|
9649
9657
|
};
|
|
9650
9658
|
this.handlePaste = (e) => {
|
|
9651
|
-
var _a2, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
|
|
9659
|
+
var _a2, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
|
|
9652
9660
|
if (this.opts.readonly) return;
|
|
9653
9661
|
const html = (_b = (_a2 = e.clipboardData) == null ? void 0 : _a2.getData("text/html")) != null ? _b : "";
|
|
9654
9662
|
const text = (_d = (_c = e.clipboardData) == null ? void 0 : _c.getData("text/plain")) != null ? _d : "";
|
|
@@ -9693,9 +9701,17 @@ var WebAdapter = class {
|
|
|
9693
9701
|
knownFiles.add(key);
|
|
9694
9702
|
images.push(file);
|
|
9695
9703
|
}
|
|
9696
|
-
|
|
9704
|
+
const advertisesRichClipboard = Array.from((_l = clipboard == null ? void 0 : clipboard.types) != null ? _l : []).some(
|
|
9705
|
+
(type) => /text\/html|text\/rtf|application\/rtf/i.test(type)
|
|
9706
|
+
);
|
|
9707
|
+
if (!pasteHtml2 && advertisesRichClipboard) {
|
|
9708
|
+
e.preventDefault();
|
|
9709
|
+
void this.pasteRichClipboardFallback(text, images);
|
|
9710
|
+
return;
|
|
9711
|
+
}
|
|
9712
|
+
if (pasteHtml2) {
|
|
9697
9713
|
e.preventDefault();
|
|
9698
|
-
void this.
|
|
9714
|
+
void this.pasteRichHtml(pasteHtml2, images);
|
|
9699
9715
|
return;
|
|
9700
9716
|
}
|
|
9701
9717
|
if (images.length) {
|
|
@@ -10213,7 +10229,7 @@ var WebAdapter = class {
|
|
|
10213
10229
|
cur = cur.nextElementSibling;
|
|
10214
10230
|
}
|
|
10215
10231
|
}
|
|
10216
|
-
async
|
|
10232
|
+
async pasteRichHtml(html, files) {
|
|
10217
10233
|
const template = document.createElement("template");
|
|
10218
10234
|
let safe = sanitizeWordHtml(html);
|
|
10219
10235
|
if (safe.missingImages && !files.length) files = await this.readClipboardImageFiles();
|
|
@@ -10243,6 +10259,27 @@ var WebAdapter = class {
|
|
|
10243
10259
|
safe = sanitizeWordHtml(template.innerHTML);
|
|
10244
10260
|
this.runCommand((cmd) => cmd.pasteHtmlFragment(this.editor, safe.html, safe.text));
|
|
10245
10261
|
}
|
|
10262
|
+
async pasteRichClipboardFallback(plainText, files) {
|
|
10263
|
+
var _a;
|
|
10264
|
+
try {
|
|
10265
|
+
const read = (_a = navigator.clipboard) == null ? void 0 : _a.read;
|
|
10266
|
+
if (typeof read === "function") {
|
|
10267
|
+
const items = await read.call(navigator.clipboard);
|
|
10268
|
+
for (const item of items) {
|
|
10269
|
+
if (!item.types.includes("text/html")) continue;
|
|
10270
|
+
const html = await (await item.getType("text/html")).text();
|
|
10271
|
+
if (html) {
|
|
10272
|
+
await this.pasteRichHtml(html, files);
|
|
10273
|
+
return;
|
|
10274
|
+
}
|
|
10275
|
+
}
|
|
10276
|
+
}
|
|
10277
|
+
} catch {
|
|
10278
|
+
}
|
|
10279
|
+
showToast("\u672A\u80FD\u8BFB\u53D6 Word \u7684\u683C\u5F0F\u5316\u5185\u5BB9\uFF0C\u5F53\u524D\u526A\u8D34\u677F\u53EA\u63D0\u4F9B\u7EAF\u6587\u672C\uFF0C\u56E0\u6B64\u65E0\u6CD5\u4FDD\u7559\u539F\u6392\u7248\u3002\u8BF7\u5728 Word \u4E2D\u91CD\u65B0\u590D\u5236\u540E\u7C98\u8D34\uFF0C\u6216\u68C0\u67E5\u6D4F\u89C8\u5668\u526A\u8D34\u677F\u6743\u9650\u3002", 7e3);
|
|
10280
|
+
if (plainText) this.runCommand((cmd) => cmd.pastePlainText(this.editor, plainText));
|
|
10281
|
+
for (const file of files) void this.imageCtrl.insertFile(file);
|
|
10282
|
+
}
|
|
10246
10283
|
async readClipboardImageFiles() {
|
|
10247
10284
|
var _a, _b;
|
|
10248
10285
|
try {
|
|
@@ -10792,9 +10829,6 @@ var WebAdapter = class {
|
|
|
10792
10829
|
function countNonWhitespace(text) {
|
|
10793
10830
|
return text.replace(/\s/g, "").length;
|
|
10794
10831
|
}
|
|
10795
|
-
function shouldPreserveRichHtmlPaste(html) {
|
|
10796
|
-
return /<(?:table|img|style)\b|\bstyle\s*=|\bclass\s*=|mso-[\w-]+|Microsoft Word|urn:schemas-microsoft-com|w:worddocument|v:(?:shape|imagedata)|StartFragment/i.test(html);
|
|
10797
|
-
}
|
|
10798
10832
|
function truncateTextAtLimit(text, remaining) {
|
|
10799
10833
|
let used = 0;
|
|
10800
10834
|
let result = "";
|