@juit/vue-tiny-editor 1.0.48 → 1.0.50

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