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
@@ -0,0 +1,138 @@
1
+ import { computed, defineComponent, h, inject, PropType, Ref, ref } from 'vue'
2
+ import { AlexElementsRangeType, AlexEditor } from 'alex-editor'
3
+ import { common as DapCommon } from 'dap-util'
4
+ import { MenuDisplayButtonType } from '@/core/tool'
5
+ import { hasPreInRange, queryTextStyle, setTextStyle } from '@/core/function'
6
+ import { Button, ButtonOptionsItemType } from '@/components/button'
7
+
8
+ /**
9
+ * feature名称
10
+ */
11
+ const FEATURE_NAME = 'fontFamily'
12
+
13
+ /**
14
+ * 工具栏 - 字体
15
+ */
16
+ export const FontFamilyToolbarButton = defineComponent(
17
+ (props, { expose }) => {
18
+ const editor = inject<Ref<AlexEditor>>('editor')!
19
+ const dataRangeCaches = inject<Ref<AlexElementsRangeType>>('dataRangeCaches')!
20
+ const $editTrans = inject<(key: string) => any>('$editTrans')!
21
+
22
+ const btnRef = ref<InstanceType<typeof Button> | null>(null)
23
+
24
+ const selectVal = computed<string>(() => {
25
+ const findFamilyItem = props.config.options!.find((item: string | number | ButtonOptionsItemType) => {
26
+ if (DapCommon.isObject(item)) {
27
+ return queryTextStyle(editor.value, dataRangeCaches.value, 'font-family', (item as ButtonOptionsItemType).value)
28
+ }
29
+ return queryTextStyle(editor.value, dataRangeCaches.value, 'font-family', item as string)
30
+ })
31
+ return findFamilyItem ? (DapCommon.isObject(findFamilyItem) ? ((findFamilyItem as ButtonOptionsItemType).value as string) : (findFamilyItem as string)) : (props.config.defaultValue as string)
32
+ })
33
+ expose({
34
+ btnRef
35
+ })
36
+ return () => {
37
+ return props.config.show
38
+ ? h(Button, {
39
+ ref: btnRef,
40
+ name: FEATURE_NAME,
41
+ type: 'display',
42
+ title: $editTrans('fontFamily'),
43
+ tooltip: props.tooltip,
44
+ color: props.color,
45
+ zIndex: props.zIndex,
46
+ leftBorder: props.config.leftBorder,
47
+ rightBorder: props.config.rightBorder,
48
+ active: false,
49
+ disabled: props.config.disabled,
50
+ displayConfig: {
51
+ options: props.config.options,
52
+ value: selectVal.value,
53
+ width: props.config.width,
54
+ maxHeight: props.config.maxHeight
55
+ },
56
+ onOperate: (_name: string, val: string) => {
57
+ setTextStyle(editor.value, dataRangeCaches.value, {
58
+ 'font-family': val
59
+ })
60
+ editor.value.domRender()
61
+ editor.value.rangeRender()
62
+ }
63
+ })
64
+ : null
65
+ }
66
+ },
67
+ {
68
+ name: `_${FEATURE_NAME}`,
69
+ props: {
70
+ color: String,
71
+ zIndex: Number,
72
+ config: Object as PropType<MenuDisplayButtonType>,
73
+ tooltip: Boolean
74
+ }
75
+ }
76
+ )
77
+
78
+ /**
79
+ * 菜单栏 - 字体
80
+ */
81
+ export const FontFamilyMenuButton = defineComponent(
82
+ props => {
83
+ const editor = inject<Ref<AlexEditor>>('editor')!
84
+ const dataRangeCaches = inject<Ref<AlexElementsRangeType>>('dataRangeCaches')!
85
+ const $editTrans = inject<(key: string) => any>('$editTrans')!
86
+ const isSourceView = inject<Ref<boolean>>('isSourceView')!
87
+
88
+ const selectVal = computed<string>(() => {
89
+ const findFamilyItem = props.config.options!.find((item: string | number | ButtonOptionsItemType) => {
90
+ if (DapCommon.isObject(item)) {
91
+ return queryTextStyle(editor.value, dataRangeCaches.value, 'font-family', (item as ButtonOptionsItemType).value)
92
+ }
93
+ return queryTextStyle(editor.value, dataRangeCaches.value, 'font-family', item as string)
94
+ })
95
+ return findFamilyItem ? (DapCommon.isObject(findFamilyItem) ? ((findFamilyItem as ButtonOptionsItemType).value as string) : (findFamilyItem as string)) : (props.config.defaultValue as string)
96
+ })
97
+
98
+ return () => {
99
+ return props.config.show
100
+ ? h(Button, {
101
+ name: FEATURE_NAME,
102
+ tooltip: props.tooltip,
103
+ color: props.color,
104
+ zIndex: props.zIndex,
105
+ type: 'display',
106
+ displayConfig: {
107
+ options: props.config.options,
108
+ value: selectVal.value,
109
+ width: props.config.width,
110
+ maxHeight: props.config.maxHeight
111
+ },
112
+ title: $editTrans('fontFamily'),
113
+ leftBorder: props.config.leftBorder,
114
+ rightBorder: props.config.rightBorder,
115
+ active: false,
116
+ disabled: props.disabled || isSourceView.value || hasPreInRange(editor.value, dataRangeCaches.value) || props.config.disabled,
117
+ onOperate: (_name, val) => {
118
+ setTextStyle(editor.value, dataRangeCaches.value, {
119
+ 'font-family': val
120
+ })
121
+ editor.value.domRender()
122
+ editor.value.rangeRender()
123
+ }
124
+ })
125
+ : null
126
+ }
127
+ },
128
+ {
129
+ name: `_${FEATURE_NAME}`,
130
+ props: {
131
+ color: String,
132
+ zIndex: Number,
133
+ config: Object as PropType<MenuDisplayButtonType>,
134
+ tooltip: Boolean,
135
+ disabled: Boolean
136
+ }
137
+ }
138
+ )
@@ -0,0 +1,140 @@
1
+ import { computed, defineComponent, h, inject, PropType, Ref, ref } from 'vue'
2
+ import { AlexElementsRangeType, AlexEditor } from 'alex-editor'
3
+ import { common as DapCommon } from 'dap-util'
4
+ import { MenuDisplayButtonType } from '@/core/tool'
5
+ import { hasPreInRange, queryTextStyle, setTextStyle } from '@/core/function'
6
+ import { Button, ButtonOptionsItemType } from '@/components/button'
7
+
8
+ /**
9
+ * feature名称
10
+ */
11
+ const FEATURE_NAME = 'fontSize'
12
+
13
+ /**
14
+ * 工具栏 - 字号
15
+ */
16
+ export const FontSizeToolbarButton = defineComponent(
17
+ (props, { expose }) => {
18
+ const editor = inject<Ref<AlexEditor>>('editor')!
19
+ const dataRangeCaches = inject<Ref<AlexElementsRangeType>>('dataRangeCaches')!
20
+ const $editTrans = inject<(key: string) => any>('$editTrans')!
21
+
22
+ const btnRef = ref<InstanceType<typeof Button> | null>(null)
23
+
24
+ const selectVal = computed<string | number>(() => {
25
+ const findFontItem = props.config.options!.find((item: string | number | ButtonOptionsItemType) => {
26
+ if (DapCommon.isObject(item)) {
27
+ return queryTextStyle(editor.value, dataRangeCaches.value, 'font-size', (item as ButtonOptionsItemType).value)
28
+ }
29
+ return queryTextStyle(editor.value, dataRangeCaches.value, 'font-size', item as string | number)
30
+ })
31
+ return findFontItem ? (DapCommon.isObject(findFontItem) ? ((findFontItem as ButtonOptionsItemType).value as string | number) : (findFontItem as string | number)) : (props.config.defaultValue as string | number)
32
+ })
33
+
34
+ expose({
35
+ btnRef
36
+ })
37
+
38
+ return () => {
39
+ return props.config.show
40
+ ? h(Button, {
41
+ ref: btnRef,
42
+ name: FEATURE_NAME,
43
+ type: 'display',
44
+ title: $editTrans('fontSize'),
45
+ tooltip: props.tooltip,
46
+ color: props.color,
47
+ zIndex: props.zIndex,
48
+ leftBorder: props.config.leftBorder,
49
+ rightBorder: props.config.rightBorder,
50
+ active: false,
51
+ disabled: props.config.disabled,
52
+ displayConfig: {
53
+ options: props.config.options,
54
+ value: selectVal.value,
55
+ width: props.config.width,
56
+ maxHeight: props.config.maxHeight
57
+ },
58
+ onOperate: (_name: string, val: string) => {
59
+ setTextStyle(editor.value, dataRangeCaches.value, {
60
+ 'font-size': val
61
+ })
62
+ editor.value.domRender()
63
+ editor.value.rangeRender()
64
+ }
65
+ })
66
+ : null
67
+ }
68
+ },
69
+ {
70
+ name: `_${FEATURE_NAME}`,
71
+ props: {
72
+ color: String,
73
+ zIndex: Number,
74
+ config: Object as PropType<MenuDisplayButtonType>,
75
+ tooltip: Boolean
76
+ }
77
+ }
78
+ )
79
+
80
+ /**
81
+ * 菜单栏 - 字号
82
+ */
83
+ export const FontSizeMenuButton = defineComponent(
84
+ props => {
85
+ const editor = inject<Ref<AlexEditor>>('editor')!
86
+ const dataRangeCaches = inject<Ref<AlexElementsRangeType>>('dataRangeCaches')!
87
+ const $editTrans = inject<(key: string) => any>('$editTrans')!
88
+ const isSourceView = inject<Ref<boolean>>('isSourceView')!
89
+
90
+ const selectVal = computed<string>(() => {
91
+ const findFontItem = props.config.options!.find((item: string | number | ButtonOptionsItemType) => {
92
+ if (DapCommon.isObject(item)) {
93
+ return queryTextStyle(editor.value, dataRangeCaches.value, 'font-size', (item as ButtonOptionsItemType).value as string)
94
+ }
95
+ return queryTextStyle(editor.value, dataRangeCaches.value, 'font-size', item as string)
96
+ })
97
+ return findFontItem ? (DapCommon.isObject(findFontItem) ? ((findFontItem as ButtonOptionsItemType).value as string) : (findFontItem as string)) : (props.config.defaultValue as string)
98
+ })
99
+
100
+ return () => {
101
+ return props.config.show
102
+ ? h(Button, {
103
+ name: FEATURE_NAME,
104
+ tooltip: props.tooltip,
105
+ color: props.color,
106
+ zIndex: props.zIndex,
107
+ type: 'display',
108
+ displayConfig: {
109
+ options: props.config.options,
110
+ value: selectVal.value,
111
+ width: props.config.width,
112
+ maxHeight: props.config.maxHeight
113
+ },
114
+ title: $editTrans('fontSize'),
115
+ leftBorder: props.config.leftBorder,
116
+ rightBorder: props.config.rightBorder,
117
+ disabled: props.disabled || isSourceView.value || hasPreInRange(editor.value, dataRangeCaches.value) || props.config.disabled,
118
+ active: false,
119
+ onOperate: (_name, val) => {
120
+ setTextStyle(editor.value, dataRangeCaches.value, {
121
+ 'font-size': val
122
+ })
123
+ editor.value.domRender()
124
+ editor.value.rangeRender()
125
+ }
126
+ })
127
+ : null
128
+ }
129
+ },
130
+ {
131
+ name: `_${FEATURE_NAME}`,
132
+ props: {
133
+ color: String,
134
+ zIndex: Number,
135
+ config: Object as PropType<MenuDisplayButtonType>,
136
+ tooltip: Boolean,
137
+ disabled: Boolean
138
+ }
139
+ }
140
+ )
@@ -0,0 +1,171 @@
1
+ import { computed, defineComponent, h, inject, PropType, Ref, ref } from 'vue'
2
+ import { AlexElementsRangeType, AlexEditor } from 'alex-editor'
3
+ import { common as DapCommon } from 'dap-util'
4
+ import { MenuSelectButtonType } from '@/core/tool'
5
+ import { hasPreInRange, queryTextStyle, setTextStyle } from '@/core/function'
6
+ import { Button, ButtonOptionsItemType } from '@/components/button'
7
+ import { Icon } from '@/components/icon'
8
+ import { Colors } from '@/components/colors'
9
+
10
+ /**
11
+ * feature名称
12
+ */
13
+ const FEATURE_NAME = 'foreColor'
14
+
15
+ /**
16
+ * 工具栏 - 前景色
17
+ */
18
+ export const ForeColorToolbarButton = defineComponent(
19
+ (props, { expose }) => {
20
+ const editor = inject<Ref<AlexEditor>>('editor')!
21
+ const dataRangeCaches = inject<Ref<AlexElementsRangeType>>('dataRangeCaches')!
22
+ const $editTrans = inject<(key: string) => any>('$editTrans')!
23
+
24
+ const btnRef = ref<InstanceType<typeof Button> | null>(null)
25
+
26
+ const selectVal = computed<string>(() => {
27
+ const findForeColorItem = props.config.options!.find((item: string | number | ButtonOptionsItemType) => {
28
+ if (DapCommon.isObject(item)) {
29
+ return queryTextStyle(editor.value, dataRangeCaches.value, 'color', (item as ButtonOptionsItemType).value)
30
+ }
31
+ return queryTextStyle(editor.value, dataRangeCaches.value, 'color', item as string | number)
32
+ })
33
+ return findForeColorItem ? (DapCommon.isObject(findForeColorItem) ? ((findForeColorItem as ButtonOptionsItemType).value as string) : (findForeColorItem as string)) : ''
34
+ })
35
+
36
+ expose({
37
+ btnRef
38
+ })
39
+
40
+ return () => {
41
+ return props.config.show
42
+ ? h(
43
+ Button,
44
+ {
45
+ ref: btnRef,
46
+ name: FEATURE_NAME,
47
+ type: 'select',
48
+ title: $editTrans('foreColor'),
49
+ tooltip: props.tooltip,
50
+ color: props.color,
51
+ zIndex: props.zIndex,
52
+ leftBorder: props.config.leftBorder,
53
+ rightBorder: props.config.rightBorder,
54
+ active: false,
55
+ disabled: props.config.disabled,
56
+ selectConfig: {
57
+ options: props.config.options
58
+ },
59
+ hideScroll: true
60
+ },
61
+ {
62
+ default: () => h(Icon, { value: 'font-color' }),
63
+ layer: ({ options }: { options: ButtonOptionsItemType[] }) => {
64
+ return h(Colors, {
65
+ tooltip: props.tooltip,
66
+ color: props.color,
67
+ value: selectVal.value,
68
+ data: options,
69
+ onChange: (val: string) => {
70
+ setTextStyle(editor.value, dataRangeCaches.value, {
71
+ color: val
72
+ })
73
+ btnRef.value!.show = false
74
+ editor.value.domRender()
75
+ editor.value.rangeRender()
76
+ }
77
+ })
78
+ }
79
+ }
80
+ )
81
+ : null
82
+ }
83
+ },
84
+ {
85
+ name: `_${FEATURE_NAME}`,
86
+ props: {
87
+ color: String,
88
+ zIndex: Number,
89
+ config: Object as PropType<MenuSelectButtonType>,
90
+ tooltip: Boolean
91
+ }
92
+ }
93
+ )
94
+
95
+ /**
96
+ * 菜单栏 - 前景色
97
+ */
98
+ export const ForeColorMenuButton = defineComponent(
99
+ props => {
100
+ const editor = inject<Ref<AlexEditor>>('editor')!
101
+ const dataRangeCaches = inject<Ref<AlexElementsRangeType>>('dataRangeCaches')!
102
+ const $editTrans = inject<(key: string) => any>('$editTrans')!
103
+ const isSourceView = inject<Ref<boolean>>('isSourceView')!
104
+
105
+ const btnRef = ref<InstanceType<typeof Button> | null>(null)
106
+
107
+ const selectVal = computed<string>(() => {
108
+ const findForeColorItem = props.config.options!.find((item: string | number | ButtonOptionsItemType) => {
109
+ if (DapCommon.isObject(item)) {
110
+ return queryTextStyle(editor.value, dataRangeCaches.value, 'color', (item as ButtonOptionsItemType).value)
111
+ }
112
+ return queryTextStyle(editor.value, dataRangeCaches.value, 'color', <string>item)
113
+ })
114
+ return findForeColorItem ? (DapCommon.isObject(findForeColorItem) ? ((findForeColorItem as ButtonOptionsItemType).value as string) : (findForeColorItem as string)) : ''
115
+ })
116
+
117
+ return () => {
118
+ return props.config.show
119
+ ? h(
120
+ Button,
121
+ {
122
+ ref: btnRef,
123
+ name: FEATURE_NAME,
124
+ tooltip: props.tooltip,
125
+ color: props.color,
126
+ zIndex: props.zIndex,
127
+ type: 'select',
128
+ selectConfig: {
129
+ options: props.config.options
130
+ },
131
+ hideScroll: true,
132
+ title: $editTrans('foreColor'),
133
+ leftBorder: props.config.leftBorder,
134
+ rightBorder: props.config.rightBorder,
135
+ disabled: props.disabled || isSourceView.value || hasPreInRange(editor.value, dataRangeCaches.value) || props.config.disabled,
136
+ active: false
137
+ },
138
+ {
139
+ default: () => h(Icon, { value: 'font-color' }),
140
+ layer: ({ options }: { options: ButtonOptionsItemType[] }) => {
141
+ return h(Colors, {
142
+ tooltip: props.tooltip,
143
+ color: props.color,
144
+ value: selectVal.value,
145
+ data: options,
146
+ onChange: (val: string) => {
147
+ setTextStyle(editor.value, dataRangeCaches.value, {
148
+ color: val
149
+ })
150
+ editor.value.domRender()
151
+ editor.value.rangeRender()
152
+ btnRef.value!.show = false
153
+ }
154
+ })
155
+ }
156
+ }
157
+ )
158
+ : null
159
+ }
160
+ },
161
+ {
162
+ name: `_${FEATURE_NAME}`,
163
+ props: {
164
+ color: String,
165
+ zIndex: Number,
166
+ config: Object as PropType<MenuSelectButtonType>,
167
+ tooltip: Boolean,
168
+ disabled: Boolean
169
+ }
170
+ }
171
+ )
@@ -0,0 +1,116 @@
1
+ import { defineComponent, h, inject, PropType, Ref, ref } from 'vue'
2
+ import { AlexElementsRangeType, AlexEditor } from 'alex-editor'
3
+ import { MenuButtonType } from '@/core/tool'
4
+ import { hasPreInRange, removeTextMark, removeTextStyle } from '@/core/function'
5
+ import { Button } from '@/components/button'
6
+ import { Icon } from '@/components/icon'
7
+
8
+ /**
9
+ * feature名称
10
+ */
11
+ const FEATURE_NAME = 'formatClear'
12
+
13
+ /**
14
+ * 工具栏 - 清除样式
15
+ */
16
+ export const FormatClearToolbarButton = defineComponent(
17
+ (props, { expose }) => {
18
+ const editor = inject<Ref<AlexEditor>>('editor')!
19
+ const dataRangeCaches = inject<Ref<AlexElementsRangeType>>('dataRangeCaches')!
20
+ const $editTrans = inject<(key: string) => any>('$editTrans')!
21
+
22
+ const btnRef = ref<InstanceType<typeof Button> | null>(null)
23
+
24
+ expose({
25
+ btnRef
26
+ })
27
+
28
+ return () => {
29
+ return props.config.show
30
+ ? h(
31
+ Button,
32
+ {
33
+ ref: btnRef,
34
+ name: FEATURE_NAME,
35
+ title: $editTrans('formatClear'),
36
+ tooltip: props.tooltip,
37
+ color: props.color,
38
+ zIndex: props.zIndex,
39
+ leftBorder: props.config.leftBorder,
40
+ rightBorder: props.config.rightBorder,
41
+ active: false,
42
+ disabled: props.config.disabled,
43
+ onOperate: () => {
44
+ removeTextStyle(editor.value, dataRangeCaches.value)
45
+ removeTextMark(editor.value, dataRangeCaches.value)
46
+ editor.value.domRender()
47
+ editor.value.rangeRender()
48
+ }
49
+ },
50
+ {
51
+ default: () => h(Icon, { value: 'format-clear' })
52
+ }
53
+ )
54
+ : null
55
+ }
56
+ },
57
+ {
58
+ name: `_${FEATURE_NAME}`,
59
+ props: {
60
+ color: String,
61
+ zIndex: Number,
62
+ config: Object as PropType<MenuButtonType>,
63
+ tooltip: Boolean
64
+ }
65
+ }
66
+ )
67
+
68
+ /**
69
+ * 菜单栏 - 清除样式
70
+ */
71
+ export const FormatClearMenuButton = defineComponent(
72
+ props => {
73
+ const editor = inject<Ref<AlexEditor>>('editor')!
74
+ const dataRangeCaches = inject<Ref<AlexElementsRangeType>>('dataRangeCaches')!
75
+ const $editTrans = inject<(key: string) => any>('$editTrans')!
76
+ const isSourceView = inject<Ref<boolean>>('isSourceView')!
77
+
78
+ return () => {
79
+ return props.config.show
80
+ ? h(
81
+ Button,
82
+ {
83
+ name: FEATURE_NAME,
84
+ tooltip: props.tooltip,
85
+ color: props.color,
86
+ zIndex: props.zIndex,
87
+ title: $editTrans('formatClear'),
88
+ leftBorder: props.config.leftBorder,
89
+ rightBorder: props.config.rightBorder,
90
+ active: false,
91
+ disabled: props.disabled || isSourceView.value || hasPreInRange(editor.value, dataRangeCaches.value) || props.config.disabled,
92
+ onOperate: () => {
93
+ removeTextStyle(editor.value, dataRangeCaches.value)
94
+ removeTextMark(editor.value, dataRangeCaches.value)
95
+ editor.value.domRender()
96
+ editor.value.rangeRender()
97
+ }
98
+ },
99
+ {
100
+ default: () => h(Icon, { value: 'format-clear' })
101
+ }
102
+ )
103
+ : null
104
+ }
105
+ },
106
+ {
107
+ name: `_${FEATURE_NAME}`,
108
+ props: {
109
+ color: String,
110
+ zIndex: Number,
111
+ config: Object as PropType<MenuButtonType>,
112
+ tooltip: Boolean,
113
+ disabled: Boolean
114
+ }
115
+ }
116
+ )
@@ -0,0 +1,57 @@
1
+ import { defineComponent, h, inject, PropType, Ref } from 'vue'
2
+ import { AlexEditor } from 'alex-editor'
3
+ import { Button } from '@/components/button'
4
+ import { MenuButtonType } from '@/core/tool'
5
+ import { Icon } from '@/components/icon'
6
+
7
+ /**
8
+ * feature名称
9
+ */
10
+ const FEATURE_NAME = 'fullScreen'
11
+
12
+ /**
13
+ * 菜单栏 - 全屏
14
+ */
15
+ export const FullScreenMenuButton = defineComponent(
16
+ props => {
17
+ const editor = inject<Ref<AlexEditor>>('editor')!
18
+ const $editTrans = inject<(key: string) => any>('$editTrans')!
19
+ const isFullScreen = inject<Ref<boolean>>('isFullScreen')!
20
+
21
+ return () => {
22
+ return props.config.show
23
+ ? h(
24
+ Button,
25
+ {
26
+ name: FEATURE_NAME,
27
+ tooltip: props.tooltip,
28
+ color: props.color,
29
+ zIndex: props.zIndex,
30
+ title: $editTrans('fullScreen'),
31
+ leftBorder: props.config.leftBorder,
32
+ rightBorder: props.config.rightBorder,
33
+ active: isFullScreen.value,
34
+ disabled: props.disabled || props.config.disabled,
35
+ onOperate: () => {
36
+ isFullScreen.value = !isFullScreen.value
37
+ editor.value.rangeRender()
38
+ }
39
+ },
40
+ {
41
+ default: () => h(Icon, { value: 'full-screen' })
42
+ }
43
+ )
44
+ : null
45
+ }
46
+ },
47
+ {
48
+ name: `_${FEATURE_NAME}`,
49
+ props: {
50
+ color: String,
51
+ zIndex: Number,
52
+ config: Object as PropType<MenuButtonType>,
53
+ tooltip: Boolean,
54
+ disabled: Boolean
55
+ }
56
+ }
57
+ )