@ibiz-template/vue3-components 0.7.41-alpha.42 → 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.
Files changed (40) hide show
  1. package/dist/ibiz-markdown-editor-DJ662N4_.js +1 -0
  2. package/dist/{index-CaWTEUU1.js → index-CG3sQH0b.js} +1 -1
  3. package/dist/index-D3x_MFr-.js +11 -0
  4. package/dist/{index-CD2XM6M6.js → index-kZrZndeH.js} +1 -1
  5. package/dist/index.min.css +1 -1
  6. package/dist/index.system.min.js +1 -1
  7. package/dist/wang-editor-DDSO3Ha9.js +1 -0
  8. package/dist/{xlsx-util-B1eGfH7d.js → xlsx-util-8YSXhmdI.js} +1 -1
  9. package/es/control/toolbar/export-excel/export-excel.mjs +19 -4
  10. package/es/editor/code/monaco-editor/monaco-editor.mjs +6 -194
  11. package/es/editor/html/wang-editor/module/ai-module.mjs +1 -1
  12. package/es/editor/html/wang-editor/wang-editor.mjs +20 -201
  13. package/es/editor/markdown/ibiz-markdown-editor/custom-menu.mjs +7 -223
  14. package/es/editor/text-box/input/input.mjs +9 -197
  15. package/es/locale/en/index.mjs +24 -1
  16. package/es/locale/zh-CN/index.mjs +24 -1
  17. package/es/panel-component/panel-app-title/panel-app-title.mjs +19 -42
  18. package/es/util/ai-chat-util/ai-chat-util.mjs +637 -7
  19. package/es/util/ai-chat-util/ai-feedback/ai-feedback.css +1 -0
  20. package/es/util/ai-chat-util/ai-feedback/ai-feedback.mjs +130 -0
  21. package/es/util/app-util/app-util.mjs +24 -246
  22. package/es/util/inline-ai-util/inline-ai-textarea/inline-ai-textarea.hook.mjs +5 -1
  23. package/lib/control/toolbar/export-excel/export-excel.cjs +18 -3
  24. package/lib/editor/code/monaco-editor/monaco-editor.cjs +6 -194
  25. package/lib/editor/html/wang-editor/module/ai-module.cjs +1 -1
  26. package/lib/editor/html/wang-editor/wang-editor.cjs +19 -200
  27. package/lib/editor/markdown/ibiz-markdown-editor/custom-menu.cjs +7 -223
  28. package/lib/editor/text-box/input/input.cjs +8 -196
  29. package/lib/locale/en/index.cjs +24 -1
  30. package/lib/locale/zh-CN/index.cjs +24 -1
  31. package/lib/panel-component/panel-app-title/panel-app-title.cjs +18 -41
  32. package/lib/util/ai-chat-util/ai-chat-util.cjs +635 -5
  33. package/lib/util/ai-chat-util/ai-feedback/ai-feedback.cjs +132 -0
  34. package/lib/util/ai-chat-util/ai-feedback/ai-feedback.css +1 -0
  35. package/lib/util/app-util/app-util.cjs +23 -245
  36. package/lib/util/inline-ai-util/inline-ai-textarea/inline-ai-textarea.hook.cjs +5 -1
  37. package/package.json +7 -7
  38. package/dist/ibiz-markdown-editor-pEdb_gS_.js +0 -1
  39. package/dist/index-BObZTN7-.js +0 -11
  40. package/dist/wang-editor-Ck-JCWqK.js +0 -1
@@ -1,4 +1,4 @@
1
- import { isVNode, defineComponent, createVNode, resolveComponent, createTextVNode, ref } from 'vue';
1
+ import { isVNode, defineComponent, createVNode, resolveComponent, createTextVNode, ref, onMounted } from 'vue';
2
2
  import { useNamespace } from '@ibiz-template/vue3-util';
3
3
  import { showTitle } from '@ibiz-template/core';
4
4
  import '../../../util/index.mjs';
