@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
|
@@ -23,12 +23,23 @@ const IBizCode = /* @__PURE__ */ defineComponent({
|
|
|
23
23
|
const c = props.controller;
|
|
24
24
|
const UUID = createUUID();
|
|
25
25
|
const currentVal = ref("");
|
|
26
|
+
const {
|
|
27
|
+
UIStore,
|
|
28
|
+
zIndex
|
|
29
|
+
} = useUIStore();
|
|
26
30
|
const enableEdit = ref(true);
|
|
27
31
|
const hasEnableEdit = ref(false);
|
|
28
32
|
const readonlyState = ref(false);
|
|
29
33
|
const enableFullScreen = ref(false);
|
|
30
34
|
const isFullScreen = ref(false);
|
|
31
35
|
const isLoading = ref(false);
|
|
36
|
+
let autoClose;
|
|
37
|
+
const textTBRef = ref();
|
|
38
|
+
const textTBStyle = ref({
|
|
39
|
+
[ns.cssVarBlockName("text-editor-toolbar-z-index")]: zIndex.increment()
|
|
40
|
+
});
|
|
41
|
+
const textTBVisible = ref(false);
|
|
42
|
+
const editorTheme = ref("");
|
|
32
43
|
const editorModel = c.model;
|
|
33
44
|
if (editorModel.editorParams) {
|
|
34
45
|
if (editorModel.editorParams.enableEdit) {
|
|
@@ -47,6 +58,13 @@ const IBizCode = /* @__PURE__ */ defineComponent({
|
|
|
47
58
|
if (editorModel.editorParams.enablefullscreen) {
|
|
48
59
|
enableFullScreen.value = c.toBoolean(editorModel.editorParams.enablefullscreen);
|
|
49
60
|
}
|
|
61
|
+
if (editorModel.editorParams.autoclose) {
|
|
62
|
+
try {
|
|
63
|
+
autoClose = JSON.parse(editorModel.editorParams.autoclose);
|
|
64
|
+
} catch (error) {
|
|
65
|
+
ibiz.log.error(error);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
50
68
|
}
|
|
51
69
|
let editor;
|
|
52
70
|
let monacoEditor;
|
|
@@ -54,13 +72,10 @@ const IBizCode = /* @__PURE__ */ defineComponent({
|
|
|
54
72
|
let inlineCompletionsProviderDisposable;
|
|
55
73
|
let decorationsCollection;
|
|
56
74
|
let chatInstance;
|
|
57
|
-
const {
|
|
58
|
-
UIStore,
|
|
59
|
-
zIndex
|
|
60
|
-
} = useUIStore();
|
|
61
75
|
const getMonacoTheme = (name) => {
|
|
62
|
-
var _a;
|
|
63
|
-
|
|
76
|
+
var _a, _b;
|
|
77
|
+
editorTheme.value = ((_a = c == null ? void 0 : c.editorParams) == null ? void 0 : _a.customTheme) || ibiz.config.codeEditorTheme || name;
|
|
78
|
+
const customTheme = (_b = c == null ? void 0 : c.editorParams) == null ? void 0 : _b.customTheme;
|
|
64
79
|
if (customTheme) {
|
|
65
80
|
return customTheme === "dark" ? "vs-dark" : "vs";
|
|
66
81
|
}
|
|
@@ -137,6 +152,14 @@ const IBizCode = /* @__PURE__ */ defineComponent({
|
|
|
137
152
|
},
|
|
138
153
|
// 编辑器参数srfaiappendcurdata,是否传入对象参数,用于历史查询传参
|
|
139
154
|
appendCurData: c.editorParams.srfaiappendcurdata === "true" ? props.data : void 0,
|
|
155
|
+
// 自动提问
|
|
156
|
+
autoQuestion: c.editorParams.autoquestion !== "false",
|
|
157
|
+
// 自动填充
|
|
158
|
+
autoFill: c.editorParams.autofill === "true",
|
|
159
|
+
// 窗口的打开模式
|
|
160
|
+
openMode: c.editorParams.openmode,
|
|
161
|
+
// 窗口的自动关闭模式
|
|
162
|
+
autoClose,
|
|
140
163
|
// 编辑器参数srfaiappendcurcontent,传入编辑内容作为用户消息,获取历史数据后附加
|
|
141
164
|
appendCurContent: c.editorParams.srfaiappendcurcontent ? StringUtil.fill(c.editorParams.srfaiappendcurcontent, c.context, c.params, props.data) : void 0,
|
|
142
165
|
appDataEntityId: c.model.appDataEntityId,
|
|
@@ -309,6 +332,71 @@ const IBizCode = /* @__PURE__ */ defineComponent({
|
|
|
309
332
|
return false;
|
|
310
333
|
return true;
|
|
311
334
|
};
|
|
335
|
+
const updateTextToolbarPos = (selection) => {
|
|
336
|
+
var _a;
|
|
337
|
+
const position = selection.getStartPosition();
|
|
338
|
+
if (position) {
|
|
339
|
+
const coordinates = editor == null ? void 0 : editor.getScrolledVisiblePosition(position);
|
|
340
|
+
const editorRect = (_a = editor == null ? void 0 : editor.getDomNode()) == null ? void 0 : _a.getBoundingClientRect();
|
|
341
|
+
if (!editorRect || !coordinates)
|
|
342
|
+
return;
|
|
343
|
+
textTBStyle.value = {
|
|
344
|
+
...textTBStyle.value,
|
|
345
|
+
// 编辑器左侧距离 + 选区距离编辑器左侧距离
|
|
346
|
+
[ns.cssVarBlockName("text-editor-toolbar-left")]: "".concat(editorRect.left + coordinates.left, "px"),
|
|
347
|
+
// 编辑器上方距离 + 选区距离编辑器上方距离 + 行高度
|
|
348
|
+
[ns.cssVarBlockName("text-editor-toolbar-top")]: "".concat(editorRect.top + coordinates.top + coordinates.height, "px")
|
|
349
|
+
};
|
|
350
|
+
}
|
|
351
|
+
};
|
|
352
|
+
const setTextTBVisible = () => {
|
|
353
|
+
if (props.readonly || !enableEdit.value || !c.deACMode || !c.chatCompletion)
|
|
354
|
+
return;
|
|
355
|
+
const selection = editor == null ? void 0 : editor.getSelection();
|
|
356
|
+
textTBVisible.value = !!(selection && !selection.isEmpty());
|
|
357
|
+
};
|
|
358
|
+
const onSelectionChange = (e) => {
|
|
359
|
+
const selection = e.selection;
|
|
360
|
+
if (selection) {
|
|
361
|
+
updateTextToolbarPos(selection);
|
|
362
|
+
c.currentSelection = selection;
|
|
363
|
+
}
|
|
364
|
+
};
|
|
365
|
+
const handleLineAiClick = (_e) => {
|
|
366
|
+
var _a, _b;
|
|
367
|
+
const position = (_a = editor == null ? void 0 : editor.getSelection()) == null ? void 0 : _a.getStartPosition();
|
|
368
|
+
if (!position)
|
|
369
|
+
return;
|
|
370
|
+
const coordinates = editor == null ? void 0 : editor.getScrolledVisiblePosition(position);
|
|
371
|
+
const editorRect = (_b = editor == null ? void 0 : editor.getDomNode()) == null ? void 0 : _b.getBoundingClientRect();
|
|
372
|
+
const textTBHeight = textTBRef.value.offsetHeight;
|
|
373
|
+
if (!coordinates || !editorRect || !textTBHeight)
|
|
374
|
+
return;
|
|
375
|
+
const items = ibiz.inLineAIUtil.calcContextMenus(c.deACMode, (tag) => {
|
|
376
|
+
c.doInLineAIUIAction(tag, c.model.appId);
|
|
377
|
+
});
|
|
378
|
+
if (items.length === 0)
|
|
379
|
+
return;
|
|
380
|
+
ibiz.inLineAIUtil.showContextMenus(
|
|
381
|
+
// 编辑器左侧距离 + 选区距离编辑器左侧距离
|
|
382
|
+
editorRect.left + coordinates.left,
|
|
383
|
+
// 编辑器上方距离 + 选区距离编辑器上方距离 + 行高度 + 工具栏高度
|
|
384
|
+
editorRect.top + coordinates.top + coordinates.height + textTBHeight,
|
|
385
|
+
items
|
|
386
|
+
);
|
|
387
|
+
};
|
|
388
|
+
const handleEditorClick = (e) => {
|
|
389
|
+
var _a;
|
|
390
|
+
if (!((_a = textTBRef.value) == null ? void 0 : _a.contains(e.target))) {
|
|
391
|
+
setTimeout(setTextTBVisible, 100);
|
|
392
|
+
}
|
|
393
|
+
};
|
|
394
|
+
const handleMousedown = (e) => {
|
|
395
|
+
var _a;
|
|
396
|
+
if (textTBVisible.value && !((_a = textTBRef.value) == null ? void 0 : _a.contains(e.target))) {
|
|
397
|
+
textTBVisible.value = false;
|
|
398
|
+
}
|
|
399
|
+
};
|
|
312
400
|
const editorInit = () => {
|
|
313
401
|
nextTick(() => {
|
|
314
402
|
isLoading.value = true;
|
|
@@ -318,6 +406,7 @@ const IBizCode = /* @__PURE__ */ defineComponent({
|
|
|
318
406
|
}
|
|
319
407
|
});
|
|
320
408
|
loader.init().then((loaderMonaco) => {
|
|
409
|
+
var _a;
|
|
321
410
|
isLoading.value = false;
|
|
322
411
|
if (!editor) {
|
|
323
412
|
monacoEditor = loaderMonaco.editor;
|
|
@@ -374,6 +463,7 @@ const IBizCode = /* @__PURE__ */ defineComponent({
|
|
|
374
463
|
});
|
|
375
464
|
}
|
|
376
465
|
}
|
|
466
|
+
c.onCreated(editor, loaderMonaco);
|
|
377
467
|
setTimeout(() => {
|
|
378
468
|
editor.layout();
|
|
379
469
|
editor.setValue(currentVal.value);
|
|
@@ -406,11 +496,14 @@ const IBizCode = /* @__PURE__ */ defineComponent({
|
|
|
406
496
|
createDecorationsCollection();
|
|
407
497
|
});
|
|
408
498
|
editor.onDidChangeModelContent(() => {
|
|
499
|
+
setTextTBVisible();
|
|
409
500
|
if (!hasEnableEdit.value) {
|
|
410
501
|
currentVal.value = editor.getValue();
|
|
411
502
|
emit("change", currentVal.value);
|
|
412
503
|
}
|
|
413
504
|
});
|
|
505
|
+
editor.onDidChangeCursorSelection(onSelectionChange);
|
|
506
|
+
(_a = editor.getDomNode()) == null ? void 0 : _a.addEventListener("click", handleEditorClick);
|
|
414
507
|
window.addEventListener("resize", () => {
|
|
415
508
|
editor.layout();
|
|
416
509
|
});
|
|
@@ -526,11 +619,37 @@ const IBizCode = /* @__PURE__ */ defineComponent({
|
|
|
526
619
|
}
|
|
527
620
|
}, null);
|
|
528
621
|
};
|
|
622
|
+
const renderTextEditorToolbar = () => {
|
|
623
|
+
if (!textTBVisible.value)
|
|
624
|
+
return null;
|
|
625
|
+
return createVNode("div", {
|
|
626
|
+
"ref": "textTBRef",
|
|
627
|
+
"class": [ns.b("text-editor-toolbar")],
|
|
628
|
+
"style": {
|
|
629
|
+
...textTBStyle.value
|
|
630
|
+
}
|
|
631
|
+
}, [createVNode("div", {
|
|
632
|
+
"class": [ns.be("text-editor-toolbar", "item")],
|
|
633
|
+
"title": "AI",
|
|
634
|
+
"onClick": handleLineAiClick
|
|
635
|
+
}, [createVNode("svg", {
|
|
636
|
+
"version": "1.1",
|
|
637
|
+
"xmlns": "http://www.w3.org/2000/svg",
|
|
638
|
+
"viewBox": "0 0 1024 1024",
|
|
639
|
+
"width": "1em",
|
|
640
|
+
"height": "1em",
|
|
641
|
+
"fill": "currentColor"
|
|
642
|
+
}, [createVNode("path", {
|
|
643
|
+
"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"
|
|
644
|
+
}, null)])])]);
|
|
645
|
+
};
|
|
529
646
|
onMounted(() => {
|
|
530
647
|
editorInit();
|
|
648
|
+
window.addEventListener("mousedown", handleMousedown.bind(this));
|
|
531
649
|
});
|
|
532
650
|
onUnmounted(() => {
|
|
533
651
|
unload();
|
|
652
|
+
window.removeEventListener("mousedown", handleMousedown.bind(this));
|
|
534
653
|
});
|
|
535
654
|
return {
|
|
536
655
|
ns,
|
|
@@ -540,8 +659,11 @@ const IBizCode = /* @__PURE__ */ defineComponent({
|
|
|
540
659
|
hasEnableEdit,
|
|
541
660
|
readonlyState,
|
|
542
661
|
isLoading,
|
|
662
|
+
textTBRef,
|
|
663
|
+
editorTheme,
|
|
543
664
|
renderFooter,
|
|
544
665
|
renderHeaderToolbar,
|
|
666
|
+
renderTextEditorToolbar,
|
|
545
667
|
renderCodeContent,
|
|
546
668
|
changeFullScreenState
|
|
547
669
|
};
|
|
@@ -550,24 +672,24 @@ const IBizCode = /* @__PURE__ */ defineComponent({
|
|
|
550
672
|
var _a, _b;
|
|
551
673
|
const isLoading = !((_b = (_a = this.controller.view) == null ? void 0 : _a.state) == null ? void 0 : _b.isLoading) && this.isLoading;
|
|
552
674
|
return !this.isFullScreen ? withDirectives(createVNode("div", {
|
|
553
|
-
"class": [this.ns.b(), {
|
|
675
|
+
"class": [this.ns.b(), this.ns.is(this.editorTheme, !!this.editorTheme), {
|
|
554
676
|
[this.ns.b("editor-readonly")]: this.readonlyState
|
|
555
677
|
}, {
|
|
556
678
|
[this.ns.b("editor-enable")]: !this.readonlyState
|
|
557
679
|
}, this.ns.is("enable", this.hasEnableEdit)]
|
|
558
|
-
}, [this.renderHeaderToolbar(), this.renderCodeContent(), this.hasEnableEdit && !this.readonlyState ? this.renderFooter() : null]), [[resolveDirective("loading"), isLoading]]) : createVNode(resolveComponent("el-dialog"), {
|
|
680
|
+
}, [this.renderTextEditorToolbar(), this.renderHeaderToolbar(), this.renderCodeContent(), this.hasEnableEdit && !this.readonlyState ? this.renderFooter() : null]), [[resolveDirective("loading"), isLoading]]) : createVNode(resolveComponent("el-dialog"), {
|
|
559
681
|
"modelValue": this.isFullScreen,
|
|
560
682
|
"onUpdate:modelValue": ($event) => this.isFullScreen = $event,
|
|
561
683
|
"class": this.ns.b("dialog-full-screen"),
|
|
562
684
|
"onClose": () => this.changeFullScreenState()
|
|
563
685
|
}, {
|
|
564
686
|
default: () => [withDirectives(createVNode("div", {
|
|
565
|
-
"class": [this.ns.b(), {
|
|
687
|
+
"class": [this.ns.b(), this.ns.is(this.editorTheme, !!this.editorTheme), {
|
|
566
688
|
[this.ns.b("editor-readonly")]: this.readonlyState
|
|
567
689
|
}, {
|
|
568
690
|
[this.ns.b("editor-enable")]: !this.readonlyState
|
|
569
691
|
}]
|
|
570
|
-
}, [this.renderHeaderToolbar(), this.renderCodeContent(), this.hasEnableEdit && !this.readonlyState ? this.renderFooter() : null]), [[resolveDirective("loading"), isLoading]])]
|
|
692
|
+
}, [this.renderTextEditorToolbar(), this.renderHeaderToolbar(), this.renderCodeContent(), this.hasEnableEdit && !this.readonlyState ? this.renderFooter() : null]), [[resolveDirective("loading"), isLoading]])]
|
|
571
693
|
});
|
|
572
694
|
}
|
|
573
695
|
});
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { h } from 'vue';
|
|
2
|
-
import { EditorController, getDeACMode } from '@ibiz-template/runtime';
|
|
3
|
-
import { NOOP, listenJSEvent } from '@ibiz-template/core';
|
|
2
|
+
import { EditorController, getDeACMode, UIActionUtil } from '@ibiz-template/runtime';
|
|
3
|
+
import { NOOP, listenJSEvent, RuntimeError } from '@ibiz-template/core';
|
|
4
4
|
import { Boot } from '@wangeditor/editor';
|
|
5
5
|
import './wang-editor/index.mjs';
|
|
6
6
|
import { AIMenu } from './wang-editor/module/ai-module.mjs';
|
|
7
|
+
import { InLineAIMenu } from './wang-editor/module/inline-ai-module.mjs';
|
|
7
8
|
import { EmojiElem } from './wang-editor/element/emoji.mjs';
|
|
8
9
|
import { EmojiModule } from './wang-editor/module/emoji-module.mjs';
|
|
9
10
|
import { Plugin } from './wang-editor/plugin/plugin.mjs';
|
|
@@ -170,6 +171,7 @@ class HtmlEditorController extends EditorController {
|
|
|
170
171
|
customRegister() {
|
|
171
172
|
if (!window.aichartRegister && ibiz.env.enableAI) {
|
|
172
173
|
Boot.registerMenu(AIMenu);
|
|
174
|
+
Boot.registerMenu(InLineAIMenu);
|
|
173
175
|
window.aichartRegister = true;
|
|
174
176
|
}
|
|
175
177
|
if (!window.customElements.get("emoji-elem")) {
|
|
@@ -280,6 +282,124 @@ class HtmlEditorController extends EditorController {
|
|
|
280
282
|
this.overlay.dismiss();
|
|
281
283
|
}
|
|
282
284
|
}
|
|
285
|
+
/**
|
|
286
|
+
* 获取选中文本
|
|
287
|
+
* @returns 选中文本
|
|
288
|
+
*/
|
|
289
|
+
getSelectionText() {
|
|
290
|
+
if (this.wangEditor) {
|
|
291
|
+
return this.wangEditor.getSelectionText();
|
|
292
|
+
}
|
|
293
|
+
return "";
|
|
294
|
+
}
|
|
295
|
+
/**
|
|
296
|
+
* 插入文本
|
|
297
|
+
* @param text 文本
|
|
298
|
+
*/
|
|
299
|
+
insertText(text) {
|
|
300
|
+
if (this.wangEditor) {
|
|
301
|
+
const newParagraph = {
|
|
302
|
+
type: "paragraph",
|
|
303
|
+
children: [{ text }]
|
|
304
|
+
};
|
|
305
|
+
const selection = this.wangEditor.selection;
|
|
306
|
+
if (selection) {
|
|
307
|
+
const collapsedSelection = {
|
|
308
|
+
anchor: selection.anchor,
|
|
309
|
+
focus: selection.anchor
|
|
310
|
+
};
|
|
311
|
+
if (selection.anchor.path !== selection.focus.path || selection.anchor.offset !== selection.focus.offset) {
|
|
312
|
+
collapsedSelection.anchor = selection.focus;
|
|
313
|
+
collapsedSelection.focus = selection.focus;
|
|
314
|
+
}
|
|
315
|
+
this.wangEditor.select(collapsedSelection);
|
|
316
|
+
}
|
|
317
|
+
this.wangEditor.insertNode(newParagraph);
|
|
318
|
+
this.wangEditor.move(1);
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
/**
|
|
322
|
+
* 替换选中文本
|
|
323
|
+
* @param text 文本
|
|
324
|
+
*/
|
|
325
|
+
replaceSelectionText(text) {
|
|
326
|
+
if (this.wangEditor) {
|
|
327
|
+
if (this.wangEditor.selection) {
|
|
328
|
+
this.wangEditor.deleteFragment();
|
|
329
|
+
this.wangEditor.insertText(text);
|
|
330
|
+
} else {
|
|
331
|
+
this.wangEditor.insertText(text);
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
/**
|
|
336
|
+
* 恢复选区
|
|
337
|
+
*/
|
|
338
|
+
restoreSelection() {
|
|
339
|
+
if (this.wangEditor) {
|
|
340
|
+
this.wangEditor.restoreSelection();
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
/**
|
|
344
|
+
* 获取内联AI编辑器元素
|
|
345
|
+
*/
|
|
346
|
+
getInLineAiEditorElement() {
|
|
347
|
+
if (!this.wangEditor) {
|
|
348
|
+
throw new RuntimeError("\u7F16\u8F91\u5668\u672A\u521D\u59CB\u5316");
|
|
349
|
+
}
|
|
350
|
+
return this.wangEditor.getEditableContainer();
|
|
351
|
+
}
|
|
352
|
+
/**
|
|
353
|
+
* 获取内联AI编辑器主题
|
|
354
|
+
*/
|
|
355
|
+
getInLineAiEditorTheme() {
|
|
356
|
+
const appTheme = ibiz.util.theme.getTheme();
|
|
357
|
+
if (appTheme.indexOf("dark") !== -1) {
|
|
358
|
+
return "dark";
|
|
359
|
+
}
|
|
360
|
+
return "light";
|
|
361
|
+
}
|
|
362
|
+
/**
|
|
363
|
+
* 获取内联AI参数
|
|
364
|
+
*/
|
|
365
|
+
getInLineAiChatOptions() {
|
|
366
|
+
if (!this.wangEditor) {
|
|
367
|
+
throw new RuntimeError("\u7F16\u8F91\u5668\u672A\u521D\u59CB\u5316");
|
|
368
|
+
}
|
|
369
|
+
const selectionPosition = this.wangEditor.getSelectionPosition();
|
|
370
|
+
if (!selectionPosition || !selectionPosition.left || !selectionPosition.top)
|
|
371
|
+
throw new RuntimeError("\u83B7\u53D6\u9009\u533A\u4F4D\u7F6E\u5931\u8D25");
|
|
372
|
+
const editorBoundingClientRect = this.wangEditor.getEditableContainer().getBoundingClientRect();
|
|
373
|
+
return {
|
|
374
|
+
// 编辑器的左侧距离 + 默认padding
|
|
375
|
+
left: editorBoundingClientRect.x + 10,
|
|
376
|
+
// 编辑器的上方距离+选区距离编辑器上方距离
|
|
377
|
+
top: editorBoundingClientRect.y + Number(selectionPosition.top.replace("px", "")),
|
|
378
|
+
// 编辑器的宽度 - 左右padding
|
|
379
|
+
width: editorBoundingClientRect.width - 20,
|
|
380
|
+
editorElement: this.getInLineAiEditorElement(),
|
|
381
|
+
editorTheme: this.getInLineAiEditorTheme()
|
|
382
|
+
};
|
|
383
|
+
}
|
|
384
|
+
/**
|
|
385
|
+
* 执行内联AIUI操作
|
|
386
|
+
* @param uiActionId
|
|
387
|
+
* @param appId
|
|
388
|
+
*/
|
|
389
|
+
async doInLineAIUIAction(uiActionId, appId) {
|
|
390
|
+
const eventArgs = this.ctrl.getEventArgs();
|
|
391
|
+
eventArgs.params.editor = this;
|
|
392
|
+
if (this.editorParams.srfaiappendcurdata && this.editorParams.srfaiappendcurdata === "true") {
|
|
393
|
+
eventArgs.context.srfaiappendcurdata = true;
|
|
394
|
+
}
|
|
395
|
+
await UIActionUtil.exec(
|
|
396
|
+
uiActionId,
|
|
397
|
+
{
|
|
398
|
+
...eventArgs
|
|
399
|
+
},
|
|
400
|
+
appId
|
|
401
|
+
);
|
|
402
|
+
}
|
|
283
403
|
}
|
|
284
404
|
|
|
285
405
|
export { HtmlEditorController };
|
|
@@ -4,6 +4,7 @@ import './plugin/index.mjs';
|
|
|
4
4
|
import './component/index.mjs';
|
|
5
5
|
export { AIMenu } from './module/ai-module.mjs';
|
|
6
6
|
export { EmojiModule } from './module/emoji-module.mjs';
|
|
7
|
+
export { InLineAIMenu, hoverbarKeysEx } from './module/inline-ai-module.mjs';
|
|
7
8
|
export { EmojiElem } from './element/emoji.mjs';
|
|
8
9
|
export { Plugin } from './plugin/plugin.mjs';
|
|
9
10
|
export { Emoji } from './component/emoji/emoji.mjs';
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
4
|
+
var __publicField = (obj, key, value) => {
|
|
5
|
+
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
6
|
+
return value;
|
|
7
|
+
};
|
|
8
|
+
class InLineAIButton {
|
|
9
|
+
constructor() {
|
|
10
|
+
__publicField(this, "title");
|
|
11
|
+
__publicField(this, "tag");
|
|
12
|
+
__publicField(this, "iconSvg");
|
|
13
|
+
this.title = "AI";
|
|
14
|
+
this.tag = "button";
|
|
15
|
+
this.iconSvg = '<svg t="1763370094787" class="icon" version="1.1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1024 1024" width="14" height="14" xmlns:xlink="http://www.w3.org/1999/xlink"><path 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" fill="black"></path></svg>';
|
|
16
|
+
}
|
|
17
|
+
// 获取选中文本
|
|
18
|
+
getValue(editor) {
|
|
19
|
+
return "";
|
|
20
|
+
}
|
|
21
|
+
// 判断按钮是否激活
|
|
22
|
+
isActive(editor) {
|
|
23
|
+
return false;
|
|
24
|
+
}
|
|
25
|
+
// 判断按钮是否可用
|
|
26
|
+
isDisabled(editor) {
|
|
27
|
+
return editor.getConfig().readOnly;
|
|
28
|
+
}
|
|
29
|
+
// 点击按钮的执行逻辑
|
|
30
|
+
exec(editor, value) {
|
|
31
|
+
if (this.isDisabled(editor))
|
|
32
|
+
return;
|
|
33
|
+
editor.emit("lineAiClick");
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
const InLineAIMenu = {
|
|
37
|
+
key: "inline-ai",
|
|
38
|
+
factory() {
|
|
39
|
+
return new InLineAIButton();
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
const hoverbarKeysEx = {
|
|
43
|
+
link: {
|
|
44
|
+
menuKeys: ["inline-ai", "editLink", "unLink", "viewLink"]
|
|
45
|
+
},
|
|
46
|
+
image: {
|
|
47
|
+
menuKeys: [
|
|
48
|
+
"inline-ai",
|
|
49
|
+
"imageWidth30",
|
|
50
|
+
"imageWidth50",
|
|
51
|
+
"imageWidth100",
|
|
52
|
+
"editImage",
|
|
53
|
+
"viewImageLink",
|
|
54
|
+
"deleteImage"
|
|
55
|
+
]
|
|
56
|
+
},
|
|
57
|
+
pre: {
|
|
58
|
+
menuKeys: ["inline-ai", "enter", "codeBlock", "codeSelectLang"]
|
|
59
|
+
},
|
|
60
|
+
table: {
|
|
61
|
+
menuKeys: [
|
|
62
|
+
"inline-ai",
|
|
63
|
+
"enter",
|
|
64
|
+
"tableHeader",
|
|
65
|
+
"tableFullWidth",
|
|
66
|
+
"insertTableRow",
|
|
67
|
+
"deleteTableRow",
|
|
68
|
+
"insertTableCol",
|
|
69
|
+
"deleteTableCol",
|
|
70
|
+
"deleteTable"
|
|
71
|
+
]
|
|
72
|
+
},
|
|
73
|
+
divider: {
|
|
74
|
+
menuKeys: ["inline-ai", "enter"]
|
|
75
|
+
},
|
|
76
|
+
video: {
|
|
77
|
+
menuKeys: ["inline-ai", "enter", "editVideoSize"]
|
|
78
|
+
},
|
|
79
|
+
text: {
|
|
80
|
+
menuKeys: [
|
|
81
|
+
"inline-ai",
|
|
82
|
+
"headerSelect",
|
|
83
|
+
"insertLink",
|
|
84
|
+
"bulletedList",
|
|
85
|
+
"|",
|
|
86
|
+
"bold",
|
|
87
|
+
"through",
|
|
88
|
+
"color",
|
|
89
|
+
"bgColor",
|
|
90
|
+
"clearStyle"
|
|
91
|
+
]
|
|
92
|
+
}
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
export { InLineAIMenu, hoverbarKeysEx };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
.ibiz-html{--ibiz-html-height:300px;display:inline-block;width:100%;height:100%}.ibiz-html .ibiz-html-content{display:flex;flex-direction:column;height:100%;background-color:var(--ibiz-color-bg-0)}.ibiz-html .ibiz-html-editor{height:var(--ibiz-html-height)!important;padding:0;overflow-y:scroll;border:1px solid var(--ibiz-color-border)}.ibiz-html .ibiz-html-editor.is-readonly{height:auto!important}.ibiz-html .ibiz-html-editor table{width:100%!important;border-collapse:collapse}.ibiz-html .ibiz-html-editor table th{height:var(--ibiz-height-control-large);min-height:var(--ibiz-height-control-large);padding:var(--ibiz-spacing-tight);border:1px solid var(--ibiz-color-border)}.ibiz-html .ibiz-html-editor table td{height:var(--ibiz-height-control-large);min-height:var(--ibiz-height-control-large);padding:var(--ibiz-spacing-tight);empty-cells:show;border:1px solid var(--ibiz-color-border)}.ibiz-html{--w-e-textarea-bg-color:var(--ibiz-color-bg-1);--w-e-textarea-color:var(--ibiz-color-text-2);--w-e-textarea-border-color:var(--ibiz-color-border);--w-e-textarea-slight-border-color:var(--ibiz-color-border);--w-e-textarea-slight-color:var(--ibiz-color-text-3);--w-e-textarea-slight-bg-color:var(--ibiz-color-bg-1);--w-e-textarea-selected-border-color:var(--ibiz-color-border);--w-e-textarea-handler-bg-color:var(--ibiz-color-primary);--w-e-toolbar-color:var(--ibiz-color-text-0);--w-e-toolbar-bg-color:var(--ibiz-color-bg-1);--w-e-toolbar-active-color:var(--ibiz-color-text-0);--w-e-toolbar-active-bg-color:var(--ibiz-color-bg-1);--w-e-toolbar-disabled-color:var(--ibiz-color-disabled-text);--w-e-toolbar-border-color:var(--ibiz-color-border);--w-e-modal-button-bg-color:var(--ibiz-color-bg-1);--w-e-modal-button-border-color:var(--ibiz-color-border)}.ibiz-html .w-e-menu-tooltip-v5::before{color:var(--ibiz-color-text-0);background-color:var(--w-e-toolbar-bg-color)}.ibiz-html .w-e-full-screen-container{z-index:9999}.ibiz-html .w-e-scroll>div{background-color:var(--ibiz-color-bg-1)}.ibiz-html .table-container table{width:100%}.ibiz-html-editor-readonly .ibiz-html-toolbar{display:none}.ibiz-html-editor-readonly .ibiz-html-editor{border:none}.ibiz-html-footer{display:flex;align-items:center;justify-content:end;margin-top:var(--ibiz-spacing-base-tight);margin-right:var(--ibiz-spacing-tight)}.ibiz-html-footer>*+*{margin-left:var(--ibiz-spacing-base)}.ibiz-html-footer__cancel{height:var(--ibiz-height-control-default);line-height:var(--ibiz-height-control-default);color:var(--ibiz-color-text-1);cursor:pointer;opacity:.7}.ibiz-html-footer__cancel:hover{color:var(--ibiz-color-primary);opacity:1}.ibiz-html-footer__save{height:var(--ibiz-height-control-default);padding:0 var(--ibiz-spacing-base);line-height:var(--ibiz-height-control-default);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-html-custom-toolbar{display:flex;align-items:center;justify-content:end;width:100%;height:var(--ibiz-height-control-default);padding-right:var(--ibiz-spacing-base);font-size:var(--ibiz-font-size-header-6)}.ibiz-html-custom-toolbar>*+*{margin-left:var(--ibiz-spacing-base-loose)}.ibiz-html-custom-toolbar i{cursor:pointer}.ibiz-html-custom-toolbar i:hover{color:var(--ibiz-color-primary)}.ibiz-html-message{width:500px;max-width:unset}.ibiz-html-message__message-content--message-tip{color:var(--ibiz-color-text-3)}.ibiz-html-message__message-cancel{color:var(--ibiz-color-text-1);background-color:transparent}.ibiz-html-message__message-cancel:hover{color:var(--ibiz-color-primary);background-color:transparent}.ibiz-html-message__message-comfire{background-color:var(--ibiz-color-danger)!important}.ibiz-html-message__message-comfire:hover{box-shadow:0 2px 5px 1px var(--ibiz-color-danger)}.ibiz-html-dialog-full-screen{height:80%}.ibiz-html-dialog-full-screen .ibiz-html{padding:0
|
|
1
|
+
.ibiz-html{--ibiz-html-height:300px;display:inline-block;width:100%;height:100%}.ibiz-html .ibiz-html-content{display:flex;flex-direction:column;height:100%;background-color:var(--ibiz-color-bg-0)}.ibiz-html .ibiz-html-editor{height:var(--ibiz-html-height)!important;padding:0;overflow-y:scroll;border:1px solid var(--ibiz-color-border)}.ibiz-html .ibiz-html-editor.is-readonly{height:auto!important}.ibiz-html .ibiz-html-editor table{width:100%!important;border-collapse:collapse}.ibiz-html .ibiz-html-editor table th{height:var(--ibiz-height-control-large);min-height:var(--ibiz-height-control-large);padding:var(--ibiz-spacing-tight);border:1px solid var(--ibiz-color-border)}.ibiz-html .ibiz-html-editor table td{height:var(--ibiz-height-control-large);min-height:var(--ibiz-height-control-large);padding:var(--ibiz-spacing-tight);empty-cells:show;border:1px solid var(--ibiz-color-border)}.ibiz-html{--w-e-textarea-bg-color:var(--ibiz-color-bg-1);--w-e-textarea-color:var(--ibiz-color-text-2);--w-e-textarea-border-color:var(--ibiz-color-border);--w-e-textarea-slight-border-color:var(--ibiz-color-border);--w-e-textarea-slight-color:var(--ibiz-color-text-3);--w-e-textarea-slight-bg-color:var(--ibiz-color-bg-1);--w-e-textarea-selected-border-color:var(--ibiz-color-border);--w-e-textarea-handler-bg-color:var(--ibiz-color-primary);--w-e-toolbar-color:var(--ibiz-color-text-0);--w-e-toolbar-bg-color:var(--ibiz-color-bg-1);--w-e-toolbar-active-color:var(--ibiz-color-text-0);--w-e-toolbar-active-bg-color:var(--ibiz-color-bg-1);--w-e-toolbar-disabled-color:var(--ibiz-color-disabled-text);--w-e-toolbar-border-color:var(--ibiz-color-border);--w-e-modal-button-bg-color:var(--ibiz-color-bg-1);--w-e-modal-button-border-color:var(--ibiz-color-border)}.ibiz-html .w-e-menu-tooltip-v5::before{color:var(--ibiz-color-text-0);background-color:var(--w-e-toolbar-bg-color)}.ibiz-html .w-e-full-screen-container{z-index:9999}.ibiz-html .w-e-scroll>div{background-color:var(--ibiz-color-bg-1)}.ibiz-html .table-container table{width:100%}.ibiz-html.is-enable-edit .w-e-bar-item>button{color:var(--w-e-toolbar-color);cursor:pointer}.ibiz-html.is-enable-edit .w-e-bar-item>button svg{fill:var(--w-e-toolbar-color)}.ibiz-html-editor-readonly .ibiz-html-toolbar{display:none}.ibiz-html-editor-readonly .ibiz-html-editor{border:none}.ibiz-html-toolbar .w-e-toolbar{background-color:var(--ibiz-color-bg-0);border:1px solid var(--ibiz-color-border);border-bottom:none;box-shadow:none}.ibiz-html-toolbar .w-e-toolbar .w-e-bar-item>button:hover{background-color:var(--ibiz-color-bg-0)}.ibiz-html-footer{display:flex;align-items:center;justify-content:end;margin-top:var(--ibiz-spacing-base-tight);margin-right:var(--ibiz-spacing-tight)}.ibiz-html-footer>*+*{margin-left:var(--ibiz-spacing-base)}.ibiz-html-footer__cancel{height:var(--ibiz-height-control-default);line-height:var(--ibiz-height-control-default);color:var(--ibiz-color-text-1);cursor:pointer;opacity:.7}.ibiz-html-footer__cancel:hover{color:var(--ibiz-color-primary);opacity:1}.ibiz-html-footer__save{height:var(--ibiz-height-control-default);padding:0 var(--ibiz-spacing-base);line-height:var(--ibiz-height-control-default);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-html-custom-toolbar{display:flex;align-items:center;justify-content:end;width:100%;height:var(--ibiz-height-control-default);padding-right:var(--ibiz-spacing-base);font-size:var(--ibiz-font-size-header-6)}.ibiz-html-custom-toolbar>*+*{margin-left:var(--ibiz-spacing-base-loose)}.ibiz-html-custom-toolbar i{cursor:pointer}.ibiz-html-custom-toolbar i:hover{color:var(--ibiz-color-primary)}.ibiz-html-message{width:500px;max-width:unset}.ibiz-html-message__message-content--message-tip{color:var(--ibiz-color-text-3)}.ibiz-html-message__message-cancel{color:var(--ibiz-color-text-1);background-color:transparent}.ibiz-html-message__message-cancel:hover{color:var(--ibiz-color-primary);background-color:transparent}.ibiz-html-message__message-comfire{background-color:var(--ibiz-color-danger)!important}.ibiz-html-message__message-comfire:hover{box-shadow:0 2px 5px 1px var(--ibiz-color-danger)}.ibiz-html-dialog-full-screen{height:80%}.ibiz-html-dialog-full-screen .el-dialog__header{display:none}.ibiz-html-dialog-full-screen .el-dialog__body{height:100%;padding-top:0}.ibiz-html-dialog-full-screen.is-editing .el-dialog__body{padding-bottom:0}.ibiz-html-dialog-full-screen .ibiz-html{padding:0;--w-e-toolbar-bg-color:var(--ibiz-color-bg-0)}.ibiz-html-dialog-full-screen .ibiz-html-custom-toolbar{height:56px;padding-right:0}.ibiz-html-dialog-full-screen .ibiz-html-content{height:calc(100% - 56px)}.ibiz-html-dialog-full-screen .ibiz-html-content .ibiz-html-editor{height:100%!important}.ibiz-html-dialog-full-screen .ibiz-html-content.is-editing{height:calc(100% - 128px)}.ibiz-html-footer-dialog{height:68px;margin-top:0;margin-right:0}emoji-elem{margin:0 1px!important}
|
|
@@ -7,7 +7,9 @@ import { IBizContext, StringUtil, awaitTimeout } from '@ibiz-template/core';
|
|
|
7
7
|
import { UIActionUtil, SysUIActionTag } from '@ibiz-template/runtime';
|
|
8
8
|
import { ElMessageBox } from 'element-plus';
|
|
9
9
|
import '../../../util/index.mjs';
|
|
10
|
+
import './module/index.mjs';
|
|
10
11
|
import './wang-editor.css';
|
|
12
|
+
import { hoverbarKeysEx } from './module/inline-ai-module.mjs';
|
|
11
13
|
import { calcAiToolbarItemsByAc } from '../../../util/ai-util/ai-util.mjs';
|
|
12
14
|
|
|
13
15
|
"use strict";
|
|
@@ -37,6 +39,7 @@ const IBizHtml = /* @__PURE__ */ defineComponent({
|
|
|
37
39
|
const readonlyState = ref(false);
|
|
38
40
|
const enableFullScreen = ref(false);
|
|
39
41
|
const isFullScreen = ref(false);
|
|
42
|
+
let autoClose;
|
|
40
43
|
const editorModel = c.model;
|
|
41
44
|
if (editorModel.editorParams) {
|
|
42
45
|
if (editorModel.editorParams.enableEdit) {
|
|
@@ -55,6 +58,13 @@ const IBizHtml = /* @__PURE__ */ defineComponent({
|
|
|
55
58
|
if (editorModel.editorParams.enablefullscreen) {
|
|
56
59
|
enableFullScreen.value = c.toBoolean(editorModel.editorParams.enablefullscreen);
|
|
57
60
|
}
|
|
61
|
+
if (editorModel.editorParams.autoclose) {
|
|
62
|
+
try {
|
|
63
|
+
autoClose = JSON.parse(editorModel.editorParams.autoclose);
|
|
64
|
+
} catch (error) {
|
|
65
|
+
ibiz.log.error(error);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
58
68
|
}
|
|
59
69
|
if (props.readonly) {
|
|
60
70
|
hasEnableEdit.value = false;
|
|
@@ -180,7 +190,8 @@ const IBizHtml = /* @__PURE__ */ defineComponent({
|
|
|
180
190
|
parseLinkUrl: customParseLinkUrl
|
|
181
191
|
// 也支持 async 函数
|
|
182
192
|
}
|
|
183
|
-
}
|
|
193
|
+
},
|
|
194
|
+
hoverbarKeys: hoverbarKeysEx
|
|
184
195
|
};
|
|
185
196
|
onBeforeUnmount(() => {
|
|
186
197
|
const editor = editorRef.value;
|
|
@@ -227,6 +238,14 @@ const IBizHtml = /* @__PURE__ */ defineComponent({
|
|
|
227
238
|
otherToolbarItems,
|
|
228
239
|
// 编辑器参数srfaiappendcurdata,是否传入对象参数,用于历史查询传参
|
|
229
240
|
appendCurData: c.editorParams.srfaiappendcurdata === "true" ? props.data : void 0,
|
|
241
|
+
// 自动提问
|
|
242
|
+
autoQuestion: c.editorParams.autoquestion !== "false",
|
|
243
|
+
// 自动填充
|
|
244
|
+
autoFill: c.editorParams.autofill === "true",
|
|
245
|
+
// 窗口的打开模式
|
|
246
|
+
openMode: c.editorParams.openmode,
|
|
247
|
+
// 窗口的自动关闭模式
|
|
248
|
+
autoClose,
|
|
230
249
|
// 编辑器参数srfaiappendcurcontent,传入编辑内容作为用户消息,获取历史数据后附加
|
|
231
250
|
appendCurContent: c.editorParams.srfaiappendcurcontent ? StringUtil.fill(c.editorParams.srfaiappendcurcontent, c.context, c.params, props.data) : void 0,
|
|
232
251
|
question: async (aiChat, ctx, param, other, arr, sessionid) => {
|
|
@@ -400,6 +419,24 @@ const IBizHtml = /* @__PURE__ */ defineComponent({
|
|
|
400
419
|
editor.on("aiClick", () => {
|
|
401
420
|
onClickAI();
|
|
402
421
|
});
|
|
422
|
+
editor.on("lineAiClick", () => {
|
|
423
|
+
const selectionPosition = editor.getSelectionPosition();
|
|
424
|
+
if (!selectionPosition || !selectionPosition.left || !selectionPosition.top)
|
|
425
|
+
return;
|
|
426
|
+
const items = ibiz.inLineAIUtil.calcContextMenus(c.deACMode, (tag) => {
|
|
427
|
+
c.doInLineAIUIAction(tag, c.model.appId);
|
|
428
|
+
});
|
|
429
|
+
if (items.length === 0)
|
|
430
|
+
return;
|
|
431
|
+
const editorBoundingClientRect = editor.getEditableContainer().getBoundingClientRect();
|
|
432
|
+
ibiz.inLineAIUtil.showContextMenus(
|
|
433
|
+
// 编辑器的左侧距离+选区距离编辑器左侧距离
|
|
434
|
+
editorBoundingClientRect.x + Number(selectionPosition.left.replace("px", "")),
|
|
435
|
+
// 编辑器的上方距离+选区距离编辑器上方距离+悬浮工具栏高度
|
|
436
|
+
editorBoundingClientRect.y + Number(selectionPosition.top.replace("px", "")) + 42,
|
|
437
|
+
items
|
|
438
|
+
);
|
|
439
|
+
});
|
|
403
440
|
};
|
|
404
441
|
const handleChange = (editor) => {
|
|
405
442
|
const html = editor.getHtml();
|
|
@@ -615,7 +652,7 @@ const IBizHtml = /* @__PURE__ */ defineComponent({
|
|
|
615
652
|
};
|
|
616
653
|
const renderEditorContent = () => {
|
|
617
654
|
return createVNode("div", {
|
|
618
|
-
"class": ns.b("content"),
|
|
655
|
+
"class": [ns.b("content"), ns.is("editing", !readonlyState.value)],
|
|
619
656
|
"ref": "htmlContent",
|
|
620
657
|
"style": cssVars.value
|
|
621
658
|
}, [createVNode(Toolbar, {
|
|
@@ -685,13 +722,13 @@ const IBizHtml = /* @__PURE__ */ defineComponent({
|
|
|
685
722
|
return !this.isFullScreen ? createVNode("div", {
|
|
686
723
|
"class": [this.ns.b(), {
|
|
687
724
|
[this.ns.b("editor-readonly")]: this.readonlyState
|
|
688
|
-
}, this.ns.is("show-ai", true)]
|
|
725
|
+
}, this.ns.is("show-ai", true), this.ns.is("enable-edit", !this.readonly && !this.disabled)]
|
|
689
726
|
}, [this.renderHeaserToolbar(), this.renderEditorContent(), this.hasEnableEdit && !this.readonlyState ? this.renderFooter() : null]) : createVNode(resolveComponent("el-dialog"), {
|
|
690
727
|
"modelValue": this.isFullScreen,
|
|
691
728
|
"onUpdate:modelValue": ($event) => this.isFullScreen = $event,
|
|
692
729
|
"width": "80%",
|
|
693
730
|
"top": "10vh",
|
|
694
|
-
"class": this.ns.b("dialog-full-screen"),
|
|
731
|
+
"class": [this.ns.b("dialog-full-screen"), this.ns.is("editing", !this.readonlyState)],
|
|
695
732
|
"onClose": () => this.changeFullScreenState()
|
|
696
733
|
}, {
|
|
697
734
|
default: () => [createVNode("div", {
|