@editora/core 1.0.11 → 1.0.13

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.
package/README.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # @editora/core
2
2
 
3
+ [![Version](https://img.shields.io/npm/v/@editora/core)](https://www.npmjs.com/package/@editora/core)
4
+ [![License](https://img.shields.io/npm/l/@editora/core)](https://github.com/ajaykr089/Editora/blob/main/LICENSE)
5
+ [![TypeScript](https://img.shields.io/badge/TypeScript-007ACC?logo=typescript&logoColor=white)](https://www.typescriptlang.org/)
6
+ [![Size](https://img.shields.io/bundlephobia/minzip/@editora/core)](https://bundlephobia.com/package/@editora/core)
7
+
3
8
  > [!IMPORTANT]
4
9
  > **Live Website:** https://editora-ecosystem.netlify.app/
5
10
  > **Storybook:** https://editora-ecosystem-storybook.netlify.app/
@@ -1,4 +1,4 @@
1
- const C = () => ({
1
+ const T = () => ({
2
2
  name: "clearFormatting",
3
3
  // Toolbar button configuration
4
4
  toolbar: [
@@ -19,10 +19,10 @@ const C = () => ({
19
19
  if (!t) return !1;
20
20
  const e = window.getSelection();
21
21
  if (!e || e.rangeCount === 0) return !1;
22
- const r = e.getRangeAt(0);
23
- if (!t.contains(r.commonAncestorContainer)) return !1;
24
- const n = r.cloneRange();
25
- return t.focus({ preventScroll: !0 }), A(t, n), N(t, n), t.dispatchEvent(new Event("input", { bubbles: !0 })), !0;
22
+ const n = e.getRangeAt(0);
23
+ if (!t.contains(n.commonAncestorContainer)) return !1;
24
+ const r = n.cloneRange();
25
+ return t.focus({ preventScroll: !0 }), C(t, r), y(t, r), t.dispatchEvent(new Event("input", { bubbles: !0 })), !0;
26
26
  }
27
27
  },
28
28
  // Keyboard shortcuts
@@ -72,7 +72,7 @@ const C = () => ({
72
72
  function h() {
73
73
  const t = window.getSelection();
74
74
  if (t && t.rangeCount > 0) {
75
- const r = t.getRangeAt(0).startContainer, n = r.nodeType === Node.ELEMENT_NODE ? r : r.parentElement, o = n == null ? void 0 : n.closest('[contenteditable="true"], .rte-content, .editora-content');
75
+ const n = t.getRangeAt(0).startContainer, r = n.nodeType === Node.ELEMENT_NODE ? n : n.parentElement, o = r == null ? void 0 : r.closest('[contenteditable="true"], .rte-content, .editora-content');
76
76
  if (o) return o;
77
77
  }
78
78
  const e = document.activeElement;
@@ -82,23 +82,23 @@ function c(t, e) {
82
82
  try {
83
83
  if (typeof t.intersectsNode == "function")
84
84
  return t.intersectsNode(e);
85
- } catch (n) {
85
+ } catch (r) {
86
86
  }
87
- const r = document.createRange();
88
- return e.nodeType === Node.ELEMENT_NODE ? r.selectNodeContents(e) : r.selectNode(e), t.compareBoundaryPoints(Range.END_TO_START, r) > 0 && t.compareBoundaryPoints(Range.START_TO_END, r) < 0;
87
+ const n = document.createRange();
88
+ return e.nodeType === Node.ELEMENT_NODE ? n.selectNodeContents(e) : n.selectNode(e), t.compareBoundaryPoints(Range.END_TO_START, n) > 0 && t.compareBoundaryPoints(Range.START_TO_END, n) < 0;
89
89
  }
90
- function i(t) {
91
- let e = 0, r = t;
92
- for (; r && r.parentNode; )
93
- e += 1, r = r.parentNode;
90
+ function a(t) {
91
+ let e = 0, n = t;
92
+ for (; n && n.parentNode; )
93
+ e += 1, n = n.parentNode;
94
94
  return e;
95
95
  }
96
96
  function m(t) {
97
97
  g.forEach((e) => {
98
98
  t.style.removeProperty(e);
99
- }), (!t.getAttribute("style") || t.style.length === 0) && t.removeAttribute("style"), t.classList.contains("rte-text-color") && t.classList.remove("rte-text-color"), t.classList.contains("rte-bg-color") && t.classList.remove("rte-bg-color"), t.classList.length === 0 && t.removeAttribute("class");
99
+ }), (!t.getAttribute("style") || t.style.length === 0) && t.removeAttribute("style"), t.classList.contains("rte-text-color") && t.classList.remove("rte-text-color"), t.classList.contains("rte-bg-color") && t.classList.remove("rte-bg-color"), t.classList.contains("rte-format-painted") && t.classList.remove("rte-format-painted"), t.classList.length === 0 && t.removeAttribute("class");
100
100
  }
101
- function a(t) {
101
+ function i(t) {
102
102
  const e = t.parentNode;
103
103
  if (e) {
104
104
  for (; t.firstChild; )
@@ -106,27 +106,37 @@ function a(t) {
106
106
  e.removeChild(t);
107
107
  }
108
108
  }
109
- function p(t) {
109
+ function E(t) {
110
110
  return t.tagName !== "P" || t.attributes.length > 0 || (t.textContent || "").trim() !== "" ? !1 : !t.querySelector("img, video, table, iframe, hr, pre, ul, ol");
111
111
  }
112
112
  function l(t) {
113
113
  Array.from(t.children).forEach((e) => {
114
- p(e) && e.remove();
114
+ E(e) && e.remove();
115
115
  });
116
116
  }
117
117
  function s(t) {
118
- l(t), a(t);
118
+ l(t), i(t);
119
119
  }
120
120
  function f(t) {
121
- var r;
121
+ var n;
122
122
  const e = document.createElement("p");
123
- for (Array.from(t.attributes).forEach((n) => {
124
- e.setAttribute(n.name, n.value);
123
+ for (Array.from(t.attributes).forEach((r) => {
124
+ e.setAttribute(r.name, r.value);
125
125
  }); t.firstChild; )
126
126
  e.appendChild(t.firstChild);
127
- e.innerHTML.trim() || (e.innerHTML = "<br>"), (r = t.parentNode) == null || r.replaceChild(e, t);
127
+ e.innerHTML.trim() || (e.innerHTML = "<br>"), (n = t.parentNode) == null || n.replaceChild(e, t);
128
128
  }
129
- function E(t) {
129
+ function p(t) {
130
+ return !/^(A|B|STRONG|I|EM|U|S|STRIKE|DEL|FONT|MARK|CODE|SUB|SUP|SPAN)$/.test(t.tagName) || (t.textContent || "").trim() !== "" ? !1 : !t.querySelector("img, video, table, iframe, hr, svg, math");
131
+ }
132
+ function N(t) {
133
+ Array.from(
134
+ t.querySelectorAll("a,b,strong,i,em,u,s,strike,del,font,mark,code,sub,sup,span")
135
+ ).sort((n, r) => a(r) - a(n)).forEach((n) => {
136
+ n.isConnected && p(n) && n.remove();
137
+ });
138
+ }
139
+ function A(t) {
130
140
  if (l(t), t.parentElement instanceof HTMLLIElement) {
131
141
  s(t);
132
142
  return;
@@ -137,36 +147,36 @@ function E(t) {
137
147
  }
138
148
  f(t);
139
149
  }
140
- function N(t, e) {
150
+ function y(t, e) {
141
151
  Array.from(
142
152
  t.querySelectorAll("h1,h2,h3,h4,h5,h6,blockquote,pre")
143
- ).forEach((n) => {
144
- if (c(e, n) && d.has(n.tagName)) {
145
- if (n.tagName === "BLOCKQUOTE") {
146
- E(n);
153
+ ).forEach((r) => {
154
+ if (c(e, r) && d.has(r.tagName)) {
155
+ if (r.tagName === "BLOCKQUOTE") {
156
+ A(r);
147
157
  return;
148
158
  }
149
- f(n);
159
+ f(r);
150
160
  }
151
161
  });
152
162
  }
153
- function A(t, e) {
154
- const r = Array.from(
163
+ function C(t, e) {
164
+ const n = Array.from(
155
165
  t.querySelectorAll(
156
166
  "a,b,strong,i,em,u,s,strike,del,font,mark,code,sub,sup,span,[style],[class]"
157
167
  )
158
168
  );
159
- r.sort((n, o) => i(o) - i(n)), r.forEach((n) => {
160
- if (n.isConnected && c(e, n) && !(n.getAttribute("contenteditable") === "false" || n.closest('[contenteditable="false"]'))) {
161
- if (m(n), u.has(n.tagName)) {
162
- a(n);
169
+ n.sort((r, o) => a(o) - a(r)), n.forEach((r) => {
170
+ if (r.isConnected && c(e, r) && !(r.getAttribute("contenteditable") === "false" || r.closest('[contenteditable="false"]'))) {
171
+ if (m(r), u.has(r.tagName)) {
172
+ i(r);
163
173
  return;
164
174
  }
165
- n.tagName === "SPAN" && n.attributes.length === 0 && a(n);
175
+ r.tagName === "SPAN" && r.attributes.length === 0 && i(r);
166
176
  }
167
- });
177
+ }), N(t);
168
178
  }
169
179
  export {
170
- C as ClearFormattingPlugin
180
+ T as ClearFormattingPlugin
171
181
  };
172
- //# sourceMappingURL=ClearFormattingPlugin.native-DIS6AN2t.mjs.map
182
+ //# sourceMappingURL=ClearFormattingPlugin.native-B6ro3a1h.mjs.map