vue-editify 0.2.14 → 0.2.16

Sign up to get free protection for your applications and to get access to all the features.
Files changed (190) hide show
  1. package/examples/App.vue +41 -88
  2. package/lib/components/button/button.vue.d.ts +62 -60
  3. package/lib/components/button/index.d.ts +4 -0
  4. package/lib/components/button/props.d.ts +12 -1
  5. package/lib/components/checkbox/checkbox.vue.d.ts +9 -9
  6. package/lib/components/checkbox/index.d.ts +4 -0
  7. package/lib/components/checkbox/props.d.ts +2 -2
  8. package/lib/components/colors/colors.vue.d.ts +4 -4
  9. package/lib/components/colors/index.d.ts +4 -0
  10. package/lib/components/colors/props.d.ts +2 -2
  11. package/lib/components/icon/index.d.ts +4 -0
  12. package/lib/components/insertAttachment/index.d.ts +4 -0
  13. package/lib/{plugins/attachment → components}/insertAttachment/insertAttachment.vue.d.ts +3 -3
  14. package/lib/{plugins/attachment → components}/insertAttachment/props.d.ts +1 -1
  15. package/lib/components/insertImage/index.d.ts +4 -0
  16. package/lib/components/insertImage/insertImage.vue.d.ts +3 -3
  17. package/lib/components/insertImage/props.d.ts +1 -1
  18. package/lib/components/insertLink/index.d.ts +4 -0
  19. package/lib/components/insertLink/insertLink.vue.d.ts +6 -6
  20. package/lib/components/insertLink/props.d.ts +3 -3
  21. package/lib/components/insertMathformula/index.d.ts +4 -0
  22. package/lib/{plugins/mathformula → components}/insertMathformula/insertMathformula.vue.d.ts +3 -3
  23. package/lib/{plugins/mathformula → components}/insertMathformula/props.d.ts +2 -2
  24. package/lib/components/insertTable/index.d.ts +4 -0
  25. package/lib/components/insertTable/insertTable.vue.d.ts +3 -3
  26. package/lib/components/insertTable/props.d.ts +2 -2
  27. package/lib/components/insertVideo/index.d.ts +4 -0
  28. package/lib/components/insertVideo/insertVideo.vue.d.ts +3 -3
  29. package/lib/components/insertVideo/props.d.ts +1 -1
  30. package/lib/components/layer/index.d.ts +4 -0
  31. package/lib/components/layer/layer.vue.d.ts +10 -8
  32. package/lib/components/tooltip/index.d.ts +4 -0
  33. package/lib/components/tooltip/tooltip.vue.d.ts +6 -4
  34. package/lib/components/triangle/index.d.ts +4 -0
  35. package/lib/components/triangle/triangle.vue.d.ts +1 -1
  36. package/lib/components/updateLink/index.d.ts +4 -0
  37. package/lib/components/updateLink/props.d.ts +17 -0
  38. package/lib/components/updateLink/updateLink.vue.d.ts +38 -0
  39. package/lib/core/function.d.ts +113 -36
  40. package/lib/core/rule.d.ts +20 -0
  41. package/lib/core/tool.d.ts +36 -34
  42. package/lib/editify/editify.vue.d.ts +18 -28
  43. package/lib/editify/menu/index.d.ts +4 -0
  44. package/lib/{components → editify}/menu/menu.vue.d.ts +3 -4
  45. package/lib/{components → editify}/menu/props.d.ts +1 -1
  46. package/lib/editify/props.d.ts +3 -7
  47. package/lib/editify/toolbar/index.d.ts +4 -0
  48. package/lib/{components → editify}/toolbar/props.d.ts +2 -2
  49. package/lib/{components → editify}/toolbar/toolbar.vue.d.ts +53 -53
  50. package/lib/editify.es.js +38964 -37727
  51. package/lib/editify.umd.js +2 -2
  52. package/lib/feature/align.d.ts +32 -0
  53. package/lib/feature/attachment.d.ts +18 -0
  54. package/lib/feature/backColor.d.ts +32 -0
  55. package/lib/feature/bold.d.ts +32 -0
  56. package/lib/feature/code.d.ts +32 -0
  57. package/lib/feature/codeBlock.d.ts +32 -0
  58. package/lib/feature/fontFamily.d.ts +32 -0
  59. package/lib/feature/fontSize.d.ts +32 -0
  60. package/lib/feature/foreColor.d.ts +32 -0
  61. package/lib/feature/formatClear.d.ts +32 -0
  62. package/lib/feature/fullScreen.d.ts +18 -0
  63. package/lib/feature/heading.d.ts +32 -0
  64. package/lib/feature/image.d.ts +32 -0
  65. package/lib/feature/indent.d.ts +18 -0
  66. package/lib/feature/infoBlock.d.ts +18 -0
  67. package/lib/feature/italic.d.ts +32 -0
  68. package/lib/feature/lineHeight.d.ts +32 -0
  69. package/lib/feature/link.d.ts +26 -0
  70. package/lib/feature/mathformula.d.ts +22 -0
  71. package/lib/feature/orderList.d.ts +32 -0
  72. package/lib/feature/panel.d.ts +18 -0
  73. package/lib/feature/quote.d.ts +18 -0
  74. package/lib/feature/redo.d.ts +18 -0
  75. package/lib/feature/separator.d.ts +18 -0
  76. package/lib/feature/sourceView.d.ts +18 -0
  77. package/lib/feature/strikethrough.d.ts +32 -0
  78. package/lib/feature/sub.d.ts +32 -0
  79. package/lib/feature/super.d.ts +32 -0
  80. package/lib/feature/table.d.ts +32 -0
  81. package/lib/feature/task.d.ts +32 -0
  82. package/lib/feature/underline.d.ts +32 -0
  83. package/lib/feature/undo.d.ts +18 -0
  84. package/lib/feature/unorderList.d.ts +32 -0
  85. package/lib/feature/video.d.ts +38 -0
  86. package/lib/index.d.ts +194 -202
  87. package/package.json +5 -5
  88. package/src/components/button/button.vue +21 -24
  89. package/src/components/button/index.ts +5 -0
  90. package/src/components/button/props.ts +14 -1
  91. package/src/components/checkbox/checkbox.vue +1 -1
  92. package/src/components/checkbox/index.ts +5 -0
  93. package/src/components/checkbox/props.ts +1 -1
  94. package/src/components/colors/colors.vue +3 -3
  95. package/src/components/colors/index.ts +5 -0
  96. package/src/components/colors/props.ts +2 -2
  97. package/src/components/icon/index.ts +5 -0
  98. package/src/components/insertAttachment/index.ts +5 -0
  99. package/src/{plugins/attachment → components}/insertAttachment/insertAttachment.vue +4 -2
  100. package/src/{plugins/attachment → components}/insertAttachment/props.ts +1 -1
  101. package/src/components/insertImage/index.ts +5 -0
  102. package/src/components/insertImage/insertImage.vue +5 -5
  103. package/src/components/insertImage/props.ts +1 -1
  104. package/src/components/insertLink/index.ts +5 -0
  105. package/src/components/insertLink/insertLink.vue +10 -10
  106. package/src/components/insertLink/props.ts +3 -3
  107. package/src/components/insertMathformula/index.ts +5 -0
  108. package/src/{plugins/mathformula → components}/insertMathformula/props.ts +2 -2
  109. package/src/components/insertTable/index.ts +5 -0
  110. package/src/components/insertTable/props.ts +2 -2
  111. package/src/components/insertVideo/index.ts +5 -0
  112. package/src/components/insertVideo/insertVideo.vue +2 -2
  113. package/src/components/insertVideo/props.ts +1 -1
  114. package/src/components/layer/index.ts +5 -0
  115. package/src/components/layer/layer.vue +42 -4
  116. package/src/components/tooltip/index.ts +5 -0
  117. package/src/components/tooltip/tooltip.vue +1 -1
  118. package/src/components/triangle/index.ts +5 -0
  119. package/src/components/triangle/triangle.vue +1 -1
  120. package/src/components/updateLink/index.ts +5 -0
  121. package/src/components/updateLink/props.ts +21 -0
  122. package/src/components/{toolbar/toolbar.less → updateLink/updateLink.less} +4 -20
  123. package/src/components/updateLink/updateLink.vue +74 -0
  124. package/src/core/function.ts +289 -97
  125. package/src/core/rule.ts +108 -29
  126. package/src/core/tool.ts +237 -81
  127. package/src/editify/editify.less +4 -0
  128. package/src/editify/editify.vue +183 -194
  129. package/src/editify/menu/index.ts +5 -0
  130. package/src/editify/menu/menu.vue +215 -0
  131. package/src/{components → editify}/menu/props.ts +1 -1
  132. package/src/editify/props.ts +7 -11
  133. package/src/editify/toolbar/index.ts +5 -0
  134. package/src/{components → editify}/toolbar/props.ts +1 -1
  135. package/src/editify/toolbar/toolbar.less +10 -0
  136. package/src/editify/toolbar/toolbar.vue +103 -0
  137. package/src/feature/align.ts +126 -0
  138. package/src/feature/attachment.ts +108 -0
  139. package/src/feature/backColor.ts +169 -0
  140. package/src/feature/bold.ts +134 -0
  141. package/src/feature/code.ts +134 -0
  142. package/src/feature/codeBlock.ts +201 -0
  143. package/src/feature/fontFamily.ts +138 -0
  144. package/src/feature/fontSize.ts +140 -0
  145. package/src/feature/foreColor.ts +171 -0
  146. package/src/feature/formatClear.ts +116 -0
  147. package/src/feature/fullScreen.ts +57 -0
  148. package/src/feature/heading.ts +152 -0
  149. package/src/feature/image.ts +222 -0
  150. package/src/feature/indent.ts +72 -0
  151. package/src/feature/infoBlock.ts +93 -0
  152. package/src/feature/italic.ts +134 -0
  153. package/src/feature/lineHeight.ts +163 -0
  154. package/src/feature/link.ts +146 -0
  155. package/src/feature/mathformula.ts +146 -0
  156. package/src/feature/orderList.ts +114 -0
  157. package/src/feature/panel.ts +107 -0
  158. package/src/feature/quote.ts +60 -0
  159. package/src/feature/redo.ts +56 -0
  160. package/src/feature/separator.ts +61 -0
  161. package/src/feature/sourceView.ts +59 -0
  162. package/src/feature/strikethrough.ts +134 -0
  163. package/src/feature/sub.ts +134 -0
  164. package/src/feature/super.ts +134 -0
  165. package/src/feature/table.ts +981 -0
  166. package/src/feature/task.ts +114 -0
  167. package/src/feature/underline.ts +134 -0
  168. package/src/feature/undo.ts +56 -0
  169. package/src/feature/unorderList.ts +114 -0
  170. package/src/feature/video.ts +335 -0
  171. package/src/hljs/index.ts +1 -1
  172. package/src/index.ts +82 -25
  173. package/src/locale/en_US.ts +3 -3
  174. package/src/locale/zh_CN.ts +3 -3
  175. package/lib/plugins/attachment/index.d.ts +0 -37
  176. package/lib/plugins/infoBlock/index.d.ts +0 -55
  177. package/lib/plugins/mathformula/index.d.ts +0 -49
  178. package/lib/plugins/panel/index.d.ts +0 -48
  179. package/src/components/menu/menu.vue +0 -1655
  180. package/src/components/toolbar/toolbar.vue +0 -1677
  181. package/src/plugins/attachment/index.ts +0 -237
  182. package/src/plugins/infoBlock/index.ts +0 -238
  183. package/src/plugins/mathformula/index.ts +0 -295
  184. package/src/plugins/panel/index.ts +0 -228
  185. package/tsconfig.json +0 -31
  186. package/tsconfig.node.json +0 -11
  187. /package/src/{plugins/attachment → components}/insertAttachment/insertAttachment.less +0 -0
  188. /package/src/{plugins/mathformula → components}/insertMathformula/insertMathformula.less +0 -0
  189. /package/src/{plugins/mathformula → components}/insertMathformula/insertMathformula.vue +0 -0
  190. /package/src/{components → editify}/menu/menu.less +0 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vue-editify",
