@fibery/prosemirror-schema 4.10.0 → 4.12.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 +2 -0
- package/lib/index.js +7 -1
- package/lib/src/marks/linked-highlight.js +1 -1
- package/lib/src/nodes/check-item.js +1 -1
- package/lib/src/nodes/check-list.js +1 -1
- package/lib/src/nodes/entity.d.ts +9 -0
- package/lib/src/nodes/entity.js +16 -1
- package/lib/src/nodes/media.js +18 -1
- package/lib/src/nodes/mention.js +3 -0
- 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
package/lib/index.js
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
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.createSchema = 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; } });
|
|
4
7
|
var create_schema_1 = require("./src/create-schema");
|
|
5
8
|
Object.defineProperty(exports, "createSchema", { enumerable: true, get: function () { return create_schema_1.createSchema; } });
|
|
9
|
+
var video_1 = require("./src/nodes/video");
|
|
10
|
+
Object.defineProperty(exports, "DEFAULT_VIDEO_WIDTH", { enumerable: true, get: function () { return video_1.DEFAULT_VIDEO_WIDTH; } });
|
|
11
|
+
Object.defineProperty(exports, "DEFAULT_VIDEO_HEIGHT", { enumerable: true, get: function () { return video_1.DEFAULT_VIDEO_HEIGHT; } });
|
|
@@ -35,7 +35,7 @@ const createMark = (markType, sharedColorGenerator) => {
|
|
|
35
35
|
markTag,
|
|
36
36
|
{
|
|
37
37
|
class: markClassName,
|
|
38
|
-
style: color ?
|
|
38
|
+
style: color ? `--${markType}-background-color:${color}` : ``,
|
|
39
39
|
"data-id": id,
|
|
40
40
|
...Object.keys(meta)
|
|
41
41
|
.filter((key) => meta[key] !== false) // remove specials
|
|
@@ -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
|
@@ -9,25 +9,40 @@ exports.entity = {
|
|
|
9
9
|
id: { default: "" },
|
|
10
10
|
text: { default: "" },
|
|
11
11
|
typeId: { default: "" },
|
|
12
|
+
meta: {
|
|
13
|
+
default: {},
|
|
14
|
+
},
|
|
12
15
|
},
|
|
13
16
|
parseDOM: [
|
|
14
17
|
{
|
|
15
18
|
tag: "span[data-entity-id]",
|
|
16
19
|
getAttrs: (domNode) => {
|
|
17
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") || "";
|
|
18
27
|
return {
|
|
19
28
|
id: dom.getAttribute("data-entity-id"),
|
|
20
29
|
text: dom.textContent,
|
|
21
30
|
typeId: dom.getAttribute("data-entity-type-id"),
|
|
31
|
+
meta: meta,
|
|
22
32
|
};
|
|
23
33
|
},
|
|
24
34
|
},
|
|
25
35
|
],
|
|
26
36
|
toDOM(node) {
|
|
27
|
-
const { id, typeId, text } = node.attrs;
|
|
37
|
+
const { id, typeId, text, meta } = node.attrs;
|
|
28
38
|
const attrs = {
|
|
29
39
|
"data-entity-id": id,
|
|
30
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,
|
|
31
46
|
contenteditable: "false",
|
|
32
47
|
};
|
|
33
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/mention.js
CHANGED
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,
|