vue-editify 0.2.11 → 0.2.13

Sign up to get free protection for your applications and to get access to all the features.
package/lib/index.d.ts CHANGED
@@ -150,8 +150,8 @@ declare const Editify: import('./core/tool').SFCWithInstall<import('vue').Define
150
150
  key: number;
151
151
  type: import('alex-editor').AlexElementType;
152
152
  parsedom: string | null;
153
- marks: import('alex-editor').ObjectType | null;
154
- styles: import('alex-editor').ObjectType | null;
153
+ marks: import('alex-editor/lib/core/tool').ObjectType | null;
154
+ styles: import('alex-editor/lib/core/tool').ObjectType | null;
155
155
  textContent: string | null;
156
156
  children: any[] | null;
157
157
  parent: any | null;
@@ -170,7 +170,7 @@ declare const Editify: import('./core/tool').SFCWithInstall<import('vue').Define
170
170
  getUneditableElement: () => import('alex-editor').AlexElement | null;
171
171
  isEqual: (element: import('alex-editor').AlexElement) => boolean;
172
172
  isContains: (element: import('alex-editor').AlexElement) => boolean;
173
- isOnlyHasBreak: () => boolean | 0;
173
+ isOnlyHasBreak: () => boolean;
174
174
  isPreStyle: () => boolean;
175
175
  hasMarks: () => boolean;
176
176
  hasStyles: () => boolean;
@@ -195,8 +195,8 @@ declare const Editify: import('./core/tool').SFCWithInstall<import('vue').Define
195
195
  key: number;
196
196
  type: import('alex-editor').AlexElementType;
197
197
  parsedom: string | null;
198
- marks: import('alex-editor').ObjectType | null;
199
- styles: import('alex-editor').ObjectType | null;
198
+ marks: import('alex-editor/lib/core/tool').ObjectType | null;
199
+ styles: import('alex-editor/lib/core/tool').ObjectType | null;
200
200
  textContent: string | null;
201
201
  children: any[] | null;
202
202
  parent: any | null;
@@ -215,7 +215,7 @@ declare const Editify: import('./core/tool').SFCWithInstall<import('vue').Define
215
215
  getUneditableElement: () => import('alex-editor').AlexElement | null;
216
216
  isEqual: (element: import('alex-editor').AlexElement) => boolean;
217
217
  isContains: (element: import('alex-editor').AlexElement) => boolean;
218
- isOnlyHasBreak: () => boolean | 0;
218
+ isOnlyHasBreak: () => boolean;
219
219
  isPreStyle: () => boolean;
220
220
  hasMarks: () => boolean;
221
221
  hasStyles: () => boolean;
@@ -244,8 +244,8 @@ declare const Editify: import('./core/tool').SFCWithInstall<import('vue').Define
244
244
  key: number;
245
245
  type: import('alex-editor').AlexElementType;
246
246
  parsedom: string | null;
247
- marks: import('alex-editor').ObjectType | null;
248
- styles: import('alex-editor').ObjectType | null;
247
+ marks: import('alex-editor/lib/core/tool').ObjectType | null;
248
+ styles: import('alex-editor/lib/core/tool').ObjectType | null;
249
249
  textContent: string | null;
250
250
  children: any[] | null;
251
251
  parent: any | null;
@@ -264,7 +264,7 @@ declare const Editify: import('./core/tool').SFCWithInstall<import('vue').Define
264
264
  getUneditableElement: () => import('alex-editor').AlexElement | null;
265
265
  isEqual: (element: import('alex-editor').AlexElement) => boolean;
266
266
  isContains: (element: import('alex-editor').AlexElement) => boolean;
267
- isOnlyHasBreak: () => boolean | 0;
267
+ isOnlyHasBreak: () => boolean;
268
268
  isPreStyle: () => boolean;
269
269
  hasMarks: () => boolean;
270
270
  hasStyles: () => boolean;
@@ -300,8 +300,8 @@ declare const Editify: import('./core/tool').SFCWithInstall<import('vue').Define
300
300
  key: number;
301
301
  type: import('alex-editor').AlexElementType;
302
302
  parsedom: string | null;
303
- marks: import('alex-editor').ObjectType | null;
304
- styles: import('alex-editor').ObjectType | null;
303
+ marks: import('alex-editor/lib/core/tool').ObjectType | null;
304
+ styles: import('alex-editor/lib/core/tool').ObjectType | null;
305
305
  textContent: string | null;
306
306
  children: any[] | null;
307
307
  parent: any | null;
@@ -320,7 +320,7 @@ declare const Editify: import('./core/tool').SFCWithInstall<import('vue').Define
320
320
  getUneditableElement: () => import('alex-editor').AlexElement | null;
321
321
  isEqual: (element: import('alex-editor').AlexElement) => boolean;
322
322
  isContains: (element: import('alex-editor').AlexElement) => boolean;
323
- isOnlyHasBreak: () => boolean | 0;
323
+ isOnlyHasBreak: () => boolean;
324
324
  isPreStyle: () => boolean;
325
325
  hasMarks: () => boolean;
326
326
  hasStyles: () => boolean;
