vue-editify 0.1.43 → 0.1.45
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 +57 -3
- package/lib/core/function.d.ts +83 -43
- package/lib/core/rule.d.ts +14 -2
- package/lib/editify/editify.vue.d.ts +1 -1
- package/lib/editify/props.d.ts +1 -1
- package/lib/editify.es.js +989 -230
- package/lib/editify.umd.js +1 -1
- package/lib/index.d.ts +3 -3
- package/lib/style.css +1 -1
- package/package.json +2 -2
- package/src/components/toolbar/toolbar.vue +539 -50
- package/src/core/function.ts +219 -43
- package/src/core/rule.ts +281 -42
- package/src/core/tool.ts +6 -6
- package/src/editify/editify.less +10 -0
- package/src/editify/editify.vue +144 -59
- package/src/editify/props.ts +1 -1
- package/src/icon/iconfont.css +16 -0
- package/src/icon/iconfont.ttf +0 -0
- package/src/icon/iconfont.woff +0 -0
- package/src/index.ts +3 -3
- package/src/locale/en_US.ts +4 -0
- package/src/locale/zh_CN.ts +4 -0
- package/vite.config.ts.timestamp-1715686169942-5a15122e86ee2.mjs +0 -48
package/lib/editify.es.js
CHANGED
@@ -1498,6 +1498,7 @@ const initEditorNode = function(node) {
|
|
1498
1498
|
if (typeof node == "string" && node) {
|
1499
1499
|
node = document.body.querySelector(node);
|
1500
1500
|
}
|
1501
|
+
node = node;
|
1501
1502
|
if (!element$1.isElement(node)) {
|
1502
1503
|
throw new Error("You must specify a dom container to initialize the editor");
|
1503
1504
|
}
|
@@ -1666,7 +1667,7 @@ const _AlexElement = class _AlexElement2 {
|
|
1666
1667
|
return this.isText() && !this.isEmpty() && isSpaceText(this.textContent);
|
1667
1668
|
}
|
1668
1669
|
/**
|
1669
|
-
*
|
1670
|
+
* 获取不可编辑的元素,如果是null,说明元素是可编辑的
|
1670
1671
|
*/
|
1671
1672
|
getUneditableElement() {
|
1672
1673
|
if (this.hasMarks() && this.marks["contenteditable"] == "false") {
|
@@ -2162,9 +2163,7 @@ class AlexHistory {
|
|
2162
2163
|
if (this.current < this.records.length - 1) {
|
2163
2164
|
this.records.length = this.current + 1;
|
2164
2165
|
}
|
2165
|
-
const newStack = stack.map((ele) =>
|
2166
|
-
return ele.__fullClone();
|
2167
|
-
});
|
2166
|
+
const newStack = stack.map((ele) => ele.__fullClone());
|
2168
2167
|
const newRange = this.__cloneRange(newStack, range);
|
2169
2168
|
this.records.push({
|
2170
2169
|
stack: newStack,
|
@@ -2189,9 +2188,7 @@ class AlexHistory {
|
|
2189
2188
|
current += 1;
|
2190
2189
|
}
|
2191
2190
|
const { stack, range } = this.records[current];
|
2192
|
-
const newStack = stack.map((ele) =>
|
2193
|
-
return ele.__fullClone();
|
2194
|
-
});
|
2191
|
+
const newStack = stack.map((ele) => ele.__fullClone());
|
2195
2192
|
const newRange = this.__cloneRange(newStack, range);
|
2196
2193
|
return {
|
2197
2194
|
current,
|
@@ -2789,17 +2786,17 @@ const setRecentlyPoint = function(point) {
|
|
2789
2786
|
const nextElement = this.getNextElementOfPoint(point);
|
2790
2787
|
const block = point.element.getBlock();
|
2791
2788
|
const inblock = point.element.getInblock();
|
2792
|
-
if (previousElement &&
|
2789
|
+
if (previousElement && inblock && inblock.isContains(previousElement)) {
|
2793
2790
|
point.moveToEnd(previousElement);
|
2794
|
-
} else if (nextElement &&
|
2791
|
+
} else if (nextElement && inblock && inblock.isContains(nextElement)) {
|
2795
2792
|
point.moveToStart(nextElement);
|
2796
|
-
} else if (previousElement &&
|
2793
|
+
} else if (previousElement && block.isContains(previousElement)) {
|
2797
2794
|
point.moveToEnd(previousElement);
|
2798
|
-
} else if (nextElement &&
|
2795
|
+
} else if (nextElement && block.isContains(nextElement)) {
|
2799
2796
|
point.moveToStart(nextElement);
|
2800
|
-
} else if (previousElement
|
2797
|
+
} else if (previousElement) {
|
2801
2798
|
point.moveToEnd(previousElement);
|
2802
|
-
} else if (nextElement
|
2799
|
+
} else if (nextElement) {
|
2803
2800
|
point.moveToStart(nextElement);
|
2804
2801
|
}
|
2805
2802
|
};
|
@@ -2983,24 +2980,25 @@ const handleSelectionChange = function() {
|
|
2983
2980
|
}
|
2984
2981
|
};
|
2985
2982
|
const handleBeforeInput = function(e) {
|
2983
|
+
const event2 = e;
|
2986
2984
|
if (this.disabled) {
|
2987
2985
|
return;
|
2988
2986
|
}
|
2989
|
-
if (
|
2987
|
+
if (event2.inputType == "deleteByCut" || event2.inputType == "insertFromPaste" || event2.inputType == "deleteByDrag" || event2.inputType == "insertFromDrop") {
|
2990
2988
|
return;
|
2991
2989
|
}
|
2992
|
-
|
2993
|
-
if (
|
2994
|
-
this.insertText(
|
2990
|
+
event2.preventDefault();
|
2991
|
+
if (event2.inputType == "insertText" && event2.data) {
|
2992
|
+
this.insertText(event2.data);
|
2995
2993
|
this.formatElementStack();
|
2996
2994
|
this.domRender();
|
2997
2995
|
this.rangeRender();
|
2998
|
-
} else if (
|
2996
|
+
} else if (event2.inputType == "insertParagraph" || event2.inputType == "insertLineBreak") {
|
2999
2997
|
this.insertParagraph();
|
3000
2998
|
this.formatElementStack();
|
3001
2999
|
this.domRender();
|
3002
3000
|
this.rangeRender();
|
3003
|
-
} else if (
|
3001
|
+
} else if (event2.inputType == "deleteContentBackward") {
|
3004
3002
|
this.delete();
|
3005
3003
|
this.formatElementStack();
|
3006
3004
|
this.domRender();
|
@@ -3011,16 +3009,17 @@ const handleChineseInput = function(e) {
|
|
3011
3009
|
if (this.disabled) {
|
3012
3010
|
return;
|
3013
3011
|
}
|
3014
|
-
e
|
3015
|
-
|
3012
|
+
const event2 = e;
|
3013
|
+
event2.preventDefault();
|
3014
|
+
if (event2.type == "compositionstart") {
|
3016
3015
|
if (this.__chineseInputTimer) {
|
3017
3016
|
clearTimeout(this.__chineseInputTimer);
|
3018
3017
|
this.__chineseInputTimer = null;
|
3019
3018
|
}
|
3020
3019
|
this.__isInputChinese = true;
|
3021
|
-
} else if (
|
3022
|
-
if (
|
3023
|
-
this.insertText(
|
3020
|
+
} else if (event2.type == "compositionend") {
|
3021
|
+
if (event2.data) {
|
3022
|
+
this.insertText(event2.data);
|
3024
3023
|
this.formatElementStack();
|
3025
3024
|
this.domRender();
|
3026
3025
|
this.rangeRender();
|
@@ -3037,9 +3036,10 @@ const handleKeyboard = function(e) {
|
|
3037
3036
|
if (this.__isInputChinese) {
|
3038
3037
|
return;
|
3039
3038
|
}
|
3040
|
-
|
3041
|
-
|
3042
|
-
|
3039
|
+
const event2 = e;
|
3040
|
+
if (event2.type == "keydown") {
|
3041
|
+
if (isUndo(event2)) {
|
3042
|
+
event2.preventDefault();
|
3043
3043
|
const historyRecord = this.history.get(-1);
|
3044
3044
|
if (historyRecord) {
|
3045
3045
|
this.history.current = historyRecord.current;
|
@@ -3049,8 +3049,8 @@ const handleKeyboard = function(e) {
|
|
3049
3049
|
this.domRender(true);
|
3050
3050
|
this.rangeRender();
|
3051
3051
|
}
|
3052
|
-
} else if (isRedo(
|
3053
|
-
|
3052
|
+
} else if (isRedo(event2)) {
|
3053
|
+
event2.preventDefault();
|
3054
3054
|
const historyRecord = this.history.get(1);
|
3055
3055
|
if (historyRecord) {
|
3056
3056
|
this.history.current = historyRecord.current;
|
@@ -3061,20 +3061,20 @@ const handleKeyboard = function(e) {
|
|
3061
3061
|
this.rangeRender();
|
3062
3062
|
}
|
3063
3063
|
}
|
3064
|
-
this.emit("keydown", this.value,
|
3065
|
-
} else if (
|
3066
|
-
this.emit("keyup", this.value,
|
3064
|
+
this.emit("keydown", this.value, event2);
|
3065
|
+
} else if (event2.type == "keyup") {
|
3066
|
+
this.emit("keyup", this.value, event2);
|
3067
3067
|
}
|
3068
3068
|
};
|
3069
3069
|
const handleCopy = async function(e) {
|
3070
|
-
e
|
3070
|
+
const event2 = e;
|
3071
|
+
event2.preventDefault();
|
3071
3072
|
if (!this.range) {
|
3072
3073
|
return;
|
3073
3074
|
}
|
3074
3075
|
if (!this.allowCopy) {
|
3075
3076
|
return;
|
3076
3077
|
}
|
3077
|
-
const event2 = e;
|
3078
3078
|
const result = this.getElementsByRange().list;
|
3079
3079
|
if (event2.clipboardData && result.length) {
|
3080
3080
|
const { text: text2, html } = setClipboardData.apply(this, [event2.clipboardData, result]);
|
@@ -3082,14 +3082,14 @@ const handleCopy = async function(e) {
|
|
3082
3082
|
}
|
3083
3083
|
};
|
3084
3084
|
const handleCut = async function(e) {
|
3085
|
-
e
|
3085
|
+
const event2 = e;
|
3086
|
+
event2.preventDefault();
|
3086
3087
|
if (!this.range) {
|
3087
3088
|
return;
|
3088
3089
|
}
|
3089
3090
|
if (!this.allowCut) {
|
3090
3091
|
return;
|
3091
3092
|
}
|
3092
|
-
const event2 = e;
|
3093
3093
|
const result = this.getElementsByRange().list;
|
3094
3094
|
if (event2.clipboardData && result.length) {
|
3095
3095
|
const { text: text2, html } = setClipboardData.apply(this, [event2.clipboardData, result]);
|
@@ -3103,7 +3103,8 @@ const handleCut = async function(e) {
|
|
3103
3103
|
}
|
3104
3104
|
};
|
3105
3105
|
const handlePaste = async function(e) {
|
3106
|
-
e
|
3106
|
+
const event2 = e;
|
3107
|
+
event2.preventDefault();
|
3107
3108
|
if (this.disabled) {
|
3108
3109
|
return;
|
3109
3110
|
}
|
@@ -3113,7 +3114,6 @@ const handlePaste = async function(e) {
|
|
3113
3114
|
if (!this.allowPaste) {
|
3114
3115
|
return;
|
3115
3116
|
}
|
3116
|
-
const event2 = e;
|
3117
3117
|
if (event2.clipboardData) {
|
3118
3118
|
const html = event2.clipboardData.getData("text/html");
|
3119
3119
|
const text2 = event2.clipboardData.getData("text/plain");
|
@@ -3876,48 +3876,50 @@ class AlexEditor {
|
|
3876
3876
|
* 根据range来设置真实的光标
|
3877
3877
|
*/
|
3878
3878
|
rangeRender() {
|
3879
|
-
|
3880
|
-
|
3881
|
-
|
3882
|
-
|
3883
|
-
const handler = (point) => {
|
3884
|
-
let node = null;
|
3885
|
-
let offset = null;
|
3886
|
-
if (point.element.isText()) {
|
3887
|
-
node = point.element.elm.childNodes[0];
|
3888
|
-
offset = point.offset;
|
3889
|
-
} else {
|
3890
|
-
node = point.element.parent.elm;
|
3891
|
-
const index = point.element.parent.children.findIndex((item) => {
|
3892
|
-
return point.element.isEqual(item);
|
3893
|
-
});
|
3894
|
-
offset = point.offset + index;
|
3895
|
-
}
|
3896
|
-
return { node, offset };
|
3897
|
-
};
|
3898
|
-
this.__innerSelectionChange = true;
|
3899
|
-
const anchorResult = handler(this.range.anchor);
|
3900
|
-
const focusResult = handler(this.range.focus);
|
3901
|
-
const selection = window.getSelection();
|
3902
|
-
if (selection) {
|
3903
|
-
selection.removeAllRanges();
|
3904
|
-
const range = document.createRange();
|
3905
|
-
range.setStart(anchorResult.node, anchorResult.offset);
|
3906
|
-
range.setEnd(focusResult.node, focusResult.offset);
|
3907
|
-
selection.addRange(range);
|
3879
|
+
return new Promise((resolve) => {
|
3880
|
+
if (this.disabled) {
|
3881
|
+
resolve();
|
3882
|
+
return;
|
3908
3883
|
}
|
3909
|
-
|
3910
|
-
|
3911
|
-
|
3912
|
-
|
3884
|
+
if (this.range) {
|
3885
|
+
const handler = (point) => {
|
3886
|
+
let node = null;
|
3887
|
+
let offset = null;
|
3888
|
+
if (point.element.isText()) {
|
3889
|
+
node = point.element.elm.childNodes[0];
|
3890
|
+
offset = point.offset;
|
3891
|
+
} else {
|
3892
|
+
node = point.element.parent.elm;
|
3893
|
+
const index = point.element.parent.children.findIndex((item) => point.element.isEqual(item));
|
3894
|
+
offset = point.offset + index;
|
3895
|
+
}
|
3896
|
+
return { node, offset };
|
3897
|
+
};
|
3898
|
+
this.__innerSelectionChange = true;
|
3899
|
+
const anchorResult = handler(this.range.anchor);
|
3900
|
+
const focusResult = handler(this.range.focus);
|
3901
|
+
const selection = window.getSelection();
|
3902
|
+
if (selection) {
|
3903
|
+
selection.removeAllRanges();
|
3904
|
+
const range = document.createRange();
|
3905
|
+
range.setStart(anchorResult.node, anchorResult.offset);
|
3906
|
+
range.setEnd(focusResult.node, focusResult.offset);
|
3907
|
+
selection.addRange(range);
|
3908
|
+
}
|
3909
|
+
} else {
|
3910
|
+
const selection = window.getSelection();
|
3911
|
+
if (selection) {
|
3912
|
+
selection.removeAllRanges();
|
3913
|
+
}
|
3913
3914
|
}
|
3914
|
-
|
3915
|
-
|
3916
|
-
|
3917
|
-
|
3918
|
-
|
3919
|
-
|
3920
|
-
|
3915
|
+
setTimeout(() => {
|
3916
|
+
setRangeInVisible.apply(this);
|
3917
|
+
this.__innerSelectionChange = false;
|
3918
|
+
this.history.updateCurrentRange(this.range);
|
3919
|
+
this.emit("rangeUpdate", this.range);
|
3920
|
+
resolve();
|
3921
|
+
}, 0);
|
3922
|
+
});
|
3921
3923
|
}
|
3922
3924
|
/**
|
3923
3925
|
* 将html转为元素
|
@@ -3988,11 +3990,12 @@ class AlexEditor {
|
|
3988
3990
|
if (inline.parse) {
|
3989
3991
|
config.parsedom = AlexElement.TEXT_NODE;
|
3990
3992
|
if (common$1.isObject(inline.parse)) {
|
3991
|
-
|
3992
|
-
|
3993
|
-
|
3993
|
+
const inlineParse2 = inline.parse;
|
3994
|
+
for (let key in inlineParse2) {
|
3995
|
+
if (typeof inlineParse2[key] == "function") {
|
3996
|
+
config.styles[key] = inlineParse2[key].apply(this, [node]);
|
3994
3997
|
} else {
|
3995
|
-
config.styles[key] =
|
3998
|
+
config.styles[key] = inlineParse2[key];
|
3996
3999
|
}
|
3997
4000
|
}
|
3998
4001
|
}
|
@@ -4197,6 +4200,9 @@ class AlexEditor {
|
|
4197
4200
|
if (child.isEmpty()) {
|
4198
4201
|
continue;
|
4199
4202
|
}
|
4203
|
+
if (!child.isText() && AlexElement.VOID_NODES.includes(child.parsedom)) {
|
4204
|
+
continue;
|
4205
|
+
}
|
4200
4206
|
if (child.isText() || child.isClosed()) {
|
4201
4207
|
el = child;
|
4202
4208
|
break;
|
@@ -4214,6 +4220,9 @@ class AlexEditor {
|
|
4214
4220
|
if (nextElement.isEmpty()) {
|
4215
4221
|
return fn(nextElement);
|
4216
4222
|
}
|
4223
|
+
if (!nextElement.isText() && AlexElement.VOID_NODES.includes(nextElement.parsedom)) {
|
4224
|
+
return fn(nextElement);
|
4225
|
+
}
|
4217
4226
|
if (nextElement.isText() || nextElement.isClosed()) {
|
4218
4227
|
return nextElement;
|
4219
4228
|
}
|
@@ -4549,7 +4558,7 @@ class AlexEditor {
|
|
4549
4558
|
event$1.off(this.$el, "beforeinput.alex_editor compositionstart.alex_editor compositionupdate.alex_editor compositionend.alex_editor keydown.alex_editor cut.alex_editor paste.alex_editor copy.alex_editor dragstart.alex_editor drop.alex_editor focus.alex_editor blur.alex_editor");
|
4550
4559
|
}
|
4551
4560
|
}
|
4552
|
-
const version$2 = "1.4.
|
4561
|
+
const version$2 = "1.4.8";
|
4553
4562
|
console.log(`%c alex-editor %c v${version$2} `, "padding: 2px 1px; border-radius: 3px 0 0 3px; color: #fff; background: #606060; font-weight: bold;", "padding: 2px 1px; border-radius: 0 3px 3px 0; color: #fff; background: #42c02e; font-weight: bold;");
|
4554
4563
|
const number = {
|
4555
4564
|
/**
|
@@ -17875,7 +17884,7 @@ const languages = [
|
|
17875
17884
|
value: "rust"
|
17876
17885
|
}
|
17877
17886
|
];
|
17878
|
-
const mergeObject =
|
17887
|
+
const mergeObject = (o1, o2) => {
|
17879
17888
|
if (!common.isObject(o1) && common.isObject(o2)) {
|
17880
17889
|
return null;
|
17881
17890
|
}
|
@@ -17888,7 +17897,7 @@ const mergeObject = function(o1, o2) {
|
|
17888
17897
|
}
|
17889
17898
|
return o1;
|
17890
17899
|
};
|
17891
|
-
const queryHasValue =
|
17900
|
+
const queryHasValue = (obj, name, value) => {
|
17892
17901
|
if (value == null || value == void 0) {
|
17893
17902
|
return obj.hasOwnProperty(name);
|
17894
17903
|
}
|
@@ -17918,13 +17927,13 @@ const queryHasValue = function(obj, name, value) {
|
|
17918
17927
|
}
|
17919
17928
|
return ownValue == value;
|
17920
17929
|
};
|
17921
|
-
const cloneData =
|
17930
|
+
const cloneData = (data2) => {
|
17922
17931
|
if (common.isObject(data2) || Array.isArray(data2)) {
|
17923
17932
|
return JSON.parse(JSON.stringify(data2));
|
17924
17933
|
}
|
17925
17934
|
return data2;
|
17926
17935
|
};
|
17927
|
-
const getButtonOptionsConfig =
|
17936
|
+
const getButtonOptionsConfig = (editTrans) => {
|
17928
17937
|
return {
|
17929
17938
|
//标题配置
|
17930
17939
|
heading: [
|
@@ -18118,7 +18127,7 @@ const getButtonOptionsConfig = function(editTrans) {
|
|
18118
18127
|
backColor: ["#000000", "#505050", "#808080", "#BBBBBB", "#CCCCCC", "#EEEEEE", "#F7F7F7", "#FFFFFF", "#EC1A0A", "#FF9900", "#FFFF00", "#07C160", "#00FFFF", "#0B73DE", "#9C00FF", "#FF00FF", "#F7C6CE", "#FFE7CE", "#FFEFC6", "#D6EFD6", "#CEDEE7", "#CEE7F7", "#D6D6E7", "#E7D6DE", "#E79C9C", "#FFC69C", "#FFE79C", "#B5D6A5", "#A5C6CE", "#9CC6EF", "#B5A5D6", "#D6A5BD", "#e45649", "#F7AD6B", "#FFD663", "#94BD7B", "#73A5AD", "#6BADDE", "#8C7BC6", "#C67BA5", "#CE0000", "#E79439", "#EFC631", "#50a14f", "#4A7B8C", "#03A8F3", "#634AA5", "#A54A7B", "#9C0000", "#B56308", "#BD9400", "#397B21", "#104A5A", "#085294", "#311873", "#731842", "#630000", "#7B3900", "#986801", "#295218", "#083139", "#003163", "#21104A", "#4A1031"]
|
18119
18128
|
};
|
18120
18129
|
};
|
18121
|
-
const getToolbarConfig =
|
18130
|
+
const getToolbarConfig = (editTrans, editLocale) => {
|
18122
18131
|
return {
|
18123
18132
|
//是否使用工具条
|
18124
18133
|
use: true,
|
@@ -18361,7 +18370,7 @@ const getToolbarConfig = function(editTrans, editLocale) {
|
|
18361
18370
|
extraDisabled: null
|
18362
18371
|
};
|
18363
18372
|
};
|
18364
|
-
const getMenuConfig =
|
18373
|
+
const getMenuConfig = (editTrans, editLocale) => {
|
18365
18374
|
return {
|
18366
18375
|
//是否使用菜单栏
|
18367
18376
|
use: true,
|
@@ -18756,6 +18765,128 @@ const getMenuConfig = function(editTrans, editLocale) {
|
|
18756
18765
|
extends: {}
|
18757
18766
|
};
|
18758
18767
|
};
|
18768
|
+
const setTableCellMerged = (cell) => {
|
18769
|
+
const breakEl = new AlexElement("closed", "br", null, null, null);
|
18770
|
+
cell.children = [breakEl];
|
18771
|
+
breakEl.parent = cell;
|
18772
|
+
if (cell.hasMarks()) {
|
18773
|
+
cell.marks["data-editify-merged"] = "true";
|
18774
|
+
} else {
|
18775
|
+
cell.marks = {
|
18776
|
+
"data-editify-merged": "true"
|
18777
|
+
};
|
18778
|
+
}
|
18779
|
+
};
|
18780
|
+
const getCellMergeElement = (editor, cell) => {
|
18781
|
+
const queryLeft = () => {
|
18782
|
+
let crossColumnElement = null;
|
18783
|
+
let el = editor.getPreviousElement(cell);
|
18784
|
+
let temIndex = 1;
|
18785
|
+
while (el) {
|
18786
|
+
const { colspan } = getCellSpanNumber(el);
|
18787
|
+
const isMergedCell = el.hasMarks() && el.marks["data-editify-merged"];
|
18788
|
+
if (!isMergedCell && colspan > temIndex) {
|
18789
|
+
crossColumnElement = el;
|
18790
|
+
break;
|
18791
|
+
} else {
|
18792
|
+
el = editor.getPreviousElement(el);
|
18793
|
+
temIndex++;
|
18794
|
+
}
|
18795
|
+
}
|
18796
|
+
return crossColumnElement;
|
18797
|
+
};
|
18798
|
+
const queryUp = () => {
|
18799
|
+
let crossRowElement = null;
|
18800
|
+
const index = cell.parent.children.findIndex((item) => item.isEqual(cell));
|
18801
|
+
let el = editor.getPreviousElement(cell.parent);
|
18802
|
+
let temIndex = 1;
|
18803
|
+
while (el) {
|
18804
|
+
const column = el.children[index];
|
18805
|
+
const { rowspan } = getCellSpanNumber(column);
|
18806
|
+
const isMergedCell = column.hasMarks() && column.marks["data-editify-merged"];
|
18807
|
+
if (!isMergedCell && rowspan > temIndex) {
|
18808
|
+
crossRowElement = column;
|
18809
|
+
break;
|
18810
|
+
} else {
|
18811
|
+
el = editor.getPreviousElement(el);
|
18812
|
+
temIndex++;
|
18813
|
+
}
|
18814
|
+
}
|
18815
|
+
return crossRowElement;
|
18816
|
+
};
|
18817
|
+
return {
|
18818
|
+
crossRowElement: queryUp(),
|
18819
|
+
crossColumnElement: queryLeft()
|
18820
|
+
};
|
18821
|
+
};
|
18822
|
+
const getCellSpanNumber = (cell) => {
|
18823
|
+
let rowspan = 1;
|
18824
|
+
let colspan = 1;
|
18825
|
+
if (cell.hasMarks()) {
|
18826
|
+
if (cell.marks["rowspan"]) {
|
18827
|
+
const num = Number(cell.marks["rowspan"]);
|
18828
|
+
rowspan = isNaN(num) ? 1 : num;
|
18829
|
+
}
|
18830
|
+
if (cell.marks["colspan"]) {
|
18831
|
+
const num = Number(cell.marks["colspan"]);
|
18832
|
+
colspan = isNaN(num) ? 1 : num;
|
18833
|
+
}
|
18834
|
+
}
|
18835
|
+
return {
|
18836
|
+
rowspan,
|
18837
|
+
colspan
|
18838
|
+
};
|
18839
|
+
};
|
18840
|
+
const getTableSize = (rowElements) => {
|
18841
|
+
const columns = [];
|
18842
|
+
const rows = [];
|
18843
|
+
rowElements.forEach((rowElement, rowIndex) => {
|
18844
|
+
rowElement.children.forEach((colElement, colIndex) => {
|
18845
|
+
if (Array.isArray(rows[rowIndex])) {
|
18846
|
+
rows[rowIndex].push(colElement);
|
18847
|
+
} else {
|
18848
|
+
rows[rowIndex] = [colElement];
|
18849
|
+
}
|
18850
|
+
if (Array.isArray(columns[colIndex])) {
|
18851
|
+
columns[colIndex].push(colElement);
|
18852
|
+
} else {
|
18853
|
+
columns[colIndex] = [colElement];
|
18854
|
+
}
|
18855
|
+
});
|
18856
|
+
});
|
18857
|
+
const rowNumbers = columns.map((item) => {
|
18858
|
+
return item.reduce((total, current) => {
|
18859
|
+
if (current.hasMarks()) {
|
18860
|
+
if (!!current.marks["data-editify-merged"]) {
|
18861
|
+
return total + 0;
|
18862
|
+
}
|
18863
|
+
if (!!current.marks["rowspan"]) {
|
18864
|
+
const num = Number(current.marks["rowspan"]);
|
18865
|
+
return total + (isNaN(num) ? 1 : num);
|
18866
|
+
}
|
18867
|
+
}
|
18868
|
+
return total + 1;
|
18869
|
+
}, 0);
|
18870
|
+
});
|
18871
|
+
const columnNumbers = rows.map((item) => {
|
18872
|
+
return item.reduce((total, current) => {
|
18873
|
+
if (current.hasMarks()) {
|
18874
|
+
if (!!current.marks["data-editify-merged"]) {
|
18875
|
+
return total + 0;
|
18876
|
+
}
|
18877
|
+
if (!!current.marks["colspan"]) {
|
18878
|
+
const num = Number(current.marks["colspan"]);
|
18879
|
+
return total + (isNaN(num) ? 1 : num);
|
18880
|
+
}
|
18881
|
+
}
|
18882
|
+
return total + 1;
|
18883
|
+
}, 0);
|
18884
|
+
});
|
18885
|
+
return {
|
18886
|
+
rowNumber: Math.max(...rowNumbers),
|
18887
|
+
columnNumber: Math.max(...columnNumbers)
|
18888
|
+
};
|
18889
|
+
};
|
18759
18890
|
const elementIsMatch = (element2, config) => {
|
18760
18891
|
let isMatch = true;
|
18761
18892
|
if (config.parsedom && (element2.isText() || config.parsedom != element2.parsedom)) {
|
@@ -19723,6 +19854,139 @@ const insertSeparator = (editor) => {
|
|
19723
19854
|
editor.range.anchor.moveToEnd(separator);
|
19724
19855
|
editor.range.focus.moveToEnd(separator);
|
19725
19856
|
};
|
19857
|
+
const autocompleteTableCells = (editor, rowElements, rowNumber, columnNumber) => {
|
19858
|
+
AlexElement.flatElements(rowElements).forEach((item) => {
|
19859
|
+
if (item.parsedom == "td" && item.hasMarks()) {
|
19860
|
+
if (item.marks["data-editify-merged"]) {
|
19861
|
+
delete item.marks["data-editify-merged"];
|
19862
|
+
}
|
19863
|
+
const colspan = isNaN(Number(item.marks["colspan"])) ? 1 : Number(item.marks["colspan"]);
|
19864
|
+
const rowspan = isNaN(Number(item.marks["rowspan"])) ? 1 : Number(item.marks["rowspan"]);
|
19865
|
+
if (colspan > 1) {
|
19866
|
+
let i = 1;
|
19867
|
+
while (i < colspan && item.parent.children.length < columnNumber) {
|
19868
|
+
const column = new AlexElement(
|
19869
|
+
"inblock",
|
19870
|
+
"td",
|
19871
|
+
{
|
19872
|
+
"data-editify-merged": "true"
|
19873
|
+
},
|
19874
|
+
null,
|
19875
|
+
null
|
19876
|
+
);
|
19877
|
+
const breakElement = new AlexElement("closed", "br", null, null, null);
|
19878
|
+
editor.addElementTo(breakElement, column);
|
19879
|
+
editor.addElementAfter(column, item);
|
19880
|
+
i++;
|
19881
|
+
}
|
19882
|
+
}
|
19883
|
+
if (rowspan > 1) {
|
19884
|
+
let el = item;
|
19885
|
+
let i = 1;
|
19886
|
+
while (i < rowspan && editor.getNextElement(el.parent) && editor.getNextElement(el.parent).children.length < columnNumber) {
|
19887
|
+
const nextRow = editor.getNextElement(el.parent);
|
19888
|
+
const index = el.parent.children.findIndex((item2) => item2.isEqual(el));
|
19889
|
+
const nextCell = nextRow.children[index];
|
19890
|
+
for (let j = 0; j < colspan; j++) {
|
19891
|
+
const column = new AlexElement(
|
19892
|
+
"inblock",
|
19893
|
+
"td",
|
19894
|
+
{
|
19895
|
+
"data-editify-merged": "true"
|
19896
|
+
},
|
19897
|
+
null,
|
19898
|
+
null
|
19899
|
+
);
|
19900
|
+
const breakElement = new AlexElement("closed", "br", null, null, null);
|
19901
|
+
editor.addElementTo(breakElement, column);
|
19902
|
+
if (nextCell) {
|
19903
|
+
editor.addElementBefore(column, nextCell);
|
19904
|
+
} else {
|
19905
|
+
editor.addElementTo(column, nextRow, nextRow.children.length);
|
19906
|
+
}
|
19907
|
+
}
|
19908
|
+
el = nextRow.children[index];
|
19909
|
+
i++;
|
19910
|
+
}
|
19911
|
+
}
|
19912
|
+
}
|
19913
|
+
});
|
19914
|
+
rowElements.forEach((rowElement) => {
|
19915
|
+
const number2 = rowElement.children.length;
|
19916
|
+
if (number2 < columnNumber) {
|
19917
|
+
for (let i = 0; i < columnNumber - number2; i++) {
|
19918
|
+
const column = new AlexElement("inblock", "td", null, null, null);
|
19919
|
+
const breakElement = new AlexElement("closed", "br", null, null, null);
|
19920
|
+
editor.addElementTo(breakElement, column);
|
19921
|
+
editor.addElementTo(column, rowElement, rowElement.children.length);
|
19922
|
+
}
|
19923
|
+
}
|
19924
|
+
});
|
19925
|
+
const length = rowElements.length;
|
19926
|
+
if (length < rowNumber) {
|
19927
|
+
for (let i = 0; i < rowNumber - length; i++) {
|
19928
|
+
const row = new AlexElement("inblock", "tr", null, null, null);
|
19929
|
+
for (let j = 0; j < columnNumber; j++) {
|
19930
|
+
const column = new AlexElement("inblock", "td", null, null, null);
|
19931
|
+
const breakElement = new AlexElement("closed", "br", null, null, null);
|
19932
|
+
editor.addElementTo(breakElement, column);
|
19933
|
+
editor.addElementTo(column, row);
|
19934
|
+
}
|
19935
|
+
rowElements.push(row);
|
19936
|
+
}
|
19937
|
+
}
|
19938
|
+
};
|
19939
|
+
const autoHideMergedTableCells = (editor, rowElements) => {
|
19940
|
+
const cells = AlexElement.flatElements(rowElements).filter((item) => item.parsedom == "td");
|
19941
|
+
cells.forEach((cell) => {
|
19942
|
+
if (cell.hasMarks() && !cell.marks["data-editify-merged"]) {
|
19943
|
+
const colspan = isNaN(Number(cell.marks["colspan"])) ? 1 : Number(cell.marks["colspan"]);
|
19944
|
+
const rowspan = isNaN(Number(cell.marks["rowspan"])) ? 1 : Number(cell.marks["rowspan"]);
|
19945
|
+
if (colspan > 1) {
|
19946
|
+
let el = cell;
|
19947
|
+
let i = 1;
|
19948
|
+
while (i < colspan) {
|
19949
|
+
const nextCell = editor.getNextElement(el);
|
19950
|
+
if (nextCell) {
|
19951
|
+
if (nextCell.hasMarks()) {
|
19952
|
+
nextCell.marks["data-editify-merged"] = "true";
|
19953
|
+
} else {
|
19954
|
+
nextCell.marks = {
|
19955
|
+
"data-editify-merged": "true"
|
19956
|
+
};
|
19957
|
+
}
|
19958
|
+
el = nextCell;
|
19959
|
+
i++;
|
19960
|
+
} else {
|
19961
|
+
break;
|
19962
|
+
}
|
19963
|
+
}
|
19964
|
+
}
|
19965
|
+
if (rowspan > 1) {
|
19966
|
+
const index = cell.parent.children.findIndex((item) => item.isEqual(cell));
|
19967
|
+
let el = cell;
|
19968
|
+
let i = 1;
|
19969
|
+
while (i < rowspan && el && editor.getNextElement(el.parent)) {
|
19970
|
+
const nextRow = editor.getNextElement(el.parent);
|
19971
|
+
for (let j = index; j < index + colspan; j++) {
|
19972
|
+
const current = nextRow.children[j];
|
19973
|
+
if (current) {
|
19974
|
+
if (current.hasMarks()) {
|
19975
|
+
current.marks["data-editify-merged"] = "true";
|
19976
|
+
} else {
|
19977
|
+
current.marks = {
|
19978
|
+
"data-editify-merged": "true"
|
19979
|
+
};
|
19980
|
+
}
|
19981
|
+
}
|
19982
|
+
}
|
19983
|
+
el = nextRow.children[index];
|
19984
|
+
i++;
|
19985
|
+
}
|
19986
|
+
}
|
19987
|
+
}
|
19988
|
+
});
|
19989
|
+
};
|
19726
19990
|
const updateRangeInPre = (editor, element2, originalTextElements, newElements) => {
|
19727
19991
|
if (!editor.range) {
|
19728
19992
|
return;
|
@@ -19782,7 +20046,7 @@ const parseList = (editor, element2) => {
|
|
19782
20046
|
element2.toEmpty();
|
19783
20047
|
}
|
19784
20048
|
};
|
19785
|
-
const orderdListHandle =
|
20049
|
+
const orderdListHandle = (editor, element2) => {
|
19786
20050
|
if (isList(element2, true)) {
|
19787
20051
|
const previousElement = editor.getPreviousElement(element2);
|
19788
20052
|
if (previousElement && isList(previousElement, true)) {
|
@@ -19793,7 +20057,7 @@ const orderdListHandle = function(editor, element2) {
|
|
19793
20057
|
}
|
19794
20058
|
}
|
19795
20059
|
};
|
19796
|
-
const commonElementHandle =
|
20060
|
+
const commonElementHandle = (editor, element2) => {
|
19797
20061
|
if (element2.parsedom == "img" || element2.parsedom == "video" || element2.parsedom == "a") {
|
19798
20062
|
const marks = {
|
19799
20063
|
"data-editify-element": element2.key
|
@@ -19834,7 +20098,12 @@ const commonElementHandle = function(editor, element2) {
|
|
19834
20098
|
}
|
19835
20099
|
}
|
19836
20100
|
};
|
19837
|
-
const
|
20101
|
+
const tableThTdHandle = (_editor, element2) => {
|
20102
|
+
if (element2.parsedom == "th") {
|
20103
|
+
element2.parsedom = "td";
|
20104
|
+
}
|
20105
|
+
};
|
20106
|
+
const tableFormatHandle = (editor, element2) => {
|
19838
20107
|
if (element2.parsedom == "table") {
|
19839
20108
|
const marks = {
|
19840
20109
|
"data-editify-element": element2.key
|
@@ -19857,14 +20126,10 @@ const tableHandle = function(editor, element2) {
|
|
19857
20126
|
const rows = elements.filter((el) => {
|
19858
20127
|
return el.parsedom == "tr";
|
19859
20128
|
});
|
20129
|
+
const { rowNumber, columnNumber } = getTableSize(rows);
|
19860
20130
|
let colgroup = elements.find((el) => {
|
19861
20131
|
return el.parsedom == "colgroup";
|
19862
20132
|
});
|
19863
|
-
const colNumber = Math.max(
|
19864
|
-
...rows.map((row) => {
|
19865
|
-
return row.children.length;
|
19866
|
-
})
|
19867
|
-
);
|
19868
20133
|
if (colgroup) {
|
19869
20134
|
colgroup.children.forEach((col) => {
|
19870
20135
|
if (!col.hasMarks()) {
|
@@ -19876,8 +20141,8 @@ const tableHandle = function(editor, element2) {
|
|
19876
20141
|
}
|
19877
20142
|
});
|
19878
20143
|
const length = colgroup.children.length;
|
19879
|
-
if (length <
|
19880
|
-
for (let i = 0; i <
|
20144
|
+
if (length < columnNumber) {
|
20145
|
+
for (let i = 0; i < columnNumber - length; i++) {
|
19881
20146
|
const col = new AlexElement(
|
19882
20147
|
"closed",
|
19883
20148
|
"col",
|
@@ -19892,7 +20157,7 @@ const tableHandle = function(editor, element2) {
|
|
19892
20157
|
}
|
19893
20158
|
} else {
|
19894
20159
|
colgroup = new AlexElement("inblock", "colgroup", null, null, null);
|
19895
|
-
for (let i =
|
20160
|
+
for (let i = columnNumber - 1; i >= 0; i--) {
|
19896
20161
|
const col = new AlexElement(
|
19897
20162
|
"closed",
|
19898
20163
|
"col",
|
@@ -19905,43 +20170,79 @@ const tableHandle = function(editor, element2) {
|
|
19905
20170
|
editor.addElementTo(col, colgroup);
|
19906
20171
|
}
|
19907
20172
|
}
|
20173
|
+
autocompleteTableCells(editor, rows, rowNumber, columnNumber);
|
19908
20174
|
element2.children = [];
|
19909
20175
|
const tbody = new AlexElement("inblock", "tbody", null, null, null);
|
19910
|
-
rows.
|
19911
|
-
const
|
19912
|
-
|
19913
|
-
for (let i = 0; i < colNumber - length; i++) {
|
19914
|
-
const column = new AlexElement("inblock", "td", null, null, null);
|
19915
|
-
const breakElement = new AlexElement("closed", "br", null, null, null);
|
19916
|
-
editor.addElementTo(breakElement, column);
|
19917
|
-
editor.addElementTo(column, row, row.children.length);
|
19918
|
-
}
|
19919
|
-
}
|
19920
|
-
editor.addElementTo(row, tbody);
|
20176
|
+
rows.forEach((row) => {
|
20177
|
+
const index = tbody.hasChildren() ? tbody.children.length : 0;
|
20178
|
+
editor.addElementTo(row, tbody, index);
|
19921
20179
|
});
|
19922
20180
|
editor.addElementTo(tbody, element2);
|
19923
20181
|
editor.addElementTo(colgroup, element2);
|
19924
|
-
|
19925
|
-
|
19926
|
-
|
19927
|
-
|
19928
|
-
if (element2.parsedom == "td") {
|
19929
|
-
|
19930
|
-
|
19931
|
-
|
20182
|
+
autoHideMergedTableCells(editor, rows);
|
20183
|
+
}
|
20184
|
+
};
|
20185
|
+
const tableRangeMergedHandle = (editor, element2) => {
|
20186
|
+
if (element2.parsedom == "td" && element2.hasMarks() && element2.marks["data-editify-merged"] && editor.range) {
|
20187
|
+
const queryLeftSetRange = (_element, callback) => {
|
20188
|
+
let success = false;
|
20189
|
+
let el = editor.getPreviousElement(_element);
|
20190
|
+
let tempIndex = 1;
|
20191
|
+
while (el) {
|
20192
|
+
const { colspan } = getCellSpanNumber(el);
|
20193
|
+
if (el.hasMarks() && !el.marks["data-editify-merged"] && colspan > tempIndex) {
|
20194
|
+
success = true;
|
20195
|
+
callback(el);
|
20196
|
+
break;
|
20197
|
+
} else {
|
20198
|
+
el = editor.getPreviousElement(el);
|
20199
|
+
tempIndex++;
|
20200
|
+
}
|
20201
|
+
}
|
20202
|
+
return success;
|
20203
|
+
};
|
20204
|
+
const queryUpSetRange = (_element, callback) => {
|
20205
|
+
let success = false;
|
20206
|
+
const index = _element.parent.children.findIndex((item) => item.isEqual(_element));
|
20207
|
+
let el = editor.getPreviousElement(_element.parent);
|
20208
|
+
let tempIndex = 1;
|
20209
|
+
while (el) {
|
20210
|
+
const previousColumn = el.children[index];
|
20211
|
+
const { rowspan } = getCellSpanNumber(previousColumn);
|
20212
|
+
if (previousColumn.hasMarks() && !previousColumn.marks["data-editify-merged"] && rowspan > tempIndex) {
|
20213
|
+
success = true;
|
20214
|
+
callback(previousColumn);
|
20215
|
+
break;
|
20216
|
+
} else {
|
20217
|
+
el = editor.getPreviousElement(el);
|
20218
|
+
tempIndex++;
|
20219
|
+
}
|
19932
20220
|
}
|
19933
|
-
|
19934
|
-
|
20221
|
+
return success;
|
20222
|
+
};
|
20223
|
+
if (element2.isContains(editor.range.anchor.element)) {
|
20224
|
+
const success = queryLeftSetRange(element2, (ele) => {
|
20225
|
+
editor.range.anchor.moveToEnd(ele);
|
20226
|
+
});
|
20227
|
+
if (!success) {
|
20228
|
+
queryUpSetRange(element2, (ele) => {
|
20229
|
+
editor.range.anchor.moveToEnd(ele);
|
20230
|
+
});
|
19935
20231
|
}
|
19936
20232
|
}
|
19937
|
-
if (element2.
|
19938
|
-
|
19939
|
-
|
20233
|
+
if (element2.isContains(editor.range.focus.element)) {
|
20234
|
+
const success = queryLeftSetRange(element2, (ele) => {
|
20235
|
+
editor.range.focus.moveToEnd(ele);
|
20236
|
+
});
|
20237
|
+
if (!success) {
|
20238
|
+
queryUpSetRange(element2, (ele) => {
|
20239
|
+
editor.range.focus.moveToEnd(ele);
|
20240
|
+
});
|
19940
20241
|
}
|
19941
20242
|
}
|
19942
20243
|
}
|
19943
20244
|
};
|
19944
|
-
const preHandle =
|
20245
|
+
const preHandle = (editor, element2, highlight2, languages2) => {
|
19945
20246
|
if (element2.parsedom == "pre") {
|
19946
20247
|
const marks = {
|
19947
20248
|
"data-editify-element": element2.key
|
@@ -19988,7 +20289,7 @@ const preHandle = function(editor, element2, highlight2, languages2) {
|
|
19988
20289
|
}
|
19989
20290
|
}
|
19990
20291
|
};
|
19991
|
-
const specialInblockHandle =
|
20292
|
+
const specialInblockHandle = (editor, element2) => {
|
19992
20293
|
if (element2.hasChildren()) {
|
19993
20294
|
element2.children.forEach((el) => {
|
19994
20295
|
if (isList(el, true) || isList(el, false) || isTask(el) || ["blockquote", "pre", "table", "h1", "h2", "h3", "h4", "h5", "h6", "p"].includes(el.parsedom)) {
|
@@ -21595,6 +21896,100 @@ const _sfc_main$8 = /* @__PURE__ */ defineComponent({
|
|
21595
21896
|
emits("update:modelValue", val);
|
21596
21897
|
}
|
21597
21898
|
});
|
21899
|
+
const canMergeCells = computed(() => {
|
21900
|
+
return (type) => {
|
21901
|
+
if (!editor.value.range) {
|
21902
|
+
return false;
|
21903
|
+
}
|
21904
|
+
const cell = getMatchElementByElement(editor.value.range.focus.element, {
|
21905
|
+
parsedom: "td"
|
21906
|
+
});
|
21907
|
+
if (!cell) {
|
21908
|
+
return false;
|
21909
|
+
}
|
21910
|
+
if (type == "left") {
|
21911
|
+
let flag = false;
|
21912
|
+
const cellSpanNum = getCellSpanNumber(cell);
|
21913
|
+
const previousColumn = editor.value.getPreviousElement(cell);
|
21914
|
+
if (previousColumn) {
|
21915
|
+
if (previousColumn.hasMarks() && previousColumn.marks["data-editify-merged"]) {
|
21916
|
+
const { crossColumnElement } = getCellMergeElement(editor.value, previousColumn);
|
21917
|
+
if (crossColumnElement) {
|
21918
|
+
const { rowspan } = getCellSpanNumber(crossColumnElement);
|
21919
|
+
flag = rowspan == cellSpanNum.rowspan;
|
21920
|
+
}
|
21921
|
+
} else {
|
21922
|
+
const { rowspan } = getCellSpanNumber(previousColumn);
|
21923
|
+
flag = rowspan == cellSpanNum.rowspan;
|
21924
|
+
}
|
21925
|
+
}
|
21926
|
+
return flag;
|
21927
|
+
}
|
21928
|
+
if (type == "right") {
|
21929
|
+
let flag = false;
|
21930
|
+
const cellSpanNum = getCellSpanNumber(cell);
|
21931
|
+
let nextColumn = editor.value.getNextElement(cell);
|
21932
|
+
while (nextColumn) {
|
21933
|
+
if (nextColumn.hasMarks() && nextColumn.marks["data-editify-merged"]) {
|
21934
|
+
const { crossColumnElement } = getCellMergeElement(editor.value, nextColumn);
|
21935
|
+
if (crossColumnElement) {
|
21936
|
+
nextColumn = editor.value.getNextElement(nextColumn);
|
21937
|
+
} else {
|
21938
|
+
break;
|
21939
|
+
}
|
21940
|
+
} else {
|
21941
|
+
const { rowspan } = getCellSpanNumber(nextColumn);
|
21942
|
+
flag = rowspan == cellSpanNum.rowspan;
|
21943
|
+
break;
|
21944
|
+
}
|
21945
|
+
}
|
21946
|
+
return flag;
|
21947
|
+
}
|
21948
|
+
if (type == "up") {
|
21949
|
+
let flag = false;
|
21950
|
+
const cellSpanNum = getCellSpanNumber(cell);
|
21951
|
+
const index = cell.parent.children.findIndex((item) => item.isEqual(cell));
|
21952
|
+
const previousRow = editor.value.getPreviousElement(cell.parent);
|
21953
|
+
if (previousRow) {
|
21954
|
+
const column = previousRow.children[index];
|
21955
|
+
if (column.hasMarks() && column.marks["data-editify-merged"]) {
|
21956
|
+
const { crossRowElement } = getCellMergeElement(editor.value, column);
|
21957
|
+
if (crossRowElement) {
|
21958
|
+
const { colspan } = getCellSpanNumber(crossRowElement);
|
21959
|
+
flag = colspan == cellSpanNum.colspan;
|
21960
|
+
}
|
21961
|
+
} else {
|
21962
|
+
const { colspan } = getCellSpanNumber(column);
|
21963
|
+
flag = colspan == cellSpanNum.colspan;
|
21964
|
+
}
|
21965
|
+
}
|
21966
|
+
return flag;
|
21967
|
+
}
|
21968
|
+
if (type == "down") {
|
21969
|
+
let flag = false;
|
21970
|
+
const cellSpanNum = getCellSpanNumber(cell);
|
21971
|
+
const index = cell.parent.children.findIndex((item) => item.isEqual(cell));
|
21972
|
+
let nextRow = editor.value.getNextElement(cell.parent);
|
21973
|
+
while (nextRow) {
|
21974
|
+
const column = nextRow.children[index];
|
21975
|
+
if (column.hasMarks() && column.marks["data-editify-merged"]) {
|
21976
|
+
const { crossRowElement } = getCellMergeElement(editor.value, column);
|
21977
|
+
if (crossRowElement) {
|
21978
|
+
nextRow = editor.value.getNextElement(nextRow);
|
21979
|
+
} else {
|
21980
|
+
break;
|
21981
|
+
}
|
21982
|
+
} else {
|
21983
|
+
const { colspan } = getCellSpanNumber(column);
|
21984
|
+
flag = colspan == cellSpanNum.colspan;
|
21985
|
+
break;
|
21986
|
+
}
|
21987
|
+
}
|
21988
|
+
return flag;
|
21989
|
+
}
|
21990
|
+
return false;
|
21991
|
+
};
|
21992
|
+
});
|
21598
21993
|
const handleInputFocus = (e) => {
|
21599
21994
|
if (props.color) {
|
21600
21995
|
e.currentTarget.style.borderColor = props.color;
|
@@ -21855,25 +22250,26 @@ const _sfc_main$8 = /* @__PURE__ */ defineComponent({
|
|
21855
22250
|
editor.value.range.anchor.element = editor.value.range.focus.element;
|
21856
22251
|
editor.value.range.anchor.offset = editor.value.range.focus.offset;
|
21857
22252
|
}
|
21858
|
-
const tables = getMatchElementsByRange(editor.value, dataRangeCaches.value, { parsedom: "table" });
|
21859
22253
|
const columns = getMatchElementsByRange(editor.value, dataRangeCaches.value, { parsedom: "td" });
|
21860
|
-
|
21861
|
-
|
21862
|
-
const
|
21863
|
-
const
|
22254
|
+
if (columns.length == 1) {
|
22255
|
+
const row = columns[0].parent;
|
22256
|
+
const tbody = row.parent;
|
22257
|
+
const table = tbody.parent;
|
22258
|
+
const rows = tbody.children;
|
22259
|
+
const index = row.children.findIndex((item) => {
|
21864
22260
|
return item.isEqual(columns[0]);
|
21865
22261
|
});
|
21866
|
-
rows.forEach((
|
21867
|
-
const newColumn =
|
22262
|
+
rows.forEach((item) => {
|
22263
|
+
const newColumn = new AlexElement("inblock", "td", null, null, null);
|
21868
22264
|
const breakEl = new AlexElement("closed", "br", null, null, null);
|
21869
22265
|
editor.value.addElementTo(breakEl, newColumn);
|
21870
22266
|
if (type == "left") {
|
21871
|
-
editor.value.addElementTo(newColumn,
|
22267
|
+
editor.value.addElementTo(newColumn, item, index);
|
21872
22268
|
} else {
|
21873
|
-
editor.value.addElementTo(newColumn,
|
22269
|
+
editor.value.addElementTo(newColumn, item, index + 1);
|
21874
22270
|
}
|
21875
22271
|
});
|
21876
|
-
const colgroup =
|
22272
|
+
const colgroup = table.children.find((item) => {
|
21877
22273
|
return item.parsedom == "colgroup";
|
21878
22274
|
});
|
21879
22275
|
const col = new AlexElement("closed", "col", null, null, null);
|
@@ -21882,7 +22278,6 @@ const _sfc_main$8 = /* @__PURE__ */ defineComponent({
|
|
21882
22278
|
} else {
|
21883
22279
|
editor.value.addElementTo(col, colgroup, index + 1);
|
21884
22280
|
}
|
21885
|
-
editor.value.formatElementStack();
|
21886
22281
|
if (type == "left") {
|
21887
22282
|
const previousColumn = editor.value.getPreviousElement(columns[0]);
|
21888
22283
|
editor.value.range.anchor.moveToStart(previousColumn);
|
@@ -21892,6 +22287,7 @@ const _sfc_main$8 = /* @__PURE__ */ defineComponent({
|
|
21892
22287
|
editor.value.range.anchor.moveToStart(nextColumn);
|
21893
22288
|
editor.value.range.focus.moveToStart(nextColumn);
|
21894
22289
|
}
|
22290
|
+
editor.value.formatElementStack();
|
21895
22291
|
editor.value.domRender();
|
21896
22292
|
editor.value.rangeRender();
|
21897
22293
|
}
|
@@ -21901,23 +22297,25 @@ const _sfc_main$8 = /* @__PURE__ */ defineComponent({
|
|
21901
22297
|
editor.value.range.anchor.element = editor.value.range.focus.element;
|
21902
22298
|
editor.value.range.anchor.offset = editor.value.range.focus.offset;
|
21903
22299
|
}
|
21904
|
-
const tables = getMatchElementsByRange(editor.value, dataRangeCaches.value, { parsedom: "table" });
|
21905
22300
|
const rows = getMatchElementsByRange(editor.value, dataRangeCaches.value, { parsedom: "tr" });
|
21906
|
-
if (
|
21907
|
-
const
|
21908
|
-
|
21909
|
-
|
22301
|
+
if (rows.length == 1) {
|
22302
|
+
const tbody = rows[0].parent;
|
22303
|
+
const { columnNumber } = getTableSize(tbody.children);
|
22304
|
+
const newRow = new AlexElement("inblock", "tr", null, null, null);
|
22305
|
+
for (let i = 0; i < columnNumber; i++) {
|
22306
|
+
const column = new AlexElement("inblock", "td", null, null, null);
|
21910
22307
|
const breakEl = new AlexElement("closed", "br", null, null, null);
|
21911
22308
|
editor.value.addElementTo(breakEl, column);
|
21912
|
-
|
22309
|
+
editor.value.addElementTo(column, newRow);
|
22310
|
+
}
|
21913
22311
|
if (type == "up") {
|
21914
22312
|
editor.value.addElementBefore(newRow, rows[0]);
|
21915
22313
|
} else {
|
21916
22314
|
editor.value.addElementAfter(newRow, rows[0]);
|
21917
22315
|
}
|
21918
|
-
editor.value.formatElementStack();
|
21919
22316
|
editor.value.range.anchor.moveToStart(newRow);
|
21920
22317
|
editor.value.range.focus.moveToStart(newRow);
|
22318
|
+
editor.value.formatElementStack();
|
21921
22319
|
editor.value.domRender();
|
21922
22320
|
editor.value.rangeRender();
|
21923
22321
|
setTimeout(() => {
|
@@ -21957,25 +22355,52 @@ const _sfc_main$8 = /* @__PURE__ */ defineComponent({
|
|
21957
22355
|
editor.value.range.anchor.element = editor.value.range.focus.element;
|
21958
22356
|
editor.value.range.anchor.offset = editor.value.range.focus.offset;
|
21959
22357
|
}
|
21960
|
-
const
|
21961
|
-
|
21962
|
-
|
21963
|
-
|
21964
|
-
if (parent.children.length == 1) {
|
22358
|
+
const columns = getMatchElementsByRange(editor.value, dataRangeCaches.value, { parsedom: "td" });
|
22359
|
+
if (columns.length == 1) {
|
22360
|
+
const row = columns[0].parent;
|
22361
|
+
if (row.parent.children.length == 1) {
|
21965
22362
|
deleteElement("table");
|
21966
22363
|
return;
|
21967
22364
|
}
|
21968
|
-
const
|
21969
|
-
|
21970
|
-
|
21971
|
-
editor.value.
|
22365
|
+
const index = row.children.findIndex((item) => {
|
22366
|
+
return item.isEqual(columns[0]);
|
22367
|
+
});
|
22368
|
+
const previousRow = editor.value.getPreviousElement(row);
|
22369
|
+
const nextRow = editor.value.getNextElement(row);
|
22370
|
+
row.children.forEach((item, i) => {
|
22371
|
+
const itemSpanNum = getCellSpanNumber(item);
|
22372
|
+
if (item.hasMarks() && item.marks["data-editify-merged"]) {
|
22373
|
+
const { crossRowElement } = getCellMergeElement(editor.value, item);
|
22374
|
+
if (crossRowElement) {
|
22375
|
+
const { rowspan } = getCellSpanNumber(crossRowElement);
|
22376
|
+
if (rowspan - 1 == 1) {
|
22377
|
+
delete crossRowElement.marks["rowspan"];
|
22378
|
+
} else {
|
22379
|
+
crossRowElement.marks["rowspan"] = rowspan - 1;
|
22380
|
+
}
|
22381
|
+
}
|
22382
|
+
} else if (itemSpanNum.rowspan > 1) {
|
22383
|
+
let el = editor.value.getNextElement(row);
|
22384
|
+
if (el && itemSpanNum.rowspan - 1 > 1) {
|
22385
|
+
if (el.children[i].hasMarks()) {
|
22386
|
+
el.children[i].marks["rowspan"] = itemSpanNum.rowspan - 1;
|
22387
|
+
} else {
|
22388
|
+
el.children[i].marks = {
|
22389
|
+
rowspan: itemSpanNum.rowspan - 1
|
22390
|
+
};
|
22391
|
+
}
|
22392
|
+
}
|
22393
|
+
}
|
22394
|
+
});
|
22395
|
+
row.toEmpty();
|
21972
22396
|
if (previousRow) {
|
21973
|
-
editor.value.range.anchor.moveToEnd(previousRow.children[
|
21974
|
-
editor.value.range.focus.moveToEnd(previousRow.children[
|
22397
|
+
editor.value.range.anchor.moveToEnd(previousRow.children[index]);
|
22398
|
+
editor.value.range.focus.moveToEnd(previousRow.children[index]);
|
21975
22399
|
} else {
|
21976
|
-
editor.value.range.anchor.moveToEnd(nextRow.children[
|
21977
|
-
editor.value.range.focus.moveToEnd(nextRow.children[
|
22400
|
+
editor.value.range.anchor.moveToEnd(nextRow.children[index]);
|
22401
|
+
editor.value.range.focus.moveToEnd(nextRow.children[index]);
|
21978
22402
|
}
|
22403
|
+
editor.value.formatElementStack();
|
21979
22404
|
editor.value.domRender();
|
21980
22405
|
editor.value.rangeRender();
|
21981
22406
|
setTimeout(() => {
|
@@ -21989,28 +22414,50 @@ const _sfc_main$8 = /* @__PURE__ */ defineComponent({
|
|
21989
22414
|
editor.value.range.anchor.offset = editor.value.range.focus.offset;
|
21990
22415
|
}
|
21991
22416
|
const columns = getMatchElementsByRange(editor.value, dataRangeCaches.value, { parsedom: "td" });
|
21992
|
-
|
21993
|
-
|
21994
|
-
|
21995
|
-
const
|
21996
|
-
|
21997
|
-
if (parent.children.length == 1) {
|
22417
|
+
if (columns.length == 1) {
|
22418
|
+
const row = columns[0].parent;
|
22419
|
+
const rows = row.parent.children;
|
22420
|
+
const table = row.parent.parent;
|
22421
|
+
if (row.children.length == 1) {
|
21998
22422
|
deleteElement("table");
|
21999
22423
|
return;
|
22000
22424
|
}
|
22001
|
-
const
|
22002
|
-
const nextColumn = editor.value.getNextElement(columns[0]);
|
22003
|
-
const index = columns[0].parent.children.findIndex((item) => {
|
22425
|
+
const index = row.children.findIndex((item) => {
|
22004
22426
|
return item.isEqual(columns[0]);
|
22005
22427
|
});
|
22006
|
-
|
22007
|
-
|
22428
|
+
const previousColumn = editor.value.getPreviousElement(columns[0]);
|
22429
|
+
const nextColumn = editor.value.getNextElement(columns[0]);
|
22430
|
+
rows.forEach((item) => {
|
22431
|
+
const cell = item.children[index];
|
22432
|
+
const cellSpanNum = getCellSpanNumber(cell);
|
22433
|
+
if (cell.hasMarks() && cell.marks["data-editify-merged"]) {
|
22434
|
+
const { crossColumnElement } = getCellMergeElement(editor.value, cell);
|
22435
|
+
if (crossColumnElement) {
|
22436
|
+
const { colspan } = getCellSpanNumber(crossColumnElement);
|
22437
|
+
if (colspan - 1 == 1) {
|
22438
|
+
delete crossColumnElement.marks["colspan"];
|
22439
|
+
} else {
|
22440
|
+
crossColumnElement.marks["colspan"] = colspan - 1;
|
22441
|
+
}
|
22442
|
+
}
|
22443
|
+
} else if (cellSpanNum.colspan > 1) {
|
22444
|
+
let el = editor.value.getNextElement(cell);
|
22445
|
+
if (el && cellSpanNum.colspan - 1 > 1) {
|
22446
|
+
if (el.hasMarks()) {
|
22447
|
+
el.marks["colspan"] = cellSpanNum.colspan - 1;
|
22448
|
+
} else {
|
22449
|
+
el.marks = {
|
22450
|
+
colspan: cellSpanNum.colspan - 1
|
22451
|
+
};
|
22452
|
+
}
|
22453
|
+
}
|
22454
|
+
}
|
22455
|
+
cell.toEmpty();
|
22008
22456
|
});
|
22009
|
-
const colgroup =
|
22457
|
+
const colgroup = table.children.find((item) => {
|
22010
22458
|
return item.parsedom == "colgroup";
|
22011
22459
|
});
|
22012
22460
|
colgroup.children[index].toEmpty();
|
22013
|
-
editor.value.formatElementStack();
|
22014
22461
|
if (previousColumn) {
|
22015
22462
|
editor.value.range.anchor.moveToEnd(previousColumn);
|
22016
22463
|
editor.value.range.focus.moveToEnd(previousColumn);
|
@@ -22018,10 +22465,188 @@ const _sfc_main$8 = /* @__PURE__ */ defineComponent({
|
|
22018
22465
|
editor.value.range.anchor.moveToEnd(nextColumn);
|
22019
22466
|
editor.value.range.focus.moveToEnd(nextColumn);
|
22020
22467
|
}
|
22468
|
+
editor.value.formatElementStack();
|
22021
22469
|
editor.value.domRender();
|
22022
22470
|
editor.value.rangeRender();
|
22023
22471
|
}
|
22024
22472
|
};
|
22473
|
+
const mergeCells = (type) => {
|
22474
|
+
if (!canMergeCells.value(type)) {
|
22475
|
+
return;
|
22476
|
+
}
|
22477
|
+
if (!editor.value.range.anchor.isEqual(editor.value.range.focus)) {
|
22478
|
+
editor.value.range.anchor.element = editor.value.range.focus.element;
|
22479
|
+
editor.value.range.anchor.offset = editor.value.range.focus.offset;
|
22480
|
+
}
|
22481
|
+
const columns = getMatchElementsByRange(editor.value, dataRangeCaches.value, { parsedom: "td" });
|
22482
|
+
if (columns.length == 1) {
|
22483
|
+
if (type == "left") {
|
22484
|
+
const cellSpanNum = getCellSpanNumber(columns[0]);
|
22485
|
+
const previousColumn = editor.value.getPreviousElement(columns[0]);
|
22486
|
+
if (previousColumn) {
|
22487
|
+
if (previousColumn.hasMarks() && previousColumn.marks["data-editify-merged"]) {
|
22488
|
+
const { crossColumnElement } = getCellMergeElement(editor.value, previousColumn);
|
22489
|
+
if (crossColumnElement) {
|
22490
|
+
const { rowspan, colspan } = getCellSpanNumber(crossColumnElement);
|
22491
|
+
if (rowspan == cellSpanNum.rowspan) {
|
22492
|
+
crossColumnElement.marks["colspan"] = colspan + cellSpanNum.colspan;
|
22493
|
+
columns[0].children.forEach((item) => {
|
22494
|
+
crossColumnElement.children.push(item);
|
22495
|
+
item.parent = crossColumnElement;
|
22496
|
+
});
|
22497
|
+
setTableCellMerged(columns[0]);
|
22498
|
+
editor.value.range.anchor.moveToEnd(crossColumnElement);
|
22499
|
+
editor.value.range.focus.moveToEnd(crossColumnElement);
|
22500
|
+
editor.value.formatElementStack();
|
22501
|
+
editor.value.domRender();
|
22502
|
+
editor.value.rangeRender();
|
22503
|
+
}
|
22504
|
+
}
|
22505
|
+
} else {
|
22506
|
+
const { rowspan, colspan } = getCellSpanNumber(previousColumn);
|
22507
|
+
if (rowspan == cellSpanNum.rowspan) {
|
22508
|
+
if (previousColumn.hasMarks()) {
|
22509
|
+
previousColumn.marks["colspan"] = colspan + cellSpanNum.colspan;
|
22510
|
+
} else {
|
22511
|
+
previousColumn.marks = {
|
22512
|
+
colspan: colspan + cellSpanNum.colspan
|
22513
|
+
};
|
22514
|
+
}
|
22515
|
+
columns[0].children.forEach((item) => {
|
22516
|
+
previousColumn.children.push(item);
|
22517
|
+
item.parent = previousColumn;
|
22518
|
+
});
|
22519
|
+
setTableCellMerged(columns[0]);
|
22520
|
+
editor.value.range.anchor.moveToEnd(previousColumn);
|
22521
|
+
editor.value.range.focus.moveToEnd(previousColumn);
|
22522
|
+
editor.value.formatElementStack();
|
22523
|
+
editor.value.domRender();
|
22524
|
+
editor.value.rangeRender();
|
22525
|
+
}
|
22526
|
+
}
|
22527
|
+
}
|
22528
|
+
} else if (type == "right") {
|
22529
|
+
const cellSpanNum = getCellSpanNumber(columns[0]);
|
22530
|
+
let nextColumn = editor.value.getNextElement(columns[0]);
|
22531
|
+
while (nextColumn) {
|
22532
|
+
if (nextColumn.hasMarks() && nextColumn.marks["data-editify-merged"]) {
|
22533
|
+
const { crossColumnElement } = getCellMergeElement(editor.value, nextColumn);
|
22534
|
+
if (crossColumnElement) {
|
22535
|
+
nextColumn = editor.value.getNextElement(nextColumn);
|
22536
|
+
} else {
|
22537
|
+
break;
|
22538
|
+
}
|
22539
|
+
} else {
|
22540
|
+
const { rowspan, colspan } = getCellSpanNumber(nextColumn);
|
22541
|
+
if (rowspan == cellSpanNum.rowspan) {
|
22542
|
+
if (columns[0].hasMarks()) {
|
22543
|
+
columns[0].marks["colspan"] = cellSpanNum.colspan + colspan;
|
22544
|
+
} else {
|
22545
|
+
columns[0].marks = {
|
22546
|
+
colspan: cellSpanNum.colspan + colspan
|
22547
|
+
};
|
22548
|
+
}
|
22549
|
+
nextColumn.children.forEach((item) => {
|
22550
|
+
columns[0].children.push(item);
|
22551
|
+
item.parent = columns[0];
|
22552
|
+
});
|
22553
|
+
setTableCellMerged(nextColumn);
|
22554
|
+
editor.value.range.anchor.moveToEnd(columns[0]);
|
22555
|
+
editor.value.range.focus.moveToEnd(columns[0]);
|
22556
|
+
editor.value.formatElementStack();
|
22557
|
+
editor.value.domRender();
|
22558
|
+
editor.value.rangeRender();
|
22559
|
+
}
|
22560
|
+
break;
|
22561
|
+
}
|
22562
|
+
}
|
22563
|
+
} else if (type == "up") {
|
22564
|
+
const cellSpanNum = getCellSpanNumber(columns[0]);
|
22565
|
+
const index = columns[0].parent.children.findIndex((item) => item.isEqual(columns[0]));
|
22566
|
+
const previousRow = editor.value.getPreviousElement(columns[0].parent);
|
22567
|
+
if (previousRow) {
|
22568
|
+
const previousColumn = previousRow.children[index];
|
22569
|
+
if (previousColumn.hasMarks() && previousColumn.marks["data-editify-merged"]) {
|
22570
|
+
const { crossRowElement } = getCellMergeElement(editor.value, previousColumn);
|
22571
|
+
if (crossRowElement) {
|
22572
|
+
const { rowspan, colspan } = getCellSpanNumber(crossRowElement);
|
22573
|
+
if (colspan == cellSpanNum.colspan) {
|
22574
|
+
crossRowElement.marks["rowspan"] = rowspan + cellSpanNum.rowspan;
|
22575
|
+
columns[0].children.forEach((item) => {
|
22576
|
+
crossRowElement.children.push(item);
|
22577
|
+
item.parent = crossRowElement;
|
22578
|
+
});
|
22579
|
+
setTableCellMerged(columns[0]);
|
22580
|
+
editor.value.range.anchor.moveToEnd(crossRowElement);
|
22581
|
+
editor.value.range.focus.moveToEnd(crossRowElement);
|
22582
|
+
editor.value.formatElementStack();
|
22583
|
+
editor.value.domRender();
|
22584
|
+
editor.value.rangeRender();
|
22585
|
+
}
|
22586
|
+
}
|
22587
|
+
} else {
|
22588
|
+
const { rowspan, colspan } = getCellSpanNumber(previousColumn);
|
22589
|
+
if (colspan == cellSpanNum.colspan) {
|
22590
|
+
if (previousColumn.hasMarks()) {
|
22591
|
+
previousColumn.marks["rowspan"] = rowspan + cellSpanNum.rowspan;
|
22592
|
+
} else {
|
22593
|
+
previousColumn.marks = {
|
22594
|
+
rowspan: rowspan + cellSpanNum.rowspan
|
22595
|
+
};
|
22596
|
+
}
|
22597
|
+
columns[0].children.forEach((item) => {
|
22598
|
+
previousColumn.children.push(item);
|
22599
|
+
item.parent = previousColumn;
|
22600
|
+
});
|
22601
|
+
setTableCellMerged(columns[0]);
|
22602
|
+
editor.value.range.anchor.moveToEnd(previousColumn);
|
22603
|
+
editor.value.range.focus.moveToEnd(previousColumn);
|
22604
|
+
editor.value.formatElementStack();
|
22605
|
+
editor.value.domRender();
|
22606
|
+
editor.value.rangeRender();
|
22607
|
+
}
|
22608
|
+
}
|
22609
|
+
}
|
22610
|
+
} else if (type == "down") {
|
22611
|
+
const cellSpanNum = getCellSpanNumber(columns[0]);
|
22612
|
+
const index = columns[0].parent.children.findIndex((item) => item.isEqual(columns[0]));
|
22613
|
+
let nextRow = editor.value.getNextElement(columns[0].parent);
|
22614
|
+
while (nextRow) {
|
22615
|
+
const nextColumn = nextRow.children[index];
|
22616
|
+
if (nextColumn.hasMarks() && nextColumn.marks["data-editify-merged"]) {
|
22617
|
+
const { crossRowElement } = getCellMergeElement(editor.value, nextColumn);
|
22618
|
+
if (crossRowElement) {
|
22619
|
+
nextRow = editor.value.getNextElement(nextRow);
|
22620
|
+
} else {
|
22621
|
+
break;
|
22622
|
+
}
|
22623
|
+
} else {
|
22624
|
+
const { rowspan, colspan } = getCellSpanNumber(nextColumn);
|
22625
|
+
if (colspan == cellSpanNum.colspan) {
|
22626
|
+
if (columns[0].hasMarks()) {
|
22627
|
+
columns[0].marks["rowspan"] = cellSpanNum.rowspan + rowspan;
|
22628
|
+
} else {
|
22629
|
+
columns[0].marks = {
|
22630
|
+
rowspan: cellSpanNum.rowspan + rowspan
|
22631
|
+
};
|
22632
|
+
}
|
22633
|
+
nextColumn.children.forEach((item) => {
|
22634
|
+
columns[0].children.push(item);
|
22635
|
+
item.parent = columns[0];
|
22636
|
+
});
|
22637
|
+
setTableCellMerged(nextColumn);
|
22638
|
+
editor.value.range.anchor.moveToEnd(columns[0]);
|
22639
|
+
editor.value.range.focus.moveToEnd(columns[0]);
|
22640
|
+
editor.value.formatElementStack();
|
22641
|
+
editor.value.domRender();
|
22642
|
+
editor.value.rangeRender();
|
22643
|
+
}
|
22644
|
+
break;
|
22645
|
+
}
|
22646
|
+
}
|
22647
|
+
}
|
22648
|
+
}
|
22649
|
+
};
|
22025
22650
|
const layerShow = () => {
|
22026
22651
|
if (props.type == "link") {
|
22027
22652
|
const links = getMatchElementsByRange(editor.value, dataRangeCaches.value, { parsedom: "a" });
|
@@ -22143,7 +22768,7 @@ const _sfc_main$8 = /* @__PURE__ */ defineComponent({
|
|
22143
22768
|
return (_ctx, _cache) => {
|
22144
22769
|
return openBlock(), createBlock(Layer, {
|
22145
22770
|
modelValue: show.value,
|
22146
|
-
"onUpdate:modelValue": _cache[
|
22771
|
+
"onUpdate:modelValue": _cache[25] || (_cache[25] = ($event) => show.value = $event),
|
22147
22772
|
ref_key: "layerRef",
|
22148
22773
|
ref: layerRef,
|
22149
22774
|
node: _ctx.node,
|
@@ -22478,7 +23103,63 @@ const _sfc_main$8 = /* @__PURE__ */ defineComponent({
|
|
22478
23103
|
_: 1
|
22479
23104
|
}, 8, ["title", "tooltip", "color"]),
|
22480
23105
|
createVNode(Button, {
|
22481
|
-
|
23106
|
+
disabled: !canMergeCells.value("left"),
|
23107
|
+
onOperate: _cache[18] || (_cache[18] = ($event) => mergeCells("left")),
|
23108
|
+
rightBorder: "",
|
23109
|
+
name: "mergeCellsLeft",
|
23110
|
+
title: unref($editTrans)("mergeCellsLeft"),
|
23111
|
+
tooltip: _ctx.config.tooltip,
|
23112
|
+
color: _ctx.color
|
23113
|
+
}, {
|
23114
|
+
default: withCtx(() => [
|
23115
|
+
createVNode(Icon, { value: "merge-cells-left" })
|
23116
|
+
]),
|
23117
|
+
_: 1
|
23118
|
+
}, 8, ["disabled", "title", "tooltip", "color"]),
|
23119
|
+
createVNode(Button, {
|
23120
|
+
disabled: !canMergeCells.value("right"),
|
23121
|
+
onOperate: _cache[19] || (_cache[19] = ($event) => mergeCells("right")),
|
23122
|
+
rightBorder: "",
|
23123
|
+
name: "mergeCellsRight",
|
23124
|
+
title: unref($editTrans)("mergeCellsRight"),
|
23125
|
+
tooltip: _ctx.config.tooltip,
|
23126
|
+
color: _ctx.color
|
23127
|
+
}, {
|
23128
|
+
default: withCtx(() => [
|
23129
|
+
createVNode(Icon, { value: "merge-cells-right" })
|
23130
|
+
]),
|
23131
|
+
_: 1
|
23132
|
+
}, 8, ["disabled", "title", "tooltip", "color"]),
|
23133
|
+
createVNode(Button, {
|
23134
|
+
disabled: !canMergeCells.value("up"),
|
23135
|
+
onOperate: _cache[20] || (_cache[20] = ($event) => mergeCells("up")),
|
23136
|
+
rightBorder: "",
|
23137
|
+
name: "mergeCellsUp",
|
23138
|
+
title: unref($editTrans)("mergeCellsUp"),
|
23139
|
+
tooltip: _ctx.config.tooltip,
|
23140
|
+
color: _ctx.color
|
23141
|
+
}, {
|
23142
|
+
default: withCtx(() => [
|
23143
|
+
createVNode(Icon, { value: "merge-cells-up" })
|
23144
|
+
]),
|
23145
|
+
_: 1
|
23146
|
+
}, 8, ["disabled", "title", "tooltip", "color"]),
|
23147
|
+
createVNode(Button, {
|
23148
|
+
disabled: !canMergeCells.value("down"),
|
23149
|
+
onOperate: _cache[21] || (_cache[21] = ($event) => mergeCells("down")),
|
23150
|
+
rightBorder: "",
|
23151
|
+
name: "mergeCellsDown",
|
23152
|
+
title: unref($editTrans)("mergeCellsDown"),
|
23153
|
+
tooltip: _ctx.config.tooltip,
|
23154
|
+
color: _ctx.color
|
23155
|
+
}, {
|
23156
|
+
default: withCtx(() => [
|
23157
|
+
createVNode(Icon, { value: "merge-cells-down" })
|
23158
|
+
]),
|
23159
|
+
_: 1
|
23160
|
+
}, 8, ["disabled", "title", "tooltip", "color"]),
|
23161
|
+
createVNode(Button, {
|
23162
|
+
onOperate: _cache[22] || (_cache[22] = ($event) => deleteElement("table")),
|
22482
23163
|
leftBorder: "",
|
22483
23164
|
name: "deleteTable",
|
22484
23165
|
title: unref($editTrans)("deleteTable"),
|
@@ -22493,7 +23174,7 @@ const _sfc_main$8 = /* @__PURE__ */ defineComponent({
|
|
22493
23174
|
], 64)) : createCommentVNode("", true),
|
22494
23175
|
_ctx.type == "codeBlock" ? (openBlock(), createElementBlock(Fragment, { key: 4 }, [
|
22495
23176
|
createVNode(Button, {
|
22496
|
-
onOperate: _cache[
|
23177
|
+
onOperate: _cache[23] || (_cache[23] = ($event) => insertParagraphWithPre("up")),
|
22497
23178
|
name: "textWrapUp",
|
22498
23179
|
title: unref($editTrans)("textWrapUp"),
|
22499
23180
|
tooltip: _ctx.config.tooltip,
|
@@ -22508,7 +23189,7 @@ const _sfc_main$8 = /* @__PURE__ */ defineComponent({
|
|
22508
23189
|
_: 1
|
22509
23190
|
}, 8, ["title", "tooltip", "color"]),
|
22510
23191
|
createVNode(Button, {
|
22511
|
-
onOperate: _cache[
|
23192
|
+
onOperate: _cache[24] || (_cache[24] = ($event) => insertParagraphWithPre("down")),
|
22512
23193
|
name: "textWrapDown",
|
22513
23194
|
title: unref($editTrans)("textWrapDown"),
|
22514
23195
|
tooltip: _ctx.config.tooltip,
|
@@ -22864,7 +23545,7 @@ const _sfc_main$8 = /* @__PURE__ */ defineComponent({
|
|
22864
23545
|
};
|
22865
23546
|
}
|
22866
23547
|
});
|
22867
|
-
const Toolbar = /* @__PURE__ */ _export_sfc(_sfc_main$8, [["__scopeId", "data-v-
|
23548
|
+
const Toolbar = /* @__PURE__ */ _export_sfc(_sfc_main$8, [["__scopeId", "data-v-c1aa741f"]]);
|
22868
23549
|
const InsertLinkProps = {
|
22869
23550
|
//主题色
|
22870
23551
|
color: {
|
@@ -25058,6 +25739,10 @@ const en_US = {
|
|
25058
25739
|
insertColumnRight: "Insert column backward",
|
25059
25740
|
deleteRow: "Delete rows",
|
25060
25741
|
deleteColumn: "Delete column",
|
25742
|
+
mergeCellsLeft: "Merge cells to the left",
|
25743
|
+
mergeCellsRight: "Merge cells to the right",
|
25744
|
+
mergeCellsUp: "Merge cells up",
|
25745
|
+
mergeCellsDown: "Merge cells down",
|
25061
25746
|
deleteTable: "Delete table",
|
25062
25747
|
selectLanguages: "Select language",
|
25063
25748
|
autoRecognize: "Auto",
|
@@ -25158,6 +25843,10 @@ const zh_CN = {
|
|
25158
25843
|
insertColumnRight: "向后插入列",
|
25159
25844
|
deleteRow: "删除行",
|
25160
25845
|
deleteColumn: "删除列",
|
25846
|
+
mergeCellsLeft: "向左合并单元格",
|
25847
|
+
mergeCellsRight: "向右合并单元格",
|
25848
|
+
mergeCellsUp: "向上合并单元格",
|
25849
|
+
mergeCellsDown: "向下合并单元格",
|
25161
25850
|
deleteTable: "删除表格",
|
25162
25851
|
selectLanguages: "选择语言",
|
25163
25852
|
autoRecognize: "自动识别",
|
@@ -25273,7 +25962,7 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
|
|
25273
25962
|
const isModelChange = ref(false);
|
25274
25963
|
const isInputChinese = ref(false);
|
25275
25964
|
const rangeUpdateTimer = ref(null);
|
25276
|
-
const
|
25965
|
+
const resizeParams = ref({
|
25277
25966
|
element: null,
|
25278
25967
|
//被拖拽的td
|
25279
25968
|
start: 0
|
@@ -25470,7 +26159,13 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
|
|
25470
26159
|
commonElementHandle(editor.value, el);
|
25471
26160
|
},
|
25472
26161
|
(el) => {
|
25473
|
-
|
26162
|
+
tableThTdHandle(editor.value, el);
|
26163
|
+
},
|
26164
|
+
(el) => {
|
26165
|
+
tableFormatHandle(editor.value, el);
|
26166
|
+
},
|
26167
|
+
(el) => {
|
26168
|
+
tableRangeMergedHandle(editor.value, el);
|
25474
26169
|
},
|
25475
26170
|
(el) => {
|
25476
26171
|
var _a, _b, _c, _d, _e, _f, _g;
|
@@ -25521,25 +26216,34 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
|
|
25521
26216
|
if (props.disabled) {
|
25522
26217
|
return;
|
25523
26218
|
}
|
25524
|
-
|
25525
|
-
|
26219
|
+
const elm = e.target;
|
26220
|
+
const event2 = e;
|
26221
|
+
if (element.isContains(contentRef.value, elm)) {
|
25526
26222
|
const key = data.get(elm, "data-alex-editor-key");
|
25527
26223
|
if (key) {
|
25528
26224
|
const element$12 = editor.value.getElementByKey(key);
|
25529
|
-
if (element$12
|
25530
|
-
|
25531
|
-
|
25532
|
-
|
25533
|
-
|
25534
|
-
|
25535
|
-
|
25536
|
-
|
25537
|
-
|
26225
|
+
if (element$12) {
|
26226
|
+
if (element$12.parsedom == "td") {
|
26227
|
+
const length = element$12.parent.children.length;
|
26228
|
+
if (element$12.parent.children[length - 1].isEqual(element$12)) {
|
26229
|
+
return;
|
26230
|
+
}
|
26231
|
+
const rect = element.getElementBounding(elm);
|
26232
|
+
if (event2.pageX >= Math.abs(rect.left + elm.offsetWidth - 5) && event2.pageX <= Math.abs(rect.left + elm.offsetWidth + 5)) {
|
26233
|
+
resizeParams.value.element = element$12;
|
26234
|
+
resizeParams.value.start = event2.pageX;
|
26235
|
+
}
|
26236
|
+
} else if (["img", "video"].includes(element$12.parsedom)) {
|
26237
|
+
const rect = element.getElementBounding(elm);
|
26238
|
+
if (event2.pageX >= Math.abs(rect.left + elm.offsetWidth - 10) && event2.pageX <= Math.abs(rect.left + elm.offsetWidth) || event2.pageX >= Math.abs(rect.left) && event2.pageX <= Math.abs(rect.left + 10)) {
|
26239
|
+
resizeParams.value.element = element$12;
|
26240
|
+
resizeParams.value.start = event2.pageX;
|
26241
|
+
}
|
25538
26242
|
}
|
25539
26243
|
}
|
25540
26244
|
}
|
25541
26245
|
}
|
25542
|
-
if (!element.isContains(elRef.value,
|
26246
|
+
if (!element.isContains(elRef.value, elm) && !isSourceView.value) {
|
25543
26247
|
canUseMenu.value = false;
|
25544
26248
|
}
|
25545
26249
|
};
|
@@ -25547,63 +26251,99 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
|
|
25547
26251
|
if (props.disabled) {
|
25548
26252
|
return;
|
25549
26253
|
}
|
25550
|
-
if (!
|
26254
|
+
if (!resizeParams.value.element) {
|
25551
26255
|
return;
|
25552
26256
|
}
|
25553
|
-
const
|
25554
|
-
if (
|
25555
|
-
|
26257
|
+
const event2 = e;
|
26258
|
+
if (resizeParams.value.element.parsedom == "td") {
|
26259
|
+
const tables = getMatchElementsByRange(editor.value, dataRangeCaches.value, { parsedom: "table" });
|
26260
|
+
if (tables.length != 1) {
|
26261
|
+
return;
|
26262
|
+
}
|
26263
|
+
const colgroup = tables[0].children.find((item) => {
|
26264
|
+
return item.parsedom == "colgroup";
|
26265
|
+
});
|
26266
|
+
const index = resizeParams.value.element.parent.children.findIndex((el) => {
|
26267
|
+
return el.isEqual(resizeParams.value.element);
|
26268
|
+
});
|
26269
|
+
const width = `${resizeParams.value.element.elm.offsetWidth + event2.pageX - resizeParams.value.start}`;
|
26270
|
+
colgroup.children[index].marks["width"] = width;
|
26271
|
+
colgroup.children[index].elm.setAttribute("width", width);
|
26272
|
+
resizeParams.value.start = event2.pageX;
|
26273
|
+
} else if (["img", "video"].includes(resizeParams.value.element.parsedom)) {
|
26274
|
+
const width = `${resizeParams.value.element.elm.offsetWidth + event2.pageX - resizeParams.value.start}px`;
|
26275
|
+
if (resizeParams.value.element.hasStyles()) {
|
26276
|
+
resizeParams.value.element.styles["width"] = width;
|
26277
|
+
} else {
|
26278
|
+
resizeParams.value.element.styles = {
|
26279
|
+
width
|
26280
|
+
};
|
26281
|
+
}
|
26282
|
+
resizeParams.value.element.elm.style.width = width;
|
26283
|
+
if (resizeParams.value.element.parsedom == "video") {
|
26284
|
+
setVideoHeight();
|
26285
|
+
}
|
26286
|
+
resizeParams.value.start = event2.pageX;
|
25556
26287
|
}
|
25557
|
-
const colgroup = tables[0].children.find((item) => {
|
25558
|
-
return item.parsedom == "colgroup";
|
25559
|
-
});
|
25560
|
-
const index = tableColumnResizeParams.value.element.parent.children.findIndex((el) => {
|
25561
|
-
return el.isEqual(tableColumnResizeParams.value.element);
|
25562
|
-
});
|
25563
|
-
const width = `${tableColumnResizeParams.value.element.elm.offsetWidth + e.pageX - tableColumnResizeParams.value.start}`;
|
25564
|
-
colgroup.children[index].marks["width"] = width;
|
25565
|
-
colgroup.children[index].elm.setAttribute("width", width);
|
25566
|
-
tableColumnResizeParams.value.start = e.pageX;
|
25567
26288
|
};
|
25568
26289
|
const documentMouseUp = () => {
|
25569
26290
|
if (props.disabled) {
|
25570
26291
|
return;
|
25571
26292
|
}
|
25572
|
-
if (!
|
25573
|
-
return;
|
25574
|
-
}
|
25575
|
-
const tables = getMatchElementsByRange(editor.value, dataRangeCaches.value, { parsedom: "table" });
|
25576
|
-
if (tables.length != 1) {
|
26293
|
+
if (!resizeParams.value.element) {
|
25577
26294
|
return;
|
25578
26295
|
}
|
25579
|
-
|
25580
|
-
|
25581
|
-
|
25582
|
-
|
25583
|
-
|
25584
|
-
|
25585
|
-
|
25586
|
-
|
25587
|
-
|
25588
|
-
|
25589
|
-
|
25590
|
-
|
26296
|
+
if (resizeParams.value.element.parsedom == "td") {
|
26297
|
+
const tables = getMatchElementsByRange(editor.value, dataRangeCaches.value, { parsedom: "table" });
|
26298
|
+
if (tables.length != 1) {
|
26299
|
+
return;
|
26300
|
+
}
|
26301
|
+
const colgroup = tables[0].children.find((item) => {
|
26302
|
+
return item.parsedom == "colgroup";
|
26303
|
+
});
|
26304
|
+
const index = resizeParams.value.element.parent.children.findIndex((el) => {
|
26305
|
+
return el.isEqual(resizeParams.value.element);
|
26306
|
+
});
|
26307
|
+
const width = parseFloat(colgroup.children[index].marks["width"]);
|
26308
|
+
if (!isNaN(width)) {
|
26309
|
+
colgroup.children[index].marks["width"] = `${Number((width / resizeParams.value.element.parent.elm.offsetWidth * 100).toFixed(2))}%`;
|
26310
|
+
editor.value.formatElementStack();
|
26311
|
+
editor.value.domRender();
|
26312
|
+
editor.value.rangeRender();
|
26313
|
+
}
|
26314
|
+
resizeParams.value.element = null;
|
26315
|
+
resizeParams.value.start = 0;
|
26316
|
+
} else if (["img", "video"].includes(resizeParams.value.element.parsedom)) {
|
26317
|
+
const width = parseFloat(resizeParams.value.element.styles["width"]);
|
26318
|
+
if (!isNaN(width)) {
|
26319
|
+
if (resizeParams.value.element.hasStyles()) {
|
26320
|
+
resizeParams.value.element.styles["width"] = `${Number((width / element.width(contentRef.value) * 100).toFixed(2))}%`;
|
26321
|
+
} else {
|
26322
|
+
resizeParams.value.element.styles = {
|
26323
|
+
width: `${Number((width / element.width(contentRef.value) * 100).toFixed(2))}%`
|
26324
|
+
};
|
26325
|
+
}
|
26326
|
+
editor.value.formatElementStack();
|
26327
|
+
editor.value.domRender();
|
26328
|
+
editor.value.rangeRender();
|
26329
|
+
}
|
26330
|
+
resizeParams.value.element = null;
|
26331
|
+
resizeParams.value.start = 0;
|
25591
26332
|
}
|
25592
|
-
tableColumnResizeParams.value.element = null;
|
25593
|
-
tableColumnResizeParams.value.start = 0;
|
25594
26333
|
};
|
25595
26334
|
const documentClick = (e) => {
|
25596
26335
|
if (props.disabled) {
|
25597
26336
|
return;
|
25598
26337
|
}
|
25599
|
-
|
25600
|
-
|
26338
|
+
const elm = e.target;
|
26339
|
+
const event2 = e;
|
26340
|
+
if (element.isContains(contentRef.value, elm)) {
|
25601
26341
|
const key = data.get(elm, "data-alex-editor-key");
|
25602
26342
|
if (key) {
|
25603
26343
|
const element$12 = editor.value.getElementByKey(key);
|
25604
26344
|
if (isTask(element$12)) {
|
25605
26345
|
const rect = element.getElementBounding(elm);
|
25606
|
-
if (
|
26346
|
+
if (event2.pageX >= Math.abs(rect.left) && event2.pageX <= Math.abs(rect.left + 16) && event2.pageY >= Math.abs(rect.top + elm.offsetHeight / 2 - 8) && event2.pageY <= Math.abs(rect.top + elm.offsetHeight / 2 + 8)) {
|
25607
26347
|
if (element$12.marks["data-editify-task"] == "checked") {
|
25608
26348
|
element$12.marks["data-editify-task"] = "uncheck";
|
25609
26349
|
} else {
|
@@ -25637,6 +26377,9 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
|
|
25637
26377
|
if (el.marks["disabled"]) {
|
25638
26378
|
marks["disabled"] = el.marks["disabled"];
|
25639
26379
|
}
|
26380
|
+
if (el.parsedom == "img" && el.marks["alt"]) {
|
26381
|
+
marks["alt"] = el.marks["alt"];
|
26382
|
+
}
|
25640
26383
|
if (["img", "video"].includes(el.parsedom) && el.marks["src"]) {
|
25641
26384
|
marks["src"] = el.marks["src"];
|
25642
26385
|
}
|
@@ -25670,8 +26413,23 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
|
|
25670
26413
|
if (el.parsedom == "div" && el.marks["data-editify-task"]) {
|
25671
26414
|
marks["data-editify-task"] = el.marks["data-editify-task"];
|
25672
26415
|
}
|
26416
|
+
if (el.parsedom == "col" && el.marks["width"]) {
|
26417
|
+
marks["width"] = el.marks["width"];
|
26418
|
+
}
|
26419
|
+
if (["td", "th"].includes(el.parsedom) && el.marks["colspan"]) {
|
26420
|
+
marks["colspan"] = el.marks["colspan"];
|
26421
|
+
}
|
26422
|
+
if (["td", "th"].includes(el.parsedom) && el.marks["rowspan"]) {
|
26423
|
+
marks["rowspan"] = el.marks["rowspan"];
|
26424
|
+
}
|
26425
|
+
if (["td", "th"].includes(el.parsedom) && el.marks["data-editify-merged"]) {
|
26426
|
+
marks["data-editify-merged"] = el.marks["data-editify-merged"];
|
26427
|
+
}
|
25673
26428
|
}
|
25674
26429
|
if (el.hasStyles()) {
|
26430
|
+
if (["img", "video"].includes(el.parsedom) && el.styles["width"]) {
|
26431
|
+
styles2["width"] = el.styles["width"];
|
26432
|
+
}
|
25675
26433
|
if ((el.isBlock() || el.isInblock()) && el.styles["text-indent"]) {
|
25676
26434
|
styles2["text-indent"] = el.styles["text-indent"];
|
25677
26435
|
}
|
@@ -25760,9 +26518,9 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
|
|
25760
26518
|
if (props.disabled || isSourceView.value) {
|
25761
26519
|
return;
|
25762
26520
|
}
|
25763
|
-
const
|
25764
|
-
if (
|
25765
|
-
const key = Number(
|
26521
|
+
const elm = e.target;
|
26522
|
+
if (elm.nodeName.toLocaleLowerCase() == "img" || elm.nodeName.toLocaleLowerCase() == "video") {
|
26523
|
+
const key = Number(elm.getAttribute("data-editify-element"));
|
25766
26524
|
if (number.isNumber(key)) {
|
25767
26525
|
const element2 = editor.value.getElementByKey(key);
|
25768
26526
|
if (!editor.value.range) {
|
@@ -26061,7 +26819,7 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
|
|
26061
26819
|
};
|
26062
26820
|
}
|
26063
26821
|
});
|
26064
|
-
const Editify = /* @__PURE__ */ _export_sfc(_sfc_main$2, [["__scopeId", "data-v-
|
26822
|
+
const Editify = /* @__PURE__ */ _export_sfc(_sfc_main$2, [["__scopeId", "data-v-ee554bc1"]]);
|
26065
26823
|
const InsertAttachmentProps = {
|
26066
26824
|
//主题色
|
26067
26825
|
color: {
|
@@ -41185,7 +41943,7 @@ const attachment = (options) => {
|
|
41185
41943
|
const install = (app) => {
|
41186
41944
|
app.component(Editify.name, Editify);
|
41187
41945
|
};
|
41188
|
-
const version = "0.1.
|
41946
|
+
const version = "0.1.45";
|
41189
41947
|
console.log(`%c vue-editify %c v${version} `, "padding: 2px 1px; border-radius: 3px 0 0 3px; color: #fff; background: #606060; font-weight: bold;", "padding: 2px 1px; border-radius: 0 3px 3px 0; color: #fff; background: #42c02e; font-weight: bold;");
|
41190
41948
|
export {
|
41191
41949
|
AlexElement,
|
@@ -41213,6 +41971,7 @@ export {
|
|
41213
41971
|
insertCodeBlock,
|
41214
41972
|
insertImage,
|
41215
41973
|
insertLink,
|
41974
|
+
insertSeparator,
|
41216
41975
|
insertTable,
|
41217
41976
|
insertVideo,
|
41218
41977
|
install,
|