vue-editify 0.1.46 → 0.1.48
Sign up to get free protection for your applications and to get access to all the features.
- package/examples/App.vue +30 -51
- package/lib/core/function.d.ts +50 -63
- package/lib/editify.es.js +18653 -18044
- package/lib/editify.umd.js +1 -1
- package/lib/index.d.ts +6 -2
- package/lib/plugins/infoBlock/index.d.ts +55 -0
- package/lib/plugins/panel/index.d.ts +48 -0
- package/lib/style.css +1 -1
- package/package.json +2 -2
- package/src/components/menu/menu.vue +14 -13
- package/src/components/toolbar/toolbar.vue +146 -111
- package/src/core/function.ts +249 -183
- package/src/core/rule.ts +78 -48
- package/src/editify/editify.less +52 -1
- package/src/editify/editify.vue +29 -29
- package/src/icon/iconfont.css +8 -0
- package/src/icon/iconfont.ttf +0 -0
- package/src/icon/iconfont.woff +0 -0
- package/src/index.ts +8 -2
- package/src/locale/en_US.ts +9 -1
- package/src/locale/zh_CN.ts +9 -1
- package/src/plugins/attachment/index.ts +10 -6
- package/src/plugins/infoBlock/index.ts +238 -0
- package/src/plugins/mathformula/index.ts +1 -3
- package/src/plugins/panel/index.ts +228 -0
package/examples/App.vue
CHANGED
@@ -1,51 +1,13 @@
|
|
1
1
|
<template>
|
2
2
|
<div style="padding: 10px; height: 100%; box-sizing: border-box">
|
3
|
-
<
|
4
|
-
|
5
|
-
<tr>
|
6
|
-
<td><br /></td>
|
7
|
-
<td><br /></td>
|
8
|
-
<td><br /></td>
|
9
|
-
<td><br /></td>
|
10
|
-
<td><br /></td>
|
11
|
-
</tr>
|
12
|
-
<tr>
|
13
|
-
<td><br /></td>
|
14
|
-
<td><br /></td>
|
15
|
-
<td><br /></td>
|
16
|
-
<td><br /></td>
|
17
|
-
<td><br /></td>
|
18
|
-
</tr>
|
19
|
-
<tr>
|
20
|
-
<td><br /></td>
|
21
|
-
<td><br /></td>
|
22
|
-
<td><br /></td>
|
23
|
-
<td><br /></td>
|
24
|
-
<td><br /></td>
|
25
|
-
</tr>
|
26
|
-
<tr>
|
27
|
-
<td><br /></td>
|
28
|
-
<td><br /></td>
|
29
|
-
<td><br /></td>
|
30
|
-
<td><br /></td>
|
31
|
-
<td><br /></td>
|
32
|
-
</tr>
|
33
|
-
<tr>
|
34
|
-
<td><br /></td>
|
35
|
-
<td><br /></td>
|
36
|
-
<td><br /></td>
|
37
|
-
<td><br /></td>
|
38
|
-
<td><br /></td>
|
39
|
-
</tr>
|
40
|
-
</tbody>
|
41
|
-
</table>
|
42
|
-
<Editify ref="editify" border v-model="val" :menu="menuConfig" style="height: 100%" placeholder="Please Enter Text..." :toolbar="toolbarConfig" locale="zh_CN" allow-paste-html :plugins="plugins" @rangeupdate="rangeupdate"></Editify>
|
3
|
+
<button @click="setStart">setStart</button>
|
4
|
+
<Editify color="#f30" ref="editify" border v-model="val" :menu="menuConfig" style="height: 100%" placeholder="Please Enter Text..." :toolbar="toolbarConfig" locale="zh_CN" allow-paste-html :plugins="plugins" @rangeupdate="rangeUpdate"></Editify>
|
43
5
|
</div>
|
44
6
|
</template>
|
45
7
|
<script setup lang="ts">
|
46
|
-
import { h, ref } from 'vue'
|
47
|
-
import { AlexElement, MenuConfigType, Editify, attachment, PluginType, mathformula, ToolbarConfigType,
|
48
|
-
const val = ref<string>('<
|
8
|
+
import { h, onMounted, ref } from 'vue'
|
9
|
+
import { AlexElement, MenuConfigType, Editify, attachment, PluginType, mathformula, ToolbarConfigType, getMatchElementByRange, panel, elementIsMatch, infoBlock } from '../src/index'
|
10
|
+
const val = ref<string>('33<div data-editify-info="true">4444</div>3333<div data-editify-panel="true"><div>标题</div><div>这是一个面板</div></div>333')
|
49
11
|
|
50
12
|
const editify = ref<InstanceType<typeof Editify> | null>(null)
|
51
13
|
const menuConfig = ref<MenuConfigType>({
|
@@ -66,19 +28,36 @@ const toolbarConfig = ref<ToolbarConfigType>({
|
|
66
28
|
})
|
67
29
|
|
68
30
|
const plugins = ref<PluginType[]>([
|
69
|
-
|
31
|
+
panel(),
|
32
|
+
mathformula(),
|
33
|
+
attachment(),
|
34
|
+
infoBlock({
|
70
35
|
leftBorder: true
|
71
|
-
})
|
72
|
-
mathformula()
|
36
|
+
})
|
73
37
|
])
|
74
38
|
|
75
|
-
const
|
76
|
-
|
77
|
-
|
78
|
-
|
39
|
+
const setStart = () => {
|
40
|
+
editify.value!.editor!.range!.anchor.moveToStart(editify.value!.editor!.stack[0])
|
41
|
+
editify.value!.editor!.range!.focus.moveToStart(editify.value!.editor!.stack[0])
|
42
|
+
editify.value!.editor!.rangeRender()
|
43
|
+
}
|
44
|
+
|
45
|
+
const rangeUpdate = () => {
|
46
|
+
const element = getMatchElementByRange(editify.value!.editor!, editify.value!.dataRangeCaches, {
|
47
|
+
parsedom: 'div',
|
48
|
+
marks: {
|
49
|
+
'data-editify-task': true
|
79
50
|
}
|
80
51
|
})
|
81
|
-
|
52
|
+
if (element) {
|
53
|
+
console.log(
|
54
|
+
elementIsMatch(element, {
|
55
|
+
marks: {
|
56
|
+
'data-editify-task': true
|
57
|
+
}
|
58
|
+
})
|
59
|
+
)
|
60
|
+
}
|
82
61
|
}
|
83
62
|
</script>
|
84
63
|
<style lang="less">
|
package/lib/core/function.d.ts
CHANGED
@@ -6,12 +6,6 @@ export type ElementMatchConfigType = {
|
|
6
6
|
marks?: ObjectType;
|
7
7
|
styles?: ObjectType;
|
8
8
|
};
|
9
|
-
export type CellMergeTypeResultType = {
|
10
|
-
crossRow: boolean;
|
11
|
-
crossColumn: boolean;
|
12
|
-
rowspan?: number;
|
13
|
-
colspan?: number;
|
14
|
-
};
|
15
9
|
/**
|
16
10
|
* 清空单元格的内容并隐藏
|
17
11
|
* @param editor
|
@@ -61,39 +55,39 @@ export declare const elementIsMatch: (element: AlexElement, config: ElementMatch
|
|
61
55
|
*/
|
62
56
|
export declare const getMatchElementByElement: (element: AlexElement, config: ElementMatchConfigType) => AlexElement | null;
|
63
57
|
/**
|
64
|
-
* Open API
|
58
|
+
* Open API:判断光标范围内的元素是否在同一个符合条件的元素下,如果是返回那个符合条件的元素,否则返回null
|
65
59
|
* @param editor
|
66
60
|
* @param dataRangeCaches
|
67
61
|
* @param config
|
68
62
|
* @returns
|
69
63
|
*/
|
70
|
-
export declare const
|
64
|
+
export declare const getMatchElementByRange: (editor: AlexEditor, dataRangeCaches: AlexElementsRangeType, config: ElementMatchConfigType) => AlexElement | null;
|
71
65
|
/**
|
72
|
-
* Open API
|
66
|
+
* Open API:判断元素是否有序或者无序列表
|
73
67
|
* @param element
|
74
68
|
* @param ordered
|
75
69
|
* @returns
|
76
70
|
*/
|
77
|
-
export declare const
|
71
|
+
export declare const isList: (element: AlexElement, ordered?: boolean | undefined) => boolean;
|
78
72
|
/**
|
79
|
-
* Open API
|
73
|
+
* Open API:判断元素是否任务列表
|
80
74
|
* @param element
|
81
75
|
* @returns
|
82
76
|
*/
|
83
|
-
export declare const
|
77
|
+
export declare const isTask: (element: AlexElement) => boolean;
|
84
78
|
/**
|
85
|
-
* Open API
|
79
|
+
* Open API:判断元素是否在有序列表或者无序列表下
|
86
80
|
* @param element
|
87
81
|
* @param ordered
|
88
82
|
* @returns
|
89
83
|
*/
|
90
|
-
export declare const
|
84
|
+
export declare const elementIsInList: (element: AlexElement, ordered: boolean) => boolean;
|
91
85
|
/**
|
92
|
-
* Open API
|
86
|
+
* Open API:判断元素是否在任务列表下
|
93
87
|
* @param element
|
94
88
|
* @returns
|
95
89
|
*/
|
96
|
-
export declare const
|
90
|
+
export declare const elementIsInTask: (element: AlexElement) => boolean;
|
97
91
|
/**
|
98
92
|
* Open API:选区是否含有代码块
|
99
93
|
* @param editor
|
@@ -101,13 +95,6 @@ export declare const isTask: (element: AlexElement) => boolean;
|
|
101
95
|
* @returns
|
102
96
|
*/
|
103
97
|
export declare const hasPreInRange: (editor: AlexEditor, dataRangeCaches: AlexElementsRangeType) => boolean;
|
104
|
-
/**
|
105
|
-
* Open API:选区是否全部在代码块内
|
106
|
-
* @param editor
|
107
|
-
* @param dataRangeCaches
|
108
|
-
* @returns
|
109
|
-
*/
|
110
|
-
export declare const isRangeInPre: (editor: AlexEditor, dataRangeCaches: AlexElementsRangeType) => boolean;
|
111
98
|
/**
|
112
99
|
* Open API:选区是否含有引用
|
113
100
|
* @param editor
|
@@ -116,70 +103,70 @@ export declare const isRangeInPre: (editor: AlexEditor, dataRangeCaches: AlexEle
|
|
116
103
|
*/
|
117
104
|
export declare const hasQuoteInRange: (editor: AlexEditor, dataRangeCaches: AlexElementsRangeType) => boolean;
|
118
105
|
/**
|
119
|
-
* Open API
|
106
|
+
* Open API:选区是否含有有序列表或者无序列表
|
120
107
|
* @param editor
|
121
108
|
* @param dataRangeCaches
|
109
|
+
* @param ordered
|
122
110
|
* @returns
|
123
111
|
*/
|
124
|
-
export declare const
|
112
|
+
export declare const hasListInRange: (editor: AlexEditor, dataRangeCaches: AlexElementsRangeType, ordered?: boolean | undefined) => boolean;
|
125
113
|
/**
|
126
|
-
* Open API
|
114
|
+
* Open API:选区是否含有任务列表
|
127
115
|
* @param editor
|
128
116
|
* @param dataRangeCaches
|
129
|
-
* @param ordered
|
130
117
|
* @returns
|
131
118
|
*/
|
132
|
-
export declare const
|
119
|
+
export declare const hasTaskInRange: (editor: AlexEditor, dataRangeCaches: AlexElementsRangeType) => boolean;
|
133
120
|
/**
|
134
|
-
* Open API
|
121
|
+
* Open API:选区是否含有链接
|
135
122
|
* @param editor
|
136
123
|
* @param dataRangeCaches
|
137
|
-
* @param ordered
|
138
124
|
* @returns
|
139
125
|
*/
|
140
|
-
export declare const
|
126
|
+
export declare const hasLinkInRange: (editor: AlexEditor, dataRangeCaches: AlexElementsRangeType) => boolean;
|
141
127
|
/**
|
142
|
-
* Open API
|
128
|
+
* Open API:选区是否含有表格
|
143
129
|
* @param editor
|
144
130
|
* @param dataRangeCaches
|
145
131
|
* @returns
|
146
132
|
*/
|
147
|
-
export declare const
|
133
|
+
export declare const hasTableInRange: (editor: AlexEditor, dataRangeCaches: AlexElementsRangeType) => boolean;
|
148
134
|
/**
|
149
|
-
* Open API
|
135
|
+
* Open API:选区是否含有图片
|
150
136
|
* @param editor
|
151
137
|
* @param dataRangeCaches
|
152
138
|
* @returns
|
153
139
|
*/
|
154
|
-
export declare const
|
140
|
+
export declare const hasImageInRange: (editor: AlexEditor, dataRangeCaches: AlexElementsRangeType) => boolean;
|
155
141
|
/**
|
156
|
-
* Open API
|
142
|
+
* Open API:选区是否含有视频
|
157
143
|
* @param editor
|
158
144
|
* @param dataRangeCaches
|
159
145
|
* @returns
|
160
146
|
*/
|
161
|
-
export declare const
|
147
|
+
export declare const hasVideoInRange: (editor: AlexEditor, dataRangeCaches: AlexElementsRangeType) => boolean;
|
162
148
|
/**
|
163
|
-
* Open API
|
149
|
+
* Open API:选区是否全部在引用内
|
164
150
|
* @param editor
|
165
151
|
* @param dataRangeCaches
|
166
152
|
* @returns
|
167
153
|
*/
|
168
|
-
export declare const
|
154
|
+
export declare const isRangeInQuote: (editor: AlexEditor, dataRangeCaches: AlexElementsRangeType) => boolean;
|
169
155
|
/**
|
170
|
-
* Open API
|
156
|
+
* Open API:选区是否全部在有序列表或者无序列表内
|
171
157
|
* @param editor
|
172
158
|
* @param dataRangeCaches
|
159
|
+
* @param ordered
|
173
160
|
* @returns
|
174
161
|
*/
|
175
|
-
export declare const
|
162
|
+
export declare const isRangeInList: (editor: AlexEditor, dataRangeCaches: AlexElementsRangeType, ordered?: boolean | undefined) => boolean;
|
176
163
|
/**
|
177
|
-
* Open API
|
164
|
+
* Open API:选区是否全部在任务列表里
|
178
165
|
* @param editor
|
179
166
|
* @param dataRangeCaches
|
180
167
|
* @returns
|
181
168
|
*/
|
182
|
-
export declare const
|
169
|
+
export declare const isRangeInTask: (editor: AlexEditor, dataRangeCaches: AlexElementsRangeType) => boolean;
|
183
170
|
/**
|
184
171
|
* Open API:查询光标所在的文本元素是否具有某个样式
|
185
172
|
* @param editor
|
@@ -260,18 +247,18 @@ export declare const setIndentDecrease: (editor: AlexEditor, dataRangeCaches: Al
|
|
260
247
|
*/
|
261
248
|
export declare const setQuote: (editor: AlexEditor, dataRangeCaches: AlexElementsRangeType) => void;
|
262
249
|
/**
|
263
|
-
* Open API
|
250
|
+
* Open API:设置对齐方式
|
264
251
|
* @param editor
|
265
252
|
* @param dataRangeCaches
|
266
|
-
* @param value
|
253
|
+
* @param value 取值justify/left/right/center
|
267
254
|
* @returns
|
268
255
|
*/
|
269
|
-
export declare const setAlign: (editor: AlexEditor, dataRangeCaches: AlexElementsRangeType, value:
|
256
|
+
export declare const setAlign: (editor: AlexEditor, dataRangeCaches: AlexElementsRangeType, value: 'justify' | 'left' | 'right' | 'center') => void;
|
270
257
|
/**
|
271
|
-
* Open API:插入或者取消 有序或者无序列表
|
258
|
+
* Open API:插入或者取消 有序或者无序列表
|
272
259
|
* @param editor
|
273
260
|
* @param dataRangeCaches
|
274
|
-
* @param ordered
|
261
|
+
* @param ordered 为true表示有序列表
|
275
262
|
* @returns
|
276
263
|
*/
|
277
264
|
export declare const setList: (editor: AlexEditor, dataRangeCaches: AlexElementsRangeType, ordered: boolean) => void;
|
@@ -283,34 +270,34 @@ export declare const setList: (editor: AlexEditor, dataRangeCaches: AlexElements
|
|
283
270
|
*/
|
284
271
|
export declare const setTask: (editor: AlexEditor, dataRangeCaches: AlexElementsRangeType) => void;
|
285
272
|
/**
|
286
|
-
* Open API
|
273
|
+
* Open API:设置文本元素的样式
|
287
274
|
* @param editor
|
288
275
|
* @param dataRangeCaches
|
289
|
-
* @param styles
|
276
|
+
* @param styles 值为{ 'font-weight':'bold' }这类格式
|
290
277
|
* @returns
|
291
278
|
*/
|
292
279
|
export declare const setTextStyle: (editor: AlexEditor, dataRangeCaches: AlexElementsRangeType, styles: ObjectType) => void;
|
293
280
|
/**
|
294
|
-
* Open API
|
281
|
+
* Open API:设置文本元素的标记
|
295
282
|
* @param editor
|
296
283
|
* @param dataRangeCaches
|
297
|
-
* @param marks
|
284
|
+
* @param marks 值为{ 'class':'a' }这类格式
|
298
285
|
* @returns
|
299
286
|
*/
|
300
287
|
export declare const setTextMark: (editor: AlexEditor, dataRangeCaches: AlexElementsRangeType, marks: ObjectType) => void;
|
301
288
|
/**
|
302
|
-
* Open API
|
289
|
+
* Open API:移除文本元素的样式
|
303
290
|
* @param editor
|
304
291
|
* @param dataRangeCaches
|
305
|
-
* @param styleNames
|
292
|
+
* @param styleNames 样式名称数组,如果不存在则移除全部样式
|
306
293
|
* @returns
|
307
294
|
*/
|
308
295
|
export declare const removeTextStyle: (editor: AlexEditor, dataRangeCaches: AlexElementsRangeType, styleNames?: string[]) => void;
|
309
296
|
/**
|
310
|
-
* Open API
|
297
|
+
* Open API:移除文本元素的标记
|
311
298
|
* @param editor
|
312
299
|
* @param dataRangeCaches
|
313
|
-
* @param markNames
|
300
|
+
* @param markNames 标记名称数组,如果不存在则移除全部标记
|
314
301
|
* @returns
|
315
302
|
*/
|
316
303
|
export declare const removeTextMark: (editor: AlexEditor, dataRangeCaches: AlexElementsRangeType, markNames?: string[]) => void;
|
@@ -325,31 +312,31 @@ export declare const setLineHeight: (editor: AlexEditor, dataRangeCaches: AlexEl
|
|
325
312
|
/**
|
326
313
|
* Open API:插入链接
|
327
314
|
* @param editor
|
328
|
-
* @param text
|
329
|
-
* @param url
|
330
|
-
* @param newOpen
|
315
|
+
* @param text 链接名称
|
316
|
+
* @param url 链接地址
|
317
|
+
* @param newOpen 是否新窗口打开
|
331
318
|
* @returns
|
332
319
|
*/
|
333
320
|
export declare const insertLink: (editor: AlexEditor, text: string, url: string, newOpen: boolean) => void;
|
334
321
|
/**
|
335
322
|
* Open API:插入图片
|
336
323
|
* @param editor
|
337
|
-
* @param value
|
324
|
+
* @param value 图片地址
|
338
325
|
* @returns
|
339
326
|
*/
|
340
327
|
export declare const insertImage: (editor: AlexEditor, value: string) => void;
|
341
328
|
/**
|
342
329
|
* Open API:插入视频
|
343
330
|
* @param editor
|
344
|
-
* @param value
|
331
|
+
* @param value 视频地址
|
345
332
|
* @returns
|
346
333
|
*/
|
347
334
|
export declare const insertVideo: (editor: AlexEditor, value: string) => void;
|
348
335
|
/**
|
349
336
|
* Open API:插入表格
|
350
337
|
* @param editor
|
351
|
-
* @param rowLength
|
352
|
-
* @param colLength
|
338
|
+
* @param rowLength 表格行数
|
339
|
+
* @param colLength 表格列数
|
353
340
|
* @returns
|
354
341
|
*/
|
355
342
|
export declare const insertTable: (editor: AlexEditor, rowLength: number, colLength: number) => void;
|