@fibery/prosemirror-schema 4.1.0 → 4.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/src/create-schema.js
CHANGED
|
@@ -23,6 +23,8 @@ const video_1 = require("./nodes/video");
|
|
|
23
23
|
const file_1 = require("./nodes/file");
|
|
24
24
|
const callout_1 = require("./nodes/callout");
|
|
25
25
|
const emoji_1 = require("./nodes/emoji");
|
|
26
|
+
const columns_1 = require("./nodes/columns");
|
|
27
|
+
const column_1 = require("./nodes/column");
|
|
26
28
|
const strike_1 = require("./marks/strike");
|
|
27
29
|
const underline_1 = require("./marks/underline");
|
|
28
30
|
const hint_query_1 = require("./marks/hint-query");
|
|
@@ -47,6 +49,8 @@ const createSchema = ({ sharedColorGenerator = null, headingToDOM = null, mediaT
|
|
|
47
49
|
file: file_1.file,
|
|
48
50
|
emoji: (0, emoji_1.makeEmoji)(emojiOptions),
|
|
49
51
|
callout: callout_1.callout,
|
|
52
|
+
columns: columns_1.columns,
|
|
53
|
+
column: column_1.column,
|
|
50
54
|
};
|
|
51
55
|
let actualNodes = (0, prosemirror_schema_list_1.addListNodes)(base.spec.nodes, "paragraph block*", "block")
|
|
52
56
|
.append({ ...table_nodes_1.tableNodes })
|
|
@@ -60,6 +64,9 @@ const createSchema = ({ sharedColorGenerator = null, headingToDOM = null, mediaT
|
|
|
60
64
|
else {
|
|
61
65
|
actualNodes = actualNodes.addToEnd("imageBlock", image_block_1.imageBlock);
|
|
62
66
|
}
|
|
67
|
+
actualNodes = actualNodes.update("doc", {
|
|
68
|
+
content: `(block | columns)+`,
|
|
69
|
+
});
|
|
63
70
|
return new prosemirror_model_1.Schema({
|
|
64
71
|
nodes: actualNodes,
|
|
65
72
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.column = void 0;
|
|
4
|
+
exports.column = {
|
|
5
|
+
content: "block+",
|
|
6
|
+
selectable: true,
|
|
7
|
+
draggable: false,
|
|
8
|
+
defining: true,
|
|
9
|
+
attrs: {
|
|
10
|
+
columnRatio: {
|
|
11
|
+
default: 0.5,
|
|
12
|
+
},
|
|
13
|
+
},
|
|
14
|
+
parseDOM: [
|
|
15
|
+
{
|
|
16
|
+
tag: "div.fibery-column-node",
|
|
17
|
+
getAttrs: (domNode) => {
|
|
18
|
+
const dom = domNode;
|
|
19
|
+
return {
|
|
20
|
+
columnRatio: dom.getAttribute("data-column-ratio"),
|
|
21
|
+
};
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
],
|
|
25
|
+
toDOM(node) {
|
|
26
|
+
const { columnRatio } = node.attrs;
|
|
27
|
+
const attrs = {
|
|
28
|
+
class: "fibery-column-node",
|
|
29
|
+
"data-column-ratio": columnRatio,
|
|
30
|
+
style: "min-width: 0;",
|
|
31
|
+
};
|
|
32
|
+
return ["div", attrs, 0];
|
|
33
|
+
},
|
|
34
|
+
};
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.columns = void 0;
|
|
4
|
+
exports.columns = {
|
|
5
|
+
content: "column{2,}",
|
|
6
|
+
selectable: true,
|
|
7
|
+
draggable: false,
|
|
8
|
+
attrs: {
|
|
9
|
+
id: { default: "" },
|
|
10
|
+
nodeHeight: {
|
|
11
|
+
default: 400,
|
|
12
|
+
},
|
|
13
|
+
nodeWidth: {
|
|
14
|
+
default: 900,
|
|
15
|
+
},
|
|
16
|
+
nodePageWidth: {
|
|
17
|
+
default: true,
|
|
18
|
+
},
|
|
19
|
+
nodeFullWidth: {
|
|
20
|
+
default: false,
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
parseDOM: [
|
|
24
|
+
{
|
|
25
|
+
tag: "div.fibery-columns-node",
|
|
26
|
+
getAttrs: (domNode) => {
|
|
27
|
+
const dom = domNode;
|
|
28
|
+
return {
|
|
29
|
+
nodeHeight: dom.getAttribute("data-node-height"),
|
|
30
|
+
nodeWidth: dom.getAttribute("data-node-width"),
|
|
31
|
+
nodePageWidth: dom.getAttribute("data-node-page-width"),
|
|
32
|
+
nodeFullWidth: dom.getAttribute("data-node-full-width"),
|
|
33
|
+
};
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
],
|
|
37
|
+
toDOM(node) {
|
|
38
|
+
const { nodeHeight, nodeWidth, nodePageWidth, nodeFullWidth } = node.attrs;
|
|
39
|
+
let gridTemplateColumns = ``;
|
|
40
|
+
node.forEach((node, offset, index) => {
|
|
41
|
+
if (index !== 0) {
|
|
42
|
+
gridTemplateColumns += ` `;
|
|
43
|
+
}
|
|
44
|
+
gridTemplateColumns += `${node.attrs.columnRatio}fr`;
|
|
45
|
+
});
|
|
46
|
+
const attrs = {
|
|
47
|
+
class: "fibery-columns-node",
|
|
48
|
+
"data-node-height": nodeHeight,
|
|
49
|
+
"data-node-width": nodeWidth,
|
|
50
|
+
"data-node-page-width": nodePageWidth,
|
|
51
|
+
"data-node-full-width": nodeFullWidth,
|
|
52
|
+
style: `display: grid; gap: 46px; grid-template-columns: ${gridTemplateColumns}`,
|
|
53
|
+
};
|
|
54
|
+
return ["div", attrs, 0];
|
|
55
|
+
},
|
|
56
|
+
};
|
|
@@ -31,8 +31,8 @@ exports.fiberyView = {
|
|
|
31
31
|
id: dom.getAttribute("data-view-id"),
|
|
32
32
|
nodeHeight: dom.getAttribute("data-node-height"),
|
|
33
33
|
nodeWidth: dom.getAttribute("data-node-width"),
|
|
34
|
-
nodePageWidth: dom.getAttribute("node-page-width"),
|
|
35
|
-
nodeFullWidth: dom.getAttribute("node-full-width"),
|
|
34
|
+
nodePageWidth: dom.getAttribute("data-node-page-width"),
|
|
35
|
+
nodeFullWidth: dom.getAttribute("data-node-full-width"),
|
|
36
36
|
};
|
|
37
37
|
},
|
|
38
38
|
},
|
|
@@ -43,8 +43,8 @@ exports.fiberyView = {
|
|
|
43
43
|
"data-view-id": id,
|
|
44
44
|
"data-node-height": nodeHeight,
|
|
45
45
|
"data-node-width": nodeWidth,
|
|
46
|
-
"node-page-width": nodePageWidth,
|
|
47
|
-
"node-full-width": nodeFullWidth,
|
|
46
|
+
"data-node-page-width": nodePageWidth,
|
|
47
|
+
"data-node-full-width": nodeFullWidth,
|
|
48
48
|
contenteditable: "false",
|
|
49
49
|
};
|
|
50
50
|
return ["div", attrs, ""];
|