@fibery/prosemirror-schema 4.17.0 → 4.18.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.
Files changed (35) hide show
  1. package/lib/src/create-schema.d.ts +3 -2
  2. package/lib/src/create-schema.js +59 -25
  3. package/lib/src/marks/code.d.ts +1 -1
  4. package/lib/src/marks/em.d.ts +1 -1
  5. package/lib/src/marks/hint-query.d.ts +1 -1
  6. package/lib/src/marks/link.d.ts +1 -1
  7. package/lib/src/marks/linked-highlight.d.ts +1 -1
  8. package/lib/src/marks/strike.d.ts +1 -1
  9. package/lib/src/marks/strong.d.ts +1 -1
  10. package/lib/src/marks/text-background-color.d.ts +1 -1
  11. package/lib/src/marks/text-background-color.js +5 -1
  12. package/lib/src/marks/underline.d.ts +1 -1
  13. package/lib/src/nodes/check-item.d.ts +2 -2
  14. package/lib/src/nodes/check-list.d.ts +2 -2
  15. package/lib/src/nodes/code-block.d.ts +1 -1
  16. package/lib/src/nodes/column.d.ts +1 -1
  17. package/lib/src/nodes/columns.d.ts +1 -1
  18. package/lib/src/nodes/entity.d.ts +1 -1
  19. package/lib/src/nodes/fibery-view.d.ts +1 -1
  20. package/lib/src/nodes/heading.d.ts +1 -1
  21. package/lib/src/nodes/image-block.d.ts +1 -1
  22. package/lib/src/nodes/important.d.ts +1 -1
  23. package/lib/src/nodes/math-display.d.ts +1 -1
  24. package/lib/src/nodes/math-inline.d.ts +1 -1
  25. package/lib/src/nodes/media.d.ts +1 -1
  26. package/lib/src/nodes/mention.d.ts +1 -1
  27. package/lib/src/nodes/note.d.ts +1 -1
  28. package/lib/src/nodes/paragraph.d.ts +1 -1
  29. package/lib/src/nodes/types/inline-content.d.ts +3 -3
  30. package/lib/src/nodes/video.d.ts +1 -1
  31. package/lib/src/resizable-node-attrs.d.ts +1 -1
  32. package/lib/test-helpers/index.d.ts +1 -1
  33. package/package.json +7 -10
  34. package/lib/jest.config.cjs +0 -12
  35. package/lib/jest.config.d.cts +0 -3
