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