@fibery/prosemirror-schema 4.24.0 → 4.24.1

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 CHANGED
@@ -5,7 +5,7 @@ import { Basic, createSchema } from "./create-schema.js";
5
5
  import { defaultHeight, defaultWidth } from "./resizable-node-attrs.js";
6
6
  import { DEFAULT_VIDEO_HEIGHT, DEFAULT_VIDEO_WIDTH } from "./nodes/video.js";
7
7
  import { DEFAULT_CALLOUT_ICON, DEFAULT_CALLOUT_ICON_TYPE } from "./nodes/callout.js";
8
- import { ColorToken } from "./marks/text-background-color.js";
8
+ import { ColorToken, isColorToken, validateColorToken } from "./marks/text-background-color.js";
9
9
  import { INLINE_SUGGESTION_MARK_NAMES, SUGGESTION_MARKS_EXPR, SUGGESTION_MARK_NAMES, SuggestionBaggage, SuggestionMarkName, isSuggestionBaggage } from "./marks/suggestions.js";
10
10
  import { Node, Schema } from "prosemirror-model";
11
- export { type AttrConstraint, type AttrConstraintType, type AttrValidationIssue, Basic, ColorToken, DEFAULT_CALLOUT_ICON, DEFAULT_CALLOUT_ICON_TYPE, DEFAULT_VIDEO_HEIGHT, DEFAULT_VIDEO_WIDTH, type EmojiOptions, FIBERY_VIEW_TYPE, INLINE_SUGGESTION_MARK_NAMES, MARK_ATTR_CONSTRAINTS, NODE_ATTR_CONSTRAINTS, Node, SUGGESTION_MARKS_EXPR, SUGGESTION_MARK_NAMES, Schema, type SuggestionBaggage, type SuggestionMarkName, buildBlockIdAttrs, createSchema, defaultHeight, defaultWidth, getBlockId, getBlockIdAttr, getFiberyViewRef, hasLegacyGuidAttr, isSuggestionBaggage, validateAttrValue, validateAttrs, validateMarkAttrValue, validateMarkAttrs };
11
+ export { type AttrConstraint, type AttrConstraintType, type AttrValidationIssue, Basic, ColorToken, DEFAULT_CALLOUT_ICON, DEFAULT_CALLOUT_ICON_TYPE, DEFAULT_VIDEO_HEIGHT, DEFAULT_VIDEO_WIDTH, type EmojiOptions, FIBERY_VIEW_TYPE, INLINE_SUGGESTION_MARK_NAMES, MARK_ATTR_CONSTRAINTS, NODE_ATTR_CONSTRAINTS, Node, SUGGESTION_MARKS_EXPR, SUGGESTION_MARK_NAMES, Schema, type SuggestionBaggage, type SuggestionMarkName, buildBlockIdAttrs, createSchema, defaultHeight, defaultWidth, getBlockId, getBlockIdAttr, getFiberyViewRef, hasLegacyGuidAttr, isColorToken, isSuggestionBaggage, validateAttrValue, validateAttrs, validateColorToken, validateMarkAttrValue, validateMarkAttrs };
package/lib/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { INLINE_SUGGESTION_MARK_NAMES, SUGGESTION_MARKS_EXPR, SUGGESTION_MARK_NAMES, isSuggestionBaggage } from "./marks/suggestions.js";
2
- import { ColorToken } from "./marks/text-background-color.js";
2
+ import { ColorToken, isColorToken, validateColorToken } from "./marks/text-background-color.js";
3
3
  import { MARK_ATTR_CONSTRAINTS, NODE_ATTR_CONSTRAINTS, validateAttrValue, validateAttrs, validateMarkAttrValue, validateMarkAttrs } from "./attr-constraints.js";
4
4
  import { FIBERY_VIEW_TYPE, buildBlockIdAttrs, getBlockId, getBlockIdAttr, getFiberyViewRef, hasLegacyGuidAttr } from "./block-id-utils.js";
5
5
  import { DEFAULT_CALLOUT_ICON, DEFAULT_CALLOUT_ICON_TYPE } from "./nodes/callout.js";
@@ -7,4 +7,4 @@ import { defaultHeight, defaultWidth } from "./resizable-node-attrs.js";
7
7
  import { DEFAULT_VIDEO_HEIGHT, DEFAULT_VIDEO_WIDTH } from "./nodes/video.js";
8
8
  import { Basic, createSchema } from "./create-schema.js";
9
9
  import { Node, Schema } from "prosemirror-model";