@@ -29,7 +29,8 @@ const IBizExportExcel = /* @__PURE__ */ defineComponent({
29
29
  required: true
30
30
  },
31
31
  controller: {
32
- type: Object
32
+ type: Object,
33
+ required: true
33
34
  }
34
35
  },
35
36
  emits: ["exportExcel"],
@@ -39,6 +40,15 @@ const IBizExportExcel = /* @__PURE__ */ defineComponent({
39
40
  const ns = useNamespace("export-excel");
40
41
  const startPage = ref(1);
41
42
  const endPage = ref(9999);
43
+ const maxRowCount = ref(1e3);
44
+ const xdataControl = props.controller.xdataControl;
45
+ onMounted(() => {
46
+ if (xdataControl)
47
+ xdataControl.evt.on("onMounted", () => {
48
+ var _a;
49
+ maxRowCount.value = ((_a = xdataControl.dataExport) == null ? void 0 : _a.maxRowCount) || 1e3;
50
+ });
51
+ });
42
52
  const onCommand = (command, e) => {
43
53
  if (!command) {
44
54
  return;
@@ -51,6 +61,7 @@ const IBizExportExcel = /* @__PURE__ */ defineComponent({
51
61
  };
52
62
  return {
53
63
  ns,
64
+ maxRowCount,
54
65
  endPage,
55
66
  startPage,
56
67
  onCommand
@@ -78,7 +89,9 @@ const IBizExportExcel = /* @__PURE__ */ defineComponent({
78
89
  return [createVNode(resolveComponent("el-menu-item"), {
79
90
  "class": this.ns.b("menu-item"),
80
91
  "onClick": (e) => this.onCommand("maxRowCount", e)
81
- }, _isSlot(_slot2 = ibiz.i18n.t("control.toolbar.exportExcel.exportAll")) ? _slot2 : {
92
+ }, _isSlot(_slot2 = ibiz.i18n.t("control.toolbar.exportExcel.exportAll", {
93
+ maxRowCount: this.maxRowCount
94
+ })) ? _slot2 : {
82
95
  default: () => [_slot2]
83
96
  }), createVNode(resolveComponent("el-menu-item"), {
84
97
  "class": this.ns.b("menu-item"),
@@ -154,7 +167,9 @@ const IBizExportExcel = /* @__PURE__ */ defineComponent({
154
167
  return createVNode(resolveComponent("el-dropdown-menu"), null, {
155
168
  default: () => [createVNode(resolveComponent("el-dropdown-item"), {
156
169
  "command": "maxRowCount"
157
- }, _isSlot(_slot7 = ibiz.i18n.t("control.toolbar.exportExcel.exportAll")) ? _slot7 : {
170
+ }, _isSlot(_slot7 = ibiz.i18n.t("control.toolbar.exportExcel.exportAll", {
171
+ maxRowCount: this.maxRowCount
172
+ })) ? _slot7 : {
158
173
  default: () => [_slot7]
159
174
  }), createVNode(resolveComponent("el-dropdown-item"), {
160
175
  "command": "activatedPage"
@@ -3,8 +3,6 @@ import { useNamespace, useUIStore, getEditorEmits, getCodeProps } from '@ibiz-te
3
3
  import { createUUID } from 'qx-util';
4
4
  import { ElMessageBox } from 'element-plus';
5
5
  import '../../../node_modules/.pnpm/@monaco-editor_loader@1.5.0/node_modules/@monaco-editor/loader/lib/es/index.mjs';
6
- import { UIActionUtil, SysUIActionTag } from '@ibiz-template/runtime';
7
- import { IBizContext } from '@ibiz-template/core';
8
6
  import './monaco-editor.css';
9
7
  import loader from '../../../node_modules/.pnpm/@monaco-editor_loader@1.5.0/node_modules/@monaco-editor/loader/lib/es/loader/index.mjs';
10
8
 
@@ -117,20 +115,15 @@ const IBizCode = /* @__PURE__ */ defineComponent({
117
115
  const openAIChat = async () => {
118
116
  if (!c.deACMode || !c.model.appDataEntityId)
119
117
  return;
120
- const aiAgentlist = await ibiz.aiChatUtil.getAIAgentList(c.context, c.params, c.editorParams);
121
- const {
122
- contentToolbarItems,
123
- footerToolbarItems,
124
- questionToolbarItems,
125
- otherToolbarItems
126
- } = ibiz.aiChatUtil.calcAiToolbarItemsByAc(c.deACMode);
118
+ chatInstance = await ibiz.aiChatUtil.getAIChat();
127
119
  const {
128
120
  containerOptions,
129
121
  chatOptions
130
- } = ibiz.aiChatUtil.getEditorExAIChatParams(c.editorParams, c.context, c.params, props.data);
131
- chatInstance = await ibiz.aiChatUtil.getAIChat();
132
- let id = "";
133
- let abortController;
122
+ } = await ibiz.aiChatUtil.getEditorExAIChatParams(c.editorParams, c.context, c.params, props.data, c.deACMode, {
123
+ chatInstance,
124
+ view: c.view,
125
+ ctrl: c.ctrl
126
+ });
134
127
  chatInstance.create({
135
128
  containerOptions: {
136
129
  zIndex: zIndex.increment(),
@@ -146,191 +139,10 @@ const IBizCode = /* @__PURE__ */ defineComponent({
146
139
  srfactag: c.deACMode.codeName
147
140
  },
148
141
  appDataEntityId: c.model.appDataEntityId,
149
- contentToolbarItems,
150
- footerToolbarItems,
151
- questionToolbarItems,
152
- otherToolbarItems,
153
- aiAgentlist,
154
142
  ...chatOptions,
155
- question: async (aiChat, ctx, param, other, arr, sessionid, srfaiagent, srfmode) => {
156
- id = createUUID();
157
- abortController = new AbortController();
158
- const deService = await ibiz.hub.getApp(ctx.srfappid).deService.getService(ctx, other.appDataEntityId);
159
- try {
160
- const questionRequestData = {
161
- messages: arr,
162
- sessionid
163
- };
164
- if (srfaiagent) {
165
- questionRequestData.srfaiagent = srfaiagent;
166
- }
167
- if (srfmode) {
168
- questionRequestData.mode = srfmode;
169
- }
170
- await deService.aiChatSse((msg) => {
171
- if (msg.actionstate === 20 && msg.actionresult) {
172
- aiChat.addMessage({
173
- messageid: id,
174
- state: msg.actionstate,
175
- type: "DEFAULT",
176
- role: "ASSISTANT",
177
- content: msg.actionresult
178
- });
179
- } else if (msg.actionstate === 30 && msg.actionresult) {
180
- const result = JSON.parse(msg.actionresult);
181
- const choices = result.choices;
182
- if (choices && choices.length > 0) {
183
- aiChat.replaceMessage({
184
- messageid: id,
185
- state: msg.actionstate,
186
- type: "DEFAULT",
187
- role: "ASSISTANT",
188
- content: choices[0].content || ""
189
- });
190
- }
191
- } else if (msg.actionstate === 40) {
192
- aiChat.replaceMessage({
193
- messageid: id,
194
- state: msg.actionstate,
195
- type: "ERROR",
196
- role: "ASSISTANT",
197
- content: msg.actionresult
198
- });
199
- }
200
- }, abortController, ctx, param, {
201
- ...questionRequestData
202
- });
203
- } catch (error) {
204
- aiChat.replaceMessage({
205
- messageid: id,
206
- state: 40,
207
- type: "ERROR",
208
- role: "ASSISTANT",
209
- content: error.message || ibiz.i18n.t("app.aiError")
210
- });
211
- abortController == null ? void 0 : abortController.abort();
212
- } finally {
213
- aiChat.completeMessage(id, true);
214
- return true;
215
- }
216
- },
217
- abortQuestion: async (aiChat) => {
218
- abortController == null ? void 0 : abortController.abort();
219
- await aiChat.stopMessage({
220
- messageid: id,
221
- state: 30,
222
- type: "DEFAULT",
223
- role: "ASSISTANT",
224
- content: ""
225
- });
226
- await aiChat.completeMessage(id, true);
227
- },
228
143
  action: (action, message) => {
229
144
  if (action === "backfill")
230
145
  emit("change", message.realcontent);
231
- },
232
- history: async (ctx, param, other) => {
233
- const deService = await ibiz.hub.getApp(ctx.srfappid).deService.getService(ctx, other.appDataEntityId);
234
- const historyRequestData = {};
235
- if (other.appendCurData) {
236
- Object.assign(historyRequestData, {
237
- ...other.appendCurData
238
- });
239
- }
240
- if (other.srfaiagent) {
241
- Object.assign(historyRequestData, {
242
- srfaiagent: other.srfaiagent
243
- });
244
- }
245
- if (other.srfmode) {
246
- Object.assign(historyRequestData, {
247
- mode: other.srfmode
248
- });
249
- }
250
- const result = await deService.aiChatHistory(ctx, param, historyRequestData);
251
- if (result.data && Array.isArray(result.data)) {
252
- let preMsg;
253
- result.data.forEach((item) => {
254
- if (item.role === "TOOL") {
255
- if (preMsg && item.content) {
256
- chatInstance.aiChat.updateRecommendPrompt(preMsg, item.content);
257
- }
258
- } else {
259
- const msg = {
260
- messageid: createUUID(),
261
- state: 30,
262
- type: "DEFAULT",
263
- role: item.role,
264
- content: item.content,
265
- completed: true
266
- };
267
- preMsg = msg;
268
- chatInstance.aiChat.addMessage(msg);
269
- }
270
- });
271
- }
272
- return true;
273
- },
274
- recommendPrompt: async (ctx, param, other) => {
275
- const deService = await ibiz.hub.getApp(ctx.srfappid).deService.getService(ctx, other.appDataEntityId);
276
- const result = await deService.aiChatRecommendPrompt(ctx, param, other.message);
277
- if (result.ok && result.data) {
278
- const choices = result.data.choices;
279
- if (choices && choices.length > 0) {
280
- return choices[0];
281
- }
282
- return null;
283
- }
284
- return null;
285
- },
286
- uploader: {
287
- onUpload: async (file, reportProgress, options) => {
288
- const fileMeata = ibiz.util.file.calcFileUpDownUrl((options == null ? void 0 : options.context) || c.context, (options == null ? void 0 : options.params) || c.params, {});
289
- const uploadHeaders = ibiz.util.file.getUploadHeaders();
290
- const formData = new FormData();
291
- formData.append("file", file);
292
- const res = await ibiz.net.axios({
293
- url: fileMeata.uploadUrl,
294
- method: "post",
295
- headers: uploadHeaders,
296
- data: formData,
297
- onUploadProgress: (progressEvent) => {
298
- const percent = progressEvent.loaded / progressEvent.total * 100;
299
- reportProgress(percent);
300
- }
301
- });
302
- return res.data;
303
- }
304
- },
305
- extendToolbarClick: async (event, source, context, params, data) => {
306
- var _a, _b;
307
- const result = await UIActionUtil.exec(source.id, {
308
- view: c.view,
309
- ctrl: c.ctrl,
310
- context: IBizContext.create(context),
311
- params,
312
- data: [data],
313
- event
314
- }, source.appId);
315
- if (result.closeView) {
316
- c.view.closeView({
317
- ok: true
318
- });
319
- } else if (result.refresh) {
320
- switch (result.refreshMode) {
321
- case 1:
322
- c.view.callUIAction(SysUIActionTag.REFRESH);
323
- break;
324
- case 2:
325
- (_a = c.view.parentView) == null ? void 0 : _a.callUIAction(SysUIActionTag.REFRESH);
326
- break;
327
- case 3:
328
- (_b = c.view.getTopView()) == null ? void 0 : _b.callUIAction(SysUIActionTag.REFRESH);
329
- break;
330
- default:
331
- }
332
- }
333
- return result;
334
146
  }
335
147
  }
336
148
  });
@@ -20,7 +20,7 @@ class AIButtonMenu {
20
20
  * @type {string}
21
21
  * @memberof AIButtonMenu
22
22
  */
23
- __publicField(this, "iconSvg", '<svg xmlns="http://www.w3.org/2000/svg" version="1.1"> <text x="0" y="13" font-size="16" fill="black">AI</text></svg>');
23
+ __publicField(this, "iconSvg", '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" fill="currentColor" height="1em" width="1em" preserveAspectRatio="xMidYMid meet" focusable="false" class="cherry-menu-AIChart"><g id="aae1.Base\u57FA\u7840/1.icon\u56FE\u6807/2.normal/ai-star" stroke-width="1" fill-rule="evenodd"><path 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" id="aae\u5F62\u72B6\u7ED3\u5408"></path></g></svg>');
24
24
  /**
25
25
  *
26
26
  *
@@ -1,10 +1,8 @@
1
1
  import { defineComponent, createVNode, resolveComponent, ref, shallowRef, watch, onBeforeUnmount, onMounted, nextTick, onUnmounted } from 'vue';
2
2
  import { Toolbar, Editor } from '@wangeditor/editor-for-vue';
3
- import { createUUID } from 'qx-util';
4
3
  import { isNil } from 'ramda';
5
4
  import { useNamespace, useUIStore, getEditorEmits, getHtmlProps } from '@ibiz-template/vue3-util';
6
- import { IBizContext, awaitTimeout } from '@ibiz-template/core';
7
- import { UIActionUtil, SysUIActionTag } from '@ibiz-template/runtime';
5
+ import { awaitTimeout } from '@ibiz-template/core';
8
6
  import { ElMessageBox } from 'element-plus';
9
7
  import './module/index.mjs';
10
8
  import './config/index.mjs';
@@ -197,24 +195,19 @@ const IBizHtml = /* @__PURE__ */ defineComponent({
197
195
  const appDataEntityId = c.model.appDataEntityId;
198
196
  if (!appDataEntityId || !c.deACMode)
199
197
  return;
200
- const aiAgentlist = await ibiz.aiChatUtil.getAIAgentList(c.context, c.params, c.editorParams);
201
- const {
202
- contentToolbarItems,
203
- footerToolbarItems,
204
- questionToolbarItems,
205
- otherToolbarItems
206
- } = ibiz.aiChatUtil.calcAiToolbarItemsByAc(c.deACMode);
207
- const {
208
- containerOptions,
209
- chatOptions
210
- } = ibiz.aiChatUtil.getEditorExAIChatParams(c.editorParams, c.context, c.params, props.data);
211
198
  const {
212
199
  zIndex
213
200
  } = useUIStore();
214
201
  const containerZIndex = zIndex.increment();
215
202
  chatInstance = await ibiz.aiChatUtil.getAIChat();
216
- let id = "";
217
- let abortController;
203
+ const {
204
+ containerOptions,
205
+ chatOptions
206
+ } = await ibiz.aiChatUtil.getEditorExAIChatParams(c.editorParams, c.context, c.params, props.data, c.deACMode, {
207
+ chatInstance,
208
+ view: c.view,
209
+ ctrl: c.ctrl
210
+ });
218
211
  chatInstance.create({
219
212
  containerOptions: {
220
213
  zIndex: containerZIndex,
@@ -230,85 +223,7 @@ const IBizHtml = /* @__PURE__ */ defineComponent({
230
223
  srfactag: c.deACMode.codeName
231
224
  },
232
225
  appDataEntityId,
233
- contentToolbarItems,
234
- footerToolbarItems,
235
- questionToolbarItems,
236
- otherToolbarItems,
237
- aiAgentlist,
238
226
  ...chatOptions,
239
- question: async (aiChat, ctx, param, other, arr, sessionid, srfaiagent, srfmode) => {
240
- id = createUUID();
241
- abortController = new AbortController();
242
- const deService = await ibiz.hub.getApp(ctx.srfappid).deService.getService(ctx, other.appDataEntityId);
243
- try {
244
- const questionRequestData = {
245
- messages: arr,
246
- sessionid
247
- };
248
- if (srfaiagent) {
249
- questionRequestData.srfaiagent = srfaiagent;
250
- }
251
- if (srfmode) {
252
- questionRequestData.mode = srfmode;
253
- }
254
- await deService.aiChatSse((msg) => {
255
- if (msg.actionstate === 20 && msg.actionresult) {
256
- aiChat.addMessage({
257
- messageid: id,
258
- state: msg.actionstate,
259
- type: "DEFAULT",
260
- role: "ASSISTANT",
261
- content: msg.actionresult
262
- });
263
- } else if (msg.actionstate === 30 && msg.actionresult) {
264
- const result = JSON.parse(msg.actionresult);
265
- const choices = result.choices;
266
- if (choices && choices.length > 0) {
267
- aiChat.replaceMessage({
268
- messageid: id,
269
- state: msg.actionstate,
270
- type: "DEFAULT",
271
- role: "ASSISTANT",
272
- content: choices[0].content || ""
273
- });
274
- }
275
- } else if (msg.actionstate === 40) {
276
- aiChat.replaceMessage({
277
- messageid: id,
278
- state: msg.actionstate,
279
- type: "ERROR",
280
- role: "ASSISTANT",
281
- content: msg.actionresult
282
- });
283
- }
284
- }, abortController, ctx, param, {
285
- ...questionRequestData
286
- });
287
- } catch (error) {
288
- aiChat.replaceMessage({
289
- messageid: id,
290
- state: 40,
291
- type: "ERROR",
292
- role: "ASSISTANT",
293
- content: error.message || ibiz.i18n.t("app.aiError")
294
- });
295
- abortController == null ? void 0 : abortController.abort();
296
- } finally {
297
- aiChat.completeMessage(id, true);
298
- return true;
299
- }
300
- },
301
- abortQuestion: async (aiChat) => {
302
- abortController == null ? void 0 : abortController.abort();
303
- await aiChat.stopMessage({
304
- messageid: id,
305
- state: 30,
306
- type: "DEFAULT",
307
- role: "ASSISTANT",
308
- content: ""
309
- });
310
- await aiChat.completeMessage(id, true);
311
- },
312
227
  action: (action, message) => {
313
228
  if (action === "backfill") {
314
229
  if (hasEnableEdit.value) {
@@ -317,109 +232,6 @@ const IBizHtml = /* @__PURE__ */ defineComponent({
317
232
  emit("change", message.realcontent);
318
233
  }
319
234
  }
320
- },
321
- history: async (ctx, param, other) => {
322
- const deService = await ibiz.hub.getApp(ctx.srfappid).deService.getService(ctx, other.appDataEntityId);
323
- const historyRequestData = {};
324
- if (other.appendCurData) {
325
- Object.assign(historyRequestData, {
326
- ...other.appendCurData
327
- });
328
- }
329
- if (other.srfaiagent) {
330
- Object.assign(historyRequestData, {
331
- srfaiagent: other.srfaiagent
332
- });
333
- }
334
- if (other.srfmode) {
335
- Object.assign(historyRequestData, {
336
- mode: other.srfmode
337
- });
338
- }
339
- const result = await deService.aiChatHistory(ctx, param, historyRequestData);
340
- if (result.data && Array.isArray(result.data)) {
341
- let preMsg;
342
- result.data.forEach((item) => {
343
- if (item.role === "TOOL") {
344
- if (preMsg && item.content) {
345
- chatInstance.aiChat.updateRecommendPrompt(preMsg, item.content);
346
- }
347
- } else {
348
- const msg = {
349
- messageid: createUUID(),
350
- state: 30,
351
- type: "DEFAULT",
352
- role: item.role,
353
- content: item.content,
354
- completed: true
355
- };
356
- preMsg = msg;
357
- chatInstance.aiChat.addMessage(msg);
358
- }
359
- });
360
- }
361
- return true;
362
- },
363
- recommendPrompt: async (ctx, param, other) => {
364
- const deService = await ibiz.hub.getApp(ctx.srfappid).deService.getService(ctx, other.appDataEntityId);
365
- const result = await deService.aiChatRecommendPrompt(ctx, param, other.message);
366
- if (result.ok && result.data) {
367
- const choices = result.data.choices;
368
- if (choices && choices.length > 0) {
369
- return choices[0];
370
- }
371
- return null;
372
- }
373
- return null;
374
- },
375
- uploader: {
376
- onUpload: async (file, reportProgress, options) => {
377
- const fileMeata = ibiz.util.file.calcFileUpDownUrl((options == null ? void 0 : options.context) || c.context, (options == null ? void 0 : options.params) || c.params, {});
378
- const fielUploadHeaders = ibiz.util.file.getUploadHeaders();
379
- const formData = new FormData();
380
- formData.append("file", file);
381
- const res = await ibiz.net.axios({
382
- url: fileMeata.uploadUrl,
383
- method: "post",
384
- headers: fielUploadHeaders,
385
- data: formData,
386
- onUploadProgress: (progressEvent) => {
387
- const percent = progressEvent.loaded / progressEvent.total * 100;
388
- reportProgress(percent);
389
- }
390
- });
391
- return res.data;
392
- }
393
- },
394
- extendToolbarClick: async (event, source, context, params, data) => {
395
- var _a, _b;
396
- const result = await UIActionUtil.exec(source.id, {
397
- view: c.view,
398
- ctrl: c.ctrl,
399
- context: IBizContext.create(context),
400
- params,
401
- data: [data],
402
- event
403
- }, source.appId);
404
- if (result.closeView) {
405
- c.view.closeView({
406
- ok: true
407
- });
408
- } else if (result.refresh) {
409
- switch (result.refreshMode) {
410
- case 1:
411
- c.view.callUIAction(SysUIActionTag.REFRESH);
412
- break;
413
- case 2:
414
- (_a = c.view.parentView) == null ? void 0 : _a.callUIAction(SysUIActionTag.REFRESH);
415
- break;
416
- case 3:
417
- (_b = c.view.getTopView()) == null ? void 0 : _b.callUIAction(SysUIActionTag.REFRESH);
418
- break;
419
- default:
420
- }
421
- }
422
- return result;
423
235
  }
424
236
  }
425
237
  });
@@ -432,9 +244,16 @@ const IBizHtml = /* @__PURE__ */ defineComponent({
432
244
  onClickAI();
433
245
  });
434
246
  editor.on("lineAiClick", () => {
435
- const selectionPosition = editor.getSelectionPosition();
436
- if (!selectionPosition || !selectionPosition.left || !selectionPosition.top)
247
+ const container = editor.getEditableContainer();
248
+ const hoverToolbar = container.querySelector(".w-e-hover-bar");
249
+ if (!hoverToolbar) {
437
250
  return;
251
+ }
252
+ const {
253
+ offsetLeft,
254
+ offsetTop,
255
+ offsetHeight
256
+ } = hoverToolbar;
438
257
  const items = ibiz.inLineAIUtil.calcContextMenus(c.deACMode, (tag) => {
439
258
  c.doInLineAIUIAction(tag, c.model.appId);
440
259
  });
@@ -447,9 +266,9 @@ const IBizHtml = /* @__PURE__ */ defineComponent({
447
266
  const popoverZIndex = zIndex.increment();
448
267
  ibiz.inLineAIUtil.showContextMenus(
449
268
  // 编辑器的左侧距离+选区距离编辑器左侧距离
450
- editorBoundingClientRect.x + Number(selectionPosition.left.replace("px", "")),
269
+ editorBoundingClientRect.x + offsetLeft,
451
270
  // 编辑器的上方距离+选区距离编辑器上方距离+悬浮工具栏高度
452
- editorBoundingClientRect.y + Number(selectionPosition.top.replace("px", "")) + 42,
271
+ editorBoundingClientRect.y + offsetTop + offsetHeight,
453
272
  items,
454
273
  {
455
274
  zIndex: popoverZIndex,