@fibery/prosemirror-schema 4.21.0 → 4.23.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/lib/index.d.ts +10 -8
- package/lib/index.js +9 -26
- package/lib/src/attr-constraints.d.ts +15 -12
- package/lib/src/attr-constraints.js +128 -168
- package/lib/src/block-id-utils.d.ts +10 -7
- package/lib/src/block-id-utils.js +16 -39
- package/lib/src/create-schema.d.ts +16 -15
- package/lib/src/create-schema.js +204 -249
- package/lib/src/marks/code.d.ts +5 -2
- package/lib/src/marks/code.js +10 -10
- package/lib/src/marks/em.d.ts +5 -2
- package/lib/src/marks/em.js +19 -16
- package/lib/src/marks/hint-query.d.ts +5 -2
- package/lib/src/marks/hint-query.js +19 -22
- package/lib/src/marks/link.d.ts +5 -2
- package/lib/src/marks/link.js +40 -36
- package/lib/src/marks/linked-highlight.d.ts +9 -7
- package/lib/src/marks/linked-highlight.js +38 -51
- package/lib/src/marks/strike.d.ts +5 -2
- package/lib/src/marks/strike.js +6 -6
- package/lib/src/marks/strong.d.ts +5 -2
- package/lib/src/marks/strong.js +29 -29
- package/lib/src/marks/text-background-color.d.ts +16 -2
- package/lib/src/marks/text-background-color.js +63 -81
- package/lib/src/marks/underline.d.ts +5 -2
- package/lib/src/marks/underline.js +6 -6
- package/lib/src/nodes/callout.d.ts +29 -28
- package/lib/src/nodes/callout.js +58 -36
- package/lib/src/nodes/check-item.d.ts +13 -10
- package/lib/src/nodes/check-item.js +32 -33
- package/lib/src/nodes/check-list.d.ts +14 -11
- package/lib/src/nodes/check-list.js +23 -30
- package/lib/src/nodes/code-block.d.ts +5 -2
- package/lib/src/nodes/code-block.js +70 -101
- package/lib/src/nodes/column.d.ts +5 -2
- package/lib/src/nodes/column.js +28 -34
- package/lib/src/nodes/columns.d.ts +5 -2
- package/lib/src/nodes/columns.js +34 -36
- package/lib/src/nodes/emoji.d.ts +28 -26
- package/lib/src/nodes/emoji.js +38 -47
- package/lib/src/nodes/entity.d.ts +18 -16
- package/lib/src/nodes/entity.js +48 -49
- package/lib/src/nodes/fibery-view.d.ts +5 -2
- package/lib/src/nodes/fibery-view.js +38 -42
- package/lib/src/nodes/file.d.ts +37 -34
- package/lib/src/nodes/file.js +41 -40
- package/lib/src/nodes/heading.d.ts +6 -3
- package/lib/src/nodes/heading.js +57 -33
- package/lib/src/nodes/image-block.d.ts +5 -2
- package/lib/src/nodes/image-block.js +43 -42
- package/lib/src/nodes/important.d.ts +5 -2
- package/lib/src/nodes/important.js +14 -10
- package/lib/src/nodes/math-display.d.ts +5 -2
- package/lib/src/nodes/math-display.js +14 -15
- package/lib/src/nodes/math-inline.d.ts +5 -2
- package/lib/src/nodes/math-inline.js +14 -15
- package/lib/src/nodes/media.d.ts +6 -3
- package/lib/src/nodes/media.js +52 -68
- package/lib/src/nodes/mention.d.ts +12 -9
- package/lib/src/nodes/mention.js +36 -37
- package/lib/src/nodes/note.d.ts +5 -2
- package/lib/src/nodes/note.js +14 -10
- package/lib/src/nodes/paragraph.d.ts +5 -2
- package/lib/src/nodes/paragraph.js +32 -26
- package/lib/src/nodes/table-nodes.d.ts +5 -2
- package/lib/src/nodes/table-nodes.js +16 -20
- package/lib/src/nodes/types/inline-content.d.ts +10 -8
- package/lib/src/nodes/types/inline-content.js +0 -2
- package/lib/src/nodes/types/text.d.ts +7 -4
- package/lib/src/nodes/types/text.js +0 -2
- package/lib/src/nodes/video.d.ts +7 -4
- package/lib/src/nodes/video.js +49 -54
- package/lib/src/resizable-node-attrs.d.ts +29 -26
- package/lib/src/resizable-node-attrs.js +23 -34
- package/lib/src/transcription-node-attrs.d.ts +10 -7
- package/lib/src/transcription-node-attrs.js +8 -8
- package/lib/test-helpers/index.d.ts +7 -4
- package/lib/test-helpers/index.js +11 -15
- package/package.json +11 -4
package/lib/src/nodes/emoji.d.ts
CHANGED
|
@@ -1,31 +1,33 @@
|
|
|
1
|
+
//#region src/nodes/emoji.d.ts
|
|
1
2
|
type Emoji = {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
name: string;
|
|
4
|
+
shortNames: string[];
|
|
5
|
+
colons: string;
|
|
6
|
+
native?: string;
|
|
6
7
|
};
|
|
7
|
-
|
|
8
|
-
|
|
8
|
+
type EmojiOptions = {
|
|
9
|
+
getEmoji: (code: string) => Emoji | void;
|
|
9
10
|
};
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
declare const makeEmoji: ({ getEmoji }?: EmojiOptions) => {
|
|
12
|
+
attrs: {
|
|
13
|
+
code: {};
|
|
14
|
+
};
|
|
15
|
+
inline: true;
|
|
16
|
+
atom: true;
|
|
17
|
+
group: string;
|
|
18
|
+
selectable: false;
|
|
19
|
+
draggable: false;
|
|
20
|
+
leafText: (node: import("prosemirror-model").Node) => any;
|
|
21
|
+
parseDOM: {
|
|
22
|
+
tag: string;
|
|
23
|
+
getAttrs(domNode: HTMLElement): {
|
|
24
|
+
code: string;
|
|
13
25
|
};
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
leafText: (node: import("prosemirror-model").Node) => any;
|
|
20
|
-
parseDOM: {
|
|
21
|
-
tag: string;
|
|
22
|
-
getAttrs(domNode: HTMLElement): {
|
|
23
|
-
code: string;
|
|
24
|
-
};
|
|
25
|
-
}[];
|
|
26
|
-
toDOM(node: import("prosemirror-model").Node): [string, {
|
|
27
|
-
"data-emoji-node": string;
|
|
28
|
-
"data-emoji-code": any;
|
|
29
|
-
}, any];
|
|
26
|
+
}[];
|
|
27
|
+
toDOM(node: import("prosemirror-model").Node): [string, {
|
|
28
|
+
"data-emoji-node": string;
|
|
29
|
+
"data-emoji-code": any;
|
|
30
|
+
}, any];
|
|
30
31
|
};
|
|
31
|
-
|
|
32
|
+
//#endregion
|
|
33
|
+
export { EmojiOptions, makeEmoji };
|
package/lib/src/nodes/emoji.js
CHANGED
|
@@ -1,51 +1,42 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.makeEmoji = void 0;
|
|
1
|
+
//#region src/nodes/emoji.ts
|
|
4
2
|
const typeAttr = "data-emoji-node";
|
|
5
3
|
const codeAttr = "data-emoji-code";
|
|
6
|
-
const defaultOptions = {
|
|
7
|
-
getEmoji() {
|
|
8
|
-
return;
|
|
9
|
-
},
|
|
10
|
-
};
|
|
4
|
+
const defaultOptions = { getEmoji() {} };
|
|
11
5
|
const makeEmoji = ({ getEmoji } = defaultOptions) => ({
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
};
|
|
47
|
-
const emoji = getEmoji(code);
|
|
48
|
-
return ["span", attrs, emoji ? emoji.native || `:${emoji.shortNames[0]}:` : code];
|
|
49
|
-
},
|
|
6
|
+
attrs: { code: {} },
|
|
7
|
+
inline: true,
|
|
8
|
+
atom: true,
|
|
9
|
+
group: "inline",
|
|
10
|
+
selectable: false,
|
|
11
|
+
draggable: false,
|
|
12
|
+
leafText: (node) => {
|
|
13
|
+
const { code } = node.attrs;
|
|
14
|
+
const emoji = getEmoji(code);
|
|
15
|
+
return emoji ? emoji.native || `:${emoji.shortNames[0]}:` : code;
|
|
16
|
+
},
|
|
17
|
+
parseDOM: [{
|
|
18
|
+
tag: `span[${typeAttr}]`,
|
|
19
|
+
getAttrs(domNode) {
|
|
20
|
+
const dom = domNode;
|
|
21
|
+
const code = dom.getAttribute(codeAttr);
|
|
22
|
+
const alias = dom.textContent;
|
|
23
|
+
const emoji = code && getEmoji(code) || alias && getEmoji(alias) || null;
|
|
24
|
+
return { code: emoji ? emoji.colons : alias };
|
|
25
|
+
}
|
|
26
|
+
}],
|
|
27
|
+
toDOM(node) {
|
|
28
|
+
const { code } = node.attrs;
|
|
29
|
+
const attrs = {
|
|
30
|
+
[typeAttr]: "",
|
|
31
|
+
[codeAttr]: code
|
|
32
|
+
};
|
|
33
|
+
const emoji = getEmoji(code);
|
|
34
|
+
return [
|
|
35
|
+
"span",
|
|
36
|
+
attrs,
|
|
37
|
+
emoji ? emoji.native || `:${emoji.shortNames[0]}:` : code
|
|
38
|
+
];
|
|
39
|
+
}
|
|
50
40
|
});
|
|
51
|
-
|
|
41
|
+
//#endregion
|
|
42
|
+
export { makeEmoji };
|
|
@@ -1,20 +1,22 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { NodeSpec } from "prosemirror-model";
|
|
2
|
+
//#region src/nodes/entity.d.ts
|
|
2
3
|
type Meta = {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
4
|
+
comment?: string;
|
|
5
|
+
anchor?: string;
|
|
6
|
+
field?: string;
|
|
7
|
+
contextEntityTypeId?: string;
|
|
8
|
+
contextEntityPublicId?: string;
|
|
8
9
|
};
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
10
|
+
interface EntityAttributes {
|
|
11
|
+
id: string;
|
|
12
|
+
typeId: string;
|
|
13
|
+
text?: string;
|
|
14
|
+
meta: Meta;
|
|
14
15
|
}
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
interface EntityDefinition {
|
|
17
|
+
type: "entity";
|
|
18
|
+
attrs: EntityAttributes;
|
|
18
19
|
}
|
|
19
|
-
|
|
20
|
-
|
|
20
|
+
declare const entity: NodeSpec;
|
|
21
|
+
//#endregion
|
|
22
|
+
export { EntityAttributes, EntityDefinition, entity };
|
package/lib/src/nodes/entity.js
CHANGED
|
@@ -1,50 +1,49 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
};
|
|
48
|
-
return ["span", attrs, text];
|
|
49
|
-
},
|
|
1
|
+
//#region src/nodes/entity.ts
|
|
2
|
+
const entity = {
|
|
3
|
+
inline: true,
|
|
4
|
+
group: "inline",
|
|
5
|
+
selectable: false,
|
|
6
|
+
attrs: {
|
|
7
|
+
id: { default: "" },
|
|
8
|
+
text: { default: "" },
|
|
9
|
+
typeId: { default: "" },
|
|
10
|
+
meta: { default: {} }
|
|
11
|
+
},
|
|
12
|
+
parseDOM: [{
|
|
13
|
+
tag: "span[data-entity-id]",
|
|
14
|
+
getAttrs: (domNode) => {
|
|
15
|
+
const dom = domNode;
|
|
16
|
+
const meta = {};
|
|
17
|
+
meta.comment = dom.getAttribute("data-comment") || "";
|
|
18
|
+
meta.anchor = dom.getAttribute("data-anchor") || "";
|
|
19
|
+
meta.field = dom.getAttribute("data-field") || "";
|
|
20
|
+
meta.contextEntityTypeId = dom.getAttribute("data-context-entity-type-id") || "";
|
|
21
|
+
meta.contextEntityPublicId = dom.getAttribute("data-context-entity-public-id") || "";
|
|
22
|
+
return {
|
|
23
|
+
id: dom.getAttribute("data-entity-id"),
|
|
24
|
+
text: dom.textContent,
|
|
25
|
+
typeId: dom.getAttribute("data-entity-type-id"),
|
|
26
|
+
meta
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
}],
|
|
30
|
+
toDOM(node) {
|
|
31
|
+
const { id, typeId, text, meta } = node.attrs;
|
|
32
|
+
return [
|
|
33
|
+
"span",
|
|
34
|
+
{
|
|
35
|
+
"data-entity-id": id,
|
|
36
|
+
"data-entity-type-id": typeId,
|
|
37
|
+
"data-comment": meta.comment,
|
|
38
|
+
"data-anchor": meta.anchor,
|
|
39
|
+
"data-field": meta.field,
|
|
40
|
+
"data-context-entity-type-id": meta.contextEntityTypeId,
|
|
41
|
+
"data-context-entity-public-id": meta.contextEntityPublicId,
|
|
42
|
+
contenteditable: "false"
|
|
43
|
+
},
|
|
44
|
+
text
|
|
45
|
+
];
|
|
46
|
+
}
|
|
50
47
|
};
|
|
48
|
+
//#endregion
|
|
49
|
+
export { entity };
|
|
@@ -1,43 +1,39 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
"data-view-id": viewId,
|
|
38
|
-
contenteditable: "false",
|
|
39
|
-
...(0, resizable_node_attrs_1.createToDomAttrs)(node.attrs),
|
|
40
|
-
};
|
|
41
|
-
return ["div", attrs, ""];
|
|
42
|
-
},
|
|
1
|
+
import { createDefaultAttrs, createParseDomAttrs, createToDomAttrs } from "../resizable-node-attrs.js";
|
|
2
|
+
//#region src/nodes/fibery-view.ts
|
|
3
|
+
const fiberyView = {
|
|
4
|
+
inline: false,
|
|
5
|
+
group: "block",
|
|
6
|
+
selectable: true,
|
|
7
|
+
atom: true,
|
|
8
|
+
draggable: false,
|
|
9
|
+
attrs: {
|
|
10
|
+
viewId: { default: null },
|
|
11
|
+
id: { default: "" },
|
|
12
|
+
...createDefaultAttrs()
|
|
13
|
+
},
|
|
14
|
+
parseDOM: [{
|
|
15
|
+
tag: "div[data-view-id]",
|
|
16
|
+
getAttrs: (domNode) => {
|
|
17
|
+
const dom = domNode;
|
|
18
|
+
const viewId = dom.getAttribute("data-view-id");
|
|
19
|
+
return {
|
|
20
|
+
viewId,
|
|
21
|
+
id: viewId,
|
|
22
|
+
...createParseDomAttrs(dom)
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
}],
|
|
26
|
+
toDOM(node) {
|
|
27
|
+
return [
|
|
28
|
+
"div",
|
|
29
|
+
{
|
|
30
|
+
"data-view-id": node.attrs.viewId || node.attrs.id,
|
|
31
|
+
contenteditable: "false",
|
|
32
|
+
...createToDomAttrs(node.attrs)
|
|
33
|
+
},
|
|
34
|
+
""
|
|
35
|
+
];
|
|
36
|
+
}
|
|
43
37
|
};
|
|
38
|
+
//#endregion
|
|
39
|
+
export { fiberyView };
|
package/lib/src/nodes/file.d.ts
CHANGED
|
@@ -1,36 +1,39 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
src: {};
|
|
11
|
-
title: {
|
|
12
|
-
default: string;
|
|
13
|
-
};
|
|
14
|
-
size: {};
|
|
15
|
-
type: {};
|
|
1
|
+
//#region src/nodes/file.d.ts
|
|
2
|
+
declare const file: {
|
|
3
|
+
attrs: {
|
|
4
|
+
transcription: {
|
|
5
|
+
default: {
|
|
6
|
+
status: string;
|
|
7
|
+
userId: string;
|
|
8
|
+
inserted: boolean;
|
|
9
|
+
};
|
|
16
10
|
};
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
11
|
+
src: {};
|
|
12
|
+
title: {
|
|
13
|
+
default: string;
|
|
14
|
+
};
|
|
15
|
+
size: {};
|
|
16
|
+
type: {};
|
|
17
|
+
};
|
|
18
|
+
inline: true;
|
|
19
|
+
group: string;
|
|
20
|
+
selectable: false;
|
|
21
|
+
draggable: false;
|
|
22
|
+
leafText: (node: import("prosemirror-model").Node) => any;
|
|
23
|
+
parseDOM: {
|
|
24
|
+
tag: string;
|
|
25
|
+
getAttrs(domNode: HTMLElement): {
|
|
26
|
+
src: string | null;
|
|
27
|
+
title: string;
|
|
28
|
+
size: string | null;
|
|
29
|
+
type: string | null;
|
|
30
|
+
};
|
|
31
|
+
}[];
|
|
32
|
+
toDOM(node: import("prosemirror-model").Node): [string, {
|
|
33
|
+
"data-file-href": any;
|
|
34
|
+
"data-size": any;
|
|
35
|
+
"data-type": any;
|
|
36
|
+
}, any];
|
|
36
37
|
};
|
|
38
|
+
//#endregion
|
|
39
|
+
export { file };
|
package/lib/src/nodes/file.js
CHANGED
|
@@ -1,41 +1,42 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
},
|
|
1
|
+
import { createDefaultAttrs } from "../transcription-node-attrs.js";
|
|
2
|
+
//#region src/nodes/file.ts
|
|
3
|
+
const file = {
|
|
4
|
+
attrs: {
|
|
5
|
+
src: {},
|
|
6
|
+
title: { default: "Untitled" },
|
|
7
|
+
size: {},
|
|
8
|
+
type: {},
|
|
9
|
+
...createDefaultAttrs()
|
|
10
|
+
},
|
|
11
|
+
inline: true,
|
|
12
|
+
group: "inline",
|
|
13
|
+
selectable: false,
|
|
14
|
+
draggable: false,
|
|
15
|
+
leafText: (node) => node.attrs.title,
|
|
16
|
+
parseDOM: [{
|
|
17
|
+
tag: "span[data-file-href]",
|
|
18
|
+
getAttrs(domNode) {
|
|
19
|
+
const dom = domNode;
|
|
20
|
+
return {
|
|
21
|
+
src: dom.getAttribute("data-file-href"),
|
|
22
|
+
title: dom.textContent,
|
|
23
|
+
size: dom.getAttribute("data-size"),
|
|
24
|
+
type: dom.getAttribute("data-type")
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
}],
|
|
28
|
+
toDOM(node) {
|
|
29
|
+
const { src, title, type, size } = node.attrs;
|
|
30
|
+
return [
|
|
31
|
+
"span",
|
|
32
|
+
{
|
|
33
|
+
"data-file-href": src,
|
|
34
|
+
"data-size": size,
|
|
35
|
+
"data-type": type
|
|
36
|
+
},
|
|
37
|
+
title
|
|
38
|
+
];
|
|
39
|
+
}
|
|
41
40
|
};
|
|
41
|
+
//#endregion
|
|
42
|
+
export { file };
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { Node, NodeSpec } from "prosemirror-model";
|
|
2
|
+
//#region src/nodes/heading.d.ts
|
|
3
|
+
declare const makeHeading: ({ headingToDOM }: {
|
|
4
|
+
headingToDOM: ((node: Node) => HTMLElement) | null;
|
|
4
5
|
}) => NodeSpec;
|
|
6
|
+
//#endregion
|
|
7
|
+
export { makeHeading };
|
package/lib/src/nodes/heading.js
CHANGED
|
@@ -1,39 +1,63 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.makeHeading = void 0;
|
|
4
|
-
const uuid_1 = require("uuid");
|
|
1
|
+
import { v4 } from "uuid";
|
|
2
|
+
//#region src/nodes/heading.ts
|
|
5
3
|
const parseGuid = (dom) => {
|
|
6
|
-
|
|
4
|
+
return dom.getAttribute("guid") || v4();
|
|
7
5
|
};
|
|
8
6
|
const makeGetAttrs = (level) => (dom) => {
|
|
9
|
-
|
|
10
|
-
|
|
7
|
+
const id = parseGuid(dom);
|
|
8
|
+
return {
|
|
9
|
+
level,
|
|
10
|
+
id,
|
|
11
|
+
guid: id
|
|
12
|
+
};
|
|
11
13
|
};
|
|
12
14
|
const makeHeading = ({ headingToDOM }) => ({
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
15
|
+
content: "inline*",
|
|
16
|
+
group: "block",
|
|
17
|
+
attrs: {
|
|
18
|
+
level: { default: 1 },
|
|
19
|
+
id: { default: null },
|
|
20
|
+
guid: { default: "" }
|
|
21
|
+
},
|
|
22
|
+
defining: true,
|
|
23
|
+
parseDOM: [
|
|
24
|
+
{
|
|
25
|
+
tag: "h1",
|
|
26
|
+
getAttrs: makeGetAttrs(1)
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
tag: "h2",
|
|
30
|
+
getAttrs: makeGetAttrs(2)
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
tag: "h3",
|
|
34
|
+
getAttrs: makeGetAttrs(3)
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
tag: "h4",
|
|
38
|
+
getAttrs: makeGetAttrs(4)
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
tag: "h5",
|
|
42
|
+
getAttrs: makeGetAttrs(5)
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
tag: "h6",
|
|
46
|
+
getAttrs: makeGetAttrs(6)
|
|
47
|
+
}
|
|
48
|
+
],
|
|
49
|
+
toDOM(node) {
|
|
50
|
+
if (headingToDOM) return headingToDOM(node);
|
|
51
|
+
const id = node.attrs.id || node.attrs.guid;
|
|
52
|
+
return [
|
|
53
|
+
"h" + node.attrs.level,
|
|
54
|
+
{
|
|
55
|
+
"data-id": id,
|
|
56
|
+
guid: id
|
|
57
|
+
},
|
|
58
|
+
0
|
|
59
|
+
];
|
|
60
|
+
}
|
|
38
61
|
});
|
|
39
|
-
|
|
62
|
+
//#endregion
|
|
63
|
+
export { makeHeading };
|