10
- export { Basic, ColorToken, DEFAULT_CALLOUT_ICON, DEFAULT_CALLOUT_ICON_TYPE, DEFAULT_VIDEO_HEIGHT, DEFAULT_VIDEO_WIDTH, FIBERY_VIEW_TYPE, INLINE_SUGGESTION_MARK_NAMES, MARK_ATTR_CONSTRAINTS, NODE_ATTR_CONSTRAINTS, Node, SUGGESTION_MARKS_EXPR, SUGGESTION_MARK_NAMES, Schema, buildBlockIdAttrs, createSchema, defaultHeight, defaultWidth, getBlockId, getBlockIdAttr, getFiberyViewRef, hasLegacyGuidAttr, isSuggestionBaggage, validateAttrValue, validateAttrs, validateMarkAttrValue, validateMarkAttrs };
10
+ export { Basic, ColorToken, DEFAULT_CALLOUT_ICON, DEFAULT_CALLOUT_ICON_TYPE, DEFAULT_VIDEO_HEIGHT, DEFAULT_VIDEO_WIDTH, FIBERY_VIEW_TYPE, INLINE_SUGGESTION_MARK_NAMES, MARK_ATTR_CONSTRAINTS, NODE_ATTR_CONSTRAINTS, Node, SUGGESTION_MARKS_EXPR, SUGGESTION_MARK_NAMES, Schema, buildBlockIdAttrs, createSchema, defaultHeight, defaultWidth, getBlockId, getBlockIdAttr, getFiberyViewRef, hasLegacyGuidAttr, isColorToken, isSuggestionBaggage, validateAttrValue, validateAttrs, validateColorToken, validateMarkAttrValue, validateMarkAttrs };
@@ -11,6 +11,8 @@ declare enum ColorToken {
11
11
  Red = "RED",
12
12
  Grey = "GREY"
13
13
  }
14
+ declare const isColorToken: (text: string) => text is ColorToken;
15
+ declare const validateColorToken: (color: string | undefined) => ColorToken | undefined;
14
16
  declare const textBackgroundColor: MarkSpec;
15
17
  //#endregion
16
- export { ColorToken, textBackgroundColor };
18
+ export { ColorToken, isColorToken, textBackgroundColor, validateColorToken };
@@ -24,7 +24,8 @@ const persistedRawColorToColorTokenLookup = {
24
24
  ["#f1ebfe"]: "PURPLE",
25
25
  ["#fce7fb"]: "PINK",
26
26
  ["#fce9e9"]: "RED",
27
- ["#e7e9eb"]: "GREY"
27
+ ["#e7e9eb"]: "GREY",
28
+ ["var(--actionMenuHover)"]: "GREY"
28
29
  };
29
30
  const validateColorToken = (color) => {
30
31
  if (!color) return;
@@ -69,4 +70,4 @@ const textBackgroundColor = {
69
70
  }
70
71
  };
71
72
  //#endregion
72
- export { ColorToken, textBackgroundColor };
73
+ export { ColorToken, isColorToken, textBackgroundColor, validateColorToken };
@@ -1,3 +1,4 @@
1
+ import { validateColorToken } from "../marks/text-background-color.js";
1
2
  import { tableNodes as tableNodes$1 } from "prosemirror-tables";
2
3
  //#region src/nodes/table-nodes.ts
3
4
  const tableNodes = tableNodes$1({
@@ -6,10 +7,17 @@ const tableNodes = tableNodes$1({
6
7
  cellAttributes: { background: {
7
8
  default: null,
8
9
  getFromDOM(dom) {
9
- return dom.style.backgroundColor || null;
10
+ const el = dom;
11
+ const raw = el.getAttribute("data-cell-bg") || el.style.backgroundColor || null;
12
+ return raw ? validateColorToken(raw) ?? raw : null;
10
13
  },
11
14
  setDOMAttr(value, attrs) {
12
- if (value) attrs.style = (attrs.style || "") + `background-color: ${value};`;
15
+ if (!value) return;
16
+ const token = typeof value === "string" ? validateColorToken(value) : void 0;
17
+ if (token) {
18
+ attrs["data-cell-bg"] = token;
19
+ attrs.class = [attrs.class, `bg-${token.toLowerCase()}`].filter(Boolean).join(" ");
20
+ } else attrs.style = (attrs.style || "") + `background-color: ${value};`;
13
21
  }
14
22
  } }
15
23
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fibery/prosemirror-schema",
3
- "version": "4.24.0",
3
+ "version": "4.24.1",
4
4
  "description": "Fibery prosemirror schema",
5
5
  "license": "UNLICENSED",
6
6
  "files": [