@ibiz-template/vue3-components 0.7.41-alpha.38 → 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-Dp8ExwuL.js → index-BewO9StC.js} +1 -1
- package/dist/{index-C28lnh2e.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-DDVqSnRX.js → wang-editor-BYeoazrn.js} +1 -1
- package/dist/{xlsx-util-BMANxyk-.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/editor/code/code-editor.controller.mjs +72 -25
- package/es/editor/code/monaco-editor/monaco-editor.css +1 -1
- package/es/editor/code/monaco-editor/monaco-editor.mjs +20 -8
- package/es/editor/html/html-editor.controller.mjs +49 -4
- package/es/editor/html/wang-editor/wang-editor.mjs +7 -1
- package/es/editor/markdown/ibiz-markdown-editor/custom-menu.mjs +5 -7
- package/es/editor/markdown/ibiz-markdown-editor/ibiz-markdown-editor.css +1 -1
- package/es/editor/markdown/ibiz-markdown-editor/ibiz-markdown-editor.mjs +42 -4
- package/es/editor/markdown/markdown-editor.controller.mjs +111 -6
- package/es/locale/en/index.mjs +5 -2
- package/es/locale/zh-CN/index.mjs +5 -2
- package/es/util/inline-ai-util/inline-ai-textarea/inline-ai-textarea.css +1 -1
- package/es/util/inline-ai-util/inline-ai-textarea/inline-ai-textarea.hook.mjs +76 -21
- package/es/util/inline-ai-util/inline-ai-textarea/inline-ai-textarea.mjs +48 -33
- package/lib/control/form/form-detail/form-item/form-item-container/form-item-container.cjs +42 -8
- package/lib/editor/code/code-editor.controller.cjs +72 -25
- package/lib/editor/code/monaco-editor/monaco-editor.cjs +20 -8
- package/lib/editor/code/monaco-editor/monaco-editor.css +1 -1
- package/lib/editor/html/html-editor.controller.cjs +49 -4
- package/lib/editor/html/wang-editor/wang-editor.cjs +7 -1
- package/lib/editor/markdown/ibiz-markdown-editor/custom-menu.cjs +5 -7
- package/lib/editor/markdown/ibiz-markdown-editor/ibiz-markdown-editor.cjs +42 -4
- package/lib/editor/markdown/ibiz-markdown-editor/ibiz-markdown-editor.css +1 -1
- package/lib/editor/markdown/markdown-editor.controller.cjs +111 -6
- package/lib/locale/en/index.cjs +5 -2
- package/lib/locale/zh-CN/index.cjs +5 -2
- package/lib/util/inline-ai-util/inline-ai-textarea/inline-ai-textarea.cjs +48 -33
- package/lib/util/inline-ai-util/inline-ai-textarea/inline-ai-textarea.css +1 -1
- package/lib/util/inline-ai-util/inline-ai-textarea/inline-ai-textarea.hook.cjs +76 -21
- package/package.json +4 -4
- package/dist/ibiz-markdown-editor-qRaayafj.js +0 -1
- package/dist/index-BiYphJ2f.js +0 -11
|
@@ -91,6 +91,20 @@ class MarkDownEditorController extends runtime.EditorController {
|
|
|
91
91
|
* @memberof MarkDownEditorController
|
|
92
92
|
*/
|
|
93
93
|
__publicField(this, "selectionAreaPosition", null);
|
|
94
|
+
/**
|
|
95
|
+
* 选区方向 true表示正向,从左到右;false表示反向,从右到左
|
|
96
|
+
*
|
|
97
|
+
* @type {boolean}
|
|
98
|
+
* @memberof MarkDownEditorController
|
|
99
|
+
*/
|
|
100
|
+
__publicField(this, "selectionDirection", true);
|
|
101
|
+
/**
|
|
102
|
+
* 当前编辑器使用主题
|
|
103
|
+
*
|
|
104
|
+
* @type {string}
|
|
105
|
+
* @memberof MarkDownEditorController
|
|
106
|
+
*/
|
|
107
|
+
__publicField(this, "currentEditorTheme", "light");
|
|
94
108
|
}
|
|
95
109
|
async onInit() {
|
|
96
110
|
await super.onInit();
|
|
@@ -176,6 +190,33 @@ class MarkDownEditorController extends runtime.EditorController {
|
|
|
176
190
|
setCursorPos(start, end) {
|
|
177
191
|
this.selectionAreaPosition = { start, end };
|
|
178
192
|
}
|
|
193
|
+
/**
|
|
194
|
+
* 设置当前编辑器的主题
|
|
195
|
+
*
|
|
196
|
+
* @param {string} theme
|
|
197
|
+
* @memberof MarkDownEditorController
|
|
198
|
+
*/
|
|
199
|
+
setCurrentEditorTheme(theme) {
|
|
200
|
+
this.currentEditorTheme = theme;
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* 设置当前选区方向
|
|
204
|
+
*
|
|
205
|
+
* @param {boolean} direction
|
|
206
|
+
* @memberof MarkDownEditorController
|
|
207
|
+
*/
|
|
208
|
+
setSelectionDirection(direction) {
|
|
209
|
+
this.selectionDirection = direction;
|
|
210
|
+
}
|
|
211
|
+
/**
|
|
212
|
+
* 获取当前主题
|
|
213
|
+
*
|
|
214
|
+
* @return {*} {('light' | 'dark')}
|
|
215
|
+
* @memberof MarkDownEditorController
|
|
216
|
+
*/
|
|
217
|
+
getCurrentTheme() {
|
|
218
|
+
return this.currentEditorTheme === "dark" ? "dark" : "light";
|
|
219
|
+
}
|
|
179
220
|
/**
|
|
180
221
|
* 获取选中文本
|
|
181
222
|
*
|
|
@@ -186,6 +227,30 @@ class MarkDownEditorController extends runtime.EditorController {
|
|
|
186
227
|
var _a;
|
|
187
228
|
return (_a = this.mdeditor) == null ? void 0 : _a.editor.editor.getSelection();
|
|
188
229
|
}
|
|
230
|
+
/**
|
|
231
|
+
* 获取内联AI编辑器主题
|
|
232
|
+
*
|
|
233
|
+
* @return {*} {('light' | 'dark')}
|
|
234
|
+
* @memberof MarkDownEditorController
|
|
235
|
+
*/
|
|
236
|
+
getInLineAiEditorTheme() {
|
|
237
|
+
return this.getCurrentTheme();
|
|
238
|
+
}
|
|
239
|
+
/**
|
|
240
|
+
* 判断选区方向
|
|
241
|
+
*
|
|
242
|
+
* @param {IData} posA
|
|
243
|
+
* @param {IData} posB
|
|
244
|
+
* @return {*} {boolean}
|
|
245
|
+
* @memberof MarkDownEditorController
|
|
246
|
+
*/
|
|
247
|
+
isPositionBefore(posA, posB) {
|
|
248
|
+
if (posA.line < posB.line)
|
|
249
|
+
return true;
|
|
250
|
+
if (posA.line > posB.line)
|
|
251
|
+
return false;
|
|
252
|
+
return posA.ch < posB.ch;
|
|
253
|
+
}
|
|
189
254
|
/**
|
|
190
255
|
* 插入文本
|
|
191
256
|
*
|
|
@@ -193,8 +258,32 @@ class MarkDownEditorController extends runtime.EditorController {
|
|
|
193
258
|
* @memberof MarkDownEditorController
|
|
194
259
|
*/
|
|
195
260
|
insertText(text) {
|
|
196
|
-
var _a;
|
|
197
|
-
(
|
|
261
|
+
var _a, _b, _c;
|
|
262
|
+
if (this.selectionAreaPosition) {
|
|
263
|
+
const { start, end } = this.selectionAreaPosition;
|
|
264
|
+
const contentToInsert = "\n".concat(text, "\n");
|
|
265
|
+
const hasSelection = !(start.line === end.line && start.ch === end.ch);
|
|
266
|
+
if (!hasSelection) {
|
|
267
|
+
(_a = this.mdeditor) == null ? void 0 : _a.editor.editor.replaceSelection(contentToInsert);
|
|
268
|
+
return;
|
|
269
|
+
}
|
|
270
|
+
let insetPos;
|
|
271
|
+
if (this.selectionDirection) {
|
|
272
|
+
insetPos = end;
|
|
273
|
+
} else {
|
|
274
|
+
insetPos = start;
|
|
275
|
+
}
|
|
276
|
+
(_b = this.mdeditor) == null ? void 0 : _b.editor.editor.setCursor(insetPos);
|
|
277
|
+
(_c = this.mdeditor) == null ? void 0 : _c.editor.editor.replaceSelection(contentToInsert);
|
|
278
|
+
if (this.selectionDirection === false) {
|
|
279
|
+
const index = (contentToInsert.match(/\n/g) || []).length;
|
|
280
|
+
this.selectionAreaPosition.start.line += index;
|
|
281
|
+
this.selectionAreaPosition.end.line += index;
|
|
282
|
+
this.selectionAreaPosition.end.ch -= this.selectionAreaPosition.start.ch;
|
|
283
|
+
this.selectionAreaPosition.start.ch = 0;
|
|
284
|
+
}
|
|
285
|
+
this.restoreSelection();
|
|
286
|
+
}
|
|
198
287
|
}
|
|
199
288
|
/**
|
|
200
289
|
* 替换选中文本
|
|
@@ -225,14 +314,30 @@ class MarkDownEditorController extends runtime.EditorController {
|
|
|
225
314
|
* @memberof MarkDownEditorController
|
|
226
315
|
*/
|
|
227
316
|
getInLineAiChatOptions() {
|
|
228
|
-
var _a;
|
|
317
|
+
var _a, _b, _c;
|
|
229
318
|
const editorRect = (_a = this.mdeditor) == null ? void 0 : _a.wrapperDom.getBoundingClientRect();
|
|
319
|
+
const bubbleRect = (_b = this.mdeditor) == null ? void 0 : _b.bubble.bubbleDom.getBoundingClientRect();
|
|
230
320
|
return {
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
321
|
+
// 编辑器的左侧距离 + 10px
|
|
322
|
+
left: editorRect.left + 10,
|
|
323
|
+
// 浮动工具栏的顶部距离位置
|
|
324
|
+
top: bubbleRect.top,
|
|
325
|
+
// 编辑器的宽度 - 右侧工具栏的宽度(38px) - 左侧边距(10px)- 右侧边距(10px)
|
|
326
|
+
width: editorRect.width - 58,
|
|
327
|
+
editorElement: (_c = this.mdeditor) == null ? void 0 : _c.wrapperDom,
|
|
328
|
+
editorTheme: this.getCurrentTheme()
|
|
234
329
|
};
|
|
235
330
|
}
|
|
331
|
+
/**
|
|
332
|
+
* 返回内联AI编辑器元素
|
|
333
|
+
*
|
|
334
|
+
* @return {*} {Element}
|
|
335
|
+
* @memberof MarkDownEditorController
|
|
336
|
+
*/
|
|
337
|
+
getInLineAiEditorElement() {
|
|
338
|
+
var _a;
|
|
339
|
+
return (_a = this.mdeditor) == null ? void 0 : _a.wrapperDom;
|
|
340
|
+
}
|
|
236
341
|
/**
|
|
237
342
|
* 执行内联AIUI操作
|
|
238
343
|
*
|
package/lib/locale/en/index.cjs
CHANGED
|
@@ -629,7 +629,8 @@ var index = {
|
|
|
629
629
|
noEditorArea: "Editor content area not found",
|
|
630
630
|
noSelStart: "No start position of current selection",
|
|
631
631
|
noEditorRect: "No editor DOM node position info",
|
|
632
|
-
noSelCoords: "No scroll coordinates of selection"
|
|
632
|
+
noSelCoords: "No scroll coordinates of selection",
|
|
633
|
+
editorNotInit: "Editor not initialized"
|
|
633
634
|
},
|
|
634
635
|
dateRange: {
|
|
635
636
|
rangeSeparator: "To"
|
|
@@ -846,7 +847,9 @@ var index = {
|
|
|
846
847
|
replaceText: "Replace Text",
|
|
847
848
|
copyText: "Copy Text",
|
|
848
849
|
info: "The content is generated by AI, please carefully discern.",
|
|
849
|
-
stopEdit: "Terminate editing"
|
|
850
|
+
stopEdit: "Terminate editing",
|
|
851
|
+
warningTitle: "Confirm termination",
|
|
852
|
+
warningDesc: "Are you sure to terminate the creation?"
|
|
850
853
|
}
|
|
851
854
|
},
|
|
852
855
|
// runTime
|
|
@@ -625,7 +625,8 @@ var index = {
|
|
|
625
625
|
noEditorArea: "\u672A\u627E\u5230\u7F16\u8F91\u5668\u5185\u5BB9\u533A\u57DF",
|
|
626
626
|
noSelStart: "\u672A\u83B7\u53D6\u5230\u5F53\u524D\u9009\u4E2D\u533A\u57DF\u7684\u8D77\u59CB\u4F4D\u7F6E",
|
|
627
627
|
noEditorRect: "\u672A\u83B7\u53D6\u5230\u7F16\u8F91\u5668DOM\u8282\u70B9\u7684\u4F4D\u7F6E\u4FE1\u606F",
|
|
628
|
-
noSelCoords: "\u672A\u8BA1\u7B97\u51FA\u9009\u4E2D\u4F4D\u7F6E\u7684\u6EDA\u52A8\u53EF\u89C6\u5750\u6807"
|
|
628
|
+
noSelCoords: "\u672A\u8BA1\u7B97\u51FA\u9009\u4E2D\u4F4D\u7F6E\u7684\u6EDA\u52A8\u53EF\u89C6\u5750\u6807",
|
|
629
|
+
editorNotInit: "\u7F16\u8F91\u5668\u672A\u521D\u59CB\u5316"
|
|
629
630
|
},
|
|
630
631
|
dateRange: {
|
|
631
632
|
rangeSeparator: "\u81F3"
|
|
@@ -842,7 +843,9 @@ var index = {
|
|
|
842
843
|
replaceText: "\u66FF\u6362\u6587\u672C",
|
|
843
844
|
copyText: "\u590D\u5236\u6587\u672C",
|
|
844
845
|
info: "\u5185\u5BB9\u7531 AI \u751F\u6210\uFF0C\u8BF7\u4ED4\u7EC6\u7504\u522B\u3002",
|
|
845
|
-
stopEdit: "\u7EC8\u6B62\u7F16\u8F91"
|
|
846
|
+
stopEdit: "\u7EC8\u6B62\u7F16\u8F91",
|
|
847
|
+
warningTitle: "\u786E\u8BA4\u4E2D\u6B62",
|
|
848
|
+
warningDesc: "\u786E\u8BA4\u4E2D\u6B62\u521B\u4F5C\u5417\uFF1F"
|
|
846
849
|
}
|
|
847
850
|
},
|
|
848
851
|
// runTime
|
|
@@ -54,32 +54,45 @@ const InlineAITextArea = /* @__PURE__ */ vue.defineComponent({
|
|
|
54
54
|
const ns = vue3Util.useNamespace("inline-ai-textarea-container");
|
|
55
55
|
const containerRef = vue.ref();
|
|
56
56
|
const actionsRef = vue.ref();
|
|
57
|
+
const textareaRef = vue.ref();
|
|
58
|
+
const textareaContent = vue.ref(props.content);
|
|
59
|
+
let question;
|
|
60
|
+
const contentType = vue.ref("USER");
|
|
61
|
+
const isLoading = vue.ref(false);
|
|
62
|
+
const disabled = vue.computed(() => {
|
|
63
|
+
return contentType.value === "ASSISTANT" || isLoading.value;
|
|
64
|
+
});
|
|
65
|
+
const isShow = vue.computed(() => {
|
|
66
|
+
return contentType.value === "ASSISTANT" && !isLoading.value;
|
|
67
|
+
});
|
|
57
68
|
const {
|
|
58
69
|
srfaiappendcurdata,
|
|
59
70
|
srfaiautoappend,
|
|
60
|
-
srfmode
|
|
71
|
+
srfmode,
|
|
72
|
+
srfaiagent
|
|
61
73
|
} = inlineAiTextarea_hook.computedInLineAIParams(props);
|
|
62
74
|
const {
|
|
75
|
+
theme,
|
|
63
76
|
actions,
|
|
64
77
|
actionStyle,
|
|
65
78
|
containerStyle,
|
|
66
79
|
contentStyle
|
|
67
80
|
} = inlineAiTextarea_hook.useBase(props, containerRef, actionsRef);
|
|
68
|
-
inlineAiTextarea_hook.useInLineAIContainerClick(props);
|
|
81
|
+
inlineAiTextarea_hook.useInLineAIContainerClick(props, textareaContent, isLoading);
|
|
69
82
|
const {
|
|
70
83
|
askAI
|
|
71
84
|
} = inlineAiTextarea_hook.useAI(props, {
|
|
72
85
|
srfaiappendcurdata,
|
|
73
|
-
srfmode
|
|
74
|
-
|
|
75
|
-
const textareaContent = vue.ref(props.content);
|
|
76
|
-
let question;
|
|
77
|
-
const contentType = vue.ref("USER");
|
|
78
|
-
const isLoading = vue.ref(false);
|
|
79
|
-
const disabled = vue.computed(() => {
|
|
80
|
-
return contentType.value === "ASSISTANT" || isLoading.value;
|
|
86
|
+
srfmode,
|
|
87
|
+
srfaiagent
|
|
81
88
|
});
|
|
89
|
+
const restoreFocus = () => {
|
|
90
|
+
var _a;
|
|
91
|
+
(_a = textareaRef.value) == null ? void 0 : _a.blur();
|
|
92
|
+
props.restoreSelection();
|
|
93
|
+
};
|
|
82
94
|
const sendQuestion = async (content) => {
|
|
95
|
+
restoreFocus();
|
|
83
96
|
question = content;
|
|
84
97
|
textareaContent.value = "";
|
|
85
98
|
isLoading.value = true;
|
|
@@ -124,15 +137,22 @@ const InlineAITextArea = /* @__PURE__ */ vue.defineComponent({
|
|
|
124
137
|
}
|
|
125
138
|
};
|
|
126
139
|
vue.onMounted(() => {
|
|
127
|
-
|
|
140
|
+
var _a;
|
|
141
|
+
if (srfaiautoappend) {
|
|
128
142
|
sendQuestion(textareaContent.value);
|
|
143
|
+
} else {
|
|
144
|
+
(_a = textareaRef.value) == null ? void 0 : _a.focus();
|
|
145
|
+
}
|
|
129
146
|
});
|
|
130
147
|
return {
|
|
131
148
|
ns,
|
|
149
|
+
theme,
|
|
150
|
+
isShow,
|
|
132
151
|
actions,
|
|
152
|
+
disabled,
|
|
133
153
|
isLoading,
|
|
134
154
|
actionsRef,
|
|
135
|
-
|
|
155
|
+
textareaRef,
|
|
136
156
|
actionStyle,
|
|
137
157
|
contentType,
|
|
138
158
|
containerRef,
|
|
@@ -148,8 +168,8 @@ const InlineAITextArea = /* @__PURE__ */ vue.defineComponent({
|
|
|
148
168
|
render() {
|
|
149
169
|
return vue.createVNode("div", {
|
|
150
170
|
"ref": "containerRef",
|
|
151
|
-
"
|
|
152
|
-
"
|
|
171
|
+
"style": this.containerStyle,
|
|
172
|
+
"class": [this.ns.b(), this.ns.m(this.theme), this.ns.is("show-ai", this.isShow)]
|
|
153
173
|
}, [vue.createVNode("div", {
|
|
154
174
|
"class": this.ns.e("content"),
|
|
155
175
|
"style": this.contentStyle
|
|
@@ -160,36 +180,31 @@ const InlineAITextArea = /* @__PURE__ */ vue.defineComponent({
|
|
|
160
180
|
}, [icon.AIIcon])]), vue.createVNode("div", {
|
|
161
181
|
"class": this.ns.em("content", "textarea")
|
|
162
182
|
}, [this.isLoading && vue.createVNode("div", {
|
|
163
|
-
"class": "
|
|
164
|
-
"style": ""
|
|
183
|
+
"class": this.ns.e("loading")
|
|
165
184
|
}, [vue.createVNode("div", {
|
|
166
|
-
"class": "
|
|
167
|
-
},
|
|
168
|
-
"class": "
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
"
|
|
173
|
-
"cy": "25",
|
|
174
|
-
"r": "20",
|
|
175
|
-
"fill": "none"
|
|
176
|
-
}, null)])])]), vue.withDirectives(vue.createVNode("textarea", {
|
|
185
|
+
"class": this.ns.em("loading", "dot")
|
|
186
|
+
}, null), vue.createVNode("div", {
|
|
187
|
+
"class": this.ns.em("loading", "dot")
|
|
188
|
+
}, null), vue.createVNode("div", {
|
|
189
|
+
"class": this.ns.em("loading", "dot")
|
|
190
|
+
}, null)]), vue.withDirectives(vue.createVNode("textarea", {
|
|
191
|
+
"ref": "textareaRef",
|
|
177
192
|
"disabled": this.disabled,
|
|
178
193
|
"onKeydown": this.onKeydown,
|
|
179
194
|
"onUpdate:modelValue": ($event) => this.textareaContent = $event
|
|
180
|
-
}, null), [[vue.vModelText, this.textareaContent]])]),
|
|
195
|
+
}, null), [[vue.vModelText, this.textareaContent]])]), vue.createVNode("div", {
|
|
181
196
|
"class": this.ns.em("content", "suffix")
|
|
182
|
-
}, [this.isLoading
|
|
197
|
+
}, [this.isLoading && vue.createVNode("div", {
|
|
183
198
|
"class": this.ns.em("content", "stop-icon"),
|
|
184
199
|
"onClick": () => this.stopQuestion()
|
|
185
|
-
}, [icon.StopIcon, vue.createVNode("span", null, [ibiz.i18n.t("util.inlineAiUtil.stopEdit")])])
|
|
200
|
+
}, [icon.StopIcon, vue.createVNode("span", null, [ibiz.i18n.t("util.inlineAiUtil.stopEdit")])]), !this.disabled && vue.createVNode("div", {
|
|
186
201
|
"class": this.ns.em("content", "sand-icon"),
|
|
187
202
|
"onClick": () => this.sendQuestion(this.textareaContent)
|
|
188
|
-
}, [icon.SendIcon])])]),
|
|
189
|
-
"class": this.ns.e("footer")
|
|
203
|
+
}, [icon.SendIcon])])]), vue.createVNode("div", {
|
|
204
|
+
"class": [this.ns.e("footer"), this.ns.is("show", this.isShow)]
|
|
190
205
|
}, [ibiz.i18n.t("util.inlineAiUtil.info")]), vue.createVNode("div", {
|
|
191
206
|
"ref": "actionsRef",
|
|
192
|
-
"class": [this.ns.e("actions"), this.ns.is("show", this.
|
|
207
|
+
"class": [this.ns.e("actions"), this.ns.is("show", this.isShow)],
|
|
193
208
|
"style": this.actionStyle
|
|
194
209
|
}, [this.actions.map((action) => {
|
|
195
210
|
if (action.itemType === "divider")
|
|
@@ -1 +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)}.ibiz-inline-ai-container-context-menu .scroll-content{pointer-events:unset}.ibiz-inline-ai-container-context-menu .mx-context-menu{cursor:pointer}.ibiz-inline-ai-textarea-container{position:absolute;z-index:
|
|
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}
|
|
@@ -10,14 +10,27 @@ const computedInLineAIParams = (props) => {
|
|
|
10
10
|
return {
|
|
11
11
|
srfaiappendcurdata: (_a = props.context.srfaiappendcurdata) != null ? _a : true,
|
|
12
12
|
srfaiautoappend: props.params.srfaiautoappend === "true" || props.params.srfaiautoappend === true,
|
|
13
|
-
srfmode: props.params.srfmode
|
|
13
|
+
srfmode: props.params.srfmode,
|
|
14
|
+
srfaiagent: props.params.srfaiagent
|
|
14
15
|
};
|
|
15
16
|
};
|
|
16
|
-
const useInLineAIContainerClick = (props) => {
|
|
17
|
-
const handclick = (evt) => {
|
|
17
|
+
const useInLineAIContainerClick = (props, content, isLoading) => {
|
|
18
|
+
const handclick = async (evt) => {
|
|
18
19
|
const target = evt.target;
|
|
19
|
-
if (!target.closest(".ibiz-inline-ai-textarea-container")) {
|
|
20
|
-
props.
|
|
20
|
+
if (!target.closest(".ibiz-inline-ai-textarea-container") && !target.closest(".ibiz-inline-ai-alert") && !isLoading.value) {
|
|
21
|
+
const isChange = props.content !== content.value;
|
|
22
|
+
let isClose = true;
|
|
23
|
+
if (isChange) {
|
|
24
|
+
isClose = await ibiz.confirm.warning({
|
|
25
|
+
title: ibiz.i18n.t("util.inlineAiUtil.warningTitle"),
|
|
26
|
+
desc: ibiz.i18n.t("util.inlineAiUtil.warningDesc"),
|
|
27
|
+
options: {
|
|
28
|
+
modalClass: "ibiz-inline-ai-alert"
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
if (isClose)
|
|
33
|
+
props.unMountAIChat();
|
|
21
34
|
}
|
|
22
35
|
};
|
|
23
36
|
vue.onMounted(() => {
|
|
@@ -29,7 +42,7 @@ const useInLineAIContainerClick = (props) => {
|
|
|
29
42
|
};
|
|
30
43
|
const useAI = (props, opts) => {
|
|
31
44
|
const { context, data, deACMode } = props;
|
|
32
|
-
const { srfaiappendcurdata, srfmode } = opts;
|
|
45
|
+
const { srfaiappendcurdata, srfmode, srfaiagent } = opts;
|
|
33
46
|
const params = { srfactag: deACMode.codeName };
|
|
34
47
|
const app = ibiz.hub.getApp(deACMode.appId);
|
|
35
48
|
let history = [];
|
|
@@ -50,6 +63,8 @@ const useAI = (props, opts) => {
|
|
|
50
63
|
Object.assign(body, { data });
|
|
51
64
|
if (srfmode)
|
|
52
65
|
Object.assign(body, { mode: srfmode });
|
|
66
|
+
if (srfaiagent)
|
|
67
|
+
Object.assign(body, { srfaiagent });
|
|
53
68
|
const response = await app.net.post(path, body, params);
|
|
54
69
|
if (response.ok && Array.isArray(response.data)) {
|
|
55
70
|
history = response.data.filter(
|
|
@@ -70,6 +85,8 @@ const useAI = (props, opts) => {
|
|
|
70
85
|
};
|
|
71
86
|
if (srfmode)
|
|
72
87
|
Object.assign(body, { mode: srfmode });
|
|
88
|
+
if (srfaiagent)
|
|
89
|
+
Object.assign(body, { srfaiagent });
|
|
73
90
|
const appDataEntity = await ibiz.hub.getAppDataEntity(
|
|
74
91
|
deACMode.appDataEntityId,
|
|
75
92
|
deACMode.appId
|
|
@@ -125,24 +142,47 @@ const useBase = (props, container, target) => {
|
|
|
125
142
|
actionName: "cancel"
|
|
126
143
|
}
|
|
127
144
|
];
|
|
145
|
+
const { options } = props;
|
|
146
|
+
const editorRect = options.editorElement.getBoundingClientRect();
|
|
147
|
+
const offsetX = options.left - editorRect.left;
|
|
148
|
+
const offsetY = options.top - editorRect.top;
|
|
149
|
+
const theme = options.editorTheme || "light";
|
|
128
150
|
const actionStyle = vue.ref({});
|
|
129
151
|
const containerStyle = vue.ref({
|
|
130
|
-
width: "".concat(
|
|
131
|
-
left: "".concat(
|
|
132
|
-
top: "".concat(
|
|
152
|
+
width: "".concat(options.width, "px"),
|
|
153
|
+
left: "".concat(options.left, "px"),
|
|
154
|
+
top: "".concat(options.top, "px")
|
|
133
155
|
});
|
|
134
156
|
const contentStyle = vue.ref({
|
|
135
|
-
height: "".concat(
|
|
136
|
-
"max-height": "".concat(
|
|
157
|
+
height: "".concat(options.height || 80, "px"),
|
|
158
|
+
"max-height": "".concat(options.maxHeight, "px")
|
|
137
159
|
});
|
|
138
|
-
const
|
|
160
|
+
const updatePosition = () => {
|
|
139
161
|
if (!container.value || !target.value)
|
|
140
162
|
return;
|
|
141
|
-
const
|
|
163
|
+
const rect = options.editorElement.getBoundingClientRect();
|
|
164
|
+
let top = rect.top + offsetY;
|
|
165
|
+
let left = rect.left + offsetX;
|
|
166
|
+
const containerWidth = container.value.offsetWidth;
|
|
167
|
+
const containerHeight = container.value.offsetHeight;
|
|
168
|
+
const windowWidth = window.innerWidth;
|
|
169
|
+
const windowHeight = window.innerHeight;
|
|
170
|
+
const margin = 8;
|
|
171
|
+
if (left + containerWidth + margin > windowWidth) {
|
|
172
|
+
left = windowWidth - containerWidth - margin;
|
|
173
|
+
} else if (left < margin) {
|
|
174
|
+
left = margin;
|
|
175
|
+
}
|
|
176
|
+
if (top + containerHeight + margin > windowHeight) {
|
|
177
|
+
top = windowHeight - containerHeight - margin;
|
|
178
|
+
} else if (top < margin) {
|
|
179
|
+
top = margin;
|
|
180
|
+
}
|
|
181
|
+
containerStyle.value.top = "".concat(top, "px");
|
|
182
|
+
containerStyle.value.left = "".concat(left, "px");
|
|
183
|
+
const position = containerHeight + 4;
|
|
142
184
|
const targetHeight = target.value.offsetHeight;
|
|
143
|
-
|
|
144
|
-
const position = (isInit ? containerRect.height + 41 : containerRect.height) + 4;
|
|
145
|
-
if (spaceBelow >= targetHeight + 8) {
|
|
185
|
+
if (windowHeight - (top + containerHeight + targetHeight) > margin) {
|
|
146
186
|
actionStyle.value.top = "".concat(position, "px");
|
|
147
187
|
actionStyle.value.bottom = "auto";
|
|
148
188
|
} else {
|
|
@@ -150,15 +190,30 @@ const useBase = (props, container, target) => {
|
|
|
150
190
|
actionStyle.value.top = "auto";
|
|
151
191
|
}
|
|
152
192
|
};
|
|
153
|
-
|
|
193
|
+
let ticking = false;
|
|
194
|
+
const optimizedUpdatePosition = () => {
|
|
195
|
+
if (!ticking) {
|
|
196
|
+
requestAnimationFrame(() => {
|
|
197
|
+
updatePosition();
|
|
198
|
+
ticking = false;
|
|
199
|
+
});
|
|
200
|
+
ticking = true;
|
|
201
|
+
}
|
|
202
|
+
};
|
|
154
203
|
vue.onMounted(() => {
|
|
155
|
-
|
|
156
|
-
|
|
204
|
+
updatePosition();
|
|
205
|
+
document.addEventListener("scroll", optimizedUpdatePosition, {
|
|
206
|
+
capture: true
|
|
207
|
+
});
|
|
208
|
+
window.addEventListener("resize", optimizedUpdatePosition);
|
|
157
209
|
});
|
|
158
210
|
vue.onUnmounted(() => {
|
|
159
|
-
|
|
211
|
+
document.removeEventListener("scroll", optimizedUpdatePosition, {
|
|
212
|
+
capture: true
|
|
213
|
+
});
|
|
214
|
+
window.removeEventListener("resize", optimizedUpdatePosition);
|
|
160
215
|
});
|
|
161
|
-
return { actions, actionStyle, containerStyle, contentStyle };
|
|
216
|
+
return { theme, actions, actionStyle, containerStyle, contentStyle };
|
|
162
217
|
};
|
|
163
218
|
|
|
164
219
|
exports.computedInLineAIParams = computedInLineAIParams;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ibiz-template/vue3-components",
|
|
3
|
-
"version": "0.7.41-alpha.
|
|
3
|
+
"version": "0.7.41-alpha.39",
|
|
4
4
|
"description": "web端组件库(vue3)",
|
|
5
5
|
"main": "lib/index.cjs",
|
|
6
6
|
"module": "es/index.mjs",
|
|
@@ -36,10 +36,10 @@
|
|
|
36
36
|
"@ibiz-template-plugin/data-view": "0.0.6",
|
|
37
37
|
"@ibiz-template/core": "0.7.41-alpha.35",
|
|
38
38
|
"@ibiz-template/devtool": "0.0.13",
|
|
39
|
-
"@ibiz-template/model-helper": "0.7.41-alpha.
|
|
40
|
-
"@ibiz-template/runtime": "0.7.41-alpha.
|
|
39
|
+
"@ibiz-template/model-helper": "0.7.41-alpha.38",
|
|
40
|
+
"@ibiz-template/runtime": "0.7.41-alpha.38",
|
|
41
41
|
"@ibiz-template/theme": "0.7.39",
|
|
42
|
-
"@ibiz-template/vue3-util": "0.7.41-alpha.
|
|
42
|
+
"@ibiz-template/vue3-util": "0.7.41-alpha.38",
|
|
43
43
|
"@ibiz-template/web-theme": "3.9.0",
|
|
44
44
|
"@ibiz/model-core": "^0.1.83",
|
|
45
45
|
"@imengyu/vue3-context-menu": "^1.3.5",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
System.register(["vue","@ibiz-template/vue3-util","qx-util","cherry-markdown"],function(e){"use strict";var t,i,l,n,o,a,r,s,d,c,u,m,h,f;return{setters:[function(e){t=e.nextTick,i=e.defineComponent,l=e.createVNode,n=e.ref,o=e.watch,a=e.onMounted,r=e.onBeforeUnmount,s=e.onUnmounted},function(e){d=e.getEditorEmits,c=e.getMarkDownProps,u=e.useNamespace,m=e.useUIStore},function(e){h=e.createUUID},function(e){f=e.default}],execute:function(){e("default",i({name:"IBizMarkDown",props:c(),emits:d(),setup(e,{emit:i}){var d,c,v;const b=u("markdown"),p=e.controller,g=n("");let w=null;const k=h(),[C]=function(e){return[f.createMenuHook("AI",{icon:{type:"svg",content:"<svg\n viewBox='0 0 16 16'\n xmlns='http://www.w3.org/2000/svg'\n fill='currentColor'\n height='1em'\n width='1em'\n preserveAspectRatio='xMidYMid meet'\n focusable='false'\n >\n <g\n id='aae1.Base基础/1.icon图标/2.normal/ai-star'\n stroke-width='1'\n fill-rule='evenodd'\n >\n <path\n 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'\n id='aae形状结合'\n ></path>\n </g>\n </svg>\n "},onClick:(i,l,n)=>{var o,a;const r=null==(o=e.mdeditor)?void 0:o.editor.editor.getCursor("start"),s=null==(a=e.mdeditor)?void 0:a.editor.editor.getCursor("end");e.setCursorPos(r,s),n.stopPropagation(),n.preventDefault(),t(()=>{var t;if(null==(t=e.mdeditor)?void 0:t.bubble){e.mdeditor.bubble.visible=!0;const t=e.mdeditor.bubble.bubbleDom.getBoundingClientRect();if(!t||!t.left||!t.top)return;const i=ibiz.inLineAIUtil.calcContextMenus(e.deACMode,t=>{e.doInLineAIUIAction(t,e.model.appId)});if(0===i.length)return;ibiz.inLineAIUtil.showContextMenus(t.left,t.top+60,i)}})}})]}(p),y=ibiz.util.file.getUploadHeaders(),x=n({...y}),z=n(""),M=(null==(d=null==p?void 0:p.editorParams)?void 0:d.customTheme)||(null==(c=null==p?void 0:p.editorParams)?void 0:c.customtheme),{UIStore:U}=m(),I=n(M||U.theme),P=n(!1);let D="default";p&&(null==(v=p.editorParams)?void 0:v.showmode)&&(D=p.editorParams.showmode);const E=n(!1),T=n("editOnly");let A=null,B=0;const O=n({});let L=!1;o(()=>e.data,e=>{if(e&&p){const t={...p.editorParams};t.uploadparams&&(t.uploadParams=JSON.parse(t.uploadparams));const i=ibiz.util.file.calcFileUpDownUrl(p.context,p.params,e,t);z.value=i.uploadUrl}},{immediate:!0,deep:!0});const N=n(),S=async(t,i)=>{const l=await ibiz.util.file.fileUpload(z.value,t,x.value),n=((e,t)=>{if(!p)return"";const i={...p.editorParams};return i.exportparams&&(i.exportParams=JSON.parse(i.exportparams)),t&&t.folder&&(i.osscat=t.folder),ibiz.util.file.calcFileUpDownUrl(p.context,p.params,e,i).downloadUrl})(e.data||{},l.fileid);let o=n.replace("%fileId%",l.fileid);if(ibiz.config.common.enableDownloadTicket&&p){const t=await ibiz.util.file.getDownloadTicket(p.context,p.params,e.data||{},{fileId:l.fileid},p.downloadTicketParams);t&&t.ticket&&(o=n.replace("%fileId%",t.ticket),i(o))}else i(o)},H=()=>null==w?void 0:w.getMarkdown(),V=e=>{L=!0,null==w||w.setMarkdown(e,!0)};o(()=>e.value,(e,t)=>{e!==t&&(g.value=e||"")},{immediate:!0}),o(g,(e,t)=>{const i=H();e!==t&&i!==e&&V(e)});const R=e=>{"manual"!==D&&(i("change",H(),null==p?void 0:p.model.id,L),L=!1)},q=(e,t)=>({[e]:t}),F=(e,t="")=>{const i=document.createElement(e);return i.className=t,i},j=e=>F("i","ch-icon ch-icon-".concat(e)),J=b.e("fullscreen"),W=e=>{for(;e.firstChild;)e.removeChild(e.firstChild)},Y=()=>{if(w&&N.value){const e=w.editor.options.editorDom.parentElement;if(!e)return{};const t=e.classList,i=N.value.querySelector(".".concat(J));return i?{parentElement:e,cherryClass:t,fullscreenNode:i}:{}}return{}},G=()=>{const{parentElement:e,cherryClass:t,fullscreenNode:i}=Y();e&&t&&i&&(W(i),i.appendChild(j("fullscreen")),i.title=ibiz.i18n.t("editor.common.fullscreen"),t.remove("fullscreen"),null==e||e.blur(),e.setAttribute("tabindex","-1"))},K=()=>{const{cherryClass:e}=Y();return null==e?void 0:e.contains("fullscreen")},Q=()=>{w&&N.value&&(K()?(G(),E.value=!1):((()=>{const{parentElement:e,cherryClass:i,fullscreenNode:l}=Y();e&&i&&l&&(W(l),l.appendChild(j("minscreen")),i.add("fullscreen"),l.title=ibiz.i18n.t("editor.common.minimize"),e.setAttribute("tabindex","-1"),t(()=>null==e?void 0:e.focus()))})(),E.value=!0))},X=e=>{e.stopPropagation(),"Escape"===e.key&&K()&&(G(),E.value=!1)};o(()=>U.theme,e=>{I.value=M||e,null==w||w.setTheme(I.value),null==w||w.setCodeBlockTheme(I.value)});const Z=()=>{P.value=!0,T.value="editOnly",null==w||w.switchModel(T.value)},$=()=>{P.value=!1,T.value="previewOnly",null==w||w.switchModel(T.value)},_=()=>{V(g.value),$()},ee=()=>{i("change",H(),null==p?void 0:p.model.id,L),L=!1,$()};return a(()=>{(e.disabled||e.readonly||"manual"===D)&&(T.value="previewOnly"),t(()=>{var t;const i=["bold","italic","underline","strikethrough","sub","sup","|","size","color"];p.editorParams.ac&&p.deACMode&&i.unshift("AI"),w=new f({id:k,value:g.value,previewer:{enablePreviewerBubble:!(e.disabled||e.readonly)},themeSettings:{mainTheme:I.value,codeBlockTheme:I.value},fileUpload:S,emoji:{useUnicode:!0},header:{anchorStyle:"autonumber"},editor:{height:"100%",defaultModel:T.value,codemirror:{autofocus:!1}},toolbars:{toolbar:["bold","italic","underline","strikethrough","|","color","header","|","list","image",{insert:["link","hr","br","code","formula","toc","table","line-table","bar-table"]},"settings","togglePreview"],bubble:i,float:["h1","h2","h3","|","checklist","quote","quickTable","code"],customMenu:{AI:C},sidebar:["theme","copy"],toolbarRight:[],toc:{updateLocationHash:!1,defaultModel:"pure",showAutoNumber:!0,position:"absolute",cssText:""}},callback:{afterChange:R,beforeImageMounted:q},engine:{syntax:{table:{enableChart:!1,externals:["echarts"]}}}}),w.setTheme(I.value),M&&(w.setTheme(M),w.setCodeBlockTheme(M));const l=F("span","".concat(J," cherry-toolbar-button"));l.title=ibiz.i18n.t("editor.common.fullscreen"),l.onclick=Q,l.appendChild(j("fullscreen"));const n=e.disabled?w.editor.options.editorDom.parentElement:null==(t=w.editor.options.editorDom.parentElement)?void 0:t.querySelector(".cherry-toolbar>.toolbar-right");null==n||n.appendChild(l),p.setMDEditor(w)}),(()=>{if(window.ResizeObserver&&N.value){const e={width:N.value.offsetWidth?"".concat(N.value.offsetWidth,"px"):"100%"};p&&"number"==typeof p.parent.model.height&&Object.assign(e,{height:"".concat(p.parent.model.height,"px")}),O.value=b.cssVarBlock(e),A=new ResizeObserver(e=>{const t=e[0].contentRect.width;if(t!==B){const i={width:"".concat(e[0].contentRect.width,"px")};p&&"number"==typeof p.parent.model.height&&Object.assign(i,{height:"".concat(p.parent.model.height,"px")}),O.value=b.cssVarBlock(i),B=t}}),A.observe(N.value)}})(),document.addEventListener("keydown",X.bind(this))}),r(()=>{document.removeEventListener("keydown",X.bind(this))}),s(()=>{w=null,A&&A.disconnect()}),{ns:b,currentVal:g,id:k,editor:w,markDownBox:N,headers:x,theme:I,defaultModel:T,cssVars:O,isEditing:P,showmode:D,getCherryHtml:()=>null==w?void 0:w.getHtml(),getCherryContent:H,setCherryContent:V,renderHeader:()=>{if("manual"===D&&!P.value)return l("div",{class:[b.e("header"),b.is("fullscreen",E.value)]},[!e.disabled&&!e.readonly&&l("div",{class:b.em("header","edit"),onClick:Z,title:ibiz.i18n.t("editor.markdown.edit")},[l("i",{class:"fa fa-edit","aria-hidden":"true"},null)]),l("div",{class:b.em("header","full"),onClick:Q},[E.value?l("i",{class:"fa fa-compress","aria-hidden":"true",title:ibiz.i18n.t("editor.html.reduce")},null):l("i",{class:"fa fa-expand","aria-hidden":"true",title:ibiz.i18n.t("editor.common.fullscreen")},null)])])},renderFooter:()=>{if("manual"===D&&P.value&&!e.disabled&&!e.readonly)return l("div",{class:[b.e("footer"),b.is("fullscreen",E.value)]},[l("div",{class:b.em("footer","cancel"),onClick:_},[ibiz.i18n.t("editor.common.cancel")]),l("div",{class:b.em("footer","save"),onClick:ee},[ibiz.i18n.t("editor.common.confirm")])])}}},render(){return l("div",{ref:"markDownBox",class:[this.ns.b(),this.ns.is("disabled",this.disabled),this.ns.is("manual","manual"===this.showmode),this.ns.is("editing",this.isEditing)]},[this.renderHeader(),this.renderFooter(),l("div",{id:this.id,style:this.cssVars,class:this.ns.b("cherry")},null)])}}))}}});
|