3
- "version": "0.2.14",
3
+ "version": "0.2.16",
4
4
  "private": false,
5
5
  "sideEffects": [
6
6
  "*.css"
@@ -17,7 +17,7 @@
17
17
  "lib": "vue-tsc && vite build"
18
18
  },
19
19
  "dependencies": {
20
- "alex-editor": "^1.4.20",
20
+ "alex-editor": "^1.4.24",
21
21
  "dap-util": "^1.5.8",
22
22
  "highlight.js": "^11.8.0",
23
23
  "katex": "^0.16.10",
@@ -29,11 +29,11 @@
29
29
  "@vitejs/plugin-vue": "^5.0.4",
30
30
  "less": "^3.0.4",
31
31
  "terser": "^5.16.9",
32
- "typescript": "^5.2.2",
32
+ "typescript": "^5.5.3",
33
33
  "vite": "^5.2.8",
34
34
  "vite-plugin-css-injected-by-js": "^3.5.1",
35
- "vite-plugin-dts": "^3.7.3",
36
- "vue-tsc": "^1.8.27"
35
+ "vite-plugin-dts": "^3.9.1",
36
+ "vue-tsc": "^2.0.26"
37
37
  },
38
38
  "browserslist": [
39
39
  "> 1%",
@@ -30,11 +30,11 @@
30
30
  <script setup lang="ts">
31
31
  import { computed, ref } from 'vue'
32
32
  import { common as DapCommon, color as DapColor } from 'dap-util'
33
- import Tooltip from '@/components/tooltip/tooltip.vue'
34
- import Layer from '@/components/layer/layer.vue'
35
- import Icon from '@/components/icon/icon.vue'
36
33
  import { ObjectType } from '@/core/tool'
37
- import { ButtonDisplayConfigType, ButtonOptionsItemType, ButtonProps, ButtonSelectConfigType } from './props'
34
+ import { Tooltip } from '@/components/tooltip'
35
+ import { Layer } from '@/components/layer'
36
+ import { Icon } from '@/components/icon'
37
+ import { ButtonOptionsItemType, ButtonParseDisplayConfigType, ButtonParseSelectConfigType, ButtonProps } from './props'
38
38
 
39
39
  defineOptions({
40
40
  name: 'Button'
@@ -50,7 +50,7 @@ const btnRef = ref<HTMLElement | null>(null)
50
50
  const layerRef = ref<InstanceType<typeof Layer> | null>(null)
51
51
 
52
52
  //处理后的select配置
53
- const parseSelectConfig = computed<ButtonSelectConfigType>(() => {
53
+ const parseSelectConfig = computed<ButtonParseSelectConfigType>(() => {
54
54
  let options: ButtonOptionsItemType[] = []
55
55
  let width: number | '' = ''
56
56
  let maxHeight: number | '' = ''
@@ -59,15 +59,15 @@ const parseSelectConfig = computed<ButtonSelectConfigType>(() => {
59
59
  options = props.selectConfig.options.map(item => {
60
60
  if (DapCommon.isObject(item)) {
61
61
  return {
62
- label: (<ButtonOptionsItemType>item).label,
63
- value: (<ButtonOptionsItemType>item).value,
64
- icon: (<ButtonOptionsItemType>item).icon,
65
- style: (<ButtonOptionsItemType>item).style
62
+ label: (item as ButtonOptionsItemType).label,
63
+ value: (item as ButtonOptionsItemType).value,
64
+ icon: (item as ButtonOptionsItemType).icon,
65
+ style: (item as ButtonOptionsItemType).style
66
66
  }
67
67
  }
68
68
  return {
69
- label: <string | number>item,
70
- value: <string | number>item
69
+ label: item as string | number,
70
+ value: item as string | number
71
71
  }
72
72
  })
73
73
  }
@@ -85,7 +85,7 @@ const parseSelectConfig = computed<ButtonSelectConfigType>(() => {
85
85
  }
86
86
  })
87
87
  //处理后的display配置
88
- const parseDisplayConfig = computed<ButtonDisplayConfigType>(() => {
88
+ const parseDisplayConfig = computed<ButtonParseDisplayConfigType>(() => {
89
89
  let options: ButtonOptionsItemType[] = []
90
90
  let width: number | '' = ''
91
91
  let maxHeight: number | '' = ''
@@ -98,15 +98,15 @@ const parseDisplayConfig = computed<ButtonDisplayConfigType>(() => {
98
98
  options = props.displayConfig.options.map(item => {
99
99
  if (DapCommon.isObject(item)) {
100
100
  return {
101
- label: (<ButtonOptionsItemType>item).label,
102
- value: (<ButtonOptionsItemType>item).value,
103
- icon: (<ButtonOptionsItemType>item).icon,
104
- style: (<ButtonOptionsItemType>item).style
101
+ label: (item as ButtonOptionsItemType).label,
102
+ value: (item as ButtonOptionsItemType).value,
103
+ icon: (item as ButtonOptionsItemType).icon,
104
+ style: (item as ButtonOptionsItemType).style
105
105
  }
106
106
  }
107
107
  return {
108
- label: <string | number>item,
109
- value: <string | number>item
108
+ label: item as string | number,
109
+ value: item as string | number
110
110
  }
111
111
  })
112
112
  let optItem = options.find(item => {
@@ -132,11 +132,11 @@ const parseDisplayConfig = computed<ButtonDisplayConfigType>(() => {
132
132
  })
133
133
  //渲染的浮层列表数据
134
134
  const cmpOptions = computed<ButtonOptionsItemType[]>(() => {
135
- return props.type == 'select' ? <ButtonOptionsItemType[]>parseSelectConfig.value.options : <ButtonOptionsItemType[]>parseDisplayConfig.value.options
135
+ return props.type == 'select' ? parseSelectConfig.value.options! : parseDisplayConfig.value.options!
136
136
  })
137
137
  //显示在页面的value值对应的label
138
138
  const displayLabel = computed<string | number>(() => {
139
- const val = (<ButtonOptionsItemType[]>parseDisplayConfig.value.options).find(item => {
139
+ const val = parseDisplayConfig.value.options!.find(item => {
140
140
  return item.value == parseDisplayConfig.value.value
141
141
  })
142
142
  return val ? val.label! : ''
@@ -150,10 +150,7 @@ const parseColor = computed<number[]>(() => {
150
150
  })
151
151
  //按钮样式
152
152
  const btnStyle = computed<ObjectType>(() => {
153
- if (props.disabled) {
154
- return {}
155
- }
156
- if (props.color) {
153
+ if (!props.disabled && props.color) {
157
154
  //激活情况下和鼠标按下状态
158
155
  if (props.active || status.value == 'down') {
159
156
  return {
@@ -0,0 +1,5 @@
1
+ import Button from './button.vue'
2
+
3
+ export type * from './props'
4
+
5
+ export { Button }
@@ -16,6 +16,12 @@ export type ButtonSelectConfigType = {
16
16
  maxHeight?: number | ''
17
17
  }
18
18
 
19
+ export type ButtonParseSelectConfigType = {
20
+ options?: ButtonOptionsItemType[]
21
+ width?: number | ''
22
+ maxHeight?: number | ''
23
+ }
24
+
19
25
  export type ButtonDisplayConfigType = {
20
26
  options?: (ButtonOptionsItemType | number | string)[]
21
27
  width?: number | ''
@@ -23,6 +29,13 @@ export type ButtonDisplayConfigType = {
23
29
  value?: string | number
24
30
  }
25
31
 
32
+ export type ButtonParseDisplayConfigType = {
33
+ options?: ButtonOptionsItemType[]
34
+ width?: number | ''
35
+ maxHeight?: number | ''
36
+ value?: string | number
37
+ }
38
+
26
39
  export const ButtonProps = {
27
40
  //按钮类型
28
41
  type: {
@@ -62,7 +75,7 @@ export const ButtonProps = {
62
75
  },
63
76
  //主题色,用于按钮悬浮颜色变化使用,仅支持十六进制
64
77
  color: {
65
- type: String as PropType<string | null>,
78
+ type: String,
66
79
  default: ''
67
80
  },
68
81
  //是否禁用
@@ -12,7 +12,7 @@
12
12
  <script setup lang="ts">
13
13
  import { computed } from 'vue'
14
14
  import { common as DapCommon } from 'dap-util'
15
- import Icon from '@/components/icon/icon.vue'
15
+ import { Icon } from '@/components/icon'
16
16
  import { ObjectType } from '@/core/tool'
17
17
  import { CheckboxProps } from './props'
18
18
 
@@ -0,0 +1,5 @@
1
+ import Checkbox from './checkbox.vue'
2
+
3
+ export type * from './props'
4
+
5
+ export { Checkbox }
@@ -38,7 +38,7 @@ export const CheckboxProps = {
38
38
  },
39
39
  //主题颜色
40
40
  color: {
41
- type: String as PropType<string | null>,
41
+ type: String,
42
42
  default: '',
43
43
  validator(value: any) {
44
44
  return DapCommon.matchingText(value, 'hex')
@@ -15,9 +15,9 @@
15
15
  </template>
16
16
  <script setup lang="ts">
17
17
  import { inject } from 'vue'
18
- import Icon from '@/components/icon/icon.vue'
19
- import Tooltip from '@/components/tooltip/tooltip.vue'
20
- import { ButtonOptionsItemType } from '@/components/button/props'
18
+ import { Icon } from '@/components/icon'
19
+ import { Tooltip } from '@/components/tooltip'
20
+ import { ButtonOptionsItemType } from '@/components/button'
21
21
  import { ColorsProps } from './props'
22
22
 
23
23
  defineOptions({
@@ -0,0 +1,5 @@
1
+ import Colors from './colors.vue'
2
+
3
+ export type * from './props'
4
+
5
+ export { Colors }
@@ -1,5 +1,5 @@
1
1
  import { ExtractPublicPropTypes, PropType } from 'vue'
2
- import { ButtonOptionsItemType } from '@/components/button/props'
2
+ import { ButtonOptionsItemType } from '@/components/button'
3
3
 
4
4
  export const ColorsProps = {
5
5
  //颜色数组
@@ -16,7 +16,7 @@ export const ColorsProps = {
16
16
  },
17
17
  //激活状态颜色
18
18
  color: {
19
- type: String as PropType<string | null>,
19
+ type: String,
20
20
  default: ''
21
21
  },
22
22
  //是否使用工具提示
@@ -0,0 +1,5 @@
1
+ import Icon from './icon.vue'
2
+
3
+ export type * from './props'
4
+
5
+ export { Icon }
@@ -0,0 +1,5 @@
1
+ import InsertAttachment from './insertAttachment.vue'
2
+
3
+ export type * from './props'
4
+
5
+ export { InsertAttachment }
@@ -24,16 +24,18 @@
24
24
  </div>
25
25
  </template>
26
26
  <script setup lang="ts">
27
- import { file as DapFile } from 'dap-util'
28
27
  import { computed, inject, ref, watch } from 'vue'
28
+ import { file as DapFile } from 'dap-util'
29
29
  import { ObjectType } from '@/core/tool'
30
- import Icon from '@/components/icon/icon.vue'
30
+ import { Icon } from '@/components/icon'
31
31
  import { InsertAttachmentProps } from './props'
32
32
 
33
33
  defineOptions({
34
34
  name: 'InsertAttachment'
35
35
  })
36
+ //属性
36
37
  const props = defineProps(InsertAttachmentProps)
38
+ //事件
37
39
  const emits = defineEmits(['change', 'insert'])
38
40
 
39
41
  const $editTrans = inject<(key: string) => any>('$editTrans')!
@@ -5,7 +5,7 @@ export type InsertAttachmentUploadErrorType = 'suffixError' | 'maxSizeError' | '
5
5
  export const InsertAttachmentProps = {
6
6
  //主题色
7
7
  color: {
8
- type: String as PropType<string | null>,
8
+ type: String,
9
9
  default: ''
10
10
  },
11
11
  //可选择的文件类型
@@ -0,0 +1,5 @@
1
+ import InsertImage from './insertImage.vue'
2
+
3
+ export type * from './props'
4
+
5
+ export { InsertImage }
@@ -20,10 +20,10 @@
20
20
  </div>
21
21
  </template>
22
22
  <script setup lang="ts">
23
- import { file as DapFile } from 'dap-util'
24
23
  import { computed, inject, ref, watch } from 'vue'
25
- import Icon from '@/components/icon/icon.vue'
24
+ import { file as DapFile } from 'dap-util'
26
25
  import { ObjectType } from '@/core/tool'
26
+ import { Icon } from '@/components/icon'
27
27
  import { InsertImageProps } from './props'
28
28
 
29
29
  defineOptions({
@@ -61,12 +61,12 @@ const getSuffix = (file: File) => {
61
61
  //输入框获取焦点
62
62
  const handleInputFocus = (e: Event) => {
63
63
  if (props.color) {
64
- ;(<HTMLInputElement>e.currentTarget).style.borderColor = props.color
64
+ ;(e.currentTarget as HTMLInputElement).style.borderColor = props.color
65
65
  }
66
66
  }
67
67
  //输入框失去焦点
68
68
  const handleInputBlur = (e: Event) => {
69
- ;(<HTMLInputElement>e.currentTarget).style.borderColor = ''
69
+ ;(e.currentTarget as HTMLInputElement).style.borderColor = ''
70
70
  }
71
71
  //插入网络图片
72
72
  const insertRemoteImage = () => {
@@ -74,7 +74,7 @@ const insertRemoteImage = () => {
74
74
  }
75
75
  //选择文件
76
76
  const selectFile = async (e: Event) => {
77
- const inputEle = <HTMLInputElement>e.currentTarget
77
+ const inputEle = e.currentTarget as HTMLInputElement
78
78
  const files = inputEle.files
79
79
  if (!files || !files.length) {
80
80
  return
@@ -5,7 +5,7 @@ export type InsertImageUploadErrorType = 'suffixError' | 'maxSizeError' | 'minSi
5
5
  export const InsertImageProps = {
6
6
  //主题色
7
7
  color: {
8
- type: String as PropType<string | null>,
8
+ type: String,
9
9
  default: ''
10
10
  },
11
11
  //支持的图片类型数组
@@ -0,0 +1,5 @@
1
+ import InsertLink from './insertLink.vue'
2
+
3
+ export type * from './props'
4
+
5
+ export { InsertLink }
@@ -1,8 +1,8 @@
1
1
  <template>
2
2
  <div class="editify-link">
3
3
  <div class="editify-link-label">{{ $editTrans('linkAddress') }}</div>
4
- <input @focus="handleInputFocus" @blur="handleInputBlur" :placeholder="$editTrans('linkTextEnterPlaceholder')" v-model.trim="linkText" type="text" />
5
- <input @focus="handleInputFocus" @blur="handleInputBlur" :placeholder="$editTrans('linkUrlEnterPlaceholder')" v-model.trim="linkUrl" type="url" />
4
+ <input @focus="handleInputFocus" @blur="handleInputBlur" :placeholder="$editTrans('linkTextEnterPlaceholder')" v-model.trim="text" type="text" />
5
+ <input @focus="handleInputFocus" @blur="handleInputBlur" :placeholder="$editTrans('linkUrlEnterPlaceholder')" v-model.trim="url" type="url" />
6
6
  <div class="editify-link-footer">
7
7
  <Checkbox v-model="newOpen" :label="$editTrans('newWindowOpen')" :color="color" :size="10"></Checkbox>
8
8
  <div class="editify-link-operations">
@@ -13,7 +13,7 @@
13
13
  </template>
14
14
  <script setup lang="ts">
15
15
  import { inject, ref, watch } from 'vue'
16
- import Checkbox from '@/components/checkbox/checkbox.vue'
16
+ import { Checkbox } from '@/components/checkbox'
17
17
  import { InsertLinkProps } from './props'
18
18
 
19
19
  defineOptions({
@@ -25,16 +25,16 @@ const emits = defineEmits(['insert'])
25
25
  const $editTrans = inject<(key: string) => any>('$editTrans')!
26
26
 
27
27
  //链接地址
28
- const linkUrl = ref<string>('')
28
+ const url = ref<string>('')
29
29
  //链接文本
30
- const linkText = ref<string>('')
30
+ const text = ref<string>('')
31
31
  //是否新窗口打开
32
32
  const newOpen = ref<boolean>(false)
33
33
 
34
34
  watch(
35
- () => props.text,
35
+ () => props.presetText,
36
36
  newVal => {
37
- linkText.value = newVal
37
+ text.value = newVal || ''
38
38
  },
39
39
  {
40
40
  immediate: true
@@ -43,16 +43,16 @@ watch(
43
43
  //输入框获取焦点
44
44
  const handleInputFocus = (e: Event) => {
45
45
  if (props.color) {
46
- ;(<HTMLInputElement>e.currentTarget).style.borderColor = props.color
46
+ ;(e.currentTarget as HTMLInputElement).style.borderColor = props.color
47
47
  }
48
48
  }
49
49
  //输入框失去焦点
50
50
  const handleInputBlur = (e: Event) => {
51
- ;(<HTMLInputElement>e.currentTarget).style.borderColor = ''
51
+ ;(e.currentTarget as HTMLInputElement).style.borderColor = ''
52
52
  }
53
53
  //插入链接
54
54
  const insertLink = () => {
55
- emits('insert', linkText.value, linkUrl.value, newOpen.value)
55
+ emits('insert', text.value, url.value, newOpen.value)
56
56
  }
57
57
  </script>
58
58
  <style scoped src="./insertLink.less"></style>
@@ -1,13 +1,13 @@
1
- import { ExtractPublicPropTypes, PropType } from 'vue'
1
+ import { ExtractPublicPropTypes } from 'vue'
2
2
 
3
3
  export const InsertLinkProps = {
4
4
  //主题色
5
5
  color: {
6
- type: String as PropType<string | null>,
6
+ type: String,
7
7
  default: ''
8
8
  },
9
9
  //预置的链接文本值
10
- text: {
10
+ presetText: {
11
11
  type: String,
12
12
  default: ''
13
13
  }
@@ -0,0 +1,5 @@
1
+ import InsertMathformula from './insertMathformula.vue'
2
+
3
+ export type * from './props'
4
+
5
+ export { InsertMathformula }
@@ -1,9 +1,9 @@
1
- import { ExtractPublicPropTypes, PropType } from 'vue'
1
+ import { ExtractPublicPropTypes } from 'vue'
2
2
 
3
3
  export const InsertMathformulaProps = {
4
4
  //主题色
5
5
  color: {
6
- type: String as PropType<string | null>,
6
+ type: String,
7
7
  default: ''
8
8
  },
9
9
  //预置的LaTex文本内容
@@ -0,0 +1,5 @@
1
+ import InsertTable from './insertTable.vue'
2
+
3
+ export type * from './props'
4
+
5
+ export { InsertTable }
@@ -1,4 +1,4 @@
1
- import { ExtractPublicPropTypes, PropType } from 'vue'
1
+ import { ExtractPublicPropTypes } from 'vue'
2
2
 
3
3
  export type InsertTableGridType = {
4
4
  x: number
@@ -9,7 +9,7 @@ export type InsertTableGridType = {
9
9
  export const InsertTableProps = {
10
10
  //主题色
11
11
  color: {
12
- type: String as PropType<string | null>,
12
+ type: String,
13
13
  default: ''
14
14
  },
15
15
  //最大行数
@@ -0,0 +1,5 @@
1
+ import InsertVideo from './insertVideo.vue'
2
+
3
+ export type * from './props'
4
+
5
+ export { InsertVideo }
@@ -20,10 +20,10 @@
20
20
  </div>
21
21
  </template>
22
22
  <script setup lang="ts">
23
- import { file as DapFile } from 'dap-util'
24
23
  import { computed, inject, ref, watch } from 'vue'
24
+ import { file as DapFile } from 'dap-util'
25
25
  import { ObjectType } from '@/core/tool'
26
- import Icon from '@/components/icon/icon.vue'
26
+ import { Icon } from '@/components/icon'
27
27
  import { InsertVideoProps } from './props'
28
28
 
29
29
  defineOptions({
@@ -5,7 +5,7 @@ export type InsertVideoUploadErrorType = 'suffixError' | 'maxSizeError' | 'minSi
5
5
  export const InsertVideoProps = {
6
6
  //主题色
7
7
  color: {
8
- type: String as PropType<string | null>,
8
+ type: String,
9
9
  default: ''
10
10
  },
11
11
  //支持的视频类型数组
@@ -0,0 +1,5 @@
1
+ import Layer from './layer.vue'
2
+
3
+ export type * from './props'
4
+
5
+ export { Layer }
@@ -1,6 +1,6 @@
1
1
  <template>
2
2
  <Teleport to="body">
3
- <Transition :name="animation ? 'editify-layer-' + animation : 'editify-layer'" @enter="handleEnter" @after-enter="el => emits('shown', el)" @after-leave="el => emits('hidden', el)">
3
+ <Transition :name="animation ? 'editify-layer-' + animation : 'editify-layer'" @enter="handleEnter" @after-enter="(el:Element) => emits('shown', el)" @after-leave="(el:Element) => emits('hidden', el)">
4
4
  <div v-if="modelValue" class="editify-layer" :data-editify-placement="realPlacement || null" :style="{ zIndex: zIndex }" ref="elRef">
5
5
  <Triangle v-if="showTriangle" :color="border && borderColor ? borderColor : background" :background="background" :placement="triPlacement" ref="triangleRef" />
6
6
  <div ref="wrapRef" class="editify-layer-wrap" :class="{ 'editify-border': border }" :style="wrapStyle">
@@ -11,11 +11,10 @@
11
11
  </Teleport>
12
12
  </template>
13
13
  <script setup lang="ts">
14
- import { computed, getCurrentInstance, nextTick, onBeforeUnmount, onMounted, ref } from 'vue'
14
+ import { computed, getCurrentInstance, nextTick, onBeforeUnmount, onMounted, ref, watch } from 'vue'
15
15
  import { element as DapElement, event as DapEvent } from 'dap-util'
16
- import Triangle from '@/components/triangle/triangle.vue'
17
- import { TrianglePlacementType } from '@/components/triangle/props'
18
16
  import { ObjectType } from '@/core/tool'
17
+ import { Triangle, TrianglePlacementType } from '@/components/triangle'
19
18
  import { LayerPlacementType, LayerProps } from './props'
20
19
 
21
20
  defineOptions({
@@ -572,6 +571,30 @@ const handleResize = () => {
572
571
  emits('update:modelValue', false)
573
572
  }
574
573
  }
574
+ //有元素滚动
575
+ const handleScroll = () => {
576
+ const setScroll = (el: HTMLElement) => {
577
+ DapEvent.on(el, `scroll.editify_layer_${instance.uid}`, () => {
578
+ if (props.modelValue) {
579
+ emits('update:modelValue', false)
580
+ }
581
+ })
582
+ if (el.parentNode) {
583
+ setScroll(el.parentNode as HTMLElement)
584
+ }
585
+ }
586
+ setScroll(getNode()! || getScrollNode()!)
587
+ }
588
+ //移除上述滚动事件的监听
589
+ const removeScrollHandle = () => {
590
+ const removeScroll = (el: HTMLElement) => {
591
+ DapEvent.off(el, `scroll.editify_layer_${instance.uid}`)
592
+ if (el.parentNode) {
593
+ removeScroll(el.parentNode as HTMLElement)
594
+ }
595
+ }
596
+ removeScroll(getNode()! || getScrollNode()!)
597
+ }
575
598
  //点击定位元素和自身以外的元素关闭浮层
576
599
  const handleClick = (e: Event) => {
577
600
  if (!DapElement.isElement(elRef.value)) {
@@ -595,6 +618,20 @@ const handleClick = (e: Event) => {
595
618
  }
596
619
  }
597
620
 
621
+ watch(
622
+ () => props.modelValue,
623
+ newVal => {
624
+ if (newVal) {
625
+ nextTick(() => {
626
+ handleScroll()
627
+ })
628
+ }
629
+ },
630
+ {
631
+ immediate: true
632
+ }
633
+ )
634
+
598
635
  onMounted(() => {
599
636
  if (props.modelValue) {
600
637
  setPosition()
@@ -604,6 +641,7 @@ onMounted(() => {
604
641
  })
605
642
 
606
643
  onBeforeUnmount(() => {
644
+ removeScrollHandle()
607
645
  DapEvent.off(window, `mousedown.editify_layer_${instance.uid} resize.editify_layer_${instance.uid}`)
608
646
  })
609
647
 
@@ -0,0 +1,5 @@
1
+ import Tooltip from './tooltip.vue'
2
+
3
+ export type * from './props'
4
+
5
+ export { Tooltip }
@@ -8,7 +8,7 @@
8
8
  </template>
9
9
  <script setup lang="ts">
10
10
  import { ComputedRef, inject, ref } from 'vue'
11
- import Layer from '@/components/layer/layer.vue'
11
+ import { Layer } from '@/components/layer'
12
12
  import { TooltipProps } from './props'
13
13
 
14
14
  defineOptions({
@@ -0,0 +1,5 @@
1
+ import Triangle from './triangle.vue'
2
+
3
+ export type * from './props'
4
+
5
+ export { Triangle }
@@ -6,8 +6,8 @@
6
6
 
7
7
  <script setup lang="ts">
8
8
  import { computed } from 'vue'
9
- import { TriangleProps } from './props'
10
9
  import { ObjectType } from '@/core/tool'
10
+ import { TriangleProps } from './props'
11
11
 
12
12
  defineOptions({
13
13
  name: 'Triangle'
@@ -0,0 +1,5 @@
1
+ import UpdateLink from './updateLink.vue'
2
+
3
+ export type * from './props'
4
+
5
+ export { UpdateLink }
@@ -0,0 +1,21 @@
1
+ import { ExtractPublicPropTypes } from 'vue'
2
+
3
+ export const UpdateLinkProps = {
4
+ //主题色
5
+ color: {
6
+ type: String,
7
+ default: ''
8
+ },
9
+ //预置链接值
10
+ presetUrl: {
11
+ type: String,
12
+ default: ''
13
+ },
14
+ //预置是否新窗口打开
15
+ presetNewOpen: {
16
+ type: Boolean,
17
+ default: false
18
+ }
19
+ }
20
+
21
+ export type UpdateLinkPropsType = ExtractPublicPropTypes<typeof UpdateLinkProps>