@fibery/prosemirror-schema 1.6.1 → 3.0.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 +1 -0
- package/lib/index.js +17 -848
- package/lib/src/create-schema.d.ts +10 -0
- package/lib/src/create-schema.js +69 -0
- package/lib/src/marks/highlight.d.ts +2 -0
- package/lib/src/marks/highlight.js +68 -0
- package/lib/src/marks/highlight.test.d.ts +1 -0
- package/lib/src/marks/highlight.test.js +23 -0
- package/lib/src/marks/hint-query.d.ts +2 -0
- package/lib/src/marks/hint-query.js +23 -0
- package/lib/src/marks/link.d.ts +2 -0
- package/lib/src/marks/link.js +13 -0
- package/lib/src/marks/linked-highlight.d.ts +30 -0
- package/lib/src/marks/linked-highlight.js +57 -0
- package/lib/src/marks/linked-highlight.test.d.ts +1 -0
- package/lib/src/marks/linked-highlight.test.js +37 -0
- package/lib/src/marks/strike.d.ts +2 -0
- package/lib/src/marks/strike.js +7 -0
- package/lib/src/marks/types/mark.d.ts +3 -0
- package/lib/src/marks/types/mark.js +2 -0
- package/lib/src/marks/underline.d.ts +2 -0
- package/lib/src/marks/underline.js +7 -0
- package/lib/src/nodes/check-item.d.ts +11 -0
- package/lib/src/nodes/check-item.js +34 -0
- package/lib/src/nodes/check-list.d.ts +13 -0
- package/lib/src/nodes/check-list.js +31 -0
- package/lib/src/nodes/code-block.d.ts +2 -0
- package/lib/src/nodes/code-block.js +99 -0
- package/lib/src/nodes/code-block.test.d.ts +1 -0
- package/lib/src/nodes/code-block.test.js +147 -0
- package/lib/src/nodes/entity.d.ts +11 -0
- package/lib/src/nodes/entity.js +35 -0
- package/lib/src/nodes/fibery-view.d.ts +2 -0
- package/lib/src/nodes/fibery-view.js +32 -0
- package/lib/src/nodes/heading.d.ts +4 -0
- package/lib/src/nodes/heading.js +65 -0
- package/lib/src/nodes/image-block.d.ts +2 -0
- package/lib/src/nodes/image-block.js +35 -0
- package/lib/src/nodes/important.d.ts +2 -0
- package/lib/src/nodes/important.js +11 -0
- package/lib/src/nodes/media.d.ts +4 -0
- package/lib/src/nodes/media.js +33 -0
- package/lib/src/nodes/mention.d.ts +11 -0
- package/lib/src/nodes/mention.js +35 -0
- package/lib/src/nodes/note.d.ts +2 -0
- package/lib/src/nodes/note.js +11 -0
- package/lib/src/nodes/paragraph.d.ts +2 -0
- package/lib/src/nodes/paragraph.js +20 -0
- package/lib/src/nodes/table-nodes.d.ts +1 -0
- package/lib/src/nodes/table-nodes.js +22 -0
- package/lib/src/nodes/types/inline-content.d.ts +7 -0
- package/lib/src/nodes/types/inline-content.js +2 -0
- package/lib/src/nodes/types/text.d.ts +5 -0
- package/lib/src/nodes/types/text.js +2 -0
- package/lib/src/nodes/video.d.ts +2 -0
- package/lib/src/nodes/video.js +49 -0
- package/lib/src/nodes/video.test.d.ts +1 -0
- package/lib/src/nodes/video.test.js +42 -0
- package/lib/test-helpers/index.d.ts +4 -0
- package/lib/test-helpers/index.js +21 -0
- package/package.json +5 -6
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const create_schema_1 = require("../create-schema");
|
|
4
|
+
const code_block_1 = require("./code-block");
|
|
5
|
+
const test_helpers_1 = require("../../test-helpers");
|
|
6
|
+
// import {DEFAULT_LANGUAGES} from "../../../../utils";
|
|
7
|
+
function makeSchema() {
|
|
8
|
+
return (0, create_schema_1.createSchema)();
|
|
9
|
+
}
|
|
10
|
+
describe(`schema code_block node`, () => {
|
|
11
|
+
const schema = makeSchema();
|
|
12
|
+
it("should have code property to be true", () => {
|
|
13
|
+
expect(schema.nodes.code_block.spec.code).toEqual(true);
|
|
14
|
+
});
|
|
15
|
+
describe("parse from html", () => {
|
|
16
|
+
describe("parse from editor encoded HTML", () => {
|
|
17
|
+
describe("when language is not set", () => {
|
|
18
|
+
it("converts to block code node", () => {
|
|
19
|
+
const doc = (0, test_helpers_1.fromHTML)('<pre><span>window.alert("hello");<span></pre>', schema);
|
|
20
|
+
expect(doc.firstChild.type.spec).toEqual(code_block_1.code_block);
|
|
21
|
+
});
|
|
22
|
+
it("has language attribute as null", () => {
|
|
23
|
+
const doc = (0, test_helpers_1.fromHTML)('<pre><span>window.alert("hello");<span></pre>', schema);
|
|
24
|
+
expect(doc.firstChild.attrs["language"]).toEqual(null);
|
|
25
|
+
});
|
|
26
|
+
});
|
|
27
|
+
describe("when language is set", () => {
|
|
28
|
+
it("converts to block code node", () => {
|
|
29
|
+
const doc = (0, test_helpers_1.fromHTML)('<pre data-language="javascript"><span>window.alert("hello");<span></pre>', schema);
|
|
30
|
+
expect(doc.firstChild.type.spec).toEqual(code_block_1.code_block);
|
|
31
|
+
});
|
|
32
|
+
// DEFAULT_LANGUAGES.forEach((language) => {
|
|
33
|
+
// it(`extracts language "${language.name}" from data-language attribute`, () => {
|
|
34
|
+
// const doc = fromHTML(
|
|
35
|
+
// `<pre data-language='${language.name}'><span>window.alert("hello");<span></pre>`,
|
|
36
|
+
// schema
|
|
37
|
+
// );
|
|
38
|
+
//
|
|
39
|
+
// expect(doc.firstChild!.attrs["language"]).toEqual(language.name);
|
|
40
|
+
// });
|
|
41
|
+
// });
|
|
42
|
+
});
|
|
43
|
+
it("preserves all newlines and whitespace", () => {
|
|
44
|
+
const doc = (0, test_helpers_1.fromHTML)("<pre><span></span> bar\n baz\n</pre>", schema);
|
|
45
|
+
expect(doc.firstChild.textContent).toEqual(" bar\n baz\n");
|
|
46
|
+
});
|
|
47
|
+
});
|
|
48
|
+
describe("parse from Bitbucket", () => {
|
|
49
|
+
describe("when language is not set", () => {
|
|
50
|
+
it("converts to block code node", () => {
|
|
51
|
+
const doc = (0, test_helpers_1.fromHTML)('<div class="codehilite"><pre><span>window.alert("hello");<span></pre></div>', schema);
|
|
52
|
+
expect(doc.firstChild.type.spec).toEqual(code_block_1.code_block);
|
|
53
|
+
});
|
|
54
|
+
it("has language attribute as null", () => {
|
|
55
|
+
const doc = (0, test_helpers_1.fromHTML)('<div class="codehilite"><pre><span>window.alert("hello");<span></pre></div>', schema);
|
|
56
|
+
const code_block = doc.firstChild;
|
|
57
|
+
expect(code_block.attrs.language).toEqual(null);
|
|
58
|
+
});
|
|
59
|
+
});
|
|
60
|
+
describe("when other class similar to language is set", () => {
|
|
61
|
+
it("has language attribute as null", () => {
|
|
62
|
+
const doc = (0, test_helpers_1.fromHTML)('<div class="codehilite nolanguage-javascript"><pre><span>window.alert("hello");<span></pre></div>', schema);
|
|
63
|
+
const code_block = doc.firstChild;
|
|
64
|
+
expect(code_block.attrs.language).toEqual(null);
|
|
65
|
+
});
|
|
66
|
+
});
|
|
67
|
+
});
|
|
68
|
+
it("should parse code block from tag with font-family monospace css", () => {
|
|
69
|
+
const doc = (0, test_helpers_1.fromHTML)(`<meta charset="utf-8"><div style="font-family: Menlo, Monaco, 'Courier New', monospace;">Code :D</div>`, schema);
|
|
70
|
+
expect(doc.firstChild.type.spec).toEqual(code_block_1.code_block);
|
|
71
|
+
});
|
|
72
|
+
it("should parse code block from tag with `whitespace: pre` css", () => {
|
|
73
|
+
const doc = (0, test_helpers_1.fromHTML)('<meta charset="utf-8"><div style="white-space: pre;">Hello</div>', schema);
|
|
74
|
+
expect(doc.firstChild.type.spec).toEqual(code_block_1.code_block);
|
|
75
|
+
});
|
|
76
|
+
it("should not create code block for `whitespace pre-wrap` css", () => {
|
|
77
|
+
const doc = (0, test_helpers_1.fromHTML)('<meta charset="utf-8"><div style="white-space: pre-wrap;">Hello</div>', schema);
|
|
78
|
+
expect(doc.firstChild.type.name).toEqual("paragraph");
|
|
79
|
+
});
|
|
80
|
+
describe("when language is set", () => {
|
|
81
|
+
it("converts to block code node", () => {
|
|
82
|
+
const doc = (0, test_helpers_1.fromHTML)('<div class="codehilite language-javascript"><pre><span>window.alert("hello");<span></pre></div>', schema);
|
|
83
|
+
expect(doc.firstChild.type.spec).toEqual(code_block_1.code_block);
|
|
84
|
+
});
|
|
85
|
+
// DEFAULT_LANGUAGES.forEach((language) => {
|
|
86
|
+
// it(`extracts language attribute from class "language-${language.name}"`, () => {
|
|
87
|
+
// const doc = fromHTML(
|
|
88
|
+
// `<div class="codehilite language-${language.name}"><pre><span>window.alert("hello");<span></pre></div>`,
|
|
89
|
+
// schema
|
|
90
|
+
// );
|
|
91
|
+
// const code_block = doc.firstChild!;
|
|
92
|
+
//
|
|
93
|
+
// expect(code_block.attrs.language).toEqual(language.name);
|
|
94
|
+
// });
|
|
95
|
+
// });
|
|
96
|
+
it("removes last new line", () => {
|
|
97
|
+
const doc = (0, test_helpers_1.fromHTML)('<div class="codehilite"><pre><span>hello world;<span><span>\n<span></pre></div>', schema);
|
|
98
|
+
expect(doc.firstChild.textContent).toEqual("hello world;");
|
|
99
|
+
});
|
|
100
|
+
it("preserves newlines in the middle and whitespace", () => {
|
|
101
|
+
const doc = (0, test_helpers_1.fromHTML)('<div class="codehilite"><pre><span></span> bar\n baz</pre></div>', schema);
|
|
102
|
+
expect(doc.firstChild.textContent).toEqual(" bar\n baz");
|
|
103
|
+
});
|
|
104
|
+
});
|
|
105
|
+
});
|
|
106
|
+
describe("convert to HTML", () => {
|
|
107
|
+
const schema = makeSchema();
|
|
108
|
+
describe("when language is not set", () => {
|
|
109
|
+
it("converts to pre tag", () => {
|
|
110
|
+
const code_block = schema.nodes.code_block.create();
|
|
111
|
+
expect((0, test_helpers_1.toHTML)(code_block, schema)).toContain("<pre");
|
|
112
|
+
});
|
|
113
|
+
it("does not set data-language attributes", () => {
|
|
114
|
+
const code_block = schema.nodes.code_block.create();
|
|
115
|
+
expect((0, test_helpers_1.toHTML)(code_block, schema)).not.toContain("data-language");
|
|
116
|
+
});
|
|
117
|
+
});
|
|
118
|
+
describe("when language is set to null", () => {
|
|
119
|
+
it("does not set data-language attributes", () => {
|
|
120
|
+
const code_block = schema.nodes.code_block.create({ language: null });
|
|
121
|
+
expect((0, test_helpers_1.toHTML)(code_block, schema)).not.toContain("data-language");
|
|
122
|
+
});
|
|
123
|
+
});
|
|
124
|
+
describe("when language is set to undefined", () => {
|
|
125
|
+
it("does not set data-language attributes", () => {
|
|
126
|
+
const code_block = schema.nodes.code_block.create({
|
|
127
|
+
language: undefined,
|
|
128
|
+
});
|
|
129
|
+
expect((0, test_helpers_1.toHTML)(code_block, schema)).not.toContain("data-language");
|
|
130
|
+
});
|
|
131
|
+
});
|
|
132
|
+
describe("when language is set to a value", () => {
|
|
133
|
+
it("converts to pre tag", () => {
|
|
134
|
+
const code_block = schema.nodes.code_block.create({
|
|
135
|
+
language: "javascript",
|
|
136
|
+
});
|
|
137
|
+
expect((0, test_helpers_1.toHTML)(code_block, schema)).toContain("<pre");
|
|
138
|
+
});
|
|
139
|
+
it("sets data-language attributes", () => {
|
|
140
|
+
const code_block = schema.nodes.code_block.create({
|
|
141
|
+
language: "javascript",
|
|
142
|
+
});
|
|
143
|
+
expect((0, test_helpers_1.toHTML)(code_block, schema)).toContain('data-language="javascript"');
|
|
144
|
+
});
|
|
145
|
+
});
|
|
146
|
+
});
|
|
147
|
+
});
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { NodeSpec } from "prosemirror-model";
|
|
2
|
+
export interface EntityAttributes {
|
|
3
|
+
id: string;
|
|
4
|
+
typeId: string;
|
|
5
|
+
text?: string;
|
|
6
|
+
}
|
|
7
|
+
export interface EntityDefinition {
|
|
8
|
+
type: "entity";
|
|
9
|
+
attrs: EntityAttributes;
|
|
10
|
+
}
|
|
11
|
+
export declare const entity: NodeSpec;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.entity = void 0;
|
|
4
|
+
exports.entity = {
|
|
5
|
+
inline: true,
|
|
6
|
+
group: "inline",
|
|
7
|
+
selectable: false,
|
|
8
|
+
attrs: {
|
|
9
|
+
id: { default: "" },
|
|
10
|
+
text: { default: "" },
|
|
11
|
+
typeId: { default: "" },
|
|
12
|
+
},
|
|
13
|
+
parseDOM: [
|
|
14
|
+
{
|
|
15
|
+
tag: "span[data-entity-id]",
|
|
16
|
+
getAttrs: (domNode) => {
|
|
17
|
+
const dom = domNode;
|
|
18
|
+
return {
|
|
19
|
+
id: dom.getAttribute("data-entity-id"),
|
|
20
|
+
text: dom.textContent,
|
|
21
|
+
typeId: dom.getAttribute("data-entity-type-id"),
|
|
22
|
+
};
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
],
|
|
26
|
+
toDOM(node) {
|
|
27
|
+
const { id, typeId, text } = node.attrs;
|
|
28
|
+
const attrs = {
|
|
29
|
+
"data-entity-id": id,
|
|
30
|
+
"data-entity-type-id": typeId,
|
|
31
|
+
contenteditable: "false",
|
|
32
|
+
};
|
|
33
|
+
return ["span", attrs, text];
|
|
34
|
+
},
|
|
35
|
+
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.fiberyView = void 0;
|
|
4
|
+
exports.fiberyView = {
|
|
5
|
+
inline: false,
|
|
6
|
+
group: "block",
|
|
7
|
+
selectable: true,
|
|
8
|
+
atom: true,
|
|
9
|
+
draggable: false,
|
|
10
|
+
attrs: {
|
|
11
|
+
id: { default: "" },
|
|
12
|
+
},
|
|
13
|
+
parseDOM: [
|
|
14
|
+
{
|
|
15
|
+
tag: "div[data-view-id]",
|
|
16
|
+
getAttrs: (domNode) => {
|
|
17
|
+
const dom = domNode;
|
|
18
|
+
return {
|
|
19
|
+
id: dom.getAttribute("data-view-id"),
|
|
20
|
+
};
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
],
|
|
24
|
+
toDOM(node) {
|
|
25
|
+
const { id } = node.attrs;
|
|
26
|
+
const attrs = {
|
|
27
|
+
"data-view-id": id,
|
|
28
|
+
contenteditable: "false",
|
|
29
|
+
};
|
|
30
|
+
return ["div", attrs, ""];
|
|
31
|
+
},
|
|
32
|
+
};
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.makeHeading = void 0;
|
|
4
|
+
const DEFAULT_GUID = "";
|
|
5
|
+
const makeHeading = ({ headingToDOM }) => ({
|
|
6
|
+
content: "inline*",
|
|
7
|
+
group: "block",
|
|
8
|
+
attrs: {
|
|
9
|
+
level: { default: 1 },
|
|
10
|
+
guid: { default: DEFAULT_GUID },
|
|
11
|
+
},
|
|
12
|
+
defining: true,
|
|
13
|
+
parseDOM: [
|
|
14
|
+
{
|
|
15
|
+
tag: "h1",
|
|
16
|
+
getAttrs: (dom) => ({
|
|
17
|
+
level: 1,
|
|
18
|
+
guid: dom.getAttribute("guid") || DEFAULT_GUID,
|
|
19
|
+
}),
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
tag: "h2",
|
|
23
|
+
getAttrs: (dom) => ({
|
|
24
|
+
level: 2,
|
|
25
|
+
guid: dom.getAttribute("guid") || DEFAULT_GUID,
|
|
26
|
+
}),
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
tag: "h3",
|
|
30
|
+
getAttrs: (dom) => ({
|
|
31
|
+
level: 3,
|
|
32
|
+
guid: dom.getAttribute("guid") || DEFAULT_GUID,
|
|
33
|
+
}),
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
tag: "h4",
|
|
37
|
+
getAttrs: (dom) => ({
|
|
38
|
+
level: 4,
|
|
39
|
+
guid: dom.getAttribute("guid") || DEFAULT_GUID,
|
|
40
|
+
}),
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
tag: "h5",
|
|
44
|
+
getAttrs: (dom) => ({
|
|
45
|
+
level: 5,
|
|
46
|
+
guid: dom.getAttribute("guid") || DEFAULT_GUID,
|
|
47
|
+
}),
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
tag: "h6",
|
|
51
|
+
getAttrs: (dom) => ({
|
|
52
|
+
level: 6,
|
|
53
|
+
guid: dom.getAttribute("guid") || DEFAULT_GUID,
|
|
54
|
+
}),
|
|
55
|
+
},
|
|
56
|
+
],
|
|
57
|
+
toDOM(node) {
|
|
58
|
+
if (headingToDOM) {
|
|
59
|
+
return headingToDOM(node);
|
|
60
|
+
}
|
|
61
|
+
const { guid } = node.attrs;
|
|
62
|
+
return ["h" + node.attrs.level, { guid }, 0];
|
|
63
|
+
},
|
|
64
|
+
});
|
|
65
|
+
exports.makeHeading = makeHeading;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.imageBlock = void 0;
|
|
4
|
+
exports.imageBlock = {
|
|
5
|
+
attrs: {
|
|
6
|
+
src: {},
|
|
7
|
+
alt: { default: null },
|
|
8
|
+
title: { default: null },
|
|
9
|
+
},
|
|
10
|
+
// ----------------
|
|
11
|
+
inline: false,
|
|
12
|
+
group: "block",
|
|
13
|
+
content: "inline*",
|
|
14
|
+
atom: true,
|
|
15
|
+
// ----------------
|
|
16
|
+
draggable: true,
|
|
17
|
+
parseDOM: [
|
|
18
|
+
{
|
|
19
|
+
tag: "img[src]",
|
|
20
|
+
getAttrs(domNode) {
|
|
21
|
+
const dom = domNode;
|
|
22
|
+
return {
|
|
23
|
+
src: dom.getAttribute("src"),
|
|
24
|
+
title: dom.getAttribute("title"),
|
|
25
|
+
alt: dom.getAttribute("alt"),
|
|
26
|
+
};
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
],
|
|
30
|
+
toDOM(node) {
|
|
31
|
+
const { src, alt, title } = node.attrs;
|
|
32
|
+
// return ["img", {src, alt, title}];
|
|
33
|
+
return ["div", {}, ["img", { src, alt, title }]];
|
|
34
|
+
},
|
|
35
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.important = void 0;
|
|
4
|
+
exports.important = {
|
|
5
|
+
content: "inline*",
|
|
6
|
+
group: "block",
|
|
7
|
+
parseDOM: [{ tag: "div.fibery-important" }],
|
|
8
|
+
toDOM() {
|
|
9
|
+
return ["div", { class: "fibery-important" }, ["p", 0]];
|
|
10
|
+
},
|
|
11
|
+
};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.makeMedia = void 0;
|
|
4
|
+
const makeMedia = ({ mediaToDom }) => ({
|
|
5
|
+
inline: false,
|
|
6
|
+
attrs: {
|
|
7
|
+
url: {},
|
|
8
|
+
},
|
|
9
|
+
group: "block",
|
|
10
|
+
draggable: true,
|
|
11
|
+
parseDOM: [
|
|
12
|
+
{
|
|
13
|
+
tag: "div[data-url]",
|
|
14
|
+
getAttrs(dom) {
|
|
15
|
+
return {
|
|
16
|
+
url: dom.getAttribute("data-url"),
|
|
17
|
+
};
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
],
|
|
21
|
+
toDOM(node) {
|
|
22
|
+
if (mediaToDom) {
|
|
23
|
+
return mediaToDom(node);
|
|
24
|
+
}
|
|
25
|
+
const { url } = node.attrs;
|
|
26
|
+
const attrs = {
|
|
27
|
+
"data-url": url,
|
|
28
|
+
contenteditable: "false",
|
|
29
|
+
};
|
|
30
|
+
return ["div", attrs, url];
|
|
31
|
+
},
|
|
32
|
+
});
|
|
33
|
+
exports.makeMedia = makeMedia;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { NodeSpec } from "prosemirror-model";
|
|
2
|
+
export interface MentionAttributes {
|
|
3
|
+
id: string;
|
|
4
|
+
typeId: string;
|
|
5
|
+
name?: string;
|
|
6
|
+
}
|
|
7
|
+
export interface MentionDefinition {
|
|
8
|
+
type: "mention";
|
|
9
|
+
attrs: MentionAttributes;
|
|
10
|
+
}
|
|
11
|
+
export declare const mention: NodeSpec;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.mention = void 0;
|
|
4
|
+
exports.mention = {
|
|
5
|
+
inline: true,
|
|
6
|
+
group: "inline",
|
|
7
|
+
selectable: false,
|
|
8
|
+
attrs: {
|
|
9
|
+
id: { default: "" },
|
|
10
|
+
name: { default: "" },
|
|
11
|
+
typeId: { default: "" },
|
|
12
|
+
},
|
|
13
|
+
parseDOM: [
|
|
14
|
+
{
|
|
15
|
+
tag: "span[data-mention-id]",
|
|
16
|
+
getAttrs: (domNode) => {
|
|
17
|
+
const dom = domNode;
|
|
18
|
+
return {
|
|
19
|
+
id: dom.getAttribute("data-mention-id"),
|
|
20
|
+
name: dom.textContent,
|
|
21
|
+
typeId: dom.getAttribute("data-mention-type-id"),
|
|
22
|
+
};
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
],
|
|
26
|
+
toDOM(node) {
|
|
27
|
+
const { id, typeId, name } = node.attrs;
|
|
28
|
+
const attrs = {
|
|
29
|
+
"data-mention-id": id,
|
|
30
|
+
"data-mention-type-id": typeId,
|
|
31
|
+
contenteditable: "false",
|
|
32
|
+
};
|
|
33
|
+
return ["span", attrs, name];
|
|
34
|
+
},
|
|
35
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.note = void 0;
|
|
4
|
+
exports.note = {
|
|
5
|
+
content: "inline*",
|
|
6
|
+
group: "block",
|
|
7
|
+
toDOM() {
|
|
8
|
+
return ["div", { class: "fibery-note" }, ["p", 0]];
|
|
9
|
+
},
|
|
10
|
+
parseDOM: [{ tag: "div.fibery-note" }],
|
|
11
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.paragraph = void 0;
|
|
4
|
+
exports.paragraph = {
|
|
5
|
+
content: "inline*",
|
|
6
|
+
group: "block",
|
|
7
|
+
attrs: {
|
|
8
|
+
guid: { default: "" },
|
|
9
|
+
},
|
|
10
|
+
parseDOM: [
|
|
11
|
+
{
|
|
12
|
+
tag: "p",
|
|
13
|
+
getAttrs: (dom) => ({ guid: dom.getAttribute("data-guid") }),
|
|
14
|
+
},
|
|
15
|
+
],
|
|
16
|
+
toDOM(node) {
|
|
17
|
+
const { guid } = node.attrs;
|
|
18
|
+
return ["p", { "data-guid": guid }, 0];
|
|
19
|
+
},
|
|
20
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const tableNodes: any;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.tableNodes = void 0;
|
|
4
|
+
// @ts-ignore
|
|
5
|
+
const prosemirror_tables_1 = require("prosemirror-tables");
|
|
6
|
+
exports.tableNodes = (0, prosemirror_tables_1.tableNodes)({
|
|
7
|
+
tableGroup: "block",
|
|
8
|
+
cellContent: "block+",
|
|
9
|
+
cellAttributes: {
|
|
10
|
+
background: {
|
|
11
|
+
default: null,
|
|
12
|
+
getFromDOM(dom) {
|
|
13
|
+
return dom.style.backgroundColor || null;
|
|
14
|
+
},
|
|
15
|
+
setDOMAttr(value, attrs) {
|
|
16
|
+
if (value) {
|
|
17
|
+
attrs.style = (attrs.style || "") + `background-color: ${value};`;
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
});
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { MentionDefinition as Mention } from "../mention";
|
|
2
|
+
import { EntityDefinition as Entity } from "../entity";
|
|
3
|
+
import { TextDefinition as Text } from "./text";
|
|
4
|
+
import { MarksObject } from "../../marks/types/mark";
|
|
5
|
+
export declare type InlineFormattedText = Text & MarksObject<unknown>;
|
|
6
|
+
export declare type InlineAtomic = Mention | Entity | unknown;
|
|
7
|
+
export declare type Inline = InlineFormattedText | InlineAtomic;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.video = void 0;
|
|
4
|
+
const DEFAULT_VIDEO_WIDTH = 400;
|
|
5
|
+
const DEFAULT_VIDEO_HEIGHT = 200;
|
|
6
|
+
exports.video = {
|
|
7
|
+
inline: false,
|
|
8
|
+
attrs: {
|
|
9
|
+
src: {},
|
|
10
|
+
type: {},
|
|
11
|
+
width: { default: DEFAULT_VIDEO_WIDTH },
|
|
12
|
+
height: { default: DEFAULT_VIDEO_HEIGHT },
|
|
13
|
+
title: { default: "" },
|
|
14
|
+
alignment: { default: ":alignment/block-center" },
|
|
15
|
+
},
|
|
16
|
+
group: "block",
|
|
17
|
+
draggable: true,
|
|
18
|
+
parseDOM: [
|
|
19
|
+
{
|
|
20
|
+
tag: "video",
|
|
21
|
+
getAttrs(domNode) {
|
|
22
|
+
const dom = domNode;
|
|
23
|
+
return {
|
|
24
|
+
src: dom.getAttribute("src"),
|
|
25
|
+
type: dom.getAttribute("type"),
|
|
26
|
+
width: Number(dom.getAttribute("width")) || DEFAULT_VIDEO_WIDTH,
|
|
27
|
+
height: Number(dom.getAttribute("height")) || DEFAULT_VIDEO_HEIGHT,
|
|
28
|
+
title: dom.getAttribute("title"),
|
|
29
|
+
};
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
],
|
|
33
|
+
toDOM(node) {
|
|
34
|
+
const { src, type, width = DEFAULT_VIDEO_WIDTH, height = DEFAULT_VIDEO_HEIGHT, title } = node.attrs;
|
|
35
|
+
return [
|
|
36
|
+
"video",
|
|
37
|
+
{
|
|
38
|
+
src,
|
|
39
|
+
type,
|
|
40
|
+
width,
|
|
41
|
+
height,
|
|
42
|
+
title,
|
|
43
|
+
playsinline: "",
|
|
44
|
+
controls: "",
|
|
45
|
+
preload: "metadata",
|
|
46
|
+
},
|
|
47
|
+
];
|
|
48
|
+
},
|
|
49
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const create_schema_1 = require("../create-schema");
|
|
4
|
+
const test_helpers_1 = require("../../test-helpers");
|
|
5
|
+
describe("schema video node", () => {
|
|
6
|
+
const schema = (0, create_schema_1.createSchema)();
|
|
7
|
+
it("serializes to the correct HTML", () => {
|
|
8
|
+
const node = schema.nodes.video.create({
|
|
9
|
+
src: "/api/files/secret",
|
|
10
|
+
type: "video/quicktime",
|
|
11
|
+
width: 400,
|
|
12
|
+
height: 200,
|
|
13
|
+
title: "Video",
|
|
14
|
+
alignment: ":alignment/block-center",
|
|
15
|
+
});
|
|
16
|
+
const html = (0, test_helpers_1.toHTML)(node, schema);
|
|
17
|
+
expect(html).toContain(`src="/api/files/secret"`);
|
|
18
|
+
expect(html).toContain(`type="video/quicktime"`);
|
|
19
|
+
expect(html).toContain(`width="400"`);
|
|
20
|
+
expect(html).toContain(`height="200"`);
|
|
21
|
+
expect(html).toContain(`title="Video"`);
|
|
22
|
+
});
|
|
23
|
+
it("parses html", () => {
|
|
24
|
+
const doc = (0, test_helpers_1.fromHTML)(`
|
|
25
|
+
<video
|
|
26
|
+
src="/api/files/secret"
|
|
27
|
+
type="video/quicktime"
|
|
28
|
+
width="400"
|
|
29
|
+
height="200"
|
|
30
|
+
title="Video"
|
|
31
|
+
/>
|
|
32
|
+
`, schema);
|
|
33
|
+
const video = doc.firstChild;
|
|
34
|
+
expect(video.attrs).toMatchObject({
|
|
35
|
+
src: "/api/files/secret",
|
|
36
|
+
type: "video/quicktime",
|
|
37
|
+
width: 400,
|
|
38
|
+
height: 200,
|
|
39
|
+
title: "Video",
|
|
40
|
+
});
|
|
41
|
+
});
|
|
42
|
+
});
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { Schema, Node as PMNode, ParseOptions } from "prosemirror-model";
|
|
2
|
+
export declare const fromHTML: (html: string, schema: Schema, options?: ParseOptions) => PMNode;
|
|
3
|
+
export declare const toDOM: (node: PMNode, schema: Schema) => Node;
|
|
4
|
+
export declare const toHTML: (node: PMNode, schema: Schema) => string;
|