@fibery/prosemirror-schema 4.24.1 → 4.25.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.
@@ -122,7 +122,13 @@ function cellConstraints() {
122
122
  type: ["integer"],
123
123
  minimum: 1
124
124
  },
125
- background: { type: ["string", "null"] }
125
+ background: { type: ["string", "null"] },
126
+ align: { enum: [
127
+ "left",
128
+ "center",
129
+ "right",
130
+ null
131
+ ] }
126
132
  };
127
133
  }
128
134
  const matchesType = (type, value) => {
package/lib/index.d.ts CHANGED
@@ -3,9 +3,12 @@ import { FIBERY_VIEW_TYPE, buildBlockIdAttrs, getBlockId, getBlockIdAttr, getFib
3
3
  import { EmojiOptions } from "./nodes/emoji.js";
4
4
  import { Basic, createSchema } from "./create-schema.js";
5
5
  import { defaultHeight, defaultWidth } from "./resizable-node-attrs.js";
6
+ import { EntityAttributes } from "./nodes/entity.js";
7
+ import { MentionAttributes } from "./nodes/mention.js";
6
8
  import { DEFAULT_VIDEO_HEIGHT, DEFAULT_VIDEO_WIDTH } from "./nodes/video.js";
7
9
  import { DEFAULT_CALLOUT_ICON, DEFAULT_CALLOUT_ICON_TYPE } from "./nodes/callout.js";
10
+ import { CellAlign, cellAlignValues } from "./nodes/table-nodes.js";
8
11
  import { ColorToken, isColorToken, validateColorToken } from "./marks/text-background-color.js";
9
12
  import { INLINE_SUGGESTION_MARK_NAMES, SUGGESTION_MARKS_EXPR, SUGGESTION_MARK_NAMES, SuggestionBaggage, SuggestionMarkName, isSuggestionBaggage } from "./marks/suggestions.js";
10
13
  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, isColorToken, isSuggestionBaggage, validateAttrValue, validateAttrs, validateColorToken, validateMarkAttrValue, validateMarkAttrs };
14
+ export { type AttrConstraint, type AttrConstraintType, type AttrValidationIssue, Basic, type CellAlign, ColorToken, DEFAULT_CALLOUT_ICON, DEFAULT_CALLOUT_ICON_TYPE, DEFAULT_VIDEO_HEIGHT, DEFAULT_VIDEO_WIDTH, type EmojiOptions, type EntityAttributes, FIBERY_VIEW_TYPE, INLINE_SUGGESTION_MARK_NAMES, MARK_ATTR_CONSTRAINTS, type MentionAttributes, NODE_ATTR_CONSTRAINTS, Node, SUGGESTION_MARKS_EXPR, SUGGESTION_MARK_NAMES, Schema, type SuggestionBaggage, type SuggestionMarkName, buildBlockIdAttrs, cellAlignValues, createSchema, defaultHeight, defaultWidth, getBlockId, getBlockIdAttr, getFiberyViewRef, hasLegacyGuidAttr, isColorToken, isSuggestionBaggage, validateAttrValue, validateAttrs, validateColorToken, validateMarkAttrValue, validateMarkAttrs };
package/lib/index.js CHANGED
@@ -4,7 +4,8 @@ import { MARK_ATTR_CONSTRAINTS, NODE_ATTR_CONSTRAINTS, validateAttrValue, valida
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";
6
6
  import { defaultHeight, defaultWidth } from "./resizable-node-attrs.js";
7
+ import { cellAlignValues } from "./nodes/table-nodes.js";
7
8
  import { DEFAULT_VIDEO_HEIGHT, DEFAULT_VIDEO_WIDTH } from "./nodes/video.js";
8
9
  import { Basic, createSchema } from "./create-schema.js";
9
10
  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, isColorToken, isSuggestionBaggage, validateAttrValue, validateAttrs, validateColorToken, validateMarkAttrValue, validateMarkAttrs };
11
+ 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, cellAlignValues, createSchema, defaultHeight, defaultWidth, getBlockId, getBlockIdAttr, getFiberyViewRef, hasLegacyGuidAttr, isColorToken, isSuggestionBaggage, validateAttrValue, validateAttrs, validateColorToken, validateMarkAttrValue, validateMarkAttrs };
@@ -1,5 +1,7 @@
1
1
  import { NodeSpec } from "prosemirror-model";
2
2
  //#region src/nodes/table-nodes.d.ts
3
+ declare const cellAlignValues: readonly ["left", "center", "right"];
4
+ type CellAlign = (typeof cellAlignValues)[number];
3
5
  declare const tableNodes: Record<string, NodeSpec>;
4
6
  //#endregion
5
- export { tableNodes };
7
+ export { CellAlign, cellAlignValues, tableNodes };
@@ -1,25 +1,44 @@
1
1
  import { validateColorToken } from "../marks/text-background-color.js";
2
2
  import { tableNodes as tableNodes$1 } from "prosemirror-tables";
3
3
  //#region src/nodes/table-nodes.ts
4
+ const cellAlignValues = [
5
+ "left",
6
+ "center",
7
+ "right"
8
+ ];
9
+ const isCellAlign = (value) => cellAlignValues.includes(value);
4
10
  const tableNodes = tableNodes$1({
5
11
  tableGroup: "block",
6
12
  cellContent: "block+",
7
- cellAttributes: { background: {
8
- default: null,
9
- getFromDOM(dom) {
10
- const el = dom;
11
- const raw = el.getAttribute("data-cell-bg") || el.style.backgroundColor || null;
12
- return raw ? validateColorToken(raw) ?? raw : null;
13
+ cellAttributes: {
14
+ align: {
15
+ default: null,
16
+ getFromDOM(dom) {
17
+ const raw = dom.getAttribute("data-cell-align") || dom.style.textAlign;
18
+ return isCellAlign(raw) ? raw : null;
19
+ },
20
+ setDOMAttr(value, attrs) {
21
+ if (!isCellAlign(value)) return;
22
+ attrs["data-cell-align"] = value;
23
+ }
13
24
  },
14
- setDOMAttr(value, attrs) {
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};`;
25
+ background: {
26
+ default: null,
27
+ getFromDOM(dom) {
28
+ const el = dom;
29
+ const raw = el.getAttribute("data-cell-bg") || el.style.backgroundColor || null;
30
+ return raw ? validateColorToken(raw) ?? raw : null;
31
+ },
32
+ setDOMAttr(value, attrs) {
33
+ if (!value) return;
34
+ const token = typeof value === "string" ? validateColorToken(value) : void 0;
35
+ if (token) {
36
+ attrs["data-cell-bg"] = token;
37
+ attrs.class = [attrs.class, `bg-${token.toLowerCase()}`].filter(Boolean).join(" ");
38
+ } else attrs.style = (attrs.style || "") + `background-color: ${value};`;
39
+ }
21
40
  }
22
- } }
41
+ }
23
42
  });
24
43
  //#endregion
25
- export { tableNodes };
44
+ export { cellAlignValues, tableNodes };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fibery/prosemirror-schema",
3
- "version": "4.24.1",
3
+ "version": "4.25.1",
4
4
  "description": "Fibery prosemirror schema",
5
5
  "license": "UNLICENSED",
6
6
  "files": [