@matechat/core 1.11.0 → 1.12.0-alpha

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.
Files changed (45) hide show
  1. package/Attachment/Attachment.vue.d.ts +8 -8
  2. package/Attachment/attachment-types.d.ts +3 -35
  3. package/Attachment/index.css +1 -1
  4. package/Attachment/index.js +43 -45
  5. package/Bubble/index.css +1 -1
  6. package/Bubble/index.js +322 -186
  7. package/Bubble/useBubbleFoundation.d.ts +9 -0
  8. package/FileList/index.js +1 -1
  9. package/Header/index.css +1 -1
  10. package/Header/index.js +12 -11
  11. package/Input/components/EditableBlock.vue.d.ts +2 -2
  12. package/Input/index.css +1 -1
  13. package/Input/index.js +699 -108
  14. package/Introduction/index.css +1 -1
  15. package/Introduction/index.js +138 -38
  16. package/Layout/index.js +7 -6
  17. package/List/index.css +1 -1
  18. package/List/index.js +54 -51
  19. package/Locale/index.js +85 -35
  20. package/MarkdownCard/MDCardParser.d.ts +0 -10
  21. package/MarkdownCard/MermaidService-yeLQUW_e.js +142 -0
  22. package/MarkdownCard/index.css +1 -1
  23. package/MarkdownCard/index.js +735 -200
  24. package/MarkdownCard/mdCard.types.d.ts +2 -29
  25. package/MarkdownCard/mdCard.vue.d.ts +2 -2
  26. package/MarkdownCard/useMarkdownCardFoundation.d.ts +8 -0
  27. package/Mention/Mention.vue.d.ts +12 -3
  28. package/Mention/index.css +1 -1
  29. package/Mention/index.js +365 -110
  30. package/Mention/mention-types.d.ts +6 -4
  31. package/Mention/use-mention.d.ts +7 -0
  32. package/Prompt/index.js +1 -1
  33. package/README.md +8 -12
  34. package/Toolbar/index.css +1 -1
  35. package/Toolbar/index.d.ts +2 -1
  36. package/Toolbar/index.js +189 -198
  37. package/Toolbar/toolbar.types.d.ts +2 -26
  38. package/index.d.ts +18 -6
  39. package/mate-chat.js +17 -2
  40. package/package.json +1 -4
  41. package/Attachment/uploader.d.ts +0 -11
  42. package/MarkdownCard/MDCardService.d.ts +0 -14
  43. package/MarkdownCard/MermaidService-B6BcjbW_.js +0 -127
  44. package/MarkdownCard/MermaidService.d.ts +0 -22
  45. package/Mention/const.d.ts +0 -4
@@ -1,33 +1,6 @@
1
- import type { Options, PluginSimple, PluginWithOptions, PluginWithParams } from 'markdown-it';
1
+ import type { Options } from 'markdown-it';
2
2
  import type { PropType } from 'vue';