@@ -345,8 +345,8 @@ declare const Editify: import('./core/tool').SFCWithInstall<import('vue').Define
345
345
  key: number;
346
346
  type: import('alex-editor').AlexElementType;
347
347
  parsedom: string | null;
348
- marks: import('alex-editor').ObjectType | null;
349
- styles: import('alex-editor').ObjectType | null;
348
+ marks: import('alex-editor/lib/core/tool').ObjectType | null;
349
+ styles: import('alex-editor/lib/core/tool').ObjectType | null;
350
350
  textContent: string | null;
351
351
  children: any[] | null;
352
352
  parent: any | null;
@@ -365,7 +365,7 @@ declare const Editify: import('./core/tool').SFCWithInstall<import('vue').Define
365
365
  getUneditableElement: () => import('alex-editor').AlexElement | null;
366
366
  isEqual: (element: import('alex-editor').AlexElement) => boolean;
367
367
  isContains: (element: import('alex-editor').AlexElement) => boolean;
368
- isOnlyHasBreak: () => boolean | 0;
368
+ isOnlyHasBreak: () => boolean;
369
369
  isPreStyle: () => boolean;
370
370
  hasMarks: () => boolean;
371
371
  hasStyles: () => boolean;
@@ -394,8 +394,8 @@ declare const Editify: import('./core/tool').SFCWithInstall<import('vue').Define
394
394
  key: number;
395
395
  type: import('alex-editor').AlexElementType;
396
396
  parsedom: string | null;
397
- marks: import('alex-editor').ObjectType | null;
398
- styles: import('alex-editor').ObjectType | null;
397
+ marks: import('alex-editor/lib/core/tool').ObjectType | null;
398
+ styles: import('alex-editor/lib/core/tool').ObjectType | null;
399
399
  textContent: string | null;
400
400
  children: any[] | null;
401
401
  parent: any | null;
@@ -414,7 +414,7 @@ declare const Editify: import('./core/tool').SFCWithInstall<import('vue').Define
414
414
  getUneditableElement: () => import('alex-editor').AlexElement | null;
415
415
  isEqual: (element: import('alex-editor').AlexElement) => boolean;
416
416
  isContains: (element: import('alex-editor').AlexElement) => boolean;
417
- isOnlyHasBreak: () => boolean | 0;
417
+ isOnlyHasBreak: () => boolean;
418
418
  isPreStyle: () => boolean;
419
419
  hasMarks: () => boolean;
420
420
  hasStyles: () => boolean;
@@ -440,50 +440,8 @@ declare const Editify: import('./core/tool').SFCWithInstall<import('vue').Define
440
440
  };
441
441
  } | null;
442
442
  __guid: number;
443
- __events: import('alex-editor').ObjectType;
444
- __oldStack: {
445
- key: number;
446
- type: import('alex-editor').AlexElementType;
447
- parsedom: string | null;
448
- marks: import('alex-editor').ObjectType | null;
449
- styles: import('alex-editor').ObjectType | null;
450
- textContent: string | null;
451
- children: any[] | null;
452
- parent: any | null;
453
- behavior: "default" | "block";
454
- namespace: string | null;
455
- locked: boolean;
456
- elm: HTMLElement | null;
457
- isBlock: () => boolean;
458
- isInblock: () => boolean;
459
- isInline: () => boolean;
460
- isClosed: () => boolean;
461
- isText: () => boolean;
462
- isBreak: () => boolean;
463
- isEmpty: () => boolean;
464
- isSpaceText: () => boolean;
465
- getUneditableElement: () => import('alex-editor').AlexElement | null;
466
- isEqual: (element: import('alex-editor').AlexElement) => boolean;
467
- isContains: (element: import('alex-editor').AlexElement) => boolean;
468
- isOnlyHasBreak: () => boolean | 0;
469
- isPreStyle: () => boolean;
470
- hasMarks: () => boolean;
471
- hasStyles: () => boolean;
472
- hasChildren: () => boolean;
473
- hasContains: (element: import('alex-editor').AlexElement) => boolean;
474
- clone: (deep?: boolean | undefined) => import('alex-editor').AlexElement;
475
- convertToBlock: () => void;
476
- toEmpty: () => void;
477
- getBlock: () => import('alex-editor').AlexElement;
478
- getInblock: () => import('alex-editor').AlexElement | null;
479
- getInline: () => import('alex-editor').AlexElement | null;
480
- isEqualStyles: (element: import('alex-editor').AlexElement) => boolean;
481
- isEqualMarks: (element: import('alex-editor').AlexElement) => boolean;
482
- isFirst: (element: import('alex-editor').AlexElement) => boolean;
483
- isLast: (element: import('alex-editor').AlexElement) => boolean;
484
- __render: () => void;
485
- __fullClone: () => import('alex-editor').AlexElement;
486
- }[];
443
+ __events: import('alex-editor/lib/core/tool').ObjectType;
444
+ __firstRender: boolean;
487
445
  __isInputChinese: boolean;
488
446
  __innerSelectionChange: boolean;
489
447
  __chineseInputTimer: any;
