@fibery/prosemirror-schema 4.6.0 → 4.7.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,4 +1,4 @@
1
- import { Schema, Node } from "prosemirror-model";
1
+ import { Node, Schema } from "prosemirror-model";
2
2
  import { EmojiOptions } from "./nodes/emoji";
3
3
  interface SchemaProps {
4
4
  isImageBlockEnabled?: boolean;
@@ -28,7 +28,7 @@ const column_1 = require("./nodes/column");
28
28
  const strike_1 = require("./marks/strike");
29
29
  const underline_1 = require("./marks/underline");
30
30
  const hint_query_1 = require("./marks/hint-query");
31
- const highlight_1 = require("./marks/highlight");
31
+ const text_background_color_1 = require("./marks/text-background-color");
32
32
  const linked_highlight_1 = require("./marks/linked-highlight");
33
33
  const link_1 = require("./marks/link");
34
34
  const createSchema = ({ sharedColorGenerator = null, headingToDOM = null, mediaToDom = null, isImageBlockEnabled = false, fiberyViewEnabled = false, emojiOptions, } = {}) => {
@@ -77,9 +77,11 @@ const createSchema = ({ sharedColorGenerator = null, headingToDOM = null, mediaT
77
77
  .addToEnd("strike", strike_1.strike)
78
78
  .addToEnd("underline", underline_1.underline)
79
79
  .addToEnd("hintQuery", hint_query_1.hintQuery)
80
- .addToEnd("highlight", highlight_1.highlight)
80
+ // We leave mark key as "highlight" only because we don't want to do migration.
81
+ // "TextBackgroundColor" term is used everywhere through codebase.
82
+ .addToEnd("highlight", text_background_color_1.textBackgroundColor)
81
83
  .addToEnd("linkedhighlight", (0, linked_highlight_1.makeLinkedHighlight)({ sharedColorGenerator }))
82
- .addToEnd("userreference", (0, linked_highlight_1.makeUserReference)({ sharedColorGenerator })),
84
+ .addToEnd("linkedhighlightentity", (0, linked_highlight_1.makeLinkedHighlightEntity)({ sharedColorGenerator })),
83
85
  });
84
86
  };
85
87
  exports.createSchema = createSchema;
@@ -5,7 +5,7 @@ type Generator = {
5
5
  export declare const makeLinkedHighlight: ({ sharedColorGenerator }: {
6
6
  sharedColorGenerator?: Generator | undefined;
7
7
  }) => MarkSpec;
8
- export declare const makeUserReference: ({ sharedColorGenerator }: {
8
+ export declare const makeLinkedHighlightEntity: ({ sharedColorGenerator }: {
9
9
  sharedColorGenerator?: Generator | undefined;
10
10
  }) => MarkSpec;
11
11
  export {};
@@ -1,11 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.makeUserReference = exports.makeLinkedHighlight = void 0;
3
+ exports.makeLinkedHighlightEntity = exports.makeLinkedHighlight = void 0;
4
4
  const hyphenatePascal = (str) => str
5
5
  .replace(/([a-z])([A-Z])/g, "$1-$2")
6
6
  .replace(/([A-Z]{2})[a-z]/, "$1-")
7
7
  .toLowerCase();
8
- const createMark = (markType, sharedColorGenerator) => {
8
+ const createMark = (markType, getTypeId, sharedColorGenerator) => {
9
9
  const markTag = `span.${markType}`;
10
10
  const markClassName = `${markType}`;
11
11
  const preserveBool = (attr) => (attr === "true" ? true : attr === "false" ? false : attr);
@@ -31,8 +31,8 @@ const createMark = (markType, sharedColorGenerator) => {
31
31
  toDOM: ({ attrs }) => {
32
32
  const { id, meta } = attrs;
33
33
  const { hidden = false } = meta;
34
- const { typeId } = meta.links && meta.links.length > 0 ? meta.links[0] : {};
35
- const color = sharedColorGenerator ? sharedColorGenerator.generate(typeId) : "#eeeeee";
34
+ const typeId = getTypeId(meta);
35
+ const color = sharedColorGenerator ? sharedColorGenerator.generate(typeId) : "#EEEEEE";
36
36
  return [
37
37
  markTag,
38
38
  {
@@ -53,11 +53,17 @@ const createMark = (markType, sharedColorGenerator) => {
53
53
  };
54
54
  const makeLinkedHighlight = ({ sharedColorGenerator }) => {
55
55
  // @ts-expect-error todo: fix this
56
- return createMark("linkedhighlight", sharedColorGenerator);
56
+ return createMark("linkedhighlight", (meta) => {
57
+ const { typeId } = meta.links && meta.links.length > 0 ? meta.links[0] : {};
58
+ return typeId;
59
+ }, sharedColorGenerator);
57
60
  };
58
61
  exports.makeLinkedHighlight = makeLinkedHighlight;
59
- const makeUserReference = ({ sharedColorGenerator }) => {
62
+ const makeLinkedHighlightEntity = ({ sharedColorGenerator }) => {
60
63
  // @ts-expect-error todo: fix this
61
- return createMark("userreference", sharedColorGenerator);
64
+ return createMark("linkedhighlightentity", (meta) => {
65
+ const { typeId } = meta.highlightEntities && meta.highlightEntities.length > 0 ? meta.highlightEntities[0] : {};
66
+ return typeId;
67
+ }, sharedColorGenerator);
62
68
  };
63
- exports.makeUserReference = makeUserReference;
69
+ exports.makeLinkedHighlightEntity = makeLinkedHighlightEntity;
@@ -0,0 +1,2 @@
1
+ import { MarkSpec } from "prosemirror-model";
2
+ export declare const textBackgroundColor: MarkSpec;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.highlight = void 0;
3
+ exports.textBackgroundColor = void 0;
4
4
  const COLORS_NAMES = ["YELLOW", "GREEN", "AQUAMARINE", "AQUA", "BLUE", "PURPLE", "PINK", "RED", "GREY"];
5
5
  const DEFAULT_COLOR = "YELLOW";
6
6
  const isColorName = (color) => {
@@ -33,16 +33,16 @@ const getColorName = (color) => {
33
33
  return getMigratedColorName(color);
34
34
  };
35
35
  const getClassName = (colorName) => {
36
- return `highlight ${colorName.toLowerCase()}`;
36
+ return `text-background-color ${colorName.toLowerCase()}`;
37
37
  };
38
- exports.highlight = {
38
+ exports.textBackgroundColor = {
39
39
  attrs: {
40
40
  guid: { default: "" },
41
41
  color: { default: "YELLOW" },
42
42
  },
43
43
  parseDOM: [
44
44
  {
45
- tag: "span[data-highlight]",
45
+ tag: "span[data-text-background-color]",
46
46
  getAttrs: (domNode) => {
47
47
  const dom = domNode;
48
48
  return {
@@ -58,7 +58,7 @@ exports.highlight = {
58
58
  return [
59
59
  "span",
60
60
  {
61
- "data-highlight": "true",
61
+ "data-text-background-color": "true",
62
62
  "data-guid": node.attrs.guid,
63
63
  "data-color": node.attrs.color,
64
64
  class: className,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fibery/prosemirror-schema",
3
- "version": "4.6.0",
3
+ "version": "4.7.0",
4
4
  "description": "Fibery prosemirror schema",
5
5
  "main": "./lib/index.js",
6
6
  "types": "./lib/index.d.ts",
@@ -40,8 +40,8 @@
40
40
  "prosemirror-schema-list": "1.2.2",
41
41
  "prosemirror-tables": "1.3.2",
42
42
  "typescript": "5.1.6",
43
- "@fibery/babel-preset": "7.3.0",
44
- "@fibery/eslint-config": "8.4.0"
43
+ "@fibery/eslint-config": "8.5.0",
44
+ "@fibery/babel-preset": "7.3.0"
45
45
  },
46
46
  "jest": {
47
47
  "testEnvironment": "jsdom",
@@ -1,2 +0,0 @@
1
- import { MarkSpec } from "prosemirror-model";
2
- export declare const highlight: MarkSpec;