vue-editify 0.1.17 → 0.1.19

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (80) hide show
  1. package/README.md +3 -3
  2. package/examples/App.vue +62 -53
  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 +88 -70
  18. package/lib/editify/props.d.ts +11 -3
  19. package/lib/editify.es.js +65 -46
  20. package/lib/editify.umd.js +1 -1
  21. package/lib/index.d.ts +1 -1
  22. package/lib/style.css +1 -1
  23. package/package.json +45 -45
  24. package/src/components/button/button.less +145 -145
  25. package/src/components/button/button.vue +197 -197
  26. package/src/components/button/props.ts +95 -95
  27. package/src/components/checkbox/checkbox.less +84 -84
  28. package/src/components/checkbox/checkbox.vue +68 -68
  29. package/src/components/checkbox/props.ts +49 -49
  30. package/src/components/colors/colors.less +75 -75
  31. package/src/components/colors/colors.vue +36 -36
  32. package/src/components/colors/props.ts +29 -29
  33. package/src/components/icon/icon.less +14 -14
  34. package/src/components/icon/icon.vue +12 -12
  35. package/src/components/icon/props.ts +11 -11
  36. package/src/components/insertImage/insertImage.less +135 -135
  37. package/src/components/insertImage/insertImage.vue +146 -146
  38. package/src/components/insertImage/props.ts +43 -43
  39. package/src/components/insertLink/insertLink.less +64 -64
  40. package/src/components/insertLink/insertLink.vue +58 -58
  41. package/src/components/insertLink/props.ts +16 -16
  42. package/src/components/insertTable/insertTable.less +54 -54
  43. package/src/components/insertTable/insertTable.vue +85 -85
  44. package/src/components/insertTable/props.ts +27 -27
  45. package/src/components/insertVideo/insertVideo.less +135 -135
  46. package/src/components/insertVideo/insertVideo.vue +146 -146
  47. package/src/components/insertVideo/props.ts +43 -43
  48. package/src/components/layer/layer.less +49 -49
  49. package/src/components/layer/layer.vue +598 -598
  50. package/src/components/layer/props.ts +71 -71
  51. package/src/components/menu/menu.less +63 -63
  52. package/src/components/menu/menu.vue +1569 -1569
  53. package/src/components/menu/props.ts +17 -17
  54. package/src/components/toolbar/props.ts +35 -35
  55. package/src/components/toolbar/toolbar.less +89 -89
  56. package/src/components/toolbar/toolbar.vue +1101 -1101
  57. package/src/components/tooltip/props.ts +21 -21
  58. package/src/components/tooltip/tooltip.less +23 -23
  59. package/src/components/tooltip/tooltip.vue +37 -37
  60. package/src/components/triangle/props.ts +26 -26
  61. package/src/components/triangle/triangle.less +79 -79
  62. package/src/components/triangle/triangle.vue +65 -65
  63. package/src/core/function.ts +1144 -1144
  64. package/src/core/rule.ts +259 -259
  65. package/src/core/tool.ts +1137 -1137
  66. package/src/css/base.less +30 -30
  67. package/src/css/hljs.less +54 -54
  68. package/src/editify/editify.less +404 -403
  69. package/src/editify/editify.vue +803 -792
  70. package/src/editify/props.ts +156 -146
  71. package/src/hljs/index.ts +197 -197
  72. package/src/icon/iconfont.css +219 -219
  73. package/src/index.ts +32 -32
  74. package/src/locale/en_US.ts +88 -88
  75. package/src/locale/index.ts +12 -12
  76. package/src/locale/zh_CN.ts +88 -88
  77. package/tsconfig.json +27 -27
  78. package/tsconfig.node.json +11 -11
  79. package/vite-env.d.ts +1 -1
  80. package/vite.config.ts +42 -42
