wi-chat 0.6.2 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/core/index.cjs +1 -1
- package/dist/core/index.d.ts +12 -0
- package/dist/core/index.js +731 -328
- package/dist/core/useAnswerActions.d.ts +61 -0
- package/dist/core/useChat.d.ts +29 -3
- package/dist/core/useChatAuth.d.ts +96 -0
- package/dist/core/useChatRooms.d.ts +66 -0
- package/dist/core/useKeepAlive.d.ts +41 -0
- package/dist/core/useLlm.d.ts +73 -0
- package/dist/core/useRunningGroups.d.ts +58 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.js +119 -108
- package/dist/mobile-ui/chat/ChatContainer.vue.d.ts +2 -2
- package/dist/mobile-ui/inputbox/Inputbox.vue.d.ts +1 -1
- package/dist/parser/answerCom/generic/parseGeneric.d.ts +52 -0
- package/dist/parser/answerCom/generic/types.d.ts +75 -0
- package/dist/parser/answerCom/outputFile/parseOutputFile.d.ts +7 -6
- package/dist/parser/answerCom/outputFile/types.d.ts +15 -5
- package/dist/parser/answerCom/presentFiles/parsePresentFiles.d.ts +58 -0
- package/dist/parser/answerCom/presentFiles/types.d.ts +27 -0
- package/dist/parser/answerMeta.d.ts +71 -0
- package/dist/parser/deepThinking/parseDeepThinking.d.ts +8 -0
- package/dist/parser/history/history.d.ts +9 -0
- package/dist/parser/history/index.d.ts +1 -1
- package/dist/parser/index.cjs +6 -2
- package/dist/parser/index.d.ts +11 -2
- package/dist/parser/index.js +591 -366
- package/dist/parser/message.d.ts +9 -0
- package/dist/parser/runTime.d.ts +29 -0
- package/dist/renderers/TextAnswer-BgKGvG_o.cjs +2 -0
- package/dist/renderers/TextAnswer-PQwV3K7v.js +5 -0
- package/dist/renderers/answerCard/AnswerCard.vue.d.ts +65 -0
- package/dist/renderers/answerCard/AnswerToolbar.vue.d.ts +42 -0
- package/dist/renderers/answerConfig.d.ts +33 -0
- package/dist/renderers/deviceLastValue/DeviceLastValue.vue.d.ts +37 -0
- package/dist/renderers/index.cjs +6 -1
- package/dist/renderers/index.d.ts +14 -0
- package/dist/renderers/index.js +1485 -574
- package/dist/renderers/media/MediaAnswer.vue.d.ts +19 -0
- package/dist/renderers/outputFile/OutputFileLink.vue.d.ts +19 -0
- package/dist/renderers/outputFile/localFile.d.ts +46 -0
- package/dist/renderers/outputFile/useOutputFile.d.ts +32 -3
- package/dist/renderers/presentFiles/PresentFiles.vue.d.ts +19 -0
- package/dist/renderers/recordset/RecordsetView.vue.d.ts +19 -0
- package/dist/renderers/sqlQuery/SqlQuery.vue.d.ts +19 -0
- package/dist/renderers/style.css +1 -1
- package/dist/renderers/text/TextAnswer.vue.d.ts +19 -0
- package/dist/request/api.d.ts +121 -1
- package/dist/request/client.d.ts +6 -0
- package/dist/request/index.cjs +4 -2
- package/dist/request/index.d.ts +4 -2
- package/dist/request/index.js +753 -173
- package/dist/request/ws.d.ts +11 -86
- package/dist/request/wsCore.d.ts +104 -0
- package/dist/request/wsSession.d.ts +353 -0
- package/dist/right-panel/RightPanelTabs.vue.d.ts +4 -0
- package/dist/right-panel/index.cjs +1 -1
- package/dist/right-panel/index.d.ts +1 -1
- package/dist/right-panel/index.js +598 -499
- package/dist/right-panel/style.css +1 -1
- package/dist/right-panel/types.d.ts +10 -0
- package/dist/tools/index.cjs +5 -5
- package/dist/tools/index.d.ts +2 -2
- package/dist/tools/index.js +323 -208
- package/dist/tools/markdown/index.d.ts +2 -0
- package/dist/tools/markdown/interactions.d.ts +39 -0
- package/dist/tools/markdown/sanitize.d.ts +6 -0
- package/dist/tools/style.css +1 -1
- package/dist/web-ui/attach/AttachmentCard.vue.d.ts +1 -1
- package/dist/web-ui/attach/AttachmentList.vue.d.ts +1 -1
- package/dist/web-ui/chat/ChatContainer.vue.d.ts +5 -5
- package/dist/web-ui/envswitch/EnvSwitch.vue.d.ts +1 -1
- package/dist/web-ui/index.cjs +1 -1
- package/dist/web-ui/index.js +1 -1
- package/dist/web-ui/inputbox/Inputbox.vue.d.ts +5 -5
- package/dist/web-ui/style.css +1 -1
- package/package.json +2 -2
package/dist/tools/index.js
CHANGED
|
@@ -1,34 +1,49 @@
|
|
|
1
1
|
import "wi-chat/style.css";
|
|
2
|
-
import { createVNode as
|
|
3
|
-
import { resolveAttachDownloadUrl as
|
|
4
|
-
import { consumeStream as
|
|
5
|
-
import { katex as
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
|
|
9
|
-
|
|
2
|
+
import { createVNode as q, render as B, defineComponent as F, ref as O, watch as $, onMounted as N, onBeforeUnmount as G, openBlock as z, createElementBlock as J, unref as V, getCurrentInstance as Y, onUnmounted as Z, nextTick as P } from "vue";
|
|
3
|
+
import { resolveAttachDownloadUrl as W } from "wi-chat/parser";
|
|
4
|
+
import { consumeStream as Me } from "wi-chat/parser";
|
|
5
|
+
import { katex as X } from "@mdit/plugin-katex";
|
|
6
|
+
import U from "highlight.js";
|
|
7
|
+
import I from "markdown-it";
|
|
8
|
+
import K from "dompurify";
|
|
9
|
+
const A = (e) => e.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'"), Q = (e) => {
|
|
10
|
+
if (!e) return e;
|
|
11
|
+
if (typeof window > "u") return A(e);
|
|
12
|
+
try {
|
|
13
|
+
const n = K(window);
|
|
14
|
+
return !n.isSupported || !n.sanitize('<div class="wi-probe"><span>ok</span></div>').includes("wi-probe") ? A(e) : n.sanitize(e, {
|
|
15
|
+
FORCE_BODY: !0,
|
|
16
|
+
ADD_TAGS: ["style"],
|
|
17
|
+
ADD_ATTR: ["rel", "target"],
|
|
18
|
+
FORBID_TAGS: ["iframe", "object", "embed", "base", "link"]
|
|
19
|
+
});
|
|
20
|
+
} catch {
|
|
21
|
+
return A(e);
|
|
22
|
+
}
|
|
23
|
+
}, R = (e) => new I().utils.escapeHtml(e), E = (e) => R(e).replace(/"/g, """).replace(/'/g, "'"), ee = (e) => !e || e.includes("get_image_full") ? e : e.replace("get_image", "get_image_full"), j = (e) => {
|
|
24
|
+
const { langPrefix: n = "language-", imagePreview: r = !0, showCodeLang: o = !0, imageSrcResolver: s, imageDownload: i = !0, tableDownload: t = !0 } = e, l = '<button type="button" class="wi-md-table-download" title="下载 Excel" aria-label="下载表格为 Excel"><svg viewBox="0 0 24 24" width="14" height="14" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/><polyline points="7 10 12 15 17 10"/><line x1="12" y1="15" x2="12" y2="3"/></svg></button>', a = new I({
|
|
10
25
|
linkify: !0,
|
|
11
26
|
typographer: !0,
|
|
12
27
|
breaks: !0,
|
|
13
28
|
html: !0,
|
|
14
|
-
langPrefix:
|
|
29
|
+
langPrefix: n,
|
|
15
30
|
highlight: (c, u) => {
|
|
16
|
-
if (u &&
|
|
31
|
+
if (u && U.getLanguage(u))
|
|
17
32
|
try {
|
|
18
|
-
return
|
|
33
|
+
return U.highlight(c, { language: u }).value;
|
|
19
34
|
} catch {
|
|
20
|
-
return
|
|
35
|
+
return R(c);
|
|
21
36
|
}
|
|
22
|
-
return
|
|
37
|
+
return R(c);
|
|
23
38
|
}
|
|
24
|
-
}).use(
|
|
25
|
-
return
|
|
26
|
-
var
|
|
27
|
-
const
|
|
39
|
+
}).use(X, { delimiters: "dollars" });
|
|
40
|
+
return a.renderer.rules.fence = (c, u, w, k, h) => {
|
|
41
|
+
var p;
|
|
42
|
+
const b = c[u], g = b.info.trim().split(/\s+/)[0].toLowerCase(), v = ((p = w.highlight) == null ? void 0 : p.call(w, b.content, g, "")) || R(b.content);
|
|
28
43
|
return `
|
|
29
44
|
<div class="wi-md-block">
|
|
30
|
-
<div class="wi-md-block-header">
|
|
31
|
-
<div class="wi-md-block-header-left">${
|
|
45
|
+
<div class="wi-md-block-header" tabindex="0" aria-expanded="true" title="点击折叠 / 展开">
|
|
46
|
+
<div class="wi-md-block-header-left">${o && g ? `<span class="wi-md-lang">${R(g)}</span>` : ""}</div>
|
|
32
47
|
<div class="wi-md-block-header-right">
|
|
33
48
|
<button type="button" class="wi-md-copy" title="复制" aria-label="复制代码">
|
|
34
49
|
<svg viewBox="0 0 16 16" width="14" height="14" fill="currentColor"><path d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 0 1 0 1.5h-1.5a.25.25 0 0 0-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 0 0 .25-.25v-1.5a.75.75 0 0 1 1.5 0v1.5A1.75 1.75 0 0 1 9.25 16h-7.5A1.75 1.75 0 0 1 0 14.25Zm5-5C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0 1 14.25 11h-7.5A1.75 1.75 0 0 1 5 9.25Zm1.75-.25a.25.25 0 0 0-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 0 0 .25-.25v-7.5a.25.25 0 0 0-.25-.25Z"/></svg>
|
|
@@ -38,240 +53,340 @@ const C = (e) => new A().utils.escapeHtml(e), $ = (e) => C(e).replace(/"/g, "&qu
|
|
|
38
53
|
</button>
|
|
39
54
|
</div>
|
|
40
55
|
</div>
|
|
41
|
-
<pre class="wi-md-code"><code class="${
|
|
56
|
+
<pre class="wi-md-code"><code class="${w.langPrefix}${R(g)}">${v}</code></pre>
|
|
42
57
|
</div>
|
|
43
58
|
`.trim();
|
|
44
|
-
},
|
|
45
|
-
const
|
|
46
|
-
`src="${
|
|
47
|
-
`alt="${
|
|
48
|
-
|
|
59
|
+
}, a.renderer.rules.table_open = () => t ? '<div class="wi-md-table-wrap"><table class="wi-md-table">' : '<table class="wi-md-table">', a.renderer.rules.table_close = () => t ? `</table>${l}</div>` : "</table>", a.renderer.rules.ordered_list_open = (c, u, w, k, h) => (c[u].attrJoin("class", "wi-md-list wi-md-list-ordered"), h.renderToken(c, u, w)), a.renderer.rules.bullet_list_open = (c, u, w, k, h) => (c[u].attrJoin("class", "wi-md-list wi-md-list-bullet"), h.renderToken(c, u, w)), a.renderer.rules.list_item_open = (c, u, w, k, h) => (c[u].attrJoin("class", "wi-md-list-item"), h.renderToken(c, u, w)), a.renderer.rules.image = (c, u, w, k, h) => {
|
|
60
|
+
const b = c[u], g = b.attrGet("src") || "", v = b.attrGet("alt") || b.content || "", f = b.attrGet("title") || "", p = [
|
|
61
|
+
`src="${E(g)}"`,
|
|
62
|
+
`alt="${E(v)}"`,
|
|
63
|
+
f ? `title="${E(f)}"` : ""
|
|
49
64
|
].filter(Boolean).join(" ");
|
|
50
|
-
if (!
|
|
51
|
-
const
|
|
52
|
-
return `<span class="wi-md-image-wrap" data-src="${
|
|
53
|
-
},
|
|
54
|
-
},
|
|
55
|
-
let
|
|
56
|
-
const
|
|
57
|
-
const e = "data-wi-md-scope",
|
|
58
|
-
return { attr: e, id:
|
|
59
|
-
},
|
|
60
|
-
const
|
|
61
|
-
return
|
|
62
|
-
}),
|
|
63
|
-
const
|
|
64
|
-
let
|
|
65
|
-
const
|
|
66
|
-
return
|
|
65
|
+
if (!r) return `<img ${p} />`;
|
|
66
|
+
const m = s ? s(g) : ee(g), S = i ? '<span class="wi-md-image-download" title="下载图片" role="button" aria-label="下载图片"><svg viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/><polyline points="7 10 12 15 17 10"/><line x1="12" y1="15" x2="12" y2="3"/></svg></span>' : "";
|
|
67
|
+
return `<span class="wi-md-image-wrap" data-src="${E(m)}"><img ${p} loading="lazy" />${S}</span>`;
|
|
68
|
+
}, a;
|
|
69
|
+
}, te = ".wi-markdown";
|
|
70
|
+
let oe = 0;
|
|
71
|
+
const ne = () => {
|
|
72
|
+
const e = "data-wi-md-scope", n = `wi-md-scope-${++oe}`;
|
|
73
|
+
return { attr: e, id: n, selector: `[${e}="${n}"]` };
|
|
74
|
+
}, re = /^(background|padding|margin|width|height|min-width|min-height|max-width|max-height|overflow|display|position|inset|top|right|bottom|left|border|box-shadow|flex|gap|justify-content|align-items)/i, le = (e) => e.replace(/(^|[{};,])(\s*)(?:html|body|:root)(?![\w-])\s*\{([^}]*)\}/gi, (n, r, o, s) => {
|
|
75
|
+
const i = s.split(";").map((t) => t.trim()).filter((t) => t && !re.test(t)).join(";");
|
|
76
|
+
return i ? `${r}${o}:scope{${i}}` : "";
|
|
77
|
+
}), ae = (e, n) => {
|
|
78
|
+
const r = [];
|
|
79
|
+
let o = e.replace(/<style\b([^>]*)>([\s\S]*?)<\/style\s*>/gi, (s, i, t) => {
|
|
80
|
+
const l = /^\s*@scope\b/i.test(t) ? `<style${i}>${t}</style>` : `<style${i}>@scope (${n}) {${le(t)}}</style>`;
|
|
81
|
+
return r.push(l), `\0wi-md-style-${r.length - 1}\0`;
|
|
67
82
|
});
|
|
68
|
-
return
|
|
83
|
+
return o = o.replace(/<\/?style\b[^>]*>/gi, ""), o = o.replace(/<script\b[^>]*>[\s\S]*?<\/script\s*>/gi, "").replace(/<\/?script\b[^>]*>/gi, ""), o = o.replace(/<link\b[^>]*>/gi, ""), o.replace(/\u0000wi-md-style-(\d+)\u0000/g, (s, i) => r[Number(i)]);
|
|
69
84
|
};
|
|
70
|
-
let
|
|
71
|
-
const
|
|
72
|
-
const
|
|
73
|
-
return
|
|
85
|
+
let D = null;
|
|
86
|
+
const ie = () => (D || (D = j({})), D), se = (e) => (e.langPrefix === void 0 || e.langPrefix === "language-") && (e.imagePreview === void 0 || e.imagePreview) && (e.showCodeLang === void 0 || e.showCodeLang) && (e.imageDownload === void 0 || e.imageDownload) && (e.tableDownload === void 0 || e.tableDownload) && !e.imageSrcResolver, ce = (e, n = {}) => {
|
|
87
|
+
const r = se(n) ? ie() : j(n), o = ae(r.render(e), n.styleScope || te);
|
|
88
|
+
return Q(o);
|
|
74
89
|
};
|
|
75
|
-
let
|
|
76
|
-
const
|
|
77
|
-
|
|
78
|
-
},
|
|
79
|
-
|
|
80
|
-
const
|
|
81
|
-
document.body.appendChild(
|
|
82
|
-
const { ElImageViewer:
|
|
83
|
-
if (
|
|
84
|
-
const
|
|
85
|
-
urlList:
|
|
86
|
-
initialIndex: Math.min(
|
|
87
|
-
onClose:
|
|
90
|
+
let x = null;
|
|
91
|
+
const M = () => {
|
|
92
|
+
x && (B(null, x), x.remove(), x = null);
|
|
93
|
+
}, de = async (e, n, r) => {
|
|
94
|
+
M();
|
|
95
|
+
const o = n && n.length ? n.includes(e) ? n : [e, ...n.filter((a) => a !== e)] : [e], s = Math.max(r ?? o.indexOf(e), 0), i = document.createElement("div");
|
|
96
|
+
document.body.appendChild(i), x = i;
|
|
97
|
+
const { ElImageViewer: t } = await import("element-plus");
|
|
98
|
+
if (x !== i) return;
|
|
99
|
+
const l = q(t, {
|
|
100
|
+
urlList: o,
|
|
101
|
+
initialIndex: Math.min(s, o.length - 1),
|
|
102
|
+
onClose: M,
|
|
88
103
|
hideOnClickModal: !0,
|
|
89
104
|
teleported: !0
|
|
90
105
|
});
|
|
91
|
-
|
|
92
|
-
},
|
|
93
|
-
fetch(e).then((
|
|
94
|
-
var
|
|
95
|
-
const
|
|
96
|
-
|
|
106
|
+
B(l, i);
|
|
107
|
+
}, ue = (e) => {
|
|
108
|
+
fetch(e).then((n) => n.blob()).then((n) => {
|
|
109
|
+
var s;
|
|
110
|
+
const r = URL.createObjectURL(n), o = document.createElement("a");
|
|
111
|
+
o.href = r, o.download = ((s = e.split("/").pop()) == null ? void 0 : s.split("?")[0]) || "image", document.body.appendChild(o), o.click(), document.body.removeChild(o), URL.revokeObjectURL(r);
|
|
97
112
|
}).catch(() => {
|
|
98
|
-
const
|
|
99
|
-
|
|
113
|
+
const n = document.createElement("a");
|
|
114
|
+
n.href = e, n.download = "", n.target = "_blank", document.body.appendChild(n), n.click(), document.body.removeChild(n);
|
|
100
115
|
});
|
|
101
|
-
},
|
|
116
|
+
}, me = async (e, n) => {
|
|
117
|
+
try {
|
|
118
|
+
const r = await import("xlsx"), o = r.utils.table_to_sheet(e), s = r.utils.book_new();
|
|
119
|
+
r.utils.book_append_sheet(s, o, "查询结果");
|
|
120
|
+
const i = r.write(s, { bookType: "xlsx", type: "array" }), t = new Blob([i], { type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" }), l = URL.createObjectURL(t), a = document.createElement("a");
|
|
121
|
+
a.href = l, a.download = `${n || "表格"}_${(/* @__PURE__ */ new Date()).toISOString().slice(0, 10)}.xlsx`, document.body.appendChild(a), a.click(), document.body.removeChild(a), URL.revokeObjectURL(l);
|
|
122
|
+
} catch (r) {
|
|
123
|
+
console.error("[downloadTableAsExcel] 表格导出 Excel 失败:", r);
|
|
124
|
+
}
|
|
125
|
+
}, fe = async (e) => {
|
|
126
|
+
var i;
|
|
127
|
+
if ((i = navigator.clipboard) != null && i.writeText)
|
|
128
|
+
try {
|
|
129
|
+
await navigator.clipboard.writeText(e);
|
|
130
|
+
return;
|
|
131
|
+
} catch {
|
|
132
|
+
}
|
|
133
|
+
if (typeof document.execCommand != "function")
|
|
134
|
+
throw new Error("当前环境不支持复制");
|
|
135
|
+
const n = /iP(ad|hone|od)/.test(navigator.userAgent), r = document.createElement("textarea");
|
|
136
|
+
r.value = e, r.setAttribute("readonly", ""), r.style.cssText = "position:fixed;top:0;left:0;width:1px;height:1px;padding:0;border:0;opacity:0;", document.body.appendChild(r);
|
|
137
|
+
const o = document.getSelection(), s = o && o.rangeCount > 0 ? o.getRangeAt(0) : null;
|
|
102
138
|
try {
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
139
|
+
if (n) {
|
|
140
|
+
r.contentEditable = "true", r.readOnly = !1;
|
|
141
|
+
const t = document.createRange();
|
|
142
|
+
t.selectNodeContents(r), o == null || o.removeAllRanges(), o == null || o.addRange(t), r.setSelectionRange(0, e.length);
|
|
143
|
+
} else
|
|
144
|
+
r.select();
|
|
145
|
+
if (r.focus(), !document.execCommand("copy"))
|
|
146
|
+
throw new Error("浏览器拒绝复制");
|
|
147
|
+
} finally {
|
|
148
|
+
r.remove(), s && o && (o.removeAllRanges(), o.addRange(s));
|
|
109
149
|
}
|
|
110
|
-
},
|
|
150
|
+
}, pe = (e, n = {}) => {
|
|
151
|
+
if (!e) return () => {
|
|
152
|
+
};
|
|
153
|
+
const r = (t, l) => {
|
|
154
|
+
const a = l ? "wi-md-copied" : "wi-md-copy-failed";
|
|
155
|
+
t.classList.remove("wi-md-copied", "wi-md-copy-failed"), t.classList.add(a), t.title = l ? "已复制" : "复制失败,请手动选择代码复制", window.setTimeout(() => {
|
|
156
|
+
t.classList.remove(a), t.title = "复制";
|
|
157
|
+
}, 1500);
|
|
158
|
+
}, o = (t) => {
|
|
159
|
+
const l = t.classList.toggle("wi-md-collapsed"), a = t.querySelector(":scope > .wi-md-block-header"), c = t.querySelector(".wi-md-toggle");
|
|
160
|
+
a && (a.setAttribute("aria-expanded", String(!l)), a.title = l ? "点击展开" : "点击折叠"), c && (c.title = l ? "展开" : "折叠", c.setAttribute("aria-label", l ? "展开代码块" : "折叠代码块"));
|
|
161
|
+
}, s = (t) => {
|
|
162
|
+
var b, g, v, f, p;
|
|
163
|
+
if (t.defaultPrevented) return;
|
|
164
|
+
const l = t.target;
|
|
165
|
+
if (!(l instanceof Element)) return;
|
|
166
|
+
const a = l.closest(".wi-md-copy");
|
|
167
|
+
if (a) {
|
|
168
|
+
t.preventDefault(), t.stopPropagation();
|
|
169
|
+
const m = ((g = (b = a.closest(".wi-md-block")) == null ? void 0 : b.querySelector(".wi-md-code code")) == null ? void 0 : g.textContent) || "";
|
|
170
|
+
fe(m).then(() => r(a, !0)).catch(() => r(a, !1));
|
|
171
|
+
return;
|
|
172
|
+
}
|
|
173
|
+
const c = l.closest(".wi-md-toggle");
|
|
174
|
+
if (c) {
|
|
175
|
+
t.preventDefault();
|
|
176
|
+
const m = c.closest(".wi-md-block");
|
|
177
|
+
m && o(m);
|
|
178
|
+
return;
|
|
179
|
+
}
|
|
180
|
+
const u = l.closest(".wi-md-block-header");
|
|
181
|
+
if (u) {
|
|
182
|
+
t.preventDefault();
|
|
183
|
+
const m = u.closest(".wi-md-block");
|
|
184
|
+
m && o(m);
|
|
185
|
+
return;
|
|
186
|
+
}
|
|
187
|
+
const w = l.closest(".wi-md-image-download");
|
|
188
|
+
if (w) {
|
|
189
|
+
t.preventDefault(), t.stopPropagation();
|
|
190
|
+
const m = (v = w.closest(".wi-md-image-wrap")) == null ? void 0 : v.dataset.src;
|
|
191
|
+
m && ue(m);
|
|
192
|
+
return;
|
|
193
|
+
}
|
|
194
|
+
const k = l.closest(".wi-md-table-download");
|
|
195
|
+
if (k) {
|
|
196
|
+
t.preventDefault(), t.stopPropagation();
|
|
197
|
+
const m = (f = k.closest(".wi-md-table-wrap")) == null ? void 0 : f.querySelector("table");
|
|
198
|
+
m && me(m);
|
|
199
|
+
return;
|
|
200
|
+
}
|
|
201
|
+
const h = l.closest(".wi-md-image-wrap img");
|
|
202
|
+
if (h) {
|
|
203
|
+
t.preventDefault();
|
|
204
|
+
const m = h.closest(".wi-md-image-wrap"), S = (m == null ? void 0 : m.dataset.src) || h.src || "";
|
|
205
|
+
if (!S) return;
|
|
206
|
+
const _ = ((p = n.imageRoot) == null ? void 0 : p.call(n)) ?? e, C = Array.from(_.querySelectorAll(".wi-md-image-wrap")).map((T) => {
|
|
207
|
+
var d;
|
|
208
|
+
return T.dataset.src || ((d = T.querySelector("img")) == null ? void 0 : d.getAttribute("src")) || "";
|
|
209
|
+
}).filter(Boolean);
|
|
210
|
+
de(S, C.length > 1 ? C : void 0, C.indexOf(S));
|
|
211
|
+
}
|
|
212
|
+
};
|
|
213
|
+
e.addEventListener("click", s);
|
|
214
|
+
const i = (t) => {
|
|
215
|
+
if (t.key !== "Enter" && t.key !== " ") return;
|
|
216
|
+
const l = t.target;
|
|
217
|
+
if (!(l instanceof Element) || l.closest(".wi-md-copy, .wi-md-toggle")) return;
|
|
218
|
+
const a = l.closest(".wi-md-block-header");
|
|
219
|
+
if (!a) return;
|
|
220
|
+
t.preventDefault();
|
|
221
|
+
const c = a.closest(".wi-md-block");
|
|
222
|
+
c && o(c);
|
|
223
|
+
};
|
|
224
|
+
return e.addEventListener("keydown", i), () => {
|
|
225
|
+
e.removeEventListener("click", s), e.removeEventListener("keydown", i);
|
|
226
|
+
};
|
|
227
|
+
}, we = ["data-wi-md-scope", "innerHTML"], ge = 120, he = 3, Ae = /* @__PURE__ */ F({
|
|
111
228
|
__name: "MarkdownContent",
|
|
112
229
|
props: {
|
|
113
230
|
source: { default: "" },
|
|
114
231
|
renderOptions: { default: () => ({}) }
|
|
115
232
|
},
|
|
116
233
|
setup(e) {
|
|
117
|
-
const
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
if (c) {
|
|
129
|
-
a.preventDefault();
|
|
130
|
-
const w = ((p = (h = c.closest(".wi-md-block")) == null ? void 0 : h.querySelector(".wi-md-code code")) == null ? void 0 : p.textContent) || "";
|
|
131
|
-
l(c, w);
|
|
132
|
-
return;
|
|
133
|
-
}
|
|
134
|
-
const u = i.closest(".wi-md-toggle");
|
|
135
|
-
if (u) {
|
|
136
|
-
a.preventDefault(), (y = u.closest(".wi-md-block")) == null || y.classList.toggle("wi-md-collapsed");
|
|
137
|
-
return;
|
|
138
|
-
}
|
|
139
|
-
const m = i.closest(".wi-md-image-download");
|
|
140
|
-
if (m) {
|
|
141
|
-
a.preventDefault(), a.stopPropagation();
|
|
142
|
-
const w = (k = m.closest(".wi-md-image-wrap")) == null ? void 0 : k.dataset.src;
|
|
143
|
-
w && se(w);
|
|
144
|
-
return;
|
|
145
|
-
}
|
|
146
|
-
const b = i.closest(".wi-md-table-download");
|
|
147
|
-
if (b) {
|
|
148
|
-
a.preventDefault(), a.stopPropagation();
|
|
149
|
-
const w = (v = b.closest(".wi-md-table-wrap")) == null ? void 0 : v.querySelector("table");
|
|
150
|
-
w && ie(w);
|
|
151
|
-
return;
|
|
152
|
-
}
|
|
153
|
-
const f = i.closest(".wi-md-image-wrap img");
|
|
154
|
-
if (f) {
|
|
155
|
-
a.preventDefault();
|
|
156
|
-
const w = f.closest(".wi-md-image-wrap"), x = (w == null ? void 0 : w.dataset.src) || f.src || "";
|
|
157
|
-
if (!x) return;
|
|
158
|
-
const L = Array.from(((S = o.value) == null ? void 0 : S.querySelectorAll(".wi-md-image-wrap")) ?? []).map((T) => {
|
|
159
|
-
var s;
|
|
160
|
-
return T.dataset.src || ((s = T.querySelector("img")) == null ? void 0 : s.getAttribute("src")) || "";
|
|
161
|
-
}).filter(Boolean);
|
|
162
|
-
ce(x, L.length > 1 ? L : void 0, L.indexOf(x));
|
|
163
|
-
}
|
|
234
|
+
const n = e, r = O(), o = ne(), s = O("");
|
|
235
|
+
let i = "", t = 0, l = 0, a = null;
|
|
236
|
+
const c = () => {
|
|
237
|
+
const f = performance.now();
|
|
238
|
+
s.value = ce(n.source, { ...n.renderOptions, styleScope: o.selector }), l = performance.now() - f, t = performance.now();
|
|
239
|
+
}, u = () => {
|
|
240
|
+
a !== null && (clearTimeout(a), a = null);
|
|
241
|
+
}, w = (f) => {
|
|
242
|
+
a === null && (a = setTimeout(() => {
|
|
243
|
+
a = null, c();
|
|
244
|
+
}, f));
|
|
164
245
|
};
|
|
165
|
-
|
|
246
|
+
$(
|
|
247
|
+
() => n.source,
|
|
248
|
+
(f) => {
|
|
249
|
+
const p = f.length >= i.length && f.startsWith(i);
|
|
250
|
+
if (i = f, !s.value || !p) {
|
|
251
|
+
u(), c();
|
|
252
|
+
return;
|
|
253
|
+
}
|
|
254
|
+
const m = performance.now() - t, S = Math.max(ge, l * he - m);
|
|
255
|
+
w(Math.max(0, S));
|
|
256
|
+
},
|
|
257
|
+
{ immediate: !0 }
|
|
258
|
+
);
|
|
259
|
+
const k = /* @__PURE__ */ new WeakMap();
|
|
260
|
+
let h = 0;
|
|
261
|
+
const b = (f) => {
|
|
262
|
+
let p = k.get(f);
|
|
263
|
+
return p === void 0 && (p = ++h, k.set(f, p)), p;
|
|
264
|
+
}, g = (f) => f ? Object.keys(f).sort().map((p) => {
|
|
265
|
+
const m = f[p];
|
|
266
|
+
return typeof m == "function" ? `${p}=fn:${b(m)}` : `${p}=${JSON.stringify(m)}`;
|
|
267
|
+
}).join("|") : "";
|
|
268
|
+
$(
|
|
269
|
+
() => g(n.renderOptions),
|
|
270
|
+
() => {
|
|
271
|
+
u(), c();
|
|
272
|
+
}
|
|
273
|
+
);
|
|
274
|
+
let v;
|
|
275
|
+
return N(() => {
|
|
276
|
+
v = pe(r.value, { imageRoot: () => r.value });
|
|
277
|
+
}), G(() => {
|
|
278
|
+
u(), v == null || v(), M();
|
|
279
|
+
}), (f, p) => (z(), J("div", {
|
|
166
280
|
ref_key: "rootEl",
|
|
167
|
-
ref:
|
|
281
|
+
ref: r,
|
|
168
282
|
class: "wi-markdown",
|
|
169
|
-
"data-wi-md-scope":
|
|
170
|
-
innerHTML:
|
|
171
|
-
|
|
172
|
-
}, null, 8, de));
|
|
283
|
+
"data-wi-md-scope": V(o).id,
|
|
284
|
+
innerHTML: s.value
|
|
285
|
+
}, null, 8, we));
|
|
173
286
|
}
|
|
174
|
-
}),
|
|
175
|
-
await
|
|
176
|
-
},
|
|
287
|
+
}), be = 48, ve = 48, ye = async () => {
|
|
288
|
+
await P(), await new Promise((e) => requestAnimationFrame(() => e()));
|
|
289
|
+
}, ke = (e) => {
|
|
177
290
|
typeof requestAnimationFrame == "function" ? requestAnimationFrame(e) : setTimeout(e, 0);
|
|
178
|
-
},
|
|
179
|
-
const
|
|
180
|
-
let
|
|
181
|
-
const
|
|
182
|
-
const
|
|
183
|
-
if (!
|
|
184
|
-
const
|
|
185
|
-
|
|
186
|
-
const H =
|
|
187
|
-
|
|
188
|
-
},
|
|
189
|
-
|
|
190
|
-
|
|
291
|
+
}, Ee = (e) => {
|
|
292
|
+
const n = O(!1), r = O(!0);
|
|
293
|
+
let o, s, i, t = !1, l = 0, a, c = { preserveScroll: !0 }, u = !1, w = !1;
|
|
294
|
+
const k = (d) => d.scrollHeight - d.scrollTop - d.clientHeight <= be, h = (d) => d.scrollTop <= ve, b = (d) => {
|
|
295
|
+
const y = e.value;
|
|
296
|
+
if (!y) return;
|
|
297
|
+
const L = y.scrollHeight > l;
|
|
298
|
+
l = y.scrollHeight, d && L && r.value && (y.scrollTop = y.scrollHeight);
|
|
299
|
+
const H = k(y);
|
|
300
|
+
r.value = H, n.value = !H;
|
|
301
|
+
}, g = () => b(!1), v = () => {
|
|
302
|
+
t || (t = !0, ke(() => {
|
|
303
|
+
t = !1, b(!0);
|
|
191
304
|
}));
|
|
192
|
-
},
|
|
193
|
-
|
|
194
|
-
},
|
|
195
|
-
await
|
|
196
|
-
const
|
|
197
|
-
|
|
198
|
-
},
|
|
199
|
-
if (!
|
|
200
|
-
|
|
305
|
+
}, f = () => {
|
|
306
|
+
o == null || o(), o = void 0, s == null || s.disconnect(), s = void 0, i == null || i.disconnect(), i = void 0;
|
|
307
|
+
}, p = async () => {
|
|
308
|
+
await ye();
|
|
309
|
+
const d = e.value;
|
|
310
|
+
d && (d.scrollTop = d.scrollHeight, l = d.scrollHeight, r.value = !0, n.value = !1);
|
|
311
|
+
}, m = async () => {
|
|
312
|
+
if (!r.value) {
|
|
313
|
+
n.value = !0;
|
|
201
314
|
return;
|
|
202
315
|
}
|
|
203
|
-
await
|
|
204
|
-
},
|
|
205
|
-
const
|
|
206
|
-
|
|
207
|
-
},
|
|
208
|
-
const
|
|
316
|
+
await p();
|
|
317
|
+
}, S = () => {
|
|
318
|
+
const d = e.value;
|
|
319
|
+
d && (d.scrollTop = 0), l = 0, r.value = !0, n.value = !1, w = !1, u = !1;
|
|
320
|
+
}, _ = async (d) => {
|
|
321
|
+
const y = e.value, L = y ? y.scrollHeight : 0;
|
|
209
322
|
try {
|
|
210
|
-
await
|
|
323
|
+
await d();
|
|
211
324
|
} finally {
|
|
212
|
-
await
|
|
325
|
+
await P(), e.value && L && (e.value.scrollTop += e.value.scrollHeight - L, l = e.value.scrollHeight);
|
|
213
326
|
}
|
|
214
|
-
},
|
|
215
|
-
|
|
327
|
+
}, C = (d, y = { preserveScroll: !0 }) => {
|
|
328
|
+
a = d, c = y;
|
|
216
329
|
}, T = async () => {
|
|
217
|
-
const
|
|
218
|
-
if (!
|
|
219
|
-
const
|
|
220
|
-
if (
|
|
221
|
-
|
|
330
|
+
const d = e.value;
|
|
331
|
+
if (!d || (g(), !a || u)) return;
|
|
332
|
+
const y = h(d);
|
|
333
|
+
if (y && !w) {
|
|
334
|
+
w = !0, u = !0;
|
|
222
335
|
try {
|
|
223
|
-
(c == null ? void 0 : c.preserveScroll) !== !1 ? await
|
|
336
|
+
(c == null ? void 0 : c.preserveScroll) !== !1 ? await _(a) : await a();
|
|
224
337
|
} finally {
|
|
225
|
-
u = !1,
|
|
338
|
+
u = !1, h(d) || (w = !1);
|
|
226
339
|
}
|
|
227
|
-
} else
|
|
340
|
+
} else y || (w = !1);
|
|
228
341
|
};
|
|
229
|
-
return
|
|
342
|
+
return $(
|
|
230
343
|
e,
|
|
231
|
-
(
|
|
232
|
-
|
|
344
|
+
(d) => {
|
|
345
|
+
f(), d && (d.addEventListener("scroll", T, { passive: !0 }), o = () => d.removeEventListener("scroll", T), typeof MutationObserver < "u" && (s = new MutationObserver(v), s.observe(d, { childList: !0, subtree: !0, characterData: !0 })), typeof ResizeObserver < "u" && (i = new ResizeObserver(v), i.observe(d)), l = 0, g());
|
|
233
346
|
},
|
|
234
347
|
{ immediate: !0, flush: "post" }
|
|
235
|
-
),
|
|
236
|
-
showScrollToBottom:
|
|
237
|
-
forceScrollToBottom:
|
|
238
|
-
requestScrollToBottom:
|
|
239
|
-
syncScrollState:
|
|
240
|
-
resetScrollState:
|
|
241
|
-
onReachTop:
|
|
242
|
-
preserveScrollPosition:
|
|
348
|
+
), Y() && Z(() => f()), {
|
|
349
|
+
showScrollToBottom: n,
|
|
350
|
+
forceScrollToBottom: p,
|
|
351
|
+
requestScrollToBottom: m,
|
|
352
|
+
syncScrollState: g,
|
|
353
|
+
resetScrollState: S,
|
|
354
|
+
onReachTop: C,
|
|
355
|
+
preserveScrollPosition: _
|
|
243
356
|
};
|
|
244
|
-
},
|
|
357
|
+
}, Oe = async (e, n = {}) => {
|
|
245
358
|
if (typeof window > "u" || typeof document > "u") return;
|
|
246
|
-
const
|
|
247
|
-
if (
|
|
248
|
-
const
|
|
249
|
-
|
|
359
|
+
const r = e.attachContent || {}, o = e.name || r.file_name || "download";
|
|
360
|
+
if (r.raw) {
|
|
361
|
+
const i = URL.createObjectURL(r.raw), t = document.createElement("a");
|
|
362
|
+
t.href = i, t.download = o, document.body.appendChild(t), t.click(), document.body.removeChild(t), URL.revokeObjectURL(i);
|
|
250
363
|
return;
|
|
251
364
|
}
|
|
252
|
-
if (!
|
|
253
|
-
const
|
|
254
|
-
if (
|
|
365
|
+
if (!r.fileId) return;
|
|
366
|
+
const s = W(r.fileId, n.baseURL, n.getFileUrl);
|
|
367
|
+
if (s)
|
|
255
368
|
try {
|
|
256
|
-
const
|
|
257
|
-
if (!
|
|
258
|
-
const
|
|
259
|
-
|
|
260
|
-
} catch (
|
|
261
|
-
console.error("[downloadAttachment] fetch blob 失败,降级为直接链接触发:",
|
|
262
|
-
const
|
|
263
|
-
|
|
369
|
+
const i = await fetch(s, { credentials: "include" });
|
|
370
|
+
if (!i.ok) throw new Error(`Download failed with status ${i.status}`);
|
|
371
|
+
const t = URL.createObjectURL(await i.blob()), l = document.createElement("a");
|
|
372
|
+
l.href = t, l.download = o, document.body.appendChild(l), l.click(), document.body.removeChild(l), URL.revokeObjectURL(t);
|
|
373
|
+
} catch (i) {
|
|
374
|
+
console.error("[downloadAttachment] fetch blob 失败,降级为直接链接触发:", i);
|
|
375
|
+
const t = document.createElement("a");
|
|
376
|
+
t.href = s, t.download = o, document.body.appendChild(t), t.click(), document.body.removeChild(t);
|
|
264
377
|
}
|
|
265
378
|
};
|
|
266
379
|
export {
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
380
|
+
Ae as MarkdownContent,
|
|
381
|
+
pe as bindMarkdownInteractions,
|
|
382
|
+
M as closeImagePreview,
|
|
383
|
+
Me as consumeStream,
|
|
384
|
+
ne as createStyleScope,
|
|
385
|
+
Oe as downloadAttachment,
|
|
386
|
+
me as downloadTableAsExcel,
|
|
387
|
+
de as openImagePreview,
|
|
388
|
+
ce as renderMarkdown,
|
|
389
|
+
Ee as useAutoScroll,
|
|
390
|
+
fe as writeClipboard
|
|
276
391
|
};
|
|
277
392
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
export { renderMarkdown, createStyleScope } from './renderMarkdown';
|
|
2
2
|
export type { MarkdownRenderOptions } from './renderMarkdown';
|
|
3
|
+
export { bindMarkdownInteractions, writeClipboard } from './interactions';
|
|
4
|
+
export type { BindMarkdownInteractionsOptions } from './interactions';
|
|
3
5
|
export { default as MarkdownContent } from './MarkdownContent.vue';
|
|
4
6
|
export { openImagePreview, closeImagePreview } from './imagePreview';
|
|
5
7
|
export { downloadTableAsExcel } from './tableDownload';
|