@fibery/prosemirror-schema 3.2.0 → 3.4.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.
@@ -21,6 +21,7 @@ const check_item_1 = require("./nodes/check-item");
21
21
  const code_block_1 = require("./nodes/code-block");
22
22
  const video_1 = require("./nodes/video");
23
23
  const file_1 = require("./nodes/file");
24
+ const callout_1 = require("./nodes/callout");
24
25
  const strike_1 = require("./marks/strike");
25
26
  const underline_1 = require("./marks/underline");
26
27
  const hint_query_1 = require("./marks/hint-query");
@@ -44,6 +45,7 @@ const createSchema = ({ sharedColorGenerator = null, headingToDOM = null, mediaT
44
45
  check_list: check_list_1.check_list,
45
46
  video: video_1.video,
46
47
  file: file_1.file,
48
+ callout: callout_1.callout,
47
49
  };
48
50
  let actualNodes = (0, prosemirror_schema_list_1.addListNodes)(base.spec.nodes, "paragraph block*", "block")
49
51
  .append({ ...table_nodes_1.tableNodes })
@@ -1,12 +1,19 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.makeLink = void 0;
4
+ const httpRegex = /^[-a-zA-Z0-9@:%._+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b[-a-zA-Z0-9()@:%_+.~#?&/=]*$/;
4
5
  const makeLink = (baseLink) => {
5
6
  return {
6
7
  ...baseLink,
7
8
  toDOM(node) {
8
- const { href, title } = node.attrs;
9
- return ["a", { href, title, target: "_blank", class: "prosemirror-link" }, 0];
9
+ const { href } = node.attrs;
10
+ let fixedHref = href;
11
+ if (!fixedHref.startsWith("http") && !fixedHref.startsWith("/")) {
12
+ if (httpRegex.test(href)) {
13
+ fixedHref = `https://${href}`;
14
+ }
15
+ }
16
+ return ["a", { href: fixedHref, target: "_blank", class: "prosemirror-link", rel: "noopener noreferrer" }, 0];
10
17
  },
11
18
  };
12
19
  };
@@ -0,0 +1,30 @@
1
+ export declare const callout: {
2
+ attrs: {
3
+ color: {
4
+ default: string;
5
+ };
6
+ iconType: {
7
+ default: string;
8
+ };
9
+ icon: {
10
+ default: string;
11
+ };
12
+ };
13
+ group: string;
14
+ content: string;
15
+ defining: true;
16
+ parseDOM: {
17
+ tag: string;
18
+ getAttrs(domNode: string | HTMLElement): {
19
+ color: string | null;
20
+ iconType: string | null;
21
+ icon: string | null;
22
+ };
23
+ }[];
24
+ toDOM(node: import("prosemirror-model").Node): [string, {
25
+ "data-callout-node": string;
26
+ "data-color": any;
27
+ "data-icon-type": any;
28
+ "data-icon": any;
29
+ }, number];
30
+ };
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.callout = void 0;
4
+ const nodeType = "data-callout-node";
5
+ exports.callout = {
6
+ attrs: {
7
+ color: { default: "#4A4A4A" },
8
+ iconType: { default: "icon" },
9
+ icon: { default: "exclamation-circle" },
10
+ },
11
+ group: "block",
12
+ content: "block+",
13
+ defining: true,
14
+ parseDOM: [
15
+ {
16
+ tag: `div[${nodeType}]`,
17
+ getAttrs(domNode) {
18
+ const dom = domNode;
19
+ return {
20
+ color: dom.getAttribute("data-color"),
21
+ iconType: dom.getAttribute("data-icon-type"),
22
+ icon: dom.getAttribute("data-icon"),
23
+ };
24
+ },
25
+ },
26
+ ],
27
+ toDOM(node) {
28
+ const { color, iconType, icon } = node.attrs;
29
+ const attrs = {
30
+ [nodeType]: "",
31
+ "data-color": color,
32
+ "data-icon-type": iconType,
33
+ "data-icon": icon,
34
+ };
35
+ return ["div", attrs, 0];
36
+ },
37
+ };
@@ -42,6 +42,7 @@ exports.code_block = {
42
42
  marks: "",
43
43
  group: "block",
44
44
  code: true,
45
+ isolating: true,
45
46
  defining: true,
46
47
  attrs: {
47
48
  language: { default: null },
@@ -9,6 +9,18 @@ exports.fiberyView = {
9
9
  draggable: false,
10
10
  attrs: {
11
11
  id: { default: "" },
12
+ nodeHeight: {
13
+ default: 300,
14
+ },
15
+ nodeWidth: {
16
+ default: 900,
17
+ },
18
+ nodePageWidth: {
19
+ default: true,
20
+ },
21
+ nodeFullWidth: {
22
+ default: false,
23
+ },
12
24
  },
13
25
  parseDOM: [
14
26
  {
@@ -17,14 +29,22 @@ exports.fiberyView = {
17
29
  const dom = domNode;
18
30
  return {
19
31
  id: dom.getAttribute("data-view-id"),
32
+ nodeHeight: dom.getAttribute("data-node-height"),
33
+ nodeWidth: dom.getAttribute("data-node-width"),
34
+ nodePageWidth: dom.getAttribute("node-page-width"),
35
+ nodeFullWidth: dom.getAttribute("node-full-width"),
20
36
  };
21
37
  },
22
38
  },
23
39
  ],
24
40
  toDOM(node) {
25
- const { id } = node.attrs;
41
+ const { id, nodeHeight, nodeWidth, nodePageWidth, nodeFullWidth } = node.attrs;
26
42
  const attrs = {
27
43
  "data-view-id": id,
44
+ "data-node-height": nodeHeight,
45
+ "data-node-width": nodeWidth,
46
+ "node-page-width": nodePageWidth,
47
+ "node-full-width": nodeFullWidth,
28
48
  contenteditable: "false",
29
49
  };
30
50
  return ["div", attrs, ""];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fibery/prosemirror-schema",
3
- "version": "3.2.0",
3
+ "version": "3.4.0",
4
4
  "description": "Fibery prosemirror schema",
5
5
  "main": "./lib/index.js",
6
6
  "files": [
@@ -25,18 +25,18 @@
25
25
  "peerDependencies": {
26
26
  "prosemirror-model": "^1.18.2",
27
27
  "prosemirror-schema-list": "^1.2.2",
28
- "prosemirror-tables": "^1.2.5"
28
+ "prosemirror-tables": "1.3.2"
29
29
  },
30
30
  "devDependencies": {
31
- "@fibery/babel-preset": "7.2.0",
32
- "@fibery/eslint-config": "8.3.0",
33
31
  "@types/uuid": "8.3.3",
34
32
  "jest": "27.5.1",
35
33
  "jest-junit": "13.0.0",
36
34
  "prosemirror-model": "1.18.2",
37
35
  "prosemirror-schema-list": "1.2.2",
38
- "prosemirror-tables": "1.2.5",
39
- "typescript": "5.0.3"
36
+ "prosemirror-tables": "1.3.2",
37
+ "typescript": "5.0.3",
38
+ "@fibery/babel-preset": "7.2.0",
39
+ "@fibery/eslint-config": "8.3.0"
40
40
  },
41
41
  "jest": {
42
42
  "testEnvironment": "jsdom",