vue-editify 0.0.46 → 0.0.47
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 +6 -5
- package/lib/editify.es.js +224 -203
- package/lib/editify.umd.js +1 -1
- package/lib/style.css +1 -1
- package/package.json +2 -2
- package/src/Editify.vue +135 -128
- package/src/components/bussiness/Menu.vue +14 -12
- package/src/components/bussiness/Toolbar.vue +18 -20
- package/src/index.js +1 -1
package/lib/editify.es.js
CHANGED
@@ -3277,7 +3277,16 @@ class AlexEditor {
|
|
3277
3277
|
this.__isInputChinese = false;
|
3278
3278
|
this.__innerSelectionChange = false;
|
3279
3279
|
this.__chineseInputTimer = null;
|
3280
|
-
this.
|
3280
|
+
this.__rangeElementsCache = {
|
3281
|
+
//includes和flat都是true
|
3282
|
+
all: [],
|
3283
|
+
//includes为true
|
3284
|
+
includes: [],
|
3285
|
+
//flat为true
|
3286
|
+
flat: [],
|
3287
|
+
//includes和flat都是false
|
3288
|
+
none: []
|
3289
|
+
};
|
3281
3290
|
this.disabled ? this.setDisabled() : this.setEnabled();
|
3282
3291
|
obj$1.event.on(document, `selectionchange.alex_editor_${this.__guid}`, handleSelectionChange.bind(this));
|
3283
3292
|
obj$1.event.on(this.$el, "beforeinput.alex_editor", handleBeforeInput.bind(this));
|
@@ -4428,24 +4437,48 @@ class AlexEditor {
|
|
4428
4437
|
/**
|
4429
4438
|
* 获取选区之间的元素
|
4430
4439
|
*/
|
4431
|
-
getElementsByRange(includes = false, flat = false) {
|
4440
|
+
getElementsByRange(includes = false, flat = false, useCache = false) {
|
4432
4441
|
if (!this.range) {
|
4433
4442
|
return [];
|
4434
4443
|
}
|
4435
4444
|
if (this.range.anchor.isEqual(this.range.focus)) {
|
4436
4445
|
return [];
|
4437
4446
|
}
|
4447
|
+
if (useCache) {
|
4448
|
+
if (includes && flat) {
|
4449
|
+
return this.__rangeElementsCache.all || [];
|
4450
|
+
}
|
4451
|
+
if (includes) {
|
4452
|
+
return this.__rangeElementsCache.includes || [];
|
4453
|
+
}
|
4454
|
+
if (flat) {
|
4455
|
+
return this.__rangeElementsCache.flat || [];
|
4456
|
+
}
|
4457
|
+
return this.__rangeElementsCache.none || [];
|
4458
|
+
}
|
4459
|
+
const setRangeElementsCache = (result2 = []) => {
|
4460
|
+
if (includes && flat) {
|
4461
|
+
this.__rangeElementsCache.all = result2;
|
4462
|
+
} else if (includes) {
|
4463
|
+
this.__rangeElementsCache.includes = result2;
|
4464
|
+
} else if (flat) {
|
4465
|
+
this.__rangeElementsCache.flat = result2;
|
4466
|
+
} else {
|
4467
|
+
this.__rangeElementsCache.none = result2;
|
4468
|
+
}
|
4469
|
+
return result2;
|
4470
|
+
};
|
4438
4471
|
if (this.range.anchor.element.isEqual(this.range.focus.element)) {
|
4439
4472
|
if (includes) {
|
4440
4473
|
const isCover = this.range.anchor.offset == 0 && this.range.focus.offset == (this.range.anchor.element.isText() ? this.range.anchor.element.textContent.length : 1);
|
4441
|
-
return [
|
4474
|
+
return setRangeElementsCache([
|
4442
4475
|
{
|
4443
4476
|
element: this.range.anchor.element,
|
4444
4477
|
offset: isCover ? false : [this.range.anchor.offset, this.range.focus.offset]
|
4445
4478
|
}
|
4446
|
-
];
|
4479
|
+
]);
|
4447
4480
|
}
|
4448
|
-
return
|
4481
|
+
return setRangeElementsCache();
|
4449
4482
|
}
|
4450
4483
|
let result = [];
|
4451
4484
|
if (includes) {
|
@@ -4520,7 +4553,7 @@ class AlexEditor {
|
|
4520
4553
|
}
|
4521
4554
|
}
|
4522
4555
|
if (flat) {
|
4523
|
-
return newResult;
|
4556
|
+
return setRangeElementsCache(newResult);
|
4524
4557
|
}
|
4525
4558
|
let notFlatResult = [];
|
4526
4559
|
const length = newResult.length;
|
@@ -4534,16 +4567,16 @@ class AlexEditor {
|
|
4534
4567
|
}
|
4535
4568
|
}
|
4536
4569
|
}
|
4537
|
-
return notFlatResult;
|
4570
|
+
return setRangeElementsCache(notFlatResult);
|
4538
4571
|
}
|
4539
4572
|
/**
|
4540
4573
|
* 分割选区选中的元素,会更新光标位置
|
4541
4574
|
*/
|
4542
|
-
splitElementsByRange(includes = false, flat = false) {
|
4575
|
+
splitElementsByRange(includes = false, flat = false, useCache = false) {
|
4543
4576
|
if (!this.range) {
|
4544
4577
|
return [];
|
4545
4578
|
}
|
4546
|
-
const result = this.getElementsByRange(includes, flat);
|
4579
|
+
const result = this.getElementsByRange(includes, flat, useCache);
|
4547
4580
|
let elements = [];
|
4548
4581
|
result.forEach((item, index) => {
|
4549
4582
|
if (item.offset) {
|
@@ -4733,7 +4766,7 @@ class AlexEditor {
|
|
4733
4766
|
/**
|
4734
4767
|
* 设置文本元素的样式
|
4735
4768
|
*/
|
4736
|
-
setTextStyle(styles) {
|
4769
|
+
setTextStyle(styles, useCache = false) {
|
4737
4770
|
if (this.disabled) {
|
4738
4771
|
return;
|
4739
4772
|
}
|
@@ -4766,7 +4799,7 @@ class AlexEditor {
|
|
4766
4799
|
this.insertElement(el);
|
4767
4800
|
}
|
4768
4801
|
} else {
|
4769
|
-
const elements = this.splitElementsByRange(true, true);
|
4802
|
+
const elements = this.splitElementsByRange(true, true, useCache);
|
4770
4803
|
elements.forEach((ele) => {
|
4771
4804
|
if (ele.isText()) {
|
4772
4805
|
if (ele.hasStyles()) {
|
@@ -4781,7 +4814,7 @@ class AlexEditor {
|
|
4781
4814
|
/**
|
4782
4815
|
* 移除文本元素的样式
|
4783
4816
|
*/
|
4784
|
-
removeTextStyle(styleNames) {
|
4817
|
+
removeTextStyle(styleNames, useCache = false) {
|
4785
4818
|
if (this.disabled) {
|
4786
4819
|
return;
|
4787
4820
|
}
|
@@ -4814,7 +4847,7 @@ class AlexEditor {
|
|
4814
4847
|
this.insertElement(el);
|
4815
4848
|
}
|
4816
4849
|
} else {
|
4817
|
-
const elements = this.splitElementsByRange(true, true);
|
4850
|
+
const elements = this.splitElementsByRange(true, true, useCache);
|
4818
4851
|
elements.forEach((ele) => {
|
4819
4852
|
if (ele.isText()) {
|
4820
4853
|
removeFn(ele);
|
@@ -4838,17 +4871,9 @@ class AlexEditor {
|
|
4838
4871
|
}
|
4839
4872
|
return false;
|
4840
4873
|
}
|
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
|
-
}
|
4874
|
+
let result = this.getElementsByRange(true, true, useCache).filter((item) => {
|
4875
|
+
return item.element.isText();
|
4876
|
+
});
|
4852
4877
|
if (result.length == 0) {
|
4853
4878
|
return false;
|
4854
4879
|
}
|
@@ -4863,7 +4888,7 @@ class AlexEditor {
|
|
4863
4888
|
/**
|
4864
4889
|
* 设置文本元素的标记
|
4865
4890
|
*/
|
4866
|
-
setTextMark(marks) {
|
4891
|
+
setTextMark(marks, useCache = false) {
|
4867
4892
|
if (this.disabled) {
|
4868
4893
|
return;
|
4869
4894
|
}
|
@@ -4896,7 +4921,7 @@ class AlexEditor {
|
|
4896
4921
|
this.insertElement(el);
|
4897
4922
|
}
|
4898
4923
|
} else {
|
4899
|
-
const elements = this.splitElementsByRange(true, true);
|
4924
|
+
const elements = this.splitElementsByRange(true, true, useCache);
|
4900
4925
|
elements.forEach((ele) => {
|
4901
4926
|
if (ele.isText()) {
|
4902
4927
|
if (ele.hasMarks()) {
|
@@ -4911,7 +4936,7 @@ class AlexEditor {
|
|
4911
4936
|
/**
|
4912
4937
|
* 移除文本元素的标记
|
4913
4938
|
*/
|
4914
|
-
removeTextMark(markNames) {
|
4939
|
+
removeTextMark(markNames, useCache = false) {
|
4915
4940
|
if (this.disabled) {
|
4916
4941
|
return;
|
4917
4942
|
}
|
@@ -4944,7 +4969,7 @@ class AlexEditor {
|
|
4944
4969
|
this.insertElement(el);
|
4945
4970
|
}
|
4946
4971
|
} else {
|
4947
|
-
const elements = this.splitElementsByRange(true, true);
|
4972
|
+
const elements = this.splitElementsByRange(true, true, useCache);
|
4948
4973
|
elements.forEach((ele) => {
|
4949
4974
|
if (ele.isText()) {
|
4950
4975
|
removeFn(ele);
|
@@ -4968,17 +4993,9 @@ class AlexEditor {
|
|
4968
4993
|
}
|
4969
4994
|
return false;
|
4970
4995
|
}
|
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
|
-
}
|
4996
|
+
let result = this.getElementsByRange(true, true, useCache).filter((item) => {
|
4997
|
+
return item.element.isText();
|
4998
|
+
});
|
4982
4999
|
if (result.length == 0) {
|
4983
5000
|
return false;
|
4984
5001
|
}
|
@@ -17869,7 +17886,7 @@ function _sfc_render$7(_ctx, _cache, $props, $setup, $data, $options) {
|
|
17869
17886
|
]);
|
17870
17887
|
}
|
17871
17888
|
const Colors = /* @__PURE__ */ _export_sfc(_sfc_main$7, [["render", _sfc_render$7], ["__scopeId", "data-v-dc6d3d68"]]);
|
17872
|
-
const
|
17889
|
+
const Toolbar_vue_vue_type_style_index_0_scoped_38c4144f_lang = "";
|
17873
17890
|
const _sfc_main$6 = {
|
17874
17891
|
name: "Toolbar",
|
17875
17892
|
emits: ["update:modelValue"],
|
@@ -18234,7 +18251,7 @@ const _sfc_main$6 = {
|
|
18234
18251
|
if (this.$parent.disabled) {
|
18235
18252
|
return;
|
18236
18253
|
}
|
18237
|
-
const element2 = this.$parent.getCurrentParsedomElement("img") || this.$parent.getCurrentParsedomElement("video");
|
18254
|
+
const element2 = this.$parent.getCurrentParsedomElement("img") || this.$parent.getCurrentParsedomElement("video", true);
|
18238
18255
|
if (element2) {
|
18239
18256
|
const styles = {
|
18240
18257
|
width: value
|
@@ -18339,8 +18356,8 @@ const _sfc_main$6 = {
|
|
18339
18356
|
this.$parent.editor.range.anchor.offset = this.$parent.editor.range.focus.offset;
|
18340
18357
|
}
|
18341
18358
|
const table = this.$parent.getCurrentParsedomElement("table");
|
18342
|
-
const column = this.$parent.getCurrentParsedomElement("td");
|
18343
|
-
const tbody = this.$parent.getCurrentParsedomElement("tbody");
|
18359
|
+
const column = this.$parent.getCurrentParsedomElement("td", true);
|
18360
|
+
const tbody = this.$parent.getCurrentParsedomElement("tbody", true);
|
18344
18361
|
if (column && table && tbody) {
|
18345
18362
|
const rows = tbody.children;
|
18346
18363
|
const index = column.parent.children.findIndex((item) => {
|
@@ -18389,7 +18406,7 @@ const _sfc_main$6 = {
|
|
18389
18406
|
this.$parent.editor.range.anchor.offset = this.$parent.editor.range.focus.offset;
|
18390
18407
|
}
|
18391
18408
|
const table = this.$parent.getCurrentParsedomElement("table");
|
18392
|
-
const row = this.$parent.getCurrentParsedomElement("tr");
|
18409
|
+
const row = this.$parent.getCurrentParsedomElement("tr", true);
|
18393
18410
|
if (table && row) {
|
18394
18411
|
const newRow = row.clone();
|
18395
18412
|
newRow.children.forEach((column) => {
|
@@ -18444,7 +18461,7 @@ const _sfc_main$6 = {
|
|
18444
18461
|
this.$parent.editor.range.anchor.offset = this.$parent.editor.range.focus.offset;
|
18445
18462
|
}
|
18446
18463
|
const table = this.$parent.getCurrentParsedomElement("table");
|
18447
|
-
const row = this.$parent.getCurrentParsedomElement("tr");
|
18464
|
+
const row = this.$parent.getCurrentParsedomElement("tr", true);
|
18448
18465
|
if (table && row) {
|
18449
18466
|
const parent = row.parent;
|
18450
18467
|
if (parent.children.length == 1) {
|
@@ -18479,13 +18496,13 @@ const _sfc_main$6 = {
|
|
18479
18496
|
this.$parent.editor.range.anchor.offset = this.$parent.editor.range.focus.offset;
|
18480
18497
|
}
|
18481
18498
|
const column = this.$parent.getCurrentParsedomElement("td");
|
18482
|
-
const tbody = this.$parent.getCurrentParsedomElement("tbody");
|
18483
|
-
const table = this.$parent.getCurrentParsedomElement("table");
|
18499
|
+
const tbody = this.$parent.getCurrentParsedomElement("tbody", true);
|
18500
|
+
const table = this.$parent.getCurrentParsedomElement("table", true);
|
18484
18501
|
if (column && table && tbody) {
|
18485
18502
|
const rows = tbody.children;
|
18486
18503
|
const parent = column.parent;
|
18487
18504
|
if (parent.children.length == 1) {
|
18488
|
-
this.$parent.deleteByParsedom("table");
|
18505
|
+
this.$parent.deleteByParsedom("table", true);
|
18489
18506
|
return;
|
18490
18507
|
}
|
18491
18508
|
const previousColumn = this.$parent.editor.getPreviousElement(column);
|
@@ -18514,19 +18531,20 @@ const _sfc_main$6 = {
|
|
18514
18531
|
},
|
18515
18532
|
//浮层显示时
|
18516
18533
|
layerShow() {
|
18534
|
+
const result = this.$parent.editor.getElementsByRange(true, false, true);
|
18517
18535
|
if (this.type == "codeBlock") {
|
18518
|
-
const pre = this.$parent.getCurrentParsedomElement("pre");
|
18536
|
+
const pre = this.$parent.getCurrentParsedomElement("pre", true);
|
18519
18537
|
if (pre) {
|
18520
18538
|
this.languageConfig.displayConfig.value = pre.marks["data-editify-hljs"] || "";
|
18521
18539
|
}
|
18522
18540
|
} else if (this.type == "link") {
|
18523
|
-
const link = this.$parent.getCurrentParsedomElement("a");
|
18541
|
+
const link = this.$parent.getCurrentParsedomElement("a", true);
|
18524
18542
|
if (link) {
|
18525
18543
|
this.linkConfig.url = link.marks["href"];
|
18526
18544
|
this.linkConfig.newOpen = link.marks["target"] == "_blank";
|
18527
18545
|
}
|
18528
18546
|
} else if (this.type == "video") {
|
18529
|
-
const video = this.$parent.getCurrentParsedomElement("video");
|
18547
|
+
const video = this.$parent.getCurrentParsedomElement("video", true);
|
18530
18548
|
if (video) {
|
18531
18549
|
this.videoConfig.autoplay = !!video.marks["autoplay"];
|
18532
18550
|
this.videoConfig.loop = !!video.marks["loop"];
|
@@ -18540,7 +18558,6 @@ const _sfc_main$6 = {
|
|
18540
18558
|
}
|
18541
18559
|
return false;
|
18542
18560
|
};
|
18543
|
-
const result = this.$parent.editor.getElementsByRange(true, false);
|
18544
18561
|
const findHeadingItem = this.headingConfig.displayConfig.options.find((item) => {
|
18545
18562
|
let val = item;
|
18546
18563
|
if (obj.common.isObject(item)) {
|
@@ -18556,13 +18573,13 @@ const _sfc_main$6 = {
|
|
18556
18573
|
this.headingConfig.displayConfig.value = findHeadingItem ? obj.common.isObject(findHeadingItem) ? findHeadingItem.value : findHeadingItem : this.headingConfig.defaultValue;
|
18557
18574
|
this.headingConfig.disabled = extraDisabled("heading");
|
18558
18575
|
this.alignConfig.disabled = extraDisabled("align");
|
18559
|
-
this.orderListConfig.active = this.$parent.inList(true);
|
18576
|
+
this.orderListConfig.active = this.$parent.inList(true, true);
|
18560
18577
|
this.orderListConfig.disabled = extraDisabled("orderList");
|
18561
|
-
this.unorderListConfig.active = this.$parent.inList(false);
|
18578
|
+
this.unorderListConfig.active = this.$parent.inList(false, true);
|
18562
18579
|
this.unorderListConfig.disabled = extraDisabled("unorderList");
|
18563
|
-
this.taskConfig.active = this.$parent.inTask();
|
18580
|
+
this.taskConfig.active = this.$parent.inTask(true, true);
|
18564
18581
|
this.taskConfig.disabled = extraDisabled("task");
|
18565
|
-
this.boldConfig.active = this.$parent.queryTextStyle("font-weight", "bold");
|
18582
|
+
this.boldConfig.active = this.$parent.queryTextStyle("font-weight", "bold", true);
|
18566
18583
|
this.boldConfig.disabled = extraDisabled("bold");
|
18567
18584
|
this.italicConfig.active = this.$parent.queryTextStyle("font-style", "italic", true);
|
18568
18585
|
this.italicConfig.disabled = extraDisabled("italic");
|
@@ -18570,7 +18587,7 @@ const _sfc_main$6 = {
|
|
18570
18587
|
this.strikethroughConfig.disabled = extraDisabled("strikethrough");
|
18571
18588
|
this.underlineConfig.active = this.$parent.queryTextStyle("text-decoration", "underline", true);
|
18572
18589
|
this.underlineConfig.disabled = extraDisabled("underline");
|
18573
|
-
this.codeConfig.active = this.$parent.queryTextMark("data-editify-code");
|
18590
|
+
this.codeConfig.active = this.$parent.queryTextMark("data-editify-code", null, true);
|
18574
18591
|
this.codeConfig.disabled = extraDisabled("code");
|
18575
18592
|
this.superConfig.active = this.$parent.queryTextStyle("vertical-align", "super", true);
|
18576
18593
|
this.superConfig.disabled = extraDisabled("super");
|
@@ -19364,7 +19381,7 @@ function _sfc_render$6(_ctx, _cache, $props, $setup, $data, $options) {
|
|
19364
19381
|
_: 1
|
19365
19382
|
}, 8, ["modelValue", "node", "onShow", "useRange"]);
|
19366
19383
|
}
|
19367
|
-
const Toolbar = /* @__PURE__ */ _export_sfc(_sfc_main$6, [["render", _sfc_render$6], ["__scopeId", "data-v-
|
19384
|
+
const Toolbar = /* @__PURE__ */ _export_sfc(_sfc_main$6, [["render", _sfc_render$6], ["__scopeId", "data-v-38c4144f"]]);
|
19368
19385
|
const InsertLink_vue_vue_type_style_index_0_scoped_e6c3c2ee_lang = "";
|
19369
19386
|
const _sfc_main$5 = {
|
19370
19387
|
name: "InsertLink",
|
@@ -20012,7 +20029,7 @@ function _sfc_render$2(_ctx, _cache, $props, $setup, $data, $options) {
|
|
20012
20029
|
]);
|
20013
20030
|
}
|
20014
20031
|
const InsertTable = /* @__PURE__ */ _export_sfc(_sfc_main$2, [["render", _sfc_render$2], ["__scopeId", "data-v-227ede65"]]);
|
20015
|
-
const
|
20032
|
+
const Menu_vue_vue_type_style_index_0_scoped_afb2092e_lang = "";
|
20016
20033
|
const _sfc_main$1 = {
|
20017
20034
|
name: "Menu",
|
20018
20035
|
props: {
|
@@ -21090,15 +21107,15 @@ const _sfc_main$1 = {
|
|
21090
21107
|
if (this.disabled) {
|
21091
21108
|
return;
|
21092
21109
|
}
|
21093
|
-
const result = this.$parent.editor.getElementsByRange(true, false);
|
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();
|
21110
|
+
const result = this.$parent.editor.getElementsByRange(true, false, true);
|
21111
|
+
const hasPreStyle = this.$parent.hasPreStyle(true);
|
21112
|
+
const hasTable = this.$parent.hasTable(true);
|
21113
|
+
const hasQuote = this.$parent.hasQuote(true);
|
21114
|
+
const inQuote = this.$parent.inQuote(true);
|
21115
|
+
const hasLink = this.$parent.hasLink(true);
|
21116
|
+
const inOrderList = this.$parent.inList(true, true);
|
21117
|
+
const inUnorderList = this.$parent.inList(false, true);
|
21118
|
+
const inTask = this.$parent.inTask(true);
|
21102
21119
|
const extraDisabled = (name) => {
|
21103
21120
|
if (typeof this.config.extraDisabled == "function") {
|
21104
21121
|
return this.config.extraDisabled.apply(this.$parent, [name]) || false;
|
@@ -21134,7 +21151,7 @@ const _sfc_main$1 = {
|
|
21134
21151
|
this.unorderListConfig.disabled = hasPreStyle || hasTable || extraDisabled("unorderList");
|
21135
21152
|
this.taskConfig.active = inTask;
|
21136
21153
|
this.taskConfig.disabled = hasPreStyle || hasTable || extraDisabled("task");
|
21137
|
-
this.boldConfig.active = this.$parent.queryTextStyle("font-weight", "bold");
|
21154
|
+
this.boldConfig.active = this.$parent.queryTextStyle("font-weight", "bold", true);
|
21138
21155
|
this.boldConfig.disabled = hasPreStyle || extraDisabled("bold");
|
21139
21156
|
this.underlineConfig.active = this.$parent.queryTextStyle("text-decoration", "underline", true);
|
21140
21157
|
this.underlineConfig.disabled = hasPreStyle || extraDisabled("underline");
|
@@ -21142,7 +21159,7 @@ const _sfc_main$1 = {
|
|
21142
21159
|
this.italicConfig.disabled = hasPreStyle || extraDisabled("italic");
|
21143
21160
|
this.strikethroughConfig.active = this.$parent.queryTextStyle("text-decoration", "line-through", true);
|
21144
21161
|
this.strikethroughConfig.disabled = hasPreStyle || extraDisabled("strikethrough");
|
21145
|
-
this.codeConfig.active = this.$parent.queryTextMark("data-editify-code");
|
21162
|
+
this.codeConfig.active = this.$parent.queryTextMark("data-editify-code", null, true);
|
21146
21163
|
this.codeConfig.disabled = hasPreStyle || extraDisabled("code");
|
21147
21164
|
this.superConfig.active = this.$parent.queryTextStyle("vertical-align", "super", true);
|
21148
21165
|
this.superConfig.disabled = hasPreStyle || extraDisabled("super");
|
@@ -21208,7 +21225,7 @@ const _sfc_main$1 = {
|
|
21208
21225
|
this.imageConfig.disabled = hasPreStyle || extraDisabled("image");
|
21209
21226
|
this.videoConfig.disabled = hasPreStyle || extraDisabled("video");
|
21210
21227
|
this.tableConfig.disabled = hasPreStyle || hasTable || hasQuote || extraDisabled("table");
|
21211
|
-
this.codeBlockConfig.active = !!this.$parent.getCurrentParsedomElement("pre");
|
21228
|
+
this.codeBlockConfig.active = !!this.$parent.getCurrentParsedomElement("pre", true);
|
21212
21229
|
this.codeBlockConfig.disabled = hasTable || hasQuote || extraDisabled("codeBlock");
|
21213
21230
|
this.sourceViewConfig.active = this.$parent.isSourceView;
|
21214
21231
|
}
|
@@ -21230,8 +21247,8 @@ function _sfc_render$1(_ctx, _cache, $props, $setup, $data, $options) {
|
|
21230
21247
|
}), 256))
|
21231
21248
|
], 14, _hoisted_1$1);
|
21232
21249
|
}
|
21233
|
-
const Menu = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["render", _sfc_render$1], ["__scopeId", "data-v-
|
21234
|
-
const
|
21250
|
+
const Menu = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["render", _sfc_render$1], ["__scopeId", "data-v-afb2092e"]]);
|
21251
|
+
const Editify_vue_vue_type_style_index_0_scoped_b523f8ea_lang = "";
|
21235
21252
|
const _sfc_main = {
|
21236
21253
|
name: "editify",
|
21237
21254
|
props: { ...editorProps },
|
@@ -21268,8 +21285,8 @@ const _sfc_main = {
|
|
21268
21285
|
//类型
|
21269
21286
|
type: "text"
|
21270
21287
|
},
|
21271
|
-
//
|
21272
|
-
|
21288
|
+
//rangeUpdate更新延时器
|
21289
|
+
updateTimer: null,
|
21273
21290
|
//菜单栏是否可以使用标识
|
21274
21291
|
canUseMenu: false
|
21275
21292
|
};
|
@@ -21434,72 +21451,67 @@ const _sfc_main = {
|
|
21434
21451
|
if (this.disabled || this.isSourceView) {
|
21435
21452
|
return;
|
21436
21453
|
}
|
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.
|
21454
|
+
this.hideToolbar();
|
21455
|
+
this.$nextTick(() => {
|
21456
|
+
const table = this.getCurrentParsedomElement("table", true);
|
21457
|
+
const pre = this.getCurrentParsedomElement("pre", true);
|
21458
|
+
const link = this.getCurrentParsedomElement("a", true);
|
21459
|
+
const image = this.getCurrentParsedomElement("img", true);
|
21460
|
+
const video = this.getCurrentParsedomElement("video", true);
|
21461
|
+
if (link) {
|
21462
|
+
this.toolbarOptions.type = "link";
|
21463
|
+
this.toolbarOptions.node = `[data-editify-uid="${this.uid}"] [data-editify-element="${link.key}"]`;
|
21464
|
+
if (this.toolbarOptions.show) {
|
21465
|
+
this.$refs.toolbar.$refs.layer.setPosition();
|
21466
|
+
} else {
|
21467
|
+
this.toolbarOptions.show = true;
|
21468
|
+
}
|
21469
|
+
} else if (image) {
|
21470
|
+
this.toolbarOptions.type = "image";
|
21471
|
+
this.toolbarOptions.node = `[data-editify-uid="${this.uid}"] [data-editify-element="${image.key}"]`;
|
21472
|
+
if (this.toolbarOptions.show) {
|
21473
|
+
this.$refs.toolbar.$refs.layer.setPosition();
|
21474
|
+
} else {
|
21475
|
+
this.toolbarOptions.show = true;
|
21476
|
+
}
|
21477
|
+
} else if (video) {
|
21478
|
+
this.toolbarOptions.type = "video";
|
21479
|
+
this.toolbarOptions.node = `[data-editify-uid="${this.uid}"] [data-editify-element="${video.key}"]`;
|
21480
|
+
if (this.toolbarOptions.show) {
|
21481
|
+
this.$refs.toolbar.$refs.layer.setPosition();
|
21482
|
+
} else {
|
21483
|
+
this.toolbarOptions.show = true;
|
21484
|
+
}
|
21485
|
+
} else if (table) {
|
21486
|
+
this.toolbarOptions.type = "table";
|
21487
|
+
this.toolbarOptions.node = `[data-editify-uid="${this.uid}"] [data-editify-element="${table.key}"]`;
|
21488
|
+
if (this.toolbarOptions.show) {
|
21489
|
+
this.$refs.toolbar.$refs.layer.setPosition();
|
21490
|
+
} else {
|
21491
|
+
this.toolbarOptions.show = true;
|
21492
|
+
}
|
21493
|
+
} else if (pre) {
|
21494
|
+
this.toolbarOptions.type = "codeBlock";
|
21495
|
+
this.toolbarOptions.node = `[data-editify-uid="${this.uid}"] [data-editify-element="${pre.key}"]`;
|
21496
|
+
if (this.toolbarOptions.show) {
|
21497
|
+
this.$refs.toolbar.$refs.layer.setPosition();
|
21498
|
+
} else {
|
21499
|
+
this.toolbarOptions.show = true;
|
21500
|
+
}
|
21501
|
+
} else {
|
21502
|
+
const result = this.editor.getElementsByRange(true, true, true).filter((item) => {
|
21503
|
+
return item.element.isText();
|
21504
|
+
});
|
21505
|
+
if (result.length && !this.hasTable(true) && !this.hasPreStyle(true) && !this.hasLink(true) && !this.hasImage(true) && !this.hasVideo(true)) {
|
21506
|
+
this.toolbarOptions.type = "text";
|
21483
21507
|
if (this.toolbarOptions.show) {
|
21484
21508
|
this.$refs.toolbar.$refs.layer.setPosition();
|
21485
21509
|
} else {
|
21486
21510
|
this.toolbarOptions.show = true;
|
21487
21511
|
}
|
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
21512
|
}
|
21501
|
-
}
|
21502
|
-
}
|
21513
|
+
}
|
21514
|
+
});
|
21503
21515
|
},
|
21504
21516
|
//重新定义编辑器合并元素的逻辑
|
21505
21517
|
handleCustomMerge(ele, preEle) {
|
@@ -21745,12 +21757,21 @@ const _sfc_main = {
|
|
21745
21757
|
if (this.disabled) {
|
21746
21758
|
return;
|
21747
21759
|
}
|
21748
|
-
if (this.
|
21749
|
-
this.
|
21750
|
-
}
|
21751
|
-
if (this.menuConfig.use) {
|
21752
|
-
this.$refs.menu.handleRangeUpdate();
|
21760
|
+
if (this.updateTimer) {
|
21761
|
+
clearTimeout(this.updateTimer);
|
21753
21762
|
}
|
21763
|
+
this.updateTimer = setTimeout(() => {
|
21764
|
+
if (this.toolbarConfig.use || this.menuConfig.use) {
|
21765
|
+
this.editor.getElementsByRange(true, false);
|
21766
|
+
this.editor.getElementsByRange(true, true);
|
21767
|
+
}
|
21768
|
+
if (this.toolbarConfig.use) {
|
21769
|
+
this.handleToolbar();
|
21770
|
+
}
|
21771
|
+
if (this.menuConfig.use) {
|
21772
|
+
this.$refs.menu.handleRangeUpdate();
|
21773
|
+
}
|
21774
|
+
}, 200);
|
21754
21775
|
this.$emit("rangeupdate", this.value, range);
|
21755
21776
|
},
|
21756
21777
|
//编辑器复制
|
@@ -21866,7 +21887,7 @@ const _sfc_main = {
|
|
21866
21887
|
return this.getParsedomElementByElement(element2.parent, parsedom);
|
21867
21888
|
},
|
21868
21889
|
//api:获取光标是否在指定标签元素下,如果是返回该标签元素,否则返回null
|
21869
|
-
getCurrentParsedomElement(parsedom) {
|
21890
|
+
getCurrentParsedomElement(parsedom, useCache = false) {
|
21870
21891
|
if (this.disabled) {
|
21871
21892
|
return null;
|
21872
21893
|
}
|
@@ -21876,7 +21897,7 @@ const _sfc_main = {
|
|
21876
21897
|
if (this.editor.range.anchor.element.isEqual(this.editor.range.focus.element)) {
|
21877
21898
|
return this.getParsedomElementByElement(this.editor.range.anchor.element, parsedom);
|
21878
21899
|
}
|
21879
|
-
const arr = this.editor.getElementsByRange(true, false).map((item) => {
|
21900
|
+
const arr = this.editor.getElementsByRange(true, false, useCache).map((item) => {
|
21880
21901
|
return this.getParsedomElementByElement(item.element, parsedom);
|
21881
21902
|
});
|
21882
21903
|
let hasNull = arr.some((el) => {
|
@@ -21901,14 +21922,14 @@ const _sfc_main = {
|
|
21901
21922
|
return null;
|
21902
21923
|
},
|
21903
21924
|
//api:删除光标所在的指定标签元素
|
21904
|
-
deleteByParsedom(parsedom, isRender = true) {
|
21925
|
+
deleteByParsedom(parsedom, isRender = true, useCache = false) {
|
21905
21926
|
if (this.disabled) {
|
21906
21927
|
return;
|
21907
21928
|
}
|
21908
21929
|
if (!this.editor.range) {
|
21909
21930
|
return;
|
21910
21931
|
}
|
21911
|
-
const element2 = this.getCurrentParsedomElement(parsedom);
|
21932
|
+
const element2 = this.getCurrentParsedomElement(parsedom, useCache);
|
21912
21933
|
if (element2) {
|
21913
21934
|
element2.toEmpty();
|
21914
21935
|
if (isRender) {
|
@@ -21919,14 +21940,14 @@ const _sfc_main = {
|
|
21919
21940
|
}
|
21920
21941
|
},
|
21921
21942
|
//api:当光标在链接上时可以移除链接
|
21922
|
-
removeLink(isRender = true) {
|
21943
|
+
removeLink(isRender = true, useCache = false) {
|
21923
21944
|
if (this.disabled) {
|
21924
21945
|
return;
|
21925
21946
|
}
|
21926
21947
|
if (!this.editor.range) {
|
21927
21948
|
return;
|
21928
21949
|
}
|
21929
|
-
const link = this.getCurrentParsedomElement("a");
|
21950
|
+
const link = this.getCurrentParsedomElement("a", useCache);
|
21930
21951
|
if (link) {
|
21931
21952
|
link.parsedom = AlexElement.TEXT_NODE;
|
21932
21953
|
delete link.marks.target;
|
@@ -21939,7 +21960,7 @@ const _sfc_main = {
|
|
21939
21960
|
}
|
21940
21961
|
},
|
21941
21962
|
//api:设置标题
|
21942
|
-
setHeading(parsedom, isRender = true) {
|
21963
|
+
setHeading(parsedom, isRender = true, useCache = false) {
|
21943
21964
|
if (this.disabled) {
|
21944
21965
|
return;
|
21945
21966
|
}
|
@@ -21957,7 +21978,7 @@ const _sfc_main = {
|
|
21957
21978
|
blockToParagraph(block);
|
21958
21979
|
block.parsedom = parsedom;
|
21959
21980
|
} else {
|
21960
|
-
const result = this.editor.getElementsByRange(true, false);
|
21981
|
+
const result = this.editor.getElementsByRange(true, false, useCache);
|
21961
21982
|
result.forEach((el) => {
|
21962
21983
|
if (el.element.isBlock()) {
|
21963
21984
|
blockToParagraph(el.element);
|
@@ -21976,7 +21997,7 @@ const _sfc_main = {
|
|
21976
21997
|
}
|
21977
21998
|
},
|
21978
21999
|
//api:插入有序列表 ordered为true表示有序列表
|
21979
|
-
setList(ordered, isRender = true) {
|
22000
|
+
setList(ordered, isRender = true, useCache = false) {
|
21980
22001
|
if (this.disabled) {
|
21981
22002
|
return;
|
21982
22003
|
}
|
@@ -21993,7 +22014,7 @@ const _sfc_main = {
|
|
21993
22014
|
}
|
21994
22015
|
} else {
|
21995
22016
|
let blocks = [];
|
21996
|
-
const result = this.editor.getElementsByRange(true, false);
|
22017
|
+
const result = this.editor.getElementsByRange(true, false, useCache);
|
21997
22018
|
result.forEach((item) => {
|
21998
22019
|
const block = item.element.getBlock();
|
21999
22020
|
const exist = blocks.some((el) => block.isEqual(el));
|
@@ -22017,7 +22038,7 @@ const _sfc_main = {
|
|
22017
22038
|
}
|
22018
22039
|
},
|
22019
22040
|
//api:插入任务列表
|
22020
|
-
setTask(isRender = true) {
|
22041
|
+
setTask(isRender = true, useCache = false) {
|
22021
22042
|
if (this.disabled) {
|
22022
22043
|
return;
|
22023
22044
|
}
|
@@ -22034,7 +22055,7 @@ const _sfc_main = {
|
|
22034
22055
|
}
|
22035
22056
|
} else {
|
22036
22057
|
let blocks = [];
|
22037
|
-
const result = this.editor.getElementsByRange(true, false);
|
22058
|
+
const result = this.editor.getElementsByRange(true, false, useCache);
|
22038
22059
|
result.forEach((item) => {
|
22039
22060
|
const block = item.element.getBlock();
|
22040
22061
|
const exist = blocks.some((el) => block.isEqual(el));
|
@@ -22058,20 +22079,20 @@ const _sfc_main = {
|
|
22058
22079
|
}
|
22059
22080
|
},
|
22060
22081
|
//api:设置样式
|
22061
|
-
setTextStyle(name, value, isRender = true) {
|
22082
|
+
setTextStyle(name, value, isRender = true, useCache = false) {
|
22062
22083
|
if (this.disabled) {
|
22063
22084
|
return;
|
22064
22085
|
}
|
22065
22086
|
if (!this.editor.range) {
|
22066
22087
|
return;
|
22067
22088
|
}
|
22068
|
-
const active = this.queryTextStyle(name, value);
|
22089
|
+
const active = this.queryTextStyle(name, value, useCache);
|
22069
22090
|
if (active) {
|
22070
|
-
this.editor.removeTextStyle([name]);
|
22091
|
+
this.editor.removeTextStyle([name], useCache);
|
22071
22092
|
} else {
|
22072
22093
|
let styles = {};
|
22073
22094
|
styles[name] = value;
|
22074
|
-
this.editor.setTextStyle(styles);
|
22095
|
+
this.editor.setTextStyle(styles, useCache);
|
22075
22096
|
}
|
22076
22097
|
if (isRender) {
|
22077
22098
|
this.editor.formatElementStack();
|
@@ -22080,24 +22101,24 @@ const _sfc_main = {
|
|
22080
22101
|
}
|
22081
22102
|
},
|
22082
22103
|
//api:查询是否具有某个样式
|
22083
|
-
queryTextStyle(name, value, useCache) {
|
22104
|
+
queryTextStyle(name, value, useCache = false) {
|
22084
22105
|
return this.editor.queryTextStyle(name, value, useCache);
|
22085
22106
|
},
|
22086
22107
|
//api:设置标记
|
22087
|
-
setTextMark(name, value, isRender = true) {
|
22108
|
+
setTextMark(name, value, isRender = true, useCache = false) {
|
22088
22109
|
if (this.disabled) {
|
22089
22110
|
return;
|
22090
22111
|
}
|
22091
22112
|
if (!this.editor.range) {
|
22092
22113
|
return;
|
22093
22114
|
}
|
22094
|
-
const active = this.queryTextMark(name, value);
|
22115
|
+
const active = this.queryTextMark(name, value, useCache);
|
22095
22116
|
if (active) {
|
22096
|
-
this.editor.removeTextMark([name]);
|
22117
|
+
this.editor.removeTextMark([name], useCache);
|
22097
22118
|
} else {
|
22098
22119
|
let marks = {};
|
22099
22120
|
marks[name] = value;
|
22100
|
-
this.editor.setTextMark(marks);
|
22121
|
+
this.editor.setTextMark(marks, useCache);
|
22101
22122
|
}
|
22102
22123
|
if (isRender) {
|
22103
22124
|
this.editor.formatElementStack();
|
@@ -22106,19 +22127,19 @@ const _sfc_main = {
|
|
22106
22127
|
}
|
22107
22128
|
},
|
22108
22129
|
//api:查询是否具有某个标记
|
22109
|
-
queryTextMark(name, value, useCache) {
|
22130
|
+
queryTextMark(name, value, useCache = false) {
|
22110
22131
|
return this.editor.queryTextMark(name, value, useCache);
|
22111
22132
|
},
|
22112
22133
|
//api:清除文本样式和标记
|
22113
|
-
formatText(isRender = true) {
|
22134
|
+
formatText(isRender = true, useCache = false) {
|
22114
22135
|
if (this.disabled) {
|
22115
22136
|
return;
|
22116
22137
|
}
|
22117
22138
|
if (!this.editor.range) {
|
22118
22139
|
return;
|
22119
22140
|
}
|
22120
|
-
this.editor.removeTextStyle();
|
22121
|
-
this.editor.removeTextMark();
|
22141
|
+
this.editor.removeTextStyle(null, useCache);
|
22142
|
+
this.editor.removeTextMark(null, useCache);
|
22122
22143
|
if (isRender) {
|
22123
22144
|
this.editor.formatElementStack();
|
22124
22145
|
this.editor.domRender();
|
@@ -22126,7 +22147,7 @@ const _sfc_main = {
|
|
22126
22147
|
}
|
22127
22148
|
},
|
22128
22149
|
//api:设置对齐方式,参数取值justify/left/right/center
|
22129
|
-
setAlign(value, isRender = true) {
|
22150
|
+
setAlign(value, isRender = true, useCache = false) {
|
22130
22151
|
if (this.disabled) {
|
22131
22152
|
return;
|
22132
22153
|
}
|
@@ -22154,7 +22175,7 @@ const _sfc_main = {
|
|
22154
22175
|
}
|
22155
22176
|
}
|
22156
22177
|
} else {
|
22157
|
-
const result = this.editor.getElementsByRange(true, false);
|
22178
|
+
const result = this.editor.getElementsByRange(true, false, useCache);
|
22158
22179
|
result.forEach((el) => {
|
22159
22180
|
if (el.element.isBlock() || el.element.isInblock()) {
|
22160
22181
|
if (el.element.hasStyles()) {
|
@@ -22224,7 +22245,7 @@ const _sfc_main = {
|
|
22224
22245
|
}
|
22225
22246
|
},
|
22226
22247
|
//api:插入引用
|
22227
|
-
setQuote(isRender = true) {
|
22248
|
+
setQuote(isRender = true, useCache = false) {
|
22228
22249
|
if (this.disabled) {
|
22229
22250
|
return;
|
22230
22251
|
}
|
@@ -22240,7 +22261,7 @@ const _sfc_main = {
|
|
22240
22261
|
}
|
22241
22262
|
} else {
|
22242
22263
|
let blocks = [];
|
22243
|
-
const result = this.editor.getElementsByRange(true, false);
|
22264
|
+
const result = this.editor.getElementsByRange(true, false, useCache);
|
22244
22265
|
result.forEach((item) => {
|
22245
22266
|
const block = item.element.getBlock();
|
22246
22267
|
const exist = blocks.some((el) => block.isEqual(el));
|
@@ -22263,7 +22284,7 @@ const _sfc_main = {
|
|
22263
22284
|
}
|
22264
22285
|
},
|
22265
22286
|
//api:设置行高
|
22266
|
-
setLineHeight(value, isRender = true) {
|
22287
|
+
setLineHeight(value, isRender = true, useCache = false) {
|
22267
22288
|
if (this.disabled) {
|
22268
22289
|
return;
|
22269
22290
|
}
|
@@ -22291,7 +22312,7 @@ const _sfc_main = {
|
|
22291
22312
|
}
|
22292
22313
|
}
|
22293
22314
|
} else {
|
22294
|
-
const result = this.editor.getElementsByRange(true, false);
|
22315
|
+
const result = this.editor.getElementsByRange(true, false, useCache);
|
22295
22316
|
result.forEach((el) => {
|
22296
22317
|
if (el.element.isBlock() || el.element.isInblock()) {
|
22297
22318
|
if (el.element.hasStyles()) {
|
@@ -22331,7 +22352,7 @@ const _sfc_main = {
|
|
22331
22352
|
}
|
22332
22353
|
},
|
22333
22354
|
//api:增加缩进
|
22334
|
-
setIndentIncrease(isRender = true) {
|
22355
|
+
setIndentIncrease(isRender = true, useCache = false) {
|
22335
22356
|
if (this.disabled) {
|
22336
22357
|
return;
|
22337
22358
|
}
|
@@ -22366,7 +22387,7 @@ const _sfc_main = {
|
|
22366
22387
|
fn(block);
|
22367
22388
|
}
|
22368
22389
|
} else {
|
22369
|
-
const result = this.editor.getElementsByRange(true, false);
|
22390
|
+
const result = this.editor.getElementsByRange(true, false, useCache);
|
22370
22391
|
result.forEach((item) => {
|
22371
22392
|
const block = item.element.getBlock();
|
22372
22393
|
const inblock = item.element.getInblock();
|
@@ -22384,7 +22405,7 @@ const _sfc_main = {
|
|
22384
22405
|
}
|
22385
22406
|
},
|
22386
22407
|
//api:减少缩进
|
22387
|
-
setIndentDecrease(isRender = true) {
|
22408
|
+
setIndentDecrease(isRender = true, useCache = false) {
|
22388
22409
|
if (this.disabled) {
|
22389
22410
|
return;
|
22390
22411
|
}
|
@@ -22411,7 +22432,7 @@ const _sfc_main = {
|
|
22411
22432
|
fn(block);
|
22412
22433
|
}
|
22413
22434
|
} else {
|
22414
|
-
const result = this.editor.getElementsByRange(true, false);
|
22435
|
+
const result = this.editor.getElementsByRange(true, false, useCache);
|
22415
22436
|
result.forEach((item) => {
|
22416
22437
|
const block = item.element.getBlock();
|
22417
22438
|
const inblock = item.element.getInblock();
|
@@ -22489,20 +22510,20 @@ const _sfc_main = {
|
|
22489
22510
|
}
|
22490
22511
|
},
|
22491
22512
|
//api:选区是否含有代码块样式
|
22492
|
-
hasPreStyle() {
|
22513
|
+
hasPreStyle(useCache = false) {
|
22493
22514
|
if (!this.editor.range) {
|
22494
22515
|
return false;
|
22495
22516
|
}
|
22496
22517
|
if (this.editor.range.anchor.isEqual(this.editor.range.focus)) {
|
22497
22518
|
return this.editor.range.anchor.element.isPreStyle();
|
22498
22519
|
}
|
22499
|
-
const result = this.editor.getElementsByRange(true, false);
|
22520
|
+
const result = this.editor.getElementsByRange(true, false, useCache);
|
22500
22521
|
return result.some((item) => {
|
22501
22522
|
return item.element.isPreStyle();
|
22502
22523
|
});
|
22503
22524
|
},
|
22504
22525
|
//api:选区是否含有引用
|
22505
|
-
hasQuote() {
|
22526
|
+
hasQuote(useCache = false) {
|
22506
22527
|
if (!this.editor.range) {
|
22507
22528
|
return false;
|
22508
22529
|
}
|
@@ -22510,7 +22531,7 @@ const _sfc_main = {
|
|
22510
22531
|
const block = this.editor.range.anchor.element.getBlock();
|
22511
22532
|
return block.parsedom == "blockquote";
|
22512
22533
|
}
|
22513
|
-
const result = this.editor.getElementsByRange(true, false);
|
22534
|
+
const result = this.editor.getElementsByRange(true, false, useCache);
|
22514
22535
|
return result.some((item) => {
|
22515
22536
|
if (item.element.isBlock()) {
|
22516
22537
|
return item.element.parsedom == "blockquote";
|
@@ -22521,7 +22542,7 @@ const _sfc_main = {
|
|
22521
22542
|
});
|
22522
22543
|
},
|
22523
22544
|
//api:选区是否含有列表
|
22524
|
-
hasList(ordered = false) {
|
22545
|
+
hasList(ordered = false, useCache = false) {
|
22525
22546
|
if (!this.editor.range) {
|
22526
22547
|
return false;
|
22527
22548
|
}
|
@@ -22529,7 +22550,7 @@ const _sfc_main = {
|
|
22529
22550
|
const block = this.editor.range.anchor.element.getBlock();
|
22530
22551
|
return blockIsList(block, ordered);
|
22531
22552
|
}
|
22532
|
-
const result = this.editor.getElementsByRange(true, false);
|
22553
|
+
const result = this.editor.getElementsByRange(true, false, useCache);
|
22533
22554
|
return result.some((item) => {
|
22534
22555
|
if (item.element.isBlock()) {
|
22535
22556
|
return blockIsList(item.element, ordered);
|
@@ -22540,14 +22561,14 @@ const _sfc_main = {
|
|
22540
22561
|
});
|
22541
22562
|
},
|
22542
22563
|
//api:选区是否含有链接
|
22543
|
-
hasLink() {
|
22564
|
+
hasLink(useCache = false) {
|
22544
22565
|
if (!this.editor.range) {
|
22545
22566
|
return false;
|
22546
22567
|
}
|
22547
22568
|
if (this.editor.range.anchor.isEqual(this.editor.range.focus)) {
|
22548
22569
|
return !!this.getParsedomElementByElement(this.editor.range.anchor.element, "a");
|
22549
22570
|
}
|
22550
|
-
const result = this.editor.getElementsByRange(true, true).filter((item) => {
|
22571
|
+
const result = this.editor.getElementsByRange(true, true, useCache).filter((item) => {
|
22551
22572
|
return item.element.isText();
|
22552
22573
|
});
|
22553
22574
|
return result.some((item) => {
|
@@ -22555,7 +22576,7 @@ const _sfc_main = {
|
|
22555
22576
|
});
|
22556
22577
|
},
|
22557
22578
|
//api:选区是否含有表格
|
22558
|
-
hasTable() {
|
22579
|
+
hasTable(useCache = false) {
|
22559
22580
|
if (!this.editor.range) {
|
22560
22581
|
return false;
|
22561
22582
|
}
|
@@ -22563,7 +22584,7 @@ const _sfc_main = {
|
|
22563
22584
|
const block = this.editor.range.anchor.element.getBlock();
|
22564
22585
|
return block.parsedom == "table";
|
22565
22586
|
}
|
22566
|
-
const result = this.editor.getElementsByRange(true, false);
|
22587
|
+
const result = this.editor.getElementsByRange(true, false, useCache);
|
22567
22588
|
return result.some((item) => {
|
22568
22589
|
if (item.element.isBlock()) {
|
22569
22590
|
return item.element.parsedom == "table";
|
@@ -22574,7 +22595,7 @@ const _sfc_main = {
|
|
22574
22595
|
});
|
22575
22596
|
},
|
22576
22597
|
//api:选区是否含有任务列表
|
22577
|
-
hasTask() {
|
22598
|
+
hasTask(useCache = false) {
|
22578
22599
|
if (!this.editor.range) {
|
22579
22600
|
return false;
|
22580
22601
|
}
|
@@ -22582,7 +22603,7 @@ const _sfc_main = {
|
|
22582
22603
|
const block = this.editor.range.anchor.element.getBlock();
|
22583
22604
|
return blockIsTask(block);
|
22584
22605
|
}
|
22585
|
-
const result = this.editor.getElementsByRange(true, false);
|
22606
|
+
const result = this.editor.getElementsByRange(true, false, useCache);
|
22586
22607
|
return result.some((item) => {
|
22587
22608
|
if (item.element.isBlock()) {
|
22588
22609
|
return blockIsTask(item.element);
|
@@ -22593,33 +22614,33 @@ const _sfc_main = {
|
|
22593
22614
|
});
|
22594
22615
|
},
|
22595
22616
|
//api:选区是否含有图片
|
22596
|
-
hasImage() {
|
22617
|
+
hasImage(useCache = false) {
|
22597
22618
|
if (!this.editor.range) {
|
22598
22619
|
return false;
|
22599
22620
|
}
|
22600
22621
|
if (this.editor.range.anchor.isEqual(this.editor.range.focus)) {
|
22601
22622
|
return this.editor.range.anchor.element.isClosed() && this.editor.range.anchor.element.parsedom == "img";
|
22602
22623
|
}
|
22603
|
-
const result = this.editor.getElementsByRange(true, true);
|
22624
|
+
const result = this.editor.getElementsByRange(true, true, useCache);
|
22604
22625
|
return result.some((item) => {
|
22605
22626
|
return item.element.isClosed() && item.element.parsedom == "img";
|
22606
22627
|
});
|
22607
22628
|
},
|
22608
22629
|
//api:选区是否含有视频
|
22609
|
-
hasVideo() {
|
22630
|
+
hasVideo(useCache = false) {
|
22610
22631
|
if (!this.editor.range) {
|
22611
22632
|
return false;
|
22612
22633
|
}
|
22613
22634
|
if (this.editor.range.anchor.isEqual(this.editor.range.focus)) {
|
22614
22635
|
return this.editor.range.anchor.element.isClosed() && this.editor.range.anchor.element.parsedom == "video";
|
22615
22636
|
}
|
22616
|
-
const result = this.editor.getElementsByRange(true, true);
|
22637
|
+
const result = this.editor.getElementsByRange(true, true, useCache);
|
22617
22638
|
return result.some((item) => {
|
22618
22639
|
return item.element.isClosed() && item.element.parsedom == "video";
|
22619
22640
|
});
|
22620
22641
|
},
|
22621
22642
|
//api:选区是否全部在引用内
|
22622
|
-
inQuote() {
|
22643
|
+
inQuote(useCache = false) {
|
22623
22644
|
if (!this.editor.range) {
|
22624
22645
|
return false;
|
22625
22646
|
}
|
@@ -22627,7 +22648,7 @@ const _sfc_main = {
|
|
22627
22648
|
const block = this.editor.range.anchor.element.getBlock();
|
22628
22649
|
return block.parsedom == "blockquote";
|
22629
22650
|
}
|
22630
|
-
const result = this.editor.getElementsByRange(true, false);
|
22651
|
+
const result = this.editor.getElementsByRange(true, false, useCache);
|
22631
22652
|
return result.every((item) => {
|
22632
22653
|
if (item.element.isBlock()) {
|
22633
22654
|
return item.element.parsedom == "blockquote";
|
@@ -22638,7 +22659,7 @@ const _sfc_main = {
|
|
22638
22659
|
});
|
22639
22660
|
},
|
22640
22661
|
//api:选区是否全部在列表内
|
22641
|
-
inList(ordered = false) {
|
22662
|
+
inList(ordered = false, useCache = false) {
|
22642
22663
|
if (!this.editor.range) {
|
22643
22664
|
return false;
|
22644
22665
|
}
|
@@ -22646,7 +22667,7 @@ const _sfc_main = {
|
|
22646
22667
|
const block = this.editor.range.anchor.element.getBlock();
|
22647
22668
|
return blockIsList(block, ordered);
|
22648
22669
|
}
|
22649
|
-
const result = this.editor.getElementsByRange(true, false);
|
22670
|
+
const result = this.editor.getElementsByRange(true, false, useCache);
|
22650
22671
|
return result.every((item) => {
|
22651
22672
|
if (item.element.isBlock()) {
|
22652
22673
|
return blockIsList(item.element, ordered);
|
@@ -22657,7 +22678,7 @@ const _sfc_main = {
|
|
22657
22678
|
});
|
22658
22679
|
},
|
22659
22680
|
//api:选区是否全部在任务列表里
|
22660
|
-
inTask() {
|
22681
|
+
inTask(useCache = false) {
|
22661
22682
|
if (!this.editor.range) {
|
22662
22683
|
return false;
|
22663
22684
|
}
|
@@ -22665,7 +22686,7 @@ const _sfc_main = {
|
|
22665
22686
|
const block = this.editor.range.anchor.element.getBlock();
|
22666
22687
|
return blockIsTask(block);
|
22667
22688
|
}
|
22668
|
-
const result = this.editor.getElementsByRange(true, false);
|
22689
|
+
const result = this.editor.getElementsByRange(true, false, useCache);
|
22669
22690
|
return result.every((item) => {
|
22670
22691
|
if (item.element.isBlock()) {
|
22671
22692
|
return blockIsTask(item.element);
|
@@ -22710,14 +22731,14 @@ const _sfc_main = {
|
|
22710
22731
|
}
|
22711
22732
|
},
|
22712
22733
|
//api:插入代码块
|
22713
|
-
insertCodeBlock(isRender = true) {
|
22734
|
+
insertCodeBlock(isRender = true, useCache = false) {
|
22714
22735
|
if (this.disabled) {
|
22715
22736
|
return;
|
22716
22737
|
}
|
22717
22738
|
if (!this.editor.range) {
|
22718
22739
|
return;
|
22719
22740
|
}
|
22720
|
-
const pre = this.getCurrentParsedomElement("pre");
|
22741
|
+
const pre = this.getCurrentParsedomElement("pre", useCache);
|
22721
22742
|
if (pre) {
|
22722
22743
|
let content = "";
|
22723
22744
|
AlexElement.flatElements(pre.children).filter((item) => {
|
@@ -22743,10 +22764,10 @@ const _sfc_main = {
|
|
22743
22764
|
this.editor.addElementTo(breakEl, paragraph);
|
22744
22765
|
this.editor.addElementAfter(paragraph, block);
|
22745
22766
|
} else {
|
22746
|
-
let result = this.editor.getElementsByRange(true, false);
|
22767
|
+
let result = this.editor.getElementsByRange(true, false, useCache);
|
22747
22768
|
this.editor.range.anchor.moveToStart(result[0].element.getBlock());
|
22748
22769
|
this.editor.range.focus.moveToEnd(result[result.length - 1].element.getBlock());
|
22749
|
-
const res = this.editor.getElementsByRange(true, true).filter((el) => el.element.isText());
|
22770
|
+
const res = this.editor.getElementsByRange(true, true, useCache).filter((el) => el.element.isText());
|
22750
22771
|
const obj2 = {};
|
22751
22772
|
res.forEach((el) => {
|
22752
22773
|
if (obj2[el.element.getBlock().key]) {
|
@@ -22883,7 +22904,7 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
22883
22904
|
])) : createCommentVNode("", true)
|
22884
22905
|
]);
|
22885
22906
|
}
|
22886
|
-
const Editify = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render], ["__scopeId", "data-v-
|
22907
|
+
const Editify = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render], ["__scopeId", "data-v-b523f8ea"]]);
|
22887
22908
|
const iconfont = "";
|
22888
22909
|
const en_US = {
|
22889
22910
|
textWrapUp: "Up feed",
|
@@ -23064,7 +23085,7 @@ const i18n = (locale) => {
|
|
23064
23085
|
return translations[locale][key];
|
23065
23086
|
};
|
23066
23087
|
};
|
23067
|
-
const version = "0.0.
|
23088
|
+
const version = "0.0.47";
|
23068
23089
|
const install = (app, props) => {
|
23069
23090
|
const locale = (props ? props.locale : "zh_CN") || "zh_CN";
|
23070
23091
|
app.provide("$editTrans", i18n(locale));
|