@ibiz-template/vue3-components 0.7.41-alpha.37 → 0.7.41-alpha.39
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-D4Og0fLv.js +1 -0
- package/dist/{index-BiFsbM1Y.js → index-BewO9StC.js} +1 -1
- package/dist/{index-BFGNWF-0.js → index-ClxO69TM.js} +1 -1
- package/dist/index-DHKZJQyN.js +11 -0
- package/dist/index.min.css +1 -1
- package/dist/index.system.min.js +1 -1
- package/dist/wang-editor-BYeoazrn.js +1 -0
- package/dist/{xlsx-util-DZ5-cWNj.js → xlsx-util-DpgMzatq.js} +1 -1
- package/es/control/form/form-detail/form-item/form-item-container/form-item-container.mjs +42 -8
- package/es/control/form/form-detail/form-mdctrl/form-mdctrl-repeater/form-mdctrl-repeater.mjs +10 -0
- package/es/control/form/form-detail/form-mdctrl/form-mdctrl-repeater/repeater-grid2/repeater-grid2.css +1 -0
- package/es/control/form/form-detail/form-mdctrl/form-mdctrl-repeater/repeater-grid2/repeater-grid2.mjs +309 -0
- package/es/editor/code/code-editor.controller.mjs +223 -1
- package/es/editor/code/monaco-editor/monaco-editor.css +1 -1
- package/es/editor/code/monaco-editor/monaco-editor.mjs +132 -10
- package/es/editor/html/html-editor.controller.mjs +122 -2
- package/es/editor/html/wang-editor/index.mjs +1 -0
- package/es/editor/html/wang-editor/module/index.mjs +1 -0
- package/es/editor/html/wang-editor/module/inline-ai-module.mjs +95 -0
- package/es/editor/html/wang-editor/wang-editor.css +1 -1
- package/es/editor/html/wang-editor/wang-editor.mjs +41 -4
- package/es/editor/markdown/ibiz-markdown-editor/custom-menu.mjs +43 -0
- package/es/editor/markdown/ibiz-markdown-editor/ibiz-markdown-editor.css +1 -1
- package/es/editor/markdown/ibiz-markdown-editor/ibiz-markdown-editor.mjs +143 -9
- package/es/editor/markdown/markdown-editor.controller.mjs +218 -1
- package/es/index.mjs +1 -0
- package/es/locale/en/index.mjs +18 -2
- package/es/locale/zh-CN/index.mjs +18 -2
- package/es/util/ai-util/ai-util.mjs +6 -2
- package/es/util/app-util/app-util.mjs +41 -2
- package/es/util/index.mjs +1 -0
- package/es/util/inline-ai-util/inline-ai-textarea/icon.mjs +142 -0
- package/es/util/inline-ai-util/inline-ai-textarea/inline-ai-textarea.css +1 -0
- package/es/util/inline-ai-util/inline-ai-textarea/inline-ai-textarea.hook.mjs +217 -0
- package/es/util/inline-ai-util/inline-ai-textarea/inline-ai-textarea.mjs +220 -0
- package/es/util/inline-ai-util/inline-ai-util.mjs +145 -0
- package/es/web-app/main.mjs +2 -0
- package/lib/control/form/form-detail/form-item/form-item-container/form-item-container.cjs +42 -8
- package/lib/control/form/form-detail/form-mdctrl/form-mdctrl-repeater/form-mdctrl-repeater.cjs +10 -0
- package/lib/control/form/form-detail/form-mdctrl/form-mdctrl-repeater/repeater-grid2/repeater-grid2.cjs +311 -0
- package/lib/control/form/form-detail/form-mdctrl/form-mdctrl-repeater/repeater-grid2/repeater-grid2.css +1 -0
- package/lib/editor/code/code-editor.controller.cjs +222 -0
- package/lib/editor/code/monaco-editor/monaco-editor.cjs +132 -10
- package/lib/editor/code/monaco-editor/monaco-editor.css +1 -1
- package/lib/editor/html/html-editor.controller.cjs +120 -0
- package/lib/editor/html/wang-editor/index.cjs +3 -0
- package/lib/editor/html/wang-editor/module/index.cjs +3 -0
- package/lib/editor/html/wang-editor/module/inline-ai-module.cjs +98 -0
- package/lib/editor/html/wang-editor/wang-editor.cjs +41 -4
- package/lib/editor/html/wang-editor/wang-editor.css +1 -1
- package/lib/editor/markdown/ibiz-markdown-editor/custom-menu.cjs +45 -0
- package/lib/editor/markdown/ibiz-markdown-editor/ibiz-markdown-editor.cjs +143 -9
- package/lib/editor/markdown/ibiz-markdown-editor/ibiz-markdown-editor.css +1 -1
- package/lib/editor/markdown/markdown-editor.controller.cjs +217 -0
- package/lib/index.cjs +2 -0
- package/lib/locale/en/index.cjs +18 -2
- package/lib/locale/zh-CN/index.cjs +18 -2
- package/lib/util/ai-util/ai-util.cjs +6 -2
- package/lib/util/app-util/app-util.cjs +40 -1
- package/lib/util/index.cjs +2 -0
- package/lib/util/inline-ai-util/inline-ai-textarea/icon.cjs +151 -0
- package/lib/util/inline-ai-util/inline-ai-textarea/inline-ai-textarea.cjs +222 -0
- package/lib/util/inline-ai-util/inline-ai-textarea/inline-ai-textarea.css +1 -0
- package/lib/util/inline-ai-util/inline-ai-textarea/inline-ai-textarea.hook.cjs +222 -0
- package/lib/util/inline-ai-util/inline-ai-util.cjs +147 -0
- package/lib/web-app/main.cjs +2 -0
- package/package.json +5 -5
- package/dist/ibiz-markdown-editor-Cs1m7gKI.js +0 -1
- package/dist/index-Dds3BDDF.js +0 -11
- package/dist/wang-editor-4cJ6X_hb.js +0 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { getDeACMode, calcDeCodeNameById, UIActionUtil, SysUIActionTag, ConfigService } from '@ibiz-template/runtime';
|
|
2
2
|
import { createUUID } from 'qx-util';
|
|
3
|
-
import { IBizContext } from '@ibiz-template/core';
|
|
3
|
+
import { StringUtil, IBizContext } from '@ibiz-template/core';
|
|
4
4
|
import { route2routePath, useUIStore, routePath2string } from '@ibiz-template/vue3-util';
|
|
5
5
|
import { calcAiToolbarItemsByAc } from '../ai-util/ai-util.mjs';
|
|
6
6
|
|
|
@@ -184,6 +184,42 @@ class AppUtil {
|
|
|
184
184
|
}
|
|
185
185
|
return true;
|
|
186
186
|
}
|
|
187
|
+
/**
|
|
188
|
+
* 计算AI扩展参数
|
|
189
|
+
*
|
|
190
|
+
* @private
|
|
191
|
+
* @param {IData} params
|
|
192
|
+
* @return {*} {IData}
|
|
193
|
+
*/
|
|
194
|
+
computeAiExParams(context, params, data) {
|
|
195
|
+
const exParams = {};
|
|
196
|
+
if (params.hasOwnProperty("autoquestion")) {
|
|
197
|
+
exParams.autoQuestion = params.autoquestion !== "false";
|
|
198
|
+
delete params.autoquestion;
|
|
199
|
+
}
|
|
200
|
+
if (params.hasOwnProperty("openmode")) {
|
|
201
|
+
exParams.openMode = params.openmode;
|
|
202
|
+
delete params.openmode;
|
|
203
|
+
}
|
|
204
|
+
if (params.hasOwnProperty("autoclose")) {
|
|
205
|
+
try {
|
|
206
|
+
exParams.autoClose = JSON.parse(params.autoclose);
|
|
207
|
+
delete params.autoclose;
|
|
208
|
+
} catch (error) {
|
|
209
|
+
ibiz.log.error(error);
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
if (params.hasOwnProperty("srfaiappendcurcontent")) {
|
|
213
|
+
exParams.appendCurContent = StringUtil.fill(
|
|
214
|
+
params.srfaiappendcurcontent,
|
|
215
|
+
context,
|
|
216
|
+
params,
|
|
217
|
+
data
|
|
218
|
+
);
|
|
219
|
+
delete params.srfaiappendcurcontent;
|
|
220
|
+
}
|
|
221
|
+
return exParams;
|
|
222
|
+
}
|
|
187
223
|
/**
|
|
188
224
|
* 打开AI聊天
|
|
189
225
|
*
|
|
@@ -201,6 +237,7 @@ class AppUtil {
|
|
|
201
237
|
appDEACModeId,
|
|
202
238
|
appDataEntityId
|
|
203
239
|
} = chartParams;
|
|
240
|
+
const exParams = this.computeAiExParams(context, params, data);
|
|
204
241
|
const deACMode = await getDeACMode(
|
|
205
242
|
appDEACModeId,
|
|
206
243
|
appDataEntityId,
|
|
@@ -449,7 +486,9 @@ class AppUtil {
|
|
|
449
486
|
}
|
|
450
487
|
}
|
|
451
488
|
return result;
|
|
452
|
-
}
|
|
489
|
+
},
|
|
490
|
+
// 扩展参数
|
|
491
|
+
...exParams
|
|
453
492
|
}
|
|
454
493
|
});
|
|
455
494
|
});
|
package/es/util/index.mjs
CHANGED
|
@@ -15,5 +15,6 @@ export { useFocusByEnter } from './keydown-util/keydown-util.mjs';
|
|
|
15
15
|
export { calcAiToolbarItemsByAc } from './ai-util/ai-util.mjs';
|
|
16
16
|
export { convertBtnType } from './button-util/button-util.mjs';
|
|
17
17
|
export { ArrowLeftBold, ArrowRightBold } from './icon/icon.mjs';
|
|
18
|
+
export { InLineAIUtil } from './inline-ai-util/inline-ai-util.mjs';
|
|
18
19
|
|
|
19
20
|
"use strict";
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import { createVNode } from 'vue';
|
|
2
|
+
|
|
3
|
+
"use strict";
|
|
4
|
+
const StopIcon = createVNode("svg", {
|
|
5
|
+
"class": "icon",
|
|
6
|
+
"viewBox": "0 0 1040 1024",
|
|
7
|
+
"version": "1.1",
|
|
8
|
+
"xmlns": "http://www.w3.org/2000/svg",
|
|
9
|
+
"p-id": "12982",
|
|
10
|
+
"width": "16",
|
|
11
|
+
"height": "16",
|
|
12
|
+
"fill": "currentColor"
|
|
13
|
+
}, [createVNode("path", {
|
|
14
|
+
"d": "M528 960C280.576 960 80 759.424 80 512S280.576 64 528 64s448 200.576 448 448-200.576 448-448 448z m-80-592a64 64 0 0 0-64 64v160a64 64 0 0 0 64 64h160a64 64 0 0 0 64-64V432a64 64 0 0 0-64-64H448z",
|
|
15
|
+
"p-id": "12983"
|
|
16
|
+
}, null)]);
|
|
17
|
+
const AIIcon = createVNode("svg", {
|
|
18
|
+
"id": "ai",
|
|
19
|
+
"viewBox": "0 0 16 16",
|
|
20
|
+
"xmlns": "http://www.w3.org/2000/svg",
|
|
21
|
+
"width": "16",
|
|
22
|
+
"height": "16",
|
|
23
|
+
"preserveAspectRatio": "xMidYMid meet",
|
|
24
|
+
"focusable": "false",
|
|
25
|
+
"fill": "currentColor"
|
|
26
|
+
}, [createVNode("g", {
|
|
27
|
+
"id": "aae1.Base\u57FA\u7840/1.icon\u56FE\u6807/2.normal/ai-star",
|
|
28
|
+
"stroke-width": "1",
|
|
29
|
+
"fill-rule": "evenodd"
|
|
30
|
+
}, [createVNode("path", {
|
|
31
|
+
"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",
|
|
32
|
+
"id": "aae\u5F62\u72B6\u7ED3\u5408"
|
|
33
|
+
}, null)])]);
|
|
34
|
+
const SendIcon = createVNode("svg", {
|
|
35
|
+
"id": "send",
|
|
36
|
+
"viewBox": "0 0 16 16",
|
|
37
|
+
"version": "1.1",
|
|
38
|
+
"xmlns": "http://www.w3.org/2000/svg",
|
|
39
|
+
"width": "16",
|
|
40
|
+
"height": "16",
|
|
41
|
+
"preserveAspectRatio": "xMidYMid meet",
|
|
42
|
+
"focusable": "false",
|
|
43
|
+
"fill": "currentColor"
|
|
44
|
+
}, [createVNode("g", {
|
|
45
|
+
"id": "az1.Base\u57FA\u7840/1.icon\u56FE\u6807/2.normal/airplane-fill",
|
|
46
|
+
"stroke-width": "1",
|
|
47
|
+
"fill-rule": "evenodd"
|
|
48
|
+
}, [createVNode("path", {
|
|
49
|
+
"d": "M9.09609607,13.5642768 L13.2170975,15.5669393 C13.4741816,15.6766453 13.7609293,15.517073 13.8004807,15.2378214 L15.9955838,0.48735567 C16.0450231,0.138291234 15.6692847,-0.121013775 15.3726492,0.0585050774 L0.20432945,7.12444843 C-0.0824182488,7.29399401 -0.0626425454,7.7228446 0.233993005,7.87244365 L4.41476499,10.6518549 C4.57297062,10.7216678 4.75095195,10.7017213 4.87949402,10.5820421 L11.7317893,4.66709687 C11.7735964,4.63100873 11.8367429,4.63564485 11.872831,4.67745192 C11.9046123,4.71426959 11.9052944,4.76861446 11.8744472,4.80621817 L5.83087229,12.1735275 L5.83087229,12.1735275 C5.77154518,12.2433404 5.74188162,12.3330998 5.74188162,12.4228593 L5.3388256,15.5669393 C5.32893775,15.9658701 5.82333033,16.1553622 6.08041448,15.8461909 L8.63136704,13.683956 C8.73024556,13.5443302 8.92800259,13.4944639 9.09609607,13.5642768 Z",
|
|
50
|
+
"id": "az\u8DEF\u5F84"
|
|
51
|
+
}, null)])]);
|
|
52
|
+
const RegenerateIcon = createVNode("svg", {
|
|
53
|
+
"viewBox": "0 0 16 16",
|
|
54
|
+
"xmlns": "http://www.w3.org/2000/svg",
|
|
55
|
+
"width": "16",
|
|
56
|
+
"height": "16",
|
|
57
|
+
"preserveAspectRatio": "xMidYMid meet",
|
|
58
|
+
"focusable": "false",
|
|
59
|
+
"fill": "currentColor"
|
|
60
|
+
}, [createVNode("g", {
|
|
61
|
+
"id": "avf1.Base\u57FA\u7840/1.icon\u56FE\u6807/11.editor/redo",
|
|
62
|
+
"stroke-width": "1",
|
|
63
|
+
"fill-rule": "evenodd"
|
|
64
|
+
}, [createVNode("g", {
|
|
65
|
+
"id": "avf\u7F16\u7EC4",
|
|
66
|
+
"transform": "matrix(-1 0 0 1 15.015 1)"
|
|
67
|
+
}, [createVNode("path", {
|
|
68
|
+
"d": "M3.84 5.825a.6.6 0 01.063.774l-.064.075a.6.6 0 01-.774.063l-.074-.063L.176 3.859a.6.6 0 01-.064-.775l.064-.074L3.01.176a.6.6 0 01.912.774l-.063.074-1.795 1.794h6.851a5.1 5.1 0 01.216 10.196l-.216.004h-4a.6.6 0 01-.097-1.192l.097-.008h4a3.9 3.9 0 00.201-7.795l-.2-.005H2.033l1.805 1.807z",
|
|
69
|
+
"id": "avf\u5F62\u72B6\u7ED3\u5408"
|
|
70
|
+
}, null)])])]);
|
|
71
|
+
const insertTextIcon = createVNode("svg", {
|
|
72
|
+
"viewBox": "0 0 16 16",
|
|
73
|
+
"version": "1.1",
|
|
74
|
+
"xmlns": "http://www.w3.org/2000/svg",
|
|
75
|
+
"fill": "currentColor",
|
|
76
|
+
"width": "16",
|
|
77
|
+
"height": "16",
|
|
78
|
+
"preserveAspectRatio": "xMidYMid meet",
|
|
79
|
+
"focusable": "false"
|
|
80
|
+
}, [createVNode("g", {
|
|
81
|
+
"id": "ae1.Base\u57FA\u7840/1.icon\u56FE\u6807/2.normal/insert-below",
|
|
82
|
+
"stroke-width": "1",
|
|
83
|
+
"fill-rule": "evenodd"
|
|
84
|
+
}, [createVNode("path", {
|
|
85
|
+
"d": "M13.4,12.7902394 C13.7313708,12.7902394 14,13.0588685 14,13.3902394 C14,13.7216102 13.7313708,13.9902394 13.4,13.9902394 L9.61247231,13.9902394 C9.28110146,13.9902394 9.01247231,13.7216102 9.01247231,13.3902394 C9.01247231,13.0588685 9.28110146,12.7902394 9.61247231,12.7902394 L13.4,12.7902394 Z M2.64424308,9.33926858 C2.97561393,9.33926858 3.24424308,9.60789773 3.24424308,9.93926858 L3.24424308,11.3602686 L5.96531725,11.3599906 L5.33280173,10.7263268 C5.12191861,10.5154437 5.1008303,10.1866372 5.2695368,9.95216939 L5.33280173,9.87779866 C5.56711631,9.64348408 5.94701529,9.64348408 6.18132987,9.87779866 L7.8400676,11.5365364 C8.07438217,11.770851 8.07438217,12.1507499 7.8400676,12.3850645 L6.4106287,13.8145034 C6.17631412,14.048818 5.79641514,14.048818 5.56210056,13.8145034 C5.32778599,13.5801888 5.32778599,13.2002899 5.56210056,12.9659753 L5.96631725,12.5599906 L2.64424308,12.5608005 C2.31287223,12.5608005 2.04424308,12.2921713 2.04424308,11.9608005 L2.04424308,9.93926858 C2.04424308,9.60789773 2.31287223,9.33926858 2.64424308,9.33926858 Z M13.4,9.19548978 C13.7313708,9.19548978 14,9.46411893 14,9.79548978 C14,10.1268606 13.7313708,10.3954898 13.4,10.3954898 L9.61247231,10.3954898 C9.28110146,10.3954898 9.01247231,10.1268606 9.01247231,9.79548978 C9.01247231,9.46411893 9.28110146,9.19548978 9.61247231,9.19548978 L13.4,9.19548978 Z M13.4,5.60074021 C13.7313708,5.60074021 14,5.86936936 14,6.20074021 C14,6.53211106 13.7313708,6.80074021 13.4,6.80074021 L2.61931725,6.80074021 C2.2879464,6.80074021 2.01931725,6.53211106 2.01931725,6.20074021 C2.01931725,5.86936936 2.2879464,5.60074021 2.61931725,5.60074021 L13.4,5.60074021 Z M13.4,2.00599065 C13.7313708,2.00599065 14,2.2746198 14,2.60599065 C14,2.9373615 13.7313708,3.20599065 13.4,3.20599065 L2.61931725,3.20599065 C2.2879464,3.20599065 2.01931725,2.9373615 2.01931725,2.60599065 C2.01931725,2.2746198 2.2879464,2.00599065 2.61931725,2.00599065 L13.4,2.00599065 Z",
|
|
86
|
+
"id": "ae\u5F62\u72B6\u7ED3\u5408"
|
|
87
|
+
}, null)])]);
|
|
88
|
+
const ReplaceTextIcon = createVNode("svg", {
|
|
89
|
+
"viewBox": "0 0 16 16",
|
|
90
|
+
"version": "1.1",
|
|
91
|
+
"xmlns": "http://www.w3.org/2000/svg",
|
|
92
|
+
"fill": "currentColor",
|
|
93
|
+
"width": "16",
|
|
94
|
+
"height": "16",
|
|
95
|
+
"preserveAspectRatio": "xMidYMid meet",
|
|
96
|
+
"focusable": "false"
|
|
97
|
+
}, [createVNode("g", {
|
|
98
|
+
"id": "ao1.Base\u57FA\u7840/1.icon\u56FE\u6807/2.normal/replace-selection",
|
|
99
|
+
"stroke-width": "1",
|
|
100
|
+
"fill-rule": "evenodd"
|
|
101
|
+
}, [createVNode("path", {
|
|
102
|
+
"d": "M6.61931725,12.8 C6.9506881,12.8 7.21931725,13.0686292 7.21931725,13.4 C7.21931725,13.7313708 6.9506881,14 6.61931725,14 L2.61931725,14 C2.2879464,14 2.01931725,13.7313708 2.01931725,13.4 C2.01931725,13.0686292 2.2879464,12.8 2.61931725,12.8 L6.61931725,12.8 Z M13.882771,9.53617937 L13.9544547,9.59882598 C14.2050411,9.8494124 14.2259233,10.2427187 14.0171013,10.5170918 L13.9544547,10.5887755 L10.6802912,13.862939 C10.6039101,13.93932 10.4806802,13.9412495 10.4019453,13.8672971 L8.52941673,12.1085105 C8.24762538,11.8438358 8.23374956,11.4008376 8.49842422,11.1190462 C8.74104265,10.8607375 9.13350242,10.8275522 9.41427862,11.027682 L9.48788845,11.0880537 L10.5124867,12.0507581 L12.9645052,9.59882598 C13.2150916,9.34823956 13.608398,9.32735736 13.882771,9.53617937 Z M6.61931725,9.20415791 C6.9506881,9.20415791 7.21931725,9.47278706 7.21931725,9.80415791 C7.21931725,10.1355288 6.9506881,10.4041579 6.61931725,10.4041579 L2.61931725,10.4041579 C2.2879464,10.4041579 2.01931725,10.1355288 2.01931725,9.80415791 C2.01931725,9.47278706 2.2879464,9.20415791 2.61931725,9.20415791 L6.61931725,9.20415791 Z M13.4,5.60831582 C13.7313708,5.60831582 14,5.87694497 14,6.20831582 C14,6.53968667 13.7313708,6.80831582 13.4,6.80831582 L2.61931725,6.80831582 C2.2879464,6.80831582 2.01931725,6.53968667 2.01931725,6.20831582 C2.01931725,5.87694497 2.2879464,5.60831582 2.61931725,5.60831582 L13.4,5.60831582 Z M13.4,2.01247373 C13.7313708,2.01247373 14,2.28110288 14,2.61247373 C14,2.94384458 13.7313708,3.21247373 13.4,3.21247373 L2.61931725,3.21247373 C2.2879464,3.21247373 2.01931725,2.94384458 2.01931725,2.61247373 C2.01931725,2.28110288 2.2879464,2.01247373 2.61931725,2.01247373 L13.4,2.01247373 Z",
|
|
103
|
+
"id": "ao\u5F62\u72B6\u7ED3\u5408"
|
|
104
|
+
}, null)])]);
|
|
105
|
+
const CopyTextIcon = createVNode("svg", {
|
|
106
|
+
"viewBox": "0 0 16 16",
|
|
107
|
+
"xmlns": "http://www.w3.org/2000/svg",
|
|
108
|
+
"fill": "currentColor",
|
|
109
|
+
"width": "16",
|
|
110
|
+
"height": "16",
|
|
111
|
+
"preserveAspectRatio": "xMidYMid meet",
|
|
112
|
+
"focusable": "false"
|
|
113
|
+
}, [createVNode("g", {
|
|
114
|
+
"id": "aiqaction/copy",
|
|
115
|
+
"stroke-width": "1",
|
|
116
|
+
"fill-rule": "evenodd"
|
|
117
|
+
}, [createVNode("g", {
|
|
118
|
+
"id": "aiq\u590D\u5236",
|
|
119
|
+
"transform": "translate(2 -.27)",
|
|
120
|
+
"fill-rule": "nonzero"
|
|
121
|
+
}, [createVNode("path", {
|
|
122
|
+
"d": "M5.6 8.47v-1.2h4.174v1.2H5.6zm0 3v-1.2h4.174v1.2H5.6zm-4.4-10v10.075H0L.003 2.27c0-1.088.895-2 1.997-2h7.585v1.2H1.2zm1.8.8h9a1 1 0 011 1v12a1 1 0 01-1 1H3a1 1 0 01-1-1v-12a1 1 0 011-1zm.2 1.2v11.6h8.6V3.47H3.2z",
|
|
123
|
+
"id": "aiq\u5F62\u72B6\u7ED3\u5408"
|
|
124
|
+
}, null)])])]);
|
|
125
|
+
const CancelIcon = createVNode("svg", {
|
|
126
|
+
"viewBox": "0 0 16 16",
|
|
127
|
+
"xmlns": "http://www.w3.org/2000/svg",
|
|
128
|
+
"fill": "currentColor",
|
|
129
|
+
"width": "16",
|
|
130
|
+
"height": "16",
|
|
131
|
+
"preserveAspectRatio": "xMidYMid meet",
|
|
132
|
+
"focusable": "false"
|
|
133
|
+
}, [createVNode("g", {
|
|
134
|
+
"id": "bbhaction/trash",
|
|
135
|
+
"stroke-width": "1",
|
|
136
|
+
"fill-rule": "evenodd"
|
|
137
|
+
}, [createVNode("path", {
|
|
138
|
+
"d": "M4.002 3.403V1a1 1 0 011-1h6.003a1 1 0 011 1v2.403h3.396a.6.6 0 110 1.2h-1.395V15a1 1 0 01-1 1H3a1 1 0 01-1-1V4.603H.6a.6.6 0 110-1.2h3.4zm8.804 1.205H3.2V14.8h9.605V4.608zM5.202 1.2v2.155h5.603V1.2H5.202zm.6 6.417a.6.6 0 011.201 0v4.758a.6.6 0 01-1.2 0V7.617zm3.202 0a.6.6 0 011.2 0v4.758a.6.6 0 01-1.2 0V7.617z",
|
|
139
|
+
"id": "bbh\u5220\u9664"
|
|
140
|
+
}, null)])]);
|
|
141
|
+
|
|
142
|
+
export { AIIcon, CancelIcon, CopyTextIcon, RegenerateIcon, ReplaceTextIcon, SendIcon, StopIcon, insertTextIcon };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.ibiz-inline-ai-container-context-menu{--ibiz-inline-ai-context-menu-color-bg:var(--ibiz-color-bg-2);--ibiz-inline-ai-context-menu-color-text:var(--ibiz-color-text-0);--ibiz-inline-ai-context-menu-color-bg-active:var(--ibiz-color-fill-0);--mx-menu-text:var(--ibiz-inline-ai-context-menu-color-text);--mx-menu-backgroud:var(--ibiz-inline-ai-context-menu-color-bg);--mx-menu-hover-backgroud:var(--ibiz-inline-ai-context-menu-color-bg-active);--mx-menu-hover-text:var(--ibiz-inline-ai-context-menu-color-text);--mx-menu-open-text:var(--ibiz-inline-ai-context-menu-color-text);--mx-menu-open-backgroud:var(--ibiz-inline-ai-context-menu-color-bg-active);--mx-menu-open-hover-text:var(--ibiz-inline-ai-context-menu-color-text);--mx-menu-open-hover-backgroud:var(--ibiz-inline-ai-context-menu-color-bg-active);--mx-menu-active-backgroud:var(--ibiz-inline-ai-context-menu-color-bg-active);--mx-menu-active-text:var(--ibiz-inline-ai-context-menu-color-text);--mx-menu-backgroud-radius:0}.ibiz-inline-ai-container-context-menu .scroll-content{pointer-events:unset}.ibiz-inline-ai-container-context-menu .mx-context-menu-item{cursor:pointer}.ibiz-inline-ai-textarea-container{--ibiz-inline-ai-textarea-container-color-bg-0:rgb(255, 255, 255);--ibiz-inline-ai-textarea-container-color-bg-1:rgb(249, 249, 249);--ibiz-inline-ai-textarea-container-color-border:rgba(29, 31, 35, 0.1);--ibiz-inline-ai-textarea-container-color-text-0:rgb(29, 31, 35);--ibiz-inline-ai-textarea-container-color-text-1:rgba(29, 31, 35, 0.35);--ibiz-inline-ai-textarea-container-color-text-2:rgb(85, 125, 165);--ibiz-inline-ai-textarea-container-color-text-hove-1:rgb(105, 148, 190);--ibiz-inline-ai-textarea-container-color-bg-hover-1:rgb(217, 236, 255);--ibiz-inline-ai-textarea-container-color-bg-hover-2:rgba(46, 50, 55, 0.05);--ibiz-inline-ai-textarea-container-color-loading:#65b3fc}.ibiz-inline-ai-textarea-container--dark{--ibiz-inline-ai-textarea-container-color-bg-0:rgb(28, 28, 28);--ibiz-inline-ai-textarea-container-color-bg-1:rgb(53, 54, 60);--ibiz-inline-ai-textarea-container-color-border:rgba(255, 255, 255, 0.08);--ibiz-inline-ai-textarea-container-color-text-0:rgb(255, 255, 255);--ibiz-inline-ai-textarea-container-color-text-1:rgba(249, 249, 249, 0.35);--ibiz-inline-ai-textarea-container-color-text-2:rgb(70, 107, 144);--ibiz-inline-ai-textarea-container-color-text-hove-1:rgb(105, 148, 190);--ibiz-inline-ai-textarea-container-color-bg-hover-1:rgba(85, 125, 165, 0.2);--ibiz-inline-ai-textarea-container-color-bg-hover-2:rgb(67, 68, 74);--ibiz-inline-ai-textarea-container-color-loading:rgba(204, 204, 204, 0.6)}.ibiz-inline-ai-textarea-container{position:absolute;z-index:2000;color:var(--ibiz-inline-ai-textarea-container-color-text-0);-webkit-user-select:none;-moz-user-select:none;user-select:none}.ibiz-inline-ai-textarea-container .ibiz-inline-ai-textarea-container__content{border:1px solid var(--ibiz-inline-ai-textarea-container-color-border);border-radius:var(--ibiz-border-radius-small);box-shadow:0 0 16px var(--ibiz-color-shadow)}.ibiz-inline-ai-textarea-container.is-show-ai{border:1px solid var(--ibiz-inline-ai-textarea-container-color-border);border-radius:var(--ibiz-border-radius-small);box-shadow:0 0 16px var(--ibiz-color-shadow)}.ibiz-inline-ai-textarea-container.is-show-ai .ibiz-inline-ai-textarea-container__content{border:none;border-radius:var(--ibiz-border-radius-small) var(--ibiz-border-radius-small) 0 0;box-shadow:none}.ibiz-inline-ai-textarea-container.is-show-ai .ibiz-inline-ai-textarea-container__footer{border-radius:0 0 var(--ibiz-border-radius-small) var(--ibiz-border-radius-small)}.ibiz-inline-ai-textarea-container__content{position:relative;display:flex;gap:var(--ibiz-spacing-tight);padding:var(--ibiz-spacing-base-tight);background-color:var(--ibiz-inline-ai-textarea-container-color-bg-0)}.ibiz-inline-ai-textarea-container__content--prefix{flex-shrink:0;color:var(--ibiz-inline-ai-textarea-container-color-text-1)}.ibiz-inline-ai-textarea-container__content--textarea{position:relative;flex-grow:1}.ibiz-inline-ai-textarea-container__content--textarea textarea{width:100%;height:100%;padding:0;color:var(--ibiz-inline-ai-textarea-container-color-text-0);resize:none;background-color:var(--ibiz-inline-ai-textarea-container-color-bg-0);border:none;outline:0}.ibiz-inline-ai-textarea-container__content--textarea textarea:disabled{background-color:var(--ibiz-inline-ai-textarea-container-color-bg-0)}.ibiz-inline-ai-textarea-container__content--suffix{display:flex;flex-direction:column-reverse;flex-shrink:0}.ibiz-inline-ai-textarea-container__content--sand-icon{display:flex;align-items:center;justify-content:center;width:28px;height:28px;color:var(--ibiz-inline-ai-textarea-container-color-text-2);cursor:pointer;border-radius:var(--ibiz-spacing-extra-tight)}.ibiz-inline-ai-textarea-container__content--sand-icon:hover{background-color:var(--ibiz-inline-ai-textarea-container-color-bg-hover-1)}.ibiz-inline-ai-textarea-container__content--stop-icon{display:flex;gap:var(--ibiz-spacing-extra-tight);align-items:center;font-size:var(--ibiz-font-size-small);color:var(--ibiz-inline-ai-textarea-container-color-text-1);cursor:pointer}.ibiz-inline-ai-textarea-container__content--stop-icon:hover{color:var(--ibiz-inline-ai-textarea-container-color-text-hove-1)}.ibiz-inline-ai-textarea-container__footer{padding:var(--ibiz-spacing-base-tight) var(--ibiz-spacing-base);font-size:var(--ibiz-font-size-small);color:var(--ibiz-inline-ai-textarea-container-color-text-1);visibility:hidden;background-color:var(--ibiz-inline-ai-textarea-container-color-bg-1);border-top:1px solid var(--ibiz-inline-ai-textarea-container-color-border)}.ibiz-inline-ai-textarea-container__footer.is-show{visibility:visible}.ibiz-inline-ai-textarea-container__actions{position:absolute;width:240px;padding:var(--ibiz-spacing-base-tight) 0;font-size:var(--ibiz-font-size-regular);visibility:hidden;background-color:var(--ibiz-inline-ai-textarea-container-color-bg-0);border:1px solid var(--ibiz-inline-ai-textarea-container-color-border);border-radius:var(--ibiz-border-radius-small);box-shadow:0 0 16px var(--ibiz-color-shadow)}.ibiz-inline-ai-textarea-container__actions.is-show{visibility:visible}.ibiz-inline-ai-textarea-container__actions--action{display:flex;gap:var(--ibiz-spacing-tight);align-items:center;padding:var(--ibiz-spacing-tight) var(--ibiz-spacing-base-loose);cursor:pointer}.ibiz-inline-ai-textarea-container__actions--action:hover{background-color:var(--ibiz-inline-ai-textarea-container-color-bg-hover-2)}.ibiz-inline-ai-textarea-container__actions--action.is-danger:hover{color:var(--ibiz-color-danger)}.ibiz-inline-ai-textarea-container__actions--divider{margin:var(--ibiz-spacing-extra-tight) var(--ibiz-spacing-base-loose);border-top:1px solid var(--ibiz-inline-ai-textarea-container-color-border)}.ibiz-inline-ai-textarea-container__loading{position:absolute;top:0;left:0;display:flex;gap:8px;align-items:center;width:100%;height:100%;overflow:hidden}@keyframes bounce{0%,100%,80%{transform:scale(0)}40%{transform:scale(1)}}.ibiz-inline-ai-textarea-container__loading--dot{width:12px;height:12px;background:var(--ibiz-inline-ai-textarea-container-color-loading);border-radius:50%;animation:bounce 1.5s infinite ease-in-out}.ibiz-inline-ai-textarea-container__loading--dot:nth-child(2){animation-delay:.2s}.ibiz-inline-ai-textarea-container__loading--dot:nth-child(3){animation-delay:.4s}
|
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
import { onMounted, onUnmounted, ref } from 'vue';
|
|
2
|
+
import { calcResPath } from '@ibiz-template/runtime';
|
|
3
|
+
import { RegenerateIcon, insertTextIcon, ReplaceTextIcon, CopyTextIcon, CancelIcon } from './icon.mjs';
|
|
4
|
+
|
|
5
|
+
"use strict";
|
|
6
|
+
const computedInLineAIParams = (props) => {
|
|
7
|
+
var _a;
|
|
8
|
+
return {
|
|
9
|
+
srfaiappendcurdata: (_a = props.context.srfaiappendcurdata) != null ? _a : true,
|
|
10
|
+
srfaiautoappend: props.params.srfaiautoappend === "true" || props.params.srfaiautoappend === true,
|
|
11
|
+
srfmode: props.params.srfmode,
|
|
12
|
+
srfaiagent: props.params.srfaiagent
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
const useInLineAIContainerClick = (props, content, isLoading) => {
|
|
16
|
+
const handclick = async (evt) => {
|
|
17
|
+
const target = evt.target;
|
|
18
|
+
if (!target.closest(".ibiz-inline-ai-textarea-container") && !target.closest(".ibiz-inline-ai-alert") && !isLoading.value) {
|
|
19
|
+
const isChange = props.content !== content.value;
|
|
20
|
+
let isClose = true;
|
|
21
|
+
if (isChange) {
|
|
22
|
+
isClose = await ibiz.confirm.warning({
|
|
23
|
+
title: ibiz.i18n.t("util.inlineAiUtil.warningTitle"),
|
|
24
|
+
desc: ibiz.i18n.t("util.inlineAiUtil.warningDesc"),
|
|
25
|
+
options: {
|
|
26
|
+
modalClass: "ibiz-inline-ai-alert"
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
if (isClose)
|
|
31
|
+
props.unMountAIChat();
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
onMounted(() => {
|
|
35
|
+
document.addEventListener("click", handclick, true);
|
|
36
|
+
});
|
|
37
|
+
onUnmounted(() => {
|
|
38
|
+
document.removeEventListener("click", handclick, true);
|
|
39
|
+
});
|
|
40
|
+
};
|
|
41
|
+
const useAI = (props, opts) => {
|
|
42
|
+
const { context, data, deACMode } = props;
|
|
43
|
+
const { srfaiappendcurdata, srfmode, srfaiagent } = opts;
|
|
44
|
+
const params = { srfactag: deACMode.codeName };
|
|
45
|
+
const app = ibiz.hub.getApp(deACMode.appId);
|
|
46
|
+
let history = [];
|
|
47
|
+
const calcAIPath = (appDataEntity, isHistories = false) => {
|
|
48
|
+
const srfkey = context[appDataEntity.codeName.toLowerCase()];
|
|
49
|
+
const curPath = "/".concat(appDataEntity.deapicodeName2, "/chatcompletion").concat(isHistories ? "/histories" : "").concat(srfkey ? "/".concat(srfkey) : "");
|
|
50
|
+
const resPath = calcResPath(context, appDataEntity);
|
|
51
|
+
return resPath ? "/".concat(resPath).concat(curPath) : "".concat(curPath);
|
|
52
|
+
};
|
|
53
|
+
const loadAiHistory = async () => {
|
|
54
|
+
const appDataEntity = await ibiz.hub.getAppDataEntity(
|
|
55
|
+
deACMode.appDataEntityId,
|
|
56
|
+
deACMode.appId
|
|
57
|
+
);
|
|
58
|
+
const path = calcAIPath(appDataEntity, true);
|
|
59
|
+
const body = {};
|
|
60
|
+
if (srfaiappendcurdata)
|
|
61
|
+
Object.assign(body, { data });
|
|
62
|
+
if (srfmode)
|
|
63
|
+
Object.assign(body, { mode: srfmode });
|
|
64
|
+
if (srfaiagent)
|
|
65
|
+
Object.assign(body, { srfaiagent });
|
|
66
|
+
const response = await app.net.post(path, body, params);
|
|
67
|
+
if (response.ok && Array.isArray(response.data)) {
|
|
68
|
+
history = response.data.filter(
|
|
69
|
+
(item) => ["USER", "ASSISTANT"].includes(item.role)
|
|
70
|
+
);
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
const askAI = async (content) => {
|
|
74
|
+
var _a, _b;
|
|
75
|
+
const body = {
|
|
76
|
+
messages: [
|
|
77
|
+
...history,
|
|
78
|
+
{
|
|
79
|
+
role: "USER",
|
|
80
|
+
content
|
|
81
|
+
}
|
|
82
|
+
]
|
|
83
|
+
};
|
|
84
|
+
if (srfmode)
|
|
85
|
+
Object.assign(body, { mode: srfmode });
|
|
86
|
+
if (srfaiagent)
|
|
87
|
+
Object.assign(body, { srfaiagent });
|
|
88
|
+
const appDataEntity = await ibiz.hub.getAppDataEntity(
|
|
89
|
+
deACMode.appDataEntityId,
|
|
90
|
+
deACMode.appId
|
|
91
|
+
);
|
|
92
|
+
const path = calcAIPath(appDataEntity);
|
|
93
|
+
const response = await app.net.post(path, body, params);
|
|
94
|
+
if (response.ok) {
|
|
95
|
+
const result = (_b = (_a = response.data.choices) == null ? void 0 : _a[0]) == null ? void 0 : _b.content;
|
|
96
|
+
return result;
|
|
97
|
+
}
|
|
98
|
+
return "";
|
|
99
|
+
};
|
|
100
|
+
onMounted(() => {
|
|
101
|
+
loadAiHistory();
|
|
102
|
+
});
|
|
103
|
+
return {
|
|
104
|
+
askAI
|
|
105
|
+
};
|
|
106
|
+
};
|
|
107
|
+
const useBase = (props, container, target) => {
|
|
108
|
+
const actions = [
|
|
109
|
+
{
|
|
110
|
+
title: ibiz.i18n.t("util.inlineAiUtil.regenerate"),
|
|
111
|
+
icon: RegenerateIcon,
|
|
112
|
+
itemType: "action",
|
|
113
|
+
actionName: "regenerate"
|
|
114
|
+
},
|
|
115
|
+
{
|
|
116
|
+
title: ibiz.i18n.t("util.inlineAiUtil.insertText"),
|
|
117
|
+
icon: insertTextIcon,
|
|
118
|
+
itemType: "action",
|
|
119
|
+
actionName: "insertText"
|
|
120
|
+
},
|
|
121
|
+
{
|
|
122
|
+
title: ibiz.i18n.t("util.inlineAiUtil.replaceText"),
|
|
123
|
+
icon: ReplaceTextIcon,
|
|
124
|
+
itemType: "action",
|
|
125
|
+
actionName: "replaceText"
|
|
126
|
+
},
|
|
127
|
+
{
|
|
128
|
+
itemType: "divider"
|
|
129
|
+
},
|
|
130
|
+
{
|
|
131
|
+
title: ibiz.i18n.t("util.inlineAiUtil.copyText"),
|
|
132
|
+
icon: CopyTextIcon,
|
|
133
|
+
itemType: "action",
|
|
134
|
+
actionName: "copyText"
|
|
135
|
+
},
|
|
136
|
+
{
|
|
137
|
+
title: ibiz.i18n.t("app.cancel"),
|
|
138
|
+
icon: CancelIcon,
|
|
139
|
+
itemType: "action",
|
|
140
|
+
actionName: "cancel"
|
|
141
|
+
}
|
|
142
|
+
];
|
|
143
|
+
const { options } = props;
|
|
144
|
+
const editorRect = options.editorElement.getBoundingClientRect();
|
|
145
|
+
const offsetX = options.left - editorRect.left;
|
|
146
|
+
const offsetY = options.top - editorRect.top;
|
|
147
|
+
const theme = options.editorTheme || "light";
|
|
148
|
+
const actionStyle = ref({});
|
|
149
|
+
const containerStyle = ref({
|
|
150
|
+
width: "".concat(options.width, "px"),
|
|
151
|
+
left: "".concat(options.left, "px"),
|
|
152
|
+
top: "".concat(options.top, "px")
|
|
153
|
+
});
|
|
154
|
+
const contentStyle = ref({
|
|
155
|
+
height: "".concat(options.height || 80, "px"),
|
|
156
|
+
"max-height": "".concat(options.maxHeight, "px")
|
|
157
|
+
});
|
|
158
|
+
const updatePosition = () => {
|
|
159
|
+
if (!container.value || !target.value)
|
|
160
|
+
return;
|
|
161
|
+
const rect = options.editorElement.getBoundingClientRect();
|
|
162
|
+
let top = rect.top + offsetY;
|
|
163
|
+
let left = rect.left + offsetX;
|
|
164
|
+
const containerWidth = container.value.offsetWidth;
|
|
165
|
+
const containerHeight = container.value.offsetHeight;
|
|
166
|
+
const windowWidth = window.innerWidth;
|
|
167
|
+
const windowHeight = window.innerHeight;
|
|
168
|
+
const margin = 8;
|
|
169
|
+
if (left + containerWidth + margin > windowWidth) {
|
|
170
|
+
left = windowWidth - containerWidth - margin;
|
|
171
|
+
} else if (left < margin) {
|
|
172
|
+
left = margin;
|
|
173
|
+
}
|
|
174
|
+
if (top + containerHeight + margin > windowHeight) {
|
|
175
|
+
top = windowHeight - containerHeight - margin;
|
|
176
|
+
} else if (top < margin) {
|
|
177
|
+
top = margin;
|
|
178
|
+
}
|
|
179
|
+
containerStyle.value.top = "".concat(top, "px");
|
|
180
|
+
containerStyle.value.left = "".concat(left, "px");
|
|
181
|
+
const position = containerHeight + 4;
|
|
182
|
+
const targetHeight = target.value.offsetHeight;
|
|
183
|
+
if (windowHeight - (top + containerHeight + targetHeight) > margin) {
|
|
184
|
+
actionStyle.value.top = "".concat(position, "px");
|
|
185
|
+
actionStyle.value.bottom = "auto";
|
|
186
|
+
} else {
|
|
187
|
+
actionStyle.value.bottom = "".concat(position, "px");
|
|
188
|
+
actionStyle.value.top = "auto";
|
|
189
|
+
}
|
|
190
|
+
};
|
|
191
|
+
let ticking = false;
|
|
192
|
+
const optimizedUpdatePosition = () => {
|
|
193
|
+
if (!ticking) {
|
|
194
|
+
requestAnimationFrame(() => {
|
|
195
|
+
updatePosition();
|
|
196
|
+
ticking = false;
|
|
197
|
+
});
|
|
198
|
+
ticking = true;
|
|
199
|
+
}
|
|
200
|
+
};
|
|
201
|
+
onMounted(() => {
|
|
202
|
+
updatePosition();
|
|
203
|
+
document.addEventListener("scroll", optimizedUpdatePosition, {
|
|
204
|
+
capture: true
|
|
205
|
+
});
|
|
206
|
+
window.addEventListener("resize", optimizedUpdatePosition);
|
|
207
|
+
});
|
|
208
|
+
onUnmounted(() => {
|
|
209
|
+
document.removeEventListener("scroll", optimizedUpdatePosition, {
|
|
210
|
+
capture: true
|
|
211
|
+
});
|
|
212
|
+
window.removeEventListener("resize", optimizedUpdatePosition);
|
|
213
|
+
});
|
|
214
|
+
return { theme, actions, actionStyle, containerStyle, contentStyle };
|
|
215
|
+
};
|
|
216
|
+
|
|
217
|
+
export { computedInLineAIParams, useAI, useBase, useInLineAIContainerClick };
|
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
import { defineComponent, createVNode, withDirectives, vModelText, ref, computed, onMounted } from 'vue';
|
|
2
|
+
import { useNamespace } from '@ibiz-template/vue3-util';
|
|
3
|
+
import { computedInLineAIParams, useBase, useInLineAIContainerClick, useAI } from './inline-ai-textarea.hook.mjs';
|
|
4
|
+
import { AIIcon, StopIcon, SendIcon } from './icon.mjs';
|
|
5
|
+
import './inline-ai-textarea.css';
|
|
6
|
+
|
|
7
|
+
"use strict";
|
|
8
|
+
const InlineAITextArea = /* @__PURE__ */ defineComponent({
|
|
9
|
+
props: {
|
|
10
|
+
context: {
|
|
11
|
+
type: Object,
|
|
12
|
+
required: true
|
|
13
|
+
},
|
|
14
|
+
params: {
|
|
15
|
+
type: Object,
|
|
16
|
+
required: true
|
|
17
|
+
},
|
|
18
|
+
data: {
|
|
19
|
+
type: Object,
|
|
20
|
+
required: true
|
|
21
|
+
},
|
|
22
|
+
content: {
|
|
23
|
+
type: String,
|
|
24
|
+
required: true
|
|
25
|
+
},
|
|
26
|
+
deACMode: {
|
|
27
|
+
type: Object,
|
|
28
|
+
required: true
|
|
29
|
+
},
|
|
30
|
+
options: {
|
|
31
|
+
type: Object,
|
|
32
|
+
required: true
|
|
33
|
+
},
|
|
34
|
+
insertText: {
|
|
35
|
+
type: Function,
|
|
36
|
+
required: true
|
|
37
|
+
},
|
|
38
|
+
replaceSelectionText: {
|
|
39
|
+
type: Function,
|
|
40
|
+
required: true
|
|
41
|
+
},
|
|
42
|
+
restoreSelection: {
|
|
43
|
+
type: Function,
|
|
44
|
+
required: true
|
|
45
|
+
},
|
|
46
|
+
unMountAIChat: {
|
|
47
|
+
type: Function,
|
|
48
|
+
required: true
|
|
49
|
+
}
|
|
50
|
+
},
|
|
51
|
+
setup(props, ctx) {
|
|
52
|
+
const ns = useNamespace("inline-ai-textarea-container");
|
|
53
|
+
const containerRef = ref();
|
|
54
|
+
const actionsRef = ref();
|
|
55
|
+
const textareaRef = ref();
|
|
56
|
+
const textareaContent = ref(props.content);
|
|
57
|
+
let question;
|
|
58
|
+
const contentType = ref("USER");
|
|
59
|
+
const isLoading = ref(false);
|
|
60
|
+
const disabled = computed(() => {
|
|
61
|
+
return contentType.value === "ASSISTANT" || isLoading.value;
|
|
62
|
+
});
|
|
63
|
+
const isShow = computed(() => {
|
|
64
|
+
return contentType.value === "ASSISTANT" && !isLoading.value;
|
|
65
|
+
});
|
|
66
|
+
const {
|
|
67
|
+
srfaiappendcurdata,
|
|
68
|
+
srfaiautoappend,
|
|
69
|
+
srfmode,
|
|
70
|
+
srfaiagent
|
|
71
|
+
} = computedInLineAIParams(props);
|
|
72
|
+
const {
|
|
73
|
+
theme,
|
|
74
|
+
actions,
|
|
75
|
+
actionStyle,
|
|
76
|
+
containerStyle,
|
|
77
|
+
contentStyle
|
|
78
|
+
} = useBase(props, containerRef, actionsRef);
|
|
79
|
+
useInLineAIContainerClick(props, textareaContent, isLoading);
|
|
80
|
+
const {
|
|
81
|
+
askAI
|
|
82
|
+
} = useAI(props, {
|
|
83
|
+
srfaiappendcurdata,
|
|
84
|
+
srfmode,
|
|
85
|
+
srfaiagent
|
|
86
|
+
});
|
|
87
|
+
const restoreFocus = () => {
|
|
88
|
+
var _a;
|
|
89
|
+
(_a = textareaRef.value) == null ? void 0 : _a.blur();
|
|
90
|
+
props.restoreSelection();
|
|
91
|
+
};
|
|
92
|
+
const sendQuestion = async (content) => {
|
|
93
|
+
restoreFocus();
|
|
94
|
+
question = content;
|
|
95
|
+
textareaContent.value = "";
|
|
96
|
+
isLoading.value = true;
|
|
97
|
+
textareaContent.value = await askAI(question);
|
|
98
|
+
isLoading.value = false;
|
|
99
|
+
contentType.value = "ASSISTANT";
|
|
100
|
+
};
|
|
101
|
+
const stopQuestion = () => {
|
|
102
|
+
props.unMountAIChat();
|
|
103
|
+
};
|
|
104
|
+
const onKeydown = (e) => {
|
|
105
|
+
if (e.code === "Enter" && !e.isComposing) {
|
|
106
|
+
e.stopPropagation();
|
|
107
|
+
if (e.shiftKey === false) {
|
|
108
|
+
sendQuestion(textareaContent.value);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
};
|
|
112
|
+
const handleAction = (_e, actionName) => {
|
|
113
|
+
const content = textareaContent.value;
|
|
114
|
+
switch (actionName) {
|
|
115
|
+
case "regenerate":
|
|
116
|
+
sendQuestion(question);
|
|
117
|
+
break;
|
|
118
|
+
case "insertText":
|
|
119
|
+
props.insertText(content);
|
|
120
|
+
props.unMountAIChat();
|
|
121
|
+
break;
|
|
122
|
+
case "replaceText":
|
|
123
|
+
props.replaceSelectionText(content);
|
|
124
|
+
props.unMountAIChat();
|
|
125
|
+
break;
|
|
126
|
+
case "copyText":
|
|
127
|
+
ibiz.util.text.copy(content);
|
|
128
|
+
props.unMountAIChat();
|
|
129
|
+
break;
|
|
130
|
+
case "cancel":
|
|
131
|
+
props.unMountAIChat();
|
|
132
|
+
break;
|
|
133
|
+
default:
|
|
134
|
+
break;
|
|
135
|
+
}
|
|
136
|
+
};
|
|
137
|
+
onMounted(() => {
|
|
138
|
+
var _a;
|
|
139
|
+
if (srfaiautoappend) {
|
|
140
|
+
sendQuestion(textareaContent.value);
|
|
141
|
+
} else {
|
|
142
|
+
(_a = textareaRef.value) == null ? void 0 : _a.focus();
|
|
143
|
+
}
|
|
144
|
+
});
|
|
145
|
+
return {
|
|
146
|
+
ns,
|
|
147
|
+
theme,
|
|
148
|
+
isShow,
|
|
149
|
+
actions,
|
|
150
|
+
disabled,
|
|
151
|
+
isLoading,
|
|
152
|
+
actionsRef,
|
|
153
|
+
textareaRef,
|
|
154
|
+
actionStyle,
|
|
155
|
+
contentType,
|
|
156
|
+
containerRef,
|
|
157
|
+
contentStyle,
|
|
158
|
+
containerStyle,
|
|
159
|
+
textareaContent,
|
|
160
|
+
onKeydown,
|
|
161
|
+
sendQuestion,
|
|
162
|
+
stopQuestion,
|
|
163
|
+
handleAction
|
|
164
|
+
};
|
|
165
|
+
},
|
|
166
|
+
render() {
|
|
167
|
+
return createVNode("div", {
|
|
168
|
+
"ref": "containerRef",
|
|
169
|
+
"style": this.containerStyle,
|
|
170
|
+
"class": [this.ns.b(), this.ns.m(this.theme), this.ns.is("show-ai", this.isShow)]
|
|
171
|
+
}, [createVNode("div", {
|
|
172
|
+
"class": this.ns.e("content"),
|
|
173
|
+
"style": this.contentStyle
|
|
174
|
+
}, [!this.disabled && createVNode("div", {
|
|
175
|
+
"class": this.ns.em("content", "prefix")
|
|
176
|
+
}, [createVNode("div", {
|
|
177
|
+
"class": this.ns.em("content", "ai-icon")
|
|
178
|
+
}, [AIIcon])]), createVNode("div", {
|
|
179
|
+
"class": this.ns.em("content", "textarea")
|
|
180
|
+
}, [this.isLoading && createVNode("div", {
|
|
181
|
+
"class": this.ns.e("loading")
|
|
182
|
+
}, [createVNode("div", {
|
|
183
|
+
"class": this.ns.em("loading", "dot")
|
|
184
|
+
}, null), createVNode("div", {
|
|
185
|
+
"class": this.ns.em("loading", "dot")
|
|
186
|
+
}, null), createVNode("div", {
|
|
187
|
+
"class": this.ns.em("loading", "dot")
|
|
188
|
+
}, null)]), withDirectives(createVNode("textarea", {
|
|
189
|
+
"ref": "textareaRef",
|
|
190
|
+
"disabled": this.disabled,
|
|
191
|
+
"onKeydown": this.onKeydown,
|
|
192
|
+
"onUpdate:modelValue": ($event) => this.textareaContent = $event
|
|
193
|
+
}, null), [[vModelText, this.textareaContent]])]), createVNode("div", {
|
|
194
|
+
"class": this.ns.em("content", "suffix")
|
|
195
|
+
}, [this.isLoading && createVNode("div", {
|
|
196
|
+
"class": this.ns.em("content", "stop-icon"),
|
|
197
|
+
"onClick": () => this.stopQuestion()
|
|
198
|
+
}, [StopIcon, createVNode("span", null, [ibiz.i18n.t("util.inlineAiUtil.stopEdit")])]), !this.disabled && createVNode("div", {
|
|
199
|
+
"class": this.ns.em("content", "sand-icon"),
|
|
200
|
+
"onClick": () => this.sendQuestion(this.textareaContent)
|
|
201
|
+
}, [SendIcon])])]), createVNode("div", {
|
|
202
|
+
"class": [this.ns.e("footer"), this.ns.is("show", this.isShow)]
|
|
203
|
+
}, [ibiz.i18n.t("util.inlineAiUtil.info")]), createVNode("div", {
|
|
204
|
+
"ref": "actionsRef",
|
|
205
|
+
"class": [this.ns.e("actions"), this.ns.is("show", this.isShow)],
|
|
206
|
+
"style": this.actionStyle
|
|
207
|
+
}, [this.actions.map((action) => {
|
|
208
|
+
if (action.itemType === "divider")
|
|
209
|
+
return createVNode("div", {
|
|
210
|
+
"class": this.ns.em("actions", action.itemType)
|
|
211
|
+
}, null);
|
|
212
|
+
return createVNode("div", {
|
|
213
|
+
"class": [this.ns.em("actions", action.itemType), this.ns.is("danger", action.actionName === "cancel")],
|
|
214
|
+
"onClick": (e) => this.handleAction(e, action.actionName)
|
|
215
|
+
}, [action.icon, createVNode("span", null, [action.title])]);
|
|
216
|
+
})])]);
|
|
217
|
+
}
|
|
218
|
+
});
|
|
219
|
+
|
|
220
|
+
export { InlineAITextArea };
|