@fibery/prosemirror-schema 4.19.0-next.0 → 4.19.0-next.2
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 +4 -15
- package/lib/src/create-schema.d.ts +1 -1
- package/lib/src/create-schema.js +81 -85
- package/lib/src/marks/code.js +1 -4
- package/lib/src/marks/em.js +1 -4
- package/lib/src/marks/hint-query.js +1 -4
- package/lib/src/marks/link.js +1 -4
- package/lib/src/marks/linked-highlight.js +2 -7
- package/lib/src/marks/strike.js +1 -4
- package/lib/src/marks/strong.js +1 -4
- package/lib/src/marks/text-background-color.js +1 -4
- package/lib/src/marks/underline.js +1 -4
- package/lib/src/nodes/callout.d.ts +1 -1
- package/lib/src/nodes/callout.js +1 -4
- package/lib/src/nodes/check-item.d.ts +1 -1
- package/lib/src/nodes/check-item.js +3 -6
- package/lib/src/nodes/check-list.d.ts +1 -1
- package/lib/src/nodes/check-list.js +3 -6
- package/lib/src/nodes/code-block.js +7 -10
- package/lib/src/nodes/column.js +1 -4
- package/lib/src/nodes/columns.js +5 -8
- package/lib/src/nodes/emoji.d.ts +2 -2
- package/lib/src/nodes/emoji.js +1 -5
- package/lib/src/nodes/entity.js +1 -4
- package/lib/src/nodes/fibery-view.js +5 -8
- package/lib/src/nodes/file.d.ts +2 -2
- package/lib/src/nodes/file.js +3 -6
- package/lib/src/nodes/heading.js +3 -7
- package/lib/src/nodes/image-block.js +5 -8
- package/lib/src/nodes/important.js +1 -4
- package/lib/src/nodes/math-display.js +1 -4
- package/lib/src/nodes/math-inline.js +1 -4
- package/lib/src/nodes/media.js +5 -9
- package/lib/src/nodes/mention.js +1 -4
- package/lib/src/nodes/note.js +1 -4
- package/lib/src/nodes/paragraph.js +3 -6
- package/lib/src/nodes/table-nodes.js +2 -5
- package/lib/src/nodes/types/inline-content.d.ts +3 -3
- package/lib/src/nodes/types/inline-content.js +1 -2
- package/lib/src/nodes/types/text.js +1 -2
- package/lib/src/nodes/video.js +14 -17
- package/lib/src/resizable-node-attrs.js +7 -13
- package/lib/src/transcription-node-attrs.js +1 -4
- package/lib/test-helpers/index.js +8 -14
- package/package.json +2 -1
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.js";
|
|
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.js";
|
|
4
|
+
export { DEFAULT_VIDEO_WIDTH, DEFAULT_VIDEO_HEIGHT } from "./src/nodes/video.js";
|
|
5
|
+
export type { EmojiOptions } from "./src/nodes/emoji.js";
|
package/lib/index.js
CHANGED
|
@@ -1,15 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
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
|
+
export { defaultHeight, defaultWidth } from "./src/resizable-node-attrs.js";
|
|
2
|
+
export { Node, Schema } from "prosemirror-model";
|
|
3
|
+
export { createSchema, Basic } from "./src/create-schema.js";
|
|
4
|
+
export { DEFAULT_VIDEO_WIDTH, DEFAULT_VIDEO_HEIGHT } from "./src/nodes/video.js";
|
|
@@ -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.js";
|
|
4
4
|
type Params = {
|
|
5
5
|
isImageBlockEnabled?: boolean;
|
|
6
6
|
fiberyViewEnabled?: boolean;
|
package/lib/src/create-schema.js
CHANGED
|
@@ -1,83 +1,80 @@
|
|
|
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
|
-
const
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
prosemirror_schema_basic_1.nodes.heading = (0, heading_1.makeHeading)({ headingToDOM });
|
|
42
|
-
const base = new prosemirror_model_1.Schema({
|
|
43
|
-
nodes: prosemirror_schema_basic_1.nodes,
|
|
1
|
+
import { deletion, insertion, modification } from "@handlewithcare/prosemirror-suggest-changes";
|
|
2
|
+
import { Schema } from "prosemirror-model";
|
|
3
|
+
import { marks, nodes } from "prosemirror-schema-basic";
|
|
4
|
+
import { addListNodes } from "prosemirror-schema-list";
|
|
5
|
+
import { code } from "./marks/code.js";
|
|
6
|
+
import { em } from "./marks/em.js";
|
|
7
|
+
import { hintQuery } from "./marks/hint-query.js";
|
|
8
|
+
import { link } from "./marks/link.js";
|
|
9
|
+
import { makeLinkedHighlight, makeLinkedHighlightEntity } from "./marks/linked-highlight.js";
|
|
10
|
+
import { strike } from "./marks/strike.js";
|
|
11
|
+
import { strong } from "./marks/strong.js";
|
|
12
|
+
import { textBackgroundColor } from "./marks/text-background-color.js";
|
|
13
|
+
import { underline } from "./marks/underline.js";
|
|
14
|
+
import { callout } from "./nodes/callout.js";
|
|
15
|
+
import { check_item } from "./nodes/check-item.js";
|
|
16
|
+
import { check_list } from "./nodes/check-list.js";
|
|
17
|
+
import { code_block } from "./nodes/code-block.js";
|
|
18
|
+
import { column } from "./nodes/column.js";
|
|
19
|
+
import { columns } from "./nodes/columns.js";
|
|
20
|
+
import { makeEmoji } from "./nodes/emoji.js";
|
|
21
|
+
import { entity } from "./nodes/entity.js";
|
|
22
|
+
import { fiberyView } from "./nodes/fibery-view.js";
|
|
23
|
+
import { file } from "./nodes/file.js";
|
|
24
|
+
import { makeHeading } from "./nodes/heading.js";
|
|
25
|
+
import { imageBlock } from "./nodes/image-block.js";
|
|
26
|
+
import { important } from "./nodes/important.js";
|
|
27
|
+
import { math_display } from "./nodes/math-display.js";
|
|
28
|
+
import { math_inline } from "./nodes/math-inline.js";
|
|
29
|
+
import { makeMedia } from "./nodes/media.js";
|
|
30
|
+
import { mention } from "./nodes/mention.js";
|
|
31
|
+
import { note } from "./nodes/note.js";
|
|
32
|
+
import { paragraph } from "./nodes/paragraph.js";
|
|
33
|
+
import { tableNodes } from "./nodes/table-nodes.js";
|
|
34
|
+
import { video } from "./nodes/video.js";
|
|
35
|
+
export const createSchema = ({ sharedColorGenerator = null, headingToDOM = null, mediaToDom = null, isImageBlockEnabled = false, fiberyViewEnabled = false, emojiOptions, } = {}) => {
|
|
36
|
+
nodes.code_block = code_block;
|
|
37
|
+
nodes.paragraph = paragraph;
|
|
38
|
+
nodes.heading = makeHeading({ headingToDOM });
|
|
39
|
+
const base = new Schema({
|
|
40
|
+
nodes,
|
|
44
41
|
marks: {
|
|
45
|
-
link
|
|
46
|
-
em
|
|
47
|
-
strong
|
|
48
|
-
code
|
|
49
|
-
linkedhighlight:
|
|
50
|
-
linkedhighlightentity:
|
|
42
|
+
link,
|
|
43
|
+
em,
|
|
44
|
+
strong,
|
|
45
|
+
code,
|
|
46
|
+
linkedhighlight: makeLinkedHighlight({ sharedColorGenerator }),
|
|
47
|
+
linkedhighlightentity: makeLinkedHighlightEntity({ sharedColorGenerator }),
|
|
51
48
|
},
|
|
52
49
|
});
|
|
53
50
|
const customNodes = {
|
|
54
|
-
note
|
|
55
|
-
important
|
|
56
|
-
entity
|
|
57
|
-
mention
|
|
58
|
-
media:
|
|
59
|
-
check_item
|
|
60
|
-
check_list
|
|
61
|
-
video
|
|
62
|
-
file
|
|
63
|
-
emoji:
|
|
64
|
-
callout
|
|
65
|
-
columns
|
|
66
|
-
column
|
|
67
|
-
math_display
|
|
68
|
-
math_inline
|
|
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,
|
|
69
66
|
};
|
|
70
|
-
let actualNodes =
|
|
71
|
-
.append({ ...
|
|
67
|
+
let actualNodes = addListNodes(base.spec.nodes, "paragraph block*", "block")
|
|
68
|
+
.append({ ...tableNodes })
|
|
72
69
|
.append(customNodes);
|
|
73
70
|
if (fiberyViewEnabled) {
|
|
74
|
-
actualNodes = actualNodes.append({ fiberyView
|
|
71
|
+
actualNodes = actualNodes.append({ fiberyView });
|
|
75
72
|
}
|
|
76
73
|
if (isImageBlockEnabled) {
|
|
77
|
-
actualNodes = actualNodes.addToStart("imageBlock",
|
|
74
|
+
actualNodes = actualNodes.addToStart("imageBlock", imageBlock);
|
|
78
75
|
}
|
|
79
76
|
else {
|
|
80
|
-
actualNodes = actualNodes.addToEnd("imageBlock",
|
|
77
|
+
actualNodes = actualNodes.addToEnd("imageBlock", imageBlock);
|
|
81
78
|
}
|
|
82
79
|
actualNodes = actualNodes.update("doc", {
|
|
83
80
|
content: `(block | columns)+`,
|
|
@@ -183,28 +180,27 @@ const createSchema = ({ sharedColorGenerator = null, headingToDOM = null, mediaT
|
|
|
183
180
|
return Object.keys(attrs).length ? ["li", attrs, 0] : ["li", 0];
|
|
184
181
|
},
|
|
185
182
|
});
|
|
186
|
-
return new
|
|
183
|
+
return new Schema({
|
|
187
184
|
nodes: actualNodes,
|
|
188
185
|
marks: base.spec.marks
|
|
189
|
-
.addToEnd("strike",
|
|
190
|
-
.addToEnd("underline",
|
|
191
|
-
.addToEnd("hintQuery",
|
|
186
|
+
.addToEnd("strike", strike)
|
|
187
|
+
.addToEnd("underline", underline)
|
|
188
|
+
.addToEnd("hintQuery", hintQuery)
|
|
192
189
|
// We leave mark key as "highlight" only because we don't want to do migration.
|
|
193
190
|
// "TextBackgroundColor" term is used everywhere through codebase.
|
|
194
|
-
.addToEnd("highlight",
|
|
195
|
-
.addToEnd("insertion",
|
|
196
|
-
.addToEnd("deletion",
|
|
197
|
-
.addToEnd("modification",
|
|
191
|
+
.addToEnd("highlight", textBackgroundColor)
|
|
192
|
+
.addToEnd("insertion", insertion)
|
|
193
|
+
.addToEnd("deletion", deletion)
|
|
194
|
+
.addToEnd("modification", modification),
|
|
198
195
|
});
|
|
199
196
|
};
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
marks: prosemirror_schema_basic_1.marks,
|
|
197
|
+
export const Basic = {
|
|
198
|
+
nodes,
|
|
199
|
+
marks,
|
|
204
200
|
fibery: {
|
|
205
|
-
link
|
|
206
|
-
strike
|
|
207
|
-
underline
|
|
208
|
-
textBackgroundColor
|
|
201
|
+
link,
|
|
202
|
+
strike,
|
|
203
|
+
underline,
|
|
204
|
+
textBackgroundColor,
|
|
209
205
|
},
|
|
210
206
|
};
|
package/lib/src/marks/code.js
CHANGED
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.code = void 0;
|
|
4
1
|
const codeDOM = ["code", 0];
|
|
5
2
|
/**
|
|
6
3
|
Code font mark. Represented as a `<code>` element.
|
|
7
4
|
*/
|
|
8
|
-
|
|
5
|
+
export const code = {
|
|
9
6
|
parseDOM: [{ tag: "code" }],
|
|
10
7
|
toDOM() {
|
|
11
8
|
return codeDOM;
|
package/lib/src/marks/em.js
CHANGED
|
@@ -1,12 +1,9 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.em = void 0;
|
|
4
1
|
const emDOM = ["em", 0];
|
|
5
2
|
/**
|
|
6
3
|
An emphasis mark. Rendered as an `<em>` element. Has parse rules
|
|
7
4
|
that also match `<i>` and `font-style: italic`.
|
|
8
5
|
*/
|
|
9
|
-
|
|
6
|
+
export const em = {
|
|
10
7
|
parseDOM: [
|
|
11
8
|
{ tag: "i" },
|
|
12
9
|
{ tag: "em" },
|
package/lib/src/marks/link.js
CHANGED
|
@@ -1,13 +1,10 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.link = void 0;
|
|
4
1
|
const httpRegex = /^[-a-zA-Z0-9@:%._+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b[-a-zA-Z0-9()@:%_+.~#?&/=]*$/;
|
|
5
2
|
/**
|
|
6
3
|
A link. Has `href` and `title` attributes. `title`
|
|
7
4
|
defaults to the empty string. Rendered and parsed as an `<a>`
|
|
8
5
|
element.
|
|
9
6
|
*/
|
|
10
|
-
|
|
7
|
+
export const link = {
|
|
11
8
|
attrs: {
|
|
12
9
|
href: {},
|
|
13
10
|
title: { default: null },
|
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.makeLinkedHighlightEntity = exports.makeLinkedHighlight = void 0;
|
|
4
1
|
const hyphenatePascal = (str) => str
|
|
5
2
|
.replace(/([a-z])([A-Z])/g, "$1-$2")
|
|
6
3
|
.replace(/([A-Z]{2})[a-z]/, "$1-")
|
|
@@ -48,13 +45,11 @@ const createMark = (markType, sharedColorGenerator) => {
|
|
|
48
45
|
},
|
|
49
46
|
};
|
|
50
47
|
};
|
|
51
|
-
const makeLinkedHighlight = ({ sharedColorGenerator }) => {
|
|
48
|
+
export const makeLinkedHighlight = ({ sharedColorGenerator }) => {
|
|
52
49
|
// @ts-expect-error todo: fix this
|
|
53
50
|
return createMark("linkedhighlight", sharedColorGenerator);
|
|
54
51
|
};
|
|
55
|
-
|
|
56
|
-
const makeLinkedHighlightEntity = ({ sharedColorGenerator }) => {
|
|
52
|
+
export const makeLinkedHighlightEntity = ({ sharedColorGenerator }) => {
|
|
57
53
|
// @ts-expect-error todo: fix this
|
|
58
54
|
return createMark("linkedhighlightentity", sharedColorGenerator);
|
|
59
55
|
};
|
|
60
|
-
exports.makeLinkedHighlightEntity = makeLinkedHighlightEntity;
|
package/lib/src/marks/strike.js
CHANGED
package/lib/src/marks/strong.js
CHANGED
|
@@ -1,12 +1,9 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.strong = void 0;
|
|
4
1
|
const strongDOM = ["strong", 0];
|
|
5
2
|
/**
|
|
6
3
|
A strong mark. Rendered as `<strong>`, parse rules also match
|
|
7
4
|
`<b>` and `font-weight: bold`.
|
|
8
5
|
*/
|
|
9
|
-
|
|
6
|
+
export const strong = {
|
|
10
7
|
parseDOM: [
|
|
11
8
|
{ tag: "strong" },
|
|
12
9
|
// This works around a Google Docs misbehavior where
|
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.textBackgroundColor = void 0;
|
|
4
1
|
var ColorToken;
|
|
5
2
|
(function (ColorToken) {
|
|
6
3
|
ColorToken["Yellow"] = "YELLOW";
|
|
@@ -51,7 +48,7 @@ const getClassName = (bgColorToken, fgColorToken) => {
|
|
|
51
48
|
.filter(Boolean)
|
|
52
49
|
.join(` `);
|
|
53
50
|
};
|
|
54
|
-
|
|
51
|
+
export const textBackgroundColor = {
|
|
55
52
|
attrs: {
|
|
56
53
|
guid: { default: "" },
|
|
57
54
|
color: { default: undefined },
|
package/lib/src/nodes/callout.js
CHANGED
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.callout = void 0;
|
|
4
1
|
const nodeType = "data-callout-node";
|
|
5
|
-
|
|
2
|
+
export const callout = {
|
|
6
3
|
attrs: {
|
|
7
4
|
color: { default: "#199EE3" },
|
|
8
5
|
iconType: { default: "icon" },
|
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.check_item = void 0;
|
|
4
|
-
const uuid_1 = require("uuid");
|
|
5
|
-
exports.check_item = {
|
|
1
|
+
import { v4 as uuidv4 } from "uuid";
|
|
2
|
+
export const check_item = {
|
|
6
3
|
content: "inline*",
|
|
7
4
|
defining: true,
|
|
8
5
|
selectable: true,
|
|
@@ -18,7 +15,7 @@ exports.check_item = {
|
|
|
18
15
|
// also used by list-item we need to make sure that we run this parser first.
|
|
19
16
|
priority: 100,
|
|
20
17
|
getAttrs: (dom) => ({
|
|
21
|
-
id: (
|
|
18
|
+
id: uuidv4(),
|
|
22
19
|
state: dom.getAttribute("data-check-item-state"),
|
|
23
20
|
}),
|
|
24
21
|
},
|
|
@@ -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.js";
|
|
3
3
|
export interface CheckListContent extends Array<CheckItemDefinition | CheckListDefinition> {
|
|
4
4
|
0: CheckItemDefinition;
|
|
5
5
|
}
|
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.check_list = void 0;
|
|
4
|
-
const uuid_1 = require("uuid");
|
|
5
|
-
exports.check_list = {
|
|
1
|
+
import { v4 as uuidv4 } from "uuid";
|
|
2
|
+
export const check_list = {
|
|
6
3
|
group: "block",
|
|
7
4
|
defining: true,
|
|
8
5
|
selectable: true,
|
|
@@ -17,7 +14,7 @@ exports.check_list = {
|
|
|
17
14
|
// also used by ordered-list we need to make sure that we run this parser first.
|
|
18
15
|
priority: 100,
|
|
19
16
|
getAttrs: () => ({
|
|
20
|
-
id: (
|
|
17
|
+
id: uuidv4(),
|
|
21
18
|
}),
|
|
22
19
|
},
|
|
23
20
|
],
|
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.code_block = void 0;
|
|
4
|
-
const uuid_1 = require("uuid");
|
|
5
|
-
const resizable_node_attrs_1 = require("../resizable-node-attrs");
|
|
1
|
+
import { v4 } from "uuid";
|
|
2
|
+
import { createDefaultAttrs, createParseDomAttrs, createToDomAttrs } from "../resizable-node-attrs.js";
|
|
6
3
|
const getLanguageFromEditorStyle = (dom) => {
|
|
7
4
|
return dom.getAttribute("data-language") || undefined;
|
|
8
5
|
};
|
|
@@ -38,7 +35,7 @@ const removeLastNewLine = (dom) => {
|
|
|
38
35
|
}
|
|
39
36
|
return dom;
|
|
40
37
|
};
|
|
41
|
-
|
|
38
|
+
export const code_block = {
|
|
42
39
|
content: "text*",
|
|
43
40
|
marks: "linkedhighlightentity linkedhighlight",
|
|
44
41
|
group: "block",
|
|
@@ -50,7 +47,7 @@ exports.code_block = {
|
|
|
50
47
|
language: { default: null },
|
|
51
48
|
wrapCode: { default: false },
|
|
52
49
|
mode: { default: "split" },
|
|
53
|
-
...
|
|
50
|
+
...createDefaultAttrs(),
|
|
54
51
|
},
|
|
55
52
|
parseDOM: [
|
|
56
53
|
{
|
|
@@ -58,7 +55,7 @@ exports.code_block = {
|
|
|
58
55
|
preserveWhitespace: "full",
|
|
59
56
|
getAttrs: (domNode) => {
|
|
60
57
|
const dom = domNode;
|
|
61
|
-
const guid = dom.getAttribute("data-guid") ||
|
|
58
|
+
const guid = dom.getAttribute("data-guid") || v4();
|
|
62
59
|
const language = getLanguageFromBitbucketStyle(dom.parentElement) ||
|
|
63
60
|
getLanguageFromEditorStyle(dom.parentElement) ||
|
|
64
61
|
getLanguageFromCode(dom) ||
|
|
@@ -66,7 +63,7 @@ exports.code_block = {
|
|
|
66
63
|
const wrapCodeAttr = dom.getAttribute("data-wrap-code");
|
|
67
64
|
const wrapCode = wrapCodeAttr === "true";
|
|
68
65
|
removeLastNewLine(dom);
|
|
69
|
-
return { guid, language, wrapCode, mode: dom.getAttribute("data-mode") || "split", ...
|
|
66
|
+
return { guid, language, wrapCode, mode: dom.getAttribute("data-mode") || "split", ...createParseDomAttrs(dom) };
|
|
70
67
|
},
|
|
71
68
|
},
|
|
72
69
|
// Handle GitHub/Gist paste
|
|
@@ -92,7 +89,7 @@ exports.code_block = {
|
|
|
92
89
|
"data-guid": guid,
|
|
93
90
|
"data-wrap-code": node.attrs.wrapCode || false,
|
|
94
91
|
"data-mode": node.attrs.mode || "split",
|
|
95
|
-
...
|
|
92
|
+
...createToDomAttrs(node.attrs),
|
|
96
93
|
},
|
|
97
94
|
0,
|
|
98
95
|
],
|
package/lib/src/nodes/column.js
CHANGED
package/lib/src/nodes/columns.js
CHANGED
|
@@ -1,21 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.columns = void 0;
|
|
4
|
-
const resizable_node_attrs_1 = require("../resizable-node-attrs");
|
|
5
|
-
exports.columns = {
|
|
1
|
+
import { createDefaultAttrs, createParseDomAttrs, createToDomAttrs } from "../resizable-node-attrs.js";
|
|
2
|
+
export const columns = {
|
|
6
3
|
content: "column+",
|
|
7
4
|
selectable: true,
|
|
8
5
|
draggable: false,
|
|
9
6
|
attrs: {
|
|
10
7
|
id: { default: "" },
|
|
11
|
-
...
|
|
8
|
+
...createDefaultAttrs(),
|
|
12
9
|
},
|
|
13
10
|
parseDOM: [
|
|
14
11
|
{
|
|
15
12
|
tag: "div.fibery-columns-node",
|
|
16
13
|
getAttrs: (domNode) => {
|
|
17
14
|
const dom = domNode;
|
|
18
|
-
return
|
|
15
|
+
return createParseDomAttrs(dom);
|
|
19
16
|
},
|
|
20
17
|
},
|
|
21
18
|
],
|
|
@@ -30,7 +27,7 @@ exports.columns = {
|
|
|
30
27
|
const attrs = {
|
|
31
28
|
class: "fibery-columns-node",
|
|
32
29
|
style: `display: grid; gap: 46px; grid-template-columns: ${gridTemplateColumns}`,
|
|
33
|
-
...
|
|
30
|
+
...createToDomAttrs(node.attrs),
|
|
34
31
|
};
|
|
35
32
|
return ["div", attrs, 0];
|
|
36
33
|
},
|
package/lib/src/nodes/emoji.d.ts
CHANGED
|
@@ -16,14 +16,14 @@ export declare const makeEmoji: ({ getEmoji }?: EmojiOptions) => {
|
|
|
16
16
|
group: string;
|
|
17
17
|
selectable: false;
|
|
18
18
|
draggable: false;
|
|
19
|
-
leafText: (node: import("
|
|
19
|
+
leafText: (node: import("prosemirror-model").Node) => any;
|
|
20
20
|
parseDOM: {
|
|
21
21
|
tag: string;
|
|
22
22
|
getAttrs(domNode: HTMLElement): {
|
|
23
23
|
code: string;
|
|
24
24
|
};
|
|
25
25
|
}[];
|
|
26
|
-
toDOM(node: import("
|
|
26
|
+
toDOM(node: import("prosemirror-model").Node): [string, {
|
|
27
27
|
"data-emoji-node": string;
|
|
28
28
|
"data-emoji-code": any;
|
|
29
29
|
}, any];
|
package/lib/src/nodes/emoji.js
CHANGED
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.makeEmoji = void 0;
|
|
4
1
|
const typeAttr = "data-emoji-node";
|
|
5
2
|
const codeAttr = "data-emoji-code";
|
|
6
3
|
const defaultOptions = {
|
|
@@ -8,7 +5,7 @@ const defaultOptions = {
|
|
|
8
5
|
return;
|
|
9
6
|
},
|
|
10
7
|
};
|
|
11
|
-
const makeEmoji = ({ getEmoji } = defaultOptions) => ({
|
|
8
|
+
export const makeEmoji = ({ getEmoji } = defaultOptions) => ({
|
|
12
9
|
attrs: {
|
|
13
10
|
code: {},
|
|
14
11
|
},
|
|
@@ -48,4 +45,3 @@ const makeEmoji = ({ getEmoji } = defaultOptions) => ({
|
|
|
48
45
|
return ["span", attrs, emoji ? emoji.native || `:${emoji.shortNames[0]}:` : code];
|
|
49
46
|
},
|
|
50
47
|
});
|
|
51
|
-
exports.makeEmoji = makeEmoji;
|
package/lib/src/nodes/entity.js
CHANGED
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.fiberyView = void 0;
|
|
4
|
-
const resizable_node_attrs_1 = require("../resizable-node-attrs");
|
|
5
|
-
exports.fiberyView = {
|
|
1
|
+
import { createDefaultAttrs, createParseDomAttrs, createToDomAttrs } from "../resizable-node-attrs.js";
|
|
2
|
+
export const fiberyView = {
|
|
6
3
|
inline: false,
|
|
7
4
|
group: "block",
|
|
8
5
|
selectable: true,
|
|
@@ -10,7 +7,7 @@ exports.fiberyView = {
|
|
|
10
7
|
draggable: false,
|
|
11
8
|
attrs: {
|
|
12
9
|
id: { default: "" },
|
|
13
|
-
...
|
|
10
|
+
...createDefaultAttrs(),
|
|
14
11
|
},
|
|
15
12
|
parseDOM: [
|
|
16
13
|
{
|
|
@@ -19,7 +16,7 @@ exports.fiberyView = {
|
|
|
19
16
|
const dom = domNode;
|
|
20
17
|
return {
|
|
21
18
|
id: dom.getAttribute("data-view-id"),
|
|
22
|
-
...
|
|
19
|
+
...createParseDomAttrs(dom),
|
|
23
20
|
};
|
|
24
21
|
},
|
|
25
22
|
},
|
|
@@ -29,7 +26,7 @@ exports.fiberyView = {
|
|
|
29
26
|
const attrs = {
|
|
30
27
|
"data-view-id": id,
|
|
31
28
|
contenteditable: "false",
|
|
32
|
-
...
|
|
29
|
+
...createToDomAttrs(node.attrs),
|
|
33
30
|
};
|
|
34
31
|
return ["div", attrs, ""];
|
|
35
32
|
},
|
package/lib/src/nodes/file.d.ts
CHANGED
|
@@ -18,7 +18,7 @@ export declare const file: {
|
|
|
18
18
|
group: string;
|
|
19
19
|
selectable: false;
|
|
20
20
|
draggable: false;
|
|
21
|
-
leafText: (node: import("
|
|
21
|
+
leafText: (node: import("prosemirror-model").Node) => any;
|
|
22
22
|
parseDOM: {
|
|
23
23
|
tag: string;
|
|
24
24
|
getAttrs(domNode: HTMLElement): {
|
|
@@ -28,7 +28,7 @@ export declare const file: {
|
|
|
28
28
|
type: string | null;
|
|
29
29
|
};
|
|
30
30
|
}[];
|
|
31
|
-
toDOM(node: import("
|
|
31
|
+
toDOM(node: import("prosemirror-model").Node): [string, {
|
|
32
32
|
"data-file-href": any;
|
|
33
33
|
"data-size": any;
|
|
34
34
|
"data-type": any;
|
package/lib/src/nodes/file.js
CHANGED
|
@@ -1,14 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.file = void 0;
|
|
4
|
-
const transcription_node_attrs_1 = require("../transcription-node-attrs");
|
|
5
|
-
exports.file = {
|
|
1
|
+
import { createDefaultAttrs } from "../transcription-node-attrs.js";
|
|
2
|
+
export const file = {
|
|
6
3
|
attrs: {
|
|
7
4
|
src: {},
|
|
8
5
|
title: { default: "Untitled" },
|
|
9
6
|
size: {},
|
|
10
7
|
type: {},
|
|
11
|
-
...
|
|
8
|
+
...createDefaultAttrs(),
|
|
12
9
|
},
|
|
13
10
|
inline: true,
|
|
14
11
|
group: "inline",
|
package/lib/src/nodes/heading.js
CHANGED
|
@@ -1,12 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.makeHeading = void 0;
|
|
4
|
-
const uuid_1 = require("uuid");
|
|
1
|
+
import { v4 } from "uuid";
|
|
5
2
|
const parseGuid = (dom) => {
|
|
6
|
-
return dom.getAttribute("guid") ||
|
|
3
|
+
return dom.getAttribute("guid") || v4();
|
|
7
4
|
};
|
|
8
5
|
const makeGetAttrs = (level) => (dom) => ({ level, guid: parseGuid(dom) });
|
|
9
|
-
const makeHeading = ({ headingToDOM }) => ({
|
|
6
|
+
export const makeHeading = ({ headingToDOM }) => ({
|
|
10
7
|
content: "inline*",
|
|
11
8
|
group: "block",
|
|
12
9
|
attrs: {
|
|
@@ -30,4 +27,3 @@ const makeHeading = ({ headingToDOM }) => ({
|
|
|
30
27
|
return ["h" + node.attrs.level, { guid }, 0];
|
|
31
28
|
},
|
|
32
29
|
});
|
|
33
|
-
exports.makeHeading = makeHeading;
|
|
@@ -1,15 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.imageBlock = void 0;
|
|
4
|
-
const resizable_node_attrs_1 = require("../resizable-node-attrs");
|
|
5
|
-
exports.imageBlock = {
|
|
1
|
+
import { createDefaultAttrs, createParseDomAttrs, createToDomAttrs } from "../resizable-node-attrs.js";
|
|
2
|
+
export const imageBlock = {
|
|
6
3
|
attrs: {
|
|
7
4
|
src: {},
|
|
8
5
|
alt: { default: null },
|
|
9
6
|
title: { default: null },
|
|
10
7
|
size: { default: null },
|
|
11
8
|
type: { default: null },
|
|
12
|
-
...
|
|
9
|
+
...createDefaultAttrs(),
|
|
13
10
|
},
|
|
14
11
|
inline: false,
|
|
15
12
|
group: "block",
|
|
@@ -25,7 +22,7 @@ exports.imageBlock = {
|
|
|
25
22
|
src: dom.getAttribute("src"),
|
|
26
23
|
title: dom.getAttribute("title"),
|
|
27
24
|
alt: dom.getAttribute("alt"),
|
|
28
|
-
...
|
|
25
|
+
...createParseDomAttrs(dom),
|
|
29
26
|
};
|
|
30
27
|
},
|
|
31
28
|
},
|
|
@@ -36,7 +33,7 @@ exports.imageBlock = {
|
|
|
36
33
|
src,
|
|
37
34
|
alt,
|
|
38
35
|
title,
|
|
39
|
-
...
|
|
36
|
+
...createToDomAttrs(node.attrs),
|
|
40
37
|
};
|
|
41
38
|
return ["div", {}, ["img", attrs]];
|
|
42
39
|
},
|
package/lib/src/nodes/media.js
CHANGED
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.makeMedia = void 0;
|
|
4
|
-
const resizable_node_attrs_1 = require("../resizable-node-attrs");
|
|
1
|
+
import { createDefaultAttrs, createParseDomAttrs, createToDomAttrs } from "../resizable-node-attrs.js";
|
|
5
2
|
function toBoolean(attr) {
|
|
6
3
|
if (typeof attr === "boolean") {
|
|
7
4
|
return attr;
|
|
@@ -23,7 +20,7 @@ function toNumberOrNull(value) {
|
|
|
23
20
|
const parsed = parseFloat(value);
|
|
24
21
|
return isNaN(parsed) ? null : parsed;
|
|
25
22
|
}
|
|
26
|
-
const makeMedia = ({ mediaToDom }) => ({
|
|
23
|
+
export const makeMedia = ({ mediaToDom }) => ({
|
|
27
24
|
inline: false,
|
|
28
25
|
attrs: {
|
|
29
26
|
url: {},
|
|
@@ -36,7 +33,7 @@ const makeMedia = ({ mediaToDom }) => ({
|
|
|
36
33
|
aspectRatio: {
|
|
37
34
|
default: null,
|
|
38
35
|
},
|
|
39
|
-
...
|
|
36
|
+
...createDefaultAttrs(),
|
|
40
37
|
},
|
|
41
38
|
group: "block",
|
|
42
39
|
draggable: true,
|
|
@@ -50,7 +47,7 @@ const makeMedia = ({ mediaToDom }) => ({
|
|
|
50
47
|
dynamicContent: htmlElement.getAttribute("data-dynamic-content") !== "false",
|
|
51
48
|
aspectRatio: toNumberOrNull(htmlElement.getAttribute("data-aspect-ratio")),
|
|
52
49
|
compatibleMode: toBoolean(htmlElement.getAttribute("data-compatible-mode")),
|
|
53
|
-
...
|
|
50
|
+
...createParseDomAttrs(htmlElement),
|
|
54
51
|
};
|
|
55
52
|
},
|
|
56
53
|
},
|
|
@@ -66,9 +63,8 @@ const makeMedia = ({ mediaToDom }) => ({
|
|
|
66
63
|
"data-dynamic-content": typeof dynamicContent === "boolean" ? String(dynamicContent) : "false",
|
|
67
64
|
"data-aspect-ratio": aspectRatio,
|
|
68
65
|
contenteditable: "false",
|
|
69
|
-
...
|
|
66
|
+
...createToDomAttrs(node),
|
|
70
67
|
};
|
|
71
68
|
return ["div", attrs, url];
|
|
72
69
|
},
|
|
73
70
|
});
|
|
74
|
-
exports.makeMedia = makeMedia;
|
package/lib/src/nodes/mention.js
CHANGED
package/lib/src/nodes/note.js
CHANGED
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.paragraph = void 0;
|
|
4
|
-
const uuid_1 = require("uuid");
|
|
5
|
-
exports.paragraph = {
|
|
1
|
+
import { v4 } from "uuid";
|
|
2
|
+
export const paragraph = {
|
|
6
3
|
content: "inline*",
|
|
7
4
|
group: "block",
|
|
8
5
|
attrs: {
|
|
@@ -12,7 +9,7 @@ exports.paragraph = {
|
|
|
12
9
|
{
|
|
13
10
|
tag: "p",
|
|
14
11
|
getAttrs: (dom) => ({
|
|
15
|
-
guid: dom.getAttribute("data-guid") ||
|
|
12
|
+
guid: dom.getAttribute("data-guid") || v4(),
|
|
16
13
|
}),
|
|
17
14
|
},
|
|
18
15
|
],
|
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.tableNodes = void 0;
|
|
4
|
-
const prosemirror_tables_1 = require("prosemirror-tables");
|
|
5
|
-
exports.tableNodes = (0, prosemirror_tables_1.tableNodes)({
|
|
1
|
+
import { tableNodes as prosemirrorTableNodes } from "prosemirror-tables";
|
|
2
|
+
export const tableNodes = prosemirrorTableNodes({
|
|
6
3
|
tableGroup: "block",
|
|
7
4
|
cellContent: "block+",
|
|
8
5
|
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.js";
|
|
2
|
+
import type { MentionDefinition as Mention } from "../mention.js";
|
|
3
|
+
import type { TextDefinition as Text } from "./text.js";
|
|
4
4
|
interface MarksObject<T> {
|
|
5
5
|
marks?: Array<T>;
|
|
6
6
|
}
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
export {};
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
export {};
|
package/lib/src/nodes/video.js
CHANGED
|
@@ -1,21 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
exports.DEFAULT_VIDEO_WIDTH = 400;
|
|
7
|
-
exports.DEFAULT_VIDEO_HEIGHT = 200;
|
|
8
|
-
exports.video = {
|
|
1
|
+
import { createDefaultAttrs, createParseDomAttrs, createToDomAttrs } from "../resizable-node-attrs.js";
|
|
2
|
+
import { createDefaultAttrs as createTranscriptionDefaultAttrs } from "../transcription-node-attrs.js";
|
|
3
|
+
export const DEFAULT_VIDEO_WIDTH = 400;
|
|
4
|
+
export const DEFAULT_VIDEO_HEIGHT = 200;
|
|
5
|
+
export const video = {
|
|
9
6
|
inline: false,
|
|
10
7
|
attrs: {
|
|
11
8
|
src: {},
|
|
12
9
|
type: {},
|
|
13
|
-
width: { default:
|
|
14
|
-
height: { default:
|
|
10
|
+
width: { default: DEFAULT_VIDEO_WIDTH },
|
|
11
|
+
height: { default: DEFAULT_VIDEO_HEIGHT },
|
|
15
12
|
title: { default: "" },
|
|
16
13
|
alignment: { default: ":alignment/block-center" },
|
|
17
|
-
...
|
|
18
|
-
...(
|
|
14
|
+
...createDefaultAttrs(),
|
|
15
|
+
...createTranscriptionDefaultAttrs(),
|
|
19
16
|
},
|
|
20
17
|
group: "block",
|
|
21
18
|
draggable: true,
|
|
@@ -27,16 +24,16 @@ exports.video = {
|
|
|
27
24
|
return {
|
|
28
25
|
src: dom.getAttribute("src"),
|
|
29
26
|
type: dom.getAttribute("type"),
|
|
30
|
-
width: Number(dom.getAttribute("width")) ||
|
|
31
|
-
height: Number(dom.getAttribute("height")) ||
|
|
27
|
+
width: Number(dom.getAttribute("width")) || DEFAULT_VIDEO_WIDTH,
|
|
28
|
+
height: Number(dom.getAttribute("height")) || DEFAULT_VIDEO_HEIGHT,
|
|
32
29
|
title: dom.getAttribute("title"),
|
|
33
|
-
...
|
|
30
|
+
...createParseDomAttrs(dom),
|
|
34
31
|
};
|
|
35
32
|
},
|
|
36
33
|
},
|
|
37
34
|
],
|
|
38
35
|
toDOM(node) {
|
|
39
|
-
const { src, type, width =
|
|
36
|
+
const { src, type, width = DEFAULT_VIDEO_WIDTH, height = DEFAULT_VIDEO_HEIGHT, title } = node.attrs;
|
|
40
37
|
return [
|
|
41
38
|
"video",
|
|
42
39
|
{
|
|
@@ -48,7 +45,7 @@ exports.video = {
|
|
|
48
45
|
playsinline: "",
|
|
49
46
|
controls: "",
|
|
50
47
|
preload: "metadata",
|
|
51
|
-
...
|
|
48
|
+
...createToDomAttrs(node.attrs),
|
|
52
49
|
},
|
|
53
50
|
];
|
|
54
51
|
},
|
|
@@ -1,18 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
exports.createDefaultAttrs = createDefaultAttrs;
|
|
5
|
-
exports.createParseDomAttrs = createParseDomAttrs;
|
|
6
|
-
exports.createToDomAttrs = createToDomAttrs;
|
|
7
|
-
exports.defaultHeight = 400;
|
|
8
|
-
exports.defaultWidth = 900;
|
|
9
|
-
function createDefaultAttrs() {
|
|
1
|
+
export const defaultHeight = 400;
|
|
2
|
+
export const defaultWidth = 900;
|
|
3
|
+
export function createDefaultAttrs() {
|
|
10
4
|
return {
|
|
11
5
|
nodeHeight: {
|
|
12
|
-
default:
|
|
6
|
+
default: defaultHeight,
|
|
13
7
|
},
|
|
14
8
|
nodeWidth: {
|
|
15
|
-
default:
|
|
9
|
+
default: defaultWidth,
|
|
16
10
|
},
|
|
17
11
|
nodePageWidth: {
|
|
18
12
|
default: true,
|
|
@@ -22,7 +16,7 @@ function createDefaultAttrs() {
|
|
|
22
16
|
},
|
|
23
17
|
};
|
|
24
18
|
}
|
|
25
|
-
function createParseDomAttrs(dom) {
|
|
19
|
+
export function createParseDomAttrs(dom) {
|
|
26
20
|
return {
|
|
27
21
|
nodeHeight: dom.getAttribute("data-node-height"),
|
|
28
22
|
nodeWidth: dom.getAttribute("data-node-width"),
|
|
@@ -30,7 +24,7 @@ function createParseDomAttrs(dom) {
|
|
|
30
24
|
nodeFullWidth: dom.getAttribute("data-node-full-width"),
|
|
31
25
|
};
|
|
32
26
|
}
|
|
33
|
-
function createToDomAttrs({ nodeHeight, nodeWidth, nodePageWidth, nodeFullWidth }) {
|
|
27
|
+
export function createToDomAttrs({ nodeHeight, nodeWidth, nodePageWidth, nodeFullWidth }) {
|
|
34
28
|
return {
|
|
35
29
|
"data-node-height": nodeHeight,
|
|
36
30
|
"data-node-width": nodeWidth,
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createDefaultAttrs = createDefaultAttrs;
|
|
4
|
-
function createDefaultAttrs() {
|
|
1
|
+
export function createDefaultAttrs() {
|
|
5
2
|
return {
|
|
6
3
|
transcription: {
|
|
7
4
|
default: { status: "IDLE", userId: "", inserted: false },
|
|
@@ -1,21 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.toHTML = exports.toDOM = exports.fromHTML = void 0;
|
|
4
|
-
const prosemirror_model_1 = require("prosemirror-model");
|
|
5
|
-
const fromHTML = (html, schema, options) => {
|
|
1
|
+
import { DOMParser, DOMSerializer, Fragment } from "prosemirror-model";
|
|
2
|
+
export const fromHTML = (html, schema, options) => {
|
|
6
3
|
const el = document.createElement("div");
|
|
7
4
|
el.innerHTML = html;
|
|
8
|
-
return
|
|
5
|
+
return DOMParser.fromSchema(schema).parse(el, options);
|
|
9
6
|
};
|
|
10
|
-
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
return serializer.serializeFragment(prosemirror_model_1.Fragment.from(node));
|
|
7
|
+
export const toDOM = (node, schema) => {
|
|
8
|
+
const serializer = DOMSerializer.fromSchema(schema);
|
|
9
|
+
return serializer.serializeFragment(Fragment.from(node));
|
|
14
10
|
};
|
|
15
|
-
|
|
16
|
-
const toHTML = (node, schema) => {
|
|
11
|
+
export const toHTML = (node, schema) => {
|
|
17
12
|
const el = document.createElement("div");
|
|
18
|
-
el.appendChild(
|
|
13
|
+
el.appendChild(toDOM(node, schema));
|
|
19
14
|
return el.innerHTML;
|
|
20
15
|
};
|
|
21
|
-
exports.toHTML = toHTML;
|
package/package.json
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fibery/prosemirror-schema",
|
|
3
|
-
"version": "4.19.0-next.
|
|
3
|
+
"version": "4.19.0-next.2",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Fibery prosemirror schema",
|
|
6
6
|
"files": [
|
|
7
7
|
"/lib"
|
|
8
8
|
],
|
|
9
|
+
"type": "module",
|
|
9
10
|
"main": "./lib/index.js",
|
|
10
11
|
"exports": {
|
|
11
12
|
".": {
|