@fibery/prosemirror-schema 4.14.0 → 4.14.2

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.
@@ -31,6 +31,9 @@ const hint_query_1 = require("./marks/hint-query");
31
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
+ const em_1 = require("./marks/em");
35
+ const strong_1 = require("./marks/strong");
36
+ const code_1 = require("./marks/code");
34
37
  const createSchema = ({ sharedColorGenerator = null, headingToDOM = null, mediaToDom = null, isImageBlockEnabled = false, fiberyViewEnabled = false, emojiOptions, } = {}) => {
35
38
  prosemirror_schema_basic_1.nodes.code_block = code_block_1.code_block;
36
39
  prosemirror_schema_basic_1.nodes.paragraph = paragraph_1.paragraph;
@@ -38,8 +41,10 @@ const createSchema = ({ sharedColorGenerator = null, headingToDOM = null, mediaT
38
41
  const base = new prosemirror_model_1.Schema({
39
42
  nodes: prosemirror_schema_basic_1.nodes,
40
43
  marks: {
41
- ...prosemirror_schema_basic_1.marks,
42
- link: (0, link_1.makeLink)(prosemirror_schema_basic_1.marks.link),
44
+ link: link_1.link,
45
+ em: em_1.em,
46
+ strong: strong_1.strong,
47
+ code: code_1.code,
43
48
  linkedhighlight: (0, linked_highlight_1.makeLinkedHighlight)({ sharedColorGenerator }),
44
49
  linkedhighlightentity: (0, linked_highlight_1.makeLinkedHighlightEntity)({ sharedColorGenerator }),
45
50
  },
@@ -92,7 +97,7 @@ exports.Basic = {
92
97
  nodes: prosemirror_schema_basic_1.nodes,
93
98
  marks: prosemirror_schema_basic_1.marks,
94
99
  fibery: {
95
- link: (0, link_1.makeLink)(prosemirror_schema_basic_1.marks.link),
100
+ link: link_1.link,
96
101
  strike: strike_1.strike,
97
102
  underline: underline_1.underline,
98
103
  textBackgroundColor: text_background_color_1.textBackgroundColor,
@@ -0,0 +1,5 @@
1
+ import { MarkSpec } from "prosemirror-model";
2
+ /**
3
+ Code font mark. Represented as a `<code>` element.
4
+ */
5
+ export declare const code: MarkSpec;
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.code = void 0;
4
+ const codeDOM = ["code", 0];
5
+ /**
6
+ Code font mark. Represented as a `<code>` element.
7
+ */
8
+ exports.code = {
9
+ parseDOM: [{ tag: "code" }],
10
+ toDOM() {
11
+ return codeDOM;
12
+ },
13
+ };
@@ -0,0 +1,6 @@
1
+ import { MarkSpec } from "prosemirror-model";
2
+ /**
3
+ An emphasis mark. Rendered as an `<em>` element. Has parse rules
4
+ that also match `<i>` and `font-style: italic`.
5
+ */
6
+ export declare const em: MarkSpec;
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.em = void 0;
4
+ const emDOM = ["em", 0];
5
+ /**
6
+ An emphasis mark. Rendered as an `<em>` element. Has parse rules
7
+ that also match `<i>` and `font-style: italic`.
8
+ */
9
+ exports.em = {
10
+ parseDOM: [
11
+ { tag: "i" },
12
+ { tag: "em" },
13
+ { style: "font-style=italic" },
14
+ /* eslint-disable-next-line eqeqeq */
15
+ { style: "font-style=normal", clearMark: (m) => m.type.name == "em" },
16
+ ],
17
+ toDOM() {
18
+ return emDOM;
19
+ },
20
+ };
@@ -1,2 +1,7 @@
1
1
  import { MarkSpec } from "prosemirror-model";
2
- export declare const makeLink: (baseLink: any) => MarkSpec;
2
+ /**
3
+ A link. Has `href` and `title` attributes. `title`
4
+ defaults to the empty string. Rendered and parsed as an `<a>`
5
+ element.
6
+ */
7
+ export declare const link: MarkSpec;
@@ -1,24 +1,39 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.makeLink = void 0;
3
+ exports.link = void 0;
4
4
  const httpRegex = /^[-a-zA-Z0-9@:%._+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b[-a-zA-Z0-9()@:%_+.~#?&/=]*$/;
5
- const makeLink = (baseLink) => {
6
- return {
7
- ...baseLink,
8
- toDOM(node) {
9
- const { href } = node.attrs;
10
- let fixedHref = href;
11
- if (href && !href.startsWith("mailto:") && !fixedHref.startsWith("http") && !fixedHref.startsWith("/")) {
12
- if (httpRegex.test(href)) {
13
- fixedHref = `https://${href}`;
14
- }
15
- }
16
- return [
17
- "a",
18
- { href: fixedHref, target: "_blank", class: "prosemirror-link", rel: "noopener noreferrer nofollow" },
19
- 0,
20
- ];
5
+ /**
6
+ A link. Has `href` and `title` attributes. `title`
7
+ defaults to the empty string. Rendered and parsed as an `<a>`
8
+ element.
9
+ */
10
+ exports.link = {
11
+ attrs: {
12
+ href: {},
13
+ title: { default: null },
14
+ },
15
+ inclusive: false,
16
+ parseDOM: [
17
+ {
18
+ tag: "a[href]",
19
+ getAttrs(domNode) {
20
+ const dom = domNode;
21
+ return { href: dom.getAttribute("href"), title: dom.getAttribute("title") };
22
+ },
21
23
  },
22
- };
24
+ ],
25
+ toDOM(node) {
26
+ const { href } = node.attrs;
27
+ let fixedHref = href;
28
+ if (href && !href.startsWith("mailto:") && !fixedHref.startsWith("http") && !fixedHref.startsWith("/")) {
29
+ if (httpRegex.test(href)) {
30
+ fixedHref = `https://${href}`;
31
+ }
32
+ }
33
+ return [
34
+ "a",
35
+ { href: fixedHref, target: "_blank", class: "prosemirror-link", rel: "noopener noreferrer nofollow" },
36
+ 0,
37
+ ];
38
+ },
23
39
  };
24
- exports.makeLink = makeLink;
@@ -3,9 +3,9 @@ type Generator = {
3
3
  generate: (typeId?: string) => string;
4
4
  };
5
5
  export declare const makeLinkedHighlight: ({ sharedColorGenerator }: {
6
- sharedColorGenerator?: Generator | undefined;
6
+ sharedColorGenerator?: Generator;
7
7
  }) => MarkSpec;
8
8
  export declare const makeLinkedHighlightEntity: ({ sharedColorGenerator }: {
9
- sharedColorGenerator?: Generator | undefined;
9
+ sharedColorGenerator?: Generator;
10
10
  }) => MarkSpec;
11
11
  export {};
@@ -0,0 +1,6 @@
1
+ import { MarkSpec } from "prosemirror-model";
2
+ /**
3
+ A strong mark. Rendered as `<strong>`, parse rules also match
4
+ `<b>` and `font-weight: bold`.
5
+ */
6
+ export declare const strong: MarkSpec;
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.strong = void 0;
4
+ const strongDOM = ["strong", 0];
5
+ /**
6
+ A strong mark. Rendered as `<strong>`, parse rules also match
7
+ `<b>` and `font-weight: bold`.
8
+ */
9
+ exports.strong = {
10
+ parseDOM: [
11
+ { tag: "strong" },
12
+ // This works around a Google Docs misbehavior where
13
+ // pasted content will be inexplicably wrapped in `<b>`
14
+ // tags with a font-weight normal.
15
+ {
16
+ tag: "b",
17
+ getAttrs: (dom) => {
18
+ /* eslint-disable-next-line eqeqeq */
19
+ return dom.style.fontWeight != "normal" && null;
20
+ },
21
+ },
22
+ /* eslint-disable-next-line eqeqeq */
23
+ { style: "font-weight=400", clearMark: (m) => m.type.name == "strong" },
24
+ {
25
+ style: "font-weight",
26
+ getAttrs: (value) => {
27
+ return /^(bold(er)?|[5-9]\d{2,})$/.test(value) && null;
28
+ },
29
+ },
30
+ ],
31
+ toDOM() {
32
+ return strongDOM;
33
+ },
34
+ };
@@ -1,39 +1,41 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.textBackgroundColor = void 0;
4
- const COLORS_NAMES = ["YELLOW", "GREEN", "AQUAMARINE", "AQUA", "BLUE", "PURPLE", "PINK", "RED", "GREY"];
5
- const DEFAULT_COLOR = "YELLOW";
6
- const isColorName = (color) => {
7
- return COLORS_NAMES.includes(color);
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);
8
18
  };
9
- // Long time ago we used to persist raw colors values, now we've moved to persist colors enum values
10
- // Until the migration is applied(raw colors -> colors names) we need to map raw colors values to color names on client side
11
- const getMigratedColorName = (color) => {
12
- const LEGACY_RAW_COLORS_BY_COLORS_NAMES = {
13
- YELLOW: "#f6f1a2",
14
- GREEN: "#d2faad",
15
- AQUAMARINE: "#befccc",
16
- AQUA: "#bbf9f8",
17
- BLUE: "#e0f0fe",
18
- PURPLE: "#f1ebfe",
19
- PINK: "#fce7fb",
20
- RED: "#fce9e9",
21
- GREY: "#e7e9eb",
22
- };
23
- if (Object.values(LEGACY_RAW_COLORS_BY_COLORS_NAMES).includes(color)) {
24
- const entry = Object.entries(LEGACY_RAW_COLORS_BY_COLORS_NAMES).find(([, value]) => value === color);
25
- return entry[0];
26
- }
27
- return DEFAULT_COLOR;
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,
28
30
  };
29
- const getColorName = (color) => {
30
- if (isColorName(color)) {
31
+ const validateColorName = (color) => {
32
+ if (isColor(color)) {
31
33
  return color;
32
34
  }
33
- return getMigratedColorName(color);
35
+ return oldValueToColorLookup[color] || Color.Yellow;
34
36
  };
35
- const getClassName = (colorName) => {
36
- return `text-background-color ${colorName.toLowerCase()}`;
37
+ const getClassName = (color) => {
38
+ return `text-background-color ${color.toLowerCase()}`;
37
39
  };
38
40
  exports.textBackgroundColor = {
39
41
  attrs: {
@@ -46,14 +48,14 @@ exports.textBackgroundColor = {
46
48
  getAttrs: (domNode) => {
47
49
  const dom = domNode;
48
50
  return {
49
- color: dom.getAttribute("data-color") || DEFAULT_COLOR,
51
+ color: dom.getAttribute("data-color") || Color.Yellow,
50
52
  };
51
53
  },
52
54
  },
53
55
  ],
54
56
  toDOM(node) {
55
57
  const color = node.attrs.color;
56
- const colorName = getColorName(color);
58
+ const colorName = validateColorName(color);
57
59
  const className = getClassName(colorName);
58
60
  return [
59
61
  "span",
@@ -15,7 +15,7 @@ export declare const callout: {
15
15
  defining: true;
16
16
  parseDOM: {
17
17
  tag: string;
18
- getAttrs(domNode: string | HTMLElement): {
18
+ getAttrs(domNode: HTMLElement): {
19
19
  color: string | null;
20
20
  iconType: string | null;
21
21
  icon: string | null;
@@ -4,7 +4,7 @@ exports.callout = void 0;
4
4
  const nodeType = "data-callout-node";
5
5
  exports.callout = {
6
6
  attrs: {
7
- color: { default: "#6A849B" },
7
+ color: { default: "#199EE3" },
8
8
  iconType: { default: "icon" },
9
9
  icon: { default: "exclamation-circle" },
10
10
  },
@@ -19,8 +19,8 @@ export declare const makeEmoji: ({ getEmoji }?: EmojiOptions) => {
19
19
  leafText: (node: import("prosemirror-model").Node) => any;
20
20
  parseDOM: {
21
21
  tag: string;
22
- getAttrs(domNode: string | HTMLElement): {
23
- code: string | null;
22
+ getAttrs(domNode: HTMLElement): {
23
+ code: string;
24
24
  };
25
25
  }[];
26
26
  toDOM(node: import("prosemirror-model").Node): [string, {
@@ -21,9 +21,9 @@ export declare const file: {
21
21
  leafText: (node: import("prosemirror-model").Node) => any;
22
22
  parseDOM: {
23
23
  tag: string;
24
- getAttrs(domNode: string | HTMLElement): {
24
+ getAttrs(domNode: HTMLElement): {
25
25
  src: string | null;
26
- title: string | null;
26
+ title: string;
27
27
  size: string | null;
28
28
  type: string | null;
29
29
  };
@@ -1,7 +1,10 @@
1
1
  import { MentionDefinition as Mention } from "../mention";
2
2
  import { EntityDefinition as Entity } from "../entity";
3
3
  import { TextDefinition as Text } from "./text";
4
- import { MarksObject } from "../../marks/types/mark";
4
+ interface MarksObject<T> {
5
+ marks?: Array<T>;
6
+ }
5
7
  export type InlineFormattedText = Text & MarksObject<unknown>;
6
8
  export type InlineAtomic = Mention | Entity | unknown;
7
9
  export type Inline = InlineFormattedText | InlineAtomic;
10
+ export {};
@@ -1,6 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createToDomAttrs = exports.createParseDomAttrs = exports.createDefaultAttrs = exports.defaultWidth = exports.defaultHeight = void 0;
3
+ exports.defaultWidth = exports.defaultHeight = void 0;
4
+ exports.createDefaultAttrs = createDefaultAttrs;
5
+ exports.createParseDomAttrs = createParseDomAttrs;
6
+ exports.createToDomAttrs = createToDomAttrs;
4
7
  exports.defaultHeight = 400;
5
8
  exports.defaultWidth = 900;
6
9
  function createDefaultAttrs() {
@@ -19,7 +22,6 @@ function createDefaultAttrs() {
19
22
  },
20
23
  };
21
24
  }
22
- exports.createDefaultAttrs = createDefaultAttrs;
23
25
  function createParseDomAttrs(dom) {
24
26
  return {
25
27
  nodeHeight: dom.getAttribute("data-node-height"),
@@ -28,7 +30,6 @@ function createParseDomAttrs(dom) {
28
30
  nodeFullWidth: dom.getAttribute("data-node-full-width"),
29
31
  };
30
32
  }
31
- exports.createParseDomAttrs = createParseDomAttrs;
32
33
  function createToDomAttrs({ nodeHeight, nodeWidth, nodePageWidth, nodeFullWidth }) {
33
34
  return {
34
35
  "data-node-height": nodeHeight,
@@ -37,4 +38,3 @@ function createToDomAttrs({ nodeHeight, nodeWidth, nodePageWidth, nodeFullWidth
37
38
  "data-node-full-width": nodeFullWidth,
38
39
  };
39
40
  }
40
- exports.createToDomAttrs = createToDomAttrs;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createDefaultAttrs = void 0;
3
+ exports.createDefaultAttrs = createDefaultAttrs;
4
4
  function createDefaultAttrs() {
5
5
  return {
6
6
  transcription: {
@@ -8,4 +8,3 @@ function createDefaultAttrs() {
8
8
  },
9
9
  };
10
10
  }
11
- exports.createDefaultAttrs = createDefaultAttrs;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fibery/prosemirror-schema",
3
- "version": "4.14.0",
3
+ "version": "4.14.2",
4
4
  "description": "Fibery prosemirror schema",
5
5
  "main": "./lib/index.js",
6
6
  "types": "./lib/index.d.ts",
@@ -24,24 +24,23 @@
24
24
  "private": false,
25
25
  "dependencies": {
26
26
  "prosemirror-schema-basic": "1.2.2",
27
- "uuid": "8.3.2"
27
+ "uuid": "11.1.0"
28
28
  },
29
29
  "peerDependencies": {
30
- "prosemirror-model": "^1.19.4",
31
- "prosemirror-schema-list": "^1.3.0",
32
- "prosemirror-tables": "1.3.7"
30
+ "prosemirror-model": "1.25.4",
31
+ "prosemirror-schema-list": "1.3.0",
32
+ "prosemirror-tables": "1.4.2"
33
33
  },
34
34
  "devDependencies": {
35
- "@types/jest": "27.0.1",
36
- "@types/uuid": "8.3.3",
37
- "jest": "27.5.1",
38
- "jest-junit": "13.0.0",
39
- "prosemirror-model": "1.19.4",
35
+ "@types/jest": "30.0.0",
36
+ "jest": "30.2.0",
37
+ "jest-junit": "16.0.0",
38
+ "prosemirror-model": "1.25.4",
40
39
  "prosemirror-schema-list": "1.3.0",
41
- "prosemirror-tables": "1.3.7",
42
- "typescript": "5.4.3",
43
- "@fibery/babel-preset": "7.4.0",
44
- "@fibery/eslint-config": "8.6.0"
40
+ "prosemirror-tables": "1.4.2",
41
+ "typescript": "5.9.3",
42
+ "@fibery/eslint-config": "8.6.2",
43
+ "@fibery/babel-preset": "7.4.1"
45
44
  },
46
45
  "jest": {
47
46
  "testEnvironment": "jsdom",
@@ -1,3 +0,0 @@
1
- export interface MarksObject<T> {
2
- marks?: Array<T>;
3
- }
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });