@fibery/prosemirror-schema 4.22.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 -10
- package/lib/index.js +9 -31
- 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 +15 -12
- 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 -26
- package/lib/src/nodes/callout.js +55 -58
- 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/callout.js
CHANGED
|
@@ -1,62 +1,59 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.makeCallout = exports.DEFAULT_CALLOUT_ICON = exports.DEFAULT_CALLOUT_ICON_TYPE = void 0;
|
|
1
|
+
//#region src/nodes/callout.ts
|
|
4
2
|
const nodeType = "data-callout-node";
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
const DEFAULT_CALLOUT_ICON_TYPE = "icon";
|
|
4
|
+
const DEFAULT_CALLOUT_ICON = "exclamation-circle";
|
|
7
5
|
const aliasAttr = "data-icon-emoji-alias";
|
|
8
|
-
const defaultOptions = {
|
|
9
|
-
getEmoji() {
|
|
10
|
-
return;
|
|
11
|
-
},
|
|
12
|
-
};
|
|
6
|
+
const defaultOptions = { getEmoji() {} };
|
|
13
7
|
const makeCallout = ({ getEmoji } = defaultOptions) => ({
|
|
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
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
8
|
+
attrs: {
|
|
9
|
+
color: { default: "#199EE3" },
|
|
10
|
+
iconType: { default: DEFAULT_CALLOUT_ICON_TYPE },
|
|
11
|
+
icon: { default: DEFAULT_CALLOUT_ICON }
|
|
12
|
+
},
|
|
13
|
+
group: "block",
|
|
14
|
+
content: "block+",
|
|
15
|
+
defining: true,
|
|
16
|
+
parseDOM: [{
|
|
17
|
+
tag: `div[${nodeType}]`,
|
|
18
|
+
getAttrs(domNode) {
|
|
19
|
+
const dom = domNode;
|
|
20
|
+
const color = dom.getAttribute("data-color");
|
|
21
|
+
const iconType = dom.getAttribute("data-icon-type");
|
|
22
|
+
const icon = dom.getAttribute("data-icon");
|
|
23
|
+
if (iconType === "emoji") {
|
|
24
|
+
const alias = dom.getAttribute(aliasAttr);
|
|
25
|
+
const emoji = icon && getEmoji(icon) || alias && getEmoji(alias) || null;
|
|
26
|
+
return {
|
|
27
|
+
color,
|
|
28
|
+
iconType,
|
|
29
|
+
icon: emoji ? emoji.colons : icon
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
return {
|
|
33
|
+
color,
|
|
34
|
+
iconType,
|
|
35
|
+
icon
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
}],
|
|
39
|
+
toDOM(node) {
|
|
40
|
+
const { color, iconType, icon } = node.attrs;
|
|
41
|
+
const attrs = {
|
|
42
|
+
[nodeType]: "",
|
|
43
|
+
"data-color": color,
|
|
44
|
+
"data-icon-type": iconType,
|
|
45
|
+
"data-icon": icon
|
|
46
|
+
};
|
|
47
|
+
if (iconType === "emoji") {
|
|
48
|
+
const emoji = getEmoji(icon);
|
|
49
|
+
if (emoji) attrs[aliasAttr] = emoji.native || `:${emoji.shortNames[0]}:`;
|
|
50
|
+
}
|
|
51
|
+
return [
|
|
52
|
+
"div",
|
|
53
|
+
attrs,
|
|
54
|
+
0
|
|
55
|
+
];
|
|
56
|
+
}
|
|
61
57
|
});
|
|
62
|
-
|
|
58
|
+
//#endregion
|
|
59
|
+
export { DEFAULT_CALLOUT_ICON, DEFAULT_CALLOUT_ICON_TYPE, makeCallout };
|
|
@@ -1,11 +1,14 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
import { Inline } from "./types/inline-content.js";
|
|
2
|
+
import { NodeSpec } from "prosemirror-model";
|
|
3
|
+
//#region src/nodes/check-item.d.ts
|
|
4
|
+
interface CheckItemDefinition {
|
|
5
|
+
type: "check_item";
|
|
6
|
+
content?: Array<Inline>;
|
|
7
|
+
attrs: {
|
|
8
|
+
id: string;
|
|
9
|
+
state: "TODO" | "DONE";
|
|
10
|
+
};
|
|
10
11
|
}
|
|
11
|
-
|
|
12
|
+
declare const check_item: NodeSpec;
|
|
13
|
+
//#endregion
|
|
14
|
+
export { CheckItemDefinition, check_item };
|
|
@@ -1,34 +1,33 @@
|
|
|
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
|
-
return ["div", attrs, 0];
|
|
33
|
-
},
|
|
1
|
+
import { v4 } from "uuid";
|
|
2
|
+
//#region src/nodes/check-item.ts
|
|
3
|
+
const check_item = {
|
|
4
|
+
content: "inline*",
|
|
5
|
+
defining: true,
|
|
6
|
+
selectable: true,
|
|
7
|
+
marks: "_",
|
|
8
|
+
attrs: {
|
|
9
|
+
id: { default: "" },
|
|
10
|
+
state: { default: "TODO" }
|
|
11
|
+
},
|
|
12
|
+
parseDOM: [{
|
|
13
|
+
tag: `div[data-check-item-id]`,
|
|
14
|
+
priority: 100,
|
|
15
|
+
getAttrs: (dom) => ({
|
|
16
|
+
id: v4(),
|
|
17
|
+
state: dom.getAttribute("data-check-item-state")
|
|
18
|
+
})
|
|
19
|
+
}],
|
|
20
|
+
toDOM(node) {
|
|
21
|
+
const { id, state } = node.attrs;
|
|
22
|
+
return [
|
|
23
|
+
"div",
|
|
24
|
+
{
|
|
25
|
+
"data-check-item-id": id,
|
|
26
|
+
"data-check-item-state": state
|
|
27
|
+
},
|
|
28
|
+
0
|
|
29
|
+
];
|
|
30
|
+
}
|
|
34
31
|
};
|
|
32
|
+
//#endregion
|
|
33
|
+
export { check_item };
|
|
@@ -1,13 +1,16 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import { CheckItemDefinition } from "./check-item.js";
|
|
2
|
+
import { NodeSpec } from "prosemirror-model";
|
|
3
|
+
//#region src/nodes/check-list.d.ts
|
|
4
|
+
interface CheckListContent extends Array<CheckItemDefinition | CheckListDefinition> {
|
|
5
|
+
0: CheckItemDefinition;
|
|
5
6
|
}
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
7
|
+
interface CheckListDefinition {
|
|
8
|
+
type: "check_list";
|
|
9
|
+
content: CheckListContent;
|
|
10
|
+
attrs: {
|
|
11
|
+
id: string;
|
|
12
|
+
};
|
|
12
13
|
}
|
|
13
|
-
|
|
14
|
+
declare const check_list: NodeSpec;
|
|
15
|
+
//#endregion
|
|
16
|
+
export { CheckListContent, CheckListDefinition, check_list };
|
|
@@ -1,31 +1,24 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
},
|
|
23
|
-
],
|
|
24
|
-
toDOM(node) {
|
|
25
|
-
const { id } = node.attrs;
|
|
26
|
-
const attrs = {
|
|
27
|
-
"data-check-list-id": id,
|
|
28
|
-
};
|
|
29
|
-
return ["div", attrs, 0];
|
|
30
|
-
},
|
|
1
|
+
import { v4 } from "uuid";
|
|
2
|
+
//#region src/nodes/check-list.ts
|
|
3
|
+
const check_list = {
|
|
4
|
+
group: "block",
|
|
5
|
+
defining: true,
|
|
6
|
+
selectable: true,
|
|
7
|
+
content: `(check_item)+ (check_item|check_list)*`,
|
|
8
|
+
attrs: { id: { default: "" } },
|
|
9
|
+
parseDOM: [{
|
|
10
|
+
tag: `div[data-check-list-id]`,
|
|
11
|
+
priority: 100,
|
|
12
|
+
getAttrs: () => ({ id: v4() })
|
|
13
|
+
}],
|
|
14
|
+
toDOM(node) {
|
|
15
|
+
const { id } = node.attrs;
|
|
16
|
+
return [
|
|
17
|
+
"div",
|
|
18
|
+
{ "data-check-list-id": id },
|
|
19
|
+
0
|
|
20
|
+
];
|
|
21
|
+
}
|
|
31
22
|
};
|
|
23
|
+
//#endregion
|
|
24
|
+
export { check_list };
|
|
@@ -1,112 +1,81 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const uuid_1 = require("uuid");
|
|
5
|
-
const resizable_node_attrs_1 = require("../resizable-node-attrs");
|
|
1
|
+
import { createDefaultAttrs, createParseDomAttrs, createToDomAttrs } from "../resizable-node-attrs.js";
|
|
2
|
+
import { v4 } from "uuid";
|
|
3
|
+
//#region src/nodes/code-block.ts
|
|
6
4
|
const getLanguageFromEditorStyle = (dom) => {
|
|
7
|
-
|
|
5
|
+
return dom.getAttribute("data-language") || void 0;
|
|
8
6
|
};
|
|
9
|
-
// example of BB style:
|
|
10
|
-
// <div class="codehilite language-javascript"><pre><span>hello world</span><span>\n</span></pre></div>
|
|
11
7
|
const getLanguageFromBitbucketStyle = (dom) => {
|
|
12
|
-
|
|
13
|
-
// code block html from Bitbucket always contains an extra new line
|
|
14
|
-
return extractLanguageFromClass(dom.className);
|
|
15
|
-
}
|
|
16
|
-
return undefined;
|
|
8
|
+
if (dom && dom.classList.contains("codehilite")) return extractLanguageFromClass(dom.className);
|
|
17
9
|
};
|
|
18
|
-
// If there is a child code element, check that for data-language
|
|
19
10
|
const getLanguageFromCode = (dom) => {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
return firstChild.getAttribute("data-language") || undefined;
|
|
23
|
-
}
|
|
24
|
-
return undefined;
|
|
11
|
+
const firstChild = dom.firstElementChild;
|
|
12
|
+
if (firstChild && firstChild.nodeName === "CODE") return firstChild.getAttribute("data-language") || void 0;
|
|
25
13
|
};
|
|
26
14
|
const extractLanguageFromClass = (className) => {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
if (result && result[1]) {
|
|
30
|
-
return result[1];
|
|
31
|
-
}
|
|
32
|
-
return undefined;
|
|
15
|
+
const result = /(?:^|\s)language-([^\s]+)/.exec(className);
|
|
16
|
+
if (result && result[1]) return result[1];
|
|
33
17
|
};
|
|
34
18
|
const removeLastNewLine = (dom) => {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
}
|
|
39
|
-
return dom;
|
|
19
|
+
const parent = dom && dom.parentElement;
|
|
20
|
+
if (parent && parent.classList.contains("codehilite")) dom.textContent = dom.textContent.replace(/\n$/, "");
|
|
21
|
+
return dom;
|
|
40
22
|
};
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
"pre",
|
|
98
|
-
[
|
|
99
|
-
"code",
|
|
100
|
-
{
|
|
101
|
-
"data-language": node.attrs.language,
|
|
102
|
-
"data-id": id,
|
|
103
|
-
"data-guid": id,
|
|
104
|
-
"data-wrap-code": node.attrs.wrapCode || false,
|
|
105
|
-
"data-mode": node.attrs.mode || "split",
|
|
106
|
-
...(0, resizable_node_attrs_1.createToDomAttrs)(node.attrs),
|
|
107
|
-
},
|
|
108
|
-
0,
|
|
109
|
-
],
|
|
110
|
-
];
|
|
111
|
-
},
|
|
23
|
+
const code_block = {
|
|
24
|
+
content: "text*",
|
|
25
|
+
marks: "linkedhighlightentity linkedhighlight",
|
|
26
|
+
group: "block",
|
|
27
|
+
code: true,
|
|
28
|
+
isolating: true,
|
|
29
|
+
defining: true,
|
|
30
|
+
attrs: {
|
|
31
|
+
id: { default: null },
|
|
32
|
+
guid: { default: "" },
|
|
33
|
+
language: { default: null },
|
|
34
|
+
wrapCode: { default: false },
|
|
35
|
+
mode: { default: "split" },
|
|
36
|
+
...createDefaultAttrs()
|
|
37
|
+
},
|
|
38
|
+
parseDOM: [{
|
|
39
|
+
tag: "pre",
|
|
40
|
+
preserveWhitespace: "full",
|
|
41
|
+
getAttrs: (domNode) => {
|
|
42
|
+
const dom = domNode;
|
|
43
|
+
const id = dom.getAttribute("data-guid") || v4();
|
|
44
|
+
const language = getLanguageFromBitbucketStyle(dom.parentElement) || getLanguageFromEditorStyle(dom.parentElement) || getLanguageFromCode(dom) || dom.getAttribute("data-language");
|
|
45
|
+
const wrapCode = dom.getAttribute("data-wrap-code") === "true";
|
|
46
|
+
removeLastNewLine(dom);
|
|
47
|
+
return {
|
|
48
|
+
id,
|
|
49
|
+
guid: id,
|
|
50
|
+
language,
|
|
51
|
+
wrapCode,
|
|
52
|
+
mode: dom.getAttribute("data-mode") || "split",
|
|
53
|
+
...createParseDomAttrs(dom)
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
}, {
|
|
57
|
+
tag: "table[style]",
|
|
58
|
+
preserveWhitespace: "full",
|
|
59
|
+
getAttrs: (dom) => {
|
|
60
|
+
if (dom.querySelector("td[class*=\"blob-code\"]")) return {};
|
|
61
|
+
return false;
|
|
62
|
+
}
|
|
63
|
+
}],
|
|
64
|
+
toDOM(node) {
|
|
65
|
+
const id = node.attrs.id || node.attrs.guid || "";
|
|
66
|
+
return ["pre", [
|
|
67
|
+
"code",
|
|
68
|
+
{
|
|
69
|
+
"data-language": node.attrs.language,
|
|
70
|
+
"data-id": id,
|
|
71
|
+
"data-guid": id,
|
|
72
|
+
"data-wrap-code": node.attrs.wrapCode || false,
|
|
73
|
+
"data-mode": node.attrs.mode || "split",
|
|
74
|
+
...createToDomAttrs(node.attrs)
|
|
75
|
+
},
|
|
76
|
+
0
|
|
77
|
+
]];
|
|
78
|
+
}
|
|
112
79
|
};
|
|
80
|
+
//#endregion
|
|
81
|
+
export { code_block };
|
package/lib/src/nodes/column.js
CHANGED
|
@@ -1,35 +1,29 @@
|
|
|
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
|
-
const { columnRatio } = node.attrs;
|
|
28
|
-
const attrs = {
|
|
29
|
-
class: "fibery-column-node",
|
|
30
|
-
"data-column-ratio": columnRatio,
|
|
31
|
-
style: "min-width: 0;",
|
|
32
|
-
};
|
|
33
|
-
return ["div", attrs, 0];
|
|
34
|
-
},
|
|
1
|
+
//#region src/nodes/column.ts
|
|
2
|
+
const column = {
|
|
3
|
+
content: "block+",
|
|
4
|
+
selectable: true,
|
|
5
|
+
draggable: false,
|
|
6
|
+
definingAsContext: true,
|
|
7
|
+
isolating: true,
|
|
8
|
+
attrs: { columnRatio: { default: 1 } },
|
|
9
|
+
parseDOM: [{
|
|
10
|
+
tag: "div.fibery-column-node",
|
|
11
|
+
getAttrs: (domNode) => {
|
|
12
|
+
return { columnRatio: domNode.getAttribute("data-column-ratio") };
|
|
13
|
+
}
|
|
14
|
+
}],
|
|
15
|
+
toDOM(node) {
|
|
16
|
+
const { columnRatio } = node.attrs;
|
|
17
|
+
return [
|
|
18
|
+
"div",
|
|
19
|
+
{
|
|
20
|
+
class: "fibery-column-node",
|
|
21
|
+
"data-column-ratio": columnRatio,
|
|
22
|
+
style: "min-width: 0;"
|
|
23
|
+
},
|
|
24
|
+
0
|
|
25
|
+
];
|
|
26
|
+
}
|
|
35
27
|
};
|
|
28
|
+
//#endregion
|
|
29
|
+
export { column };
|
package/lib/src/nodes/columns.js
CHANGED
|
@@ -1,37 +1,35 @@
|
|
|
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
|
-
...(0, resizable_node_attrs_1.createToDomAttrs)(node.attrs),
|
|
34
|
-
};
|
|
35
|
-
return ["div", attrs, 0];
|
|
36
|
-
},
|
|
1
|
+
import { createDefaultAttrs, createParseDomAttrs, createToDomAttrs } from "../resizable-node-attrs.js";
|
|
2
|
+
//#region src/nodes/columns.ts
|
|
3
|
+
const columns = {
|
|
4
|
+
content: "column+",
|
|
5
|
+
selectable: true,
|
|
6
|
+
draggable: false,
|
|
7
|
+
attrs: {
|
|
8
|
+
id: { default: "" },
|
|
9
|
+
...createDefaultAttrs()
|
|
10
|
+
},
|
|
11
|
+
parseDOM: [{
|
|
12
|
+
tag: "div.fibery-columns-node",
|
|
13
|
+
getAttrs: (domNode) => {
|
|
14
|
+
return createParseDomAttrs(domNode);
|
|
15
|
+
}
|
|
16
|
+
}],
|
|
17
|
+
toDOM(node) {
|
|
18
|
+
let gridTemplateColumns = ``;
|
|
19
|
+
node.forEach((node, offset, index) => {
|
|
20
|
+
if (index !== 0) gridTemplateColumns += ` `;
|
|
21
|
+
gridTemplateColumns += `${node.attrs.columnRatio}fr`;
|
|
22
|
+
});
|
|
23
|
+
return [
|
|
24
|
+
"div",
|
|
25
|
+
{
|
|
26
|
+
class: "fibery-columns-node",
|
|
27
|
+
style: `display: grid; gap: 46px; grid-template-columns: ${gridTemplateColumns}`,
|
|
28
|
+
...createToDomAttrs(node.attrs)
|
|
29
|
+
},
|
|
30
|
+
0
|
|
31
|
+
];
|
|
32
|
+
}
|
|
37
33
|
};
|
|
34
|
+
//#endregion
|
|
35
|
+
export { columns };
|