vue-editify 0.1.9 → 0.1.12

Sign up to get free protection for your applications and to get access to all the features.
Files changed (112) hide show
  1. package/examples/App.vue +22 -5644
  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 +5547 -5667
  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.js → function.ts} +268 -267
  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/index.js +0 -24
  112. package/src/locale/index.js +0 -14
@@ -1,136 +0,0 @@
1
- <template>
2
- <div class="editify-link">
3
- <div class="editify-link-label">{{ $editTrans('linkAddress') }}</div>
4
- <input @focus="handleInputFocus" @blur="handleInputBlur" :placeholder="$editTrans('linkTextEnterPlaceholder')" v-model.trim="linkText" type="text" />
5
- <input @focus="handleInputFocus" @blur="handleInputBlur" :placeholder="$editTrans('linkUrlEnterPlaceholder')" v-model.trim="linkUrl" type="url" />
6
- <div class="editify-link-footer">
7
- <Checkbox v-model="newOpen" :label="$editTrans('newWindowOpen')" :color="color" :size="10"></Checkbox>
8
- <div class="editify-link-operations">
9
- <span :style="{ color: color }" @click="insertLink">{{ $editTrans('insertLink') }}</span>
10
- </div>
11
- </div>
12
- </div>
13
- </template>
14
- <script>
15
- import Checkbox from '../base/Checkbox'
16
- export default {
17
- name: 'InsertLink',
18
- emits: ['insert'],
19
- inject: ['$editTrans'],
20
- props: {
21
- //主题色
22
- color: {
23
- type: String,
24
- default: ''
25
- },
26
- //预置的链接文本值
27
- text: {
28
- type: String,
29
- default: ''
30
- }
31
- },
32
- data() {
33
- return {
34
- //链接地址
35
- linkUrl: '',
36
- //链接文本
37
- linkText: '',
38
- //是否新窗口打开
39
- newOpen: false
40
- }
41
- },
42
- watch: {
43
- text: {
44
- immediate: true,
45
- handler: function (newValue) {
46
- this.linkText = newValue
47
- }
48
- }
49
- },
50
- components: {
51
- Checkbox
52
- },
53
- methods: {
54
- //输入框获取焦点
55
- handleInputFocus(e) {
56
- if (this.color) {
57
- e.currentTarget.style.borderColor = this.color
58
- }
59
- },
60
- //输入框失去焦点
61
- handleInputBlur(e) {
62
- e.currentTarget.style.borderColor = ''
63
- },
64
- //插入链接
65
- insertLink() {
66
- this.$emit('insert', this.linkText, this.linkUrl, this.newOpen)
67
- }
68
- }
69
- }
70
- </script>
71
- <style lang="less" scoped>
72
- .editify-link {
73
- display: block;
74
- width: 280px;
75
- padding: 10px 14px;
76
-
77
- .editify-link-label {
78
- display: block;
79
- text-align: left;
80
- margin-bottom: 10px;
81
- font-size: @font-size;
82
- color: @font-color;
83
- }
84
-
85
- input {
86
- appearance: none;
87
- -webkit-appearance: none;
88
- -moz-appearance: none;
89
- display: block;
90
- width: 100%;
91
- margin: 0 0 10px 0;
92
- padding: 4px 2px;
93
- border: none;
94
- font-size: @font-size;
95
- color: @font-color;
96
- border-bottom: 1px solid @border-color;
97
- line-height: 1.5;
98
- transition: border-color 500ms;
99
- background-color: transparent;
100
- outline: none;
101
- box-sizing: border-box;
102
-
103
- &::-webkit-input-placeholder,
104
- &::placeholder {
105
- color: @font-color-disabled;
106
- font-family: inherit;
107
- font-size: inherit;
108
- vertical-align: middle;
109
- }
110
- }
111
-
112
- .editify-link-footer {
113
- display: flex;
114
- justify-content: space-between;
115
- align-items: center;
116
- width: 100%;
117
-
118
- .editify-link-operations {
119
- display: flex;
120
- justify-content: flex-start;
121
- align-items: center;
122
-
123
- & > span {
124
- cursor: pointer;
125
- opacity: 0.8;
126
- transition: all 200ms;
127
- font-size: @font-size;
128
-
129
- &:hover {
130
- opacity: 1;
131
- }
132
- }
133
- }
134
- }
135
- }
136
- </style>
@@ -1,157 +0,0 @@
1
- <template>
2
- <div class="editify-table">
3
- <table>
4
- <tr v-for="row in tableGrids">
5
- <td :class="{ inside: column.inside }" v-for="column in row" @mouseenter="changeTableSize(column)" @click="createTable(column)">
6
- <span></span>
7
- </td>
8
- </tr>
9
- </table>
10
- <div class="editify-table-footer">
11
- <span v-if="specification">{{ specification.x }} x {{ specification.y }}</span>
12
- <span v-else>{{ $editTrans('insertTable') }}</span>
13
- </div>
14
- </div>
15
- </template>
16
- <script>
17
- export default {
18
- name: 'InsertTable',
19
- emits: ['insert'],
20
- inject: ['$editTrans'],
21
- props: {
22
- //主题色
23
- color: {
24
- type: String,
25
- default: ''
26
- },
27
- //最大行数
28
- maxRows: {
29
- type: Number,
30
- default: 10
31
- },
32
- //最大列数
33
- maxColumns: {
34
- type: Number,
35
- default: 10
36
- }
37
- },
38
- data() {
39
- return {
40
- tableGrids: this.getTableGrids()
41
- }
42
- },
43
- computed: {
44
- //表格规格
45
- specification() {
46
- return this.tableGrids
47
- .flat()
48
- .filter(item => {
49
- return item.inside
50
- })
51
- .sort((a, b) => {
52
- if (a.x > b.x && a.y > b.y) {
53
- return -1
54
- }
55
- if (a.x > b.x) {
56
- return -1
57
- }
58
- if (a.y > b.y) {
59
- return -1
60
- }
61
- return 1
62
- })[0]
63
- }
64
- },
65
- methods: {
66
- //确认创立表格
67
- createTable(data) {
68
- this.$emit('insert', data.x, data.y)
69
- },
70
- //改变表格大小
71
- changeTableSize(data) {
72
- for (let i in this.tableGrids) {
73
- const grid = this.tableGrids[i]
74
- for (let j in grid) {
75
- if (grid[j].x <= data.x && grid[j].y <= data.y) {
76
- this.tableGrids[i][j].inside = true
77
- } else {
78
- this.tableGrids[i][j].inside = false
79
- }
80
- }
81
- }
82
- },
83
- //获取表格
84
- getTableGrids() {
85
- const grids = []
86
- for (let i = 1; i <= this.maxRows; i++) {
87
- let row = []
88
- for (let j = 1; j <= this.maxColumns; j++) {
89
- row.push({
90
- x: i,
91
- y: j,
92
- inside: false //是否被选中
93
- })
94
- }
95
- grids.push(row)
96
- }
97
- return grids
98
- }
99
- }
100
- }
101
- </script>
102
- <style lang="less" scoped>
103
- .editify-table {
104
- display: block;
105
- position: relative;
106
- padding: 10px 10px 32px 10px;
107
- box-sizing: border-box;
108
-
109
- table {
110
- border: 1px solid @border-color;
111
- margin: 0;
112
- padding: 0;
113
- border-collapse: collapse;
114
-
115
- tr {
116
- margin: 0;
117
- padding: 0;
118
-
119
- td {
120
- margin: 0;
121
- padding: 0;
122
- border: 1px solid @border-color;
123
-
124
- span {
125
- display: block;
126
- width: 15px;
127
- height: 15px;
128
- }
129
-
130
- &:hover {
131
- cursor: pointer;
132
- }
133
-
134
- &.inside {
135
- background-color: @background-darker;
136
- }
137
- }
138
- }
139
- }
140
-
141
- .editify-table-footer {
142
- text-align: center;
143
- color: @font-color-light;
144
- line-height: 1;
145
- font-size: 12px;
146
- position: absolute;
147
- padding: 0 10px;
148
- bottom: 10px;
149
- left: 0;
150
- width: 100%;
151
- overflow: hidden;
152
- text-overflow: ellipsis;
153
- white-space: nowrap;
154
- box-sizing: border-box;
155
- }
156
- }
157
- </style>
@@ -1,316 +0,0 @@
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>
23
- import { file as DapFile } from 'dap-util'
24
- import Icon from '../base/Icon'
25
- export default {
26
- name: 'InsertVideo',
27
- emits: ['change', 'insert'],
28
- props: {
29
- //主题色
30
- color: {
31
- type: String,
32
- default: ''
33
- },
34
- //支持的视频类型数组
35
- accept: {
36
- type: Array,
37
- default: null
38
- },
39
- //是否支持多选
40
- multiple: {
41
- type: Boolean,
42
- default: false
43
- },
44
- //单个文件最大值
45
- maxSize: {
46
- type: Number,
47
- default: null
48
- },
49
- //单个文件最小值
50
- minSize: {
51
- type: Number,
52
- default: null
53
- },
54
- //是否自定义上传视频
55
- customUpload: {
56
- type: Function,
57
- default: null
58
- },
59
- //处理上传视频异常
60
- handleError: {
61
- type: Function,
62
- default: null
63
- }
64
- },
65
- inject: ['$editTrans'],
66
- data() {
67
- return {
68
- current: 'upload', //当前展示的面板,取值remote和upload
69
- remoteUrl: '' //远程视频链接
70
- }
71
- },
72
- computed: {
73
- activeStyle() {
74
- return name => {
75
- if (this.current == name) {
76
- return {
77
- color: this.color
78
- }
79
- }
80
- return {}
81
- }
82
- }
83
- },
84
- components: {
85
- Icon
86
- },
87
- watch: {
88
- //监听current变更触发change事件
89
- current() {
90
- this.$emit('change')
91
- }
92
- },
93
- methods: {
94
- //选择文件
95
- async selectFile(e) {
96
- const inputEle = e.currentTarget
97
- const files = inputEle.files
98
- if (!files.length) {
99
- return
100
- }
101
- let filterFiles = []
102
- for (let i = 0; i < files.length; i++) {
103
- const file = files[i]
104
- const suffix = this.getSuffix(file)
105
- const isMatch = this.accept.some(item => {
106
- return item.toLocaleLowerCase() == suffix.toLocaleLowerCase()
107
- })
108
- //后缀不符合
109
- if (!isMatch) {
110
- //如果自定义了异常处理
111
- if (typeof this.handleError == 'function') {
112
- this.handleError.apply(this, ['suffixError', file])
113
- }
114
- continue
115
- }
116
- //超过最大值
117
- if (this.maxSize && file.size / 1024 > this.maxSize) {
118
- //如果自定义了异常处理
119
- if (typeof this.handleError == 'function') {
120
- this.handleError.apply(this, ['maxSizeError', file])
121
- }
122
- continue
123
- }
124
- //没达到最小值
125
- if (this.minSize && file.size / 1024 < this.minSize) {
126
- //如果自定义了异常处理
127
- if (typeof this.handleError == 'function') {
128
- this.handleError.apply(this, ['minSizeError', file])
129
- }
130
- continue
131
- }
132
- filterFiles.push(file)
133
- }
134
- //有文件可上传
135
- if (filterFiles.length) {
136
- let videos = []
137
- //自定义上传方法
138
- if (typeof this.customUpload == 'function') {
139
- videos = (await this.customUpload.apply(this, [filterFiles])) || []
140
- }
141
- //默认上传方法
142
- else {
143
- for (let i = 0; i < filterFiles.length; i++) {
144
- const url = await DapFile.dataFileToBase64(filterFiles[i])
145
- videos.push(url)
146
- }
147
- }
148
- videos.forEach(url => {
149
- this.$emit('insert', url)
150
- })
151
- }
152
- //清空文件选择框
153
- inputEle.value = ''
154
- },
155
- //获取文件后缀
156
- getSuffix(file) {
157
- const index = file.name.lastIndexOf('.')
158
- if (index <= 0) {
159
- return ''
160
- }
161
- return file.name.substring(index + 1)
162
- },
163
- //输入框获取焦点
164
- handleInputFocus(e) {
165
- if (this.color) {
166
- e.currentTarget.style.borderColor = this.color
167
- }
168
- },
169
- //输入框失去焦点
170
- handleInputBlur(e) {
171
- e.currentTarget.style.borderColor = ''
172
- },
173
- //插入网络视频
174
- insertRemoteVideo() {
175
- this.$emit('insert', this.remoteUrl)
176
- }
177
- }
178
- }
179
- </script>
180
- <style lang="less" scoped>
181
- .editify-video {
182
- display: block;
183
- width: 280px;
184
- padding: 10px 14px;
185
-
186
- .editify-video-header {
187
- display: flex;
188
- justify-content: flex-start;
189
- align-items: center;
190
- width: 100%;
191
- margin-bottom: 20px;
192
- position: relative;
193
- padding-bottom: 6px;
194
-
195
- .editify-video-header-slider {
196
- position: absolute;
197
- width: 50px;
198
- height: 2px;
199
- border-radius: 2px;
200
- left: 0;
201
- bottom: 0;
202
- transition: left 200ms;
203
-
204
- &.upload {
205
- left: 5px;
206
- }
207
-
208
- &.remote {
209
- left: 85px;
210
- }
211
- }
212
-
213
- .editify-video-header-item {
214
- display: block;
215
- text-align: center;
216
- font-size: @font-size;
217
- color: @font-color;
218
- opacity: 0.8;
219
- transition: all 200ms;
220
- width: 60px;
221
- overflow: hidden;
222
- white-space: nowrap;
223
- text-overflow: ellipsis;
224
-
225
- &:hover {
226
- opacity: 1;
227
- cursor: pointer;
228
- }
229
-
230
- &:first-child {
231
- margin-right: 20px;
232
- }
233
-
234
- &.active {
235
- opacity: 1;
236
- color: @font-color-dark;
237
- }
238
- }
239
- }
240
-
241
- .editify-video-remote {
242
- display: block;
243
- width: 100%;
244
-
245
- input {
246
- appearance: none;
247
- -webkit-appearance: none;
248
- -moz-appearance: none;
249
- display: block;
250
- width: 100%;
251
- margin: 0 0 10px 0;
252
- padding: 4px 2px;
253
- border: none;
254
- font-size: @font-size;
255
- color: @font-color;
256
- border-bottom: 1px solid @border-color;
257
- line-height: 1.5;
258
- transition: border-color 500ms;
259
- background-color: transparent;
260
- outline: none;
261
- box-sizing: border-box;
262
-
263
- &::-webkit-input-placeholder,
264
- &::placeholder {
265
- color: @font-color-disabled;
266
- font-family: inherit;
267
- font-size: inherit;
268
- vertical-align: middle;
269
- }
270
- }
271
-
272
- .editify-video-remote-footer {
273
- display: flex;
274
- justify-content: flex-end;
275
- align-items: center;
276
- width: 100%;
277
- font-size: @font-size;
278
- opacity: 0.8;
279
- transition: all 200ms;
280
-
281
- &:hover {
282
- cursor: pointer;
283
- opacity: 1;
284
- }
285
- }
286
- }
287
-
288
- .editify-video-upload {
289
- display: flex;
290
- justify-content: center;
291
- align-items: center;
292
- width: 100%;
293
- padding: 15px 0;
294
- font-size: 36px;
295
- opacity: 0.8;
296
- transition: all 200ms;
297
- position: relative;
298
-
299
- &:hover {
300
- cursor: pointer;
301
- opacity: 1;
302
- }
303
-
304
- input {
305
- opacity: 0;
306
- position: absolute;
307
- left: 0;
308
- top: 0;
309
- width: 100%;
310
- height: 100%;
311
- z-index: 1;
312
- cursor: pointer;
313
- }
314
- }
315
- }
316
- </style>
package/src/index.js DELETED
@@ -1,24 +0,0 @@
1
- //引入AlexElement
2
- import { AlexElement } from 'alex-editor'
3
- //引入组件
4
- import Editify from './Editify'
5
- //引入图标样式
6
- import './icon/iconfont.css'
7
- //引入国际化
8
- import i18n from './locale'
9
- //版本号
10
- const version = '0.1.9'
11
- //安装函数
12
- const install = (app, props) => {
13
- const locale = (props ? props.locale : 'zh_CN') || 'zh_CN'
14
- app.provide('$editTrans', i18n(locale))
15
- app.provide('$editLocale', locale)
16
- app.component(Editify.name, Editify)
17
- }
18
-
19
- const stdin_default = {
20
- install,
21
- version
22
- }
23
-
24
- export { stdin_default as default, install, version, Editify, AlexElement }
@@ -1,14 +0,0 @@
1
- import en_US from './en_US'
2
- import zh_CN from './zh_CN'
3
-
4
- //翻译词组
5
- const translations = {
6
- zh_CN,
7
- en_US
8
- }
9
-
10
- export default locale => {
11
- return key => {
12
- return translations[locale][key]
13
- }
14
- }