vue-editify 0.1.18 → 0.1.19

Sign up to get free protection for your applications and to get access to all the features.
Files changed (79) hide show
  1. package/README.md +3 -3
  2. package/examples/App.vue +62 -61
  3. package/examples/main.ts +4 -4
  4. package/lib/components/button/button.vue.d.ts +11 -11
  5. package/lib/components/checkbox/checkbox.vue.d.ts +8 -8
  6. package/lib/components/colors/colors.vue.d.ts +4 -4
  7. package/lib/components/icon/icon.vue.d.ts +1 -1
  8. package/lib/components/insertImage/insertImage.vue.d.ts +9 -9
  9. package/lib/components/insertLink/insertLink.vue.d.ts +2 -2
  10. package/lib/components/insertTable/insertTable.vue.d.ts +2 -2
  11. package/lib/components/insertVideo/insertVideo.vue.d.ts +9 -9
  12. package/lib/components/layer/layer.vue.d.ts +9 -9
  13. package/lib/components/menu/menu.vue.d.ts +4 -4
  14. package/lib/components/toolbar/toolbar.vue.d.ts +9 -9
  15. package/lib/components/tooltip/tooltip.vue.d.ts +1 -1
  16. package/lib/components/triangle/triangle.vue.d.ts +4 -4
  17. package/lib/editify/editify.vue.d.ts +68 -68
  18. package/lib/editify.es.js +17 -17
  19. package/lib/editify.umd.js +1 -1
  20. package/lib/index.d.ts +1 -1
  21. package/lib/style.css +1 -1
  22. package/package.json +45 -45
  23. package/src/components/button/button.less +145 -145
  24. package/src/components/button/button.vue +197 -197
  25. package/src/components/button/props.ts +95 -95
  26. package/src/components/checkbox/checkbox.less +84 -84
  27. package/src/components/checkbox/checkbox.vue +68 -68
  28. package/src/components/checkbox/props.ts +49 -49
  29. package/src/components/colors/colors.less +75 -75
  30. package/src/components/colors/colors.vue +36 -36
  31. package/src/components/colors/props.ts +29 -29
  32. package/src/components/icon/icon.less +14 -14
  33. package/src/components/icon/icon.vue +12 -12
  34. package/src/components/icon/props.ts +11 -11
  35. package/src/components/insertImage/insertImage.less +135 -135
  36. package/src/components/insertImage/insertImage.vue +146 -146
  37. package/src/components/insertImage/props.ts +43 -43
  38. package/src/components/insertLink/insertLink.less +64 -64
  39. package/src/components/insertLink/insertLink.vue +58 -58
  40. package/src/components/insertLink/props.ts +16 -16
  41. package/src/components/insertTable/insertTable.less +54 -54
  42. package/src/components/insertTable/insertTable.vue +85 -85
  43. package/src/components/insertTable/props.ts +27 -27
  44. package/src/components/insertVideo/insertVideo.less +135 -135
  45. package/src/components/insertVideo/insertVideo.vue +146 -146
  46. package/src/components/insertVideo/props.ts +43 -43
  47. package/src/components/layer/layer.less +49 -49
  48. package/src/components/layer/layer.vue +598 -598
  49. package/src/components/layer/props.ts +71 -71
  50. package/src/components/menu/menu.less +63 -63
  51. package/src/components/menu/menu.vue +1569 -1569
  52. package/src/components/menu/props.ts +17 -17
  53. package/src/components/toolbar/props.ts +35 -35
  54. package/src/components/toolbar/toolbar.less +89 -89
  55. package/src/components/toolbar/toolbar.vue +1101 -1101
  56. package/src/components/tooltip/props.ts +21 -21
  57. package/src/components/tooltip/tooltip.less +23 -23
  58. package/src/components/tooltip/tooltip.vue +37 -37
  59. package/src/components/triangle/props.ts +26 -26
  60. package/src/components/triangle/triangle.less +79 -79
  61. package/src/components/triangle/triangle.vue +65 -65
  62. package/src/core/function.ts +1144 -1144
  63. package/src/core/rule.ts +259 -259
  64. package/src/core/tool.ts +1137 -1137
  65. package/src/css/base.less +30 -30
  66. package/src/css/hljs.less +54 -54
  67. package/src/editify/editify.less +404 -403
  68. package/src/editify/editify.vue +803 -803
  69. package/src/editify/props.ts +156 -156
  70. package/src/hljs/index.ts +197 -197
  71. package/src/icon/iconfont.css +219 -219
  72. package/src/index.ts +32 -32
  73. package/src/locale/en_US.ts +88 -88
  74. package/src/locale/index.ts +12 -12
  75. package/src/locale/zh_CN.ts +88 -88
  76. package/tsconfig.json +27 -27
  77. package/tsconfig.node.json +11 -11
  78. package/vite-env.d.ts +1 -1
  79. package/vite.config.ts +42 -42
@@ -1,84 +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
- }
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
+ }
@@ -1,68 +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>
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>
@@ -1,49 +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>
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>
@@ -1,75 +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
- }
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
+ }
@@ -1,36 +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>
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>