@fibery/prosemirror-schema 3.3.0 → 3.4.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.
@@ -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
9
  const { href } = node.attrs;
9
- return ["a", { href, target: "_blank", class: "prosemirror-link", rel: "noopener noreferrer" }, 0];
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
  };
@@ -9,6 +9,18 @@ exports.fiberyView = {
9
9
  draggable: false,
10
10
  attrs: {
11
11
  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
+ },
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.3.0",
3
+ "version": "3.4.1",
4
4
  "description": "Fibery prosemirror schema",
5
5
  "main": "./lib/index.js",
6
6
  "files": [
@@ -35,8 +35,8 @@
35
35
  "prosemirror-schema-list": "1.2.2",
36
36
  "prosemirror-tables": "1.3.2",
37
37
  "typescript": "5.0.3",
38
- "@fibery/babel-preset": "7.2.0",
39
- "@fibery/eslint-config": "8.3.0"
38
+ "@fibery/eslint-config": "8.3.0",
39
+ "@fibery/babel-preset": "7.2.0"
40
40
  },
41
41
  "jest": {
42
42
  "testEnvironment": "jsdom",