@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.
- package/Attachment/Attachment.vue.d.ts +8 -8
- package/Attachment/attachment-types.d.ts +3 -35
- package/Attachment/index.css +1 -1
- package/Attachment/index.js +43 -45
- package/Bubble/index.css +1 -1
- package/Bubble/index.js +322 -186
- package/Bubble/useBubbleFoundation.d.ts +9 -0
- package/FileList/index.js +1 -1
- package/Header/index.css +1 -1
- package/Header/index.js +12 -11
- package/Input/components/EditableBlock.vue.d.ts +2 -2
- package/Input/index.css +1 -1
- package/Input/index.js +699 -108
- package/Introduction/index.css +1 -1
- package/Introduction/index.js +138 -38
- package/Layout/index.js +7 -6
- package/List/index.css +1 -1
- package/List/index.js +54 -51
- package/Locale/index.js +85 -35
- package/MarkdownCard/MDCardParser.d.ts +0 -10
- package/MarkdownCard/MermaidService-yeLQUW_e.js +142 -0
- package/MarkdownCard/index.css +1 -1
- package/MarkdownCard/index.js +735 -200
- package/MarkdownCard/mdCard.types.d.ts +2 -29
- package/MarkdownCard/mdCard.vue.d.ts +2 -2
- package/MarkdownCard/useMarkdownCardFoundation.d.ts +8 -0
- package/Mention/Mention.vue.d.ts +12 -3
- package/Mention/index.css +1 -1
- package/Mention/index.js +365 -110
- package/Mention/mention-types.d.ts +6 -4
- package/Mention/use-mention.d.ts +7 -0
- package/Prompt/index.js +1 -1
- package/README.md +8 -12
- package/Toolbar/index.css +1 -1
- package/Toolbar/index.d.ts +2 -1
- package/Toolbar/index.js +189 -198
- package/Toolbar/toolbar.types.d.ts +2 -26
- package/index.d.ts +18 -6
- package/mate-chat.js +17 -2
- package/package.json +1 -4
- package/Attachment/uploader.d.ts +0 -11
- package/MarkdownCard/MDCardService.d.ts +0 -14
- package/MarkdownCard/MermaidService-B6BcjbW_.js +0 -127
- package/MarkdownCard/MermaidService.d.ts +0 -22
- package/Mention/const.d.ts +0 -4
|
@@ -1,33 +1,6 @@
|
|
|
1
|
-
import type { Options
|
|
1
|
+
import type { Options } from 'markdown-it';
|
|
2
2
|
import type { PropType } from 'vue';
|
|
3
|
-
|
|
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
|
+
};
|
package/Mention/Mention.vue.d.ts
CHANGED
|
@@ -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("
|
|
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("
|
|
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("
|
|
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-
|
|
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
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
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
|
-
},
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
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
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
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
|
|
71
|
-
if (
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
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
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
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
|
-
|
|
93
|
-
const
|
|
94
|
-
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
|
|
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
|
|
361
|
+
const it = /* @__PURE__ */ U({
|
|
107
362
|
__name: "Mention",
|
|
108
|
-
props:
|
|
109
|
-
emits:
|
|
110
|
-
setup(
|
|
111
|
-
const
|
|
112
|
-
return (
|
|
113
|
-
|
|
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
|
-
|
|
117
|
-
|
|
371
|
+
x(
|
|
372
|
+
w(z),
|
|
118
373
|
{
|
|
119
374
|
ref_key: "popperTriggerEl",
|
|
120
|
-
ref:
|
|
375
|
+
ref: o
|
|
121
376
|
},
|
|
122
377
|
{
|
|
123
|
-
default:
|
|
124
|
-
|
|
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
|
-
(
|
|
133
|
-
|
|
134
|
-
default:
|
|
135
|
-
|
|
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:
|
|
141
|
-
class:
|
|
142
|
-
style:
|
|
395
|
+
ref: l,
|
|
396
|
+
class: W(["mc-mention", n.menuClass]),
|
|
397
|
+
style: H(w(a))
|
|
143
398
|
},
|
|
144
399
|
[
|
|
145
|
-
|
|
400
|
+
k(n.$slots, "menu", {}, void 0, !0)
|
|
146
401
|
],
|
|
147
402
|
6
|
|
148
403
|
/* CLASS, STYLE */
|
|
149
|
-
)) :
|
|
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
|
-
}),
|
|
161
|
-
const
|
|
162
|
-
for (const [
|
|
163
|
-
|
|
164
|
-
return
|
|
165
|
-
},
|
|
166
|
-
|
|
167
|
-
|
|
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
|
-
|
|
425
|
+
_ as McMention
|
|
171
426
|
};
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import type { ExtractPropTypes, PropType } from 'vue';
|
|
2
|
-
|
|
3
|
-
|
|
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
|
};
|