@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,5 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
var core = require('@ibiz-template/core');
|
|
3
4
|
var runtime = require('@ibiz-template/runtime');
|
|
4
5
|
|
|
5
6
|
"use strict";
|
|
@@ -19,6 +20,36 @@ class CodeEditorController extends runtime.EditorController {
|
|
|
19
20
|
* @memberof CodeEditorController
|
|
20
21
|
*/
|
|
21
22
|
__publicField(this, "deACMode");
|
|
23
|
+
/**
|
|
24
|
+
* editor 实例
|
|
25
|
+
*
|
|
26
|
+
* @private
|
|
27
|
+
* @type {Monaco.editor.IStandaloneCodeEditor}
|
|
28
|
+
* @memberof HtmlEditorController
|
|
29
|
+
*/
|
|
30
|
+
__publicField(this, "editor");
|
|
31
|
+
/**
|
|
32
|
+
* monaco 实例
|
|
33
|
+
*
|
|
34
|
+
* @private
|
|
35
|
+
* @type {IMonaco}
|
|
36
|
+
* @memberof CodeEditorController
|
|
37
|
+
*/
|
|
38
|
+
__publicField(this, "monaco");
|
|
39
|
+
/**
|
|
40
|
+
* editor 当前选区
|
|
41
|
+
*
|
|
42
|
+
* @type {monaco.Selection}
|
|
43
|
+
* @memberof CodeEditorController
|
|
44
|
+
*/
|
|
45
|
+
__publicField(this, "currentSelection");
|
|
46
|
+
/**
|
|
47
|
+
* AI 聊天自填模式
|
|
48
|
+
*
|
|
49
|
+
* @type {boolean}
|
|
50
|
+
* @memberof CodeEditorController
|
|
51
|
+
*/
|
|
52
|
+
__publicField(this, "chatCompletion", false);
|
|
22
53
|
}
|
|
23
54
|
/**
|
|
24
55
|
* 语言类型
|
|
@@ -54,6 +85,197 @@ class CodeEditorController extends runtime.EditorController {
|
|
|
54
85
|
appDataEntityId,
|
|
55
86
|
this.context.srfappid
|
|
56
87
|
);
|
|
88
|
+
if (this.deACMode) {
|
|
89
|
+
if (this.deACMode.actype === "CHATCOMPLETION") {
|
|
90
|
+
this.chatCompletion = true;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* editor 创建完成
|
|
96
|
+
*
|
|
97
|
+
* @private
|
|
98
|
+
* @param {Monaco.editor.IStandaloneCodeEditor} editor
|
|
99
|
+
*/
|
|
100
|
+
onCreated(editor, monaco) {
|
|
101
|
+
this.editor = editor;
|
|
102
|
+
this.monaco = monaco;
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* 获取选中文本
|
|
106
|
+
* @return {*} {string} 选中文本
|
|
107
|
+
*/
|
|
108
|
+
getSelectionText() {
|
|
109
|
+
var _a, _b, _c;
|
|
110
|
+
const selection = (_a = this.editor) == null ? void 0 : _a.getSelection();
|
|
111
|
+
let selectedText;
|
|
112
|
+
if (selection) {
|
|
113
|
+
selectedText = (_c = (_b = this.editor) == null ? void 0 : _b.getModel()) == null ? void 0 : _c.getValueInRange(selection);
|
|
114
|
+
}
|
|
115
|
+
return selectedText || "";
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* 插入文本
|
|
119
|
+
* @param {string} text 文本
|
|
120
|
+
*/
|
|
121
|
+
insertText(text) {
|
|
122
|
+
var _a, _b, _c, _d;
|
|
123
|
+
if (!this.editor || !this.monaco) {
|
|
124
|
+
throw new core.RuntimeError(ibiz.i18n.t("editor.code.editorNotInit"));
|
|
125
|
+
}
|
|
126
|
+
const selections = this.editor.getSelections();
|
|
127
|
+
if (!selections || selections.length === 0)
|
|
128
|
+
return;
|
|
129
|
+
const activeSelection = selections[selections.length - 1];
|
|
130
|
+
const insertLine = activeSelection.positionLineNumber;
|
|
131
|
+
const insertColumn = activeSelection.positionColumn;
|
|
132
|
+
const formattedText = "\n".concat(text, "\n");
|
|
133
|
+
(_a = this.editor) == null ? void 0 : _a.executeEdits("", [
|
|
134
|
+
{
|
|
135
|
+
range: new this.monaco.Range(
|
|
136
|
+
insertLine,
|
|
137
|
+
insertColumn,
|
|
138
|
+
insertLine,
|
|
139
|
+
insertColumn
|
|
140
|
+
// 光标位置纯插入,不替换任何内容
|
|
141
|
+
),
|
|
142
|
+
text: formattedText
|
|
143
|
+
}
|
|
144
|
+
]);
|
|
145
|
+
const linesInText = formattedText.split("\n");
|
|
146
|
+
const linesAdded = linesInText.length - 1;
|
|
147
|
+
const lastLineOfInsert = insertLine + linesAdded - 1;
|
|
148
|
+
const lastLineContent = linesInText[linesInText.length - 2] || "";
|
|
149
|
+
const newColumn = lastLineContent.length + 1;
|
|
150
|
+
const newPosition = new this.monaco.Position(lastLineOfInsert, newColumn);
|
|
151
|
+
(_b = this.editor) == null ? void 0 : _b.setPosition(newPosition);
|
|
152
|
+
(_c = this.editor) == null ? void 0 : _c.revealPositionInCenter(newPosition);
|
|
153
|
+
(_d = this.editor) == null ? void 0 : _d.focus();
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* 替换选中文本
|
|
157
|
+
* @param {string} text
|
|
158
|
+
*/
|
|
159
|
+
replaceSelectionText(text) {
|
|
160
|
+
var _a;
|
|
161
|
+
const selection = (_a = this.editor) == null ? void 0 : _a.getSelection();
|
|
162
|
+
if (!selection || selection.isEmpty() || !this.monaco || !this.editor) {
|
|
163
|
+
return;
|
|
164
|
+
}
|
|
165
|
+
const startPosition = selection.getStartPosition();
|
|
166
|
+
this.editor.executeEdits("", [
|
|
167
|
+
{
|
|
168
|
+
range: selection,
|
|
169
|
+
text
|
|
170
|
+
}
|
|
171
|
+
]);
|
|
172
|
+
const textLines = text.split("\n");
|
|
173
|
+
const lineCount = textLines.length;
|
|
174
|
+
const lastLineChars = textLines[lineCount - 1].length;
|
|
175
|
+
let finalLineNumber;
|
|
176
|
+
let finalColumn;
|
|
177
|
+
if (lineCount === 1) {
|
|
178
|
+
finalLineNumber = startPosition.lineNumber;
|
|
179
|
+
finalColumn = startPosition.column + lastLineChars;
|
|
180
|
+
} else {
|
|
181
|
+
finalLineNumber = startPosition.lineNumber + (lineCount - 1);
|
|
182
|
+
finalColumn = 1 + lastLineChars;
|
|
183
|
+
}
|
|
184
|
+
const newSelection = new this.monaco.Range(
|
|
185
|
+
finalLineNumber,
|
|
186
|
+
finalColumn,
|
|
187
|
+
finalLineNumber,
|
|
188
|
+
finalColumn
|
|
189
|
+
);
|
|
190
|
+
this.editor.createDecorationsCollection().clear();
|
|
191
|
+
this.editor.setSelection(newSelection);
|
|
192
|
+
this.editor.focus();
|
|
193
|
+
}
|
|
194
|
+
/**
|
|
195
|
+
* 恢复选取
|
|
196
|
+
*/
|
|
197
|
+
restoreSelection() {
|
|
198
|
+
var _a;
|
|
199
|
+
(_a = this.editor) == null ? void 0 : _a.focus();
|
|
200
|
+
}
|
|
201
|
+
/**
|
|
202
|
+
* 获取内联AI编辑器元素
|
|
203
|
+
*/
|
|
204
|
+
getInLineAiEditorElement() {
|
|
205
|
+
if (!this.editor) {
|
|
206
|
+
throw new core.RuntimeError(ibiz.i18n.t("editor.code.editorNotInit"));
|
|
207
|
+
}
|
|
208
|
+
return this.editor.getDomNode();
|
|
209
|
+
}
|
|
210
|
+
/**
|
|
211
|
+
* 获取内联AI编辑器主题
|
|
212
|
+
*/
|
|
213
|
+
getInLineAiEditorTheme() {
|
|
214
|
+
var _a, _b, _c;
|
|
215
|
+
const currentTheme = (_c = (_b = (_a = this.editor) == null ? void 0 : _a._themeService) == null ? void 0 : _b._theme) == null ? void 0 : _c.themeName;
|
|
216
|
+
switch (currentTheme) {
|
|
217
|
+
case "vs-dark":
|
|
218
|
+
return "dark";
|
|
219
|
+
case "vs":
|
|
220
|
+
default:
|
|
221
|
+
return "light";
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
/**
|
|
225
|
+
* 获取内联AI聊天参数
|
|
226
|
+
*/
|
|
227
|
+
getInLineAiChatOptions() {
|
|
228
|
+
var _a, _b, _c, _d, _e, _f;
|
|
229
|
+
if (!this.editor || !this.monaco) {
|
|
230
|
+
throw new core.RuntimeError(ibiz.i18n.t("editor.code.editorNotInit"));
|
|
231
|
+
}
|
|
232
|
+
const contentArea = (_b = (_a = this.editor) == null ? void 0 : _a.getDomNode()) == null ? void 0 : _b.querySelector(".editor-scrollable");
|
|
233
|
+
if (!contentArea) {
|
|
234
|
+
throw new core.RuntimeError(ibiz.i18n.t("editor.code.noEditorArea"));
|
|
235
|
+
}
|
|
236
|
+
const position = (_c = this.currentSelection) == null ? void 0 : _c.getStartPosition();
|
|
237
|
+
if (!position) {
|
|
238
|
+
throw new core.RuntimeError(ibiz.i18n.t("editor.code.noSelStart"));
|
|
239
|
+
}
|
|
240
|
+
const coordinates = (_d = this.editor) == null ? void 0 : _d.getScrolledVisiblePosition(position);
|
|
241
|
+
const editorRect = (_f = (_e = this.editor) == null ? void 0 : _e.getDomNode()) == null ? void 0 : _f.getBoundingClientRect();
|
|
242
|
+
if (!editorRect) {
|
|
243
|
+
throw new core.RuntimeError(ibiz.i18n.t("editor.code.noEditorRect"));
|
|
244
|
+
}
|
|
245
|
+
if (!coordinates) {
|
|
246
|
+
throw new core.RuntimeError(ibiz.i18n.t("editor.code.noSelCoords"));
|
|
247
|
+
}
|
|
248
|
+
const rect = contentArea.getBoundingClientRect();
|
|
249
|
+
const layoutInfo = this.editor.getLayoutInfo();
|
|
250
|
+
return {
|
|
251
|
+
// 编辑器编辑区左侧距离
|
|
252
|
+
left: rect.left,
|
|
253
|
+
// 编辑器上方距离 + 选区距离编辑器上方距离 + 行高度
|
|
254
|
+
top: editorRect.top + coordinates.top + coordinates.height,
|
|
255
|
+
// 编辑器编辑区宽度 - 代码预览区宽度 - 代码预览区标尺宽度
|
|
256
|
+
width: rect.width - layoutInfo.minimap.minimapWidth - layoutInfo.overviewRuler.width,
|
|
257
|
+
editorElement: this.getInLineAiEditorElement(),
|
|
258
|
+
editorTheme: this.getInLineAiEditorTheme()
|
|
259
|
+
};
|
|
260
|
+
}
|
|
261
|
+
/**
|
|
262
|
+
* 执行内联AIUI操作
|
|
263
|
+
* @param uiActionId
|
|
264
|
+
* @param appId
|
|
265
|
+
*/
|
|
266
|
+
async doInLineAIUIAction(uiActionId, appId) {
|
|
267
|
+
const eventArgs = this.ctrl.getEventArgs();
|
|
268
|
+
eventArgs.params.editor = this;
|
|
269
|
+
if (this.editorParams.srfaiappendcurdata && this.editorParams.srfaiappendcurdata === "true") {
|
|
270
|
+
eventArgs.context.srfaiappendcurdata = true;
|
|
271
|
+
}
|
|
272
|
+
await runtime.UIActionUtil.exec(
|
|
273
|
+
uiActionId,
|
|
274
|
+
{
|
|
275
|
+
...eventArgs
|
|
276
|
+
},
|
|
277
|
+
appId
|
|
278
|
+
);
|
|
57
279
|
}
|
|
58
280
|
}
|
|
59
281
|
|
|
@@ -25,12 +25,23 @@ const IBizCode = /* @__PURE__ */ vue.defineComponent({
|
|
|
25
25
|
const c = props.controller;
|
|
26
26
|
const UUID = qxUtil.createUUID();
|
|
27
27
|
const currentVal = vue.ref("");
|
|
28
|
+
const {
|
|
29
|
+
UIStore,
|
|
30
|
+
zIndex
|
|
31
|
+
} = vue3Util.useUIStore();
|
|
28
32
|
const enableEdit = vue.ref(true);
|
|
29
33
|
const hasEnableEdit = vue.ref(false);
|
|
30
34
|
const readonlyState = vue.ref(false);
|
|
31
35
|
const enableFullScreen = vue.ref(false);
|
|
32
36
|
const isFullScreen = vue.ref(false);
|
|
33
37
|
const isLoading = vue.ref(false);
|
|
38
|
+
let autoClose;
|
|
39
|
+
const textTBRef = vue.ref();
|
|
40
|
+
const textTBStyle = vue.ref({
|
|
41
|
+
[ns.cssVarBlockName("text-editor-toolbar-z-index")]: zIndex.increment()
|
|
42
|
+
});
|
|
43
|
+
const textTBVisible = vue.ref(false);
|
|
44
|
+
const editorTheme = vue.ref("");
|
|
34
45
|
const editorModel = c.model;
|
|
35
46
|
if (editorModel.editorParams) {
|
|
36
47
|
if (editorModel.editorParams.enableEdit) {
|
|
@@ -49,6 +60,13 @@ const IBizCode = /* @__PURE__ */ vue.defineComponent({
|
|
|
49
60
|
if (editorModel.editorParams.enablefullscreen) {
|
|
50
61
|
enableFullScreen.value = c.toBoolean(editorModel.editorParams.enablefullscreen);
|
|
51
62
|
}
|
|
63
|
+
if (editorModel.editorParams.autoclose) {
|
|
64
|
+
try {
|
|
65
|
+
autoClose = JSON.parse(editorModel.editorParams.autoclose);
|
|
66
|
+
} catch (error) {
|
|
67
|
+
ibiz.log.error(error);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
52
70
|
}
|
|
53
71
|
let editor;
|
|
54
72
|
let monacoEditor;
|
|
@@ -56,13 +74,10 @@ const IBizCode = /* @__PURE__ */ vue.defineComponent({
|
|
|
56
74
|
let inlineCompletionsProviderDisposable;
|
|
57
75
|
let decorationsCollection;
|
|
58
76
|
let chatInstance;
|
|
59
|
-
const {
|
|
60
|
-
UIStore,
|
|
61
|
-
zIndex
|
|
62
|
-
} = vue3Util.useUIStore();
|
|
63
77
|
const getMonacoTheme = (name) => {
|
|
64
|
-
var _a;
|
|
65
|
-
|
|
78
|
+
var _a, _b;
|
|
79
|
+
editorTheme.value = ((_a = c == null ? void 0 : c.editorParams) == null ? void 0 : _a.customTheme) || ibiz.config.codeEditorTheme || name;
|
|
80
|
+
const customTheme = (_b = c == null ? void 0 : c.editorParams) == null ? void 0 : _b.customTheme;
|
|
66
81
|
if (customTheme) {
|
|
67
82
|
return customTheme === "dark" ? "vs-dark" : "vs";
|
|
68
83
|
}
|
|
@@ -139,6 +154,14 @@ const IBizCode = /* @__PURE__ */ vue.defineComponent({
|
|
|
139
154
|
},
|
|
140
155
|
// 编辑器参数srfaiappendcurdata,是否传入对象参数,用于历史查询传参
|
|
141
156
|
appendCurData: c.editorParams.srfaiappendcurdata === "true" ? props.data : void 0,
|
|
157
|
+
// 自动提问
|
|
158
|
+
autoQuestion: c.editorParams.autoquestion !== "false",
|
|
159
|
+
// 自动填充
|
|
160
|
+
autoFill: c.editorParams.autofill === "true",
|
|
161
|
+
// 窗口的打开模式
|
|
162
|
+
openMode: c.editorParams.openmode,
|
|
163
|
+
// 窗口的自动关闭模式
|
|
164
|
+
autoClose,
|
|
142
165
|
// 编辑器参数srfaiappendcurcontent,传入编辑内容作为用户消息,获取历史数据后附加
|
|
143
166
|
appendCurContent: c.editorParams.srfaiappendcurcontent ? core.StringUtil.fill(c.editorParams.srfaiappendcurcontent, c.context, c.params, props.data) : void 0,
|
|
144
167
|
appDataEntityId: c.model.appDataEntityId,
|
|
@@ -311,6 +334,71 @@ const IBizCode = /* @__PURE__ */ vue.defineComponent({
|
|
|
311
334
|
return false;
|
|
312
335
|
return true;
|
|
313
336
|
};
|
|
337
|
+
const updateTextToolbarPos = (selection) => {
|
|
338
|
+
var _a;
|
|
339
|
+
const position = selection.getStartPosition();
|
|
340
|
+
if (position) {
|
|
341
|
+
const coordinates = editor == null ? void 0 : editor.getScrolledVisiblePosition(position);
|
|
342
|
+
const editorRect = (_a = editor == null ? void 0 : editor.getDomNode()) == null ? void 0 : _a.getBoundingClientRect();
|
|
343
|
+
if (!editorRect || !coordinates)
|
|
344
|
+
return;
|
|
345
|
+
textTBStyle.value = {
|
|
346
|
+
...textTBStyle.value,
|
|
347
|
+
// 编辑器左侧距离 + 选区距离编辑器左侧距离
|
|
348
|
+
[ns.cssVarBlockName("text-editor-toolbar-left")]: "".concat(editorRect.left + coordinates.left, "px"),
|
|
349
|
+
// 编辑器上方距离 + 选区距离编辑器上方距离 + 行高度
|
|
350
|
+
[ns.cssVarBlockName("text-editor-toolbar-top")]: "".concat(editorRect.top + coordinates.top + coordinates.height, "px")
|
|
351
|
+
};
|
|
352
|
+
}
|
|
353
|
+
};
|
|
354
|
+
const setTextTBVisible = () => {
|
|
355
|
+
if (props.readonly || !enableEdit.value || !c.deACMode || !c.chatCompletion)
|
|
356
|
+
return;
|
|
357
|
+
const selection = editor == null ? void 0 : editor.getSelection();
|
|
358
|
+
textTBVisible.value = !!(selection && !selection.isEmpty());
|
|
359
|
+
};
|
|
360
|
+
const onSelectionChange = (e) => {
|
|
361
|
+
const selection = e.selection;
|
|
362
|
+
if (selection) {
|
|
363
|
+
updateTextToolbarPos(selection);
|
|
364
|
+
c.currentSelection = selection;
|
|
365
|
+
}
|
|
366
|
+
};
|
|
367
|
+
const handleLineAiClick = (_e) => {
|
|
368
|
+
var _a, _b;
|
|
369
|
+
const position = (_a = editor == null ? void 0 : editor.getSelection()) == null ? void 0 : _a.getStartPosition();
|
|
370
|
+
if (!position)
|
|
371
|
+
return;
|
|
372
|
+
const coordinates = editor == null ? void 0 : editor.getScrolledVisiblePosition(position);
|
|
373
|
+
const editorRect = (_b = editor == null ? void 0 : editor.getDomNode()) == null ? void 0 : _b.getBoundingClientRect();
|
|
374
|
+
const textTBHeight = textTBRef.value.offsetHeight;
|
|
375
|
+
if (!coordinates || !editorRect || !textTBHeight)
|
|
376
|
+
return;
|
|
377
|
+
const items = ibiz.inLineAIUtil.calcContextMenus(c.deACMode, (tag) => {
|
|
378
|
+
c.doInLineAIUIAction(tag, c.model.appId);
|
|
379
|
+
});
|
|
380
|
+
if (items.length === 0)
|
|
381
|
+
return;
|
|
382
|
+
ibiz.inLineAIUtil.showContextMenus(
|
|
383
|
+
// 编辑器左侧距离 + 选区距离编辑器左侧距离
|
|
384
|
+
editorRect.left + coordinates.left,
|
|
385
|
+
// 编辑器上方距离 + 选区距离编辑器上方距离 + 行高度 + 工具栏高度
|
|
386
|
+
editorRect.top + coordinates.top + coordinates.height + textTBHeight,
|
|
387
|
+
items
|
|
388
|
+
);
|
|
389
|
+
};
|
|
390
|
+
const handleEditorClick = (e) => {
|
|
391
|
+
var _a;
|
|
392
|
+
if (!((_a = textTBRef.value) == null ? void 0 : _a.contains(e.target))) {
|
|
393
|
+
setTimeout(setTextTBVisible, 100);
|
|
394
|
+
}
|
|
395
|
+
};
|
|
396
|
+
const handleMousedown = (e) => {
|
|
397
|
+
var _a;
|
|
398
|
+
if (textTBVisible.value && !((_a = textTBRef.value) == null ? void 0 : _a.contains(e.target))) {
|
|
399
|
+
textTBVisible.value = false;
|
|
400
|
+
}
|
|
401
|
+
};
|
|
314
402
|
const editorInit = () => {
|
|
315
403
|
vue.nextTick(() => {
|
|
316
404
|
isLoading.value = true;
|
|
@@ -320,6 +408,7 @@ const IBizCode = /* @__PURE__ */ vue.defineComponent({
|
|
|
320
408
|
}
|
|
321
409
|
});
|
|
322
410
|
index.default.init().then((loaderMonaco) => {
|
|
411
|
+
var _a;
|
|
323
412
|
isLoading.value = false;
|
|
324
413
|
if (!editor) {
|
|
325
414
|
monacoEditor = loaderMonaco.editor;
|
|
@@ -376,6 +465,7 @@ const IBizCode = /* @__PURE__ */ vue.defineComponent({
|
|
|
376
465
|
});
|
|
377
466
|
}
|
|
378
467
|
}
|
|
468
|
+
c.onCreated(editor, loaderMonaco);
|
|
379
469
|
setTimeout(() => {
|
|
380
470
|
editor.layout();
|
|
381
471
|
editor.setValue(currentVal.value);
|
|
@@ -408,11 +498,14 @@ const IBizCode = /* @__PURE__ */ vue.defineComponent({
|
|
|
408
498
|
createDecorationsCollection();
|
|
409
499
|
});
|
|
410
500
|
editor.onDidChangeModelContent(() => {
|
|
501
|
+
setTextTBVisible();
|
|
411
502
|
if (!hasEnableEdit.value) {
|
|
412
503
|
currentVal.value = editor.getValue();
|
|
413
504
|
emit("change", currentVal.value);
|
|
414
505
|
}
|
|
415
506
|
});
|
|
507
|
+
editor.onDidChangeCursorSelection(onSelectionChange);
|
|
508
|
+
(_a = editor.getDomNode()) == null ? void 0 : _a.addEventListener("click", handleEditorClick);
|
|
416
509
|
window.addEventListener("resize", () => {
|
|
417
510
|
editor.layout();
|
|
418
511
|
});
|
|
@@ -528,11 +621,37 @@ const IBizCode = /* @__PURE__ */ vue.defineComponent({
|
|
|
528
621
|
}
|
|
529
622
|
}, null);
|
|
530
623
|
};
|
|
624
|
+
const renderTextEditorToolbar = () => {
|
|
625
|
+
if (!textTBVisible.value)
|
|
626
|
+
return null;
|
|
627
|
+
return vue.createVNode("div", {
|
|
628
|
+
"ref": "textTBRef",
|
|
629
|
+
"class": [ns.b("text-editor-toolbar")],
|
|
630
|
+
"style": {
|
|
631
|
+
...textTBStyle.value
|
|
632
|
+
}
|
|
633
|
+
}, [vue.createVNode("div", {
|
|
634
|
+
"class": [ns.be("text-editor-toolbar", "item")],
|
|
635
|
+
"title": "AI",
|
|
636
|
+
"onClick": handleLineAiClick
|
|
637
|
+
}, [vue.createVNode("svg", {
|
|
638
|
+
"version": "1.1",
|
|
639
|
+
"xmlns": "http://www.w3.org/2000/svg",
|
|
640
|
+
"viewBox": "0 0 1024 1024",
|
|
641
|
+
"width": "1em",
|
|
642
|
+
"height": "1em",
|
|
643
|
+
"fill": "currentColor"
|
|
644
|
+
}, [vue.createVNode("path", {
|
|
645
|
+
"d": "M274.344554 173.673875c16.429399 0 30.950568 8.00526 39.956484 20.338945a34.906655 34.906655 0 0 1 14.660796 15.754537l1.117013 2.815803 210.138065 597.927736c6.795162 19.268474-5.329083 40.817516-27.041022 48.147913-20.641469 6.95806-42.493035-1.419537-50.451753-18.803052l-1.117013-2.815803-54.477653-154.939008H134.997185L80.566074 837.039954c-6.771891 19.268474-29.856826 28.949253-51.568765 21.618855-20.641469-6.981331-32.602816-26.761769-27.925325-45.239025l0.861031-2.908888L212.047809 212.58316c4.025901-11.426112 13.799764-19.477914 25.598214-22.619512 9.029188-10.006575 22.107548-16.289773 36.67526-16.289773z m386.416675 169.460176c21.828295 0 39.723774 10.890876 41.469106 24.713912l0.116356 2.210755v461.652153c0 14.893506-18.616883 26.947938-41.585462 26.947938-21.805024 0-39.700503-10.890876-41.422565-24.737183l-0.162897-2.210755V370.081989c0-14.870235 18.616883-26.924667 41.585462-26.924667z m-389.697901-48.171184L163.620643 600.628812h214.88537l-107.442685-305.665945z m602.163076-206.181978a12.566396 12.566396 0 0 1 8.144887 8.051802l32.509731 99.041817 101.694723 36.07021a12.566396 12.566396 0 0 1-0.791218 23.922695l-99.53051 27.995137-30.857483 97.552467a12.566396 12.566396 0 0 1-23.899423 0.116355l-32.509732-99.018546-98.669479-31.322905a12.566396 12.566396 0 0 1-0.186169-23.876152l97.505924-32.812256 30.834212-97.529195a12.566396 12.566396 0 0 1 15.754537-8.191429zM649.544557 0.513593c2.676177 0.884302 4.770576 3.025243 5.608336 5.724692l18.523798 59.294772 60.970292 20.66474a8.796477 8.796477 0 0 1-0.325796 16.755194l-60.73758 18.058377-19.780438 59.550754a8.796477 8.796477 0 0 1-16.731924-0.162898l-18.523798-59.271501-59.062061-17.825665a8.796477 8.796477 0 0 1-0.395609-16.708653l59.574025-20.943993 19.780438-59.574025a8.796477 8.796477 0 0 1 11.100317-5.561794z"
|
|
646
|
+
}, null)])])]);
|
|
647
|
+
};
|
|
531
648
|
vue.onMounted(() => {
|
|
532
649
|
editorInit();
|
|
650
|
+
window.addEventListener("mousedown", handleMousedown.bind(this));
|
|
533
651
|
});
|
|
534
652
|
vue.onUnmounted(() => {
|
|
535
653
|
unload();
|
|
654
|
+
window.removeEventListener("mousedown", handleMousedown.bind(this));
|
|
536
655
|
});
|
|
537
656
|
return {
|
|
538
657
|
ns,
|
|
@@ -542,8 +661,11 @@ const IBizCode = /* @__PURE__ */ vue.defineComponent({
|
|
|
542
661
|
hasEnableEdit,
|
|
543
662
|
readonlyState,
|
|
544
663
|
isLoading,
|
|
664
|
+
textTBRef,
|
|
665
|
+
editorTheme,
|
|
545
666
|
renderFooter,
|
|
546
667
|
renderHeaderToolbar,
|
|
668
|
+
renderTextEditorToolbar,
|
|
547
669
|
renderCodeContent,
|
|
548
670
|
changeFullScreenState
|
|
549
671
|
};
|
|
@@ -552,24 +674,24 @@ const IBizCode = /* @__PURE__ */ vue.defineComponent({
|
|
|
552
674
|
var _a, _b;
|
|
553
675
|
const isLoading = !((_b = (_a = this.controller.view) == null ? void 0 : _a.state) == null ? void 0 : _b.isLoading) && this.isLoading;
|
|
554
676
|
return !this.isFullScreen ? vue.withDirectives(vue.createVNode("div", {
|
|
555
|
-
"class": [this.ns.b(), {
|
|
677
|
+
"class": [this.ns.b(), this.ns.is(this.editorTheme, !!this.editorTheme), {
|
|
556
678
|
[this.ns.b("editor-readonly")]: this.readonlyState
|
|
557
679
|
}, {
|
|
558
680
|
[this.ns.b("editor-enable")]: !this.readonlyState
|
|
559
681
|
}, this.ns.is("enable", this.hasEnableEdit)]
|
|
560
|
-
}, [this.renderHeaderToolbar(), this.renderCodeContent(), this.hasEnableEdit && !this.readonlyState ? this.renderFooter() : null]), [[vue.resolveDirective("loading"), isLoading]]) : vue.createVNode(vue.resolveComponent("el-dialog"), {
|
|
682
|
+
}, [this.renderTextEditorToolbar(), this.renderHeaderToolbar(), this.renderCodeContent(), this.hasEnableEdit && !this.readonlyState ? this.renderFooter() : null]), [[vue.resolveDirective("loading"), isLoading]]) : vue.createVNode(vue.resolveComponent("el-dialog"), {
|
|
561
683
|
"modelValue": this.isFullScreen,
|
|
562
684
|
"onUpdate:modelValue": ($event) => this.isFullScreen = $event,
|
|
563
685
|
"class": this.ns.b("dialog-full-screen"),
|
|
564
686
|
"onClose": () => this.changeFullScreenState()
|
|
565
687
|
}, {
|
|
566
688
|
default: () => [vue.withDirectives(vue.createVNode("div", {
|
|
567
|
-
"class": [this.ns.b(), {
|
|
689
|
+
"class": [this.ns.b(), this.ns.is(this.editorTheme, !!this.editorTheme), {
|
|
568
690
|
[this.ns.b("editor-readonly")]: this.readonlyState
|
|
569
691
|
}, {
|
|
570
692
|
[this.ns.b("editor-enable")]: !this.readonlyState
|
|
571
693
|
}]
|
|
572
|
-
}, [this.renderHeaderToolbar(), this.renderCodeContent(), this.hasEnableEdit && !this.readonlyState ? this.renderFooter() : null]), [[vue.resolveDirective("loading"), isLoading]])]
|
|
694
|
+
}, [this.renderTextEditorToolbar(), this.renderHeaderToolbar(), this.renderCodeContent(), this.hasEnableEdit && !this.readonlyState ? this.renderFooter() : null]), [[vue.resolveDirective("loading"), isLoading]])]
|
|
573
695
|
});
|
|
574
696
|
}
|
|
575
697
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
.ibiz-code{display:flex;flex-direction:column;width:100%;height:100%}.ibiz-code__box{width:100%;height:100%;min-height:200px;overflow:hidden}.ibiz-code__first-prompt::before{padding-right:var(--ibiz-spacing-base);content:var(--ibiz-code-placeholder)}.ibiz-code-toolbar{position:absolute;top:4px;right:18px;z-index:10;display:flex;align-items:center;justify-content:end;width:auto;height:auto;padding-right:0;font-size:var(--ibiz-font-size-header-6)}.ibiz-code-toolbar>*+*{margin-left:var(--ibiz-spacing-base-loose)}.ibiz-code-toolbar__fullscreen{height:38px;padding:0 12px;font-size:var(--ibiz-font-size-regular);font-style:normal;line-height:2.8;cursor:pointer}.ibiz-code-toolbar__fullscreen:hover{background-color:var(--ibiz-color-bg-3)}.ibiz-code-footer{
|
|
1
|
+
.ibiz-code{--ibiz-code-color-text-editor-toolbar-bg:var(--ibiz-color-bg-2);--ibiz-code-color-text-editor-toolbar-text:var(--ibiz-color-text-0);--ibiz-code-color-text-editor-toolbar-item-bg-hover:var(--ibiz-color-primary-light-default);--ibiz-code-color-text-editor-toolbar-item-text-hover:var(--ibiz-color-primary);--ibiz-code-height-text-editor-toolbar:40px;--ibiz-code-footer-toolbar-height:36px;--ibiz-code-footer-button-height:36px;--ibiz-code-spacing-code-text-editor-toolbar-padding:var(--ibiz-spacing-extra-tight);--ibiz-code-spacing-code-text-editor-toolbar-item-padding:var(--ibiz-spacing-extra-tight) var(--ibiz-spacing-tight);--ibiz-code-spacing-code-text-editor-toolbar-circle:var(--ibiz-border-radius-extra-small);--ibiz-code-spacing-code-text-editor-toolbar-item-circle:var(--ibiz-border-radius-extra-small);--ibiz-code-text-editor-toolbar-z-index:1;--ibiz-code-text-editor-toolbar-left:0;--ibiz-code-text-editor-toolbar-top:0;display:flex;flex-direction:column;width:100%;height:100%}.ibiz-code__box{width:100%;height:100%;min-height:200px;overflow:hidden}.ibiz-code__first-prompt::before{padding-right:var(--ibiz-spacing-base);content:var(--ibiz-code-placeholder)}.ibiz-code-toolbar{position:absolute;top:4px;right:18px;z-index:10;display:flex;align-items:center;justify-content:end;width:auto;height:auto;padding-right:0;font-size:var(--ibiz-font-size-header-6)}.ibiz-code-toolbar>*+*{margin-left:var(--ibiz-spacing-base-loose)}.ibiz-code-toolbar__fullscreen{height:38px;padding:0 12px;font-size:var(--ibiz-font-size-regular);font-style:normal;line-height:2.8;cursor:pointer}.ibiz-code-toolbar__fullscreen:hover{background-color:var(--ibiz-color-bg-3)}.ibiz-code-footer{display:flex;align-items:center;justify-content:end;width:100%;min-height:var(--ibiz-code-footer-toolbar-height);margin-top:var(--ibiz-spacing-base-tight);margin-right:var(--ibiz-spacing-tight)}.ibiz-code-footer>*+*{margin-left:var(--ibiz-spacing-base)}.ibiz-code-footer__cancel{height:var(--ibiz-code-footer-button-height);line-height:var(--ibiz-code-footer-button-height);color:var(--ibiz-color-text-1);cursor:pointer;opacity:.7}.ibiz-code-footer__cancel:hover{color:var(--ibiz-color-primary);opacity:1}.ibiz-code-footer__save{width:96px;height:var(--ibiz-code-footer-button-height);line-height:var(--ibiz-code-footer-button-height);color:var(--ibiz-color-primary-active-text);text-align:center;cursor:pointer;background-color:var(--ibiz-color-primary);border-radius:var(--ibiz-border-radius-small)}.ibiz-code-footer__save:hover{box-shadow:0 2px 5px 1px var(--ibiz-color-primary)}.ibiz-code-message{width:500px;max-width:unset}.ibiz-code-message__message-content--message-tip{color:var(--ibiz-color-text-3)}.ibiz-code-message__message-cancel{color:var(--ibiz-color-text-1);background-color:transparent}.ibiz-code-message__message-cancel:hover{color:var(--ibiz-color-primary);background-color:transparent}.ibiz-code-message__message-comfire{background-color:var(--ibiz-color-danger)!important}.ibiz-code-message__message-comfire:hover{box-shadow:0 2px 5px 1px var(--ibiz-color-danger)}.ibiz-code-editor-enable .ibiz-code__box{height:100%}.ibiz-code-editor-enable:has(.ibiz-code-footer) .ibiz-code__box{height:calc(100% - var(--ibiz-code-footer-toolbar-height))}.ibiz-code-dialog-full-screen{width:100%!important;height:100%!important;margin:0!important}.ibiz-code-dialog-full-screen .ibiz-code-footer{--ibiz-code-footer-toolbar-height:68px}.ibiz-code-dialog-full-screen .ibiz-code{gap:0;padding:0 var(--ibiz-spacing-extra-loose);--w-e-toolbar-bg-color:var(--ibiz-color-bg-0)}.ibiz-code-dialog-full-screen .ibiz-code .ibiz-code-toolbar{right:calc(var(--ibiz-spacing-extra-loose) + 18px)}.ibiz-code-dialog-full-screen .el-dialog__header{display:none!important}.ibiz-code-dialog-full-screen .el-dialog__body{width:100%;height:100%;padding:0 0 var(--ibiz-spacing-base)}.ibiz-code-dialog-full-screen .el-dialog__body:has(.ibiz-code-footer){padding-bottom:0}.ibiz-code-footer-dialog{margin-top:0}.ibiz-code-text-editor-toolbar{position:fixed;top:var(--ibiz-code-text-editor-toolbar-top);left:var(--ibiz-code-text-editor-toolbar-left);z-index:var(--ibiz-code-text-editor-toolbar-z-index);display:flex;gap:var(--ibiz-spacing-tight);height:var(--ibiz-code-height-text-editor-toolbar);padding:var(--ibiz-code-spacing-code-text-editor-toolbar-padding);font-size:var(--ibiz-font-size-regular);color:var(--ibiz-code-color-text-editor-toolbar-text);background-color:var(--ibiz-code-color-text-editor-toolbar-bg);border-radius:var(--ibiz-code-spacing-code-text-editor-toolbar-circle);box-shadow:var(--ibiz-shadow-elevated)}.ibiz-code-text-editor-toolbar__item{display:flex;align-items:center;justify-content:center;padding:var(--ibiz-code-spacing-code-text-editor-toolbar-item-padding);cursor:pointer;border-radius:var(--ibiz-code-spacing-code-text-editor-toolbar-item-circle)}.ibiz-code-text-editor-toolbar__item:hover{color:var(--ibiz-code-color-text-editor-toolbar-item-text-hover);background-color:var(--ibiz-code-color-text-editor-toolbar-item-bg-hover)}.ibiz-code.is-dark{--ibiz-code-color-text-editor-toolbar-bg:rgb(53, 54, 60);--ibiz-code-color-text-editor-toolbar-text:rgb(249, 249, 249);--ibiz-code-color-text-editor-toolbar-item-bg-hover:rgba(255, 255, 255, 0.12);--ibiz-code-color-text-editor-toolbar-item-text-hover:rgb(249, 249, 249)}
|
|
@@ -6,6 +6,7 @@ var core = require('@ibiz-template/core');
|
|
|
6
6
|
var editor = require('@wangeditor/editor');
|
|
7
7
|
require('./wang-editor/index.cjs');
|
|
8
8
|
var aiModule = require('./wang-editor/module/ai-module.cjs');
|
|
9
|
+
var inlineAiModule = require('./wang-editor/module/inline-ai-module.cjs');
|
|
9
10
|
var emoji = require('./wang-editor/element/emoji.cjs');
|
|
10
11
|
var emojiModule = require('./wang-editor/module/emoji-module.cjs');
|
|
11
12
|
var plugin = require('./wang-editor/plugin/plugin.cjs');
|
|
@@ -172,6 +173,7 @@ class HtmlEditorController extends runtime.EditorController {
|
|
|
172
173
|
customRegister() {
|
|
173
174
|
if (!window.aichartRegister && ibiz.env.enableAI) {
|
|
174
175
|
editor.Boot.registerMenu(aiModule.AIMenu);
|
|
176
|
+
editor.Boot.registerMenu(inlineAiModule.InLineAIMenu);
|
|
175
177
|
window.aichartRegister = true;
|
|
176
178
|
}
|
|
177
179
|
if (!window.customElements.get("emoji-elem")) {
|
|
@@ -282,6 +284,124 @@ class HtmlEditorController extends runtime.EditorController {
|
|
|
282
284
|
this.overlay.dismiss();
|
|
283
285
|
}
|
|
284
286
|
}
|
|
287
|
+
/**
|
|
288
|
+
* 获取选中文本
|
|
289
|
+
* @returns 选中文本
|
|
290
|
+
*/
|
|
291
|
+
getSelectionText() {
|
|
292
|
+
if (this.wangEditor) {
|
|
293
|
+
return this.wangEditor.getSelectionText();
|
|
294
|
+
}
|
|
295
|
+
return "";
|
|
296
|
+
}
|
|
297
|
+
/**
|
|
298
|
+
* 插入文本
|
|
299
|
+
* @param text 文本
|
|
300
|
+
*/
|
|
301
|
+
insertText(text) {
|
|
302
|
+
if (this.wangEditor) {
|
|
303
|
+
const newParagraph = {
|
|
304
|
+
type: "paragraph",
|
|
305
|
+
children: [{ text }]
|
|
306
|
+
};
|
|
307
|
+
const selection = this.wangEditor.selection;
|
|
308
|
+
if (selection) {
|
|
309
|
+
const collapsedSelection = {
|
|
310
|
+
anchor: selection.anchor,
|
|
311
|
+
focus: selection.anchor
|
|
312
|
+
};
|
|
313
|
+
if (selection.anchor.path !== selection.focus.path || selection.anchor.offset !== selection.focus.offset) {
|
|
314
|
+
collapsedSelection.anchor = selection.focus;
|
|
315
|
+
collapsedSelection.focus = selection.focus;
|
|
316
|
+
}
|
|
317
|
+
this.wangEditor.select(collapsedSelection);
|
|
318
|
+
}
|
|
319
|
+
this.wangEditor.insertNode(newParagraph);
|
|
320
|
+
this.wangEditor.move(1);
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
/**
|
|
324
|
+
* 替换选中文本
|
|
325
|
+
* @param text 文本
|
|
326
|
+
*/
|
|
327
|
+
replaceSelectionText(text) {
|
|
328
|
+
if (this.wangEditor) {
|
|
329
|
+
if (this.wangEditor.selection) {
|
|
330
|
+
this.wangEditor.deleteFragment();
|
|
331
|
+
this.wangEditor.insertText(text);
|
|
332
|
+
} else {
|
|
333
|
+
this.wangEditor.insertText(text);
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
/**
|
|
338
|
+
* 恢复选区
|
|
339
|
+
*/
|
|
340
|
+
restoreSelection() {
|
|
341
|
+
if (this.wangEditor) {
|
|
342
|
+
this.wangEditor.restoreSelection();
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
/**
|
|
346
|
+
* 获取内联AI编辑器元素
|
|
347
|
+
*/
|
|
348
|
+
getInLineAiEditorElement() {
|
|
349
|
+
if (!this.wangEditor) {
|
|
350
|
+
throw new core.RuntimeError("\u7F16\u8F91\u5668\u672A\u521D\u59CB\u5316");
|
|
351
|
+
}
|
|
352
|
+
return this.wangEditor.getEditableContainer();
|
|
353
|
+
}
|
|
354
|
+
/**
|
|
355
|
+
* 获取内联AI编辑器主题
|
|
356
|
+
*/
|
|
357
|
+
getInLineAiEditorTheme() {
|
|
358
|
+
const appTheme = ibiz.util.theme.getTheme();
|
|
359
|
+
if (appTheme.indexOf("dark") !== -1) {
|
|
360
|
+
return "dark";
|
|
361
|
+
}
|
|
362
|
+
return "light";
|
|
363
|
+
}
|
|
364
|
+
/**
|
|
365
|
+
* 获取内联AI参数
|
|
366
|
+
*/
|
|
367
|
+
getInLineAiChatOptions() {
|
|
368
|
+
if (!this.wangEditor) {
|
|
369
|
+
throw new core.RuntimeError("\u7F16\u8F91\u5668\u672A\u521D\u59CB\u5316");
|
|
370
|
+
}
|
|
371
|
+
const selectionPosition = this.wangEditor.getSelectionPosition();
|
|
372
|
+
if (!selectionPosition || !selectionPosition.left || !selectionPosition.top)
|
|
373
|
+
throw new core.RuntimeError("\u83B7\u53D6\u9009\u533A\u4F4D\u7F6E\u5931\u8D25");
|
|
374
|
+
const editorBoundingClientRect = this.wangEditor.getEditableContainer().getBoundingClientRect();
|
|
375
|
+
return {
|
|
376
|
+
// 编辑器的左侧距离 + 默认padding
|
|
377
|
+
left: editorBoundingClientRect.x + 10,
|
|
378
|
+
// 编辑器的上方距离+选区距离编辑器上方距离
|
|
379
|
+
top: editorBoundingClientRect.y + Number(selectionPosition.top.replace("px", "")),
|
|
380
|
+
// 编辑器的宽度 - 左右padding
|
|
381
|
+
width: editorBoundingClientRect.width - 20,
|
|
382
|
+
editorElement: this.getInLineAiEditorElement(),
|
|
383
|
+
editorTheme: this.getInLineAiEditorTheme()
|
|
384
|
+
};
|
|
385
|
+
}
|
|
386
|
+
/**
|
|
387
|
+
* 执行内联AIUI操作
|
|
388
|
+
* @param uiActionId
|
|
389
|
+
* @param appId
|
|
390
|
+
*/
|
|
391
|
+
async doInLineAIUIAction(uiActionId, appId) {
|
|
392
|
+
const eventArgs = this.ctrl.getEventArgs();
|
|
393
|
+
eventArgs.params.editor = this;
|
|
394
|
+
if (this.editorParams.srfaiappendcurdata && this.editorParams.srfaiappendcurdata === "true") {
|
|
395
|
+
eventArgs.context.srfaiappendcurdata = true;
|
|
396
|
+
}
|
|
397
|
+
await runtime.UIActionUtil.exec(
|
|
398
|
+
uiActionId,
|
|
399
|
+
{
|
|
400
|
+
...eventArgs
|
|
401
|
+
},
|
|
402
|
+
appId
|
|
403
|
+
);
|
|
404
|
+
}
|
|
285
405
|
}
|
|
286
406
|
|
|
287
407
|
exports.HtmlEditorController = HtmlEditorController;
|
|
@@ -6,6 +6,7 @@ require('./plugin/index.cjs');
|
|
|
6
6
|
require('./component/index.cjs');
|
|
7
7
|
var aiModule = require('./module/ai-module.cjs');
|
|
8
8
|
var emojiModule = require('./module/emoji-module.cjs');
|
|
9
|
+
var inlineAiModule = require('./module/inline-ai-module.cjs');
|
|
9
10
|
var emoji = require('./element/emoji.cjs');
|
|
10
11
|
var plugin = require('./plugin/plugin.cjs');
|
|
11
12
|
var emoji$1 = require('./component/emoji/emoji.cjs');
|
|
@@ -14,6 +15,8 @@ var emoji$1 = require('./component/emoji/emoji.cjs');
|
|
|
14
15
|
|
|
15
16
|
exports.AIMenu = aiModule.AIMenu;
|
|
16
17
|
exports.EmojiModule = emojiModule.EmojiModule;
|
|
18
|
+
exports.InLineAIMenu = inlineAiModule.InLineAIMenu;
|
|
19
|
+
exports.hoverbarKeysEx = inlineAiModule.hoverbarKeysEx;
|
|
17
20
|
exports.EmojiElem = emoji.EmojiElem;
|
|
18
21
|
exports.Plugin = plugin.Plugin;
|
|
19
22
|
exports.Emoji = emoji$1.Emoji;
|
|
@@ -2,8 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
var aiModule = require('./ai-module.cjs');
|
|
4
4
|
var emojiModule = require('./emoji-module.cjs');
|
|
5
|
+
var inlineAiModule = require('./inline-ai-module.cjs');
|
|
5
6
|
|
|
6
7
|
"use strict";
|
|
7
8
|
|
|
8
9
|
exports.AIMenu = aiModule.AIMenu;
|
|
9
10
|
exports.EmojiModule = emojiModule.EmojiModule;
|
|
11
|
+
exports.InLineAIMenu = inlineAiModule.InLineAIMenu;
|
|
12
|
+
exports.hoverbarKeysEx = inlineAiModule.hoverbarKeysEx;
|