@mobilon-dev/chotto 0.3.99 → 0.3.100
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/chotto.css +1 -1
- package/dist/components/1_atoms/EmojiGlyph/EmojiGlyph.vue.js +15 -15
- package/dist/components/2_chatinput_elements/ButtonEmojiPicker/ButtonEmojiPicker.vue.js +1 -1
- package/dist/components/2_chatinput_elements/ButtonEmojiPicker/ButtonEmojiPicker.vue2.js +79 -65
- package/dist/components/2_chatlist_elements/ChatItem/ChatItem.vue.js +1 -1
- package/dist/components/2_chatlist_elements/ChatItem/ChatItem.vue2.js +150 -150
- package/dist/components/2_feed_elements/MessageReactions/MessageReactions.vue.js +2 -2
- package/dist/components/2_feed_elements/MessageReactions/MessageReactions.vue2.js +79 -78
- package/dist/components/2_feed_elements/ReplyStickerMessage/ReplyStickerMessage.vue.js +2 -2
- package/dist/components/2_feed_elements/ReplyStickerMessage/ReplyStickerMessage.vue2.js +42 -42
- package/dist/components/3_compounds/ChatInput/ChatInput.vue.js +2 -2
- package/dist/components/3_compounds/ChatInput/ChatInput.vue2.js +68 -68
- package/dist/functions/renderAppleEmojis.js +120 -91
- package/dist/hooks/messages/useMessageLinks.js +15 -15
- package/dist/hooks/useEmojiNative.js +24 -12
- package/dist/node_modules/vue3-emoji-picker-ru/dist/emoji-picker.es.js +581 -555
- package/dist/themes/dark.css +1 -1
- package/dist/themes/default.css +1 -1
- package/dist/themes/glass.css +1 -1
- package/dist/themes/green.css +1 -1
- package/dist/themes/mobilon1.css +1 -1
- package/dist/types/components/2_chatinput_elements/ButtonEmojiPicker/ButtonEmojiPicker.vue.d.ts +21 -2
- package/dist/types/functions/renderAppleEmojis.d.ts +13 -10
- package/dist/types/hooks/useEmojiNative.d.ts +5 -2
- package/package.json +2 -2
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { defineComponent as
|
|
2
|
-
import { useImmediateDebouncedRef as
|
|
3
|
-
import { useMessageDraft as
|
|
1
|
+
import { defineComponent as we, inject as Ce, watch as d, ref as E, computed as _, nextTick as S, unref as u, onMounted as Ae, onUnmounted as Ee, createElementBlock as k, openBlock as F, createElementVNode as h, createVNode as O, normalizeClass as j, createBlock as Fe, createCommentVNode as U, renderSlot as Y, toDisplayString as Me, withDirectives as Re, withKeys as He, vModelText as ke } from "vue";
|
|
2
|
+
import { useImmediateDebouncedRef as Le } from "../../../hooks/useImmediateDebouncedRef.js";
|
|
3
|
+
import { useMessageDraft as De, commitChatDraftToList as Pe } from "../../../hooks/useMessageDraft.js";
|
|
4
4
|
import "../../../hooks/useSearchModel.js";
|
|
5
5
|
import "../../../hooks/useTheme.js";
|
|
6
|
-
import { useEmojiNative as
|
|
6
|
+
import { useEmojiNative as We } from "../../../hooks/useEmojiNative.js";
|
|
7
7
|
/* empty css */
|
|
8
8
|
/* empty css */
|
|
9
9
|
import { t as I } from "../../../locale/useLocale.js";
|
|
@@ -11,18 +11,18 @@ import { t as I } from "../../../locale/useLocale.js";
|
|
|
11
11
|
import "../../../node_modules/linkifyjs/dist/linkify.js";
|
|
12
12
|
import "../../../node_modules/linkify-string/dist/linkify-string.js";
|
|
13
13
|
import "../../../functions/parseMarkdown.js";
|
|
14
|
-
import { textToAppleEmojiHtml as
|
|
15
|
-
import { hideEditPreview as
|
|
14
|
+
import { textToAppleEmojiHtml as qe, textContainsEmoji as Be, previousGraphemeIndex as V, nextGraphemeIndex as $, snapIndexToGrapheme as J } from "../../../functions/renderAppleEmojis.js";
|
|
15
|
+
import { hideEditPreview as je } from "../../../hooks/messages/useStartEdit.js";
|
|
16
16
|
import ze from "./icons/SendIcon.vue.js";
|
|
17
17
|
import Ke from "../../2_chatinput_elements/TextFormatToolbar/TextFormatToolbar.vue.js";
|
|
18
|
-
import
|
|
19
|
-
const
|
|
18
|
+
import Ne from "../../2_chatinput_elements/FilePreview/FilePreview.vue.js";
|
|
19
|
+
const Ge = { class: "chat-input__container" }, Oe = ["id"], Ue = ["id"], Ye = { class: "chat-input__inline-buttons" }, Ve = {
|
|
20
20
|
key: 0,
|
|
21
21
|
class: "chat-input__input chat-input__disabled-placeholder"
|
|
22
|
-
},
|
|
22
|
+
}, $e = {
|
|
23
23
|
key: 1,
|
|
24
24
|
class: "chat-input__input-wrap"
|
|
25
|
-
},
|
|
25
|
+
}, Je = ["innerHTML"], Qe = ["disabled", "placeholder"], Xe = ["disabled"], Ze = { class: "" }, et = { class: "chat-input__third-line" }, z = 40, _t = /* @__PURE__ */ we({
|
|
26
26
|
__name: "ChatInput",
|
|
27
27
|
props: {
|
|
28
28
|
state: {
|
|
@@ -52,21 +52,21 @@ const Ne = { class: "chat-input__container" }, Ge = ["id"], Oe = ["id"], Ue = {
|
|
|
52
52
|
},
|
|
53
53
|
emits: ["send", "typing"],
|
|
54
54
|
setup(T, { emit: Q }) {
|
|
55
|
-
const L = Q, b =
|
|
56
|
-
let
|
|
55
|
+
const L = Q, b = Ce("chatAppId"), { resetMessage: X, getMessage: l, setMessageText: M, setForceSendMessage: Z, resetEdit: ee, resetMessageFile: te } = De(b), { isNative: ne, emojiSrc: ie } = We(b);
|
|
56
|
+
let K = l().id;
|
|
57
57
|
d(
|
|
58
58
|
() => l().id,
|
|
59
59
|
(e) => {
|
|
60
|
-
|
|
60
|
+
K = e;
|
|
61
61
|
}
|
|
62
62
|
);
|
|
63
|
-
const n = E(), m = E(), v = E(null), w = E(!1),
|
|
63
|
+
const n = E(), m = E(), v = E(null), w = E(!1), oe = Le("", 2e3), D = _(() => {
|
|
64
64
|
var e;
|
|
65
65
|
return (e = l().file) == null ? void 0 : e.preview;
|
|
66
|
-
}),
|
|
67
|
-
() =>
|
|
66
|
+
}), le = _(
|
|
67
|
+
() => qe(l().text || "", v.value, ie.value)
|
|
68
68
|
), g = _(
|
|
69
|
-
() => !ne.value &&
|
|
69
|
+
() => !ne.value && Be(l().text || "")
|
|
70
70
|
), c = () => {
|
|
71
71
|
if (!m.value || !n.value) return;
|
|
72
72
|
const e = n.value, t = m.value, o = Math.max(0, e.offsetWidth - e.clientWidth);
|
|
@@ -76,16 +76,16 @@ const Ne = { class: "chat-input__container" }, Ge = ["id"], Oe = ["id"], Ue = {
|
|
|
76
76
|
function P() {
|
|
77
77
|
v.value = null;
|
|
78
78
|
}
|
|
79
|
-
function
|
|
79
|
+
function se(e = "nearest") {
|
|
80
80
|
const t = n.value;
|
|
81
81
|
if (!t || !g.value) return;
|
|
82
82
|
const o = t.value, i = J(o, t.selectionStart, e), r = J(o, t.selectionEnd, e);
|
|
83
83
|
(i !== t.selectionStart || r !== t.selectionEnd) && t.setSelectionRange(i, r);
|
|
84
84
|
}
|
|
85
85
|
function W() {
|
|
86
|
-
|
|
86
|
+
se("nearest"), f();
|
|
87
87
|
}
|
|
88
|
-
function
|
|
88
|
+
function ae(e) {
|
|
89
89
|
if (!g.value || e.key !== "ArrowLeft" && e.key !== "ArrowRight" || e.altKey || e.metaKey || e.ctrlKey) return;
|
|
90
90
|
const t = n.value;
|
|
91
91
|
if (!t) return;
|
|
@@ -130,13 +130,13 @@ const Ne = { class: "chat-input__container" }, Ge = ["id"], Oe = ["id"], Ue = {
|
|
|
130
130
|
});
|
|
131
131
|
});
|
|
132
132
|
}
|
|
133
|
-
function
|
|
133
|
+
function re(e) {
|
|
134
134
|
e.buttons && f();
|
|
135
135
|
}
|
|
136
136
|
function N() {
|
|
137
137
|
document.activeElement === n.value && f();
|
|
138
138
|
}
|
|
139
|
-
const a = T,
|
|
139
|
+
const a = T, ue = _(() => !!(a.state == "disabled" || l().text == "" && !l().file || l().isRecording)), ce = _(() => {
|
|
140
140
|
var t;
|
|
141
141
|
if (a.inputButtonColor)
|
|
142
142
|
return a.inputButtonColor;
|
|
@@ -144,7 +144,7 @@ const Ne = { class: "chat-input__container" }, Ge = ["id"], Oe = ["id"], Ue = {
|
|
|
144
144
|
return "#25D366";
|
|
145
145
|
const e = a.selectedChannel.channelId.toLowerCase();
|
|
146
146
|
return e.includes("whatsapp") || e.includes("waba") ? "#25D366" : e.includes("telegram") ? "#37AFE2" : e.includes("sms") ? "#6C757D" : e.includes("max") ? "#4B0082" : "#25D366";
|
|
147
|
-
}),
|
|
147
|
+
}), de = _(() => {
|
|
148
148
|
var t;
|
|
149
149
|
if (!((t = a.selectedChannel) != null && t.channelId))
|
|
150
150
|
return I("component.ChatInput.InputPlaceholder");
|
|
@@ -152,7 +152,7 @@ const Ne = { class: "chat-input__container" }, Ge = ["id"], Oe = ["id"], Ue = {
|
|
|
152
152
|
return e.includes("whatsapp") || e.includes("waba") ? I("component.ChatInput.WhatsappInputPlaceholder") : e.includes("telegram") ? I("component.ChatInput.TelegramInputPlaceholder") : e.includes("sms") ? I("component.ChatInput.SmsInputPlaceholder") : e.includes("max") ? I("component.ChatInput.MaxInputPlaceholder") : I("component.ChatInput.InputPlaceholder");
|
|
153
153
|
});
|
|
154
154
|
d(
|
|
155
|
-
() =>
|
|
155
|
+
() => oe.value,
|
|
156
156
|
() => {
|
|
157
157
|
L("typing");
|
|
158
158
|
}
|
|
@@ -203,9 +203,9 @@ const Ne = { class: "chat-input__container" }, Ge = ["id"], Oe = ["id"], Ue = {
|
|
|
203
203
|
});
|
|
204
204
|
function R(e) {
|
|
205
205
|
const t = l().inputHeight;
|
|
206
|
-
e.style.height = (t ||
|
|
206
|
+
e.style.height = (t || z) + "px", (!t || t <= z) && (e.style.overflowY = "hidden");
|
|
207
207
|
}
|
|
208
|
-
function
|
|
208
|
+
function fe(e) {
|
|
209
209
|
const t = parseFloat(e.style.height);
|
|
210
210
|
Number.isFinite(t) && (l().inputHeight = t);
|
|
211
211
|
}
|
|
@@ -217,17 +217,17 @@ const Ne = { class: "chat-input__container" }, Ge = ["id"], Oe = ["id"], Ue = {
|
|
|
217
217
|
}
|
|
218
218
|
const o = e.scrollTop;
|
|
219
219
|
e.style.height = "auto";
|
|
220
|
-
const i = getComputedStyle(e), r = parseFloat(i.fontSize) || 16, p = parseFloat(i.lineHeight) || r * 1.4, x =
|
|
220
|
+
const i = getComputedStyle(e), r = parseFloat(i.fontSize) || 16, p = parseFloat(i.lineHeight) || r * 1.4, x = z, A = p * 11, B = e.scrollHeight, xe = t.split(`
|
|
221
221
|
`).length > 1, s = document.createElement("div");
|
|
222
222
|
s.style.position = "absolute", s.style.visibility = "hidden", s.style.whiteSpace = "nowrap", s.style.font = i.font, s.style.fontSize = i.fontSize, s.style.fontFamily = i.fontFamily, s.style.fontWeight = i.fontWeight, s.style.letterSpacing = i.letterSpacing, s.textContent = t, document.body.appendChild(s);
|
|
223
|
-
const
|
|
223
|
+
const _e = s.offsetWidth;
|
|
224
224
|
document.body.removeChild(s);
|
|
225
|
-
const
|
|
225
|
+
const Se = parseFloat(i.paddingLeft) || 0, Ie = parseFloat(i.paddingRight) || 0, Te = e.clientWidth - Se - Ie, be = _e > Te, G = xe || be;
|
|
226
226
|
if (G && B <= x + 1) {
|
|
227
227
|
R(e);
|
|
228
228
|
return;
|
|
229
229
|
}
|
|
230
|
-
t.trim() && G ? B <= A ? (e.style.height = B + "px", e.style.overflowY = "hidden") : (e.style.height = A + "px", e.style.overflowY = "auto", e.scrollTop = o) : (e.style.height = x + "px", e.style.overflowY = "hidden"),
|
|
230
|
+
t.trim() && G ? B <= A ? (e.style.height = B + "px", e.style.overflowY = "hidden") : (e.style.height = A + "px", e.style.overflowY = "auto", e.scrollTop = o) : (e.style.height = x + "px", e.style.overflowY = "hidden"), fe(e), c(), requestAnimationFrame(c);
|
|
231
231
|
}
|
|
232
232
|
function H(e) {
|
|
233
233
|
if (a.state === "disabled" || l().isRecording) return;
|
|
@@ -240,17 +240,17 @@ const Ne = { class: "chat-input__container" }, Ge = ["id"], Oe = ["id"], Ue = {
|
|
|
240
240
|
l().forceSend && (q(), Z(!1));
|
|
241
241
|
}
|
|
242
242
|
);
|
|
243
|
-
const
|
|
243
|
+
const pe = (e) => {
|
|
244
244
|
const t = e.target;
|
|
245
245
|
L("typing", t.value), f();
|
|
246
246
|
};
|
|
247
|
-
|
|
247
|
+
Ae(() => {
|
|
248
248
|
const e = n.value;
|
|
249
249
|
e && (R(e), C(e)), document.addEventListener("selectionchange", N);
|
|
250
|
-
}),
|
|
251
|
-
|
|
250
|
+
}), Ee(() => {
|
|
251
|
+
Pe(K), document.removeEventListener("selectionchange", N), y && cancelAnimationFrame(y);
|
|
252
252
|
});
|
|
253
|
-
const
|
|
253
|
+
const he = (e) => {
|
|
254
254
|
if (e.shiftKey) {
|
|
255
255
|
if (n.value instanceof HTMLTextAreaElement) {
|
|
256
256
|
let t = n.value.selectionStart;
|
|
@@ -267,7 +267,7 @@ const Ne = { class: "chat-input__container" }, Ge = ["id"], Oe = ["id"], Ue = {
|
|
|
267
267
|
e.preventDefault();
|
|
268
268
|
} else
|
|
269
269
|
e.preventDefault(), q();
|
|
270
|
-
},
|
|
270
|
+
}, me = (e) => {
|
|
271
271
|
if (n.value) {
|
|
272
272
|
const t = n.value.value;
|
|
273
273
|
n.value.value = e.newText;
|
|
@@ -277,21 +277,21 @@ const Ne = { class: "chat-input__container" }, Ge = ["id"], Oe = ["id"], Ue = {
|
|
|
277
277
|
});
|
|
278
278
|
}
|
|
279
279
|
};
|
|
280
|
-
function me() {
|
|
281
|
-
te();
|
|
282
|
-
}
|
|
283
280
|
function ve() {
|
|
284
|
-
|
|
281
|
+
te();
|
|
285
282
|
}
|
|
286
283
|
function ge() {
|
|
284
|
+
ee(), M(""), je(b), n.value && n.value.focus();
|
|
285
|
+
}
|
|
286
|
+
function ye() {
|
|
287
287
|
const e = l();
|
|
288
288
|
return e.edit ? (e.text ?? "").trim() === (e.edit.text ?? "").trim() : !1;
|
|
289
289
|
}
|
|
290
290
|
const q = () => {
|
|
291
291
|
var t, o;
|
|
292
292
|
const e = E(l());
|
|
293
|
-
if (e.value.edit &&
|
|
294
|
-
|
|
293
|
+
if (e.value.edit && ye()) {
|
|
294
|
+
ge();
|
|
295
295
|
return;
|
|
296
296
|
}
|
|
297
297
|
if (e.value.text != "" || e.value.file) {
|
|
@@ -306,75 +306,75 @@ const Ne = { class: "chat-input__container" }, Ge = ["id"], Oe = ["id"], Ue = {
|
|
|
306
306
|
e.value.file ? (i.type = "message." + e.value.file.type, i.url = e.value.file.url, i.filename = e.value.file.name, i.size = (t = e.value.file.size) == null ? void 0 : t.toString(), i.text = (o = e == null ? void 0 : e.value) == null ? void 0 : o.text.trim()) : (i.type = "message.text", i.text = e.value.text.trim()), e.value.reply && (i.reply = e.value.reply), e.value.edit && (i.edit = e.value.edit), L("send", i), X(), n.value && n.value.focus();
|
|
307
307
|
}
|
|
308
308
|
};
|
|
309
|
-
return (e, t) => (F(), k("div",
|
|
309
|
+
return (e, t) => (F(), k("div", Ge, [
|
|
310
310
|
h("div", {
|
|
311
311
|
id: "chat-input-reply-line-" + u(b),
|
|
312
312
|
class: "chat-input__reply-line"
|
|
313
|
-
}, null, 8,
|
|
313
|
+
}, null, 8, Oe),
|
|
314
314
|
h("div", {
|
|
315
315
|
id: "chat-input-file-line-" + u(b),
|
|
316
|
-
class:
|
|
316
|
+
class: j(["chat-input__file-line", { "chat-input__file-line--visible": !!D.value }])
|
|
317
317
|
}, [
|
|
318
|
-
D.value ? (F(),
|
|
318
|
+
D.value ? (F(), Fe(Ne, {
|
|
319
319
|
key: 0,
|
|
320
320
|
"file-info": D.value,
|
|
321
|
-
onReset:
|
|
321
|
+
onReset: ve
|
|
322
322
|
}, null, 8, ["file-info"])) : U("", !0)
|
|
323
|
-
], 10,
|
|
324
|
-
h("div",
|
|
323
|
+
], 10, Ue),
|
|
324
|
+
h("div", Ye, [
|
|
325
325
|
Y(e.$slots, "inline-buttons", {}, void 0, !0)
|
|
326
326
|
]),
|
|
327
|
-
T.disabledPlaceholder && (T.state == "disabled" || u(l)().isRecording) ? (F(), k("div",
|
|
327
|
+
T.disabledPlaceholder && (T.state == "disabled" || u(l)().isRecording) ? (F(), k("div", Ve, Me(T.disabledPlaceholder), 1)) : (F(), k("div", $e, [
|
|
328
328
|
g.value ? (F(), k("div", {
|
|
329
329
|
key: 0,
|
|
330
330
|
ref_key: "refMirror",
|
|
331
331
|
ref: m,
|
|
332
332
|
class: "chat-input__input-mirror",
|
|
333
333
|
"aria-hidden": "true",
|
|
334
|
-
innerHTML:
|
|
335
|
-
}, null, 8,
|
|
336
|
-
|
|
334
|
+
innerHTML: le.value
|
|
335
|
+
}, null, 8, Je)) : U("", !0),
|
|
336
|
+
Re(h("textarea", {
|
|
337
337
|
ref_key: "refInput",
|
|
338
338
|
ref: n,
|
|
339
339
|
"onUpdate:modelValue": t[0] || (t[0] = (o) => u(l)().text = o),
|
|
340
340
|
rows: "1",
|
|
341
341
|
disabled: T.state == "disabled" || u(l)().isRecording,
|
|
342
|
-
class:
|
|
343
|
-
placeholder:
|
|
342
|
+
class: j(["chat-input__input", { "chat-input__input--emoji-images": g.value }]),
|
|
343
|
+
placeholder: de.value,
|
|
344
344
|
onKeydown: [
|
|
345
|
-
|
|
346
|
-
|
|
345
|
+
ae,
|
|
346
|
+
He(he, ["enter"])
|
|
347
347
|
],
|
|
348
|
-
onInput:
|
|
348
|
+
onInput: pe,
|
|
349
349
|
onScroll: c,
|
|
350
350
|
onSelect: f,
|
|
351
351
|
onMouseup: W,
|
|
352
352
|
onKeyup: W,
|
|
353
|
-
onMousemove:
|
|
353
|
+
onMousemove: re,
|
|
354
354
|
onBlur: P
|
|
355
|
-
}, null, 42,
|
|
356
|
-
[
|
|
355
|
+
}, null, 42, Qe), [
|
|
356
|
+
[ke, u(l)().text]
|
|
357
357
|
])
|
|
358
358
|
])),
|
|
359
359
|
O(Ke, {
|
|
360
360
|
textarea: n.value,
|
|
361
|
-
onFormatApplied:
|
|
361
|
+
onFormatApplied: me
|
|
362
362
|
}, null, 8, ["textarea"]),
|
|
363
363
|
h("button", {
|
|
364
|
-
class:
|
|
364
|
+
class: j(["chat-input__button", { "chat-input__button-disabled": ue.value }]),
|
|
365
365
|
disabled: u(l)().isRecording,
|
|
366
366
|
onClick: q
|
|
367
367
|
}, [
|
|
368
|
-
h("span",
|
|
369
|
-
O(u(ze), { color:
|
|
368
|
+
h("span", Ze, [
|
|
369
|
+
O(u(ze), { color: ce.value }, null, 8, ["color"])
|
|
370
370
|
])
|
|
371
|
-
], 10,
|
|
372
|
-
h("div",
|
|
371
|
+
], 10, Xe),
|
|
372
|
+
h("div", et, [
|
|
373
373
|
Y(e.$slots, "buttons", {}, void 0, !0)
|
|
374
374
|
])
|
|
375
375
|
]));
|
|
376
376
|
}
|
|
377
377
|
});
|
|
378
378
|
export {
|
|
379
|
-
|
|
379
|
+
_t as default
|
|
380
380
|
};
|
|
@@ -1,36 +1,50 @@
|
|
|
1
|
-
const
|
|
2
|
-
function
|
|
1
|
+
const i = "https://cdn.jsdelivr.net/npm/emoji-datasource-apple@6.0.1/img/apple/64";
|
|
2
|
+
function f(t) {
|
|
3
|
+
return (t || i).trim().replace(/\/+$/, "") || i;
|
|
4
|
+
}
|
|
5
|
+
function b(t) {
|
|
6
|
+
return /emoji-datasource-apple/i.test(t);
|
|
7
|
+
}
|
|
8
|
+
const I = /* @__PURE__ */ new Set([
|
|
9
|
+
"2640",
|
|
10
|
+
"2640-fe0f",
|
|
11
|
+
"2642",
|
|
12
|
+
"2642-fe0f",
|
|
13
|
+
"2695",
|
|
14
|
+
"2695-fe0f"
|
|
15
|
+
]), u = new RegExp("(?:\\p{Regional_Indicator}{2})|(?:[#*0-9]\\uFE0F?\\u20E3)|(?:\\p{Extended_Pictographic}(?:\\uFE0F|\\uFE0E)?(?:\\p{Emoji_Modifier})?(?:\\u200D(?:\\p{Extended_Pictographic}|\\p{Emoji_Modifier_Base})(?:\\uFE0F|\\uFE0E)?(?:\\p{Emoji_Modifier})?)*)", "gu"), v = "position:relative;display:inline-block;vertical-align:baseline;", M = "visibility:hidden;", $ = "position:absolute;left:0;top:0;width:100%;height:100%;object-fit:contain;pointer-events:none;display:block;margin:0;", C = Intl.Segmenter, m = typeof Intl < "u" && C ? new C(void 0, { granularity: "grapheme" }) : null;
|
|
16
|
+
function O(t, e, r = "nearest") {
|
|
3
17
|
const n = t.length;
|
|
4
18
|
if (e <= 0) return 0;
|
|
5
19
|
if (e >= n) return n;
|
|
6
|
-
if (
|
|
7
|
-
let
|
|
8
|
-
for (const { index:
|
|
9
|
-
if (
|
|
10
|
-
if (
|
|
11
|
-
return r === "before" ?
|
|
12
|
-
|
|
20
|
+
if (m) {
|
|
21
|
+
let a = 0;
|
|
22
|
+
for (const { index: c } of m.segment(t)) {
|
|
23
|
+
if (c === e) return e;
|
|
24
|
+
if (c > e)
|
|
25
|
+
return r === "before" ? a : r === "after" ? c : e - a <= c - e ? a : c;
|
|
26
|
+
a = c;
|
|
13
27
|
}
|
|
14
28
|
return n;
|
|
15
29
|
}
|
|
16
30
|
const o = t.charCodeAt(e);
|
|
17
31
|
return o >= 56320 && o <= 57343 ? r === "after" ? Math.min(n, e + 1) : e - 1 : e;
|
|
18
32
|
}
|
|
19
|
-
function
|
|
33
|
+
function w(t, e) {
|
|
20
34
|
if (e >= t.length) return t.length;
|
|
21
|
-
if (
|
|
22
|
-
for (const { index: n } of
|
|
35
|
+
if (m) {
|
|
36
|
+
for (const { index: n } of m.segment(t))
|
|
23
37
|
if (n > e) return n;
|
|
24
38
|
return t.length;
|
|
25
39
|
}
|
|
26
40
|
const r = t.codePointAt(e);
|
|
27
41
|
return e + (r !== void 0 && r > 65535 ? 2 : 1);
|
|
28
42
|
}
|
|
29
|
-
function
|
|
43
|
+
function P(t, e) {
|
|
30
44
|
if (e <= 0) return 0;
|
|
31
|
-
if (
|
|
45
|
+
if (m) {
|
|
32
46
|
let n = 0;
|
|
33
|
-
for (const { index: o } of
|
|
47
|
+
for (const { index: o } of m.segment(t)) {
|
|
34
48
|
if (o >= e) return n;
|
|
35
49
|
n = o;
|
|
36
50
|
}
|
|
@@ -39,7 +53,7 @@ function j(t, e) {
|
|
|
39
53
|
const r = t.charCodeAt(e - 1);
|
|
40
54
|
return r >= 56320 && r <= 57343 ? e - 2 : e - 1;
|
|
41
55
|
}
|
|
42
|
-
function
|
|
56
|
+
function p(t, e) {
|
|
43
57
|
const r = [];
|
|
44
58
|
for (const n of t) {
|
|
45
59
|
const o = n.codePointAt(0);
|
|
@@ -47,107 +61,122 @@ function d(t, e) {
|
|
|
47
61
|
}
|
|
48
62
|
return r.join("-");
|
|
49
63
|
}
|
|
50
|
-
function
|
|
51
|
-
|
|
64
|
+
function A(t, e = i) {
|
|
65
|
+
const r = f(e), n = p(t);
|
|
66
|
+
if (!n || b(r) && I.has(n)) return !1;
|
|
67
|
+
const o = p(t, { stripVariationSelectors: !0 });
|
|
68
|
+
return !(b(r) && I.has(o));
|
|
69
|
+
}
|
|
70
|
+
function S(t, e = i) {
|
|
71
|
+
return `${f(e)}/${p(t)}.png`;
|
|
52
72
|
}
|
|
53
|
-
function
|
|
54
|
-
const
|
|
55
|
-
if (
|
|
56
|
-
|
|
73
|
+
function k(t, e = i) {
|
|
74
|
+
const r = f(e);
|
|
75
|
+
if (!A(t, r)) return null;
|
|
76
|
+
const n = p(t), o = p(t, { stripVariationSelectors: !0 });
|
|
77
|
+
if (n !== o)
|
|
78
|
+
return b(r) && I.has(o) ? null : `${r}/${o}.png`;
|
|
57
79
|
if (!/[\uFE0E\uFE0F]/.test(t)) {
|
|
58
|
-
const
|
|
59
|
-
if (
|
|
60
|
-
return `${
|
|
80
|
+
const a = p(`${t}️`);
|
|
81
|
+
if (a !== n)
|
|
82
|
+
return b(r) && I.has(a) ? null : `${r}/${a}.png`;
|
|
61
83
|
}
|
|
62
84
|
return null;
|
|
63
85
|
}
|
|
64
|
-
function
|
|
65
|
-
const
|
|
66
|
-
|
|
86
|
+
function y(t, e, r) {
|
|
87
|
+
const n = k(e, r);
|
|
88
|
+
n && t.addEventListener(
|
|
67
89
|
"error",
|
|
68
90
|
() => {
|
|
69
|
-
t.src !==
|
|
91
|
+
t.src !== n && (t.src = n);
|
|
70
92
|
},
|
|
71
93
|
{ once: !0 }
|
|
72
94
|
);
|
|
73
95
|
}
|
|
74
|
-
function
|
|
75
|
-
const e =
|
|
76
|
-
if (!
|
|
77
|
-
const
|
|
78
|
-
return `<span class="chotto-emoji-slot" style="${
|
|
79
|
-
}
|
|
80
|
-
function
|
|
81
|
-
const
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
96
|
+
function j(t, e = i) {
|
|
97
|
+
const r = f(e), n = p(t);
|
|
98
|
+
if (!n || !A(t, r)) return _(t);
|
|
99
|
+
const o = `${r}/${n}.png`, a = k(t, r), c = a ? ` data-fallback="${T(a)}" onerror="if(this.dataset.fallback&&this.src!==this.dataset.fallback){this.onerror=null;this.src=this.dataset.fallback}"` : "";
|
|
100
|
+
return `<span class="chotto-emoji-slot" style="${v}"><span class="chotto-emoji-metric" style="${M}">${_(t)}</span><img class="chotto-emoji" src="${T(o)}" alt="${T(t)}" draggable="false" style="${$}"${c} /></span>`;
|
|
101
|
+
}
|
|
102
|
+
function L(t, e = i) {
|
|
103
|
+
const r = f(e);
|
|
104
|
+
if (!A(t, r)) {
|
|
105
|
+
const c = document.createElement("span");
|
|
106
|
+
return c.textContent = t, c;
|
|
107
|
+
}
|
|
108
|
+
const n = document.createElement("span");
|
|
109
|
+
n.className = "chotto-emoji-slot", n.setAttribute("style", v);
|
|
110
|
+
const o = document.createElement("span");
|
|
111
|
+
o.className = "chotto-emoji-metric", o.setAttribute("style", M), o.textContent = t;
|
|
112
|
+
const a = document.createElement("img");
|
|
113
|
+
return a.className = "chotto-emoji", a.src = S(t, r), a.alt = t, a.draggable = !1, a.setAttribute("style", $), y(a, t, r), n.append(o, a), n;
|
|
114
|
+
}
|
|
115
|
+
function T(t) {
|
|
89
116
|
return t.replace(/&/g, "&").replace(/"/g, """).replace(/</g, "<").replace(/>/g, ">");
|
|
90
117
|
}
|
|
91
|
-
function
|
|
118
|
+
function _(t) {
|
|
92
119
|
return t.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");
|
|
93
120
|
}
|
|
94
|
-
function
|
|
95
|
-
return t ?
|
|
121
|
+
function g(t, e) {
|
|
122
|
+
return t ? _(t).replace(u, (r) => j(r, e)) : "";
|
|
96
123
|
}
|
|
97
|
-
function
|
|
124
|
+
function H(t, e, r = i) {
|
|
98
125
|
if (!t) return "";
|
|
99
|
-
const r = e ? Math.max(0, Math.min(e.start, e.end)) : -1,
|
|
100
|
-
return
|
|
126
|
+
const n = f(r), o = e ? Math.max(0, Math.min(e.start, e.end)) : -1, a = e ? Math.min(t.length, Math.max(e.start, e.end)) : -1;
|
|
127
|
+
return o < 0 || o === a ? g(t, n) : g(t.slice(0, o), n) + `<span class="chat-input__emoji-selection" style="background-color: var(--chotto-chatinput-selection-bg, rgba(51, 133, 255, 0.35)); border-radius: 2px; box-decoration-break: clone; -webkit-box-decoration-break: clone;">${g(t.slice(o, a), n)}</span>` + g(t.slice(a), n);
|
|
101
128
|
}
|
|
102
|
-
function
|
|
103
|
-
return t ? (
|
|
129
|
+
function R(t) {
|
|
130
|
+
return t ? (u.lastIndex = 0, u.test(t)) : !1;
|
|
104
131
|
}
|
|
105
|
-
function
|
|
106
|
-
var
|
|
132
|
+
function J(t, e = i) {
|
|
133
|
+
var F;
|
|
107
134
|
if (!t || typeof document > "u") return t;
|
|
108
|
-
const e = document.createElement("div");
|
|
109
|
-
|
|
110
|
-
const
|
|
111
|
-
acceptNode: (
|
|
112
|
-
let
|
|
113
|
-
for (;
|
|
114
|
-
const
|
|
115
|
-
if (
|
|
135
|
+
const r = f(e), n = document.createElement("div");
|
|
136
|
+
n.innerHTML = t;
|
|
137
|
+
const o = document.createTreeWalker(n, NodeFilter.SHOW_TEXT, {
|
|
138
|
+
acceptNode: (E) => {
|
|
139
|
+
let s = E.parentNode;
|
|
140
|
+
for (; s && s !== n; ) {
|
|
141
|
+
const l = s.nodeName;
|
|
142
|
+
if (l === "SCRIPT" || l === "STYLE" || l === "TEXTAREA")
|
|
116
143
|
return NodeFilter.FILTER_REJECT;
|
|
117
|
-
|
|
144
|
+
s = s.parentNode;
|
|
118
145
|
}
|
|
119
146
|
return NodeFilter.FILTER_ACCEPT;
|
|
120
147
|
}
|
|
121
|
-
}),
|
|
122
|
-
let
|
|
123
|
-
for (;
|
|
124
|
-
|
|
125
|
-
for (const
|
|
126
|
-
const
|
|
127
|
-
if (
|
|
128
|
-
|
|
129
|
-
const
|
|
130
|
-
let
|
|
131
|
-
for (;
|
|
132
|
-
|
|
133
|
-
const
|
|
134
|
-
|
|
148
|
+
}), a = [];
|
|
149
|
+
let c;
|
|
150
|
+
for (; c = o.nextNode(); )
|
|
151
|
+
a.push(c);
|
|
152
|
+
for (const E of a.reverse()) {
|
|
153
|
+
const s = E.textContent || "";
|
|
154
|
+
if (u.lastIndex = 0, !u.test(s)) continue;
|
|
155
|
+
u.lastIndex = 0;
|
|
156
|
+
const l = document.createDocumentFragment();
|
|
157
|
+
let h = 0, d;
|
|
158
|
+
for (; d = u.exec(s); ) {
|
|
159
|
+
d.index > h && l.appendChild(document.createTextNode(s.slice(h, d.index)));
|
|
160
|
+
const N = L(d[0], r);
|
|
161
|
+
l.appendChild(N), h = d.index + d[0].length;
|
|
135
162
|
}
|
|
136
|
-
|
|
163
|
+
h < s.length && l.appendChild(document.createTextNode(s.slice(h))), (F = E.parentNode) == null || F.replaceChild(l, E);
|
|
137
164
|
}
|
|
138
|
-
return
|
|
165
|
+
return n.innerHTML;
|
|
139
166
|
}
|
|
140
167
|
export {
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
168
|
+
i as APPLE_EMOJI_CDN,
|
|
169
|
+
j as createAppleEmojiImgHtml,
|
|
170
|
+
L as createAppleEmojiSlotElement,
|
|
171
|
+
p as emojiToAppleCode,
|
|
172
|
+
k as getAppleEmojiFallbackUrl,
|
|
173
|
+
S as getAppleEmojiUrl,
|
|
174
|
+
A as hasAppleEmojiImage,
|
|
175
|
+
w as nextGraphemeIndex,
|
|
176
|
+
f as normalizeEmojiCdn,
|
|
177
|
+
P as previousGraphemeIndex,
|
|
178
|
+
J as replaceEmojisInHtml,
|
|
179
|
+
O as snapIndexToGrapheme,
|
|
180
|
+
R as textContainsEmoji,
|
|
181
|
+
H as textToAppleEmojiHtml
|
|
153
182
|
};
|