@mobilon-dev/chotto 0.3.125 → 0.3.126
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/2_blocks/FeedFoundItem/FeedFoundItem.vue.js +2 -2
- package/dist/components/2_blocks/FeedFoundItem/FeedFoundItem.vue2.js +41 -31
- package/dist/components/2_feed_elements/FeedReplyQuote/FeedReplyQuote.vue.js +2 -2
- package/dist/components/2_feed_elements/FeedReplyQuote/FeedReplyQuote.vue2.js +51 -30
- package/dist/components/2_feed_elements/ImageMessage/ImageMessage.vue.js +2 -2
- package/dist/components/2_feed_elements/ImageMessage/ImageMessage.vue2.js +286 -270
- package/dist/components/2_feed_elements/ReplyImageMessage/ReplyImageMessage.vue.js +3 -3
- package/dist/components/2_feed_elements/ReplyImageMessage/ReplyImageMessage.vue2.js +40 -34
- package/dist/components/3_compounds/ChatInput/ChatInput.vue.js +1 -1
- package/dist/components/3_compounds/ChatInput/ChatInput.vue2.js +282 -259
- package/dist/components/3_compounds/Feed/composables/useFeedScroll.js +79 -59
- package/dist/functions/parseMarkdown.js +7 -6
- package/dist/hooks/messages/useImageFeedSrc.js +50 -0
- package/dist/index.js +118 -113
- 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/src/components/2_feed_elements/ImageMessage/stories/ImageMessage.stories.d.ts +2 -0
- package/dist/types/src/components/3_compounds/Feed/composables/useFeedScroll.d.ts +3 -0
- package/dist/types/src/components/4_layouts/ChatWrapper/styles/types.d.ts +4 -0
- package/dist/types/src/hooks/messages/index.d.ts +1 -0
- package/dist/types/src/hooks/messages/useImageFeedSrc.d.ts +29 -0
- package/package.json +1 -1
|
@@ -1,98 +1,118 @@
|
|
|
1
|
-
import { ref as
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import { ref as k, watch as p, nextTick as w, onUnmounted as D } from "vue";
|
|
2
|
+
const N = 100;
|
|
3
|
+
function X({ feedRef: i, objectsRef: c, scrollToBottomRef: x }) {
|
|
4
|
+
const u = k(!1), o = k(!1);
|
|
5
|
+
let l = !1, v = !1, h = null, n = null, f = 0, d = 0;
|
|
6
|
+
function r() {
|
|
7
|
+
if (!o.value) return;
|
|
7
8
|
const t = i.value;
|
|
8
|
-
|
|
9
|
-
|
|
9
|
+
if (!t) return;
|
|
10
|
+
const e = t.scrollTop, T = Math.max(0, t.scrollHeight - t.clientHeight);
|
|
11
|
+
f = t.scrollHeight, d = t.clientHeight, !(Math.abs(e - T) < 1) && (l = !0, t.style.scrollBehavior = "auto", t.scrollTop = t.scrollHeight, requestAnimationFrame(() => {
|
|
12
|
+
l = !1;
|
|
10
13
|
}));
|
|
11
14
|
}
|
|
12
|
-
function
|
|
15
|
+
function A() {
|
|
13
16
|
const t = i.value;
|
|
14
17
|
if (!t) return;
|
|
15
|
-
const
|
|
16
|
-
t.style.scrollBehavior = "auto", t.scrollTop =
|
|
18
|
+
const e = t.scrollTop;
|
|
19
|
+
t.style.scrollBehavior = "auto", t.scrollTop = e;
|
|
17
20
|
}
|
|
18
|
-
function
|
|
19
|
-
|
|
20
|
-
|
|
21
|
+
function g() {
|
|
22
|
+
o.value = !0, w(() => {
|
|
23
|
+
r(), requestAnimationFrame(() => r());
|
|
21
24
|
});
|
|
22
25
|
}
|
|
23
|
-
function
|
|
24
|
-
|
|
25
|
-
}
|
|
26
|
-
function p(t) {
|
|
27
|
-
e == null || e.disconnect(), e = new ResizeObserver(() => {
|
|
28
|
-
c();
|
|
29
|
-
}), e.observe(t);
|
|
30
|
-
for (const o of t.children)
|
|
31
|
-
o instanceof HTMLElement && e.observe(o);
|
|
26
|
+
function s() {
|
|
27
|
+
o.value && (o.value = !1, A());
|
|
32
28
|
}
|
|
33
|
-
function
|
|
34
|
-
|
|
29
|
+
function C() {
|
|
30
|
+
const t = i.value;
|
|
31
|
+
if (!t) return;
|
|
32
|
+
const { scrollHeight: e, clientHeight: T, scrollTop: F } = t, a = f, P = d;
|
|
33
|
+
if (f = e, d = T, !a && !P) {
|
|
34
|
+
o.value && r();
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
const y = a - F - P;
|
|
38
|
+
if (o.value || y < N) {
|
|
39
|
+
o.value = !0, r();
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
e !== a && e > a && (l = !0, t.style.scrollBehavior = "auto", t.scrollTop = F + (e - a), requestAnimationFrame(() => {
|
|
43
|
+
l = !1;
|
|
44
|
+
}));
|
|
35
45
|
}
|
|
36
|
-
function
|
|
37
|
-
|
|
46
|
+
function H(t) {
|
|
47
|
+
n == null || n.disconnect(), f = t.scrollHeight, d = t.clientHeight, n = new ResizeObserver(() => {
|
|
48
|
+
C();
|
|
49
|
+
}), n.observe(t);
|
|
50
|
+
for (const e of t.children)
|
|
51
|
+
e instanceof HTMLElement && n.observe(e);
|
|
38
52
|
}
|
|
39
53
|
function L() {
|
|
40
|
-
|
|
54
|
+
v = !0;
|
|
55
|
+
}
|
|
56
|
+
function m() {
|
|
57
|
+
v = !1;
|
|
58
|
+
}
|
|
59
|
+
function E() {
|
|
60
|
+
l || v && s();
|
|
41
61
|
}
|
|
42
|
-
function
|
|
43
|
-
t.addEventListener("wheel",
|
|
62
|
+
function M(t) {
|
|
63
|
+
t.addEventListener("wheel", s, { passive: !0 }), t.addEventListener("touchstart", s, { passive: !0 }), t.addEventListener("pointerdown", L), t.addEventListener("scroll", E, { passive: !0 }), window.addEventListener("pointerup", m), window.addEventListener("pointercancel", m);
|
|
44
64
|
}
|
|
45
|
-
function
|
|
46
|
-
t.removeEventListener("wheel",
|
|
65
|
+
function B(t) {
|
|
66
|
+
t.removeEventListener("wheel", s), t.removeEventListener("touchstart", s), t.removeEventListener("pointerdown", L), t.removeEventListener("scroll", E), window.removeEventListener("pointerup", m), window.removeEventListener("pointercancel", m), v = !1;
|
|
47
67
|
}
|
|
48
|
-
function
|
|
49
|
-
|
|
68
|
+
function U() {
|
|
69
|
+
g();
|
|
50
70
|
}
|
|
51
|
-
function
|
|
52
|
-
!
|
|
71
|
+
function S() {
|
|
72
|
+
!u.value && c.value.length > 0 && (g(), u.value = !0);
|
|
53
73
|
}
|
|
54
|
-
function
|
|
55
|
-
|
|
74
|
+
function q() {
|
|
75
|
+
o.value = !0, w(() => {
|
|
56
76
|
const t = i.value;
|
|
57
77
|
t && t.scrollTo({ top: t.scrollHeight, behavior: "smooth" });
|
|
58
78
|
});
|
|
59
79
|
}
|
|
60
|
-
return
|
|
80
|
+
return p(
|
|
61
81
|
i,
|
|
62
|
-
(t,
|
|
63
|
-
|
|
82
|
+
(t, e) => {
|
|
83
|
+
e && B(e), h = t ?? null, t && (M(t), H(t), o.value && r());
|
|
64
84
|
},
|
|
65
85
|
{ immediate: !0 }
|
|
66
|
-
),
|
|
67
|
-
|
|
86
|
+
), p(
|
|
87
|
+
c,
|
|
68
88
|
() => {
|
|
69
|
-
|
|
70
|
-
i.value &&
|
|
89
|
+
w(() => {
|
|
90
|
+
i.value && H(i.value);
|
|
71
91
|
});
|
|
72
92
|
}
|
|
73
|
-
),
|
|
74
|
-
() =>
|
|
93
|
+
), p(
|
|
94
|
+
() => x.value,
|
|
75
95
|
(t) => {
|
|
76
|
-
t &&
|
|
96
|
+
t && g();
|
|
77
97
|
},
|
|
78
98
|
{ immediate: !0 }
|
|
79
|
-
),
|
|
80
|
-
() =>
|
|
99
|
+
), p(
|
|
100
|
+
() => c.value.length,
|
|
81
101
|
() => {
|
|
82
|
-
!
|
|
102
|
+
!u.value && c.value.length > 0 && S();
|
|
83
103
|
},
|
|
84
104
|
{ immediate: !0 }
|
|
85
|
-
),
|
|
86
|
-
|
|
105
|
+
), D(() => {
|
|
106
|
+
n == null || n.disconnect(), n = null, h && (B(h), h = null);
|
|
87
107
|
}), {
|
|
88
|
-
isInitialized:
|
|
108
|
+
isInitialized: u,
|
|
89
109
|
/** true, пока лента прижата вниз (автоскролл при новых сообщениях) */
|
|
90
|
-
stickToBottom:
|
|
91
|
-
performScrollToBottom:
|
|
92
|
-
initializeScroll:
|
|
93
|
-
smoothScrollToBottom:
|
|
110
|
+
stickToBottom: o,
|
|
111
|
+
performScrollToBottom: U,
|
|
112
|
+
initializeScroll: S,
|
|
113
|
+
smoothScrollToBottom: q
|
|
94
114
|
};
|
|
95
115
|
}
|
|
96
116
|
export {
|
|
97
|
-
|
|
117
|
+
X as useFeedScroll
|
|
98
118
|
};
|
|
@@ -1,18 +1,19 @@
|
|
|
1
|
-
import
|
|
2
|
-
const e = new
|
|
1
|
+
import l from "../node_modules/markdown-it/lib/index.js";
|
|
2
|
+
const e = new l("default", {
|
|
3
3
|
html: !0,
|
|
4
4
|
// Разрешаем HTML-теги (для <u>)
|
|
5
|
-
breaks:
|
|
6
|
-
//
|
|
5
|
+
// breaks: false — иначе каждый \n → <br>, а в ленте ещё white-space: pre-wrap,
|
|
6
|
+
// и перенос удваивается (пустая строка между каждой строкой при наличии \n\n в тексте).
|
|
7
|
+
breaks: !1,
|
|
7
8
|
linkify: !1
|
|
8
9
|
// Отключаем авто-ссылки, так как их обрабатывает linkifyStr
|
|
9
10
|
});
|
|
10
|
-
function
|
|
11
|
+
function i(n) {
|
|
11
12
|
if (!n) return "";
|
|
12
13
|
const r = n.includes(`
|
|
13
14
|
`), s = n.includes("> ");
|
|
14
15
|
return r || s ? e.render(n) : e.renderInline(n);
|
|
15
16
|
}
|
|
16
17
|
export {
|
|
17
|
-
|
|
18
|
+
i as parseMarkdown
|
|
18
19
|
};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { ref as l, watch as f, computed as v } from "vue";
|
|
2
|
+
function i(a, e, n) {
|
|
3
|
+
return !!(e && n && e !== n && a === e);
|
|
4
|
+
}
|
|
5
|
+
function s(a, e, n = !1) {
|
|
6
|
+
return n ? e || a || "" : a || e || "";
|
|
7
|
+
}
|
|
8
|
+
function d(a, e) {
|
|
9
|
+
const n = l(!1);
|
|
10
|
+
f(
|
|
11
|
+
() => [a(), e()],
|
|
12
|
+
() => {
|
|
13
|
+
n.value = !1;
|
|
14
|
+
}
|
|
15
|
+
);
|
|
16
|
+
const u = v(
|
|
17
|
+
() => s(a(), e(), n.value)
|
|
18
|
+
);
|
|
19
|
+
function r() {
|
|
20
|
+
i(u.value, a(), e()) && (n.value = !0);
|
|
21
|
+
}
|
|
22
|
+
return { displaySrc: u, onImageError: r, preferOriginal: n };
|
|
23
|
+
}
|
|
24
|
+
function m(a) {
|
|
25
|
+
const e = l(/* @__PURE__ */ new Set());
|
|
26
|
+
f(
|
|
27
|
+
() => a().map((r) => `${r.imagePreviewUrl ?? ""}\0${r.url ?? ""}`).join(`
|
|
28
|
+
`),
|
|
29
|
+
() => {
|
|
30
|
+
e.value = /* @__PURE__ */ new Set();
|
|
31
|
+
}
|
|
32
|
+
);
|
|
33
|
+
function n(r) {
|
|
34
|
+
const o = r.imagePreviewUrl, t = !!(o && e.value.has(o));
|
|
35
|
+
return s(o, r.url, t);
|
|
36
|
+
}
|
|
37
|
+
function u(r) {
|
|
38
|
+
const o = r.imagePreviewUrl, t = r.url;
|
|
39
|
+
if (!i(n(r), o, t) || !o) return;
|
|
40
|
+
const c = new Set(e.value);
|
|
41
|
+
c.add(o), e.value = c;
|
|
42
|
+
}
|
|
43
|
+
return { getItemSrc: n, onItemError: u, failedPreviews: e };
|
|
44
|
+
}
|
|
45
|
+
export {
|
|
46
|
+
i as canFallbackImagePreviewToUrl,
|
|
47
|
+
s as getImageFeedSrc,
|
|
48
|
+
m as useAlbumImageFeedSrc,
|
|
49
|
+
d as useImageFeedSrc
|
|
50
|
+
};
|