@@ -524,8 +482,8 @@ declare const Editify: import('./core/tool').SFCWithInstall<import('vue').Define
524
482
  key: number;
525
483
  type: import('alex-editor').AlexElementType;
526
484
  parsedom: string | null;
527
- marks: import('alex-editor').ObjectType | null;
528
- styles: import('alex-editor').ObjectType | null;
485
+ marks: import('alex-editor/lib/core/tool').ObjectType | null;
486
+ styles: import('alex-editor/lib/core/tool').ObjectType | null;
529
487
  textContent: string | null;
530
488
  children: any[] | null;
531
489
  parent: any | null;
@@ -544,7 +502,7 @@ declare const Editify: import('./core/tool').SFCWithInstall<import('vue').Define
544
502
  getUneditableElement: () => import('alex-editor').AlexElement | null;
545
503
  isEqual: (element: import('alex-editor').AlexElement) => boolean;
546
504
  isContains: (element: import('alex-editor').AlexElement) => boolean;
547
- isOnlyHasBreak: () => boolean | 0;
505
+ isOnlyHasBreak: () => boolean;
548
506
  isPreStyle: () => boolean;
549
507
  hasMarks: () => boolean;
550
508
  hasStyles: () => boolean;
@@ -570,8 +528,8 @@ declare const Editify: import('./core/tool').SFCWithInstall<import('vue').Define
570
528
  key: number;
571
529
  type: import('alex-editor').AlexElementType;
572
530
  parsedom: string | null;
573
- marks: import('alex-editor').ObjectType | null;
574
- styles: import('alex-editor').ObjectType | null;
531
+ marks: import('alex-editor/lib/core/tool').ObjectType | null;
532
+ styles: import('alex-editor/lib/core/tool').ObjectType | null;
575
533
  textContent: string | null;
576
534
  children: any[] | null;
577
535
  parent: any | null;
@@ -590,7 +548,7 @@ declare const Editify: import('./core/tool').SFCWithInstall<import('vue').Define
590
548
  getUneditableElement: () => import('alex-editor').AlexElement | null;
591
549
  isEqual: (element: import('alex-editor').AlexElement) => boolean;
592
550
  isContains: (element: import('alex-editor').AlexElement) => boolean;
593
- isOnlyHasBreak: () => boolean | 0;
551
+ isOnlyHasBreak: () => boolean;
594
552
  isPreStyle: () => boolean;
595
553
  hasMarks: () => boolean;
596
554
  hasStyles: () => boolean;
@@ -800,11 +758,11 @@ declare const Editify: import('./core/tool').SFCWithInstall<import('vue').Define
800
758
  export type { ButtonTypeType, ButtonOptionsItemType, ButtonSelectConfigType, ButtonDisplayConfigType } from './components/button/props';
801
759
  export type { InsertImageUploadErrorType } from './components/insertImage/props';
802
760
  export type { InsertVideoUploadErrorType } from './components/insertVideo/props';
803
- export type { MenuButtonType, MenuSelectButtonType, MenuDisplayButtonType, MenuImageButtonType, MenuVideoButtonType, MenuTableButtonType, MenuCustomButtonType, CodeBlockToolbarType, TextToolbarType, ToolbarConfigType, MenuSequenceType, MenuModeType, MenuExtendType, MenuConfigType, PluginType, PluginResultType } from './core/tool';
761
+ export type { MenuButtonType, MenuSelectButtonType, MenuDisplayButtonType, MenuImageButtonType, MenuVideoButtonType, MenuTableButtonType, MenuCustomButtonType, CodeBlockToolbarType, TextToolbarType, ToolbarConfigType, MenuSequenceType, MenuModeType, MenuExtendType, MenuConfigType, PluginMenuConfigType, PluginType, PluginResultType } from './core/tool';
804
762
  export type { ElementMatchConfigType } from './core/function';
805
763
  export { elementIsMatch, getMatchElementByElement, getMatchElementByRange, isList, isTask, elementIsInList, elementIsInTask, hasPreInRange, hasQuoteInRange, hasListInRange, hasTaskInRange, hasLinkInRange, hasTableInRange, hasImageInRange, hasVideoInRange, isRangeInQuote, isRangeInList, isRangeInTask, queryTextStyle, queryTextMark, getRangeText, setIndentIncrease, setIndentDecrease, setQuote, setAlign, setList, setTask, setTextStyle, setTextMark, removeTextStyle, removeTextMark, setLineHeight, insertLink, insertImage, insertVideo, insertTable, insertCodeBlock, insertSeparator } from './core/function';
806
764
  declare const install: (app: App) => void;
807
- declare const version = "0.2.11";
765
+ declare const version = "0.2.13";
808
766
  export { AlexElement } from 'alex-editor';
809
767
  export type { AttachmentOptionsType } from './plugins/attachment';
810
768
  export type { InsertAttachmentUploadErrorType } from './plugins/attachment/insertAttachment/props';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vue-editify",
3
- "version": "0.2.11",
3
+ "version": "0.2.13",
4
4
  "private": false,
