@ibiz-template/vue3-components 0.7.41-alpha.40 → 0.7.41-alpha.41
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-DEV-iSvz.js +1 -0
- package/dist/index-Bv2fgePf.js +11 -0
- package/dist/{index-BewO9StC.js → index-CD2XM6M6.js} +1 -1
- package/dist/{index-ClxO69TM.js → index-CaWTEUU1.js} +1 -1
- package/dist/index.min.css +1 -1
- package/dist/index.system.min.js +1 -1
- package/dist/wang-editor-4cNAgOaJ.js +1 -0
- package/dist/{xlsx-util-Cg5zMYCC.js → xlsx-util-Dvg2kWh7.js} +1 -1
- package/es/control/form/form-detail/form-item/composite-form-item-ex/composite-form-item-ex.controller.mjs +2 -1
- package/es/control/form/form-detail/form-item/composite-form-item-ex/composite-form-item-ex.css +1 -1
- package/es/control/form/form-detail/form-item/composite-form-item-ex/composite-form-item-ex.mjs +12 -2
- package/es/editor/code/monaco-editor/monaco-editor.mjs +41 -32
- package/es/editor/html/wang-editor/config/index.mjs +3 -0
- package/es/editor/html/wang-editor/config/toolbar.mjs +90 -0
- package/es/editor/html/wang-editor/constants/svg.mjs +8 -0
- package/es/editor/html/wang-editor/wang-editor.css +1 -1
- package/es/editor/html/wang-editor/wang-editor.mjs +52 -39
- package/es/editor/markdown/ibiz-markdown-editor/custom-menu.mjs +264 -2
- package/es/editor/markdown/ibiz-markdown-editor/ibiz-markdown-editor.css +1 -1
- package/es/editor/markdown/ibiz-markdown-editor/ibiz-markdown-editor.mjs +38 -6
- package/es/editor/markdown/ibiz-markdown-editor/render-util.mjs +33 -4
- package/es/editor/text-box/input/input.mjs +41 -32
- package/es/index.mjs +1 -1
- package/es/locale/en/index.mjs +3 -1
- package/es/locale/zh-CN/index.mjs +3 -1
- package/es/util/ai-chat-util/ai-chat-util.mjs +216 -0
- package/es/util/app-util/app-util.mjs +20 -48
- package/es/util/index.mjs +1 -1
- package/es/util/inline-ai-util/inline-ai-textarea/icon.mjs +75 -1
- package/es/util/inline-ai-util/inline-ai-textarea/inline-ai-textarea.css +1 -1
- package/es/util/inline-ai-util/inline-ai-textarea/inline-ai-textarea.hook.mjs +136 -43
- package/es/util/inline-ai-util/inline-ai-textarea/inline-ai-textarea.mjs +130 -48
- package/es/util/inline-ai-util/inline-ai-util.mjs +2 -1
- package/es/web-app/main.mjs +2 -0
- package/lib/control/form/form-detail/form-item/composite-form-item-ex/composite-form-item-ex.cjs +12 -2
- package/lib/control/form/form-detail/form-item/composite-form-item-ex/composite-form-item-ex.controller.cjs +2 -1
- package/lib/control/form/form-detail/form-item/composite-form-item-ex/composite-form-item-ex.css +1 -1
- package/lib/editor/code/monaco-editor/monaco-editor.cjs +40 -31
- package/lib/editor/html/wang-editor/config/index.cjs +7 -0
- package/lib/editor/html/wang-editor/config/toolbar.cjs +92 -0
- package/lib/editor/html/wang-editor/constants/svg.cjs +14 -0
- package/lib/editor/html/wang-editor/wang-editor.cjs +51 -38
- package/lib/editor/html/wang-editor/wang-editor.css +1 -1
- package/lib/editor/markdown/ibiz-markdown-editor/custom-menu.cjs +264 -2
- package/lib/editor/markdown/ibiz-markdown-editor/ibiz-markdown-editor.cjs +38 -6
- package/lib/editor/markdown/ibiz-markdown-editor/ibiz-markdown-editor.css +1 -1
- package/lib/editor/markdown/ibiz-markdown-editor/render-util.cjs +33 -4
- package/lib/editor/text-box/input/input.cjs +40 -31
- package/lib/index.cjs +2 -2
- package/lib/locale/en/index.cjs +3 -1
- package/lib/locale/zh-CN/index.cjs +3 -1
- package/lib/util/ai-chat-util/ai-chat-util.cjs +218 -0
- package/lib/util/app-util/app-util.cjs +19 -47
- package/lib/util/index.cjs +2 -2
- package/lib/util/inline-ai-util/inline-ai-textarea/icon.cjs +78 -0
- package/lib/util/inline-ai-util/inline-ai-textarea/inline-ai-textarea.cjs +129 -47
- package/lib/util/inline-ai-util/inline-ai-textarea/inline-ai-textarea.css +1 -1
- package/lib/util/inline-ai-util/inline-ai-textarea/inline-ai-textarea.hook.cjs +135 -42
- package/lib/util/inline-ai-util/inline-ai-util.cjs +2 -1
- package/lib/web-app/main.cjs +2 -0
- package/package.json +5 -5
- package/dist/ibiz-markdown-editor-CxFS8frQ.js +0 -1
- package/dist/index-2eZnbrr4.js +0 -11
- package/dist/wang-editor-BPl509oX.js +0 -1
- package/es/util/ai-util/ai-util.mjs +0 -68
- package/lib/util/ai-util/ai-util.cjs +0 -71
|
@@ -2,9 +2,15 @@
|
|
|
2
2
|
|
|
3
3
|
var Cherry = require('cherry-markdown');
|
|
4
4
|
var vue = require('vue');
|
|
5
|
+
var qxUtil = require('qx-util');
|
|
6
|
+
var vue3Util = require('@ibiz-template/vue3-util');
|
|
7
|
+
var core = require('@ibiz-template/core');
|
|
8
|
+
var runtime = require('@ibiz-template/runtime');
|
|
5
9
|
|
|
6
10
|
"use strict";
|
|
7
|
-
function initCustomMenu(c) {
|
|
11
|
+
function initCustomMenu(c, opts) {
|
|
12
|
+
const { props, isEditing, currentVal, emit } = opts;
|
|
13
|
+
let chatInstance = opts.chatInstance;
|
|
8
14
|
const AIMenu = Cherry.createMenuHook("AI", {
|
|
9
15
|
icon: {
|
|
10
16
|
type: "svg",
|
|
@@ -39,7 +45,263 @@ function initCustomMenu(c) {
|
|
|
39
45
|
});
|
|
40
46
|
}
|
|
41
47
|
});
|
|
42
|
-
|
|
48
|
+
const AIChart = Cherry.createMenuHook("AIChart", {
|
|
49
|
+
icon: {
|
|
50
|
+
type: "svg",
|
|
51
|
+
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\u57FA\u7840/1.icon\u56FE\u6807/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\u5F62\u72B6\u7ED3\u5408'\n ></path>\n </g>\n </svg>\n "
|
|
52
|
+
},
|
|
53
|
+
onClick: async () => {
|
|
54
|
+
const appDataEntityId = c.model.appDataEntityId;
|
|
55
|
+
if (!appDataEntityId || !c.deACMode)
|
|
56
|
+
return;
|
|
57
|
+
const aiAgentlist = await ibiz.aiChatUtil.getAIAgentList(
|
|
58
|
+
c.context,
|
|
59
|
+
c.params
|
|
60
|
+
);
|
|
61
|
+
const {
|
|
62
|
+
contentToolbarItems,
|
|
63
|
+
footerToolbarItems,
|
|
64
|
+
questionToolbarItems,
|
|
65
|
+
otherToolbarItems
|
|
66
|
+
} = ibiz.aiChatUtil.calcAiToolbarItemsByAc(c.deACMode);
|
|
67
|
+
const { containerOptions, chatOptions } = ibiz.aiChatUtil.getEditorExAIChatParams(
|
|
68
|
+
c.editorParams,
|
|
69
|
+
c.context,
|
|
70
|
+
c.params,
|
|
71
|
+
props.data
|
|
72
|
+
);
|
|
73
|
+
const { zIndex } = vue3Util.useUIStore();
|
|
74
|
+
const containerZIndex = zIndex.increment();
|
|
75
|
+
chatInstance = await ibiz.aiChatUtil.getAIChat();
|
|
76
|
+
let id = "";
|
|
77
|
+
let abortController;
|
|
78
|
+
chatInstance.create({
|
|
79
|
+
containerOptions: {
|
|
80
|
+
zIndex: containerZIndex,
|
|
81
|
+
...containerOptions
|
|
82
|
+
},
|
|
83
|
+
chatOptions: {
|
|
84
|
+
caption: c.deACMode.logicName,
|
|
85
|
+
context: { ...c.context },
|
|
86
|
+
params: { ...c.params, srfactag: c.deACMode.codeName },
|
|
87
|
+
appDataEntityId,
|
|
88
|
+
contentToolbarItems,
|
|
89
|
+
footerToolbarItems,
|
|
90
|
+
questionToolbarItems,
|
|
91
|
+
otherToolbarItems,
|
|
92
|
+
aiAgentlist,
|
|
93
|
+
...chatOptions,
|
|
94
|
+
question: async (aiChat, ctx, param, other, arr, sessionid, srfaiagent, srfmode) => {
|
|
95
|
+
id = qxUtil.createUUID();
|
|
96
|
+
abortController = new AbortController();
|
|
97
|
+
const deService = await ibiz.hub.getApp(ctx.srfappid).deService.getService(ctx, other.appDataEntityId);
|
|
98
|
+
try {
|
|
99
|
+
const questionRequestData = {
|
|
100
|
+
messages: arr,
|
|
101
|
+
sessionid
|
|
102
|
+
};
|
|
103
|
+
if (srfaiagent) {
|
|
104
|
+
questionRequestData.srfaiagent = srfaiagent;
|
|
105
|
+
}
|
|
106
|
+
if (srfmode) {
|
|
107
|
+
questionRequestData.mode = srfmode;
|
|
108
|
+
}
|
|
109
|
+
await deService.aiChatSse(
|
|
110
|
+
(msg) => {
|
|
111
|
+
if (msg.actionstate === 20 && msg.actionresult) {
|
|
112
|
+
aiChat.addMessage({
|
|
113
|
+
messageid: id,
|
|
114
|
+
state: msg.actionstate,
|
|
115
|
+
type: "DEFAULT",
|
|
116
|
+
role: "ASSISTANT",
|
|
117
|
+
content: msg.actionresult
|
|
118
|
+
});
|
|
119
|
+
} else if (msg.actionstate === 30 && msg.actionresult) {
|
|
120
|
+
const result = JSON.parse(msg.actionresult);
|
|
121
|
+
const choices = result.choices;
|
|
122
|
+
if (choices && choices.length > 0) {
|
|
123
|
+
aiChat.replaceMessage({
|
|
124
|
+
messageid: id,
|
|
125
|
+
state: msg.actionstate,
|
|
126
|
+
type: "DEFAULT",
|
|
127
|
+
role: "ASSISTANT",
|
|
128
|
+
content: choices[0].content || ""
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
} else if (msg.actionstate === 40) {
|
|
132
|
+
aiChat.replaceMessage({
|
|
133
|
+
messageid: id,
|
|
134
|
+
state: msg.actionstate,
|
|
135
|
+
type: "ERROR",
|
|
136
|
+
role: "ASSISTANT",
|
|
137
|
+
content: msg.actionresult
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
},
|
|
141
|
+
abortController,
|
|
142
|
+
ctx,
|
|
143
|
+
param,
|
|
144
|
+
{ ...questionRequestData }
|
|
145
|
+
);
|
|
146
|
+
} catch (error) {
|
|
147
|
+
aiChat.replaceMessage({
|
|
148
|
+
messageid: id,
|
|
149
|
+
state: 40,
|
|
150
|
+
type: "ERROR",
|
|
151
|
+
role: "ASSISTANT",
|
|
152
|
+
content: error.message || ibiz.i18n.t("app.aiError")
|
|
153
|
+
});
|
|
154
|
+
abortController == null ? void 0 : abortController.abort();
|
|
155
|
+
} finally {
|
|
156
|
+
aiChat.completeMessage(id, true);
|
|
157
|
+
return true;
|
|
158
|
+
}
|
|
159
|
+
},
|
|
160
|
+
abortQuestion: async (aiChat) => {
|
|
161
|
+
abortController == null ? void 0 : abortController.abort();
|
|
162
|
+
await aiChat.stopMessage({
|
|
163
|
+
messageid: id,
|
|
164
|
+
state: 30,
|
|
165
|
+
type: "DEFAULT",
|
|
166
|
+
role: "ASSISTANT",
|
|
167
|
+
content: ""
|
|
168
|
+
});
|
|
169
|
+
await aiChat.completeMessage(id, true);
|
|
170
|
+
},
|
|
171
|
+
action: (action, message) => {
|
|
172
|
+
if (action === "backfill") {
|
|
173
|
+
if (isEditing.value) {
|
|
174
|
+
currentVal.value = message.realcontent || "";
|
|
175
|
+
} else {
|
|
176
|
+
emit("change", message.realcontent);
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
},
|
|
180
|
+
history: async (ctx, param, other) => {
|
|
181
|
+
const deService = await ibiz.hub.getApp(ctx.srfappid).deService.getService(ctx, other.appDataEntityId);
|
|
182
|
+
const historyRequestData = {};
|
|
183
|
+
if (other.appendCurData) {
|
|
184
|
+
Object.assign(historyRequestData, {
|
|
185
|
+
...other.appendCurData
|
|
186
|
+
});
|
|
187
|
+
}
|
|
188
|
+
if (other.srfaiagent) {
|
|
189
|
+
Object.assign(historyRequestData, {
|
|
190
|
+
srfaiagent: other.srfaiagent
|
|
191
|
+
});
|
|
192
|
+
}
|
|
193
|
+
if (other.srfmode) {
|
|
194
|
+
Object.assign(historyRequestData, {
|
|
195
|
+
mode: other.srfmode
|
|
196
|
+
});
|
|
197
|
+
}
|
|
198
|
+
const result = await deService.aiChatHistory(
|
|
199
|
+
ctx,
|
|
200
|
+
param,
|
|
201
|
+
historyRequestData
|
|
202
|
+
);
|
|
203
|
+
if (result.data && Array.isArray(result.data)) {
|
|
204
|
+
let preMsg;
|
|
205
|
+
result.data.forEach((item) => {
|
|
206
|
+
if (item.role === "TOOL") {
|
|
207
|
+
if (preMsg && item.content) {
|
|
208
|
+
chatInstance.aiChat.updateRecommendPrompt(
|
|
209
|
+
preMsg,
|
|
210
|
+
item.content
|
|
211
|
+
);
|
|
212
|
+
}
|
|
213
|
+
} else {
|
|
214
|
+
const msg = {
|
|
215
|
+
messageid: qxUtil.createUUID(),
|
|
216
|
+
state: 30,
|
|
217
|
+
type: "DEFAULT",
|
|
218
|
+
role: item.role,
|
|
219
|
+
content: item.content,
|
|
220
|
+
completed: true
|
|
221
|
+
};
|
|
222
|
+
preMsg = msg;
|
|
223
|
+
chatInstance.aiChat.addMessage(msg);
|
|
224
|
+
}
|
|
225
|
+
});
|
|
226
|
+
}
|
|
227
|
+
return true;
|
|
228
|
+
},
|
|
229
|
+
recommendPrompt: async (ctx, param, other) => {
|
|
230
|
+
const deService = await ibiz.hub.getApp(ctx.srfappid).deService.getService(ctx, other.appDataEntityId);
|
|
231
|
+
const result = await deService.aiChatRecommendPrompt(
|
|
232
|
+
ctx,
|
|
233
|
+
param,
|
|
234
|
+
other.message
|
|
235
|
+
);
|
|
236
|
+
if (result.ok && result.data) {
|
|
237
|
+
const choices = result.data.choices;
|
|
238
|
+
if (choices && choices.length > 0) {
|
|
239
|
+
return choices[0];
|
|
240
|
+
}
|
|
241
|
+
return null;
|
|
242
|
+
}
|
|
243
|
+
return null;
|
|
244
|
+
},
|
|
245
|
+
uploader: {
|
|
246
|
+
onUpload: async (file, reportProgress, options) => {
|
|
247
|
+
const fileMeata = ibiz.util.file.calcFileUpDownUrl(
|
|
248
|
+
(options == null ? void 0 : options.context) || c.context,
|
|
249
|
+
(options == null ? void 0 : options.params) || c.params,
|
|
250
|
+
{}
|
|
251
|
+
);
|
|
252
|
+
const fielUploadHeaders = ibiz.util.file.getUploadHeaders();
|
|
253
|
+
const formData = new FormData();
|
|
254
|
+
formData.append("file", file);
|
|
255
|
+
const res = await ibiz.net.axios({
|
|
256
|
+
url: fileMeata.uploadUrl,
|
|
257
|
+
method: "post",
|
|
258
|
+
headers: fielUploadHeaders,
|
|
259
|
+
data: formData,
|
|
260
|
+
onUploadProgress: (progressEvent) => {
|
|
261
|
+
const percent = progressEvent.loaded / progressEvent.total * 100;
|
|
262
|
+
reportProgress(percent);
|
|
263
|
+
}
|
|
264
|
+
});
|
|
265
|
+
return res.data;
|
|
266
|
+
}
|
|
267
|
+
},
|
|
268
|
+
extendToolbarClick: async (event, source, context, params, data) => {
|
|
269
|
+
var _a, _b;
|
|
270
|
+
const result = await runtime.UIActionUtil.exec(
|
|
271
|
+
source.id,
|
|
272
|
+
{
|
|
273
|
+
view: c.view,
|
|
274
|
+
ctrl: c.ctrl,
|
|
275
|
+
context: core.IBizContext.create(context),
|
|
276
|
+
params,
|
|
277
|
+
data: [data],
|
|
278
|
+
event
|
|
279
|
+
},
|
|
280
|
+
source.appId
|
|
281
|
+
);
|
|
282
|
+
if (result.closeView) {
|
|
283
|
+
c.view.closeView({ ok: true });
|
|
284
|
+
} else if (result.refresh) {
|
|
285
|
+
switch (result.refreshMode) {
|
|
286
|
+
case 1:
|
|
287
|
+
c.view.callUIAction(runtime.SysUIActionTag.REFRESH);
|
|
288
|
+
break;
|
|
289
|
+
case 2:
|
|
290
|
+
(_a = c.view.parentView) == null ? void 0 : _a.callUIAction(runtime.SysUIActionTag.REFRESH);
|
|
291
|
+
break;
|
|
292
|
+
case 3:
|
|
293
|
+
(_b = c.view.getTopView()) == null ? void 0 : _b.callUIAction(runtime.SysUIActionTag.REFRESH);
|
|
294
|
+
break;
|
|
295
|
+
default:
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
return result;
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
});
|
|
302
|
+
}
|
|
303
|
+
});
|
|
304
|
+
return [AIMenu, AIChart];
|
|
43
305
|
}
|
|
44
306
|
|
|
45
307
|
exports.initCustomMenu = initCustomMenu;
|
|
@@ -25,7 +25,6 @@ const IBizMarkDown = /* @__PURE__ */ vue.defineComponent({
|
|
|
25
25
|
const currentVal = vue.ref("");
|
|
26
26
|
let editor = null;
|
|
27
27
|
const id = qxUtil.createUUID();
|
|
28
|
-
const [AIMenu] = customMenu.initCustomMenu(c);
|
|
29
28
|
const {
|
|
30
29
|
onMDEditorCreated,
|
|
31
30
|
renderImgPreview
|
|
@@ -48,10 +47,20 @@ const IBizMarkDown = /* @__PURE__ */ vue.defineComponent({
|
|
|
48
47
|
const isFullScreen = vue.ref(false);
|
|
49
48
|
const defaultModel = vue.ref("editOnly");
|
|
50
49
|
let resizeObserver = null;
|
|
50
|
+
let toolbarResizeObserver = null;
|
|
51
51
|
let lastMarkDownWidth = 0;
|
|
52
52
|
const cssVars = vue.ref({});
|
|
53
|
+
const toolbarCssVars = vue.ref({});
|
|
53
54
|
const lastDirectoryState = vue.ref("full");
|
|
54
55
|
let isIgnoreChange = false;
|
|
56
|
+
let chatInstance;
|
|
57
|
+
const [AIMenu, AIChart] = customMenu.initCustomMenu(c, {
|
|
58
|
+
props,
|
|
59
|
+
chatInstance,
|
|
60
|
+
isEditing,
|
|
61
|
+
currentVal,
|
|
62
|
+
emit
|
|
63
|
+
});
|
|
55
64
|
vue.watch(() => props.data, (newVal) => {
|
|
56
65
|
if (newVal && c) {
|
|
57
66
|
const editorParams = {
|
|
@@ -264,7 +273,11 @@ const IBizMarkDown = /* @__PURE__ */ vue.defineComponent({
|
|
|
264
273
|
vue.nextTick(() => {
|
|
265
274
|
var _a2;
|
|
266
275
|
const bubble = ["bold", "italic", "underline", "strikethrough", "sub", "sup", "|", "size", "color"];
|
|
276
|
+
const toolbar = ["bold", "italic", "underline", "strikethrough", "|", "color", "header", "|", "list", "image", {
|
|
277
|
+
insert: ["link", "hr", "br", "code", "formula", "toc", "table", "line-table", "bar-table"]
|
|
278
|
+
}, "settings", "togglePreview"];
|
|
267
279
|
if (c && c.chatCompletion) {
|
|
280
|
+
toolbar.unshift("AIChart");
|
|
268
281
|
bubble.unshift("AI");
|
|
269
282
|
}
|
|
270
283
|
editor = new Cherry({
|
|
@@ -300,13 +313,12 @@ const IBizMarkDown = /* @__PURE__ */ vue.defineComponent({
|
|
|
300
313
|
}
|
|
301
314
|
},
|
|
302
315
|
toolbars: {
|
|
303
|
-
toolbar
|
|
304
|
-
insert: ["link", "hr", "br", "code", "formula", "toc", "table", "line-table", "bar-table"]
|
|
305
|
-
}, "settings", "togglePreview"],
|
|
316
|
+
toolbar,
|
|
306
317
|
bubble,
|
|
307
318
|
float: ["h1", "h2", "h3", "|", "checklist", "quote", "quickTable", "code"],
|
|
308
319
|
customMenu: {
|
|
309
|
-
AI: AIMenu
|
|
320
|
+
AI: AIMenu,
|
|
321
|
+
AIChart
|
|
310
322
|
},
|
|
311
323
|
// 定义侧边栏,默认为空
|
|
312
324
|
sidebar: ["theme", "copy"],
|
|
@@ -356,6 +368,19 @@ const IBizMarkDown = /* @__PURE__ */ vue.defineComponent({
|
|
|
356
368
|
parentElement == null ? void 0 : parentElement.appendChild(span);
|
|
357
369
|
c == null ? void 0 : c.setMDEditor(editor);
|
|
358
370
|
onMDEditorCreated(editor);
|
|
371
|
+
if (slots.editorSwitchMenu && window.ResizeObserver && markDownBox.value) {
|
|
372
|
+
const cherryToolbar = markDownBox.value.querySelector(".cherry-toolbar");
|
|
373
|
+
if (cherryToolbar) {
|
|
374
|
+
toolbarResizeObserver = new ResizeObserver((entries) => {
|
|
375
|
+
var _a3;
|
|
376
|
+
const height = (_a3 = entries[0]) == null ? void 0 : _a3.contentRect.height;
|
|
377
|
+
toolbarCssVars.value = ns.cssVarBlock({
|
|
378
|
+
"toolbar-height": "".concat(height, "px")
|
|
379
|
+
});
|
|
380
|
+
});
|
|
381
|
+
toolbarResizeObserver.observe(cherryToolbar);
|
|
382
|
+
}
|
|
383
|
+
}
|
|
359
384
|
});
|
|
360
385
|
};
|
|
361
386
|
vue.watch(() => UIStore.theme, (newVal) => {
|
|
@@ -458,7 +483,8 @@ const IBizMarkDown = /* @__PURE__ */ vue.defineComponent({
|
|
|
458
483
|
const renderEditorSwitchMenu = () => {
|
|
459
484
|
var _a2;
|
|
460
485
|
return vue.createVNode("div", {
|
|
461
|
-
"class": [ns.b("menu"), ns.is("fullscreen", isFullScreen.value)]
|
|
486
|
+
"class": [ns.b("menu"), ns.is("fullscreen", isFullScreen.value)],
|
|
487
|
+
"style": toolbarCssVars.value
|
|
462
488
|
}, [(_a2 = slots.editorSwitchMenu) == null ? void 0 : _a2.call(slots)]);
|
|
463
489
|
};
|
|
464
490
|
vue.onMounted(() => {
|
|
@@ -476,6 +502,12 @@ const IBizMarkDown = /* @__PURE__ */ vue.defineComponent({
|
|
|
476
502
|
if (resizeObserver) {
|
|
477
503
|
resizeObserver.disconnect();
|
|
478
504
|
}
|
|
505
|
+
if (toolbarResizeObserver) {
|
|
506
|
+
toolbarResizeObserver.disconnect();
|
|
507
|
+
}
|
|
508
|
+
if (chatInstance && chatInstance.close) {
|
|
509
|
+
chatInstance.close();
|
|
510
|
+
}
|
|
479
511
|
});
|
|
480
512
|
return {
|
|
481
513
|
ns,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
.ibiz-markdown{--ibiz-markdown-width:100%;--ibiz-markdown-color-manual-toolbar-bg-save:var(--ibiz-color-primary);--ibiz-markdown-color-manual-toolbar-text-save:var(--ibiz-color-primary-active-text);--ibiz-markdown-color-manual-toolbar-text-cancel:var(--ibiz-color-text-1);--ibiz-markdown-color-manual-toolbar-text-cancel-hover:var(--ibiz-color-primary);--ibiz-markdown-color-dark-scrollbar-thumb-dark:rgb(var(--ibiz-grey-4));--ibiz-markdown-color-light-scrollbar-thumb-dark:rgb(var(--ibiz-grey-4));--ibiz-markdown-color-scrollbar-thumb-dark-hover:rgba(var(--ibiz-grey-4), 0.5);--ibiz-markdown-color-dark-toc-text:var(--ibiz-color-fill-0);--ibiz-markdown-color-toc-header-text:var(--ibiz-color-text-0);--ibiz-markdown-color-dark-mardown-border:rgb(var(--ibiz-grey-2));--ibiz-markdown-spacing-manual-toolbar-height:32px;--ibiz-markdown-spacing-manual-toolbar-gap:var(--ibiz-spacing-base);--ibiz-markdown-spacing-manual-toolbar-item-padding:0 var(--ibiz-spacing-base);--ibiz-markdown-spacing-manual-toolbar-margin:var(--ibiz-spacing-base-tight) var(--ibiz-spacing-tight) 0 0;--ibiz-markdown-spacing-manual-toolbar-fullscreen-height:var(--ibiz-height-control-default);--ibiz-markdown-spacing-manual-toolbar-fullscreen-padding:0 var(--ibiz-spacing-extra-loose);--ibiz-markdown-spacing-manual-toolbar-fullscreen-height-header:var(--ibiz-spacing-super-loose);--ibiz-markdown-height-manual-toolbar-height:var(--ibiz-height-control-default);--ibiz-markdown-border-radius-manual-toolbar-item:var(--ibiz-border-radius-small);--ibiz-markdown-border-manual-toolbar-fullscreen-footer:1px solid var(--ibiz-color-border);--ibiz-markdown-img-preview-top:-32px;--ibiz-markdown-img-preview-right:-36px;--ibiz-markdown-img-preview-width:32px;--ibiz-markdown-img-preview-height:32px}.ibiz-markdown__header{display:flex;flex-shrink:0;gap:var(--ibiz-markdown-spacing-manual-toolbar-gap);align-items:center;justify-content:end;height:var(--ibiz-markdown-spacing-manual-toolbar-height)}.ibiz-markdown__header--edit{cursor:pointer}.ibiz-markdown__header--full{cursor:pointer}.ibiz-markdown__header.is-fullscreen{position:fixed;top:0;right:0;left:0;z-index:999;width:100%;height:calc(var(--ibiz-markdown-spacing-manual-toolbar-fullscreen-height-header));padding:var(--ibiz-markdown-spacing-manual-toolbar-fullscreen-padding);margin-top:0;background-color:var(--ibiz-view-bg-color)}.ibiz-markdown__header.is-fullscreen+.ibiz-markdown-cherry .cherry.fullscreen{top:calc(var(--ibiz-markdown-spacing-manual-toolbar-fullscreen-height-header));height:calc(100% - var(--ibiz-markdown-spacing-manual-toolbar-fullscreen-height-header))}.ibiz-markdown__footer{display:flex;gap:var(--ibiz-markdown-spacing-manual-toolbar-gap);align-items:center;justify-content:end;height:var(--ibiz-markdown-spacing-manual-toolbar-height);margin:var(--ibiz-markdown-spacing-manual-toolbar-margin)}.ibiz-markdown__footer--save{height:var(--ibiz-markdown-height-manual-toolbar-height);padding:var(--ibiz-markdown-spacing-manual-toolbar-item-padding);line-height:var(--ibiz-markdown-height-manual-toolbar-height);color:var(--ibiz-markdown-color-manual-toolbar-text-save);text-align:center;cursor:pointer;background-color:var(--ibiz-markdown-color-manual-toolbar-bg-save);border-radius:var(--ibiz-markdown-border-radius-manual-toolbar-item)}.ibiz-markdown__footer--cancel{color:var(--ibiz-markdown-color-manual-toolbar-text-cancel);cursor:pointer}.ibiz-markdown__footer--cancel:hover{color:var(--ibiz-markdown-color-manual-toolbar-text-cancel-hover)}.ibiz-markdown__footer.is-fullscreen{position:fixed;right:0;bottom:0;left:0;z-index:999;width:100%;height:calc(var(--ibiz-markdown-spacing-manual-toolbar-fullscreen-height) * 2);padding:var(--ibiz-markdown-spacing-manual-toolbar-fullscreen-padding);margin-top:0;background-color:var(--ibiz-view-bg-color);border-top:var(--ibiz-markdown-border-manual-toolbar-fullscreen-footer)}.ibiz-markdown__footer.is-fullscreen+.ibiz-markdown-cherry .cherry.fullscreen{height:calc(100% - var(--ibiz-markdown-spacing-manual-toolbar-fullscreen-height) * 2)}.ibiz-markdown__img-preview.el-image{position:absolute;height:0}.ibiz-markdown__img-preview .el-image-viewer__wrapper{width:90%;height:90%;margin:auto}.ibiz-markdown__img-preview .el-image-viewer__mask{position:fixed;width:100vw;height:100vh;cursor:zoom-out;opacity:.7}.ibiz-markdown__img-preview .el-image-viewer__close{top:var(--ibiz-markdown-img-preview-top);right:var(--ibiz-markdown-img-preview-right);width:var(--ibiz-markdown-img-preview-width);height:var(--ibiz-markdown-img-preview-height)}.ibiz-markdown .ibiz-markdown-cherry{width:var(--ibiz-markdown-width);outline:0}.ibiz-markdown .ibiz-markdown-cherry .cherry{width:100%;border:1px solid var(--ibiz-color-border);box-shadow:none}.ibiz-markdown .ibiz-markdown-cherry .cherry .cherry-toolbar{box-shadow:none}.ibiz-markdown .ibiz-markdown-cherry .cherry .cherry-editor{border-top:1px solid var(--ibiz-color-border)}.ibiz-markdown .ibiz-markdown-cherry .cherry .cherry-previewer{border-top:1px solid var(--ibiz-color-border)}.ibiz-markdown .ibiz-markdown-cherry .cherry .cherry-previewer img{cursor:zoom-in}.ibiz-markdown .ibiz-markdown-cherry .cherry .cherry-sidebar{border-left:1px solid var(--ibiz-color-border);box-shadow:none}.ibiz-markdown.is-disabled .cherry{min-height:auto}.ibiz-markdown.is-disabled .ibiz-markdown__fullscreen{position:absolute;top:8px;right:12px;z-index:98;font-size:var(--ibiz-font-size-regular);line-height:2.8}.ibiz-markdown.is-disabled .theme__dark .ibiz-markdown__fullscreen{color:var(--ibiz-color-text-0)}.ibiz-markdown.is-disabled .theme__dark .ibiz-markdown__fullscreen:hover{background-color:var(--ibiz-color-bg-3)}.ibiz-markdown.is-manual{display:flex;flex-direction:column}.ibiz-markdown.is-manual .ibiz-markdown-cherry{flex-grow:1;height:calc(100% - var(--ibiz-markdown-spacing-manual-toolbar-height))!important}.ibiz-markdown.is-manual.is-editing{flex-direction:column-reverse}.ibiz-markdown.is-manual .ibiz-markdown-menu{display:none}.ibiz-markdown.is-manual.is-editing .ibiz-markdown-menu{display:block}.ibiz-markdown.is-show-editor-switch-menu .ibiz-composite-form-item-ex-menu{--ibiz-composite-form-item-ex-menu-height:
|
|
1
|
+
.ibiz-markdown{--ibiz-markdown-width:100%;--ibiz-markdown-color-manual-toolbar-bg-save:var(--ibiz-color-primary);--ibiz-markdown-color-manual-toolbar-text-save:var(--ibiz-color-primary-active-text);--ibiz-markdown-color-manual-toolbar-text-cancel:var(--ibiz-color-text-1);--ibiz-markdown-color-manual-toolbar-text-cancel-hover:var(--ibiz-color-primary);--ibiz-markdown-color-dark-scrollbar-thumb-dark:rgb(var(--ibiz-grey-4));--ibiz-markdown-color-light-scrollbar-thumb-dark:rgb(var(--ibiz-grey-4));--ibiz-markdown-color-scrollbar-thumb-dark-hover:rgba(var(--ibiz-grey-4), 0.5);--ibiz-markdown-color-dark-toc-text:var(--ibiz-color-fill-0);--ibiz-markdown-color-toc-header-text:var(--ibiz-color-text-0);--ibiz-markdown-color-dark-mardown-border:rgb(var(--ibiz-grey-2));--ibiz-markdown-spacing-manual-toolbar-height:32px;--ibiz-markdown-spacing-manual-toolbar-gap:var(--ibiz-spacing-base);--ibiz-markdown-spacing-manual-toolbar-item-padding:0 var(--ibiz-spacing-base);--ibiz-markdown-spacing-manual-toolbar-margin:var(--ibiz-spacing-base-tight) var(--ibiz-spacing-tight) 0 0;--ibiz-markdown-spacing-manual-toolbar-fullscreen-height:var(--ibiz-height-control-default);--ibiz-markdown-spacing-manual-toolbar-fullscreen-padding:0 var(--ibiz-spacing-extra-loose);--ibiz-markdown-spacing-manual-toolbar-fullscreen-height-header:var(--ibiz-spacing-super-loose);--ibiz-markdown-height-manual-toolbar-height:var(--ibiz-height-control-default);--ibiz-markdown-border-radius-manual-toolbar-item:var(--ibiz-border-radius-small);--ibiz-markdown-border-manual-toolbar-fullscreen-footer:1px solid var(--ibiz-color-border);--ibiz-markdown-img-preview-top:-32px;--ibiz-markdown-img-preview-right:-36px;--ibiz-markdown-img-preview-width:32px;--ibiz-markdown-img-preview-height:32px}.ibiz-markdown__header{display:flex;flex-shrink:0;gap:var(--ibiz-markdown-spacing-manual-toolbar-gap);align-items:center;justify-content:end;height:var(--ibiz-markdown-spacing-manual-toolbar-height)}.ibiz-markdown__header--edit{cursor:pointer}.ibiz-markdown__header--full{cursor:pointer}.ibiz-markdown__header.is-fullscreen{position:fixed;top:0;right:0;left:0;z-index:999;width:100%;height:calc(var(--ibiz-markdown-spacing-manual-toolbar-fullscreen-height-header));padding:var(--ibiz-markdown-spacing-manual-toolbar-fullscreen-padding);margin-top:0;background-color:var(--ibiz-view-bg-color)}.ibiz-markdown__header.is-fullscreen+.ibiz-markdown-cherry .cherry.fullscreen{top:calc(var(--ibiz-markdown-spacing-manual-toolbar-fullscreen-height-header));height:calc(100% - var(--ibiz-markdown-spacing-manual-toolbar-fullscreen-height-header))}.ibiz-markdown__footer{display:flex;gap:var(--ibiz-markdown-spacing-manual-toolbar-gap);align-items:center;justify-content:end;height:var(--ibiz-markdown-spacing-manual-toolbar-height);margin:var(--ibiz-markdown-spacing-manual-toolbar-margin)}.ibiz-markdown__footer--save{height:var(--ibiz-markdown-height-manual-toolbar-height);padding:var(--ibiz-markdown-spacing-manual-toolbar-item-padding);line-height:var(--ibiz-markdown-height-manual-toolbar-height);color:var(--ibiz-markdown-color-manual-toolbar-text-save);text-align:center;cursor:pointer;background-color:var(--ibiz-markdown-color-manual-toolbar-bg-save);border-radius:var(--ibiz-markdown-border-radius-manual-toolbar-item)}.ibiz-markdown__footer--cancel{color:var(--ibiz-markdown-color-manual-toolbar-text-cancel);cursor:pointer}.ibiz-markdown__footer--cancel:hover{color:var(--ibiz-markdown-color-manual-toolbar-text-cancel-hover)}.ibiz-markdown__footer.is-fullscreen{position:fixed;right:0;bottom:0;left:0;z-index:999;width:100%;height:calc(var(--ibiz-markdown-spacing-manual-toolbar-fullscreen-height) * 2);padding:var(--ibiz-markdown-spacing-manual-toolbar-fullscreen-padding);margin-top:0;background-color:var(--ibiz-view-bg-color);border-top:var(--ibiz-markdown-border-manual-toolbar-fullscreen-footer)}.ibiz-markdown__footer.is-fullscreen+.ibiz-markdown-cherry .cherry.fullscreen{height:calc(100% - var(--ibiz-markdown-spacing-manual-toolbar-fullscreen-height) * 2)}.ibiz-markdown__img-preview.el-image{position:absolute;height:0}.ibiz-markdown__img-preview .el-image-viewer__wrapper{width:90%;height:90%;margin:auto}.ibiz-markdown__img-preview .el-image-viewer__mask{position:fixed;width:100vw;height:100vh;cursor:zoom-out;opacity:.7}.ibiz-markdown__img-preview .el-image-viewer__close{top:var(--ibiz-markdown-img-preview-top);right:var(--ibiz-markdown-img-preview-right);width:var(--ibiz-markdown-img-preview-width);height:var(--ibiz-markdown-img-preview-height)}.ibiz-markdown .ibiz-markdown-cherry{width:var(--ibiz-markdown-width);outline:0}.ibiz-markdown .ibiz-markdown-cherry .cherry{width:100%;border:1px solid var(--ibiz-color-border);box-shadow:none}.ibiz-markdown .ibiz-markdown-cherry .cherry .cherry-toolbar{box-shadow:none}.ibiz-markdown .ibiz-markdown-cherry .cherry .cherry-editor{border-top:1px solid var(--ibiz-color-border)}.ibiz-markdown .ibiz-markdown-cherry .cherry .cherry-previewer{border-top:1px solid var(--ibiz-color-border)}.ibiz-markdown .ibiz-markdown-cherry .cherry .cherry-previewer img{cursor:zoom-in}.ibiz-markdown .ibiz-markdown-cherry .cherry .cherry-sidebar{border-left:1px solid var(--ibiz-color-border);box-shadow:none}.ibiz-markdown.is-disabled .cherry{min-height:auto}.ibiz-markdown.is-disabled .ibiz-markdown__fullscreen{position:absolute;top:8px;right:12px;z-index:98;font-size:var(--ibiz-font-size-regular);line-height:2.8}.ibiz-markdown.is-disabled .theme__dark .ibiz-markdown__fullscreen{color:var(--ibiz-color-text-0)}.ibiz-markdown.is-disabled .theme__dark .ibiz-markdown__fullscreen:hover{background-color:var(--ibiz-color-bg-3)}.ibiz-markdown.is-manual{display:flex;flex-direction:column}.ibiz-markdown.is-manual .ibiz-markdown-cherry{flex-grow:1;height:calc(100% - var(--ibiz-markdown-spacing-manual-toolbar-height))!important}.ibiz-markdown.is-manual.is-editing{flex-direction:column-reverse}.ibiz-markdown.is-manual .ibiz-markdown-menu{display:none}.ibiz-markdown.is-manual.is-editing .ibiz-markdown-menu{display:block}.ibiz-markdown.is-show-editor-switch-menu .ibiz-composite-form-item-ex-menu{--ibiz-composite-form-item-ex-menu-height:47px;--ibiz-composite-form-item-ex-menu-padding:var(--ibiz-spacing-tight) var(--ibiz-spacing-tight) 0;max-height:100%}.ibiz-markdown.is-show-editor-switch-menu .cherry-toolbar{padding-right:calc(var(--ibiz-composite-form-item-ex-menu-width) + 36px)}.ibiz-markdown.is-show-editor-switch-menu .ibiz-markdown-menu{position:absolute;top:1px;right:37px;z-index:var(--ibiz-composite-form-item-ex-menu-z-index);display:flex;align-items:center;height:calc(var(--ibiz-markdown-toolbar-height) - 1px);background:var(--ibiz-composite-form-item-ex-menu-bg-color);border-right:1px solid var(--ibiz-color-border);border-left:1px solid var(--ibiz-color-border)}.ibiz-markdown.is-show-editor-switch-menu .ibiz-markdown-menu.is-fullscreen{position:fixed;z-index:1000}.ibiz-markdown.is-show-editor-switch-menu .ibiz-markdown-menu .ibiz-composite-form-item-ex-menu{position:relative}.ibiz-markdown .cherry-preview--full{border-left:none}.ibiz-markdown .theme__dark,.ibiz-markdown .theme__light{color:var(--ibiz-form-item-text-color)}.ibiz-markdown .cherry-markdown h1 a::before,.ibiz-markdown .cherry-markdown h2 a::before,.ibiz-markdown .cherry-markdown h3 a::before,.ibiz-markdown .cherry-markdown h4 a::before,.ibiz-markdown .cherry-markdown h5 a::before,.ibiz-markdown .cherry-markdown h6 a::before{display:none}.ibiz-markdown .cherry.fullscreen{z-index:999}.ibiz-markdown--light .theme__green .cherry-toolbar,.ibiz-markdown--light .theme__light .cherry-toolbar,.ibiz-markdown--light .theme__violet .cherry-toolbar{background-color:var(--ibiz-color-bg-0)}.ibiz-markdown--light .theme__dark.cherry .cherry-flex-toc{color:var(--ibiz-markdown-color-toc-header-text)}.ibiz-markdown--light .theme__dark.cherry ::-webkit-scrollbar-thumb{background:var(--ibiz-markdown-color-light-scrollbar-thumb-dark)}.ibiz-markdown--light .theme__dark.cherry ::-webkit-scrollbar-thumb:hover{background:var(--ibiz-markdown-color-scrollbar-thumb-dark-hover)}.ibiz-markdown--dark.ibiz-markdown-cherry .cherry{border:1px solid var(--ibiz-markdown-color-dark-mardown-border)}.ibiz-markdown--dark .theme__green .cherry-toolbar,.ibiz-markdown--dark .theme__light .cherry-toolbar,.ibiz-markdown--dark .theme__violet .cherry-toolbar{background-color:var(--ibiz-color-shadow)}.ibiz-markdown--dark .theme__dark.cherry .cherry-toc-head{color:var(--ibiz-markdown-color-dark-toc-text)}.ibiz-markdown--dark .theme__dark.cherry ::-webkit-scrollbar-thumb{background:var(--ibiz-markdown-color-dark-scrollbar-thumb-dark)}.ibiz-markdown--dark .theme__dark.cherry ::-webkit-scrollbar-thumb:hover{background:var(--ibiz-markdown-color-scrollbar-thumb-dark-hover)}
|
|
@@ -6,6 +6,31 @@ var vue = require('vue');
|
|
|
6
6
|
function isElement(element, nodeName) {
|
|
7
7
|
return !!(element && element.nodeType === 1 && element.nodeName === nodeName);
|
|
8
8
|
}
|
|
9
|
+
function getMermaidSvg(element) {
|
|
10
|
+
let current = element;
|
|
11
|
+
while (current) {
|
|
12
|
+
if (current.classList.contains("cherry-previewer")) {
|
|
13
|
+
return null;
|
|
14
|
+
}
|
|
15
|
+
const parent = current.parentElement;
|
|
16
|
+
if (isElement(current, "svg") && parent && parent.dataset.type === "mermaid") {
|
|
17
|
+
return current;
|
|
18
|
+
}
|
|
19
|
+
current = current.parentElement;
|
|
20
|
+
}
|
|
21
|
+
return null;
|
|
22
|
+
}
|
|
23
|
+
function svgToBase64(svgElement) {
|
|
24
|
+
const clonedSvg = svgElement.cloneNode(true);
|
|
25
|
+
const width = svgElement.width.baseVal.value || svgElement.clientWidth;
|
|
26
|
+
const height = svgElement.height.baseVal.value || svgElement.clientHeight;
|
|
27
|
+
clonedSvg.setAttribute("width", width);
|
|
28
|
+
clonedSvg.setAttribute("height", height);
|
|
29
|
+
clonedSvg.style.backgroundColor = "white";
|
|
30
|
+
const svgString = new XMLSerializer().serializeToString(clonedSvg);
|
|
31
|
+
const base64 = btoa(unescape(encodeURIComponent(svgString)));
|
|
32
|
+
return "data:image/svg+xml;base64,".concat(base64);
|
|
33
|
+
}
|
|
9
34
|
function useImgPreviewRender(ns) {
|
|
10
35
|
const imgPreviewUrl = vue.ref("");
|
|
11
36
|
const imgPreviewUrlList = vue.ref([]);
|
|
@@ -51,10 +76,14 @@ function useImgPreviewRender(ns) {
|
|
|
51
76
|
imgViewerWrapper == null ? void 0 : imgViewerWrapper.removeEventListener("keydown", handleKeyPress);
|
|
52
77
|
};
|
|
53
78
|
const handlePreviewerImgClick = (event) => {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
79
|
+
const target = event == null ? void 0 : event.target;
|
|
80
|
+
if (isElement(target, "IMG") && target) {
|
|
81
|
+
openImgPreview(target.src);
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
const mermaidSvg = getMermaidSvg(target);
|
|
85
|
+
if (mermaidSvg) {
|
|
86
|
+
openImgPreview(svgToBase64(mermaidSvg));
|
|
58
87
|
}
|
|
59
88
|
};
|
|
60
89
|
const renderImgPreview = () => {
|
|
@@ -6,9 +6,7 @@ var vue3Util = require('@ibiz-template/vue3-util');
|
|
|
6
6
|
var runtime = require('@ibiz-template/runtime');
|
|
7
7
|
var core = require('@ibiz-template/core');
|
|
8
8
|
var qxUtil = require('qx-util');
|
|
9
|
-
require('../../../util/index.cjs');
|
|
10
9
|
require('./input.css');
|
|
11
|
-
var aiUtil = require('../../../util/ai-util/ai-util.cjs');
|
|
12
10
|
|
|
13
11
|
"use strict";
|
|
14
12
|
function _isSlot(s) {
|
|
@@ -32,7 +30,6 @@ const IBizInput = /* @__PURE__ */ vue.defineComponent({
|
|
|
32
30
|
if (editorModel.editorType === "TEXTAREA_10") {
|
|
33
31
|
rows.value = 10;
|
|
34
32
|
}
|
|
35
|
-
let autoClose;
|
|
36
33
|
if (c.editorParams) {
|
|
37
34
|
if (c.editorParams.SHOWLIMIT === "false" || c.editorParams.showlimit === "false") {
|
|
38
35
|
showLimit.value = false;
|
|
@@ -40,13 +37,6 @@ const IBizInput = /* @__PURE__ */ vue.defineComponent({
|
|
|
40
37
|
if (c.editorParams.ISAUTO === "true" || c.editorParams.isauto === "true") {
|
|
41
38
|
isAuto.value = true;
|
|
42
39
|
}
|
|
43
|
-
if (c.editorParams.autoclose) {
|
|
44
|
-
try {
|
|
45
|
-
autoClose = JSON.parse(c.editorParams.autoclose);
|
|
46
|
-
} catch (error) {
|
|
47
|
-
ibiz.log.error(error);
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
40
|
}
|
|
51
41
|
const type = vue.computed(() => {
|
|
52
42
|
switch (editorModel.editorType) {
|
|
@@ -181,18 +171,23 @@ const IBizInput = /* @__PURE__ */ vue.defineComponent({
|
|
|
181
171
|
footerToolbarItems,
|
|
182
172
|
questionToolbarItems,
|
|
183
173
|
otherToolbarItems
|
|
184
|
-
} =
|
|
174
|
+
} = ibiz.aiChatUtil.calcAiToolbarItemsByAc(c.deACMode);
|
|
175
|
+
const aiAgentlist = await ibiz.aiChatUtil.getAIAgentList(c.context, c.params);
|
|
176
|
+
const {
|
|
177
|
+
containerOptions,
|
|
178
|
+
chatOptions
|
|
179
|
+
} = ibiz.aiChatUtil.getEditorExAIChatParams(c.editorParams, c.context, c.params, props.data);
|
|
185
180
|
const {
|
|
186
181
|
zIndex
|
|
187
182
|
} = vue3Util.useUIStore();
|
|
188
183
|
const containerZIndex = zIndex.increment();
|
|
189
|
-
|
|
190
|
-
chatInstance = module.chat || module.default.chat;
|
|
184
|
+
chatInstance = await ibiz.aiChatUtil.getAIChat();
|
|
191
185
|
let id = "";
|
|
192
186
|
let abortController;
|
|
193
187
|
chatInstance.create({
|
|
194
188
|
containerOptions: {
|
|
195
|
-
zIndex: containerZIndex
|
|
189
|
+
zIndex: containerZIndex,
|
|
190
|
+
...containerOptions
|
|
196
191
|
},
|
|
197
192
|
chatOptions: {
|
|
198
193
|
caption: c.deACMode.logicName,
|
|
@@ -203,28 +198,28 @@ const IBizInput = /* @__PURE__ */ vue.defineComponent({
|
|
|
203
198
|
...c.params,
|
|
204
199
|
srfactag: c.deACMode.codeName
|
|
205
200
|
},
|
|
206
|
-
// 编辑器参数srfaiappendcurdata,是否传入对象参数,用于历史查询传参
|
|
207
|
-
appendCurData: c.editorParams.srfaiappendcurdata === "true" ? props.data : void 0,
|
|
208
|
-
// 自动提问
|
|
209
|
-
autoQuestion: c.editorParams.autoquestion !== "false",
|
|
210
|
-
// 自动填充
|
|
211
|
-
autoFill: c.editorParams.autofill === "true",
|
|
212
|
-
// 窗口的打开模式
|
|
213
|
-
openMode: c.editorParams.openmode,
|
|
214
|
-
// 窗口的自动关闭模式
|
|
215
|
-
autoClose,
|
|
216
|
-
// 编辑器参数srfaiappendcurcontent,传入编辑内容作为用户消息,获取历史数据后附加
|
|
217
|
-
appendCurContent: c.editorParams.srfaiappendcurcontent ? core.StringUtil.fill(c.editorParams.srfaiappendcurcontent, c.context, c.params, props.data) : void 0,
|
|
218
201
|
appDataEntityId,
|
|
219
202
|
contentToolbarItems,
|
|
220
203
|
footerToolbarItems,
|
|
221
204
|
questionToolbarItems,
|
|
222
205
|
otherToolbarItems,
|
|
223
|
-
|
|
206
|
+
aiAgentlist,
|
|
207
|
+
...chatOptions,
|
|
208
|
+
question: async (aiChat, ctx, param, other, arr, sessionid, srfaiagent, srfmode) => {
|
|
224
209
|
id = qxUtil.createUUID();
|
|
225
210
|
abortController = new AbortController();
|
|
226
211
|
const deService = await ibiz.hub.getApp(ctx.srfappid).deService.getService(ctx, other.appDataEntityId);
|
|
227
212
|
try {
|
|
213
|
+
const questionRequestData = {
|
|
214
|
+
messages: arr,
|
|
215
|
+
sessionid
|
|
216
|
+
};
|
|
217
|
+
if (srfaiagent) {
|
|
218
|
+
questionRequestData.srfaiagent = srfaiagent;
|
|
219
|
+
}
|
|
220
|
+
if (srfmode) {
|
|
221
|
+
questionRequestData.mode = srfmode;
|
|
222
|
+
}
|
|
228
223
|
await deService.aiChatSse((msg) => {
|
|
229
224
|
if (msg.actionstate === 20 && msg.actionresult) {
|
|
230
225
|
aiChat.addMessage({
|
|
@@ -256,8 +251,7 @@ const IBizInput = /* @__PURE__ */ vue.defineComponent({
|
|
|
256
251
|
});
|
|
257
252
|
}
|
|
258
253
|
}, abortController, ctx, param, {
|
|
259
|
-
|
|
260
|
-
sessionid
|
|
254
|
+
...questionRequestData
|
|
261
255
|
});
|
|
262
256
|
} catch (error) {
|
|
263
257
|
aiChat.replaceMessage({
|
|
@@ -290,8 +284,23 @@ const IBizInput = /* @__PURE__ */ vue.defineComponent({
|
|
|
290
284
|
},
|
|
291
285
|
history: async (ctx, param, other) => {
|
|
292
286
|
const deService = await ibiz.hub.getApp(ctx.srfappid).deService.getService(ctx, other.appDataEntityId);
|
|
293
|
-
const
|
|
294
|
-
|
|
287
|
+
const historyRequestData = {};
|
|
288
|
+
if (other.appendCurData) {
|
|
289
|
+
Object.assign(historyRequestData, {
|
|
290
|
+
...other.appendCurData
|
|
291
|
+
});
|
|
292
|
+
}
|
|
293
|
+
if (other.srfaiagent) {
|
|
294
|
+
Object.assign(historyRequestData, {
|
|
295
|
+
srfaiagent: other.srfaiagent
|
|
296
|
+
});
|
|
297
|
+
}
|
|
298
|
+
if (other.srfmode) {
|
|
299
|
+
Object.assign(historyRequestData, {
|
|
300
|
+
mode: other.srfmode
|
|
301
|
+
});
|
|
302
|
+
}
|
|
303
|
+
const result = await deService.aiChatHistory(ctx, param, historyRequestData);
|
|
295
304
|
if (result.data && Array.isArray(result.data)) {
|
|
296
305
|
let preMsg;
|
|
297
306
|
result.data.forEach((item) => {
|
package/lib/index.cjs
CHANGED
|
@@ -180,9 +180,9 @@ var renderUtil = require('./util/render-util/render-util.cjs');
|
|
|
180
180
|
var appUtil = require('./util/app-util/app-util.cjs');
|
|
181
181
|
var fullscreenUtil = require('./util/fullscreen/fullscreen-util.cjs');
|
|
182
182
|
var keydownUtil = require('./util/keydown-util/keydown-util.cjs');
|
|
183
|
-
var aiUtil = require('./util/ai-util/ai-util.cjs');
|
|
184
183
|
var buttonUtil = require('./util/button-util/button-util.cjs');
|
|
185
184
|
var inlineAiUtil = require('./util/inline-ai-util/inline-ai-util.cjs');
|
|
185
|
+
var aiChatUtil = require('./util/ai-chat-util/ai-chat-util.cjs');
|
|
186
186
|
var wangEditorUtil = require('./util/wang-editor-util/wang-editor-util.cjs');
|
|
187
187
|
var icon = require('./util/icon/icon.cjs');
|
|
188
188
|
var authGuard = require('./web-app/guard/auth-guard/auth-guard.cjs');
|
|
@@ -371,9 +371,9 @@ exports.RenderUtil = renderUtil.RenderUtil;
|
|
|
371
371
|
exports.AppUtil = appUtil.AppUtil;
|
|
372
372
|
exports.FullscreenUtil = fullscreenUtil.FullscreenUtil;
|
|
373
373
|
exports.useFocusByEnter = keydownUtil.useFocusByEnter;
|
|
374
|
-
exports.calcAiToolbarItemsByAc = aiUtil.calcAiToolbarItemsByAc;
|
|
375
374
|
exports.convertBtnType = buttonUtil.convertBtnType;
|
|
376
375
|
exports.InLineAIUtil = inlineAiUtil.InLineAIUtil;
|
|
376
|
+
exports.AIChatUtil = aiChatUtil.AIChatUtil;
|
|
377
377
|
exports.parseHtml = wangEditorUtil.parseHtml;
|
|
378
378
|
exports.ArrowLeftBold = icon.ArrowLeftBold;
|
|
379
379
|
exports.ArrowRightBold = icon.ArrowRightBold;
|
package/lib/locale/en/index.cjs
CHANGED
|
@@ -849,7 +849,9 @@ var index = {
|
|
|
849
849
|
info: "The content is generated by AI, please carefully discern.",
|
|
850
850
|
stopEdit: "Terminate editing",
|
|
851
851
|
warningTitle: "Confirm termination",
|
|
852
|
-
warningDesc: "Are you sure to terminate the creation?"
|
|
852
|
+
warningDesc: "Are you sure to terminate the creation?",
|
|
853
|
+
thinking: "In depth thinking",
|
|
854
|
+
thinked: "Deeply pondered"
|
|
853
855
|
}
|
|
854
856
|
},
|
|
855
857
|
// runTime
|
|
@@ -845,7 +845,9 @@ var index = {
|
|
|
845
845
|
info: "\u5185\u5BB9\u7531 AI \u751F\u6210\uFF0C\u8BF7\u4ED4\u7EC6\u7504\u522B\u3002",
|
|
846
846
|
stopEdit: "\u7EC8\u6B62\u7F16\u8F91",
|
|
847
847
|
warningTitle: "\u786E\u8BA4\u4E2D\u6B62",
|
|
848
|
-
warningDesc: "\u786E\u8BA4\u4E2D\u6B62\u521B\u4F5C\u5417\uFF1F"
|
|
848
|
+
warningDesc: "\u786E\u8BA4\u4E2D\u6B62\u521B\u4F5C\u5417\uFF1F",
|
|
849
|
+
thinking: "\u6DF1\u5EA6\u601D\u8003\u4E2D",
|
|
850
|
+
thinked: "\u5DF2\u6DF1\u5EA6\u601D\u8003"
|
|
849
851
|
}
|
|
850
852
|
},
|
|
851
853
|
// runTime
|