3
- export interface MermaidConfig {
4
- theme?: string;
5
- }
6
- export interface CustomXssRule {
7
- key: string;
8
- value: string[] | null;
9
- }
10
- export interface CodBlockData {
11
- code: string;
12
- language: string;
13
- }
14
- export type CodeBlockSlot = {
15
- actions?: () => void;
16
- header?: () => void;
17
- content?: () => void;
18
- };
19
- export type Theme = 'light' | 'dark';
20
- export type TypingStyle = 'normal' | 'cursor' | 'color' | 'gradient';
21
- export type IntervalType = number | [number, number];
22
- export declare const defaultTypingConfig: {
23
- step: number;
24
- interval: number;
25
- style: string;
26
- };
27
- export interface MdPlugin {
28
- plugin: PluginSimple | PluginWithOptions | PluginWithParams;
29
- opts?: unknown;
30
- }
3
+ import { TypingStyle, CustomXssRule, MdPlugin, Theme, MermaidConfig } from '@matechat/common/MarkdownCard/common/mdCard.types';
31
4
  export declare const mdCardProps: {
32
5
  content: {
33
6
  type: StringConstructor;
@@ -10,14 +10,14 @@ declare const __VLS_base: import("vue").DefineComponent<{}, {
10
10
  mdt: MarkdownIt;
11
11
  }, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
12
12
  typing: (...args: any[]) => void;
13
- afterMdtInit: (...args: any[]) => void;
14
13
  typingStart: (...args: any[]) => void;
15
14
  typingEnd: (...args: any[]) => void;
15
+ afterMdtInit: (...args: any[]) => void;
16
16
  }, string, import("vue").PublicProps, Readonly<{}> & Readonly<{
17
17
  onTyping?: ((...args: any[]) => any) | undefined;
18
- onAfterMdtInit?: ((...args: any[]) => any) | undefined;
19
18
  onTypingStart?: ((...args: any[]) => any) | undefined;
20
19
  onTypingEnd?: ((...args: any[]) => any) | undefined;
20
+ onAfterMdtInit?: ((...args: any[]) => any) | undefined;
21
21
  }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
22
22
  declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
23
23
  declare const _default: typeof __VLS_export;
@@ -0,0 +1,8 @@
1
+ import { MarkdownCardFoundation } from "@matechat/common/MarkdownCard/foundation";
2
+ export interface UseMarkdownCardFoundationOptions {
3
+ props: any;
4
+ emit: any;
5
+ }
6
+ export declare function useMarkdownCardFoundation({ props, emit, }: UseMarkdownCardFoundationOptions): {
7
+ foundation: MarkdownCardFoundation;
8
+ };
@@ -10,13 +10,17 @@ declare const __VLS_base: import("vue").DefineComponent<import("vue").ExtractPro
10
10
  default: boolean;
11
11
  };
12
12
  prefix: {
13
- type: import("vue").PropType<Array<string | import("./mention-types").Trigger>>;
13
+ type: import("vue").PropType<Array<string | import("@matechat/common/Mention/common/mention-types").Trigger>>;
14
14
  default: () => never[];
15
15
  };
16
16
  fitHostWidth: {
17
17
  type: BooleanConstructor;
18
18
  default: boolean;
19
19
  };
20
+ optionsCount: {
21
+ type: NumberConstructor;
22
+ default: number;
23
+ };
20
24
  menuClass: {
21
25
  type: StringConstructor;
22
26
  };
@@ -26,20 +30,25 @@ declare const __VLS_base: import("vue").DefineComponent<import("vue").ExtractPro
26
30
  default: boolean;
27
31
  };
28
32
  prefix: {
29
- type: import("vue").PropType<Array<string | import("./mention-types").Trigger>>;
33
+ type: import("vue").PropType<Array<string | import("@matechat/common/Mention/common/mention-types").Trigger>>;
30
34
  default: () => never[];
31
35
  };
32
36
  fitHostWidth: {
33
37
  type: BooleanConstructor;
34
38
  default: boolean;
35
39
  };
40
+ optionsCount: {
41
+ type: NumberConstructor;
42
+ default: number;
43
+ };
36
44
  menuClass: {
37
45
  type: StringConstructor;
38
46
  };