@@ -1,146 +1,146 @@
1
- <template>
2
- <div class="editify-video">
3
- <div class="editify-video-header">
4
- <div @click="current = 'upload'" class="editify-video-header-item" :class="{ active: current == 'upload' }" :style="activeStyle('upload')">{{ $editTrans('uploadVideo') }}</div>
5
- <div @click="current = 'remote'" class="editify-video-header-item" :class="{ active: current == 'remote' }" :style="activeStyle('remote')">{{ $editTrans('remoteVideo') }}</div>
6
- <div class="editify-video-header-slider" :class="current" :style="{ backgroundColor: color || '' }"></div>
7
- </div>
8
- <!-- 网络视频 -->
9
- <div class="editify-video-remote" v-if="current == 'remote'">
10
- <input v-model.trim="remoteUrl" :placeholder="$editTrans('videoUrlPlaceholder')" @blur="handleInputBlur" @focus="handleInputFocus" />
11
- <div class="editify-video-remote-footer" :style="{ color: color }">
12
- <span @click="insertRemoteVideo">{{ $editTrans('insert') }}</span>
13
- </div>
14
- </div>
15
- <!-- 上传视频 -->
16
- <div class="editify-video-upload" v-else>
17
- <Icon value="upload"></Icon>
18
- <input :multiple="multiple" accept="video/*" @change="selectFile" type="file" />
19
- </div>
20
- </div>
21
- </template>
22
- <script setup lang="ts">
23
- import { file as DapFile } from 'dap-util'
24
- import Icon from '../icon/icon.vue'
25
- import { InsertVideoProps } from './props'
26
- import { ComponentInternalInstance, computed, inject, ref, watch } from 'vue'
27
- import { ObjectType } from '../../core/tool'
28
-
29
- defineOptions({
30
- name: 'InsertVideo'
31
- })
32
- const props = defineProps(InsertVideoProps)
33
- const emits = defineEmits(['change', 'insert'])
34
-
35
- const $editTrans = inject<(key: string) => any>('$editTrans')!
36
- const editify = inject<ComponentInternalInstance>('editify')!
37
-
38
- //当前展示的面板,取值remote和upload
39
- const current = ref<'remote' | 'upload'>('upload')
40
- //远程视频链接
41
- const remoteUrl = ref<string>('')
42
-
43
- const activeStyle = computed<(name: 'remote' | 'upload') => ObjectType>(() => {
44
- return (name: 'remote' | 'upload') => {
45
- if (current.value == name) {
46
- return {
47
- color: props.color
48
- }
49
- }
50
- return {}
51
- }
52
- })
53
-
54
- //获取文件后缀
55
- const getSuffix = (file: File) => {
56
- const index = file.name.lastIndexOf('.')
57
- if (index <= 0) {
58
- return ''
59
- }
60
- return file.name.substring(index + 1)
61
- }
62
- //输入框获取焦点
63
- const handleInputFocus = (e: Event) => {
64
- if (props.color) {
65
- ;(<HTMLInputElement>e.currentTarget).style.borderColor = props.color
66
- }
67
- }
68
- //输入框失去焦点
69
- const handleInputBlur = (e: Event) => {
70
- ;(<HTMLInputElement>e.currentTarget).style.borderColor = ''
71
- }
72
- //插入网络视频
73
- const insertRemoteVideo = () => {
74
- emits('insert', remoteUrl.value)
75
- }
76
- //选择文件
77
- const selectFile = async (e: Event) => {
78
- const inputEle = <HTMLInputElement>e.currentTarget
79
- const files = inputEle.files
80
- if (!files || !files.length) {
81
- return
82
- }
83
- let filterFiles = []
84
- for (let i = 0; i < files.length; i++) {
85
- const file = files[i]
86
- const suffix = getSuffix(file)
87
- const isMatch = props.accept.some(item => {
88
- return item.toLocaleLowerCase() == suffix.toLocaleLowerCase()
89
- })
90
- //后缀不符合
91
- if (!isMatch) {
92
- //如果自定义了异常处理
93
- if (typeof props.handleError == 'function') {
94
- props.handleError.apply(editify.proxy!, ['suffixError', file])
95
- }
96
- continue
97
- }
98
- //超过最大值
99
- if (props.maxSize && file.size / 1024 > props.maxSize) {
100
- //如果自定义了异常处理
101
- if (typeof props.handleError == 'function') {
102
- props.handleError.apply(editify.proxy!, ['maxSizeError', file])
103
- }
104
- continue
105
- }
106
- //没达到最小值
107
- if (props.minSize && file.size / 1024 < props.minSize) {
108
- //如果自定义了异常处理
109
- if (typeof props.handleError == 'function') {
110
- props.handleError.apply(editify.proxy!, ['minSizeError', file])
111
- }
112
- continue
113
- }
114
- filterFiles.push(file)
115
- }
116
- //有文件可上传
117
- if (filterFiles.length) {
118
- let videos = []
119
- //自定义上传方法
120
- if (typeof props.customUpload == 'function') {
121
- videos = (await props.customUpload.apply(editify.proxy!, [filterFiles])) || []
122
- }
123
- //默认上传方法
124
- else {
125
- for (let i = 0; i < filterFiles.length; i++) {
126
- const url = await DapFile.dataFileToBase64(filterFiles[i])
127
- videos.push(url)
128
- }
129
- }
130
- videos.forEach(url => {
131
- emits('insert', url)
132
- })
133
- }
134
- //清空文件选择框
135
- inputEle.value = ''
136
- }
137
-
138
- //监听current变更触发change事件
139
- watch(
140
- () => current.value,
141
- () => {
142
- emits('change')
143
- }
144
- )
145
- </script>
146
- <style scoped src="./insertVideo.less"></style>
1
+ <template>
2
+ <div class="editify-video">
3
+ <div class="editify-video-header">
4
+ <div @click="current = 'upload'" class="editify-video-header-item" :class="{ active: current == 'upload' }" :style="activeStyle('upload')">{{ $editTrans('uploadVideo') }}</div>
5
+ <div @click="current = 'remote'" class="editify-video-header-item" :class="{ active: current == 'remote' }" :style="activeStyle('remote')">{{ $editTrans('remoteVideo') }}</div>
6
+ <div class="editify-video-header-slider" :class="current" :style="{ backgroundColor: color || '' }"></div>
7
+ </div>
8
+ <!-- 网络视频 -->
9
+ <div class="editify-video-remote" v-if="current == 'remote'">
10
+ <input v-model.trim="remoteUrl" :placeholder="$editTrans('videoUrlPlaceholder')" @blur="handleInputBlur" @focus="handleInputFocus" />
11
+ <div class="editify-video-remote-footer" :style="{ color: color }">
12
+ <span @click="insertRemoteVideo">{{ $editTrans('insert') }}</span>
13
+ </div>
14
+ </div>
15
+ <!-- 上传视频 -->
16
+ <div class="editify-video-upload" v-else>
17
+ <Icon value="upload"></Icon>
18
+ <input :multiple="multiple" accept="video/*" @change="selectFile" type="file" />
19
+ </div>
20
+ </div>
21
+ </template>
22
+ <script setup lang="ts">
23
+ import { file as DapFile } from 'dap-util'
24
+ import Icon from '../icon/icon.vue'
25
+ import { InsertVideoProps } from './props'
26
+ import { ComponentInternalInstance, computed, inject, ref, watch } from 'vue'
27
+ import { ObjectType } from '../../core/tool'
28
+
29
+ defineOptions({
30
+ name: 'InsertVideo'
31
+ })
32
+ const props = defineProps(InsertVideoProps)
33
+ const emits = defineEmits(['change', 'insert'])
34
+
35
+ const $editTrans = inject<(key: string) => any>('$editTrans')!
36
+ const editify = inject<ComponentInternalInstance>('editify')!
37
+
38
+ //当前展示的面板,取值remote和upload
39
+ const current = ref<'remote' | 'upload'>('upload')
40
+ //远程视频链接
41
+ const remoteUrl = ref<string>('')
42
+
43
+ const activeStyle = computed<(name: 'remote' | 'upload') => ObjectType>(() => {
44
+ return (name: 'remote' | 'upload') => {
45
+ if (current.value == name) {
46
+ return {
47
+ color: props.color
48
+ }
49
+ }
50
+ return {}
51
+ }
52
+ })
53
+
54
+ //获取文件后缀
55
+ const getSuffix = (file: File) => {
56
+ const index = file.name.lastIndexOf('.')
57
+ if (index <= 0) {
58
+ return ''
59
+ }
60
+ return file.name.substring(index + 1)
61
+ }
62
+ //输入框获取焦点
63
+ const handleInputFocus = (e: Event) => {
64
+ if (props.color) {
65
+ ;(<HTMLInputElement>e.currentTarget).style.borderColor = props.color
66
+ }
67
+ }
68
+ //输入框失去焦点
69
+ const handleInputBlur = (e: Event) => {
70
+ ;(<HTMLInputElement>e.currentTarget).style.borderColor = ''
71
+ }
72
+ //插入网络视频
73
+ const insertRemoteVideo = () => {
74
+ emits('insert', remoteUrl.value)
75
+ }
76
+ //选择文件
77
+ const selectFile = async (e: Event) => {
78
+ const inputEle = <HTMLInputElement>e.currentTarget
79
+ const files = inputEle.files
80
+ if (!files || !files.length) {
81
+ return
82
+ }
83
+ let filterFiles = []
84
+ for (let i = 0; i < files.length; i++) {
85
+ const file = files[i]
86
+ const suffix = getSuffix(file)
87
+ const isMatch = props.accept.some(item => {
88
+ return item.toLocaleLowerCase() == suffix.toLocaleLowerCase()
89
+ })
90
+ //后缀不符合
91
+ if (!isMatch) {
92
+ //如果自定义了异常处理
93
+ if (typeof props.handleError == 'function') {
94
+ props.handleError.apply(editify.proxy!, ['suffixError', file])
95
+ }
96
+ continue
97
+ }
98
+ //超过最大值
99
+ if (props.maxSize && file.size / 1024 > props.maxSize) {
100
+ //如果自定义了异常处理
101
+ if (typeof props.handleError == 'function') {
102
+ props.handleError.apply(editify.proxy!, ['maxSizeError', file])
103
+ }
104
+ continue
105
+ }
106
+ //没达到最小值
107
+ if (props.minSize && file.size / 1024 < props.minSize) {
108
+ //如果自定义了异常处理
109
+ if (typeof props.handleError == 'function') {
110
+ props.handleError.apply(editify.proxy!, ['minSizeError', file])
111
+ }
112
+ continue
113
+ }
114
+ filterFiles.push(file)
115
+ }
116
+ //有文件可上传
117
+ if (filterFiles.length) {
118
+ let videos = []
119
+ //自定义上传方法
120
+ if (typeof props.customUpload == 'function') {
121
+ videos = (await props.customUpload.apply(editify.proxy!, [filterFiles])) || []
122
+ }
123
+ //默认上传方法
124
+ else {
125
+ for (let i = 0; i < filterFiles.length; i++) {
126
+ const url = await DapFile.dataFileToBase64(filterFiles[i])
127
+ videos.push(url)
128
+ }
129
+ }
130
+ videos.forEach(url => {
131
+ emits('insert', url)
132
+ })
133
+ }
134
+ //清空文件选择框
135
+ inputEle.value = ''
136
+ }
137
+
138
+ //监听current变更触发change事件
139
+ watch(
140
+ () => current.value,
141
+ () => {
142
+ emits('change')
143
+ }
144
+ )
145
+ </script>
146
+ <style scoped src="./insertVideo.less"></style>
@@ -1,43 +1,43 @@
1
- import { ExtractPublicPropTypes, PropType } from 'vue'
2
-
3
- export type InsertVideoUploadErrorType = 'suffixError' | 'maxSizeError' | 'minSizeError'
4
-
5
- export const InsertVideoProps = {
6
- //主题色
7
- color: {
8
- type: String,
9
- default: ''
10
- },
11
- //支持的视频类型数组
12
- accept: {
13
- type: Array as PropType<string[]>,
14
- default: null
15
- },
16
- //是否支持多选
17
- multiple: {
18
- type: Boolean,
19
- default: false
20
- },
21
- //单个文件最大值
22
- maxSize: {
23
- type: Number,
24
- default: null
25
- },
26
- //单个文件最小值
27
- minSize: {
28
- type: Number,
29
- default: null
30
- },
31
- //是否自定义上传视频
32
- customUpload: {
33
- type: Function as PropType<(files: File[]) => string[] | Promise<string[]>>,
34
- default: null
35
- },
36
- //处理上传视频异常
37
- handleError: {
38
- type: Function as PropType<(error: InsertVideoUploadErrorType, file: File) => void>,
39
- default: null
40
- }
41
- }
42
-
43
- export type InsertVideoPropsType = ExtractPublicPropTypes<typeof InsertVideoProps>
1
+ import { ExtractPublicPropTypes, PropType } from 'vue'
2
+
3
+ export type InsertVideoUploadErrorType = 'suffixError' | 'maxSizeError' | 'minSizeError'
4
+
5
+ export const InsertVideoProps = {
6
+ //主题色
7
+ color: {
8
+ type: String,
9
+ default: ''
10
+ },
11
+ //支持的视频类型数组
12
+ accept: {
13
+ type: Array as PropType<string[]>,
14
+ default: null
15
+ },
16
+ //是否支持多选
17
+ multiple: {
18
+ type: Boolean,
19
+ default: false
20
+ },
21
+ //单个文件最大值
22
+ maxSize: {
23
+ type: Number,
24
+ default: null
25
+ },
26
+ //单个文件最小值
27
+ minSize: {
28
+ type: Number,
29
+ default: null
30
+ },
31
+ //是否自定义上传视频
32
+ customUpload: {
33
+ type: Function as PropType<(files: File[]) => string[] | Promise<string[]>>,
34
+ default: null
35
+ },
36
+ //处理上传视频异常
37
+ handleError: {
38
+ type: Function as PropType<(error: InsertVideoUploadErrorType, file: File) => void>,
39
+ default: null
40
+ }
41
+ }
42
+
43
+ export type InsertVideoPropsType = ExtractPublicPropTypes<typeof InsertVideoProps>
@@ -1,49 +1,49 @@
1
- .editify-layer-fade-enter-from,
2
- .editify-layer-fade-leave-to {
3
- opacity: 0;
4
- }
5
- .editify-layer-fade-enter-active,
6
- .editify-layer-fade-leave-active {
7
- transition: opacity 200ms linear;
8
- }
9
-
10
- .editify-layer-translate-enter-from,
11
- .editify-layer-translate-leave-to {
12
- opacity: 0;
13
- transform: translateY(20px);
14
- }
15
-
16
- .editify-layer-translate-enter-active,
17
- .editify-layer-translate-leave-active {
18
- transition: opacity 200ms ease-in-out, transform 200ms ease-in-out;
19
- }
20
-
21
- .editify-layer {
22
- display: block;
23
- position: absolute;
24
- padding: 0 0 10px 0;
25
- font-size: @font-size;
26
- color: @font-color;
27
-
28
- &[data-editify-placement='bottom'],
29
- &[data-editify-placement='bottom-start'],
30
- &[data-editify-placement='bottom-end'] {
31
- padding: 10px 0 0 0;
32
- }
33
-
34
- :deep(.editify-triangle) {
35
- position: absolute;
36
- z-index: 1;
37
- }
38
-
39
- .editify-layer-wrap {
40
- display: block;
41
- background-color: @background;
42
- box-shadow: 0px 2px 10px rgba(0, 0, 0, 0.1);
43
- border-radius: 4px;
44
-
45
- &.border {
46
- border: 1px solid @border-color;
47
- }
48
- }
49
- }
1
+ .editify-layer-fade-enter-from,
2
+ .editify-layer-fade-leave-to {
3
+ opacity: 0;
4
+ }
5
+ .editify-layer-fade-enter-active,
6
+ .editify-layer-fade-leave-active {
7
+ transition: opacity 200ms linear;
8
+ }
9
+
10
+ .editify-layer-translate-enter-from,
11
+ .editify-layer-translate-leave-to {
12
+ opacity: 0;
13
+ transform: translateY(20px);
14
+ }
15
+
16
+ .editify-layer-translate-enter-active,
17
+ .editify-layer-translate-leave-active {
18
+ transition: opacity 200ms ease-in-out, transform 200ms ease-in-out;
19
+ }
20
+
21
+ .editify-layer {
22
+ display: block;
23
+ position: absolute;
24
+ padding: 0 0 10px 0;
25
+ font-size: @font-size;
26
+ color: @font-color;
27
+
28
+ &[data-editify-placement='bottom'],
29
+ &[data-editify-placement='bottom-start'],
30
+ &[data-editify-placement='bottom-end'] {
31
+ padding: 10px 0 0 0;
32
+ }
33
+
34
+ :deep(.editify-triangle) {
35
+ position: absolute;
36
+ z-index: 1;
37
+ }
38
+
39
+ .editify-layer-wrap {
40
+ display: block;
41
+ background-color: @background;
42
+ box-shadow: 0px 2px 10px rgba(0, 0, 0, 0.1);
43
+ border-radius: 4px;
44
+
45
+ &.border {
46
+ border: 1px solid @border-color;
47
+ }
48
+ }
49
+ }