5
5
  "sideEffects": [
6
6
  "*.css"
@@ -11,7 +11,7 @@
11
11
  </Teleport>
12
12
  </template>
13
13
  <script setup lang="ts">
14
- import { computed, getCurrentInstance, nextTick, onMounted, ref } from 'vue'
14
+ import { computed, getCurrentInstance, nextTick, onBeforeUnmount, onMounted, ref } from 'vue'
15
15
  import { element as DapElement, event as DapEvent } from 'dap-util'
16
16
  import Triangle from '@/components/triangle/triangle.vue'
17
17
  import { TrianglePlacementType } from '@/components/triangle/props'
@@ -577,12 +577,19 @@ const handleClick = (e: Event) => {
577
577
  if (!DapElement.isElement(elRef.value)) {
578
578
  return
579
579
  }
580
+ //如果在浮层内点击,不用关闭
580
581
  if (DapElement.isContains(elRef.value!, e.target as HTMLElement)) {
581
582
  return
582
583
  }
584
+ //如果在浮层关联的元素内点击,不用关闭
583
585
  if (!props.useRange && getNode()! && DapElement.isContains(getNode()!, e.target as HTMLElement)) {
584
586
  return
585
587
  }
588
+ //如果在insideElement规定的元素内,不用关闭
589
+ if (props.insideElements.some(el => DapElement.isContains(el, e.target as HTMLElement))) {
590
+ return
591
+ }
592
+
586
593
  if (props.modelValue) {
587
594
  emits('update:modelValue', false)
588
595
  }
@@ -596,8 +603,13 @@ onMounted(() => {
596
603
  DapEvent.on(window, `resize.editify_layer_${instance.uid}`, handleResize)
597
604
  })
598
605
 
606
+ onBeforeUnmount(() => {
607
+ DapEvent.off(window, `mousedown.editify_layer_${instance.uid} resize.editify_layer_${instance.uid}`)
608
+ })
609
+
599
610
  defineExpose({
600
- setPosition
611
+ setPosition,
612
+ elRef
601
613
  })
602
614
  </script>
603
615
  <style scoped src="./layer.less"></style>
@@ -70,6 +70,13 @@ export const LayerProps = {
70
70
  useRange: {
71
71
  type: Boolean,
72
72
  default: false
73
+ },
74
+ //点击无需关闭layer的元素数组
75
+ insideElements: {
76
+ type: Array as PropType<HTMLElement[]>,
77
+ default: function () {
78
+ return []
79
+ }
73
80
  }
74
81
  }
75
82
 
@@ -1,5 +1,5 @@
1
1
  <template>
2
- <Layer v-model="show" ref="layerRef" :node="node" :scroll-node="scrollNode" border placement="bottom-start" @show="layerShow" :useRange="type == 'text'" :z-index="zIndex">
2
+ <Layer v-model="show" ref="layerRef" :node="node" :scroll-node="scrollNode" border placement="bottom-start" @show="layerShow" :useRange="type == 'text'" :z-index="zIndex" :inside-elements="insideElements">
3
3
  <div class="editify-toolbar" ref="toolbarRef" :style="config.style">
4
4
  <!-- 链接工具条 -->
5
5
  <template v-if="type == 'link'">
@@ -131,14 +131,14 @@
131
131
  <Icon value="text-wrap"></Icon>
132
132
  </Button>
133
133
  <!-- 代码块语言选择 -->
134
- <Button v-if="languageConfig.show" name="languages" type="display" :title="$editTrans('selectLanguages')" :tooltip="config.tooltip" :leftBorder="languageConfig.leftBorder" :rightBorder="languageConfig.rightBorder" :display-config="languageConfig.displayConfig" :color="color" :active="languageConfig.active" :disabled="languageConfig.disabled" @operate="selectLanguage" :z-index="zIndex + 1"></Button>
134
+ <Button v-if="languageConfig.show" ref="languagesBtnRef" name="languages" type="display" :title="$editTrans('selectLanguages')" :tooltip="config.tooltip" :leftBorder="languageConfig.leftBorder" :rightBorder="languageConfig.rightBorder" :display-config="languageConfig.displayConfig" :color="color" :active="languageConfig.active" :disabled="languageConfig.disabled" @operate="selectLanguage" :z-index="zIndex + 1"></Button>
135
135
  </template>
136
136
  <!-- 文本工具条 -->
137
137
  <template v-else-if="type == 'text'">
138
138
  <!-- 设置段落和标题 -->
139
- <Button v-if="headingConfig.show" name="heading" type="display" :title="$editTrans('heading')" :tooltip="config.tooltip" :display-config="headingConfig.displayConfig" :leftBorder="headingConfig.leftBorder" :rightBorder="headingConfig.rightBorder" :color="color" :active="headingConfig.active" :disabled="headingConfig.disabled" @operate="_setHeading" :z-index="zIndex + 1"></Button>
139
+ <Button v-if="headingConfig.show" ref="headingBtnRef" name="heading" type="display" :title="$editTrans('heading')" :tooltip="config.tooltip" :display-config="headingConfig.displayConfig" :leftBorder="headingConfig.leftBorder" :rightBorder="headingConfig.rightBorder" :color="color" :active="headingConfig.active" :disabled="headingConfig.disabled" @operate="_setHeading" :z-index="zIndex + 1"></Button>
140
140
  <!-- 对齐方式 -->
141
- <Button v-if="alignConfig.show" name="align" type="select" :title="$editTrans('align')" :tooltip="config.tooltip" :select-config="alignConfig.selectConfig" :leftBorder="alignConfig.leftBorder" :rightBorder="alignConfig.rightBorder" :color="color" :active="alignConfig.active" :disabled="alignConfig.disabled" @operate="_setAlign" :z-index="zIndex + 1">
141
+ <Button v-if="alignConfig.show" name="align" ref="alignBtnRef" type="select" :title="$editTrans('align')" :tooltip="config.tooltip" :select-config="alignConfig.selectConfig" :leftBorder="alignConfig.leftBorder" :rightBorder="alignConfig.rightBorder" :color="color" :active="alignConfig.active" :disabled="alignConfig.disabled" @operate="_setAlign" :z-index="zIndex + 1">
142
142
  <Icon value="align-left"></Icon>
143
143
  </Button>
144
144
  <!-- 有序列表 -->
@@ -182,20 +182,20 @@
182
182
  <Icon value="subscript"></Icon>
183
183
  </Button>
184
184
  <!-- 字号大小 -->
185
- <Button v-if="fontSizeConfig.show" name="fontSize" type="display" :title="$editTrans('fontSize')" :tooltip="config.tooltip" :display-config="fontSizeConfig.displayConfig" :leftBorder="fontSizeConfig.leftBorder" :rightBorder="fontSizeConfig.rightBorder" :color="color" :active="fontSizeConfig.active" :disabled="fontSizeConfig.disabled" @operate="setFontSize" :z-index="zIndex + 1"></Button>
185
+ <Button v-if="fontSizeConfig.show" ref="fontSizeBtnRef" name="fontSize" type="display" :title="$editTrans('fontSize')" :tooltip="config.tooltip" :display-config="fontSizeConfig.displayConfig" :leftBorder="fontSizeConfig.leftBorder" :rightBorder="fontSizeConfig.rightBorder" :color="color" :active="fontSizeConfig.active" :disabled="fontSizeConfig.disabled" @operate="setFontSize" :z-index="zIndex + 1"></Button>
186
186
  <!-- 字体 -->
187
- <Button v-if="fontFamilyConfig.show" name="fontFamily" type="display" :title="$editTrans('fontFamily')" :tooltip="config.tooltip" :display-config="fontFamilyConfig.displayConfig" :leftBorder="fontFamilyConfig.leftBorder" :rightBorder="fontFamilyConfig.rightBorder" :color="color" :active="fontFamilyConfig.active" :disabled="fontFamilyConfig.disabled" @operate="setFontFamily" :z-index="zIndex + 1"></Button>
187
+ <Button v-if="fontFamilyConfig.show" ref="fontFamilyBtnRef" name="fontFamily" type="display" :title="$editTrans('fontFamily')" :tooltip="config.tooltip" :display-config="fontFamilyConfig.displayConfig" :leftBorder="fontFamilyConfig.leftBorder" :rightBorder="fontFamilyConfig.rightBorder" :color="color" :active="fontFamilyConfig.active" :disabled="fontFamilyConfig.disabled" @operate="setFontFamily" :z-index="zIndex + 1"></Button>
188
188
  <!-- 行高 -->
189
- <Button v-if="lineHeightConfig.show" name="lineHeight" type="display" :title="$editTrans('lineHeight')" :tooltip="config.tooltip" :display-config="lineHeightConfig.displayConfig" :leftBorder="lineHeightConfig.leftBorder" :rightBorder="lineHeightConfig.rightBorder" :color="color" :active="lineHeightConfig.active" :disabled="lineHeightConfig.disabled" @operate="_setLineHeight" :z-index="zIndex + 1"></Button>
189
+ <Button v-if="lineHeightConfig.show" ref="lineHeightBtnRef" name="lineHeight" type="display" :title="$editTrans('lineHeight')" :tooltip="config.tooltip" :display-config="lineHeightConfig.displayConfig" :leftBorder="lineHeightConfig.leftBorder" :rightBorder="lineHeightConfig.rightBorder" :color="color" :active="lineHeightConfig.active" :disabled="lineHeightConfig.disabled" @operate="_setLineHeight" :z-index="zIndex + 1"></Button>
190
190
  <!-- 前景色 -->
191
- <Button v-if="foreColorConfig.show" name="foreColor" type="select" :title="$editTrans('foreColor')" :tooltip="config.tooltip" :select-config="foreColorConfig.selectConfig" :leftBorder="foreColorConfig.leftBorder" :rightBorder="foreColorConfig.rightBorder" :color="color" :active="foreColorConfig.active" :disabled="foreColorConfig.disabled" hideScroll ref="foreColorRef" :z-index="zIndex + 1">
191
+ <Button v-if="foreColorConfig.show" name="foreColor" type="select" :title="$editTrans('foreColor')" :tooltip="config.tooltip" :select-config="foreColorConfig.selectConfig" :leftBorder="foreColorConfig.leftBorder" :rightBorder="foreColorConfig.rightBorder" :color="color" :active="foreColorConfig.active" :disabled="foreColorConfig.disabled" hideScroll ref="foreColorBtnRef" :z-index="zIndex + 1">
192
192
  <Icon value="font-color"></Icon>
193
193
  <template #layer="{ options }">
194
194
  <Colors :tooltip="config.tooltip" :color="color" :value="foreColorConfig.value" @change="setForeColor" :data="options"></Colors>
195
195
  </template>
196
196
  </Button>
197
197
  <!-- 背景色 -->
198
- <Button v-if="backColorConfig.show" name="backColor" type="select" :title="$editTrans('backColor')" :tooltip="config.tooltip" :select-config="backColorConfig.selectConfig" :leftBorder="backColorConfig.leftBorder" :rightBorder="backColorConfig.rightBorder" :color="color" :active="backColorConfig.active" :disabled="backColorConfig.disabled" hideScroll ref="backColorRef" :z-index="zIndex + 1">
198
+ <Button v-if="backColorConfig.show" name="backColor" type="select" :title="$editTrans('backColor')" :tooltip="config.tooltip" :select-config="backColorConfig.selectConfig" :leftBorder="backColorConfig.leftBorder" :rightBorder="backColorConfig.rightBorder" :color="color" :active="backColorConfig.active" :disabled="backColorConfig.disabled" hideScroll ref="backColorBtnRef" :z-index="zIndex + 1">
199
199
  <Icon value="brush"></Icon>
200
200
  <template #layer="{ options }">
201
201
  <Colors :tooltip="config.tooltip" :color="color" :value="backColorConfig.value" @change="setBackColor" :data="options"></Colors>
@@ -235,8 +235,14 @@ const $editTrans = inject<(key: string) => any>('$editTrans')!
235
235
 
236
236
  const layerRef = ref<InstanceType<typeof Layer> | null>(null)
237
237
  const toolbarRef = ref<HTMLElement | null>(null)
238
- const foreColorRef = ref<InstanceType<typeof Button> | null>(null)
239
- const backColorRef = ref<InstanceType<typeof Button> | null>(null)
238
+ const foreColorBtnRef = ref<InstanceType<typeof Button> | null>(null)
239
+ const backColorBtnRef = ref<InstanceType<typeof Button> | null>(null)
240
+ const languagesBtnRef = ref<InstanceType<typeof Button> | null>(null)
241
+ const headingBtnRef = ref<InstanceType<typeof Button> | null>(null)
242
+ const alignBtnRef = ref<InstanceType<typeof Button> | null>(null)
243
+ const fontSizeBtnRef = ref<InstanceType<typeof Button> | null>(null)
244
+ const fontFamilyBtnRef = ref<InstanceType<typeof Button> | null>(null)
245
+ const lineHeightBtnRef = ref<InstanceType<typeof Button> | null>(null)
240
246
 
241
247
  //链接参数配置
242
248
  const linkConfig = ref<ObjectType>({
@@ -622,6 +628,43 @@ const canMergeCells = computed<(type: 'left' | 'right' | 'up' | 'down') => boole
622
628
  return false
623
629
  }
624
630
  })
631
+ //点击不关闭工具条浮层的元素(算在工具条浮层元素范围内)
632
+ const insideElements = computed<HTMLElement[]>(() => {
633
+ let elements: HTMLElement[] = []
634
+ //语言选择浮层元素
635
+ if (languagesBtnRef.value && languagesBtnRef.value.layerRef && languagesBtnRef.value.layerRef.elRef) {
636
+ elements.push(languagesBtnRef.value.layerRef.elRef)
637
+ }
638
+ //前景色选择浮层元素
639
+ if (foreColorBtnRef.value && foreColorBtnRef.value.layerRef && foreColorBtnRef.value.layerRef.elRef) {
640
+ elements.push(foreColorBtnRef.value.layerRef.elRef)
641
+ }
642
+ //背景色选择浮层元素
643
+ if (backColorBtnRef.value && backColorBtnRef.value.layerRef && backColorBtnRef.value.layerRef.elRef) {
644
+ elements.push(backColorBtnRef.value.layerRef.elRef)
645
+ }
646
+ //标题选择浮层元素
647
+ if (headingBtnRef.value && headingBtnRef.value.layerRef && headingBtnRef.value.layerRef.elRef) {
648
+ elements.push(headingBtnRef.value.layerRef.elRef)
649
+ }
650
+ //对齐方式选择浮层元素
651
+ if (alignBtnRef.value && alignBtnRef.value.layerRef && alignBtnRef.value.layerRef.elRef) {
652
+ elements.push(alignBtnRef.value.layerRef.elRef)
653
+ }
654
+ //字号选择浮层元素
655
+ if (fontSizeBtnRef.value && fontSizeBtnRef.value.layerRef && fontSizeBtnRef.value.layerRef.elRef) {
656
+ elements.push(fontSizeBtnRef.value.layerRef.elRef)
657
+ }
658
+ //字体选择浮层元素
659
+ if (fontFamilyBtnRef.value && fontFamilyBtnRef.value.layerRef && fontFamilyBtnRef.value.layerRef.elRef) {
660
+ elements.push(fontFamilyBtnRef.value.layerRef.elRef)
661
+ }
662
+ //行高选择浮层元素
663
+ if (lineHeightBtnRef.value && lineHeightBtnRef.value.layerRef && lineHeightBtnRef.value.layerRef.elRef) {
664
+ elements.push(lineHeightBtnRef.value.layerRef.elRef)
665
+ }
666
+ return elements
667
+ })
625
668
 
626
669
  //输入框获取焦点
627
670
  const handleInputFocus = (e: Event) => {
@@ -646,7 +689,7 @@ const setBackColor = (value: string) => {
646
689
  setTextStyle(editor.value, dataRangeCaches.value, {
647
690
  'background-color': value
648
691
  })
649
- backColorRef.value!.show = false
692
+ backColorBtnRef.value!.show = false
650
693
  editor.value.formatElementStack()
651
694
  editor.value.domRender()
652
695
  editor.value.rangeRender()
@@ -656,7 +699,7 @@ const setForeColor = (value: string) => {
656
699
  setTextStyle(editor.value, dataRangeCaches.value, {
657
700
  color: value
658
701
  })
659
- foreColorRef.value!.show = false
702
+ foreColorBtnRef.value!.show = false
660
703
  editor.value.formatElementStack()
661
704
  editor.value.domRender()
662
705
  editor.value.rangeRender()
@@ -1626,5 +1669,9 @@ const layerShow = () => {
1626
1669
  formatClearConfig.value.disabled = extraDisabled('formatClear')
1627
1670
  }
1628
1671
  }
1672
+
1673
+ defineExpose({
1674
+ layerRef
1675
+ })
1629
1676
  </script>
1630
1677
  <style scoped src="./toolbar.less"></style>
@@ -1,5 +1,5 @@
1
1
  <template>
2
- <div class="editify" :class="{ 'editify-fullscreen': isFullScreen, 'editify-autoheight': !isFullScreen && autoheight }" :style="{ zIndex: zIndex, paddingTop: (offset || '') + 'px' }" ref="elRef">
2
+ <div class="editify" :class="{ 'editify-fullscreen': isFullScreen, 'editify-autoheight': !isFullScreen && autoheight }" :style="{ zIndex: zIndex, paddingTop: isFullScreen ? '' : (offset || '') + 'px' }" ref="elRef">
3
3
  <!-- 菜单区域 -->
4
4
  <Menu ref="menuRef" v-if="menuConfig.use" :config="menuConfig" :color="color" :z-index="zIndex + 1"></Menu>
5
5
  <!-- 编辑层,与编辑区域宽高相同必须适配 -->
@@ -27,7 +27,6 @@ import { parseList, orderdListHandle, commonElementHandle, tableThTdHandle, tabl
27
27
  import { isTask, elementToParagraph, getMatchElementByRange, hasTableInRange, hasLinkInRange, hasPreInRange, hasImageInRange, hasVideoInRange } from '@/core/function'
28
28
  import Toolbar from '@/components/toolbar/toolbar.vue'
29
29
  import Menu from '@/components/menu/menu.vue'
30
- import Layer from '@/components/layer/layer.vue'
31
30
  import { trans } from '@/locale'
32
31
  import { LanguagesItemType } from '@/hljs'
33
32
  import { EditifyProps, EditifyResizeParamsType, EditifyToolbarOptionsType } from './props'
@@ -194,7 +193,7 @@ const handleToolbar = () => {
194
193
  toolbarOptions.value.type = 'link'
195
194
  toolbarOptions.value.node = `[data-editify-uid="${instance.uid}"] [data-editify-element="${link.key}"]`
196
195
  if (toolbarOptions.value.show) {
197
- ;(<InstanceType<typeof Layer>>toolbarRef.value!.$refs.layerRef).setPosition()
196
+ toolbarRef.value!.layerRef!.setPosition()
198
197
  } else {
199
198
  toolbarOptions.value.show = true
200
199
  }
@@ -204,7 +203,7 @@ const handleToolbar = () => {
204
203
  toolbarOptions.value.type = 'image'
205
204
  toolbarOptions.value.node = `[data-editify-uid="${instance.uid}"] [data-editify-element="${image.key}"]`
206
205
  if (toolbarOptions.value.show) {
207
- ;(<InstanceType<typeof Layer>>toolbarRef.value!.$refs.layerRef).setPosition()
206
+ toolbarRef.value!.layerRef!.setPosition()
208
207
  } else {
209
208
  toolbarOptions.value.show = true
210
209
  }
@@ -214,7 +213,7 @@ const handleToolbar = () => {
214
213
  toolbarOptions.value.type = 'video'
215
214
  toolbarOptions.value.node = `[data-editify-uid="${instance.uid}"] [data-editify-element="${video.key}"]`
216
215
  if (toolbarOptions.value.show) {
217
- ;(<InstanceType<typeof Layer>>toolbarRef.value!.$refs.layerRef).setPosition()
216
+ toolbarRef.value!.layerRef!.setPosition()
218
217
  } else {
219
218
  toolbarOptions.value.show = true
220
219
  }
@@ -224,7 +223,7 @@ const handleToolbar = () => {
224
223
  toolbarOptions.value.type = 'table'
225
224
  toolbarOptions.value.node = `[data-editify-uid="${instance.uid}"] [data-editify-element="${table.key}"]`
226
225
  if (toolbarOptions.value.show) {
227
- ;(<InstanceType<typeof Layer>>toolbarRef.value!.$refs.layerRef).setPosition()
226
+ toolbarRef.value!.layerRef!.setPosition()
228
227
  } else {
229
228
  toolbarOptions.value.show = true
230
229
  }
@@ -234,7 +233,7 @@ const handleToolbar = () => {
234
233
  toolbarOptions.value.type = 'codeBlock'
235
234
  toolbarOptions.value.node = `[data-editify-uid="${instance.uid}"] [data-editify-element="${pre.key}"]`
236
235
  if (toolbarOptions.value.show) {
237
- ;(<InstanceType<typeof Layer>>toolbarRef.value!.$refs.layerRef).setPosition()
236
+ toolbarRef.value!.layerRef!.setPosition()
238
237
  } else {
239
238
  toolbarOptions.value.show = true
240
239
  }
@@ -247,7 +246,7 @@ const handleToolbar = () => {
247
246
  if (result.length && !hasTableInRange(editor.value!, dataRangeCaches.value) && !hasPreInRange(editor.value!, dataRangeCaches.value) && !hasLinkInRange(editor.value!, dataRangeCaches.value) && !hasImageInRange(editor.value!, dataRangeCaches.value) && !hasVideoInRange(editor.value!, dataRangeCaches.value)) {
248
247
  toolbarOptions.value.type = 'text'
249
248
  if (toolbarOptions.value.show) {
250
- ;(toolbarRef.value!.$refs.layerRef as InstanceType<typeof Layer>).setPosition()
249
+ toolbarRef.value!.layerRef!.setPosition()
251
250
  } else {
252
251
  toolbarOptions.value.show = true
253
252
  }
package/src/index.ts CHANGED
@@ -13,7 +13,7 @@ const Editify = withInstall(editify)
13
13
  export type { ButtonTypeType, ButtonOptionsItemType, ButtonSelectConfigType, ButtonDisplayConfigType } from '@/components/button/props'
14
14
  export type { InsertImageUploadErrorType } from '@/components/insertImage/props'
15
15
  export type { InsertVideoUploadErrorType } from '@/components/insertVideo/props'
16
- export type { MenuButtonType, MenuSelectButtonType, MenuDisplayButtonType, MenuImageButtonType, MenuVideoButtonType, MenuTableButtonType, MenuCustomButtonType, CodeBlockToolbarType, TextToolbarType, ToolbarConfigType, MenuSequenceType, MenuModeType, MenuExtendType, MenuConfigType, PluginType, PluginResultType } from '@/core/tool'
16
+ export type { MenuButtonType, MenuSelectButtonType, MenuDisplayButtonType, MenuImageButtonType, MenuVideoButtonType, MenuTableButtonType, MenuCustomButtonType, CodeBlockToolbarType, TextToolbarType, ToolbarConfigType, MenuSequenceType, MenuModeType, MenuExtendType, MenuConfigType, PluginMenuConfigType, PluginType, PluginResultType } from '@/core/tool'
17
17
  export type { ElementMatchConfigType } from '@/core/function'
18
18
 
19
19
  //导出编辑器操作方法
@@ -24,7 +24,7 @@ const install = (app: App) => {
24
24
  app.component(Editify.name!, Editify)
25
25
  }
26
26
  //版本号
27
- const version = '0.2.11'
27
+ const version = '0.2.13'
28
28
 
29
29
  //导出AlexElement元素
30
30
  export { AlexElement } from 'alex-editor'
@@ -2,7 +2,6 @@ import { ComponentInternalInstance, h } from 'vue'
2
2
  import { AlexEditor, AlexElement, AlexElementsRangeType } from 'alex-editor'
3
3
  import { event as DapEvent, common as DapCommon } from 'dap-util'
4
4
  import { ObjectType, PluginType } from '@/core/tool'
5
- import Layer from '@/components/layer/layer.vue'
6
5
  import Button from '@/components/button/button.vue'
7
6
  import Icon from '@/components/icon/icon.vue'
8
7
  import InsertAttachment from './insertAttachment/insertAttachment.vue'
@@ -114,7 +113,7 @@ export const attachment = (options?: AttachmentOptionsType) => {
114
113
  customUpload: options!.customUpload,
115
114
  handleError: options!.handleError,
116
115
  onChange: () => {
117
- ;(<InstanceType<typeof Layer>>btnInstance.$refs.layerRef).setPosition()
116
+ btnInstance.layerRef!.setPosition()
118
117
  },
119
118
  onInsert: (name: string, urls: string[]) => {
120
119
  //过滤掉空的地址