@matechat/core 1.0.0 → 1.1.0-alpha.1
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/Bubble/index.css +1 -0
- package/Bubble/index.js +166 -0
- package/Header/index.css +1 -0
- package/Header/index.js +65 -0
- package/Input/index.css +1 -0
- package/Input/index.js +220 -0
- package/Introduction/index.css +1 -0
- package/Introduction/index.js +97 -0
- package/Layout/index.css +1 -0
- package/Layout/index.js +48 -0
- package/List/index.css +1 -0
- package/List/index.js +143 -0
- package/MarkdownCard/index.css +1 -0
- package/MarkdownCard/index.js +309 -0
- package/Mention/index.css +1 -0
- package/Mention/index.js +172 -0
- package/PopperTrigger/index.js +48 -0
- package/Prompt/index.css +1 -0
- package/Prompt/index.js +110 -0
- package/README.md +14 -11
- package/index.d.ts +0 -1
- package/mate-chat.js +40 -866
- package/package.json +7 -5
- package/mate-chat.css +0 -1
package/List/index.js
ADDED
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import "./index.css";
|
|
2
|
+
import { ref as E, onMounted as L, computed as p, defineComponent as w, openBlock as u, createElementBlock as f, normalizeClass as g, unref as c, Fragment as b, renderList as z, renderSlot as h, createTextVNode as C, toDisplayString as T } from "vue";
|
|
3
|
+
var v = /* @__PURE__ */ ((e) => (e.Horizontal = "horizontal", e.Vertical = "vertical", e))(v || {}), k = /* @__PURE__ */ ((e) => (e.Transparent = "transparent", e.Filled = "filled", e.Bordered = "bordered", e.None = "none", e))(k || {});
|
|
4
|
+
const A = {
|
|
5
|
+
direction: {
|
|
6
|
+
type: String,
|
|
7
|
+
default: "vertical"
|
|
8
|
+
/* Vertical */
|
|
9
|
+
},
|
|
10
|
+
autoWrap: {
|
|
11
|
+
type: Boolean,
|
|
12
|
+
default: !0
|
|
13
|
+
},
|
|
14
|
+
variant: {
|
|
15
|
+
type: String,
|
|
16
|
+
default: "transparent"
|
|
17
|
+
/* Transparent */
|
|
18
|
+
},
|
|
19
|
+
enableLazyLoad: {
|
|
20
|
+
type: Boolean,
|
|
21
|
+
default: !1
|
|
22
|
+
},
|
|
23
|
+
data: {
|
|
24
|
+
type: Array,
|
|
25
|
+
default: () => []
|
|
26
|
+
},
|
|
27
|
+
enableShortKey: {
|
|
28
|
+
type: Boolean,
|
|
29
|
+
default: !1
|
|
30
|
+
},
|
|
31
|
+
inputEl: {
|
|
32
|
+
type: Object
|
|
33
|
+
},
|
|
34
|
+
selectable: {
|
|
35
|
+
type: Boolean,
|
|
36
|
+
default: !0
|
|
37
|
+
}
|
|
38
|
+
}, B = 50, H = ["TEXTAREA", "INPUT"], I = "ArrowUp", _ = "ArrowDown", N = "Enter";
|
|
39
|
+
function M(e, o) {
|
|
40
|
+
const n = E(e.enableShortKey ? 0 : -1), i = (t) => {
|
|
41
|
+
if (!t.disabled) {
|
|
42
|
+
if (e.selectable)
|
|
43
|
+
for (let l = 0; l < e.data.length; l++)
|
|
44
|
+
e.data[l].active = e.data[l].value === t.value;
|
|
45
|
+
o("select", { ...t });
|
|
46
|
+
}
|
|
47
|
+
}, s = (t) => {
|
|
48
|
+
if (!e.enableLazyLoad || e.direction !== v.Vertical)
|
|
49
|
+
return;
|
|
50
|
+
const l = t.target, r = l.scrollHeight, d = l.clientHeight, a = l.scrollTop;
|
|
51
|
+
r - d - a < B && o("loadMore", t);
|
|
52
|
+
}, m = (t) => {
|
|
53
|
+
t.code === I && (n.value = n.value === 0 ? e.data.length - 1 : n.value - 1), t.code === _ && (n.value = n.value === e.data.length - 1 ? 0 : n.value + 1), t.code === N && (e.selectable && (e.data[n.value].active = !0), o("select", { ...e.data[n.value] }));
|
|
54
|
+
};
|
|
55
|
+
return L(() => {
|
|
56
|
+
let t;
|
|
57
|
+
if (e.inputEl) {
|
|
58
|
+
const l = e.inputEl.$el ?? e.inputEl;
|
|
59
|
+
H.includes(l.tagName) ? t = l : t = l.querySelector("textarea") || l.querySelector("input") || document;
|
|
60
|
+
} else
|
|
61
|
+
t = document;
|
|
62
|
+
e.enableShortKey && t.addEventListener("keydown", m);
|
|
63
|
+
}), { preSelectIndex: n, onItemClick: i, onListScroll: s };
|
|
64
|
+
}
|
|
65
|
+
function D(e) {
|
|
66
|
+
return { listClasses: p(() => ({
|
|
67
|
+
"mc-list": !0,
|
|
68
|
+
"mc-list-horizontal": e.direction === v.Horizontal,
|
|
69
|
+
"mc-list-nowrap": e.direction === v.Horizontal && !e.autoWrap
|
|
70
|
+
})) };
|
|
71
|
+
}
|
|
72
|
+
const K = ["onClick"], U = /* @__PURE__ */ w({
|
|
73
|
+
__name: "List",
|
|
74
|
+
props: A,
|
|
75
|
+
emits: ["select", "loadMore"],
|
|
76
|
+
setup(e, { emit: o }) {
|
|
77
|
+
const n = e, i = o, { listClasses: s } = D(n), { preSelectIndex: m, onItemClick: t, onListScroll: l } = M(n, i);
|
|
78
|
+
return (r, d) => (u(), f(
|
|
79
|
+
"div",
|
|
80
|
+
{
|
|
81
|
+
class: g(c(s)),
|
|
82
|
+
onScroll: d[0] || (d[0] = //@ts-ignore
|
|
83
|
+
(...a) => c(l) && c(l)(...a))
|
|
84
|
+
},
|
|
85
|
+
[
|
|
86
|
+
(u(!0), f(
|
|
87
|
+
b,
|
|
88
|
+
null,
|
|
89
|
+
z(r.data, (a, y) => (u(), f(
|
|
90
|
+
b,
|
|
91
|
+
{ key: y },
|
|
92
|
+
[
|
|
93
|
+
r.variant === c(k).None ? h(r.$slots, "item", {
|
|
94
|
+
key: 0,
|
|
95
|
+
item: a
|
|
96
|
+
}, void 0, !0) : (u(), f("div", {
|
|
97
|
+
key: 1,
|
|
98
|
+
class: g([
|
|
99
|
+
"mc-list-item",
|
|
100
|
+
{
|
|
101
|
+
"mc-list-item-disabled": a.disabled,
|
|
102
|
+
"mc-list-item-active": a.active,
|
|
103
|
+
"mc-list-item-pre-selection": y === c(m)
|
|
104
|
+
},
|
|
105
|
+
r.variant
|
|
106
|
+
]),
|
|
107
|
+
onClick: () => c(t)(a)
|
|
108
|
+
}, [
|
|
109
|
+
h(r.$slots, "item", { item: a }, () => [
|
|
110
|
+
C(
|
|
111
|
+
T(a.label),
|
|
112
|
+
1
|
|
113
|
+
/* TEXT */
|
|
114
|
+
)
|
|
115
|
+
], !0)
|
|
116
|
+
], 10, K))
|
|
117
|
+
],
|
|
118
|
+
64
|
|
119
|
+
/* STABLE_FRAGMENT */
|
|
120
|
+
))),
|
|
121
|
+
128
|
|
122
|
+
/* KEYED_FRAGMENT */
|
|
123
|
+
))
|
|
124
|
+
],
|
|
125
|
+
34
|
|
126
|
+
/* CLASS, NEED_HYDRATION */
|
|
127
|
+
));
|
|
128
|
+
}
|
|
129
|
+
}), $ = (e, o) => {
|
|
130
|
+
const n = e.__vccOpts || e;
|
|
131
|
+
for (const [i, s] of o)
|
|
132
|
+
n[i] = s;
|
|
133
|
+
return n;
|
|
134
|
+
}, S = /* @__PURE__ */ $(U, [["__scopeId", "data-v-adad50a4"]]);
|
|
135
|
+
S.install = (e) => {
|
|
136
|
+
e.component("McList", S);
|
|
137
|
+
};
|
|
138
|
+
export {
|
|
139
|
+
v as ListDirection,
|
|
140
|
+
k as ListVariant,
|
|
141
|
+
S as McList,
|
|
142
|
+
A as listProps
|
|
143
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.mc-code-block-light[data-v-83d11992] pre code.hljs{display:block;overflow-x:auto;padding:1em}.mc-code-block-light[data-v-83d11992] code.hljs{padding:3px 5px}.mc-code-block-light[data-v-83d11992] .hljs{background:#fefefe;color:#545454}.mc-code-block-light[data-v-83d11992] .hljs-comment,.mc-code-block-light[data-v-83d11992] .hljs-quote{color:#696969}.mc-code-block-light[data-v-83d11992] .hljs-variable,.mc-code-block-light[data-v-83d11992] .hljs-template-variable,.mc-code-block-light[data-v-83d11992] .hljs-tag,.mc-code-block-light[data-v-83d11992] .hljs-name,.mc-code-block-light[data-v-83d11992] .hljs-selector-id,.mc-code-block-light[data-v-83d11992] .hljs-selector-class,.mc-code-block-light[data-v-83d11992] .hljs-regexp,.mc-code-block-light[data-v-83d11992] .hljs-deletion{color:#d91e18}.mc-code-block-light[data-v-83d11992] .hljs-number,.mc-code-block-light[data-v-83d11992] .hljs-built_in,.mc-code-block-light[data-v-83d11992] .hljs-literal,.mc-code-block-light[data-v-83d11992] .hljs-type,.mc-code-block-light[data-v-83d11992] .hljs-params,.mc-code-block-light[data-v-83d11992] .hljs-meta,.mc-code-block-light[data-v-83d11992] .hljs-link,.mc-code-block-light[data-v-83d11992] .hljs-attribute{color:#aa5d00}.mc-code-block-light[data-v-83d11992] .hljs-string,.mc-code-block-light[data-v-83d11992] .hljs-symbol,.mc-code-block-light[data-v-83d11992] .hljs-bullet,.mc-code-block-light[data-v-83d11992] .hljs-addition{color:green}.mc-code-block-light[data-v-83d11992] .hljs-title,.mc-code-block-light[data-v-83d11992] .hljs-section{color:#007faa}.mc-code-block-light[data-v-83d11992] .hljs-keyword,.mc-code-block-light[data-v-83d11992] .hljs-selector-tag{color:#7928a1}.mc-code-block-light[data-v-83d11992] .hljs-emphasis{font-style:italic}.mc-code-block-light[data-v-83d11992] .hljs-strong{font-weight:700}@media screen and (-ms-high-contrast: active){.mc-code-block-light[data-v-83d11992] .hljs-addition,.mc-code-block-light[data-v-83d11992] .hljs-attribute,.mc-code-block-light[data-v-83d11992] .hljs-built_in,.mc-code-block-light[data-v-83d11992] .hljs-bullet,.mc-code-block-light[data-v-83d11992] .hljs-comment,.mc-code-block-light[data-v-83d11992] .hljs-link,.mc-code-block-light[data-v-83d11992] .hljs-literal,.mc-code-block-light[data-v-83d11992] .hljs-meta,.mc-code-block-light[data-v-83d11992] .hljs-number,.mc-code-block-light[data-v-83d11992] .hljs-params,.mc-code-block-light[data-v-83d11992] .hljs-string,.mc-code-block-light[data-v-83d11992] .hljs-symbol,.mc-code-block-light[data-v-83d11992] .hljs-type,.mc-code-block-light[data-v-83d11992] .hljs-quote{color:highlight}.mc-code-block-light[data-v-83d11992] .hljs-keyword,.mc-code-block-light[data-v-83d11992] .hljs-selector-tag{font-weight:700}}.mc-code-block-dark[data-v-83d11992] pre code.hljs{display:block;overflow-x:auto;padding:1em}.mc-code-block-dark[data-v-83d11992] code.hljs{padding:3px 5px}.mc-code-block-dark[data-v-83d11992] .hljs{background:#2b2b2b;color:#f8f8f2}.mc-code-block-dark[data-v-83d11992] .hljs-comment,.mc-code-block-dark[data-v-83d11992] .hljs-quote{color:#d4d0ab}.mc-code-block-dark[data-v-83d11992] .hljs-variable,.mc-code-block-dark[data-v-83d11992] .hljs-template-variable,.mc-code-block-dark[data-v-83d11992] .hljs-tag,.mc-code-block-dark[data-v-83d11992] .hljs-name,.mc-code-block-dark[data-v-83d11992] .hljs-selector-id,.mc-code-block-dark[data-v-83d11992] .hljs-selector-class,.mc-code-block-dark[data-v-83d11992] .hljs-regexp,.mc-code-block-dark[data-v-83d11992] .hljs-deletion{color:#ffa07a}.mc-code-block-dark[data-v-83d11992] .hljs-number,.mc-code-block-dark[data-v-83d11992] .hljs-built_in,.mc-code-block-dark[data-v-83d11992] .hljs-literal,.mc-code-block-dark[data-v-83d11992] .hljs-type,.mc-code-block-dark[data-v-83d11992] .hljs-params,.mc-code-block-dark[data-v-83d11992] .hljs-meta,.mc-code-block-dark[data-v-83d11992] .hljs-link{color:#f5ab35}.mc-code-block-dark[data-v-83d11992] .hljs-attribute{color:gold}.mc-code-block-dark[data-v-83d11992] .hljs-string,.mc-code-block-dark[data-v-83d11992] .hljs-symbol,.mc-code-block-dark[data-v-83d11992] .hljs-bullet,.mc-code-block-dark[data-v-83d11992] .hljs-addition{color:#abe338}.mc-code-block-dark[data-v-83d11992] .hljs-title,.mc-code-block-dark[data-v-83d11992] .hljs-section{color:#00e0e0}.mc-code-block-dark[data-v-83d11992] .hljs-keyword,.mc-code-block-dark[data-v-83d11992] .hljs-selector-tag{color:#dcc6e0}.mc-code-block-dark[data-v-83d11992] .hljs-emphasis{font-style:italic}.mc-code-block-dark[data-v-83d11992] .hljs-strong{font-weight:700}@media screen and (-ms-high-contrast: active){.mc-code-block-dark[data-v-83d11992] .hljs-addition,.mc-code-block-dark[data-v-83d11992] .hljs-attribute,.mc-code-block-dark[data-v-83d11992] .hljs-built_in,.mc-code-block-dark[data-v-83d11992] .hljs-bullet,.mc-code-block-dark[data-v-83d11992] .hljs-comment,.mc-code-block-dark[data-v-83d11992] .hljs-link,.mc-code-block-dark[data-v-83d11992] .hljs-literal,.mc-code-block-dark[data-v-83d11992] .hljs-meta,.mc-code-block-dark[data-v-83d11992] .hljs-number,.mc-code-block-dark[data-v-83d11992] .hljs-params,.mc-code-block-dark[data-v-83d11992] .hljs-string,.mc-code-block-dark[data-v-83d11992] .hljs-symbol,.mc-code-block-dark[data-v-83d11992] .hljs-type,.mc-code-block-dark[data-v-83d11992] .hljs-quote{color:highlight}.mc-code-block-dark[data-v-83d11992] .hljs-keyword,.mc-code-block-dark[data-v-83d11992] .hljs-selector-tag{font-weight:700}}.v-enter-active[data-v-83d11992],.v-leave-active[data-v-83d11992]{transition:opacity .5s ease}.v-enter-from[data-v-83d11992],.v-leave-to[data-v-83d11992]{opacity:0}.mc-code-block[data-v-83d11992]{margin:1rem 0;overflow:hidden;border-radius:14px}.mc-code-block pre[data-v-83d11992]{margin:0}.mc-code-block .mc-action-btn[data-v-83d11992]{width:24px;height:24px}.mc-code-block .mc-code-block-header[data-v-83d11992]{display:flex;justify-content:space-between;align-items:center;padding:.5rem 1rem}.mc-code-block .mc-code-block-header .mc-code-lang[data-v-83d11992]{font-size:var(--devui-font-size, 12px)}.mc-code-block .mc-code-block-actions[data-v-83d11992]{display:flex;align-items:center}.mc-code-block .mc-code-block-actions .mc-copy-btn[data-v-83d11992],.mc-code-block .mc-code-block-actions .mc-toggle-btn[data-v-83d11992]{cursor:pointer;border-radius:4px;font-size:18px;padding:4px}.mc-code-block-light[data-v-83d11992]{border:1px solid #d7d8da;background-color:#f5f5f5}.mc-code-block-light code.hljs[data-v-83d11992]{padding:1em}.mc-code-block-light .mc-code-lang[data-v-83d11992],.mc-code-block-light .mc-code-block-actions .mc-copy-btn[data-v-83d11992],.mc-code-block-light .mc-code-block-actions .mc-toggle-btn[data-v-83d11992]{color:#252b3a}.mc-code-block-light .mc-code-block-actions .mc-copy-btn[data-v-83d11992]:hover,.mc-code-block-light .mc-code-block-actions .mc-toggle-btn[data-v-83d11992]:hover{background-color:#ebebeb}.mc-code-block-dark[data-v-83d11992]{border:1px solid #4e5057;background-color:#34363a}.mc-code-block-dark code.hljs[data-v-83d11992]{padding:1em}.mc-code-block-dark .mc-code-lang[data-v-83d11992],.mc-code-block-dark .mc-code-block-actions .mc-copy-btn[data-v-83d11992],.mc-code-block-dark .mc-code-block-actions .mc-toggle-btn[data-v-83d11992]{color:#ced1db}.mc-code-block-dark .mc-code-block-actions .mc-copy-btn[data-v-83d11992]:hover,.mc-code-block-dark .mc-code-block-actions .mc-toggle-btn[data-v-83d11992]:hover{background-color:#393a3e}.mc-code-block-dark .mc-code-block-actions .mc-copy-btn img[data-v-83d11992],.mc-code-block-dark .mc-code-block-actions .mc-toggle-btn img[data-v-83d11992]{filter:brightness(1.5)}.collapse-transition-enter-from[data-v-83d11992],.collapse-transition-leave-to[data-v-83d11992]{opacity:0}.collapse-transition-enter-to[data-v-83d11992],.collapse-transition-leave-from[data-v-83d11992]{opacity:1}.collapse-transition-enter-active[data-v-83d11992],.collapse-transition-leave-active[data-v-83d11992]{transition:max-height .3s cubic-bezier(.5,.05,.5,.95),opacity .3s cubic-bezier(.5,.05,.5,.95)}.mc-markdown-render[data-v-a398f75b]{overflow-x:auto}.mc-markdown-render.mc-markdown-render-dark[data-v-a398f75b]{color:#ced1db}.mc-markdown-render.mc-markdown-render-light[data-v-a398f75b]{color:#252b3a}
|
|
@@ -0,0 +1,309 @@
|
|
|
1
|
+
import "./index.css";
|
|
2
|
+
var E = Object.defineProperty;
|
|
3
|
+
var W = (n, t, s) => t in n ? E(n, t, { enumerable: !0, configurable: !0, writable: !0, value: s }) : n[t] = s;
|
|
4
|
+
var T = (n, t, s) => W(n, typeof t != "symbol" ? t + "" : t, s);
|
|
5
|
+
import { defineComponent as v, ref as x, computed as m, openBlock as d, createElementBlock as M, normalizeClass as k, createElementVNode as I, toDisplayString as _, renderSlot as j, unref as p, createVNode as z, Transition as Y, withCtx as Q, createCommentVNode as O, useSlots as G, h as w, watch as H, Fragment as Z, createBlock as P, resolveDynamicComponent as X } from "vue";
|
|
6
|
+
import R from "markdown-it";
|
|
7
|
+
import y from "highlight.js";
|
|
8
|
+
import { debounce as F } from "lodash-es";
|
|
9
|
+
import { getDefaultWhiteList as V, getDefaultCSSWhiteList as K, filterXSS as J } from "xss";
|
|
10
|
+
const $ = "data:image/svg+xml,%3c?xml%20version='1.0'%20encoding='UTF-8'?%3e%3csvg%20width='16px'%20height='16px'%20viewBox='0%200%2016%2016'%20version='1.1'%20xmlns='http://www.w3.org/2000/svg'%20xmlns:xlink='http://www.w3.org/1999/xlink'%3e%3ctitle%3e全部收起%3c/title%3e%3cg%20id='全部收起'%20stroke='none'%20stroke-width='1'%20fill='none'%20fill-rule='evenodd'%3e%3cpath%20d='M4.715694,14.4114091%20C4.910563,14.5464051%205.179987,14.5271201%205.353553,14.3535531%20L5.353553,14.3535531%20L7.99999988,11.7070001%20L10.646447,14.3535531%20L10.715694,14.4114091%20C10.910563,14.5464051%2011.179987,14.5271201%2011.353553,14.3535531%20C11.548816,14.1582911%2011.548816,13.8417091%2011.353553,13.6464471%20L11.353553,13.6464471%20L8.353553,10.6464471%20L8.284306,10.5885911%20C8.089437,10.4535951%207.820013,10.4728801%207.646447,10.6464471%20L7.646447,10.6464471%20L4.646447,13.6464471%20L4.588591,13.7156941%20C4.453595,13.9105631%204.47288,14.1799871%204.646447,14.3535531%20L4.646447,14.3535531%20L4.715694,14.4114091%20Z%20M14.5,7.50000012%20C14.776142,7.50000012%2015,7.72385812%2015,8.00000012%20C15,8.27614212%2014.776142,8.50000012%2014.5,8.50000012%20L1.5,8.50000012%20C1.223858,8.50000012%201,8.27614212%201,8.00000012%20C1,7.72385812%201.223858,7.50000012%201.5,7.50000012%20L14.5,7.50000012%20Z%20M8.284306,5.41140912%20L8.353553,5.35355312%20L11.353553,2.35355312%20C11.548816,2.15829112%2011.548816,1.84170912%2011.353553,1.64644712%20C11.179987,1.47288012%2010.910563,1.45359512%2010.715694,1.58859112%20L10.646447,1.64644712%20L7.99999988,4.29300012%20L5.353553,1.64644712%20C5.179987,1.47288012%204.910563,1.45359512%204.715694,1.58859112%20L4.646447,1.64644712%20C4.47288,1.82001312%204.453595,2.08943712%204.588591,2.28430612%20L4.646447,2.35355312%20L7.646447,5.35355312%20C7.820013,5.52712012%208.089437,5.54640512%208.284306,5.41140912%20Z'%20id='形状结合'%20fill='%2371757F'%20fill-rule='nonzero'%3e%3c/path%3e%3c/g%3e%3c/svg%3e", q = "data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz4KPHN2ZyB3aWR0aD0iMTZweCIgaGVpZ2h0PSIxNnB4IiB2aWV3Qm94PSIwIDAgMTYgMTYiIHZlcnNpb249IjEuMSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB4bWxuczp4bGluaz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94bGluayI+CiAgICA8dGl0bGU+ZnVuY3Rpb24gaWNvbi9jb3B5PC90aXRsZT4KICAgIDxnIGlkPSLpobXpnaItMSIgc3Ryb2tlPSJub25lIiBzdHJva2Utd2lkdGg9IjEiIGZpbGw9Im5vbmUiIGZpbGwtcnVsZT0iZXZlbm9kZCI+CiAgICAgICAgPGcgaWQ9IkFQSS1zdGFydGVyLeWbvuagh+WFpeW6kyIgdHJhbnNmb3JtPSJ0cmFuc2xhdGUoLTU5Mi4wMDAwMDAsIC0yMDQuMDAwMDAwKSI+CiAgICAgICAgICAgIDxnIGlkPSLmlrnmoLzlpIfku70tMTYiIHRyYW5zZm9ybT0idHJhbnNsYXRlKDU2MC4wMDAwMDAsIDE4MC4wMDAwMDApIj4KICAgICAgICAgICAgICAgIDx0ZXh0IGlkPSLlm77moIciIGZvbnQtZmFtaWx5PSJQaW5nRmFuZ1NDLVJlZ3VsYXIsIFBpbmdGYW5nIFNDIiBmb250LXNpemU9IjEyIiBmb250LXdlaWdodD0ibm9ybWFsIiBsaW5lLXNwYWNpbmc9IjE2IiBmaWxsPSIjNzE3NTdGIj4KICAgICAgICAgICAgICAgICAgICA8dHNwYW4geD0iMjcuMTM2IiB5PSI2MSI+5aSN5Yi2PC90c3Bhbj4KICAgICAgICAgICAgICAgIDwvdGV4dD4KICAgICAgICAgICAgPC9nPgogICAgICAgICAgICA8cGF0aCBkPSJNNjA0LjUsMjA2IEM2MDUuMjc5Njk2LDIwNiA2MDUuOTIwNDQ5LDIwNi41OTQ4ODggNjA1Ljk5MzEzMywyMDcuMzU1NTQgTDYwNiwyMDcuNSBMNjA2LDIxNC41IEM2MDYsMjE1LjI3OTY5NiA2MDUuNDA1MTEyLDIxNS45MjA0NDkgNjA0LjY0NDQ2LDIxNS45OTMxMzMgTDYwNC41LDIxNiBMNjA0LDIxNiBMNjA0LDIxNi41IEM2MDQsMjE3LjI3OTY5NiA2MDMuNDA1MTEyLDIxNy45MjA0NDkgNjAyLjY0NDQ2LDIxNy45OTMxMzMgTDYwMi41LDIxOCBMNTk1LjUsMjE4IEM1OTQuNjcxNTczLDIxOCA1OTQsMjE3LjMyODQyNyA1OTQsMjE2LjUgTDU5NCwyMTYuNSBMNTk0LDIwOS41IEM1OTQsMjA4LjY3MTU3MyA1OTQuNjcxNTczLDIwOCA1OTUuNSwyMDggTDU5NS41LDIwOCBMNTk2LDIwOCBMNTk2LDIwNy41IEM1OTYsMjA2LjcyMDMwNCA1OTYuNTk0ODg4LDIwNi4wNzk1NTEgNTk3LjM1NTU0LDIwNi4wMDY4NjcgTDU5Ny41LDIwNiBMNjA0LjUsMjA2IFogTTYwMi41LDIwOSBMNTk1LjUsMjA5IEM1OTUuMjIzODU4LDIwOSA1OTUsMjA5LjIyMzg1OCA1OTUsMjA5LjUgTDU5NSwyMDkuNSBMNTk1LDIxNi41IEM1OTUsMjE2Ljc3NjE0MiA1OTUuMjIzODU4LDIxNyA1OTUuNSwyMTcgTDU5NS41LDIxNyBMNjAyLjUsMjE3IEM2MDIuNzc2MTQyLDIxNyA2MDMsMjE2Ljc3NjE0MiA2MDMsMjE2LjUgTDYwMywyMTYuNSBMNjAzLDIwOS41IEM2MDMsMjA5LjIyMzg1OCA2MDIuNzc2MTQyLDIwOSA2MDIuNSwyMDkgTDYwMi41LDIwOSBaIE02MDQuNSwyMDcgTDU5Ny41LDIwNyBDNTk3LjI1NDU0LDIwNyA1OTcuMDUwMzkyLDIwNy4xNzY4NzUgNTk3LjAwODA1NiwyMDcuNDEwMTI0IEw1OTcsMjA3LjUgTDU5NywyMDggTDYwMi41LDIwOCBDNjAzLjI3OTY5NiwyMDggNjAzLjkyMDQ0OSwyMDguNTk0ODg4IDYwMy45OTMxMzMsMjA5LjM1NTU0IEw2MDQsMjA5LjUgTDYwNCwyMTUgTDYwNC41LDIxNSBDNjA0Ljc0NTQ2LDIxNSA2MDQuOTQ5NjA4LDIxNC44MjMxMjUgNjA0Ljk5MTk0NCwyMTQuNTg5ODc2IEw2MDUsMjE0LjUgTDYwNSwyMDcuNSBDNjA1LDIwNy4yNTQ1NCA2MDQuODIzMTI1LDIwNy4wNTAzOTIgNjA0LjU4OTg3NiwyMDcuMDA4MDU2IEw2MDQuNSwyMDcgWiIgaWQ9IuW9oueKtue7k+WQiCIgZmlsbD0iIzcxNzU3RiIgZmlsbC1ydWxlPSJub256ZXJvIj48L3BhdGg+CiAgICAgICAgPC9nPgogICAgPC9nPgo8L3N2Zz4=", ee = "data:image/svg+xml,%3c?xml%20version='1.0'%20encoding='UTF-8'?%3e%3csvg%20width='16px'%20height='16px'%20viewBox='0%200%2016%2016'%20version='1.1'%20xmlns='http://www.w3.org/2000/svg'%20xmlns:xlink='http://www.w3.org/1999/xlink'%3e%3ctitle%3estatus/whiteBG/correct%3c/title%3e%3cdesc%3eCreated%20with%20Sketch.%3c/desc%3e%3cdefs%3e%3cpolygon%20id='path-1'%20points='6.53553391%209.77817459%2012.1923882%204.12132034%2013.6066017%205.53553391%206.53553391%2012.6066017%203%209.07106781%204.41421356%207.65685425%206.53553391%209.77817459'%3e%3c/polygon%3e%3c/defs%3e%3cg%20id='status/whiteBG/correct'%20stroke='none'%20stroke-width='1'%20fill='none'%20fill-rule='evenodd'%3e%3cmask%20id='mask-2'%20fill='white'%3e%3cuse%20xlink:href='%23path-1'%3e%3c/use%3e%3c/mask%3e%3cuse%20id='Mask'%20fill='%233DCCA6'%20xlink:href='%23path-1'%3e%3c/use%3e%3c/g%3e%3c/svg%3e";
|
|
11
|
+
class S {
|
|
12
|
+
constructor() {
|
|
13
|
+
T(this, "xssWhiteList", V());
|
|
14
|
+
T(this, "cssWhiteList", K());
|
|
15
|
+
this.setDefaultXss();
|
|
16
|
+
}
|
|
17
|
+
setDefaultXss() {
|
|
18
|
+
this.xssWhiteList.input = ["type", "checked", "disabled", "class"], this.xssWhiteList.label = ["for"], this.xssWhiteList.ul = ["class"], this.xssWhiteList.div = ["class"], this.xssWhiteList.a = ["href", "class", "target", "name"], this.xssWhiteList.ol = ["start"], this.xssWhiteList.p = ["class"], this.xssWhiteList.span = ["style", "class", "title", "id"], this.xssWhiteList.svg = ["style", "class", "width", "height", "viewbox", "preserveaspectratio", "id", "fill", "stroke"], this.xssWhiteList.path = ["style", "class", "d", "id", "fill", "stroke"], this.xssWhiteList.th = ["style"], this.xssWhiteList.td = ["style"];
|
|
19
|
+
}
|
|
20
|
+
onIgnoreTagAttr(t, s, a, i) {
|
|
21
|
+
if (!i && (s === "id" || t === "span" && s === "style"))
|
|
22
|
+
return s + "=" + a;
|
|
23
|
+
}
|
|
24
|
+
getXssWhiteList() {
|
|
25
|
+
return this.xssWhiteList;
|
|
26
|
+
}
|
|
27
|
+
setXssWhiteList(t) {
|
|
28
|
+
this.xssWhiteList = t;
|
|
29
|
+
}
|
|
30
|
+
setCustomXssRules(t) {
|
|
31
|
+
t && t.forEach((s) => {
|
|
32
|
+
s.value === null ? delete this.xssWhiteList[s.key] : this.xssWhiteList[s.key] = s.value;
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
filterHtml(t) {
|
|
36
|
+
return J(t, {
|
|
37
|
+
whiteList: this.xssWhiteList,
|
|
38
|
+
onIgnoreTagAttr: this.onIgnoreTagAttr,
|
|
39
|
+
css: {
|
|
40
|
+
whiteList: Object.assign({}, this.cssWhiteList, {
|
|
41
|
+
top: !0,
|
|
42
|
+
left: !0,
|
|
43
|
+
bottom: !0,
|
|
44
|
+
right: !0
|
|
45
|
+
})
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
const te = {
|
|
51
|
+
key: 0,
|
|
52
|
+
class: "mc-code-block-header"
|
|
53
|
+
}, se = { class: "mc-code-lang" }, ie = { class: "mc-code-block-actions" }, oe = {
|
|
54
|
+
key: 0,
|
|
55
|
+
src: q
|
|
56
|
+
}, ne = {
|
|
57
|
+
key: 1,
|
|
58
|
+
src: ee
|
|
59
|
+
}, ce = { key: 0 }, ae = { key: 0 }, re = ["innerHTML"], le = /* @__PURE__ */ v({
|
|
60
|
+
__name: "CodeBlock",
|
|
61
|
+
props: {
|
|
62
|
+
code: {
|
|
63
|
+
type: String,
|
|
64
|
+
required: !0
|
|
65
|
+
},
|
|
66
|
+
language: {
|
|
67
|
+
type: String,
|
|
68
|
+
default: ""
|
|
69
|
+
},
|
|
70
|
+
blockIndex: {
|
|
71
|
+
type: Number,
|
|
72
|
+
required: !0
|
|
73
|
+
},
|
|
74
|
+
theme: {
|
|
75
|
+
type: String,
|
|
76
|
+
default: "light"
|
|
77
|
+
}
|
|
78
|
+
},
|
|
79
|
+
setup(n) {
|
|
80
|
+
const t = n, s = new S(), a = x(!0), i = x(!1), h = m(() => {
|
|
81
|
+
if (t.language && y.getLanguage(t.language))
|
|
82
|
+
try {
|
|
83
|
+
return y.highlight(t.code, { language: t.language }).value;
|
|
84
|
+
} catch {
|
|
85
|
+
}
|
|
86
|
+
return s.filterHtml(t.code);
|
|
87
|
+
}), C = () => {
|
|
88
|
+
a.value = !a.value;
|
|
89
|
+
}, L = F((e) => {
|
|
90
|
+
const g = e.target;
|
|
91
|
+
navigator.clipboard.writeText(t.code), g.classList.remove("icon-copy-new"), i.value = !0, setTimeout(() => {
|
|
92
|
+
i.value = !1;
|
|
93
|
+
}, 1500);
|
|
94
|
+
}, 300), A = (e) => {
|
|
95
|
+
e.dataset || (e.dataset = {}), e.style.height && (e.dataset.height = e.style.height), e.style.maxHeight = 0;
|
|
96
|
+
}, r = (e) => {
|
|
97
|
+
requestAnimationFrame(() => {
|
|
98
|
+
e.dataset.oldOverflow = e.style.overflow, e.dataset.height ? e.style.maxHeight = e.dataset.height : e.scrollHeight !== 0 ? e.style.maxHeight = `${e.scrollHeight}px` : e.style.maxHeight = 0, e.style.overflow = "hidden";
|
|
99
|
+
});
|
|
100
|
+
}, o = (e) => {
|
|
101
|
+
e.style.maxHeight = "", e.style.overflow = e.dataset.oldOverflow;
|
|
102
|
+
}, D = (e) => {
|
|
103
|
+
e.dataset || (e.dataset = {}), e.dataset.oldOverflow = e.style.overflow, e.style.maxHeight = `${e.scrollHeight}px`, e.style.overflow = "hidden";
|
|
104
|
+
}, l = (e) => {
|
|
105
|
+
e.scrollHeight !== 0 && (e.style.maxHeight = 0);
|
|
106
|
+
}, c = (e) => {
|
|
107
|
+
e.style.maxHeight = "", e.style.overflow = e.dataset.oldOverflow;
|
|
108
|
+
}, u = m(() => t.theme === "dark" ? "mc-code-block-dark" : "mc-code-block-light");
|
|
109
|
+
return (e, g) => (d(), M(
|
|
110
|
+
"div",
|
|
111
|
+
{
|
|
112
|
+
class: k(["mc-code-block", u.value])
|
|
113
|
+
},
|
|
114
|
+
[
|
|
115
|
+
e.$slots.header ? j(e.$slots, "header", { key: 1 }, void 0, !0) : (d(), M("div", te, [
|
|
116
|
+
I(
|
|
117
|
+
"span",
|
|
118
|
+
se,
|
|
119
|
+
_(n.language),
|
|
120
|
+
1
|
|
121
|
+
/* TEXT */
|
|
122
|
+
),
|
|
123
|
+
j(e.$slots, "actions", {}, () => [
|
|
124
|
+
I("div", ie, [
|
|
125
|
+
I("div", {
|
|
126
|
+
class: "mc-action-btn mc-toggle-btn",
|
|
127
|
+
onClick: C
|
|
128
|
+
}, g[1] || (g[1] = [
|
|
129
|
+
I(
|
|
130
|
+
"img",
|
|
131
|
+
{ src: $ },
|
|
132
|
+
null,
|
|
133
|
+
-1
|
|
134
|
+
/* HOISTED */
|
|
135
|
+
)
|
|
136
|
+
])),
|
|
137
|
+
I("div", {
|
|
138
|
+
class: "mc-action-btn mc-copy-btn",
|
|
139
|
+
onClick: g[0] || (g[0] = //@ts-ignore
|
|
140
|
+
(...N) => p(L) && p(L)(...N))
|
|
141
|
+
}, [
|
|
142
|
+
i.value ? (d(), M("img", ne)) : (d(), M("img", oe))
|
|
143
|
+
])
|
|
144
|
+
])
|
|
145
|
+
], !0)
|
|
146
|
+
])),
|
|
147
|
+
z(Y, {
|
|
148
|
+
name: "collapse-transition",
|
|
149
|
+
onBeforeEnter: A,
|
|
150
|
+
onEnter: r,
|
|
151
|
+
onAfterEnter: o,
|
|
152
|
+
onBeforeLeave: D,
|
|
153
|
+
onLeave: l,
|
|
154
|
+
onAfterLeave: c
|
|
155
|
+
}, {
|
|
156
|
+
default: Q(() => [
|
|
157
|
+
a.value ? (d(), M("div", ce, [
|
|
158
|
+
e.$slots.content ? j(e.$slots, "content", { key: 1 }, void 0, !0) : (d(), M("pre", ae, [
|
|
159
|
+
I("code", {
|
|
160
|
+
class: k(`hljs language-${n.language}`),
|
|
161
|
+
innerHTML: h.value
|
|
162
|
+
}, null, 10, re)
|
|
163
|
+
]))
|
|
164
|
+
])) : O("v-if", !0)
|
|
165
|
+
]),
|
|
166
|
+
_: 3
|
|
167
|
+
/* FORWARDED */
|
|
168
|
+
})
|
|
169
|
+
],
|
|
170
|
+
2
|
|
171
|
+
/* CLASS */
|
|
172
|
+
));
|
|
173
|
+
}
|
|
174
|
+
}), b = (n, t) => {
|
|
175
|
+
const s = n.__vccOpts || n;
|
|
176
|
+
for (const [a, i] of t)
|
|
177
|
+
s[a] = i;
|
|
178
|
+
return s;
|
|
179
|
+
}, ge = /* @__PURE__ */ b(le, [["__scopeId", "data-v-83d11992"]]), de = {
|
|
180
|
+
content: {
|
|
181
|
+
type: String,
|
|
182
|
+
default: ""
|
|
183
|
+
},
|
|
184
|
+
mdOptions: {
|
|
185
|
+
type: Object,
|
|
186
|
+
default: () => ({})
|
|
187
|
+
},
|
|
188
|
+
customXssRules: {
|
|
189
|
+
type: Array,
|
|
190
|
+
default: () => []
|
|
191
|
+
},
|
|
192
|
+
theme: {
|
|
193
|
+
type: String,
|
|
194
|
+
default: "light"
|
|
195
|
+
}
|
|
196
|
+
}, Me = /* @__PURE__ */ v({
|
|
197
|
+
__name: "mdCard",
|
|
198
|
+
props: de,
|
|
199
|
+
setup(n, { expose: t }) {
|
|
200
|
+
const s = new S(), a = n, i = G(), h = R({
|
|
201
|
+
breaks: !0,
|
|
202
|
+
linkify: !0,
|
|
203
|
+
html: !0,
|
|
204
|
+
highlight: (r, o) => {
|
|
205
|
+
if (o && y.getLanguage(o))
|
|
206
|
+
try {
|
|
207
|
+
return y.highlight(r, { language: o }).value;
|
|
208
|
+
} catch {
|
|
209
|
+
}
|
|
210
|
+
return "";
|
|
211
|
+
},
|
|
212
|
+
...a.mdOptions
|
|
213
|
+
});
|
|
214
|
+
h.renderer.rules.fence = (r, o) => `<!----MC_MARKDOWN_CODE_BLOCK_${o}---->`;
|
|
215
|
+
const C = (r, o, D) => {
|
|
216
|
+
const l = {
|
|
217
|
+
actions: () => {
|
|
218
|
+
var c;
|
|
219
|
+
return (c = i.actions) == null ? void 0 : c.call(i, {
|
|
220
|
+
codeBlockData: {
|
|
221
|
+
code: o,
|
|
222
|
+
language: r
|
|
223
|
+
}
|
|
224
|
+
});
|
|
225
|
+
}
|
|
226
|
+
};
|
|
227
|
+
return i.header && (l.header = () => {
|
|
228
|
+
var c;
|
|
229
|
+
return (c = i.header) == null ? void 0 : c.call(i, {
|
|
230
|
+
codeBlockData: {
|
|
231
|
+
code: o,
|
|
232
|
+
language: r
|
|
233
|
+
}
|
|
234
|
+
});
|
|
235
|
+
}), i.content && (l.content = () => {
|
|
236
|
+
var c;
|
|
237
|
+
return (c = i.content) == null ? void 0 : c.call(i, {
|
|
238
|
+
codeBlockData: {
|
|
239
|
+
code: o,
|
|
240
|
+
language: r
|
|
241
|
+
}
|
|
242
|
+
});
|
|
243
|
+
}), w(ge, {
|
|
244
|
+
language: r,
|
|
245
|
+
code: o,
|
|
246
|
+
blockIndex: D,
|
|
247
|
+
theme: a.theme
|
|
248
|
+
}, l);
|
|
249
|
+
}, L = m(() => {
|
|
250
|
+
const r = h.parse(a.content, {}), o = h.render(a.content);
|
|
251
|
+
return {
|
|
252
|
+
name: "MarkdownRenderer",
|
|
253
|
+
render() {
|
|
254
|
+
const D = document.createElement("div");
|
|
255
|
+
D.innerHTML = o;
|
|
256
|
+
const l = [];
|
|
257
|
+
let c = 0, u;
|
|
258
|
+
const e = /<!----MC_MARKDOWN_CODE_BLOCK_(\d+)---->/g;
|
|
259
|
+
let g = 0;
|
|
260
|
+
for (; (u = e.exec(o)) !== null; ) {
|
|
261
|
+
u.index > c && l.push(w(
|
|
262
|
+
"div",
|
|
263
|
+
{
|
|
264
|
+
innerHTML: o.slice(c, u.index)
|
|
265
|
+
}
|
|
266
|
+
));
|
|
267
|
+
const N = r[parseInt(u[1])], B = N.info || "", U = N.content;
|
|
268
|
+
l.push(C(B, U, g)), g++, c = e.lastIndex;
|
|
269
|
+
}
|
|
270
|
+
return c < o.length && l.push(w("div", {
|
|
271
|
+
innerHTML: o.slice(c)
|
|
272
|
+
})), w("div", l);
|
|
273
|
+
}
|
|
274
|
+
};
|
|
275
|
+
});
|
|
276
|
+
H(() => a.customXssRules, (r) => {
|
|
277
|
+
s.setCustomXssRules(r);
|
|
278
|
+
});
|
|
279
|
+
const A = m(() => a.theme === "dark" ? "mc-markdown-render-dark" : "mc-markdown-render-light");
|
|
280
|
+
return t({
|
|
281
|
+
mdt: h
|
|
282
|
+
}), (r, o) => (d(), M(
|
|
283
|
+
Z,
|
|
284
|
+
null,
|
|
285
|
+
[
|
|
286
|
+
I(
|
|
287
|
+
"div",
|
|
288
|
+
{
|
|
289
|
+
class: k(["mc-markdown-render", A.value])
|
|
290
|
+
},
|
|
291
|
+
[
|
|
292
|
+
(d(), P(X(L.value)))
|
|
293
|
+
],
|
|
294
|
+
2
|
|
295
|
+
/* CLASS */
|
|
296
|
+
),
|
|
297
|
+
O("v-if", !0)
|
|
298
|
+
],
|
|
299
|
+
64
|
|
300
|
+
/* STABLE_FRAGMENT */
|
|
301
|
+
));
|
|
302
|
+
}
|
|
303
|
+
}), f = /* @__PURE__ */ b(Me, [["__scopeId", "data-v-a398f75b"]]);
|
|
304
|
+
f.install = (n) => {
|
|
305
|
+
n.component("McMarkdownCard", f);
|
|
306
|
+
};
|
|
307
|
+
export {
|
|
308
|
+
f as McMarkdownCard
|
|
309
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.mc-mention[data-v-4ce5ce76]{position:fixed;max-height:300px;border-radius:var(--devui-border-radius, 2px);background-color:var(--devui-connected-overlay-bg, #ffffff);box-shadow:var(--devui-shadow-length-connected-overlay, 0 2px 12px 0) var(--devui-shadow, rgba(37, 43, 58, .24));transform-origin:0% 100%;z-index:1000}.mc-mention-fade-enter-from[data-v-4ce5ce76],.mc-mention-fade-leave-to[data-v-4ce5ce76]{opacity:.8;transform:scaleY(.8) translateY(4px)}.mc-mention-fade-enter-to[data-v-4ce5ce76],.mc-mention-fade-leave-from[data-v-4ce5ce76]{opacity:1;transform:scaleY(.9999) translateY(0)}.mc-mention-fade-enter-active[data-v-4ce5ce76]{transition:transform .2s cubic-bezier(.16,.75,.5,1),opacity .2s cubic-bezier(.16,.75,.5,1)}.mc-mention-fade-leave-active[data-v-4ce5ce76]{transition:transform .2s cubic-bezier(.5,0,.84,.25),opacity .2s cubic-bezier(.5,0,.84,.25)}
|
package/Mention/index.js
ADDED
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
import "./index.css";
|
|
2
|
+
import { ref as T, reactive as F, watch as K, nextTick as U, onMounted as G, onBeforeUnmount as J, defineComponent as Q, openBlock as C, createElementBlock as O, Fragment as X, createVNode as P, unref as A, withCtx as $, renderSlot as R, createBlock as Y, Teleport as Z, Transition as ee, normalizeClass as te, normalizeStyle as ne, createCommentVNode as oe } from "vue";
|
|
3
|
+
import { PopperTrigger as re } from "@matechat/core/PopperTrigger";
|
|
4
|
+
import { computePosition as ie, offset as le } from "@floating-ui/dom";
|
|
5
|
+
import { debounce as se, isObject as ae } from "lodash-es";
|
|
6
|
+
const ce = {
|
|
7
|
+
modelValue: {
|
|
8
|
+
type: Boolean,
|
|
9
|
+
default: !1
|
|
10
|
+
},
|
|
11
|
+
prefix: {
|
|
12
|
+
type: Array,
|
|
13
|
+
default: () => []
|
|
14
|
+
},
|
|
15
|
+
fitHostWidth: {
|
|
16
|
+
type: Boolean,
|
|
17
|
+
default: !0
|
|
18
|
+
},
|
|
19
|
+
menuClass: {
|
|
20
|
+
type: String
|
|
21
|
+
}
|
|
22
|
+
}, ue = ["update:modelValue", "searchChange", "toggleChange"], M = " ", de = "ArrowLeft", fe = "ArrowRight", me = "Escape";
|
|
23
|
+
function pe(r, l) {
|
|
24
|
+
const s = T(), t = T(), a = T(), c = F({ top: "0px", left: "0px", width: "" });
|
|
25
|
+
let o, i, v, w, h = "", y, d;
|
|
26
|
+
const E = async () => {
|
|
27
|
+
if (!t.value || !a.value)
|
|
28
|
+
return;
|
|
29
|
+
const { x: e, y: n } = await ie(t.value, a.value, {
|
|
30
|
+
strategy: "fixed",
|
|
31
|
+
placement: "top-start",
|
|
32
|
+
middleware: [le(4)]
|
|
33
|
+
});
|
|
34
|
+
c.top = `${n}px`, c.left = `${e}px`;
|
|
35
|
+
}, D = () => {
|
|
36
|
+
const { width: e } = t.value.getBoundingClientRect();
|
|
37
|
+
c.width = `${e}px`, E();
|
|
38
|
+
}, W = () => {
|
|
39
|
+
r.fitHostWidth && typeof window < "u" && t.value && (d = new window.ResizeObserver(D), d.observe(t.value));
|
|
40
|
+
}, _ = () => {
|
|
41
|
+
t.value && (d == null || d.unobserve(t.value));
|
|
42
|
+
};
|
|
43
|
+
K(
|
|
44
|
+
() => r.modelValue,
|
|
45
|
+
(e, n) => {
|
|
46
|
+
e ? (U(E), W(), typeof window < "u" && window.addEventListener("scroll", x, !0)) : (_(), typeof window < "u" && window.removeEventListener("scroll", x, !0)), n !== void 0 && l("toggleChange", e);
|
|
47
|
+
},
|
|
48
|
+
{ immediate: !0 }
|
|
49
|
+
);
|
|
50
|
+
const L = () => {
|
|
51
|
+
i = null, v = -1, w = -1, h = "";
|
|
52
|
+
}, f = (e) => {
|
|
53
|
+
l("update:modelValue", e);
|
|
54
|
+
}, q = () => {
|
|
55
|
+
if (!o)
|
|
56
|
+
return;
|
|
57
|
+
const e = o.value.replace(/[\r\n]/g, M) || "", n = o.selectionStart;
|
|
58
|
+
if (!e.trim() || !n) {
|
|
59
|
+
L();
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
for (let u = 0; u < r.prefix.length; u++) {
|
|
63
|
+
const m = r.prefix[u];
|
|
64
|
+
let p = "", I = !1;
|
|
65
|
+
if (typeof m == "string")
|
|
66
|
+
p = m;
|
|
67
|
+
else if (ae(m))
|
|
68
|
+
p = m.key, I = !!m.onlyInputStart;
|
|
69
|
+
else
|
|
70
|
+
continue;
|
|
71
|
+
const g = e.lastIndexOf(p, n), N = e.lastIndexOf(M, n), S = e.substring(g, n), j = S.charAt(S.length - 1);
|
|
72
|
+
if (g < 0 || g > 0 && I || g < N || j === M)
|
|
73
|
+
L();
|
|
74
|
+
else {
|
|
75
|
+
i = p, v = g, w = n, h = S.slice(p.length);
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}, k = () => {
|
|
80
|
+
if (q(), !i) {
|
|
81
|
+
f(!1);
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
l("searchChange", { value: h, trigger: i, triggerIndex: v, cursorIndex: w }), f(!0);
|
|
85
|
+
}, V = se(k, 300), b = (e) => {
|
|
86
|
+
(e.code === de || e.code === fe) && (y = setTimeout(() => {
|
|
87
|
+
k(), y && (y = void 0, clearTimeout(y));
|
|
88
|
+
})), e.code === me && f(!1);
|
|
89
|
+
}, B = (e) => {
|
|
90
|
+
var n, u;
|
|
91
|
+
r.modelValue ? (n = t.value) != null && n.contains(e.target) || f(!1) : (u = t.value) != null && u.contains(e.target) && k();
|
|
92
|
+
};
|
|
93
|
+
function x(e) {
|
|
94
|
+
const n = e.target;
|
|
95
|
+
n != null && n.contains(t.value) && E();
|
|
96
|
+
}
|
|
97
|
+
const H = () => {
|
|
98
|
+
t.value && (o = t.value.querySelector("textarea") || t.value.querySelector("input"), o && (o.addEventListener("input", V), o.addEventListener("keydown", b))), document.addEventListener("click", B);
|
|
99
|
+
};
|
|
100
|
+
return G(() => {
|
|
101
|
+
const e = s.value.triggerEl;
|
|
102
|
+
t.value = e.$el ?? e, H();
|
|
103
|
+
}), J(() => {
|
|
104
|
+
f(!1), o == null || o.removeEventListener("input", V), o == null || o.removeEventListener("keydown", b), document.removeEventListener("click", B), typeof window < "u" && window.removeEventListener("scroll", x, !0), _();
|
|
105
|
+
}), { popperTriggerEl: s, overlayEl: a, overlayStyle: c };
|
|
106
|
+
}
|
|
107
|
+
const ge = /* @__PURE__ */ Q({
|
|
108
|
+
__name: "Mention",
|
|
109
|
+
props: ce,
|
|
110
|
+
emits: ue,
|
|
111
|
+
setup(r, { emit: l }) {
|
|
112
|
+
const s = r, t = l, { popperTriggerEl: a, overlayEl: c, overlayStyle: o } = pe(s, t);
|
|
113
|
+
return (i, v) => (C(), O(
|
|
114
|
+
X,
|
|
115
|
+
null,
|
|
116
|
+
[
|
|
117
|
+
P(
|
|
118
|
+
A(re),
|
|
119
|
+
{
|
|
120
|
+
ref_key: "popperTriggerEl",
|
|
121
|
+
ref: a
|
|
122
|
+
},
|
|
123
|
+
{
|
|
124
|
+
default: $(() => [
|
|
125
|
+
R(i.$slots, "default", {}, void 0, !0)
|
|
126
|
+
]),
|
|
127
|
+
_: 3
|
|
128
|
+
/* FORWARDED */
|
|
129
|
+
},
|
|
130
|
+
512
|
|
131
|
+
/* NEED_PATCH */
|
|
132
|
+
),
|
|
133
|
+
(C(), Y(Z, { to: "body" }, [
|
|
134
|
+
P(ee, { name: "mc-mention-fade" }, {
|
|
135
|
+
default: $(() => [
|
|
136
|
+
i.modelValue ? (C(), O(
|
|
137
|
+
"div",
|
|
138
|
+
{
|
|
139
|
+
key: 0,
|
|
140
|
+
ref_key: "overlayEl",
|
|
141
|
+
ref: c,
|
|
142
|
+
class: te(["mc-mention", i.menuClass]),
|
|
143
|
+
style: ne(A(o))
|
|
144
|
+
},
|
|
145
|
+
[
|
|
146
|
+
R(i.$slots, "menu", {}, void 0, !0)
|
|
147
|
+
],
|
|
148
|
+
6
|
|
149
|
+
/* CLASS, STYLE */
|
|
150
|
+
)) : oe("v-if", !0)
|
|
151
|
+
]),
|
|
152
|
+
_: 3
|
|
153
|
+
/* FORWARDED */
|
|
154
|
+
})
|
|
155
|
+
]))
|
|
156
|
+
],
|
|
157
|
+
64
|
|
158
|
+
/* STABLE_FRAGMENT */
|
|
159
|
+
));
|
|
160
|
+
}
|
|
161
|
+
}), ve = (r, l) => {
|
|
162
|
+
const s = r.__vccOpts || r;
|
|
163
|
+
for (const [t, a] of l)
|
|
164
|
+
s[t] = a;
|
|
165
|
+
return s;
|
|
166
|
+
}, z = /* @__PURE__ */ ve(ge, [["__scopeId", "data-v-4ce5ce76"]]);
|
|
167
|
+
z.install = (r) => {
|
|
168
|
+
r.component("McMention", z);
|
|
169
|
+
};
|
|
170
|
+
export {
|
|
171
|
+
z as McMention
|
|
172
|
+
};
|