@ibiz-template/vue3-components 0.7.41-alpha.37 → 0.7.41-alpha.38

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 (68) hide show
  1. package/dist/ibiz-markdown-editor-qRaayafj.js +1 -0
  2. package/dist/index-BiYphJ2f.js +11 -0
  3. package/dist/{index-BFGNWF-0.js → index-C28lnh2e.js} +1 -1
  4. package/dist/{index-BiFsbM1Y.js → index-Dp8ExwuL.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-DDVqSnRX.js +1 -0
  8. package/dist/{xlsx-util-DZ5-cWNj.js → xlsx-util-BMANxyk-.js} +1 -1
  9. package/es/control/form/form-detail/form-mdctrl/form-mdctrl-repeater/form-mdctrl-repeater.mjs +10 -0
  10. package/es/control/form/form-detail/form-mdctrl/form-mdctrl-repeater/repeater-grid2/repeater-grid2.css +1 -0
  11. package/es/control/form/form-detail/form-mdctrl/form-mdctrl-repeater/repeater-grid2/repeater-grid2.mjs +309 -0
  12. package/es/editor/code/code-editor.controller.mjs +176 -1
  13. package/es/editor/code/monaco-editor/monaco-editor.css +1 -1
  14. package/es/editor/code/monaco-editor/monaco-editor.mjs +116 -6
  15. package/es/editor/html/html-editor.controller.mjs +77 -2
  16. package/es/editor/html/wang-editor/index.mjs +1 -0
  17. package/es/editor/html/wang-editor/module/index.mjs +1 -0
  18. package/es/editor/html/wang-editor/module/inline-ai-module.mjs +95 -0
  19. package/es/editor/html/wang-editor/wang-editor.css +1 -1
  20. package/es/editor/html/wang-editor/wang-editor.mjs +35 -4
  21. package/es/editor/markdown/ibiz-markdown-editor/custom-menu.mjs +45 -0
  22. package/es/editor/markdown/ibiz-markdown-editor/ibiz-markdown-editor.css +1 -1
  23. package/es/editor/markdown/ibiz-markdown-editor/ibiz-markdown-editor.mjs +109 -13
  24. package/es/editor/markdown/markdown-editor.controller.mjs +113 -1
  25. package/es/index.mjs +1 -0
  26. package/es/locale/en/index.mjs +15 -2
  27. package/es/locale/zh-CN/index.mjs +15 -2
  28. package/es/util/ai-util/ai-util.mjs +6 -2
  29. package/es/util/app-util/app-util.mjs +41 -2
  30. package/es/util/index.mjs +1 -0
  31. package/es/util/inline-ai-util/inline-ai-textarea/icon.mjs +142 -0
  32. package/es/util/inline-ai-util/inline-ai-textarea/inline-ai-textarea.css +1 -0
  33. package/es/util/inline-ai-util/inline-ai-textarea/inline-ai-textarea.hook.mjs +162 -0
  34. package/es/util/inline-ai-util/inline-ai-textarea/inline-ai-textarea.mjs +205 -0
  35. package/es/util/inline-ai-util/inline-ai-util.mjs +145 -0
  36. package/es/web-app/main.mjs +2 -0
  37. package/lib/control/form/form-detail/form-mdctrl/form-mdctrl-repeater/form-mdctrl-repeater.cjs +10 -0
  38. package/lib/control/form/form-detail/form-mdctrl/form-mdctrl-repeater/repeater-grid2/repeater-grid2.cjs +311 -0
  39. package/lib/control/form/form-detail/form-mdctrl/form-mdctrl-repeater/repeater-grid2/repeater-grid2.css +1 -0
  40. package/lib/editor/code/code-editor.controller.cjs +175 -0
  41. package/lib/editor/code/monaco-editor/monaco-editor.cjs +116 -6
  42. package/lib/editor/code/monaco-editor/monaco-editor.css +1 -1
  43. package/lib/editor/html/html-editor.controller.cjs +75 -0
  44. package/lib/editor/html/wang-editor/index.cjs +3 -0
  45. package/lib/editor/html/wang-editor/module/index.cjs +3 -0
  46. package/lib/editor/html/wang-editor/module/inline-ai-module.cjs +98 -0
  47. package/lib/editor/html/wang-editor/wang-editor.cjs +35 -4
  48. package/lib/editor/html/wang-editor/wang-editor.css +1 -1
  49. package/lib/editor/markdown/ibiz-markdown-editor/custom-menu.cjs +47 -0
  50. package/lib/editor/markdown/ibiz-markdown-editor/ibiz-markdown-editor.cjs +109 -13
  51. package/lib/editor/markdown/ibiz-markdown-editor/ibiz-markdown-editor.css +1 -1
  52. package/lib/editor/markdown/markdown-editor.controller.cjs +112 -0
  53. package/lib/index.cjs +2 -0
  54. package/lib/locale/en/index.cjs +15 -2
  55. package/lib/locale/zh-CN/index.cjs +15 -2
  56. package/lib/util/ai-util/ai-util.cjs +6 -2
  57. package/lib/util/app-util/app-util.cjs +40 -1
  58. package/lib/util/index.cjs +2 -0
  59. package/lib/util/inline-ai-util/inline-ai-textarea/icon.cjs +151 -0
  60. package/lib/util/inline-ai-util/inline-ai-textarea/inline-ai-textarea.cjs +207 -0
  61. package/lib/util/inline-ai-util/inline-ai-textarea/inline-ai-textarea.css +1 -0
  62. package/lib/util/inline-ai-util/inline-ai-textarea/inline-ai-textarea.hook.cjs +167 -0
  63. package/lib/util/inline-ai-util/inline-ai-util.cjs +147 -0
  64. package/lib/web-app/main.cjs +2 -0
  65. package/package.json +5 -5
  66. package/dist/ibiz-markdown-editor-Cs1m7gKI.js +0 -1
  67. package/dist/index-Dds3BDDF.js +0 -11
  68. package/dist/wang-editor-4cJ6X_hb.js +0 -1
@@ -6,6 +6,7 @@ var vue3Util = require('@ibiz-template/vue3-util');
6
6
  var repeaterSingleForm = require('./repeater-single-form/repeater-single-form.cjs');
7
7
  var repeaterMultiForm = require('./repeater-multi-form/repeater-multi-form.cjs');
8
8
  var repeaterGrid = require('./repeater-grid/repeater-grid.cjs');
9
+ var repeaterGrid2 = require('./repeater-grid2/repeater-grid2.cjs');
9
10
 
10
11
  "use strict";
11
12
  const FormMDCtrlRepeater = /* @__PURE__ */ vue.defineComponent({
@@ -27,6 +28,7 @@ const FormMDCtrlRepeater = /* @__PURE__ */ vue.defineComponent({
27
28
  };
28
29
  },
29
30
  render() {
31
+ var _a;
30
32
  const classNames = [this.ns.b()];
31
33
  switch (this.controller.repeaterStyle) {
32
34
  case "MultiForm":
@@ -36,6 +38,14 @@ const FormMDCtrlRepeater = /* @__PURE__ */ vue.defineComponent({
36
38
  "controller": this.controller
37
39
  }, null);
38
40
  case "Grid":
41
+ const gridStyle = (_a = this.controller.model.ctrlParams) == null ? void 0 : _a.gridStyle;
42
+ if (gridStyle === "style2") {
43
+ return vue.createVNode(repeaterGrid2.RepeaterGrid2, {
44
+ "class": classNames,
45
+ "controller": this.controller,
46
+ "onChange": this.onDataChange
47
+ }, null);
48
+ }
39
49
  return vue.createVNode(repeaterGrid.RepeaterGrid, {
40
50
  "class": classNames,
41
51
  "controller": this.controller,
@@ -0,0 +1,311 @@
1
+ 'use strict';
2
+
3
+ var vue = require('vue');
4
+ var sortable_esm = require('../../../../../../node_modules/.pnpm/sortablejs@1.15.6/node_modules/sortablejs/modular/sortable.esm.cjs');
5
+ var runtime = require('@ibiz-template/runtime');
6
+ var qxUtil = require('qx-util');
7
+ var vue3Util = require('@ibiz-template/vue3-util');
8
+ var core = require('@ibiz-template/core');
9
+ var formMdctrlRepeater_util = require('../form-mdctrl-repeater.util.cjs');
10
+ require('./repeater-grid2.css');
11
+
12
+ "use strict";
13
+ function _isSlot(s) {
14
+ return typeof s === "function" || Object.prototype.toString.call(s) === "[object Object]" && !vue.isVNode(s);
15
+ }
16
+ const RepeaterGrid2 = /* @__PURE__ */ vue.defineComponent({
17
+ name: "IBizRepeaterGrid2",
18
+ props: {
19
+ controller: {
20
+ type: runtime.FormMDCtrlRepeaterController,
21
+ required: true
22
+ }
23
+ },
24
+ emits: {
25
+ change: (_value) => true
26
+ },
27
+ setup(props, {
28
+ emit
29
+ }) {
30
+ var _a, _b;
31
+ const ns = vue3Util.useNamespace("repeater-grid2");
32
+ const formItems = [];
33
+ const tableRef = vue.ref();
34
+ const tableKey = vue.ref(qxUtil.createUUID());
35
+ const chunkSize = ((_a = props.controller.model.ctrlParams) == null ? void 0 : _a.chunkSize) ? Number((_b = props.controller.model.ctrlParams) == null ? void 0 : _b.chunkSize) : 100;
36
+ const {
37
+ renderItems,
38
+ loadMore,
39
+ updateTotalItems
40
+ } = formMdctrlRepeater_util.useLoadMore(props.controller.value, chunkSize);
41
+ core.recursiveIterate(props.controller.repeatedForm, (item) => {
42
+ var _a2;
43
+ if (item.detailType === "FORMITEM") {
44
+ if (((_a2 = item.editor) == null ? void 0 : _a2.editorType) !== "HIDDEN") {
45
+ formItems.push(item);
46
+ }
47
+ }
48
+ }, {
49
+ childrenFields: ["deformPages", "deformTabPages", "deformDetails"]
50
+ });
51
+ const onSingleValueChange = (value, index) => {
52
+ const arrData = [...props.controller.value || []];
53
+ arrData[index] = value;
54
+ emit("change", arrData);
55
+ };
56
+ const ctx = vue3Util.useCtx();
57
+ const formControllers = vue.reactive([]);
58
+ const addFormController = async (data = {}) => {
59
+ const formC = new runtime.EditFormController(props.controller.repeatedForm, props.controller.context, props.controller.params, ctx);
60
+ formC.state.isSimple = true;
61
+ await formC.created();
62
+ formC.setSimpleData(data);
63
+ formControllers.push(formC);
64
+ props.controller.setRepeaterController("".concat(formControllers.length - 1), formC);
65
+ formC.evt.on("onFormDataChange", (event) => {
66
+ const item = event.data[0];
67
+ const formData = item instanceof runtime.ControlVO ? item.clone() : {
68
+ ...item
69
+ };
70
+ const index = formControllers.indexOf(formC);
71
+ onSingleValueChange(formData, index);
72
+ });
73
+ };
74
+ vue.watch(() => props.controller.value, (newVal) => {
75
+ if (newVal && newVal.length > 0) {
76
+ newVal.forEach((item, index) => {
77
+ const formC = formControllers[index];
78
+ if (formC) {
79
+ const changeVal = item || {};
80
+ const find = Object.keys(formC.data).find((key) => {
81
+ return changeVal[key] !== formC.data[key];
82
+ });
83
+ if (find) {
84
+ formC.setSimpleData(changeVal);
85
+ }
86
+ } else {
87
+ addFormController(item);
88
+ }
89
+ });
90
+ }
91
+ updateTotalItems(newVal || []);
92
+ }, {
93
+ immediate: true,
94
+ deep: true
95
+ });
96
+ let sortable;
97
+ const rowDrop = () => {
98
+ var _a2, _b2;
99
+ const wrapper = (_b2 = (_a2 = tableRef.value) == null ? void 0 : _a2.$el) == null ? void 0 : _b2.querySelector(".el-table__body-wrapper tbody");
100
+ if (!wrapper || !props.controller.enableSort)
101
+ return;
102
+ sortable = sortable_esm.default.create(wrapper, {
103
+ animation: 150,
104
+ handle: ".".concat(ns.e("drag-icon")),
105
+ ghostClass: "".concat(ns.e("sortable-ghost")),
106
+ onEnd({
107
+ newIndex,
108
+ oldIndex
109
+ }) {
110
+ props.controller.dragChange(oldIndex, newIndex);
111
+ tableKey.value = qxUtil.createUUID();
112
+ }
113
+ });
114
+ };
115
+ vue.watch(() => tableRef.value, () => {
116
+ if (!props.controller.enableSort)
117
+ return;
118
+ tableRef.value ? rowDrop() : sortable == null ? void 0 : sortable.destroy();
119
+ });
120
+ vue.onUnmounted(() => sortable == null ? void 0 : sortable.destroy());
121
+ const renderRemoveBtn = (index) => {
122
+ if (ibiz.config.form.mdCtrlConfirmBeforeRemove) {
123
+ return vue.createVNode(vue.resolveComponent("el-popconfirm"), {
124
+ "title": ibiz.i18n.t("control.form.repeaterGrid.promptInformation"),
125
+ "confirm-button-text": ibiz.i18n.t("app.confirm"),
126
+ "cancel-button-text": ibiz.i18n.t("app.cancel"),
127
+ "onConfirm": () => {
128
+ props.controller.remove(index);
129
+ formControllers.splice(index, 1);
130
+ }
131
+ }, {
132
+ reference: () => {
133
+ return vue.createVNode("ion-icon", {
134
+ "name": "remove-outline",
135
+ "title": ibiz.i18n.t("app.delete"),
136
+ "class": ns.b("remove-btn")
137
+ }, null);
138
+ }
139
+ });
140
+ }
141
+ return vue.createVNode("ion-icon", {
142
+ "name": "remove-outline",
143
+ "title": ibiz.i18n.t("app.delete"),
144
+ "class": ns.b("remove-btn"),
145
+ "onClick": () => {
146
+ props.controller.remove(index);
147
+ formControllers.splice(index, 1);
148
+ }
149
+ }, null);
150
+ };
151
+ return {
152
+ ns,
153
+ tableRef,
154
+ tableKey,
155
+ formItems,
156
+ renderItems,
157
+ formControllers,
158
+ renderRemoveBtn,
159
+ loadMore
160
+ };
161
+ },
162
+ render() {
163
+ var _a;
164
+ const tableHeight = (_a = this.controller.model.layoutPos) == null ? void 0 : _a.height;
165
+ const heightObject = tableHeight ? {
166
+ height: tableHeight
167
+ } : {};
168
+ const isEmpty = this.renderItems.length === 0;
169
+ return vue.createVNode("div", {
170
+ "class": this.ns.b()
171
+ }, [vue.createVNode(vue.resolveComponent("el-table"), vue.mergeProps({
172
+ "ref": "tableRef",
173
+ "key": this.tableKey,
174
+ "show-header": true,
175
+ "class": this.ns.e("table"),
176
+ "data": isEmpty && this.controller.enableCreate ? [{}] : this.renderItems,
177
+ "cell-class-name": ({
178
+ columnIndex
179
+ }) => {
180
+ const shouldShowIndex = this.controller.enableSort ? columnIndex === 1 : columnIndex === 0;
181
+ return shouldShowIndex ? this.ns.b("index") : "";
182
+ }
183
+ }, heightObject), {
184
+ default: () => {
185
+ return [this.controller.enableSort && vue.createVNode(vue.resolveComponent("el-table-column"), {
186
+ "width": 26,
187
+ "type": "default"
188
+ }, {
189
+ default: () => {
190
+ if (isEmpty) {
191
+ return "";
192
+ }
193
+ return vue.createVNode("svg", {
194
+ "viewBox": "0 0 16 16",
195
+ "xmlns": "http://www.w3.org/2000/svg",
196
+ "height": "1em",
197
+ "width": "1em",
198
+ "class": this.ns.e("drag-icon"),
199
+ "preserveAspectRatio": "xMidYMid meet",
200
+ "focusable": "false"
201
+ }, [vue.createVNode("g", {
202
+ "stroke-width": "1",
203
+ "fill-rule": "evenodd"
204
+ }, [vue.createVNode("g", {
205
+ "transform": "translate(5 1)",
206
+ "fill-rule": "nonzero"
207
+ }, [vue.createVNode("path", {
208
+ "d": "M1 2a1 1 0 1 1 0-2 1 1 0 0 1 0 2zm4 0a1 1 0 1 1 0-2 1 1 0 0 1 0 2zM1 6a1 1 0 1 1 0-2 1 1 0 0 1 0 2zm4 0a1 1 0 1 1 0-2 1 1 0 0 1 0 2zm-4 4a1 1 0 1 1 0-2 1 1 0 0 1 0 2zm4 0a1 1 0 1 1 0-2 1 1 0 0 1 0 2zm-4 4a1 1 0 1 1 0-2 1 1 0 0 1 0 2zm4 0a1 1 0 1 1 0-2 1 1 0 0 1 0 2z"
209
+ }, null)])])]);
210
+ }
211
+ }), vue.createVNode(vue.resolveComponent("el-table-column"), {
212
+ "type": "index",
213
+ "width": 66,
214
+ "align": "center"
215
+ }, {
216
+ default: (opts) => {
217
+ if (isEmpty) {
218
+ return "";
219
+ }
220
+ const {
221
+ $index
222
+ } = opts;
223
+ return vue.createVNode("span", null, [$index + 1]);
224
+ }
225
+ }), this.formItems.length > 0 && this.formItems.map((item) => {
226
+ const width = item.labelWidth;
227
+ let widthName = "width";
228
+ let columnWidth = "";
229
+ if (typeof width === "number") {
230
+ if (width === 1) {
231
+ widthName = "min-width";
232
+ }
233
+ columnWidth = "".concat(width, "px");
234
+ }
235
+ return vue.createVNode(vue.resolveComponent("el-table-column"), vue.mergeProps({
236
+ "label": item.caption,
237
+ "prop": item.id
238
+ }, {
239
+ [widthName]: columnWidth
240
+ }, {
241
+ "align": "center"
242
+ }), {
243
+ default: (opts) => {
244
+ if (isEmpty) {
245
+ return "";
246
+ }
247
+ const {
248
+ $index
249
+ } = opts;
250
+ const formC = vue.toRaw(this.formControllers[$index]);
251
+ if (!formC || !formC.state.isLoaded) {
252
+ return vue.createVNode("div", null, [ibiz.i18n.t("control.form.repeaterGrid.absentOrLoad")]);
253
+ }
254
+ const formItemC = formC.formItems.find((x) => x.name === item.id);
255
+ let editor = null;
256
+ if (!formItemC.editorProvider) {
257
+ editor = vue.createVNode(vue.resolveComponent("not-supported-editor"), {
258
+ "modelData": item.editor
259
+ }, null);
260
+ } else {
261
+ const component = vue.resolveComponent(formItemC.editorProvider.formEditor);
262
+ editor = vue.h(component, {
263
+ value: formItemC.value,
264
+ data: formItemC.data,
265
+ controller: formItemC.editor,
266
+ disabled: formItemC.state.disabled,
267
+ readonly: formItemC.state.readonly,
268
+ onChange: (val, name) => {
269
+ formItemC.setDataValue(val, name);
270
+ }
271
+ });
272
+ }
273
+ return vue.createVNode(vue.resolveComponent("iBizGridEditItem"), {
274
+ "error": formItemC.state.error,
275
+ "required": formItemC.state.required
276
+ }, _isSlot(editor) ? editor : {
277
+ default: () => [editor]
278
+ });
279
+ }
280
+ });
281
+ }), (this.controller.enableCreate || this.controller.enableDelete) && vue.createVNode(vue.resolveComponent("el-table-column"), {
282
+ "width": 80,
283
+ "align": "center"
284
+ }, {
285
+ default: (opts) => {
286
+ const {
287
+ $index
288
+ } = opts;
289
+ return vue.createVNode("div", {
290
+ "class": this.ns.b("action-group")
291
+ }, [this.controller.enableCreate && vue.createVNode("ion-icon", {
292
+ "name": "add-outline",
293
+ "title": ibiz.i18n.t("app.add"),
294
+ "class": this.ns.b("add-btn"),
295
+ "onClick": () => {
296
+ this.controller.create(isEmpty ? 0 : $index + 1);
297
+ }
298
+ }, null), this.controller.enableDelete && !isEmpty && this.renderRemoveBtn($index)]);
299
+ }
300
+ })];
301
+ },
302
+ append: () => {
303
+ return [tableHeight && vue.withDirectives(vue.createVNode("div", {
304
+ "infinite-scroll-distance": 20
305
+ }, null), [[vue.resolveDirective("infinite-scroll"), () => this.loadMore()]])];
306
+ }
307
+ })]);
308
+ }
309
+ });
310
+
311
+ exports.RepeaterGrid2 = RepeaterGrid2;
@@ -0,0 +1 @@
1
+ .ibiz-repeater-grid2{--ibiz-repeater-grid2-row-height:57px;--ibiz-repeater-grid2-index-cell-padding:var(--ibiz-spacing-extra-tight);--ibiz-repeater-grid2-btn-size:var(--ibiz-width-icon-large);--ibiz-repeater-grid2-btn-color:var(--ibiz-color-text-2);--ibiz-repeater-grid2-btn-border:1px solid var(--ibiz-color-border);--ibiz-repeater-grid2-btn-margin-left:var(--ibiz-spacing-tight);--ibiz-repeater-grid2-btn-hover-color:var(--ibiz-color-primary-hover);--ibiz-repeater-grid2-btn-hover-border:1px solid var(--ibiz-color-primary-hover);position:relative;width:100%;--ibiz-grid-column-justify-content:center}.ibiz-repeater-grid2__drag-icon{cursor:move}.ibiz-repeater-grid2__sortable-ghost{opacity:.5}.ibiz-repeater-grid2 .el-table__row{height:var(--ibiz-repeater-grid2-row-height)}.ibiz-repeater-grid2-index .cell{padding:var(--ibiz-repeater-grid2-index-cell-padding)}.ibiz-repeater-grid2-action-group{display:flex;align-items:center;justify-content:center}.ibiz-repeater-grid2-action-group ion-icon{font-size:var(--ibiz-repeater-grid2-btn-size);color:var(--ibiz-repeater-grid2-btn-color);cursor:pointer;border:var(--ibiz-repeater-grid2-btn-border)}.ibiz-repeater-grid2-action-group ion-icon+ion-icon{margin-left:var(--ibiz-repeater-grid2-btn-margin-left)}.ibiz-repeater-grid2-action-group ion-icon:hover{color:var(--ibiz-repeater-grid2-btn-hover-color);border:var(--ibiz-repeater-grid2-btn-hover-border)}
@@ -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,29 @@ 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");
22
46
  }
23
47
  /**
24
48
  * 语言类型
@@ -55,6 +79,157 @@ class CodeEditorController extends runtime.EditorController {
55
79
  this.context.srfappid
56
80
  );
57
81
  }
82
+ /**
83
+ * editor 创建完成
84
+ *
85
+ * @private
86
+ * @param {Monaco.editor.IStandaloneCodeEditor} editor
87
+ */
88
+ onCreated(editor, monaco) {
89
+ this.editor = editor;
90
+ this.monaco = monaco;
91
+ }
92
+ /**
93
+ * 获取选中文本
94
+ * @return {*} {string} 选中文本
95
+ */
96
+ getSelectionText() {
97
+ var _a, _b, _c;
98
+ const selection = (_a = this.editor) == null ? void 0 : _a.getSelection();
99
+ let selectedText;
100
+ if (selection) {
101
+ selectedText = (_c = (_b = this.editor) == null ? void 0 : _b.getModel()) == null ? void 0 : _c.getValueInRange(selection);
102
+ }
103
+ return selectedText || "";
104
+ }
105
+ /**
106
+ * 插入文本
107
+ * @param {string} text 文本
108
+ */
109
+ insertText(text) {
110
+ var _a, _b, _c, _d, _e, _f;
111
+ const model = (_a = this.editor) == null ? void 0 : _a.getModel();
112
+ if (!model || !this.monaco)
113
+ return;
114
+ const lastLineNumber = model.getLineCount();
115
+ const lastLineContent = model.getLineContent(lastLineNumber);
116
+ const lastColumn = lastLineContent.length + 1;
117
+ (_b = this.editor) == null ? void 0 : _b.executeEdits("", [
118
+ {
119
+ range: new this.monaco.Range(
120
+ lastLineNumber,
121
+ lastColumn,
122
+ lastLineNumber,
123
+ lastColumn
124
+ ),
125
+ text
126
+ }
127
+ ]);
128
+ const newLastLine = lastLineNumber + (text.includes("\n") ? 1 : 0);
129
+ const newLastColumn = ((_c = text.split("\n").pop()) == null ? void 0 : _c.length) || 0;
130
+ (_d = this.editor) == null ? void 0 : _d.setPosition(
131
+ new this.monaco.Position(newLastLine, newLastColumn)
132
+ );
133
+ (_e = this.editor) == null ? void 0 : _e.revealPositionInCenter(
134
+ new this.monaco.Position(newLastLine, newLastColumn)
135
+ );
136
+ (_f = this.editor) == null ? void 0 : _f.focus();
137
+ }
138
+ /**
139
+ * 替换选中文本
140
+ * @param {string} text
141
+ */
142
+ replaceSelectionText(text) {
143
+ var _a;
144
+ const selection = (_a = this.editor) == null ? void 0 : _a.getSelection();
145
+ if (!selection || selection.isEmpty() || !this.monaco || !this.editor) {
146
+ return;
147
+ }
148
+ const startPosition = selection.getStartPosition();
149
+ this.editor.executeEdits("", [
150
+ {
151
+ range: selection,
152
+ text
153
+ }
154
+ ]);
155
+ const textLines = text.split("\n");
156
+ const lineCount = textLines.length;
157
+ const lastLineChars = textLines[lineCount - 1].length;
158
+ let finalLineNumber;
159
+ let finalColumn;
160
+ if (lineCount === 1) {
161
+ finalLineNumber = startPosition.lineNumber;
162
+ finalColumn = startPosition.column + lastLineChars;
163
+ } else {
164
+ finalLineNumber = startPosition.lineNumber + (lineCount - 1);
165
+ finalColumn = 1 + lastLineChars;
166
+ }
167
+ const newSelection = new this.monaco.Range(
168
+ finalLineNumber,
169
+ finalColumn,
170
+ finalLineNumber,
171
+ finalColumn
172
+ );
173
+ this.editor.createDecorationsCollection().clear();
174
+ this.editor.setSelection(newSelection);
175
+ this.editor.focus();
176
+ }
177
+ /**
178
+ * 恢复选取
179
+ */
180
+ restoreSelection() {
181
+ var _a;
182
+ (_a = this.editor) == null ? void 0 : _a.focus();
183
+ }
184
+ /**
185
+ * 获取内联AI聊天参数
186
+ */
187
+ getInLineAiChatOptions() {
188
+ var _a, _b, _c, _d, _e, _f;
189
+ const contentArea = (_b = (_a = this.editor) == null ? void 0 : _a.getDomNode()) == null ? void 0 : _b.querySelector(".editor-scrollable");
190
+ if (!contentArea) {
191
+ throw new core.RuntimeError(ibiz.i18n.t("editor.code.noEditorArea"));
192
+ }
193
+ const position = (_c = this.currentSelection) == null ? void 0 : _c.getStartPosition();
194
+ if (!position) {
195
+ throw new core.RuntimeError(ibiz.i18n.t("editor.code.noSelStart"));
196
+ }
197
+ const coordinates = (_d = this.editor) == null ? void 0 : _d.getScrolledVisiblePosition(position);
198
+ const editorRect = (_f = (_e = this.editor) == null ? void 0 : _e.getDomNode()) == null ? void 0 : _f.getBoundingClientRect();
199
+ if (!editorRect) {
200
+ throw new core.RuntimeError(ibiz.i18n.t("editor.code.noEditorRect"));
201
+ }
202
+ if (!coordinates) {
203
+ throw new core.RuntimeError(ibiz.i18n.t("editor.code.noSelCoords"));
204
+ }
205
+ const rect = contentArea.getBoundingClientRect();
206
+ return {
207
+ left: rect.left,
208
+ top: editorRect.top + coordinates.top + 28,
209
+ // 减去 20px 的行高度及 8px 向下偏移
210
+ width: rect.width - 160
211
+ // 减去 左侧占位 及 右侧代码预览 边距
212
+ };
213
+ }
214
+ /**
215
+ * 执行内联AIUI操作
216
+ * @param uiActionId
217
+ * @param appId
218
+ */
219
+ async doInLineAIUIAction(uiActionId, appId) {
220
+ const eventArgs = this.ctrl.getEventArgs();
221
+ eventArgs.params.editor = this;
222
+ if (this.editorParams.srfaiappendcurdata && this.editorParams.srfaiappendcurdata === "true") {
223
+ eventArgs.context.srfaiappendcurdata = true;
224
+ }
225
+ await runtime.UIActionUtil.exec(
226
+ uiActionId,
227
+ {
228
+ ...eventArgs
229
+ },
230
+ appId
231
+ );
232
+ }
58
233
  }
59
234
 
60
235
  exports.CodeEditorController = CodeEditorController;