@fibery/prosemirror-schema 4.14.3 → 4.16.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 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);
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
- // 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,
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 validateColorName = (color) => {
32
- if (isColor(color)) {
31
+ const validateColorToken = (color) => {
32
+ if (isColorToken(color)) {
33
33
  return color;
34
34
  }
35
- return oldValueToColorLookup[color] || Color.Yellow;
35
+ return persistedRawColorToColorTokenLookup[color] || ColorToken.Yellow;
36
36
  };
37
- const getClassName = (color) => {
38
- return `text-background-color ${color.toLowerCase()}`;
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") || Color.Yellow,
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 colorName = validateColorName(color);
59
- const className = getClassName(colorName);
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,8 @@ exports.code_block = {
48
49
  guid: { default: "" },
49
50
  language: { default: null },
50
51
  wrapCode: { default: false },
52
+ mode: { default: "split" },
53
+ ...(0, resizable_node_attrs_1.createDefaultAttrs)(),
51
54
  },
52
55
  parseDOM: [
53
56
  {
@@ -63,7 +66,7 @@ exports.code_block = {
63
66
  const wrapCodeAttr = dom.getAttribute("data-wrap-code");
64
67
  const wrapCode = wrapCodeAttr === "true";
65
68
  removeLastNewLine(dom);
66
- return { guid, language, wrapCode };
69
+ return { guid, language, wrapCode, mode: dom.getAttribute("data-mode") || "split", ...(0, resizable_node_attrs_1.createParseDomAttrs)(dom) };
67
70
  },
68
71
  },
69
72
  // Handle GitHub/Gist paste
@@ -84,7 +87,13 @@ exports.code_block = {
84
87
  "pre",
85
88
  [
86
89
  "code",
87
- { "data-language": node.attrs.language, "data-guid": guid, "data-wrap-code": node.attrs.wrapCode || false },
90
+ {
91
+ "data-language": node.attrs.language,
92
+ "data-guid": guid,
93
+ "data-wrap-code": node.attrs.wrapCode || false,
94
+ "data-mode": node.attrs.mode || "split",
95
+ ...(0, resizable_node_attrs_1.createToDomAttrs)(node.attrs),
96
+ },
88
97
  0,
89
98
  ],
90
99
  ];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fibery/prosemirror-schema",
3
- "version": "4.14.3",
3
+ "version": "4.16.0",
4
4
  "description": "Fibery prosemirror schema",
5
5
  "main": "./lib/index.js",
6
6
  "types": "./lib/index.d.ts",