@fibery/prosemirror-schema 4.14.1 → 4.14.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/src/create-schema.js +8 -3
- package/lib/src/marks/code.d.ts +5 -0
- package/lib/src/marks/code.js +13 -0
- package/lib/src/marks/em.d.ts +6 -0
- package/lib/src/marks/em.js +20 -0
- package/lib/src/marks/link.d.ts +6 -1
- package/lib/src/marks/link.js +34 -19
- package/lib/src/marks/strong.d.ts +6 -0
- package/lib/src/marks/strong.js +34 -0
- package/lib/src/marks/text-background-color.js +32 -30
- package/lib/src/nodes/callout.d.ts +1 -1
- package/lib/src/nodes/emoji.d.ts +2 -2
- package/lib/src/nodes/file.d.ts +2 -2
- package/lib/src/nodes/image-block.js +4 -5
- package/lib/src/nodes/types/inline-content.d.ts +4 -1
- package/package.json +13 -14
- package/lib/src/marks/types/mark.d.ts +0 -3
- package/lib/src/marks/types/mark.js +0 -2
package/lib/src/create-schema.js
CHANGED
|
@@ -31,6 +31,9 @@ const hint_query_1 = require("./marks/hint-query");
|
|
|
31
31
|
const text_background_color_1 = require("./marks/text-background-color");
|
|
32
32
|
const linked_highlight_1 = require("./marks/linked-highlight");
|
|
33
33
|
const link_1 = require("./marks/link");
|
|
34
|
+
const em_1 = require("./marks/em");
|
|
35
|
+
const strong_1 = require("./marks/strong");
|
|
36
|
+
const code_1 = require("./marks/code");
|
|
34
37
|
const createSchema = ({ sharedColorGenerator = null, headingToDOM = null, mediaToDom = null, isImageBlockEnabled = false, fiberyViewEnabled = false, emojiOptions, } = {}) => {
|
|
35
38
|
prosemirror_schema_basic_1.nodes.code_block = code_block_1.code_block;
|
|
36
39
|
prosemirror_schema_basic_1.nodes.paragraph = paragraph_1.paragraph;
|
|
@@ -38,8 +41,10 @@ const createSchema = ({ sharedColorGenerator = null, headingToDOM = null, mediaT
|
|
|
38
41
|
const base = new prosemirror_model_1.Schema({
|
|
39
42
|
nodes: prosemirror_schema_basic_1.nodes,
|
|
40
43
|
marks: {
|
|
41
|
-
|
|
42
|
-
|
|
44
|
+
link: link_1.link,
|
|
45
|
+
em: em_1.em,
|
|
46
|
+
strong: strong_1.strong,
|
|
47
|
+
code: code_1.code,
|
|
43
48
|
linkedhighlight: (0, linked_highlight_1.makeLinkedHighlight)({ sharedColorGenerator }),
|
|
44
49
|
linkedhighlightentity: (0, linked_highlight_1.makeLinkedHighlightEntity)({ sharedColorGenerator }),
|
|
45
50
|
},
|
|
@@ -92,7 +97,7 @@ exports.Basic = {
|
|
|
92
97
|
nodes: prosemirror_schema_basic_1.nodes,
|
|
93
98
|
marks: prosemirror_schema_basic_1.marks,
|
|
94
99
|
fibery: {
|
|
95
|
-
link:
|
|
100
|
+
link: link_1.link,
|
|
96
101
|
strike: strike_1.strike,
|
|
97
102
|
underline: underline_1.underline,
|
|
98
103
|
textBackgroundColor: text_background_color_1.textBackgroundColor,
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.code = void 0;
|
|
4
|
+
const codeDOM = ["code", 0];
|
|
5
|
+
/**
|
|
6
|
+
Code font mark. Represented as a `<code>` element.
|
|
7
|
+
*/
|
|
8
|
+
exports.code = {
|
|
9
|
+
parseDOM: [{ tag: "code" }],
|
|
10
|
+
toDOM() {
|
|
11
|
+
return codeDOM;
|
|
12
|
+
},
|
|
13
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.em = void 0;
|
|
4
|
+
const emDOM = ["em", 0];
|
|
5
|
+
/**
|
|
6
|
+
An emphasis mark. Rendered as an `<em>` element. Has parse rules
|
|
7
|
+
that also match `<i>` and `font-style: italic`.
|
|
8
|
+
*/
|
|
9
|
+
exports.em = {
|
|
10
|
+
parseDOM: [
|
|
11
|
+
{ tag: "i" },
|
|
12
|
+
{ tag: "em" },
|
|
13
|
+
{ style: "font-style=italic" },
|
|
14
|
+
/* eslint-disable-next-line eqeqeq */
|
|
15
|
+
{ style: "font-style=normal", clearMark: (m) => m.type.name == "em" },
|
|
16
|
+
],
|
|
17
|
+
toDOM() {
|
|
18
|
+
return emDOM;
|
|
19
|
+
},
|
|
20
|
+
};
|
package/lib/src/marks/link.d.ts
CHANGED
|
@@ -1,2 +1,7 @@
|
|
|
1
1
|
import { MarkSpec } from "prosemirror-model";
|
|
2
|
-
|
|
2
|
+
/**
|
|
3
|
+
A link. Has `href` and `title` attributes. `title`
|
|
4
|
+
defaults to the empty string. Rendered and parsed as an `<a>`
|
|
5
|
+
element.
|
|
6
|
+
*/
|
|
7
|
+
export declare const link: MarkSpec;
|
package/lib/src/marks/link.js
CHANGED
|
@@ -1,24 +1,39 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.link = void 0;
|
|
4
4
|
const httpRegex = /^[-a-zA-Z0-9@:%._+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b[-a-zA-Z0-9()@:%_+.~#?&/=]*$/;
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
5
|
+
/**
|
|
6
|
+
A link. Has `href` and `title` attributes. `title`
|
|
7
|
+
defaults to the empty string. Rendered and parsed as an `<a>`
|
|
8
|
+
element.
|
|
9
|
+
*/
|
|
10
|
+
exports.link = {
|
|
11
|
+
attrs: {
|
|
12
|
+
href: {},
|
|
13
|
+
title: { default: null },
|
|
14
|
+
},
|
|
15
|
+
inclusive: false,
|
|
16
|
+
parseDOM: [
|
|
17
|
+
{
|
|
18
|
+
tag: "a[href]",
|
|
19
|
+
getAttrs(domNode) {
|
|
20
|
+
const dom = domNode;
|
|
21
|
+
return { href: dom.getAttribute("href"), title: dom.getAttribute("title") };
|
|
22
|
+
},
|
|
21
23
|
},
|
|
22
|
-
|
|
24
|
+
],
|
|
25
|
+
toDOM(node) {
|
|
26
|
+
const { href } = node.attrs;
|
|
27
|
+
let fixedHref = href;
|
|
28
|
+
if (href && !href.startsWith("mailto:") && !fixedHref.startsWith("http") && !fixedHref.startsWith("/")) {
|
|
29
|
+
if (httpRegex.test(href)) {
|
|
30
|
+
fixedHref = `https://${href}`;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
return [
|
|
34
|
+
"a",
|
|
35
|
+
{ href: fixedHref, target: "_blank", class: "prosemirror-link", rel: "noopener noreferrer nofollow" },
|
|
36
|
+
0,
|
|
37
|
+
];
|
|
38
|
+
},
|
|
23
39
|
};
|
|
24
|
-
exports.makeLink = makeLink;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.strong = void 0;
|
|
4
|
+
const strongDOM = ["strong", 0];
|
|
5
|
+
/**
|
|
6
|
+
A strong mark. Rendered as `<strong>`, parse rules also match
|
|
7
|
+
`<b>` and `font-weight: bold`.
|
|
8
|
+
*/
|
|
9
|
+
exports.strong = {
|
|
10
|
+
parseDOM: [
|
|
11
|
+
{ tag: "strong" },
|
|
12
|
+
// This works around a Google Docs misbehavior where
|
|
13
|
+
// pasted content will be inexplicably wrapped in `<b>`
|
|
14
|
+
// tags with a font-weight normal.
|
|
15
|
+
{
|
|
16
|
+
tag: "b",
|
|
17
|
+
getAttrs: (dom) => {
|
|
18
|
+
/* eslint-disable-next-line eqeqeq */
|
|
19
|
+
return dom.style.fontWeight != "normal" && null;
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
/* eslint-disable-next-line eqeqeq */
|
|
23
|
+
{ style: "font-weight=400", clearMark: (m) => m.type.name == "strong" },
|
|
24
|
+
{
|
|
25
|
+
style: "font-weight",
|
|
26
|
+
getAttrs: (value) => {
|
|
27
|
+
return /^(bold(er)?|[5-9]\d{2,})$/.test(value) && null;
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
],
|
|
31
|
+
toDOM() {
|
|
32
|
+
return strongDOM;
|
|
33
|
+
},
|
|
34
|
+
};
|
|
@@ -1,39 +1,41 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.textBackgroundColor = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
4
|
+
var Color;
|
|
5
|
+
(function (Color) {
|
|
6
|
+
Color["Yellow"] = "YELLOW";
|
|
7
|
+
Color["Green"] = "GREEN";
|
|
8
|
+
Color["Aquamarine"] = "AQUAMARINE";
|
|
9
|
+
Color["Aqua"] = "AQUA";
|
|
10
|
+
Color["Blue"] = "BLUE";
|
|
11
|
+
Color["Purple"] = "PURPLE";
|
|
12
|
+
Color["Pink"] = "PINK";
|
|
13
|
+
Color["Red"] = "RED";
|
|
14
|
+
Color["Grey"] = "GREY";
|
|
15
|
+
})(Color || (Color = {}));
|
|
16
|
+
const isColor = (color) => {
|
|
17
|
+
return Object.values(Color).includes(color);
|
|
8
18
|
};
|
|
9
|
-
//
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
RED: "#fce9e9",
|
|
21
|
-
GREY: "#e7e9eb",
|
|
22
|
-
};
|
|
23
|
-
if (Object.values(LEGACY_RAW_COLORS_BY_COLORS_NAMES).includes(color)) {
|
|
24
|
-
const entry = Object.entries(LEGACY_RAW_COLORS_BY_COLORS_NAMES).find(([, value]) => value === color);
|
|
25
|
-
return entry[0];
|
|
26
|
-
}
|
|
27
|
-
return DEFAULT_COLOR;
|
|
19
|
+
// Map hex values to color names for backwards compatibility with legacy data
|
|
20
|
+
const oldValueToColorLookup = {
|
|
21
|
+
["#f6f1a2"]: Color.Yellow,
|
|
22
|
+
["#d2faad"]: Color.Green,
|
|
23
|
+
["#befccc"]: Color.Aquamarine,
|
|
24
|
+
["#bbf9f8"]: Color.Aqua,
|
|
25
|
+
["#e0f0fe"]: Color.Blue,
|
|
26
|
+
["#f1ebfe"]: Color.Purple,
|
|
27
|
+
["#fce7fb"]: Color.Pink,
|
|
28
|
+
["#fce9e9"]: Color.Red,
|
|
29
|
+
["#e7e9eb"]: Color.Grey,
|
|
28
30
|
};
|
|
29
|
-
const
|
|
30
|
-
if (
|
|
31
|
+
const validateColorName = (color) => {
|
|
32
|
+
if (isColor(color)) {
|
|
31
33
|
return color;
|
|
32
34
|
}
|
|
33
|
-
return
|
|
35
|
+
return oldValueToColorLookup[color] || Color.Yellow;
|
|
34
36
|
};
|
|
35
|
-
const getClassName = (
|
|
36
|
-
return `text-background-color ${
|
|
37
|
+
const getClassName = (color) => {
|
|
38
|
+
return `text-background-color ${color.toLowerCase()}`;
|
|
37
39
|
};
|
|
38
40
|
exports.textBackgroundColor = {
|
|
39
41
|
attrs: {
|
|
@@ -46,14 +48,14 @@ exports.textBackgroundColor = {
|
|
|
46
48
|
getAttrs: (domNode) => {
|
|
47
49
|
const dom = domNode;
|
|
48
50
|
return {
|
|
49
|
-
color: dom.getAttribute("data-color") ||
|
|
51
|
+
color: dom.getAttribute("data-color") || Color.Yellow,
|
|
50
52
|
};
|
|
51
53
|
},
|
|
52
54
|
},
|
|
53
55
|
],
|
|
54
56
|
toDOM(node) {
|
|
55
57
|
const color = node.attrs.color;
|
|
56
|
-
const colorName =
|
|
58
|
+
const colorName = validateColorName(color);
|
|
57
59
|
const className = getClassName(colorName);
|
|
58
60
|
return [
|
|
59
61
|
"span",
|
package/lib/src/nodes/emoji.d.ts
CHANGED
|
@@ -19,8 +19,8 @@ export declare const makeEmoji: ({ getEmoji }?: EmojiOptions) => {
|
|
|
19
19
|
leafText: (node: import("prosemirror-model").Node) => any;
|
|
20
20
|
parseDOM: {
|
|
21
21
|
tag: string;
|
|
22
|
-
getAttrs(domNode:
|
|
23
|
-
code: string
|
|
22
|
+
getAttrs(domNode: HTMLElement): {
|
|
23
|
+
code: string;
|
|
24
24
|
};
|
|
25
25
|
}[];
|
|
26
26
|
toDOM(node: import("prosemirror-model").Node): [string, {
|
package/lib/src/nodes/file.d.ts
CHANGED
|
@@ -21,9 +21,9 @@ export declare const file: {
|
|
|
21
21
|
leafText: (node: import("prosemirror-model").Node) => any;
|
|
22
22
|
parseDOM: {
|
|
23
23
|
tag: string;
|
|
24
|
-
getAttrs(domNode:
|
|
24
|
+
getAttrs(domNode: HTMLElement): {
|
|
25
25
|
src: string | null;
|
|
26
|
-
title: string
|
|
26
|
+
title: string;
|
|
27
27
|
size: string | null;
|
|
28
28
|
type: string | null;
|
|
29
29
|
};
|
|
@@ -7,14 +7,14 @@ exports.imageBlock = {
|
|
|
7
7
|
src: {},
|
|
8
8
|
alt: { default: null },
|
|
9
9
|
title: { default: null },
|
|
10
|
+
size: { default: null },
|
|
11
|
+
type: { default: null },
|
|
10
12
|
...(0, resizable_node_attrs_1.createDefaultAttrs)(),
|
|
11
13
|
},
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
group: "block", // group: "inline",
|
|
14
|
+
inline: false,
|
|
15
|
+
group: "block",
|
|
15
16
|
content: "inline*",
|
|
16
17
|
atom: true,
|
|
17
|
-
// ----------------
|
|
18
18
|
draggable: true,
|
|
19
19
|
parseDOM: [
|
|
20
20
|
{
|
|
@@ -38,7 +38,6 @@ exports.imageBlock = {
|
|
|
38
38
|
title,
|
|
39
39
|
...(0, resizable_node_attrs_1.createToDomAttrs)(node.attrs),
|
|
40
40
|
};
|
|
41
|
-
// return ["img", {src, alt, title}];
|
|
42
41
|
return ["div", {}, ["img", attrs]];
|
|
43
42
|
},
|
|
44
43
|
};
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import { MentionDefinition as Mention } from "../mention";
|
|
2
2
|
import { EntityDefinition as Entity } from "../entity";
|
|
3
3
|
import { TextDefinition as Text } from "./text";
|
|
4
|
-
|
|
4
|
+
interface MarksObject<T> {
|
|
5
|
+
marks?: Array<T>;
|
|
6
|
+
}
|
|
5
7
|
export type InlineFormattedText = Text & MarksObject<unknown>;
|
|
6
8
|
export type InlineAtomic = Mention | Entity | unknown;
|
|
7
9
|
export type Inline = InlineFormattedText | InlineAtomic;
|
|
10
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fibery/prosemirror-schema",
|
|
3
|
-
"version": "4.14.
|
|
3
|
+
"version": "4.14.3",
|
|
4
4
|
"description": "Fibery prosemirror schema",
|
|
5
5
|
"main": "./lib/index.js",
|
|
6
6
|
"types": "./lib/index.d.ts",
|
|
@@ -24,24 +24,23 @@
|
|
|
24
24
|
"private": false,
|
|
25
25
|
"dependencies": {
|
|
26
26
|
"prosemirror-schema-basic": "1.2.2",
|
|
27
|
-
"uuid": "
|
|
27
|
+
"uuid": "11.1.0"
|
|
28
28
|
},
|
|
29
29
|
"peerDependencies": {
|
|
30
|
-
"prosemirror-model": "
|
|
31
|
-
"prosemirror-schema-list": "
|
|
32
|
-
"prosemirror-tables": "1.
|
|
30
|
+
"prosemirror-model": "1.25.4",
|
|
31
|
+
"prosemirror-schema-list": "1.3.0",
|
|
32
|
+
"prosemirror-tables": "1.4.2"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
|
-
"@types/jest": "
|
|
36
|
-
"
|
|
37
|
-
"jest": "
|
|
38
|
-
"
|
|
39
|
-
"prosemirror-model": "1.19.4",
|
|
35
|
+
"@types/jest": "30.0.0",
|
|
36
|
+
"jest": "30.2.0",
|
|
37
|
+
"jest-junit": "16.0.0",
|
|
38
|
+
"prosemirror-model": "1.25.4",
|
|
40
39
|
"prosemirror-schema-list": "1.3.0",
|
|
41
|
-
"prosemirror-tables": "1.
|
|
42
|
-
"typescript": "5.
|
|
43
|
-
"@fibery/
|
|
44
|
-
"@fibery/
|
|
40
|
+
"prosemirror-tables": "1.4.2",
|
|
41
|
+
"typescript": "5.9.3",
|
|
42
|
+
"@fibery/babel-preset": "7.4.1",
|
|
43
|
+
"@fibery/eslint-config": "8.6.2"
|
|
45
44
|
},
|
|
46
45
|
"jest": {
|
|
47
46
|
"testEnvironment": "jsdom",
|