@fibery/prosemirror-schema 4.17.0 → 4.18.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.d.ts +3 -2
- package/lib/src/create-schema.js +125 -25
- package/lib/src/marks/code.d.ts +1 -1
- package/lib/src/marks/em.d.ts +1 -1
- package/lib/src/marks/hint-query.d.ts +1 -1
- package/lib/src/marks/link.d.ts +1 -1
- package/lib/src/marks/linked-highlight.d.ts +1 -1
- package/lib/src/marks/strike.d.ts +1 -1
- package/lib/src/marks/strong.d.ts +1 -1
- package/lib/src/marks/text-background-color.d.ts +1 -1
- package/lib/src/marks/text-background-color.js +5 -1
- package/lib/src/marks/underline.d.ts +1 -1
- package/lib/src/nodes/check-item.d.ts +2 -2
- package/lib/src/nodes/check-list.d.ts +2 -2
- package/lib/src/nodes/code-block.d.ts +1 -1
- package/lib/src/nodes/column.d.ts +1 -1
- package/lib/src/nodes/columns.d.ts +1 -1
- package/lib/src/nodes/entity.d.ts +1 -1
- package/lib/src/nodes/fibery-view.d.ts +1 -1
- package/lib/src/nodes/heading.d.ts +1 -1
- package/lib/src/nodes/image-block.d.ts +1 -1
- package/lib/src/nodes/important.d.ts +1 -1
- package/lib/src/nodes/math-display.d.ts +1 -1
- package/lib/src/nodes/math-inline.d.ts +1 -1
- package/lib/src/nodes/media.d.ts +1 -1
- package/lib/src/nodes/mention.d.ts +1 -1
- package/lib/src/nodes/note.d.ts +1 -1
- package/lib/src/nodes/paragraph.d.ts +1 -1
- package/lib/src/nodes/types/inline-content.d.ts +3 -3
- package/lib/src/nodes/video.d.ts +1 -1
- package/lib/src/resizable-node-attrs.d.ts +1 -1
- package/lib/test-helpers/index.d.ts +1 -1
- package/package.json +7 -10
- package/lib/jest.config.cjs +0 -12
- package/lib/jest.config.d.cts +0 -3
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { Node
|
|
2
|
-
import {
|
|
1
|
+
import type { Node } from "prosemirror-model";
|
|
2
|
+
import { Schema, type NodeSpec, type MarkSpec } from "prosemirror-model";
|
|
3
|
+
import type { EmojiOptions } from "./nodes/emoji";
|
|
3
4
|
type Params = {
|
|
4
5
|
isImageBlockEnabled?: boolean;
|
|
5
6
|
fiberyViewEnabled?: boolean;
|
package/lib/src/create-schema.js
CHANGED
|
@@ -4,36 +4,36 @@ exports.Basic = exports.createSchema = void 0;
|
|
|
4
4
|
const prosemirror_model_1 = require("prosemirror-model");
|
|
5
5
|
const prosemirror_schema_basic_1 = require("prosemirror-schema-basic");
|
|
6
6
|
const prosemirror_schema_list_1 = require("prosemirror-schema-list");
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
const
|
|
10
|
-
const
|
|
11
|
-
const
|
|
12
|
-
const
|
|
13
|
-
const
|
|
7
|
+
const code_1 = require("./marks/code");
|
|
8
|
+
const em_1 = require("./marks/em");
|
|
9
|
+
const hint_query_1 = require("./marks/hint-query");
|
|
10
|
+
const link_1 = require("./marks/link");
|
|
11
|
+
const linked_highlight_1 = require("./marks/linked-highlight");
|
|
12
|
+
const strike_1 = require("./marks/strike");
|
|
13
|
+
const strong_1 = require("./marks/strong");
|
|
14
|
+
const text_background_color_1 = require("./marks/text-background-color");
|
|
15
|
+
const underline_1 = require("./marks/underline");
|
|
16
|
+
const callout_1 = require("./nodes/callout");
|
|
17
|
+
const check_item_1 = require("./nodes/check-item");
|
|
18
|
+
const check_list_1 = require("./nodes/check-list");
|
|
19
|
+
const code_block_1 = require("./nodes/code-block");
|
|
20
|
+
const column_1 = require("./nodes/column");
|
|
21
|
+
const columns_1 = require("./nodes/columns");
|
|
22
|
+
const emoji_1 = require("./nodes/emoji");
|
|
14
23
|
const entity_1 = require("./nodes/entity");
|
|
15
|
-
const mention_1 = require("./nodes/mention");
|
|
16
24
|
const fibery_view_1 = require("./nodes/fibery-view");
|
|
17
|
-
const
|
|
18
|
-
const
|
|
25
|
+
const file_1 = require("./nodes/file");
|
|
26
|
+
const heading_1 = require("./nodes/heading");
|
|
27
|
+
const image_block_1 = require("./nodes/image-block");
|
|
28
|
+
const important_1 = require("./nodes/important");
|
|
19
29
|
const math_display_1 = require("./nodes/math-display");
|
|
20
30
|
const math_inline_1 = require("./nodes/math-inline");
|
|
21
|
-
const
|
|
31
|
+
const media_1 = require("./nodes/media");
|
|
32
|
+
const mention_1 = require("./nodes/mention");
|
|
33
|
+
const note_1 = require("./nodes/note");
|
|
34
|
+
const paragraph_1 = require("./nodes/paragraph");
|
|
35
|
+
const table_nodes_1 = require("./nodes/table-nodes");
|
|
22
36
|
const video_1 = require("./nodes/video");
|
|
23
|
-
const file_1 = require("./nodes/file");
|
|
24
|
-
const callout_1 = require("./nodes/callout");
|
|
25
|
-
const emoji_1 = require("./nodes/emoji");
|
|
26
|
-
const columns_1 = require("./nodes/columns");
|
|
27
|
-
const column_1 = require("./nodes/column");
|
|
28
|
-
const strike_1 = require("./marks/strike");
|
|
29
|
-
const underline_1 = require("./marks/underline");
|
|
30
|
-
const hint_query_1 = require("./marks/hint-query");
|
|
31
|
-
const text_background_color_1 = require("./marks/text-background-color");
|
|
32
|
-
const linked_highlight_1 = require("./marks/linked-highlight");
|
|
33
|
-
const link_1 = require("./marks/link");
|
|
34
|
-
const em_1 = require("./marks/em");
|
|
35
|
-
const strong_1 = require("./marks/strong");
|
|
36
|
-
const code_1 = require("./marks/code");
|
|
37
37
|
const createSchema = ({ sharedColorGenerator = null, headingToDOM = null, mediaToDom = null, isImageBlockEnabled = false, fiberyViewEnabled = false, emojiOptions, } = {}) => {
|
|
38
38
|
prosemirror_schema_basic_1.nodes.code_block = code_block_1.code_block;
|
|
39
39
|
prosemirror_schema_basic_1.nodes.paragraph = paragraph_1.paragraph;
|
|
@@ -81,6 +81,106 @@ const createSchema = ({ sharedColorGenerator = null, headingToDOM = null, mediaT
|
|
|
81
81
|
actualNodes = actualNodes.update("doc", {
|
|
82
82
|
content: `(block | columns)+`,
|
|
83
83
|
});
|
|
84
|
+
// prosemirror-schema-list@1.5.0+ added validate:"number" to the order attr,
|
|
85
|
+
// which rejects legacy documents where order was stored as null. Drop the
|
|
86
|
+
// validator so those documents can still be parsed.
|
|
87
|
+
const orderedListSpec = actualNodes.get("ordered_list");
|
|
88
|
+
actualNodes = actualNodes.update("ordered_list", {
|
|
89
|
+
...orderedListSpec,
|
|
90
|
+
attrs: { order: { default: 1 } },
|
|
91
|
+
});
|
|
92
|
+
const listItemSpec = actualNodes.get("list_item");
|
|
93
|
+
actualNodes = actualNodes.update("list_item", {
|
|
94
|
+
...listItemSpec,
|
|
95
|
+
attrs: {
|
|
96
|
+
...(listItemSpec.attrs ?? {}),
|
|
97
|
+
state: { default: null },
|
|
98
|
+
id: { default: null },
|
|
99
|
+
},
|
|
100
|
+
parseDOM: [
|
|
101
|
+
{
|
|
102
|
+
tag: "li[data-check-item-state]",
|
|
103
|
+
getAttrs: (dom) => {
|
|
104
|
+
const el = dom;
|
|
105
|
+
const state = el.getAttribute("data-check-item-state");
|
|
106
|
+
// Strip the "[] "/"[x] " text prefix added by the clipboard serializer so
|
|
107
|
+
// it doesn't appear as document content when pasting back into Fibery.
|
|
108
|
+
// getAttrs runs before ProseMirror walks the children, so mutation is safe.
|
|
109
|
+
const firstBlock = el.firstChild;
|
|
110
|
+
if (firstBlock !== null && firstBlock.nodeType === 1 /* ELEMENT_NODE */) {
|
|
111
|
+
const firstText = firstBlock.firstChild;
|
|
112
|
+
if (firstText !== null && firstText.nodeType === 3 /* TEXT_NODE */) {
|
|
113
|
+
const text = firstText.textContent ?? "";
|
|
114
|
+
if (text.startsWith("[ ] ") || text.startsWith("[x] ")) {
|
|
115
|
+
const rest = text.slice(4);
|
|
116
|
+
if (rest) {
|
|
117
|
+
firstText.textContent = rest;
|
|
118
|
+
}
|
|
119
|
+
else {
|
|
120
|
+
firstBlock.removeChild(firstText);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
return {
|
|
126
|
+
state: state === "TODO" || state === "DONE" ? state : null,
|
|
127
|
+
id: el.getAttribute("data-list-item-id") ?? null,
|
|
128
|
+
};
|
|
129
|
+
},
|
|
130
|
+
},
|
|
131
|
+
{
|
|
132
|
+
tag: "li",
|
|
133
|
+
getAttrs: (dom) => {
|
|
134
|
+
const el = dom;
|
|
135
|
+
const firstChild = el.firstChild;
|
|
136
|
+
if (firstChild === null) {
|
|
137
|
+
return false;
|
|
138
|
+
}
|
|
139
|
+
// Support pasting from external editors that output [ ] / [x] as text
|
|
140
|
+
// without data-check-item-state. Check text directly in <li> or inside
|
|
141
|
+
// the first block element (e.g. <p>).
|
|
142
|
+
let textNode = null;
|
|
143
|
+
let textParent = null;
|
|
144
|
+
if (firstChild.nodeType === 3 /* TEXT_NODE */) {
|
|
145
|
+
textNode = firstChild;
|
|
146
|
+
textParent = el;
|
|
147
|
+
}
|
|
148
|
+
else if (firstChild.nodeType === 1 /* ELEMENT_NODE */ && firstChild.firstChild?.nodeType === 3) {
|
|
149
|
+
textNode = firstChild.firstChild;
|
|
150
|
+
textParent = firstChild;
|
|
151
|
+
}
|
|
152
|
+
if (textNode === null) {
|
|
153
|
+
return false;
|
|
154
|
+
}
|
|
155
|
+
const text = textNode.textContent ?? "";
|
|
156
|
+
const state = text.startsWith("[ ] ") ? "TODO" : text.startsWith("[x] ") ? "DONE" : null;
|
|
157
|
+
if (state === null) {
|
|
158
|
+
return false;
|
|
159
|
+
}
|
|
160
|
+
const rest = text.slice(4);
|
|
161
|
+
if (rest) {
|
|
162
|
+
textNode.textContent = rest;
|
|
163
|
+
}
|
|
164
|
+
else {
|
|
165
|
+
textParent.removeChild(textNode);
|
|
166
|
+
}
|
|
167
|
+
return { state, id: null };
|
|
168
|
+
},
|
|
169
|
+
},
|
|
170
|
+
{ tag: "li" },
|
|
171
|
+
],
|
|
172
|
+
toDOM(node) {
|
|
173
|
+
const { state, id } = node.attrs;
|
|
174
|
+
const attrs = {};
|
|
175
|
+
if (state) {
|
|
176
|
+
attrs["data-check-item-state"] = state;
|
|
177
|
+
}
|
|
178
|
+
if (id) {
|
|
179
|
+
attrs["data-list-item-id"] = id;
|
|
180
|
+
}
|
|
181
|
+
return Object.keys(attrs).length ? ["li", attrs, 0] : ["li", 0];
|
|
182
|
+
},
|
|
183
|
+
});
|
|
84
184
|
return new prosemirror_model_1.Schema({
|
|
85
185
|
nodes: actualNodes,
|
|
86
186
|
marks: base.spec.marks
|
package/lib/src/marks/code.d.ts
CHANGED
package/lib/src/marks/em.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { MarkSpec } from "prosemirror-model";
|
|
1
|
+
import type { MarkSpec } from "prosemirror-model";
|
|
2
2
|
export declare const hintQuery: MarkSpec;
|
package/lib/src/marks/link.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { MarkSpec } from "prosemirror-model";
|
|
1
|
+
import type { MarkSpec } from "prosemirror-model";
|
|
2
2
|
export declare const strike: MarkSpec;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { MarkSpec } from "prosemirror-model";
|
|
1
|
+
import type { MarkSpec } from "prosemirror-model";
|
|
2
2
|
export declare const textBackgroundColor: MarkSpec;
|
|
@@ -42,7 +42,11 @@ const getClassName = (bgColorToken, fgColorToken) => {
|
|
|
42
42
|
return [
|
|
43
43
|
`text-background-color`,
|
|
44
44
|
bgColorToken ? `bg-${bgColorToken.toLowerCase()}` : null,
|
|
45
|
-
fgColorToken
|
|
45
|
+
fgColorToken
|
|
46
|
+
? bgColorToken
|
|
47
|
+
? `fg-on-bg-${fgColorToken.toLowerCase()}`
|
|
48
|
+
: `fg-${fgColorToken.toLowerCase()}`
|
|
49
|
+
: null,
|
|
46
50
|
]
|
|
47
51
|
.filter(Boolean)
|
|
48
52
|
.join(` `);
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { MarkSpec } from "prosemirror-model";
|
|
1
|
+
import type { MarkSpec } from "prosemirror-model";
|
|
2
2
|
export declare const underline: MarkSpec;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { NodeSpec } from "prosemirror-model";
|
|
2
|
-
import { Inline } from "./types/inline-content";
|
|
1
|
+
import type { NodeSpec } from "prosemirror-model";
|
|
2
|
+
import type { Inline } from "./types/inline-content";
|
|
3
3
|
export interface CheckItemDefinition {
|
|
4
4
|
type: "check_item";
|
|
5
5
|
content?: Array<Inline>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { NodeSpec } from "prosemirror-model";
|
|
2
|
-
import { CheckItemDefinition } from "./check-item";
|
|
1
|
+
import type { NodeSpec } from "prosemirror-model";
|
|
2
|
+
import type { CheckItemDefinition } from "./check-item";
|
|
3
3
|
export interface CheckListContent extends Array<CheckItemDefinition | CheckListDefinition> {
|
|
4
4
|
0: CheckItemDefinition;
|
|
5
5
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { NodeSpec } from "prosemirror-model";
|
|
1
|
+
import type { NodeSpec } from "prosemirror-model";
|
|
2
2
|
export declare const code_block: NodeSpec;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { NodeSpec } from "prosemirror-model";
|
|
1
|
+
import type { NodeSpec } from "prosemirror-model";
|
|
2
2
|
export declare const column: NodeSpec;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { NodeSpec } from "prosemirror-model";
|
|
1
|
+
import type { NodeSpec } from "prosemirror-model";
|
|
2
2
|
export declare const columns: NodeSpec;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { NodeSpec } from "prosemirror-model";
|
|
1
|
+
import type { NodeSpec } from "prosemirror-model";
|
|
2
2
|
export declare const fiberyView: NodeSpec;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { NodeSpec } from "prosemirror-model";
|
|
1
|
+
import type { NodeSpec } from "prosemirror-model";
|
|
2
2
|
export declare const imageBlock: NodeSpec;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { NodeSpec } from "prosemirror-model";
|
|
1
|
+
import type { NodeSpec } from "prosemirror-model";
|
|
2
2
|
export declare const important: NodeSpec;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { NodeSpec } from "prosemirror-model";
|
|
1
|
+
import type { NodeSpec } from "prosemirror-model";
|
|
2
2
|
export declare const math_display: NodeSpec;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { NodeSpec } from "prosemirror-model";
|
|
1
|
+
import type { NodeSpec } from "prosemirror-model";
|
|
2
2
|
export declare const math_inline: NodeSpec;
|
package/lib/src/nodes/media.d.ts
CHANGED
package/lib/src/nodes/note.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { NodeSpec } from "prosemirror-model";
|
|
1
|
+
import type { NodeSpec } from "prosemirror-model";
|
|
2
2
|
export declare const note: NodeSpec;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { NodeSpec } from "prosemirror-model";
|
|
1
|
+
import type { NodeSpec } from "prosemirror-model";
|
|
2
2
|
export declare const paragraph: NodeSpec;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { TextDefinition as Text } from "./text";
|
|
1
|
+
import type { EntityDefinition as Entity } from "../entity";
|
|
2
|
+
import type { MentionDefinition as Mention } from "../mention";
|
|
3
|
+
import type { TextDefinition as Text } from "./text";
|
|
4
4
|
interface MarksObject<T> {
|
|
5
5
|
marks?: Array<T>;
|
|
6
6
|
}
|
package/lib/src/nodes/video.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Schema, Node as PMNode, ParseOptions } from "prosemirror-model";
|
|
1
|
+
import type { Schema, Node as PMNode, ParseOptions } from "prosemirror-model";
|
|
2
2
|
export declare const fromHTML: (html: string, schema: Schema, options?: ParseOptions) => PMNode;
|
|
3
3
|
export declare const toDOM: (node: PMNode, schema: Schema) => Node;
|
|
4
4
|
export declare const toHTML: (node: PMNode, schema: Schema) => string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fibery/prosemirror-schema",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.18.1",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Fibery prosemirror schema",
|
|
6
6
|
"files": [
|
|
@@ -9,8 +9,8 @@
|
|
|
9
9
|
"main": "./lib/index.js",
|
|
10
10
|
"exports": {
|
|
11
11
|
".": {
|
|
12
|
-
"types": "./lib/index.d.ts",
|
|
13
12
|
"@fibery/source": "./index.ts",
|
|
13
|
+
"types": "./lib/index.d.ts",
|
|
14
14
|
"default": "./lib/index.js"
|
|
15
15
|
},
|
|
16
16
|
"./src/nodes/fibery-section": {
|
|
@@ -24,27 +24,24 @@
|
|
|
24
24
|
"dependencies": {
|
|
25
25
|
"prosemirror-model": "1.25.4",
|
|
26
26
|
"prosemirror-schema-basic": "1.2.2",
|
|
27
|
-
"prosemirror-schema-list": "1.
|
|
27
|
+
"prosemirror-schema-list": "1.5.1",
|
|
28
28
|
"prosemirror-tables": "1.4.2",
|
|
29
29
|
"uuid": "11.1.0"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
|
-
"@types/jest": "30.0.0",
|
|
33
|
-
"jest": "30.2.0",
|
|
34
|
-
"jest-junit": "16.0.0",
|
|
35
32
|
"typescript": "6.0.1-rc",
|
|
36
33
|
"@fibery/babel-preset": "7.4.2"
|
|
37
34
|
},
|
|
38
35
|
"peerDependencies": {
|
|
39
36
|
"prosemirror-model": "1.25.4",
|
|
40
|
-
"prosemirror-schema-list": "1.
|
|
37
|
+
"prosemirror-schema-list": "1.5.1",
|
|
41
38
|
"prosemirror-tables": "1.4.2"
|
|
42
39
|
},
|
|
43
40
|
"scripts": {
|
|
44
41
|
"build": "rm -rf lib && tsc --project tsconfig.build.json",
|
|
45
|
-
"test": "
|
|
46
|
-
"test:ci": "
|
|
47
|
-
"test:coverage": "
|
|
42
|
+
"test": "../../scripts/test.sh",
|
|
43
|
+
"test:ci": "../../scripts/test.sh --ci",
|
|
44
|
+
"test:coverage": "../../scripts/test.sh --ci --coverage",
|
|
48
45
|
"check": "../../scripts/check.sh",
|
|
49
46
|
"lint": "../../scripts/lint.sh"
|
|
50
47
|
},
|
package/lib/jest.config.cjs
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/** @type {import('@jest/schemas').InitialOptions} */
|
|
3
|
-
const config = {
|
|
4
|
-
collectCoverageFrom: ["src/**/*.{js,jsx,ts,tsx}", "!src/**/*.d.ts"],
|
|
5
|
-
coveragePathIgnorePatterns: ["/node_modules/"],
|
|
6
|
-
coverageReporters: ["text", "cobertura"],
|
|
7
|
-
testEnvironment: "jsdom",
|
|
8
|
-
testEnvironmentOptions: {
|
|
9
|
-
customExportConditions: ["@fibery/source"],
|
|
10
|
-
},
|
|
11
|
-
};
|
|
12
|
-
module.exports = config;
|
package/lib/jest.config.d.cts
DELETED