vue-editify 0.0.46 → 0.0.48
Sign up to get free protection for your applications and to get access to all the features.
- package/examples/App.vue +3 -13
- package/lib/editify.es.js +377 -353
- package/lib/editify.umd.js +1 -1
- package/lib/style.css +1 -1
- package/package.json +2 -2
- package/src/Editify.vue +151 -143
- package/src/components/bussiness/Menu.vue +14 -14
- package/src/components/bussiness/Toolbar.vue +46 -48
- package/src/index.js +1 -1
package/lib/editify.es.js
CHANGED
@@ -1722,7 +1722,7 @@ const speech$1 = {
|
|
1722
1722
|
}
|
1723
1723
|
};
|
1724
1724
|
const obj$1 = { number: number$1, data: data$1, element: element$1, event: event$1, common: common$1, color: color$1, file: file$1, string: string$1, platform: platform$1, speech: speech$1 };
|
1725
|
-
const getAttributes = (node)
|
1725
|
+
const getAttributes = function(node) {
|
1726
1726
|
let o = {};
|
1727
1727
|
const length = node.attributes.length;
|
1728
1728
|
for (let i = 0; i < length; i++) {
|
@@ -1733,7 +1733,7 @@ const getAttributes = (node) => {
|
|
1733
1733
|
}
|
1734
1734
|
return o;
|
1735
1735
|
};
|
1736
|
-
const getStyles = (node)
|
1736
|
+
const getStyles = function(node) {
|
1737
1737
|
let o = {};
|
1738
1738
|
if (node.getAttribute("style")) {
|
1739
1739
|
const styles = node.getAttribute("style");
|
@@ -1759,34 +1759,34 @@ const getStyles = (node) => {
|
|
1759
1759
|
}
|
1760
1760
|
return o;
|
1761
1761
|
};
|
1762
|
-
const createUniqueKey = ()
|
1762
|
+
const createUniqueKey = function() {
|
1763
1763
|
let key = obj$1.data.get(window, "data-alex-editor-key") || 0;
|
1764
1764
|
key++;
|
1765
1765
|
obj$1.data.set(window, "data-alex-editor-key", key);
|
1766
1766
|
return key;
|
1767
1767
|
};
|
1768
|
-
const createGuid = ()
|
1768
|
+
const createGuid = function() {
|
1769
1769
|
let key = obj$1.data.get(window, "data-alex-editor-guid") || 0;
|
1770
1770
|
key++;
|
1771
1771
|
obj$1.data.set(window, "data-alex-editor-guid", key);
|
1772
1772
|
return key;
|
1773
1773
|
};
|
1774
|
-
const isSpaceText = (val)
|
1774
|
+
const isSpaceText = function(val) {
|
1775
1775
|
return /^[\uFEFF]+$/g.test(val);
|
1776
1776
|
};
|
1777
|
-
const cloneData = (data2)
|
1777
|
+
const cloneData = function(data2) {
|
1778
1778
|
if (obj$1.common.isObject(data2) || Array.isArray(data2)) {
|
1779
1779
|
return JSON.parse(JSON.stringify(data2));
|
1780
1780
|
}
|
1781
1781
|
return data2;
|
1782
1782
|
};
|
1783
|
-
const isContains = (parentNode, childNode)
|
1783
|
+
const isContains = function(parentNode, childNode) {
|
1784
1784
|
if (childNode.nodeType == 3) {
|
1785
1785
|
return obj$1.element.isContains(parentNode, childNode.parentNode);
|
1786
1786
|
}
|
1787
1787
|
return obj$1.element.isContains(parentNode, childNode);
|
1788
1788
|
};
|
1789
|
-
const blobToBase64 = (blob)
|
1789
|
+
const blobToBase64 = function(blob) {
|
1790
1790
|
return new Promise((resolve) => {
|
1791
1791
|
const fileReader = new FileReader();
|
1792
1792
|
fileReader.onload = (e) => {
|
@@ -1795,7 +1795,7 @@ const blobToBase64 = (blob) => {
|
|
1795
1795
|
fileReader.readAsDataURL(blob);
|
1796
1796
|
});
|
1797
1797
|
};
|
1798
|
-
const canUseClipboard = ()
|
1798
|
+
const canUseClipboard = function() {
|
1799
1799
|
if (!window.ClipboardItem) {
|
1800
1800
|
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");
|
1801
1801
|
return false;
|
@@ -1806,7 +1806,7 @@ const canUseClipboard = () => {
|
|
1806
1806
|
}
|
1807
1807
|
return true;
|
1808
1808
|
};
|
1809
|
-
const initEditorNode = (node)
|
1809
|
+
const initEditorNode = function(node) {
|
1810
1810
|
if (typeof node == "string" && node) {
|
1811
1811
|
node = document.body.querySelector(node);
|
1812
1812
|
}
|
@@ -1819,7 +1819,7 @@ const initEditorNode = (node) => {
|
|
1819
1819
|
obj$1.data.set(node, "data-alex-editor-init", true);
|
1820
1820
|
return node;
|
1821
1821
|
};
|
1822
|
-
const initEditorOptions = (options)
|
1822
|
+
const initEditorOptions = function(options) {
|
1823
1823
|
let opts = {
|
1824
1824
|
//是否禁用
|
1825
1825
|
disabled: false,
|
@@ -1891,7 +1891,7 @@ const initEditorOptions = (options) => {
|
|
1891
1891
|
}
|
1892
1892
|
return opts;
|
1893
1893
|
};
|
1894
|
-
const queryHasValue = (obj$1$1, name, value)
|
1894
|
+
const queryHasValue = function(obj$1$1, name, value) {
|
1895
1895
|
if (value == null || value == void 0) {
|
1896
1896
|
return obj$1$1.hasOwnProperty(name);
|
1897
1897
|
}
|
@@ -1921,6 +1921,60 @@ const queryHasValue = (obj$1$1, name, value) => {
|
|
1921
1921
|
}
|
1922
1922
|
return ownValue == value;
|
1923
1923
|
};
|
1924
|
+
const getNewFlatData = function(arr) {
|
1925
|
+
const length = arr.length;
|
1926
|
+
let newArr = [];
|
1927
|
+
for (let i = length - 1; i >= 0; i--) {
|
1928
|
+
if (arr[i].element.hasChildren()) {
|
1929
|
+
let allIn = arr[i].element.children.every((child) => {
|
1930
|
+
return newArr.some((item) => {
|
1931
|
+
return item.element.isEqual(child) && !item.offset;
|
1932
|
+
});
|
1933
|
+
});
|
1934
|
+
if (allIn) {
|
1935
|
+
newArr.unshift(arr[i]);
|
1936
|
+
}
|
1937
|
+
} else {
|
1938
|
+
newArr.unshift(arr[i]);
|
1939
|
+
}
|
1940
|
+
}
|
1941
|
+
for (let i = 0; i < newArr.length; i++) {
|
1942
|
+
const element2 = newArr[i].element;
|
1943
|
+
if (!element2.offset && element2.parent) {
|
1944
|
+
const selfIn = newArr.some((item) => {
|
1945
|
+
return item.element.isEqual(element2.parent);
|
1946
|
+
});
|
1947
|
+
const allIn = element2.parent.children.every((child) => {
|
1948
|
+
return newArr.some((item) => {
|
1949
|
+
return item.element.isEqual(child) && !item.offset;
|
1950
|
+
});
|
1951
|
+
});
|
1952
|
+
if (allIn && !selfIn) {
|
1953
|
+
newArr.splice(i, 0, {
|
1954
|
+
element: element2.parent,
|
1955
|
+
offset: false
|
1956
|
+
});
|
1957
|
+
i++;
|
1958
|
+
}
|
1959
|
+
}
|
1960
|
+
}
|
1961
|
+
return newArr;
|
1962
|
+
};
|
1963
|
+
const getNoFlatData = function(arr) {
|
1964
|
+
let noFlat = [];
|
1965
|
+
const length = arr.length;
|
1966
|
+
for (let i = 0; i < length; i++) {
|
1967
|
+
if (arr[i].element.isBlock()) {
|
1968
|
+
noFlat.push(arr[i]);
|
1969
|
+
} else {
|
1970
|
+
const isIn = arr.some((item) => item.element.isEqual(arr[i].element.parent));
|
1971
|
+
if (!isIn) {
|
1972
|
+
noFlat.push(arr[i]);
|
1973
|
+
}
|
1974
|
+
}
|
1975
|
+
}
|
1976
|
+
return noFlat;
|
1977
|
+
};
|
1924
1978
|
const _AlexElement = class _AlexElement2 {
|
1925
1979
|
constructor(type, parsedom, marks, styles, textContent) {
|
1926
1980
|
this.key = createUniqueKey();
|
@@ -3277,7 +3331,16 @@ class AlexEditor {
|
|
3277
3331
|
this.__isInputChinese = false;
|
3278
3332
|
this.__innerSelectionChange = false;
|
3279
3333
|
this.__chineseInputTimer = null;
|
3280
|
-
this.
|
3334
|
+
this.__getElementsByRangeData = {
|
3335
|
+
//起点和终点范围内的元素,但是不包含起点和终点所在的元素
|
3336
|
+
default: [],
|
3337
|
+
//起点和终点范围内的元素,但是包含起点和终点所在的元素
|
3338
|
+
includes: [],
|
3339
|
+
//起点和终点范围内的元素扁平化处理结果,不包含起点和终点所在的元素
|
3340
|
+
flat: [],
|
3341
|
+
//起点和终点范围内的元素扁平化处理结果,包含起点和终点所在的元素
|
3342
|
+
flatIncludes: []
|
3343
|
+
};
|
3281
3344
|
this.disabled ? this.setDisabled() : this.setEnabled();
|
3282
3345
|
obj$1.event.on(document, `selectionchange.alex_editor_${this.__guid}`, handleSelectionChange.bind(this));
|
3283
3346
|
obj$1.event.on(this.$el, "beforeinput.alex_editor", handleBeforeInput.bind(this));
|
@@ -3427,7 +3490,7 @@ class AlexEditor {
|
|
3427
3490
|
const result = await this.copy(true);
|
3428
3491
|
if (result) {
|
3429
3492
|
if (!this.disabled) {
|
3430
|
-
this.delete();
|
3493
|
+
this.delete(true);
|
3431
3494
|
}
|
3432
3495
|
this.emit("cut", result.text, result.html);
|
3433
3496
|
}
|
@@ -3447,7 +3510,7 @@ class AlexEditor {
|
|
3447
3510
|
if (!this.allowCopy) {
|
3448
3511
|
return;
|
3449
3512
|
}
|
3450
|
-
let result = this.getElementsByRange(
|
3513
|
+
let result = this.getElementsByRange().includes;
|
3451
3514
|
if (result.length == 0) {
|
3452
3515
|
return;
|
3453
3516
|
}
|
@@ -3475,7 +3538,7 @@ class AlexEditor {
|
|
3475
3538
|
/**
|
3476
3539
|
* 根据光标进行删除操作
|
3477
3540
|
*/
|
3478
|
-
delete() {
|
3541
|
+
delete(useCache = false) {
|
3479
3542
|
if (this.disabled) {
|
3480
3543
|
return;
|
3481
3544
|
}
|
@@ -3623,7 +3686,7 @@ class AlexEditor {
|
|
3623
3686
|
}
|
3624
3687
|
}
|
3625
3688
|
} else {
|
3626
|
-
const result = this.getElementsByRange(
|
3689
|
+
const result = this.getElementsByRange(useCache).includes.filter((item) => {
|
3627
3690
|
return !AlexElement.VOID_NODES.includes(item.element.parsedom);
|
3628
3691
|
});
|
3629
3692
|
const anchorInblock = this.range.anchor.element.getInblock();
|
@@ -3741,7 +3804,7 @@ class AlexEditor {
|
|
3741
3804
|
/**
|
3742
3805
|
* 根据光标位置向编辑器内插入文本
|
3743
3806
|
*/
|
3744
|
-
insertText(data2) {
|
3807
|
+
insertText(data2, useCache = false) {
|
3745
3808
|
if (this.disabled) {
|
3746
3809
|
return;
|
3747
3810
|
}
|
@@ -3775,14 +3838,14 @@ class AlexEditor {
|
|
3775
3838
|
this.range.focus.moveToEnd(textEl);
|
3776
3839
|
}
|
3777
3840
|
} else {
|
3778
|
-
this.delete();
|
3841
|
+
this.delete(useCache);
|
3779
3842
|
this.insertText(data2);
|
3780
3843
|
}
|
3781
3844
|
}
|
3782
3845
|
/**
|
3783
3846
|
* 在光标处换行
|
3784
3847
|
*/
|
3785
|
-
insertParagraph() {
|
3848
|
+
insertParagraph(useCache = false) {
|
3786
3849
|
if (this.disabled) {
|
3787
3850
|
return;
|
3788
3851
|
}
|
@@ -3878,7 +3941,7 @@ class AlexEditor {
|
|
3878
3941
|
}
|
3879
3942
|
}
|
3880
3943
|
} else {
|
3881
|
-
this.delete();
|
3944
|
+
this.delete(useCache);
|
3882
3945
|
this.insertParagraph();
|
3883
3946
|
}
|
3884
3947
|
}
|
@@ -3886,7 +3949,7 @@ class AlexEditor {
|
|
3886
3949
|
* 根据光标插入元素
|
3887
3950
|
* cover表示所在根级块或者内部块元素只有换行符时是否覆盖此元素
|
3888
3951
|
*/
|
3889
|
-
insertElement(ele, cover = true) {
|
3952
|
+
insertElement(ele, cover = true, useCache = false) {
|
3890
3953
|
if (this.disabled) {
|
3891
3954
|
return;
|
3892
3955
|
}
|
@@ -4020,7 +4083,7 @@ class AlexEditor {
|
|
4020
4083
|
this.range.anchor.moveToEnd(ele);
|
4021
4084
|
this.range.focus.moveToEnd(ele);
|
4022
4085
|
} else {
|
4023
|
-
this.delete();
|
4086
|
+
this.delete(useCache);
|
4024
4087
|
this.insertElement(ele, cover);
|
4025
4088
|
}
|
4026
4089
|
}
|
@@ -4428,122 +4491,96 @@ class AlexEditor {
|
|
4428
4491
|
/**
|
4429
4492
|
* 获取选区之间的元素
|
4430
4493
|
*/
|
4431
|
-
getElementsByRange(
|
4494
|
+
getElementsByRange(useCache = false) {
|
4495
|
+
if (useCache) {
|
4496
|
+
return this.__getElementsByRangeData;
|
4497
|
+
}
|
4498
|
+
const result = {
|
4499
|
+
//起点和终点范围内的元素,但是不包含起点和终点所在的元素
|
4500
|
+
default: [],
|
4501
|
+
//起点和终点范围内的元素,但是包含起点和终点所在的元素
|
4502
|
+
includes: [],
|
4503
|
+
//起点和终点范围内的元素扁平化处理结果,不包含起点和终点所在的元素
|
4504
|
+
flat: [],
|
4505
|
+
//起点和终点范围内的元素扁平化处理结果,包含起点和终点所在的元素
|
4506
|
+
flatIncludes: []
|
4507
|
+
};
|
4432
4508
|
if (!this.range) {
|
4433
|
-
|
4509
|
+
this.__getElementsByRangeData = result;
|
4510
|
+
return result;
|
4434
4511
|
}
|
4435
4512
|
if (this.range.anchor.isEqual(this.range.focus)) {
|
4436
|
-
|
4513
|
+
this.__getElementsByRangeData = result;
|
4514
|
+
return result;
|
4437
4515
|
}
|
4438
4516
|
if (this.range.anchor.element.isEqual(this.range.focus.element)) {
|
4439
|
-
|
4440
|
-
|
4441
|
-
|
4442
|
-
{
|
4443
|
-
element: this.range.anchor.element,
|
4444
|
-
offset: isCover ? false : [this.range.anchor.offset, this.range.focus.offset]
|
4445
|
-
}
|
4446
|
-
];
|
4447
|
-
}
|
4448
|
-
return [];
|
4449
|
-
}
|
4450
|
-
let result = [];
|
4451
|
-
if (includes) {
|
4452
|
-
if (this.range.anchor.offset == 0) {
|
4453
|
-
result.push({
|
4517
|
+
const isCover = this.range.anchor.offset == 0 && this.range.focus.offset == (this.range.anchor.element.isText() ? this.range.anchor.element.textContent.length : 1);
|
4518
|
+
result.includes = [
|
4519
|
+
{
|
4454
4520
|
element: this.range.anchor.element,
|
4455
|
-
offset: false
|
4456
|
-
}
|
4457
|
-
|
4458
|
-
|
4521
|
+
offset: isCover ? false : [this.range.anchor.offset, this.range.focus.offset]
|
4522
|
+
}
|
4523
|
+
];
|
4524
|
+
result.flatIncludes = [
|
4525
|
+
{
|
4459
4526
|
element: this.range.anchor.element,
|
4460
|
-
offset: [this.range.anchor.offset, this.range.
|
4461
|
-
}
|
4462
|
-
|
4527
|
+
offset: isCover ? false : [this.range.anchor.offset, this.range.focus.offset]
|
4528
|
+
}
|
4529
|
+
];
|
4530
|
+
this.__getElementsByRangeData = result;
|
4531
|
+
return result;
|
4532
|
+
}
|
4533
|
+
if (this.range.anchor.offset == 0) {
|
4534
|
+
result.flatIncludes.push({
|
4535
|
+
element: this.range.anchor.element,
|
4536
|
+
offset: false
|
4537
|
+
});
|
4538
|
+
} else if (this.range.anchor.offset < (this.range.anchor.element.isText() ? this.range.anchor.element.textContent.length : 1)) {
|
4539
|
+
result.flatIncludes.push({
|
4540
|
+
element: this.range.anchor.element,
|
4541
|
+
offset: [this.range.anchor.offset, this.range.anchor.element.isText() ? this.range.anchor.element.textContent.length : 1]
|
4542
|
+
});
|
4463
4543
|
}
|
4464
4544
|
const elements = AlexElement.flatElements(this.stack);
|
4465
4545
|
const anchorIndex = elements.findIndex((el) => el.isEqual(this.range.anchor.element));
|
4466
4546
|
const focusIndex = elements.findIndex((el) => el.isEqual(this.range.focus.element));
|
4467
4547
|
for (let i = anchorIndex + 1; i < focusIndex; i++) {
|
4468
|
-
result.push({
|
4548
|
+
result.flatIncludes.push({
|
4549
|
+
element: elements[i],
|
4550
|
+
offset: false
|
4551
|
+
});
|
4552
|
+
result.flat.push({
|
4469
4553
|
element: elements[i],
|
4470
4554
|
offset: false
|
4471
4555
|
});
|
4472
4556
|
}
|
4473
|
-
if (
|
4474
|
-
|
4475
|
-
|
4476
|
-
|
4477
|
-
|
4478
|
-
|
4479
|
-
|
4480
|
-
|
4481
|
-
|
4482
|
-
|
4483
|
-
});
|
4484
|
-
}
|
4485
|
-
}
|
4486
|
-
const resLength = result.length;
|
4487
|
-
let newResult = [];
|
4488
|
-
for (let i = resLength - 1; i >= 0; i--) {
|
4489
|
-
if (result[i].element.hasChildren()) {
|
4490
|
-
let allIn = result[i].element.children.every((child) => {
|
4491
|
-
return newResult.some((item) => {
|
4492
|
-
return item.element.isEqual(child) && !item.offset;
|
4493
|
-
});
|
4494
|
-
});
|
4495
|
-
if (allIn) {
|
4496
|
-
newResult.unshift(result[i]);
|
4497
|
-
}
|
4498
|
-
} else {
|
4499
|
-
newResult.unshift(result[i]);
|
4500
|
-
}
|
4501
|
-
}
|
4502
|
-
for (let i = 0; i < newResult.length; i++) {
|
4503
|
-
const element2 = newResult[i].element;
|
4504
|
-
if (!element2.offset && element2.parent) {
|
4505
|
-
const selfIn = newResult.some((item) => {
|
4506
|
-
return item.element.isEqual(element2.parent);
|
4507
|
-
});
|
4508
|
-
const allIn = element2.parent.children.every((child) => {
|
4509
|
-
return newResult.some((item) => {
|
4510
|
-
return item.element.isEqual(child) && !item.offset;
|
4511
|
-
});
|
4512
|
-
});
|
4513
|
-
if (allIn && !selfIn) {
|
4514
|
-
newResult.splice(i, 0, {
|
4515
|
-
element: element2.parent,
|
4516
|
-
offset: false
|
4517
|
-
});
|
4518
|
-
i++;
|
4519
|
-
}
|
4520
|
-
}
|
4521
|
-
}
|
4522
|
-
if (flat) {
|
4523
|
-
return newResult;
|
4524
|
-
}
|
4525
|
-
let notFlatResult = [];
|
4526
|
-
const length = newResult.length;
|
4527
|
-
for (let i = 0; i < length; i++) {
|
4528
|
-
if (newResult[i].element.isBlock()) {
|
4529
|
-
notFlatResult.push(newResult[i]);
|
4530
|
-
} else {
|
4531
|
-
const isIn = newResult.some((item) => item.element.isEqual(newResult[i].element.parent));
|
4532
|
-
if (!isIn) {
|
4533
|
-
notFlatResult.push(newResult[i]);
|
4534
|
-
}
|
4535
|
-
}
|
4557
|
+
if (this.range.focus.offset == (this.range.focus.element.isText() ? this.range.focus.element.textContent.length : 1)) {
|
4558
|
+
result.flatIncludes.push({
|
4559
|
+
element: this.range.focus.element,
|
4560
|
+
offset: false
|
4561
|
+
});
|
4562
|
+
} else if (this.range.focus.offset > 0) {
|
4563
|
+
result.flatIncludes.push({
|
4564
|
+
element: this.range.focus.element,
|
4565
|
+
offset: [0, this.range.focus.offset]
|
4566
|
+
});
|
4536
4567
|
}
|
4537
|
-
|
4568
|
+
result.flat = getNewFlatData.apply(this, [result.flat]);
|
4569
|
+
result.flatIncludes = getNewFlatData.apply(this, [result.flatIncludes]);
|
4570
|
+
result.default = getNoFlatData.apply(this, [result.flat]);
|
4571
|
+
result.includes = getNoFlatData.apply(this, [result.flatIncludes]);
|
4572
|
+
this.__getElementsByRangeData = result;
|
4573
|
+
return result;
|
4538
4574
|
}
|
4539
4575
|
/**
|
4540
4576
|
* 分割选区选中的元素,会更新光标位置
|
4541
4577
|
*/
|
4542
|
-
splitElementsByRange(includes = false, flat = false) {
|
4578
|
+
splitElementsByRange(includes = false, flat = false, useCache = false) {
|
4543
4579
|
if (!this.range) {
|
4544
4580
|
return [];
|
4545
4581
|
}
|
4546
|
-
const
|
4582
|
+
const key = includes && flat ? "flatIncludes" : includes ? "includes" : flat ? "flat" : "default";
|
4583
|
+
const result = this.getElementsByRange(useCache)[key];
|
4547
4584
|
let elements = [];
|
4548
4585
|
result.forEach((item, index) => {
|
4549
4586
|
if (item.offset) {
|
@@ -4733,7 +4770,7 @@ class AlexEditor {
|
|
4733
4770
|
/**
|
4734
4771
|
* 设置文本元素的样式
|
4735
4772
|
*/
|
4736
|
-
setTextStyle(styles) {
|
4773
|
+
setTextStyle(styles, useCache = false) {
|
4737
4774
|
if (this.disabled) {
|
4738
4775
|
return;
|
4739
4776
|
}
|
@@ -4766,7 +4803,7 @@ class AlexEditor {
|
|
4766
4803
|
this.insertElement(el);
|
4767
4804
|
}
|
4768
4805
|
} else {
|
4769
|
-
const elements = this.splitElementsByRange(true, true);
|
4806
|
+
const elements = this.splitElementsByRange(true, true, useCache);
|
4770
4807
|
elements.forEach((ele) => {
|
4771
4808
|
if (ele.isText()) {
|
4772
4809
|
if (ele.hasStyles()) {
|
@@ -4781,7 +4818,7 @@ class AlexEditor {
|
|
4781
4818
|
/**
|
4782
4819
|
* 移除文本元素的样式
|
4783
4820
|
*/
|
4784
|
-
removeTextStyle(styleNames) {
|
4821
|
+
removeTextStyle(styleNames, useCache = false) {
|
4785
4822
|
if (this.disabled) {
|
4786
4823
|
return;
|
4787
4824
|
}
|
@@ -4814,7 +4851,7 @@ class AlexEditor {
|
|
4814
4851
|
this.insertElement(el);
|
4815
4852
|
}
|
4816
4853
|
} else {
|
4817
|
-
const elements = this.splitElementsByRange(true, true);
|
4854
|
+
const elements = this.splitElementsByRange(true, true, useCache);
|
4818
4855
|
elements.forEach((ele) => {
|
4819
4856
|
if (ele.isText()) {
|
4820
4857
|
removeFn(ele);
|
@@ -4838,17 +4875,9 @@ class AlexEditor {
|
|
4838
4875
|
}
|
4839
4876
|
return false;
|
4840
4877
|
}
|
4841
|
-
let result =
|
4842
|
-
|
4843
|
-
|
4844
|
-
} else {
|
4845
|
-
result = this.getElementsByRange(true, true).filter((item) => {
|
4846
|
-
return item.element.isText();
|
4847
|
-
});
|
4848
|
-
}
|
4849
|
-
if (!useCache) {
|
4850
|
-
this.__dataCaches["queryTextStyle"] = result;
|
4851
|
-
}
|
4878
|
+
let result = this.getElementsByRange(useCache).flatIncludes.filter((item) => {
|
4879
|
+
return item.element.isText();
|
4880
|
+
});
|
4852
4881
|
if (result.length == 0) {
|
4853
4882
|
return false;
|
4854
4883
|
}
|
@@ -4863,7 +4892,7 @@ class AlexEditor {
|
|
4863
4892
|
/**
|
4864
4893
|
* 设置文本元素的标记
|
4865
4894
|
*/
|
4866
|
-
setTextMark(marks) {
|
4895
|
+
setTextMark(marks, useCache = false) {
|
4867
4896
|
if (this.disabled) {
|
4868
4897
|
return;
|
4869
4898
|
}
|
@@ -4896,7 +4925,7 @@ class AlexEditor {
|
|
4896
4925
|
this.insertElement(el);
|
4897
4926
|
}
|
4898
4927
|
} else {
|
4899
|
-
const elements = this.splitElementsByRange(true, true);
|
4928
|
+
const elements = this.splitElementsByRange(true, true, useCache);
|
4900
4929
|
elements.forEach((ele) => {
|
4901
4930
|
if (ele.isText()) {
|
4902
4931
|
if (ele.hasMarks()) {
|
@@ -4911,7 +4940,7 @@ class AlexEditor {
|
|
4911
4940
|
/**
|
4912
4941
|
* 移除文本元素的标记
|
4913
4942
|
*/
|
4914
|
-
removeTextMark(markNames) {
|
4943
|
+
removeTextMark(markNames, useCache = false) {
|
4915
4944
|
if (this.disabled) {
|
4916
4945
|
return;
|
4917
4946
|
}
|
@@ -4944,7 +4973,7 @@ class AlexEditor {
|
|
4944
4973
|
this.insertElement(el);
|
4945
4974
|
}
|
4946
4975
|
} else {
|
4947
|
-
const elements = this.splitElementsByRange(true, true);
|
4976
|
+
const elements = this.splitElementsByRange(true, true, useCache);
|
4948
4977
|
elements.forEach((ele) => {
|
4949
4978
|
if (ele.isText()) {
|
4950
4979
|
removeFn(ele);
|
@@ -4968,17 +4997,9 @@ class AlexEditor {
|
|
4968
4997
|
}
|
4969
4998
|
return false;
|
4970
4999
|
}
|
4971
|
-
let result =
|
4972
|
-
|
4973
|
-
|
4974
|
-
} else {
|
4975
|
-
result = this.getElementsByRange(true, true).filter((item) => {
|
4976
|
-
return item.element.isText();
|
4977
|
-
});
|
4978
|
-
}
|
4979
|
-
if (!useCache) {
|
4980
|
-
this.__dataCaches["queryTextMark"] = result;
|
4981
|
-
}
|
5000
|
+
let result = this.getElementsByRange(useCache).flatIncludes.filter((item) => {
|
5001
|
+
return item.element.isText();
|
5002
|
+
});
|
4982
5003
|
if (result.length == 0) {
|
4983
5004
|
return false;
|
4984
5005
|
}
|
@@ -17869,7 +17890,7 @@ function _sfc_render$7(_ctx, _cache, $props, $setup, $data, $options) {
|
|
17869
17890
|
]);
|
17870
17891
|
}
|
17871
17892
|
const Colors = /* @__PURE__ */ _export_sfc(_sfc_main$7, [["render", _sfc_render$7], ["__scopeId", "data-v-dc6d3d68"]]);
|
17872
|
-
const
|
17893
|
+
const Toolbar_vue_vue_type_style_index_0_scoped_36dbd332_lang = "";
|
17873
17894
|
const _sfc_main$6 = {
|
17874
17895
|
name: "Toolbar",
|
17875
17896
|
emits: ["update:modelValue"],
|
@@ -18144,80 +18165,80 @@ const _sfc_main$6 = {
|
|
18144
18165
|
methods: {
|
18145
18166
|
//清除格式
|
18146
18167
|
clearFormat() {
|
18147
|
-
this.$parent.formatText();
|
18168
|
+
this.$parent.formatText(true, true);
|
18148
18169
|
},
|
18149
18170
|
//设置背景色
|
18150
18171
|
setBackColor(value) {
|
18151
|
-
this.$parent.setTextStyle("background-color", value);
|
18172
|
+
this.$parent.setTextStyle("background-color", value, true, true);
|
18152
18173
|
this.$refs.backColor.hideLayer();
|
18153
18174
|
},
|
18154
18175
|
//设置前景色
|
18155
18176
|
setForeColor(value) {
|
18156
|
-
this.$parent.setTextStyle("color", value);
|
18177
|
+
this.$parent.setTextStyle("color", value, true, true);
|
18157
18178
|
this.$refs.foreColor.hideLayer();
|
18158
18179
|
},
|
18159
18180
|
//设置行高
|
18160
18181
|
setLineHeight(name, value) {
|
18161
|
-
this.$parent.setLineHeight(value);
|
18182
|
+
this.$parent.setLineHeight(value, true, true);
|
18162
18183
|
},
|
18163
18184
|
//设置字体
|
18164
18185
|
setFontFamily(name, value) {
|
18165
|
-
this.$parent.setTextStyle("font-family", value);
|
18186
|
+
this.$parent.setTextStyle("font-family", value, true, true);
|
18166
18187
|
},
|
18167
18188
|
//设置字号
|
18168
18189
|
setFontSize(name, value) {
|
18169
|
-
this.$parent.setTextStyle("font-size", value);
|
18190
|
+
this.$parent.setTextStyle("font-size", value, true, true);
|
18170
18191
|
},
|
18171
18192
|
//设置上标
|
18172
18193
|
setSuperscript() {
|
18173
|
-
this.$parent.setTextStyle("vertical-align", "super");
|
18194
|
+
this.$parent.setTextStyle("vertical-align", "super", true, true);
|
18174
18195
|
},
|
18175
18196
|
//设置下标
|
18176
18197
|
setSubscript() {
|
18177
|
-
this.$parent.setTextStyle("vertical-align", "sub");
|
18198
|
+
this.$parent.setTextStyle("vertical-align", "sub", true, true);
|
18178
18199
|
},
|
18179
18200
|
//设置行内代码样式
|
18180
18201
|
setCodeStyle() {
|
18181
|
-
this.$parent.setTextMark("data-editify-code", true);
|
18202
|
+
this.$parent.setTextMark("data-editify-code", true, true, true);
|
18182
18203
|
},
|
18183
18204
|
//设置下划线
|
18184
18205
|
setUnderline() {
|
18185
|
-
this.$parent.setTextStyle("text-decoration", "underline");
|
18206
|
+
this.$parent.setTextStyle("text-decoration", "underline", true, true);
|
18186
18207
|
},
|
18187
18208
|
//设置删除线
|
18188
18209
|
setStrikethrough() {
|
18189
|
-
this.$parent.setTextStyle("text-decoration", "line-through");
|
18210
|
+
this.$parent.setTextStyle("text-decoration", "line-through", true, true);
|
18190
18211
|
},
|
18191
18212
|
//设置列表
|
18192
18213
|
setList(name) {
|
18193
|
-
this.$parent.setList(name == "orderList");
|
18214
|
+
this.$parent.setList(name == "orderList", true, true);
|
18194
18215
|
},
|
18195
18216
|
//设置任务列表
|
18196
18217
|
setTask() {
|
18197
|
-
this.$parent.setTask();
|
18218
|
+
this.$parent.setTask(true, true);
|
18198
18219
|
},
|
18199
18220
|
//斜体
|
18200
18221
|
setItalic() {
|
18201
|
-
this.$parent.setTextStyle("font-style", "italic");
|
18222
|
+
this.$parent.setTextStyle("font-style", "italic", true, true);
|
18202
18223
|
},
|
18203
18224
|
//加粗
|
18204
18225
|
setBold() {
|
18205
|
-
this.$parent.setTextStyle("font-weight", "bold");
|
18226
|
+
this.$parent.setTextStyle("font-weight", "bold", true, true);
|
18206
18227
|
},
|
18207
18228
|
//设置标题
|
18208
18229
|
setHeading(name, value) {
|
18209
|
-
this.$parent.setHeading(value);
|
18230
|
+
this.$parent.setHeading(value, true, true);
|
18210
18231
|
},
|
18211
18232
|
//设置对齐方式
|
18212
18233
|
setAlign(name, value) {
|
18213
|
-
this.$parent.setAlign(value);
|
18234
|
+
this.$parent.setAlign(value, true, true);
|
18214
18235
|
},
|
18215
18236
|
//设置视频
|
18216
18237
|
setVideo(prop) {
|
18217
18238
|
if (this.$parent.disabled) {
|
18218
18239
|
return;
|
18219
18240
|
}
|
18220
|
-
const video = this.$parent.getCurrentParsedomElement("video");
|
18241
|
+
const video = this.$parent.getCurrentParsedomElement("video", true);
|
18221
18242
|
if (video) {
|
18222
18243
|
if (this.videoConfig[prop]) {
|
18223
18244
|
delete video.marks[prop];
|
@@ -18234,7 +18255,7 @@ const _sfc_main$6 = {
|
|
18234
18255
|
if (this.$parent.disabled) {
|
18235
18256
|
return;
|
18236
18257
|
}
|
18237
|
-
const element2 = this.$parent.getCurrentParsedomElement("img") || this.$parent.getCurrentParsedomElement("video");
|
18258
|
+
const element2 = this.$parent.getCurrentParsedomElement("img", true) || this.$parent.getCurrentParsedomElement("video", true);
|
18238
18259
|
if (element2) {
|
18239
18260
|
const styles = {
|
18240
18261
|
width: value
|
@@ -18260,7 +18281,7 @@ const _sfc_main$6 = {
|
|
18260
18281
|
if (!this.linkConfig.url) {
|
18261
18282
|
return;
|
18262
18283
|
}
|
18263
|
-
const link = this.$parent.getCurrentParsedomElement("a");
|
18284
|
+
const link = this.$parent.getCurrentParsedomElement("a", true);
|
18264
18285
|
if (link) {
|
18265
18286
|
link.marks.href = this.linkConfig.url;
|
18266
18287
|
if (this.linkConfig.newOpen) {
|
@@ -18293,7 +18314,7 @@ const _sfc_main$6 = {
|
|
18293
18314
|
if (this.$parent.disabled) {
|
18294
18315
|
return;
|
18295
18316
|
}
|
18296
|
-
const pre = this.$parent.getCurrentParsedomElement("pre");
|
18317
|
+
const pre = this.$parent.getCurrentParsedomElement("pre", true);
|
18297
18318
|
if (pre) {
|
18298
18319
|
Object.assign(pre.marks, {
|
18299
18320
|
"data-editify-hljs": value
|
@@ -18312,7 +18333,7 @@ const _sfc_main$6 = {
|
|
18312
18333
|
this.$parent.editor.range.anchor.element = this.$parent.editor.range.focus.element;
|
18313
18334
|
this.$parent.editor.range.anchor.offset = this.$parent.editor.range.focus.offset;
|
18314
18335
|
}
|
18315
|
-
const pre = this.$parent.getCurrentParsedomElement("pre");
|
18336
|
+
const pre = this.$parent.getCurrentParsedomElement("pre", true);
|
18316
18337
|
if (pre) {
|
18317
18338
|
const paragraph = new AlexElement("block", AlexElement.BLOCK_NODE, null, null, null);
|
18318
18339
|
const breakEl = new AlexElement("closed", "br", null, null, null);
|
@@ -18338,9 +18359,9 @@ const _sfc_main$6 = {
|
|
18338
18359
|
this.$parent.editor.range.anchor.element = this.$parent.editor.range.focus.element;
|
18339
18360
|
this.$parent.editor.range.anchor.offset = this.$parent.editor.range.focus.offset;
|
18340
18361
|
}
|
18341
|
-
const table = this.$parent.getCurrentParsedomElement("table");
|
18342
|
-
const column = this.$parent.getCurrentParsedomElement("td");
|
18343
|
-
const tbody = this.$parent.getCurrentParsedomElement("tbody");
|
18362
|
+
const table = this.$parent.getCurrentParsedomElement("table", true);
|
18363
|
+
const column = this.$parent.getCurrentParsedomElement("td", true);
|
18364
|
+
const tbody = this.$parent.getCurrentParsedomElement("tbody", true);
|
18344
18365
|
if (column && table && tbody) {
|
18345
18366
|
const rows = tbody.children;
|
18346
18367
|
const index = column.parent.children.findIndex((item) => {
|
@@ -18379,7 +18400,7 @@ const _sfc_main$6 = {
|
|
18379
18400
|
this.$parent.editor.rangeRender();
|
18380
18401
|
}
|
18381
18402
|
},
|
18382
|
-
|
18403
|
+
//表格前后插入行
|
18383
18404
|
insertTableRow(type = "up") {
|
18384
18405
|
if (this.$parent.disabled) {
|
18385
18406
|
return;
|
@@ -18388,8 +18409,8 @@ const _sfc_main$6 = {
|
|
18388
18409
|
this.$parent.editor.range.anchor.element = this.$parent.editor.range.focus.element;
|
18389
18410
|
this.$parent.editor.range.anchor.offset = this.$parent.editor.range.focus.offset;
|
18390
18411
|
}
|
18391
|
-
const table = this.$parent.getCurrentParsedomElement("table");
|
18392
|
-
const row = this.$parent.getCurrentParsedomElement("tr");
|
18412
|
+
const table = this.$parent.getCurrentParsedomElement("table", true);
|
18413
|
+
const row = this.$parent.getCurrentParsedomElement("tr", true);
|
18393
18414
|
if (table && row) {
|
18394
18415
|
const newRow = row.clone();
|
18395
18416
|
newRow.children.forEach((column) => {
|
@@ -18417,7 +18438,7 @@ const _sfc_main$6 = {
|
|
18417
18438
|
if (this.$parent.disabled) {
|
18418
18439
|
return;
|
18419
18440
|
}
|
18420
|
-
const table = this.$parent.getCurrentParsedomElement("table");
|
18441
|
+
const table = this.$parent.getCurrentParsedomElement("table", true);
|
18421
18442
|
if (table) {
|
18422
18443
|
const paragraph = new AlexElement("block", AlexElement.BLOCK_NODE, null, null, null);
|
18423
18444
|
const breakEl = new AlexElement("closed", "br", null, null, null);
|
@@ -18443,12 +18464,12 @@ const _sfc_main$6 = {
|
|
18443
18464
|
this.$parent.editor.range.anchor.element = this.$parent.editor.range.focus.element;
|
18444
18465
|
this.$parent.editor.range.anchor.offset = this.$parent.editor.range.focus.offset;
|
18445
18466
|
}
|
18446
|
-
const table = this.$parent.getCurrentParsedomElement("table");
|
18447
|
-
const row = this.$parent.getCurrentParsedomElement("tr");
|
18467
|
+
const table = this.$parent.getCurrentParsedomElement("table", true);
|
18468
|
+
const row = this.$parent.getCurrentParsedomElement("tr", true);
|
18448
18469
|
if (table && row) {
|
18449
18470
|
const parent = row.parent;
|
18450
18471
|
if (parent.children.length == 1) {
|
18451
|
-
this.$parent.deleteByParsedom("table");
|
18472
|
+
this.$parent.deleteByParsedom("table", true, true);
|
18452
18473
|
return;
|
18453
18474
|
}
|
18454
18475
|
const previousRow = this.$parent.editor.getPreviousElement(row);
|
@@ -18478,14 +18499,14 @@ const _sfc_main$6 = {
|
|
18478
18499
|
this.$parent.editor.range.anchor.element = this.$parent.editor.range.focus.element;
|
18479
18500
|
this.$parent.editor.range.anchor.offset = this.$parent.editor.range.focus.offset;
|
18480
18501
|
}
|
18481
|
-
const column = this.$parent.getCurrentParsedomElement("td");
|
18482
|
-
const tbody = this.$parent.getCurrentParsedomElement("tbody");
|
18483
|
-
const table = this.$parent.getCurrentParsedomElement("table");
|
18502
|
+
const column = this.$parent.getCurrentParsedomElement("td", true);
|
18503
|
+
const tbody = this.$parent.getCurrentParsedomElement("tbody", true);
|
18504
|
+
const table = this.$parent.getCurrentParsedomElement("table", true);
|
18484
18505
|
if (column && table && tbody) {
|
18485
18506
|
const rows = tbody.children;
|
18486
18507
|
const parent = column.parent;
|
18487
18508
|
if (parent.children.length == 1) {
|
18488
|
-
this.$parent.deleteByParsedom("table");
|
18509
|
+
this.$parent.deleteByParsedom("table", true, true);
|
18489
18510
|
return;
|
18490
18511
|
}
|
18491
18512
|
const previousColumn = this.$parent.editor.getPreviousElement(column);
|
@@ -18514,19 +18535,20 @@ const _sfc_main$6 = {
|
|
18514
18535
|
},
|
18515
18536
|
//浮层显示时
|
18516
18537
|
layerShow() {
|
18538
|
+
const result = this.$parent.editor.getElementsByRange(true).includes;
|
18517
18539
|
if (this.type == "codeBlock") {
|
18518
|
-
const pre = this.$parent.getCurrentParsedomElement("pre");
|
18540
|
+
const pre = this.$parent.getCurrentParsedomElement("pre", true);
|
18519
18541
|
if (pre) {
|
18520
18542
|
this.languageConfig.displayConfig.value = pre.marks["data-editify-hljs"] || "";
|
18521
18543
|
}
|
18522
18544
|
} else if (this.type == "link") {
|
18523
|
-
const link = this.$parent.getCurrentParsedomElement("a");
|
18545
|
+
const link = this.$parent.getCurrentParsedomElement("a", true);
|
18524
18546
|
if (link) {
|
18525
18547
|
this.linkConfig.url = link.marks["href"];
|
18526
18548
|
this.linkConfig.newOpen = link.marks["target"] == "_blank";
|
18527
18549
|
}
|
18528
18550
|
} else if (this.type == "video") {
|
18529
|
-
const video = this.$parent.getCurrentParsedomElement("video");
|
18551
|
+
const video = this.$parent.getCurrentParsedomElement("video", true);
|
18530
18552
|
if (video) {
|
18531
18553
|
this.videoConfig.autoplay = !!video.marks["autoplay"];
|
18532
18554
|
this.videoConfig.loop = !!video.marks["loop"];
|
@@ -18540,7 +18562,6 @@ const _sfc_main$6 = {
|
|
18540
18562
|
}
|
18541
18563
|
return false;
|
18542
18564
|
};
|
18543
|
-
const result = this.$parent.editor.getElementsByRange(true, false);
|
18544
18565
|
const findHeadingItem = this.headingConfig.displayConfig.options.find((item) => {
|
18545
18566
|
let val = item;
|
18546
18567
|
if (obj.common.isObject(item)) {
|
@@ -18556,13 +18577,13 @@ const _sfc_main$6 = {
|
|
18556
18577
|
this.headingConfig.displayConfig.value = findHeadingItem ? obj.common.isObject(findHeadingItem) ? findHeadingItem.value : findHeadingItem : this.headingConfig.defaultValue;
|
18557
18578
|
this.headingConfig.disabled = extraDisabled("heading");
|
18558
18579
|
this.alignConfig.disabled = extraDisabled("align");
|
18559
|
-
this.orderListConfig.active = this.$parent.inList(true);
|
18580
|
+
this.orderListConfig.active = this.$parent.inList(true, true);
|
18560
18581
|
this.orderListConfig.disabled = extraDisabled("orderList");
|
18561
|
-
this.unorderListConfig.active = this.$parent.inList(false);
|
18582
|
+
this.unorderListConfig.active = this.$parent.inList(false, true);
|
18562
18583
|
this.unorderListConfig.disabled = extraDisabled("unorderList");
|
18563
|
-
this.taskConfig.active = this.$parent.inTask();
|
18584
|
+
this.taskConfig.active = this.$parent.inTask(true, true);
|
18564
18585
|
this.taskConfig.disabled = extraDisabled("task");
|
18565
|
-
this.boldConfig.active = this.$parent.queryTextStyle("font-weight", "bold");
|
18586
|
+
this.boldConfig.active = this.$parent.queryTextStyle("font-weight", "bold", true);
|
18566
18587
|
this.boldConfig.disabled = extraDisabled("bold");
|
18567
18588
|
this.italicConfig.active = this.$parent.queryTextStyle("font-style", "italic", true);
|
18568
18589
|
this.italicConfig.disabled = extraDisabled("italic");
|
@@ -18570,7 +18591,7 @@ const _sfc_main$6 = {
|
|
18570
18591
|
this.strikethroughConfig.disabled = extraDisabled("strikethrough");
|
18571
18592
|
this.underlineConfig.active = this.$parent.queryTextStyle("text-decoration", "underline", true);
|
18572
18593
|
this.underlineConfig.disabled = extraDisabled("underline");
|
18573
|
-
this.codeConfig.active = this.$parent.queryTextMark("data-editify-code");
|
18594
|
+
this.codeConfig.active = this.$parent.queryTextMark("data-editify-code", null, true);
|
18574
18595
|
this.codeConfig.disabled = extraDisabled("code");
|
18575
18596
|
this.superConfig.active = this.$parent.queryTextStyle("vertical-align", "super", true);
|
18576
18597
|
this.superConfig.disabled = extraDisabled("super");
|
@@ -19364,7 +19385,7 @@ function _sfc_render$6(_ctx, _cache, $props, $setup, $data, $options) {
|
|
19364
19385
|
_: 1
|
19365
19386
|
}, 8, ["modelValue", "node", "onShow", "useRange"]);
|
19366
19387
|
}
|
19367
|
-
const Toolbar = /* @__PURE__ */ _export_sfc(_sfc_main$6, [["render", _sfc_render$6], ["__scopeId", "data-v-
|
19388
|
+
const Toolbar = /* @__PURE__ */ _export_sfc(_sfc_main$6, [["render", _sfc_render$6], ["__scopeId", "data-v-36dbd332"]]);
|
19368
19389
|
const InsertLink_vue_vue_type_style_index_0_scoped_e6c3c2ee_lang = "";
|
19369
19390
|
const _sfc_main$5 = {
|
19370
19391
|
name: "InsertLink",
|
@@ -20012,7 +20033,7 @@ function _sfc_render$2(_ctx, _cache, $props, $setup, $data, $options) {
|
|
20012
20033
|
]);
|
20013
20034
|
}
|
20014
20035
|
const InsertTable = /* @__PURE__ */ _export_sfc(_sfc_main$2, [["render", _sfc_render$2], ["__scopeId", "data-v-227ede65"]]);
|
20015
|
-
const
|
20036
|
+
const Menu_vue_vue_type_style_index_0_scoped_da918768_lang = "";
|
20016
20037
|
const _sfc_main$1 = {
|
20017
20038
|
name: "Menu",
|
20018
20039
|
props: {
|
@@ -20762,7 +20783,7 @@ const _sfc_main$1 = {
|
|
20762
20783
|
hideScroll: true,
|
20763
20784
|
onLayerShow: () => {
|
20764
20785
|
let text2 = "";
|
20765
|
-
const result = this.$parent.$parent.editor.getElementsByRange(
|
20786
|
+
const result = this.$parent.$parent.editor.getElementsByRange().flatIncludes;
|
20766
20787
|
result.forEach((item) => {
|
20767
20788
|
if (item.element.isText()) {
|
20768
20789
|
if (item.offset) {
|
@@ -21086,19 +21107,19 @@ const _sfc_main$1 = {
|
|
21086
21107
|
}
|
21087
21108
|
},
|
21088
21109
|
//处理光标更新
|
21089
|
-
handleRangeUpdate() {
|
21110
|
+
handleRangeUpdate(useCache = false) {
|
21090
21111
|
if (this.disabled) {
|
21091
21112
|
return;
|
21092
21113
|
}
|
21093
|
-
const result = this.$parent.editor.getElementsByRange(
|
21094
|
-
const hasPreStyle = this.$parent.hasPreStyle();
|
21095
|
-
const hasTable = this.$parent.hasTable();
|
21096
|
-
const hasQuote = this.$parent.hasQuote();
|
21097
|
-
const inQuote = this.$parent.inQuote();
|
21098
|
-
const hasLink = this.$parent.hasLink();
|
21099
|
-
const inOrderList = this.$parent.inList(true);
|
21100
|
-
const inUnorderList = this.$parent.inList(false);
|
21101
|
-
const inTask = this.$parent.inTask();
|
21114
|
+
const result = this.$parent.editor.getElementsByRange(useCache).includes;
|
21115
|
+
const hasPreStyle = this.$parent.hasPreStyle(true);
|
21116
|
+
const hasTable = this.$parent.hasTable(true);
|
21117
|
+
const hasQuote = this.$parent.hasQuote(true);
|
21118
|
+
const inQuote = this.$parent.inQuote(true);
|
21119
|
+
const hasLink = this.$parent.hasLink(true);
|
21120
|
+
const inOrderList = this.$parent.inList(true, true);
|
21121
|
+
const inUnorderList = this.$parent.inList(false, true);
|
21122
|
+
const inTask = this.$parent.inTask(true);
|
21102
21123
|
const extraDisabled = (name) => {
|
21103
21124
|
if (typeof this.config.extraDisabled == "function") {
|
21104
21125
|
return this.config.extraDisabled.apply(this.$parent, [name]) || false;
|
@@ -21134,7 +21155,7 @@ const _sfc_main$1 = {
|
|
21134
21155
|
this.unorderListConfig.disabled = hasPreStyle || hasTable || extraDisabled("unorderList");
|
21135
21156
|
this.taskConfig.active = inTask;
|
21136
21157
|
this.taskConfig.disabled = hasPreStyle || hasTable || extraDisabled("task");
|
21137
|
-
this.boldConfig.active = this.$parent.queryTextStyle("font-weight", "bold");
|
21158
|
+
this.boldConfig.active = this.$parent.queryTextStyle("font-weight", "bold", true);
|
21138
21159
|
this.boldConfig.disabled = hasPreStyle || extraDisabled("bold");
|
21139
21160
|
this.underlineConfig.active = this.$parent.queryTextStyle("text-decoration", "underline", true);
|
21140
21161
|
this.underlineConfig.disabled = hasPreStyle || extraDisabled("underline");
|
@@ -21142,7 +21163,7 @@ const _sfc_main$1 = {
|
|
21142
21163
|
this.italicConfig.disabled = hasPreStyle || extraDisabled("italic");
|
21143
21164
|
this.strikethroughConfig.active = this.$parent.queryTextStyle("text-decoration", "line-through", true);
|
21144
21165
|
this.strikethroughConfig.disabled = hasPreStyle || extraDisabled("strikethrough");
|
21145
|
-
this.codeConfig.active = this.$parent.queryTextMark("data-editify-code");
|
21166
|
+
this.codeConfig.active = this.$parent.queryTextMark("data-editify-code", null, true);
|
21146
21167
|
this.codeConfig.disabled = hasPreStyle || extraDisabled("code");
|
21147
21168
|
this.superConfig.active = this.$parent.queryTextStyle("vertical-align", "super", true);
|
21148
21169
|
this.superConfig.disabled = hasPreStyle || extraDisabled("super");
|
@@ -21208,7 +21229,7 @@ const _sfc_main$1 = {
|
|
21208
21229
|
this.imageConfig.disabled = hasPreStyle || extraDisabled("image");
|
21209
21230
|
this.videoConfig.disabled = hasPreStyle || extraDisabled("video");
|
21210
21231
|
this.tableConfig.disabled = hasPreStyle || hasTable || hasQuote || extraDisabled("table");
|
21211
|
-
this.codeBlockConfig.active = !!this.$parent.getCurrentParsedomElement("pre");
|
21232
|
+
this.codeBlockConfig.active = !!this.$parent.getCurrentParsedomElement("pre", true);
|
21212
21233
|
this.codeBlockConfig.disabled = hasTable || hasQuote || extraDisabled("codeBlock");
|
21213
21234
|
this.sourceViewConfig.active = this.$parent.isSourceView;
|
21214
21235
|
}
|
@@ -21230,8 +21251,8 @@ function _sfc_render$1(_ctx, _cache, $props, $setup, $data, $options) {
|
|
21230
21251
|
}), 256))
|
21231
21252
|
], 14, _hoisted_1$1);
|
21232
21253
|
}
|
21233
|
-
const Menu = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["render", _sfc_render$1], ["__scopeId", "data-v-
|
21234
|
-
const
|
21254
|
+
const Menu = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["render", _sfc_render$1], ["__scopeId", "data-v-da918768"]]);
|
21255
|
+
const Editify_vue_vue_type_style_index_0_scoped_3f1c784c_lang = "";
|
21235
21256
|
const _sfc_main = {
|
21236
21257
|
name: "editify",
|
21237
21258
|
props: { ...editorProps },
|
@@ -21268,8 +21289,8 @@ const _sfc_main = {
|
|
21268
21289
|
//类型
|
21269
21290
|
type: "text"
|
21270
21291
|
},
|
21271
|
-
//
|
21272
|
-
|
21292
|
+
//rangeUpdate更新延时器
|
21293
|
+
updateTimer: null,
|
21273
21294
|
//菜单栏是否可以使用标识
|
21274
21295
|
canUseMenu: false
|
21275
21296
|
};
|
@@ -21430,76 +21451,71 @@ const _sfc_main = {
|
|
21430
21451
|
removeScroll(this.$refs.content);
|
21431
21452
|
},
|
21432
21453
|
//工具条显示判断
|
21433
|
-
handleToolbar() {
|
21454
|
+
handleToolbar(useCache = false) {
|
21434
21455
|
if (this.disabled || this.isSourceView) {
|
21435
21456
|
return;
|
21436
21457
|
}
|
21437
|
-
|
21438
|
-
|
21439
|
-
|
21440
|
-
|
21441
|
-
this.
|
21442
|
-
this
|
21443
|
-
|
21444
|
-
|
21445
|
-
|
21446
|
-
|
21447
|
-
|
21448
|
-
|
21449
|
-
|
21450
|
-
this.toolbarOptions.
|
21451
|
-
|
21452
|
-
|
21453
|
-
|
21454
|
-
|
21455
|
-
|
21456
|
-
|
21457
|
-
|
21458
|
-
this.toolbarOptions.
|
21459
|
-
|
21460
|
-
|
21461
|
-
|
21462
|
-
|
21463
|
-
|
21464
|
-
|
21465
|
-
|
21466
|
-
this.toolbarOptions.
|
21467
|
-
|
21468
|
-
|
21469
|
-
|
21470
|
-
|
21471
|
-
|
21472
|
-
|
21473
|
-
|
21474
|
-
this.toolbarOptions.
|
21475
|
-
|
21476
|
-
|
21477
|
-
|
21478
|
-
|
21479
|
-
|
21480
|
-
|
21481
|
-
|
21482
|
-
this.toolbarOptions.
|
21458
|
+
this.hideToolbar();
|
21459
|
+
this.$nextTick(() => {
|
21460
|
+
const table = this.getCurrentParsedomElement("table", useCache);
|
21461
|
+
const pre = this.getCurrentParsedomElement("pre", true);
|
21462
|
+
const link = this.getCurrentParsedomElement("a", true);
|
21463
|
+
const image = this.getCurrentParsedomElement("img", true);
|
21464
|
+
const video = this.getCurrentParsedomElement("video", true);
|
21465
|
+
if (link) {
|
21466
|
+
this.toolbarOptions.type = "link";
|
21467
|
+
this.toolbarOptions.node = `[data-editify-uid="${this.uid}"] [data-editify-element="${link.key}"]`;
|
21468
|
+
if (this.toolbarOptions.show) {
|
21469
|
+
this.$refs.toolbar.$refs.layer.setPosition();
|
21470
|
+
} else {
|
21471
|
+
this.toolbarOptions.show = true;
|
21472
|
+
}
|
21473
|
+
} else if (image) {
|
21474
|
+
this.toolbarOptions.type = "image";
|
21475
|
+
this.toolbarOptions.node = `[data-editify-uid="${this.uid}"] [data-editify-element="${image.key}"]`;
|
21476
|
+
if (this.toolbarOptions.show) {
|
21477
|
+
this.$refs.toolbar.$refs.layer.setPosition();
|
21478
|
+
} else {
|
21479
|
+
this.toolbarOptions.show = true;
|
21480
|
+
}
|
21481
|
+
} else if (video) {
|
21482
|
+
this.toolbarOptions.type = "video";
|
21483
|
+
this.toolbarOptions.node = `[data-editify-uid="${this.uid}"] [data-editify-element="${video.key}"]`;
|
21484
|
+
if (this.toolbarOptions.show) {
|
21485
|
+
this.$refs.toolbar.$refs.layer.setPosition();
|
21486
|
+
} else {
|
21487
|
+
this.toolbarOptions.show = true;
|
21488
|
+
}
|
21489
|
+
} else if (table) {
|
21490
|
+
this.toolbarOptions.type = "table";
|
21491
|
+
this.toolbarOptions.node = `[data-editify-uid="${this.uid}"] [data-editify-element="${table.key}"]`;
|
21492
|
+
if (this.toolbarOptions.show) {
|
21493
|
+
this.$refs.toolbar.$refs.layer.setPosition();
|
21494
|
+
} else {
|
21495
|
+
this.toolbarOptions.show = true;
|
21496
|
+
}
|
21497
|
+
} else if (pre) {
|
21498
|
+
this.toolbarOptions.type = "codeBlock";
|
21499
|
+
this.toolbarOptions.node = `[data-editify-uid="${this.uid}"] [data-editify-element="${pre.key}"]`;
|
21500
|
+
if (this.toolbarOptions.show) {
|
21501
|
+
this.$refs.toolbar.$refs.layer.setPosition();
|
21502
|
+
} else {
|
21503
|
+
this.toolbarOptions.show = true;
|
21504
|
+
}
|
21505
|
+
} else {
|
21506
|
+
const result = this.editor.getElementsByRange(true).flatIncludes.filter((item) => {
|
21507
|
+
return item.element.isText();
|
21508
|
+
});
|
21509
|
+
if (result.length && !this.hasTable(true) && !this.hasPreStyle(true) && !this.hasLink(true) && !this.hasImage(true) && !this.hasVideo(true)) {
|
21510
|
+
this.toolbarOptions.type = "text";
|
21483
21511
|
if (this.toolbarOptions.show) {
|
21484
21512
|
this.$refs.toolbar.$refs.layer.setPosition();
|
21485
21513
|
} else {
|
21486
21514
|
this.toolbarOptions.show = true;
|
21487
21515
|
}
|
21488
|
-
} else {
|
21489
|
-
const result = this.editor.getElementsByRange(true, true).filter((item) => {
|
21490
|
-
return item.element.isText();
|
21491
|
-
});
|
21492
|
-
if (result.length && !this.hasTable() && !this.hasPreStyle() && !this.hasLink() && !this.hasImage() && !this.hasVideo()) {
|
21493
|
-
this.toolbarOptions.type = "text";
|
21494
|
-
if (this.toolbarOptions.show) {
|
21495
|
-
this.$refs.toolbar.$refs.layer.setPosition();
|
21496
|
-
} else {
|
21497
|
-
this.toolbarOptions.show = true;
|
21498
|
-
}
|
21499
|
-
}
|
21500
21516
|
}
|
21501
|
-
}
|
21502
|
-
}
|
21517
|
+
}
|
21518
|
+
});
|
21503
21519
|
},
|
21504
21520
|
//重新定义编辑器合并元素的逻辑
|
21505
21521
|
handleCustomMerge(ele, preEle) {
|
@@ -21741,17 +21757,25 @@ const _sfc_main = {
|
|
21741
21757
|
this.$emit("insertparagraph", this.value);
|
21742
21758
|
},
|
21743
21759
|
//编辑器焦点更新
|
21744
|
-
handleRangeUpdate(
|
21760
|
+
handleRangeUpdate() {
|
21745
21761
|
if (this.disabled) {
|
21746
21762
|
return;
|
21747
21763
|
}
|
21748
|
-
if (this.
|
21749
|
-
this.
|
21750
|
-
}
|
21751
|
-
if (this.menuConfig.use) {
|
21752
|
-
this.$refs.menu.handleRangeUpdate();
|
21764
|
+
if (this.updateTimer) {
|
21765
|
+
clearTimeout(this.updateTimer);
|
21753
21766
|
}
|
21754
|
-
this
|
21767
|
+
this.updateTimer = setTimeout(() => {
|
21768
|
+
if (this.toolbarConfig.use || this.menuConfig.use) {
|
21769
|
+
this.editor.getElementsByRange();
|
21770
|
+
if (this.toolbarConfig.use) {
|
21771
|
+
this.handleToolbar(true);
|
21772
|
+
}
|
21773
|
+
if (this.menuConfig.use) {
|
21774
|
+
this.$refs.menu.handleRangeUpdate(true);
|
21775
|
+
}
|
21776
|
+
}
|
21777
|
+
}, 200);
|
21778
|
+
this.$emit("rangeupdate", this.value);
|
21755
21779
|
},
|
21756
21780
|
//编辑器复制
|
21757
21781
|
handleCopy(text2, html) {
|
@@ -21766,7 +21790,7 @@ const _sfc_main = {
|
|
21766
21790
|
this.$emit("paste-text", data2);
|
21767
21791
|
},
|
21768
21792
|
//编辑器粘贴html
|
21769
|
-
handlePasteHtml(elements
|
21793
|
+
handlePasteHtml(elements) {
|
21770
21794
|
const keepStyles = Object.assign(pasteKeepData.styles, this.pasteKeepStyles || {});
|
21771
21795
|
const keepMarks = Object.assign(pasteKeepData.marks, this.pasteKeepMarks || {});
|
21772
21796
|
AlexElement.flatElements(elements).forEach((el) => {
|
@@ -21866,7 +21890,7 @@ const _sfc_main = {
|
|
21866
21890
|
return this.getParsedomElementByElement(element2.parent, parsedom);
|
21867
21891
|
},
|
21868
21892
|
//api:获取光标是否在指定标签元素下,如果是返回该标签元素,否则返回null
|
21869
|
-
getCurrentParsedomElement(parsedom) {
|
21893
|
+
getCurrentParsedomElement(parsedom, useCache = false) {
|
21870
21894
|
if (this.disabled) {
|
21871
21895
|
return null;
|
21872
21896
|
}
|
@@ -21876,7 +21900,7 @@ const _sfc_main = {
|
|
21876
21900
|
if (this.editor.range.anchor.element.isEqual(this.editor.range.focus.element)) {
|
21877
21901
|
return this.getParsedomElementByElement(this.editor.range.anchor.element, parsedom);
|
21878
21902
|
}
|
21879
|
-
const arr = this.editor.getElementsByRange(
|
21903
|
+
const arr = this.editor.getElementsByRange(useCache).includes.map((item) => {
|
21880
21904
|
return this.getParsedomElementByElement(item.element, parsedom);
|
21881
21905
|
});
|
21882
21906
|
let hasNull = arr.some((el) => {
|
@@ -21901,14 +21925,14 @@ const _sfc_main = {
|
|
21901
21925
|
return null;
|
21902
21926
|
},
|
21903
21927
|
//api:删除光标所在的指定标签元素
|
21904
|
-
deleteByParsedom(parsedom, isRender = true) {
|
21928
|
+
deleteByParsedom(parsedom, isRender = true, useCache = false) {
|
21905
21929
|
if (this.disabled) {
|
21906
21930
|
return;
|
21907
21931
|
}
|
21908
21932
|
if (!this.editor.range) {
|
21909
21933
|
return;
|
21910
21934
|
}
|
21911
|
-
const element2 = this.getCurrentParsedomElement(parsedom);
|
21935
|
+
const element2 = this.getCurrentParsedomElement(parsedom, useCache);
|
21912
21936
|
if (element2) {
|
21913
21937
|
element2.toEmpty();
|
21914
21938
|
if (isRender) {
|
@@ -21919,14 +21943,14 @@ const _sfc_main = {
|
|
21919
21943
|
}
|
21920
21944
|
},
|
21921
21945
|
//api:当光标在链接上时可以移除链接
|
21922
|
-
removeLink(isRender = true) {
|
21946
|
+
removeLink(isRender = true, useCache = false) {
|
21923
21947
|
if (this.disabled) {
|
21924
21948
|
return;
|
21925
21949
|
}
|
21926
21950
|
if (!this.editor.range) {
|
21927
21951
|
return;
|
21928
21952
|
}
|
21929
|
-
const link = this.getCurrentParsedomElement("a");
|
21953
|
+
const link = this.getCurrentParsedomElement("a", useCache);
|
21930
21954
|
if (link) {
|
21931
21955
|
link.parsedom = AlexElement.TEXT_NODE;
|
21932
21956
|
delete link.marks.target;
|
@@ -21939,7 +21963,7 @@ const _sfc_main = {
|
|
21939
21963
|
}
|
21940
21964
|
},
|
21941
21965
|
//api:设置标题
|
21942
|
-
setHeading(parsedom, isRender = true) {
|
21966
|
+
setHeading(parsedom, isRender = true, useCache = false) {
|
21943
21967
|
if (this.disabled) {
|
21944
21968
|
return;
|
21945
21969
|
}
|
@@ -21957,7 +21981,7 @@ const _sfc_main = {
|
|
21957
21981
|
blockToParagraph(block);
|
21958
21982
|
block.parsedom = parsedom;
|
21959
21983
|
} else {
|
21960
|
-
const result = this.editor.getElementsByRange(
|
21984
|
+
const result = this.editor.getElementsByRange(useCache).includes;
|
21961
21985
|
result.forEach((el) => {
|
21962
21986
|
if (el.element.isBlock()) {
|
21963
21987
|
blockToParagraph(el.element);
|
@@ -21976,7 +22000,7 @@ const _sfc_main = {
|
|
21976
22000
|
}
|
21977
22001
|
},
|
21978
22002
|
//api:插入有序列表 ordered为true表示有序列表
|
21979
|
-
setList(ordered, isRender = true) {
|
22003
|
+
setList(ordered, isRender = true, useCache = false) {
|
21980
22004
|
if (this.disabled) {
|
21981
22005
|
return;
|
21982
22006
|
}
|
@@ -21993,7 +22017,7 @@ const _sfc_main = {
|
|
21993
22017
|
}
|
21994
22018
|
} else {
|
21995
22019
|
let blocks = [];
|
21996
|
-
const result = this.editor.getElementsByRange(
|
22020
|
+
const result = this.editor.getElementsByRange(useCache).includes;
|
21997
22021
|
result.forEach((item) => {
|
21998
22022
|
const block = item.element.getBlock();
|
21999
22023
|
const exist = blocks.some((el) => block.isEqual(el));
|
@@ -22017,7 +22041,7 @@ const _sfc_main = {
|
|
22017
22041
|
}
|
22018
22042
|
},
|
22019
22043
|
//api:插入任务列表
|
22020
|
-
setTask(isRender = true) {
|
22044
|
+
setTask(isRender = true, useCache = false) {
|
22021
22045
|
if (this.disabled) {
|
22022
22046
|
return;
|
22023
22047
|
}
|
@@ -22034,7 +22058,7 @@ const _sfc_main = {
|
|
22034
22058
|
}
|
22035
22059
|
} else {
|
22036
22060
|
let blocks = [];
|
22037
|
-
const result = this.editor.getElementsByRange(
|
22061
|
+
const result = this.editor.getElementsByRange(useCache).includes;
|
22038
22062
|
result.forEach((item) => {
|
22039
22063
|
const block = item.element.getBlock();
|
22040
22064
|
const exist = blocks.some((el) => block.isEqual(el));
|
@@ -22058,20 +22082,20 @@ const _sfc_main = {
|
|
22058
22082
|
}
|
22059
22083
|
},
|
22060
22084
|
//api:设置样式
|
22061
|
-
setTextStyle(name, value, isRender = true) {
|
22085
|
+
setTextStyle(name, value, isRender = true, useCache = false) {
|
22062
22086
|
if (this.disabled) {
|
22063
22087
|
return;
|
22064
22088
|
}
|
22065
22089
|
if (!this.editor.range) {
|
22066
22090
|
return;
|
22067
22091
|
}
|
22068
|
-
const active = this.queryTextStyle(name, value);
|
22092
|
+
const active = this.queryTextStyle(name, value, useCache);
|
22069
22093
|
if (active) {
|
22070
|
-
this.editor.removeTextStyle([name]);
|
22094
|
+
this.editor.removeTextStyle([name], true);
|
22071
22095
|
} else {
|
22072
22096
|
let styles = {};
|
22073
22097
|
styles[name] = value;
|
22074
|
-
this.editor.setTextStyle(styles);
|
22098
|
+
this.editor.setTextStyle(styles, true);
|
22075
22099
|
}
|
22076
22100
|
if (isRender) {
|
22077
22101
|
this.editor.formatElementStack();
|
@@ -22080,24 +22104,24 @@ const _sfc_main = {
|
|
22080
22104
|
}
|
22081
22105
|
},
|
22082
22106
|
//api:查询是否具有某个样式
|
22083
|
-
queryTextStyle(name, value, useCache) {
|
22107
|
+
queryTextStyle(name, value, useCache = false) {
|
22084
22108
|
return this.editor.queryTextStyle(name, value, useCache);
|
22085
22109
|
},
|
22086
22110
|
//api:设置标记
|
22087
|
-
setTextMark(name, value, isRender = true) {
|
22111
|
+
setTextMark(name, value, isRender = true, useCache = false) {
|
22088
22112
|
if (this.disabled) {
|
22089
22113
|
return;
|
22090
22114
|
}
|
22091
22115
|
if (!this.editor.range) {
|
22092
22116
|
return;
|
22093
22117
|
}
|
22094
|
-
const active = this.queryTextMark(name, value);
|
22118
|
+
const active = this.queryTextMark(name, value, useCache);
|
22095
22119
|
if (active) {
|
22096
|
-
this.editor.removeTextMark([name]);
|
22120
|
+
this.editor.removeTextMark([name], true);
|
22097
22121
|
} else {
|
22098
22122
|
let marks = {};
|
22099
22123
|
marks[name] = value;
|
22100
|
-
this.editor.setTextMark(marks);
|
22124
|
+
this.editor.setTextMark(marks, true);
|
22101
22125
|
}
|
22102
22126
|
if (isRender) {
|
22103
22127
|
this.editor.formatElementStack();
|
@@ -22106,19 +22130,19 @@ const _sfc_main = {
|
|
22106
22130
|
}
|
22107
22131
|
},
|
22108
22132
|
//api:查询是否具有某个标记
|
22109
|
-
queryTextMark(name, value, useCache) {
|
22133
|
+
queryTextMark(name, value, useCache = false) {
|
22110
22134
|
return this.editor.queryTextMark(name, value, useCache);
|
22111
22135
|
},
|
22112
22136
|
//api:清除文本样式和标记
|
22113
|
-
formatText(isRender = true) {
|
22137
|
+
formatText(isRender = true, useCache = false) {
|
22114
22138
|
if (this.disabled) {
|
22115
22139
|
return;
|
22116
22140
|
}
|
22117
22141
|
if (!this.editor.range) {
|
22118
22142
|
return;
|
22119
22143
|
}
|
22120
|
-
this.editor.removeTextStyle();
|
22121
|
-
this.editor.removeTextMark();
|
22144
|
+
this.editor.removeTextStyle(null, useCache);
|
22145
|
+
this.editor.removeTextMark(null);
|
22122
22146
|
if (isRender) {
|
22123
22147
|
this.editor.formatElementStack();
|
22124
22148
|
this.editor.domRender();
|
@@ -22126,7 +22150,7 @@ const _sfc_main = {
|
|
22126
22150
|
}
|
22127
22151
|
},
|
22128
22152
|
//api:设置对齐方式,参数取值justify/left/right/center
|
22129
|
-
setAlign(value, isRender = true) {
|
22153
|
+
setAlign(value, isRender = true, useCache = false) {
|
22130
22154
|
if (this.disabled) {
|
22131
22155
|
return;
|
22132
22156
|
}
|
@@ -22154,7 +22178,7 @@ const _sfc_main = {
|
|
22154
22178
|
}
|
22155
22179
|
}
|
22156
22180
|
} else {
|
22157
|
-
const result = this.editor.getElementsByRange(
|
22181
|
+
const result = this.editor.getElementsByRange(useCache).includes;
|
22158
22182
|
result.forEach((el) => {
|
22159
22183
|
if (el.element.isBlock() || el.element.isInblock()) {
|
22160
22184
|
if (el.element.hasStyles()) {
|
@@ -22224,7 +22248,7 @@ const _sfc_main = {
|
|
22224
22248
|
}
|
22225
22249
|
},
|
22226
22250
|
//api:插入引用
|
22227
|
-
setQuote(isRender = true) {
|
22251
|
+
setQuote(isRender = true, useCache = false) {
|
22228
22252
|
if (this.disabled) {
|
22229
22253
|
return;
|
22230
22254
|
}
|
@@ -22240,7 +22264,7 @@ const _sfc_main = {
|
|
22240
22264
|
}
|
22241
22265
|
} else {
|
22242
22266
|
let blocks = [];
|
22243
|
-
const result = this.editor.getElementsByRange(
|
22267
|
+
const result = this.editor.getElementsByRange(useCache).includes;
|
22244
22268
|
result.forEach((item) => {
|
22245
22269
|
const block = item.element.getBlock();
|
22246
22270
|
const exist = blocks.some((el) => block.isEqual(el));
|
@@ -22263,7 +22287,7 @@ const _sfc_main = {
|
|
22263
22287
|
}
|
22264
22288
|
},
|
22265
22289
|
//api:设置行高
|
22266
|
-
setLineHeight(value, isRender = true) {
|
22290
|
+
setLineHeight(value, isRender = true, useCache = false) {
|
22267
22291
|
if (this.disabled) {
|
22268
22292
|
return;
|
22269
22293
|
}
|
@@ -22291,7 +22315,7 @@ const _sfc_main = {
|
|
22291
22315
|
}
|
22292
22316
|
}
|
22293
22317
|
} else {
|
22294
|
-
const result = this.editor.getElementsByRange(
|
22318
|
+
const result = this.editor.getElementsByRange(useCache).includes;
|
22295
22319
|
result.forEach((el) => {
|
22296
22320
|
if (el.element.isBlock() || el.element.isInblock()) {
|
22297
22321
|
if (el.element.hasStyles()) {
|
@@ -22331,7 +22355,7 @@ const _sfc_main = {
|
|
22331
22355
|
}
|
22332
22356
|
},
|
22333
22357
|
//api:增加缩进
|
22334
|
-
setIndentIncrease(isRender = true) {
|
22358
|
+
setIndentIncrease(isRender = true, useCache = false) {
|
22335
22359
|
if (this.disabled) {
|
22336
22360
|
return;
|
22337
22361
|
}
|
@@ -22366,7 +22390,7 @@ const _sfc_main = {
|
|
22366
22390
|
fn(block);
|
22367
22391
|
}
|
22368
22392
|
} else {
|
22369
|
-
const result = this.editor.getElementsByRange(
|
22393
|
+
const result = this.editor.getElementsByRange(useCache).includes;
|
22370
22394
|
result.forEach((item) => {
|
22371
22395
|
const block = item.element.getBlock();
|
22372
22396
|
const inblock = item.element.getInblock();
|
@@ -22384,7 +22408,7 @@ const _sfc_main = {
|
|
22384
22408
|
}
|
22385
22409
|
},
|
22386
22410
|
//api:减少缩进
|
22387
|
-
setIndentDecrease(isRender = true) {
|
22411
|
+
setIndentDecrease(isRender = true, useCache = false) {
|
22388
22412
|
if (this.disabled) {
|
22389
22413
|
return;
|
22390
22414
|
}
|
@@ -22411,7 +22435,7 @@ const _sfc_main = {
|
|
22411
22435
|
fn(block);
|
22412
22436
|
}
|
22413
22437
|
} else {
|
22414
|
-
const result = this.editor.getElementsByRange(
|
22438
|
+
const result = this.editor.getElementsByRange(useCache).includes;
|
22415
22439
|
result.forEach((item) => {
|
22416
22440
|
const block = item.element.getBlock();
|
22417
22441
|
const inblock = item.element.getInblock();
|
@@ -22429,7 +22453,7 @@ const _sfc_main = {
|
|
22429
22453
|
}
|
22430
22454
|
},
|
22431
22455
|
//api:插入图片
|
22432
|
-
insertImage(url2, isRender = true) {
|
22456
|
+
insertImage(url2, isRender = true, useCache = false) {
|
22433
22457
|
if (this.disabled) {
|
22434
22458
|
return;
|
22435
22459
|
}
|
@@ -22448,7 +22472,7 @@ const _sfc_main = {
|
|
22448
22472
|
null,
|
22449
22473
|
null
|
22450
22474
|
);
|
22451
|
-
this.editor.insertElement(image);
|
22475
|
+
this.editor.insertElement(image, true, useCache);
|
22452
22476
|
if (isRender) {
|
22453
22477
|
this.editor.formatElementStack();
|
22454
22478
|
this.editor.domRender();
|
@@ -22456,7 +22480,7 @@ const _sfc_main = {
|
|
22456
22480
|
}
|
22457
22481
|
},
|
22458
22482
|
//api:插入视频
|
22459
|
-
insertVideo(url2, isRender = true) {
|
22483
|
+
insertVideo(url2, isRender = true, useCache = false) {
|
22460
22484
|
if (this.disabled) {
|
22461
22485
|
return;
|
22462
22486
|
}
|
@@ -22475,7 +22499,7 @@ const _sfc_main = {
|
|
22475
22499
|
null,
|
22476
22500
|
null
|
22477
22501
|
);
|
22478
|
-
this.editor.insertElement(video);
|
22502
|
+
this.editor.insertElement(video, true, useCache);
|
22479
22503
|
const leftSpace = AlexElement.getSpaceElement();
|
22480
22504
|
const rightSpace = AlexElement.getSpaceElement();
|
22481
22505
|
this.editor.addElementAfter(rightSpace, video);
|
@@ -22489,20 +22513,20 @@ const _sfc_main = {
|
|
22489
22513
|
}
|
22490
22514
|
},
|
22491
22515
|
//api:选区是否含有代码块样式
|
22492
|
-
hasPreStyle() {
|
22516
|
+
hasPreStyle(useCache = false) {
|
22493
22517
|
if (!this.editor.range) {
|
22494
22518
|
return false;
|
22495
22519
|
}
|
22496
22520
|
if (this.editor.range.anchor.isEqual(this.editor.range.focus)) {
|
22497
22521
|
return this.editor.range.anchor.element.isPreStyle();
|
22498
22522
|
}
|
22499
|
-
const result = this.editor.getElementsByRange(
|
22523
|
+
const result = this.editor.getElementsByRange(useCache).includes;
|
22500
22524
|
return result.some((item) => {
|
22501
22525
|
return item.element.isPreStyle();
|
22502
22526
|
});
|
22503
22527
|
},
|
22504
22528
|
//api:选区是否含有引用
|
22505
|
-
hasQuote() {
|
22529
|
+
hasQuote(useCache = false) {
|
22506
22530
|
if (!this.editor.range) {
|
22507
22531
|
return false;
|
22508
22532
|
}
|
@@ -22510,7 +22534,7 @@ const _sfc_main = {
|
|
22510
22534
|
const block = this.editor.range.anchor.element.getBlock();
|
22511
22535
|
return block.parsedom == "blockquote";
|
22512
22536
|
}
|
22513
|
-
const result = this.editor.getElementsByRange(
|
22537
|
+
const result = this.editor.getElementsByRange(useCache).includes;
|
22514
22538
|
return result.some((item) => {
|
22515
22539
|
if (item.element.isBlock()) {
|
22516
22540
|
return item.element.parsedom == "blockquote";
|
@@ -22521,7 +22545,7 @@ const _sfc_main = {
|
|
22521
22545
|
});
|
22522
22546
|
},
|
22523
22547
|
//api:选区是否含有列表
|
22524
|
-
hasList(ordered = false) {
|
22548
|
+
hasList(ordered = false, useCache = false) {
|
22525
22549
|
if (!this.editor.range) {
|
22526
22550
|
return false;
|
22527
22551
|
}
|
@@ -22529,7 +22553,7 @@ const _sfc_main = {
|
|
22529
22553
|
const block = this.editor.range.anchor.element.getBlock();
|
22530
22554
|
return blockIsList(block, ordered);
|
22531
22555
|
}
|
22532
|
-
const result = this.editor.getElementsByRange(
|
22556
|
+
const result = this.editor.getElementsByRange(useCache).includes;
|
22533
22557
|
return result.some((item) => {
|
22534
22558
|
if (item.element.isBlock()) {
|
22535
22559
|
return blockIsList(item.element, ordered);
|
@@ -22540,14 +22564,14 @@ const _sfc_main = {
|
|
22540
22564
|
});
|
22541
22565
|
},
|
22542
22566
|
//api:选区是否含有链接
|
22543
|
-
hasLink() {
|
22567
|
+
hasLink(useCache = false) {
|
22544
22568
|
if (!this.editor.range) {
|
22545
22569
|
return false;
|
22546
22570
|
}
|
22547
22571
|
if (this.editor.range.anchor.isEqual(this.editor.range.focus)) {
|
22548
22572
|
return !!this.getParsedomElementByElement(this.editor.range.anchor.element, "a");
|
22549
22573
|
}
|
22550
|
-
const result = this.editor.getElementsByRange(
|
22574
|
+
const result = this.editor.getElementsByRange(useCache).flatIncludes.filter((item) => {
|
22551
22575
|
return item.element.isText();
|
22552
22576
|
});
|
22553
22577
|
return result.some((item) => {
|
@@ -22555,7 +22579,7 @@ const _sfc_main = {
|
|
22555
22579
|
});
|
22556
22580
|
},
|
22557
22581
|
//api:选区是否含有表格
|
22558
|
-
hasTable() {
|
22582
|
+
hasTable(useCache = false) {
|
22559
22583
|
if (!this.editor.range) {
|
22560
22584
|
return false;
|
22561
22585
|
}
|
@@ -22563,7 +22587,7 @@ const _sfc_main = {
|
|
22563
22587
|
const block = this.editor.range.anchor.element.getBlock();
|
22564
22588
|
return block.parsedom == "table";
|
22565
22589
|
}
|
22566
|
-
const result = this.editor.getElementsByRange(
|
22590
|
+
const result = this.editor.getElementsByRange(useCache).includes;
|
22567
22591
|
return result.some((item) => {
|
22568
22592
|
if (item.element.isBlock()) {
|
22569
22593
|
return item.element.parsedom == "table";
|
@@ -22574,7 +22598,7 @@ const _sfc_main = {
|
|
22574
22598
|
});
|
22575
22599
|
},
|
22576
22600
|
//api:选区是否含有任务列表
|
22577
|
-
hasTask() {
|
22601
|
+
hasTask(useCache = false) {
|
22578
22602
|
if (!this.editor.range) {
|
22579
22603
|
return false;
|
22580
22604
|
}
|
@@ -22582,7 +22606,7 @@ const _sfc_main = {
|
|
22582
22606
|
const block = this.editor.range.anchor.element.getBlock();
|
22583
22607
|
return blockIsTask(block);
|
22584
22608
|
}
|
22585
|
-
const result = this.editor.getElementsByRange(
|
22609
|
+
const result = this.editor.getElementsByRange(useCache).includes;
|
22586
22610
|
return result.some((item) => {
|
22587
22611
|
if (item.element.isBlock()) {
|
22588
22612
|
return blockIsTask(item.element);
|
@@ -22593,33 +22617,33 @@ const _sfc_main = {
|
|
22593
22617
|
});
|
22594
22618
|
},
|
22595
22619
|
//api:选区是否含有图片
|
22596
|
-
hasImage() {
|
22620
|
+
hasImage(useCache = false) {
|
22597
22621
|
if (!this.editor.range) {
|
22598
22622
|
return false;
|
22599
22623
|
}
|
22600
22624
|
if (this.editor.range.anchor.isEqual(this.editor.range.focus)) {
|
22601
22625
|
return this.editor.range.anchor.element.isClosed() && this.editor.range.anchor.element.parsedom == "img";
|
22602
22626
|
}
|
22603
|
-
const result = this.editor.getElementsByRange(
|
22627
|
+
const result = this.editor.getElementsByRange(useCache).flatIncludes;
|
22604
22628
|
return result.some((item) => {
|
22605
22629
|
return item.element.isClosed() && item.element.parsedom == "img";
|
22606
22630
|
});
|
22607
22631
|
},
|
22608
22632
|
//api:选区是否含有视频
|
22609
|
-
hasVideo() {
|
22633
|
+
hasVideo(useCache = false) {
|
22610
22634
|
if (!this.editor.range) {
|
22611
22635
|
return false;
|
22612
22636
|
}
|
22613
22637
|
if (this.editor.range.anchor.isEqual(this.editor.range.focus)) {
|
22614
22638
|
return this.editor.range.anchor.element.isClosed() && this.editor.range.anchor.element.parsedom == "video";
|
22615
22639
|
}
|
22616
|
-
const result = this.editor.getElementsByRange(
|
22640
|
+
const result = this.editor.getElementsByRange(useCache).flatIncludes;
|
22617
22641
|
return result.some((item) => {
|
22618
22642
|
return item.element.isClosed() && item.element.parsedom == "video";
|
22619
22643
|
});
|
22620
22644
|
},
|
22621
22645
|
//api:选区是否全部在引用内
|
22622
|
-
inQuote() {
|
22646
|
+
inQuote(useCache = false) {
|
22623
22647
|
if (!this.editor.range) {
|
22624
22648
|
return false;
|
22625
22649
|
}
|
@@ -22627,7 +22651,7 @@ const _sfc_main = {
|
|
22627
22651
|
const block = this.editor.range.anchor.element.getBlock();
|
22628
22652
|
return block.parsedom == "blockquote";
|
22629
22653
|
}
|
22630
|
-
const result = this.editor.getElementsByRange(
|
22654
|
+
const result = this.editor.getElementsByRange(useCache).includes;
|
22631
22655
|
return result.every((item) => {
|
22632
22656
|
if (item.element.isBlock()) {
|
22633
22657
|
return item.element.parsedom == "blockquote";
|
@@ -22638,7 +22662,7 @@ const _sfc_main = {
|
|
22638
22662
|
});
|
22639
22663
|
},
|
22640
22664
|
//api:选区是否全部在列表内
|
22641
|
-
inList(ordered = false) {
|
22665
|
+
inList(ordered = false, useCache = false) {
|
22642
22666
|
if (!this.editor.range) {
|
22643
22667
|
return false;
|
22644
22668
|
}
|
@@ -22646,7 +22670,7 @@ const _sfc_main = {
|
|
22646
22670
|
const block = this.editor.range.anchor.element.getBlock();
|
22647
22671
|
return blockIsList(block, ordered);
|
22648
22672
|
}
|
22649
|
-
const result = this.editor.getElementsByRange(
|
22673
|
+
const result = this.editor.getElementsByRange(useCache).includes;
|
22650
22674
|
return result.every((item) => {
|
22651
22675
|
if (item.element.isBlock()) {
|
22652
22676
|
return blockIsList(item.element, ordered);
|
@@ -22657,7 +22681,7 @@ const _sfc_main = {
|
|
22657
22681
|
});
|
22658
22682
|
},
|
22659
22683
|
//api:选区是否全部在任务列表里
|
22660
|
-
inTask() {
|
22684
|
+
inTask(useCache = false) {
|
22661
22685
|
if (!this.editor.range) {
|
22662
22686
|
return false;
|
22663
22687
|
}
|
@@ -22665,7 +22689,7 @@ const _sfc_main = {
|
|
22665
22689
|
const block = this.editor.range.anchor.element.getBlock();
|
22666
22690
|
return blockIsTask(block);
|
22667
22691
|
}
|
22668
|
-
const result = this.editor.getElementsByRange(
|
22692
|
+
const result = this.editor.getElementsByRange(useCache).includes;
|
22669
22693
|
return result.every((item) => {
|
22670
22694
|
if (item.element.isBlock()) {
|
22671
22695
|
return blockIsTask(item.element);
|
@@ -22676,7 +22700,7 @@ const _sfc_main = {
|
|
22676
22700
|
});
|
22677
22701
|
},
|
22678
22702
|
//api:创建一个空的表格
|
22679
|
-
insertTable(rowLength, colLength, isRender = true) {
|
22703
|
+
insertTable(rowLength, colLength, isRender = true, useCache = false) {
|
22680
22704
|
if (this.disabled) {
|
22681
22705
|
return;
|
22682
22706
|
}
|
@@ -22696,7 +22720,7 @@ const _sfc_main = {
|
|
22696
22720
|
}
|
22697
22721
|
this.editor.addElementTo(row, tbody);
|
22698
22722
|
}
|
22699
|
-
this.editor.insertElement(table);
|
22723
|
+
this.editor.insertElement(table, true, useCache);
|
22700
22724
|
const paragraph = new AlexElement("block", AlexElement.BLOCK_NODE, null, null, null);
|
22701
22725
|
const breakEl = new AlexElement("closed", "br", null, null, null);
|
22702
22726
|
this.editor.addElementTo(breakEl, paragraph);
|
@@ -22710,14 +22734,14 @@ const _sfc_main = {
|
|
22710
22734
|
}
|
22711
22735
|
},
|
22712
22736
|
//api:插入代码块
|
22713
|
-
insertCodeBlock(isRender = true) {
|
22737
|
+
insertCodeBlock(isRender = true, useCache = false) {
|
22714
22738
|
if (this.disabled) {
|
22715
22739
|
return;
|
22716
22740
|
}
|
22717
22741
|
if (!this.editor.range) {
|
22718
22742
|
return;
|
22719
22743
|
}
|
22720
|
-
const pre = this.getCurrentParsedomElement("pre");
|
22744
|
+
const pre = this.getCurrentParsedomElement("pre", useCache);
|
22721
22745
|
if (pre) {
|
22722
22746
|
let content = "";
|
22723
22747
|
AlexElement.flatElements(pre.children).filter((item) => {
|
@@ -22743,10 +22767,10 @@ const _sfc_main = {
|
|
22743
22767
|
this.editor.addElementTo(breakEl, paragraph);
|
22744
22768
|
this.editor.addElementAfter(paragraph, block);
|
22745
22769
|
} else {
|
22746
|
-
let result = this.editor.getElementsByRange(true
|
22770
|
+
let result = this.editor.getElementsByRange(true).includes;
|
22747
22771
|
this.editor.range.anchor.moveToStart(result[0].element.getBlock());
|
22748
22772
|
this.editor.range.focus.moveToEnd(result[result.length - 1].element.getBlock());
|
22749
|
-
const res = this.editor.getElementsByRange(true
|
22773
|
+
const res = this.editor.getElementsByRange(true).flatIncludes.filter((el) => el.element.isText());
|
22750
22774
|
const obj2 = {};
|
22751
22775
|
res.forEach((el) => {
|
22752
22776
|
if (obj2[el.element.getBlock().key]) {
|
@@ -22788,14 +22812,14 @@ const _sfc_main = {
|
|
22788
22812
|
}
|
22789
22813
|
},
|
22790
22814
|
//api:插入文本
|
22791
|
-
insertText(text2, isRender = true) {
|
22815
|
+
insertText(text2, isRender = true, useCache = false) {
|
22792
22816
|
if (this.disabled) {
|
22793
22817
|
return;
|
22794
22818
|
}
|
22795
22819
|
if (!this.editor.range) {
|
22796
22820
|
return;
|
22797
22821
|
}
|
22798
|
-
this.editor.insertText(text2);
|
22822
|
+
this.editor.insertText(text2, useCache);
|
22799
22823
|
if (isRender) {
|
22800
22824
|
this.editor.formatElementStack();
|
22801
22825
|
this.editor.domRender();
|
@@ -22803,7 +22827,7 @@ const _sfc_main = {
|
|
22803
22827
|
}
|
22804
22828
|
},
|
22805
22829
|
//api:插入html
|
22806
|
-
insertHtml(html, isRender = true) {
|
22830
|
+
insertHtml(html, isRender = true, useCache = false) {
|
22807
22831
|
if (this.disabled) {
|
22808
22832
|
return;
|
22809
22833
|
}
|
@@ -22812,7 +22836,7 @@ const _sfc_main = {
|
|
22812
22836
|
}
|
22813
22837
|
const elements = this.editor.parseHtml(html);
|
22814
22838
|
for (let i = 0; i < elements.length; i++) {
|
22815
|
-
this.editor.insertElement(elements[i], false);
|
22839
|
+
this.editor.insertElement(elements[i], false, i == 0 ? useCache : false);
|
22816
22840
|
}
|
22817
22841
|
if (isRender) {
|
22818
22842
|
this.editor.formatElementStack();
|
@@ -22883,7 +22907,7 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
22883
22907
|
])) : createCommentVNode("", true)
|
22884
22908
|
]);
|
22885
22909
|
}
|
22886
|
-
const Editify = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render], ["__scopeId", "data-v-
|
22910
|
+
const Editify = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render], ["__scopeId", "data-v-3f1c784c"]]);
|
22887
22911
|
const iconfont = "";
|
22888
22912
|
const en_US = {
|
22889
22913
|
textWrapUp: "Up feed",
|
@@ -23064,7 +23088,7 @@ const i18n = (locale) => {
|
|
23064
23088
|
return translations[locale][key];
|
23065
23089
|
};
|
23066
23090
|
};
|
23067
|
-
const version = "0.0.
|
23091
|
+
const version = "0.0.48";
|
23068
23092
|
const install = (app, props) => {
|
23069
23093
|
const locale = (props ? props.locale : "zh_CN") || "zh_CN";
|
23070
23094
|
app.provide("$editTrans", i18n(locale));
|