@@ -1,5 +1,6 @@
1
- import { Node, Schema, type NodeSpec, type MarkSpec } from "prosemirror-model";
2
- import { EmojiOptions } from "./nodes/emoji";
1
+ import type { Node } from "prosemirror-model";
2
+ import { Schema, type NodeSpec, type MarkSpec } from "prosemirror-model";
3
+ import type { EmojiOptions } from "./nodes/emoji";
3
4
  type Params = {
4
5
  isImageBlockEnabled?: boolean;
5
6
  fiberyViewEnabled?: boolean;
@@ -4,36 +4,36 @@ exports.Basic = exports.createSchema = void 0;
4
4
  const prosemirror_model_1 = require("prosemirror-model");
5
5
  const prosemirror_schema_basic_1 = require("prosemirror-schema-basic");
6
6
  const prosemirror_schema_list_1 = require("prosemirror-schema-list");
7
- const table_nodes_1 = require("./nodes/table-nodes");
8
- const paragraph_1 = require("./nodes/paragraph");
9
- const heading_1 = require("./nodes/heading");
10
- const media_1 = require("./nodes/media");
11
- const note_1 = require("./nodes/note");
12
- const important_1 = require("./nodes/important");
13
- const image_block_1 = require("./nodes/image-block");
7
+ const code_1 = require("./marks/code");
8
+ const em_1 = require("./marks/em");
9
+ const hint_query_1 = require("./marks/hint-query");
10
+ const link_1 = require("./marks/link");
11
+ const linked_highlight_1 = require("./marks/linked-highlight");
12
+ const strike_1 = require("./marks/strike");
13
+ const strong_1 = require("./marks/strong");
14
+ const text_background_color_1 = require("./marks/text-background-color");
15
+ const underline_1 = require("./marks/underline");
16
+ const callout_1 = require("./nodes/callout");
17
+ const check_item_1 = require("./nodes/check-item");
18
+ const check_list_1 = require("./nodes/check-list");
19
+ const code_block_1 = require("./nodes/code-block");
20
+ const column_1 = require("./nodes/column");
21
+ const columns_1 = require("./nodes/columns");
22
+ const emoji_1 = require("./nodes/emoji");
14
23
  const entity_1 = require("./nodes/entity");
15
- const mention_1 = require("./nodes/mention");
16
24
  const fibery_view_1 = require("./nodes/fibery-view");
17
- const check_list_1 = require("./nodes/check-list");
18
- const check_item_1 = require("./nodes/check-item");
25
+ const file_1 = require("./nodes/file");
26
+ const heading_1 = require("./nodes/heading");
27
+ const image_block_1 = require("./nodes/image-block");
28
+ const important_1 = require("./nodes/important");
19
29
  const math_display_1 = require("./nodes/math-display");
20
30
  const math_inline_1 = require("./nodes/math-inline");
21
- const code_block_1 = require("./nodes/code-block");
31
+ const media_1 = require("./nodes/media");
32
+ const mention_1 = require("./nodes/mention");
33
+ const note_1 = require("./nodes/note");
34
+ const paragraph_1 = require("./nodes/paragraph");
35
+ const table_nodes_1 = require("./nodes/table-nodes");
22
36
  const video_1 = require("./nodes/video");
23
- const file_1 = require("./nodes/file");
24
- const callout_1 = require("./nodes/callout");
25
- const emoji_1 = require("./nodes/emoji");
26
- const columns_1 = require("./nodes/columns");
27
- const column_1 = require("./nodes/column");
28
- const strike_1 = require("./marks/strike");
29
- const underline_1 = require("./marks/underline");
30
- const hint_query_1 = require("./marks/hint-query");
31
- const text_background_color_1 = require("./marks/text-background-color");
32
- const linked_highlight_1 = require("./marks/linked-highlight");
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");
37
37
  const createSchema = ({ sharedColorGenerator = null, headingToDOM = null, mediaToDom = null, isImageBlockEnabled = false, fiberyViewEnabled = false, emojiOptions, } = {}) => {
38
38
  prosemirror_schema_basic_1.nodes.code_block = code_block_1.code_block;
39
39
  prosemirror_schema_basic_1.nodes.paragraph = paragraph_1.paragraph;
@@ -81,6 +81,40 @@ const createSchema = ({ sharedColorGenerator = null, headingToDOM = null, mediaT
81
81
  actualNodes = actualNodes.update("doc", {
82
82
  content: `(block | columns)+`,
83
83
  });
84
+ const listItemSpec = actualNodes.get("list_item");
85
+ actualNodes = actualNodes.update("list_item", {
86
+ ...listItemSpec,
87
+ attrs: {
88
+ ...(listItemSpec.attrs ?? {}),
89
+ state: { default: null },
90
+ id: { default: null },
91
+ },
92
+ parseDOM: [
93
+ {
94
+ tag: "li[data-check-item-state]",
95
+ getAttrs: (dom) => {
96
+ const el = dom;
97
+ const state = el.getAttribute("data-check-item-state");
98
+ return {
99
+ state: state === "TODO" || state === "DONE" ? state : null,
100
+ id: el.getAttribute("data-list-item-id") ?? null,
101
+ };
102
+ },
103
+ },
104
+ { tag: "li" },
105
+ ],
106
+ toDOM(node) {
107
+ const { state, id } = node.attrs;
108
+ const attrs = {};
109
+ if (state) {
110
+ attrs["data-check-item-state"] = state;
111
+ }
112
+ if (id) {
113
+ attrs["data-list-item-id"] = id;
114
+ }
115
+ return Object.keys(attrs).length ? ["li", attrs, 0] : ["li", 0];
116
+ },
117
+ });
84
118
  return new prosemirror_model_1.Schema({
85
119
  nodes: actualNodes,
86
120
  marks: base.spec.marks
@@ -1,4 +1,4 @@
1
- import { MarkSpec } from "prosemirror-model";
1
+ import type { MarkSpec } from "prosemirror-model";
2
2
  /**
3
3
  Code font mark. Represented as a `<code>` element.
4
4
  */
@@ -1,4 +1,4 @@
1
- import { MarkSpec } from "prosemirror-model";
1
+ import type { MarkSpec } from "prosemirror-model";
2
2
  /**
3
3
  An emphasis mark. Rendered as an `<em>` element. Has parse rules
4
4
  that also match `<i>` and `font-style: italic`.
@@ -1,2 +1,2 @@
1
- import { MarkSpec } from "prosemirror-model";
1
+ import type { MarkSpec } from "prosemirror-model";
2
2
  export declare const hintQuery: MarkSpec;
@@ -1,4 +1,4 @@
1
- import { MarkSpec } from "prosemirror-model";
1
+ import type { MarkSpec } from "prosemirror-model";
2
2
  /**
3
3
  A link. Has `href` and `title` attributes. `title`
4
4
  defaults to the empty string. Rendered and parsed as an `<a>`
@@ -1,4 +1,4 @@
1
- import { MarkSpec } from "prosemirror-model";
1
+ import type { MarkSpec } from "prosemirror-model";
2
2
  type Generator = {
3
3
  generate: (typeId?: string) => string;
4
4
  };
@@ -1,2 +1,2 @@
1
- import { MarkSpec } from "prosemirror-model";
1
+ import type { MarkSpec } from "prosemirror-model";
2
2
  export declare const strike: MarkSpec;
@@ -1,4 +1,4 @@
1
- import { MarkSpec } from "prosemirror-model";
1
+ import type { MarkSpec } from "prosemirror-model";
2
2
  /**
3
3
  A strong mark. Rendered as `<strong>`, parse rules also match
4
4
  `<b>` and `font-weight: bold`.
@@ -1,2 +1,2 @@
1
- import { MarkSpec } from "prosemirror-model";
1
+ import type { MarkSpec } from "prosemirror-model";
2
2
  export declare const textBackgroundColor: MarkSpec;
@@ -42,7 +42,11 @@ const getClassName = (bgColorToken, fgColorToken) => {
42
42
  return [
43
43
  `text-background-color`,
44
44
  bgColorToken ? `bg-${bgColorToken.toLowerCase()}` : null,
45
- fgColorToken ? `fg-${fgColorToken.toLowerCase()}` : null,
45
+ fgColorToken
46
+ ? bgColorToken
47
+ ? `fg-on-bg-${fgColorToken.toLowerCase()}`
48
+ : `fg-${fgColorToken.toLowerCase()}`
49
+ : null,
46
50
  ]
47
51
  .filter(Boolean)
48
52
  .join(` `);
@@ -1,2 +1,2 @@
1
- import { MarkSpec } from "prosemirror-model";
1
+ import type { MarkSpec } from "prosemirror-model";
2
2
  export declare const underline: MarkSpec;
@@ -1,5 +1,5 @@
1
- import { NodeSpec } from "prosemirror-model";
2
- import { Inline } from "./types/inline-content";
1
+ import type { NodeSpec } from "prosemirror-model";
2
+ import type { Inline } from "./types/inline-content";
3
3
  export interface CheckItemDefinition {
4
4
  type: "check_item";
5
5
  content?: Array<Inline>;
@@ -1,5 +1,5 @@
1
- import { NodeSpec } from "prosemirror-model";
2
- import { CheckItemDefinition } from "./check-item";
1
+ import type { NodeSpec } from "prosemirror-model";
2
+ import type { CheckItemDefinition } from "./check-item";
3
3
  export interface CheckListContent extends Array<CheckItemDefinition | CheckListDefinition> {
4
4
  0: CheckItemDefinition;
5
5
  }
@@ -1,2 +1,2 @@
1
- import { NodeSpec } from "prosemirror-model";
1
+ import type { NodeSpec } from "prosemirror-model";
2
2
  export declare const code_block: NodeSpec;
@@ -1,2 +1,2 @@
1
- import { NodeSpec } from "prosemirror-model";
1
+ import type { NodeSpec } from "prosemirror-model";
2
2
  export declare const column: NodeSpec;
@@ -1,2 +1,2 @@
1
- import { NodeSpec } from "prosemirror-model";
1
+ import type { NodeSpec } from "prosemirror-model";
2
2
  export declare const columns: NodeSpec;
@@ -1,4 +1,4 @@
1
- import { NodeSpec } from "prosemirror-model";
1
+ import type { NodeSpec } from "prosemirror-model";
2
2
  type Meta = {
3
3
  comment?: string;
4
4
  anchor?: string;
@@ -1,2 +1,2 @@
1
- import { NodeSpec } from "prosemirror-model";
1
+ import type { NodeSpec } from "prosemirror-model";
2
2
  export declare const fiberyView: NodeSpec;
@@ -1,4 +1,4 @@
1
- import { Node, NodeSpec } from "prosemirror-model";
1
+ import type { Node, NodeSpec } from "prosemirror-model";
2
2
  export declare const makeHeading: ({ headingToDOM }: {
3
3
  headingToDOM: ((node: Node) => HTMLElement) | null;
4
4
  }) => NodeSpec;
@@ -1,2 +1,2 @@
1
- import { NodeSpec } from "prosemirror-model";
1
+ import type { NodeSpec } from "prosemirror-model";
2
2
  export declare const imageBlock: NodeSpec;
@@ -1,2 +1,2 @@
1
- import { NodeSpec } from "prosemirror-model";
1
+ import type { NodeSpec } from "prosemirror-model";
2
2
  export declare const important: NodeSpec;
@@ -1,2 +1,2 @@
1
- import { NodeSpec } from "prosemirror-model";
1
+ import type { NodeSpec } from "prosemirror-model";
2
2
  export declare const math_display: NodeSpec;
@@ -1,2 +1,2 @@
1
- import { NodeSpec } from "prosemirror-model";
1
+ import type { NodeSpec } from "prosemirror-model";
2
2
  export declare const math_inline: NodeSpec;
@@ -1,4 +1,4 @@
1
- import { NodeSpec, Node } from "prosemirror-model";
1
+ import type { NodeSpec, Node } from "prosemirror-model";
2
2
  export declare const makeMedia: ({ mediaToDom }: {
3
3
  mediaToDom: ((node: Node) => HTMLElement) | null;
4
4
  }) => NodeSpec;
@@ -1,4 +1,4 @@
1
- import { NodeSpec } from "prosemirror-model";
1
+ import type { NodeSpec } from "prosemirror-model";
2
2
  export interface MentionAttributes {
3
3
  id: string;
4
4
  typeId: string;
@@ -1,2 +1,2 @@
1
- import { NodeSpec } from "prosemirror-model";
1
+ import type { NodeSpec } from "prosemirror-model";
2
2
  export declare const note: NodeSpec;
@@ -1,2 +1,2 @@
1
- import { NodeSpec } from "prosemirror-model";
1
+ import type { NodeSpec } from "prosemirror-model";
2
2
  export declare const paragraph: NodeSpec;
@@ -1,6 +1,6 @@
1
- import { MentionDefinition as Mention } from "../mention";
2
- import { EntityDefinition as Entity } from "../entity";
3
- import { TextDefinition as Text } from "./text";
1
+ import type { EntityDefinition as Entity } from "../entity";
2
+ import type { MentionDefinition as Mention } from "../mention";
3
+ import type { TextDefinition as Text } from "./text";
4
4
  interface MarksObject<T> {
5
5
  marks?: Array<T>;
6
6
  }
@@ -1,4 +1,4 @@
1
- import { NodeSpec } from "prosemirror-model";
1
+ import type { NodeSpec } from "prosemirror-model";
2
2
  export declare const DEFAULT_VIDEO_WIDTH = 400;
3
3
  export declare const DEFAULT_VIDEO_HEIGHT = 200;
4
4
  export declare const video: NodeSpec;
@@ -1,4 +1,4 @@
1
- import { Attrs } from "prosemirror-model";
1
+ import type { Attrs } from "prosemirror-model";
2
2
  export declare const defaultHeight = 400;
3
3
  export declare const defaultWidth = 900;
4
4
  export declare function createDefaultAttrs(): {
@@ -1,4 +1,4 @@
1
- import { Schema, Node as PMNode, ParseOptions } from "prosemirror-model";
1
+ import type { Schema, Node as PMNode, ParseOptions } from "prosemirror-model";
2
2
  export declare const fromHTML: (html: string, schema: Schema, options?: ParseOptions) => PMNode;
3
3
  export declare const toDOM: (node: PMNode, schema: Schema) => Node;
4
4
  export declare const toHTML: (node: PMNode, schema: Schema) => string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fibery/prosemirror-schema",
3
- "version": "4.17.0",
3
+ "version": "4.18.0",
4
4
  "private": false,
5
5
  "description": "Fibery prosemirror schema",
6
6
  "files": [
@@ -9,8 +9,8 @@
9
9
  "main": "./lib/index.js",
10
10
  "exports": {
11
11
  ".": {
12
- "types": "./lib/index.d.ts",
13
12
  "@fibery/source": "./index.ts",
13
+ "types": "./lib/index.d.ts",
14
14
  "default": "./lib/index.js"
15
15
  },
16
16
  "./src/nodes/fibery-section": {
@@ -24,27 +24,24 @@
24
24
  "dependencies": {
25
25
  "prosemirror-model": "1.25.4",
26
26
  "prosemirror-schema-basic": "1.2.2",
27
- "prosemirror-schema-list": "1.3.0",
27
+ "prosemirror-schema-list": "1.5.1",
28
28
  "prosemirror-tables": "1.4.2",
29
29
  "uuid": "11.1.0"
30
30
  },
31
31
  "devDependencies": {
32
- "@types/jest": "30.0.0",
33
- "jest": "30.2.0",
34
- "jest-junit": "16.0.0",
35
32
  "typescript": "6.0.1-rc",
36
33
  "@fibery/babel-preset": "7.4.2"
37
34
  },
38
35
  "peerDependencies": {
39
36
  "prosemirror-model": "1.25.4",
40
- "prosemirror-schema-list": "1.3.0",
37
+ "prosemirror-schema-list": "1.5.1",
41
38
  "prosemirror-tables": "1.4.2"
42
39
  },
43
40
  "scripts": {
44
41
  "build": "rm -rf lib && tsc --project tsconfig.build.json",
45
- "test": "jest",
46
- "test:ci": "jest --reporters=default --reporters=jest-junit",
47
- "test:coverage": "jest --coverage --coverageDirectory=${JEST_COVERAGE_RESULT_DIR:-$(pwd)}/coverage/prosemirror-schema --reporters=default --reporters=jest-junit",
42
+ "test": "../../scripts/test.sh",
43
+ "test:ci": "../../scripts/test.sh --ci",
44
+ "test:coverage": "../../scripts/test.sh --ci --coverage",
48
45
  "check": "../../scripts/check.sh",
49
46
  "lint": "../../scripts/lint.sh"
50
47
  },
@@ -1,12 +0,0 @@
1
- "use strict";
2
- /** @type {import('@jest/schemas').InitialOptions} */
3
- const config = {
4
- collectCoverageFrom: ["src/**/*.{js,jsx,ts,tsx}", "!src/**/*.d.ts"],
5
- coveragePathIgnorePatterns: ["/node_modules/"],
6
- coverageReporters: ["text", "cobertura"],
7
- testEnvironment: "jsdom",
8
- testEnvironmentOptions: {
9
- customExportConditions: ["@fibery/source"],
10
- },
11
- };
12
- module.exports = config;
@@ -1,3 +0,0 @@
1
- export = config;
2
- /** @type {import('@jest/schemas').InitialOptions} */
3
- declare const config: any;