vue-editify 0.1.42 → 0.1.44

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/examples/App.vue CHANGED
@@ -1,14 +1,51 @@
1
1
  <template>
2
2
  <div style="padding: 10px; height: 100%; box-sizing: border-box">
3
+ <table>
4
+ <tbody>
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>
3
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>
4
43
  </div>
5
44
  </template>
6
45
  <script setup lang="ts">
7
46
  import { h, ref } from 'vue'
8
47
  import { AlexElement, MenuConfigType, Editify, attachment, PluginType, mathformula, ToolbarConfigType, getMatchElementsByRange } from '../src/index'
9
- const val = ref<string>(
10
- '<p><span>这是一个</span><a href="#" data-editify-element="41"><span>链接</span></a><span>文本这是一</span><span style="font-weight: bold;">个链接</span><span>文本</span></p><p><img src="https://www.ling0523.cn/images/image_0_1701871044625.jpg" data-editify-element="47"></p><p><span></span><video src="https://video.699pic.com/videos/92/12/46/b_zEMHgCfQS5fV1714921246.mp4" data-editify-element="50"></video><span></span></p><pre data-editify-element="52"><span class="editify-hljs-keyword">import</span><span> </span><span class="editify-hljs-title class_">AlexEditor</span><span> </span><span class="editify-hljs-keyword">from</span><span> </span><span class="editify-hljs-string">"alex-editor"</span></pre><table data-editify-element="60" style="white-space: pre-wrap; word-break: break-word;"><colgroup><col width="50%"><col width="auto"><col width="auto"><col width="auto"><col width="auto"><col width="auto"></colgroup><tbody><tr><th rowspan="4">1</th><th>2</th><th rowspan="3">3</th><th>4</th><th>5</th><th>6</th></tr><tr><td rowspan="3"><br></td><td><br></td><td><br></td><td><br></td></tr><tr><td><br></td><td><br></td><td><br></td></tr><tr><td><br></td><td><br></td><td colspan="2"><br></td></tr></tbody></table>'
11
- )
48
+ const val = ref<string>('<table><tbody><tr><td><br></td><td><br></td><td><br></td><td><br></td><td><br></td></tr><tr><td><br></td><td><br></td><td><br></td><td><br></td><td><br></td></tr><tr><td><br></td><td><br></td><td><br></td><td><br></td><td><br></td></tr><tr><td><br></td><td><br></td><td><br></td><td><br></td><td><br></td></tr><tr><td><br></td><td><br></td><td><br></td><td><br></td><td><br></td></tr></tbody></table>')
12
49
 
13
50
  const editify = ref<InstanceType<typeof Editify> | null>(null)
14
51
  const menuConfig = ref<MenuConfigType>({
@@ -57,4 +94,21 @@ body {
57
94
  height: 100%;
58
95
  overflow: auto;
59
96
  }
97
+
98
+ table {
99
+ border: 1px solid #ccc;
100
+ width: 100%;
101
+ border-collapse: collapse;
102
+
103
+ tr,
104
+ td,
105
+ th {
106
+ border: 1px solid #ccc;
107
+ }
108
+
109
+ td {
110
+ text-align: center;
111
+ padding: 10px;
112
+ }
113
+ }
60
114
  </style>
@@ -1,89 +1,129 @@
1
1
  import { AlexElement, AlexElementsRangeType, AlexEditor } from 'alex-editor';
2
2
  import { ObjectType } from './tool';
3
3
 
4
- export type ElementMatchConfig = {
4
+ export type ElementMatchConfigType = {
5
5
  parsedom?: string;
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
+ /**
16
+ * 清空单元格的内容并隐藏
17
+ * @param editor
18
+ * @param cell
19
+ */
20
+ export declare const setTableCellMerged: (cell: AlexElement) => void;
21
+ /**
22
+ * 判断被隐藏的单元格是属于跨行的单元格还是跨列的单元格,返回跨行或者跨列的单元格
23
+ * @param editor
24
+ * @param cell
25
+ * @returns
26
+ */
27
+ export declare const getCellMergeElement: (editor: AlexEditor, cell: AlexElement) => {
28
+ crossRowElement: AlexElement | null;
29
+ crossColumnElement: AlexElement | null;
30
+ };
31
+ /**
32
+ * 获取某个单元格的rowspan和colspan值
33
+ * @param cell
34
+ * @returns
35
+ */
36
+ export declare const getCellSpanNumber: (cell: AlexElement) => {
37
+ rowspan: number;
38
+ colspan: number;
39
+ };
40
+ /**
41
+ * 获取表格规格:行数和列数
42
+ * @param rowElements
43
+ * @returns
44
+ */
45
+ export declare const getTableSize: (rowElements: AlexElement[]) => {
46
+ rowNumber: number;
47
+ columnNumber: number;
48
+ };
9
49
  /**
10
- * 判断元素是否符合指定的条件
50
+ * Open API:判断元素是否符合指定的条件
11
51
  * @param element
12
52
  * @param config
13
53
  * @returns
14
54
  */
15
- export declare const elementIsMatch: (element: AlexElement, config: ElementMatchConfig) => boolean;
55
+ export declare const elementIsMatch: (element: AlexElement, config: ElementMatchConfigType) => boolean;
16
56
  /**
17
- * 判断元素是否在符合条件的元素下,如果是返回符合条件的元素,否则返回null
57
+ * Open API:判断元素是否在符合条件的元素下,如果是返回符合条件的元素,否则返回null
18
58
  * @param element
19
59
  * @param config
20
60
  * @returns
21
61
  */
22
- export declare const getMatchElementByElement: (element: AlexElement, config: ElementMatchConfig) => AlexElement | null;
62
+ export declare const getMatchElementByElement: (element: AlexElement, config: ElementMatchConfigType) => AlexElement | null;
23
63
  /**
24
- * 判断光标范围内的元素是否在符合条件的元素下,如果是所有的返回符合条件的元素,否则返回[]
64
+ * Open API:判断光标范围内的元素是否在符合条件的元素下,如果是所有的返回符合条件的元素,否则返回[]
25
65
  * @param editor
26
66
  * @param dataRangeCaches
27
67
  * @param config
28
68
  * @returns
29
69
  */
30
- export declare const getMatchElementsByRange: (editor: AlexEditor, dataRangeCaches: AlexElementsRangeType, config: ElementMatchConfig) => AlexElement[];
70
+ export declare const getMatchElementsByRange: (editor: AlexEditor, dataRangeCaches: AlexElementsRangeType, config: ElementMatchConfigType) => AlexElement[];
31
71
  /**
32
- * 判断元素是否在有序列表或者无序列表下
72
+ * Open API:判断元素是否在有序列表或者无序列表下
33
73
  * @param element
34
74
  * @param ordered
35
75
  * @returns
36
76
  */
37
77
  export declare const elementIsInList: (element: AlexElement, ordered: boolean) => boolean;
38
78
  /**
39
- * 判断元素是否在任务列表下
79
+ * Open API:判断元素是否在任务列表下
40
80
  * @param element
41
81
  * @returns
42
82
  */
43
83
  export declare const elementIsInTask: (element: AlexElement) => boolean;
44
84
  /**
45
- * 判断元素是否有序或者无序列表
85
+ * Open API:判断元素是否有序或者无序列表
46
86
  * @param element
47
87
  * @param ordered
48
88
  * @returns
49
89
  */
50
90
  export declare const isList: (element: AlexElement, ordered?: boolean | undefined) => boolean;
51
91
  /**
52
- * 判断元素是否任务列表
92
+ * Open API:判断元素是否任务列表
53
93
  * @param element
54
94
  * @returns
55
95
  */
56
96
  export declare const isTask: (element: AlexElement) => boolean;
57
97
  /**
58
- * 选区是否含有代码块
98
+ * Open API:选区是否含有代码块
59
99
  * @param editor
60
100
  * @param dataRangeCaches
61
101
  * @returns
62
102
  */
63
103
  export declare const hasPreInRange: (editor: AlexEditor, dataRangeCaches: AlexElementsRangeType) => boolean;
64
104
  /**
65
- * 选区是否全部在代码块内
105
+ * Open API:选区是否全部在代码块内
66
106
  * @param editor
67
107
  * @param dataRangeCaches
68
108
  * @returns
69
109
  */
70
110
  export declare const isRangeInPre: (editor: AlexEditor, dataRangeCaches: AlexElementsRangeType) => boolean;
71
111
  /**
72
- * 选区是否含有引用
112
+ * Open API:选区是否含有引用
73
113
  * @param editor
74
114
  * @param dataRangeCaches
75
115
  * @returns
76
116
  */
77
117
  export declare const hasQuoteInRange: (editor: AlexEditor, dataRangeCaches: AlexElementsRangeType) => boolean;
78
118
  /**
79
- * 选区是否全部在引用内
119
+ * Open API:选区是否全部在引用内
80
120
  * @param editor
81
121
  * @param dataRangeCaches
82
122
  * @returns
83
123
  */
84
124
  export declare const isRangeInQuote: (editor: AlexEditor, dataRangeCaches: AlexElementsRangeType) => boolean;
85
125
  /**
86
- * 选区是否含有有序列表或者无序列表
126
+ * Open API:选区是否含有有序列表或者无序列表
87
127
  * @param editor
88
128
  * @param dataRangeCaches
89
129
  * @param ordered
@@ -91,7 +131,7 @@ export declare const isRangeInQuote: (editor: AlexEditor, dataRangeCaches: AlexE
91
131
  */
92
132
  export declare const hasListInRange: (editor: AlexEditor, dataRangeCaches: AlexElementsRangeType, ordered?: boolean | undefined) => boolean;
93
133
  /**
94
- * 选区是否全部在有序列表或者无序列表内
134
+ * Open API:选区是否全部在有序列表或者无序列表内
95
135
  * @param editor
96
136
  * @param dataRangeCaches
97
137
  * @param ordered
@@ -99,49 +139,49 @@ export declare const hasListInRange: (editor: AlexEditor, dataRangeCaches: AlexE
99
139
  */
100
140
  export declare const isRangeInList: (editor: AlexEditor, dataRangeCaches: AlexElementsRangeType, ordered?: boolean | undefined) => boolean;
101
141
  /**
102
- * 选区是否含有任务列表
142
+ * Open API:选区是否含有任务列表
103
143
  * @param editor
104
144
  * @param dataRangeCaches
105
145
  * @returns
106
146
  */
107
147
  export declare const hasTaskInRange: (editor: AlexEditor, dataRangeCaches: AlexElementsRangeType) => boolean;
108
148
  /**
109
- * 选区是否全部在任务列表里
149
+ * Open API:选区是否全部在任务列表里
110
150
  * @param editor
111
151
  * @param dataRangeCaches
112
152
  * @returns
113
153
  */
114
154
  export declare const isRangeInTask: (editor: AlexEditor, dataRangeCaches: AlexElementsRangeType) => boolean;
115
155
  /**
116
- * 选区是否含有链接
156
+ * Open API:选区是否含有链接
117
157
  * @param editor
118
158
  * @param dataRangeCaches
119
159
  * @returns
120
160
  */
121
161
  export declare const hasLinkInRange: (editor: AlexEditor, dataRangeCaches: AlexElementsRangeType) => boolean;
122
162
  /**
123
- * 选区是否含有表格
163
+ * Open API:选区是否含有表格
124
164
  * @param editor
125
165
  * @param dataRangeCaches
126
166
  * @returns
127
167
  */
128
168
  export declare const hasTableInRange: (editor: AlexEditor, dataRangeCaches: AlexElementsRangeType) => boolean;
129
169
  /**
130
- * 选区是否含有图片
170
+ * Open API:选区是否含有图片
131
171
  * @param editor
132
172
  * @param dataRangeCaches
133
173
  * @returns
134
174
  */
135
175
  export declare const hasImageInRange: (editor: AlexEditor, dataRangeCaches: AlexElementsRangeType) => boolean;
136
176
  /**
137
- * 选区是否含有视频
177
+ * Open API:选区是否含有视频
138
178
  * @param editor
139
179
  * @param dataRangeCaches
140
180
  * @returns
141
181
  */
142
182
  export declare const hasVideoInRange: (editor: AlexEditor, dataRangeCaches: AlexElementsRangeType) => boolean;
143
183
  /**
144
- * 查询光标所在的文本元素是否具有某个样式
184
+ * Open API:查询光标所在的文本元素是否具有某个样式
145
185
  * @param editor
146
186
  * @param dataRangeCaches
147
187
  * @param name
@@ -150,7 +190,7 @@ export declare const hasVideoInRange: (editor: AlexEditor, dataRangeCaches: Alex
150
190
  */
151
191
  export declare const queryTextStyle: (editor: AlexEditor, dataRangeCaches: AlexElementsRangeType, name: string, value?: string | number) => boolean;
152
192
  /**
153
- * 查询光标所在的文本元素是否具有某个标记
193
+ * Open API:查询光标所在的文本元素是否具有某个标记
154
194
  * @param editor
155
195
  * @param dataRangeCaches
156
196
  * @param name
@@ -159,7 +199,7 @@ export declare const queryTextStyle: (editor: AlexEditor, dataRangeCaches: AlexE
159
199
  */
160
200
  export declare const queryTextMark: (editor: AlexEditor, dataRangeCaches: AlexElementsRangeType, name: string, value?: string | number) => boolean;
161
201
  /**
162
- * 获取选区内的文字内容,用于预置链接文字
202
+ * Open API:获取选区内的文字内容,用于预置链接文字
163
203
  * @param dataRangeCaches
164
204
  * @returns
165
205
  */
@@ -199,28 +239,28 @@ export declare const elementToTask: (element: AlexElement) => void;
199
239
  */
200
240
  export declare const setHeading: (editor: AlexEditor, dataRangeCaches: AlexElementsRangeType, editTrans: (key: string) => any, parsedom: string) => void;
201
241
  /**
202
- * 根级块元素或者内部块元素增加缩进
242
+ * Open API:根级块元素或者内部块元素增加缩进
203
243
  * @param editor
204
244
  * @param dataRangeCaches
205
245
  * @returns
206
246
  */
207
247
  export declare const setIndentIncrease: (editor: AlexEditor, dataRangeCaches: AlexElementsRangeType) => void;
208
248
  /**
209
- * 根级块元素或者内部块元素减少缩进
249
+ * Open API:根级块元素或者内部块元素减少缩进
210
250
  * @param editor
211
251
  * @param dataRangeCaches
212
252
  * @returns
213
253
  */
214
254
  export declare const setIndentDecrease: (editor: AlexEditor, dataRangeCaches: AlexElementsRangeType) => void;
215
255
  /**
216
- * 插入或者取消引用
256
+ * Open API:插入或者取消引用
217
257
  * @param editor
218
258
  * @param dataRangeCaches
219
259
  * @returns
220
260
  */
221
261
  export declare const setQuote: (editor: AlexEditor, dataRangeCaches: AlexElementsRangeType) => void;
222
262
  /**
223
- * 设置对齐方式,参数取值justify/left/right/center
263
+ * Open API:设置对齐方式,参数取值justify/left/right/center
224
264
  * @param editor
225
265
  * @param dataRangeCaches
226
266
  * @param value
@@ -228,7 +268,7 @@ export declare const setQuote: (editor: AlexEditor, dataRangeCaches: AlexElement
228
268
  */
229
269
  export declare const setAlign: (editor: AlexEditor, dataRangeCaches: AlexElementsRangeType, value: string) => void;
230
270
  /**
231
- * 插入或者取消 有序或者无序列表 ordered为true表示有序列表
271
+ * Open API:插入或者取消 有序或者无序列表 ordered为true表示有序列表
232
272
  * @param editor
233
273
  * @param dataRangeCaches
234
274
  * @param ordered
@@ -236,14 +276,14 @@ export declare const setAlign: (editor: AlexEditor, dataRangeCaches: AlexElement
236
276
  */
237
277
  export declare const setList: (editor: AlexEditor, dataRangeCaches: AlexElementsRangeType, ordered: boolean) => void;
238
278
  /**
239
- * 插入或者取消任务列表
279
+ * Open API:插入或者取消任务列表
240
280
  * @param editor
241
281
  * @param dataRangeCaches
242
282
  * @returns
243
283
  */
244
284
  export declare const setTask: (editor: AlexEditor, dataRangeCaches: AlexElementsRangeType) => void;
245
285
  /**
246
- * 设置文本元素的样式,styles为{ 'font-weight':'bold' }这类格式
286
+ * Open API:设置文本元素的样式,styles为{ 'font-weight':'bold' }这类格式
247
287
  * @param editor
248
288
  * @param dataRangeCaches
249
289
  * @param styles
@@ -251,7 +291,7 @@ export declare const setTask: (editor: AlexEditor, dataRangeCaches: AlexElements
251
291
  */
252
292
  export declare const setTextStyle: (editor: AlexEditor, dataRangeCaches: AlexElementsRangeType, styles: ObjectType) => void;
253
293
  /**
254
- * 设置文本元素的标记,marks为{ 'class':'a' }这类格式
294
+ * Open API:设置文本元素的标记,marks为{ 'class':'a' }这类格式
255
295
  * @param editor
256
296
  * @param dataRangeCaches
257
297
  * @param marks
@@ -259,7 +299,7 @@ export declare const setTextStyle: (editor: AlexEditor, dataRangeCaches: AlexEle
259
299
  */
260
300
  export declare const setTextMark: (editor: AlexEditor, dataRangeCaches: AlexElementsRangeType, marks: ObjectType) => void;
261
301
  /**
262
- * 移除文本元素的样式,styleNames是样式名称数组,如果不存在则移除全部样式
302
+ * Open API:移除文本元素的样式,styleNames是样式名称数组,如果不存在则移除全部样式
263
303
  * @param editor
264
304
  * @param dataRangeCaches
265
305
  * @param styleNames
@@ -267,7 +307,7 @@ export declare const setTextMark: (editor: AlexEditor, dataRangeCaches: AlexElem
267
307
  */
268
308
  export declare const removeTextStyle: (editor: AlexEditor, dataRangeCaches: AlexElementsRangeType, styleNames?: string[]) => void;
269
309
  /**
270
- * 移除文本元素的标记,markNames是标记名称数组,如果不存在则移除全部标记
310
+ * Open API:移除文本元素的标记,markNames是标记名称数组,如果不存在则移除全部标记
271
311
  * @param editor
272
312
  * @param dataRangeCaches
273
313
  * @param markNames
@@ -275,7 +315,7 @@ export declare const removeTextStyle: (editor: AlexEditor, dataRangeCaches: Alex
275
315
  */
276
316
  export declare const removeTextMark: (editor: AlexEditor, dataRangeCaches: AlexElementsRangeType, markNames?: string[]) => void;
277
317
  /**
278
- * 设置块元素或者根级块元素的行高
318
+ * Open API:设置块元素或者根级块元素的行高
279
319
  * @param editor
280
320
  * @param dataRangeCaches
281
321
  * @param value
@@ -283,7 +323,7 @@ export declare const removeTextMark: (editor: AlexEditor, dataRangeCaches: AlexE
283
323
  */
284
324
  export declare const setLineHeight: (editor: AlexEditor, dataRangeCaches: AlexElementsRangeType, value: string | number) => void;
285
325
  /**
286
- * 插入链接
326
+ * Open API:插入链接
287
327
  * @param editor
288
328
  * @param text
289
329
  * @param url
@@ -292,21 +332,21 @@ export declare const setLineHeight: (editor: AlexEditor, dataRangeCaches: AlexEl
292
332
  */
293
333
  export declare const insertLink: (editor: AlexEditor, text: string, url: string, newOpen: boolean) => void;
294
334
  /**
295
- * 插入图片
335
+ * Open API:插入图片
296
336
  * @param editor
297
337
  * @param value
298
338
  * @returns
299
339
  */
300
340
  export declare const insertImage: (editor: AlexEditor, value: string) => void;
301
341
  /**
302
- * 插入视频
342
+ * Open API:插入视频
303
343
  * @param editor
304
344
  * @param value
305
345
  * @returns
306
346
  */
307
347
  export declare const insertVideo: (editor: AlexEditor, value: string) => void;
308
348
  /**
309
- * 插入表格
349
+ * Open API:插入表格
310
350
  * @param editor
311
351
  * @param rowLength
312
352
  * @param colLength
@@ -314,14 +354,14 @@ export declare const insertVideo: (editor: AlexEditor, value: string) => void;
314
354
  */
315
355
  export declare const insertTable: (editor: AlexEditor, rowLength: number, colLength: number) => void;
316
356
  /**
317
- * 插入或者取消代码块
357
+ * Open API:插入或者取消代码块
318
358
  * @param editor
319
359
  * @param dataRangeCaches
320
360
  * @returns
321
361
  */
322
362
  export declare const insertCodeBlock: (editor: AlexEditor, dataRangeCaches: AlexElementsRangeType) => void;
323
363
  /**
324
- * 插入分隔线
364
+ * Open API:插入分隔线
325
365
  * @param editor
326
366
  * @param dataRangeCaches
327
367
  * @returns
@@ -20,11 +20,23 @@ export declare const orderdListHandle: (editor: AlexEditor, element: AlexElement
20
20
  */
21
21
  export declare const commonElementHandle: (editor: AlexEditor, element: AlexElement) => void;
22
22
  /**
23
- * 元素格式化时处理表格
23
+ * 元素格式化时处理表格:th转为td
24
24
  * @param editor
25
25
  * @param element
26
26
  */
27
- export declare const tableHandle: (editor: AlexEditor, element: AlexElement) => void;
27
+ export declare const tableThTdHandle: (_editor: AlexEditor, element: AlexElement) => void;
28
+ /**
29
+ * 元素格式化时处理表格:格式化表格
30
+ * @param editor
31
+ * @param element
32
+ */
33
+ export declare const tableFormatHandle: (editor: AlexEditor, element: AlexElement) => void;
34
+ /**
35
+ * 元素格式化时处理表格:处理光标在表格隐藏单元格内的情况
36
+ * @param editor
37
+ * @param element
38
+ */
39
+ export declare const tableRangeMergedHandle: (editor: AlexEditor, element: AlexElement) => void;
28
40
  /**
29
41
  * 元素格式化时处理pre,将pre的内容根据语言进行样式处理
30
42
  * @param editor
@@ -441,7 +441,7 @@ declare const _default: import('vue').DefineComponent<{
441
441
  insertElement: (ele: AlexElement, cover?: boolean | undefined) => void;
442
442
  formatElementStack: () => void;
443
443
  domRender: (unPushHistory?: boolean | undefined) => void;
444
- rangeRender: () => void;
444
+ rangeRender: () => Promise<void>;
445
445
  parseHtml: (html: string) => AlexElement[];
446
446
  parseNode: (node: HTMLElement) => AlexElement;
447
447
  merge: (ele: AlexElement, previousEle: AlexElement) => void;