vue-editify 0.0.46 → 0.0.48
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 +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
@@ -789,7 +789,7 @@ export default {
|
|
789
789
|
onLayerShow: () => {
|
790
790
|
//存在选区的情况下预置链接文本值
|
791
791
|
let text = ''
|
792
|
-
const result = this.$parent.$parent.editor.getElementsByRange(
|
792
|
+
const result = this.$parent.$parent.editor.getElementsByRange().flatIncludes
|
793
793
|
result.forEach(item => {
|
794
794
|
if (item.element.isText()) {
|
795
795
|
if (item.offset) {
|
@@ -1189,28 +1189,28 @@ export default {
|
|
1189
1189
|
}
|
1190
1190
|
},
|
1191
1191
|
//处理光标更新
|
1192
|
-
handleRangeUpdate() {
|
1192
|
+
handleRangeUpdate(useCache = false) {
|
1193
1193
|
if (this.disabled) {
|
1194
1194
|
return
|
1195
1195
|
}
|
1196
1196
|
//获取选区的元素
|
1197
|
-
const result = this.$parent.editor.getElementsByRange(
|
1197
|
+
const result = this.$parent.editor.getElementsByRange(useCache).includes
|
1198
1198
|
//选区是否含有代码块元素
|
1199
|
-
const hasPreStyle = this.$parent.hasPreStyle()
|
1199
|
+
const hasPreStyle = this.$parent.hasPreStyle(true)
|
1200
1200
|
//选区是否含有表格元素
|
1201
|
-
const hasTable = this.$parent.hasTable()
|
1201
|
+
const hasTable = this.$parent.hasTable(true)
|
1202
1202
|
//选区是否含有引用元素
|
1203
|
-
const hasQuote = this.$parent.hasQuote()
|
1203
|
+
const hasQuote = this.$parent.hasQuote(true)
|
1204
1204
|
//选区是否都在引用元素内
|
1205
|
-
const inQuote = this.$parent.inQuote()
|
1205
|
+
const inQuote = this.$parent.inQuote(true)
|
1206
1206
|
//选区是否含有链接元素
|
1207
|
-
const hasLink = this.$parent.hasLink()
|
1207
|
+
const hasLink = this.$parent.hasLink(true)
|
1208
1208
|
//选区是否都在有序列表内
|
1209
|
-
const inOrderList = this.$parent.inList(true)
|
1209
|
+
const inOrderList = this.$parent.inList(true, true)
|
1210
1210
|
//选区是否都在无序列表内
|
1211
|
-
const inUnorderList = this.$parent.inList(false)
|
1211
|
+
const inUnorderList = this.$parent.inList(false, true)
|
1212
1212
|
//选区是否都在任务列表内
|
1213
|
-
const inTask = this.$parent.inTask()
|
1213
|
+
const inTask = this.$parent.inTask(true)
|
1214
1214
|
//额外禁用判定
|
1215
1215
|
const extraDisabled = name => {
|
1216
1216
|
if (typeof this.config.extraDisabled == 'function') {
|
@@ -1272,7 +1272,7 @@ export default {
|
|
1272
1272
|
this.taskConfig.disabled = hasPreStyle || hasTable || extraDisabled('task')
|
1273
1273
|
|
1274
1274
|
//粗体按钮激活
|
1275
|
-
this.boldConfig.active = this.$parent.queryTextStyle('font-weight', 'bold')
|
1275
|
+
this.boldConfig.active = this.$parent.queryTextStyle('font-weight', 'bold', true)
|
1276
1276
|
//粗体按钮禁用
|
1277
1277
|
this.boldConfig.disabled = hasPreStyle || extraDisabled('bold')
|
1278
1278
|
|
@@ -1292,7 +1292,7 @@ export default {
|
|
1292
1292
|
this.strikethroughConfig.disabled = hasPreStyle || extraDisabled('strikethrough')
|
1293
1293
|
|
1294
1294
|
//行内代码按钮激活
|
1295
|
-
this.codeConfig.active = this.$parent.queryTextMark('data-editify-code')
|
1295
|
+
this.codeConfig.active = this.$parent.queryTextMark('data-editify-code', null, true)
|
1296
1296
|
//行内代码按钮禁用
|
1297
1297
|
this.codeConfig.disabled = hasPreStyle || extraDisabled('code')
|
1298
1298
|
|
@@ -1392,7 +1392,7 @@ export default {
|
|
1392
1392
|
this.tableConfig.disabled = hasPreStyle || hasTable || hasQuote || extraDisabled('table')
|
1393
1393
|
|
1394
1394
|
//代码块按钮激活
|
1395
|
-
this.codeBlockConfig.active = !!this.$parent.getCurrentParsedomElement('pre')
|
1395
|
+
this.codeBlockConfig.active = !!this.$parent.getCurrentParsedomElement('pre', true)
|
1396
1396
|
//代码块按钮禁用
|
1397
1397
|
this.codeBlockConfig.disabled = hasTable || hasQuote || extraDisabled('codeBlock')
|
1398
1398
|
|
@@ -474,80 +474,80 @@ export default {
|
|
474
474
|
methods: {
|
475
475
|
//清除格式
|
476
476
|
clearFormat() {
|
477
|
-
this.$parent.formatText()
|
477
|
+
this.$parent.formatText(true, true)
|
478
478
|
},
|
479
479
|
//设置背景色
|
480
480
|
setBackColor(value) {
|
481
|
-
this.$parent.setTextStyle('background-color', value)
|
481
|
+
this.$parent.setTextStyle('background-color', value, true, true)
|
482
482
|
this.$refs.backColor.hideLayer()
|
483
483
|
},
|
484
484
|
//设置前景色
|
485
485
|
setForeColor(value) {
|
486
|
-
this.$parent.setTextStyle('color', value)
|
486
|
+
this.$parent.setTextStyle('color', value, true, true)
|
487
487
|
this.$refs.foreColor.hideLayer()
|
488
488
|
},
|
489
489
|
//设置行高
|
490
490
|
setLineHeight(name, value) {
|
491
|
-
this.$parent.setLineHeight(value)
|
491
|
+
this.$parent.setLineHeight(value, true, true)
|
492
492
|
},
|
493
493
|
//设置字体
|
494
494
|
setFontFamily(name, value) {
|
495
|
-
this.$parent.setTextStyle('font-family', value)
|
495
|
+
this.$parent.setTextStyle('font-family', value, true, true)
|
496
496
|
},
|
497
497
|
//设置字号
|
498
498
|
setFontSize(name, value) {
|
499
|
-
this.$parent.setTextStyle('font-size', value)
|
499
|
+
this.$parent.setTextStyle('font-size', value, true, true)
|
500
500
|
},
|
501
501
|
//设置上标
|
502
502
|
setSuperscript() {
|
503
|
-
this.$parent.setTextStyle('vertical-align', 'super')
|
503
|
+
this.$parent.setTextStyle('vertical-align', 'super', true, true)
|
504
504
|
},
|
505
505
|
//设置下标
|
506
506
|
setSubscript() {
|
507
|
-
this.$parent.setTextStyle('vertical-align', 'sub')
|
507
|
+
this.$parent.setTextStyle('vertical-align', 'sub', true, true)
|
508
508
|
},
|
509
509
|
//设置行内代码样式
|
510
510
|
setCodeStyle() {
|
511
|
-
this.$parent.setTextMark('data-editify-code', true)
|
511
|
+
this.$parent.setTextMark('data-editify-code', true, true, true)
|
512
512
|
},
|
513
513
|
//设置下划线
|
514
514
|
setUnderline() {
|
515
|
-
this.$parent.setTextStyle('text-decoration', 'underline')
|
515
|
+
this.$parent.setTextStyle('text-decoration', 'underline', true, true)
|
516
516
|
},
|
517
517
|
//设置删除线
|
518
518
|
setStrikethrough() {
|
519
|
-
this.$parent.setTextStyle('text-decoration', 'line-through')
|
519
|
+
this.$parent.setTextStyle('text-decoration', 'line-through', true, true)
|
520
520
|
},
|
521
521
|
//设置列表
|
522
522
|
setList(name) {
|
523
|
-
this.$parent.setList(name == 'orderList')
|
523
|
+
this.$parent.setList(name == 'orderList', true, true)
|
524
524
|
},
|
525
525
|
//设置任务列表
|
526
526
|
setTask() {
|
527
|
-
this.$parent.setTask()
|
527
|
+
this.$parent.setTask(true, true)
|
528
528
|
},
|
529
529
|
//斜体
|
530
530
|
setItalic() {
|
531
|
-
this.$parent.setTextStyle('font-style', 'italic')
|
531
|
+
this.$parent.setTextStyle('font-style', 'italic', true, true)
|
532
532
|
},
|
533
533
|
//加粗
|
534
534
|
setBold() {
|
535
|
-
this.$parent.setTextStyle('font-weight', 'bold')
|
535
|
+
this.$parent.setTextStyle('font-weight', 'bold', true, true)
|
536
536
|
},
|
537
537
|
//设置标题
|
538
538
|
setHeading(name, value) {
|
539
|
-
this.$parent.setHeading(value)
|
539
|
+
this.$parent.setHeading(value, true, true)
|
540
540
|
},
|
541
541
|
//设置对齐方式
|
542
542
|
setAlign(name, value) {
|
543
|
-
this.$parent.setAlign(value)
|
543
|
+
this.$parent.setAlign(value, true, true)
|
544
544
|
},
|
545
545
|
//设置视频
|
546
546
|
setVideo(prop) {
|
547
547
|
if (this.$parent.disabled) {
|
548
548
|
return
|
549
549
|
}
|
550
|
-
const video = this.$parent.getCurrentParsedomElement('video')
|
550
|
+
const video = this.$parent.getCurrentParsedomElement('video', true)
|
551
551
|
if (video) {
|
552
552
|
//当前是拥有该属性
|
553
553
|
if (this.videoConfig[prop]) {
|
@@ -567,7 +567,7 @@ export default {
|
|
567
567
|
if (this.$parent.disabled) {
|
568
568
|
return
|
569
569
|
}
|
570
|
-
const element = this.$parent.getCurrentParsedomElement('img') || this.$parent.getCurrentParsedomElement('video')
|
570
|
+
const element = this.$parent.getCurrentParsedomElement('img', true) || this.$parent.getCurrentParsedomElement('video', true)
|
571
571
|
if (element) {
|
572
572
|
const styles = {
|
573
573
|
width: value
|
@@ -594,7 +594,7 @@ export default {
|
|
594
594
|
if (!this.linkConfig.url) {
|
595
595
|
return
|
596
596
|
}
|
597
|
-
const link = this.$parent.getCurrentParsedomElement('a')
|
597
|
+
const link = this.$parent.getCurrentParsedomElement('a', true)
|
598
598
|
if (link) {
|
599
599
|
link.marks.href = this.linkConfig.url
|
600
600
|
if (this.linkConfig.newOpen) {
|
@@ -627,7 +627,7 @@ export default {
|
|
627
627
|
if (this.$parent.disabled) {
|
628
628
|
return
|
629
629
|
}
|
630
|
-
const pre = this.$parent.getCurrentParsedomElement('pre')
|
630
|
+
const pre = this.$parent.getCurrentParsedomElement('pre', true)
|
631
631
|
if (pre) {
|
632
632
|
Object.assign(pre.marks, {
|
633
633
|
'data-editify-hljs': value
|
@@ -646,7 +646,7 @@ export default {
|
|
646
646
|
this.$parent.editor.range.anchor.element = this.$parent.editor.range.focus.element
|
647
647
|
this.$parent.editor.range.anchor.offset = this.$parent.editor.range.focus.offset
|
648
648
|
}
|
649
|
-
const pre = this.$parent.getCurrentParsedomElement('pre')
|
649
|
+
const pre = this.$parent.getCurrentParsedomElement('pre', true)
|
650
650
|
if (pre) {
|
651
651
|
const paragraph = new AlexElement('block', AlexElement.BLOCK_NODE, null, null, null)
|
652
652
|
const breakEl = new AlexElement('closed', 'br', null, null, null)
|
@@ -672,9 +672,9 @@ export default {
|
|
672
672
|
this.$parent.editor.range.anchor.element = this.$parent.editor.range.focus.element
|
673
673
|
this.$parent.editor.range.anchor.offset = this.$parent.editor.range.focus.offset
|
674
674
|
}
|
675
|
-
const table = this.$parent.getCurrentParsedomElement('table')
|
676
|
-
const column = this.$parent.getCurrentParsedomElement('td')
|
677
|
-
const tbody = this.$parent.getCurrentParsedomElement('tbody')
|
675
|
+
const table = this.$parent.getCurrentParsedomElement('table', true)
|
676
|
+
const column = this.$parent.getCurrentParsedomElement('td', true)
|
677
|
+
const tbody = this.$parent.getCurrentParsedomElement('tbody', true)
|
678
678
|
if (column && table && tbody) {
|
679
679
|
const rows = tbody.children
|
680
680
|
const index = column.parent.children.findIndex(item => {
|
@@ -716,7 +716,7 @@ export default {
|
|
716
716
|
this.$parent.editor.rangeRender()
|
717
717
|
}
|
718
718
|
},
|
719
|
-
|
719
|
+
//表格前后插入行
|
720
720
|
insertTableRow(type = 'up') {
|
721
721
|
if (this.$parent.disabled) {
|
722
722
|
return
|
@@ -725,8 +725,8 @@ export default {
|
|
725
725
|
this.$parent.editor.range.anchor.element = this.$parent.editor.range.focus.element
|
726
726
|
this.$parent.editor.range.anchor.offset = this.$parent.editor.range.focus.offset
|
727
727
|
}
|
728
|
-
const table = this.$parent.getCurrentParsedomElement('table')
|
729
|
-
const row = this.$parent.getCurrentParsedomElement('tr')
|
728
|
+
const table = this.$parent.getCurrentParsedomElement('table', true)
|
729
|
+
const row = this.$parent.getCurrentParsedomElement('tr', true)
|
730
730
|
if (table && row) {
|
731
731
|
const newRow = row.clone()
|
732
732
|
newRow.children.forEach(column => {
|
@@ -755,7 +755,7 @@ export default {
|
|
755
755
|
if (this.$parent.disabled) {
|
756
756
|
return
|
757
757
|
}
|
758
|
-
const table = this.$parent.getCurrentParsedomElement('table')
|
758
|
+
const table = this.$parent.getCurrentParsedomElement('table', true)
|
759
759
|
if (table) {
|
760
760
|
const paragraph = new AlexElement('block', AlexElement.BLOCK_NODE, null, null, null)
|
761
761
|
const breakEl = new AlexElement('closed', 'br', null, null, null)
|
@@ -781,12 +781,12 @@ export default {
|
|
781
781
|
this.$parent.editor.range.anchor.element = this.$parent.editor.range.focus.element
|
782
782
|
this.$parent.editor.range.anchor.offset = this.$parent.editor.range.focus.offset
|
783
783
|
}
|
784
|
-
const table = this.$parent.getCurrentParsedomElement('table')
|
785
|
-
const row = this.$parent.getCurrentParsedomElement('tr')
|
784
|
+
const table = this.$parent.getCurrentParsedomElement('table', true)
|
785
|
+
const row = this.$parent.getCurrentParsedomElement('tr', true)
|
786
786
|
if (table && row) {
|
787
787
|
const parent = row.parent
|
788
788
|
if (parent.children.length == 1) {
|
789
|
-
this.$parent.deleteByParsedom('table')
|
789
|
+
this.$parent.deleteByParsedom('table', true, true)
|
790
790
|
return
|
791
791
|
}
|
792
792
|
const previousRow = this.$parent.editor.getPreviousElement(row)
|
@@ -817,14 +817,14 @@ export default {
|
|
817
817
|
this.$parent.editor.range.anchor.element = this.$parent.editor.range.focus.element
|
818
818
|
this.$parent.editor.range.anchor.offset = this.$parent.editor.range.focus.offset
|
819
819
|
}
|
820
|
-
const column = this.$parent.getCurrentParsedomElement('td')
|
821
|
-
const tbody = this.$parent.getCurrentParsedomElement('tbody')
|
822
|
-
const table = this.$parent.getCurrentParsedomElement('table')
|
820
|
+
const column = this.$parent.getCurrentParsedomElement('td', true)
|
821
|
+
const tbody = this.$parent.getCurrentParsedomElement('tbody', true)
|
822
|
+
const table = this.$parent.getCurrentParsedomElement('table', true)
|
823
823
|
if (column && table && tbody) {
|
824
824
|
const rows = tbody.children
|
825
825
|
const parent = column.parent
|
826
826
|
if (parent.children.length == 1) {
|
827
|
-
this.$parent.deleteByParsedom('table')
|
827
|
+
this.$parent.deleteByParsedom('table', true, true)
|
828
828
|
return
|
829
829
|
}
|
830
830
|
const previousColumn = this.$parent.editor.getPreviousElement(column)
|
@@ -856,16 +856,18 @@ export default {
|
|
856
856
|
},
|
857
857
|
//浮层显示时
|
858
858
|
layerShow() {
|
859
|
+
//获取选区的元素
|
860
|
+
const result = this.$parent.editor.getElementsByRange(true).includes
|
859
861
|
//代码块初始化展示设置
|
860
862
|
if (this.type == 'codeBlock') {
|
861
|
-
const pre = this.$parent.getCurrentParsedomElement('pre')
|
863
|
+
const pre = this.$parent.getCurrentParsedomElement('pre', true)
|
862
864
|
if (pre) {
|
863
865
|
this.languageConfig.displayConfig.value = pre.marks['data-editify-hljs'] || ''
|
864
866
|
}
|
865
867
|
}
|
866
868
|
//链接初始化展示
|
867
869
|
else if (this.type == 'link') {
|
868
|
-
const link = this.$parent.getCurrentParsedomElement('a')
|
870
|
+
const link = this.$parent.getCurrentParsedomElement('a', true)
|
869
871
|
if (link) {
|
870
872
|
this.linkConfig.url = link.marks['href']
|
871
873
|
this.linkConfig.newOpen = link.marks['target'] == '_blank'
|
@@ -873,7 +875,7 @@ export default {
|
|
873
875
|
}
|
874
876
|
//视频初始化显示
|
875
877
|
else if (this.type == 'video') {
|
876
|
-
const video = this.$parent.getCurrentParsedomElement('video')
|
878
|
+
const video = this.$parent.getCurrentParsedomElement('video', true)
|
877
879
|
if (video) {
|
878
880
|
this.videoConfig.autoplay = !!video.marks['autoplay']
|
879
881
|
this.videoConfig.loop = !!video.marks['loop']
|
@@ -890,10 +892,6 @@ export default {
|
|
890
892
|
}
|
891
893
|
return false
|
892
894
|
}
|
893
|
-
|
894
|
-
//获取选区的元素
|
895
|
-
const result = this.$parent.editor.getElementsByRange(true, false)
|
896
|
-
|
897
895
|
//显示已设置标题
|
898
896
|
const findHeadingItem = this.headingConfig.displayConfig.options.find(item => {
|
899
897
|
let val = item
|
@@ -915,22 +913,22 @@ export default {
|
|
915
913
|
this.alignConfig.disabled = extraDisabled('align')
|
916
914
|
|
917
915
|
//有序列表按钮激活
|
918
|
-
this.orderListConfig.active = this.$parent.inList(true)
|
916
|
+
this.orderListConfig.active = this.$parent.inList(true, true)
|
919
917
|
//有序列表按钮禁用
|
920
918
|
this.orderListConfig.disabled = extraDisabled('orderList')
|
921
919
|
|
922
920
|
//无序列表按钮激活
|
923
|
-
this.unorderListConfig.active = this.$parent.inList(false)
|
921
|
+
this.unorderListConfig.active = this.$parent.inList(false, true)
|
924
922
|
//无序列表按钮禁用
|
925
923
|
this.unorderListConfig.disabled = extraDisabled('unorderList')
|
926
924
|
|
927
925
|
//任务列表按钮激活
|
928
|
-
this.taskConfig.active = this.$parent.inTask()
|
926
|
+
this.taskConfig.active = this.$parent.inTask(true, true)
|
929
927
|
//任务列表按钮禁用
|
930
928
|
this.taskConfig.disabled = extraDisabled('task')
|
931
929
|
|
932
930
|
//粗体按钮激活
|
933
|
-
this.boldConfig.active = this.$parent.queryTextStyle('font-weight', 'bold')
|
931
|
+
this.boldConfig.active = this.$parent.queryTextStyle('font-weight', 'bold', true)
|
934
932
|
//粗体按钮禁用
|
935
933
|
this.boldConfig.disabled = extraDisabled('bold')
|
936
934
|
|
@@ -950,7 +948,7 @@ export default {
|
|
950
948
|
this.underlineConfig.disabled = extraDisabled('underline')
|
951
949
|
|
952
950
|
//行内代码按钮激活
|
953
|
-
this.codeConfig.active = this.$parent.queryTextMark('data-editify-code')
|
951
|
+
this.codeConfig.active = this.$parent.queryTextMark('data-editify-code', null, true)
|
954
952
|
//行内代码按钮禁用
|
955
953
|
this.codeConfig.disabled = extraDisabled('code')
|
956
954
|
|
package/src/index.js
CHANGED