@fibery/prosemirror-schema 3.1.2 → 3.3.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/src/create-schema.d.ts +3 -1
- package/lib/src/create-schema.js +19 -1
- package/lib/src/marks/link.js +2 -2
- package/lib/src/nodes/callout.d.ts +30 -0
- package/lib/src/nodes/callout.js +37 -0
- package/lib/src/nodes/code-block.js +1 -0
- package/lib/src/nodes/fibery-section.d.ts +3 -0
- package/lib/src/nodes/fibery-section.js +31 -0
- package/lib/src/nodes/file.d.ts +3 -3
- package/lib/src/nodes/file.js +6 -6
- package/package.json +13 -8
|
@@ -2,9 +2,11 @@ import { Schema, Node } from "prosemirror-model";
|
|
|
2
2
|
interface SchemaProps {
|
|
3
3
|
isImageBlockEnabled?: boolean;
|
|
4
4
|
fiberyViewEnabled?: boolean;
|
|
5
|
+
fiberySectionEnabled?: boolean;
|
|
6
|
+
fiberySectionStrictMode?: boolean;
|
|
5
7
|
sharedColorGenerator?: any;
|
|
6
8
|
headingToDOM?: ((node: Node) => HTMLElement) | null;
|
|
7
9
|
mediaToDom?: ((node: Node) => HTMLElement) | null;
|
|
8
10
|
}
|
|
9
|
-
export declare const createSchema: ({ sharedColorGenerator, headingToDOM, mediaToDom, isImageBlockEnabled, fiberyViewEnabled, }?: SchemaProps) => Schema;
|
|
11
|
+
export declare const createSchema: ({ sharedColorGenerator, headingToDOM, mediaToDom, isImageBlockEnabled, fiberyViewEnabled, fiberySectionEnabled, fiberySectionStrictMode, }?: SchemaProps) => Schema;
|
|
10
12
|
export {};
|
package/lib/src/create-schema.js
CHANGED
|
@@ -21,13 +21,15 @@ const check_item_1 = require("./nodes/check-item");
|
|
|
21
21
|
const code_block_1 = require("./nodes/code-block");
|
|
22
22
|
const video_1 = require("./nodes/video");
|
|
23
23
|
const file_1 = require("./nodes/file");
|
|
24
|
+
const callout_1 = require("./nodes/callout");
|
|
24
25
|
const strike_1 = require("./marks/strike");
|
|
25
26
|
const underline_1 = require("./marks/underline");
|
|
26
27
|
const hint_query_1 = require("./marks/hint-query");
|
|
27
28
|
const highlight_1 = require("./marks/highlight");
|
|
28
29
|
const linked_highlight_1 = require("./marks/linked-highlight");
|
|
29
30
|
const link_1 = require("./marks/link");
|
|
30
|
-
const
|
|
31
|
+
const fibery_section_1 = require("./nodes/fibery-section");
|
|
32
|
+
const createSchema = ({ sharedColorGenerator = null, headingToDOM = null, mediaToDom = null, isImageBlockEnabled = false, fiberyViewEnabled = false, fiberySectionEnabled = false, fiberySectionStrictMode = true, } = {}) => {
|
|
31
33
|
prosemirror_schema_basic_1.nodes.code_block = code_block_1.code_block;
|
|
32
34
|
prosemirror_schema_basic_1.nodes.paragraph = paragraph_1.paragraph;
|
|
33
35
|
prosemirror_schema_basic_1.nodes.heading = (0, heading_1.makeHeading)({ headingToDOM });
|
|
@@ -43,6 +45,7 @@ const createSchema = ({ sharedColorGenerator = null, headingToDOM = null, mediaT
|
|
|
43
45
|
check_list: check_list_1.check_list,
|
|
44
46
|
video: video_1.video,
|
|
45
47
|
file: file_1.file,
|
|
48
|
+
callout: callout_1.callout,
|
|
46
49
|
};
|
|
47
50
|
let actualNodes = (0, prosemirror_schema_list_1.addListNodes)(base.spec.nodes, "paragraph block*", "block")
|
|
48
51
|
.append({ ...table_nodes_1.tableNodes })
|
|
@@ -56,6 +59,21 @@ const createSchema = ({ sharedColorGenerator = null, headingToDOM = null, mediaT
|
|
|
56
59
|
else {
|
|
57
60
|
actualNodes = actualNodes.addToEnd("imageBlock", image_block_1.imageBlock);
|
|
58
61
|
}
|
|
62
|
+
if (fiberySectionEnabled) {
|
|
63
|
+
actualNodes = actualNodes.append({
|
|
64
|
+
[fibery_section_1.fiberySectionNodeTypeName]: fibery_section_1.fiberySection,
|
|
65
|
+
});
|
|
66
|
+
if (fiberySectionStrictMode) {
|
|
67
|
+
actualNodes = actualNodes.update("doc", {
|
|
68
|
+
content: `${fibery_section_1.fiberySectionNodeTypeName}+`,
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
else {
|
|
72
|
+
actualNodes = actualNodes.update("doc", {
|
|
73
|
+
content: `(block | ${fibery_section_1.fiberySectionNodeTypeName})+`,
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
}
|
|
59
77
|
return new prosemirror_model_1.Schema({
|
|
60
78
|
nodes: actualNodes,
|
|
61
79
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
package/lib/src/marks/link.js
CHANGED
|
@@ -5,8 +5,8 @@ const makeLink = (baseLink) => {
|
|
|
5
5
|
return {
|
|
6
6
|
...baseLink,
|
|
7
7
|
toDOM(node) {
|
|
8
|
-
const { href
|
|
9
|
-
return ["a", { href,
|
|
8
|
+
const { href } = node.attrs;
|
|
9
|
+
return ["a", { href, target: "_blank", class: "prosemirror-link", rel: "noopener noreferrer" }, 0];
|
|
10
10
|
},
|
|
11
11
|
};
|
|
12
12
|
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export declare const callout: {
|
|
2
|
+
attrs: {
|
|
3
|
+
color: {
|
|
4
|
+
default: string;
|
|
5
|
+
};
|
|
6
|
+
iconType: {
|
|
7
|
+
default: string;
|
|
8
|
+
};
|
|
9
|
+
icon: {
|
|
10
|
+
default: string;
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
group: string;
|
|
14
|
+
content: string;
|
|
15
|
+
defining: true;
|
|
16
|
+
parseDOM: {
|
|
17
|
+
tag: string;
|
|
18
|
+
getAttrs(domNode: string | HTMLElement): {
|
|
19
|
+
color: string | null;
|
|
20
|
+
iconType: string | null;
|
|
21
|
+
icon: string | null;
|
|
22
|
+
};
|
|
23
|
+
}[];
|
|
24
|
+
toDOM(node: import("prosemirror-model").Node): [string, {
|
|
25
|
+
"data-callout-node": string;
|
|
26
|
+
"data-color": any;
|
|
27
|
+
"data-icon-type": any;
|
|
28
|
+
"data-icon": any;
|
|
29
|
+
}, number];
|
|
30
|
+
};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.callout = void 0;
|
|
4
|
+
const nodeType = "data-callout-node";
|
|
5
|
+
exports.callout = {
|
|
6
|
+
attrs: {
|
|
7
|
+
color: { default: "#4A4A4A" },
|
|
8
|
+
iconType: { default: "icon" },
|
|
9
|
+
icon: { default: "exclamation-circle" },
|
|
10
|
+
},
|
|
11
|
+
group: "block",
|
|
12
|
+
content: "block+",
|
|
13
|
+
defining: true,
|
|
14
|
+
parseDOM: [
|
|
15
|
+
{
|
|
16
|
+
tag: `div[${nodeType}]`,
|
|
17
|
+
getAttrs(domNode) {
|
|
18
|
+
const dom = domNode;
|
|
19
|
+
return {
|
|
20
|
+
color: dom.getAttribute("data-color"),
|
|
21
|
+
iconType: dom.getAttribute("data-icon-type"),
|
|
22
|
+
icon: dom.getAttribute("data-icon"),
|
|
23
|
+
};
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
],
|
|
27
|
+
toDOM(node) {
|
|
28
|
+
const { color, iconType, icon } = node.attrs;
|
|
29
|
+
const attrs = {
|
|
30
|
+
[nodeType]: "",
|
|
31
|
+
"data-color": color,
|
|
32
|
+
"data-icon-type": iconType,
|
|
33
|
+
"data-icon": icon,
|
|
34
|
+
};
|
|
35
|
+
return ["div", attrs, 0];
|
|
36
|
+
},
|
|
37
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.fiberySection = exports.fiberySectionNodeTypeName = void 0;
|
|
4
|
+
const sectionIdAttrName = "data-section-id";
|
|
5
|
+
const tagName = "fibery-section";
|
|
6
|
+
exports.fiberySectionNodeTypeName = "fiberySection";
|
|
7
|
+
exports.fiberySection = {
|
|
8
|
+
content: "block+",
|
|
9
|
+
selectable: false,
|
|
10
|
+
attrs: {
|
|
11
|
+
id: { default: "" },
|
|
12
|
+
},
|
|
13
|
+
parseDOM: [
|
|
14
|
+
{
|
|
15
|
+
tag: `${tagName}[${sectionIdAttrName}]`,
|
|
16
|
+
getAttrs: (domNode) => {
|
|
17
|
+
const dom = domNode;
|
|
18
|
+
return {
|
|
19
|
+
id: dom.getAttribute(sectionIdAttrName),
|
|
20
|
+
};
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
],
|
|
24
|
+
toDOM(node) {
|
|
25
|
+
const { id } = node.attrs;
|
|
26
|
+
const attrs = {
|
|
27
|
+
[sectionIdAttrName]: id,
|
|
28
|
+
};
|
|
29
|
+
return [tagName, attrs, 0];
|
|
30
|
+
},
|
|
31
|
+
};
|
package/lib/src/nodes/file.d.ts
CHANGED
|
@@ -7,10 +7,10 @@ export declare const file: {
|
|
|
7
7
|
size: {};
|
|
8
8
|
type: {};
|
|
9
9
|
};
|
|
10
|
-
inline:
|
|
10
|
+
inline: true;
|
|
11
11
|
group: string;
|
|
12
|
-
selectable:
|
|
13
|
-
draggable:
|
|
12
|
+
selectable: false;
|
|
13
|
+
draggable: false;
|
|
14
14
|
leafText: (node: import("prosemirror-model").Node) => any;
|
|
15
15
|
parseDOM: {
|
|
16
16
|
tag: string;
|
package/lib/src/nodes/file.js
CHANGED
|
@@ -8,14 +8,14 @@ exports.file = {
|
|
|
8
8
|
size: {},
|
|
9
9
|
type: {},
|
|
10
10
|
},
|
|
11
|
-
inline:
|
|
12
|
-
group: "
|
|
13
|
-
selectable:
|
|
14
|
-
draggable:
|
|
11
|
+
inline: true,
|
|
12
|
+
group: "inline",
|
|
13
|
+
selectable: false,
|
|
14
|
+
draggable: false,
|
|
15
15
|
leafText: (node) => node.attrs.title,
|
|
16
16
|
parseDOM: [
|
|
17
17
|
{
|
|
18
|
-
tag: "
|
|
18
|
+
tag: "span[data-file-href]",
|
|
19
19
|
getAttrs(domNode) {
|
|
20
20
|
const dom = domNode;
|
|
21
21
|
return {
|
|
@@ -34,6 +34,6 @@ exports.file = {
|
|
|
34
34
|
"data-size": size,
|
|
35
35
|
"data-type": type,
|
|
36
36
|
};
|
|
37
|
-
return ["
|
|
37
|
+
return ["span", attrs, title];
|
|
38
38
|
},
|
|
39
39
|
};
|
package/package.json
CHANGED
|
@@ -1,16 +1,21 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fibery/prosemirror-schema",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.3.0",
|
|
4
4
|
"description": "Fibery prosemirror schema",
|
|
5
5
|
"main": "./lib/index.js",
|
|
6
6
|
"files": [
|
|
7
7
|
"/lib"
|
|
8
8
|
],
|
|
9
9
|
"exports": {
|
|
10
|
-
".": "./lib/index.js"
|
|
10
|
+
".": "./lib/index.js",
|
|
11
|
+
"./src/nodes/fibery-section": "./lib/src/nodes/fibery-section.js",
|
|
12
|
+
"./src/nodes/fibery-section.d.ts": "./lib/src/nodes/fibery-section.d.ts",
|
|
13
|
+
"./lib/src/nodes/fibery-section": "./lib/src/nodes/fibery-section.js",
|
|
14
|
+
"./lib/src/nodes/fibery-section.d.ts": "./lib/src/nodes/fibery-section.d.ts"
|
|
11
15
|
},
|
|
12
16
|
"fiberyDevExports": {
|
|
13
|
-
".": "./index.ts"
|
|
17
|
+
".": "./index.ts",
|
|
18
|
+
"./src/nodes/fibery-section": "./src/nodes/fibery-section.ts"
|
|
14
19
|
},
|
|
15
20
|
"private": false,
|
|
16
21
|
"dependencies": {
|
|
@@ -20,18 +25,18 @@
|
|
|
20
25
|
"peerDependencies": {
|
|
21
26
|
"prosemirror-model": "^1.18.2",
|
|
22
27
|
"prosemirror-schema-list": "^1.2.2",
|
|
23
|
-
"prosemirror-tables": "
|
|
28
|
+
"prosemirror-tables": "1.3.2"
|
|
24
29
|
},
|
|
25
30
|
"devDependencies": {
|
|
26
|
-
"@fibery/babel-preset": "7.2.0",
|
|
27
|
-
"@fibery/eslint-config": "8.3.0",
|
|
28
31
|
"@types/uuid": "8.3.3",
|
|
29
32
|
"jest": "27.5.1",
|
|
30
33
|
"jest-junit": "13.0.0",
|
|
31
34
|
"prosemirror-model": "1.18.2",
|
|
32
35
|
"prosemirror-schema-list": "1.2.2",
|
|
33
|
-
"prosemirror-tables": "1.2
|
|
34
|
-
"typescript": "5.0.3"
|
|
36
|
+
"prosemirror-tables": "1.3.2",
|
|
37
|
+
"typescript": "5.0.3",
|
|
38
|
+
"@fibery/babel-preset": "7.2.0",
|
|
39
|
+
"@fibery/eslint-config": "8.3.0"
|
|
35
40
|
},
|
|
36
41
|
"jest": {
|
|
37
42
|
"testEnvironment": "jsdom",
|