@fibery/prosemirror-schema 4.11.0 → 4.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/index.d.ts +4 -1
- package/lib/index.js +11 -1
- package/lib/src/create-schema.d.ts +25 -0
- package/lib/src/create-schema.js +11 -1
- package/lib/src/marks/link.js +1 -1
- package/lib/src/nodes/code-block.js +12 -2
- package/lib/src/nodes/entity.d.ts +9 -0
- package/lib/src/nodes/entity.js +13 -1
- package/lib/src/nodes/media.js +18 -1
- package/lib/src/nodes/video.d.ts +2 -0
- package/lib/src/nodes/video.js +8 -8
- package/lib/src/resizable-node-attrs.d.ts +2 -0
- package/lib/src/resizable-node-attrs.js +5 -3
- package/package.json +1 -1
package/lib/index.d.ts
CHANGED
|
@@ -1,2 +1,5 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { defaultHeight, defaultWidth } from "./src/resizable-node-attrs";
|
|
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";
|
|
2
5
|
export type { EmojiOptions } from "./src/nodes/emoji";
|
package/lib/index.js
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createSchema = void 0;
|
|
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; } });
|
|
4
10
|
var create_schema_1 = require("./src/create-schema");
|
|
5
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; } });
|
|
@@ -9,4 +9,29 @@ type Params = {
|
|
|
9
9
|
emojiOptions?: EmojiOptions;
|
|
10
10
|
};
|
|
11
11
|
export declare const createSchema: ({ sharedColorGenerator, headingToDOM, mediaToDom, isImageBlockEnabled, fiberyViewEnabled, emojiOptions, }?: Params) => Schema;
|
|
12
|
+
export declare const Basic: {
|
|
13
|
+
nodes: {
|
|
14
|
+
doc: import("prosemirror-model").NodeSpec;
|
|
15
|
+
paragraph: import("prosemirror-model").NodeSpec;
|
|
16
|
+
blockquote: import("prosemirror-model").NodeSpec;
|
|
17
|
+
horizontal_rule: import("prosemirror-model").NodeSpec;
|
|
18
|
+
heading: import("prosemirror-model").NodeSpec;
|
|
19
|
+
code_block: import("prosemirror-model").NodeSpec;
|
|
20
|
+
text: import("prosemirror-model").NodeSpec;
|
|
21
|
+
image: import("prosemirror-model").NodeSpec;
|
|
22
|
+
hard_break: import("prosemirror-model").NodeSpec;
|
|
23
|
+
};
|
|
24
|
+
marks: {
|
|
25
|
+
link: import("prosemirror-model").MarkSpec;
|
|
26
|
+
em: import("prosemirror-model").MarkSpec;
|
|
27
|
+
strong: import("prosemirror-model").MarkSpec;
|
|
28
|
+
code: import("prosemirror-model").MarkSpec;
|
|
29
|
+
};
|
|
30
|
+
fibery: {
|
|
31
|
+
link: import("prosemirror-model").MarkSpec;
|
|
32
|
+
strike: import("prosemirror-model").MarkSpec;
|
|
33
|
+
underline: import("prosemirror-model").MarkSpec;
|
|
34
|
+
textBackgroundColor: import("prosemirror-model").MarkSpec;
|
|
35
|
+
};
|
|
36
|
+
};
|
|
12
37
|
export {};
|
package/lib/src/create-schema.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createSchema = void 0;
|
|
3
|
+
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");
|
|
@@ -84,3 +84,13 @@ const createSchema = ({ sharedColorGenerator = null, headingToDOM = null, mediaT
|
|
|
84
84
|
});
|
|
85
85
|
};
|
|
86
86
|
exports.createSchema = createSchema;
|
|
87
|
+
exports.Basic = {
|
|
88
|
+
nodes: prosemirror_schema_basic_1.nodes,
|
|
89
|
+
marks: prosemirror_schema_basic_1.marks,
|
|
90
|
+
fibery: {
|
|
91
|
+
link: (0, link_1.makeLink)(prosemirror_schema_basic_1.marks.link),
|
|
92
|
+
strike: strike_1.strike,
|
|
93
|
+
underline: underline_1.underline,
|
|
94
|
+
textBackgroundColor: text_background_color_1.textBackgroundColor,
|
|
95
|
+
},
|
|
96
|
+
};
|
package/lib/src/marks/link.js
CHANGED
|
@@ -8,7 +8,7 @@ const makeLink = (baseLink) => {
|
|
|
8
8
|
toDOM(node) {
|
|
9
9
|
const { href } = node.attrs;
|
|
10
10
|
let fixedHref = href;
|
|
11
|
-
if (!fixedHref.startsWith("http") && !fixedHref.startsWith("/")) {
|
|
11
|
+
if (href && !href.startsWith("mailto:") && !fixedHref.startsWith("http") && !fixedHref.startsWith("/")) {
|
|
12
12
|
if (httpRegex.test(href)) {
|
|
13
13
|
fixedHref = `https://${href}`;
|
|
14
14
|
}
|
|
@@ -47,6 +47,7 @@ exports.code_block = {
|
|
|
47
47
|
attrs: {
|
|
48
48
|
guid: { default: "" },
|
|
49
49
|
language: { default: null },
|
|
50
|
+
wrapCode: { default: false },
|
|
50
51
|
},
|
|
51
52
|
parseDOM: [
|
|
52
53
|
{
|
|
@@ -59,8 +60,10 @@ exports.code_block = {
|
|
|
59
60
|
getLanguageFromEditorStyle(dom.parentElement) ||
|
|
60
61
|
getLanguageFromCode(dom) ||
|
|
61
62
|
dom.getAttribute("data-language");
|
|
63
|
+
const wrapCodeAttr = dom.getAttribute("data-wrap-code");
|
|
64
|
+
const wrapCode = wrapCodeAttr === "true";
|
|
62
65
|
removeLastNewLine(dom);
|
|
63
|
-
return { guid, language };
|
|
66
|
+
return { guid, language, wrapCode };
|
|
64
67
|
},
|
|
65
68
|
},
|
|
66
69
|
// Handle GitHub/Gist paste
|
|
@@ -77,6 +80,13 @@ exports.code_block = {
|
|
|
77
80
|
],
|
|
78
81
|
toDOM(node) {
|
|
79
82
|
const { guid = "" } = node.attrs;
|
|
80
|
-
return [
|
|
83
|
+
return [
|
|
84
|
+
"pre",
|
|
85
|
+
[
|
|
86
|
+
"code",
|
|
87
|
+
{ "data-language": node.attrs.language, "data-guid": guid, "data-wrap-code": node.attrs.wrapCode || false },
|
|
88
|
+
0,
|
|
89
|
+
],
|
|
90
|
+
];
|
|
81
91
|
},
|
|
82
92
|
};
|
|
@@ -1,11 +1,20 @@
|
|
|
1
1
|
import { NodeSpec } from "prosemirror-model";
|
|
2
|
+
type Meta = {
|
|
3
|
+
comment?: string;
|
|
4
|
+
anchor?: string;
|
|
5
|
+
field?: string;
|
|
6
|
+
contextEntityTypeId?: string;
|
|
7
|
+
contextEntityPublicId?: string;
|
|
8
|
+
};
|
|
2
9
|
export interface EntityAttributes {
|
|
3
10
|
id: string;
|
|
4
11
|
typeId: string;
|
|
5
12
|
text?: string;
|
|
13
|
+
meta: Meta;
|
|
6
14
|
}
|
|
7
15
|
export interface EntityDefinition {
|
|
8
16
|
type: "entity";
|
|
9
17
|
attrs: EntityAttributes;
|
|
10
18
|
}
|
|
11
19
|
export declare const entity: NodeSpec;
|
|
20
|
+
export {};
|
package/lib/src/nodes/entity.js
CHANGED
|
@@ -18,19 +18,31 @@ exports.entity = {
|
|
|
18
18
|
tag: "span[data-entity-id]",
|
|
19
19
|
getAttrs: (domNode) => {
|
|
20
20
|
const dom = domNode;
|
|
21
|
+
const meta = {};
|
|
22
|
+
meta.comment = dom.getAttribute("data-comment") || "";
|
|
23
|
+
meta.anchor = dom.getAttribute("data-anchor") || "";
|
|
24
|
+
meta.field = dom.getAttribute("data-field") || "";
|
|
25
|
+
meta.contextEntityTypeId = dom.getAttribute("data-context-entity-type-id") || "";
|
|
26
|
+
meta.contextEntityPublicId = dom.getAttribute("data-context-entity-public-id") || "";
|
|
21
27
|
return {
|
|
22
28
|
id: dom.getAttribute("data-entity-id"),
|
|
23
29
|
text: dom.textContent,
|
|
24
30
|
typeId: dom.getAttribute("data-entity-type-id"),
|
|
31
|
+
meta: meta,
|
|
25
32
|
};
|
|
26
33
|
},
|
|
27
34
|
},
|
|
28
35
|
],
|
|
29
36
|
toDOM(node) {
|
|
30
|
-
const { id, typeId, text } = node.attrs;
|
|
37
|
+
const { id, typeId, text, meta } = node.attrs;
|
|
31
38
|
const attrs = {
|
|
32
39
|
"data-entity-id": id,
|
|
33
40
|
"data-entity-type-id": typeId,
|
|
41
|
+
"data-comment": meta.comment,
|
|
42
|
+
"data-anchor": meta.anchor,
|
|
43
|
+
"data-field": meta.field,
|
|
44
|
+
"data-context-entity-type-id": meta.contextEntityTypeId,
|
|
45
|
+
"data-context-entity-public-id": meta.contextEntityPublicId,
|
|
34
46
|
contenteditable: "false",
|
|
35
47
|
};
|
|
36
48
|
return ["span", attrs, text];
|
package/lib/src/nodes/media.js
CHANGED
|
@@ -16,6 +16,13 @@ function toBoolean(attr) {
|
|
|
16
16
|
}
|
|
17
17
|
return Boolean(attr);
|
|
18
18
|
}
|
|
19
|
+
function toNumberOrNull(value) {
|
|
20
|
+
if (!value) {
|
|
21
|
+
return null;
|
|
22
|
+
}
|
|
23
|
+
const parsed = parseFloat(value);
|
|
24
|
+
return isNaN(parsed) ? null : parsed;
|
|
25
|
+
}
|
|
19
26
|
const makeMedia = ({ mediaToDom }) => ({
|
|
20
27
|
inline: false,
|
|
21
28
|
attrs: {
|
|
@@ -23,6 +30,12 @@ const makeMedia = ({ mediaToDom }) => ({
|
|
|
23
30
|
compatibleMode: {
|
|
24
31
|
default: false,
|
|
25
32
|
},
|
|
33
|
+
dynamicContent: {
|
|
34
|
+
default: true,
|
|
35
|
+
},
|
|
36
|
+
aspectRatio: {
|
|
37
|
+
default: null,
|
|
38
|
+
},
|
|
26
39
|
...(0, resizable_node_attrs_1.createDefaultAttrs)(),
|
|
27
40
|
},
|
|
28
41
|
group: "block",
|
|
@@ -34,6 +47,8 @@ const makeMedia = ({ mediaToDom }) => ({
|
|
|
34
47
|
const htmlElement = dom;
|
|
35
48
|
return {
|
|
36
49
|
url: htmlElement.getAttribute("data-url"),
|
|
50
|
+
dynamicContent: htmlElement.getAttribute("data-dynamic-content") !== "false",
|
|
51
|
+
aspectRatio: toNumberOrNull(htmlElement.getAttribute("data-aspect-ratio")),
|
|
37
52
|
compatibleMode: toBoolean(htmlElement.getAttribute("data-compatible-mode")),
|
|
38
53
|
...(0, resizable_node_attrs_1.createParseDomAttrs)(htmlElement),
|
|
39
54
|
};
|
|
@@ -44,10 +59,12 @@ const makeMedia = ({ mediaToDom }) => ({
|
|
|
44
59
|
if (mediaToDom) {
|
|
45
60
|
return mediaToDom(node);
|
|
46
61
|
}
|
|
47
|
-
const { url, compatibleMode } = node.attrs;
|
|
62
|
+
const { url, compatibleMode, dynamicContent, aspectRatio } = node.attrs;
|
|
48
63
|
const attrs = {
|
|
49
64
|
"data-url": url,
|
|
50
65
|
"data-compatible-mode": compatibleMode,
|
|
66
|
+
"data-dynamic-content": typeof dynamicContent === "boolean" ? String(dynamicContent) : "false",
|
|
67
|
+
"data-aspect-ratio": aspectRatio,
|
|
51
68
|
contenteditable: "false",
|
|
52
69
|
...(0, resizable_node_attrs_1.createToDomAttrs)(node),
|
|
53
70
|
};
|
package/lib/src/nodes/video.d.ts
CHANGED
package/lib/src/nodes/video.js
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.video = void 0;
|
|
3
|
+
exports.video = exports.DEFAULT_VIDEO_HEIGHT = exports.DEFAULT_VIDEO_WIDTH = void 0;
|
|
4
4
|
const resizable_node_attrs_1 = require("../resizable-node-attrs");
|
|
5
5
|
const transcription_node_attrs_1 = require("../transcription-node-attrs");
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
exports.DEFAULT_VIDEO_WIDTH = 400;
|
|
7
|
+
exports.DEFAULT_VIDEO_HEIGHT = 200;
|
|
8
8
|
exports.video = {
|
|
9
9
|
inline: false,
|
|
10
10
|
attrs: {
|
|
11
11
|
src: {},
|
|
12
12
|
type: {},
|
|
13
|
-
width: { default: DEFAULT_VIDEO_WIDTH },
|
|
14
|
-
height: { default: DEFAULT_VIDEO_HEIGHT },
|
|
13
|
+
width: { default: exports.DEFAULT_VIDEO_WIDTH },
|
|
14
|
+
height: { default: exports.DEFAULT_VIDEO_HEIGHT },
|
|
15
15
|
title: { default: "" },
|
|
16
16
|
alignment: { default: ":alignment/block-center" },
|
|
17
17
|
...(0, resizable_node_attrs_1.createDefaultAttrs)(),
|
|
@@ -27,8 +27,8 @@ exports.video = {
|
|
|
27
27
|
return {
|
|
28
28
|
src: dom.getAttribute("src"),
|
|
29
29
|
type: dom.getAttribute("type"),
|
|
30
|
-
width: Number(dom.getAttribute("width")) || DEFAULT_VIDEO_WIDTH,
|
|
31
|
-
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,
|
|
32
32
|
title: dom.getAttribute("title"),
|
|
33
33
|
...(0, resizable_node_attrs_1.createParseDomAttrs)(dom),
|
|
34
34
|
};
|
|
@@ -36,7 +36,7 @@ exports.video = {
|
|
|
36
36
|
},
|
|
37
37
|
],
|
|
38
38
|
toDOM(node) {
|
|
39
|
-
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;
|
|
40
40
|
return [
|
|
41
41
|
"video",
|
|
42
42
|
{
|
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createToDomAttrs = exports.createParseDomAttrs = exports.createDefaultAttrs = void 0;
|
|
3
|
+
exports.createToDomAttrs = exports.createParseDomAttrs = exports.createDefaultAttrs = exports.defaultWidth = exports.defaultHeight = void 0;
|
|
4
|
+
exports.defaultHeight = 400;
|
|
5
|
+
exports.defaultWidth = 900;
|
|
4
6
|
function createDefaultAttrs() {
|
|
5
7
|
return {
|
|
6
8
|
nodeHeight: {
|
|
7
|
-
default:
|
|
9
|
+
default: exports.defaultHeight,
|
|
8
10
|
},
|
|
9
11
|
nodeWidth: {
|
|
10
|
-
default:
|
|
12
|
+
default: exports.defaultWidth,
|
|
11
13
|
},
|
|
12
14
|
nodePageWidth: {
|
|
13
15
|
default: true,
|