@websline/system-components 1.4.1 → 1.4.3

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.
@@ -68,15 +68,18 @@
68
68
  return {
69
69
  href: {
70
70
  default: null,
71
+ parseHTML: (el) => el.getAttribute("href"),
71
72
  },
72
- page: {
73
+
74
+ pageUuid: {
73
75
  default: null,
74
- parseHTML: (el) => el.getAttribute("data-page"),
76
+ parseHTML: (el) => el.getAttribute("data-page-uuid"),
75
77
  renderHTML: (attrs) => {
76
- if (!attrs.page) return {};
77
- return { "data-page": attrs.page };
78
+ if (!attrs.pageUuid) return {};
79
+ return { "data-page-uuid": attrs.pageUuid };
78
80
  },
79
81
  },
82
+
80
83
  anchor: {
81
84
  default: null,
82
85
  parseHTML: (el) => el.getAttribute("data-anchor"),
@@ -85,11 +88,21 @@
85
88
  return { "data-anchor": attrs.anchor };
86
89
  },
87
90
  },
88
- target: {
91
+
92
+ title: {
89
93
  default: null,
90
- parseHTML: (el) => el.getAttribute("target"),
94
+ parseHTML: (el) => el.getAttribute("title"),
95
+ renderHTML: (attrs) => {
96
+ if (!attrs.title) return {};
97
+ return { title: attrs.title };
98
+ },
99
+ },
100
+
101
+ openInNewWindow: {
102
+ default: false,
103
+ parseHTML: (el) => el.getAttribute("target") === "_blank",
91
104
  renderHTML: (attrs) => {
92
- if (attrs.target === "_blank") {
105
+ if (attrs.openInNewWindow) {
93
106
  return { target: "_blank" };
94
107
  }
95
108
  return {};
@@ -107,6 +120,8 @@
107
120
 
108
121
  return ["a", attrs, 0];
109
122
  },
123
+ }).configure({
124
+ openOnClick: false,
110
125
  });
111
126
 
112
127
  editor = new Editor({
@@ -17,7 +17,21 @@
17
17
  onOpenLink({
18
18
  editor,
19
19
  getCurrentLink: () => editor.getAttributes("link"),
20
- applyLink: (attrs) => editor.chain().focus().setLink(attrs).run(),
20
+ applyLink: (attrs) => {
21
+ const chain = editor.chain().focus().extendMarkRange("link");
22
+
23
+ chain.unsetLink();
24
+
25
+ const linkAttrs = {
26
+ anchor: attrs.anchor || null,
27
+ href: attrs.url || null,
28
+ openInNewWindow: !!attrs.openInNewWindow,
29
+ pageUuid: attrs.pageUuid || null,
30
+ title: attrs.title || null,
31
+ };
32
+
33
+ return chain.setLink(linkAttrs).run();
34
+ },
21
35
  removeLink: () => editor.chain().focus().unsetLink().run(),
22
36
  });
23
37
  return;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@websline/system-components",
3
- "version": "1.4.1",
3
+ "version": "1.4.3",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },