@ibiz-template/vue3-components 0.7.41-alpha.36 → 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 (82) 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-CxXULY47.js → xlsx-util-BMANxyk-.js} +1 -1
  9. package/es/control/calendar/calendar.mjs +33 -8
  10. package/es/control/form/form-detail/form-mdctrl/form-mdctrl-repeater/form-mdctrl-repeater.mjs +10 -0
  11. package/es/control/form/form-detail/form-mdctrl/form-mdctrl-repeater/form-mdctrl-repeater.util.mjs +30 -0
  12. package/es/control/form/form-detail/form-mdctrl/form-mdctrl-repeater/repeater-grid/repeater-grid.mjs +114 -85
  13. package/es/control/form/form-detail/form-mdctrl/form-mdctrl-repeater/repeater-grid2/repeater-grid2.css +1 -0
  14. package/es/control/form/form-detail/form-mdctrl/form-mdctrl-repeater/repeater-grid2/repeater-grid2.mjs +309 -0
  15. package/es/control/tab-exp-panel/tab-exp-panel.mjs +4 -17
  16. package/es/editor/code/code-editor.controller.mjs +176 -1
  17. package/es/editor/code/monaco-editor/monaco-editor.css +1 -1
  18. package/es/editor/code/monaco-editor/monaco-editor.mjs +116 -6
  19. package/es/editor/html/html-editor.controller.mjs +77 -2
  20. package/es/editor/html/wang-editor/index.mjs +1 -0
  21. package/es/editor/html/wang-editor/module/index.mjs +1 -0
  22. package/es/editor/html/wang-editor/module/inline-ai-module.mjs +95 -0
  23. package/es/editor/html/wang-editor/wang-editor.css +1 -1
  24. package/es/editor/html/wang-editor/wang-editor.mjs +35 -4
  25. package/es/editor/markdown/ibiz-markdown-editor/custom-menu.mjs +45 -0
  26. package/es/editor/markdown/ibiz-markdown-editor/ibiz-markdown-editor.css +1 -1
  27. package/es/editor/markdown/ibiz-markdown-editor/ibiz-markdown-editor.mjs +109 -13
  28. package/es/editor/markdown/markdown-editor.controller.mjs +113 -1
  29. package/es/editor/text-box/input/input.css +1 -1
  30. package/es/index.mjs +1 -0
  31. package/es/locale/en/index.mjs +15 -2
  32. package/es/locale/zh-CN/index.mjs +15 -2
  33. package/es/panel-component/nav-breadcrumb/nav-breadcrumb.util.mjs +1 -1
  34. package/es/panel-component/user-message/internal-message/internal-message-json/internal-message-json.provider.mjs +2 -2
  35. package/es/util/ai-util/ai-util.mjs +6 -2
  36. package/es/util/app-util/app-util.mjs +41 -2
  37. package/es/util/index.mjs +1 -0
  38. package/es/util/inline-ai-util/inline-ai-textarea/icon.mjs +142 -0
  39. package/es/util/inline-ai-util/inline-ai-textarea/inline-ai-textarea.css +1 -0
  40. package/es/util/inline-ai-util/inline-ai-textarea/inline-ai-textarea.hook.mjs +162 -0
  41. package/es/util/inline-ai-util/inline-ai-textarea/inline-ai-textarea.mjs +205 -0
  42. package/es/util/inline-ai-util/inline-ai-util.mjs +145 -0
  43. package/es/web-app/main.mjs +2 -0
  44. package/lib/control/calendar/calendar.cjs +32 -7
  45. package/lib/control/form/form-detail/form-mdctrl/form-mdctrl-repeater/form-mdctrl-repeater.cjs +10 -0
  46. package/lib/control/form/form-detail/form-mdctrl/form-mdctrl-repeater/form-mdctrl-repeater.util.cjs +32 -0
  47. package/lib/control/form/form-detail/form-mdctrl/form-mdctrl-repeater/repeater-grid/repeater-grid.cjs +113 -84
  48. package/lib/control/form/form-detail/form-mdctrl/form-mdctrl-repeater/repeater-grid2/repeater-grid2.cjs +311 -0
  49. package/lib/control/form/form-detail/form-mdctrl/form-mdctrl-repeater/repeater-grid2/repeater-grid2.css +1 -0
  50. package/lib/control/tab-exp-panel/tab-exp-panel.cjs +3 -16
  51. package/lib/editor/code/code-editor.controller.cjs +175 -0
  52. package/lib/editor/code/monaco-editor/monaco-editor.cjs +116 -6
  53. package/lib/editor/code/monaco-editor/monaco-editor.css +1 -1
  54. package/lib/editor/html/html-editor.controller.cjs +75 -0
  55. package/lib/editor/html/wang-editor/index.cjs +3 -0
  56. package/lib/editor/html/wang-editor/module/index.cjs +3 -0
  57. package/lib/editor/html/wang-editor/module/inline-ai-module.cjs +98 -0
  58. package/lib/editor/html/wang-editor/wang-editor.cjs +35 -4
  59. package/lib/editor/html/wang-editor/wang-editor.css +1 -1
  60. package/lib/editor/markdown/ibiz-markdown-editor/custom-menu.cjs +47 -0
  61. package/lib/editor/markdown/ibiz-markdown-editor/ibiz-markdown-editor.cjs +109 -13
  62. package/lib/editor/markdown/ibiz-markdown-editor/ibiz-markdown-editor.css +1 -1
  63. package/lib/editor/markdown/markdown-editor.controller.cjs +112 -0
  64. package/lib/editor/text-box/input/input.css +1 -1
  65. package/lib/index.cjs +2 -0
  66. package/lib/locale/en/index.cjs +15 -2
  67. package/lib/locale/zh-CN/index.cjs +15 -2
  68. package/lib/panel-component/nav-breadcrumb/nav-breadcrumb.util.cjs +1 -1
  69. package/lib/panel-component/user-message/internal-message/internal-message-json/internal-message-json.provider.cjs +2 -2
  70. package/lib/util/ai-util/ai-util.cjs +6 -2
  71. package/lib/util/app-util/app-util.cjs +40 -1
  72. package/lib/util/index.cjs +2 -0
  73. package/lib/util/inline-ai-util/inline-ai-textarea/icon.cjs +151 -0
  74. package/lib/util/inline-ai-util/inline-ai-textarea/inline-ai-textarea.cjs +207 -0
  75. package/lib/util/inline-ai-util/inline-ai-textarea/inline-ai-textarea.css +1 -0
  76. package/lib/util/inline-ai-util/inline-ai-textarea/inline-ai-textarea.hook.cjs +167 -0
  77. package/lib/util/inline-ai-util/inline-ai-util.cjs +147 -0
  78. package/lib/web-app/main.cjs +2 -0
  79. package/package.json +5 -5
  80. package/dist/ibiz-markdown-editor-Cs1m7gKI.js +0 -1
  81. package/dist/index-CCKb6xlM.js +0 -11
  82. package/dist/wang-editor-BIllIvre.js +0 -1
