vue-editify 0.1.27 → 0.1.30
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.
- package/lib/core/function.d.ts +265 -0
- package/lib/core/rule.d.ts +32 -0
- package/lib/core/tool.d.ts +50 -1
- package/lib/editify.es.js +140 -66
- package/lib/editify.umd.js +1 -1
- package/lib/hljs/index.d.ts +9 -0
- package/lib/index.d.ts +1 -1
- package/lib/locale/index.d.ts +5 -0
- package/lib/plugins/attachment/index.d.ts +19 -0
- package/lib/style.css +1 -1
- package/package.json +2 -2
- package/src/components/menu/menu.vue +51 -11
- package/src/core/function.ts +265 -42
- package/src/core/rule.ts +49 -7
- package/src/core/tool.ts +51 -9
- package/src/editify/editify.less +2 -1
- package/src/editify/editify.vue +3 -11
- package/src/hljs/index.ts +9 -2
- package/src/index.ts +1 -1
- package/src/locale/index.ts +5 -2
- package/src/plugins/attachment/index.ts +101 -57
- package/vite.config.ts.timestamp-1714200628309-967ea10c27215.mjs +0 -48
package/lib/core/function.d.ts
CHANGED
@@ -1,45 +1,310 @@
|
|
1
1
|
import { ObjectType } from './tool';
|
2
2
|
import { AlexElement, AlexElementsRangeType, AlexEditor } from 'alex-editor';
|
3
3
|
|
4
|
+
/**
|
5
|
+
* 判断元素是否在某个标签下,如果是返回该标签对应的元素,否则返回null
|
6
|
+
* @param element
|
7
|
+
* @param parsedom
|
8
|
+
* @returns
|
9
|
+
*/
|
4
10
|
export declare const getParsedomElementByElement: (element: AlexElement, parsedom: string) => AlexElement | null;
|
11
|
+
/**
|
12
|
+
* 获取光标是否在指定标签下,如果是返回该标签对应的元素,否则返回null
|
13
|
+
* @param editor
|
14
|
+
* @param dataRangeCaches
|
15
|
+
* @param parsedom
|
16
|
+
* @returns
|
17
|
+
*/
|
5
18
|
export declare const getCurrentParsedomElement: (editor: AlexEditor, dataRangeCaches: AlexElementsRangeType, parsedom: string) => AlexElement | null;
|
19
|
+
/**
|
20
|
+
* 判断元素是否在有序列表或者无序列表下
|
21
|
+
* @param element
|
22
|
+
* @param ordered
|
23
|
+
* @returns
|
24
|
+
*/
|
6
25
|
export declare const elementIsInList: (element: AlexElement, ordered: boolean) => boolean;
|
26
|
+
/**
|
27
|
+
* 判断元素是否在任务列表下
|
28
|
+
* @param element
|
29
|
+
* @returns
|
30
|
+
*/
|
7
31
|
export declare const elementIsInTask: (element: AlexElement) => boolean;
|
32
|
+
/**
|
33
|
+
* 判断元素是否有序或者无序列表
|
34
|
+
* @param element
|
35
|
+
* @param ordered
|
36
|
+
* @returns
|
37
|
+
*/
|
8
38
|
export declare const isList: (element: AlexElement, ordered?: boolean | undefined) => boolean;
|
39
|
+
/**
|
40
|
+
* 判断元素是否任务列表
|
41
|
+
* @param element
|
42
|
+
* @returns
|
43
|
+
*/
|
9
44
|
export declare const isTask: (element: AlexElement) => boolean;
|
45
|
+
/**
|
46
|
+
* 选区是否含有代码块
|
47
|
+
* @param editor
|
48
|
+
* @param dataRangeCaches
|
49
|
+
* @returns
|
50
|
+
*/
|
10
51
|
export declare const hasPreInRange: (editor: AlexEditor, dataRangeCaches: AlexElementsRangeType) => boolean;
|
52
|
+
/**
|
53
|
+
* 选区是否全部在代码块内
|
54
|
+
* @param editor
|
55
|
+
* @param dataRangeCaches
|
56
|
+
* @returns
|
57
|
+
*/
|
11
58
|
export declare const isRangeInPre: (editor: AlexEditor, dataRangeCaches: AlexElementsRangeType) => boolean;
|
59
|
+
/**
|
60
|
+
* 选区是否含有引用
|
61
|
+
* @param editor
|
62
|
+
* @param dataRangeCaches
|
63
|
+
* @returns
|
64
|
+
*/
|
12
65
|
export declare const hasQuoteInRange: (editor: AlexEditor, dataRangeCaches: AlexElementsRangeType) => boolean;
|
66
|
+
/**
|
67
|
+
* 选区是否全部在引用内
|
68
|
+
* @param editor
|
69
|
+
* @param dataRangeCaches
|
70
|
+
* @returns
|
71
|
+
*/
|
13
72
|
export declare const isRangeInQuote: (editor: AlexEditor, dataRangeCaches: AlexElementsRangeType) => boolean;
|
73
|
+
/**
|
74
|
+
* 选区是否含有有序列表或者无序列表
|
75
|
+
* @param editor
|
76
|
+
* @param dataRangeCaches
|
77
|
+
* @param ordered
|
78
|
+
* @returns
|
79
|
+
*/
|
14
80
|
export declare const hasListInRange: (editor: AlexEditor, dataRangeCaches: AlexElementsRangeType, ordered?: boolean | undefined) => boolean;
|
81
|
+
/**
|
82
|
+
* 选区是否全部在有序列表或者无序列表内
|
83
|
+
* @param editor
|
84
|
+
* @param dataRangeCaches
|
85
|
+
* @param ordered
|
86
|
+
* @returns
|
87
|
+
*/
|
15
88
|
export declare const isRangeInList: (editor: AlexEditor, dataRangeCaches: AlexElementsRangeType, ordered?: boolean | undefined) => boolean;
|
89
|
+
/**
|
90
|
+
* 选区是否含有任务列表
|
91
|
+
* @param editor
|
92
|
+
* @param dataRangeCaches
|
93
|
+
* @returns
|
94
|
+
*/
|
16
95
|
export declare const hasTaskInRange: (editor: AlexEditor, dataRangeCaches: AlexElementsRangeType) => boolean;
|
96
|
+
/**
|
97
|
+
* 选区是否全部在任务列表里
|
98
|
+
* @param editor
|
99
|
+
* @param dataRangeCaches
|
100
|
+
* @returns
|
101
|
+
*/
|
17
102
|
export declare const isRangeInTask: (editor: AlexEditor, dataRangeCaches: AlexElementsRangeType) => boolean;
|
103
|
+
/**
|
104
|
+
* 选区是否含有链接
|
105
|
+
* @param editor
|
106
|
+
* @param dataRangeCaches
|
107
|
+
* @returns
|
108
|
+
*/
|
18
109
|
export declare const hasLinkInRange: (editor: AlexEditor, dataRangeCaches: AlexElementsRangeType) => boolean;
|
110
|
+
/**
|
111
|
+
* 选区是否含有表格
|
112
|
+
* @param editor
|
113
|
+
* @param dataRangeCaches
|
114
|
+
* @returns
|
115
|
+
*/
|
19
116
|
export declare const hasTableInRange: (editor: AlexEditor, dataRangeCaches: AlexElementsRangeType) => boolean;
|
117
|
+
/**
|
118
|
+
* 选区是否含有图片
|
119
|
+
* @param editor
|
120
|
+
* @param dataRangeCaches
|
121
|
+
* @returns
|
122
|
+
*/
|
20
123
|
export declare const hasImageInRange: (editor: AlexEditor, dataRangeCaches: AlexElementsRangeType) => boolean;
|
124
|
+
/**
|
125
|
+
* 选区是否含有视频
|
126
|
+
* @param editor
|
127
|
+
* @param dataRangeCaches
|
128
|
+
* @returns
|
129
|
+
*/
|
21
130
|
export declare const hasVideoInRange: (editor: AlexEditor, dataRangeCaches: AlexElementsRangeType) => boolean;
|
131
|
+
/**
|
132
|
+
* 查询光标所在的文本元素是否具有某个样式
|
133
|
+
* @param editor
|
134
|
+
* @param dataRangeCaches
|
135
|
+
* @param name
|
136
|
+
* @param value
|
137
|
+
* @returns
|
138
|
+
*/
|
22
139
|
export declare const queryTextStyle: (editor: AlexEditor, dataRangeCaches: AlexElementsRangeType, name: string, value?: string | number) => boolean;
|
140
|
+
/**
|
141
|
+
* 查询光标所在的文本元素是否具有某个标记
|
142
|
+
* @param editor
|
143
|
+
* @param dataRangeCaches
|
144
|
+
* @param name
|
145
|
+
* @param value
|
146
|
+
* @returns
|
147
|
+
*/
|
23
148
|
export declare const queryTextMark: (editor: AlexEditor, dataRangeCaches: AlexElementsRangeType, name: string, value?: string | number) => boolean;
|
149
|
+
/**
|
150
|
+
* 获取选区内的文字内容,用于预置链接文字
|
151
|
+
* @param dataRangeCaches
|
152
|
+
* @returns
|
153
|
+
*/
|
24
154
|
export declare const getRangeText: (dataRangeCaches: AlexElementsRangeType) => string;
|
155
|
+
/**
|
156
|
+
* 获取光标选取内的扁平化元素数组(可能会分割文本元素导致stack变更,同时也会更新选取元素和光标位置)
|
157
|
+
* @param editor
|
158
|
+
* @param dataRangeCaches
|
159
|
+
* @returns
|
160
|
+
*/
|
25
161
|
export declare const getFlatElementsByRange: (editor: AlexEditor, dataRangeCaches: AlexElementsRangeType) => AlexElement[];
|
162
|
+
/**
|
163
|
+
* 将某个元素转为段落标签
|
164
|
+
* @param element
|
165
|
+
*/
|
26
166
|
export declare const elementToParagraph: (element: AlexElement) => void;
|
167
|
+
/**
|
168
|
+
* 其他元素转为有序或者无序列表
|
169
|
+
* @param element
|
170
|
+
* @param ordered
|
171
|
+
* @returns
|
172
|
+
*/
|
27
173
|
export declare const elementToList: (element: AlexElement, ordered?: boolean | undefined) => void;
|
174
|
+
/**
|
175
|
+
* 其他元素转为任务列表
|
176
|
+
* @param element
|
177
|
+
* @returns
|
178
|
+
*/
|
28
179
|
export declare const elementToTask: (element: AlexElement) => void;
|
180
|
+
/**
|
181
|
+
* 设置标题
|
182
|
+
* @param editor
|
183
|
+
* @param dataRangeCaches
|
184
|
+
* @param editTrans
|
185
|
+
* @param parsedom
|
186
|
+
* @returns
|
187
|
+
*/
|
29
188
|
export declare const setHeading: (editor: AlexEditor, dataRangeCaches: AlexElementsRangeType, editTrans: (key: string) => any, parsedom: string) => void;
|
189
|
+
/**
|
190
|
+
* 根级块元素或者内部块元素增加缩进
|
191
|
+
* @param editor
|
192
|
+
* @param dataRangeCaches
|
193
|
+
* @returns
|
194
|
+
*/
|
30
195
|
export declare const setIndentIncrease: (editor: AlexEditor, dataRangeCaches: AlexElementsRangeType) => void;
|
196
|
+
/**
|
197
|
+
* 根级块元素或者内部块元素减少缩进
|
198
|
+
* @param editor
|
199
|
+
* @param dataRangeCaches
|
200
|
+
* @returns
|
201
|
+
*/
|
31
202
|
export declare const setIndentDecrease: (editor: AlexEditor, dataRangeCaches: AlexElementsRangeType) => void;
|
203
|
+
/**
|
204
|
+
* 插入或者取消引用
|
205
|
+
* @param editor
|
206
|
+
* @param dataRangeCaches
|
207
|
+
* @returns
|
208
|
+
*/
|
32
209
|
export declare const setQuote: (editor: AlexEditor, dataRangeCaches: AlexElementsRangeType) => void;
|
210
|
+
/**
|
211
|
+
* 设置对齐方式,参数取值justify/left/right/center
|
212
|
+
* @param editor
|
213
|
+
* @param dataRangeCaches
|
214
|
+
* @param value
|
215
|
+
* @returns
|
216
|
+
*/
|
33
217
|
export declare const setAlign: (editor: AlexEditor, dataRangeCaches: AlexElementsRangeType, value: string) => void;
|
218
|
+
/**
|
219
|
+
* 插入或者取消 有序或者无序列表 ordered为true表示有序列表
|
220
|
+
* @param editor
|
221
|
+
* @param dataRangeCaches
|
222
|
+
* @param ordered
|
223
|
+
* @returns
|
224
|
+
*/
|
34
225
|
export declare const setList: (editor: AlexEditor, dataRangeCaches: AlexElementsRangeType, ordered: boolean) => void;
|
226
|
+
/**
|
227
|
+
* 插入或者取消任务列表
|
228
|
+
* @param editor
|
229
|
+
* @param dataRangeCaches
|
230
|
+
* @returns
|
231
|
+
*/
|
35
232
|
export declare const setTask: (editor: AlexEditor, dataRangeCaches: AlexElementsRangeType) => void;
|
233
|
+
/**
|
234
|
+
* 设置文本元素的样式,styles为{ 'font-weight':'bold' }这类格式
|
235
|
+
* @param editor
|
236
|
+
* @param dataRangeCaches
|
237
|
+
* @param styles
|
238
|
+
* @returns
|
239
|
+
*/
|
36
240
|
export declare const setTextStyle: (editor: AlexEditor, dataRangeCaches: AlexElementsRangeType, styles: ObjectType) => void;
|
241
|
+
/**
|
242
|
+
* 设置文本元素的标记,marks为{ 'class':'a' }这类格式
|
243
|
+
* @param editor
|
244
|
+
* @param dataRangeCaches
|
245
|
+
* @param marks
|
246
|
+
* @returns
|
247
|
+
*/
|
37
248
|
export declare const setTextMark: (editor: AlexEditor, dataRangeCaches: AlexElementsRangeType, marks: ObjectType) => void;
|
249
|
+
/**
|
250
|
+
* 移除文本元素的样式,styleNames是样式名称数组,如果不存在则移除全部样式
|
251
|
+
* @param editor
|
252
|
+
* @param dataRangeCaches
|
253
|
+
* @param styleNames
|
254
|
+
* @returns
|
255
|
+
*/
|
38
256
|
export declare const removeTextStyle: (editor: AlexEditor, dataRangeCaches: AlexElementsRangeType, styleNames?: string[]) => void;
|
257
|
+
/**
|
258
|
+
* 移除文本元素的标记,markNames是标记名称数组,如果不存在则移除全部标记
|
259
|
+
* @param editor
|
260
|
+
* @param dataRangeCaches
|
261
|
+
* @param markNames
|
262
|
+
* @returns
|
263
|
+
*/
|
39
264
|
export declare const removeTextMark: (editor: AlexEditor, dataRangeCaches: AlexElementsRangeType, markNames?: string[]) => void;
|
265
|
+
/**
|
266
|
+
* 设置块元素或者根级块元素的行高
|
267
|
+
* @param editor
|
268
|
+
* @param dataRangeCaches
|
269
|
+
* @param value
|
270
|
+
* @returns
|
271
|
+
*/
|
40
272
|
export declare const setLineHeight: (editor: AlexEditor, dataRangeCaches: AlexElementsRangeType, value: string | number) => void;
|
273
|
+
/**
|
274
|
+
* 插入链接
|
275
|
+
* @param editor
|
276
|
+
* @param text
|
277
|
+
* @param url
|
278
|
+
* @param newOpen
|
279
|
+
* @returns
|
280
|
+
*/
|
41
281
|
export declare const insertLink: (editor: AlexEditor, text: string, url: string, newOpen: boolean) => void;
|
282
|
+
/**
|
283
|
+
* 插入图片
|
284
|
+
* @param editor
|
285
|
+
* @param value
|
286
|
+
* @returns
|
287
|
+
*/
|
42
288
|
export declare const insertImage: (editor: AlexEditor, value: string) => void;
|
289
|
+
/**
|
290
|
+
* 插入视频
|
291
|
+
* @param editor
|
292
|
+
* @param value
|
293
|
+
* @returns
|
294
|
+
*/
|
43
295
|
export declare const insertVideo: (editor: AlexEditor, value: string) => void;
|
296
|
+
/**
|
297
|
+
* 插入表格
|
298
|
+
* @param editor
|
299
|
+
* @param rowLength
|
300
|
+
* @param colLength
|
301
|
+
* @returns
|
302
|
+
*/
|
44
303
|
export declare const insertTable: (editor: AlexEditor, rowLength: number, colLength: number) => void;
|
304
|
+
/**
|
305
|
+
* 插入或者取消代码块
|
306
|
+
* @param editor
|
307
|
+
* @param dataRangeCaches
|
308
|
+
* @returns
|
309
|
+
*/
|
45
310
|
export declare const insertCodeBlock: (editor: AlexEditor, dataRangeCaches: AlexElementsRangeType) => void;
|
package/lib/core/rule.d.ts
CHANGED
@@ -1,9 +1,41 @@
|
|
1
1
|
import { LanguagesItemType } from '../hljs';
|
2
2
|
import { AlexEditor, AlexElement } from 'alex-editor';
|
3
3
|
|
4
|
+
/**
|
5
|
+
* 元素格式化时转换ol和li标签
|
6
|
+
* @param editor
|
7
|
+
* @param element
|
8
|
+
*/
|
4
9
|
export declare const parseList: (editor: AlexEditor, element: AlexElement) => void;
|
10
|
+
/**
|
11
|
+
* 元素格式化时处理有序列表的序号值
|
12
|
+
* @param editor
|
13
|
+
* @param element
|
14
|
+
*/
|
5
15
|
export declare const orderdListHandle: (editor: AlexEditor, element: AlexElement) => void;
|
16
|
+
/**
|
17
|
+
* 元素格式化时处理媒体元素和链接
|
18
|
+
* @param editor
|
19
|
+
* @param element
|
20
|
+
*/
|
6
21
|
export declare const mediaHandle: (editor: AlexEditor, element: AlexElement) => void;
|
22
|
+
/**
|
23
|
+
* 元素格式化时处理表格
|
24
|
+
* @param editor
|
25
|
+
* @param element
|
26
|
+
*/
|
7
27
|
export declare const tableHandle: (editor: AlexEditor, element: AlexElement) => void;
|
28
|
+
/**
|
29
|
+
* 元素格式化时处理pre,将pre的内容根据语言进行样式处理
|
30
|
+
* @param editor
|
31
|
+
* @param element
|
32
|
+
* @param highlight
|
33
|
+
* @param languages
|
34
|
+
*/
|
8
35
|
export declare const preHandle: (editor: AlexEditor, element: AlexElement, highlight: boolean, languages: (string | LanguagesItemType)[]) => void;
|
36
|
+
/**
|
37
|
+
* 元素格式化时处理一些特殊的内部块元素,转为根级块元素
|
38
|
+
* @param editor
|
39
|
+
* @param element
|
40
|
+
*/
|
9
41
|
export declare const specialInblockHandle: (editor: AlexEditor, element: AlexElement) => void;
|
package/lib/core/tool.d.ts
CHANGED
@@ -176,8 +176,14 @@ export type MenuConfigType = {
|
|
176
176
|
fullScreen?: MenuButtonType;
|
177
177
|
extends?: MenuExtendType;
|
178
178
|
};
|
179
|
+
export type PluginMenuConfigType = {
|
180
|
+
extraDisabled?: ((name: string) => boolean) | null;
|
181
|
+
sequence: number;
|
182
|
+
extend: MenuCustomButtonType;
|
183
|
+
};
|
179
184
|
export type PluginResultType = {
|
180
|
-
|
185
|
+
name: string;
|
186
|
+
menu?: PluginMenuConfigType;
|
181
187
|
updateView?: () => void;
|
182
188
|
customParseNode?: (element: AlexElement) => AlexElement;
|
183
189
|
renderRule?: (el: AlexElement) => void;
|
@@ -185,11 +191,54 @@ export type PluginResultType = {
|
|
185
191
|
pasteKeepMarks?: ObjectType;
|
186
192
|
};
|
187
193
|
export type PluginType = (editifyInstance: ComponentInternalInstance, color: string | null, editTrans: (key: string) => any) => PluginResultType;
|
194
|
+
/**
|
195
|
+
* 粘贴html时保留的数据
|
196
|
+
*/
|
188
197
|
export declare const pasteKeepData: ObjectType;
|
198
|
+
/**
|
199
|
+
* 对象平替值方法
|
200
|
+
* @param o1
|
201
|
+
* @param o2
|
202
|
+
* @returns
|
203
|
+
*/
|
189
204
|
export declare const mergeObject: (o1: ObjectType, o2: ObjectType) => ObjectType | null;
|
205
|
+
/**
|
206
|
+
* 判断对象是否含有某个属性或者属性值是否一致
|
207
|
+
* @param obj
|
208
|
+
* @param name
|
209
|
+
* @param value
|
210
|
+
* @returns
|
211
|
+
*/
|
190
212
|
export declare const queryHasValue: (obj: ObjectType, name: string, value?: string | number) => boolean;
|
213
|
+
/**
|
214
|
+
* 深拷贝函数
|
215
|
+
* @param data
|
216
|
+
* @returns
|
217
|
+
*/
|
191
218
|
export declare const cloneData: (data: any) => any;
|
219
|
+
/**
|
220
|
+
* 根据行元素获取colgroup的col数量
|
221
|
+
* @param row
|
222
|
+
* @returns
|
223
|
+
*/
|
192
224
|
export declare const getColNumbers: (row: AlexElement) => number;
|
225
|
+
/**
|
226
|
+
* 获取菜单按钮列表数据配置
|
227
|
+
* @param editTrans
|
228
|
+
* @returns
|
229
|
+
*/
|
193
230
|
export declare const getButtonOptionsConfig: (editTrans: (key: string) => any) => ButtonOptionsConfigType;
|
231
|
+
/**
|
232
|
+
* 工具条全量配置
|
233
|
+
* @param editTrans
|
234
|
+
* @param editLocale
|
235
|
+
* @returns
|
236
|
+
*/
|
194
237
|
export declare const getToolbarConfig: (editTrans: (key: string) => any, editLocale: LocaleType) => ToolbarConfigType;
|
238
|
+
/**
|
239
|
+
* 菜单栏全量配置
|
240
|
+
* @param editTrans
|
241
|
+
* @param editLocale
|
242
|
+
* @returns
|
243
|
+
*/
|
195
244
|
export declare const getMenuConfig: (editTrans: (key: string) => any, editLocale: LocaleType) => MenuConfigType;
|