vue-editify 0.2.18 → 0.2.20
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 +3 -287
- package/lib/components/tooltip/tooltip.vue.d.ts +1 -1
- package/lib/core/function.d.ts +1 -28
- package/lib/core/shortcut.d.ts +36 -0
- package/lib/core/tool.d.ts +11 -3
- package/lib/editify/editify.vue.d.ts +152 -14
- package/lib/editify/props.d.ts +0 -4
- package/lib/editify/toolbar/toolbar.vue.d.ts +1 -1
- package/lib/editify.es.js +3534 -2669
- package/lib/editify.umd.js +2 -2
- package/lib/index.d.ts +154 -16
- package/package.json +2 -2
- package/src/core/function.ts +1 -105
- package/src/core/rule.ts +2 -2
- package/src/core/shortcut.ts +386 -0
- package/src/core/tool.ts +107 -49
- package/src/css/var.less +0 -10
- package/src/editify/editify.less +1 -29
- package/src/editify/editify.vue +89 -25
- package/src/editify/menu/menu.vue +2 -3
- package/src/editify/props.ts +0 -5
- package/src/feature/align.ts +1 -1
- package/src/feature/attachment.ts +1 -1
- package/src/feature/backColor.ts +1 -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 +1 -1
- package/src/feature/formatClear.ts +1 -1
- package/src/feature/fullScreen.ts +1 -1
- package/src/feature/heading.ts +3 -3
- package/src/feature/image.ts +1 -1
- package/src/feature/indent.ts +1 -1
- package/src/feature/infoBlock.ts +3 -3
- package/src/feature/italic.ts +1 -1
- package/src/feature/lineHeight.ts +1 -1
- package/src/feature/link.ts +1 -1
- package/src/feature/mathformula.ts +1 -1
- package/src/feature/orderList.ts +3 -3
- 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 +3 -3
- package/src/feature/underline.ts +1 -1
- package/src/feature/undo.ts +1 -1
- package/src/feature/unorderList.ts +3 -3
- package/src/feature/video.ts +1 -1
- package/src/icon/iconfont.css +4 -8
- package/src/icon/iconfont.ttf +0 -0
- package/src/icon/iconfont.woff +0 -0
- package/src/index.ts +2 -6
- package/src/locale/en_US.ts +0 -3
- package/src/locale/zh_CN.ts +0 -3
- package/lib/feature/panel.d.ts +0 -18
- package/src/feature/panel.ts +0 -62
package/lib/index.d.ts
CHANGED
@@ -107,10 +107,6 @@ declare const Editify: import('./core/tool').SFCWithInstall<import('vue').Define
|
|
107
107
|
type: BooleanConstructor;
|
108
108
|
default: boolean;
|
109
109
|
};
|
110
|
-
tab: {
|
111
|
-
type: BooleanConstructor;
|
112
|
-
default: boolean;
|
113
|
-
};
|
114
110
|
dark: {
|
115
111
|
type: BooleanConstructor;
|
116
112
|
default: boolean;
|
@@ -287,11 +283,156 @@ declare const Editify: import('./core/tool').SFCWithInstall<import('vue').Define
|
|
287
283
|
};
|
288
284
|
} | null;
|
289
285
|
}[];
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
286
|
+
redoRecords: {
|
287
|
+
stack: {
|
288
|
+
key: number;
|
289
|
+
type: import('alex-editor').AlexElementType;
|
290
|
+
parsedom: string | null;
|
291
|
+
marks: import('alex-editor').ObjectType | null;
|
292
|
+
styles: import('alex-editor').ObjectType | null;
|
293
|
+
textContent: string | null;
|
294
|
+
children: any[] | null;
|
295
|
+
parent: any | null;
|
296
|
+
behavior: "default" | "block";
|
297
|
+
namespace: string | null;
|
298
|
+
locked: boolean;
|
299
|
+
elm: HTMLElement | null;
|
300
|
+
isBlock: () => boolean;
|
301
|
+
isInblock: () => boolean;
|
302
|
+
isInline: () => boolean;
|
303
|
+
isClosed: () => boolean;
|
304
|
+
isText: () => boolean;
|
305
|
+
isBreak: () => boolean;
|
306
|
+
isEmpty: () => boolean;
|
307
|
+
isSpaceText: () => boolean;
|
308
|
+
getUneditableElement: () => AlexElement | null;
|
309
|
+
isEqual: (element: AlexElement) => boolean;
|
310
|
+
isContains: (element: AlexElement) => boolean;
|
311
|
+
isOnlyHasBreak: () => boolean | 0;
|
312
|
+
isPreStyle: () => boolean;
|
313
|
+
hasMarks: () => boolean;
|
314
|
+
hasStyles: () => boolean;
|
315
|
+
hasChildren: () => boolean;
|
316
|
+
hasContains: (element: AlexElement) => boolean;
|
317
|
+
clone: (deep?: boolean | undefined) => AlexElement;
|
318
|
+
convertToBlock: () => void;
|
319
|
+
toEmpty: () => void;
|
320
|
+
getBlock: () => AlexElement;
|
321
|
+
getInblock: () => AlexElement | null;
|
322
|
+
getInline: () => AlexElement | null;
|
323
|
+
isEqualStyles: (element: AlexElement) => boolean;
|
324
|
+
isEqualMarks: (element: AlexElement) => boolean;
|
325
|
+
isFirst: (element: AlexElement) => boolean;
|
326
|
+
isLast: (element: AlexElement) => boolean;
|
327
|
+
__render: () => void;
|
328
|
+
__fullClone: () => AlexElement;
|
329
|
+
}[];
|
330
|
+
range: {
|
331
|
+
anchor: {
|
332
|
+
element: {
|
333
|
+
key: number;
|
334
|
+
type: import('alex-editor').AlexElementType;
|
335
|
+
parsedom: string | null;
|
336
|
+
marks: import('alex-editor').ObjectType | null;
|
337
|
+
styles: import('alex-editor').ObjectType | null;
|
338
|
+
textContent: string | null;
|
339
|
+
children: any[] | null;
|
340
|
+
parent: any | null;
|
341
|
+
behavior: "default" | "block";
|
342
|
+
namespace: string | null;
|
343
|
+
locked: boolean;
|
344
|
+
elm: HTMLElement | null;
|
345
|
+
isBlock: () => boolean;
|
346
|
+
isInblock: () => boolean;
|
347
|
+
isInline: () => boolean;
|
348
|
+
isClosed: () => boolean;
|
349
|
+
isText: () => boolean;
|
350
|
+
isBreak: () => boolean;
|
351
|
+
isEmpty: () => boolean;
|
352
|
+
isSpaceText: () => boolean;
|
353
|
+
getUneditableElement: () => AlexElement | null;
|
354
|
+
isEqual: (element: AlexElement) => boolean;
|
355
|
+
isContains: (element: AlexElement) => boolean;
|
356
|
+
isOnlyHasBreak: () => boolean | 0;
|
357
|
+
isPreStyle: () => boolean;
|
358
|
+
hasMarks: () => boolean;
|
359
|
+
hasStyles: () => boolean;
|
360
|
+
hasChildren: () => boolean;
|
361
|
+
hasContains: (element: AlexElement) => boolean;
|
362
|
+
clone: (deep?: boolean | undefined) => AlexElement;
|
363
|
+
convertToBlock: () => void;
|
364
|
+
toEmpty: () => void;
|
365
|
+
getBlock: () => AlexElement;
|
366
|
+
getInblock: () => AlexElement | null;
|
367
|
+
getInline: () => AlexElement | null;
|
368
|
+
isEqualStyles: (element: AlexElement) => boolean;
|
369
|
+
isEqualMarks: (element: AlexElement) => boolean;
|
370
|
+
isFirst: (element: AlexElement) => boolean;
|
371
|
+
isLast: (element: AlexElement) => boolean;
|
372
|
+
__render: () => void;
|
373
|
+
__fullClone: () => AlexElement;
|
374
|
+
};
|
375
|
+
offset: number;
|
376
|
+
isEqual: (point: import('alex-editor').AlexPoint) => boolean;
|
377
|
+
moveToEnd: (element: AlexElement) => void;
|
378
|
+
moveToStart: (element: AlexElement) => void;
|
379
|
+
};
|
380
|
+
focus: {
|
381
|
+
element: {
|
382
|
+
key: number;
|
383
|
+
type: import('alex-editor').AlexElementType;
|
384
|
+
parsedom: string | null;
|
385
|
+
marks: import('alex-editor').ObjectType | null;
|
386
|
+
styles: import('alex-editor').ObjectType | null;
|
387
|
+
textContent: string | null;
|
388
|
+
children: any[] | null;
|
389
|
+
parent: any | null;
|
390
|
+
behavior: "default" | "block";
|
391
|
+
namespace: string | null;
|
392
|
+
locked: boolean;
|
393
|
+
elm: HTMLElement | null;
|
394
|
+
isBlock: () => boolean;
|
395
|
+
isInblock: () => boolean;
|
396
|
+
isInline: () => boolean;
|
397
|
+
isClosed: () => boolean;
|
398
|
+
isText: () => boolean;
|
399
|
+
isBreak: () => boolean;
|
400
|
+
isEmpty: () => boolean;
|
401
|
+
isSpaceText: () => boolean;
|
402
|
+
getUneditableElement: () => AlexElement | null;
|
403
|
+
isEqual: (element: AlexElement) => boolean;
|
404
|
+
isContains: (element: AlexElement) => boolean;
|
405
|
+
isOnlyHasBreak: () => boolean | 0;
|
406
|
+
isPreStyle: () => boolean;
|
407
|
+
hasMarks: () => boolean;
|
408
|
+
hasStyles: () => boolean;
|
409
|
+
hasChildren: () => boolean;
|
410
|
+
hasContains: (element: AlexElement) => boolean;
|
411
|
+
clone: (deep?: boolean | undefined) => AlexElement;
|
412
|
+
convertToBlock: () => void;
|
413
|
+
toEmpty: () => void;
|
414
|
+
getBlock: () => AlexElement;
|
415
|
+
getInblock: () => AlexElement | null;
|
416
|
+
getInline: () => AlexElement | null;
|
417
|
+
isEqualStyles: (element: AlexElement) => boolean;
|
418
|
+
isEqualMarks: (element: AlexElement) => boolean;
|
419
|
+
isFirst: (element: AlexElement) => boolean;
|
420
|
+
isLast: (element: AlexElement) => boolean;
|
421
|
+
__render: () => void;
|
422
|
+
__fullClone: () => AlexElement;
|
423
|
+
};
|
424
|
+
offset: number;
|
425
|
+
isEqual: (point: import('alex-editor').AlexPoint) => boolean;
|
426
|
+
moveToEnd: (element: AlexElement) => void;
|
427
|
+
moveToStart: (element: AlexElement) => void;
|
428
|
+
};
|
429
|
+
} | null;
|
430
|
+
}[];
|
431
|
+
cloneRange: (newStack: AlexElement[], range: import('alex-editor').AlexRange | null) => import('alex-editor').AlexRange | null;
|
432
|
+
setState: (stack: AlexElement[], range: import('alex-editor').AlexRange | null) => void;
|
433
|
+
undo: () => import('alex-editor').AlexHistoryRecordType | null;
|
434
|
+
redo: () => import('alex-editor').AlexHistoryRecordType | null;
|
435
|
+
updateRange: (range: import('alex-editor').AlexRange) => void;
|
295
436
|
};
|
296
437
|
stack: {
|
297
438
|
key: number;
|
@@ -515,6 +656,8 @@ declare const Editify: import('./core/tool').SFCWithInstall<import('vue').Define
|
|
515
656
|
collapseToEnd: (element?: AlexElement) => void;
|
516
657
|
setDisabled: () => void;
|
517
658
|
setEnabled: () => void;
|
659
|
+
undo: () => void;
|
660
|
+
redo: () => void;
|
518
661
|
emit: (eventName: string, ...value: any) => boolean;
|
519
662
|
on: (eventName: string, eventHandle: (...args: any) => void) => void;
|
520
663
|
off: (eventName: string, eventHandle?: (...args: any) => void) => void;
|
@@ -739,10 +882,6 @@ declare const Editify: import('./core/tool').SFCWithInstall<import('vue').Define
|
|
739
882
|
type: BooleanConstructor;
|
740
883
|
default: boolean;
|
741
884
|
};
|
742
|
-
tab: {
|
743
|
-
type: BooleanConstructor;
|
744
|
-
default: boolean;
|
745
|
-
};
|
746
885
|
dark: {
|
747
886
|
type: BooleanConstructor;
|
748
887
|
default: boolean;
|
@@ -793,7 +932,6 @@ declare const Editify: import('./core/tool').SFCWithInstall<import('vue').Define
|
|
793
932
|
extraKeepTags: string[];
|
794
933
|
renderRules: ((el: AlexElement) => void)[];
|
795
934
|
autoheight: boolean;
|
796
|
-
tab: boolean;
|
797
935
|
dark: boolean;
|
798
936
|
offset: number;
|
799
937
|
}, {}>>;
|
@@ -813,7 +951,7 @@ export type * from './core/tool';
|
|
813
951
|
export type * from './core/function';
|
814
952
|
export type * from './editify/menu';
|
815
953
|
export type * from './editify/toolbar';
|
816
|
-
export { elementIsMatch, getMatchElementByElement, getMatchElementByRange, elementIsList, getListByElement, hasListInRange, rangeIsInList, elementIsTask, getTaskByElement, hasTaskInRange, rangeIsInTask, elementIsAttachment, hasAttachmentInRange, elementIsMathformula, getMathformulaByElement, hasMathformulaInRange,
|
954
|
+
export { elementIsMatch, getMatchElementByElement, getMatchElementByRange, elementIsList, getListByElement, hasListInRange, rangeIsInList, elementIsTask, getTaskByElement, hasTaskInRange, rangeIsInTask, elementIsAttachment, hasAttachmentInRange, elementIsMathformula, getMathformulaByElement, hasMathformulaInRange, elementIsInfoBlock, getInfoBlockByElement, hasInfoBlockInRange, rangeIsInInfoBlock, hasPreInRange, hasTableInRange, hasQuoteInRange, rangeIsInQuote, hasLinkInRange, hasImageInRange, hasVideoInRange, queryTextStyle, setTextStyle, removeTextStyle, queryTextMark, setTextMark, removeTextMark, getRangeText, addSpaceTextToBothSides, setHeading, setIndentIncrease, setIndentDecrease, setQuote, setAlign, setList, setTask, setLineHeight, insertLink, insertImage, insertVideo, insertTable, insertCodeBlock, insertSeparator, insertAttachment, insertMathformula, insertInfoBlock } from './core/function';
|
817
955
|
declare const install: (app: App) => void;
|
818
|
-
declare const version = "0.2.
|
956
|
+
declare const version = "0.2.20";
|
819
957
|
export { Editify as default, Editify, install, AlexElement, version };
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "vue-editify",
|
3
|
-
"version": "0.2.
|
3
|
+
"version": "0.2.20",
|
4
4
|
"private": false,
|
5
5
|
"sideEffects": [
|
6
6
|
"*.css"
|
@@ -17,7 +17,7 @@
|
|
17
17
|
"lib": "vue-tsc && vite build"
|
18
18
|
},
|
19
19
|
"dependencies": {
|
20
|
-
"alex-editor": "^1.4.
|
20
|
+
"alex-editor": "^1.4.34",
|
21
21
|
"dap-util": "^1.5.8",
|
22
22
|
"highlight.js": "^11.8.0",
|
23
23
|
"katex": "^0.16.10",
|
package/src/core/function.ts
CHANGED
@@ -763,54 +763,6 @@ export const hasMathformulaInRange = (editor: AlexEditor, dataRangeCaches: AlexE
|
|
763
763
|
})
|
764
764
|
}
|
765
765
|
|
766
|
-
/** --------------------------------面板判断函数--------------------------------------------------- */
|
767
|
-
|
768
|
-
/**
|
769
|
-
* Open API:判断元素是否面板,不做空元素判断
|
770
|
-
* @param el
|
771
|
-
* @returns
|
772
|
-
*/
|
773
|
-
export const elementIsPanel = (element: AlexElement) => {
|
774
|
-
return elementIsMatch(element, {
|
775
|
-
parsedom: 'div',
|
776
|
-
marks: {
|
777
|
-
'data-editify-panel': true
|
778
|
-
}
|
779
|
-
})
|
780
|
-
}
|
781
|
-
|
782
|
-
/**
|
783
|
-
* Open API:判断元素是否在面板内,是的话返回面板元素,否则返回null
|
784
|
-
* @param el
|
785
|
-
* @returns
|
786
|
-
*/
|
787
|
-
export const getPanelByElement = (element: AlexElement): AlexElement | null => {
|
788
|
-
return getMatchElementByElement(element, {
|
789
|
-
parsedom: 'div',
|
790
|
-
marks: {
|
791
|
-
'data-editify-panel': true
|
792
|
-
}
|
793
|
-
})
|
794
|
-
}
|
795
|
-
|
796
|
-
/**
|
797
|
-
* Open API:选区是否含有面板,不一定是同一个面板,只要含有面板即返回true
|
798
|
-
* @param editor
|
799
|
-
* @param dataRangeCaches
|
800
|
-
* @returns
|
801
|
-
*/
|
802
|
-
export const hasPanelInRange = (editor: AlexEditor, dataRangeCaches: AlexElementsRangeType) => {
|
803
|
-
if (!editor.range) {
|
804
|
-
return false
|
805
|
-
}
|
806
|
-
if (editor.range.anchor.isEqual(editor.range.focus)) {
|
807
|
-
return !!getPanelByElement(editor.range.anchor.element)
|
808
|
-
}
|
809
|
-
return dataRangeCaches.flatList.some(item => {
|
810
|
-
return !!getPanelByElement(item.element)
|
811
|
-
})
|
812
|
-
}
|
813
|
-
|
814
766
|
/** --------------------------------信息块判断函数---------------------------------------------- */
|
815
767
|
|
816
768
|
/**
|
@@ -1507,7 +1459,7 @@ export const addSpaceTextToBothSides = (editor: AlexEditor, element: AlexElement
|
|
1507
1459
|
/** --------------------------------菜单功能函数----------------------------------------------------- */
|
1508
1460
|
|
1509
1461
|
/**
|
1510
|
-
*
|
1462
|
+
* Open API:设置标题,支持h1-h6和p
|
1511
1463
|
* @param editor
|
1512
1464
|
* @param dataRangeCaches
|
1513
1465
|
* @param editTrans
|
@@ -2274,59 +2226,3 @@ export const insertInfoBlock = (editor: AlexEditor, dataRangeCaches: AlexElement
|
|
2274
2226
|
})
|
2275
2227
|
}
|
2276
2228
|
}
|
2277
|
-
|
2278
|
-
/**
|
2279
|
-
* Open API:插入面板
|
2280
|
-
* @param editor
|
2281
|
-
* @param panelTitle 面板标题
|
2282
|
-
* @param panelContent 面板内容
|
2283
|
-
*/
|
2284
|
-
export const insertPanel = (editor: AlexEditor, panelTitle: string, panelContent: string) => {
|
2285
|
-
const panelElement = AlexElement.create({
|
2286
|
-
type: 'block',
|
2287
|
-
parsedom: 'div',
|
2288
|
-
marks: {
|
2289
|
-
'data-editify-panel': 'true'
|
2290
|
-
},
|
2291
|
-
children: [
|
2292
|
-
{
|
2293
|
-
type: 'inblock',
|
2294
|
-
parsedom: 'div',
|
2295
|
-
behavior: 'block',
|
2296
|
-
children: [
|
2297
|
-
{
|
2298
|
-
type: 'text',
|
2299
|
-
textcontent: panelTitle
|
2300
|
-
}
|
2301
|
-
]
|
2302
|
-
},
|
2303
|
-
{
|
2304
|
-
type: 'inblock',
|
2305
|
-
parsedom: 'div',
|
2306
|
-
behavior: 'block',
|
2307
|
-
children: [
|
2308
|
-
{
|
2309
|
-
type: 'text',
|
2310
|
-
textcontent: panelContent
|
2311
|
-
}
|
2312
|
-
]
|
2313
|
-
}
|
2314
|
-
]
|
2315
|
-
})
|
2316
|
-
editor.insertElement(panelElement)
|
2317
|
-
//面板后面插入段落
|
2318
|
-
const paragraph = AlexElement.create({
|
2319
|
-
type: 'block',
|
2320
|
-
parsedom: AlexElement.BLOCK_NODE,
|
2321
|
-
children: [
|
2322
|
-
{
|
2323
|
-
type: 'closed',
|
2324
|
-
parsedom: 'br'
|
2325
|
-
}
|
2326
|
-
]
|
2327
|
-
})
|
2328
|
-
editor.addElementAfter(paragraph, panelElement)
|
2329
|
-
//移动光标到新插入的元素
|
2330
|
-
editor.range!.anchor.moveToEnd(panelElement.children![0])
|
2331
|
-
editor.range!.focus.moveToEnd(panelElement.children![0])
|
2332
|
-
}
|
package/src/core/rule.ts
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
import { AlexEditor, AlexElement, AlexElementCreateConfigType } from 'alex-editor'
|
2
2
|
import { common as DapCommon, color as DapColor } from 'dap-util'
|
3
3
|
import { LanguagesItemType, getHljsHtml } from '@/hljs'
|
4
|
-
import { getTableSize, getCellSpanNumber, elementIsList, elementIsTask, elementIsAttachment, elementIsMathformula, elementIsInfoBlock,
|
4
|
+
import { getTableSize, getCellSpanNumber, elementIsList, elementIsTask, elementIsAttachment, elementIsMathformula, elementIsInfoBlock, autocompleteTableCells, autoHideMergedTableCells, updateRangeInPre, addSpaceTextToBothSides } from './function'
|
5
5
|
|
6
6
|
/**
|
7
7
|
* 有序列表和无序列表的格式化处理
|
@@ -434,7 +434,7 @@ export const infoBlockHandle = (_editor: AlexEditor, element: AlexElement, color
|
|
434
434
|
export const specialInblockHandle = (editor: AlexEditor, element: AlexElement) => {
|
435
435
|
if (element.hasChildren()) {
|
436
436
|
element.children!.forEach(el => {
|
437
|
-
if (elementIsList(el, true) || elementIsList(el, false) || elementIsTask(el) || elementIsInfoBlock(el) ||
|
437
|
+
if (elementIsList(el, true) || elementIsList(el, false) || elementIsTask(el) || elementIsInfoBlock(el) || ['blockquote', 'pre', 'table', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'p'].includes(el.parsedom!)) {
|
438
438
|
const newEl = el.clone()
|
439
439
|
newEl.type = 'block'
|
440
440
|
const block = element.getBlock()
|