@ibiz-template/vue3-components 0.7.41-alpha.41 → 0.7.41-alpha.43
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/ibiz-markdown-editor-DJ662N4_.js +1 -0
- package/dist/{index-CaWTEUU1.js → index-CG3sQH0b.js} +1 -1
- package/dist/index-D3x_MFr-.js +11 -0
- package/dist/{index-CD2XM6M6.js → index-kZrZndeH.js} +1 -1
- package/dist/index.min.css +1 -1
- package/dist/index.system.min.js +1 -1
- package/dist/wang-editor-DDSO3Ha9.js +1 -0
- package/dist/{xlsx-util-Dvg2kWh7.js → xlsx-util-8YSXhmdI.js} +1 -1
- package/es/control/form/form-detail/form-item/composite-form-item-ex/composite-form-item-ex.controller.mjs +16 -6
- package/es/control/toolbar/export-excel/export-excel.mjs +19 -4
- package/es/editor/code/monaco-editor/monaco-editor.mjs +13 -195
- package/es/editor/html/wang-editor/module/ai-module.mjs +1 -1
- package/es/editor/html/wang-editor/wang-editor.mjs +31 -202
- package/es/editor/markdown/ibiz-markdown-editor/custom-menu.mjs +16 -223
- package/es/editor/markdown/ibiz-markdown-editor/ibiz-markdown-editor.css +1 -1
- package/es/editor/markdown/ibiz-markdown-editor/ibiz-markdown-editor.mjs +2 -1
- package/es/editor/text-box/input/input.mjs +9 -197
- package/es/locale/en/index.mjs +24 -1
- package/es/locale/zh-CN/index.mjs +24 -1
- package/es/panel-component/panel-app-title/panel-app-title.mjs +19 -42
- package/es/util/ai-chat-util/ai-chat-util.mjs +644 -15
- package/es/util/ai-chat-util/ai-feedback/ai-feedback.css +1 -0
- package/es/util/ai-chat-util/ai-feedback/ai-feedback.mjs +130 -0
- package/es/util/app-util/app-util.mjs +24 -246
- package/es/util/inline-ai-util/inline-ai-textarea/inline-ai-textarea.hook.mjs +12 -4
- package/es/util/inline-ai-util/inline-ai-textarea/inline-ai-textarea.mjs +3 -1
- package/lib/control/form/form-detail/form-item/composite-form-item-ex/composite-form-item-ex.controller.cjs +16 -6
- package/lib/control/toolbar/export-excel/export-excel.cjs +18 -3
- package/lib/editor/code/monaco-editor/monaco-editor.cjs +13 -195
- package/lib/editor/html/wang-editor/module/ai-module.cjs +1 -1
- package/lib/editor/html/wang-editor/wang-editor.cjs +30 -201
- package/lib/editor/markdown/ibiz-markdown-editor/custom-menu.cjs +16 -223
- package/lib/editor/markdown/ibiz-markdown-editor/ibiz-markdown-editor.cjs +2 -1
- package/lib/editor/markdown/ibiz-markdown-editor/ibiz-markdown-editor.css +1 -1
- package/lib/editor/text-box/input/input.cjs +8 -196
- package/lib/locale/en/index.cjs +24 -1
- package/lib/locale/zh-CN/index.cjs +24 -1
- package/lib/panel-component/panel-app-title/panel-app-title.cjs +18 -41
- package/lib/util/ai-chat-util/ai-chat-util.cjs +642 -13
- package/lib/util/ai-chat-util/ai-feedback/ai-feedback.cjs +132 -0
- package/lib/util/ai-chat-util/ai-feedback/ai-feedback.css +1 -0
- package/lib/util/app-util/app-util.cjs +23 -245
- package/lib/util/inline-ai-util/inline-ai-textarea/inline-ai-textarea.cjs +3 -1
- package/lib/util/inline-ai-util/inline-ai-textarea/inline-ai-textarea.hook.cjs +12 -4
- package/package.json +7 -7
- package/dist/ibiz-markdown-editor-DEV-iSvz.js +0 -1
- package/dist/index-Bv2fgePf.js +0 -11
- package/dist/wang-editor-4cNAgOaJ.js +0 -1
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var vue = require('vue');
|
|
4
|
+
var vue3Util = require('@ibiz-template/vue3-util');
|
|
5
|
+
require('./ai-feedback.css');
|
|
6
|
+
|
|
7
|
+
"use strict";
|
|
8
|
+
function _isSlot(s) {
|
|
9
|
+
return typeof s === "function" || Object.prototype.toString.call(s) === "[object Object]" && !vue.isVNode(s);
|
|
10
|
+
}
|
|
11
|
+
const AIFeedback = /* @__PURE__ */ vue.defineComponent({
|
|
12
|
+
name: "IBizAIFeedback",
|
|
13
|
+
props: {
|
|
14
|
+
content: {
|
|
15
|
+
type: String
|
|
16
|
+
},
|
|
17
|
+
modal: {
|
|
18
|
+
type: Object,
|
|
19
|
+
required: true
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
setup(props) {
|
|
23
|
+
const ns = vue3Util.useNamespace("ai-feedback");
|
|
24
|
+
const feedback = vue.reactive({
|
|
25
|
+
description: "",
|
|
26
|
+
feedbackItems: []
|
|
27
|
+
});
|
|
28
|
+
const FEEDBACK_CATEGORIES = [{
|
|
29
|
+
title: ibiz.i18n.t("util.aiChartUtil.regardingIssue"),
|
|
30
|
+
children: [ibiz.i18n.t("util.aiChartUtil.understandProblem"), ibiz.i18n.t("util.aiChartUtil.forgotContext"), ibiz.i18n.t("util.aiChartUtil.notFollowingRequire")]
|
|
31
|
+
}, {
|
|
32
|
+
title: ibiz.i18n.t("util.aiChartUtil.regardingResponse"),
|
|
33
|
+
children: [ibiz.i18n.t("util.aiChartUtil.incorrectAswer"), ibiz.i18n.t("util.aiChartUtil.logicalConfusion"), ibiz.i18n.t("util.aiChartUtil.poorTimeliness"), ibiz.i18n.t("util.aiChartUtil.poorReadability"), ibiz.i18n.t("util.aiChartUtil.incompleteAnswer"), ibiz.i18n.t("util.aiChartUtil.unprofessional")]
|
|
34
|
+
}, {
|
|
35
|
+
title: ibiz.i18n.t("util.aiChartUtil.report"),
|
|
36
|
+
children: [ibiz.i18n.t("util.aiChartUtil.pornographicVulgar"), ibiz.i18n.t("util.aiChartUtil.politicallySensitive"), ibiz.i18n.t("util.aiChartUtil.illegalCriminal"), ibiz.i18n.t("util.aiChartUtil.discriminationPrejudice"), ibiz.i18n.t("util.aiChartUtil.violationPrivacy"), ibiz.i18n.t("util.aiChartUtil.contentInfringement")]
|
|
37
|
+
}];
|
|
38
|
+
const onInitFeedback = () => {
|
|
39
|
+
feedback.feedbackItems = FEEDBACK_CATEGORIES.map((category) => ({
|
|
40
|
+
title: category.title,
|
|
41
|
+
value: void 0,
|
|
42
|
+
children: [...category.children]
|
|
43
|
+
}));
|
|
44
|
+
if (props.content) {
|
|
45
|
+
const contentArray = props.content.split(";").filter((item) => item.trim());
|
|
46
|
+
if (contentArray.length > 0) {
|
|
47
|
+
const feedbackValues = contentArray.slice(0, FEEDBACK_CATEGORIES.length);
|
|
48
|
+
feedbackValues.forEach((value, index) => {
|
|
49
|
+
feedback.feedbackItems[index].value = value;
|
|
50
|
+
});
|
|
51
|
+
const descriptionParts = contentArray.slice(FEEDBACK_CATEGORIES.length);
|
|
52
|
+
feedback.description = descriptionParts.join(";");
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
const onCancel = () => {
|
|
57
|
+
props.modal.dismiss();
|
|
58
|
+
};
|
|
59
|
+
const onConfirm = () => {
|
|
60
|
+
const contentArray = feedback.feedbackItems.map((item) => item.value || "").filter((item) => !!item);
|
|
61
|
+
contentArray.push(feedback.description);
|
|
62
|
+
props.modal.dismiss({
|
|
63
|
+
ok: true,
|
|
64
|
+
data: [{
|
|
65
|
+
feedbackContent: contentArray.join(";")
|
|
66
|
+
}]
|
|
67
|
+
});
|
|
68
|
+
};
|
|
69
|
+
vue.onMounted(() => {
|
|
70
|
+
onInitFeedback();
|
|
71
|
+
});
|
|
72
|
+
return {
|
|
73
|
+
ns,
|
|
74
|
+
feedback,
|
|
75
|
+
onCancel,
|
|
76
|
+
onConfirm
|
|
77
|
+
};
|
|
78
|
+
},
|
|
79
|
+
render() {
|
|
80
|
+
let _slot2, _slot3;
|
|
81
|
+
return vue.createVNode("div", {
|
|
82
|
+
"class": this.ns.b()
|
|
83
|
+
}, [vue.createVNode("div", {
|
|
84
|
+
"class": this.ns.e("header")
|
|
85
|
+
}, [ibiz.i18n.t("util.aiChartUtil.feedback")]), vue.createVNode("div", {
|
|
86
|
+
"class": this.ns.e("content")
|
|
87
|
+
}, [this.feedback.feedbackItems.map((item) => {
|
|
88
|
+
let _slot;
|
|
89
|
+
return vue.createVNode("div", {
|
|
90
|
+
"class": this.ns.e("group")
|
|
91
|
+
}, [vue.createVNode("div", {
|
|
92
|
+
"class": this.ns.em("group", "title")
|
|
93
|
+
}, [item.title]), vue.createVNode(vue.resolveComponent("el-radio-group"), {
|
|
94
|
+
"modelValue": item.value,
|
|
95
|
+
"onUpdate:modelValue": ($event) => item.value = $event,
|
|
96
|
+
"class": this.ns.em("group", "content")
|
|
97
|
+
}, _isSlot(_slot = item.children.map((child, index) => {
|
|
98
|
+
return vue.createVNode(vue.resolveComponent("el-radio"), {
|
|
99
|
+
"key": index,
|
|
100
|
+
"label": child
|
|
101
|
+
}, _isSlot(child) ? child : {
|
|
102
|
+
default: () => [child]
|
|
103
|
+
});
|
|
104
|
+
})) ? _slot : {
|
|
105
|
+
default: () => [_slot]
|
|
106
|
+
})]);
|
|
107
|
+
}), vue.createVNode("div", {
|
|
108
|
+
"class": this.ns.e("description")
|
|
109
|
+
}, [vue.createVNode("div", {
|
|
110
|
+
"class": this.ns.em("description", "title")
|
|
111
|
+
}, [ibiz.i18n.t("util.aiChartUtil.description")]), vue.createVNode(vue.resolveComponent("el-input"), {
|
|
112
|
+
"rows": 3,
|
|
113
|
+
"type": "textarea",
|
|
114
|
+
"modelValue": this.feedback.description,
|
|
115
|
+
"onUpdate:modelValue": ($event) => this.feedback.description = $event,
|
|
116
|
+
"placeholder": ibiz.i18n.t("util.aiChartUtil.placeholder")
|
|
117
|
+
}, null)])]), vue.createVNode("div", {
|
|
118
|
+
"class": this.ns.e("footer")
|
|
119
|
+
}, [vue.createVNode(vue.resolveComponent("el-button"), {
|
|
120
|
+
"onClick": this.onCancel
|
|
121
|
+
}, _isSlot(_slot2 = ibiz.i18n.t("app.cancel")) ? _slot2 : {
|
|
122
|
+
default: () => [_slot2]
|
|
123
|
+
}), vue.createVNode(vue.resolveComponent("el-button"), {
|
|
124
|
+
"type": "primary",
|
|
125
|
+
"onClick": this.onConfirm
|
|
126
|
+
}, _isSlot(_slot3 = ibiz.i18n.t("app.confirm")) ? _slot3 : {
|
|
127
|
+
default: () => [_slot3]
|
|
128
|
+
})])]);
|
|
129
|
+
}
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
exports.AIFeedback = AIFeedback;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.ibiz-ai-feedback{padding:var(--ibiz-spacing-base)}.ibiz-ai-feedback__header{padding:var(--ibiz-spacing-base-tight) 0;font-size:var(--ibiz-font-size-header-5)}.ibiz-ai-feedback__group--title{padding:var(--ibiz-spacing-tight) 0;font-size:var(--ibiz-font-size-header-6);color:var(--ibiz-color-text-2)}.ibiz-ai-feedback__group--content .el-radio{min-width:130px}.ibiz-ai-feedback__description--title{padding:var(--ibiz-spacing-tight) 0;font-size:var(--ibiz-font-size-header-6)}.ibiz-ai-feedback__footer{display:flex;justify-content:end;margin-top:var(--ibiz-spacing-tight)}
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var runtime = require('@ibiz-template/runtime');
|
|
4
|
-
var qxUtil = require('qx-util');
|
|
5
|
-
var core = require('@ibiz-template/core');
|
|
6
4
|
var vue3Util = require('@ibiz-template/vue3-util');
|
|
7
5
|
|
|
8
6
|
"use strict";
|
|
@@ -202,11 +200,6 @@ class AppUtil {
|
|
|
202
200
|
appDEACModeId,
|
|
203
201
|
appDataEntityId
|
|
204
202
|
} = chartParams;
|
|
205
|
-
const { containerOptions, chatOptions } = ibiz.aiChatUtil.getUIActionExAIChatParams(context, params, data);
|
|
206
|
-
const aiAgentlist = await ibiz.aiChatUtil.getAIAgentList(
|
|
207
|
-
context,
|
|
208
|
-
params
|
|
209
|
-
);
|
|
210
203
|
const deACMode = await runtime.getDeACMode(
|
|
211
204
|
appDEACModeId,
|
|
212
205
|
appDataEntityId,
|
|
@@ -214,26 +207,31 @@ class AppUtil {
|
|
|
214
207
|
);
|
|
215
208
|
if (!deACMode)
|
|
216
209
|
return Promise.resolve([]);
|
|
217
|
-
const {
|
|
218
|
-
contentToolbarItems,
|
|
219
|
-
footerToolbarItems,
|
|
220
|
-
questionToolbarItems,
|
|
221
|
-
otherToolbarItems
|
|
222
|
-
} = ibiz.aiChatUtil.calcAiToolbarItemsByAc(deACMode);
|
|
223
210
|
const chatInstance = await ibiz.aiChatUtil.getAIChat();
|
|
224
211
|
const messages = [];
|
|
225
212
|
const appDataEntityName = runtime.calcDeCodeNameById(appDataEntityId);
|
|
226
|
-
let topicId = "".concat(
|
|
227
|
-
topicId += context[appDataEntityName] ? context[appDataEntityName] :
|
|
228
|
-
const
|
|
213
|
+
let topicId = "".concat(appDataEntityId, "@").concat(appDEACModeId, "@");
|
|
214
|
+
topicId += context[appDataEntityName] ? context[appDataEntityName] : "default";
|
|
215
|
+
const sessionid = ibiz.aiChatUtil.getChatSessionId("TOPIC", topicId);
|
|
216
|
+
const topicCaption = "[".concat(deACMode.logicName, "]").concat((data == null ? void 0 : data.srfmajortext) || "");
|
|
229
217
|
const tempParams = { ...params, ...{ srfactag: deACMode.codeName } };
|
|
230
218
|
const { zIndex } = vue3Util.useUIStore();
|
|
231
219
|
const containerZIndex = zIndex.increment();
|
|
220
|
+
const { containerOptions, topicOptions, chatOptions } = await ibiz.aiChatUtil.getUIActionExAIChatParams(
|
|
221
|
+
context,
|
|
222
|
+
params,
|
|
223
|
+
data,
|
|
224
|
+
deACMode,
|
|
225
|
+
{ chatInstance, view, ctrl }
|
|
226
|
+
);
|
|
227
|
+
const resourceOptions = await ibiz.aiChatUtil.getAIResourceOptions(
|
|
228
|
+
context,
|
|
229
|
+
params
|
|
230
|
+
);
|
|
232
231
|
return new Promise((resolve) => {
|
|
233
|
-
let id = "";
|
|
234
|
-
let abortController;
|
|
235
232
|
chatInstance.create({
|
|
236
233
|
mode: "TOPIC",
|
|
234
|
+
resourceOptions,
|
|
237
235
|
containerOptions: {
|
|
238
236
|
zIndex: containerZIndex,
|
|
239
237
|
enableBackFill: false,
|
|
@@ -242,243 +240,23 @@ class AppUtil {
|
|
|
242
240
|
topicOptions: {
|
|
243
241
|
appid: ibiz.env.appId,
|
|
244
242
|
id: topicId,
|
|
245
|
-
caption,
|
|
243
|
+
caption: topicCaption,
|
|
246
244
|
url: window.location.hash.substring(1),
|
|
247
245
|
type: context.srftopicpath || "default",
|
|
248
|
-
|
|
249
|
-
const isBatchRemove = args[4];
|
|
250
|
-
const result = await ibiz.confirm.warning({
|
|
251
|
-
title: ibiz.i18n.t(
|
|
252
|
-
"util.appUtil.".concat(isBatchRemove ? "clearTopic" : "aiTitle")
|
|
253
|
-
),
|
|
254
|
-
desc: ibiz.i18n.t(
|
|
255
|
-
"util.appUtil.".concat(isBatchRemove ? "clearTopicDesc" : "aiDesc")
|
|
256
|
-
)
|
|
257
|
-
});
|
|
258
|
-
return result;
|
|
259
|
-
},
|
|
260
|
-
action: async (action, context2, params2, data2, event) => {
|
|
261
|
-
if (action === "LINK") {
|
|
262
|
-
await ibiz.openView.push(data2.url);
|
|
263
|
-
}
|
|
264
|
-
return true;
|
|
265
|
-
},
|
|
266
|
-
configService: (appid, storageType, subType) => {
|
|
267
|
-
return new runtime.ConfigService(appid, storageType, subType);
|
|
268
|
-
}
|
|
246
|
+
...topicOptions
|
|
269
247
|
},
|
|
270
248
|
chatOptions: {
|
|
271
249
|
caption: deACMode.logicName,
|
|
272
250
|
context: { ...context },
|
|
273
251
|
params: tempParams,
|
|
274
252
|
appDataEntityId,
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
aiAgentlist,
|
|
280
|
-
question: async (aiChat, ctx, param, other, arr, sessionid, srfaiagent, srfmode) => {
|
|
281
|
-
id = qxUtil.createUUID();
|
|
282
|
-
abortController = new AbortController();
|
|
283
|
-
const deService = await ibiz.hub.getApp(ctx.srfappid).deService.getService(ctx, other.appDataEntityId);
|
|
284
|
-
try {
|
|
285
|
-
const questionRequestData = {
|
|
286
|
-
messages: arr,
|
|
287
|
-
sessionid
|
|
288
|
-
};
|
|
289
|
-
if (srfaiagent) {
|
|
290
|
-
questionRequestData.srfaiagent = srfaiagent;
|
|
291
|
-
}
|
|
292
|
-
if (srfmode) {
|
|
293
|
-
questionRequestData.mode = srfmode;
|
|
294
|
-
}
|
|
295
|
-
await deService.aiChatSse(
|
|
296
|
-
(msg) => {
|
|
297
|
-
if (msg.actionstate === 20 && msg.actionresult) {
|
|
298
|
-
aiChat.addMessage({
|
|
299
|
-
messageid: id,
|
|
300
|
-
state: msg.actionstate,
|
|
301
|
-
type: "DEFAULT",
|
|
302
|
-
role: "ASSISTANT",
|
|
303
|
-
content: msg.actionresult
|
|
304
|
-
});
|
|
305
|
-
} else if (msg.actionstate === 30 && msg.actionresult) {
|
|
306
|
-
const result = JSON.parse(msg.actionresult);
|
|
307
|
-
const choices = result.choices;
|
|
308
|
-
if (choices && choices.length > 0) {
|
|
309
|
-
aiChat.replaceMessage({
|
|
310
|
-
messageid: id,
|
|
311
|
-
state: msg.actionstate,
|
|
312
|
-
type: "DEFAULT",
|
|
313
|
-
role: "ASSISTANT",
|
|
314
|
-
content: choices[0].content || ""
|
|
315
|
-
});
|
|
316
|
-
}
|
|
317
|
-
} else if (msg.actionstate === 40) {
|
|
318
|
-
aiChat.replaceMessage({
|
|
319
|
-
messageid: id,
|
|
320
|
-
state: msg.actionstate,
|
|
321
|
-
type: "ERROR",
|
|
322
|
-
role: "ASSISTANT",
|
|
323
|
-
content: msg.actionresult
|
|
324
|
-
});
|
|
325
|
-
}
|
|
326
|
-
},
|
|
327
|
-
abortController,
|
|
328
|
-
ctx,
|
|
329
|
-
param,
|
|
330
|
-
{ ...questionRequestData }
|
|
331
|
-
);
|
|
332
|
-
} catch (error) {
|
|
333
|
-
aiChat.replaceMessage({
|
|
334
|
-
messageid: id,
|
|
335
|
-
state: 40,
|
|
336
|
-
type: "ERROR",
|
|
337
|
-
role: "ASSISTANT",
|
|
338
|
-
content: error.message || ibiz.i18n.t("app.aiError")
|
|
339
|
-
});
|
|
340
|
-
abortController == null ? void 0 : abortController.abort();
|
|
341
|
-
} finally {
|
|
342
|
-
aiChat.completeMessage(id, true);
|
|
343
|
-
return true;
|
|
344
|
-
}
|
|
345
|
-
},
|
|
346
|
-
abortQuestion: async (aiChat) => {
|
|
347
|
-
abortController == null ? void 0 : abortController.abort();
|
|
348
|
-
await aiChat.stopMessage({
|
|
349
|
-
messageid: id,
|
|
350
|
-
state: 30,
|
|
351
|
-
type: "DEFAULT",
|
|
352
|
-
role: "ASSISTANT",
|
|
353
|
-
content: ""
|
|
354
|
-
});
|
|
355
|
-
await aiChat.completeMessage(id, true);
|
|
356
|
-
},
|
|
253
|
+
sessionid,
|
|
254
|
+
// 扩展参数
|
|
255
|
+
...chatOptions,
|
|
256
|
+
// 关闭回调
|
|
357
257
|
closed: () => {
|
|
358
258
|
resolve(messages);
|
|
359
|
-
}
|
|
360
|
-
history: async (ctx, param, other) => {
|
|
361
|
-
const deService = await ibiz.hub.getApp(ctx.srfappid).deService.getService(ctx, other.appDataEntityId);
|
|
362
|
-
const historyRequestData = {};
|
|
363
|
-
if (other.appendCurData) {
|
|
364
|
-
Object.assign(historyRequestData, {
|
|
365
|
-
...other.appendCurData
|
|
366
|
-
});
|
|
367
|
-
}
|
|
368
|
-
if (other.srfaiagent) {
|
|
369
|
-
Object.assign(historyRequestData, {
|
|
370
|
-
srfaiagent: other.srfaiagent
|
|
371
|
-
});
|
|
372
|
-
}
|
|
373
|
-
if (other.srfmode) {
|
|
374
|
-
Object.assign(historyRequestData, {
|
|
375
|
-
mode: other.srfmode
|
|
376
|
-
});
|
|
377
|
-
}
|
|
378
|
-
const result = await deService.aiChatHistory(
|
|
379
|
-
ctx,
|
|
380
|
-
param,
|
|
381
|
-
historyRequestData
|
|
382
|
-
);
|
|
383
|
-
if (result.data && Array.isArray(result.data)) {
|
|
384
|
-
let preMsg;
|
|
385
|
-
result.data.forEach((item) => {
|
|
386
|
-
if (item.role === "TOOL") {
|
|
387
|
-
if (preMsg && item.content) {
|
|
388
|
-
chatInstance.aiChat.updateRecommendPrompt(
|
|
389
|
-
preMsg,
|
|
390
|
-
item.content
|
|
391
|
-
);
|
|
392
|
-
}
|
|
393
|
-
} else {
|
|
394
|
-
const msg = {
|
|
395
|
-
messageid: qxUtil.createUUID(),
|
|
396
|
-
state: 30,
|
|
397
|
-
type: "DEFAULT",
|
|
398
|
-
role: item.role,
|
|
399
|
-
content: item.content,
|
|
400
|
-
completed: true
|
|
401
|
-
};
|
|
402
|
-
preMsg = msg;
|
|
403
|
-
chatInstance.aiChat.addMessage(msg);
|
|
404
|
-
}
|
|
405
|
-
});
|
|
406
|
-
}
|
|
407
|
-
return true;
|
|
408
|
-
},
|
|
409
|
-
recommendPrompt: async (ctx, param, other) => {
|
|
410
|
-
const deService = await ibiz.hub.getApp(ctx.srfappid).deService.getService(ctx, other.appDataEntityId);
|
|
411
|
-
const result = await deService.aiChatRecommendPrompt(
|
|
412
|
-
ctx,
|
|
413
|
-
param,
|
|
414
|
-
other.message
|
|
415
|
-
);
|
|
416
|
-
if (result.ok && result.data) {
|
|
417
|
-
const choices = result.data.choices;
|
|
418
|
-
if (choices && choices.length > 0) {
|
|
419
|
-
return choices[0];
|
|
420
|
-
}
|
|
421
|
-
return null;
|
|
422
|
-
}
|
|
423
|
-
return null;
|
|
424
|
-
},
|
|
425
|
-
uploader: {
|
|
426
|
-
onUpload: async (file, reportProgress, options) => {
|
|
427
|
-
const { uploadUrl } = ibiz.util.file.calcFileUpDownUrl(
|
|
428
|
-
(options == null ? void 0 : options.context) || context,
|
|
429
|
-
(options == null ? void 0 : options.params) || params,
|
|
430
|
-
{}
|
|
431
|
-
);
|
|
432
|
-
const headers = ibiz.util.file.getUploadHeaders();
|
|
433
|
-
const formData = new FormData();
|
|
434
|
-
formData.append("file", file);
|
|
435
|
-
const res = await ibiz.net.axios({
|
|
436
|
-
url: uploadUrl,
|
|
437
|
-
method: "post",
|
|
438
|
-
headers,
|
|
439
|
-
data: formData,
|
|
440
|
-
onUploadProgress: (progressEvent) => {
|
|
441
|
-
const percent = progressEvent.loaded / progressEvent.total * 100;
|
|
442
|
-
reportProgress(percent);
|
|
443
|
-
}
|
|
444
|
-
});
|
|
445
|
-
return res.data;
|
|
446
|
-
}
|
|
447
|
-
},
|
|
448
|
-
extendToolbarClick: async (event, source, context2, params2, data2) => {
|
|
449
|
-
var _a, _b;
|
|
450
|
-
const result = await runtime.UIActionUtil.exec(
|
|
451
|
-
source.id,
|
|
452
|
-
{
|
|
453
|
-
view,
|
|
454
|
-
ctrl,
|
|
455
|
-
context: core.IBizContext.create(context2),
|
|
456
|
-
params: params2,
|
|
457
|
-
data: [data2],
|
|
458
|
-
event
|
|
459
|
-
},
|
|
460
|
-
source.appId
|
|
461
|
-
);
|
|
462
|
-
if (result.closeView) {
|
|
463
|
-
view.closeView({ ok: true });
|
|
464
|
-
} else if (result.refresh) {
|
|
465
|
-
switch (result.refreshMode) {
|
|
466
|
-
case 1:
|
|
467
|
-
view.callUIAction(runtime.SysUIActionTag.REFRESH);
|
|
468
|
-
break;
|
|
469
|
-
case 2:
|
|
470
|
-
(_a = view.parentView) == null ? void 0 : _a.callUIAction(runtime.SysUIActionTag.REFRESH);
|
|
471
|
-
break;
|
|
472
|
-
case 3:
|
|
473
|
-
(_b = view.getTopView()) == null ? void 0 : _b.callUIAction(runtime.SysUIActionTag.REFRESH);
|
|
474
|
-
break;
|
|
475
|
-
default:
|
|
476
|
-
}
|
|
477
|
-
}
|
|
478
|
-
return result;
|
|
479
|
-
},
|
|
480
|
-
// 扩展参数
|
|
481
|
-
...chatOptions
|
|
259
|
+
}
|
|
482
260
|
}
|
|
483
261
|
});
|
|
484
262
|
});
|
|
@@ -150,7 +150,9 @@ const InlineAITextArea = /* @__PURE__ */ vue.defineComponent({
|
|
|
150
150
|
});
|
|
151
151
|
isCollapse.value = false;
|
|
152
152
|
if (inlinecompletionmode === "async") {
|
|
153
|
-
await asyncAskAI(question, handleAnswer)
|
|
153
|
+
await asyncAskAI(question, handleAnswer, () => {
|
|
154
|
+
isLoading.value = false;
|
|
155
|
+
});
|
|
154
156
|
} else {
|
|
155
157
|
const answer = await syncAskAI(question);
|
|
156
158
|
handleAnswer(answer);
|
|
@@ -60,6 +60,7 @@ const useAI = (props, opts) => {
|
|
|
60
60
|
const { context, data, deACMode } = props;
|
|
61
61
|
const { srfaiappendcurdata, srfmode, srfaiagent } = opts;
|
|
62
62
|
const params = { srfactag: deACMode.codeName };
|
|
63
|
+
const sessionid = ibiz.aiChatUtil.getChatSessionId("INLINE");
|
|
63
64
|
const app = ibiz.hub.getApp(deACMode.appId);
|
|
64
65
|
let history = [];
|
|
65
66
|
let appDataEntity;
|
|
@@ -77,7 +78,9 @@ const useAI = (props, opts) => {
|
|
|
77
78
|
deACMode.appId
|
|
78
79
|
);
|
|
79
80
|
const path = calcAIPath(true);
|
|
80
|
-
const body = {
|
|
81
|
+
const body = {
|
|
82
|
+
sessionid
|
|
83
|
+
};
|
|
81
84
|
if (srfaiappendcurdata)
|
|
82
85
|
Object.assign(body, data);
|
|
83
86
|
if (srfmode)
|
|
@@ -114,6 +117,7 @@ const useAI = (props, opts) => {
|
|
|
114
117
|
};
|
|
115
118
|
const prepareData = (question, isAsync = false) => {
|
|
116
119
|
const body = {
|
|
120
|
+
sessionid,
|
|
117
121
|
messages: [
|
|
118
122
|
...history,
|
|
119
123
|
{
|
|
@@ -146,8 +150,8 @@ const useAI = (props, opts) => {
|
|
|
146
150
|
}
|
|
147
151
|
return { think, content };
|
|
148
152
|
};
|
|
149
|
-
const asyncAskAI = (question, callBack) => {
|
|
150
|
-
return new Promise((resolve
|
|
153
|
+
const asyncAskAI = (question, callBack, errorBack) => {
|
|
154
|
+
return new Promise((resolve) => {
|
|
151
155
|
abortController.value = new AbortController();
|
|
152
156
|
const { body, url } = prepareData(question, true);
|
|
153
157
|
app.net.sse(url, params, {
|
|
@@ -170,7 +174,11 @@ const useAI = (props, opts) => {
|
|
|
170
174
|
}
|
|
171
175
|
},
|
|
172
176
|
onclose: () => resolve(),
|
|
173
|
-
onerror: () =>
|
|
177
|
+
onerror: (error) => {
|
|
178
|
+
callBack({ state: 40, content: error.message });
|
|
179
|
+
errorBack();
|
|
180
|
+
throw error;
|
|
181
|
+
},
|
|
174
182
|
signal: abortController.value.signal
|
|
175
183
|
});
|
|
176
184
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ibiz-template/vue3-components",
|
|
3
|
-
"version": "0.7.41-alpha.
|
|
3
|
+
"version": "0.7.41-alpha.43",
|
|
4
4
|
"description": "web端组件库(vue3)",
|
|
5
5
|
"main": "lib/index.cjs",
|
|
6
6
|
"module": "es/index.mjs",
|
|
@@ -30,18 +30,18 @@
|
|
|
30
30
|
"dependencies": {
|
|
31
31
|
"@amap/amap-jsapi-loader": "^1.0.1",
|
|
32
32
|
"@floating-ui/dom": "^1.5.3",
|
|
33
|
-
"@ibiz-template-plugin/ai-chat": "^0.0.
|
|
33
|
+
"@ibiz-template-plugin/ai-chat": "^0.0.36",
|
|
34
34
|
"@ibiz-template-plugin/gantt": "0.1.8-alpha.316",
|
|
35
35
|
"@ibiz-template-plugin/bi-report": "0.0.30",
|
|
36
36
|
"@ibiz-template-plugin/data-view": "0.0.6",
|
|
37
37
|
"@ibiz-template/core": "0.7.41-alpha.35",
|
|
38
38
|
"@ibiz-template/devtool": "0.0.13",
|
|
39
|
-
"@ibiz-template/model-helper": "0.7.41-alpha.
|
|
40
|
-
"@ibiz-template/runtime": "0.7.41-alpha.
|
|
39
|
+
"@ibiz-template/model-helper": "0.7.41-alpha.42",
|
|
40
|
+
"@ibiz-template/runtime": "0.7.41-alpha.42",
|
|
41
41
|
"@ibiz-template/theme": "0.7.39",
|
|
42
|
-
"@ibiz-template/vue3-util": "0.7.41-alpha.
|
|
42
|
+
"@ibiz-template/vue3-util": "0.7.41-alpha.42",
|
|
43
43
|
"@ibiz-template/web-theme": "3.9.0",
|
|
44
|
-
"@ibiz/model-core": "^0.1.
|
|
44
|
+
"@ibiz/model-core": "^0.1.84",
|
|
45
45
|
"@imengyu/vue3-context-menu": "^1.3.5",
|
|
46
46
|
"@monaco-editor/loader": "^1.4.0",
|
|
47
47
|
"@wangeditor/editor": "^5.1.23",
|
|
@@ -108,7 +108,7 @@
|
|
|
108
108
|
"@ibiz-template/runtime": "^0.7.0",
|
|
109
109
|
"@ibiz-template/theme": "^0.7.0",
|
|
110
110
|
"@ibiz-template/vue3-util": "^0.7.0",
|
|
111
|
-
"@ibiz/model-core": "^0.1.
|
|
111
|
+
"@ibiz/model-core": "^0.1.84",
|
|
112
112
|
"@imengyu/vue3-context-menu": "^1.3.3",
|
|
113
113
|
"@monaco-editor/loader": "^1.3.3",
|
|
114
114
|
"@wangeditor/editor": "^5.1.23",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
System.register(["vue","@ibiz-template/vue3-util","qx-util","cherry-markdown","@ibiz-template/core","@ibiz-template/runtime"],function(e){"use strict";var t,n,a,i,o,l,r,s,c,d,u,m,h,p,v,f,b,g;return{setters:[function(e){t=e.nextTick,n=e.ref,a=e.onBeforeUnmount,i=e.createVNode,o=e.resolveComponent,l=e.defineComponent,r=e.watch,s=e.onMounted,c=e.onUnmounted},function(e){d=e.useUIStore,u=e.getEditorEmits,m=e.getMarkDownProps,h=e.useNamespace},function(e){p=e.createUUID},function(e){v=e.default},function(e){f=e.IBizContext},function(e){b=e.UIActionUtil,g=e.SysUIActionTag}],execute:function(){function w(e,t){return!(!e||1!==e.nodeType||e.nodeName!==t)}function y(e){const l=n(""),r=n([]),s=n();let c=null;const d=async e=>{var n;if(l.value=e,r.value=[e],await t(),s.value){const{container:e}=s.value.$refs;e&&(null==(n=e.children[0])||n.click())}},u=e=>{"Escape"!==e.key&&27!==e.keyCode||(e.stopPropagation(),e.preventDefault(),r.value=[],h())},m=async()=>{var e;await t();const n=null==(e=s.value)?void 0:e.$refs.container;if(!n)return;const a=n.querySelector(".el-image-viewer__wrapper");null==a||a.addEventListener("keydown",u)},h=()=>{var e;const t=null==(e=s.value)?void 0:e.$refs.container;if(!t)return;const n=t.querySelector(".el-image-viewer__wrapper");null==n||n.removeEventListener("keydown",u)},p=e=>{const t=null==e?void 0:e.target;if(w(t,"IMG")&&t)return void d(t.src);const n=function(e){let t=e;for(;t;){if(t.classList.contains("cherry-previewer"))return null;const e=t.parentElement;if(w(t,"svg")&&e&&"mermaid"===e.dataset.type)return t;t=t.parentElement}return null}(t);n&&d(function(e){const t=e.cloneNode(!0),n=e.width.baseVal.value||e.clientWidth,a=e.height.baseVal.value||e.clientHeight;t.setAttribute("width",n),t.setAttribute("height",a),t.style.backgroundColor="white";const i=(new XMLSerializer).serializeToString(t),o=btoa(unescape(encodeURIComponent(i)));return"data:image/svg+xml;base64,".concat(o)}(n))};return a(()=>{c&&(c.removeEventListener("click",p),c=null),h()}),{renderImgPreview:()=>i(o("el-image"),{class:e.e("img-preview"),ref:s,"zoom-rate":1.1,src:l.value,"preview-src-list":r.value,"hide-on-click-modal":!0,onShow:m,fit:"cover"},null),onMDEditorCreated:e=>{var t,n;c=(null==(n=null==(t=null==e?void 0:e.previewer)?void 0:t.previewerBubble)?void 0:n.previewerDom)||null,null==c||c.addEventListener("click",p)}}}e("default",l({name:"IBizMarkDown",props:m(),emits:u(),setup(e,{emit:o,slots:l}){var u,m,w;const C=h("markdown"),k=e.controller,I=n("");let A=null;const z=p(),{onMDEditorCreated:E,renderImgPreview:M}=y(C),S=ibiz.util.file.getUploadHeaders(),T=n({...S}),x=n(""),U=(null==(u=null==k?void 0:k.editorParams)?void 0:u.customTheme)||(null==(m=null==k?void 0:k.editorParams)?void 0:m.customtheme),{UIStore:D}=d(),P=n(U||D.theme),R=n(!1);let O="default";k&&(null==(w=k.editorParams)?void 0:w.showmode)&&(O=k.editorParams.showmode);const L=n(!1),B=n("editOnly");let N=null,V=null,H=0;const F=n({}),q=n({}),j=n("full");let $=!1;const[_,J]=function(e,n){const{props:a,isEditing:i,currentVal:o,emit:l}=n;let r=n.chatInstance;return[v.createMenuHook("AI",{icon:{type:"svg",content:"<svg\n viewBox='0 0 16 16'\n xmlns='http://www.w3.org/2000/svg'\n fill='currentColor'\n height='1em'\n width='1em'\n preserveAspectRatio='xMidYMid meet'\n focusable='false'\n >\n <g\n id='aae1.Base基础/1.icon图标/2.normal/ai-star'\n stroke-width='1'\n fill-rule='evenodd'\n >\n <path\n d='M5.817 1.53l3.158 8.797h.054v.152l1.443 4.021-1.402.001-1.041-2.982H2.495l-1.03 2.982L0 14.5 4.671 1.533l1.146-.003zm7.86 5.424V14.5h-1.213V6.954h1.212zM5.248 3.549l-2.342 6.778h4.706L5.249 3.55zM13.046 0c.075 0 .147.02.204.071a.318.318 0 01.094.181l.064.273c.097.417.17.727.255.968.084.24.177.4.31.523.134.124.318.218.599.306.281.088.65.166 1.15.265a.358.358 0 01.195.095c.056.057.083.13.083.213a.289.289 0 01-.083.21.362.362 0 01-.197.094c-.528.093-.918.167-1.214.255-.295.088-.485.187-.621.324-.137.138-.23.324-.31.606-.08.283-.145.651-.23 1.147a.329.329 0 01-.093.184.293.293 0 01-.206.075.308.308 0 01-.207-.072.322.322 0 01-.1-.188l-.006-.033c-.085-.486-.149-.845-.228-1.12-.079-.274-.17-.452-.305-.585-.135-.133-.323-.23-.618-.32s-.683-.168-1.21-.273a.353.353 0 01-.2-.096.29.29 0 01-.08-.208c0-.079.023-.153.079-.211a.35.35 0 01.2-.097c.5-.098.869-.176 1.15-.263.282-.087.465-.18.597-.302.132-.12.224-.278.306-.511.082-.236.151-.539.244-.947l.071-.312a.312.312 0 01.102-.183.311.311 0 01.205-.069z'\n id='aae形状结合'\n ></path>\n </g>\n </svg>\n "},onClick:(n,a,i)=>{i.stopPropagation(),i.preventDefault(),t(()=>{var t;if(null==(t=e.mdeditor)?void 0:t.bubble){e.mdeditor.bubble.showBubble();const t=e.mdeditor.bubble.bubbleDom.getBoundingClientRect();if(!t||!t.left||!t.top)return;const n=ibiz.inLineAIUtil.calcContextMenus(e.deACMode,t=>{e.doInLineAIUIAction(t,e.model.appId)});if(0===n.length)return;ibiz.inLineAIUtil.showContextMenus(t.left,t.top+43,n)}})}}),v.createMenuHook("AIChart",{icon:{type:"svg",content:"<svg\n viewBox='0 0 16 16'\n xmlns='http://www.w3.org/2000/svg'\n fill='currentColor'\n height='1em'\n width='1em'\n preserveAspectRatio='xMidYMid meet'\n focusable='false'\n >\n <g\n id='aae1.Base基础/1.icon图标/2.normal/ai-star'\n stroke-width='1'\n fill-rule='evenodd'\n >\n <path\n d='M5.817 1.53l3.158 8.797h.054v.152l1.443 4.021-1.402.001-1.041-2.982H2.495l-1.03 2.982L0 14.5 4.671 1.533l1.146-.003zm7.86 5.424V14.5h-1.213V6.954h1.212zM5.248 3.549l-2.342 6.778h4.706L5.249 3.55zM13.046 0c.075 0 .147.02.204.071a.318.318 0 01.094.181l.064.273c.097.417.17.727.255.968.084.24.177.4.31.523.134.124.318.218.599.306.281.088.65.166 1.15.265a.358.358 0 01.195.095c.056.057.083.13.083.213a.289.289 0 01-.083.21.362.362 0 01-.197.094c-.528.093-.918.167-1.214.255-.295.088-.485.187-.621.324-.137.138-.23.324-.31.606-.08.283-.145.651-.23 1.147a.329.329 0 01-.093.184.293.293 0 01-.206.075.308.308 0 01-.207-.072.322.322 0 01-.1-.188l-.006-.033c-.085-.486-.149-.845-.228-1.12-.079-.274-.17-.452-.305-.585-.135-.133-.323-.23-.618-.32s-.683-.168-1.21-.273a.353.353 0 01-.2-.096.29.29 0 01-.08-.208c0-.079.023-.153.079-.211a.35.35 0 01.2-.097c.5-.098.869-.176 1.15-.263.282-.087.465-.18.597-.302.132-.12.224-.278.306-.511.082-.236.151-.539.244-.947l.071-.312a.312.312 0 01.102-.183.311.311 0 01.205-.069z'\n id='aae形状结合'\n ></path>\n </g>\n </svg>\n "},onClick:async()=>{const t=e.model.appDataEntityId;if(!t||!e.deACMode)return;const n=await ibiz.aiChatUtil.getAIAgentList(e.context,e.params),{contentToolbarItems:s,footerToolbarItems:c,questionToolbarItems:u,otherToolbarItems:m}=ibiz.aiChatUtil.calcAiToolbarItemsByAc(e.deACMode),{containerOptions:h,chatOptions:v}=ibiz.aiChatUtil.getEditorExAIChatParams(e.editorParams,e.context,e.params,a.data),{zIndex:w}=d(),y=w.increment();r=await ibiz.aiChatUtil.getAIChat();let C,k="";r.create({containerOptions:{zIndex:y,...h},chatOptions:{caption:e.deACMode.logicName,context:{...e.context},params:{...e.params,srfactag:e.deACMode.codeName},appDataEntityId:t,contentToolbarItems:s,footerToolbarItems:c,questionToolbarItems:u,otherToolbarItems:m,aiAgentlist:n,...v,question:async(e,t,n,a,i,o,l,r)=>{k=p(),C=new AbortController;const s=await ibiz.hub.getApp(t.srfappid).deService.getService(t,a.appDataEntityId);try{const a={messages:i,sessionid:o};l&&(a.srfaiagent=l),r&&(a.mode=r),await s.aiChatSse(t=>{if(20===t.actionstate&&t.actionresult)e.addMessage({messageid:k,state:t.actionstate,type:"DEFAULT",role:"ASSISTANT",content:t.actionresult});else if(30===t.actionstate&&t.actionresult){const n=JSON.parse(t.actionresult).choices;n&&n.length>0&&e.replaceMessage({messageid:k,state:t.actionstate,type:"DEFAULT",role:"ASSISTANT",content:n[0].content||""})}else 40===t.actionstate&&e.replaceMessage({messageid:k,state:t.actionstate,type:"ERROR",role:"ASSISTANT",content:t.actionresult})},C,t,n,{...a})}catch(t){e.replaceMessage({messageid:k,state:40,type:"ERROR",role:"ASSISTANT",content:t.message||ibiz.i18n.t("app.aiError")}),null==C||C.abort()}finally{return e.completeMessage(k,!0),!0}},abortQuestion:async e=>{null==C||C.abort(),await e.stopMessage({messageid:k,state:30,type:"DEFAULT",role:"ASSISTANT",content:""}),await e.completeMessage(k,!0)},action:(e,t)=>{"backfill"===e&&(i.value?o.value=t.realcontent||"":l("change",t.realcontent))},history:async(e,t,n)=>{const a=await ibiz.hub.getApp(e.srfappid).deService.getService(e,n.appDataEntityId),i={};n.appendCurData&&Object.assign(i,{...n.appendCurData}),n.srfaiagent&&Object.assign(i,{srfaiagent:n.srfaiagent}),n.srfmode&&Object.assign(i,{mode:n.srfmode});const o=await a.aiChatHistory(e,t,i);if(o.data&&Array.isArray(o.data)){let e;o.data.forEach(t=>{if("TOOL"===t.role)e&&t.content&&r.aiChat.updateRecommendPrompt(e,t.content);else{const n={messageid:p(),state:30,type:"DEFAULT",role:t.role,content:t.content,completed:!0};e=n,r.aiChat.addMessage(n)}})}return!0},recommendPrompt:async(e,t,n)=>{const a=await ibiz.hub.getApp(e.srfappid).deService.getService(e,n.appDataEntityId),i=await a.aiChatRecommendPrompt(e,t,n.message);if(i.ok&&i.data){const e=i.data.choices;return e&&e.length>0?e[0]:null}return null},uploader:{onUpload:async(t,n,a)=>{const i=ibiz.util.file.calcFileUpDownUrl((null==a?void 0:a.context)||e.context,(null==a?void 0:a.params)||e.params,{}),o=ibiz.util.file.getUploadHeaders(),l=new FormData;return l.append("file",t),(await ibiz.net.axios({url:i.uploadUrl,method:"post",headers:o,data:l,onUploadProgress:e=>{const t=e.loaded/e.total*100;n(t)}})).data}},extendToolbarClick:async(t,n,a,i,o)=>{var l,r;const s=await b.exec(n.id,{view:e.view,ctrl:e.ctrl,context:f.create(a),params:i,data:[o],event:t},n.appId);if(s.closeView)e.view.closeView({ok:!0});else if(s.refresh)switch(s.refreshMode){case 1:e.view.callUIAction(g.REFRESH);break;case 2:null==(l=e.view.parentView)||l.callUIAction(g.REFRESH);break;case 3:null==(r=e.view.getTopView())||r.callUIAction(g.REFRESH)}return s}}})}})]}(k,{props:e,chatInstance:undefined,isEditing:R,currentVal:I,emit:o});r(()=>e.data,e=>{if(e&&k){const t={...k.editorParams};t.uploadparams&&(t.uploadParams=JSON.parse(t.uploadparams));const n=ibiz.util.file.calcFileUpDownUrl(k.context,k.params,e,t);x.value=n.uploadUrl}},{immediate:!0,deep:!0});const W=n(),Y=async(t,n)=>{const a=await ibiz.util.file.fileUpload(x.value,t,T.value),i=((e,t)=>{if(!k)return"";const n={...k.editorParams};return n.exportparams&&(n.exportParams=JSON.parse(n.exportparams)),t&&t.folder&&(n.osscat=t.folder),ibiz.util.file.calcFileUpDownUrl(k.context,k.params,e,n).downloadUrl})(e.data||{},a.fileid);let o=i.replace("%fileId%",a.fileid);if(ibiz.config.common.enableDownloadTicket&&k){const t=await ibiz.util.file.getDownloadTicket(k.context,k.params,e.data||{},{fileId:a.fileid},k.downloadTicketParams);t&&t.ticket&&(o=i.replace("%fileId%",t.ticket),n(o))}else n(o)},G=()=>null==A?void 0:A.getMarkdown(),Q=e=>{$=!0,null==A||A.setMarkdown(e,!0)};r(()=>e.value,(e,t)=>{e!==t&&(I.value=e||"")},{immediate:!0}),r(I,(e,t)=>{const n=G();e!==t&&n!==e&&Q(e)});const X=e=>{"manual"!==O&&(o("change",G(),null==k?void 0:k.model.id,$),$=!1)},K=(e,t)=>({[e]:t}),Z=(e,t="")=>{const n=document.createElement(e);return n.className=t,n},ee=e=>Z("i","ch-icon ch-icon-".concat(e)),te=C.e("fullscreen"),ne=e=>{for(;e.firstChild;)e.removeChild(e.firstChild)},ae=()=>{if(A&&W.value){const e=A.editor.options.editorDom.parentElement;if(!e)return{};const t=e.classList,n=W.value.querySelector(".".concat(te));return n?{parentElement:e,cherryClass:t,fullscreenNode:n}:{}}return{}},ie=()=>{const{parentElement:e,cherryClass:t,fullscreenNode:n}=ae();e&&t&&n&&(ne(n),n.appendChild(ee("fullscreen")),n.title=ibiz.i18n.t("editor.common.fullscreen"),t.remove("fullscreen"),null==e||e.blur(),e.setAttribute("tabindex","-1"))},oe=()=>{const{cherryClass:e}=ae();return null==e?void 0:e.contains("fullscreen")},le=()=>{A&&W.value&&(oe()?(ie(),A.toggleToc(j.value),L.value=!1):((()=>{const{parentElement:e,cherryClass:n,fullscreenNode:a}=ae();e&&n&&a&&(ne(a),a.appendChild(ee("minscreen")),n.add("fullscreen"),a.title=ibiz.i18n.t("editor.common.minimize"),e.setAttribute("tabindex","-1"),t(()=>null==e?void 0:e.focus()))})(),j.value=A.toc.model,A.toggleToc("full"),L.value=!0))},re=e=>{e.stopPropagation(),"Escape"===e.key&&(e.preventDefault(),oe()&&(ie(),A.toggleToc(j.value),L.value=!1))},se=e=>{null==k||k.setCurrentEditorTheme(e)},ce=e=>{var t,n;const{info:a}=e;let i=!0;const o=a.ranges&&a.ranges[0];if(o){const{anchor:e,head:t}=o;i=k.isPositionBefore(e,t)}else i=!0;const l=null==(t=k.mdeditor)?void 0:t.editor.editor.getCursor("start"),r=null==(n=k.mdeditor)?void 0:n.editor.editor.getCursor("end");k.setCursorPos(l,r),k.setSelectionDirection(i)};r(()=>D.theme,e=>{P.value=U||e,null==A||A.setTheme(P.value),null==A||A.setCodeBlockTheme(P.value)});const de=()=>{R.value=!0,B.value="editOnly",null==A||A.switchModel(B.value)},ue=()=>{R.value=!1,B.value="previewOnly",null==A||A.switchModel(B.value)},me=()=>{Q(I.value),ue()},he=()=>{o("change",G(),null==k?void 0:k.model.id,$),$=!1,ue()},pe=()=>{const e=document.getElementById(z);null==e||e.focus()};return s(()=>{var n;(e.disabled||e.readonly||"manual"===O)&&(B.value="previewOnly"),t(()=>{var t;const n=["bold","italic","underline","strikethrough","sub","sup","|","size","color"],a=["bold","italic","underline","strikethrough","|","color","header","|","list","image",{insert:["link","hr","br","code","formula","toc","table","line-table","bar-table"]},"settings","togglePreview"];k&&k.chatCompletion&&(a.unshift("AIChart"),n.unshift("AI")),A=new v({id:z,value:I.value,previewer:{enablePreviewerBubble:!(e.disabled||e.readonly)},themeSettings:{mainTheme:P.value,codeBlockTheme:P.value},fileUpload:Y,emoji:{useUnicode:!0},header:{anchorStyle:"autonumber"},editor:{height:"100%",defaultModel:B.value,codemirror:{autofocus:!1}},toolbars:{toolbar:a,bubble:n,float:["h1","h2","h3","|","checklist","quote","quickTable","code"],customMenu:{AI:_,AIChart:J},sidebar:["theme","copy"],toolbarRight:[],toc:{updateLocationHash:!1,defaultModel:"pure",showAutoNumber:!0,position:"absolute",cssText:""}},callback:{afterChange:X,beforeImageMounted:K},event:{changeMainTheme:se,selectionChange:ce},engine:{syntax:{table:{enableChart:!1,externals:["echarts"]}}}}),A.setTheme(P.value),U&&(A.setTheme(U),A.setCodeBlockTheme(U));const i=Z("span","".concat(te," cherry-toolbar-button"));i.title=ibiz.i18n.t("editor.common.fullscreen"),i.onclick=le,i.appendChild(ee("fullscreen"));const o=e.disabled?A.editor.options.editorDom.parentElement:null==(t=A.editor.options.editorDom.parentElement)?void 0:t.querySelector(".cherry-toolbar>.toolbar-right");if(null==o||o.appendChild(i),null==k||k.setMDEditor(A),E(A),l.editorSwitchMenu&&window.ResizeObserver&&W.value){const e=W.value.querySelector(".cherry-toolbar");e&&(V=new ResizeObserver(e=>{var t;const n=null==(t=e[0])?void 0:t.contentRect.height;q.value=C.cssVarBlock({"toolbar-height":"".concat(n,"px")})}),V.observe(e))}}),(()=>{if(window.ResizeObserver&&W.value){const e={width:W.value.offsetWidth?"".concat(W.value.offsetWidth,"px"):"100%"};k&&"number"==typeof k.parent.model.height&&Object.assign(e,{height:"".concat(k.parent.model.height,"px")}),F.value=C.cssVarBlock(e),N=new ResizeObserver(e=>{const t=e[0].contentRect.width;if(t!==H){const n={width:"".concat(e[0].contentRect.width,"px")};k&&"number"==typeof k.parent.model.height&&Object.assign(n,{height:"".concat(k.parent.model.height,"px")}),F.value=C.cssVarBlock(n),H=t}}),N.observe(W.value)}})(),null==(n=W.value)||n.addEventListener("keydown",re.bind(this))}),a(()=>{var e;null==(e=W.value)||e.removeEventListener("keydown",re.bind(this))}),c(()=>{A=null,N&&N.disconnect(),V&&V.disconnect()}),{ns:C,currentVal:I,id:z,editor:A,markDownBox:W,headers:T,theme:P,defaultModel:B,cssVars:F,isEditing:R,showmode:O,getCherryHtml:()=>null==A?void 0:A.getHtml(),getCherryContent:G,setCherryContent:Q,renderHeader:()=>{if("manual"===O&&!R.value)return i("div",{onClick:pe,class:[C.e("header"),C.is("fullscreen",L.value)]},[!e.disabled&&!e.readonly&&i("div",{class:C.em("header","edit"),onClick:de,title:ibiz.i18n.t("editor.markdown.edit")},[i("i",{class:"fa fa-edit","aria-hidden":"true"},null)]),i("div",{class:C.em("header","full"),onClick:le},[L.value?i("i",{class:"fa fa-compress","aria-hidden":"true",title:ibiz.i18n.t("editor.html.reduce")},null):i("i",{class:"fa fa-expand","aria-hidden":"true",title:ibiz.i18n.t("editor.common.fullscreen")},null)])])},renderFooter:()=>{if("manual"===O&&R.value&&!e.disabled&&!e.readonly)return i("div",{onClick:pe,class:[C.e("footer"),C.is("fullscreen",L.value)]},[i("div",{class:C.em("footer","cancel"),onClick:me},[ibiz.i18n.t("editor.common.cancel")]),i("div",{class:C.em("footer","save"),onClick:he},[ibiz.i18n.t("editor.common.confirm")])])},renderImgPreview:M,renderEditorSwitchMenu:()=>{var e;return i("div",{class:[C.b("menu"),C.is("fullscreen",L.value)],style:q.value},[null==(e=l.editorSwitchMenu)?void 0:e.call(l)])}}},render(){const e=!!this.$slots.editorSwitchMenu;return i("div",{ref:"markDownBox",class:[this.ns.b(),this.ns.is("disabled",this.disabled),this.ns.is("manual","manual"===this.showmode),this.ns.is("editing",this.isEditing),this.ns.is("show-editor-switch-menu",e)]},[e?this.renderEditorSwitchMenu():null,this.renderHeader(),this.renderFooter(),this.renderImgPreview(),i("div",{tabindex:"-1",id:this.id,style:this.cssVars,class:[this.ns.b("cherry"),this.ns.m("dark"===this.theme?"dark":"light")]},null)])}}))}}});
|