@fibery/prosemirror-schema 4.19.0-next.2 → 4.19.0-next.3
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 +4 -4
- package/lib/index.js +15 -4
- package/lib/src/create-schema.d.ts +1 -1
- package/lib/src/create-schema.js +124 -82
- package/lib/src/marks/code.js +4 -1
- package/lib/src/marks/em.js +4 -1
- package/lib/src/marks/hint-query.js +4 -1
- package/lib/src/marks/link.js +4 -1
- package/lib/src/marks/linked-highlight.js +7 -2
- package/lib/src/marks/strike.js +4 -1
- package/lib/src/marks/strong.js +4 -1
- package/lib/src/marks/text-background-color.js +4 -1
- package/lib/src/marks/underline.js +4 -1
- package/lib/src/nodes/callout.js +4 -1
- package/lib/src/nodes/check-item.d.ts +1 -1
- package/lib/src/nodes/check-item.js +6 -3
- package/lib/src/nodes/check-list.d.ts +1 -1
- package/lib/src/nodes/check-list.js +6 -3
- package/lib/src/nodes/code-block.js +23 -9
- package/lib/src/nodes/column.js +4 -1
- package/lib/src/nodes/columns.js +8 -5
- package/lib/src/nodes/emoji.js +5 -1
- package/lib/src/nodes/entity.js +4 -1
- package/lib/src/nodes/fibery-view.js +8 -5
- package/lib/src/nodes/file.js +6 -3
- package/lib/src/nodes/heading.js +16 -6
- package/lib/src/nodes/image-block.js +8 -5
- package/lib/src/nodes/important.js +4 -1
- package/lib/src/nodes/math-display.js +4 -1
- package/lib/src/nodes/math-inline.js +4 -1
- package/lib/src/nodes/media.js +9 -5
- package/lib/src/nodes/mention.js +4 -1
- package/lib/src/nodes/note.js +4 -1
- package/lib/src/nodes/paragraph.js +14 -7
- package/lib/src/nodes/table-nodes.js +5 -2
- package/lib/src/nodes/types/inline-content.d.ts +3 -3
- package/lib/src/nodes/types/inline-content.js +2 -1
- package/lib/src/nodes/types/text.js +2 -1
- package/lib/src/nodes/video.js +17 -14
- package/lib/src/resizable-node-attrs.js +13 -7
- package/lib/src/transcription-node-attrs.js +4 -1
- package/lib/test-helpers/index.js +14 -8
- package/package.json +7 -8
package/lib/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { defaultHeight, defaultWidth } from "./src/resizable-node-attrs
|
|
1
|
+
export { defaultHeight, defaultWidth } from "./src/resizable-node-attrs";
|
|
2
2
|
export { Node, Schema } from "prosemirror-model";
|
|
3
|
-
export { createSchema, Basic } from "./src/create-schema
|
|
4
|
-
export { DEFAULT_VIDEO_WIDTH, DEFAULT_VIDEO_HEIGHT } from "./src/nodes/video
|
|
5
|
-
export type { EmojiOptions } from "./src/nodes/emoji
|
|
3
|
+
export { createSchema, Basic } from "./src/create-schema";
|
|
4
|
+
export { DEFAULT_VIDEO_WIDTH, DEFAULT_VIDEO_HEIGHT } from "./src/nodes/video";
|
|
5
|
+
export type { EmojiOptions } from "./src/nodes/emoji";
|
package/lib/index.js
CHANGED
|
@@ -1,4 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DEFAULT_VIDEO_HEIGHT = exports.DEFAULT_VIDEO_WIDTH = exports.Basic = exports.createSchema = exports.Schema = exports.Node = exports.defaultWidth = exports.defaultHeight = void 0;
|
|
4
|
+
var resizable_node_attrs_1 = require("./src/resizable-node-attrs");
|
|
5
|
+
Object.defineProperty(exports, "defaultHeight", { enumerable: true, get: function () { return resizable_node_attrs_1.defaultHeight; } });
|
|
6
|
+
Object.defineProperty(exports, "defaultWidth", { enumerable: true, get: function () { return resizable_node_attrs_1.defaultWidth; } });
|
|
7
|
+
var prosemirror_model_1 = require("prosemirror-model");
|
|
8
|
+
Object.defineProperty(exports, "Node", { enumerable: true, get: function () { return prosemirror_model_1.Node; } });
|
|
9
|
+
Object.defineProperty(exports, "Schema", { enumerable: true, get: function () { return prosemirror_model_1.Schema; } });
|
|
10
|
+
var create_schema_1 = require("./src/create-schema");
|
|
11
|
+
Object.defineProperty(exports, "createSchema", { enumerable: true, get: function () { return create_schema_1.createSchema; } });
|
|
12
|
+
Object.defineProperty(exports, "Basic", { enumerable: true, get: function () { return create_schema_1.Basic; } });
|
|
13
|
+
var video_1 = require("./src/nodes/video");
|
|
14
|
+
Object.defineProperty(exports, "DEFAULT_VIDEO_WIDTH", { enumerable: true, get: function () { return video_1.DEFAULT_VIDEO_WIDTH; } });
|
|
15
|
+
Object.defineProperty(exports, "DEFAULT_VIDEO_HEIGHT", { enumerable: true, get: function () { return video_1.DEFAULT_VIDEO_HEIGHT; } });
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Node } from "prosemirror-model";
|
|
2
2
|
import { Schema, type NodeSpec, type MarkSpec } from "prosemirror-model";
|
|
3
|
-
import type { EmojiOptions } from "./nodes/emoji
|
|
3
|
+
import type { EmojiOptions } from "./nodes/emoji";
|
|
4
4
|
type Params = {
|
|
5
5
|
isImageBlockEnabled?: boolean;
|
|
6
6
|
fiberyViewEnabled?: boolean;
|
package/lib/src/create-schema.js
CHANGED
|
@@ -1,85 +1,101 @@
|
|
|
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
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
nodes.
|
|
39
|
-
|
|
40
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Basic = exports.createSchema = void 0;
|
|
4
|
+
const prosemirror_model_1 = require("prosemirror-model");
|
|
5
|
+
const prosemirror_schema_basic_1 = require("prosemirror-schema-basic");
|
|
6
|
+
const prosemirror_schema_list_1 = require("prosemirror-schema-list");
|
|
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");
|
|
23
|
+
const entity_1 = require("./nodes/entity");
|
|
24
|
+
const fibery_view_1 = require("./nodes/fibery-view");
|
|
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");
|
|
29
|
+
const math_display_1 = require("./nodes/math-display");
|
|
30
|
+
const math_inline_1 = require("./nodes/math-inline");
|
|
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");
|
|
36
|
+
const video_1 = require("./nodes/video");
|
|
37
|
+
const createSchema = ({ sharedColorGenerator = null, headingToDOM = null, mediaToDom = null, isImageBlockEnabled = false, fiberyViewEnabled = false, emojiOptions, } = {}) => {
|
|
38
|
+
prosemirror_schema_basic_1.nodes.code_block = code_block_1.code_block;
|
|
39
|
+
prosemirror_schema_basic_1.nodes.paragraph = paragraph_1.paragraph;
|
|
40
|
+
prosemirror_schema_basic_1.nodes.heading = (0, heading_1.makeHeading)({ headingToDOM });
|
|
41
|
+
const base = new prosemirror_model_1.Schema({
|
|
42
|
+
nodes: prosemirror_schema_basic_1.nodes,
|
|
41
43
|
marks: {
|
|
42
|
-
link,
|
|
43
|
-
em,
|
|
44
|
-
strong,
|
|
45
|
-
code,
|
|
46
|
-
linkedhighlight: makeLinkedHighlight({ sharedColorGenerator }),
|
|
47
|
-
linkedhighlightentity: makeLinkedHighlightEntity({ sharedColorGenerator }),
|
|
44
|
+
link: link_1.link,
|
|
45
|
+
em: em_1.em,
|
|
46
|
+
strong: strong_1.strong,
|
|
47
|
+
code: code_1.code,
|
|
48
|
+
linkedhighlight: (0, linked_highlight_1.makeLinkedHighlight)({ sharedColorGenerator }),
|
|
49
|
+
linkedhighlightentity: (0, linked_highlight_1.makeLinkedHighlightEntity)({ sharedColorGenerator }),
|
|
48
50
|
},
|
|
49
51
|
});
|
|
50
52
|
const customNodes = {
|
|
51
|
-
note,
|
|
52
|
-
important,
|
|
53
|
-
entity,
|
|
54
|
-
mention,
|
|
55
|
-
media: makeMedia({ mediaToDom }),
|
|
56
|
-
check_item,
|
|
57
|
-
check_list,
|
|
58
|
-
video,
|
|
59
|
-
file,
|
|
60
|
-
emoji: makeEmoji(emojiOptions),
|
|
61
|
-
callout,
|
|
62
|
-
columns,
|
|
63
|
-
column,
|
|
64
|
-
math_display,
|
|
65
|
-
math_inline,
|
|
53
|
+
note: note_1.note,
|
|
54
|
+
important: important_1.important,
|
|
55
|
+
entity: entity_1.entity,
|
|
56
|
+
mention: mention_1.mention,
|
|
57
|
+
media: (0, media_1.makeMedia)({ mediaToDom }),
|
|
58
|
+
check_item: check_item_1.check_item,
|
|
59
|
+
check_list: check_list_1.check_list,
|
|
60
|
+
video: video_1.video,
|
|
61
|
+
file: file_1.file,
|
|
62
|
+
emoji: (0, emoji_1.makeEmoji)(emojiOptions),
|
|
63
|
+
callout: callout_1.callout,
|
|
64
|
+
columns: columns_1.columns,
|
|
65
|
+
column: column_1.column,
|
|
66
|
+
math_display: math_display_1.math_display,
|
|
67
|
+
math_inline: math_inline_1.math_inline,
|
|
66
68
|
};
|
|
67
|
-
let actualNodes = addListNodes(base.spec.nodes, "paragraph block*", "block")
|
|
68
|
-
.append({ ...tableNodes })
|
|
69
|
+
let actualNodes = (0, prosemirror_schema_list_1.addListNodes)(base.spec.nodes, "paragraph block*", "block")
|
|
70
|
+
.append({ ...table_nodes_1.tableNodes })
|
|
69
71
|
.append(customNodes);
|
|
70
72
|
if (fiberyViewEnabled) {
|
|
71
|
-
actualNodes = actualNodes.append({ fiberyView });
|
|
73
|
+
actualNodes = actualNodes.append({ fiberyView: fibery_view_1.fiberyView });
|
|
72
74
|
}
|
|
73
75
|
if (isImageBlockEnabled) {
|
|
74
|
-
actualNodes = actualNodes.addToStart("imageBlock", imageBlock);
|
|
76
|
+
actualNodes = actualNodes.addToStart("imageBlock", image_block_1.imageBlock);
|
|
75
77
|
}
|
|
76
78
|
else {
|
|
77
|
-
actualNodes = actualNodes.addToEnd("imageBlock", imageBlock);
|
|
79
|
+
actualNodes = actualNodes.addToEnd("imageBlock", image_block_1.imageBlock);
|
|
78
80
|
}
|
|
79
81
|
actualNodes = actualNodes.update("doc", {
|
|
80
82
|
content: `(block | columns)+`,
|
|
81
|
-
marks: "insertion modification deletion",
|
|
82
83
|
});
|
|
84
|
+
// prosemirror-tables@1.7.0+ added validate constraints to cell attrs
|
|
85
|
+
// (colspan, rowspan, colwidth). Legacy Fibery documents may not satisfy
|
|
86
|
+
// these validators. Drop all validators so those documents can still be parsed.
|
|
87
|
+
for (const cellType of ["table_cell", "table_header"]) {
|
|
88
|
+
const cellSpec = actualNodes.get(cellType);
|
|
89
|
+
const attrsWithoutValidate = {};
|
|
90
|
+
for (const [key, attrSpec] of Object.entries(cellSpec.attrs ?? {})) {
|
|
91
|
+
const { validate: _, ...rest } = attrSpec;
|
|
92
|
+
attrsWithoutValidate[key] = rest;
|
|
93
|
+
}
|
|
94
|
+
actualNodes = actualNodes.update(cellType, {
|
|
95
|
+
...cellSpec,
|
|
96
|
+
attrs: attrsWithoutValidate,
|
|
97
|
+
});
|
|
98
|
+
}
|
|
83
99
|
// prosemirror-schema-list@1.5.0+ added validate:"number" to the order attr,
|
|
84
100
|
// which rejects legacy documents where order was stored as null. Drop the
|
|
85
101
|
// validator so those documents can still be parsed.
|
|
@@ -180,27 +196,53 @@ export const createSchema = ({ sharedColorGenerator = null, headingToDOM = null,
|
|
|
180
196
|
return Object.keys(attrs).length ? ["li", attrs, 0] : ["li", 0];
|
|
181
197
|
},
|
|
182
198
|
});
|
|
183
|
-
|
|
199
|
+
// Every block node carries a unified "id" attr so blocks are addressable in
|
|
200
|
+
// collaborative editing and block-level APIs. paragraph/heading/code_block
|
|
201
|
+
// declare it in their own specs (mirrored into the deprecated "guid");
|
|
202
|
+
// check_list/check_item/columns/fiberyView/list_item already have "id".
|
|
203
|
+
// toDOM/parseDOM are deliberately left untouched here so pasted HTML never
|
|
204
|
+
// carries an id and cannot introduce duplicates.
|
|
205
|
+
const blocksNeedingId = [
|
|
206
|
+
"blockquote",
|
|
207
|
+
"horizontal_rule",
|
|
208
|
+
"bullet_list",
|
|
209
|
+
"ordered_list",
|
|
210
|
+
"table",
|
|
211
|
+
"note",
|
|
212
|
+
"important",
|
|
213
|
+
"callout",
|
|
214
|
+
"media",
|
|
215
|
+
"video",
|
|
216
|
+
"imageBlock",
|
|
217
|
+
"math_display",
|
|
218
|
+
"column",
|
|
219
|
+
];
|
|
220
|
+
for (const name of blocksNeedingId) {
|
|
221
|
+
const spec = actualNodes.get(name);
|
|
222
|
+
actualNodes = actualNodes.update(name, {
|
|
223
|
+
...spec,
|
|
224
|
+
attrs: { ...(spec.attrs ?? {}), id: { default: null } },
|
|
225
|
+
});
|
|
226
|
+
}
|
|
227
|
+
return new prosemirror_model_1.Schema({
|
|
184
228
|
nodes: actualNodes,
|
|
185
229
|
marks: base.spec.marks
|
|
186
|
-
.addToEnd("strike", strike)
|
|
187
|
-
.addToEnd("underline", underline)
|
|
188
|
-
.addToEnd("hintQuery", hintQuery)
|
|
230
|
+
.addToEnd("strike", strike_1.strike)
|
|
231
|
+
.addToEnd("underline", underline_1.underline)
|
|
232
|
+
.addToEnd("hintQuery", hint_query_1.hintQuery)
|
|
189
233
|
// We leave mark key as "highlight" only because we don't want to do migration.
|
|
190
234
|
// "TextBackgroundColor" term is used everywhere through codebase.
|
|
191
|
-
.addToEnd("highlight", textBackgroundColor)
|
|
192
|
-
.addToEnd("insertion", insertion)
|
|
193
|
-
.addToEnd("deletion", deletion)
|
|
194
|
-
.addToEnd("modification", modification),
|
|
235
|
+
.addToEnd("highlight", text_background_color_1.textBackgroundColor),
|
|
195
236
|
});
|
|
196
237
|
};
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
238
|
+
exports.createSchema = createSchema;
|
|
239
|
+
exports.Basic = {
|
|
240
|
+
nodes: prosemirror_schema_basic_1.nodes,
|
|
241
|
+
marks: prosemirror_schema_basic_1.marks,
|
|
200
242
|
fibery: {
|
|
201
|
-
link,
|
|
202
|
-
strike,
|
|
203
|
-
underline,
|
|
204
|
-
textBackgroundColor,
|
|
243
|
+
link: link_1.link,
|
|
244
|
+
strike: strike_1.strike,
|
|
245
|
+
underline: underline_1.underline,
|
|
246
|
+
textBackgroundColor: text_background_color_1.textBackgroundColor,
|
|
205
247
|
},
|
|
206
248
|
};
|
package/lib/src/marks/code.js
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.code = void 0;
|
|
1
4
|
const codeDOM = ["code", 0];
|
|
2
5
|
/**
|
|
3
6
|
Code font mark. Represented as a `<code>` element.
|
|
4
7
|
*/
|
|
5
|
-
|
|
8
|
+
exports.code = {
|
|
6
9
|
parseDOM: [{ tag: "code" }],
|
|
7
10
|
toDOM() {
|
|
8
11
|
return codeDOM;
|
package/lib/src/marks/em.js
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.em = void 0;
|
|
1
4
|
const emDOM = ["em", 0];
|
|
2
5
|
/**
|
|
3
6
|
An emphasis mark. Rendered as an `<em>` element. Has parse rules
|
|
4
7
|
that also match `<i>` and `font-style: italic`.
|
|
5
8
|
*/
|
|
6
|
-
|
|
9
|
+
exports.em = {
|
|
7
10
|
parseDOM: [
|
|
8
11
|
{ tag: "i" },
|
|
9
12
|
{ tag: "em" },
|
package/lib/src/marks/link.js
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.link = void 0;
|
|
1
4
|
const httpRegex = /^[-a-zA-Z0-9@:%._+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b[-a-zA-Z0-9()@:%_+.~#?&/=]*$/;
|
|
2
5
|
/**
|
|
3
6
|
A link. Has `href` and `title` attributes. `title`
|
|
4
7
|
defaults to the empty string. Rendered and parsed as an `<a>`
|
|
5
8
|
element.
|
|
6
9
|
*/
|
|
7
|
-
|
|
10
|
+
exports.link = {
|
|
8
11
|
attrs: {
|
|
9
12
|
href: {},
|
|
10
13
|
title: { default: null },
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.makeLinkedHighlightEntity = exports.makeLinkedHighlight = void 0;
|
|
1
4
|
const hyphenatePascal = (str) => str
|
|
2
5
|
.replace(/([a-z])([A-Z])/g, "$1-$2")
|
|
3
6
|
.replace(/([A-Z]{2})[a-z]/, "$1-")
|
|
@@ -45,11 +48,13 @@ const createMark = (markType, sharedColorGenerator) => {
|
|
|
45
48
|
},
|
|
46
49
|
};
|
|
47
50
|
};
|
|
48
|
-
|
|
51
|
+
const makeLinkedHighlight = ({ sharedColorGenerator }) => {
|
|
49
52
|
// @ts-expect-error todo: fix this
|
|
50
53
|
return createMark("linkedhighlight", sharedColorGenerator);
|
|
51
54
|
};
|
|
52
|
-
|
|
55
|
+
exports.makeLinkedHighlight = makeLinkedHighlight;
|
|
56
|
+
const makeLinkedHighlightEntity = ({ sharedColorGenerator }) => {
|
|
53
57
|
// @ts-expect-error todo: fix this
|
|
54
58
|
return createMark("linkedhighlightentity", sharedColorGenerator);
|
|
55
59
|
};
|
|
60
|
+
exports.makeLinkedHighlightEntity = makeLinkedHighlightEntity;
|
package/lib/src/marks/strike.js
CHANGED
package/lib/src/marks/strong.js
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.strong = void 0;
|
|
1
4
|
const strongDOM = ["strong", 0];
|
|
2
5
|
/**
|
|
3
6
|
A strong mark. Rendered as `<strong>`, parse rules also match
|
|
4
7
|
`<b>` and `font-weight: bold`.
|
|
5
8
|
*/
|
|
6
|
-
|
|
9
|
+
exports.strong = {
|
|
7
10
|
parseDOM: [
|
|
8
11
|
{ tag: "strong" },
|
|
9
12
|
// This works around a Google Docs misbehavior where
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.textBackgroundColor = void 0;
|
|
1
4
|
var ColorToken;
|
|
2
5
|
(function (ColorToken) {
|
|
3
6
|
ColorToken["Yellow"] = "YELLOW";
|
|
@@ -48,7 +51,7 @@ const getClassName = (bgColorToken, fgColorToken) => {
|
|
|
48
51
|
.filter(Boolean)
|
|
49
52
|
.join(` `);
|
|
50
53
|
};
|
|
51
|
-
|
|
54
|
+
exports.textBackgroundColor = {
|
|
52
55
|
attrs: {
|
|
53
56
|
guid: { default: "" },
|
|
54
57
|
color: { default: undefined },
|
package/lib/src/nodes/callout.js
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.callout = void 0;
|
|
1
4
|
const nodeType = "data-callout-node";
|
|
2
|
-
|
|
5
|
+
exports.callout = {
|
|
3
6
|
attrs: {
|
|
4
7
|
color: { default: "#199EE3" },
|
|
5
8
|
iconType: { default: "icon" },
|
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.check_item = void 0;
|
|
4
|
+
const uuid_1 = require("uuid");
|
|
5
|
+
exports.check_item = {
|
|
3
6
|
content: "inline*",
|
|
4
7
|
defining: true,
|
|
5
8
|
selectable: true,
|
|
@@ -15,7 +18,7 @@ export const check_item = {
|
|
|
15
18
|
// also used by list-item we need to make sure that we run this parser first.
|
|
16
19
|
priority: 100,
|
|
17
20
|
getAttrs: (dom) => ({
|
|
18
|
-
id:
|
|
21
|
+
id: (0, uuid_1.v4)(),
|
|
19
22
|
state: dom.getAttribute("data-check-item-state"),
|
|
20
23
|
}),
|
|
21
24
|
},
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { NodeSpec } from "prosemirror-model";
|
|
2
|
-
import type { CheckItemDefinition } from "./check-item
|
|
2
|
+
import type { CheckItemDefinition } from "./check-item";
|
|
3
3
|
export interface CheckListContent extends Array<CheckItemDefinition | CheckListDefinition> {
|
|
4
4
|
0: CheckItemDefinition;
|
|
5
5
|
}
|
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.check_list = void 0;
|
|
4
|
+
const uuid_1 = require("uuid");
|
|
5
|
+
exports.check_list = {
|
|
3
6
|
group: "block",
|
|
4
7
|
defining: true,
|
|
5
8
|
selectable: true,
|
|
@@ -14,7 +17,7 @@ export const check_list = {
|
|
|
14
17
|
// also used by ordered-list we need to make sure that we run this parser first.
|
|
15
18
|
priority: 100,
|
|
16
19
|
getAttrs: () => ({
|
|
17
|
-
id:
|
|
20
|
+
id: (0, uuid_1.v4)(),
|
|
18
21
|
}),
|
|
19
22
|
},
|
|
20
23
|
],
|
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.code_block = void 0;
|
|
4
|
+
const uuid_1 = require("uuid");
|
|
5
|
+
const resizable_node_attrs_1 = require("../resizable-node-attrs");
|
|
3
6
|
const getLanguageFromEditorStyle = (dom) => {
|
|
4
7
|
return dom.getAttribute("data-language") || undefined;
|
|
5
8
|
};
|
|
@@ -35,7 +38,7 @@ const removeLastNewLine = (dom) => {
|
|
|
35
38
|
}
|
|
36
39
|
return dom;
|
|
37
40
|
};
|
|
38
|
-
|
|
41
|
+
exports.code_block = {
|
|
39
42
|
content: "text*",
|
|
40
43
|
marks: "linkedhighlightentity linkedhighlight",
|
|
41
44
|
group: "block",
|
|
@@ -43,11 +46,14 @@ export const code_block = {
|
|
|
43
46
|
isolating: true,
|
|
44
47
|
defining: true,
|
|
45
48
|
attrs: {
|
|
49
|
+
// "id" is the unified block identifier; "guid" is deprecated and mirrors
|
|
50
|
+
// "id" until all consumers (client editor, fibery backend) read "id".
|
|
51
|
+
id: { default: null },
|
|
46
52
|
guid: { default: "" },
|
|
47
53
|
language: { default: null },
|
|
48
54
|
wrapCode: { default: false },
|
|
49
55
|
mode: { default: "split" },
|
|
50
|
-
...createDefaultAttrs(),
|
|
56
|
+
...(0, resizable_node_attrs_1.createDefaultAttrs)(),
|
|
51
57
|
},
|
|
52
58
|
parseDOM: [
|
|
53
59
|
{
|
|
@@ -55,7 +61,7 @@ export const code_block = {
|
|
|
55
61
|
preserveWhitespace: "full",
|
|
56
62
|
getAttrs: (domNode) => {
|
|
57
63
|
const dom = domNode;
|
|
58
|
-
const
|
|
64
|
+
const id = dom.getAttribute("data-guid") || (0, uuid_1.v4)();
|
|
59
65
|
const language = getLanguageFromBitbucketStyle(dom.parentElement) ||
|
|
60
66
|
getLanguageFromEditorStyle(dom.parentElement) ||
|
|
61
67
|
getLanguageFromCode(dom) ||
|
|
@@ -63,7 +69,14 @@ export const code_block = {
|
|
|
63
69
|
const wrapCodeAttr = dom.getAttribute("data-wrap-code");
|
|
64
70
|
const wrapCode = wrapCodeAttr === "true";
|
|
65
71
|
removeLastNewLine(dom);
|
|
66
|
-
return {
|
|
72
|
+
return {
|
|
73
|
+
id,
|
|
74
|
+
guid: id,
|
|
75
|
+
language,
|
|
76
|
+
wrapCode,
|
|
77
|
+
mode: dom.getAttribute("data-mode") || "split",
|
|
78
|
+
...(0, resizable_node_attrs_1.createParseDomAttrs)(dom),
|
|
79
|
+
};
|
|
67
80
|
},
|
|
68
81
|
},
|
|
69
82
|
// Handle GitHub/Gist paste
|
|
@@ -79,17 +92,18 @@ export const code_block = {
|
|
|
79
92
|
},
|
|
80
93
|
],
|
|
81
94
|
toDOM(node) {
|
|
82
|
-
const
|
|
95
|
+
const id = node.attrs.id || node.attrs.guid || "";
|
|
83
96
|
return [
|
|
84
97
|
"pre",
|
|
85
98
|
[
|
|
86
99
|
"code",
|
|
87
100
|
{
|
|
88
101
|
"data-language": node.attrs.language,
|
|
89
|
-
"data-
|
|
102
|
+
"data-id": id,
|
|
103
|
+
"data-guid": id,
|
|
90
104
|
"data-wrap-code": node.attrs.wrapCode || false,
|
|
91
105
|
"data-mode": node.attrs.mode || "split",
|
|
92
|
-
...createToDomAttrs(node.attrs),
|
|
106
|
+
...(0, resizable_node_attrs_1.createToDomAttrs)(node.attrs),
|
|
93
107
|
},
|
|
94
108
|
0,
|
|
95
109
|
],
|
package/lib/src/nodes/column.js
CHANGED
package/lib/src/nodes/columns.js
CHANGED
|
@@ -1,18 +1,21 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.columns = void 0;
|
|
4
|
+
const resizable_node_attrs_1 = require("../resizable-node-attrs");
|
|
5
|
+
exports.columns = {
|
|
3
6
|
content: "column+",
|
|
4
7
|
selectable: true,
|
|
5
8
|
draggable: false,
|
|
6
9
|
attrs: {
|
|
7
10
|
id: { default: "" },
|
|
8
|
-
...createDefaultAttrs(),
|
|
11
|
+
...(0, resizable_node_attrs_1.createDefaultAttrs)(),
|
|
9
12
|
},
|
|
10
13
|
parseDOM: [
|
|
11
14
|
{
|
|
12
15
|
tag: "div.fibery-columns-node",
|
|
13
16
|
getAttrs: (domNode) => {
|
|
14
17
|
const dom = domNode;
|
|
15
|
-
return createParseDomAttrs(dom);
|
|
18
|
+
return (0, resizable_node_attrs_1.createParseDomAttrs)(dom);
|
|
16
19
|
},
|
|
17
20
|
},
|
|
18
21
|
],
|
|
@@ -27,7 +30,7 @@ export const columns = {
|
|
|
27
30
|
const attrs = {
|
|
28
31
|
class: "fibery-columns-node",
|
|
29
32
|
style: `display: grid; gap: 46px; grid-template-columns: ${gridTemplateColumns}`,
|
|
30
|
-
...createToDomAttrs(node.attrs),
|
|
33
|
+
...(0, resizable_node_attrs_1.createToDomAttrs)(node.attrs),
|
|
31
34
|
};
|
|
32
35
|
return ["div", attrs, 0];
|
|
33
36
|
},
|
package/lib/src/nodes/emoji.js
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.makeEmoji = void 0;
|
|
1
4
|
const typeAttr = "data-emoji-node";
|
|
2
5
|
const codeAttr = "data-emoji-code";
|
|
3
6
|
const defaultOptions = {
|
|
@@ -5,7 +8,7 @@ const defaultOptions = {
|
|
|
5
8
|
return;
|
|
6
9
|
},
|
|
7
10
|
};
|
|
8
|
-
|
|
11
|
+
const makeEmoji = ({ getEmoji } = defaultOptions) => ({
|
|
9
12
|
attrs: {
|
|
10
13
|
code: {},
|
|
11
14
|
},
|
|
@@ -45,3 +48,4 @@ export const makeEmoji = ({ getEmoji } = defaultOptions) => ({
|
|
|
45
48
|
return ["span", attrs, emoji ? emoji.native || `:${emoji.shortNames[0]}:` : code];
|
|
46
49
|
},
|
|
47
50
|
});
|
|
51
|
+
exports.makeEmoji = makeEmoji;
|
package/lib/src/nodes/entity.js
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.fiberyView = void 0;
|
|
4
|
+
const resizable_node_attrs_1 = require("../resizable-node-attrs");
|
|
5
|
+
exports.fiberyView = {
|
|
3
6
|
inline: false,
|
|
4
7
|
group: "block",
|
|
5
8
|
selectable: true,
|
|
@@ -7,7 +10,7 @@ export const fiberyView = {
|
|
|
7
10
|
draggable: false,
|
|
8
11
|
attrs: {
|
|
9
12
|
id: { default: "" },
|
|
10
|
-
...createDefaultAttrs(),
|
|
13
|
+
...(0, resizable_node_attrs_1.createDefaultAttrs)(),
|
|
11
14
|
},
|
|
12
15
|
parseDOM: [
|
|
13
16
|
{
|
|
@@ -16,7 +19,7 @@ export const fiberyView = {
|
|
|
16
19
|
const dom = domNode;
|
|
17
20
|
return {
|
|
18
21
|
id: dom.getAttribute("data-view-id"),
|
|
19
|
-
...createParseDomAttrs(dom),
|
|
22
|
+
...(0, resizable_node_attrs_1.createParseDomAttrs)(dom),
|
|
20
23
|
};
|
|
21
24
|
},
|
|
22
25
|
},
|
|
@@ -26,7 +29,7 @@ export const fiberyView = {
|
|
|
26
29
|
const attrs = {
|
|
27
30
|
"data-view-id": id,
|
|
28
31
|
contenteditable: "false",
|
|
29
|
-
...createToDomAttrs(node.attrs),
|
|
32
|
+
...(0, resizable_node_attrs_1.createToDomAttrs)(node.attrs),
|
|
30
33
|
};
|
|
31
34
|
return ["div", attrs, ""];
|
|
32
35
|
},
|
package/lib/src/nodes/file.js
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.file = void 0;
|
|
4
|
+
const transcription_node_attrs_1 = require("../transcription-node-attrs");
|
|
5
|
+
exports.file = {
|
|
3
6
|
attrs: {
|
|
4
7
|
src: {},
|
|
5
8
|
title: { default: "Untitled" },
|
|
6
9
|
size: {},
|
|
7
10
|
type: {},
|
|
8
|
-
...createDefaultAttrs(),
|
|
11
|
+
...(0, transcription_node_attrs_1.createDefaultAttrs)(),
|
|
9
12
|
},
|
|
10
13
|
inline: true,
|
|
11
14
|
group: "inline",
|
package/lib/src/nodes/heading.js
CHANGED
|
@@ -1,13 +1,22 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.makeHeading = void 0;
|
|
4
|
+
const uuid_1 = require("uuid");
|
|
2
5
|
const parseGuid = (dom) => {
|
|
3
|
-
return dom.getAttribute("guid") || v4();
|
|
6
|
+
return dom.getAttribute("guid") || (0, uuid_1.v4)();
|
|
4
7
|
};
|
|
5
|
-
const makeGetAttrs = (level) => (dom) =>
|
|
6
|
-
|
|
8
|
+
const makeGetAttrs = (level) => (dom) => {
|
|
9
|
+
const id = parseGuid(dom);
|
|
10
|
+
return { level, id, guid: id };
|
|
11
|
+
};
|
|
12
|
+
const makeHeading = ({ headingToDOM }) => ({
|
|
7
13
|
content: "inline*",
|
|
8
14
|
group: "block",
|
|
9
15
|
attrs: {
|
|
10
16
|
level: { default: 1 },
|
|
17
|
+
// "id" is the unified block identifier; "guid" is deprecated and mirrors
|
|
18
|
+
// "id" until all consumers (client editor, fibery backend) read "id".
|
|
19
|
+
id: { default: null },
|
|
11
20
|
guid: { default: "" },
|
|
12
21
|
},
|
|
13
22
|
defining: true,
|
|
@@ -23,7 +32,8 @@ export const makeHeading = ({ headingToDOM }) => ({
|
|
|
23
32
|
if (headingToDOM) {
|
|
24
33
|
return headingToDOM(node);
|
|
25
34
|
}
|
|
26
|
-
const
|
|
27
|
-
return ["h" + node.attrs.level, { guid }, 0];
|
|
35
|
+
const id = node.attrs.id || node.attrs.guid;
|
|
36
|
+
return ["h" + node.attrs.level, { "data-id": id, guid: id }, 0];
|
|
28
37
|
},
|
|
29
38
|
});
|
|
39
|
+
exports.makeHeading = makeHeading;
|
|
@@ -1,12 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.imageBlock = void 0;
|
|
4
|
+
const resizable_node_attrs_1 = require("../resizable-node-attrs");
|
|
5
|
+
exports.imageBlock = {
|
|
3
6
|
attrs: {
|
|
4
7
|
src: {},
|
|
5
8
|
alt: { default: null },
|
|
6
9
|
title: { default: null },
|
|
7
10
|
size: { default: null },
|
|
8
11
|
type: { default: null },
|
|
9
|
-
...createDefaultAttrs(),
|
|
12
|
+
...(0, resizable_node_attrs_1.createDefaultAttrs)(),
|
|
10
13
|
},
|
|
11
14
|
inline: false,
|
|
12
15
|
group: "block",
|
|
@@ -22,7 +25,7 @@ export const imageBlock = {
|
|
|
22
25
|
src: dom.getAttribute("src"),
|
|
23
26
|
title: dom.getAttribute("title"),
|
|
24
27
|
alt: dom.getAttribute("alt"),
|
|
25
|
-
...createParseDomAttrs(dom),
|
|
28
|
+
...(0, resizable_node_attrs_1.createParseDomAttrs)(dom),
|
|
26
29
|
};
|
|
27
30
|
},
|
|
28
31
|
},
|
|
@@ -33,7 +36,7 @@ export const imageBlock = {
|
|
|
33
36
|
src,
|
|
34
37
|
alt,
|
|
35
38
|
title,
|
|
36
|
-
...createToDomAttrs(node.attrs),
|
|
39
|
+
...(0, resizable_node_attrs_1.createToDomAttrs)(node.attrs),
|
|
37
40
|
};
|
|
38
41
|
return ["div", {}, ["img", attrs]];
|
|
39
42
|
},
|
package/lib/src/nodes/media.js
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.makeMedia = void 0;
|
|
4
|
+
const resizable_node_attrs_1 = require("../resizable-node-attrs");
|
|
2
5
|
function toBoolean(attr) {
|
|
3
6
|
if (typeof attr === "boolean") {
|
|
4
7
|
return attr;
|
|
@@ -20,7 +23,7 @@ function toNumberOrNull(value) {
|
|
|
20
23
|
const parsed = parseFloat(value);
|
|
21
24
|
return isNaN(parsed) ? null : parsed;
|
|
22
25
|
}
|
|
23
|
-
|
|
26
|
+
const makeMedia = ({ mediaToDom }) => ({
|
|
24
27
|
inline: false,
|
|
25
28
|
attrs: {
|
|
26
29
|
url: {},
|
|
@@ -33,7 +36,7 @@ export const makeMedia = ({ mediaToDom }) => ({
|
|
|
33
36
|
aspectRatio: {
|
|
34
37
|
default: null,
|
|
35
38
|
},
|
|
36
|
-
...createDefaultAttrs(),
|
|
39
|
+
...(0, resizable_node_attrs_1.createDefaultAttrs)(),
|
|
37
40
|
},
|
|
38
41
|
group: "block",
|
|
39
42
|
draggable: true,
|
|
@@ -47,7 +50,7 @@ export const makeMedia = ({ mediaToDom }) => ({
|
|
|
47
50
|
dynamicContent: htmlElement.getAttribute("data-dynamic-content") !== "false",
|
|
48
51
|
aspectRatio: toNumberOrNull(htmlElement.getAttribute("data-aspect-ratio")),
|
|
49
52
|
compatibleMode: toBoolean(htmlElement.getAttribute("data-compatible-mode")),
|
|
50
|
-
...createParseDomAttrs(htmlElement),
|
|
53
|
+
...(0, resizable_node_attrs_1.createParseDomAttrs)(htmlElement),
|
|
51
54
|
};
|
|
52
55
|
},
|
|
53
56
|
},
|
|
@@ -63,8 +66,9 @@ export const makeMedia = ({ mediaToDom }) => ({
|
|
|
63
66
|
"data-dynamic-content": typeof dynamicContent === "boolean" ? String(dynamicContent) : "false",
|
|
64
67
|
"data-aspect-ratio": aspectRatio,
|
|
65
68
|
contenteditable: "false",
|
|
66
|
-
...createToDomAttrs(node),
|
|
69
|
+
...(0, resizable_node_attrs_1.createToDomAttrs)(node),
|
|
67
70
|
};
|
|
68
71
|
return ["div", attrs, url];
|
|
69
72
|
},
|
|
70
73
|
});
|
|
74
|
+
exports.makeMedia = makeMedia;
|
package/lib/src/nodes/mention.js
CHANGED
package/lib/src/nodes/note.js
CHANGED
|
@@ -1,20 +1,27 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.paragraph = void 0;
|
|
4
|
+
const uuid_1 = require("uuid");
|
|
5
|
+
exports.paragraph = {
|
|
3
6
|
content: "inline*",
|
|
4
7
|
group: "block",
|
|
5
8
|
attrs: {
|
|
9
|
+
// "id" is the unified block identifier; "guid" is deprecated and mirrors
|
|
10
|
+
// "id" until all consumers (client editor, fibery backend) read "id".
|
|
11
|
+
id: { default: null },
|
|
6
12
|
guid: { default: "" },
|
|
7
13
|
},
|
|
8
14
|
parseDOM: [
|
|
9
15
|
{
|
|
10
16
|
tag: "p",
|
|
11
|
-
getAttrs: (dom) =>
|
|
12
|
-
|
|
13
|
-
|
|
17
|
+
getAttrs: (dom) => {
|
|
18
|
+
const id = dom.getAttribute("data-guid") || (0, uuid_1.v4)();
|
|
19
|
+
return { id, guid: id };
|
|
20
|
+
},
|
|
14
21
|
},
|
|
15
22
|
],
|
|
16
23
|
toDOM(node) {
|
|
17
|
-
const
|
|
18
|
-
return ["p", { "data-
|
|
24
|
+
const id = node.attrs.id || node.attrs.guid;
|
|
25
|
+
return ["p", { "data-id": id, "data-guid": id }, 0];
|
|
19
26
|
},
|
|
20
27
|
};
|
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.tableNodes = void 0;
|
|
4
|
+
const prosemirror_tables_1 = require("prosemirror-tables");
|
|
5
|
+
exports.tableNodes = (0, prosemirror_tables_1.tableNodes)({
|
|
3
6
|
tableGroup: "block",
|
|
4
7
|
cellContent: "block+",
|
|
5
8
|
cellAttributes: {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { EntityDefinition as Entity } from "../entity
|
|
2
|
-
import type { MentionDefinition as Mention } from "../mention
|
|
3
|
-
import type { 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
|
}
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
package/lib/src/nodes/video.js
CHANGED
|
@@ -1,18 +1,21 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.video = exports.DEFAULT_VIDEO_HEIGHT = exports.DEFAULT_VIDEO_WIDTH = void 0;
|
|
4
|
+
const resizable_node_attrs_1 = require("../resizable-node-attrs");
|
|
5
|
+
const transcription_node_attrs_1 = require("../transcription-node-attrs");
|
|
6
|
+
exports.DEFAULT_VIDEO_WIDTH = 400;
|
|
7
|
+
exports.DEFAULT_VIDEO_HEIGHT = 200;
|
|
8
|
+
exports.video = {
|
|
6
9
|
inline: false,
|
|
7
10
|
attrs: {
|
|
8
11
|
src: {},
|
|
9
12
|
type: {},
|
|
10
|
-
width: { default: DEFAULT_VIDEO_WIDTH },
|
|
11
|
-
height: { default: DEFAULT_VIDEO_HEIGHT },
|
|
13
|
+
width: { default: exports.DEFAULT_VIDEO_WIDTH },
|
|
14
|
+
height: { default: exports.DEFAULT_VIDEO_HEIGHT },
|
|
12
15
|
title: { default: "" },
|
|
13
16
|
alignment: { default: ":alignment/block-center" },
|
|
14
|
-
...createDefaultAttrs(),
|
|
15
|
-
...
|
|
17
|
+
...(0, resizable_node_attrs_1.createDefaultAttrs)(),
|
|
18
|
+
...(0, transcription_node_attrs_1.createDefaultAttrs)(),
|
|
16
19
|
},
|
|
17
20
|
group: "block",
|
|
18
21
|
draggable: true,
|
|
@@ -24,16 +27,16 @@ export const video = {
|
|
|
24
27
|
return {
|
|
25
28
|
src: dom.getAttribute("src"),
|
|
26
29
|
type: dom.getAttribute("type"),
|
|
27
|
-
width: Number(dom.getAttribute("width")) || DEFAULT_VIDEO_WIDTH,
|
|
28
|
-
height: Number(dom.getAttribute("height")) || DEFAULT_VIDEO_HEIGHT,
|
|
30
|
+
width: Number(dom.getAttribute("width")) || exports.DEFAULT_VIDEO_WIDTH,
|
|
31
|
+
height: Number(dom.getAttribute("height")) || exports.DEFAULT_VIDEO_HEIGHT,
|
|
29
32
|
title: dom.getAttribute("title"),
|
|
30
|
-
...createParseDomAttrs(dom),
|
|
33
|
+
...(0, resizable_node_attrs_1.createParseDomAttrs)(dom),
|
|
31
34
|
};
|
|
32
35
|
},
|
|
33
36
|
},
|
|
34
37
|
],
|
|
35
38
|
toDOM(node) {
|
|
36
|
-
const { src, type, width = DEFAULT_VIDEO_WIDTH, height = DEFAULT_VIDEO_HEIGHT, title } = node.attrs;
|
|
39
|
+
const { src, type, width = exports.DEFAULT_VIDEO_WIDTH, height = exports.DEFAULT_VIDEO_HEIGHT, title } = node.attrs;
|
|
37
40
|
return [
|
|
38
41
|
"video",
|
|
39
42
|
{
|
|
@@ -45,7 +48,7 @@ export const video = {
|
|
|
45
48
|
playsinline: "",
|
|
46
49
|
controls: "",
|
|
47
50
|
preload: "metadata",
|
|
48
|
-
...createToDomAttrs(node.attrs),
|
|
51
|
+
...(0, resizable_node_attrs_1.createToDomAttrs)(node.attrs),
|
|
49
52
|
},
|
|
50
53
|
];
|
|
51
54
|
},
|
|
@@ -1,12 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.defaultWidth = exports.defaultHeight = void 0;
|
|
4
|
+
exports.createDefaultAttrs = createDefaultAttrs;
|
|
5
|
+
exports.createParseDomAttrs = createParseDomAttrs;
|
|
6
|
+
exports.createToDomAttrs = createToDomAttrs;
|
|
7
|
+
exports.defaultHeight = 400;
|
|
8
|
+
exports.defaultWidth = 900;
|
|
9
|
+
function createDefaultAttrs() {
|
|
4
10
|
return {
|
|
5
11
|
nodeHeight: {
|
|
6
|
-
default: defaultHeight,
|
|
12
|
+
default: exports.defaultHeight,
|
|
7
13
|
},
|
|
8
14
|
nodeWidth: {
|
|
9
|
-
default: defaultWidth,
|
|
15
|
+
default: exports.defaultWidth,
|
|
10
16
|
},
|
|
11
17
|
nodePageWidth: {
|
|
12
18
|
default: true,
|
|
@@ -16,7 +22,7 @@ export function createDefaultAttrs() {
|
|
|
16
22
|
},
|
|
17
23
|
};
|
|
18
24
|
}
|
|
19
|
-
|
|
25
|
+
function createParseDomAttrs(dom) {
|
|
20
26
|
return {
|
|
21
27
|
nodeHeight: dom.getAttribute("data-node-height"),
|
|
22
28
|
nodeWidth: dom.getAttribute("data-node-width"),
|
|
@@ -24,7 +30,7 @@ export function createParseDomAttrs(dom) {
|
|
|
24
30
|
nodeFullWidth: dom.getAttribute("data-node-full-width"),
|
|
25
31
|
};
|
|
26
32
|
}
|
|
27
|
-
|
|
33
|
+
function createToDomAttrs({ nodeHeight, nodeWidth, nodePageWidth, nodeFullWidth }) {
|
|
28
34
|
return {
|
|
29
35
|
"data-node-height": nodeHeight,
|
|
30
36
|
"data-node-width": nodeWidth,
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createDefaultAttrs = createDefaultAttrs;
|
|
4
|
+
function createDefaultAttrs() {
|
|
2
5
|
return {
|
|
3
6
|
transcription: {
|
|
4
7
|
default: { status: "IDLE", userId: "", inserted: false },
|
|
@@ -1,15 +1,21 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.toHTML = exports.toDOM = exports.fromHTML = void 0;
|
|
4
|
+
const prosemirror_model_1 = require("prosemirror-model");
|
|
5
|
+
const fromHTML = (html, schema, options) => {
|
|
3
6
|
const el = document.createElement("div");
|
|
4
7
|
el.innerHTML = html;
|
|
5
|
-
return DOMParser.fromSchema(schema).parse(el, options);
|
|
8
|
+
return prosemirror_model_1.DOMParser.fromSchema(schema).parse(el, options);
|
|
6
9
|
};
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
+
exports.fromHTML = fromHTML;
|
|
11
|
+
const toDOM = (node, schema) => {
|
|
12
|
+
const serializer = prosemirror_model_1.DOMSerializer.fromSchema(schema);
|
|
13
|
+
return serializer.serializeFragment(prosemirror_model_1.Fragment.from(node));
|
|
10
14
|
};
|
|
11
|
-
|
|
15
|
+
exports.toDOM = toDOM;
|
|
16
|
+
const toHTML = (node, schema) => {
|
|
12
17
|
const el = document.createElement("div");
|
|
13
|
-
el.appendChild(toDOM(node, schema));
|
|
18
|
+
el.appendChild((0, exports.toDOM)(node, schema));
|
|
14
19
|
return el.innerHTML;
|
|
15
20
|
};
|
|
21
|
+
exports.toHTML = toHTML;
|
package/package.json
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fibery/prosemirror-schema",
|
|
3
|
-
"version": "4.19.0-next.
|
|
3
|
+
"version": "4.19.0-next.3",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Fibery prosemirror schema",
|
|
6
6
|
"files": [
|
|
7
7
|
"/lib"
|
|
8
8
|
],
|
|
9
|
-
"type": "module",
|
|
10
9
|
"main": "./lib/index.js",
|
|
11
10
|
"exports": {
|
|
12
11
|
".": {
|
|
@@ -23,29 +22,29 @@
|
|
|
23
22
|
"./lib/src/nodes/fibery-section.d.ts": "./lib/src/nodes/fibery-section.d.ts"
|
|
24
23
|
},
|
|
25
24
|
"dependencies": {
|
|
26
|
-
"@handlewithcare/prosemirror-suggest-changes": "^0.1.8",
|
|
27
25
|
"prosemirror-model": "1.25.4",
|
|
28
26
|
"prosemirror-schema-basic": "1.2.2",
|
|
29
27
|
"prosemirror-schema-list": "1.5.1",
|
|
30
|
-
"prosemirror-tables": "1.
|
|
28
|
+
"prosemirror-tables": "1.8.5",
|
|
31
29
|
"uuid": "11.1.0"
|
|
32
30
|
},
|
|
33
31
|
"devDependencies": {
|
|
34
|
-
"typescript": "
|
|
32
|
+
"typescript": "rc",
|
|
35
33
|
"@fibery/babel-preset": "7.4.2"
|
|
36
34
|
},
|
|
37
35
|
"peerDependencies": {
|
|
38
36
|
"prosemirror-model": "1.25.4",
|
|
39
37
|
"prosemirror-schema-list": "1.5.1",
|
|
40
|
-
"prosemirror-tables": "1.
|
|
38
|
+
"prosemirror-tables": "1.8.5"
|
|
41
39
|
},
|
|
42
40
|
"scripts": {
|
|
43
41
|
"build": "rm -rf lib && tsc --project tsconfig.build.json",
|
|
44
42
|
"test": "../../scripts/test.sh",
|
|
45
43
|
"test:ci": "../../scripts/test.sh --ci",
|
|
46
44
|
"test:coverage": "../../scripts/test.sh --ci --coverage",
|
|
47
|
-
"
|
|
48
|
-
"
|
|
45
|
+
"lint": "pnpm -w lint .",
|
|
46
|
+
"typecheck": "../../scripts/typecheck.sh",
|
|
47
|
+
"check": "../../scripts/check.sh"
|
|
49
48
|
},
|
|
50
49
|
"types": "./lib/index.d.ts"
|
|
51
50
|
}
|