vue-editify 0.0.46 → 0.0.47
Sign up to get free protection for your applications and to get access to all the features.
- 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
@@ -1194,23 +1194,25 @@ export default {
|
|
1194
1194
|
return
|
1195
1195
|
}
|
1196
1196
|
//获取选区的元素
|
1197
|
-
const result = this.$parent.editor.getElementsByRange(true, false)
|
1197
|
+
const result = this.$parent.editor.getElementsByRange(true, false, true)
|
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
|
//选区是否含有链接元素
|
1207
|
-
const hasLink = this.$parent.hasLink()
|
1208
|
+
const hasLink = this.$parent.hasLink(true)
|
1209
|
+
|
1208
1210
|
//选区是否都在有序列表内
|
1209
|
-
const inOrderList = this.$parent.inList(true)
|
1211
|
+
const inOrderList = this.$parent.inList(true, true)
|
1210
1212
|
//选区是否都在无序列表内
|
1211
|
-
const inUnorderList = this.$parent.inList(false)
|
1213
|
+
const inUnorderList = this.$parent.inList(false, true)
|
1212
1214
|
//选区是否都在任务列表内
|
1213
|
-
const inTask = this.$parent.inTask()
|
1215
|
+
const inTask = this.$parent.inTask(true)
|
1214
1216
|
//额外禁用判定
|
1215
1217
|
const extraDisabled = name => {
|
1216
1218
|
if (typeof this.config.extraDisabled == 'function') {
|
@@ -1272,7 +1274,7 @@ export default {
|
|
1272
1274
|
this.taskConfig.disabled = hasPreStyle || hasTable || extraDisabled('task')
|
1273
1275
|
|
1274
1276
|
//粗体按钮激活
|
1275
|
-
this.boldConfig.active = this.$parent.queryTextStyle('font-weight', 'bold')
|
1277
|
+
this.boldConfig.active = this.$parent.queryTextStyle('font-weight', 'bold', true)
|
1276
1278
|
//粗体按钮禁用
|
1277
1279
|
this.boldConfig.disabled = hasPreStyle || extraDisabled('bold')
|
1278
1280
|
|
@@ -1292,7 +1294,7 @@ export default {
|
|
1292
1294
|
this.strikethroughConfig.disabled = hasPreStyle || extraDisabled('strikethrough')
|
1293
1295
|
|
1294
1296
|
//行内代码按钮激活
|
1295
|
-
this.codeConfig.active = this.$parent.queryTextMark('data-editify-code')
|
1297
|
+
this.codeConfig.active = this.$parent.queryTextMark('data-editify-code', null, true)
|
1296
1298
|
//行内代码按钮禁用
|
1297
1299
|
this.codeConfig.disabled = hasPreStyle || extraDisabled('code')
|
1298
1300
|
|
@@ -1392,7 +1394,7 @@ export default {
|
|
1392
1394
|
this.tableConfig.disabled = hasPreStyle || hasTable || hasQuote || extraDisabled('table')
|
1393
1395
|
|
1394
1396
|
//代码块按钮激活
|
1395
|
-
this.codeBlockConfig.active = !!this.$parent.getCurrentParsedomElement('pre')
|
1397
|
+
this.codeBlockConfig.active = !!this.$parent.getCurrentParsedomElement('pre', true)
|
1396
1398
|
//代码块按钮禁用
|
1397
1399
|
this.codeBlockConfig.disabled = hasTable || hasQuote || extraDisabled('codeBlock')
|
1398
1400
|
|
@@ -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') || this.$parent.getCurrentParsedomElement('video', true)
|
571
571
|
if (element) {
|
572
572
|
const styles = {
|
573
573
|
width: value
|
@@ -673,8 +673,8 @@ export default {
|
|
673
673
|
this.$parent.editor.range.anchor.offset = this.$parent.editor.range.focus.offset
|
674
674
|
}
|
675
675
|
const table = this.$parent.getCurrentParsedomElement('table')
|
676
|
-
const column = this.$parent.getCurrentParsedomElement('td')
|
677
|
-
const tbody = this.$parent.getCurrentParsedomElement('tbody')
|
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 => {
|
@@ -726,7 +726,7 @@ export default {
|
|
726
726
|
this.$parent.editor.range.anchor.offset = this.$parent.editor.range.focus.offset
|
727
727
|
}
|
728
728
|
const table = this.$parent.getCurrentParsedomElement('table')
|
729
|
-
const row = this.$parent.getCurrentParsedomElement('tr')
|
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 => {
|
@@ -782,7 +782,7 @@ export default {
|
|
782
782
|
this.$parent.editor.range.anchor.offset = this.$parent.editor.range.focus.offset
|
783
783
|
}
|
784
784
|
const table = this.$parent.getCurrentParsedomElement('table')
|
785
|
-
const row = this.$parent.getCurrentParsedomElement('tr')
|
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) {
|
@@ -818,13 +818,13 @@ export default {
|
|
818
818
|
this.$parent.editor.range.anchor.offset = this.$parent.editor.range.focus.offset
|
819
819
|
}
|
820
820
|
const column = this.$parent.getCurrentParsedomElement('td')
|
821
|
-
const tbody = this.$parent.getCurrentParsedomElement('tbody')
|
822
|
-
const table = this.$parent.getCurrentParsedomElement('table')
|
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)
|
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, false, true)
|
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