vue-editify 0.2.17 → 0.2.19
Sign up to get free protection for your applications and to get access to all the features.
- package/examples/App.vue +4 -12
- package/lib/components/colors/colors.vue.d.ts +9 -0
- package/lib/components/colors/props.d.ts +4 -0
- package/lib/components/tooltip/tooltip.vue.d.ts +1 -1
- package/lib/core/function.d.ts +112 -64
- package/lib/core/rule.d.ts +23 -17
- package/lib/core/shortcut.d.ts +36 -0
- package/lib/core/tool.d.ts +12 -16
- package/lib/editify/editify.vue.d.ts +162 -15
- package/lib/editify/props.d.ts +1 -5
- package/lib/editify/toolbar/props.d.ts +1 -1
- package/lib/editify/toolbar/toolbar.vue.d.ts +3 -3
- package/lib/editify.es.js +13660 -12954
- package/lib/editify.umd.js +2 -2
- package/lib/feature/align.d.ts +0 -14
- package/lib/feature/heading.d.ts +0 -14
- package/lib/feature/lineHeight.d.ts +0 -14
- package/lib/feature/orderList.d.ts +1 -3
- package/lib/feature/task.d.ts +0 -14
- package/lib/feature/unorderList.d.ts +1 -3
- package/lib/index.d.ts +164 -17
- package/package.json +2 -2
- package/src/components/button/button.vue +3 -3
- package/src/components/checkbox/checkbox.vue +1 -1
- package/src/components/colors/colors.vue +4 -4
- package/src/components/colors/props.ts +6 -1
- package/src/components/insertAttachment/insertAttachment.vue +1 -1
- package/src/components/insertImage/insertImage.vue +1 -1
- package/src/components/insertLink/insertLink.vue +1 -1
- package/src/components/insertVideo/insertVideo.vue +1 -1
- package/src/components/layer/layer.vue +9 -3
- package/src/components/tooltip/tooltip.vue +1 -1
- package/src/components/updateLink/updateLink.vue +1 -1
- package/src/core/function.ts +873 -491
- package/src/core/rule.ts +86 -368
- package/src/core/shortcut.ts +386 -0
- package/src/core/tool.ts +111 -159
- package/src/css/var.less +0 -10
- package/src/editify/editify.less +85 -39
- package/src/editify/editify.vue +204 -88
- package/src/editify/menu/menu.vue +2 -3
- package/src/editify/props.ts +1 -6
- package/src/editify/toolbar/props.ts +2 -2
- package/src/editify/toolbar/toolbar.vue +12 -12
- package/src/feature/align.ts +2 -62
- package/src/feature/attachment.ts +14 -27
- package/src/feature/backColor.ts +2 -1
- package/src/feature/bold.ts +1 -1
- package/src/feature/code.ts +1 -1
- package/src/feature/codeBlock.ts +3 -3
- package/src/feature/fontFamily.ts +1 -1
- package/src/feature/fontSize.ts +1 -1
- package/src/feature/foreColor.ts +2 -1
- package/src/feature/formatClear.ts +1 -1
- package/src/feature/fullScreen.ts +1 -1
- package/src/feature/heading.ts +5 -76
- package/src/feature/image.ts +1 -1
- package/src/feature/indent.ts +1 -1
- package/src/feature/infoBlock.ts +6 -37
- package/src/feature/italic.ts +1 -1
- package/src/feature/lineHeight.ts +2 -78
- package/src/feature/link.ts +1 -1
- package/src/feature/mathformula.ts +4 -51
- package/src/feature/orderList.ts +168 -37
- package/src/feature/quote.ts +3 -3
- package/src/feature/redo.ts +1 -1
- package/src/feature/separator.ts +1 -1
- package/src/feature/sourceView.ts +1 -1
- package/src/feature/strikethrough.ts +1 -1
- package/src/feature/sub.ts +1 -1
- package/src/feature/super.ts +1 -1
- package/src/feature/table.ts +3 -3
- package/src/feature/task.ts +4 -58
- package/src/feature/underline.ts +1 -1
- package/src/feature/undo.ts +1 -1
- package/src/feature/unorderList.ts +108 -37
- package/src/feature/video.ts +1 -1
- package/src/icon/iconfont.css +39 -3
- package/src/icon/iconfont.ttf +0 -0
- package/src/icon/iconfont.woff +0 -0
- package/src/index.ts +13 -11
- package/src/locale/en_US.ts +109 -110
- package/src/locale/zh_CN.ts +11 -12
- package/lib/feature/panel.d.ts +0 -18
- package/src/feature/panel.ts +0 -107
package/examples/App.vue
CHANGED
@@ -22,6 +22,7 @@ const menuConfig = ref({
|
|
22
22
|
sourceView: {
|
23
23
|
show: true
|
24
24
|
},
|
25
|
+
heading: {},
|
25
26
|
fullScreen: {
|
26
27
|
show: true
|
27
28
|
},
|
@@ -53,19 +54,10 @@ const menuConfig = ref({
|
|
53
54
|
}
|
54
55
|
})
|
55
56
|
const toolbarConfig = ref({
|
56
|
-
use: true
|
57
|
+
use: true,
|
58
|
+
text: {}
|
57
59
|
})
|
58
|
-
const val = ref<string>(
|
59
|
-
`<div data-editify-info="true" style="background-color: rgba(3, 168, 243, 0.15); color: rgb(3, 168, 243);"><span>调用domRender方法会先对编辑器内的元素进行格式化处理,然后会更新编辑器dom内容,渲染到视图上</span></div><p><br></p><p><br></p><h5><span>如何规范化校验(格式化)?</span></h5><p><br></p><h5><span>null</span></h5><div data-editify-list="ul"><span>stack数组元素只能是block元素,同时block元素只会出现在根部,如果某个元素的子元素是block元素,那么该block元素会被转为inline元素或者inblock元素(对于被转为inblock的block元素,其行为值behavior为"block")</span></div><div data-editify-list="ul"><span>inblock与其他元素不能同时存在于子元素数组中,如果某个元素的子元素数组中含有inblock元素,那么其他子元素也必然是inblock元素,否则该inblock元素会被转为inline元素</span></div><div data-editify-list="ul"><span>inblock元素的父元素必然是block元素或者inblock元素</span></div><div data-editify-list="ul"><span>换行符清除规则:换行符与其他元素不能同时存在,并且如果某个元素下存在多个换行符则会被清除为一个换行符</span></div><div data-editify-list="ul"><span>兄弟元素合并策略:相邻的两个文本元素的styles和marks相同则会被合并;相邻的两个行内元素的parsedom、styles和marks相同则会被合并(如果两个元素中有元素的locked属性为true则无法进行合并)</span></div><div data-editify-list="ul"><span>父子元素合并策略:父元素的子元素只有一个,并且该子元素是文本元素,父元素是parsedom==AlexElement.TEXT_NODE的行内元素,则子元素会父元素进行合并;父元素的子元素只有一个,inline元素、inblock元素如果与父元素的parsedom一致,marks和styles也一致,那么会与父元素合并(如果两个元素中有元素的locked属性为true则无法进行合并)</span></div><div data-editify-list="ul"><span>多个连续空白文本字符合并策略:文本元素内的空白文本值如果存在多个连续的情况下,会被合并成一个空白文本值</span></div><div data-editify-list="ul"><span>元素进行规范化处理时,会从stack依次进行遍历处理,当遍历子元素时,也是从第一个子元素开始依次遍历</span></div><p><br></p><blockquote><span>以上是编辑器内部的默认规范化处理规则,当然,编辑器对外提供了让我们自定义额外规则的能力,它便是AlexEditor的属性renderRules</span></blockquote><p><br></p><p><br></p><h5><span>使用renderRules自定义额外的规范化校验规则</span></h5><p><br></p><p><span>renderRules是一个数组,数组中可以定义多个函数,每个函数都会在调用formatElementStack方法时进行调用</span></p><pre data-editify-element="42" data-editify-hljs="javascript"><span class="editify-hljs-comment">//例如将<b>标签转为<span>标签</span><span>
|
60
|
-
</span><span class="editify-hljs-keyword">const</span><span> parseCode = </span><span class="editify-hljs-keyword">function</span><span>(</span><span class="editify-hljs-params">element</span><span>){
|
61
|
-
</span><span class="editify-hljs-keyword">if</span><span> (element.</span><span class="editify-hljs-property">parsedom</span><span> == </span><span class="editify-hljs-string">'b'</span><span>) {
|
62
|
-
element.</span><span class="editify-hljs-property">parsedom</span><span> = </span><span class="editify-hljs-string">'span'</span><span>
|
63
|
-
element.</span><span class="editify-hljs-property">styles</span><span> = {
|
64
|
-
</span><span class="editify-hljs-string">'font-weight'</span><span>:</span><span class="editify-hljs-string">'bold'</span><span>
|
65
|
-
}
|
66
|
-
}
|
67
|
-
}</span></pre>`
|
68
|
-
)
|
60
|
+
const val = ref<string>(`<p>333</p>`)
|
69
61
|
</script>
|
70
62
|
<style lang="less">
|
71
63
|
html,
|
@@ -17,6 +17,10 @@ declare const _default: import('vue').DefineComponent<{
|
|
17
17
|
type: BooleanConstructor;
|
18
18
|
default: boolean;
|
19
19
|
};
|
20
|
+
zIndex: {
|
21
|
+
type: NumberConstructor;
|
22
|
+
default: number;
|
23
|
+
};
|
20
24
|
}, {}, unknown, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
|
21
25
|
change: (...args: any[]) => void;
|
22
26
|
}, string, import('vue').PublicProps, Readonly<import('vue').ExtractPropTypes<{
|
@@ -36,11 +40,16 @@ declare const _default: import('vue').DefineComponent<{
|
|
36
40
|
type: BooleanConstructor;
|
37
41
|
default: boolean;
|
38
42
|
};
|
43
|
+
zIndex: {
|
44
|
+
type: NumberConstructor;
|
45
|
+
default: number;
|
46
|
+
};
|
39
47
|
}>> & {
|
40
48
|
onChange?: ((...args: any[]) => any) | undefined;
|
41
49
|
}, {
|
42
50
|
tooltip: boolean;
|
43
51
|
color: string;
|
52
|
+
zIndex: number;
|
44
53
|
value: string;
|
45
54
|
data: ButtonOptionsItemType[];
|
46
55
|
}, {}>;
|
@@ -38,8 +38,8 @@ declare const __VLS_component: import('vue').DefineComponent<{
|
|
38
38
|
}>>, {
|
39
39
|
disabled: boolean;
|
40
40
|
zIndex: number;
|
41
|
-
content: string;
|
42
41
|
block: boolean;
|
42
|
+
content: string;
|
43
43
|
}, {}>;
|
44
44
|
declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, ReturnType<typeof __VLS_template>>;
|
45
45
|
export default _default;
|
package/lib/core/function.d.ts
CHANGED
@@ -6,6 +6,31 @@ export type ElementMatchConfigType = {
|
|
6
6
|
marks?: ObjectType;
|
7
7
|
styles?: ObjectType;
|
8
8
|
};
|
9
|
+
/** --------------------------------代码块操作相关函数------------------------------------------------ */
|
10
|
+
/**
|
11
|
+
* 更新代码块内的光标位置
|
12
|
+
* @param editor
|
13
|
+
* @param element
|
14
|
+
* @param originalTextElements
|
15
|
+
* @param newElements
|
16
|
+
* @returns
|
17
|
+
*/
|
18
|
+
export declare const updateRangeInPre: (editor: AlexEditor, element: AlexElement, originalTextElements: AlexElement[], newElements: AlexElement[]) => void;
|
19
|
+
/** --------------------------------表格操作相关函数--------------------------------------------- */
|
20
|
+
/**
|
21
|
+
* 自动隐藏被合并的单元格
|
22
|
+
* @param editor
|
23
|
+
* @param rowElements
|
24
|
+
*/
|
25
|
+
export declare const autoHideMergedTableCells: (editor: AlexEditor, rowElements: AlexElement[]) => void;
|
26
|
+
/**
|
27
|
+
* 自动补全表格行和列
|
28
|
+
* @param editor
|
29
|
+
* @param rowElements
|
30
|
+
* @param rowNumber
|
31
|
+
* @param columnNumber
|
32
|
+
*/
|
33
|
+
export declare const autocompleteTableCells: (editor: AlexEditor, rowElements: AlexElement[], rowNumber: number, columnNumber: number) => void;
|
9
34
|
/**
|
10
35
|
* 清空单元格的内容并隐藏
|
11
36
|
* @param editor
|
@@ -40,6 +65,7 @@ export declare const getTableSize: (rowElements: AlexElement[]) => {
|
|
40
65
|
rowNumber: number;
|
41
66
|
columnNumber: number;
|
42
67
|
};
|
68
|
+
/** --------------------------------通用的元素判断函数----------------------------------------------- */
|
43
69
|
/**
|
44
70
|
* Open API:判断元素是否符合指定的条件
|
45
71
|
* @param element
|
@@ -62,6 +88,7 @@ export declare const getMatchElementByElement: (element: AlexElement, config: El
|
|
62
88
|
* @returns
|
63
89
|
*/
|
64
90
|
export declare const getMatchElementByRange: (editor: AlexEditor, dataRangeCaches: AlexElementsRangeType, config: ElementMatchConfigType) => AlexElement | null;
|
91
|
+
/** --------------------------------列表判断函数---------------------------------------------------------- */
|
65
92
|
/**
|
66
93
|
* Open API:判断元素是否有序或者无序列表,不做空元素判断
|
67
94
|
* @param element
|
@@ -92,6 +119,7 @@ export declare const hasListInRange: (editor: AlexEditor, dataRangeCaches: AlexE
|
|
92
119
|
* @returns
|
93
120
|
*/
|
94
121
|
export declare const rangeIsInList: (editor: AlexEditor, dataRangeCaches: AlexElementsRangeType, ordered?: boolean | undefined) => boolean;
|
122
|
+
/** --------------------------------任务列表判断函数----------------------------------------------- */
|
95
123
|
/**
|
96
124
|
* Open API:判断元素是否任务列表,不做空元素判断
|
97
125
|
* @param element
|
@@ -118,6 +146,7 @@ export declare const hasTaskInRange: (editor: AlexEditor, dataRangeCaches: AlexE
|
|
118
146
|
* @returns
|
119
147
|
*/
|
120
148
|
export declare const rangeIsInTask: (editor: AlexEditor, dataRangeCaches: AlexElementsRangeType) => boolean;
|
149
|
+
/** --------------------------------附件判断函数------------------------------------------------- */
|
121
150
|
/**
|
122
151
|
* Open API:判断元素是否附件,不做空元素判断
|
123
152
|
* @param element
|
@@ -131,6 +160,7 @@ export declare const elementIsAttachment: (element: AlexElement) => boolean;
|
|
131
160
|
* @returns
|
132
161
|
*/
|
133
162
|
export declare const hasAttachmentInRange: (editor: AlexEditor, dataRangeCaches: AlexElementsRangeType) => boolean;
|
163
|
+
/** --------------------------------数学公式判断函数--------------------------------------------- */
|
134
164
|
/**
|
135
165
|
* Open API:判断元素是否数学公式,不做空元素判断
|
136
166
|
* @param element
|
@@ -150,25 +180,7 @@ export declare const getMathformulaByElement: (element: AlexElement) => AlexElem
|
|
150
180
|
* @returns
|
151
181
|
*/
|
152
182
|
export declare const hasMathformulaInRange: (editor: AlexEditor, dataRangeCaches: AlexElementsRangeType) => boolean;
|
153
|
-
/**
|
154
|
-
* Open API:判断元素是否面板,不做空元素判断
|
155
|
-
* @param el
|
156
|
-
* @returns
|
157
|
-
*/
|
158
|
-
export declare const elementIsPanel: (element: AlexElement) => boolean;
|
159
|
-
/**
|
160
|
-
* Open API:判断元素是否在面板内,是的话返回面板元素,否则返回null
|
161
|
-
* @param el
|
162
|
-
* @returns
|
163
|
-
*/
|
164
|
-
export declare const getPanelByElement: (element: AlexElement) => AlexElement | null;
|
165
|
-
/**
|
166
|
-
* Open API:选区是否含有面板,不一定是同一个面板,只要含有面板即返回true
|
167
|
-
* @param editor
|
168
|
-
* @param dataRangeCaches
|
169
|
-
* @returns
|
170
|
-
*/
|
171
|
-
export declare const hasPanelInRange: (editor: AlexEditor, dataRangeCaches: AlexElementsRangeType) => boolean;
|
183
|
+
/** --------------------------------信息块判断函数---------------------------------------------- */
|
172
184
|
/**
|
173
185
|
* Open API:判断元素是否信息块,不做空元素判断
|
174
186
|
* @param el
|
@@ -195,6 +207,7 @@ export declare const hasInfoBlockInRange: (editor: AlexEditor, dataRangeCaches:
|
|
195
207
|
* @returns
|
196
208
|
*/
|
197
209
|
export declare const rangeIsInInfoBlock: (editor: AlexEditor, dataRangeCaches: AlexElementsRangeType) => boolean;
|
210
|
+
/** --------------------------------代码块判断函数------------------------------------------------ */
|
198
211
|
/**
|
199
212
|
* Open API:选区是否含有代码块,不一定是同一个代码块,只要含有代码块即返回true
|
200
213
|
* @param editor
|
@@ -202,6 +215,15 @@ export declare const rangeIsInInfoBlock: (editor: AlexEditor, dataRangeCaches: A
|
|
202
215
|
* @returns
|
203
216
|
*/
|
204
217
|
export declare const hasPreInRange: (editor: AlexEditor, dataRangeCaches: AlexElementsRangeType) => boolean;
|
218
|
+
/** --------------------------------表格判断函数------------------------------------------------- */
|
219
|
+
/**
|
220
|
+
* Open API:选区是否含有表格,不一定是同一个表格,只要含有表格即返回true
|
221
|
+
* @param editor
|
222
|
+
* @param dataRangeCaches
|
223
|
+
* @returns
|
224
|
+
*/
|
225
|
+
export declare const hasTableInRange: (editor: AlexEditor, dataRangeCaches: AlexElementsRangeType) => boolean;
|
226
|
+
/** --------------------------------引用判断函数----------------------------------------------- */
|
205
227
|
/**
|
206
228
|
* Open API:选区是否含有引用,不一定是同一个引用,只要含有引用即返回true
|
207
229
|
* @param editor
|
@@ -210,19 +232,21 @@ export declare const hasPreInRange: (editor: AlexEditor, dataRangeCaches: AlexEl
|
|
210
232
|
*/
|
211
233
|
export declare const hasQuoteInRange: (editor: AlexEditor, dataRangeCaches: AlexElementsRangeType) => boolean;
|
212
234
|
/**
|
213
|
-
* Open API
|
235
|
+
* Open API:选区是否全部在引用内,不一定是同一个引用
|
214
236
|
* @param editor
|
215
237
|
* @param dataRangeCaches
|
216
238
|
* @returns
|
217
239
|
*/
|
218
|
-
export declare const
|
240
|
+
export declare const rangeIsInQuote: (editor: AlexEditor, dataRangeCaches: AlexElementsRangeType) => boolean;
|
241
|
+
/** --------------------------------链接判断函数-------------------------------------------------- */
|
219
242
|
/**
|
220
|
-
* Open API
|
243
|
+
* Open API:选区是否含有链接,不一定是同一个链接,只要含有链接即返回true
|
221
244
|
* @param editor
|
222
245
|
* @param dataRangeCaches
|
223
246
|
* @returns
|
224
247
|
*/
|
225
|
-
export declare const
|
248
|
+
export declare const hasLinkInRange: (editor: AlexEditor, dataRangeCaches: AlexElementsRangeType) => boolean;
|
249
|
+
/** --------------------------------图片视频判断函数--------------------------------------------- */
|
226
250
|
/**
|
227
251
|
* Open API:选区是否含有图片,不一定是同一个图片,只要含有图片即返回true
|
228
252
|
* @param editor
|
@@ -237,13 +261,14 @@ export declare const hasImageInRange: (editor: AlexEditor, dataRangeCaches: Alex
|
|
237
261
|
* @returns
|
238
262
|
*/
|
239
263
|
export declare const hasVideoInRange: (editor: AlexEditor, dataRangeCaches: AlexElementsRangeType) => boolean;
|
264
|
+
/** --------------------文本元素标记和样式相关函数--------------------------------------- */
|
240
265
|
/**
|
241
|
-
*
|
266
|
+
* 获取光标选取内的扁平化元素数组(可能会分割文本元素导致stack变更,同时也会更新选取元素和光标位置)
|
242
267
|
* @param editor
|
243
268
|
* @param dataRangeCaches
|
244
269
|
* @returns
|
245
270
|
*/
|
246
|
-
export declare const
|
271
|
+
export declare const getFlatElementsByRange: (editor: AlexEditor, dataRangeCaches: AlexElementsRangeType) => AlexElement[];
|
247
272
|
/**
|
248
273
|
* Open API:查询光标所在的文本元素是否具有某个样式
|
249
274
|
* @param editor
|
@@ -253,6 +278,22 @@ export declare const rangeIsInQuote: (editor: AlexEditor, dataRangeCaches: AlexE
|
|
253
278
|
* @returns
|
254
279
|
*/
|
255
280
|
export declare const queryTextStyle: (editor: AlexEditor, dataRangeCaches: AlexElementsRangeType, name: string, value?: string | number) => boolean;
|
281
|
+
/**
|
282
|
+
* Open API:设置文本元素的样式
|
283
|
+
* @param editor
|
284
|
+
* @param dataRangeCaches
|
285
|
+
* @param styles 值为{ 'font-weight':'bold' }这类格式
|
286
|
+
* @returns
|
287
|
+
*/
|
288
|
+
export declare const setTextStyle: (editor: AlexEditor, dataRangeCaches: AlexElementsRangeType, styles: ObjectType) => void;
|
289
|
+
/**
|
290
|
+
* Open API:移除文本元素的样式
|
291
|
+
* @param editor
|
292
|
+
* @param dataRangeCaches
|
293
|
+
* @param styleNames 样式名称数组,如果不存在则移除全部样式
|
294
|
+
* @returns
|
295
|
+
*/
|
296
|
+
export declare const removeTextStyle: (editor: AlexEditor, dataRangeCaches: AlexElementsRangeType, styleNames?: string[]) => void;
|
256
297
|
/**
|
257
298
|
* Open API:查询光标所在的文本元素是否具有某个标记
|
258
299
|
* @param editor
|
@@ -263,18 +304,22 @@ export declare const queryTextStyle: (editor: AlexEditor, dataRangeCaches: AlexE
|
|
263
304
|
*/
|
264
305
|
export declare const queryTextMark: (editor: AlexEditor, dataRangeCaches: AlexElementsRangeType, name: string, value?: string | number) => boolean;
|
265
306
|
/**
|
266
|
-
* Open API
|
307
|
+
* Open API:设置文本元素的标记
|
308
|
+
* @param editor
|
267
309
|
* @param dataRangeCaches
|
310
|
+
* @param marks 值为{ 'class':'a' }这类格式
|
268
311
|
* @returns
|
269
312
|
*/
|
270
|
-
export declare const
|
313
|
+
export declare const setTextMark: (editor: AlexEditor, dataRangeCaches: AlexElementsRangeType, marks: ObjectType) => void;
|
271
314
|
/**
|
272
|
-
*
|
315
|
+
* Open API:移除文本元素的标记
|
273
316
|
* @param editor
|
274
317
|
* @param dataRangeCaches
|
318
|
+
* @param markNames 标记名称数组,如果不存在则移除全部标记
|
275
319
|
* @returns
|
276
320
|
*/
|
277
|
-
export declare const
|
321
|
+
export declare const removeTextMark: (editor: AlexEditor, dataRangeCaches: AlexElementsRangeType, markNames?: string[]) => void;
|
322
|
+
/** --------------------------------元素转换函数-------------------------------------------------- */
|
278
323
|
/**
|
279
324
|
* 将某个元素转为段落标签
|
280
325
|
* @param element
|
@@ -293,15 +338,29 @@ export declare const elementToList: (element: AlexElement, ordered?: boolean | u
|
|
293
338
|
* @returns
|
294
339
|
*/
|
295
340
|
export declare const elementToTask: (element: AlexElement) => void;
|
341
|
+
/** --------------------------------封装的功能函数----------------------------------------------- */
|
342
|
+
/**
|
343
|
+
* Open API:获取选区内的文字内容
|
344
|
+
* @param dataRangeCaches
|
345
|
+
* @returns
|
346
|
+
*/
|
347
|
+
export declare const getRangeText: (dataRangeCaches: AlexElementsRangeType) => string;
|
296
348
|
/**
|
297
|
-
*
|
349
|
+
* Open API:给元素两侧加上空白文本元素
|
350
|
+
* @param editor
|
351
|
+
* @param element
|
352
|
+
*/
|
353
|
+
export declare const addSpaceTextToBothSides: (editor: AlexEditor, element: AlexElement) => void;
|
354
|
+
/** --------------------------------菜单功能函数----------------------------------------------------- */
|
355
|
+
/**
|
356
|
+
* Open API:设置标题,支持h1-h6和p
|
298
357
|
* @param editor
|
299
358
|
* @param dataRangeCaches
|
300
359
|
* @param editTrans
|
301
360
|
* @param parsedom
|
302
361
|
* @returns
|
303
362
|
*/
|
304
|
-
export declare const setHeading: (editor: AlexEditor, dataRangeCaches: AlexElementsRangeType,
|
363
|
+
export declare const setHeading: (editor: AlexEditor, dataRangeCaches: AlexElementsRangeType, parsedom: string) => void;
|
305
364
|
/**
|
306
365
|
* Open API:根级块元素或者内部块元素增加缩进
|
307
366
|
* @param editor
|
@@ -347,39 +406,7 @@ export declare const setList: (editor: AlexEditor, dataRangeCaches: AlexElements
|
|
347
406
|
*/
|
348
407
|
export declare const setTask: (editor: AlexEditor, dataRangeCaches: AlexElementsRangeType) => void;
|
349
408
|
/**
|
350
|
-
* Open API
|
351
|
-
* @param editor
|
352
|
-
* @param dataRangeCaches
|
353
|
-
* @param styles 值为{ 'font-weight':'bold' }这类格式
|
354
|
-
* @returns
|
355
|
-
*/
|
356
|
-
export declare const setTextStyle: (editor: AlexEditor, dataRangeCaches: AlexElementsRangeType, styles: ObjectType) => void;
|
357
|
-
/**
|
358
|
-
* Open API:设置文本元素的标记
|
359
|
-
* @param editor
|
360
|
-
* @param dataRangeCaches
|
361
|
-
* @param marks 值为{ 'class':'a' }这类格式
|
362
|
-
* @returns
|
363
|
-
*/
|
364
|
-
export declare const setTextMark: (editor: AlexEditor, dataRangeCaches: AlexElementsRangeType, marks: ObjectType) => void;
|
365
|
-
/**
|
366
|
-
* Open API:移除文本元素的样式
|
367
|
-
* @param editor
|
368
|
-
* @param dataRangeCaches
|
369
|
-
* @param styleNames 样式名称数组,如果不存在则移除全部样式
|
370
|
-
* @returns
|
371
|
-
*/
|
372
|
-
export declare const removeTextStyle: (editor: AlexEditor, dataRangeCaches: AlexElementsRangeType, styleNames?: string[]) => void;
|
373
|
-
/**
|
374
|
-
* Open API:移除文本元素的标记
|
375
|
-
* @param editor
|
376
|
-
* @param dataRangeCaches
|
377
|
-
* @param markNames 标记名称数组,如果不存在则移除全部标记
|
378
|
-
* @returns
|
379
|
-
*/
|
380
|
-
export declare const removeTextMark: (editor: AlexEditor, dataRangeCaches: AlexElementsRangeType, markNames?: string[]) => void;
|
381
|
-
/**
|
382
|
-
* Open API:设置块元素或者根级块元素的行高
|
409
|
+
* Open API:设置内部块元素或者根级块元素的行高
|
383
410
|
* @param editor
|
384
411
|
* @param dataRangeCaches
|
385
412
|
* @param value
|
@@ -431,3 +458,24 @@ export declare const insertCodeBlock: (editor: AlexEditor, dataRangeCaches: Alex
|
|
431
458
|
* @returns
|
432
459
|
*/
|
433
460
|
export declare const insertSeparator: (editor: AlexEditor) => void;
|
461
|
+
/**
|
462
|
+
* Open API:插入附件
|
463
|
+
* @param editor
|
464
|
+
* @param url 附件地址
|
465
|
+
* @param name 附件名称
|
466
|
+
*/
|
467
|
+
export declare const insertAttachment: (editor: AlexEditor, url: string, name: string) => void;
|
468
|
+
/**
|
469
|
+
* Open API:插入数学公式
|
470
|
+
* @param editor
|
471
|
+
* @param dataRangeCaches
|
472
|
+
* @param mathContent 数学公式字符串
|
473
|
+
* @param errorCallback 错误处理
|
474
|
+
*/
|
475
|
+
export declare const insertMathformula: (editor: AlexEditor, dataRangeCaches: AlexElementsRangeType, mathContent: string, errorCallback?: (err: Error) => void) => void;
|
476
|
+
/**
|
477
|
+
* Open API:插入信息块
|
478
|
+
* @param editor
|
479
|
+
* @param dataRangeCaches
|
480
|
+
*/
|
481
|
+
export declare const insertInfoBlock: (editor: AlexEditor, dataRangeCaches: AlexElementsRangeType) => void;
|
package/lib/core/rule.d.ts
CHANGED
@@ -2,43 +2,49 @@ import { AlexEditor, AlexElement } from 'alex-editor';
|
|
2
2
|
import { LanguagesItemType } from '../hljs';
|
3
3
|
|
4
4
|
/**
|
5
|
-
*
|
5
|
+
* 有序列表和无序列表的格式化处理
|
6
6
|
* @param editor
|
7
7
|
* @param element
|
8
8
|
*/
|
9
|
-
export declare const
|
9
|
+
export declare const listHandle: (editor: AlexEditor, element: AlexElement) => void;
|
10
10
|
/**
|
11
|
-
*
|
11
|
+
* 图片格式化处理
|
12
12
|
* @param editor
|
13
13
|
* @param element
|
14
14
|
*/
|
15
|
-
export declare const
|
15
|
+
export declare const imageHandle: (_editor: AlexEditor, element: AlexElement) => void;
|
16
16
|
/**
|
17
|
-
*
|
17
|
+
* 视频格式化处理
|
18
18
|
* @param editor
|
19
19
|
* @param element
|
20
20
|
*/
|
21
|
-
export declare const
|
21
|
+
export declare const videoHandle: (editor: AlexEditor, element: AlexElement) => void;
|
22
22
|
/**
|
23
|
-
*
|
23
|
+
* 分隔线格式化处理
|
24
24
|
* @param editor
|
25
25
|
* @param element
|
26
26
|
*/
|
27
|
-
export declare const
|
27
|
+
export declare const separatorHandle: (editor: AlexEditor, element: AlexElement) => void;
|
28
28
|
/**
|
29
|
-
*
|
29
|
+
* 链接格式化处理
|
30
30
|
* @param editor
|
31
31
|
* @param element
|
32
32
|
*/
|
33
|
-
export declare const
|
33
|
+
export declare const linkHandle: (_editor: AlexEditor, element: AlexElement) => void;
|
34
34
|
/**
|
35
|
-
*
|
35
|
+
* 行内代码格式化处理
|
36
|
+
* @param _editor
|
37
|
+
* @param element
|
38
|
+
*/
|
39
|
+
export declare const codeHandle: (_editor: AlexEditor, element: AlexElement) => void;
|
40
|
+
/**
|
41
|
+
* 表格格式化处理
|
36
42
|
* @param editor
|
37
43
|
* @param element
|
38
44
|
*/
|
39
|
-
export declare const
|
45
|
+
export declare const tableHandle: (editor: AlexEditor, element: AlexElement) => void;
|
40
46
|
/**
|
41
|
-
*
|
47
|
+
* 代码块格式化处理
|
42
48
|
* @param editor
|
43
49
|
* @param element
|
44
50
|
* @param highlight
|
@@ -46,27 +52,27 @@ export declare const tableRangeMergedHandle: (editor: AlexEditor, element: AlexE
|
|
46
52
|
*/
|
47
53
|
export declare const preHandle: (editor: AlexEditor, element: AlexElement, highlight: boolean, languages: (string | LanguagesItemType)[]) => void;
|
48
54
|
/**
|
49
|
-
*
|
55
|
+
* 附件格式化处理
|
50
56
|
* @param editor
|
51
57
|
* @param element
|
52
58
|
* @param $editTrans
|
53
59
|
*/
|
54
60
|
export declare const attachmentHandle: (editor: AlexEditor, element: AlexElement, $editTrans: (key: string) => any) => void;
|
55
61
|
/**
|
56
|
-
*
|
62
|
+
* 数学公式格式化处理
|
57
63
|
* @param editor
|
58
64
|
* @param element
|
59
65
|
*/
|
60
66
|
export declare const mathformulaHandle: (editor: AlexEditor, element: AlexElement) => void;
|
61
67
|
/**
|
62
|
-
*
|
68
|
+
* 信息块格式化处理
|
63
69
|
* @param editor
|
64
70
|
* @param element
|
65
71
|
* @param color
|
66
72
|
*/
|
67
73
|
export declare const infoBlockHandle: (_editor: AlexEditor, element: AlexElement, color: string) => void;
|
68
74
|
/**
|
69
|
-
*
|
75
|
+
* 一些特殊的内部块元素,转为根级块元素
|
70
76
|
* @param editor
|
71
77
|
* @param element
|
72
78
|
*/
|
@@ -0,0 +1,36 @@
|
|
1
|
+
import { ShortcutType } from './tool';
|
2
|
+
|
3
|
+
export type ShortcutConfigType = {
|
4
|
+
heading: ShortcutType;
|
5
|
+
indent: ShortcutType;
|
6
|
+
quote: ShortcutType;
|
7
|
+
separator: ShortcutType;
|
8
|
+
align: ShortcutType;
|
9
|
+
orderList: ShortcutType;
|
10
|
+
unorderList: ShortcutType;
|
11
|
+
task: ShortcutType;
|
12
|
+
bold: ShortcutType;
|
13
|
+
underline: ShortcutType;
|
14
|
+
italic: ShortcutType;
|
15
|
+
strikethrough: ShortcutType;
|
16
|
+
code: ShortcutType;
|
17
|
+
super: ShortcutType;
|
18
|
+
sub: ShortcutType;
|
19
|
+
formatClear: ShortcutType;
|
20
|
+
fontSize: ShortcutType;
|
21
|
+
fontFamily: ShortcutType;
|
22
|
+
lineHeight: ShortcutType;
|
23
|
+
foreColor: ShortcutType;
|
24
|
+
backColor: ShortcutType;
|
25
|
+
link: ShortcutType;
|
26
|
+
image: ShortcutType;
|
27
|
+
video: ShortcutType;
|
28
|
+
table: ShortcutType;
|
29
|
+
codeBlock: ShortcutType;
|
30
|
+
sourceView: ShortcutType;
|
31
|
+
fullScreen: ShortcutType;
|
32
|
+
attachment: ShortcutType;
|
33
|
+
mathformula: ShortcutType;
|
34
|
+
infoBlock: ShortcutType;
|
35
|
+
};
|
36
|
+
export declare const config: ShortcutConfigType;
|
package/lib/core/tool.d.ts
CHANGED
@@ -1,4 +1,5 @@
|
|
1
|
-
import { App, Component, VNode } from 'vue';
|
1
|
+
import { App, Component, Ref, VNode } from 'vue';
|
2
|
+
import { AlexEditor, AlexElementsRangeType } from 'alex-editor';
|
2
3
|
import { LocaleType } from '../locale';
|
3
4
|
import { Button, ButtonOptionsItemType, ButtonTypeType } from '../components/button';
|
4
5
|
import { InsertImageUploadErrorType } from '../components/insertImage';
|
@@ -17,11 +18,19 @@ export type ButtonOptionsConfigType = {
|
|
17
18
|
foreColor?: (string | number | ButtonOptionsItemType)[];
|
18
19
|
backColor?: (string | number | ButtonOptionsItemType)[];
|
19
20
|
};
|
21
|
+
export type ShortcutType = {
|
22
|
+
title: string;
|
23
|
+
define: ((event: KeyboardEvent) => boolean | {
|
24
|
+
[code: string]: boolean;
|
25
|
+
}) | null;
|
26
|
+
operation?: (editor: AlexEditor, dataRangeCaches: AlexElementsRangeType, isSourceView: Ref<boolean>, isFullScreen: Ref<boolean>, code?: string) => void;
|
27
|
+
};
|
20
28
|
export interface MenuButtonType {
|
21
29
|
show?: boolean;
|
22
30
|
leftBorder?: boolean;
|
23
31
|
rightBorder?: boolean;
|
24
32
|
disabled?: boolean;
|
33
|
+
shortcut?: ShortcutType;
|
25
34
|
}
|
26
35
|
export interface MenuSelectButtonType extends MenuButtonType {
|
27
36
|
options?: (string | number | ButtonOptionsItemType)[];
|
@@ -75,6 +84,7 @@ export type MenuCustomButtonType = {
|
|
75
84
|
options?: ButtonOptionsItemType[];
|
76
85
|
value?: string | number;
|
77
86
|
hideScroll?: boolean;
|
87
|
+
shortcut?: ShortcutType;
|
78
88
|
onLayerShow?: (name: string, btnInstance: InstanceType<typeof Button>) => void;
|
79
89
|
onLayerShown?: (name: string, btnInstance: InstanceType<typeof Button>) => void;
|
80
90
|
onLayerHidden?: (name: string, btnInstance: InstanceType<typeof Button>) => void;
|
@@ -87,11 +97,6 @@ export type CodeBlockToolbarType = {
|
|
87
97
|
languages?: MenuSelectButtonType;
|
88
98
|
};
|
89
99
|
export type TextToolbarType = {
|
90
|
-
heading?: MenuDisplayButtonType;
|
91
|
-
align?: MenuSelectButtonType;
|
92
|
-
orderList?: MenuButtonType;
|
93
|
-
unorderList?: MenuButtonType;
|
94
|
-
task?: MenuButtonType;
|
95
100
|
bold?: MenuButtonType;
|
96
101
|
italic?: MenuButtonType;
|
97
102
|
strikethrough?: MenuButtonType;
|
@@ -101,7 +106,6 @@ export type TextToolbarType = {
|
|
101
106
|
sub?: MenuButtonType;
|
102
107
|
fontSize?: MenuDisplayButtonType;
|
103
108
|
fontFamily?: MenuDisplayButtonType;
|
104
|
-
lineHeight?: MenuDisplayButtonType;
|
105
109
|
foreColor?: MenuSelectButtonType;
|
106
110
|
backColor?: MenuSelectButtonType;
|
107
111
|
formatClear?: MenuButtonType;
|
@@ -146,7 +150,6 @@ export type MenuSequenceType = {
|
|
146
150
|
fullScreen?: number;
|
147
151
|
attachment?: number;
|
148
152
|
mathformula?: number;
|
149
|
-
panel?: number;
|
150
153
|
infoBlock?: number;
|
151
154
|
};
|
152
155
|
export type MenuModeType = 'default' | 'inner' | 'fixed';
|
@@ -191,7 +194,6 @@ export type MenuConfigType = {
|
|
191
194
|
fullScreen?: MenuButtonType;
|
192
195
|
attachment?: MenuAttachmentButtonType;
|
193
196
|
mathformula?: MenuMathformulaButtonType;
|
194
|
-
panel?: MenuButtonType;
|
195
197
|
infoBlock?: MenuButtonType;
|
196
198
|
extends?: MenuExtendType;
|
197
199
|
};
|
@@ -213,12 +215,6 @@ export declare const mergeObject: (o1: ObjectType, o2: ObjectType) => ObjectType
|
|
213
215
|
* @returns
|
214
216
|
*/
|
215
217
|
export declare const queryHasValue: (obj: ObjectType, name: string, value?: string | number) => boolean;
|
216
|
-
/**
|
217
|
-
* 深拷贝函数
|
218
|
-
* @param data
|
219
|
-
* @returns
|
220
|
-
*/
|
221
|
-
export declare const cloneData: (data: any) => any;
|
222
218
|
/**
|
223
219
|
* 获取菜单按钮列表数据配置
|
224
220
|
* @param editTrans
|
@@ -231,7 +227,7 @@ export declare const getButtonOptionsConfig: (editTrans: (key: string) => any) =
|
|
231
227
|
* @param editLocale
|
232
228
|
* @returns
|
233
229
|
*/
|
234
|
-
export declare const getToolbarConfig: (editTrans: (key: string) => any
|
230
|
+
export declare const getToolbarConfig: (editTrans: (key: string) => any) => ToolbarConfigType;
|
235
231
|
/**
|
236
232
|
* 菜单栏全量配置
|
237
233
|
* @param editTrans
|