@wangeditor-next/list-module 3.0.3 → 3.1.0
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/README.md +56 -0
- package/dist/core/src/config/interface.d.ts +30 -2
- 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/dist/css/style.css +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/dist/list-module/src/locale/en.d.ts +3 -0
- package/dist/list-module/src/locale/zh-CN.d.ts +3 -0
- package/dist/list-module/src/module/custom-types.d.ts +13 -0
- package/dist/list-module/src/module/helpers.d.ts +14 -4
- package/dist/list-module/src/module/html-transform.d.ts +10 -0
- package/dist/list-module/src/module/menu/BaseMenu.d.ts +2 -2
- package/dist/list-module/src/module/outline-actions.d.ts +9 -0
- package/dist/list-module/src/module/parse-elem-html.d.ts +1 -2
- package/dist/list-module/src/module/plugin.d.ts +1 -1
- package/dist/list-module/src/utils/maps.d.ts +2 -1
- package/package.json +2 -2
- 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
package/README.md
CHANGED
|
@@ -1,3 +1,59 @@
|
|
|
1
1
|
# wangEditor list-module
|
|
2
2
|
|
|
3
3
|
List module built in [wangeditor-next](https://wangeditor-next.github.io/docs/) by default.
|
|
4
|
+
|
|
5
|
+
## Semantic heading outlines
|
|
6
|
+
|
|
7
|
+
Heading outlines preserve the historical list-item JSON shape. The existing `type`, `ordered`,
|
|
8
|
+
`level`, and text children remain unchanged; outline-specific fields are optional metadata.
|
|
9
|
+
|
|
10
|
+
```ts
|
|
11
|
+
{
|
|
12
|
+
type: 'list-item',
|
|
13
|
+
ordered: true,
|
|
14
|
+
level: 1,
|
|
15
|
+
headingType: 'header2',
|
|
16
|
+
listMode: 'outline',
|
|
17
|
+
children: [{ text: 'Scope' }],
|
|
18
|
+
}
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
- `headingType`: optional original heading type (`'header1'` through `'header6'`)
|
|
22
|
+
- `listMode`: optional `'outline'` marker for a semantic heading outline
|
|
23
|
+
- `listRestart`: optional restart value for an outline item
|
|
24
|
+
|
|
25
|
+
The default numbered-list menu applies `listMode: 'outline'` to headings. The visible marker is
|
|
26
|
+
derived from heading levels, so `h1`, `h2`, and `h3` render as `1.`, `1.1`, and `1.1.1` without
|
|
27
|
+
writing a number into the heading text. Clicking an outline marker provides continue and restart
|
|
28
|
+
actions.
|
|
29
|
+
|
|
30
|
+
## HTML contract
|
|
31
|
+
|
|
32
|
+
An outline exports semantic `ol > li > hN` HTML, with nested `ol` elements reflecting heading
|
|
33
|
+
depth:
|
|
34
|
+
|
|
35
|
+
```html
|
|
36
|
+
<ol data-w-e-list-mode="outline">
|
|
37
|
+
<li data-w-e-list-indent="0" data-w-e-outline-number="1.">
|
|
38
|
+
<h1>Overview</h1>
|
|
39
|
+
<ol data-w-e-list-mode="outline">
|
|
40
|
+
<li data-w-e-list-indent="1" data-w-e-outline-number="1.1"><h2>Scope</h2></li>
|
|
41
|
+
</ol>
|
|
42
|
+
</li>
|
|
43
|
+
</ol>
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
`data-w-e-list-indent` preserves a source heading's depth when semantic HTML cannot express a
|
|
47
|
+
missing parent level. `data-w-e-outline-number` is derived display metadata. Import recomputes it
|
|
48
|
+
from the retained heading level and optional `data-w-e-list-restart`; it is not part of the heading
|
|
49
|
+
text. Ordered standard lists carry `data-w-e-list-mode="standard"` so a semantic heading in a
|
|
50
|
+
non-outline list round-trips without being reclassified as an outline.
|
|
51
|
+
|
|
52
|
+
When an outline continues after a separate top-level HTML fragment, its new `ol` receives the
|
|
53
|
+
derived `start` value needed for correct rendering outside the editor. Because that fragment also
|
|
54
|
+
carries `data-w-e-outline-number`, parsing retains the original implicit continuation rather than
|
|
55
|
+
turning it into an explicit restart.
|
|
56
|
+
|
|
57
|
+
Historical `list-item` JSON and ordinary `<ol><li>text</li></ol>` HTML remain supported. Consumers
|
|
58
|
+
that inspect editor JSON can continue using `type: 'list-item'`, `ordered`, `level`, and text
|
|
59
|
+
children; they may ignore the optional outline metadata when that feature is not needed.
|
|
@@ -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;
|
|
@@ -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/dist/css/style.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
.w-e-list-color-ewtzuf{color:#000}.w-e-list-color-4xvty2{color:#262626}.w-e-list-color-sqycuk{color:#595959}.w-e-list-color-3z8psd{color:#8c8c8c}.w-e-list-color-wksmh8{color:#bfbfbf}.w-e-list-color-paasa7{color:#d9d9d9}.w-e-list-color-6bm9m5{color:#e9e9e9}.w-e-list-color-l91prz{color:#f5f5f5}.w-e-list-color-k3jp27{color:#fafafa}.w-e-list-color-67tap4{color:#fff}.w-e-list-color-tunwkj{color:#e13c39}.w-e-list-color-s85xre{color:#e75f33}.w-e-list-color-xx8cx7{color:#eb903a}.w-e-list-color-8hp23z{color:#f5db4d}.w-e-list-color-vbyzhj{color:#72c040}.w-e-list-color-a0scch{color:#59bfc0}.w-e-list-color-786vrv{color:#4290f7}.w-e-list-color-jztut9{color:#3658e2}.w-e-list-color-wh1hr9{color:#6a39c9}.w-e-list-color-enuf5u{color:#d84493}.w-e-list-color-ofga0e{color:#fbe9e6}.w-e-list-color-n2n1ob{color:#fcede1}.w-e-list-color-o0q9nf{color:#fcefd4}.w-e-list-color-e2ltc0{color:#fcfbcf}.w-e-list-color-sx4s4b{color:#e7f6d5}.w-e-list-color-t4t3jr{color:#daf4f0}.w-e-list-color-j4jejh{color:#d9edfa}.w-e-list-color-wb7pdv{color:#e0e8fa}.w-e-list-color-f3wgv5{color:#ede1f8}.w-e-list-color-omv2nm{color:#f6e2ea}.w-e-list-color-qn194t{color:#ffa39e}.w-e-list-color-mdg9z8{color:#ffbb96}.w-e-list-color-hl8b9g{color:#ffd591}.w-e-list-color-4bm5ce{color:#fffb8f}.w-e-list-color-xyf4ks{color:#b7eb8f}.w-e-list-color-wj8ykc{color:#87e8de}.w-e-list-color-9gfdr3{color:#91d5ff}.w-e-list-color-hsaivy{color:#adc6ff}.w-e-list-color-v3pqyx{color:#d3adf7}.w-e-list-color-5sw276{color:#ffadd2}.w-e-list-color-bsc56c{color:#ff4d4f}.w-e-list-color-qg254p{color:#ff7a45}.w-e-list-color-sg36qp{color:#ffa940}.w-e-list-color-6556xy{color:#ffec3d}.w-e-list-color-byp7re{color:#73d13d}.w-e-list-color-eyz4ng{color:#36cfc9}.w-e-list-color-9xmyha{color:#40a9ff}.w-e-list-color-g6x347{color:#597ef7}.w-e-list-color-qkkoll{color:#9254de}.w-e-list-color-4uljq8{color:#f759ab}.w-e-list-color-2zmrji{color:#cf1322}.w-e-list-color-8epkxl{color:#d4380d}.w-e-list-color-6ff92a{color:#d46b08}.w-e-list-color-6j9t63{color:#d4b106}.w-e-list-color-xsysfa{color:#389e0d}.w-e-list-color-qic72q{color:#08979c}.w-e-list-color-oounuc{color:#096dd9}.w-e-list-color-dcs2ck{color:#1d39c4}.w-e-list-color-nkq71x{color:#531dab}.w-e-list-color-v640ve{color:#c41d7f}.w-e-list-color-beewzy{color:#820014}.w-e-list-color-dsgatp{color:#871400}.w-e-list-color-du7iiy{color:#873800}.w-e-list-color-aoputq{color:#614700}.w-e-list-color-mkf87m{color:#135200}.w-e-list-color-l4iwsq{color:#00474f}.w-e-list-color-p38mu9{color:#003a8c}.w-e-list-color-z5ty33{color:#061178}.w-e-list-color-6t1egh{color:#22075e}.w-e-list-color-i6ncxa{color:#780650}
|
|
1
|
+
.w-e-list-color-ewtzuf{color:#000}.w-e-list-color-4xvty2{color:#262626}.w-e-list-color-sqycuk{color:#595959}.w-e-list-color-3z8psd{color:#8c8c8c}.w-e-list-color-wksmh8{color:#bfbfbf}.w-e-list-color-paasa7{color:#d9d9d9}.w-e-list-color-6bm9m5{color:#e9e9e9}.w-e-list-color-l91prz{color:#f5f5f5}.w-e-list-color-k3jp27{color:#fafafa}.w-e-list-color-67tap4{color:#fff}.w-e-list-color-tunwkj{color:#e13c39}.w-e-list-color-s85xre{color:#e75f33}.w-e-list-color-xx8cx7{color:#eb903a}.w-e-list-color-8hp23z{color:#f5db4d}.w-e-list-color-vbyzhj{color:#72c040}.w-e-list-color-a0scch{color:#59bfc0}.w-e-list-color-786vrv{color:#4290f7}.w-e-list-color-jztut9{color:#3658e2}.w-e-list-color-wh1hr9{color:#6a39c9}.w-e-list-color-enuf5u{color:#d84493}.w-e-list-color-ofga0e{color:#fbe9e6}.w-e-list-color-n2n1ob{color:#fcede1}.w-e-list-color-o0q9nf{color:#fcefd4}.w-e-list-color-e2ltc0{color:#fcfbcf}.w-e-list-color-sx4s4b{color:#e7f6d5}.w-e-list-color-t4t3jr{color:#daf4f0}.w-e-list-color-j4jejh{color:#d9edfa}.w-e-list-color-wb7pdv{color:#e0e8fa}.w-e-list-color-f3wgv5{color:#ede1f8}.w-e-list-color-omv2nm{color:#f6e2ea}.w-e-list-color-qn194t{color:#ffa39e}.w-e-list-color-mdg9z8{color:#ffbb96}.w-e-list-color-hl8b9g{color:#ffd591}.w-e-list-color-4bm5ce{color:#fffb8f}.w-e-list-color-xyf4ks{color:#b7eb8f}.w-e-list-color-wj8ykc{color:#87e8de}.w-e-list-color-9gfdr3{color:#91d5ff}.w-e-list-color-hsaivy{color:#adc6ff}.w-e-list-color-v3pqyx{color:#d3adf7}.w-e-list-color-5sw276{color:#ffadd2}.w-e-list-color-bsc56c{color:#ff4d4f}.w-e-list-color-qg254p{color:#ff7a45}.w-e-list-color-sg36qp{color:#ffa940}.w-e-list-color-6556xy{color:#ffec3d}.w-e-list-color-byp7re{color:#73d13d}.w-e-list-color-eyz4ng{color:#36cfc9}.w-e-list-color-9xmyha{color:#40a9ff}.w-e-list-color-g6x347{color:#597ef7}.w-e-list-color-qkkoll{color:#9254de}.w-e-list-color-4uljq8{color:#f759ab}.w-e-list-color-2zmrji{color:#cf1322}.w-e-list-color-8epkxl{color:#d4380d}.w-e-list-color-6ff92a{color:#d46b08}.w-e-list-color-6j9t63{color:#d4b106}.w-e-list-color-xsysfa{color:#389e0d}.w-e-list-color-qic72q{color:#08979c}.w-e-list-color-oounuc{color:#096dd9}.w-e-list-color-dcs2ck{color:#1d39c4}.w-e-list-color-nkq71x{color:#531dab}.w-e-list-color-v640ve{color:#c41d7f}.w-e-list-color-beewzy{color:#820014}.w-e-list-color-dsgatp{color:#871400}.w-e-list-color-du7iiy{color:#873800}.w-e-list-color-aoputq{color:#614700}.w-e-list-color-mkf87m{color:#135200}.w-e-list-color-l4iwsq{color:#00474f}.w-e-list-color-p38mu9{color:#003a8c}.w-e-list-color-z5ty33{color:#061178}.w-e-list-color-6t1egh{color:#22075e}.w-e-list-color-i6ncxa{color:#780650}.w-e-list-item .w-e-list-marker{background:transparent;border:0;color:inherit;flex:0 0 auto;font:inherit;line-height:inherit;min-width:1.5em;padding:0;text-align:right}.w-e-list-item .w-e-list-marker:is(button){cursor:pointer}.w-e-list-outline-actions{background:#fff;border:1px solid #d9d9d9;box-shadow:0 2px 8px rgba(0,0,0,.15);display:flex;flex-direction:column;min-width:176px;padding:4px;position:absolute;z-index:3}.w-e-list-outline-actions .w-e-list-outline-action{background:transparent;border:0;color:#333;cursor:pointer;font-size:14px;padding:6px 8px;text-align:left;width:100%}.w-e-list-outline-actions .w-e-list-outline-action:focus-visible,.w-e-list-outline-actions .w-e-list-outline-action:hover{background:#f5f5f5;outline:0}
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
!function(r,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e(require("@wangeditor-next/core"),require("slate"),require("dom7"),require("snabbdom")):"function"==typeof define&&define.amd?define(["@wangeditor-next/core","slate","dom7","snabbdom"],e):(r="undefined"!=typeof globalThis?globalThis:r||self).WangEditorListModule=e(r.core,r.slate,r.$,r.snabbdom)}(this,function(r,e,t,n){"use strict";r.i18nAddResources("en",{listModule:{unOrderedList:"Unordered list",orderedList:"Ordered list",lowerAlphaList:"Ordered list (a,b,c)"}}),r.i18nAddResources("zh-CN",{listModule:{unOrderedList:"无序列表",orderedList:"有序列表",lowerAlphaList:"有序列表(a,b,c)"}});var o=new WeakMap;function i(r){var t,n=r.children||[],o=n.length;if(0===o)return"";for(var i=0;i<o&&!t;i+=1){var l=n[i];e.Text.isText(l)&&(t=l)}return null==t?"":t.color||""}var l=function(r,e){return l=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,e){r.__proto__=e}||function(r,e){for(var t in e)Object.prototype.hasOwnProperty.call(e,t)&&(r[t]=e[t])},l(r,e)};function a(r,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function t(){this.constructor=r}l(r,e),r.prototype=null===e?Object.create(e):(t.prototype=e.prototype,new t)}var d=function(){return d=Object.assign||function(r){for(var e,t=1,n=arguments.length;t<n;t++)for(var o in e=arguments[t])Object.prototype.hasOwnProperty.call(e,o)&&(r[o]=e[o]);return r},d.apply(this,arguments)};function s(r){var e="function"==typeof Symbol&&Symbol.iterator,t=e&&r[e],n=0;if(t)return t.call(r);if(r&&"number"==typeof r.length)return{next:function(){return r&&n>=r.length&&(r=void 0),{value:r&&r[n++],done:!r}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function c(r,e){var t="function"==typeof Symbol&&r[Symbol.iterator];if(!t)return r;var n,o,i=t.call(r),l=[];try{for(;(void 0===e||e-- >0)&&!(n=i.next()).done;)l.push(n.value)}catch(r){o={error:r}}finally{try{n&&!n.done&&(t=i.return)&&t.call(i)}finally{if(o)throw o.error}}return l}function u(r,e,t){if(t||2===arguments.length)for(var n,o=0,i=e.length;o<i;o++)!n&&o in e||(n||(n=Array.prototype.slice.call(e,0,o)),n[o]=e[o]);return r.concat(n||Array.prototype.slice.call(e))}function f(r){var e=r.ordered,t=void 0!==e&&e,n=r.start;return t?"number"!=typeof n||Number.isNaN(n)?1:n:1}function v(r){var e=r.orderType;return"a"===e||"A"===e||"i"===e||"I"===e?e:"1"}function p(r,e){return r.ordered===e.ordered&&(!r.ordered||v(r)===v(e)&&f(r)===f(e))}function g(t,n,o){for(var i=n.type,l=function(r,e){var t={};for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&e.indexOf(n)<0&&(t[n]=r[n]);if(null!=r&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(r);o<n.length;o++)e.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(r,n[o])&&(t[n[o]]=r[n[o]])}return t}(n,["type"]),a=void 0!==o?o:l.level||0,d=r.DomEditor.findPath(t,n);;){if(0===d.length||0===d[d.length-1])return null;d=e.Path.previous(d);var s=e.Editor.node(t,d);if(!s)return null;var u=c(s,1)[0],f=u.level,v=void 0===f?0:f;if(r.DomEditor.getNodeType(u)!==i)return null;if(v===a)return u}}"function"==typeof SuppressedError&&SuppressedError;var y=new Set;function h(r){return(r||"").trim().replace(/\s+/g,"").toLowerCase()}var b=new Set(["rgb(0, 0, 0)","rgb(38, 38, 38)","rgb(89, 89, 89)","rgb(140, 140, 140)","rgb(191, 191, 191)","rgb(217, 217, 217)","rgb(233, 233, 233)","rgb(245, 245, 245)","rgb(250, 250, 250)","rgb(255, 255, 255)","rgb(225, 60, 57)","rgb(231, 95, 51)","rgb(235, 144, 58)","rgb(245, 219, 77)","rgb(114, 192, 64)","rgb(89, 191, 192)","rgb(66, 144, 247)","rgb(54, 88, 226)","rgb(106, 57, 201)","rgb(216, 68, 147)","rgb(251, 233, 230)","rgb(252, 237, 225)","rgb(252, 239, 212)","rgb(252, 251, 207)","rgb(231, 246, 213)","rgb(218, 244, 240)","rgb(217, 237, 250)","rgb(224, 232, 250)","rgb(237, 225, 248)","rgb(246, 226, 234)","rgb(255, 163, 158)","rgb(255, 187, 150)","rgb(255, 213, 145)","rgb(255, 251, 143)","rgb(183, 235, 143)","rgb(135, 232, 222)","rgb(145, 213, 255)","rgb(173, 198, 255)","rgb(211, 173, 247)","rgb(255, 173, 210)","rgb(255, 77, 79)","rgb(255, 122, 69)","rgb(255, 169, 64)","rgb(255, 236, 61)","rgb(115, 209, 61)","rgb(54, 207, 201)","rgb(64, 169, 255)","rgb(89, 126, 247)","rgb(146, 84, 222)","rgb(247, 89, 171)","rgb(207, 19, 34)","rgb(212, 56, 13)","rgb(212, 107, 8)","rgb(212, 177, 6)","rgb(56, 158, 13)","rgb(8, 151, 156)","rgb(9, 109, 217)","rgb(29, 57, 196)","rgb(83, 29, 171)","rgb(196, 29, 127)","rgb(130, 0, 20)","rgb(135, 20, 0)","rgb(135, 56, 0)","rgb(97, 71, 0)","rgb(19, 82, 0)","rgb(0, 71, 79)","rgb(0, 58, 140)","rgb(6, 17, 120)","rgb(34, 7, 94)","rgb(120, 6, 80)"].map(function(r){return h(r)}));function m(r){var e=h(r);return"w-e-list-color-".concat(function(r){var e,t,n=7;try{for(var o=s(r),i=o.next();!i.done;i=o.next())n=(31*n+(i.value.codePointAt(0)||0))%2147483647}catch(r){e={error:r}}finally{try{i&&!i.done&&(t=o.return)&&t.call(o)}finally{if(e)throw e.error}}return n.toString(36)}("color:".concat(e)))}function x(r,e){var t=h(e);return!!t&&(!!b.has(t)||!!function(r,e){for(var t,n=(null===(t=null==r?void 0:r.getConfig().styleClassTokens)||void 0===t?void 0:t.color)||[],o=h(e),i=0;i<n.length;i+=1)if(h(n[i])===o)return!0;return!1}(r,e))}var w=[],T=null;function E(r){return r.ordered?"ol":"ul"}function N(e,t,n){if("prev"===n&&0===t)return null;if("next"===n&&t===e.children.length-1)return null;var o="prev"===n?t-1:t+1,i=e.children[o];return r.DomEditor.checkNodeType(i,"list-item")?i:null}var k={type:"list-item",elemToHtml:function(e,t,n){var l="",a="",d=e,s=d.level,c=void 0===s?0:s,u=function(r){return r.ordered?"ol":"ul"}(d),g=function(r){var e=r.ordered;if(void 0===e||!e)return"<ul>";var t=[],n=v(r),o=f(r);return"1"!==n&&t.push('type="'.concat(n,'"')),1!==o&&t.push('start="'.concat(o,'"')),0===t.length?"<ol>":"<ol ".concat(t.join(" "),">")}(d),h=o.get(e),b=h&&Array.isArray(h.children)?h:null,k=n&&Array.isArray(n.children)?n:null,S=function(r){return!!r&&r.children.indexOf(e)>=0},O=k||b;S(k)?O=k:S(b)&&(O=b);var L=n||h;if(null==O)return{html:"<li>".concat(t,"</li>"),prefix:"",suffix:""};T!==O&&(w.length=0,T=O);var A=O.children.indexOf(e);if(A<0)return{html:"<li>".concat(t,"</li>"),prefix:"",suffix:""};var H=N(O,A,"prev"),M=N(O,A,"next"),D=!!M&&(M.level||0)>c;if(H){var C=H.level||0;if(c>C)for(B=0;B<c-C;B+=1)l+=g,w.push(u);else if(c===C){if(!p(H,d)){var j=w.pop()||E(H);l+="</".concat(j,">").concat(g),w.push(u)}}else{for(var z=C-c;z>0;){j=w.pop()||E(H);l+="</".concat(j,"></li>"),z-=1}var P=function(e,t,n){for(var o=t-1;o>=0;o-=1){var i=e.children[o];if(r.DomEditor.checkNodeType(i,"list-item")&&(i.level||0)===n)return i}return null}(O,A,c);if(P&&!p(P,d)){j=w.pop()||E(P);l+="</".concat(j,">").concat(g),w.push(u)}}}else{w.length=0;for(var B=0;B<c+1;B+=1)l+=g,w.push(u)}var I=i(e),V=r.getTextStyleMode(L),_="",R="",q="";if(I)if("class"===V){q=' data-w-e-color="'.concat(I,'"');var X=function(e,t){if(x(e,t))return"class";var n=r.getClassStylePolicy(e),o="preserve-data";"fallback-inline"===n&&(o="inline"),"strict"===n&&(o="throw");var i="[wangeditor] Unsupported list color class token color=".concat(t,". policy=").concat(n),l="".concat(t,"|").concat(o);if(y.has(l)||(y.add(l),r.reportUnsupportedClassStyle(e,{type:"color",value:t,scene:"toHtml",fallback:o,message:i})),"throw"===o)throw new Error(i);return"inline"===o?"inline":"preserve-data"}(L,I);"class"===X?R=' class="'.concat(m(I),'"'):"inline"===X&&(_=' style="color:'.concat(I,'"'))}else _=' style="color:'.concat(I,'"');var U="<li".concat(R).concat(q).concat(_,">").concat(t).concat(D?"":"</li>");if(!M){for(;w.length>0;){var W=w.pop();if(!W)break;a+="</".concat(W,">"),w.length>0&&(a+="</li>")}T=null}return{html:U,prefix:l,suffix:a}}},S='<svg viewBox="0 0 1024 1024"><path d="M384 832h640v128H384z m0-384h640v128H384z m0-384h640v128H384zM192 0v256H128V64H64V0zM128 526.016v50.016h128v64H64v-146.016l128-60V384H64v-64h192v146.016zM256 704v320H64v-64h128v-64H64v-64h128v-64H64v-64z"></path></svg>',O=function(){function t(){this.type="list-item",this.tag="button"}return t.prototype.getListNode=function(e){var t=this.type;return r.DomEditor.getSelectedNodeByType(e,t)},t.prototype.getValue=function(r){return""},t.prototype.isActive=function(r){var e=this.getListNode(r);if(null==e)return!1;var t=e,n=t.ordered,o=void 0!==n&&n;return o===this.ordered&&(!o||v(t)===(this.orderType||"1"))},t.prototype.isDisabled=function(t){return null==t.selection||!!r.DomEditor.getSelectedElems(t).some(function(r){if(e.Editor.isVoid(t,r)&&e.Editor.isBlock(t,r))return!0;var n=r.type;return!!["pre","code","table"].includes(n)})},t.prototype.exec=function(r,t){this.isActive(r)?e.Transforms.setNodes(r,{type:"paragraph",ordered:void 0,level:void 0,start:void 0,orderType:void 0}):e.Transforms.setNodes(r,{type:"list-item",ordered:this.ordered,indent:void 0,start:void 0,orderType:this.ordered?this.orderType:void 0})},t}(),L=function(e){function t(){var t=e.apply(this,u([],c(arguments),!1))||this;return t.ordered=!1,t.title=r.t("listModule.unOrderedList"),t.iconSvg='<svg viewBox="0 0 1024 1024"><path d="M384 64h640v128H384V64z m0 384h640v128H384v-128z m0 384h640v128H384v-128zM0 128a128 128 0 1 1 256 0 128 128 0 0 1-256 0z m0 384a128 128 0 1 1 256 0 128 128 0 0 1-256 0z m0 384a128 128 0 1 1 256 0 128 128 0 0 1-256 0z"></path></svg>',t}return a(t,e),t}(O),A=function(e){function t(){var t=e.apply(this,u([],c(arguments),!1))||this;return t.ordered=!0,t.orderType="a",t.title=r.t("listModule.lowerAlphaList"),t.iconSvg=S,t}return a(t,e),t}(O),H=function(e){function t(){var t=e.apply(this,u([],c(arguments),!1))||this;return t.ordered=!0,t.title=r.t("listModule.orderedList"),t.iconSvg=S,t}return a(t,e),t}(O),M={key:"bulletedList",factory:function(){return new L}},D={key:"numberedList",factory:function(){return new H}},C={key:"numberedListLowerAlpha",factory:function(){return new A}};function j(r){return r.length?r[0].tagName.toLowerCase():""}function z(r){return e.Text.isText(r)&&""===r.text.trim()}function P(r,t,n){t.forEach(function(t){z(t)||(e.Text.isText(t)||n.isInline(t)?r.push(t):e.Element.isElement(t)&&P(r,t.children,n))})}function B(t){return e.Editor.nodes(t,{at:t.selection||void 0,match:function(e){return 1===r.DomEditor.findPath(t,e).length}})}function I(r,e){if(void 0===e&&(e=!1),r<=0)return String(r);for(var t=r,n="";t>0;){var o=(e?65:97)+(t-1)%26;n=String.fromCharCode(o)+n,t=Math.floor((t-1)/26)}return n}function V(r,e){var t,n;if(void 0===e&&(e=!1),r<=0||r>=4e3)return String(r);var o=r,i="";try{for(var l=s([[1e3,"M"],[900,"CM"],[500,"D"],[400,"CD"],[100,"C"],[90,"XC"],[50,"L"],[40,"XL"],[10,"X"],[9,"IX"],[5,"V"],[4,"IV"],[1,"I"]]),a=l.next();!a.done;a=l.next())for(var d=c(a.value,2),u=d[0],f=d[1];o>=u;)i+=f,o-=u}catch(r){t={error:r}}finally{try{a&&!a.done&&(n=l.return)&&n.call(l)}finally{if(t)throw t.error}}return e?i:i.toLowerCase()}return t.append&&(t.fn.append=t.append),t.attr&&(t.fn.attr=t.attr),t.parent&&(t.fn.parent=t.parent),{renderElems:[{type:"list-item",renderElem:function(t,l,a){o.set(t,a);var d=t,s=d.level,c=void 0===s?0:s,u=d.ordered,g=void 0!==u&&u,y={margin:"5px 0 5px ".concat(20*c,"px"),display:"flex",alignItems:"flex-start"},h="";if(g){var b=function(t,n){var o=n,i=o.type,l=o.level,a=void 0===l?0:l,d=o.ordered,s=void 0!==d&&d,c=f(o),u=n,v=r.DomEditor.findPath(t,u);if(0===v[0])return c;for(;v[0]>0;){var g=e.Path.previous(v),y=e.Editor.node(t,g);if(null==y)break;var h=y[0],b=h.level,m=void 0===b?0:b,x=h.type,w=h.ordered;if(x!==i)break;if(m<a)break;if(m===a){if(w!==s||!p(h,o))break;c+=1}u=h,v=g}return c}(a,t);h=function(r,e){switch(e){case"a":return"".concat(I(r),".");case"A":return"".concat(I(r,!0),".");case"i":return"".concat(V(r),".");case"I":return"".concat(V(r,!0),".");default:return"".concat(r,".")}}(b,v(t))}else h=function(r){void 0===r&&(r=0);var e="";switch(r){case 0:e="•";break;case 1:e="◦";break;default:e="▪"}return e}(c);var m=i(t);return n.jsx("div",{style:y},n.jsx("span",{contentEditable:!1,style:{marginRight:"0.5em",color:m},"data-w-e-reserve":!0},h),n.jsx("span",{style:{flex:"1",wordBreak:"break-word"}},l))}}],editorPlugin:function(t){var n=t.deleteBackward,o=t.handleTab,i=t.normalizeNode,l=t.insertBreak,a=t;return a.insertBreak=function(){var n=c(e.Editor.nodes(t,{match:function(e){return r.DomEditor.checkNodeType(e,"list-item")},universal:!0}),1)[0];return n?""!==n[0].children[0].text?l():void e.Transforms.setNodes(a,{type:"paragraph",ordered:void 0,level:void 0,start:void 0,orderType:void 0}):l()},a.deleteBackward=function(o){var i=a.selection;if(null!=i)if(e.Range.isExpanded(i))n(o);else{var l=r.DomEditor.getSelectedNodeByType(a,"list-item");if(null!=l)if(0!==i.focus.offset)n(o);else{var d=l.level,s=void 0===d?0:d;if(s>0){var c=g(t,l,s-1);if(c){var u=c.ordered;e.Transforms.setNodes(a,{level:s-1,ordered:u,start:u?c.start:void 0,orderType:u?c.orderType:void 0})}else e.Transforms.setNodes(a,{level:s-1})}else e.Transforms.setNodes(a,{type:"paragraph",ordered:void 0,level:void 0,start:void 0,orderType:void 0})}else n(o)}else n(o)},a.handleTab=function(){var t,n,i,l,d=a.selection;if(null!=d){if(e.Range.isCollapsed(d)){var u=r.DomEditor.getSelectedNodeByType(a,"list-item");if(null==u)return void o();if(0===d.focus.offset){var f=u.level,v=void 0===f?0:f;return void e.Transforms.setNodes(a,{level:v+1})}}if(e.Range.isExpanded(d)){var p=0,g=!1;try{for(var y=s(B(a)),h=y.next();!h.done;h=y.next()){var b=c(h.value,1)[0];"list-item"===r.DomEditor.getNodeType(b)?p+=1:g=!0}}catch(r){t={error:r}}finally{try{h&&!h.done&&(n=y.return)&&n.call(y)}finally{if(t)throw t.error}}if(g||p<=1)return void o();try{for(var m=s(B(a)),x=m.next();!x.done;x=m.next()){var w=c(x.value,2),T=(b=w[0],w[1]),E=b.level;v=void 0===E?0:E;e.Transforms.setNodes(a,{level:v+1},{at:T})}}catch(r){i={error:r}}finally{try{x&&!x.done&&(l=m.return)&&l.call(m)}finally{if(i)throw i.error}}}else o()}else o()},a.normalizeNode=function(t){var n=c(t,2),o=n[0],l=n[1],d=r.DomEditor.getNodeType(o);return"bulleted-list"!==d&&"numbered-list"!==d||e.Transforms.unwrapNodes(a,{at:l}),i([o,l])},a},menus:[M,D,C],elemsToHtml:[k],parseElemsHtml:[{selector:"ul:not([data-w-e-type]),ol:not([data-w-e-type])",parseElemHtml:function(r,e,t){return e.flat(1/0)}},{selector:"li:not([data-w-e-type])",parseElemHtml:function(n,o,i){var l=t(n),a=[],s=[];o.forEach(function(t){z(t)||(e.Text.isText(t)||i.isInline(t)?a.push(t):r.DomEditor.checkNodeType(t,"list-item")?s.push(t):e.Element.isElement(t)&&P(a,t.children,i))}),0===a.length&&(s.length>0?a.push({text:""}):a.push({text:l.text().replace(/\s+/gm," ")}));var f=function(r){return"ol"===j(r.parent())}(l),v=function(r){for(var e=0,t=r.parent();t.length>0;){var n=j(t);"ul"!==n&&"ol"!==n||(e+=1),t=t.parent()}return Math.max(0,e-1)}(l),p=function(r){var e=r.parent();if("ol"===j(e)){var t=(e.attr("start")||"").trim();if(""!==t){var n=Number.parseInt(t,10);if(!Number.isNaN(n))return n}}}(l),g=function(r){var e=r.parent();if("ol"===j(e)){var t=(e.attr("type")||"").trim();return"1"===t||"a"===t||"A"===t||"i"===t||"I"===t?t:void 0}}(l),y=d(d(d({type:"list-item",ordered:f,level:v},void 0!==p?{start:p}:{}),void 0!==g?{orderType:g}:{}),{children:a});return 0===s.length?y:u([y],c(s),!1)}}]}});
|
|
1
|
+
!function(e,r){"object"==typeof exports&&"undefined"!=typeof module?module.exports=r(require("@wangeditor-next/core"),require("slate"),require("dom7"),require("snabbdom")):"function"==typeof define&&define.amd?define(["@wangeditor-next/core","slate","dom7","snabbdom"],r):(e="undefined"!=typeof globalThis?globalThis:e||self).WangEditorListModule=r(e.core,e.slate,e.$,e.snabbdom)}(this,function(e,r,t,n){"use strict";e.i18nAddResources("en",{listModule:{unOrderedList:"Unordered list",orderedList:"Ordered list",lowerAlphaList:"Ordered list (a,b,c)",numberingActions:"Heading numbering actions",continueNumbering:"Continue heading numbering",restartNumbering:"Restart numbering"}}),e.i18nAddResources("zh-CN",{listModule:{unOrderedList:"无序列表",orderedList:"有序列表",lowerAlphaList:"有序列表(a,b,c)",numberingActions:"标题编号操作",continueNumbering:"继续标题编号",restartNumbering:"重新开始编号"}});var o=new WeakMap;function i(e){var t,n=e.children||[],o=n.length;if(0===o)return"";for(var i=0;i<o&&!t;i+=1){var a=n[i];r.Text.isText(a)&&(t=a)}return null==t?"":t.color||""}var a=function(e,r){return a=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,r){e.__proto__=r}||function(e,r){for(var t in r)Object.prototype.hasOwnProperty.call(r,t)&&(e[t]=r[t])},a(e,r)};function l(e,r){if("function"!=typeof r&&null!==r)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");function t(){this.constructor=e}a(e,r),e.prototype=null===r?Object.create(r):(t.prototype=r.prototype,new t)}var u=function(){return u=Object.assign||function(e){for(var r,t=1,n=arguments.length;t<n;t++)for(var o in r=arguments[t])Object.prototype.hasOwnProperty.call(r,o)&&(e[o]=r[o]);return e},u.apply(this,arguments)};function c(e){var r="function"==typeof Symbol&&Symbol.iterator,t=r&&e[r],n=0;if(t)return t.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(r?"Object is not iterable.":"Symbol.iterator is not defined.")}function s(e,r){var t="function"==typeof Symbol&&e[Symbol.iterator];if(!t)return e;var n,o,i=t.call(e),a=[];try{for(;(void 0===r||r-- >0)&&!(n=i.next()).done;)a.push(n.value)}catch(e){o={error:e}}finally{try{n&&!n.done&&(t=i.return)&&t.call(i)}finally{if(o)throw o.error}}return a}function d(e,r,t){if(t||2===arguments.length)for(var n,o=0,i=r.length;o<i;o++)!n&&o in r||(n||(n=Array.prototype.slice.call(r,0,o)),n[o]=r[o]);return e.concat(n||Array.prototype.slice.call(r))}function f(r){return e.DomEditor.checkNodeType(r,"list-item")}function v(e){return"string"==typeof e&&/^header[1-6]$/.test(e)}function p(e){return f(e)&&v(e.headingType)?e.headingType:null}function g(e){return f(e)&&e.level>0?Math.floor(e.level):0}function h(e){return f(e)&&!0===e.ordered&&"outline"===e.listMode&&v(e.headingType)}function m(e){var r=p(e),t=null==r?null:/^header([1-6])$/.exec(r);return null!=t?Number.parseInt(t[1],10):g(e)+1}function b(e){var r=e.ordered,t=void 0!==r&&r,n=e.start;return!t||"number"!=typeof n||Number.isNaN(n)?1:n}function y(e){var r=e.orderType;return"a"===r||"A"===r||"i"===r||"I"===r?r:"1"}function w(e,r){return e.ordered===r.ordered&&(!e.ordered||y(e)===y(r)&&b(e)===b(r))}function E(e,r){var t,n,o=Array.from({length:6},function(){return 0});try{for(var i=c(e.children),a=i.next();!a.done;a=i.next()){var l=a.value;if(h(l)){for(var u=m(l),s=u-1,d=0;d<s;d+=1)0===o[d]&&(o[d]=1);"number"==typeof l.listRestart&&l.listRestart>0?o[s]=Math.floor(l.listRestart):0===o[s]?o[s]=1:o[s]+=1;for(var f=s+1;f<o.length;f+=1)o[f]=0;if(l===r){var v=o.slice(0,u).join(".");return 1===u?"".concat(v,"."):v}}}}catch(e){t={error:e}}finally{try{a&&!a.done&&(n=i.return)&&n.call(i)}finally{if(t)throw t.error}}return""}"function"==typeof SuppressedError&&SuppressedError;var x=new Set;function T(e){return(e||"").trim().replace(/\s+/g,"").toLowerCase()}var N=new Set(["rgb(0, 0, 0)","rgb(38, 38, 38)","rgb(89, 89, 89)","rgb(140, 140, 140)","rgb(191, 191, 191)","rgb(217, 217, 217)","rgb(233, 233, 233)","rgb(245, 245, 245)","rgb(250, 250, 250)","rgb(255, 255, 255)","rgb(225, 60, 57)","rgb(231, 95, 51)","rgb(235, 144, 58)","rgb(245, 219, 77)","rgb(114, 192, 64)","rgb(89, 191, 192)","rgb(66, 144, 247)","rgb(54, 88, 226)","rgb(106, 57, 201)","rgb(216, 68, 147)","rgb(251, 233, 230)","rgb(252, 237, 225)","rgb(252, 239, 212)","rgb(252, 251, 207)","rgb(231, 246, 213)","rgb(218, 244, 240)","rgb(217, 237, 250)","rgb(224, 232, 250)","rgb(237, 225, 248)","rgb(246, 226, 234)","rgb(255, 163, 158)","rgb(255, 187, 150)","rgb(255, 213, 145)","rgb(255, 251, 143)","rgb(183, 235, 143)","rgb(135, 232, 222)","rgb(145, 213, 255)","rgb(173, 198, 255)","rgb(211, 173, 247)","rgb(255, 173, 210)","rgb(255, 77, 79)","rgb(255, 122, 69)","rgb(255, 169, 64)","rgb(255, 236, 61)","rgb(115, 209, 61)","rgb(54, 207, 201)","rgb(64, 169, 255)","rgb(89, 126, 247)","rgb(146, 84, 222)","rgb(247, 89, 171)","rgb(207, 19, 34)","rgb(212, 56, 13)","rgb(212, 107, 8)","rgb(212, 177, 6)","rgb(56, 158, 13)","rgb(8, 151, 156)","rgb(9, 109, 217)","rgb(29, 57, 196)","rgb(83, 29, 171)","rgb(196, 29, 127)","rgb(130, 0, 20)","rgb(135, 20, 0)","rgb(135, 56, 0)","rgb(97, 71, 0)","rgb(19, 82, 0)","rgb(0, 71, 79)","rgb(0, 58, 140)","rgb(6, 17, 120)","rgb(34, 7, 94)","rgb(120, 6, 80)"].map(function(e){return T(e)}));function M(e){var r=T(e);return"w-e-list-color-".concat(function(e){var r,t,n=7;try{for(var o=c(e),i=o.next();!i.done;i=o.next())n=(31*n+(i.value.codePointAt(0)||0))%2147483647}catch(e){r={error:e}}finally{try{i&&!i.done&&(t=o.return)&&t.call(o)}finally{if(r)throw r.error}}return n.toString(36)}("color:".concat(r)))}function A(e,r){var t=T(r);return!!t&&(!!N.has(t)||!!function(e,r){for(var t,n=(null===(t=null==e?void 0:e.getConfig().styleClassTokens)||void 0===t?void 0:t.color)||[],o=T(r),i=0;i<n.length;i+=1)if(T(n[i])===o)return!0;return!1}(e,r))}function L(r,t){if(A(r,t))return"class";var n=e.getClassStylePolicy(r),o="preserve-data";"fallback-inline"===n&&(o="inline"),"strict"===n&&(o="throw");var i="[wangeditor] Unsupported list color class token color=".concat(t,". policy=").concat(n),a="".concat(t,"|").concat(o);if(x.has(a)||(x.add(a),e.reportUnsupportedClassStyle(r,{type:"color",value:t,scene:"toHtml",fallback:o,message:i})),"throw"===o)throw new Error(i);return"inline"===o?"inline":"preserve-data"}var k=[],S=null;function C(e){return e.ordered?"ol":"ul"}function H(r,t,n){if("prev"===n&&0===t)return null;if("next"===n&&t===r.children.length-1)return null;var o="prev"===n?t-1:t+1,i=r.children[o];return!e.DomEditor.checkNodeType(i,"list-item")||h(i)?null:i}var D={type:"list-item",elemToHtml:function(r,t,n){var a="",l="",u=r,c=p(u),s=null==c?null:c.replace("header","h");if(h(u)&&null!=s)return{html:"<".concat(s,">").concat(t,"</").concat(s,">"),prefix:"",suffix:""};null!=s&&(t="<".concat(s,">").concat(t,"</").concat(s,">"));var d=u.level,f=void 0===d?0:d,v=function(e){return e.ordered?"ol":"ul"}(u),g=function(e){var r=e.ordered;if(void 0===r||!r)return"<ul>";var t=[],n=y(e),o=b(e);return"1"!==n&&t.push('type="'.concat(n,'"')),1!==o&&t.push('start="'.concat(o,'"')),null!=p(e)&&t.push('data-w-e-list-mode="standard"'),0===t.length?"<ol>":"<ol ".concat(t.join(" "),">")}(u),m=o.get(r),E=m&&Array.isArray(m.children)?m:null,x=n&&Array.isArray(n.children)?n:null,T=function(e){return!!e&&e.children.indexOf(r)>=0},N=x||E;T(x)?N=x:T(E)&&(N=E);var A=n||m;if(null==N)return{html:"<li>".concat(t,"</li>"),prefix:"",suffix:""};S!==N&&(k.length=0,S=N);var D=N.children.indexOf(r);if(D<0)return{html:"<li>".concat(t,"</li>"),prefix:"",suffix:""};var R=H(N,D,"prev"),O=H(N,D,"next"),j=!!O&&(O.level||0)>f;if(R){var I=R.level||0;if(f>I)for(V=0;V<f-I;V+=1)a+=g,k.push(v);else if(f===I){if(!w(R,u)){var z=k.pop()||C(R);a+="</".concat(z,">").concat(g),k.push(v)}}else{for(var B=I-f;B>0;){z=k.pop()||C(R);a+="</".concat(z,"></li>"),B-=1}var P=function(r,t,n){for(var o=t-1;o>=0;o-=1){var i=r.children[o];if(e.DomEditor.checkNodeType(i,"list-item")&&!h(i)&&(i.level||0)===n)return i}return null}(N,D,f);if(P&&!w(P,u)){z=k.pop()||C(P);a+="</".concat(z,">").concat(g),k.push(v)}}}else{k.length=0;for(var V=0;V<f+1;V+=1)a+=g,k.push(v)}var _=i(r),$=e.getTextStyleMode(A),q="",W="",X="";if(_)if("class"===$){X=' data-w-e-color="'.concat(_,'"');var U=L(A,_);"class"===U?W=' class="'.concat(M(_),'"'):"inline"===U&&(q=' style="color:'.concat(_,'"'))}else q=' style="color:'.concat(_,'"');var G="<li".concat(W).concat(X).concat(q,">").concat(t).concat(j?"":"</li>");if(!O){for(;k.length>0;){var Y=k.pop();if(!Y)break;l+="</".concat(Y,">"),k.length>0&&(l+="</li>")}S=null}return{html:G,prefix:a,suffix:l}}};function R(e,r){var t=function(e,r){var t=E(e,r).split(".").filter(Boolean).pop(),n=Number.parseInt(t||"",10);return Number.isFinite(n)&&n>0?n:1}(r,e.node),n=1===t?"":' start="'.concat(t,'"');return"<ol".concat(n,' data-w-e-list-mode="outline">')}function O(r,t){var n=function(r,t){var n=i(r);if(!n)return[];if("class"!==e.getTextStyleMode(t))return['style="color:'.concat(n,'"')];var o=['data-w-e-color="'.concat(n,'"')],a=L(t,n);return"class"===a?o.unshift('class="'.concat(M(n),'"')):"inline"===a&&o.push('style="color:'.concat(n,'"')),o}(r,t);return n.push('data-w-e-list-indent="'.concat(m(r)-1,'"')),"number"==typeof r.listRestart&&n.push('data-w-e-list-restart="'.concat(r.listRestart,'"')),n.push('data-w-e-outline-number="'.concat(E(t,r),'"')),"<li ".concat(n.join(" "),">")}function j(e,r){var t=e.items.map(function(e){var t=e.children.map(function(e){return j(e,r)}).join("");return"".concat(O(e.node,r)).concat(e.html).concat(t,"</li>")}).join("");return"".concat(R(e,r)).concat(t,"</ol>")}var I='<svg viewBox="0 0 1024 1024"><path d="M384 832h640v128H384z m0-384h640v128H384z m0-384h640v128H384zM192 0v256H128V64H64V0zM128 526.016v50.016h128v64H64v-146.016l128-60V384H64v-64h192v146.016zM256 704v320H64v-64h128v-64H64v-64h128v-64H64v-64z"></path></svg>';function z(e){return null==e.selection?[]:Array.from(r.Editor.nodes(e,{at:e.selection,match:function(t){return r.Element.isElement(t)&&r.Editor.isBlock(e,t)},mode:"highest"})).filter(function(e){return 1===s(e,2)[1].length})}function B(e){return Number.parseInt(e.slice(6),10)-1}var P=function(){function e(){this.type="list-item",this.tag="button"}return e.prototype.isTargetListNode=function(e){return!(!f(e)||Boolean(e.ordered)!==this.ordered)&&(!this.ordered||y(e)===(this.orderType||"1"))},e.prototype.getValue=function(e){return""},e.prototype.isActive=function(e){var r=this,t=z(e);return t.length>0&&t.every(function(e){var t=s(e,1)[0];return r.isTargetListNode(t)})},e.prototype.isDisabled=function(e){var t=z(e);return 0===t.length||t.some(function(t){var n=s(t,1)[0];return!function(e,t){return!r.Editor.isVoid(e,t)&&!["pre","code","table","table-row","table-cell"].includes(t.type)}(e,n)})},e.prototype.exec=function(e,t){var n=this,o=this.isActive(e),i=z(e);0!==i.length&&r.Editor.withoutNormalizing(e,function(){i.forEach(function(t){var i=s(t,2),a=i[0],l=i[1];if(o){var u=p(a);r.Transforms.setNodes(e,{type:u||"paragraph",ordered:void 0,level:void 0,start:void 0,orderType:void 0,headingType:void 0,listMode:void 0,listRestart:void 0},{at:l})}else{var c=function(e){return f(e)?p(e):v(e.type)?e.type:null}(a),d=n.ordered&&null==n.orderType&&null!=c;r.Transforms.setNodes(e,{type:"list-item",ordered:n.ordered,level:d?B(c):g(a),start:void 0,orderType:n.ordered?n.orderType:void 0,headingType:d?c:void 0,listMode:d?"outline":void 0,listRestart:void 0},{at:l})}})})},e}(),V=function(r){function t(){var t=r.apply(this,d([],s(arguments),!1))||this;return t.ordered=!1,t.title=e.t("listModule.unOrderedList"),t.iconSvg='<svg viewBox="0 0 1024 1024"><path d="M384 64h640v128H384V64z m0 384h640v128H384v-128z m0 384h640v128H384v-128zM0 128a128 128 0 1 1 256 0 128 128 0 0 1-256 0z m0 384a128 128 0 1 1 256 0 128 128 0 0 1-256 0z m0 384a128 128 0 1 1 256 0 128 128 0 0 1-256 0z"></path></svg>',t}return l(t,r),t}(P),_=function(r){function t(){var t=r.apply(this,d([],s(arguments),!1))||this;return t.ordered=!0,t.orderType="a",t.title=e.t("listModule.lowerAlphaList"),t.iconSvg=I,t}return l(t,r),t}(P),$=function(r){function t(){var t=r.apply(this,d([],s(arguments),!1))||this;return t.ordered=!0,t.title=e.t("listModule.orderedList"),t.iconSvg=I,t}return l(t,r),t}(P),q={key:"bulletedList",factory:function(){return new V}},W={key:"numberedList",factory:function(){return new $}},X={key:"numberedListLowerAlpha",factory:function(){return new _}};function U(e){return e.length?e[0].tagName.toLowerCase():""}function G(e){return"ol"===U(e.parent())}function Y(e){var r=e.parent();if("ol"===U(r)){var t=(r.attr("start")||"").trim(),n=Number.parseInt(t,10);return Number.isNaN(n)?void 0:n}}function F(e){var r=function(e){var r=(e.attr("data-w-e-list-restart")||"").trim();if(/^\d+$/.test(r)){var t=Number.parseInt(r,10);return t>0?t:void 0}}(e);return void 0!==r?r:null==e.attr("data-w-e-outline-number")&&function(e){for(var r,t=null===(r=e[0])||void 0===r?void 0:r.previousElementSibling;null!=t;){if("li"===t.tagName.toLowerCase())return!1;t=t.previousElementSibling}return!0}(e)?Y(e):void 0}function J(e){return r.Text.isText(e)&&""===e.text.trim()}function K(e,t,n){t.forEach(function(t){J(t)||(r.Text.isText(t)||n.isInline(t)?e.push(t):r.Element.isElement(t)&&K(e,t.children,n))})}t.append&&(t.fn.append=t.append),t.attr&&(t.fn.attr=t.attr),t.parent&&(t.fn.parent=t.parent);var Q={selector:"li:not([data-w-e-type])",parseElemHtml:function(e,n,o){var i=t(e),a=function(e){var r=(e.attr("data-w-e-list-indent")||"").trim();if(/^\d+$/.test(r))return Number.parseInt(r,10);for(var t=0,n=e.parent();n.length>0;){var o=U(n);"ul"!==o&&"ol"!==o||(t+=1),n=n.parent()}return Math.max(0,t-1)}(i),l=[],p=[];n.forEach(function(e){J(e)||(f(e)&&e.level>a?p.push(e):l.push(e))});var g=function(e){var t,n;try{for(var o=c(e),i=o.next();!i.done;i=o.next()){var a=i.value;if(r.Element.isElement(a)&&v(a.type))return a}}catch(e){t={error:e}}finally{try{i&&!i.done&&(n=o.return)&&n.call(o)}finally{if(t)throw t.error}}return null}(l),h=null!=g&&v(g.type)?g.type:void 0,m=function(e,t){var n=e.parent().attr("data-w-e-list-mode");return"outline"===n||"standard"===n?n:G(e)&&t.some(function(e){return r.Element.isElement(e)&&v(e.type)})?"outline":"standard"}(i,l),b=[];K(b,l,o),0===b.length&&b.push(p.length>0?{text:""}:{text:i.text().replace(/\s+/gm," ")});var y=G(i),w=Y(i),E=function(e){var r=e.parent();if("ol"===U(r)){var t=(r.attr("type")||"").trim();return"1"===t||"a"===t||"A"===t||"i"===t||"I"===t?t:void 0}}(i),x=y&&"outline"===m&&void 0!==h,T=x?F(i):void 0,N=u(u(u(u(u(u({type:"list-item",ordered:y,level:x?Number.parseInt(h.slice(6),10)-1:a},void 0===w||x?{}:{start:w}),void 0!==E?{orderType:E}:{}),void 0!==h?{headingType:h}:{}),x?{listMode:"outline"}:{}),void 0!==T?{listRestart:T}:{}),{children:b});return 0===p.length?N:d([N],s(p),!1)}};var Z={selector:"ul:not([data-w-e-type]),ol:not([data-w-e-type])",parseElemHtml:function(e,r,t){return r.flat(1/0)}};function ee(e){var t=s(r.Editor.nodes(e,{at:e.selection||void 0,match:f,universal:!0}),1)[0];return null==t?null:t}function re(e,t,n,o){r.Transforms.setNodes(e,{type:o||p(n)||"paragraph",ordered:void 0,level:void 0,start:void 0,orderType:void 0,headingType:void 0,listMode:void 0,listRestart:void 0},{at:t})}var te=new WeakMap;function ne(e,t,n){var o=e.children.indexOf(t);o<0||r.Transforms.setNodes(e,{listRestart:n},{at:[o]})}function oe(e){var r=te.get(e);null!=r&&(r.dispose(),te.delete(e))}function ie(e,r,t){var n=e.createElement("button");return n.type="button",n.className="w-e-list-outline-action",n.textContent=r,n.addEventListener("mousedown",function(e){return e.preventDefault()}),n.addEventListener("click",function(e){e.preventDefault(),e.stopPropagation(),t()}),n}function ae(r,t,n){if(!r.isDisabled()){oe(r);var o=n.ownerDocument,i=o.createElement("div");i.className="w-e-list-outline-actions",i.setAttribute("role","menu"),i.addEventListener("mousedown",function(e){return e.preventDefault()}),i.append(ie(o,e.t("listModule.continueNumbering"),function(){!function(e,r){ne(e,r)}(r,t),oe(r)}),ie(o,e.t("listModule.restartNumbering"),function(){!function(e,r){ne(e,r,1)}(r,t),oe(r)}));var a=e.DomEditor.getTextarea(r),l=a.$textAreaContainer[0],u=a.$scroll[0],c=n.getBoundingClientRect(),s=l.getBoundingClientRect();i.style.top="".concat(c.bottom-s.top+u.scrollTop+4,"px"),i.style.left="".concat(c.left-s.left+u.scrollLeft,"px"),l.append(i);var d=function(e){var t=e.target;t instanceof Node&&(i.contains(t)||n.contains(t)||oe(r))},f=function(){return oe(r)},v=function(){return oe(r)};o.addEventListener("mousedown",d,!0),r.on(e.EditorEvents.CHANGE,f),r.on(e.EditorEvents.DESTROYED,v),te.set(r,{elem:i,dispose:function(){o.removeEventListener("mousedown",d,!0),r.off(e.EditorEvents.CHANGE,f),r.off(e.EditorEvents.DESTROYED,v),i.remove()}})}}function le(e,r){if(void 0===r&&(r=!1),e<=0)return String(e);for(var t=e,n="";t>0;){var o=(r?65:97)+(t-1)%26;n=String.fromCharCode(o)+n,t=Math.floor((t-1)/26)}return n}function ue(e,r){var t,n;if(void 0===r&&(r=!1),e<=0||e>=4e3)return String(e);var o=e,i="";try{for(var a=c([[1e3,"M"],[900,"CM"],[500,"D"],[400,"CD"],[100,"C"],[90,"XC"],[50,"L"],[40,"XL"],[10,"X"],[9,"IX"],[5,"V"],[4,"IV"],[1,"I"]]),l=a.next();!l.done;l=a.next())for(var u=s(l.value,2),d=u[0],f=u[1];o>=d;)i+=f,o-=d}catch(e){t={error:e}}finally{try{l&&!l.done&&(n=a.return)&&n.call(a)}finally{if(t)throw t.error}}return r?i:i.toLowerCase()}return{renderElems:[{type:"list-item",renderElem:function(r,t,a){o.set(r,a);var l=r,u=h(l),c=g(l),s={margin:"5px 0 5px ".concat(20*c,"px"),display:"flex",alignItems:"baseline"},d=i(l),v="";v=u?E(a,l):l.ordered?function(e,r){switch(r){case"a":return"".concat(le(e),".");case"A":return"".concat(le(e,!0),".");case"i":return"".concat(ue(e),".");case"I":return"".concat(ue(e,!0),".");default:return"".concat(e,".")}}(function(r,t){if(!t.ordered)return 1;var n=g(t),o=b(t),i=e.DomEditor.findPath(r,t)[0];if(i<=0)return o;for(var a=i-1;a>=0;a-=1){var l=r.children[a];if(!f(l))break;var u=g(l);if(u<n)break;if(u===n){if(!w(l,t)||h(l))break;o+=1}}return o}(a,l),y(l)):function(e){switch(void 0===e&&(e=0),e){case 0:return"•";case 1:return"◦";default:return"▪"}}(c);var m={marginRight:"0.5em",color:d},x=u?n.jsx("button",{type:"button",className:"w-e-list-marker",contentEditable:!1,"data-w-e-reserve":!0,"aria-label":e.t("listModule.numberingActions"),title:e.t("listModule.numberingActions"),style:m,on:{mousedown:function(e){return e.preventDefault()},click:function(e){e.preventDefault(),e.stopPropagation(),e.currentTarget instanceof HTMLElement&&ae(a,l,e.currentTarget)}}},v):n.jsx("span",{className:"w-e-list-marker",contentEditable:!1,style:m,"data-w-e-reserve":!0},v),T=p(l),N=null==T?"span":T.replace("header","h");return n.jsx("div",{className:"w-e-list-item",style:s},x,n.jsx(N,{style:{flex:"1",minWidth:"0",wordBreak:"break-word"}},t))}}],editorPlugin:function(t){var n=t.deleteBackward,o=t.handleTab,i=t.normalizeNode,a=t.insertBreak,l=t;return l.insertBreak=function(){var e=ee(l);if(null==e)return a();var t=s(e,2),n=t[0],o=t[1];if(""!==r.Node.string(n))return a();re(l,o,n,"paragraph")},l.deleteBackward=function(o){var i=l.selection;if(null==i||r.Range.isExpanded(i))n(o);else{var a=ee(l);if(null!=a&&0===i.focus.offset){var u=s(a,2),c=u[0],d=u[1];if(h(c))re(l,d,c);else{var v=g(c);if(v<=0)re(l,d,c);else{var p=function(t,n,o){for(var i=void 0!==o?o:n.level||0,a=e.DomEditor.findPath(t,n);;){if(0===a.length||0===a[a.length-1])return null;a=r.Path.previous(a);var l=r.Editor.node(t,a);if(null==l||!f(l[0]))return null;if(g(l[0])===i)return l[0]}}(t,c,v-1);null!=p?r.Transforms.setNodes(l,{level:v-1,ordered:p.ordered,start:p.ordered?p.start:void 0,orderType:p.ordered?p.orderType:void 0},{at:d}):r.Transforms.setNodes(l,{level:v-1},{at:d})}}}else n(o)}},l.handleTab=function(){var e=l.selection;if(null!=e)if(r.Range.isCollapsed(e)){var t=ee(l);if(null==t||h(t[0])||0!==e.focus.offset)return void o();var n=s(t,2),i=n[0],a=n[1];r.Transforms.setNodes(l,{level:g(i)+1},{at:a})}else{var u=function(e){return Array.from(r.Editor.nodes(e,{at:e.selection||void 0,match:function(t){return r.Element.isElement(t)&&r.Editor.isBlock(e,t)},mode:"highest"})).filter(function(e){return 1===s(e,2)[1].length})}(l),c=u.filter(function(e){var r=s(e,1)[0];return f(r)&&!h(r)});c.length!==u.length||c.length<=1?o():c.forEach(function(e){var t=s(e,2),n=t[0],o=t[1];r.Transforms.setNodes(l,{level:g(n)+1},{at:o})})}else o()},l.normalizeNode=function(t){var n=s(t,2),o=n[0],a=n[1],u=e.DomEditor.getNodeType(o);return"bulleted-list"!==u&&"numbered-list"!==u||r.Transforms.unwrapNodes(l,{at:a}),i([o,a])},l},menus:[q,W,X],htmlTransform:function(e,r,t){var n=[],o=null,i=function(){null!=o&&0!==o.roots.length&&(n.push(o.roots.map(function(e){return j(e,t)}).join("")),o=null)};return r.forEach(function(r,t){var a=e[t]||"";if(h(r))return null==o&&(o={roots:[],levels:[]}),void function(e,r,t,n){var o,i=Math.max(0,m(t)-1);i>r.length&&(i=r.length),r.length=i+1;var a,l=i>0?null===(o=r[i-1])||void 0===o?void 0:o.lastItem:null,u=r[i],c="number"==typeof t.listRestart;null==u||!w(u.container.node,t)||c?(a={node:t,items:[]},null!=l?l.children.push(a):e.push(a)):a=u.container;var s={node:t,html:n,children:[]};a.items.push(s),r[i]={container:a,lastItem:s}}(o.roots,o.levels,r,a);i(),n.push(a)}),i(),n},elemsToHtml:[D],parseElemsHtml:[Z,Q]}});
|
|
2
2
|
//# sourceMappingURL=index.js.map
|