@fibery/prosemirror-schema 4.2.2 → 4.3.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.
@@ -5,10 +5,11 @@ exports.column = {
5
5
  content: "block+",
6
6
  selectable: true,
7
7
  draggable: false,
8
- defining: true,
8
+ definingAsContext: true,
9
+ isolating: true,
9
10
  attrs: {
10
11
  columnRatio: {
11
- default: 0.5,
12
+ default: 1,
12
13
  },
13
14
  },
14
15
  parseDOM: [
@@ -1,41 +1,25 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.columns = void 0;
4
+ const resizable_node_attrs_1 = require("../resizable-node-attrs");
4
5
  exports.columns = {
5
6
  content: "column+",
6
7
  selectable: true,
7
8
  draggable: false,
8
9
  attrs: {
9
10
  id: { default: "" },
10
- nodeHeight: {
11
- default: 400,
12
- },
13
- nodeWidth: {
14
- default: 900,
15
- },
16
- nodePageWidth: {
17
- default: true,
18
- },
19
- nodeFullWidth: {
20
- default: false,
21
- },
11
+ ...(0, resizable_node_attrs_1.createDefaultAttrs)(),
22
12
  },
23
13
  parseDOM: [
24
14
  {
25
15
  tag: "div.fibery-columns-node",
26
16
  getAttrs: (domNode) => {
27
17
  const dom = domNode;
28
- return {
29
- nodeHeight: dom.getAttribute("data-node-height"),
30
- nodeWidth: dom.getAttribute("data-node-width"),
31
- nodePageWidth: dom.getAttribute("data-node-page-width"),
32
- nodeFullWidth: dom.getAttribute("data-node-full-width"),
33
- };
18
+ return (0, resizable_node_attrs_1.createParseDomAttrs)(dom);
34
19
  },
35
20
  },
36
21
  ],
37
22
  toDOM(node) {
38
- const { nodeHeight, nodeWidth, nodePageWidth, nodeFullWidth } = node.attrs;
39
23
  let gridTemplateColumns = ``;
40
24
  node.forEach((node, offset, index) => {
41
25
  if (index !== 0) {
@@ -45,11 +29,8 @@ exports.columns = {
45
29
  });
46
30
  const attrs = {
47
31
  class: "fibery-columns-node",
48
- "data-node-height": nodeHeight,
49
- "data-node-width": nodeWidth,
50
- "data-node-page-width": nodePageWidth,
51
- "data-node-full-width": nodeFullWidth,
52
32
  style: `display: grid; gap: 46px; grid-template-columns: ${gridTemplateColumns}`,
33
+ ...(0, resizable_node_attrs_1.createToDomAttrs)(node.attrs),
53
34
  };
54
35
  return ["div", attrs, 0];
55
36
  },
@@ -1,7 +1,7 @@
1
1
  type Emoji = {
2
- native: string;
3
- } | {
4
- imageUrl: string;
2
+ name: string;
3
+ shortNames: string[];
4
+ native?: string;
5
5
  };
6
6
  export type EmojiOptions = {
7
7
  getEmoji: (code: string) => Emoji | void;
@@ -20,7 +20,7 @@ const makeEmoji = ({ getEmoji } = defaultOptions) => ({
20
20
  leafText: (node) => {
21
21
  const { code } = node.attrs;
22
22
  const emoji = getEmoji(code);
23
- return emoji && "native" in emoji ? emoji.native : code;
23
+ return emoji ? emoji.native || `:${emoji.shortNames[0]}:` : code;
24
24
  },
25
25
  parseDOM: [
26
26
  {
@@ -40,9 +40,7 @@ const makeEmoji = ({ getEmoji } = defaultOptions) => ({
40
40
  [codeAttr]: code,
41
41
  };
42
42
  const emoji = getEmoji(code);
43
- const text = emoji && "native" in emoji ? emoji.native : code;
44
- // TODO: handle Twemoji and custom emojis
45
- return ["span", attrs, text];
43
+ return ["span", attrs, emoji ? emoji.native || `:${emoji.shortNames[0]}:` : code];
46
44
  },
47
45
  });
48
46
  exports.makeEmoji = makeEmoji;
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.fiberyView = void 0;
4
+ const resizable_node_attrs_1 = require("../resizable-node-attrs");
4
5
  exports.fiberyView = {
5
6
  inline: false,
6
7
  group: "block",
@@ -9,18 +10,7 @@ exports.fiberyView = {
9
10
  draggable: false,
10
11
  attrs: {
11
12
  id: { default: "" },
12
- nodeHeight: {
13
- default: 400,
14
- },
15
- nodeWidth: {
16
- default: 900,
17
- },
18
- nodePageWidth: {
19
- default: true,
20
- },
21
- nodeFullWidth: {
22
- default: false,
23
- },
13
+ ...(0, resizable_node_attrs_1.createDefaultAttrs)(),
24
14
  },
25
15
  parseDOM: [
26
16
  {
@@ -29,23 +19,17 @@ exports.fiberyView = {
29
19
  const dom = domNode;
30
20
  return {
31
21
  id: dom.getAttribute("data-view-id"),
32
- nodeHeight: dom.getAttribute("data-node-height"),
33
- nodeWidth: dom.getAttribute("data-node-width"),
34
- nodePageWidth: dom.getAttribute("data-node-page-width"),
35
- nodeFullWidth: dom.getAttribute("data-node-full-width"),
22
+ ...(0, resizable_node_attrs_1.createParseDomAttrs)(dom),
36
23
  };
37
24
  },
38
25
  },
39
26
  ],
40
27
  toDOM(node) {
41
- const { id, nodeHeight, nodeWidth, nodePageWidth, nodeFullWidth } = node.attrs;
28
+ const { id } = node.attrs;
42
29
  const attrs = {
43
30
  "data-view-id": id,
44
- "data-node-height": nodeHeight,
45
- "data-node-width": nodeWidth,
46
- "data-node-page-width": nodePageWidth,
47
- "data-node-full-width": nodeFullWidth,
48
31
  contenteditable: "false",
32
+ ...(0, resizable_node_attrs_1.createToDomAttrs)(node.attrs),
49
33
  };
50
34
  return ["div", attrs, ""];
51
35
  },
@@ -1,11 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.imageBlock = void 0;
4
+ const resizable_node_attrs_1 = require("../resizable-node-attrs");
4
5
  exports.imageBlock = {
5
6
  attrs: {
6
7
  src: {},
7
8
  alt: { default: null },
8
9
  title: { default: null },
10
+ ...(0, resizable_node_attrs_1.createDefaultAttrs)(),
9
11
  },
10
12
  // ----------------
11
13
  inline: false,
@@ -23,13 +25,20 @@ exports.imageBlock = {
23
25
  src: dom.getAttribute("src"),
24
26
  title: dom.getAttribute("title"),
25
27
  alt: dom.getAttribute("alt"),
28
+ ...(0, resizable_node_attrs_1.createParseDomAttrs)(dom),
26
29
  };
27
30
  },
28
31
  },
29
32
  ],
30
33
  toDOM(node) {
31
34
  const { src, alt, title } = node.attrs;
35
+ const attrs = {
36
+ src,
37
+ alt,
38
+ title,
39
+ ...(0, resizable_node_attrs_1.createToDomAttrs)(node.attrs),
40
+ };
32
41
  // return ["img", {src, alt, title}];
33
- return ["div", {}, ["img", { src, alt, title }]];
42
+ return ["div", {}, ["img", attrs]];
34
43
  },
35
44
  };
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.video = void 0;
4
+ const resizable_node_attrs_1 = require("../resizable-node-attrs");
4
5
  const DEFAULT_VIDEO_WIDTH = 400;
5
6
  const DEFAULT_VIDEO_HEIGHT = 200;
6
7
  exports.video = {
@@ -12,6 +13,7 @@ exports.video = {
12
13
  height: { default: DEFAULT_VIDEO_HEIGHT },
13
14
  title: { default: "" },
14
15
  alignment: { default: ":alignment/block-center" },
16
+ ...(0, resizable_node_attrs_1.createDefaultAttrs)(),
15
17
  },
16
18
  group: "block",
17
19
  draggable: true,
@@ -26,6 +28,7 @@ exports.video = {
26
28
  width: Number(dom.getAttribute("width")) || DEFAULT_VIDEO_WIDTH,
27
29
  height: Number(dom.getAttribute("height")) || DEFAULT_VIDEO_HEIGHT,
28
30
  title: dom.getAttribute("title"),
31
+ ...(0, resizable_node_attrs_1.createParseDomAttrs)(dom),
29
32
  };
30
33
  },
31
34
  },
@@ -43,6 +46,7 @@ exports.video = {
43
46
  playsinline: "",
44
47
  controls: "",
45
48
  preload: "metadata",
49
+ ...(0, resizable_node_attrs_1.createToDomAttrs)(node.attrs),
46
50
  },
47
51
  ];
48
52
  },
@@ -0,0 +1,27 @@
1
+ import { Attrs } from "prosemirror-model";
2
+ export declare function createDefaultAttrs(): {
3
+ nodeHeight: {
4
+ default: number;
5
+ };
6
+ nodeWidth: {
7
+ default: number;
8
+ };
9
+ nodePageWidth: {
10
+ default: boolean;
11
+ };
12
+ nodeFullWidth: {
13
+ default: boolean;
14
+ };
15
+ };
16
+ export declare function createParseDomAttrs(dom: HTMLElement): {
17
+ nodeHeight: string | null;
18
+ nodeWidth: string | null;
19
+ nodePageWidth: string | null;
20
+ nodeFullWidth: string | null;
21
+ };
22
+ export declare function createToDomAttrs({ nodeHeight, nodeWidth, nodePageWidth, nodeFullWidth }: Attrs): {
23
+ "data-node-height": any;
24
+ "data-node-width": any;
25
+ "data-node-page-width": any;
26
+ "data-node-full-width": any;
27
+ };
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createToDomAttrs = exports.createParseDomAttrs = exports.createDefaultAttrs = void 0;
4
+ function createDefaultAttrs() {
5
+ return {
6
+ nodeHeight: {
7
+ default: 400,
8
+ },
9
+ nodeWidth: {
10
+ default: 900,
11
+ },
12
+ nodePageWidth: {
13
+ default: true,
14
+ },
15
+ nodeFullWidth: {
16
+ default: false,
17
+ },
18
+ };
19
+ }
20
+ exports.createDefaultAttrs = createDefaultAttrs;
21
+ function createParseDomAttrs(dom) {
22
+ return {
23
+ nodeHeight: dom.getAttribute("data-node-height"),
24
+ nodeWidth: dom.getAttribute("data-node-width"),
25
+ nodePageWidth: dom.getAttribute("data-node-page-width"),
26
+ nodeFullWidth: dom.getAttribute("data-node-full-width"),
27
+ };
28
+ }
29
+ exports.createParseDomAttrs = createParseDomAttrs;
30
+ function createToDomAttrs({ nodeHeight, nodeWidth, nodePageWidth, nodeFullWidth }) {
31
+ return {
32
+ "data-node-height": nodeHeight,
33
+ "data-node-width": nodeWidth,
34
+ "data-node-page-width": nodePageWidth,
35
+ "data-node-full-width": nodeFullWidth,
36
+ };
37
+ }
38
+ exports.createToDomAttrs = createToDomAttrs;
package/package.json CHANGED
@@ -1,13 +1,17 @@
1
1
  {
2
2
  "name": "@fibery/prosemirror-schema",
3
- "version": "4.2.2",
3
+ "version": "4.3.1",
4
4
  "description": "Fibery prosemirror schema",
5
5
  "main": "./lib/index.js",
6
+ "types": "./lib/index.d.ts",
6
7
  "files": [
7
8
  "/lib"
8
9
  ],
9
10
  "exports": {
10
- ".": "./lib/index.js",
11
+ ".": {
12
+ "default": "./lib/index.js",
13
+ "types": "./lib/index.d.ts"
14
+ },
11
15
  "./src/nodes/fibery-section": "./lib/src/nodes/fibery-section.js",
12
16
  "./src/nodes/fibery-section.d.ts": "./lib/src/nodes/fibery-section.d.ts",
13
17
  "./lib/src/nodes/fibery-section": "./lib/src/nodes/fibery-section.js",
@@ -30,6 +34,7 @@
30
34
  "devDependencies": {
31
35
  "@types/uuid": "8.3.3",
32
36
  "jest": "27.5.1",
37
+ "@types/jest": "27.0.1",
33
38
  "jest-junit": "13.0.0",
34
39
  "prosemirror-model": "1.18.2",
35
40
  "prosemirror-schema-list": "1.2.2",
@@ -53,7 +58,7 @@
53
58
  ]
54
59
  },
55
60
  "scripts": {
56
- "build": "rm -rf lib && pnpm exec tsc --declaration --noEmit false",
61
+ "build": "rm -rf lib && pnpm exec tsc --project tsconfig.build.json",
57
62
  "test": "jest",
58
63
  "test:ci": "jest --reporters=default --reporters=jest-junit",
59
64
  "test:coverage": "jest --coverage --coverageDirectory=${JEST_COVERAGE_RESULT_DIR:-$(pwd)}/coverage/prosemirror-schema --reporters=default --reporters=jest-junit",