vue-editify 0.1.10 → 0.1.13

Sign up to get free protection for your applications and to get access to all the features.
Files changed (113) hide show
  1. package/examples/App.vue +21 -96
  2. package/examples/main.ts +4 -0
  3. package/lib/components/button/button.vue.d.ts +143 -0
  4. package/lib/components/button/props.d.ts +73 -0
  5. package/lib/components/checkbox/checkbox.vue.d.ts +80 -0
  6. package/lib/components/checkbox/props.d.ts +36 -0
  7. package/lib/components/colors/colors.vue.d.ts +47 -0
  8. package/lib/components/colors/props.d.ts +22 -0
  9. package/lib/components/icon/icon.vue.d.ts +14 -0
  10. package/lib/components/icon/props.d.ts +9 -0
  11. package/lib/components/insertImage/insertImage.vue.d.ts +74 -0
  12. package/lib/components/insertImage/props.d.ts +34 -0
  13. package/lib/components/insertLink/insertLink.vue.d.ts +27 -0
  14. package/lib/components/insertLink/props.d.ts +13 -0
  15. package/lib/components/insertTable/insertTable.vue.d.ts +36 -0
  16. package/lib/components/insertTable/props.d.ts +22 -0
  17. package/lib/components/insertVideo/insertVideo.vue.d.ts +74 -0
  18. package/lib/components/insertVideo/props.d.ts +34 -0
  19. package/lib/components/layer/layer.vue.d.ts +129 -0
  20. package/lib/components/layer/props.d.ts +53 -0
  21. package/lib/components/menu/menu.vue.d.ts +25 -0
  22. package/lib/components/menu/props.d.ts +14 -0
  23. package/lib/components/toolbar/props.d.ts +27 -0
  24. package/lib/components/toolbar/toolbar.vue.d.ts +56 -0
  25. package/lib/components/tooltip/props.d.ts +17 -0
  26. package/lib/components/tooltip/tooltip.vue.d.ts +39 -0
  27. package/lib/components/triangle/props.d.ts +19 -0
  28. package/lib/components/triangle/triangle.vue.d.ts +34 -0
  29. package/lib/core/function.d.ts +45 -0
  30. package/lib/core/rule.d.ts +9 -0
  31. package/lib/core/tool.d.ts +185 -0
  32. package/lib/editify/editify.vue.d.ts +676 -0
  33. package/lib/editify/props.d.ts +110 -0
  34. package/lib/editify.es.js +5706 -5727
  35. package/lib/editify.umd.js +1 -1
  36. package/lib/hljs/index.d.ts +7 -0
  37. package/lib/index.d.ts +17 -0
  38. package/lib/locale/en_US.d.ts +3 -0
  39. package/lib/locale/index.d.ts +2 -0
  40. package/lib/locale/zh_CN.d.ts +3 -0
  41. package/lib/style.css +1 -1
  42. package/package.json +16 -8
  43. package/src/components/button/button.less +145 -0
  44. package/src/components/button/button.vue +197 -0
  45. package/src/components/button/props.ts +95 -0
  46. package/src/components/checkbox/checkbox.less +84 -0
  47. package/src/components/checkbox/checkbox.vue +68 -0
  48. package/src/components/checkbox/props.ts +49 -0
  49. package/src/components/colors/colors.less +75 -0
  50. package/src/components/colors/colors.vue +36 -0
  51. package/src/components/colors/props.ts +29 -0
  52. package/src/components/{base/Icon.vue → icon/icon.less} +0 -17
  53. package/src/components/icon/icon.vue +12 -0
  54. package/src/components/icon/props.ts +11 -0
  55. package/src/components/insertImage/insertImage.less +135 -0
  56. package/src/components/insertImage/insertImage.vue +146 -0
  57. package/src/components/insertImage/props.ts +43 -0
  58. package/src/components/insertLink/insertLink.less +64 -0
  59. package/src/components/insertLink/insertLink.vue +58 -0
  60. package/src/components/insertLink/props.ts +16 -0
  61. package/src/components/insertTable/insertTable.less +54 -0
  62. package/src/components/insertTable/insertTable.vue +85 -0
  63. package/src/components/insertTable/props.ts +27 -0
  64. package/src/components/insertVideo/insertVideo.less +135 -0
  65. package/src/components/insertVideo/insertVideo.vue +146 -0
  66. package/src/components/insertVideo/props.ts +43 -0
  67. package/src/components/layer/layer.less +49 -0
  68. package/src/components/layer/layer.vue +598 -0
  69. package/src/components/layer/props.ts +71 -0
  70. package/src/components/menu/menu.less +64 -0
  71. package/src/components/menu/menu.vue +1570 -0
  72. package/src/components/menu/props.ts +17 -0
  73. package/src/components/toolbar/props.ts +35 -0
  74. package/src/components/toolbar/toolbar.less +89 -0
  75. package/src/components/toolbar/toolbar.vue +1101 -0
  76. package/src/components/tooltip/props.ts +21 -0
  77. package/src/components/tooltip/tooltip.less +23 -0
  78. package/src/components/tooltip/tooltip.vue +37 -0
  79. package/src/components/triangle/props.ts +26 -0
  80. package/src/components/triangle/triangle.less +79 -0
  81. package/src/components/triangle/triangle.vue +65 -0
  82. package/src/core/function.ts +1144 -0
  83. package/src/core/{rule.js → rule.ts} +33 -33
  84. package/src/core/{tool.js → tool.ts} +221 -145
  85. package/src/editify/editify.less +404 -0
  86. package/src/editify/editify.vue +805 -0
  87. package/src/editify/props.ts +141 -0
  88. package/src/hljs/{index.js → index.ts} +7 -4
  89. package/src/index.ts +32 -0
  90. package/src/locale/{en_US.js → en_US.ts} +3 -1
  91. package/src/locale/index.ts +12 -0
  92. package/src/locale/{zh_CN.js → zh_CN.ts} +3 -1
  93. package/tsconfig.json +27 -0
  94. package/tsconfig.node.json +11 -0
  95. package/vite-env.d.ts +1 -0
  96. package/vite.config.ts +39 -0
  97. package/examples/main.js +0 -4
  98. package/src/Editify.vue +0 -1184
  99. package/src/components/Menu.vue +0 -1623
  100. package/src/components/Toolbar.vue +0 -1215
  101. package/src/components/base/Button.vue +0 -450
  102. package/src/components/base/Checkbox.vue +0 -196
  103. package/src/components/base/Layer.vue +0 -713
  104. package/src/components/base/Tooltip.vue +0 -82
  105. package/src/components/base/Triangle.vue +0 -159
  106. package/src/components/common/Colors.vue +0 -138
  107. package/src/components/common/InsertImage.vue +0 -316
  108. package/src/components/common/InsertLink.vue +0 -136
  109. package/src/components/common/InsertTable.vue +0 -157
  110. package/src/components/common/InsertVideo.vue +0 -316
  111. package/src/core/function.js +0 -1044
  112. package/src/index.js +0 -24
  113. package/src/locale/index.js +0 -14
