@matechat/core 1.11.1 → 1.12.0-alpha.2
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 +276 -146
- package/Bubble/useBubbleFoundation.d.ts +9 -0
- package/FileList/index.js +1 -1
- package/Header/index.css +1 -1
- package/Header/index.js +11 -11
- package/Input/components/EditableBlock.vue.d.ts +2 -2
- package/Input/index.css +1 -1
- package/Input/index.js +82 -57
- package/Introduction/index.css +1 -1
- package/Introduction/index.js +129 -39
- package/Layout/index.js +6 -6
- package/List/index.js +5 -5
- 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 +545 -361
- 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 +364 -110
- package/Mention/mention-types.d.ts +6 -4
- package/Mention/use-mention.d.ts +7 -0
- package/Prompt/index.js +1 -1
- 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 +2 -2
- package/mate-chat.js +2 -1
- package/package.json +1 -1
- 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,20 +1,6 @@
|
|
|
1
|
+
import { type ActionItem, ToolbarAction } from '@matechat/common/Toolbar/common/toolbar.types';
|
|
1
2
|
import type { PropType } from 'vue';
|
|
2
|
-
export
|
|
3
|
-
COPY = "copy",
|
|
4
|
-
LIKE = "like",
|
|
5
|
-
DISLIKE = "dislike",
|
|
6
|
-
REFRESH = "refresh",
|
|
7
|
-
SHARE = "share",
|
|
8
|
-
DELETE = "delete"
|
|
9
|
-
}
|
|
10
|
-
export interface ActionItem {
|
|
11
|
-
key: string;
|
|
12
|
-
icon?: ToolbarAction;
|
|
13
|
-
label?: string;
|
|
14
|
-
onClick?: (actionItem: ActionItem, e: MouseEvent) => void;
|
|
15
|
-
isActive?: boolean;
|
|
16
|
-
text?: string;
|
|
17
|
-
}
|
|
3
|
+
export { ToolbarAction, type ActionItem };
|
|
18
4
|
export declare const ToolbarProps: {
|
|
19
5
|
items: {
|
|
20
6
|
type: PropType<ActionItem[]>;
|
|
@@ -30,16 +16,6 @@ export declare const ToolbarProps: {
|
|
|
30
16
|
};
|
|
31
17
|
};
|
|
32
18
|
export type ToolbarEmits = (e: 'onClick', actionItem: ActionItem, event: MouseEvent) => void;
|
|
33
|
-
export declare const ActionItemProps: {
|
|
34
|
-
size: {
|
|
35
|
-
type: NumberConstructor;
|
|
36
|
-
default: number;
|
|
37
|
-
};
|
|
38
|
-
configData: {
|
|
39
|
-
type: PropType<ActionItem>;
|
|
40
|
-
required: boolean;
|
|
41
|
-
};
|
|
42
|
-
};
|
|
43
19
|
export declare const IconComponentProps: {
|
|
44
20
|
width: {
|
|
45
21
|
type: NumberConstructor;
|
package/index.d.ts
CHANGED
|
@@ -10,8 +10,8 @@ import { useMcI18n, McLocale } from './Locale';
|
|
|
10
10
|
import { McMarkdownCard } from './MarkdownCard';
|
|
11
11
|
import { McMention } from './Mention';
|
|
12
12
|
import { McPrompt } from './Prompt';
|
|
13
|
-
import { McToolbar, McCopyIcon, McDeleteIcon, McLikeIcon, McRefreshIcon, McShareIcon } from './Toolbar';
|
|
14
|
-
export { McAttachment, McBubble, McFileList, McHeader, McInput, McIntroduction, McLayoutAside, McLayoutContent, McLayoutHeader, McLayout, McLayoutSender, McList, useMcI18n, McLocale, McMarkdownCard, McMention, McPrompt, McToolbar, McCopyIcon, McDeleteIcon, McLikeIcon, McRefreshIcon, McShareIcon };
|
|
13
|
+
import { McToolbar, McCopyIcon, McDeleteIcon, McLikeIcon, McDislikeIcon, McRefreshIcon, McShareIcon } from './Toolbar';
|
|
14
|
+
export { McAttachment, McBubble, McFileList, McHeader, McInput, McIntroduction, McLayoutAside, McLayoutContent, McLayoutHeader, McLayout, McLayoutSender, McList, useMcI18n, McLocale, McMarkdownCard, McMention, McPrompt, McToolbar, McCopyIcon, McDeleteIcon, McLikeIcon, McDislikeIcon, McRefreshIcon, McShareIcon };
|
|
15
15
|
declare const _default: {
|
|
16
16
|
install(app: any): void;
|
|
17
17
|
};
|
package/mate-chat.js
CHANGED
|
@@ -10,7 +10,7 @@ import { useMcI18n, McLocale } from './Locale';
|
|
|
10
10
|
import { McMarkdownCard } from './MarkdownCard';
|
|
11
11
|
import { McMention } from './Mention';
|
|
12
12
|
import { McPrompt } from './Prompt';
|
|
13
|
-
import { McToolbar, McCopyIcon, McDeleteIcon, McLikeIcon, McRefreshIcon, McShareIcon } from './Toolbar';
|
|
13
|
+
import { McToolbar, McCopyIcon, McDeleteIcon, McLikeIcon, McDislikeIcon, McRefreshIcon, McShareIcon } from './Toolbar';
|
|
14
14
|
|
|
15
15
|
const installs = [
|
|
16
16
|
McAttachment,
|
|
@@ -50,6 +50,7 @@ export {
|
|
|
50
50
|
McCopyIcon,
|
|
51
51
|
McDeleteIcon,
|
|
52
52
|
McLikeIcon,
|
|
53
|
+
McDislikeIcon,
|
|
53
54
|
McRefreshIcon,
|
|
54
55
|
McShareIcon
|
|
55
56
|
};
|
package/package.json
CHANGED
package/Attachment/uploader.d.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import type { FileItem, UploadOptions } from './attachment-types';
|
|
2
|
-
interface UploaderOptions {
|
|
3
|
-
file: File;
|
|
4
|
-
fileItem: FileItem;
|
|
5
|
-
options: UploadOptions;
|
|
6
|
-
onProgress: (percentage: number) => void;
|
|
7
|
-
onSuccess: (response: unknown) => void;
|
|
8
|
-
onError: (error: unknown) => void;
|
|
9
|
-
}
|
|
10
|
-
export declare function upload(config: UploaderOptions): void;
|
|
11
|
-
export {};
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { type IWhiteList } from 'xss';
|
|
2
|
-
import type { CustomXssRule, MdPlugin } from './mdCard.types';
|
|
3
|
-
export declare class MDCardService {
|
|
4
|
-
private xssWhiteList;
|
|
5
|
-
private cssWhiteList;
|
|
6
|
-
constructor();
|
|
7
|
-
private setDefaultXss;
|
|
8
|
-
private onIgnoreTagAttr;
|
|
9
|
-
getXssWhiteList(): IWhiteList;
|
|
10
|
-
setXssWhiteList(list: IWhiteList): void;
|
|
11
|
-
setCustomXssRules(rules: CustomXssRule[]): void;
|
|
12
|
-
setMdPlugins(plugins: MdPlugin[], mdt: any): void;
|
|
13
|
-
filterHtml(html: string): string;
|
|
14
|
-
}
|
|
@@ -1,127 +0,0 @@
|
|
|
1
|
-
class h {
|
|
2
|
-
constructor(t = {}) {
|
|
3
|
-
this.config = t, this.mermaidInstance = null, this.isLoading = !1, this.lastValidResult = "", this.viewStateMap = /* @__PURE__ */ new WeakMap(), this.containerHeight = 400;
|
|
4
|
-
}
|
|
5
|
-
async loadMermaid() {
|
|
6
|
-
if (this.mermaidInstance)
|
|
7
|
-
return this.mermaidInstance;
|
|
8
|
-
if (this.isLoading)
|
|
9
|
-
return new Promise((t) => {
|
|
10
|
-
const e = () => {
|
|
11
|
-
this.mermaidInstance ? t(this.mermaidInstance) : setTimeout(e, 50);
|
|
12
|
-
};
|
|
13
|
-
e();
|
|
14
|
-
});
|
|
15
|
-
this.isLoading = !0;
|
|
16
|
-
try {
|
|
17
|
-
const { default: t } = await import("mermaid");
|
|
18
|
-
return t.initialize({
|
|
19
|
-
theme: this.config.theme || "default",
|
|
20
|
-
startOnLoad: !1,
|
|
21
|
-
suppressErrorRendering: !0,
|
|
22
|
-
...this.config
|
|
23
|
-
}), this.mermaidInstance = t, t;
|
|
24
|
-
} catch (t) {
|
|
25
|
-
throw console.error("Failed to load mermaid:", t), new Error("Failed to load mermaid library");
|
|
26
|
-
} finally {
|
|
27
|
-
this.isLoading = !1;
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
async renderToContainer(t, e, s = "light") {
|
|
31
|
-
const a = await this.renderMermaid(e, s);
|
|
32
|
-
t.innerHTML = a;
|
|
33
|
-
const i = t.querySelector("svg");
|
|
34
|
-
i && (this.initViewState(t, i), this.applyTransform(t, i), i.addEventListener("mousedown", (o) => this.onSvgMouseDown(o, t, i)));
|
|
35
|
-
}
|
|
36
|
-
initViewState(t, e) {
|
|
37
|
-
let s = e.getAttribute("viewBox"), a = 0, i = 0;
|
|
38
|
-
if (s) {
|
|
39
|
-
const l = s.split(/\s+/);
|
|
40
|
-
a = parseFloat(l[2]), i = parseFloat(l[3]);
|
|
41
|
-
} else
|
|
42
|
-
a = e.width.baseVal.value || e.getBoundingClientRect().width, i = e.height.baseVal.value || e.getBoundingClientRect().height;
|
|
43
|
-
const o = t.clientWidth || 0, r = this.containerHeight;
|
|
44
|
-
let n = 1;
|
|
45
|
-
a && i && o && r && (n = Math.min(o / a, r / i, 1)), this.viewStateMap.set(t, {
|
|
46
|
-
scale: n,
|
|
47
|
-
offsetX: 0,
|
|
48
|
-
offsetY: 0,
|
|
49
|
-
dragging: !1,
|
|
50
|
-
dragStart: { x: 0, y: 0 },
|
|
51
|
-
lastOffset: { x: 0, y: 0 }
|
|
52
|
-
});
|
|
53
|
-
}
|
|
54
|
-
applyTransform(t, e) {
|
|
55
|
-
const s = this.viewStateMap.get(t);
|
|
56
|
-
s && (e.style.position = "absolute", e.style.left = "50%", e.style.top = "50%", e.style.transform = `translate(-50%, -50%) translate(${s.offsetX}px, ${s.offsetY}px) scale(${s.scale})`, e.style.transformOrigin = "center center", e.style.cursor = s.dragging ? "grabbing" : "grab");
|
|
57
|
-
}
|
|
58
|
-
zoomIn(t) {
|
|
59
|
-
const e = t.querySelector("svg"), s = this.viewStateMap.get(t);
|
|
60
|
-
e && s && (s.scale = Math.min(s.scale + 0.2, 3), this.applyTransform(t, e));
|
|
61
|
-
}
|
|
62
|
-
zoomOut(t) {
|
|
63
|
-
const e = t.querySelector("svg"), s = this.viewStateMap.get(t);
|
|
64
|
-
e && s && (s.scale = Math.max(s.scale - 0.2, 0.2), this.applyTransform(t, e));
|
|
65
|
-
}
|
|
66
|
-
reset(t) {
|
|
67
|
-
const e = t.querySelector("svg");
|
|
68
|
-
e && (this.initViewState(t, e), this.applyTransform(t, e));
|
|
69
|
-
}
|
|
70
|
-
async download(t, e = "diagram.png") {
|
|
71
|
-
const s = t.querySelector("svg");
|
|
72
|
-
if (s)
|
|
73
|
-
try {
|
|
74
|
-
const a = s.cloneNode(!0), i = new XMLSerializer().serializeToString(a), o = `data:image/svg+xml;charset=utf-8,${encodeURIComponent(i)}`, r = new Image();
|
|
75
|
-
await new Promise((d, m) => {
|
|
76
|
-
r.onload = () => d(), r.onerror = (c) => m(new Error("Image loading failed")), r.src = o;
|
|
77
|
-
});
|
|
78
|
-
const n = document.createElement("canvas"), l = n.getContext("2d");
|
|
79
|
-
if (!l) throw new Error("Canvas context not available");
|
|
80
|
-
n.width = r.width * 2, n.height = r.height * 2, l.fillStyle = "white", l.fillRect(0, 0, n.width, n.height), l.drawImage(r, 0, 0), n.toBlob((d) => {
|
|
81
|
-
if (!d) {
|
|
82
|
-
console.error("Failed to create blob from canvas");
|
|
83
|
-
return;
|
|
84
|
-
}
|
|
85
|
-
const m = URL.createObjectURL(d), c = document.createElement("a");
|
|
86
|
-
c.href = m, c.download = e, document.body.appendChild(c), c.click(), setTimeout(() => {
|
|
87
|
-
document.body.removeChild(c), URL.revokeObjectURL(m);
|
|
88
|
-
}, 100);
|
|
89
|
-
}, "image/png");
|
|
90
|
-
} catch (a) {
|
|
91
|
-
console.error("Failed to download diagram:", a);
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
onSvgMouseDown(t, e, s) {
|
|
95
|
-
const a = this.viewStateMap.get(e);
|
|
96
|
-
if (!a) return;
|
|
97
|
-
a.dragging = !0, a.dragStart = { x: t.clientX, y: t.clientY }, a.lastOffset = { x: a.offsetX, y: a.offsetY };
|
|
98
|
-
const i = (r) => this.onSvgMouseMove(r, e, s), o = () => this.onSvgMouseUp(e, s, i, o);
|
|
99
|
-
document.addEventListener("mousemove", i), document.addEventListener("mouseup", o), this.applyTransform(e, s);
|
|
100
|
-
}
|
|
101
|
-
onSvgMouseMove(t, e, s) {
|
|
102
|
-
const a = this.viewStateMap.get(e);
|
|
103
|
-
!a || !a.dragging || (a.offsetX = a.lastOffset.x + (t.clientX - a.dragStart.x), a.offsetY = a.lastOffset.y + (t.clientY - a.dragStart.y), this.applyTransform(e, s));
|
|
104
|
-
}
|
|
105
|
-
onSvgMouseUp(t, e, s, a) {
|
|
106
|
-
const i = this.viewStateMap.get(t);
|
|
107
|
-
i && (i.dragging = !1, document.removeEventListener("mousemove", s), document.removeEventListener("mouseup", a), this.applyTransform(t, e));
|
|
108
|
-
}
|
|
109
|
-
async renderMermaid(t, e = "light") {
|
|
110
|
-
try {
|
|
111
|
-
const s = await this.loadMermaid();
|
|
112
|
-
this.config.theme !== e && (this.config.theme = e, s.initialize({
|
|
113
|
-
startOnLoad: !1,
|
|
114
|
-
suppressErrorRendering: !0,
|
|
115
|
-
theme: e === "dark" ? "dark" : "default",
|
|
116
|
-
...this.config
|
|
117
|
-
}));
|
|
118
|
-
const a = `mc_mermaid_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`, { svg: i } = await s.render(a, t);
|
|
119
|
-
return this.lastValidResult = i, i;
|
|
120
|
-
} catch {
|
|
121
|
-
return this.lastValidResult;
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
export {
|
|
126
|
-
h as MermaidService
|
|
127
|
-
};
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import type { MermaidConfig } from './mdCard.types';
|
|
2
|
-
export declare class MermaidService {
|
|
3
|
-
private config;
|
|
4
|
-
private mermaidInstance;
|
|
5
|
-
private isLoading;
|
|
6
|
-
private lastValidResult;
|
|
7
|
-
private viewStateMap;
|
|
8
|
-
private containerHeight;
|
|
9
|
-
constructor(config?: MermaidConfig);
|
|
10
|
-
private loadMermaid;
|
|
11
|
-
renderToContainer(container: HTMLElement, code: string, theme?: 'light' | 'dark'): Promise<void>;
|
|
12
|
-
private initViewState;
|
|
13
|
-
private applyTransform;
|
|
14
|
-
zoomIn(container: HTMLElement): void;
|
|
15
|
-
zoomOut(container: HTMLElement): void;
|
|
16
|
-
reset(container: HTMLElement): void;
|
|
17
|
-
download(container: HTMLElement, filename?: string): Promise<void>;
|
|
18
|
-
private onSvgMouseDown;
|
|
19
|
-
private onSvgMouseMove;
|
|
20
|
-
private onSvgMouseUp;
|
|
21
|
-
renderMermaid(code: string, theme?: 'light' | 'dark'): Promise<string>;
|
|
22
|
-
}
|
package/Mention/const.d.ts
DELETED