vue-editify 0.0.47 → 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 -14
- package/lib/editify.es.js +241 -238
- package/lib/editify.umd.js +1 -1
- package/lib/style.css +1 -1
- package/package.json +2 -2
- package/src/Editify.vue +55 -54
- package/src/components/bussiness/Menu.vue +3 -5
- package/src/components/bussiness/Toolbar.vue +31 -31
- package/src/index.js +1 -1
package/src/Editify.vue
CHANGED
@@ -236,13 +236,13 @@ export default {
|
|
236
236
|
removeScroll(this.$refs.content)
|
237
237
|
},
|
238
238
|
//工具条显示判断
|
239
|
-
handleToolbar() {
|
239
|
+
handleToolbar(useCache = false) {
|
240
240
|
if (this.disabled || this.isSourceView) {
|
241
241
|
return
|
242
242
|
}
|
243
243
|
this.hideToolbar()
|
244
244
|
this.$nextTick(() => {
|
245
|
-
const table = this.getCurrentParsedomElement('table',
|
245
|
+
const table = this.getCurrentParsedomElement('table', useCache)
|
246
246
|
const pre = this.getCurrentParsedomElement('pre', true)
|
247
247
|
const link = this.getCurrentParsedomElement('a', true)
|
248
248
|
const image = this.getCurrentParsedomElement('img', true)
|
@@ -288,7 +288,7 @@ export default {
|
|
288
288
|
this.toolbarOptions.show = true
|
289
289
|
}
|
290
290
|
} else {
|
291
|
-
const result = this.editor.getElementsByRange(true
|
291
|
+
const result = this.editor.getElementsByRange(true).flatIncludes.filter(item => {
|
292
292
|
return item.element.isText()
|
293
293
|
})
|
294
294
|
if (result.length && !this.hasTable(true) && !this.hasPreStyle(true) && !this.hasLink(true) && !this.hasImage(true) && !this.hasVideo(true)) {
|
@@ -576,7 +576,7 @@ export default {
|
|
576
576
|
this.$emit('insertparagraph', this.value)
|
577
577
|
},
|
578
578
|
//编辑器焦点更新
|
579
|
-
handleRangeUpdate(
|
579
|
+
handleRangeUpdate() {
|
580
580
|
if (this.disabled) {
|
581
581
|
return
|
582
582
|
}
|
@@ -584,21 +584,21 @@ export default {
|
|
584
584
|
clearTimeout(this.updateTimer)
|
585
585
|
}
|
586
586
|
this.updateTimer = setTimeout(() => {
|
587
|
-
|
587
|
+
//如果使用工具条或者菜单栏
|
588
588
|
if (this.toolbarConfig.use || this.menuConfig.use) {
|
589
|
-
|
590
|
-
this.editor.getElementsByRange(
|
591
|
-
|
592
|
-
|
593
|
-
|
594
|
-
|
595
|
-
|
596
|
-
|
597
|
-
|
598
|
-
|
589
|
+
//先获取选区内的元素设置内部缓存
|
590
|
+
this.editor.getElementsByRange()
|
591
|
+
//如果使用工具条
|
592
|
+
if (this.toolbarConfig.use) {
|
593
|
+
this.handleToolbar(true)
|
594
|
+
}
|
595
|
+
//如果使用菜单栏
|
596
|
+
if (this.menuConfig.use) {
|
597
|
+
this.$refs.menu.handleRangeUpdate(true)
|
598
|
+
}
|
599
599
|
}
|
600
600
|
}, 200)
|
601
|
-
this.$emit('rangeupdate', this.value
|
601
|
+
this.$emit('rangeupdate', this.value)
|
602
602
|
},
|
603
603
|
//编辑器复制
|
604
604
|
handleCopy(text, html) {
|
@@ -613,7 +613,7 @@ export default {
|
|
613
613
|
this.$emit('paste-text', data)
|
614
614
|
},
|
615
615
|
//编辑器粘贴html
|
616
|
-
handlePasteHtml(elements
|
616
|
+
handlePasteHtml(elements) {
|
617
617
|
const keepStyles = Object.assign(pasteKeepData.styles, this.pasteKeepStyles || {})
|
618
618
|
const keepMarks = Object.assign(pasteKeepData.marks, this.pasteKeepMarks || {})
|
619
619
|
//粘贴html时过滤元素的样式和属性
|
@@ -727,7 +727,7 @@ export default {
|
|
727
727
|
if (this.editor.range.anchor.element.isEqual(this.editor.range.focus.element)) {
|
728
728
|
return this.getParsedomElementByElement(this.editor.range.anchor.element, parsedom)
|
729
729
|
}
|
730
|
-
const arr = this.editor.getElementsByRange(
|
730
|
+
const arr = this.editor.getElementsByRange(useCache).includes.map(item => {
|
731
731
|
return this.getParsedomElementByElement(item.element, parsedom)
|
732
732
|
})
|
733
733
|
let hasNull = arr.some(el => {
|
@@ -814,7 +814,7 @@ export default {
|
|
814
814
|
//设置标题
|
815
815
|
block.parsedom = parsedom
|
816
816
|
} else {
|
817
|
-
const result = this.editor.getElementsByRange(
|
817
|
+
const result = this.editor.getElementsByRange(useCache).includes
|
818
818
|
result.forEach(el => {
|
819
819
|
if (el.element.isBlock()) {
|
820
820
|
blockToParagraph(el.element)
|
@@ -853,7 +853,7 @@ export default {
|
|
853
853
|
//起点和终点不在一起
|
854
854
|
else {
|
855
855
|
let blocks = []
|
856
|
-
const result = this.editor.getElementsByRange(
|
856
|
+
const result = this.editor.getElementsByRange(useCache).includes
|
857
857
|
result.forEach(item => {
|
858
858
|
const block = item.element.getBlock()
|
859
859
|
const exist = blocks.some(el => block.isEqual(el))
|
@@ -897,7 +897,7 @@ export default {
|
|
897
897
|
//起点和终点不在一起
|
898
898
|
else {
|
899
899
|
let blocks = []
|
900
|
-
const result = this.editor.getElementsByRange(
|
900
|
+
const result = this.editor.getElementsByRange(useCache).includes
|
901
901
|
result.forEach(item => {
|
902
902
|
const block = item.element.getBlock()
|
903
903
|
const exist = blocks.some(el => block.isEqual(el))
|
@@ -930,11 +930,11 @@ export default {
|
|
930
930
|
}
|
931
931
|
const active = this.queryTextStyle(name, value, useCache)
|
932
932
|
if (active) {
|
933
|
-
this.editor.removeTextStyle([name],
|
933
|
+
this.editor.removeTextStyle([name], true)
|
934
934
|
} else {
|
935
935
|
let styles = {}
|
936
936
|
styles[name] = value
|
937
|
-
this.editor.setTextStyle(styles,
|
937
|
+
this.editor.setTextStyle(styles, true)
|
938
938
|
}
|
939
939
|
if (isRender) {
|
940
940
|
this.editor.formatElementStack()
|
@@ -956,11 +956,11 @@ export default {
|
|
956
956
|
}
|
957
957
|
const active = this.queryTextMark(name, value, useCache)
|
958
958
|
if (active) {
|
959
|
-
this.editor.removeTextMark([name],
|
959
|
+
this.editor.removeTextMark([name], true)
|
960
960
|
} else {
|
961
961
|
let marks = {}
|
962
962
|
marks[name] = value
|
963
|
-
this.editor.setTextMark(marks,
|
963
|
+
this.editor.setTextMark(marks, true)
|
964
964
|
}
|
965
965
|
if (isRender) {
|
966
966
|
this.editor.formatElementStack()
|
@@ -981,7 +981,8 @@ export default {
|
|
981
981
|
return
|
982
982
|
}
|
983
983
|
this.editor.removeTextStyle(null, useCache)
|
984
|
-
|
984
|
+
//这里不能使用缓存,因为removeTextStyle会更新光标位置
|
985
|
+
this.editor.removeTextMark(null)
|
985
986
|
if (isRender) {
|
986
987
|
this.editor.formatElementStack()
|
987
988
|
this.editor.domRender()
|
@@ -1017,7 +1018,7 @@ export default {
|
|
1017
1018
|
}
|
1018
1019
|
}
|
1019
1020
|
} else {
|
1020
|
-
const result = this.editor.getElementsByRange(
|
1021
|
+
const result = this.editor.getElementsByRange(useCache).includes
|
1021
1022
|
result.forEach(el => {
|
1022
1023
|
if (el.element.isBlock() || el.element.isInblock()) {
|
1023
1024
|
if (el.element.hasStyles()) {
|
@@ -1106,7 +1107,7 @@ export default {
|
|
1106
1107
|
//起点和终点不在一起
|
1107
1108
|
else {
|
1108
1109
|
let blocks = []
|
1109
|
-
const result = this.editor.getElementsByRange(
|
1110
|
+
const result = this.editor.getElementsByRange(useCache).includes
|
1110
1111
|
result.forEach(item => {
|
1111
1112
|
const block = item.element.getBlock()
|
1112
1113
|
const exist = blocks.some(el => block.isEqual(el))
|
@@ -1157,7 +1158,7 @@ export default {
|
|
1157
1158
|
}
|
1158
1159
|
}
|
1159
1160
|
} else {
|
1160
|
-
const result = this.editor.getElementsByRange(
|
1161
|
+
const result = this.editor.getElementsByRange(useCache).includes
|
1161
1162
|
result.forEach(el => {
|
1162
1163
|
if (el.element.isBlock() || el.element.isInblock()) {
|
1163
1164
|
if (el.element.hasStyles()) {
|
@@ -1232,7 +1233,7 @@ export default {
|
|
1232
1233
|
fn(block)
|
1233
1234
|
}
|
1234
1235
|
} else {
|
1235
|
-
const result = this.editor.getElementsByRange(
|
1236
|
+
const result = this.editor.getElementsByRange(useCache).includes
|
1236
1237
|
result.forEach(item => {
|
1237
1238
|
const block = item.element.getBlock()
|
1238
1239
|
const inblock = item.element.getInblock()
|
@@ -1277,7 +1278,7 @@ export default {
|
|
1277
1278
|
fn(block)
|
1278
1279
|
}
|
1279
1280
|
} else {
|
1280
|
-
const result = this.editor.getElementsByRange(
|
1281
|
+
const result = this.editor.getElementsByRange(useCache).includes
|
1281
1282
|
result.forEach(item => {
|
1282
1283
|
const block = item.element.getBlock()
|
1283
1284
|
const inblock = item.element.getInblock()
|
@@ -1295,7 +1296,7 @@ export default {
|
|
1295
1296
|
}
|
1296
1297
|
},
|
1297
1298
|
//api:插入图片
|
1298
|
-
insertImage(url, isRender = true) {
|
1299
|
+
insertImage(url, isRender = true, useCache = false) {
|
1299
1300
|
if (this.disabled) {
|
1300
1301
|
return
|
1301
1302
|
}
|
@@ -1314,7 +1315,7 @@ export default {
|
|
1314
1315
|
null,
|
1315
1316
|
null
|
1316
1317
|
)
|
1317
|
-
this.editor.insertElement(image)
|
1318
|
+
this.editor.insertElement(image, true, useCache)
|
1318
1319
|
if (isRender) {
|
1319
1320
|
this.editor.formatElementStack()
|
1320
1321
|
this.editor.domRender()
|
@@ -1322,7 +1323,7 @@ export default {
|
|
1322
1323
|
}
|
1323
1324
|
},
|
1324
1325
|
//api:插入视频
|
1325
|
-
insertVideo(url, isRender = true) {
|
1326
|
+
insertVideo(url, isRender = true, useCache = false) {
|
1326
1327
|
if (this.disabled) {
|
1327
1328
|
return
|
1328
1329
|
}
|
@@ -1341,7 +1342,7 @@ export default {
|
|
1341
1342
|
null,
|
1342
1343
|
null
|
1343
1344
|
)
|
1344
|
-
this.editor.insertElement(video)
|
1345
|
+
this.editor.insertElement(video, true, useCache)
|
1345
1346
|
const leftSpace = AlexElement.getSpaceElement()
|
1346
1347
|
const rightSpace = AlexElement.getSpaceElement()
|
1347
1348
|
this.editor.addElementAfter(rightSpace, video)
|
@@ -1362,7 +1363,7 @@ export default {
|
|
1362
1363
|
if (this.editor.range.anchor.isEqual(this.editor.range.focus)) {
|
1363
1364
|
return this.editor.range.anchor.element.isPreStyle()
|
1364
1365
|
}
|
1365
|
-
const result = this.editor.getElementsByRange(
|
1366
|
+
const result = this.editor.getElementsByRange(useCache).includes
|
1366
1367
|
return result.some(item => {
|
1367
1368
|
return item.element.isPreStyle()
|
1368
1369
|
})
|
@@ -1376,7 +1377,7 @@ export default {
|
|
1376
1377
|
const block = this.editor.range.anchor.element.getBlock()
|
1377
1378
|
return block.parsedom == 'blockquote'
|
1378
1379
|
}
|
1379
|
-
const result = this.editor.getElementsByRange(
|
1380
|
+
const result = this.editor.getElementsByRange(useCache).includes
|
1380
1381
|
return result.some(item => {
|
1381
1382
|
if (item.element.isBlock()) {
|
1382
1383
|
return item.element.parsedom == 'blockquote'
|
@@ -1395,7 +1396,7 @@ export default {
|
|
1395
1396
|
const block = this.editor.range.anchor.element.getBlock()
|
1396
1397
|
return blockIsList(block, ordered)
|
1397
1398
|
}
|
1398
|
-
const result = this.editor.getElementsByRange(
|
1399
|
+
const result = this.editor.getElementsByRange(useCache).includes
|
1399
1400
|
return result.some(item => {
|
1400
1401
|
if (item.element.isBlock()) {
|
1401
1402
|
return blockIsList(item.element, ordered)
|
@@ -1413,7 +1414,7 @@ export default {
|
|
1413
1414
|
if (this.editor.range.anchor.isEqual(this.editor.range.focus)) {
|
1414
1415
|
return !!this.getParsedomElementByElement(this.editor.range.anchor.element, 'a')
|
1415
1416
|
}
|
1416
|
-
const result = this.editor.getElementsByRange(
|
1417
|
+
const result = this.editor.getElementsByRange(useCache).flatIncludes.filter(item => {
|
1417
1418
|
return item.element.isText()
|
1418
1419
|
})
|
1419
1420
|
return result.some(item => {
|
@@ -1429,7 +1430,7 @@ export default {
|
|
1429
1430
|
const block = this.editor.range.anchor.element.getBlock()
|
1430
1431
|
return block.parsedom == 'table'
|
1431
1432
|
}
|
1432
|
-
const result = this.editor.getElementsByRange(
|
1433
|
+
const result = this.editor.getElementsByRange(useCache).includes
|
1433
1434
|
return result.some(item => {
|
1434
1435
|
if (item.element.isBlock()) {
|
1435
1436
|
return item.element.parsedom == 'table'
|
@@ -1448,7 +1449,7 @@ export default {
|
|
1448
1449
|
const block = this.editor.range.anchor.element.getBlock()
|
1449
1450
|
return blockIsTask(block)
|
1450
1451
|
}
|
1451
|
-
const result = this.editor.getElementsByRange(
|
1452
|
+
const result = this.editor.getElementsByRange(useCache).includes
|
1452
1453
|
return result.some(item => {
|
1453
1454
|
if (item.element.isBlock()) {
|
1454
1455
|
return blockIsTask(item.element)
|
@@ -1466,7 +1467,7 @@ export default {
|
|
1466
1467
|
if (this.editor.range.anchor.isEqual(this.editor.range.focus)) {
|
1467
1468
|
return this.editor.range.anchor.element.isClosed() && this.editor.range.anchor.element.parsedom == 'img'
|
1468
1469
|
}
|
1469
|
-
const result = this.editor.getElementsByRange(
|
1470
|
+
const result = this.editor.getElementsByRange(useCache).flatIncludes
|
1470
1471
|
return result.some(item => {
|
1471
1472
|
return item.element.isClosed() && item.element.parsedom == 'img'
|
1472
1473
|
})
|
@@ -1479,7 +1480,7 @@ export default {
|
|
1479
1480
|
if (this.editor.range.anchor.isEqual(this.editor.range.focus)) {
|
1480
1481
|
return this.editor.range.anchor.element.isClosed() && this.editor.range.anchor.element.parsedom == 'video'
|
1481
1482
|
}
|
1482
|
-
const result = this.editor.getElementsByRange(
|
1483
|
+
const result = this.editor.getElementsByRange(useCache).flatIncludes
|
1483
1484
|
return result.some(item => {
|
1484
1485
|
return item.element.isClosed() && item.element.parsedom == 'video'
|
1485
1486
|
})
|
@@ -1493,7 +1494,7 @@ export default {
|
|
1493
1494
|
const block = this.editor.range.anchor.element.getBlock()
|
1494
1495
|
return block.parsedom == 'blockquote'
|
1495
1496
|
}
|
1496
|
-
const result = this.editor.getElementsByRange(
|
1497
|
+
const result = this.editor.getElementsByRange(useCache).includes
|
1497
1498
|
return result.every(item => {
|
1498
1499
|
if (item.element.isBlock()) {
|
1499
1500
|
return item.element.parsedom == 'blockquote'
|
@@ -1512,7 +1513,7 @@ export default {
|
|
1512
1513
|
const block = this.editor.range.anchor.element.getBlock()
|
1513
1514
|
return blockIsList(block, ordered)
|
1514
1515
|
}
|
1515
|
-
const result = this.editor.getElementsByRange(
|
1516
|
+
const result = this.editor.getElementsByRange(useCache).includes
|
1516
1517
|
return result.every(item => {
|
1517
1518
|
if (item.element.isBlock()) {
|
1518
1519
|
return blockIsList(item.element, ordered)
|
@@ -1531,7 +1532,7 @@ export default {
|
|
1531
1532
|
const block = this.editor.range.anchor.element.getBlock()
|
1532
1533
|
return blockIsTask(block)
|
1533
1534
|
}
|
1534
|
-
const result = this.editor.getElementsByRange(
|
1535
|
+
const result = this.editor.getElementsByRange(useCache).includes
|
1535
1536
|
return result.every(item => {
|
1536
1537
|
if (item.element.isBlock()) {
|
1537
1538
|
return blockIsTask(item.element)
|
@@ -1542,7 +1543,7 @@ export default {
|
|
1542
1543
|
})
|
1543
1544
|
},
|
1544
1545
|
//api:创建一个空的表格
|
1545
|
-
insertTable(rowLength, colLength, isRender = true) {
|
1546
|
+
insertTable(rowLength, colLength, isRender = true, useCache = false) {
|
1546
1547
|
if (this.disabled) {
|
1547
1548
|
return
|
1548
1549
|
}
|
@@ -1562,7 +1563,7 @@ export default {
|
|
1562
1563
|
}
|
1563
1564
|
this.editor.addElementTo(row, tbody)
|
1564
1565
|
}
|
1565
|
-
this.editor.insertElement(table)
|
1566
|
+
this.editor.insertElement(table, true, useCache)
|
1566
1567
|
//在表格后创建一个段落
|
1567
1568
|
const paragraph = new AlexElement('block', AlexElement.BLOCK_NODE, null, null, null)
|
1568
1569
|
const breakEl = new AlexElement('closed', 'br', null, null, null)
|
@@ -1615,10 +1616,10 @@ export default {
|
|
1615
1616
|
}
|
1616
1617
|
//起点和终点不在一起
|
1617
1618
|
else {
|
1618
|
-
let result = this.editor.getElementsByRange(true
|
1619
|
+
let result = this.editor.getElementsByRange(true).includes
|
1619
1620
|
this.editor.range.anchor.moveToStart(result[0].element.getBlock())
|
1620
1621
|
this.editor.range.focus.moveToEnd(result[result.length - 1].element.getBlock())
|
1621
|
-
const res = this.editor.getElementsByRange(true
|
1622
|
+
const res = this.editor.getElementsByRange(true).flatIncludes.filter(el => el.element.isText())
|
1622
1623
|
const obj = {}
|
1623
1624
|
res.forEach(el => {
|
1624
1625
|
if (obj[el.element.getBlock().key]) {
|
@@ -1660,14 +1661,14 @@ export default {
|
|
1660
1661
|
}
|
1661
1662
|
},
|
1662
1663
|
//api:插入文本
|
1663
|
-
insertText(text, isRender = true) {
|
1664
|
+
insertText(text, isRender = true, useCache = false) {
|
1664
1665
|
if (this.disabled) {
|
1665
1666
|
return
|
1666
1667
|
}
|
1667
1668
|
if (!this.editor.range) {
|
1668
1669
|
return
|
1669
1670
|
}
|
1670
|
-
this.editor.insertText(text)
|
1671
|
+
this.editor.insertText(text, useCache)
|
1671
1672
|
if (isRender) {
|
1672
1673
|
this.editor.formatElementStack()
|
1673
1674
|
this.editor.domRender()
|
@@ -1675,7 +1676,7 @@ export default {
|
|
1675
1676
|
}
|
1676
1677
|
},
|
1677
1678
|
//api:插入html
|
1678
|
-
insertHtml(html, isRender = true) {
|
1679
|
+
insertHtml(html, isRender = true, useCache = false) {
|
1679
1680
|
if (this.disabled) {
|
1680
1681
|
return
|
1681
1682
|
}
|
@@ -1684,7 +1685,7 @@ export default {
|
|
1684
1685
|
}
|
1685
1686
|
const elements = this.editor.parseHtml(html)
|
1686
1687
|
for (let i = 0; i < elements.length; i++) {
|
1687
|
-
this.editor.insertElement(elements[i], false)
|
1688
|
+
this.editor.insertElement(elements[i], false, i == 0 ? useCache : false)
|
1688
1689
|
}
|
1689
1690
|
if (isRender) {
|
1690
1691
|
this.editor.formatElementStack()
|
@@ -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,12 +1189,12 @@ 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
1199
|
const hasPreStyle = this.$parent.hasPreStyle(true)
|
1200
1200
|
//选区是否含有表格元素
|
@@ -1203,10 +1203,8 @@ export default {
|
|
1203
1203
|
const hasQuote = this.$parent.hasQuote(true)
|
1204
1204
|
//选区是否都在引用元素内
|
1205
1205
|
const inQuote = this.$parent.inQuote(true)
|
1206
|
-
|
1207
1206
|
//选区是否含有链接元素
|
1208
1207
|
const hasLink = this.$parent.hasLink(true)
|
1209
|
-
|
1210
1208
|
//选区是否都在有序列表内
|
1211
1209
|
const inOrderList = this.$parent.inList(true, true)
|
1212
1210
|
//选区是否都在无序列表内
|
@@ -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', true)
|
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,7 +672,7 @@ 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')
|
675
|
+
const table = this.$parent.getCurrentParsedomElement('table', true)
|
676
676
|
const column = this.$parent.getCurrentParsedomElement('td', true)
|
677
677
|
const tbody = this.$parent.getCurrentParsedomElement('tbody', true)
|
678
678
|
if (column && table && tbody) {
|
@@ -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,7 +725,7 @@ 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')
|
728
|
+
const table = this.$parent.getCurrentParsedomElement('table', true)
|
729
729
|
const row = this.$parent.getCurrentParsedomElement('tr', true)
|
730
730
|
if (table && row) {
|
731
731
|
const newRow = row.clone()
|
@@ -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')
|
784
|
+
const table = this.$parent.getCurrentParsedomElement('table', true)
|
785
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')
|
820
|
+
const column = this.$parent.getCurrentParsedomElement('td', true)
|
821
821
|
const tbody = this.$parent.getCurrentParsedomElement('tbody', true)
|
822
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', true)
|
827
|
+
this.$parent.deleteByParsedom('table', true, true)
|
828
828
|
return
|
829
829
|
}
|
830
830
|
const previousColumn = this.$parent.editor.getPreviousElement(column)
|
@@ -857,7 +857,7 @@ export default {
|
|
857
857
|
//浮层显示时
|
858
858
|
layerShow() {
|
859
859
|
//获取选区的元素
|
860
|
-
const result = this.$parent.editor.getElementsByRange(true
|
860
|
+
const result = this.$parent.editor.getElementsByRange(true).includes
|
861
861
|
//代码块初始化展示设置
|
862
862
|
if (this.type == 'codeBlock') {
|
863
863
|
const pre = this.$parent.getCurrentParsedomElement('pre', true)
|
package/src/index.js
CHANGED