@fibery/prosemirror-schema 4.16.1 → 4.17.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/jest.config.cjs +12 -0
- package/lib/jest.config.d.cts +3 -0
- package/lib/src/create-schema.d.ts +4 -24
- package/lib/src/marks/em.d.ts +3 -3
- package/lib/src/marks/em.js +4 -5
- package/lib/src/marks/strong.d.ts +3 -3
- package/lib/src/marks/strong.js +5 -7
- package/lib/src/marks/text-background-color.js +26 -10
- package/lib/src/nodes/table-nodes.d.ts +2 -1
- package/package.json +21 -35
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/** @type {import('@jest/schemas').InitialOptions} */
|
|
3
|
+
const config = {
|
|
4
|
+
collectCoverageFrom: ["src/**/*.{js,jsx,ts,tsx}", "!src/**/*.d.ts"],
|
|
5
|
+
coveragePathIgnorePatterns: ["/node_modules/"],
|
|
6
|
+
coverageReporters: ["text", "cobertura"],
|
|
7
|
+
testEnvironment: "jsdom",
|
|
8
|
+
testEnvironmentOptions: {
|
|
9
|
+
customExportConditions: ["@fibery/source"],
|
|
10
|
+
},
|
|
11
|
+
};
|
|
12
|
+
module.exports = config;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Node, Schema } from "prosemirror-model";
|
|
1
|
+
import { Node, Schema, type NodeSpec, type MarkSpec } from "prosemirror-model";
|
|
2
2
|
import { EmojiOptions } from "./nodes/emoji";
|
|
3
3
|
type Params = {
|
|
4
4
|
isImageBlockEnabled?: boolean;
|
|
@@ -10,28 +10,8 @@ type Params = {
|
|
|
10
10
|
};
|
|
11
11
|
export declare const createSchema: ({ sharedColorGenerator, headingToDOM, mediaToDom, isImageBlockEnabled, fiberyViewEnabled, emojiOptions, }?: Params) => Schema;
|
|
12
12
|
export declare const Basic: {
|
|
13
|
-
nodes:
|
|
14
|
-
|
|
15
|
-
|
|
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
|
-
};
|
|
13
|
+
nodes: Record<string, NodeSpec>;
|
|
14
|
+
marks: Record<string, MarkSpec>;
|
|
15
|
+
fibery: Record<string, MarkSpec>;
|
|
36
16
|
};
|
|
37
17
|
export {};
|
package/lib/src/marks/em.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { MarkSpec } from "prosemirror-model";
|
|
2
2
|
/**
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
An emphasis mark. Rendered as an `<em>` element. Has parse rules
|
|
4
|
+
that also match `<i>` and `font-style: italic`.
|
|
5
|
+
*/
|
|
6
6
|
export declare const em: MarkSpec;
|
package/lib/src/marks/em.js
CHANGED
|
@@ -3,16 +3,15 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.em = void 0;
|
|
4
4
|
const emDOM = ["em", 0];
|
|
5
5
|
/**
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
An emphasis mark. Rendered as an `<em>` element. Has parse rules
|
|
7
|
+
that also match `<i>` and `font-style: italic`.
|
|
8
|
+
*/
|
|
9
9
|
exports.em = {
|
|
10
10
|
parseDOM: [
|
|
11
11
|
{ tag: "i" },
|
|
12
12
|
{ tag: "em" },
|
|
13
13
|
{ style: "font-style=italic" },
|
|
14
|
-
|
|
15
|
-
{ style: "font-style=normal", clearMark: (m) => m.type.name == "em" },
|
|
14
|
+
{ style: "font-style=normal", clearMark: (m) => m.type.name === "em" },
|
|
16
15
|
],
|
|
17
16
|
toDOM() {
|
|
18
17
|
return emDOM;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { MarkSpec } from "prosemirror-model";
|
|
2
2
|
/**
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
A strong mark. Rendered as `<strong>`, parse rules also match
|
|
4
|
+
`<b>` and `font-weight: bold`.
|
|
5
|
+
*/
|
|
6
6
|
export declare const strong: MarkSpec;
|
package/lib/src/marks/strong.js
CHANGED
|
@@ -3,9 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.strong = void 0;
|
|
4
4
|
const strongDOM = ["strong", 0];
|
|
5
5
|
/**
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
A strong mark. Rendered as `<strong>`, parse rules also match
|
|
7
|
+
`<b>` and `font-weight: bold`.
|
|
8
|
+
*/
|
|
9
9
|
exports.strong = {
|
|
10
10
|
parseDOM: [
|
|
11
11
|
{ tag: "strong" },
|
|
@@ -15,12 +15,10 @@ exports.strong = {
|
|
|
15
15
|
{
|
|
16
16
|
tag: "b",
|
|
17
17
|
getAttrs: (dom) => {
|
|
18
|
-
|
|
19
|
-
return dom.style.fontWeight != "normal" && null;
|
|
18
|
+
return dom.style.fontWeight !== "normal" && null;
|
|
20
19
|
},
|
|
21
20
|
},
|
|
22
|
-
|
|
23
|
-
{ style: "font-weight=400", clearMark: (m) => m.type.name == "strong" },
|
|
21
|
+
{ style: "font-weight=400", clearMark: (m) => m.type.name === "strong" },
|
|
24
22
|
{
|
|
25
23
|
style: "font-weight",
|
|
26
24
|
getAttrs: (value) => {
|
|
@@ -18,6 +18,7 @@ const isColorToken = (text) => {
|
|
|
18
18
|
};
|
|
19
19
|
// Previously we used to store raw color value in the attribute
|
|
20
20
|
const persistedRawColorToColorTokenLookup = {
|
|
21
|
+
["HIGHLIGHT-SEARCH"]: ColorToken.Yellow,
|
|
21
22
|
["#f6f1a2"]: ColorToken.Yellow,
|
|
22
23
|
["#d2faad"]: ColorToken.Green,
|
|
23
24
|
["#befccc"]: ColorToken.Aquamarine,
|
|
@@ -29,41 +30,56 @@ const persistedRawColorToColorTokenLookup = {
|
|
|
29
30
|
["#e7e9eb"]: ColorToken.Grey,
|
|
30
31
|
};
|
|
31
32
|
const validateColorToken = (color) => {
|
|
33
|
+
if (!color) {
|
|
34
|
+
return undefined;
|
|
35
|
+
}
|
|
32
36
|
if (isColorToken(color)) {
|
|
33
37
|
return color;
|
|
34
38
|
}
|
|
35
|
-
return persistedRawColorToColorTokenLookup[color] ||
|
|
39
|
+
return persistedRawColorToColorTokenLookup[color] || undefined;
|
|
36
40
|
};
|
|
37
|
-
const getClassName = (
|
|
38
|
-
return
|
|
41
|
+
const getClassName = (bgColorToken, fgColorToken) => {
|
|
42
|
+
return [
|
|
43
|
+
`text-background-color`,
|
|
44
|
+
bgColorToken ? `bg-${bgColorToken.toLowerCase()}` : null,
|
|
45
|
+
fgColorToken ? `fg-${fgColorToken.toLowerCase()}` : null,
|
|
46
|
+
]
|
|
47
|
+
.filter(Boolean)
|
|
48
|
+
.join(` `);
|
|
39
49
|
};
|
|
40
50
|
exports.textBackgroundColor = {
|
|
41
51
|
attrs: {
|
|
42
52
|
guid: { default: "" },
|
|
43
|
-
color: { default:
|
|
53
|
+
color: { default: undefined },
|
|
54
|
+
bgColor: { default: undefined },
|
|
55
|
+
fgColor: { default: undefined },
|
|
44
56
|
},
|
|
45
57
|
parseDOM: [
|
|
46
58
|
{
|
|
47
59
|
tag: "span[data-text-background-color]",
|
|
48
60
|
getAttrs: (domNode) => {
|
|
49
61
|
const dom = domNode;
|
|
62
|
+
const bgColor = dom.getAttribute("data-bg-color") || dom.getAttribute("data-color") || undefined;
|
|
63
|
+
const fgColor = dom.getAttribute("data-fg-color") || undefined;
|
|
50
64
|
return {
|
|
51
|
-
|
|
65
|
+
bgColor: bgColor,
|
|
66
|
+
fgColor: fgColor,
|
|
52
67
|
};
|
|
53
68
|
},
|
|
54
69
|
},
|
|
55
70
|
],
|
|
56
71
|
toDOM(node) {
|
|
57
|
-
const
|
|
58
|
-
const
|
|
59
|
-
const
|
|
72
|
+
const bgColor = node.attrs.bgColor || node.attrs.color;
|
|
73
|
+
const fgColor = node.attrs.fgColor;
|
|
74
|
+
const bgColorToken = validateColorToken(bgColor);
|
|
60
75
|
return [
|
|
61
76
|
"span",
|
|
62
77
|
{
|
|
63
78
|
"data-text-background-color": "true",
|
|
64
79
|
"data-guid": node.attrs.guid,
|
|
65
|
-
"data-color":
|
|
66
|
-
|
|
80
|
+
"data-bg-color": bgColor || undefined,
|
|
81
|
+
"data-fg-color": fgColor || undefined,
|
|
82
|
+
class: getClassName(bgColorToken, fgColor),
|
|
67
83
|
},
|
|
68
84
|
];
|
|
69
85
|
},
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import type { NodeSpec } from "prosemirror-model";
|
|
2
|
+
export declare const tableNodes: Record<string, NodeSpec>;
|
package/package.json
CHANGED
|
@@ -1,66 +1,52 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fibery/prosemirror-schema",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.17.0",
|
|
4
|
+
"private": false,
|
|
4
5
|
"description": "Fibery prosemirror schema",
|
|
5
|
-
"main": "./lib/index.js",
|
|
6
|
-
"types": "./lib/index.d.ts",
|
|
7
6
|
"files": [
|
|
8
7
|
"/lib"
|
|
9
8
|
],
|
|
9
|
+
"main": "./lib/index.js",
|
|
10
10
|
"exports": {
|
|
11
11
|
".": {
|
|
12
12
|
"types": "./lib/index.d.ts",
|
|
13
|
+
"@fibery/source": "./index.ts",
|
|
13
14
|
"default": "./lib/index.js"
|
|
14
15
|
},
|
|
15
|
-
"./src/nodes/fibery-section":
|
|
16
|
+
"./src/nodes/fibery-section": {
|
|
17
|
+
"@fibery/source": "./src/nodes/fibery-section.ts",
|
|
18
|
+
"default": "./lib/src/nodes/fibery-section.js"
|
|
19
|
+
},
|
|
16
20
|
"./src/nodes/fibery-section.d.ts": "./lib/src/nodes/fibery-section.d.ts",
|
|
17
21
|
"./lib/src/nodes/fibery-section": "./lib/src/nodes/fibery-section.js",
|
|
18
22
|
"./lib/src/nodes/fibery-section.d.ts": "./lib/src/nodes/fibery-section.d.ts"
|
|
19
23
|
},
|
|
20
|
-
"fiberyDevExports": {
|
|
21
|
-
".": "./index.ts",
|
|
22
|
-
"./src/nodes/fibery-section": "./src/nodes/fibery-section.ts"
|
|
23
|
-
},
|
|
24
|
-
"private": false,
|
|
25
24
|
"dependencies": {
|
|
26
|
-
"prosemirror-schema-basic": "1.2.2",
|
|
27
|
-
"uuid": "11.1.0"
|
|
28
|
-
},
|
|
29
|
-
"peerDependencies": {
|
|
30
25
|
"prosemirror-model": "1.25.4",
|
|
26
|
+
"prosemirror-schema-basic": "1.2.2",
|
|
31
27
|
"prosemirror-schema-list": "1.3.0",
|
|
32
|
-
"prosemirror-tables": "1.4.2"
|
|
28
|
+
"prosemirror-tables": "1.4.2",
|
|
29
|
+
"uuid": "11.1.0"
|
|
33
30
|
},
|
|
34
31
|
"devDependencies": {
|
|
35
32
|
"@types/jest": "30.0.0",
|
|
36
33
|
"jest": "30.2.0",
|
|
37
34
|
"jest-junit": "16.0.0",
|
|
35
|
+
"typescript": "6.0.1-rc",
|
|
36
|
+
"@fibery/babel-preset": "7.4.2"
|
|
37
|
+
},
|
|
38
|
+
"peerDependencies": {
|
|
38
39
|
"prosemirror-model": "1.25.4",
|
|
39
40
|
"prosemirror-schema-list": "1.3.0",
|
|
40
|
-
"prosemirror-tables": "1.4.2"
|
|
41
|
-
"typescript": "5.9.3",
|
|
42
|
-
"@fibery/babel-preset": "7.4.2",
|
|
43
|
-
"@fibery/eslint-config": "9.0.1"
|
|
44
|
-
},
|
|
45
|
-
"jest": {
|
|
46
|
-
"testEnvironment": "jsdom",
|
|
47
|
-
"coveragePathIgnorePatterns": [
|
|
48
|
-
"/node_modules/"
|
|
49
|
-
],
|
|
50
|
-
"collectCoverageFrom": [
|
|
51
|
-
"src/**/*.{js,jsx,ts,tsx}",
|
|
52
|
-
"!src/**/*.d.ts"
|
|
53
|
-
],
|
|
54
|
-
"coverageReporters": [
|
|
55
|
-
"text",
|
|
56
|
-
"cobertura"
|
|
57
|
-
]
|
|
41
|
+
"prosemirror-tables": "1.4.2"
|
|
58
42
|
},
|
|
59
43
|
"scripts": {
|
|
60
|
-
"build": "rm -rf lib &&
|
|
44
|
+
"build": "rm -rf lib && tsc --project tsconfig.build.json",
|
|
61
45
|
"test": "jest",
|
|
62
46
|
"test:ci": "jest --reporters=default --reporters=jest-junit",
|
|
63
47
|
"test:coverage": "jest --coverage --coverageDirectory=${JEST_COVERAGE_RESULT_DIR:-$(pwd)}/coverage/prosemirror-schema --reporters=default --reporters=jest-junit",
|
|
64
|
-
"
|
|
65
|
-
|
|
48
|
+
"check": "../../scripts/check.sh",
|
|
49
|
+
"lint": "../../scripts/lint.sh"
|
|
50
|
+
},
|
|
51
|
+
"types": "./lib/index.d.ts"
|
|
66
52
|
}
|