@juit/vue-tiny-editor 1.0.26 → 1.0.28

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/dist/index.js CHANGED
@@ -1,42 +1,42 @@
1
- import { createElementBlock as y, openBlock as N, createElementVNode as C, defineComponent as Qe, mergeModels as je, useModel as Ye, watch as T, shallowRef as q, ref as E, computed as H, onMounted as Ze, nextTick as Le, onUnmounted as et, normalizeClass as M, createCommentVNode as Me, Fragment as tt, renderList as nt, createTextVNode as ot, toDisplayString as V, createVNode as P, withDirectives as De, unref as A, vModelText as Be } from "vue";
1
+ import { createElementBlock as N, openBlock as w, createElementVNode as b, defineComponent as Ge, mergeModels as Xe, useModel as Je, watch as T, shallowRef as q, ref as E, computed as z, onMounted as Qe, nextTick as Oe, onUnmounted as Ye, normalizeClass as L, createCommentVNode as me, Fragment as Ze, renderList as et, createTextVNode as tt, toDisplayString as H, createVNode as V, withDirectives as je, unref as $, vModelText as Le, createBlock as nt } from "vue";
2
2
  function ie(n, e) {
3
- return n instanceof Node && (n = I(n)), n.isPointInRange(e.startContainer, e.startOffset) && n.isPointInRange(e.endContainer, e.endOffset) ? e : null;
3
+ return n instanceof Node && (n = F(n)), n.isPointInRange(e.startContainer, e.startOffset) && n.isPointInRange(e.endContainer, e.endOffset) ? e : null;
4
4
  }
