vue-editify 0.2.14 → 0.2.15
Sign up to get free protection for your applications and to get access to all the features.
- package/examples/App.vue +49 -67
- package/lib/components/button/button.vue.d.ts +62 -60
- package/lib/components/button/index.d.ts +4 -0
- package/lib/components/button/props.d.ts +12 -1
- package/lib/components/checkbox/checkbox.vue.d.ts +9 -9
- package/lib/components/checkbox/index.d.ts +4 -0
- package/lib/components/checkbox/props.d.ts +2 -2
- package/lib/components/colors/colors.vue.d.ts +4 -4
- package/lib/components/colors/index.d.ts +4 -0
- package/lib/components/colors/props.d.ts +2 -2
- package/lib/components/icon/index.d.ts +4 -0
- package/lib/components/insertAttachment/index.d.ts +4 -0
- package/lib/{plugins/attachment → components}/insertAttachment/insertAttachment.vue.d.ts +3 -3
- package/lib/{plugins/attachment → components}/insertAttachment/props.d.ts +1 -1
- package/lib/components/insertImage/index.d.ts +4 -0
- package/lib/components/insertImage/insertImage.vue.d.ts +3 -3
- package/lib/components/insertImage/props.d.ts +1 -1
- package/lib/components/insertLink/index.d.ts +4 -0
- package/lib/components/insertLink/insertLink.vue.d.ts +6 -6
- package/lib/components/insertLink/props.d.ts +3 -3
- package/lib/components/insertMathformula/index.d.ts +4 -0
- package/lib/{plugins/mathformula → components}/insertMathformula/insertMathformula.vue.d.ts +3 -3
- package/lib/{plugins/mathformula → components}/insertMathformula/props.d.ts +2 -2
- package/lib/components/insertTable/index.d.ts +4 -0
- package/lib/components/insertTable/insertTable.vue.d.ts +3 -3
- package/lib/components/insertTable/props.d.ts +2 -2
- package/lib/components/insertVideo/index.d.ts +4 -0
- package/lib/components/insertVideo/insertVideo.vue.d.ts +3 -3
- package/lib/components/insertVideo/props.d.ts +1 -1
- package/lib/components/layer/index.d.ts +4 -0
- package/lib/components/layer/layer.vue.d.ts +10 -8
- package/lib/components/tooltip/index.d.ts +4 -0
- package/lib/components/tooltip/tooltip.vue.d.ts +6 -4
- package/lib/components/triangle/index.d.ts +4 -0
- package/lib/components/triangle/triangle.vue.d.ts +1 -1
- package/lib/components/updateLink/index.d.ts +4 -0
- package/lib/components/updateLink/props.d.ts +17 -0
- package/lib/components/updateLink/updateLink.vue.d.ts +38 -0
- package/lib/core/function.d.ts +113 -36
- package/lib/core/rule.d.ts +20 -0
- package/lib/core/tool.d.ts +36 -34
- package/lib/editify/editify.vue.d.ts +18 -27
- package/lib/editify/menu/index.d.ts +4 -0
- package/lib/{components → editify}/menu/menu.vue.d.ts +3 -4
- package/lib/{components → editify}/menu/props.d.ts +1 -1
- package/lib/editify/props.d.ts +3 -7
- package/lib/editify/toolbar/index.d.ts +4 -0
- package/lib/{components → editify}/toolbar/props.d.ts +2 -2
- package/lib/{components → editify}/toolbar/toolbar.vue.d.ts +53 -53
- package/lib/editify.es.js +8797 -7560
- package/lib/editify.umd.js +2 -2
- package/lib/feature/align.d.ts +32 -0
- package/lib/feature/attachment.d.ts +18 -0
- package/lib/feature/backColor.d.ts +32 -0
- package/lib/feature/bold.d.ts +32 -0
- package/lib/feature/code.d.ts +32 -0
- package/lib/feature/codeBlock.d.ts +32 -0
- package/lib/feature/fontFamily.d.ts +32 -0
- package/lib/feature/fontSize.d.ts +32 -0
- package/lib/feature/foreColor.d.ts +32 -0
- package/lib/feature/formatClear.d.ts +32 -0
- package/lib/feature/fullScreen.d.ts +18 -0
- package/lib/feature/heading.d.ts +32 -0
- package/lib/feature/image.d.ts +32 -0
- package/lib/feature/indent.d.ts +18 -0
- package/lib/feature/infoBlock.d.ts +18 -0
- package/lib/feature/italic.d.ts +32 -0
- package/lib/feature/lineHeight.d.ts +32 -0
- package/lib/feature/link.d.ts +26 -0
- package/lib/feature/mathformula.d.ts +22 -0
- package/lib/feature/orderList.d.ts +32 -0
- package/lib/feature/panel.d.ts +18 -0
- package/lib/feature/quote.d.ts +18 -0
- package/lib/feature/redo.d.ts +18 -0
- package/lib/feature/separator.d.ts +18 -0
- package/lib/feature/sourceView.d.ts +18 -0
- package/lib/feature/strikethrough.d.ts +32 -0
- package/lib/feature/sub.d.ts +32 -0
- package/lib/feature/super.d.ts +32 -0
- package/lib/feature/table.d.ts +32 -0
- package/lib/feature/task.d.ts +32 -0
- package/lib/feature/underline.d.ts +32 -0
- package/lib/feature/undo.d.ts +18 -0
- package/lib/feature/unorderList.d.ts +32 -0
- package/lib/feature/video.d.ts +38 -0
- package/lib/index.d.ts +36 -43
- package/package.json +5 -5
- package/src/components/button/button.vue +21 -24
- package/src/components/button/index.ts +5 -0
- package/src/components/button/props.ts +14 -1
- package/src/components/checkbox/checkbox.vue +1 -1
- package/src/components/checkbox/index.ts +5 -0
- package/src/components/checkbox/props.ts +1 -1
- package/src/components/colors/colors.vue +3 -3
- package/src/components/colors/index.ts +5 -0
- package/src/components/colors/props.ts +2 -2
- package/src/components/icon/index.ts +5 -0
- package/src/components/insertAttachment/index.ts +5 -0
- package/src/{plugins/attachment → components}/insertAttachment/insertAttachment.vue +4 -2
- package/src/{plugins/attachment → components}/insertAttachment/props.ts +1 -1
- package/src/components/insertImage/index.ts +5 -0
- package/src/components/insertImage/insertImage.vue +5 -5
- package/src/components/insertImage/props.ts +1 -1
- package/src/components/insertLink/index.ts +5 -0
- package/src/components/insertLink/insertLink.vue +10 -10
- package/src/components/insertLink/props.ts +3 -3
- package/src/components/insertMathformula/index.ts +5 -0
- package/src/{plugins/mathformula → components}/insertMathformula/props.ts +2 -2
- package/src/components/insertTable/index.ts +5 -0
- package/src/components/insertTable/props.ts +2 -2
- package/src/components/insertVideo/index.ts +5 -0
- package/src/components/insertVideo/insertVideo.vue +2 -2
- package/src/components/insertVideo/props.ts +1 -1
- package/src/components/layer/index.ts +5 -0
- package/src/components/layer/layer.vue +42 -4
- package/src/components/tooltip/index.ts +5 -0
- package/src/components/tooltip/tooltip.vue +1 -1
- package/src/components/triangle/index.ts +5 -0
- package/src/components/triangle/triangle.vue +1 -1
- package/src/components/updateLink/index.ts +5 -0
- package/src/components/updateLink/props.ts +21 -0
- package/src/components/{toolbar/toolbar.less → updateLink/updateLink.less} +4 -20
- package/src/components/updateLink/updateLink.vue +74 -0
- package/src/core/function.ts +289 -97
- package/src/core/rule.ts +96 -7
- package/src/core/tool.ts +234 -78
- package/src/editify/editify.less +2 -0
- package/src/editify/editify.vue +182 -185
- package/src/editify/menu/index.ts +5 -0
- package/src/editify/menu/menu.vue +215 -0
- package/src/{components → editify}/menu/props.ts +1 -1
- package/src/editify/props.ts +7 -11
- package/src/editify/toolbar/index.ts +5 -0
- package/src/{components → editify}/toolbar/props.ts +1 -1
- package/src/editify/toolbar/toolbar.less +10 -0
- package/src/editify/toolbar/toolbar.vue +103 -0
- package/src/feature/align.ts +128 -0
- package/src/feature/attachment.ts +109 -0
- package/src/feature/backColor.ts +171 -0
- package/src/feature/bold.ts +136 -0
- package/src/feature/code.ts +136 -0
- package/src/feature/codeBlock.ts +204 -0
- package/src/feature/fontFamily.ts +140 -0
- package/src/feature/fontSize.ts +142 -0
- package/src/feature/foreColor.ts +173 -0
- package/src/feature/formatClear.ts +118 -0
- package/src/feature/fullScreen.ts +57 -0
- package/src/feature/heading.ts +154 -0
- package/src/feature/image.ts +225 -0
- package/src/feature/indent.ts +73 -0
- package/src/feature/infoBlock.ts +94 -0
- package/src/feature/italic.ts +136 -0
- package/src/feature/lineHeight.ts +165 -0
- package/src/feature/link.ts +149 -0
- package/src/feature/mathformula.ts +147 -0
- package/src/feature/orderList.ts +116 -0
- package/src/feature/panel.ts +108 -0
- package/src/feature/quote.ts +61 -0
- package/src/feature/redo.ts +56 -0
- package/src/feature/separator.ts +62 -0
- package/src/feature/sourceView.ts +59 -0
- package/src/feature/strikethrough.ts +136 -0
- package/src/feature/sub.ts +136 -0
- package/src/feature/super.ts +136 -0
- package/src/feature/table.ts +994 -0
- package/src/feature/task.ts +116 -0
- package/src/feature/underline.ts +136 -0
- package/src/feature/undo.ts +56 -0
- package/src/feature/unorderList.ts +116 -0
- package/src/feature/video.ts +339 -0
- package/src/hljs/index.ts +1 -1
- package/src/index.ts +69 -21
- package/src/locale/en_US.ts +3 -3
- package/src/locale/zh_CN.ts +3 -3
- package/lib/plugins/attachment/index.d.ts +0 -37
- package/lib/plugins/infoBlock/index.d.ts +0 -55
- package/lib/plugins/mathformula/index.d.ts +0 -49
- package/lib/plugins/panel/index.d.ts +0 -48
- package/src/components/menu/menu.vue +0 -1655
- package/src/components/toolbar/toolbar.vue +0 -1677
- package/src/plugins/attachment/index.ts +0 -237
- package/src/plugins/infoBlock/index.ts +0 -238
- package/src/plugins/mathformula/index.ts +0 -295
- package/src/plugins/panel/index.ts +0 -228
- package/tsconfig.json +0 -31
- package/tsconfig.node.json +0 -11
- /package/src/{plugins/attachment → components}/insertAttachment/insertAttachment.less +0 -0
- /package/src/{plugins/mathformula → components}/insertMathformula/insertMathformula.less +0 -0
- /package/src/{plugins/mathformula → components}/insertMathformula/insertMathformula.vue +0 -0
- /package/src/{components → editify}/menu/menu.less +0 -0
@@ -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 = '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.formatElementStack()
|
61
|
+
editor.value.domRender()
|
62
|
+
editor.value.rangeRender()
|
63
|
+
}
|
64
|
+
})
|
65
|
+
: null
|
66
|
+
}
|
67
|
+
},
|
68
|
+
{
|
69
|
+
name: `_${FEATURE_NAME}`,
|
70
|
+
props: {
|
71
|
+
color: String,
|
72
|
+
zIndex: Number,
|
73
|
+
config: Object as PropType<MenuDisplayButtonType>,
|
74
|
+
tooltip: Boolean
|
75
|
+
}
|
76
|
+
}
|
77
|
+
)
|
78
|
+
|
79
|
+
/**
|
80
|
+
* 菜单栏 - 字体
|
81
|
+
*/
|
82
|
+
export const FontFamilyMenuButton = defineComponent(
|
83
|
+
props => {
|
84
|
+
const editor = inject<Ref<AlexEditor>>('editor')!
|
85
|
+
const dataRangeCaches = inject<Ref<AlexElementsRangeType>>('dataRangeCaches')!
|
86
|
+
const $editTrans = inject<(key: string) => any>('$editTrans')!
|
87
|
+
const isSourceView = inject<Ref<boolean>>('isSourceView')!
|
88
|
+
|
89
|
+
const selectVal = computed<string>(() => {
|
90
|
+
const findFamilyItem = props.config.options!.find((item: string | number | ButtonOptionsItemType) => {
|
91
|
+
if (DapCommon.isObject(item)) {
|
92
|
+
return queryTextStyle(editor.value, dataRangeCaches.value, 'font-family', (item as ButtonOptionsItemType).value)
|
93
|
+
}
|
94
|
+
return queryTextStyle(editor.value, dataRangeCaches.value, 'font-family', item as string)
|
95
|
+
})
|
96
|
+
return findFamilyItem ? (DapCommon.isObject(findFamilyItem) ? ((findFamilyItem as ButtonOptionsItemType).value as string) : (findFamilyItem as string)) : (props.config.defaultValue as string)
|
97
|
+
})
|
98
|
+
|
99
|
+
return () => {
|
100
|
+
return props.config.show
|
101
|
+
? h(Button, {
|
102
|
+
name: FEATURE_NAME,
|
103
|
+
tooltip: props.tooltip,
|
104
|
+
color: props.color,
|
105
|
+
zIndex: props.zIndex,
|
106
|
+
type: 'display',
|
107
|
+
displayConfig: {
|
108
|
+
options: props.config.options,
|
109
|
+
value: selectVal.value,
|
110
|
+
width: props.config.width,
|
111
|
+
maxHeight: props.config.maxHeight
|
112
|
+
},
|
113
|
+
title: $editTrans('fontFamily'),
|
114
|
+
leftBorder: props.config.leftBorder,
|
115
|
+
rightBorder: props.config.rightBorder,
|
116
|
+
active: false,
|
117
|
+
disabled: props.disabled || isSourceView.value || hasPreInRange(editor.value, dataRangeCaches.value) || props.config.disabled,
|
118
|
+
onOperate: (_name, val) => {
|
119
|
+
setTextStyle(editor.value, dataRangeCaches.value, {
|
120
|
+
'font-family': val
|
121
|
+
})
|
122
|
+
editor.value.formatElementStack()
|
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,142 @@
|
|
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.formatElementStack()
|
63
|
+
editor.value.domRender()
|
64
|
+
editor.value.rangeRender()
|
65
|
+
}
|
66
|
+
})
|
67
|
+
: null
|
68
|
+
}
|
69
|
+
},
|
70
|
+
{
|
71
|
+
name: `_${FEATURE_NAME}`,
|
72
|
+
props: {
|
73
|
+
color: String,
|
74
|
+
zIndex: Number,
|
75
|
+
config: Object as PropType<MenuDisplayButtonType>,
|
76
|
+
tooltip: Boolean
|
77
|
+
}
|
78
|
+
}
|
79
|
+
)
|
80
|
+
|
81
|
+
/**
|
82
|
+
* 菜单栏 - 字号
|
83
|
+
*/
|
84
|
+
export const FontSizeMenuButton = defineComponent(
|
85
|
+
props => {
|
86
|
+
const editor = inject<Ref<AlexEditor>>('editor')!
|
87
|
+
const dataRangeCaches = inject<Ref<AlexElementsRangeType>>('dataRangeCaches')!
|
88
|
+
const $editTrans = inject<(key: string) => any>('$editTrans')!
|
89
|
+
const isSourceView = inject<Ref<boolean>>('isSourceView')!
|
90
|
+
|
91
|
+
const selectVal = computed<string>(() => {
|
92
|
+
const findFontItem = props.config.options!.find((item: string | number | ButtonOptionsItemType) => {
|
93
|
+
if (DapCommon.isObject(item)) {
|
94
|
+
return queryTextStyle(editor.value, dataRangeCaches.value, 'font-size', (item as ButtonOptionsItemType).value as string)
|
95
|
+
}
|
96
|
+
return queryTextStyle(editor.value, dataRangeCaches.value, 'font-size', item as string)
|
97
|
+
})
|
98
|
+
return findFontItem ? (DapCommon.isObject(findFontItem) ? ((findFontItem as ButtonOptionsItemType).value as string) : (findFontItem as string)) : (props.config.defaultValue as string)
|
99
|
+
})
|
100
|
+
|
101
|
+
return () => {
|
102
|
+
return props.config.show
|
103
|
+
? h(Button, {
|
104
|
+
name: FEATURE_NAME,
|
105
|
+
tooltip: props.tooltip,
|
106
|
+
color: props.color,
|
107
|
+
zIndex: props.zIndex,
|
108
|
+
type: 'display',
|
109
|
+
displayConfig: {
|
110
|
+
options: props.config.options,
|
111
|
+
value: selectVal.value,
|
112
|
+
width: props.config.width,
|
113
|
+
maxHeight: props.config.maxHeight
|
114
|
+
},
|
115
|
+
title: $editTrans('fontSize'),
|
116
|
+
leftBorder: props.config.leftBorder,
|
117
|
+
rightBorder: props.config.rightBorder,
|
118
|
+
disabled: props.disabled || isSourceView.value || hasPreInRange(editor.value, dataRangeCaches.value) || props.config.disabled,
|
119
|
+
active: false,
|
120
|
+
onOperate: (_name, val) => {
|
121
|
+
setTextStyle(editor.value, dataRangeCaches.value, {
|
122
|
+
'font-size': val
|
123
|
+
})
|
124
|
+
editor.value.formatElementStack()
|
125
|
+
editor.value.domRender()
|
126
|
+
editor.value.rangeRender()
|
127
|
+
}
|
128
|
+
})
|
129
|
+
: null
|
130
|
+
}
|
131
|
+
},
|
132
|
+
{
|
133
|
+
name: `_${FEATURE_NAME}`,
|
134
|
+
props: {
|
135
|
+
color: String,
|
136
|
+
zIndex: Number,
|
137
|
+
config: Object as PropType<MenuDisplayButtonType>,
|
138
|
+
tooltip: Boolean,
|
139
|
+
disabled: Boolean
|
140
|
+
}
|
141
|
+
}
|
142
|
+
)
|
@@ -0,0 +1,173 @@
|
|
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.formatElementStack()
|
75
|
+
editor.value.domRender()
|
76
|
+
editor.value.rangeRender()
|
77
|
+
}
|
78
|
+
})
|
79
|
+
}
|
80
|
+
}
|
81
|
+
)
|
82
|
+
: null
|
83
|
+
}
|
84
|
+
},
|
85
|
+
{
|
86
|
+
name: `_${FEATURE_NAME}`,
|
87
|
+
props: {
|
88
|
+
color: String,
|
89
|
+
zIndex: Number,
|
90
|
+
config: Object as PropType<MenuSelectButtonType>,
|
91
|
+
tooltip: Boolean
|
92
|
+
}
|
93
|
+
}
|
94
|
+
)
|
95
|
+
|
96
|
+
/**
|
97
|
+
* 菜单栏 - 前景色
|
98
|
+
*/
|
99
|
+
export const ForeColorMenuButton = defineComponent(
|
100
|
+
props => {
|
101
|
+
const editor = inject<Ref<AlexEditor>>('editor')!
|
102
|
+
const dataRangeCaches = inject<Ref<AlexElementsRangeType>>('dataRangeCaches')!
|
103
|
+
const $editTrans = inject<(key: string) => any>('$editTrans')!
|
104
|
+
const isSourceView = inject<Ref<boolean>>('isSourceView')!
|
105
|
+
|
106
|
+
const btnRef = ref<InstanceType<typeof Button> | null>(null)
|
107
|
+
|
108
|
+
const selectVal = computed<string>(() => {
|
109
|
+
const findForeColorItem = props.config.options!.find((item: string | number | ButtonOptionsItemType) => {
|
110
|
+
if (DapCommon.isObject(item)) {
|
111
|
+
return queryTextStyle(editor.value, dataRangeCaches.value, 'color', (item as ButtonOptionsItemType).value)
|
112
|
+
}
|
113
|
+
return queryTextStyle(editor.value, dataRangeCaches.value, 'color', <string>item)
|
114
|
+
})
|
115
|
+
return findForeColorItem ? (DapCommon.isObject(findForeColorItem) ? ((findForeColorItem as ButtonOptionsItemType).value as string) : (findForeColorItem as string)) : ''
|
116
|
+
})
|
117
|
+
|
118
|
+
return () => {
|
119
|
+
return props.config.show
|
120
|
+
? h(
|
121
|
+
Button,
|
122
|
+
{
|
123
|
+
ref: btnRef,
|
124
|
+
name: FEATURE_NAME,
|
125
|
+
tooltip: props.tooltip,
|
126
|
+
color: props.color,
|
127
|
+
zIndex: props.zIndex,
|
128
|
+
type: 'select',
|
129
|
+
selectConfig: {
|
130
|
+
options: props.config.options
|
131
|
+
},
|
132
|
+
hideScroll: true,
|
133
|
+
title: $editTrans('foreColor'),
|
134
|
+
leftBorder: props.config.leftBorder,
|
135
|
+
rightBorder: props.config.rightBorder,
|
136
|
+
disabled: props.disabled || isSourceView.value || hasPreInRange(editor.value, dataRangeCaches.value) || props.config.disabled,
|
137
|
+
active: false
|
138
|
+
},
|
139
|
+
{
|
140
|
+
default: () => h(Icon, { value: 'font-color' }),
|
141
|
+
layer: ({ options }: { options: ButtonOptionsItemType[] }) => {
|
142
|
+
return h(Colors, {
|
143
|
+
tooltip: props.tooltip,
|
144
|
+
color: props.color,
|
145
|
+
value: selectVal.value,
|
146
|
+
data: options,
|
147
|
+
onChange: (val: string) => {
|
148
|
+
setTextStyle(editor.value, dataRangeCaches.value, {
|
149
|
+
color: val
|
150
|
+
})
|
151
|
+
editor.value.formatElementStack()
|
152
|
+
editor.value.domRender()
|
153
|
+
editor.value.rangeRender()
|
154
|
+
btnRef.value!.show = false
|
155
|
+
}
|
156
|
+
})
|
157
|
+
}
|
158
|
+
}
|
159
|
+
)
|
160
|
+
: null
|
161
|
+
}
|
162
|
+
},
|
163
|
+
{
|
164
|
+
name: `_${FEATURE_NAME}`,
|
165
|
+
props: {
|
166
|
+
color: String,
|
167
|
+
zIndex: Number,
|
168
|
+
config: Object as PropType<MenuSelectButtonType>,
|
169
|
+
tooltip: Boolean,
|
170
|
+
disabled: Boolean
|
171
|
+
}
|
172
|
+
}
|
173
|
+
)
|
@@ -0,0 +1,118 @@
|
|
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.formatElementStack()
|
47
|
+
editor.value.domRender()
|
48
|
+
editor.value.rangeRender()
|
49
|
+
}
|
50
|
+
},
|
51
|
+
{
|
52
|
+
default: () => h(Icon, { value: 'format-clear' })
|
53
|
+
}
|
54
|
+
)
|
55
|
+
: null
|
56
|
+
}
|
57
|
+
},
|
58
|
+
{
|
59
|
+
name: `_${FEATURE_NAME}`,
|
60
|
+
props: {
|
61
|
+
color: String,
|
62
|
+
zIndex: Number,
|
63
|
+
config: Object as PropType<MenuButtonType>,
|
64
|
+
tooltip: Boolean
|
65
|
+
}
|
66
|
+
}
|
67
|
+
)
|
68
|
+
|
69
|
+
/**
|
70
|
+
* 菜单栏 - 清除样式
|
71
|
+
*/
|
72
|
+
export const FormatClearMenuButton = defineComponent(
|
73
|
+
props => {
|
74
|
+
const editor = inject<Ref<AlexEditor>>('editor')!
|
75
|
+
const dataRangeCaches = inject<Ref<AlexElementsRangeType>>('dataRangeCaches')!
|
76
|
+
const $editTrans = inject<(key: string) => any>('$editTrans')!
|
77
|
+
const isSourceView = inject<Ref<boolean>>('isSourceView')!
|
78
|
+
|
79
|
+
return () => {
|
80
|
+
return props.config.show
|
81
|
+
? h(
|
82
|
+
Button,
|
83
|
+
{
|
84
|
+
name: FEATURE_NAME,
|
85
|
+
tooltip: props.tooltip,
|
86
|
+
color: props.color,
|
87
|
+
zIndex: props.zIndex,
|
88
|
+
title: $editTrans('formatClear'),
|
89
|
+
leftBorder: props.config.leftBorder,
|
90
|
+
rightBorder: props.config.rightBorder,
|
91
|
+
active: false,
|
92
|
+
disabled: props.disabled || isSourceView.value || hasPreInRange(editor.value, dataRangeCaches.value) || props.config.disabled,
|
93
|
+
onOperate: () => {
|
94
|
+
removeTextStyle(editor.value, dataRangeCaches.value)
|
95
|
+
removeTextMark(editor.value, dataRangeCaches.value)
|
96
|
+
editor.value.formatElementStack()
|
97
|
+
editor.value.domRender()
|
98
|
+
editor.value.rangeRender()
|
99
|
+
}
|
100
|
+
},
|
101
|
+
{
|
102
|
+
default: () => h(Icon, { value: 'format-clear' })
|
103
|
+
}
|
104
|
+
)
|
105
|
+
: null
|
106
|
+
}
|
107
|
+
},
|
108
|
+
{
|
109
|
+
name: `_${FEATURE_NAME}`,
|
110
|
+
props: {
|
111
|
+
color: String,
|
112
|
+
zIndex: Number,
|
113
|
+
config: Object as PropType<MenuButtonType>,
|
114
|
+
tooltip: Boolean,
|
115
|
+
disabled: Boolean
|
116
|
+
}
|
117
|
+
}
|
118
|
+
)
|
@@ -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
|
+
)
|