vue-editify 0.0.47 → 0.0.49

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.
@@ -1,5 +1,5 @@
1
1
  <template>
2
- <div class="editify-menu" :class="{ border: $parent.border, source: $parent.isSourceView }" :data-editify-mode="config.mode" :style="config.style || ''">
2
+ <div class="editify-menu" :class="{ border: menuShowBorder, source: $parent.isSourceView && menuMode == 'inner', fullscreen: $parent.isFullScreen }" :data-editify-mode="menuMode" :style="config.style || ''">
3
3
  <MenuItem v-for="item in menuNames" :name="item" :disabled="menuDisabled(item)"></MenuItem>
4
4
  </div>
5
5
  </template>
@@ -326,6 +326,14 @@ export default {
326
326
  rightBorder: this.config.sourceView.rightBorder,
327
327
  active: false,
328
328
  disabled: false
329
+ },
330
+ //全屏按钮配置
331
+ fullScreenConfig: {
332
+ show: this.config.fullScreen.show,
333
+ leftBorder: this.config.fullScreen.leftBorder,
334
+ rightBorder: this.config.fullScreen.rightBorder,
335
+ active: false,
336
+ disabled: false
329
337
  }
330
338
  }
331
339
  },
@@ -342,11 +350,31 @@ export default {
342
350
  //菜单是否禁用
343
351
  menuDisabled() {
344
352
  return name => {
345
- if (name == 'sourceView') {
353
+ if (name == 'sourceView' || name == 'fullScreen') {
346
354
  return false
347
355
  }
348
356
  return this.$parent.isSourceView
349
357
  }
358
+ },
359
+ //菜单模式
360
+ menuMode() {
361
+ //如果是全屏状态下或者高度自适应情况下
362
+ if (this.$parent.isFullScreen || this.$parent.height === true) {
363
+ //fixed模式改为默认模式
364
+ if (this.config.mode == 'fixed') {
365
+ return 'default'
366
+ }
367
+ }
368
+ return this.config.mode
369
+ },
370
+ //菜单栏是否显示边框
371
+ menuShowBorder() {
372
+ //fixed模式下不显示边框
373
+ if (this.menuMode == 'fixed') {
374
+ return false
375
+ }
376
+ //由编辑器的border属性来决定
377
+ return this.$parent.showBorder
350
378
  }
351
379
  },
352
380
  components: {
@@ -789,7 +817,7 @@ export default {
789
817
  onLayerShow: () => {
790
818
  //存在选区的情况下预置链接文本值
791
819
  let text = ''
792
- const result = this.$parent.$parent.editor.getElementsByRange(true, true)
820
+ const result = this.$parent.$parent.editor.getElementsByRange().flatIncludes
793
821
  result.forEach(item => {
794
822
  if (item.element.isText()) {
795
823
  if (item.offset) {
@@ -969,6 +997,23 @@ export default {
969
997
  () => h(Icon, { value: 'source-view' })
970
998
  )
971
999
  }
1000
+ //全屏按钮
1001
+ if (this.name == 'fullScreen' && this.$parent.fullScreenConfig.show) {
1002
+ return h(
1003
+ Button,
1004
+ {
1005
+ ...props,
1006
+ title: this.$editTrans('fullScreen'),
1007
+ leftBorder: this.$parent.fullScreenConfig.leftBorder,
1008
+ rightBorder: this.$parent.fullScreenConfig.rightBorder,
1009
+ color: this.$parent.color,
1010
+ disabled: this.$parent.fullScreenConfig.disabled || this.disabled || this.$parent.disabled,
1011
+ active: this.$parent.fullScreenConfig.active,
1012
+ onOperate: this.$parent.handleOperate
1013
+ },
1014
+ () => h(Icon, { value: 'full-screen' })
1015
+ )
1016
+ }
972
1017
 
973
1018
  /** 下面是拓展菜单的配置 */
974
1019
  if (Dap.common.isObject(this.$parent.config.extends)) {
@@ -1187,14 +1232,20 @@ export default {
1187
1232
  this.$parent.editor.rangeRender()
1188
1233
  }
1189
1234
  }
1235
+ //全屏
1236
+ else if (name == 'fullScreen') {
1237
+ this.$parent.isFullScreen = !this.$parent.isFullScreen
1238
+ this.fullScreenConfig.active = this.$parent.isFullScreen
1239
+ this.$parent.editor.rangeRender()
1240
+ }
1190
1241
  },
1191
1242
  //处理光标更新
1192
- handleRangeUpdate() {
1243
+ handleRangeUpdate(useCache = false) {
1193
1244
  if (this.disabled) {
1194
1245
  return
1195
1246
  }
1196
1247
  //获取选区的元素
1197
- const result = this.$parent.editor.getElementsByRange(true, false, true)
1248
+ const result = this.$parent.editor.getElementsByRange(useCache).includes
1198
1249
  //选区是否含有代码块元素
1199
1250
  const hasPreStyle = this.$parent.hasPreStyle(true)
1200
1251
  //选区是否含有表格元素
@@ -1203,10 +1254,8 @@ export default {
1203
1254
  const hasQuote = this.$parent.hasQuote(true)
1204
1255
  //选区是否都在引用元素内
1205
1256
  const inQuote = this.$parent.inQuote(true)
1206
-
1207
1257
  //选区是否含有链接元素
1208
1258
  const hasLink = this.$parent.hasLink(true)
1209
-
1210
1259
  //选区是否都在有序列表内
1211
1260
  const inOrderList = this.$parent.inList(true, true)
1212
1261
  //选区是否都在无序列表内
@@ -1400,6 +1449,9 @@ export default {
1400
1449
 
1401
1450
  //代码视图按钮激活
1402
1451
  this.sourceViewConfig.active = this.$parent.isSourceView
1452
+
1453
+ //全屏按钮激活
1454
+ this.fullScreenConfig.active = this.$parent.isFullScreen
1403
1455
  }
1404
1456
  }
1405
1457
  }
@@ -1414,39 +1466,50 @@ export default {
1414
1466
  position: relative;
1415
1467
  z-index: 2;
1416
1468
 
1469
+ //默认菜单模式
1417
1470
  &[data-editify-mode='default'] {
1418
1471
  margin-bottom: 10px;
1419
1472
  padding: 6px 10px;
1420
1473
 
1474
+ //默认菜单模式显示边框,同时显示圆角
1421
1475
  &.border {
1422
1476
  border: 1px solid @border-color;
1423
1477
  border-radius: 4px;
1424
1478
  }
1479
+
1480
+ //全屏模式下,默认菜单的边框失效,此时加一个下边框
1481
+ &.fullscreen {
1482
+ border-bottom: 1px solid @border-color;
1483
+ }
1425
1484
  }
1426
1485
 
1486
+ //inner菜单模式
1427
1487
  &[data-editify-mode='inner'] {
1428
1488
  padding: 10px;
1429
1489
  margin-bottom: -20px;
1430
1490
 
1491
+ //inner菜单模式显示边框,同时显示圆角
1431
1492
  &.border {
1432
1493
  border: 1px solid @border-color;
1433
1494
  border-bottom: none;
1434
1495
  border-radius: 4px 4px 0 0;
1435
1496
  transition: all 500ms;
1497
+ }
1436
1498
 
1437
- &:not(.source)::before {
1438
- position: absolute;
1439
- content: '';
1440
- width: calc(100% - 20px);
1441
- height: 1px;
1442
- background-color: @border-color;
1443
- left: 50%;
1444
- transform: translateX(-50%);
1445
- bottom: 0;
1446
- }
1499
+ //inner菜单模式加一个下边框,此边框在代码视图下不显示
1500
+ &:not(.source)::before {
1501
+ position: absolute;
1502
+ content: '';
1503
+ width: calc(100% - 20px);
1504
+ height: 1px;
1505
+ background-color: @border-color;
1506
+ left: 50%;
1507
+ transform: translateX(-50%);
1508
+ bottom: 0;
1447
1509
  }
1448
1510
  }
1449
1511
 
1512
+ //fixed菜单模式
1450
1513
  &[data-editify-mode='fixed'] {
1451
1514
  padding: 6px 10px;
1452
1515
  position: fixed;
@@ -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, false, 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/core/index.js CHANGED
@@ -74,7 +74,7 @@ export const editorProps = {
74
74
  },
75
75
  //编辑内容高度
76
76
  height: {
77
- type: String,
77
+ type: [String, Boolean],
78
78
  default: '600px'
79
79
  },
80
80
  //是否自适应高度
@@ -934,7 +934,8 @@ export const getMenuConfig = function (editTrans, editLocale) {
934
934
  video: 24,
935
935
  table: 25,
936
936
  codeBlock: 26,
937
- sourceView: 27
937
+ sourceView: 27,
938
+ fullScreen: 28
938
939
  },
939
940
  //撤销按钮配置
940
941
  undo: {
@@ -1264,6 +1265,15 @@ export const getMenuConfig = function (editTrans, editLocale) {
1264
1265
  //右侧边框是否显示
1265
1266
  rightBorder: false
1266
1267
  },
1268
+ //全屏
1269
+ fullScreen: {
1270
+ //是否显示此工具
1271
+ show: true,
1272
+ //左侧边框是否显示
1273
+ leftBorder: false,
1274
+ //右侧边框是否显示
1275
+ rightBorder: false
1276
+ },
1267
1277
  //拓展菜单,每个key表示拓展菜单的唯一名称,value是对象,包含type/title/rightBorder/leftBorder/disabled/active/width/maxHeight/options/value/hideScroll/onLayerShow/onLayerShown/onLayerHidden/onOperate/default/layer/option属性
1268
1278
  extends: {}
1269
1279
  }
@@ -1,3 +1,7 @@
1
+ .editify-icon-full-screen:before {
2
+ content: '\e62f';
3
+ }
4
+
1
5
  .editify-icon-auto-width:before {
2
6
  content: '\e61d';
3
7
  }
Binary file
Binary file
package/src/index.js CHANGED
@@ -7,7 +7,7 @@ import './icon/iconfont.css'
7
7
  //引入国际化
8
8
  import i18n from './locale'
9
9
  //版本号
10
- const version = '0.0.47'
10
+ const version = '0.0.49'
11
11
  //安装函数
12
12
  const install = (app, props) => {
13
13
  const locale = (props ? props.locale : 'zh_CN') || 'zh_CN'
@@ -81,5 +81,6 @@ export default {
81
81
  alignRight: 'Align right',
82
82
  alignJustify: 'Align justify',
83
83
  defaultLineHeight: 'Default',
84
- auto: 'auto'
84
+ auto: 'auto',
85
+ fullScreen: 'Full screen'
85
86
  }
@@ -81,5 +81,6 @@ export default {
81
81
  alignRight: '右对齐',
82
82
  alignJustify: '两端对齐',
83
83
  defaultLineHeight: '默认行高',
84
- auto: '自适应'
84
+ auto: '自适应',
85
+ fullScreen: '全屏'
85
86
  }