@fibery/prosemirror-schema 3.4.0 → 4.0.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.
|
@@ -2,11 +2,9 @@ import { Schema, Node } from "prosemirror-model";
|
|
|
2
2
|
interface SchemaProps {
|
|
3
3
|
isImageBlockEnabled?: boolean;
|
|
4
4
|
fiberyViewEnabled?: boolean;
|
|
5
|
-
fiberySectionEnabled?: boolean;
|
|
6
|
-
fiberySectionStrictMode?: boolean;
|
|
7
5
|
sharedColorGenerator?: any;
|
|
8
6
|
headingToDOM?: ((node: Node) => HTMLElement) | null;
|
|
9
7
|
mediaToDom?: ((node: Node) => HTMLElement) | null;
|
|
10
8
|
}
|
|
11
|
-
export declare const createSchema: ({ sharedColorGenerator, headingToDOM, mediaToDom, isImageBlockEnabled, fiberyViewEnabled,
|
|
9
|
+
export declare const createSchema: ({ sharedColorGenerator, headingToDOM, mediaToDom, isImageBlockEnabled, fiberyViewEnabled, }?: SchemaProps) => Schema;
|
|
12
10
|
export {};
|
package/lib/src/create-schema.js
CHANGED
|
@@ -28,8 +28,7 @@ const hint_query_1 = require("./marks/hint-query");
|
|
|
28
28
|
const highlight_1 = require("./marks/highlight");
|
|
29
29
|
const linked_highlight_1 = require("./marks/linked-highlight");
|
|
30
30
|
const link_1 = require("./marks/link");
|
|
31
|
-
const
|
|
32
|
-
const createSchema = ({ sharedColorGenerator = null, headingToDOM = null, mediaToDom = null, isImageBlockEnabled = false, fiberyViewEnabled = false, fiberySectionEnabled = false, fiberySectionStrictMode = true, } = {}) => {
|
|
31
|
+
const createSchema = ({ sharedColorGenerator = null, headingToDOM = null, mediaToDom = null, isImageBlockEnabled = false, fiberyViewEnabled = false, } = {}) => {
|
|
33
32
|
prosemirror_schema_basic_1.nodes.code_block = code_block_1.code_block;
|
|
34
33
|
prosemirror_schema_basic_1.nodes.paragraph = paragraph_1.paragraph;
|
|
35
34
|
prosemirror_schema_basic_1.nodes.heading = (0, heading_1.makeHeading)({ headingToDOM });
|
|
@@ -59,21 +58,6 @@ const createSchema = ({ sharedColorGenerator = null, headingToDOM = null, mediaT
|
|
|
59
58
|
else {
|
|
60
59
|
actualNodes = actualNodes.addToEnd("imageBlock", image_block_1.imageBlock);
|
|
61
60
|
}
|
|
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
|
-
}
|
|
77
61
|
return new prosemirror_model_1.Schema({
|
|
78
62
|
nodes: actualNodes,
|
|
79
63
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fibery/prosemirror-schema",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.0",
|
|
4
4
|
"description": "Fibery prosemirror schema",
|
|
5
5
|
"main": "./lib/index.js",
|
|
6
6
|
"files": [
|
|
@@ -35,8 +35,8 @@
|
|
|
35
35
|
"prosemirror-schema-list": "1.2.2",
|
|
36
36
|
"prosemirror-tables": "1.3.2",
|
|
37
37
|
"typescript": "5.0.3",
|
|
38
|
-
"@fibery/
|
|
39
|
-
"@fibery/
|
|
38
|
+
"@fibery/eslint-config": "8.3.0",
|
|
39
|
+
"@fibery/babel-preset": "7.2.0"
|
|
40
40
|
},
|
|
41
41
|
"jest": {
|
|
42
42
|
"testEnvironment": "jsdom",
|
|
@@ -1,31 +0,0 @@
|
|
|
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
|
-
};
|