vue-editify 0.1.24 → 0.1.26
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/examples/App.vue +1 -1
- package/lib/editify/editify.vue.d.ts +0 -9
- package/lib/editify.es.js +227 -231
- package/lib/editify.umd.js +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/style.css +1 -1
- package/package.json +2 -2
- package/src/editify/editify.less +19 -17
- package/src/editify/editify.vue +4 -4
- package/src/icon/iconfont.css +1 -1
- package/src/icon/iconfont.ttf +0 -0
- package/src/icon/iconfont.woff +0 -0
- package/src/index.ts +1 -1
- package/src/plugins/attachment/index.ts +42 -10
package/examples/App.vue
CHANGED
@@ -128,7 +128,6 @@ declare const _default: import('vue').DefineComponent<{
|
|
128
128
|
customFilePaste: ((file: File) => void | Promise<void>) | null;
|
129
129
|
customMerge: ((mergeElement: AlexElement, targetElement: AlexElement) => void | Promise<void>) | null;
|
130
130
|
customParseNode: ((el: AlexElement) => AlexElement) | null;
|
131
|
-
useClipboard: boolean;
|
132
131
|
history: {
|
133
132
|
records: {
|
134
133
|
stack: {
|
@@ -419,14 +418,6 @@ declare const _default: import('vue').DefineComponent<{
|
|
419
418
|
__innerSelectionChange: boolean;
|
420
419
|
__chineseInputTimer: any;
|
421
420
|
initRange: () => void;
|
422
|
-
copy: (isCut?: boolean | undefined) => Promise<{
|
423
|
-
text: string;
|
424
|
-
html: string;
|
425
|
-
} | undefined>;
|
426
|
-
cut: () => Promise<{
|
427
|
-
text: string;
|
428
|
-
html: string;
|
429
|
-
} | undefined>;
|
430
421
|
delete: () => void;
|
431
422
|
insertText: (data: string) => void;
|
432
423
|
insertParagraph: () => void;
|
package/lib/editify.es.js
CHANGED
@@ -1494,17 +1494,6 @@ const isContains = function(parentNode, childNode) {
|
|
1494
1494
|
}
|
1495
1495
|
return element$1.isContains(parentNode, childNode);
|
1496
1496
|
};
|
1497
|
-
const canUseClipboard = function() {
|
1498
|
-
if (!window.ClipboardItem) {
|
1499
|
-
console.warn("window.ClipboardItem must be obtained in a secure environment, such as localhost, 127.0.0.1, or https, so the editor's copy, paste, and cut functions cannot be used");
|
1500
|
-
return false;
|
1501
|
-
}
|
1502
|
-
if (!navigator.clipboard) {
|
1503
|
-
console.warn("navigator.clipboard must be obtained in a secure environment, such as localhost, 127.0.0.1, or https, so the editor's copy, paste, and cut functions cannot be used");
|
1504
|
-
return false;
|
1505
|
-
}
|
1506
|
-
return true;
|
1507
|
-
};
|
1508
1497
|
const initEditorNode = function(node) {
|
1509
1498
|
if (typeof node == "string" && node) {
|
1510
1499
|
node = document.body.querySelector(node);
|
@@ -2466,73 +2455,6 @@ const breakFormat = function(element2) {
|
|
2466
2455
|
}
|
2467
2456
|
}
|
2468
2457
|
};
|
2469
|
-
const mergeWithParentElement = function(element2) {
|
2470
|
-
const canMerge = (parent, child) => {
|
2471
|
-
if (child.isText() && parent.isInline()) {
|
2472
|
-
return parent.parsedom == AlexElement.TEXT_NODE;
|
2473
|
-
}
|
2474
|
-
if (parent.isInline() && child.isInline() || parent.isInblock() && child.isInblock()) {
|
2475
|
-
return parent.parsedom == child.parsedom;
|
2476
|
-
}
|
2477
|
-
return false;
|
2478
|
-
};
|
2479
|
-
const merge = (parent, child) => {
|
2480
|
-
if (child.isText()) {
|
2481
|
-
parent.type = "text";
|
2482
|
-
parent.parsedom = null;
|
2483
|
-
if (child.hasMarks()) {
|
2484
|
-
if (parent.hasMarks()) {
|
2485
|
-
Object.assign(parent.marks, cloneData$1(child.marks));
|
2486
|
-
} else {
|
2487
|
-
parent.marks = cloneData$1(child.marks);
|
2488
|
-
}
|
2489
|
-
}
|
2490
|
-
if (child.hasStyles()) {
|
2491
|
-
if (parent.hasStyles()) {
|
2492
|
-
Object.assign(parent.styles, cloneData$1(child.styles));
|
2493
|
-
} else {
|
2494
|
-
parent.styles = cloneData$1(child.styles);
|
2495
|
-
}
|
2496
|
-
}
|
2497
|
-
parent.textContent = child.textContent;
|
2498
|
-
parent.children = null;
|
2499
|
-
if (this.range && child.isContains(this.range.anchor.element)) {
|
2500
|
-
this.range.anchor.element = parent;
|
2501
|
-
}
|
2502
|
-
if (this.range && child.isContains(this.range.focus.element)) {
|
2503
|
-
this.range.focus.element = parent;
|
2504
|
-
}
|
2505
|
-
} else {
|
2506
|
-
if (child.hasMarks()) {
|
2507
|
-
if (parent.hasMarks()) {
|
2508
|
-
Object.assign(parent.marks, cloneData$1(child.marks));
|
2509
|
-
} else {
|
2510
|
-
parent.marks = cloneData$1(child.marks);
|
2511
|
-
}
|
2512
|
-
}
|
2513
|
-
if (child.hasStyles()) {
|
2514
|
-
if (parent.hasStyles()) {
|
2515
|
-
Object.assign(parent.styles, cloneData$1(child.styles));
|
2516
|
-
} else {
|
2517
|
-
parent.styles = cloneData$1(child.styles);
|
2518
|
-
}
|
2519
|
-
}
|
2520
|
-
if (child.hasChildren()) {
|
2521
|
-
parent.children = [...child.children];
|
2522
|
-
parent.children.forEach((item) => {
|
2523
|
-
item.parent = parent;
|
2524
|
-
});
|
2525
|
-
}
|
2526
|
-
mergeElement(parent);
|
2527
|
-
}
|
2528
|
-
};
|
2529
|
-
const mergeElement = (ele) => {
|
2530
|
-
if (ele.hasChildren() && ele.children.length == 1 && ele.children[0] && canMerge(ele, ele.children[0])) {
|
2531
|
-
merge(ele, ele.children[0]);
|
2532
|
-
}
|
2533
|
-
};
|
2534
|
-
mergeElement(element2);
|
2535
|
-
};
|
2536
2458
|
const mergeWithBrotherElement = function(element2) {
|
2537
2459
|
const canMerge = (pel, nel) => {
|
2538
2460
|
if (pel.isEmpty() || nel.isEmpty()) {
|
@@ -2631,6 +2553,78 @@ const mergeWithBrotherElement = function(element2) {
|
|
2631
2553
|
};
|
2632
2554
|
mergeElement(element2);
|
2633
2555
|
};
|
2556
|
+
const mergeWithParentElement = function(element2) {
|
2557
|
+
const canMerge = (parent, child) => {
|
2558
|
+
if (child.isText() && parent.isInline()) {
|
2559
|
+
return parent.parsedom == AlexElement.TEXT_NODE;
|
2560
|
+
}
|
2561
|
+
if (parent.isInline() && child.isInline() || parent.isInblock() && child.isInblock()) {
|
2562
|
+
return parent.parsedom == child.parsedom;
|
2563
|
+
}
|
2564
|
+
return false;
|
2565
|
+
};
|
2566
|
+
const merge = (parent, child) => {
|
2567
|
+
if (child.isText()) {
|
2568
|
+
parent.type = "text";
|
2569
|
+
parent.parsedom = null;
|
2570
|
+
if (child.hasMarks()) {
|
2571
|
+
if (parent.hasMarks()) {
|
2572
|
+
Object.assign(parent.marks, cloneData$1(child.marks));
|
2573
|
+
} else {
|
2574
|
+
parent.marks = cloneData$1(child.marks);
|
2575
|
+
}
|
2576
|
+
}
|
2577
|
+
if (child.hasStyles()) {
|
2578
|
+
if (parent.hasStyles()) {
|
2579
|
+
Object.assign(parent.styles, cloneData$1(child.styles));
|
2580
|
+
} else {
|
2581
|
+
parent.styles = cloneData$1(child.styles);
|
2582
|
+
}
|
2583
|
+
}
|
2584
|
+
parent.textContent = child.textContent;
|
2585
|
+
parent.children = null;
|
2586
|
+
if (this.range && child.isContains(this.range.anchor.element)) {
|
2587
|
+
this.range.anchor.element = parent;
|
2588
|
+
}
|
2589
|
+
if (this.range && child.isContains(this.range.focus.element)) {
|
2590
|
+
this.range.focus.element = parent;
|
2591
|
+
}
|
2592
|
+
} else {
|
2593
|
+
if (child.hasMarks()) {
|
2594
|
+
if (parent.hasMarks()) {
|
2595
|
+
Object.assign(parent.marks, cloneData$1(child.marks));
|
2596
|
+
} else {
|
2597
|
+
parent.marks = cloneData$1(child.marks);
|
2598
|
+
}
|
2599
|
+
}
|
2600
|
+
if (child.hasStyles()) {
|
2601
|
+
if (parent.hasStyles()) {
|
2602
|
+
Object.assign(parent.styles, cloneData$1(child.styles));
|
2603
|
+
} else {
|
2604
|
+
parent.styles = cloneData$1(child.styles);
|
2605
|
+
}
|
2606
|
+
}
|
2607
|
+
if (child.hasChildren()) {
|
2608
|
+
parent.children = [...child.children];
|
2609
|
+
parent.children.forEach((item) => {
|
2610
|
+
item.parent = parent;
|
2611
|
+
});
|
2612
|
+
}
|
2613
|
+
mergeElement(parent);
|
2614
|
+
}
|
2615
|
+
};
|
2616
|
+
const mergeElement = (ele) => {
|
2617
|
+
if (ele.hasChildren() && ele.children.length == 1 && ele.children[0] && canMerge(ele, ele.children[0])) {
|
2618
|
+
merge(ele, ele.children[0]);
|
2619
|
+
}
|
2620
|
+
};
|
2621
|
+
mergeElement(element2);
|
2622
|
+
};
|
2623
|
+
const mergeWithSpaceTextElement = function(element2) {
|
2624
|
+
if (element2.isText()) {
|
2625
|
+
element2.textContent = element2.textContent.replace(/[\uFEFF]+/, "\uFEFF");
|
2626
|
+
}
|
2627
|
+
};
|
2634
2628
|
const { Mac } = platform.os();
|
2635
2629
|
const isUndo = function(e) {
|
2636
2630
|
if (Mac) {
|
@@ -2644,6 +2638,98 @@ const isRedo = function(e) {
|
|
2644
2638
|
}
|
2645
2639
|
return e.key == "z" && e.ctrlKey && !e.metaKey && !e.shiftKey && !e.altKey;
|
2646
2640
|
};
|
2641
|
+
const setClipboardData = function(data2, result) {
|
2642
|
+
let html = "";
|
2643
|
+
let text = "";
|
2644
|
+
result.forEach((item) => {
|
2645
|
+
const newEl = item.element.clone();
|
2646
|
+
if (item.offset) {
|
2647
|
+
newEl.textContent = newEl.textContent.substring(item.offset[0], item.offset[1]);
|
2648
|
+
}
|
2649
|
+
newEl.__render();
|
2650
|
+
html += newEl.elm.outerHTML;
|
2651
|
+
text += newEl.elm.innerText;
|
2652
|
+
});
|
2653
|
+
data2.setData("text/plain", text);
|
2654
|
+
data2.setData("text/html", html);
|
2655
|
+
return { html, text };
|
2656
|
+
};
|
2657
|
+
const doPaste = async function(html, text, files) {
|
2658
|
+
if (html) {
|
2659
|
+
if (this.allowPasteHtml) {
|
2660
|
+
const elements = this.parseHtml(html).filter((el) => {
|
2661
|
+
return !el.isEmpty();
|
2662
|
+
});
|
2663
|
+
if (typeof this.customHtmlPaste == "function") {
|
2664
|
+
await this.customHtmlPaste.apply(this, [elements, html]);
|
2665
|
+
} else {
|
2666
|
+
for (let i = 0; i < elements.length; i++) {
|
2667
|
+
this.insertElement(elements[i], false);
|
2668
|
+
}
|
2669
|
+
this.emit("pasteHtml", elements, html);
|
2670
|
+
}
|
2671
|
+
} else if (text) {
|
2672
|
+
if (typeof this.customTextPaste == "function") {
|
2673
|
+
await this.customTextPaste.apply(this, [text]);
|
2674
|
+
} else {
|
2675
|
+
this.insertText(text);
|
2676
|
+
this.emit("pasteText", text);
|
2677
|
+
}
|
2678
|
+
}
|
2679
|
+
} else {
|
2680
|
+
if (text) {
|
2681
|
+
if (typeof this.customTextPaste == "function") {
|
2682
|
+
await this.customTextPaste.apply(this, [text]);
|
2683
|
+
} else {
|
2684
|
+
this.insertText(text);
|
2685
|
+
this.emit("pasteText", text);
|
2686
|
+
}
|
2687
|
+
} else {
|
2688
|
+
let length = files.length;
|
2689
|
+
for (let i = 0; i < length; i++) {
|
2690
|
+
if (files[i].type.startsWith("image/")) {
|
2691
|
+
if (typeof this.customImagePaste == "function") {
|
2692
|
+
await this.customImagePaste.apply(this, [files[i]]);
|
2693
|
+
} else {
|
2694
|
+
const url = await file$1.dataFileToBase64(files[i]);
|
2695
|
+
const image = new AlexElement(
|
2696
|
+
"closed",
|
2697
|
+
"img",
|
2698
|
+
{
|
2699
|
+
src: url
|
2700
|
+
},
|
2701
|
+
null,
|
2702
|
+
null
|
2703
|
+
);
|
2704
|
+
this.insertElement(image);
|
2705
|
+
this.emit("pasteImage", url);
|
2706
|
+
}
|
2707
|
+
} else if (files[i].type.startsWith("video/")) {
|
2708
|
+
if (typeof this.customVideoPaste == "function") {
|
2709
|
+
await this.customVideoPaste.apply(this, [files[i]]);
|
2710
|
+
} else {
|
2711
|
+
const url = await file$1.dataFileToBase64(files[i]);
|
2712
|
+
const video = new AlexElement(
|
2713
|
+
"closed",
|
2714
|
+
"video",
|
2715
|
+
{
|
2716
|
+
src: url
|
2717
|
+
},
|
2718
|
+
null,
|
2719
|
+
null
|
2720
|
+
);
|
2721
|
+
this.insertElement(video);
|
2722
|
+
this.emit("pasteVideo", url);
|
2723
|
+
}
|
2724
|
+
} else {
|
2725
|
+
if (typeof this.customFilePaste == "function") {
|
2726
|
+
await this.customFilePaste.apply(this, [files[i]]);
|
2727
|
+
}
|
2728
|
+
}
|
2729
|
+
}
|
2730
|
+
}
|
2731
|
+
}
|
2732
|
+
};
|
2647
2733
|
const checkStack = function() {
|
2648
2734
|
const elements = AlexElement.flatElements(this.stack).filter((el) => {
|
2649
2735
|
return !el.isEmpty() && !AlexElement.VOID_NODES.includes(el.parsedom);
|
@@ -2934,91 +3020,38 @@ const handleKeydown = function(e) {
|
|
2934
3020
|
};
|
2935
3021
|
const handleCopy = async function(e) {
|
2936
3022
|
e.preventDefault();
|
2937
|
-
|
3023
|
+
if (!this.range) {
|
3024
|
+
return;
|
3025
|
+
}
|
3026
|
+
if (!this.allowCopy) {
|
3027
|
+
return;
|
3028
|
+
}
|
3029
|
+
const event2 = e;
|
3030
|
+
const result = this.getElementsByRange().list;
|
3031
|
+
if (event2.clipboardData && result.length) {
|
3032
|
+
const { text, html } = setClipboardData.apply(this, [event2.clipboardData, result]);
|
3033
|
+
this.emit("copy", text, html);
|
3034
|
+
}
|
2938
3035
|
};
|
2939
3036
|
const handleCut = async function(e) {
|
2940
3037
|
e.preventDefault();
|
2941
|
-
|
2942
|
-
|
2943
|
-
this.formatElementStack();
|
2944
|
-
this.domRender();
|
2945
|
-
this.rangeRender();
|
3038
|
+
if (!this.range) {
|
3039
|
+
return;
|
2946
3040
|
}
|
2947
|
-
|
2948
|
-
|
2949
|
-
|
2950
|
-
|
2951
|
-
|
2952
|
-
|
2953
|
-
|
2954
|
-
|
2955
|
-
|
2956
|
-
|
2957
|
-
|
2958
|
-
|
2959
|
-
}
|
2960
|
-
this.emit("pasteHtml", elements, html);
|
2961
|
-
}
|
2962
|
-
} else if (text) {
|
2963
|
-
if (typeof this.customTextPaste == "function") {
|
2964
|
-
await this.customTextPaste.apply(this, [text]);
|
2965
|
-
} else {
|
2966
|
-
this.insertText(text);
|
2967
|
-
this.emit("pasteText", text);
|
2968
|
-
}
|
2969
|
-
}
|
2970
|
-
} else {
|
2971
|
-
if (text) {
|
2972
|
-
if (typeof this.customTextPaste == "function") {
|
2973
|
-
await this.customTextPaste.apply(this, [text]);
|
2974
|
-
} else {
|
2975
|
-
this.insertText(text);
|
2976
|
-
this.emit("pasteText", text);
|
2977
|
-
}
|
2978
|
-
} else {
|
2979
|
-
let length = files.length;
|
2980
|
-
for (let i = 0; i < length; i++) {
|
2981
|
-
if (files[i].type.startsWith("image/")) {
|
2982
|
-
if (typeof this.customImagePaste == "function") {
|
2983
|
-
await this.customImagePaste.apply(this, [files[i]]);
|
2984
|
-
} else {
|
2985
|
-
const url = await file$1.dataFileToBase64(files[i]);
|
2986
|
-
const image = new AlexElement(
|
2987
|
-
"closed",
|
2988
|
-
"img",
|
2989
|
-
{
|
2990
|
-
src: url
|
2991
|
-
},
|
2992
|
-
null,
|
2993
|
-
null
|
2994
|
-
);
|
2995
|
-
this.insertElement(image);
|
2996
|
-
this.emit("pasteImage", url);
|
2997
|
-
}
|
2998
|
-
} else if (files[i].type.startsWith("video/")) {
|
2999
|
-
if (typeof this.customVideoPaste == "function") {
|
3000
|
-
await this.customVideoPaste.apply(this, [files[i]]);
|
3001
|
-
} else {
|
3002
|
-
const url = await file$1.dataFileToBase64(files[i]);
|
3003
|
-
const video = new AlexElement(
|
3004
|
-
"closed",
|
3005
|
-
"video",
|
3006
|
-
{
|
3007
|
-
src: url
|
3008
|
-
},
|
3009
|
-
null,
|
3010
|
-
null
|
3011
|
-
);
|
3012
|
-
this.insertElement(video);
|
3013
|
-
this.emit("pasteVideo", url);
|
3014
|
-
}
|
3015
|
-
} else {
|
3016
|
-
if (typeof this.customFilePaste == "function") {
|
3017
|
-
await this.customFilePaste.apply(this, [files[i]]);
|
3018
|
-
}
|
3019
|
-
}
|
3020
|
-
}
|
3041
|
+
if (!this.allowCut) {
|
3042
|
+
return;
|
3043
|
+
}
|
3044
|
+
const event2 = e;
|
3045
|
+
const result = this.getElementsByRange().list;
|
3046
|
+
if (event2.clipboardData && result.length) {
|
3047
|
+
const { text, html } = setClipboardData.apply(this, [event2.clipboardData, result]);
|
3048
|
+
if (!this.disabled) {
|
3049
|
+
this.delete();
|
3050
|
+
this.formatElementStack();
|
3051
|
+
this.domRender();
|
3052
|
+
this.rangeRender();
|
3021
3053
|
}
|
3054
|
+
this.emit("cut", text, html);
|
3022
3055
|
}
|
3023
3056
|
};
|
3024
3057
|
const handlePaste = async function(e) {
|
@@ -3096,7 +3129,6 @@ class AlexEditor {
|
|
3096
3129
|
__publicField(this, "customFilePaste");
|
3097
3130
|
__publicField(this, "customMerge");
|
3098
3131
|
__publicField(this, "customParseNode");
|
3099
|
-
__publicField(this, "useClipboard", canUseClipboard());
|
3100
3132
|
__publicField(this, "history", new AlexHistory());
|
3101
3133
|
__publicField(this, "stack");
|
3102
3134
|
__publicField(this, "range", null);
|
@@ -3148,67 +3180,6 @@ class AlexEditor {
|
|
3148
3180
|
const focus = new AlexPoint(firstElement, 0);
|
3149
3181
|
this.range = new AlexRange(anchor, focus);
|
3150
3182
|
}
|
3151
|
-
/**
|
3152
|
-
* 根据光标执行复制操作
|
3153
|
-
* isCut表示是否在执行剪切操作,默认为false,这个参数仅在内部使用
|
3154
|
-
*/
|
3155
|
-
async copy(isCut = false) {
|
3156
|
-
if (!this.useClipboard) {
|
3157
|
-
return;
|
3158
|
-
}
|
3159
|
-
if (!this.range) {
|
3160
|
-
return;
|
3161
|
-
}
|
3162
|
-
if (!this.allowCopy) {
|
3163
|
-
return;
|
3164
|
-
}
|
3165
|
-
let result = this.getElementsByRange().list;
|
3166
|
-
if (result.length == 0) {
|
3167
|
-
return;
|
3168
|
-
}
|
3169
|
-
let html = "";
|
3170
|
-
let text = "";
|
3171
|
-
result.forEach((item) => {
|
3172
|
-
const newEl = item.element.clone();
|
3173
|
-
if (item.offset) {
|
3174
|
-
newEl.textContent = newEl.textContent.substring(item.offset[0], item.offset[1]);
|
3175
|
-
}
|
3176
|
-
newEl.__render();
|
3177
|
-
html += newEl.elm.outerHTML;
|
3178
|
-
text += newEl.elm.innerText;
|
3179
|
-
});
|
3180
|
-
const clipboardItem = new window.ClipboardItem({
|
3181
|
-
"text/html": new Blob([html], { type: "text/html" }),
|
3182
|
-
"text/plain": new Blob([text], { type: "text/plain" })
|
3183
|
-
});
|
3184
|
-
await navigator.clipboard.write([clipboardItem]);
|
3185
|
-
if (!isCut) {
|
3186
|
-
this.emit("copy", text, html);
|
3187
|
-
}
|
3188
|
-
return { text, html };
|
3189
|
-
}
|
3190
|
-
/**
|
3191
|
-
* 根据光标进行剪切操作
|
3192
|
-
*/
|
3193
|
-
async cut() {
|
3194
|
-
if (!this.useClipboard) {
|
3195
|
-
return;
|
3196
|
-
}
|
3197
|
-
if (!this.range) {
|
3198
|
-
return;
|
3199
|
-
}
|
3200
|
-
if (!this.allowCut) {
|
3201
|
-
return;
|
3202
|
-
}
|
3203
|
-
const result = await this.copy(true);
|
3204
|
-
if (result) {
|
3205
|
-
if (!this.disabled) {
|
3206
|
-
this.delete();
|
3207
|
-
}
|
3208
|
-
this.emit("cut", result.text, result.html);
|
3209
|
-
}
|
3210
|
-
return result;
|
3211
|
-
}
|
3212
3183
|
/**
|
3213
3184
|
* 根据光标进行删除操作
|
3214
3185
|
*/
|
@@ -3818,7 +3789,7 @@ class AlexEditor {
|
|
3818
3789
|
let renderRules = this.renderRules.filter((fn) => {
|
3819
3790
|
return typeof fn == "function";
|
3820
3791
|
});
|
3821
|
-
[handleNotStackBlock, handleInblockWithOther, handleInlineChildrenNotInblock, breakFormat, mergeWithParentElement, mergeWithBrotherElement, mergeWithParentElement, ...renderRules].forEach((fn) => {
|
3792
|
+
[handleNotStackBlock, handleInblockWithOther, handleInlineChildrenNotInblock, breakFormat, mergeWithParentElement, mergeWithBrotherElement, mergeWithParentElement, mergeWithSpaceTextElement, ...renderRules].forEach((fn) => {
|
3822
3793
|
format(this.stack, fn, true);
|
3823
3794
|
});
|
3824
3795
|
handleStackEmpty.apply(this);
|
@@ -25625,6 +25596,10 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
25625
25596
|
}
|
25626
25597
|
};
|
25627
25598
|
const handleDeleteComplete = () => {
|
25599
|
+
const uneditable = editor.value.range.anchor.element.getUneditableElement();
|
25600
|
+
if (uneditable) {
|
25601
|
+
uneditable.toEmpty();
|
25602
|
+
}
|
25628
25603
|
};
|
25629
25604
|
const handleAfterRender = () => {
|
25630
25605
|
setVideoHeight();
|
@@ -25817,7 +25792,7 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
25817
25792
|
};
|
25818
25793
|
}
|
25819
25794
|
});
|
25820
|
-
const Editify = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["__scopeId", "data-v-
|
25795
|
+
const Editify = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["__scopeId", "data-v-8737320e"]]);
|
25821
25796
|
const InsertAttachmentProps = {
|
25822
25797
|
//主题色
|
25823
25798
|
color: {
|
@@ -26066,8 +26041,6 @@ const attachment = (options) => {
|
|
26066
26041
|
options = {};
|
26067
26042
|
}
|
26068
26043
|
const plugin = (editifyInstance, color2, editTrans) => {
|
26069
|
-
const editor = editifyInstance.exposed.editor.value;
|
26070
|
-
const dataRangeCaches = editifyInstance.exposed.dataRangeCaches.value;
|
26071
26044
|
return {
|
26072
26045
|
//附件菜单项配置
|
26073
26046
|
menu: {
|
@@ -26080,7 +26053,7 @@ const attachment = (options) => {
|
|
26080
26053
|
title: options.title || editTrans("insertAttachment"),
|
26081
26054
|
leftBorder: options.leftBorder,
|
26082
26055
|
rightBorder: options.rightBorder,
|
26083
|
-
disabled: editor ? hasPreInRange(editor, dataRangeCaches) : false,
|
26056
|
+
disabled: editifyInstance.exposed.editor.value ? hasPreInRange(editifyInstance.exposed.editor.value, editifyInstance.exposed.dataRangeCaches.value) : false,
|
26084
26057
|
default: () => h(Icon, { value: "attachment" }),
|
26085
26058
|
layer: (_name, btnInstance) => h(InsertAttachment, {
|
26086
26059
|
color: color2,
|
@@ -26095,10 +26068,20 @@ const attachment = (options) => {
|
|
26095
26068
|
btnInstance.$refs.layerRef.setPosition();
|
26096
26069
|
},
|
26097
26070
|
onInsert: (url) => {
|
26098
|
-
const
|
26071
|
+
const marks = {
|
26072
|
+
"data-attachment": url,
|
26073
|
+
"data-attachment-name": editTrans("attachmentDownloadName"),
|
26074
|
+
contenteditable: "false"
|
26075
|
+
};
|
26076
|
+
const attachmentElement = new AlexElement("closed", "span", marks, null, null);
|
26077
|
+
const editor = editifyInstance.exposed.editor.value;
|
26099
26078
|
editor.insertElement(attachmentElement);
|
26100
|
-
|
26101
|
-
|
26079
|
+
const beforeText = AlexElement.getSpaceElement();
|
26080
|
+
const afterText = AlexElement.getSpaceElement();
|
26081
|
+
editor.addElementAfter(afterText, attachmentElement);
|
26082
|
+
editor.addElementBefore(beforeText, attachmentElement);
|
26083
|
+
editor.range.anchor.moveToStart(afterText);
|
26084
|
+
editor.range.focus.moveToStart(afterText);
|
26102
26085
|
editor.formatElementStack();
|
26103
26086
|
editor.domRender();
|
26104
26087
|
editor.rangeRender();
|
@@ -26110,6 +26093,7 @@ const attachment = (options) => {
|
|
26110
26093
|
},
|
26111
26094
|
//找到附件元素点击下载
|
26112
26095
|
updateView: () => {
|
26096
|
+
const editor = editifyInstance.exposed.editor.value;
|
26113
26097
|
AlexElement.flatElements(editor.stack).forEach((el) => {
|
26114
26098
|
if (el.parsedom == "span" && el.hasMarks() && el.marks["data-attachment"]) {
|
26115
26099
|
event.off(el.elm, "click");
|
@@ -26132,12 +26116,24 @@ const attachment = (options) => {
|
|
26132
26116
|
},
|
26133
26117
|
//span元素粘贴保留data-attachment
|
26134
26118
|
pasteKeepMarks: {
|
26135
|
-
"data-attachment": ["span"]
|
26119
|
+
"data-attachment": ["span"],
|
26120
|
+
"data-attachment-name": ["span"]
|
26136
26121
|
},
|
26137
|
-
|
26122
|
+
//自定义渲染规范
|
26138
26123
|
renderRule: (el) => {
|
26139
26124
|
if (el.type == "closed" && el.hasMarks() && el.marks["data-attachment"]) {
|
26140
26125
|
el.marks["title"] = editTrans("downloadAttachment");
|
26126
|
+
const editor = editifyInstance.exposed.editor.value;
|
26127
|
+
const previousElement = editor.getPreviousElement(el);
|
26128
|
+
const newTextElement = editor.getNextElement(el);
|
26129
|
+
if (!previousElement || !previousElement.isSpaceText()) {
|
26130
|
+
const spaceText = AlexElement.getSpaceElement();
|
26131
|
+
editor.addElementBefore(spaceText, el);
|
26132
|
+
}
|
26133
|
+
if (!newTextElement || !newTextElement.isSpaceText()) {
|
26134
|
+
const spaceText = AlexElement.getSpaceElement();
|
26135
|
+
editor.addElementAfter(spaceText, el);
|
26136
|
+
}
|
26141
26137
|
}
|
26142
26138
|
}
|
26143
26139
|
};
|
@@ -26147,7 +26143,7 @@ const attachment = (options) => {
|
|
26147
26143
|
const install = (app) => {
|
26148
26144
|
app.component(Editify.name, Editify);
|
26149
26145
|
};
|
26150
|
-
const version = "0.1.
|
26146
|
+
const version = "0.1.26";
|
26151
26147
|
export {
|
26152
26148
|
AlexElement,
|
26153
26149
|
Editify,
|