@fibery/prosemirror-schema 4.14.2 → 4.15.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.
|
@@ -1,41 +1,41 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.textBackgroundColor = void 0;
|
|
4
|
-
var
|
|
5
|
-
(function (
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
})(
|
|
16
|
-
const
|
|
17
|
-
return Object.values(
|
|
4
|
+
var ColorToken;
|
|
5
|
+
(function (ColorToken) {
|
|
6
|
+
ColorToken["Yellow"] = "YELLOW";
|
|
7
|
+
ColorToken["Green"] = "GREEN";
|
|
8
|
+
ColorToken["Aquamarine"] = "AQUAMARINE";
|
|
9
|
+
ColorToken["Aqua"] = "AQUA";
|
|
10
|
+
ColorToken["Blue"] = "BLUE";
|
|
11
|
+
ColorToken["Purple"] = "PURPLE";
|
|
12
|
+
ColorToken["Pink"] = "PINK";
|
|
13
|
+
ColorToken["Red"] = "RED";
|
|
14
|
+
ColorToken["Grey"] = "GREY";
|
|
15
|
+
})(ColorToken || (ColorToken = {}));
|
|
16
|
+
const isColorToken = (text) => {
|
|
17
|
+
return Object.values(ColorToken).includes(text);
|
|
18
18
|
};
|
|
19
|
-
//
|
|
20
|
-
const
|
|
21
|
-
["#f6f1a2"]:
|
|
22
|
-
["#d2faad"]:
|
|
23
|
-
["#befccc"]:
|
|
24
|
-
["#bbf9f8"]:
|
|
25
|
-
["#e0f0fe"]:
|
|
26
|
-
["#f1ebfe"]:
|
|
27
|
-
["#fce7fb"]:
|
|
28
|
-
["#fce9e9"]:
|
|
29
|
-
["#e7e9eb"]:
|
|
19
|
+
// Previously we used to store raw color value in the attribute
|
|
20
|
+
const persistedRawColorToColorTokenLookup = {
|
|
21
|
+
["#f6f1a2"]: ColorToken.Yellow,
|
|
22
|
+
["#d2faad"]: ColorToken.Green,
|
|
23
|
+
["#befccc"]: ColorToken.Aquamarine,
|
|
24
|
+
["#bbf9f8"]: ColorToken.Aqua,
|
|
25
|
+
["#e0f0fe"]: ColorToken.Blue,
|
|
26
|
+
["#f1ebfe"]: ColorToken.Purple,
|
|
27
|
+
["#fce7fb"]: ColorToken.Pink,
|
|
28
|
+
["#fce9e9"]: ColorToken.Red,
|
|
29
|
+
["#e7e9eb"]: ColorToken.Grey,
|
|
30
30
|
};
|
|
31
|
-
const
|
|
32
|
-
if (
|
|
31
|
+
const validateColorToken = (color) => {
|
|
32
|
+
if (isColorToken(color)) {
|
|
33
33
|
return color;
|
|
34
34
|
}
|
|
35
|
-
return
|
|
35
|
+
return persistedRawColorToColorTokenLookup[color] || ColorToken.Yellow;
|
|
36
36
|
};
|
|
37
|
-
const getClassName = (
|
|
38
|
-
return `text-background-color ${
|
|
37
|
+
const getClassName = (token) => {
|
|
38
|
+
return `text-background-color ${token.toLowerCase()}`;
|
|
39
39
|
};
|
|
40
40
|
exports.textBackgroundColor = {
|
|
41
41
|
attrs: {
|
|
@@ -48,15 +48,15 @@ exports.textBackgroundColor = {
|
|
|
48
48
|
getAttrs: (domNode) => {
|
|
49
49
|
const dom = domNode;
|
|
50
50
|
return {
|
|
51
|
-
color: dom.getAttribute("data-color") ||
|
|
51
|
+
color: dom.getAttribute("data-color") || ColorToken.Yellow,
|
|
52
52
|
};
|
|
53
53
|
},
|
|
54
54
|
},
|
|
55
55
|
],
|
|
56
56
|
toDOM(node) {
|
|
57
57
|
const color = node.attrs.color;
|
|
58
|
-
const
|
|
59
|
-
const className = getClassName(
|
|
58
|
+
const colorToken = validateColorToken(color);
|
|
59
|
+
const className = getClassName(colorToken);
|
|
60
60
|
return [
|
|
61
61
|
"span",
|
|
62
62
|
{
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.code_block = void 0;
|
|
4
4
|
const uuid_1 = require("uuid");
|
|
5
|
+
const resizable_node_attrs_1 = require("../resizable-node-attrs");
|
|
5
6
|
const getLanguageFromEditorStyle = (dom) => {
|
|
6
7
|
return dom.getAttribute("data-language") || undefined;
|
|
7
8
|
};
|
|
@@ -48,6 +49,7 @@ exports.code_block = {
|
|
|
48
49
|
guid: { default: "" },
|
|
49
50
|
language: { default: null },
|
|
50
51
|
wrapCode: { default: false },
|
|
52
|
+
...(0, resizable_node_attrs_1.createDefaultAttrs)(),
|
|
51
53
|
},
|
|
52
54
|
parseDOM: [
|
|
53
55
|
{
|
|
@@ -63,7 +65,7 @@ exports.code_block = {
|
|
|
63
65
|
const wrapCodeAttr = dom.getAttribute("data-wrap-code");
|
|
64
66
|
const wrapCode = wrapCodeAttr === "true";
|
|
65
67
|
removeLastNewLine(dom);
|
|
66
|
-
return { guid, language, wrapCode };
|
|
68
|
+
return { guid, language, wrapCode, ...(0, resizable_node_attrs_1.createParseDomAttrs)(dom) };
|
|
67
69
|
},
|
|
68
70
|
},
|
|
69
71
|
// Handle GitHub/Gist paste
|
|
@@ -84,7 +86,12 @@ exports.code_block = {
|
|
|
84
86
|
"pre",
|
|
85
87
|
[
|
|
86
88
|
"code",
|
|
87
|
-
{
|
|
89
|
+
{
|
|
90
|
+
"data-language": node.attrs.language,
|
|
91
|
+
"data-guid": guid,
|
|
92
|
+
"data-wrap-code": node.attrs.wrapCode || false,
|
|
93
|
+
...(0, resizable_node_attrs_1.createToDomAttrs)(node.attrs),
|
|
94
|
+
},
|
|
88
95
|
0,
|
|
89
96
|
],
|
|
90
97
|
];
|
|
@@ -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
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fibery/prosemirror-schema",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.15.0",
|
|
4
4
|
"description": "Fibery prosemirror schema",
|
|
5
5
|
"main": "./lib/index.js",
|
|
6
6
|
"types": "./lib/index.d.ts",
|
|
@@ -39,8 +39,8 @@
|
|
|
39
39
|
"prosemirror-schema-list": "1.3.0",
|
|
40
40
|
"prosemirror-tables": "1.4.2",
|
|
41
41
|
"typescript": "5.9.3",
|
|
42
|
-
"@fibery/
|
|
43
|
-
"@fibery/
|
|
42
|
+
"@fibery/babel-preset": "7.4.1",
|
|
43
|
+
"@fibery/eslint-config": "8.6.2"
|
|
44
44
|
},
|
|
45
45
|
"jest": {
|
|
46
46
|
"testEnvironment": "jsdom",
|