@@ -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)}
@@ -54,19 +54,6 @@ const TabExpPanelControl = /* @__PURE__ */ vue.defineComponent({
54
54
  var _a;
55
55
  const c = vue3Util.useControlController((...args) => new runtime.TabExpPanelController(...args));
56
56
  const ns = vue3Util.useNamespace("control-".concat(c.model.controlType.toLowerCase()));
57
- const counterData = vue.ref({});
58
- const fn = (counter) => {
59
- counterData.value = counter;
60
- };
61
- c.evt.on("onCreated", () => {
62
- if (c.counter) {
63
- c.counter.onChange(fn, true);
64
- }
65
- });
66
- vue.onUnmounted(() => {
67
- var _a2;
68
- (_a2 = c.counter) == null ? void 0 : _a2.offChange(fn);
69
- });
70
57
  const handleTabChange = () => {
71
58
  c.handleTabChange();
72
59
  };
@@ -100,7 +87,6 @@ const TabExpPanelControl = /* @__PURE__ */ vue.defineComponent({
100
87
  c,
101
88
  ns,
102
89
  tabPosition,
103
- counterData,
104
90
  handleTabChange
105
91
  };
106
92
  },
@@ -108,7 +94,8 @@ const TabExpPanelControl = /* @__PURE__ */ vue.defineComponent({
108
94
  let _slot;
109
95
  const {
110
96
  isCreated,
111
- tabPages
97
+ tabPages,
98
+ counterData
112
99
  } = this.c.state;
113
100
  return vue.createVNode(vue.resolveComponent("iBizControlBase"), {
114
101
  "controller": this.c
@@ -119,7 +106,7 @@ const TabExpPanelControl = /* @__PURE__ */ vue.defineComponent({
119
106
  "tabPosition": this.tabPosition,
120
107
  "onTabChange": this.handleTabChange
121
108
  }, _isSlot(_slot = tabPages.map((tab) => {
122
- const counterNum = tab.counterId ? this.counterData[tab.counterId] : void 0;
109
+ const counterNum = tab.counterId ? counterData[tab.counterId] : void 0;
123
110
  return vue.createVNode(vue.resolveComponent("el-tab-pane"), {
124
111
  "class": [this.ns.e("tab-item")],
125
112
  "label": tab.caption,
@@ -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;