5
- function rt(n) {
5
+ function ot(n) {
6
6
  const e = document.createRange();
7
7
  return e.selectNode(n), e;
8
8
  }
9
- function I(n) {
9
+ function F(n) {
10
10
  const e = document.createRange();
11
11
  return e.selectNodeContents(n), e;
12
12
  }
13
- function be(n, e, a) {
14
- if (!I(n).isPointInRange(e, a))
13
+ function Ce(n, e, l) {
14
+ if (!F(n).isPointInRange(e, l))
15
15
  throw new Error("Range out of bounds");
16
- const i = document.createRange();
17
- return i.setStart(n, 0), i.setEnd(e, a), i.toString();
16
+ const r = document.createRange();
17
+ return r.setStart(n, 0), r.setEnd(e, l), r.toString();
18
18
  }
19
19
  function W(n, e) {
20
- const a = { start: 0, end: 0, backwards: e.backwards };
21
- return a.start = a.end = be(n, e.startContainer, e.startOffset).length, e.collapsed || (a.end = be(n, e.endContainer, e.endOffset).length), a;
20
+ const l = { start: 0, end: 0, backwards: e.backwards };
21
+ return l.start = l.end = Ce(n, e.startContainer, e.startOffset).length, e.collapsed || (l.end = Ce(n, e.endContainer, e.endOffset).length), l;
22
22
  }
23
23
  function U(n, e) {
24
- const a = I(n);
25
- e.backwards && (a.backwards = !0);
26
- let { start: s, end: i } = e, l = null, r = null, f = !1, m = !1;
27
- const c = document.createNodeIterator(n, NodeFilter.SHOW_TEXT);
28
- for (let g = c.nextNode(); g && (s >= 0 || i > 0); g = c.nextNode()) {
29
- l || (l = g), r = g;
30
- const v = g.nodeValue.length;
31
- if (s >= 0 && s < v && (f = !0, a.setStart(g, s), s === i))
32
- return m = "extra", a.setEnd(g, i), a;
33
- if (i > 0 && i <= v && (m = !0, a.setEnd(g, i), i === s))
34
- return f = "extra", a.setStart(g, s), a;
35
- s -= v, i -= v;
24
+ const l = F(n);
25
+ e.backwards && (l.backwards = !0);
26
+ let { start: s, end: r } = e, c = null, a = null, f = !1, i = !1;
27
+ const v = document.createNodeIterator(n, NodeFilter.SHOW_TEXT);
28
+ for (let h = v.nextNode(); h && (s >= 0 || r > 0); h = v.nextNode()) {
29
+ c || (c = h), a = h;
30
+ const p = h.nodeValue.length;
31
+ if (s >= 0 && s < p && (f = !0, l.setStart(h, s), s === r))
32
+ return i = "extra", l.setEnd(h, r), l;
33
+ if (r > 0 && r <= p && (i = !0, l.setEnd(h, r), r === s))
34
+ return f = "extra", l.setStart(h, s), l;
35
+ s -= p, r -= p;
36
36
  }
37
- return !f && l && a.setStart(l, 0), !m && r && a.setEnd(r, r.length), a;
37
+ return !f && c && l.setStart(c, 0), !i && a && l.setEnd(a, a.length), l;
38
38
  }
39
- const st = /* @__PURE__ */ new Set([
39
+ const rt = /* @__PURE__ */ new Set([
40
40
  "button",
41
41
  "embed",
42
42
  "form",
@@ -48,7 +48,7 @@ const st = /* @__PURE__ */ new Set([
48
48
  "style",
49
49
  "textarea"
50
50
  ]);
51
- function $e(n) {
51
+ function Me(n) {
52
52
  if (!n || !n.match(/^https?:\/\/[^\s]+$/)) return null;
53
53
  try {
54
54
  return new URL(n).href;
@@ -56,236 +56,236 @@ function $e(n) {
56
56
  return null;
57
57
  }
58
58
  }
59
- function qe(n, e, a = !1) {
60
- if (a) return n;
59
+ function De(n, e, l = !1) {
60
+ if (l) return n;
61
61
  const s = document.createElement(e);
62
62
  return s.append(n), s;
63
63
  }
64
64
  function Z(n, e = {}) {
65
65
  var s;
66
- const a = document.createDocumentFragment();
67
- for (const i of n.childNodes)
68
- if (i.nodeType === Node.TEXT_NODE)
69
- i.nodeValue && a.append(i.cloneNode());
70
- else if (i.nodeType === Node.ELEMENT_NODE) {
71
- const l = i, r = l.tagName.toLowerCase();
72
- if (st.has(r)) continue;
73
- const f = ((s = a.lastChild) == null ? void 0 : s.nodeType) === Node.ELEMENT_NODE ? {
74
- element: a.lastChild,
75
- tagName: a.lastChild.tagName.toLowerCase()
76
- } : null, m = document.createDocumentFragment();
77
- if (r === "b" || r === "strong") {
78
- const c = Z(l, { ...e, bold: !0 });
79
- if (!c.hasChildNodes()) continue;
80
- (f == null ? void 0 : f.tagName) === "b" ? f.element.append(c) : m.append(qe(c, "b", e.bold));
81
- } else if (r === "i" || r === "em") {
82
- const c = Z(l, { ...e, italic: !0 });
83
- if (!c.hasChildNodes()) continue;
84
- (f == null ? void 0 : f.tagName) === "i" ? f.element.append(c) : m.append(qe(c, "i", e.italic));
85
- } else if (r === "br")
86
- m.append(document.createElement("br"));
87
- else if (r === "div" || r === "p" || r === "pre" || r === "h1" || r === "h2" || r === "h3" || r === "h4" || r === "h5" || r === "h6" || r === "ul" || r === "ol" || r === "li") {
88
- m.append(document.createElement("br"));
89
- const c = Z(l, e);
90
- c.hasChildNodes() && (m.append(c), m.append(document.createElement("br")));
91
- } else if (r === "link") {
92
- if (l.getAttribute("rel") !== "mention") continue;
93
- const g = l.getAttribute("name"), v = l.getAttribute("title");
94
- if (!(g && v)) continue;
95
- const h = document.createElement("link");
96
- h.setAttribute("rel", "mention"), h.setAttribute("title", v), h.setAttribute("name", g), m.append(h);
66
+ const l = document.createDocumentFragment();
67
+ for (const r of n.childNodes)
68
+ if (r.nodeType === Node.TEXT_NODE)
69
+ r.nodeValue && l.append(r.cloneNode());
70
+ else if (r.nodeType === Node.ELEMENT_NODE) {
71
+ const c = r, a = c.tagName.toLowerCase();
72
+ if (rt.has(a)) continue;
73
+ const f = ((s = l.lastChild) == null ? void 0 : s.nodeType) === Node.ELEMENT_NODE ? {
74
+ element: l.lastChild,
75
+ tagName: l.lastChild.tagName.toLowerCase()
76
+ } : null, i = document.createDocumentFragment();
77
+ if (a === "b" || a === "strong") {
78
+ const v = Z(c, { ...e, bold: !0 });
79
+ if (!v.hasChildNodes()) continue;
80
+ (f == null ? void 0 : f.tagName) === "b" ? f.element.append(v) : i.append(De(v, "b", e.bold));
81
+ } else if (a === "i" || a === "em") {
82
+ const v = Z(c, { ...e, italic: !0 });
83
+ if (!v.hasChildNodes()) continue;
84
+ (f == null ? void 0 : f.tagName) === "i" ? f.element.append(v) : i.append(De(v, "i", e.italic));
85
+ } else if (a === "br")
86
+ i.append(document.createElement("br"));
87
+ else if (a === "div" || a === "p" || a === "pre" || a === "h1" || a === "h2" || a === "h3" || a === "h4" || a === "h5" || a === "h6" || a === "ul" || a === "ol" || a === "li") {
88
+ i.append(document.createElement("br"));
89
+ const v = Z(c, e);
90
+ v.hasChildNodes() && (i.append(v), i.append(document.createElement("br")));
91
+ } else if (a === "link") {
92
+ if (c.getAttribute("rel") !== "mention") continue;
93
+ const h = c.getAttribute("name"), p = c.getAttribute("title");
94
+ if (!(h && p)) continue;
95
+ const x = document.createElement("link");
96
+ x.setAttribute("rel", "mention"), x.setAttribute("title", p), x.setAttribute("name", h), i.append(x);
97
97
  } else
98
- m.append(Z(l, e));
99
- m.hasChildNodes() && a.append(m);
98
+ i.append(Z(c, e));
99
+ i.hasChildNodes() && l.append(i);
100
100
  }
101
- return a;
101
+ return l;
102
102
  }
103
103
  function lt(n) {
104
- const e = n.map((s, i) => ({ ...s, index: i }));
105
- e.sort((s, i) => s.start < i.start ? -1 : s.start > i.start || s.end < i.end ? 1 : s.end > i.end || /* v8 ignore next 3 */
106
- s.index < i.index ? -1 : s.index > i.index ? 1 : 0);
107
- const a = /* @__PURE__ */ new Set();
104
+ const e = n.map((s, r) => ({ ...s, index: r }));
105
+ e.sort((s, r) => s.start < r.start ? -1 : s.start > r.start || s.end < r.end ? 1 : s.end > r.end || /* v8 ignore next 3 */
106
+ s.index < r.index ? -1 : s.index > r.index ? 1 : 0);
107
+ const l = /* @__PURE__ */ new Set();
108
108
  for (let s = 0; s < e.length; s++) {
109
- const i = e[s];
110
- for (let l = s + 1; l < e.length; l++) {
111
- const r = e[l];
112
- a.has(r) || (r.start === r.end || r.start >= i.start && r.start < i.end || r.end >= i.start && r.end < i.end) && a.add(r);
109
+ const r = e[s];
110
+ for (let c = s + 1; c < e.length; c++) {
111
+ const a = e[c];
112
+ l.has(a) || (a.start === a.end || a.start >= r.start && a.start < r.end || a.end >= r.start && a.end < r.end) && l.add(a);
113
113
  }
114
114
  }
115
- return e.filter((s) => !a.has(s)).filter((s, i, l) => {
116
- const r = l[i - 1];
117
- return (r == null ? void 0 : r.end) === s.start && r.href === s.href ? (r.end = s.end, !1) : !0;
115
+ return e.filter((s) => !l.has(s)).filter((s, r, c) => {
116
+ const a = c[r - 1];
117
+ return (a == null ? void 0 : a.end) === s.start && a.href === s.href ? (a.end = s.end, !1) : !0;
118
118
  });
119
119
  }
120
- function at(n) {
121
- const e = [], a = /(https?:\/\/[^\s]+)/gm, s = n.textContent;
122
- for (let r = a.exec(s); r; r = a.exec(s)) {
123
- const f = r[1], m = $e(f);
124
- m && e.push({ start: r.index, end: r.index + f.length, href: m });
120
+ function st(n) {
121
+ const e = [], l = /(https?:\/\/[^\s]+)/gm, s = n.textContent;
122
+ for (let a = l.exec(s); a; a = l.exec(s)) {
123
+ const f = a[1], i = Me(f);
124
+ i && e.push({ start: a.index, end: a.index + f.length, href: i });
125
125
  }
126
- const i = [], l = document.createNodeIterator(n, NodeFilter.SHOW_ELEMENT, (r) => r.nodeName.toLowerCase() === "a" ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP);
127
- for (let r = l.nextNode(); r; r = l.nextNode()) {
128
- const f = r, m = $e(f.getAttribute("href"));
129
- if (m) {
130
- const c = I(f);
131
- i.push({ ...W(n, c), href: m });
126
+ const r = [], c = document.createNodeIterator(n, NodeFilter.SHOW_ELEMENT, (a) => a.nodeName.toLowerCase() === "a" ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP);
127
+ for (let a = c.nextNode(); a; a = c.nextNode()) {
128
+ const f = a, i = Me(f.getAttribute("href"));
129
+ if (i) {
130
+ const v = F(f);
131
+ r.push({ ...W(n, v), href: i });
132
132
  }
133
133
  }
134
- return lt([...e, ...i]);
134
+ return lt([...e, ...r]);
135
135
  }
136
- function it(n) {
137
- var a;
136
+ function at(n) {
137
+ var l;
138
138
  n.normalize();
139
139
  const e = document.createNodeIterator(n, NodeFilter.SHOW_ELEMENT);
140
140
  for (let s = e.nextNode(); s; s = e.nextNode())
141
141
  s !== n && s.nodeName.toLowerCase() !== "link" && (s.hasChildNodes() || (s.nodeName.toLowerCase() === "br" && s.parentNode.replaceChild(document.createTextNode(`
142
- `), s), (a = s.parentNode) == null || a.removeChild(s)));
142
+ `), s), (l = s.parentNode) == null || l.removeChild(s)));
143
143
  n.normalize(), n.hasChildNodes() || n.append(document.createElement("br"));
144
144
  }
145
145
  function ee(n) {
146
146
  var s;
147
147
  if (n.innerHTML === "<br>") return n;
148
148
  n.normalize();
149
- const e = at(n), a = Z(n);
150
- return ((s = a.lastChild) == null ? void 0 : s.nodeName.toLowerCase()) === "link" && a.append(document.createTextNode(" ")), n.replaceChildren(a), e.forEach((i) => {
151
- const l = U(n, i), r = l.extractContents(), f = document.createElement("a");
152
- f.setAttribute("href", i.href), f.append(r), l.insertNode(f);
153
- }), it(n), n;
149
+ const e = st(n), l = Z(n);
150
+ return ((s = l.lastChild) == null ? void 0 : s.nodeName.toLowerCase()) === "link" && l.append(document.createTextNode(" ")), n.replaceChildren(l), e.forEach((r) => {
151
+ const c = U(n, r), a = c.extractContents(), f = document.createElement("a");
152
+ f.setAttribute("href", r.href), f.append(a), c.insertNode(f);
153
+ }), at(n), n;
154
154
  }
155
- function me(n, e, a) {
156
- var v, h;
157
- if (typeof a == "string") {
155
+ function he(n, e, l) {
156
+ var p, x;
157
+ if (typeof l == "string") {
158
158
  if (!ie(n, e)) throw new Error("Range out of bounds");
159
- const S = new DOMParser().parseFromString(a, "text/html").body;
160
- a = document.createDocumentFragment(), a.append(...S.childNodes);
159
+ const P = new DOMParser().parseFromString(l, "text/html").body;
160
+ l = document.createDocumentFragment(), l.append(...P.childNodes);
161
161
  }
162
- const s = W(n, e), i = ((v = n.textContent) == null ? void 0 : v.length) || 0, l = I(n), r = document.createRange();
163
- r.setStart(l.startContainer, l.startOffset), r.setEnd(e.startContainer, e.startOffset);
162
+ const s = W(n, e), r = ((p = n.textContent) == null ? void 0 : p.length) || 0, c = F(n), a = document.createRange();
163
+ a.setStart(c.startContainer, c.startOffset), a.setEnd(e.startContainer, e.startOffset);
164
164
  const f = document.createRange();
165
- f.setStart(e.endContainer, e.endOffset), f.setEnd(l.endContainer, l.endOffset);
166
- const m = r.extractContents(), c = f.extractContents();
167
- n.replaceChildren(), n.append(m, a, c), ee(n);
168
- const g = ((h = n.textContent) == null ? void 0 : h.length) || 0;
169
- return { ...s, end: s.end + g - i };
165
+ f.setStart(e.endContainer, e.endOffset), f.setEnd(c.endContainer, c.endOffset);
166
+ const i = a.extractContents(), v = f.extractContents();
167
+ n.replaceChildren(), n.append(i, l, v), ee(n);
168
+ const h = ((x = n.textContent) == null ? void 0 : x.length) || 0;
169
+ return { ...s, end: s.end + h - r };
170
170
  }
171
- function Ce(n) {
171
+ function xe(n) {
172
172
  const e = document.getSelection();
173
173
  if (!(e != null && e.rangeCount)) return null;
174
- const a = e.getRangeAt(0);
175
- if (!ie(n, a)) return null;
174
+ const l = e.getRangeAt(0);
175
+ if (!ie(n, l)) return null;
176
176
  const s = e.isCollapsed ? !1 : e.anchorNode === e.focusNode ? e.anchorOffset > e.focusOffset : e.anchorNode.compareDocumentPosition(e.focusNode) === Node.DOCUMENT_POSITION_PRECEDING;
177
- return Object.assign(a, { backwards: s });
177
+ return Object.assign(l, { backwards: s });
178
178
  }
179
- function he(n) {
180
- const e = Ce(n);
179
+ function ge(n) {
180
+ const e = xe(n);
181
181
  return e ? W(n, e) : null;
182
182
  }
183
- function ge(n, e, a = !1) {
184
- a && (e = { start: e.end, end: e.end });
185
- const s = U(n, e), { startContainer: i, startOffset: l, endContainer: r, endOffset: f, backwards: m } = s, c = document.getSelection();
186
- return c && (m ? c.setBaseAndExtent(r, f, i, l) : c.setBaseAndExtent(i, l, r, f)), s;
183
+ function be(n, e, l = !1) {
184
+ l && (e = { start: e.end, end: e.end });
185
+ const s = U(n, e), { startContainer: r, startOffset: c, endContainer: a, endOffset: f, backwards: i } = s, v = document.getSelection();
186
+ return v && (i ? v.setBaseAndExtent(a, f, r, c) : v.setBaseAndExtent(r, c, a, f)), s;
187
187
  }
188
- function ae(n, e, a) {
189
- const s = I(n);
188
+ function ae(n, e, l) {
189
+ const s = F(n);
190
190
  if (!ie(n, e)) return null;
191
- let i = e.commonAncestorContainer;
192
- for (; i && s.intersectsNode(i); ) {
193
- if (i.nodeType === Node.ELEMENT_NODE && i.nodeName.toLowerCase() === a)
194
- return i;
195
- i = i.parentNode;
191
+ let r = e.commonAncestorContainer;
192
+ for (; r && s.intersectsNode(r); ) {
193
+ if (r.nodeType === Node.ELEMENT_NODE && r.nodeName.toLowerCase() === l)
194
+ return r;
195
+ r = r.parentNode;
196
196
  }
197
197
  return null;
198
198
  }
199
- function Pe(n, e, a, s = {}) {
199
+ function Be(n, e, l, s = {}) {
200
200
  if (e.collapsed || !ie(n, e)) return;
201
- const i = ae(n, e, a), l = i ? rt(i) : I(e.commonAncestorContainer), r = document.createRange();
202
- r.setStart(l.startContainer, l.startOffset), r.setEnd(e.startContainer, e.startOffset);
201
+ const r = ae(n, e, l), c = r ? ot(r) : F(e.commonAncestorContainer), a = document.createRange();
202
+ a.setStart(c.startContainer, c.startOffset), a.setEnd(e.startContainer, e.startOffset);
203
203
  const f = document.createRange();
204
- f.setStart(e.endContainer, e.endOffset), f.setEnd(l.endContainer, l.endOffset);
205
- const m = f.extractContents(), c = e.extractContents(), g = r.extractContents();
206
- l.deleteContents();
207
- const v = document.createDocumentFragment();
208
- if (v.append(g), i)
209
- v.append(c);
204
+ f.setStart(e.endContainer, e.endOffset), f.setEnd(c.endContainer, c.endOffset);
205
+ const i = f.extractContents(), v = e.extractContents(), h = a.extractContents();
206
+ c.deleteContents();
207
+ const p = document.createDocumentFragment();
208
+ if (p.append(h), r)
209
+ p.append(v);
210
210
  else {
211
- const h = document.createElement(a);
212
- Object.entries(s).forEach((S) => h.setAttribute(...S)), h.append(c), v.append(h);
211
+ const x = document.createElement(l);
212
+ Object.entries(s).forEach((P) => x.setAttribute(...P)), x.append(v), p.append(x);
213
213
  }
214
- v.append(m), l.insertNode(v), ee(n);
214
+ p.append(i), c.insertNode(p), ee(n);
215
215
  }
216
- const ut = {
216
+ const it = {
217
217
  xmlns: "http://www.w3.org/2000/svg",
218
218
  fill: "currentColor",
219
219
  viewBox: "0 -960 960 960"
220
220
  };
221
- function ct(n, e) {
222
- return N(), y("svg", ut, e[0] || (e[0] = [
223
- C("path", { d: "M272-200v-560h221q65 0 120 40t55 111q0 51-23 78.5T602-491q25 11 55.5 41t30.5 90q0 89-65 124.5T501-200zm121-112h104q48 0 58.5-24.5T566-372t-10.5-35.5T494-432H393zm0-228h93q33 0 48-17t15-38q0-24-17-39t-44-15h-95z" }, null, -1)
221
+ function ut(n, e) {
222
+ return w(), N("svg", it, e[0] || (e[0] = [
223
+ b("path", { d: "M272-200v-560h221q65 0 120 40t55 111q0 51-23 78.5T602-491q25 11 55.5 41t30.5 90q0 89-65 124.5T501-200zm121-112h104q48 0 58.5-24.5T566-372t-10.5-35.5T494-432H393zm0-228h93q33 0 48-17t15-38q0-24-17-39t-44-15h-95z" }, null, -1)
224
224
  ]));
225
225
  }
226
- const dt = { render: ct }, ft = {
226
+ const ct = { render: ut }, dt = {
227
227
  xmlns: "http://www.w3.org/2000/svg",
228
228
  fill: "currentColor",
229
229
  viewBox: "0 -960 960 960"
230
230
  };
231
- function pt(n, e) {
232
- return N(), y("svg", ft, e[0] || (e[0] = [
233
- C("path", { d: "M200-200v-100h160l120-360H320v-100h400v100H580L460-300h140v100z" }, null, -1)
231
+ function ft(n, e) {
232
+ return w(), N("svg", dt, e[0] || (e[0] = [
233
+ b("path", { d: "M200-200v-100h160l120-360H320v-100h400v100H580L460-300h140v100z" }, null, -1)
234
234
  ]));
235
235
  }
236
- const vt = { render: pt }, mt = {
236
+ const vt = { render: ft }, pt = {
237
237
  xmlns: "http://www.w3.org/2000/svg",
238
238
  fill: "currentColor",
239
239
  viewBox: "0 -960 960 960"
240
240
  };
241
- function ht(n, e) {
242
- return N(), y("svg", mt, e[0] || (e[0] = [
243
- C("path", { d: "M440-280H280q-83 0-141.5-58.5T80-480t58.5-141.5T280-680h160v80H280q-50 0-85 35t-35 85 35 85 85 35h160zM320-440v-80h320v80zm200 160v-80h160q50 0 85-35t35-85-35-85-85-35H520v-80h160q83 0 141.5 58.5T880-480t-58.5 141.5T680-280z" }, null, -1)
241
+ function mt(n, e) {
242
+ return w(), N("svg", pt, e[0] || (e[0] = [
243
+ b("path", { d: "M440-280H280q-83 0-141.5-58.5T80-480t58.5-141.5T280-680h160v80H280q-50 0-85 35t-35 85 35 85 85 35h160zM320-440v-80h320v80zm200 160v-80h160q50 0 85-35t35-85-35-85-85-35H520v-80h160q83 0 141.5 58.5T880-480t-58.5 141.5T680-280z" }, null, -1)
244
244
  ]));
245
245
  }
246
- const Ae = { render: ht }, gt = {
246
+ const qe = { render: mt }, ht = {
247
247
  xmlns: "http://www.w3.org/2000/svg",
248
248
  fill: "currentColor",
249
249
  viewBox: "0 -960 960 960"
250
250
  };
251
- function bt(n, e) {
252
- return N(), y("svg", gt, e[0] || (e[0] = [
253
- C("path", { d: "M480-80q-83 0-156-31.5T197-197t-85.5-127T80-480t31.5-156T197-763t127-85.5T480-880t156 31.5T763-763t85.5 127T880-480v58q0 59-40.5 100.5T740-280q-35 0-66-15t-52-43q-29 29-65.5 43.5T480-280q-83 0-141.5-58.5T280-480t58.5-141.5T480-680t141.5 58.5T680-480v58q0 26 17 44t43 18 43-18 17-44v-58q0-134-93-227t-227-93-227 93-93 227 93 227 227 93h200v80zm0-280q50 0 85-35t35-85-35-85-85-35-85 35-35 85 35 85 85 35" }, null, -1)
251
+ function gt(n, e) {
252
+ return w(), N("svg", ht, e[0] || (e[0] = [
253
+ b("path", { d: "M480-80q-83 0-156-31.5T197-197t-85.5-127T80-480t31.5-156T197-763t127-85.5T480-880t156 31.5T763-763t85.5 127T880-480v58q0 59-40.5 100.5T740-280q-35 0-66-15t-52-43q-29 29-65.5 43.5T480-280q-83 0-141.5-58.5T280-480t58.5-141.5T480-680t141.5 58.5T680-480v58q0 26 17 44t43 18 43-18 17-44v-58q0-134-93-227t-227-93-227 93-93 227 93 227 227 93h200v80zm0-280q50 0 85-35t35-85-35-85-85-35-85 35-35 85 35 85 85 35" }, null, -1)
254
254
  ]));
255
255
  }
256
- const Ct = { render: bt }, xt = {
256
+ const bt = { render: gt }, Ct = {
257
257
  xmlns: "http://www.w3.org/2000/svg",
258
258
  fill: "currentColor",
259
259
  viewBox: "0 -960 960 960"
260
260
  };
261
- function wt(n, e) {
262
- return N(), y("svg", xt, e[0] || (e[0] = [
263
- C("path", { d: "M792-443 176-183q-20 8-38-3.5T120-220v-520q0-22 18-33.5t38-3.5l616 260q25 11 25 37t-25 37M200-280l474-200-474-200v140l240 60-240 60zm0 0v-400z" }, null, -1)
261
+ function xt(n, e) {
262
+ return w(), N("svg", Ct, e[0] || (e[0] = [
263
+ b("path", { d: "M792-443 176-183q-20 8-38-3.5T120-220v-520q0-22 18-33.5t38-3.5l616 260q25 11 25 37t-25 37M200-280l474-200-474-200v140l240 60-240 60zm0 0v-400z" }, null, -1)
264
264
  ]));
265
265
  }
266
- const yt = { render: wt }, Nt = {
266
+ const yt = { render: xt }, wt = {
267
267
  xmlns: "http://www.w3.org/2000/svg",
268
268
  fill: "currentColor",
269
269
  viewBox: "0 -960 960 960"
270
270
  };
271
- function Tt(n, e) {
272
- return N(), y("svg", Nt, e[0] || (e[0] = [
273
- C("path", { d: "M280-160v-520H80v-120h520v120H400v520zm360 0v-320H520v-120h360v120H760v320z" }, null, -1)
271
+ function Nt(n, e) {
272
+ return w(), N("svg", wt, e[0] || (e[0] = [
273
+ b("path", { d: "M280-160v-520H80v-120h520v120H400v520zm360 0v-320H520v-120h360v120H760v320z" }, null, -1)
274
274
  ]));
275
275
  }
276
- const Et = { render: Tt }, Rt = ["onMousedown"], kt = { class: "-jte-mentions-entry" }, St = { class: "-jte-mentions-ref" }, Ot = {
276
+ const Tt = { render: Nt }, Et = ["onMousedown"], Rt = { class: "-jte-mentions-entry" }, kt = { class: "-jte-mentions-ref" }, St = {
277
277
  key: 0,
278
278
  class: "-jte-mentions-waiting"
279
- }, jt = {
279
+ }, Ot = {
280
280
  key: 1,
281
281
  class: "-jte-mentions-none"
282
- }, Lt = {
282
+ }, jt = {
283
283
  key: 0,
284
284
  class: "-jte-placeholder"
285
- }, Mt = ["contenteditable"], Dt = { class: "-jte-toolbox" }, $t = /* @__PURE__ */ Qe({
285
+ }, Lt = ["contenteditable"], Mt = { class: "-jte-toolbox" }, Bt = /* @__PURE__ */ Ge({
286
286
  name: "JuitTinyEditor",
287
287
  __name: "editor",
288
- props: /* @__PURE__ */ je({
288
+ props: /* @__PURE__ */ Xe({
289
289
  /** A flag indicating if content can be edited (default: `true`) */
290
290
  editable: {
291
291
  type: Boolean,
@@ -309,6 +309,18 @@ const Et = { render: Tt }, Rt = ["onMousedown"], kt = { class: "-jte-mentions-en
309
309
  type: Object,
310
310
  required: !1,
311
311
  default: () => ({})
312
+ },
313
+ /** Used as `@mention="..."`, notify the current mention text (`@abc...`) */
314
+ onMention: {
315
+ type: Function,
316
+ required: !1,
317
+ default: void 0
318
+ },
319
+ /** Used as `@submit="..."`, will display the send button and emit HTML */
320
+ onSubmit: {
321
+ type: Function,
322
+ required: !1,
323
+ default: void 0
312
324
  }
313
325
  }, {
314
326
  modelValue: {
@@ -318,110 +330,111 @@ const Et = { render: Tt }, Rt = ["onMousedown"], kt = { class: "-jte-mentions-en
318
330
  },
319
331
  modelModifiers: {}
320
332
  }),
321
- emits: /* @__PURE__ */ je(["mention", "submit"], ["update:modelValue"]),
322
- setup(n, { emit: e }) {
323
- const a = Ye(n, "modelValue"), s = n;
324
- T(() => s.dark, (o) => {
333
+ emits: ["update:modelValue"],
334
+ setup(n) {
335
+ const e = Je(n, "modelValue"), l = n;
336
+ T(() => l.dark, (o) => {
325
337
  var t;
326
- (t = i.value) == null || t.style.setProperty("color-scheme", o ? "dark light" : "light dark");
338
+ (t = s.value) == null || t.style.setProperty("color-scheme", o ? "dark light" : "light dark");
327
339
  });
328
- const i = q(null), l = q(null), r = q(null), f = q(null), m = q(null), c = q(null), g = E(""), v = E(0), h = q(null), S = H(() => {
340
+ const s = q(null), r = q(null), c = q(null), a = q(null), f = q(null), i = q(null), v = E(""), h = E(0), p = q(null), x = z(() => {
329
341
  var o;
330
- return ((o = h.value) == null ? void 0 : o.toString()) || "";
331
- }), xe = H(() => !!s.mentions), D = H(() => {
332
- const o = S.value.substring(1).toLowerCase();
333
- return s.mentions ? Object.entries(s.mentions).filter(([t, p]) => p.toLowerCase().startsWith(o)).sort(([t, p], [u, b]) => p.localeCompare(b)).map(([t, p]) => ({ name: t, value: p })) : [];
334
- }), K = E(null), G = E(null), te = E(null), _ = H(() => K.value || G.value);
342
+ return ((o = p.value) == null ? void 0 : o.toString()) || "";
343
+ }), P = z(() => !!l.mentions), M = z(() => {
344
+ const o = x.value.substring(1).toLowerCase();
345
+ return l.mentions ? Object.entries(l.mentions).filter(([t, m]) => m.toLowerCase().startsWith(o)).sort(([t, m], [u, g]) => m.localeCompare(g)).map(([t, m]) => ({ name: t, value: m })) : [];
346
+ }), K = E(null), G = E(null), te = E(null), A = z(() => K.value || G.value);
335
347
  T(K, (o) => o && (te.value = o));
336
- const ne = E(""), O = E(""), Ie = H(() => {
337
- if (!O.value) return !0;
348
+ const ne = E(""), S = E(""), $e = z(() => {
349
+ if (!S.value) return !0;
338
350
  try {
339
- return new URL(O.value), !0;
351
+ return new URL(S.value), !0;
340
352
  } catch {
341
353
  return !1;
342
354
  }
343
355
  });
344
- T([ne, O], ([o, t]) => {
345
- _.value && (_.value.textContent = o, _.value.setAttribute("href", t), $());
356
+ T([ne, S], ([o, t]) => {
357
+ A.value && (A.value.textContent = o, A.value.setAttribute("href", t), B());
346
358
  });
347
- const ue = E(null), ce = E(null), oe = E(0), _e = H(() => "." + ".".repeat(oe.value % 5));
359
+ const ue = E(null), ce = E(null), oe = E(0), Fe = z(() => "." + ".".repeat(oe.value % 5));
348
360
  let X = null;
349
- const B = E("");
350
- T(c, (o, t) => {
351
- t !== null && o !== null && (t.startContainer == o.startContainer && t.startOffset == o.startOffset && t.endContainer == o.endContainer && t.endOffset == o.endOffset && (t == null ? void 0 : t.backwards) == (o == null ? void 0 : o.backwards) || (B.value = ""));
361
+ const D = E("");
362
+ T(i, (o, t) => {
363
+ t !== null && o !== null && (t.startContainer == o.startContainer && t.startOffset == o.startOffset && t.endContainer == o.endContainer && t.endOffset == o.endOffset && (t == null ? void 0 : t.backwards) == (o == null ? void 0 : o.backwards) || (D.value = ""));
352
364
  });
353
- const F = [];
365
+ const I = [];
354
366
  function de(o, t) {
355
- return c.value ? t ? o && B.value === t ? "" : o || B.value === t ? "-jte-active" : "" : o ? "-jte-active" : c.value.collapsed ? "-jte-disabled" : "" : "-jte-disabled";
367
+ return i.value ? t ? o && D.value === t ? "" : o || D.value === t ? "-jte-active" : "" : o ? "-jte-active" : i.value.collapsed ? "-jte-disabled" : "" : "-jte-disabled";
356
368
  }
357
- function $() {
358
- if (!l.value) return void (g.value = "");
359
- const o = l.value.innerHTML;
360
- g.value = o === "<br>" ? "" : (
369
+ function B() {
370
+ if (!r.value) return void (v.value = "");
371
+ const o = r.value.innerHTML;
372
+ v.value = o === "<br>" ? "" : (
361
373
  // edge case: empty editor
362
374
  o.replaceAll("&nbsp;", " ").trimEnd()
363
375
  );
364
376
  }
365
377
  function fe() {
366
378
  var o;
367
- if (l.value && ((o = F[F.length - 1]) == null ? void 0 : o.content) !== g.value) {
368
- const t = he(l.value) || { start: 0, end: 0 };
369
- F.push({ ...t, content: g.value }), F.length > 100 && F.shift();
379
+ if (r.value && ((o = I[I.length - 1]) == null ? void 0 : o.content) !== v.value) {
380
+ const t = ge(r.value) || { start: 0, end: 0 };
381
+ I.push({ ...t, content: v.value }), I.length > 100 && I.shift();
370
382
  }
371
383
  }
372
- function Fe() {
373
- if (!l.value || !c.value) return;
374
- const o = F.pop();
384
+ function Pe() {
385
+ if (!r.value || !i.value) return;
386
+ const o = I.pop();
375
387
  if (!o) return;
376
388
  const t = new DOMParser().parseFromString(o.content, "text/html").body;
377
- l.value.replaceChildren(...t.childNodes), ge(l.value, o);
389
+ r.value.replaceChildren(...t.childNodes), be(r.value, o);
378
390
  }
379
- function we() {
391
+ function ye() {
380
392
  var o;
381
- if (h.value && ((o = c.value) != null && o.collapsed)) {
382
- const t = h.value.cloneRange();
383
- if (t.setEnd(c.value.startContainer, c.value.startOffset), t.toString().match(/^@[^\r\n]*$/)) {
384
- h.value = t;
393
+ if (p.value && ((o = i.value) != null && o.collapsed)) {
394
+ const t = p.value.cloneRange();
395
+ if (t.setEnd(i.value.startContainer, i.value.startOffset), t.toString().match(/^@[^\r\n]*$/)) {
396
+ p.value = t;
385
397
  return;
386
398
  }
387
399
  }
388
- h.value = null;
400
+ p.value = null;
389
401
  }
390
- function ye(o, t) {
391
- if (!l.value || !h.value) return;
392
- const p = l.value;
402
+ function we(o, t) {
403
+ if (!r.value || !p.value) return;
404
+ const m = r.value;
393
405
  fe();
394
- const u = document.createDocumentFragment(), b = document.createElement("link");
395
- b.setAttribute("rel", "mention"), b.setAttribute("name", o), b.setAttribute("title", t), u.append(b, " ");
396
- const d = me(p, h.value, u);
397
- z(d, !0), h.value = null, $();
406
+ const u = document.createDocumentFragment(), g = document.createElement("link");
407
+ g.setAttribute("rel", "mention"), g.setAttribute("name", o), g.setAttribute("title", t), u.append(g, " ");
408
+ const d = he(m, p.value, u);
409
+ _(d, !0), p.value = null, B();
398
410
  }
399
411
  function J(o, t = {}) {
400
- if (!l.value || !c.value) return;
401
- const p = l.value;
402
- if (c.value.collapsed) {
403
- B.value = o, p.focus();
412
+ if (!r.value || !i.value) return;
413
+ const m = r.value;
414
+ if (i.value.collapsed) {
415
+ D.value = o, m.focus();
404
416
  return;
405
417
  }
406
418
  fe();
407
- const u = W(p, c.value);
408
- Pe(p, c.value, o, t), z(u), $();
419
+ const u = W(m, i.value);
420
+ Be(m, i.value, o, t), _(u), B();
409
421
  }
410
- function ze() {
422
+ function Ae() {
411
423
  var u;
412
- if (!l.value || !((u = c.value) != null && u.collapsed)) return;
413
- const o = l.value, t = W(o, c.value), p = document.createTextNode("@");
414
- c.value.insertNode(p), t.end += 1, h.value = U(o, t), t.start += 1, z(t);
424
+ if (!r.value || !((u = i.value) != null && u.collapsed)) return;
425
+ const o = r.value, t = W(o, i.value), m = document.createTextNode("@");
426
+ i.value.insertNode(m), t.end += 1, p.value = U(o, t), t.start += 1, _(t);
415
427
  }
416
- function z(o, t) {
417
- if (!l.value) return;
418
- const p = l.value;
419
- c.value = ge(p, o, t), p.focus();
428
+ function _(o, t) {
429
+ if (!r.value) return;
430
+ const m = r.value;
431
+ i.value = be(m, o, t), m.focus();
420
432
  }
421
- function He() {
422
- g.value && Te("submit", g.value);
433
+ function Ie() {
434
+ var o;
435
+ v.value && ((o = l.onSubmit) == null || o.call(l, v.value));
423
436
  }
424
- function Ve(o) {
437
+ function _e(o) {
425
438
  if (o.metaKey || o.ctrlKey)
426
439
  switch (o.key) {
427
440
  case "b":
@@ -431,233 +444,235 @@ const Et = { render: Tt }, Rt = ["onMousedown"], kt = { class: "-jte-mentions-en
431
444
  J("i"), o.preventDefault();
432
445
  break;
433
446
  case "z":
434
- Fe(), o.preventDefault();
447
+ Pe(), o.preventDefault();
435
448
  break;
436
449
  }
437
- else if (h.value)
450
+ else if (p.value)
438
451
  switch (o.key) {
439
452
  case "Home":
440
- v.value = 0, o.preventDefault();
453
+ h.value = 0, o.preventDefault();
441
454
  break;
442
455
  case "ArrowUp":
443
- v.value = Math.max(v.value - 1, 0), o.preventDefault();
456
+ h.value = Math.max(h.value - 1, 0), o.preventDefault();
444
457
  break;
445
458
  case "PageUp":
446
- v.value = Math.max(v.value - 4, 0), o.preventDefault();
459
+ h.value = Math.max(h.value - 4, 0), o.preventDefault();
447
460
  break;
448
461
  case "ArrowDown":
449
- v.value = Math.min(v.value + 1, D.value.length - 1), o.preventDefault();
462
+ h.value = Math.min(h.value + 1, M.value.length - 1), o.preventDefault();
450
463
  break;
451
464
  case "PageDown":
452
- v.value = Math.min(v.value + 4, D.value.length - 1), o.preventDefault();
465
+ h.value = Math.min(h.value + 4, M.value.length - 1), o.preventDefault();
453
466
  break;
454
467
  case "End":
455
- v.value = D.value.length - 1, o.preventDefault();
468
+ h.value = M.value.length - 1, o.preventDefault();
456
469
  break;
457
470
  case "Escape":
458
- h.value = null, o.preventDefault();
471
+ p.value = null, o.preventDefault();
459
472
  break;
460
473
  case "Enter": {
461
- const t = D.value[v.value];
462
- t && ye(t.name, t.value), o.preventDefault();
474
+ const t = M.value[h.value];
475
+ t && we(t.name, t.value), o.preventDefault();
463
476
  break;
464
477
  }
465
478
  }
466
479
  }
467
- function Ue(o) {
468
- if (o.preventDefault(), !l.value || !c.value) return;
480
+ function ze(o) {
481
+ if (o.preventDefault(), !r.value || !i.value) return;
469
482
  const t = o.clipboardData;
470
483
  if (!t) return;
471
- const p = t.getData("text/html") || t.getData("text/plain");
472
- if (!p) return;
473
- const u = me(l.value, c.value, p);
474
- z(u, !0), $();
484
+ const m = t.getData("text/html") || t.getData("text/plain");
485
+ if (!m) return;
486
+ const u = he(r.value, i.value, m);
487
+ _(u, !0), B();
475
488
  }
476
- function We(o) {
477
- if (l.value && c.value && (fe(), !c.value.collapsed && (o.inputType === "deleteContentBackward" || o.inputType === "deleteContentForward"))) {
489
+ function He(o) {
490
+ if (r.value && i.value && (fe(), !i.value.collapsed && (o.inputType === "deleteContentBackward" || o.inputType === "deleteContentForward"))) {
478
491
  o.preventDefault(), o.stopPropagation();
479
- const t = me(l.value, c.value, "");
480
- z(t, !0), $();
492
+ const t = he(r.value, i.value, "");
493
+ _(t, !0), B();
481
494
  }
482
495
  }
483
- function Ke(o) {
484
- var b;
485
- const t = l.value;
496
+ function Ve(o) {
497
+ var g;
498
+ const t = r.value;
486
499
  if (!t) return;
487
- const p = h.value ? W(t, h.value) : null, u = he(t);
488
- if (B.value && u && u.start === u.end && o.inputType === "insertText" && o.data !== "@" && !h.value) {
500
+ const m = p.value ? W(t, p.value) : null, u = ge(t);
501
+ if (D.value && u && u.start === u.end && o.inputType === "insertText" && o.data !== "@" && !p.value) {
489
502
  const d = U(t, { start: u.start - 1, end: u.end });
490
- Pe(t, d, B.value);
503
+ Be(t, d, D.value);
491
504
  }
492
- if (B.value = "", ee(t), p && (h.value = U(t, p)), u && (t.innerHTML === "<br>" ? ((b = document.getSelection()) == null || b.setBaseAndExtent(t, 0, t, 0), t.focus()) : z(u)), !_.value && !h.value && o.data === "@" && o.inputType === "insertText") {
505
+ if (D.value = "", ee(t), m && (p.value = U(t, m)), u && (t.innerHTML === "<br>" ? ((g = document.getSelection()) == null || g.setBaseAndExtent(t, 0, t, 0), t.focus()) : _(u)), !A.value && !p.value && o.data === "@" && o.inputType === "insertText") {
493
506
  const d = document.getSelection();
494
507
  if (!(d != null && d.anchorNode)) return;
495
- const x = be(t, d.anchorNode, d.anchorOffset);
496
- if (x.match(/(\s|^)@$/)) {
497
- const w = x.length === 1 ? 0 : x.length - 1, j = x.length, R = { start: w, end: j };
498
- h.value = U(t, R);
508
+ const C = Ce(t, d.anchorNode, d.anchorOffset);
509
+ if (C.match(/(\s|^)@$/)) {
510
+ const y = C.length === 1 ? 0 : C.length - 1, O = C.length, R = { start: y, end: O };
511
+ p.value = U(t, R);
499
512
  }
500
513
  } else
501
- we();
502
- $();
514
+ ye();
515
+ B();
503
516
  }
504
517
  function Ne(o) {
505
- i.value && Ce(i.value) || (K.value = null, te.value = null, G.value = null), c.value = l.value ? Ce(l.value) : null, we();
518
+ s.value && xe(s.value) || (K.value = null, te.value = null, G.value = null), i.value = r.value ? xe(r.value) : null, ye();
506
519
  }
507
- Ze(() => {
508
- if (document.addEventListener("selectionchange", Ne), !i.value) throw new Error("Root not referenced");
509
- if (!l.value) throw new Error("Editor not referenced");
510
- if (!r.value) throw new Error("Popup not referenced");
511
- if (!f.value) throw new Error("List not referenced");
512
- if (!m.value) throw new Error("Popup not referenced");
513
- const o = i.value, t = l.value, p = r.value, u = f.value, b = m.value;
514
- T(g, (d) => {
515
- d !== a.value && (a.value = d);
516
- }), T(a, (d) => {
517
- if (d === g.value) return;
518
- const x = `<html><body>${d}</body></html>`, w = new DOMParser().parseFromString(x, "text/html").body;
519
- ee(w), t.replaceChildren(...w.childNodes), $();
520
- }, { immediate: !0 }), T(xe, (d) => {
520
+ return T(x, (o) => {
521
+ var t;
522
+ return o && ((t = l.onMention) == null ? void 0 : t.call(l, o));
523
+ }), Qe(() => {
524
+ if (document.addEventListener("selectionchange", Ne), !s.value) throw new Error("Root not referenced");
525
+ if (!r.value) throw new Error("Editor not referenced");
526
+ if (!c.value) throw new Error("Popup not referenced");
527
+ if (!a.value) throw new Error("List not referenced");
528
+ if (!f.value) throw new Error("Popup not referenced");
529
+ const o = s.value, t = r.value, m = c.value, u = a.value, g = f.value;
530
+ T(v, (d) => {
531
+ d !== e.value && (e.value = d);
532
+ }), T(e, (d) => {
533
+ if (d === v.value) return;
534
+ const C = `<html><body>${d}</body></html>`, y = new DOMParser().parseFromString(C, "text/html").body;
535
+ ee(y), t.replaceChildren(...y.childNodes), B();
536
+ }, { immediate: !0 }), T(P, (d) => {
521
537
  oe.value = 0, d ? X && clearInterval(X) : X = setInterval(() => oe.value = oe.value + 1, 200);
522
- }, { immediate: !0 }), T(_, (d) => {
523
- if (ne.value = (d == null ? void 0 : d.textContent) || "", O.value = (d == null ? void 0 : d.getAttribute("href")) || "", O.value === "http://__placeholder__/" && (d == null || d.setAttribute("href", ""), O.value = ""), !d) {
524
- const x = he(t);
525
- ee(t), x && ge(t, x), b.style.display = "none", b.style.top = "0", b.style.left = "0";
538
+ }, { immediate: !0 }), T(A, (d) => {
539
+ if (ne.value = (d == null ? void 0 : d.textContent) || "", S.value = (d == null ? void 0 : d.getAttribute("href")) || "", S.value === "http://__placeholder__/" && (d == null || d.setAttribute("href", ""), S.value = ""), !d) {
540
+ const C = ge(t);
541
+ ee(t), C && be(t, C), g.style.display = "none", g.style.top = "0", g.style.left = "0";
526
542
  return;
527
543
  }
528
- Le(() => {
529
- b.style.display = "flex";
530
- const x = o.getBoundingClientRect(), w = d.getBoundingClientRect(), j = t.getBoundingClientRect(), R = getComputedStyle(b), k = parseInt(R.width), L = parseInt(R.height), re = w.top - L - 6 > j.top, se = w.bottom + L + 3 < j.bottom, Q = w.left + k < j.right;
531
- b.style.top = !se && re ? `${w.top - L - x.top - 6}px` : (
544
+ Oe(() => {
545
+ g.style.display = "flex";
546
+ const C = o.getBoundingClientRect(), y = d.getBoundingClientRect(), O = t.getBoundingClientRect(), R = getComputedStyle(g), k = parseInt(R.width), j = parseInt(R.height), re = y.top - j - 6 > O.top, le = y.bottom + j + 3 < O.bottom, Q = y.left + k < O.right;
547
+ g.style.top = !le && re ? `${y.top - j - C.top - 6}px` : (
532
548
  // over the link
533
- `${w.bottom - x.top + 3}px`
534
- ), b.style.left = Q ? `${w.left - x.left}px` : (
549
+ `${y.bottom - C.top + 3}px`
550
+ ), g.style.left = Q ? `${y.left - C.left}px` : (
535
551
  // right of the link
536
- `${j.right - k - x.left}px`
552
+ `${O.right - k - C.left}px`
537
553
  );
538
554
  });
539
- }, { immediate: !0 }), T([v, h, D], ([d, x, w], [j = -1]) => {
540
- if (d >= w.length && (d = Math.max(w.length - 1, 0)), v.value = d, !!p && u) {
541
- if (!x) {
542
- v.value = 0, p.style.display = "none", p.style.top = "0", p.style.left = "0", u.scrollTop = 0;
555
+ }, { immediate: !0 }), T([h, p, M], ([d, C, y], [O = -1]) => {
556
+ if (d >= y.length && (d = Math.max(y.length - 1, 0)), h.value = d, !!m && u) {
557
+ if (!C) {
558
+ h.value = 0, m.style.display = "none", m.style.top = "0", m.style.left = "0", u.scrollTop = 0;
543
559
  return;
544
560
  }
545
- Le(() => {
546
- p.style.display = "block";
547
- const R = o.getBoundingClientRect(), k = x.getBoundingClientRect(), L = t.getBoundingClientRect(), re = getComputedStyle(p), se = parseInt(re.width), Q = parseInt(re.height), Ge = k.top - Q - 6 > L.top, Xe = k.bottom + Q + 3 < L.bottom, Je = k.left + se < L.right;
548
- p.style.top = !Xe && Ge ? `${k.top - Q - R.top - 6}px` : (
561
+ Oe(() => {
562
+ m.style.display = "block";
563
+ const R = o.getBoundingClientRect(), k = C.getBoundingClientRect(), j = t.getBoundingClientRect(), re = getComputedStyle(m), le = parseInt(re.width), Q = parseInt(re.height), Ue = k.top - Q - 6 > j.top, We = k.bottom + Q + 3 < j.bottom, Ke = k.left + le < j.right;
564
+ m.style.top = !We && Ue ? `${k.top - Q - R.top - 6}px` : (
549
565
  // over the link
550
566
  `${k.bottom - R.top + 3}px`
551
- ), p.style.left = Je ? `${k.left - R.left}px` : (
567
+ ), m.style.left = Ke ? `${k.left - R.left}px` : (
552
568
  // right of the link
553
- `${L.right - se - R.left}px`
569
+ `${j.right - le - R.left}px`
554
570
  );
555
- const pe = u.querySelectorAll("li")[v.value];
556
- if (!pe) return;
557
- const Ee = getComputedStyle(pe), Re = parseFloat(Ee.getPropertyValue("border-top-width")) || 0, ke = parseFloat(Ee.getPropertyValue("border-bottom-width")) || 0, Y = u.getBoundingClientRect(), ve = pe.getBoundingClientRect(), le = ve.top - Y.top, Se = ve.bottom - Y.bottom, Oe = ve.bottom - Y.top;
558
- d > j ? Oe > Y.height ? u.scrollTop += Se - ke : le < 0 && (u.scrollTop += le + Re) : le < 0 ? u.scrollTop += le + Re : Se > 0 && (u.scrollTop += Oe - Y.height - ke);
571
+ const ve = u.querySelectorAll("li")[h.value];
572
+ if (!ve) return;
573
+ const Te = getComputedStyle(ve), Ee = parseFloat(Te.getPropertyValue("border-top-width")) || 0, Re = parseFloat(Te.getPropertyValue("border-bottom-width")) || 0, Y = u.getBoundingClientRect(), pe = ve.getBoundingClientRect(), se = pe.top - Y.top, ke = pe.bottom - Y.bottom, Se = pe.bottom - Y.top;
574
+ d > O ? Se > Y.height ? u.scrollTop += ke - Re : se < 0 && (u.scrollTop += se + Ee) : se < 0 ? u.scrollTop += se + Ee : ke > 0 && (u.scrollTop += Se - Y.height - Re);
559
575
  });
560
576
  }
561
- }, { immediate: !0 }), T(c, (d) => {
577
+ }, { immediate: !0 }), T(i, (d) => {
562
578
  d ? (K.value = ae(t, d, "a"), ue.value = ae(t, d, "b"), ce.value = ae(t, d, "i")) : (K.value = null, ue.value = null, ce.value = null);
563
579
  }, { immediate: !0 });
564
- }), et(() => {
580
+ }), Ye(() => {
565
581
  document.removeEventListener("selectionchange", Ne), X && clearInterval(X);
566
- });
567
- const Te = e;
568
- return T(S, (o) => o && Te("mention", o)), (o, t) => {
569
- var p;
570
- return N(), y("div", {
571
- class: M(["juit-tiny-edit", { "-jte-editable": n.editable, "-jte-dark": n.dark }])
582
+ }), (o, t) => {
583
+ var m;
584
+ return w(), N("div", {
585
+ class: L(["juit-tiny-edit", { "-jte-editable": n.editable, "-jte-dark": n.dark }])
572
586
  }, [
573
- C("div", {
587
+ b("div", {
574
588
  ref_key: "rootRef",
575
- ref: i,
589
+ ref: s,
576
590
  class: "-jte-root"
577
591
  }, [
578
- C("div", {
592
+ b("div", {
579
593
  ref_key: "mentionsPopupRef",
580
- ref: r,
594
+ ref: c,
581
595
  class: "-jte-mentions-popup"
582
596
  }, [
583
- C("ul", {
597
+ b("ul", {
584
598
  ref_key: "mentionsListRef",
585
- ref: f
599
+ ref: a
586
600
  }, [
587
- (N(!0), y(tt, null, nt(D.value, (u, b) => (N(), y("li", {
588
- key: b,
589
- class: M({ "-jte-mentions-selected": v.value === b }),
590
- onMousedown: (d) => ye(u.name, u.value)
601
+ (w(!0), N(Ze, null, et(M.value, (u, g) => (w(), N("li", {
602
+ key: g,
603
+ class: L({ "-jte-mentions-selected": h.value === g }),
604
+ onMousedown: (d) => we(u.name, u.value)
591
605
  }, [
592
- C("div", kt, [
593
- ot(V(u.value) + " ", 1),
594
- C("span", St, V(u.name), 1)
606
+ b("div", Rt, [
607
+ tt(H(u.value) + " ", 1),
608
+ b("span", kt, H(u.name), 1)
595
609
  ])
596
- ], 42, Rt))), 128))
610
+ ], 42, Et))), 128))
597
611
  ], 512),
598
- xe.value ? D.value.length ? Me("", !0) : (N(), y("div", jt, V(S.value), 1)) : (N(), y("div", Ot, V(S.value) + V(_e.value), 1))
612
+ P.value ? M.value.length ? me("", !0) : (w(), N("div", Ot, H(x.value), 1)) : (w(), N("div", St, H(x.value) + H(Fe.value), 1))
599
613
  ], 512),
600
- C("div", {
614
+ b("div", {
601
615
  ref_key: "linksPopupRef",
602
- ref: m,
616
+ ref: f,
603
617
  class: "-jte-links-popup",
604
618
  onClick: t[2] || (t[2] = (u) => G.value = te.value),
605
619
  onFocusin: t[3] || (t[3] = (u) => G.value = te.value)
606
620
  }, [
607
- C("div", null, [
608
- P(A(Et), { class: "-jte-icon" }),
609
- De(C("input", {
621
+ b("div", null, [
622
+ V($(Tt), { class: "-jte-icon" }),
623
+ je(b("input", {
610
624
  "onUpdate:modelValue": t[0] || (t[0] = (u) => ne.value = u),
611
625
  type: "text"
612
626
  }, null, 512), [
613
- [Be, ne.value]
627
+ [Le, ne.value]
614
628
  ])
615
629
  ]),
616
- C("div", {
617
- class: M({ "-jte-error": !Ie.value })
630
+ b("div", {
631
+ class: L({ "-jte-error": !$e.value })
618
632
  }, [
619
- P(A(Ae), { class: "-jte-icon" }),
620
- De(C("input", {
621
- "onUpdate:modelValue": t[1] || (t[1] = (u) => O.value = u),
633
+ V($(qe), { class: "-jte-icon" }),
634
+ je(b("input", {
635
+ "onUpdate:modelValue": t[1] || (t[1] = (u) => S.value = u),
622
636
  type: "text"
623
637
  }, null, 512), [
624
- [Be, O.value]
638
+ [Le, S.value]
625
639
  ])
626
640
  ], 2)
627
641
  ], 544),
628
- n.placeholder && !g.value ? (N(), y("div", Lt, V(n.placeholder), 1)) : Me("", !0),
629
- C("div", {
642
+ n.placeholder && !v.value ? (w(), N("div", jt, H(n.placeholder), 1)) : me("", !0),
643
+ b("div", {
630
644
  ref_key: "editorRef",
631
- ref: l,
645
+ ref: r,
632
646
  class: "-jte-editor",
633
647
  contenteditable: n.editable ? "plaintext-only" : "false",
634
- onBeforeinput: t[4] || (t[4] = (u) => We(u)),
635
- onInput: t[5] || (t[5] = (u) => Ke(u)),
636
- onKeydown: t[6] || (t[6] = (u) => Ve(u)),
637
- onPaste: t[7] || (t[7] = (u) => Ue(u)),
648
+ onBeforeinput: t[4] || (t[4] = (u) => He(u)),
649
+ onInput: t[5] || (t[5] = (u) => Ve(u)),
650
+ onKeydown: t[6] || (t[6] = (u) => _e(u)),
651
+ onPaste: t[7] || (t[7] = (u) => ze(u)),
638
652
  onFocusin: t[8] || (t[8] = (u) => G.value = null)
639
- }, null, 40, Mt),
640
- C("div", Dt, [
641
- P(A(Ct), {
642
- class: M(["-jte-icon -jte-icon-mention", { "-jte-disabled": !((p = c.value) != null && p.collapsed) }]),
643
- onClick: ze
653
+ }, null, 40, Lt),
654
+ b("div", Mt, [
655
+ V($(bt), {
656
+ class: L(["-jte-icon -jte-icon-mention", { "-jte-disabled": !((m = i.value) != null && m.collapsed) }]),
657
+ onClick: Ae
644
658
  }, null, 8, ["class"]),
645
- P(A(dt), {
646
- class: M(["-jte-icon -jte-icon-bold", de(ue.value, "b")]),
659
+ V($(ct), {
660
+ class: L(["-jte-icon -jte-icon-bold", de(ue.value, "b")]),
647
661
  onClick: t[9] || (t[9] = (u) => J("b"))
648
662
  }, null, 8, ["class"]),
649
- P(A(vt), {
650
- class: M(["-jte-icon -jte-icon-italic", de(ce.value, "i")]),
663
+ V($(vt), {
664
+ class: L(["-jte-icon -jte-icon-italic", de(ce.value, "i")]),
651
665
  onClick: t[10] || (t[10] = (u) => J("i"))
652
666
  }, null, 8, ["class"]),
653
- P(A(Ae), {
654
- class: M(["-jte-icon -jte-icon-href", de(_.value)]),
667
+ V($(qe), {
668
+ class: L(["-jte-icon -jte-icon-href", de(A.value)]),
655
669
  onClick: t[11] || (t[11] = (u) => J("a", { href: "http://__placeholder__/" }))
656
670
  }, null, 8, ["class"]),
657
- P(A(yt), {
658
- class: M(["-jte-icon -jte-icon-send", { "-jte-disabled": !g.value, "-jte-active": !!g.value }]),
659
- onClick: He
660
- }, null, 8, ["class"])
671
+ n.onSubmit ? (w(), nt($(yt), {
672
+ key: 0,
673
+ class: L(["-jte-icon -jte-icon-send", { "-jte-disabled": !v.value, "-jte-active": !!v.value }]),
674
+ onClick: Ie
675
+ }, null, 8, ["class"])) : me("", !0)
661
676
  ])
662
677
  ], 512)
663
678
  ], 2);
@@ -665,6 +680,6 @@ const Et = { render: Tt }, Rt = ["onMousedown"], kt = { class: "-jte-mentions-en
665
680
  }
666
681
  });
667
682
  export {
668
- $t as default
683
+ Bt as default
669
684
  };
670
685
  //# sourceMappingURL=index.js.map