@@ -0,0 +1,197 @@
1
+ <template>
2
+ <div class="editify-button">
3
+ <div class="editify-button-wrap" :class="{ 'right-border': rightBorder, 'left-border': leftBorder }">
4
+ <Tooltip :content="title" :disabled="!tooltip">
5
+ <div ref="btnRef" :style="btnStyle" class="editify-button-el" :class="{ disabled: disabled, active: active }" @mouseenter="status = 'hover'" @mouseleave="status = null" @mousedown="status = 'down'" @mouseup="status = 'hover'" @click="handleClick">
6
+ <div v-if="type == 'default' || type == 'select'" class="editify-button-slot">
7
+ <slot></slot>
8
+ </div>
9
+ <div v-else-if="type == 'display'">{{ displayLabel }}</div>
10
+ <Icon v-if="type == 'select' || type == 'display'" value="caret-down" class="editify-button-caret" :class="{ rotate: show }"></Icon>
11
+ </div>
12
+ </Tooltip>
13
+ <Layer ref="layerRef" v-model="show" :node="btnRef" border fade placement="bottom-start" :z-index="12" animation="translate" @show="emits('layerShow')" @shown="emits('layerShown')" @hidden="emits('layerHidden')">
14
+ <div class="editify-button-layer" :style="{ width: (type == 'select' ? parseSelectConfig.width : parseDisplayConfig.width) + 'px', maxHeight: (type == 'select' ? parseSelectConfig.maxHeight : parseDisplayConfig.maxHeight) + 'px', overflow: hideScroll ? 'visible' : '' }">
15
+ <slot v-if="$slots.layer" name="layer" :options="cmpOptions"></slot>
16
+ <div v-else class="editify-button-options">
17
+ <div @click="select(item)" class="editify-button-option" :class="{ active: type == 'display' ? item.value == parseDisplayConfig.value : false }" :style="item.style || ''" v-for="item in cmpOptions">
18
+ <slot v-if="$slots.option" name="option" :item="item"></slot>
19
+ <div class="editify-button-option-flex" v-else>
20
+ <Icon v-if="item.icon" :value="item.icon"></Icon>
21
+ <span>{{ item.label }}</span>
22
+ </div>
23
+ </div>
24
+ </div>
25
+ </div>
26
+ </Layer>
27
+ </div>
28
+ </div>
29
+ </template>
30
+ <script setup lang="ts">
31
+ import Tooltip from '../tooltip/tooltip.vue'
32
+ import Layer from '../layer/layer.vue'
33
+ import Icon from '../icon/icon.vue'
34
+ import { common as DapCommon, color as DapColor } from 'dap-util'
35
+ import { ButtonDisplayConfigType, ButtonOptionsItemType, ButtonProps, ButtonSelectConfigType } from './props'
36
+ import { computed, ref } from 'vue'
37
+ import { ObjectType } from '../../core/tool'
38
+
39
+ defineOptions({
40
+ name: 'Button'
41
+ })
42
+ const props = defineProps(ButtonProps)
43
+ const emits = defineEmits(['operate', 'layerShow', 'layerShown', 'layerHidden'])
44
+
45
+ //是否显示浮层
46
+ const show = ref<boolean>(false)
47
+ //按钮状态,hover表示悬浮,down表示按下
48
+ const status = ref<'hover' | 'down' | null>(null)
49
+ const btnRef = ref<HTMLElement | null>(null)
50
+ const layerRef = ref<InstanceType<typeof Layer> | null>(null)
51
+
52
+ //处理后的select配置
53
+ const parseSelectConfig = computed<ButtonSelectConfigType>(() => {
54
+ let options: ButtonOptionsItemType[] = []
55
+ let width: number | '' = ''
56
+ let maxHeight: number | '' = ''
57
+ if (DapCommon.isObject(props.selectConfig)) {
58
+ if (Array.isArray(props.selectConfig.options)) {
59
+ options = props.selectConfig.options.map(item => {
60
+ if (DapCommon.isObject(item)) {
61
+ return {
62
+ label: (<ButtonOptionsItemType>item).label,
63
+ value: (<ButtonOptionsItemType>item).value,
64
+ icon: (<ButtonOptionsItemType>item).icon,
65
+ style: (<ButtonOptionsItemType>item).style
66
+ }
67
+ }
68
+ return {
69
+ label: <string | number>item,
70
+ value: <string | number>item
71
+ }
72
+ })
73
+ }
74
+ if (typeof props.selectConfig.width == 'number') {
75
+ width = props.selectConfig.width
76
+ }
77
+ if (typeof props.selectConfig.maxHeight == 'number') {
78
+ maxHeight = props.selectConfig.maxHeight
79
+ }
80
+ }
81
+ return {
82
+ options,
83
+ width,
84
+ maxHeight
85
+ }
86
+ })
87
+ //处理后的display配置
88
+ const parseDisplayConfig = computed<ButtonDisplayConfigType>(() => {
89
+ let options: ButtonOptionsItemType[] = []
90
+ let width: number | '' = ''
91
+ let maxHeight: number | '' = ''
92
+ let value: string | number = ''
93
+ if (DapCommon.isObject(props.displayConfig)) {
94
+ if (typeof props.displayConfig.value == 'string' || typeof props.displayConfig.value == 'number') {
95
+ value = props.displayConfig.value
96
+ }
97
+ if (Array.isArray(props.displayConfig.options)) {
98
+ options = props.displayConfig.options.map(item => {
99
+ if (DapCommon.isObject(item)) {
100
+ return {
101
+ label: (<ButtonOptionsItemType>item).label,
102
+ value: (<ButtonOptionsItemType>item).value,
103
+ icon: (<ButtonOptionsItemType>item).icon,
104
+ style: (<ButtonOptionsItemType>item).style
105
+ }
106
+ }
107
+ return {
108
+ label: <string | number>item,
109
+ value: <string | number>item
110
+ }
111
+ })
112
+ let optItem = options.find(item => {
113
+ return item.value == value
114
+ })
115
+ if (!optItem && options[0]) {
116
+ value = options[0].value!
117
+ }
118
+ }
119
+ if (typeof props.displayConfig.width == 'number') {
120
+ width = props.displayConfig.width
121
+ }
122
+ if (typeof props.displayConfig.maxHeight == 'number') {
123
+ maxHeight = props.displayConfig.maxHeight
124
+ }
125
+ }
126
+ return {
127
+ options,
128
+ width,
129
+ maxHeight,
130
+ value
131
+ }
132
+ })
133
+ //渲染的浮层列表数据
134
+ const cmpOptions = computed<ButtonOptionsItemType[]>(() => {
135
+ return props.type == 'select' ? <ButtonOptionsItemType[]>parseSelectConfig.value.options : <ButtonOptionsItemType[]>parseDisplayConfig.value.options
136
+ })
137
+ //显示在页面的value值对应的label
138
+ const displayLabel = computed<string | number>(() => {
139
+ const val = (<ButtonOptionsItemType[]>parseDisplayConfig.value.options).find(item => {
140
+ return item.value == parseDisplayConfig.value.value
141
+ })
142
+ return val ? val.label! : ''
143
+ })
144
+ //十六进制颜色转换的rgb颜色数组
145
+ const parseColor = computed<number[]>(() => {
146
+ return DapColor.hex2rgb(props.color)
147
+ })
148
+ //按钮样式
149
+ const btnStyle = computed<ObjectType>(() => {
150
+ if (props.disabled) {
151
+ return {}
152
+ }
153
+ if (props.color) {
154
+ //激活情况下和鼠标按下状态
155
+ if (props.active || status.value == 'down') {
156
+ return {
157
+ color: props.color,
158
+ backgroundColor: `rgba(${parseColor.value[0]},${parseColor.value[1]},${parseColor.value[2]},0.15)`
159
+ }
160
+ }
161
+ //鼠标悬浮状态
162
+ if (status.value == 'hover') {
163
+ return {
164
+ color: `rgba(${parseColor.value[0]},${parseColor.value[1]},${parseColor.value[2]},0.9)`,
165
+ backgroundColor: `rgba(${parseColor.value[0]},${parseColor.value[1]},${parseColor.value[2]},0.05)`
166
+ }
167
+ }
168
+ }
169
+ return {}
170
+ })
171
+
172
+ //列表选择
173
+ const select = (item: ButtonOptionsItemType) => {
174
+ if (props.disabled) {
175
+ return
176
+ }
177
+ emits('operate', props.name, item.value)
178
+ show.value = false
179
+ }
180
+ //按钮点击处理
181
+ const handleClick = () => {
182
+ if (props.disabled) {
183
+ return
184
+ }
185
+ if (props.type == 'default') {
186
+ emits('operate', props.name)
187
+ } else {
188
+ show.value = !show.value
189
+ }
190
+ }
191
+
192
+ defineExpose({
193
+ show,
194
+ status
195
+ })
196
+ </script>
197
+ <style scoped src="./button.less"></style>
@@ -0,0 +1,95 @@
1
+ import { ExtractPublicPropTypes, PropType } from 'vue'
2
+ import { ObjectType } from '../../core/tool'
3
+
4
+ export type ButtonTypeType = 'default' | 'select' | 'display'
5
+
6
+ export type ButtonOptionsItemType = {
7
+ label?: string | number
8
+ value?: string | number
9
+ icon?: string
10
+ style?: ObjectType
11
+ }
12
+
13
+ export type ButtonSelectConfigType = {
14
+ options?: (ButtonOptionsItemType | number | string)[]
15
+ width?: number | ''
16
+ maxHeight?: number | ''
17
+ }
18
+
19
+ export type ButtonDisplayConfigType = {
20
+ options?: (ButtonOptionsItemType | number | string)[]
21
+ width?: number | ''
22
+ maxHeight?: number | ''
23
+ value?: string | number
24
+ }
25
+
26
+ export const ButtonProps = {
27
+ //按钮类型
28
+ type: {
29
+ type: String as PropType<ButtonTypeType>,
30
+ default: 'default',
31
+ validator(value: any) {
32
+ //default表示默认的点击按钮
33
+ //select表示下拉列表的按钮
34
+ //display表示显示值的下拉列表按钮
35
+ return ['default', 'select', 'display'].includes(value)
36
+ }
37
+ },
38
+ //按钮名称,唯一值
39
+ name: {
40
+ type: String,
41
+ default: ''
42
+ },
43
+ //按钮提示内容
44
+ title: {
45
+ type: String,
46
+ default: ''
47
+ },
48
+ //是否显示工具提示
49
+ tooltip: {
50
+ type: Boolean,
51
+ default: false
52
+ },
53
+ //是否显示右侧边框
54
+ rightBorder: {
55
+ type: Boolean,
56
+ default: false
57
+ },
58
+ //是否显示左侧边框
59
+ leftBorder: {
60
+ type: Boolean,
61
+ default: false
62
+ },
63
+ //主题色,用于按钮悬浮颜色变化使用,仅支持十六进制
64
+ color: {
65
+ type: String,
66
+ default: ''
67
+ },
68
+ //是否禁用
69
+ disabled: {
70
+ type: Boolean,
71
+ default: false
72
+ },
73
+ //是否激活
74
+ active: {
75
+ type: Boolean,
76
+ default: false
77
+ },
78
+ //type=select时的配置
79
+ selectConfig: {
80
+ type: Object as PropType<ButtonSelectConfigType>,
81
+ default: null
82
+ },
83
+ //type=display时的配置
84
+ displayConfig: {
85
+ type: Object as PropType<ButtonDisplayConfigType>,
86
+ default: null
87
+ },
88
+ //浮层隐藏滚动条
89
+ hideScroll: {
90
+ type: Boolean,
91
+ default: false
92
+ }
93
+ }
94
+
95
+ export type ButtonPropsType = ExtractPublicPropTypes<typeof ButtonProps>
@@ -0,0 +1,84 @@
1
+ .editify-checkbox {
2
+ display: inline-flex;
3
+ margin: 0;
4
+ padding: 0;
5
+ position: relative;
6
+ vertical-align: middle;
7
+ justify-content: flex-start;
8
+ align-items: center;
9
+ cursor: pointer;
10
+ user-select: none;
11
+ font-size: @font-size;
12
+
13
+ input[type='checkbox'] {
14
+ width: 0;
15
+ height: 0;
16
+ opacity: 0;
17
+ border: none;
18
+ display: none;
19
+ }
20
+
21
+ .editify-checkbox-item {
22
+ display: inline-flex;
23
+ display: -webkit-inline-flex;
24
+ justify-content: center;
25
+ align-items: center;
26
+ position: relative;
27
+ margin: 0;
28
+ padding: 1px;
29
+ border: 1px solid @border-color;
30
+ background-color: @background;
31
+ border-radius: 2px;
32
+ color: @background;
33
+ transition: border-color 0.1s cubic-bezier(0.71, -0.46, 0.29, 1.46), background-color 0.1s cubic-bezier(0.71, -0.46, 0.29, 1.46), color 0.1s cubic-bezier(0.71, -0.46, 0.29, 1.46);
34
+
35
+ &.round {
36
+ border-radius: 50%;
37
+ }
38
+
39
+ &.checked {
40
+ background-color: @font-color;
41
+ border-color: @font-color;
42
+
43
+ &.reverse {
44
+ background-color: @background;
45
+ color: @font-color-light;
46
+ border-color: @border-color;
47
+ }
48
+ }
49
+
50
+ :deep(.editify-icon) {
51
+ font-size: 18px;
52
+ zoom: 50%;
53
+ }
54
+ }
55
+
56
+ .editify-checkbox-label {
57
+ vertical-align: middle;
58
+ color: @font-color;
59
+ user-select: none;
60
+ line-height: 1;
61
+
62
+ &[data-editify-placement='left'] {
63
+ margin-right: 6px;
64
+ }
65
+
66
+ &[data-editify-placement='right'] {
67
+ margin-left: 6px;
68
+ }
69
+ }
70
+
71
+ &.disabled {
72
+ cursor: not-allowed;
73
+ .editify-checkbox-item,
74
+ .editify-checkbox-item.check {
75
+ background-color: @background-darker;
76
+ border-color: @border-color;
77
+ color: @font-color-disabled;
78
+ }
79
+
80
+ .editify-checkbox-label {
81
+ color: @font-color-disabled;
82
+ }
83
+ }
84
+ }
@@ -0,0 +1,68 @@
1
+ <template>
2
+ <label class="editify-checkbox" :class="{ disabled: disabled }">
3
+ <span v-if="placement == 'left' && label" class="editify-checkbox-label" :data-editify-placement="placement" v-text="label"></span>
4
+ <input @change="change" :value="value" :disabled="disabled" :checked="check" type="checkbox" />
5
+ <span class="editify-checkbox-item" :class="{ reverse: !color, round: round, checked: check && !disabled }" :style="itemStyle">
6
+ <Icon value="check" :style="{ opacity: check ? '' : 0 }" />
7
+ </span>
8
+ <span v-if="placement == 'right' && label" class="editify-checkbox-label" :data-editify-placement="placement" v-text="label"></span>
9
+ </label>
10
+ </template>
11
+
12
+ <script setup lang="ts">
13
+ import { common as DapCommon } from 'dap-util'
14
+ import Icon from '../icon/icon.vue'
15
+ import { CheckboxProps } from './props'
16
+ import { computed } from 'vue'
17
+ import { ObjectType } from '../../core/tool'
18
+
19
+ defineOptions({
20
+ name: 'Checkbox'
21
+ })
22
+ const props = defineProps(CheckboxProps)
23
+ const emits = defineEmits(['update:modelValue', 'change'])
24
+
25
+ const check = computed<boolean>(() => {
26
+ if (typeof props.modelValue == 'boolean') {
27
+ return props.modelValue
28
+ }
29
+ if (Array.isArray(props.modelValue)) {
30
+ //数组中是否已包含此复选框的值
31
+ return props.modelValue.some(item => {
32
+ return DapCommon.equal(item, props.value)
33
+ })
34
+ }
35
+ return false
36
+ })
37
+ const itemStyle = computed<ObjectType>(() => {
38
+ let style: ObjectType = {}
39
+ if (props.color && check.value && !props.disabled) {
40
+ style.backgroundColor = props.color
41
+ style.borderColor = props.color
42
+ }
43
+ return style
44
+ })
45
+
46
+ const change = (event: Event) => {
47
+ if (Array.isArray(props.modelValue)) {
48
+ let arr = [...props.modelValue]
49
+ //勾选且不包含
50
+ if ((<HTMLInputElement>event.target).checked && !check.value) {
51
+ arr.push(props.value)
52
+ }
53
+ //取消且包含
54
+ else if (check.value) {
55
+ arr = arr.filter(item => {
56
+ return !DapCommon.equal(item, props.value)
57
+ })
58
+ }
59
+ emits('update:modelValue', arr)
60
+ emits('change', arr)
61
+ } else if (typeof props.modelValue == 'boolean') {
62
+ emits('update:modelValue', (<HTMLInputElement>event.target).checked)
63
+ emits('change', (<HTMLInputElement>event.target).checked)
64
+ }
65
+ }
66
+ </script>
67
+
68
+ <style scoped src="./checkbox.less"></style>
@@ -0,0 +1,49 @@
1
+ import { ExtractPublicPropTypes, PropType } from 'vue'
2
+ import { ObjectType } from '../../core/tool'
3
+ import { common as DapCommon } from 'dap-util'
4
+
5
+ export const CheckboxProps = {
6
+ //是否禁用
7
+ disabled: {
8
+ type: Boolean,
9
+ default: false
10
+ },
11
+ //是否选中
12
+ modelValue: {
13
+ type: [Boolean, Array] as PropType<boolean | any[]>,
14
+ default: false
15
+ },
16
+ //label文字
17
+ label: {
18
+ type: String,
19
+ default: null
20
+ },
21
+ //值
22
+ value: {
23
+ type: [Object, Number, String, Array] as PropType<ObjectType | number | string | any[]>,
24
+ default: ''
25
+ },
26
+ //是否圆形
27
+ round: {
28
+ type: Boolean,
29
+ default: false
30
+ },
31
+ //文字位置
32
+ placement: {
33
+ type: String as PropType<'left' | 'right'>,
34
+ default: 'right',
35
+ validator(value: any) {
36
+ return ['left', 'right'].includes(value)
37
+ }
38
+ },
39
+ //主题颜色
40
+ color: {
41
+ type: String,
42
+ default: '',
43
+ validator(value: any) {
44
+ return DapCommon.matchingText(value, 'hex')
45
+ }
46
+ }
47
+ }
48
+
49
+ export type CheckboxPropsType = ExtractPublicPropTypes<typeof CheckboxProps>
@@ -0,0 +1,75 @@
1
+ .editify-colors {
2
+ display: block;
3
+ color: @font-color;
4
+ font-size: @font-size;
5
+ padding: 6px 10px;
6
+ box-sizing: border-box;
7
+ width: 244px;
8
+
9
+ .editify-colors-header {
10
+ display: flex;
11
+ justify-content: flex-start;
12
+ align-items: center;
13
+ position: relative;
14
+ padding: 6px 10px;
15
+ transform: all 200ms;
16
+ margin-bottom: 10px;
17
+ opacity: 0.8;
18
+
19
+ &::after {
20
+ content: '';
21
+ width: 100%;
22
+ height: 1px;
23
+ background-color: @background-darker;
24
+ position: absolute;
25
+ left: 0;
26
+ bottom: -5px;
27
+ }
28
+
29
+ :deep(.editify-icon) {
30
+ margin-right: 10px;
31
+ }
32
+
33
+ &:hover {
34
+ cursor: pointer;
35
+ background-color: @background-dark;
36
+ opacity: 1;
37
+ }
38
+
39
+ &:active {
40
+ opacity: 1;
41
+ background-color: @background-darker;
42
+ }
43
+ }
44
+
45
+ .editify-colors-list {
46
+ display: flex;
47
+ justify-content: flex-start;
48
+ flex-wrap: wrap;
49
+
50
+ .editify-color {
51
+ display: block;
52
+ padding: 4px;
53
+ border: 1px solid transparent;
54
+ border-radius: 2px;
55
+
56
+ &.active {
57
+ border-color: @font-color-light;
58
+ }
59
+
60
+ .editify-color-el {
61
+ display: block;
62
+ width: 16px;
63
+ height: 16px;
64
+ border: 1px solid @border-color;
65
+ border-radius: 2px;
66
+ cursor: pointer;
67
+ transition: all 200ms;
68
+
69
+ &:hover {
70
+ transform: scale(1.2);
71
+ }
72
+ }
73
+ }
74
+ }
75
+ }
@@ -0,0 +1,36 @@
1
+ <template>
2
+ <div class="editify-colors">
3
+ <div class="editify-colors-header" @click="selectColor({ value: '' })">
4
+ <Icon value="remove"></Icon>
5
+ <span>{{ $editTrans('defaultColor') }}</span>
6
+ </div>
7
+ <div class="editify-colors-list">
8
+ <div class="editify-color" :class="{ active: value == item.value }" v-for="item in data" :style="{ borderColor: value == item.value ? color : '' }">
9
+ <Tooltip block :content="<string>item.label" :disabled="!tooltip">
10
+ <div @click="selectColor(item)" class="editify-color-el" :style="{ background: item.value }"></div>
11
+ </Tooltip>
12
+ </div>
13
+ </div>
14
+ </div>
15
+ </template>
16
+ <script setup lang="ts">
17
+ import { inject } from 'vue'
18
+ import Icon from '../icon/icon.vue'
19
+ import Tooltip from '../tooltip/tooltip.vue'
20
+ import { ColorsProps } from './props'
21
+ import { ButtonOptionsItemType } from '../button/props'
22
+
23
+ defineOptions({
24
+ name: 'Colors'
25
+ })
26
+ defineProps(ColorsProps)
27
+ const emits = defineEmits(['change'])
28
+
29
+ const $editTrans = inject<(key: string) => any>('$editTrans')!
30
+
31
+ //选择颜色
32
+ const selectColor = (item: ButtonOptionsItemType) => {
33
+ emits('change', item.value)
34
+ }
35
+ </script>
36
+ <style scoped src="./colors.less"></style>
@@ -0,0 +1,29 @@
1
+ import { ExtractPublicPropTypes, PropType } from 'vue'
2
+ import { ButtonOptionsItemType } from '../button/props'
3
+
4
+ export const ColorsProps = {
5
+ //颜色数组
6
+ data: {
7
+ type: Array as PropType<ButtonOptionsItemType[]>,
8
+ default: function () {
9
+ return []
10
+ }
11
+ },
12
+ //选中的颜色
13
+ value: {
14
+ type: String,
15
+ default: null
16
+ },
17
+ //激活状态颜色
18
+ color: {
19
+ type: String,
20
+ default: ''
21
+ },
22
+ //是否使用工具提示
23
+ tooltip: {
24
+ type: Boolean,
25
+ default: false
26
+ }
27
+ }
28
+
29
+ export type ColorsPropsType = ExtractPublicPropTypes<typeof ColorsProps>
@@ -1,19 +1,3 @@
1
- <template>
2
- <i class="editify-icon" :class="'editify-icon-' + value"></i>
3
- </template>
4
- <script>
5
- export default {
6
- name: 'Icon',
7
- props: {
8
- //图标值
9
- value: {
10
- type: String,
11
- default: ''
12
- }
13
- }
14
- }
15
- </script>
16
- <style lang="less" scoped>
17
1
  @font-face {
18
2
  font-family: 'editify-icon';
19
3
  src: url('../../icon/iconfont.woff?t=1699274556400') format('woff'), url('../../icon/iconfont.ttf?t=1699274556400') format('truetype');
@@ -28,4 +12,3 @@ export default {
28
12
  line-height: 1;
29
13
  vertical-align: middle;
30
14
  }
31
- </style>
@@ -0,0 +1,12 @@
1
+ <template>
2
+ <i class="editify-icon" :class="'editify-icon-' + value"></i>
3
+ </template>
4
+ <script setup lang="ts">
5
+ import { IconProps } from './props'
6
+
7
+ defineOptions({
8
+ name: 'Icon'
9
+ })
10
+ defineProps(IconProps)
11
+ </script>
12
+ <style scoped src="./icon.less"></style>
@@ -0,0 +1,11 @@
1
+ import { ExtractPublicPropTypes } from 'vue'
2
+
3
+ export const IconProps = {
4
+ //图标值
5
+ value: {
6
+ type: String,
7
+ default: ''
8
+ }
9
+ }
10
+
11
+ export type IconPropsType = ExtractPublicPropTypes<typeof IconProps>