39
47
  }>> & Readonly<{}>, {
40
- prefix: (string | import("./mention-types").Trigger)[];
48
+ prefix: (string | import("@matechat/common/Mention/common/mention-types").Trigger)[];
41
49
  modelValue: boolean;
42
50
  fitHostWidth: boolean;
51
+ optionsCount: number;
43
52
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
44
53
  declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
45
54
  declare const _default: typeof __VLS_export;
package/Mention/index.css CHANGED
@@ -1 +1 @@
1
- .mc-mention[data-v-3397c63c]{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-3397c63c],.mc-mention-fade-leave-to[data-v-3397c63c]{opacity:.8;transform:scaleY(.8) translateY(4px)}.mc-mention-fade-enter-to[data-v-3397c63c],.mc-mention-fade-leave-from[data-v-3397c63c]{opacity:1;transform:scaleY(.9999) translateY(0)}.mc-mention-fade-enter-active[data-v-3397c63c]{transition:transform .2s cubic-bezier(.16,.75,.5,1),opacity .2s cubic-bezier(.16,.75,.5,1)}.mc-mention-fade-leave-active[data-v-3397c63c]{transition:transform .2s cubic-bezier(.5,0,.84,.25),opacity .2s cubic-bezier(.5,0,.84,.25)}
1
+ .mc-mention[data-v-adc485fb]{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-adc485fb],.mc-mention-fade-leave-to[data-v-adc485fb]{opacity:.8;transform:scaleY(.8) translateY(4px)}.mc-mention-fade-enter-to[data-v-adc485fb],.mc-mention-fade-leave-from[data-v-adc485fb]{opacity:1;transform:scaleY(.9999) translateY(0)}.mc-mention-fade-enter-active[data-v-adc485fb]{transition:transform .2s cubic-bezier(.16,.75,.5,1),opacity .2s cubic-bezier(.16,.75,.5,1)}.mc-mention-fade-leave-active[data-v-adc485fb]{transition:transform .2s cubic-bezier(.5,0,.84,.25),opacity .2s cubic-bezier(.5,0,.84,.25)}
package/Mention/index.js CHANGED
@@ -1,8 +1,12 @@
1
- import { ref as T, reactive as F, watch as K, nextTick as U, onMounted as G, onBeforeUnmount as J, defineComponent as Q, createElementBlock as O, openBlock as C, Fragment as X, createVNode as P, createBlock as Y, unref as A, withCtx as $, renderSlot as R, Teleport as Z, Transition as ee, createCommentVNode as te, normalizeStyle as ne, normalizeClass as oe } from "vue";
2
- import { PopperTrigger as re } from "@matechat/core/PopperTrigger";
3
- import { computePosition as ie, offset as le } from "@floating-ui/dom";
4
- import { debounce as se, isObject as ae } from "lodash-es";
5
- const ce = {
1
+ import "./index.css";
2
+ var b = Object.defineProperty;
3
+ var O = (s, e, t) => e in s ? b(s, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : s[e] = t;
4
+ var u = (s, e, t) => O(s, typeof e != "symbol" ? e + "" : e, t);
5
+ import { ref as E, reactive as T, nextTick as v, watch as m, onMounted as A, onUnmounted as $, defineComponent as U, openBlock as y, createElementBlock as C, Fragment as D, createVNode as x, unref as w, withCtx as I, renderSlot as k, createBlock as R, Teleport as L, Transition as B, normalizeStyle as H, normalizeClass as W, createCommentVNode as K } from "vue";
6
+ import { PopperTrigger as z } from "@matechat/core/PopperTrigger";
7
+ import { computePosition as S, offset as V, autoUpdate as F } from "@floating-ui/dom";
8
+ import { debounce as j, isObject as N } from "lodash-es";
9
+ const q = {
6
10
  modelValue: {
7
11
  type: Boolean,
8
12
  default: !1
@@ -15,113 +19,364 @@ const ce = {
15
19
  type: Boolean,
16
20
  default: !0
17
21
  },
22
+ optionsCount: {
23
+ type: Number,
24
+ default: 0
25
+ },
18
26
  menuClass: {
19
27
  type: String
20
28
  }
21
- }, ue = ["update:modelValue", "searchChange", "toggleChange"], M = " ", de = "ArrowLeft", fe = "ArrowRight", me = "Escape";
22
- function pe(r, l) {
23
- const s = T(), t = T(), a = T(), c = F({ top: "0px", left: "0px", width: "" });
24
- let o, i, g, w, h = "", y, d;
25
- const E = async () => {
26
- if (!t.value || !a.value)
27
- return;
28
- const { x: e, y: n } = await ie(t.value, a.value, {
29
- strategy: "fixed",
30
- placement: "top-start",
31
- middleware: [le(4)]
29
+ }, G = ["update:modelValue", "searchChange", "toggleChange"], p = () => {
30
+ };
31
+ class f {
32
+ constructor(e) {
33
+ u(this, "_adapter");
34
+ this._adapter = { ...f.defaultAdapter, ...e };
35
+ }
36
+ static get cssClasses() {
37
+ return {};
38
+ }
39
+ static get strings() {
40
+ return {};
41
+ }
42
+ static get numbers() {
43
+ return {};
44
+ }
45
+ static get defaultAdapter() {
46
+ return {
47
+ getProp: p,
48
+ getProps: p,
49
+ getState: p,
50
+ getStates: p,
51
+ setState: p,
52
+ getContext: p,
53
+ getContexts: p,
54
+ getCache: p,
55
+ setCache: p,
56
+ getCaches: p,
57
+ stopPropagation: p
58
+ };
59
+ }
60
+ getProp(e) {
61
+ return this._adapter.getProp(e);
62
+ }
63
+ getProps() {
64
+ return this._adapter.getProps();
65
+ }
66
+ getState(e) {
67
+ return this._adapter.getState(e);
68
+ }
69
+ getStates() {
70
+ return this._adapter.getStates();
71
+ }
72
+ setState(e, t) {
73
+ return this._adapter.setState({ ...e }, t);
74
+ }
75
+ /* istanbul ignore next */
76
+ getCaches() {
77
+ return this._adapter.getCaches();
78
+ }
79
+ getCache(e) {
80
+ return this._adapter.getCache(e);
81
+ }
82
+ setCache(e, t) {
83
+ return e && this._adapter.setCache(e, t);
84
+ }
85
+ nextTick(e) {
86
+ return this._adapter.nextTick(e);
87
+ }
88
+ _isInProps(e) {
89
+ const t = this.getProps();
90
+ return e in t;
91
+ }
92
+ init(e) {
93
+ }
94
+ destroy() {
95
+ }
96
+ }
97
+ const g = " ", J = "ArrowLeft", Q = "ArrowRight", X = "ArrowUp", Y = "ArrowDown", Z = "Escape";
98
+ class tt extends f {
99
+ constructor(t) {
100
+ super({ ...t });
101
+ u(this, "props");
102
+ u(this, "inputEl", null);
103
+ u(this, "originEl", null);
104
+ u(this, "overlayEl", null);
105
+ u(this, "currentTrigger", "");
106
+ u(this, "currentSearchValue", "");
107
+ u(this, "currentTriggerIndex", -1);
108
+ u(this, "currentCursorIndex", -1);
109
+ u(this, "autoUpdateCleanup", null);
110
+ // 处理输入事件
111
+ u(this, "handleInput", () => {
112
+ if (!this.inputEl) return;
113
+ const t = this.inputEl.value, i = this.inputEl.selectionStart || 0, o = this.checkPrefixMatch(t, i);
114
+ if (o) {
115
+ const { trigger: l, triggerIndex: a, searchValue: n } = o;
116
+ this.currentTrigger = l, this.currentSearchValue = n, this.currentTriggerIndex = a, this.currentCursorIndex = i, this._adapter.searchChange({
117
+ value: n,
118
+ trigger: l,
119
+ triggerIndex: a,
120
+ cursorIndex: i
121
+ }), this.updateModelValue(!0);
122
+ } else
123
+ this.resetMention();
32
124
  });
33
- c.top = `${n}px`, c.left = `${e}px`;
34
- }, D = () => {
35
- const { width: e } = t.value.getBoundingClientRect();
36
- c.width = `${e}px`, E();
37
- }, W = () => {
38
- r.fitHostWidth && typeof window < "u" && t.value && (d = new window.ResizeObserver(D), d.observe(t.value));
39
- }, _ = () => {
40
- t.value && (d == null || d.unobserve(t.value));
41
- };
42
- K(
43
- () => r.modelValue,
44
- (e, n) => {
45
- 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);
46
- },
47
- { immediate: !0 }
48
- );
49
- const L = () => {
50
- i = null, g = -1, w = -1, h = "";
51
- }, f = (e) => {
52
- l("update:modelValue", e);
53
- }, q = () => {
54
- if (!o)
55
- return;
56
- const e = o.value.replace(/[\r\n]/g, M) || "", n = o.selectionStart;
57
- if (!e.trim() || !n) {
58
- L();
59
- return;
60
- }
61
- for (let u = 0; u < r.prefix.length; u++) {
62
- const m = r.prefix[u];
63
- let p = "", I = !1;
64
- if (typeof m == "string")
65
- p = m;
66
- else if (ae(m))
67
- p = m.key, I = !!m.onlyInputStart;
125
+ // 处理键盘事件
126
+ u(this, "handleKeyDown", (t) => {
127
+ if (this.inputEl)
128
+ switch (t.key) {
129
+ case X:
130
+ this.props.modelValue && (t.preventDefault(), this.handleArrowKey(-1));
131
+ break;
132
+ case Y:
133
+ this.props.modelValue && (t.preventDefault(), this.handleArrowKey(1));
134
+ break;
135
+ case J:
136
+ case Q:
137
+ setTimeout(() => {
138
+ this.handleInput();
139
+ });
140
+ break;
141
+ case Z:
142
+ t.preventDefault(), this.resetMention();
143
+ break;
144
+ case g:
145
+ this.props.modelValue && this.resetMention();
146
+ break;
147
+ }
148
+ });
149
+ // 处理点击事件
150
+ u(this, "handleClick", () => {
151
+ this.inputEl && this.handleInput();
152
+ });
153
+ // 处理文档点击事件
154
+ u(this, "handleDocumentClick", (t) => {
155
+ this.originEl && (this.props.modelValue ? this.originEl.contains(t.target) || this.resetMention() : this.originEl.contains(t.target) && this.handleInput());
156
+ });
157
+ this.props = {
158
+ modelValue: !1,
159
+ prefix: [],
160
+ fitHostWidth: !0,
161
+ optionsCount: 0,
162
+ ...this.getProps()
163
+ }, this.handleInput = j(this.handleInput, 300);
164
+ }
165
+ // 更新配置选项
166
+ updateOptions(t) {
167
+ this.props = { ...this.props, ...t }, this.updateOverlayPosition();
168
+ }
169
+ // 设置输入元素
170
+ setInputEl(t) {
171
+ this.inputEl = t;
172
+ }
173
+ // 设置原点元素
174
+ setOriginEl(t) {
175
+ this.originEl = t, this.updateOverlayPosition();
176
+ }
177
+ // 设置覆盖层元素
178
+ setOverlayEl(t) {
179
+ this.overlayEl = t, this.updateOverlayPosition();
180
+ }
181
+ // 初始化事件
182
+ initEvents() {
183
+ this.inputEl && (this.inputEl.addEventListener("input", this.handleInput), this.inputEl.addEventListener("keydown", this.handleKeyDown), this.inputEl.addEventListener("click", this.handleClick)), document.addEventListener("click", this.handleDocumentClick);
184
+ }
185
+ // 销毁事件
186
+ destroy() {
187
+ this.inputEl && (this.inputEl.removeEventListener("input", this.handleInput), this.inputEl.removeEventListener("keydown", this.handleKeyDown), this.inputEl.removeEventListener("click", this.handleClick)), document.removeEventListener("click", this.handleDocumentClick), this.autoUpdateCleanup && (this.autoUpdateCleanup(), this.autoUpdateCleanup = null), this.inputEl = null, this.originEl = null, this.overlayEl = null;
188
+ }
189
+ // 重置Mention状态
190
+ resetMention() {
191
+ this.currentTrigger = "", this.currentSearchValue = "", this.currentTriggerIndex = -1, this.currentCursorIndex = -1, this.updateModelValue(!1);
192
+ }
193
+ // 更新模型值
194
+ updateModelValue(t) {
195
+ this.props.modelValue !== t && (this.props.modelValue = t, this._adapter.updateModelValue(t), this._adapter.toggleChange(t));
196
+ }
197
+ // 检查前缀匹配
198
+ checkPrefixMatch(t, i) {
199
+ if (!this.props.prefix || this.props.prefix.length === 0) return null;
200
+ const l = t.replace(/[\r\n]/g, g).substring(0, i);
201
+ for (const a of this.props.prefix) {
202
+ let n = "", d = !1;
203
+ if (typeof a == "string")
204
+ n = a;
205
+ else if (N(a))
206
+ n = a.key, d = !!a.onlyInputStart;
68
207
  else
69
208
  continue;
70
- const v = e.lastIndexOf(p, n), N = e.lastIndexOf(M, n), S = e.substring(v, n), j = S.charAt(S.length - 1);
71
- if (v < 0 || v > 0 && I || v < N || j === M)
72
- L();
73
- else {
74
- i = p, g = v, w = n, h = S.slice(p.length);
209
+ const h = l.lastIndexOf(n), r = l.lastIndexOf(g), c = l.substring(h, i), P = c.charAt(c.length - 1);
210
+ if (!(h < 0 || h > 0 && d || h < r || P === g)) {
211
+ const M = c.slice(n.length);
212
+ return { trigger: n, triggerIndex: h, searchValue: M };
213
+ }
214
+ }
215
+ return null;
216
+ }
217
+ // 处理箭头键
218
+ handleArrowKey(t) {
219
+ let i = (this.getCurrentActiveIndex() + t) % this.props.optionsCount;
220
+ i < 0 && (i = this.props.optionsCount - 1), this._adapter.activeIndexChange(i);
221
+ }
222
+ // 获取当前活动索引
223
+ getCurrentActiveIndex() {
224
+ return 0;
225
+ }
226
+ // 处理选择事件
227
+ handleSelect() {
228
+ if (!this.inputEl || this.currentTriggerIndex === -1) return;
229
+ const t = this.inputEl.value, i = t.substring(0, this.currentTriggerIndex), o = t.substring(this.currentCursorIndex), l = `${i}@selected ${o}`;
230
+ this.inputEl.value = l;
231
+ const a = i.length + 10;
232
+ this.inputEl.setSelectionRange(a, a), this.resetMention(), this.inputEl.dispatchEvent(new Event("input", { bubbles: !0 }));
233
+ }
234
+ // 更新覆盖层位置
235
+ updateOverlayPosition() {
236
+ return new Promise((t) => {
237
+ if (!this.originEl || !this.overlayEl) {
238
+ t(void 0);
75
239
  return;
76
240
  }
241
+ if (this.props.fitHostWidth) {
242
+ const i = this.originEl.getBoundingClientRect();
243
+ this.overlayEl.style.width = `${i.width}px`;
244
+ } else
245
+ this.overlayEl.style.width = "";
246
+ this.autoUpdateCleanup && (this.autoUpdateCleanup(), this.autoUpdateCleanup = null), S(this.originEl, this.overlayEl, {
247
+ strategy: "fixed",
248
+ placement: "top-start",
249
+ middleware: [V(4)]
250
+ }).then(({ x: i, y: o }) => {
251
+ this.overlayEl.style.top = `${o}px`, this.overlayEl.style.left = `${i}px`, this.overlayEl.style.position = "fixed", t({
252
+ top: `${o}px`,
253
+ left: `${i}px`,
254
+ width: this.props.fitHostWidth ? `${this.originEl.getBoundingClientRect().width}px` : ""
255
+ }), this.autoUpdateCleanup = F(
256
+ this.originEl,
257
+ this.overlayEl,
258
+ () => {
259
+ if (this.originEl && this.overlayEl) {
260
+ if (this.props.fitHostWidth) {
261
+ const l = this.originEl.getBoundingClientRect();
262
+ this.overlayEl.style.width = `${l.width}px`;
263
+ }
264
+ S(this.originEl, this.overlayEl, {
265
+ strategy: "fixed",
266
+ placement: "top-start",
267
+ middleware: [V(4)]
268
+ }).then(({ x: l, y: a }) => {
269
+ this.overlayEl.style.top = `${a}px`, this.overlayEl.style.left = `${l}px`;
270
+ });
271
+ }
272
+ },
273
+ {
274
+ // 添加对视口变化的更全面监听,确保浏览器F12打开/关闭时位置能正确更新
275
+ animationFrame: !0,
276
+ elementResize: !0,
277
+ ancestorScroll: !0,
278
+ ancestorResize: !0,
279
+ layoutShift: !0
280
+ }
281
+ );
282
+ }).catch(() => {
283
+ t(void 0);
284
+ });
285
+ });
286
+ }
287
+ // 获取当前搜索值
288
+ getCurrentSearchValue() {
289
+ return this.currentSearchValue;
290
+ }
291
+ // 获取当前触发词
292
+ getCurrentTrigger() {
293
+ return this.currentTrigger;
294
+ }
295
+ }
296
+ function et(s, e) {
297
+ const t = E(), i = E(), o = E(), l = T({ top: "0px", left: "0px", width: "" });
298
+ let a, n;
299
+ n = new tt({
300
+ ...f.defaultAdapter,
301
+ getProps: () => ({
302
+ modelValue: s.modelValue,
303
+ prefix: s.prefix,
304
+ fitHostWidth: s.fitHostWidth,
305
+ optionsCount: s.optionsCount
306
+ }),
307
+ nextTick: (r) => v(r),
308
+ // 使用Vue的nextTick函数确保DOM更新完成后执行回调
309
+ updateModelValue: (r) => e("update:modelValue", r),
310
+ searchChange: (r) => e("searchChange", r),
311
+ activeIndexChange: () => {
312
+ },
313
+ toggleChange: (r) => e("toggleChange", r)
314
+ }), m(
315
+ () => s.modelValue,
316
+ (r, c) => {
317
+ n.updateOptions({ modelValue: r }), c !== void 0 && e("toggleChange", r), r && v(() => {
318
+ o.value && n.setOverlayEl(o.value), h();
319
+ });
320
+ },
321
+ { immediate: !0 }
322
+ ), m(
323
+ () => s.prefix,
324
+ (r) => {
325
+ n.updateOptions({ prefix: r });
326
+ },
327
+ { deep: !0 }
328
+ ), m(
329
+ () => s.fitHostWidth,
330
+ (r) => {
331
+ n.updateOptions({ fitHostWidth: r });
77
332
  }
78
- }, k = () => {
79
- if (q(), !i) {
80
- f(!1);
81
- return;
333
+ );
334
+ const d = () => {
335
+ i.value && (a = i.value.querySelector("textarea") || i.value.querySelector("input"), a && (n.setInputEl(a), n.setOriginEl(i.value), o.value && n.setOverlayEl(o.value), n.initEvents()));
336
+ }, h = () => {
337
+ if (i.value && o.value) {
338
+ const r = n.updateOverlayPosition();
339
+ r instanceof Promise ? r.then((c) => {
340
+ c && Object.assign(l, c);
341
+ }) : r && Object.assign(l, r);
82
342
  }
83
- l("searchChange", { value: h, trigger: i, triggerIndex: g, cursorIndex: w }), f(!0);
84
- }, V = se(k, 300), b = (e) => {
85
- (e.code === de || e.code === fe) && (y = setTimeout(() => {
86
- k(), y && (y = void 0, clearTimeout(y));
87
- })), e.code === me && f(!1);
88
- }, B = (e) => {
89
- var n, u;
90
- r.modelValue ? (n = t.value) != null && n.contains(e.target) || f(!1) : (u = t.value) != null && u.contains(e.target) && k();
91
343
  };
92
- function x(e) {
93
- const n = e.target;
94
- n != null && n.contains(t.value) && E();
95
- }
96
- const H = () => {
97
- t.value && (o = t.value.querySelector("textarea") || t.value.querySelector("input"), o && (o.addEventListener("input", V), o.addEventListener("keydown", b))), document.addEventListener("click", B);
344
+ return A(() => {
345
+ const r = t.value.triggerEl;
346
+ i.value = r.$el ?? r, d();
347
+ }), $(() => {
348
+ n.destroy();
349
+ }), {
350
+ popperTriggerEl: t,
351
+ originEl: i,
352
+ overlayEl: o,
353
+ overlayStyle: l,
354
+ initEvent: d,
355
+ mentionFoundation: n,
356
+ resetMention: () => n.resetMention(),
357
+ updateOptions: (r) => n.updateOptions(r),
358
+ updatePosition: h
98
359
  };
99
- return G(() => {
100
- const e = s.value.triggerEl;
101
- t.value = e.$el ?? e, H();
102
- }), J(() => {
103
- 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), _();
104
- }), { popperTriggerEl: s, overlayEl: a, overlayStyle: c };
105
360
  }
106
- const ve = /* @__PURE__ */ Q({
361
+ const it = /* @__PURE__ */ U({
107
362
  __name: "Mention",
108
- props: ce,
109
- emits: ue,
110
- setup(r, { emit: l }) {
111
- const s = r, t = l, { popperTriggerEl: a, overlayEl: c, overlayStyle: o } = pe(s, t);
112
- return (i, g) => (C(), O(
113
- X,
363
+ props: q,
364
+ emits: G,
365
+ setup(s, { emit: e }) {
366
+ const t = s, i = e, { popperTriggerEl: o, overlayEl: l, overlayStyle: a } = et(t, i);
367
+ return (n, d) => (y(), C(
368
+ D,
114
369
  null,
115
370
  [
116
- P(
117
- A(re),
371
+ x(
372
+ w(z),
118
373
  {
119
374
  ref_key: "popperTriggerEl",
120
- ref: a
375
+ ref: o
121
376
  },
122
377
  {
123
- default: $(() => [
124
- R(i.$slots, "default", {}, void 0, !0)
378
+ default: I(() => [
379
+ k(n.$slots, "default", {}, void 0, !0)
125
380
  ]),
126
381
  _: 3
127
382
  /* FORWARDED */
@@ -129,24 +384,24 @@ const ve = /* @__PURE__ */ Q({
129
384
  512
130
385
  /* NEED_PATCH */
131
386
  ),
132
- (C(), Y(Z, { to: "body" }, [
133
- P(ee, { name: "mc-mention-fade" }, {
134
- default: $(() => [
135
- i.modelValue ? (C(), O(
387
+ (y(), R(L, { to: "body" }, [
388
+ x(B, { name: "mc-mention-fade" }, {
389
+ default: I(() => [
390
+ n.modelValue ? (y(), C(
136
391
  "div",
137
392
  {
138
393
  key: 0,
139
394
  ref_key: "overlayEl",
140
- ref: c,
141
- class: oe(["mc-mention", i.menuClass]),
142
- style: ne(A(o))
395
+ ref: l,
396
+ class: W(["mc-mention", n.menuClass]),
397
+ style: H(w(a))
143
398
  },
144
399
  [
145
- R(i.$slots, "menu", {}, void 0, !0)
400
+ k(n.$slots, "menu", {}, void 0, !0)
146
401
  ],
147
402
  6
148
403
  /* CLASS, STYLE */
149
- )) : te("v-if", !0)
404
+ )) : K("v-if", !0)
150
405
  ]),
151
406
  _: 3
152
407
  /* FORWARDED */
@@ -157,15 +412,15 @@ const ve = /* @__PURE__ */ Q({
157
412
  /* STABLE_FRAGMENT */
158
413
  ));
159
414
  }
160
- }), ge = (r, l) => {
161
- const s = r.__vccOpts || r;
162
- for (const [t, a] of l)
163
- s[t] = a;
164
- return s;
165
- }, z = /* @__PURE__ */ ge(ve, [["__scopeId", "data-v-3397c63c"]]);
166
- z.install = (r) => {
167
- r.component("McMention", z);
415
+ }), nt = (s, e) => {
416
+ const t = s.__vccOpts || s;
417
+ for (const [i, o] of e)
418
+ t[i] = o;
419
+ return t;
420
+ }, _ = /* @__PURE__ */ nt(it, [["__scopeId", "data-v-adc485fb"]]);
421
+ _.install = (s) => {
422
+ s.component("McMention", _);
168
423
  };
169
424
  export {
170
- z as McMention
425
+ _ as McMention
171
426
  };
@@ -1,8 +1,6 @@
1
1
  import type { ExtractPropTypes, PropType } from 'vue';
2
- export interface Trigger {
3
- key: string;
4
- onlyInputStart?: boolean;
5
- }
2
+ import type { Trigger, SearchChangeEvent } from '@matechat/common/Mention/common/mention-types';
3
+ export type { Trigger, SearchChangeEvent };
6
4
  export declare const mentionProps: {
7
5
  modelValue: {
8
6
  type: BooleanConstructor;
@@ -16,6 +14,10 @@ export declare const mentionProps: {
16
14
  type: BooleanConstructor;
17
15
  default: boolean;
18
16
  };
17
+ optionsCount: {
18
+ type: NumberConstructor;
19
+ default: number;
20
+ };
19
21
  menuClass: {
20
22
  type: StringConstructor;
21
23
  };