@wangeditor-next/code-highlight 3.0.1 → 6.1.1
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/dist/core/src/config/interface.d.ts +30 -2
- package/dist/core/src/editor/dom-editor.d.ts +1 -0
- package/dist/core/src/editor/interface.d.ts +16 -3
- package/dist/core/src/index.d.ts +4 -2
- package/dist/core/src/render/helper.d.ts +1 -2
- package/dist/core/src/to-html/index.d.ts +12 -0
- package/package.json +5 -5
- package/dist/basic-modules/src/modules/image/custom-types.d.ts +0 -22
- package/dist/table-module/src/utils/has-common.d.ts +0 -7
- package/dist/table-module/src/utils/index.d.ts +0 -5
- package/dist/table-module/src/utils/is-of-type.d.ts +0 -6
- package/dist/table-module/src/utils/matrices.d.ts +0 -9
- package/dist/table-module/src/utils/options.d.ts +0 -25
- package/dist/table-module/src/utils/point.d.ts +0 -7
- package/dist/table-module/src/utils/types.d.ts +0 -19
- package/dist/video-module/src/module/custom-types.d.ts +0 -23
|
@@ -2,13 +2,41 @@
|
|
|
2
2
|
* @description config interface
|
|
3
3
|
* @author wangfupeng
|
|
4
4
|
*/
|
|
5
|
-
import type { ImageElement } from 'packages/basic-modules/src/modules/image/custom-types';
|
|
6
|
-
import type { VideoElement } from 'packages/video-module/src/module/custom-types';
|
|
7
5
|
import type { Descendant, Node, NodeEntry, Range } from 'slate';
|
|
8
6
|
import type { IDomEditor } from '../editor/interface';
|
|
9
7
|
import type { IMenuGroup } from '../menus/interface';
|
|
10
8
|
import type { IUploadConfig } from '../upload/interface';
|
|
11
9
|
import type { DOMElement } from '../utils/dom';
|
|
10
|
+
type EmptyText = {
|
|
11
|
+
text: '';
|
|
12
|
+
};
|
|
13
|
+
type ImageElement = {
|
|
14
|
+
type: 'image';
|
|
15
|
+
src: string;
|
|
16
|
+
alt?: string;
|
|
17
|
+
href?: string;
|
|
18
|
+
width?: string;
|
|
19
|
+
height?: string;
|
|
20
|
+
style?: {
|
|
21
|
+
width?: string;
|
|
22
|
+
height?: string;
|
|
23
|
+
};
|
|
24
|
+
children: EmptyText[];
|
|
25
|
+
};
|
|
26
|
+
type VideoElement = {
|
|
27
|
+
type: 'video';
|
|
28
|
+
key?: string;
|
|
29
|
+
src: string;
|
|
30
|
+
poster?: string;
|
|
31
|
+
align?: 'left' | 'center' | 'right';
|
|
32
|
+
width?: string;
|
|
33
|
+
height?: string;
|
|
34
|
+
style?: {
|
|
35
|
+
width?: string;
|
|
36
|
+
height?: string;
|
|
37
|
+
};
|
|
38
|
+
children: EmptyText[];
|
|
39
|
+
};
|
|
12
40
|
interface IHoverbarConf {
|
|
13
41
|
[key: string]: {
|
|
14
42
|
match?: (editor: IDomEditor, n: Node) => boolean;
|
|
@@ -109,6 +109,7 @@ export declare const DomEditor: {
|
|
|
109
109
|
getNodeType(node: Node): string;
|
|
110
110
|
checkNodeType(node: Node, type: string): boolean;
|
|
111
111
|
getNodesStr(nodes: Node[]): string;
|
|
112
|
+
getSelectedVoidNode(editor: IDomEditor): Element | null;
|
|
112
113
|
getSelectedElems(editor: IDomEditor): Element[];
|
|
113
114
|
getSelectedNodeByType(editor: IDomEditor, type: string): Node | null;
|
|
114
115
|
getSelectedTextNode(editor: IDomEditor): Node | null;
|
|
@@ -2,15 +2,28 @@
|
|
|
2
2
|
* @description editor interface
|
|
3
3
|
* @author wangfupeng
|
|
4
4
|
*/
|
|
5
|
-
import { NodeEntryWithContext } from '@wangeditor-next/table-module/src/utils';
|
|
6
5
|
import ee from 'event-emitter';
|
|
7
|
-
import { Ancestor, Editor, Element, Location, Node } from 'slate';
|
|
6
|
+
import { Ancestor, Editor, Element, Location, Node, NodeEntry } from 'slate';
|
|
8
7
|
import { AlertType, IEditorConfig, IMenuConfig, ISingleMenuConfig } from '../config/interface';
|
|
9
8
|
import { IPositionStyle } from '../menus/interface';
|
|
10
9
|
import { DOMElement } from '../utils/dom';
|
|
11
10
|
export type ElementWithId = Element & {
|
|
12
11
|
id: string;
|
|
13
12
|
};
|
|
13
|
+
export type TableSelectionEntry = [
|
|
14
|
+
NodeEntry<Element & {
|
|
15
|
+
type: unknown;
|
|
16
|
+
rowSpan?: number;
|
|
17
|
+
colSpan?: number;
|
|
18
|
+
hidden?: boolean;
|
|
19
|
+
}>,
|
|
20
|
+
{
|
|
21
|
+
rtl: number;
|
|
22
|
+
ltr: number;
|
|
23
|
+
ttb: number;
|
|
24
|
+
btt: number;
|
|
25
|
+
}
|
|
26
|
+
];
|
|
14
27
|
type MoveOptions = Parameters<Editor['move']>[0];
|
|
15
28
|
export type getMenuConfigReturnType<K> = K extends keyof IMenuConfig ? IMenuConfig[K] : ISingleMenuConfig;
|
|
16
29
|
/**
|
|
@@ -59,7 +72,7 @@ export interface IDomEditor extends Editor {
|
|
|
59
72
|
move(distance: number, reverse?: boolean): void;
|
|
60
73
|
moveReverse: (distance: number) => void;
|
|
61
74
|
restoreSelection: () => void;
|
|
62
|
-
getTableSelection?: () =>
|
|
75
|
+
getTableSelection?: () => TableSelectionEntry[][] | null;
|
|
63
76
|
getSelectionPosition: () => Partial<IPositionStyle>;
|
|
64
77
|
getNodePosition: (node: Node) => Partial<IPositionStyle>;
|
|
65
78
|
isSelectedAll: () => boolean;
|
package/dist/core/src/index.d.ts
CHANGED
|
@@ -7,11 +7,12 @@ import type { IDomEditor } from './editor/interface';
|
|
|
7
7
|
import type { IRegisterMenuConf } from './menus/index';
|
|
8
8
|
import type { IParseElemHtmlConf, IPreParseHtmlConf, ParseStyleHtmlFnType } from './parse-html/index';
|
|
9
9
|
import type { IRenderElemConf, RenderStyleFnType } from './render/index';
|
|
10
|
-
import type { IElemToHtmlConf, styleToHtmlFnType } from './to-html/index';
|
|
10
|
+
import type { HtmlTransformFnType, IElemToHtmlConf, styleToHtmlFnType } from './to-html/index';
|
|
11
11
|
import createUploaderRuntime from './upload/createUploader';
|
|
12
12
|
import type { IUploadConfig } from './upload/interface';
|
|
13
13
|
export * from './create/index';
|
|
14
|
-
export type { ClassStylePolicy, IClassStyleUnsupportedPayload, IEditorConfig, IToolbarConfig, IUploadImageConfig, IUploadVideoConfig, StyleClassTokenType, TextStyleMode, } from './config/interface';
|
|
14
|
+
export type { ClassStylePolicy, IClassStyleUnsupportedPayload, IEditorConfig, ISingleMenuConfig, IToolbarConfig, IUploadImageConfig, IUploadVideoConfig, StyleClassTokenType, TextStyleMode, } from './config/interface';
|
|
15
|
+
export { EditorEvents } from './config/interface';
|
|
15
16
|
export * from './config/style-mode';
|
|
16
17
|
export * from './editor/dom-editor';
|
|
17
18
|
export * from './editor/interface';
|
|
@@ -35,6 +36,7 @@ export interface IModuleConf {
|
|
|
35
36
|
renderStyle: RenderStyleFnType;
|
|
36
37
|
renderElems: Array<IRenderElemConf>;
|
|
37
38
|
styleToHtml: styleToHtmlFnType;
|
|
39
|
+
htmlTransform?: HtmlTransformFnType;
|
|
38
40
|
elemsToHtml: Array<IElemToHtmlConf>;
|
|
39
41
|
preParseHtml: Array<IPreParseHtmlConf>;
|
|
40
42
|
parseStyleHtml: ParseStyleHtmlFnType;
|
|
@@ -2,6 +2,5 @@
|
|
|
2
2
|
* @description formats helper
|
|
3
3
|
* @author wangfupeng
|
|
4
4
|
*/
|
|
5
|
-
|
|
6
|
-
export declare function genElemId(type: ElementType, id: string): string;
|
|
5
|
+
export declare function genElemId(type: string, id: string): string;
|
|
7
6
|
export declare function genTextId(id: string): string;
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import { Descendant, Element as SlateElement } from 'slate';
|
|
6
6
|
import { IDomEditor } from '../editor/interface';
|
|
7
|
+
import type { INodeToHtmlOptions } from './node2html';
|
|
7
8
|
export type styleToHtmlFnType = (node: Descendant, elemHtml: string, editor?: IDomEditor) => string;
|
|
8
9
|
export declare const STYLE_TO_HTML_FN_LIST: styleToHtmlFnType[];
|
|
9
10
|
/**
|
|
@@ -11,6 +12,17 @@ export declare const STYLE_TO_HTML_FN_LIST: styleToHtmlFnType[];
|
|
|
11
12
|
* @param fn 处理 toHtml 文本样式的函数
|
|
12
13
|
*/
|
|
13
14
|
export declare function registerStyleToHtmlHandler(fn: styleToHtmlFnType): void;
|
|
15
|
+
/**
|
|
16
|
+
* Transform the HTML fragments of the document's top-level nodes.
|
|
17
|
+
*
|
|
18
|
+
* Element serializers intentionally stay node-local. Modules that need
|
|
19
|
+
* neighboring blocks to produce valid HTML (for example semantic lists) use
|
|
20
|
+
* this hook after every node has been serialized.
|
|
21
|
+
*/
|
|
22
|
+
export type HtmlTransformFnType = (htmlList: string[], nodes: Descendant[], editor: IDomEditor, options: INodeToHtmlOptions) => string[];
|
|
23
|
+
export declare const HTML_TRANSFORM_HANDLER_LIST: HtmlTransformFnType[];
|
|
24
|
+
export declare function registerHtmlTransformHandler(fn: HtmlTransformFnType): void;
|
|
25
|
+
export declare function transformHtml(htmlList: string[], nodes: Descendant[], editor: IDomEditor, options?: INodeToHtmlOptions): string[];
|
|
14
26
|
interface IElemToHtmlRes {
|
|
15
27
|
html: string;
|
|
16
28
|
prefix?: string;
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wangeditor-next/code-highlight",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "6.1.1",
|
|
4
4
|
"description": "wangEditor code-highlight module",
|
|
5
5
|
"author": "cycleccc <2991205548@qq.com>",
|
|
6
6
|
"type": "module",
|
|
7
|
-
"homepage": "https://github.com/wangeditor-next/
|
|
7
|
+
"homepage": "https://github.com/wangeditor-next/wangEditor-next#readme",
|
|
8
8
|
"license": "MIT",
|
|
9
9
|
"types": "dist/code-highlight/src/index.d.ts",
|
|
10
10
|
"main": "dist/index.js",
|
|
@@ -32,13 +32,13 @@
|
|
|
32
32
|
"url": "git+https://github.com/wangeditor-next/wangEditor-next.git"
|
|
33
33
|
},
|
|
34
34
|
"bugs": {
|
|
35
|
-
"url": "https://github.com/wangeditor-next/
|
|
35
|
+
"url": "https://github.com/wangeditor-next/wangEditor-next/issues"
|
|
36
36
|
},
|
|
37
37
|
"peerDependencies": {
|
|
38
|
-
"@wangeditor-next/core": "1.9.1",
|
|
39
38
|
"dom7": "^3.0.0 || ^4.0.0",
|
|
40
39
|
"slate": "^0.124.0",
|
|
41
|
-
"snabbdom": "^3.6.0"
|
|
40
|
+
"snabbdom": "^3.6.0",
|
|
41
|
+
"@wangeditor-next/core": "^6.1.1"
|
|
42
42
|
},
|
|
43
43
|
"dependencies": {
|
|
44
44
|
"prismjs": "^1.23.0"
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @description image element
|
|
3
|
-
* @author wangfupeng
|
|
4
|
-
*/
|
|
5
|
-
type EmptyText = {
|
|
6
|
-
text: '';
|
|
7
|
-
};
|
|
8
|
-
export type ImageStyle = {
|
|
9
|
-
width?: string;
|
|
10
|
-
height?: string;
|
|
11
|
-
};
|
|
12
|
-
export type ImageElement = {
|
|
13
|
-
type: 'image';
|
|
14
|
-
src: string;
|
|
15
|
-
alt?: string;
|
|
16
|
-
href?: string;
|
|
17
|
-
width?: string;
|
|
18
|
-
height?: string;
|
|
19
|
-
style?: ImageStyle;
|
|
20
|
-
children: EmptyText[];
|
|
21
|
-
};
|
|
22
|
-
export {};
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { Editor, Span } from 'slate';
|
|
2
|
-
import { WithTableOptions } from './options';
|
|
3
|
-
/**
|
|
4
|
-
* Determines whether two paths belong to the same types by checking
|
|
5
|
-
* if they share a common ancestor node of type table
|
|
6
|
-
*/
|
|
7
|
-
export declare function hasCommon(editor: Editor, [path, another]: Span, ...types: Array<keyof WithTableOptions['blocks']>): boolean;
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { Editor, Element, Node, NodeMatch } from 'slate';
|
|
2
|
-
import { WithTableOptions } from './options';
|
|
3
|
-
import { WithType } from './types';
|
|
4
|
-
export declare function isElement<T extends Element>(node: Node): node is WithType<T>;
|
|
5
|
-
/** @returns a `NodeMatch` function which is used to match the elements of a specific `type`. */
|
|
6
|
-
export declare function isOfType<T extends WithType<Element>>(editor: Editor, ...types: Array<keyof WithTableOptions['blocks']>): NodeMatch<T>;
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { Editor, Location, NodeEntry } from 'slate';
|
|
2
|
-
import { CellElement, NodeEntryWithContext } from './types';
|
|
3
|
-
/** Generates a matrix for each table section (`thead`, `tbody`, `tfoot`) */
|
|
4
|
-
export declare function matrices(editor: Editor, options?: {
|
|
5
|
-
at?: Location;
|
|
6
|
-
}): Generator<NodeEntry<CellElement>[][]>;
|
|
7
|
-
export declare function filledMatrix(editor: Editor, options?: {
|
|
8
|
-
at?: Location;
|
|
9
|
-
}): NodeEntryWithContext[][];
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { CustomTypes, ExtendedType } from 'slate';
|
|
2
|
-
type ElementType = ExtendedType<'Element', CustomTypes>['type'];
|
|
3
|
-
export interface WithTableOptions {
|
|
4
|
-
blocks: {
|
|
5
|
-
td: ElementType;
|
|
6
|
-
th: ElementType;
|
|
7
|
-
content: ElementType;
|
|
8
|
-
tr: ElementType;
|
|
9
|
-
table: ElementType;
|
|
10
|
-
tbody: ElementType;
|
|
11
|
-
tfoot: ElementType;
|
|
12
|
-
thead: ElementType;
|
|
13
|
-
};
|
|
14
|
-
}
|
|
15
|
-
export declare const DEFAULT_WITH_TABLE_OPTIONS: {
|
|
16
|
-
blocks: {
|
|
17
|
-
td: string;
|
|
18
|
-
th: string;
|
|
19
|
-
content: string;
|
|
20
|
-
tr: string;
|
|
21
|
-
table: string;
|
|
22
|
-
tbody: string;
|
|
23
|
-
};
|
|
24
|
-
};
|
|
25
|
-
export {};
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { Element, NodeEntry } from 'slate';
|
|
2
|
-
export type CellElement = WithType<{
|
|
3
|
-
rowSpan?: number;
|
|
4
|
-
colSpan?: number;
|
|
5
|
-
hidden?: boolean;
|
|
6
|
-
} & Element>;
|
|
7
|
-
/** Extends an element with the "type" property */
|
|
8
|
-
export type WithType<T extends Element> = T & Record<'type', unknown>;
|
|
9
|
-
export type NodeEntryWithContext = [
|
|
10
|
-
NodeEntry<CellElement>,
|
|
11
|
-
{
|
|
12
|
-
rtl: number;
|
|
13
|
-
ltr: number;
|
|
14
|
-
ttb: number;
|
|
15
|
-
btt: number;
|
|
16
|
-
}
|
|
17
|
-
];
|
|
18
|
-
export type SelectionMode = 'start' | 'end' | 'all';
|
|
19
|
-
export type Edge = 'start' | 'end' | 'top' | 'bottom';
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @description video element
|
|
3
|
-
* @author wangfupeng
|
|
4
|
-
*/
|
|
5
|
-
type EmptyText = {
|
|
6
|
-
text: '';
|
|
7
|
-
};
|
|
8
|
-
export type videoStyle = {
|
|
9
|
-
width?: string;
|
|
10
|
-
height?: string;
|
|
11
|
-
};
|
|
12
|
-
export type VideoElement = {
|
|
13
|
-
type: 'video';
|
|
14
|
-
key?: string;
|
|
15
|
-
src: string;
|
|
16
|
-
poster?: string;
|
|
17
|
-
textAlign?: string;
|
|
18
|
-
width?: string;
|
|
19
|
-
height?: string;
|
|
20
|
-
style?: videoStyle;
|
|
21
|
-
children: EmptyText[];
|
|
22
|
-
};
|
|
23
|
-
export {};
|