@kg-ui/kg-ui-plus 0.1.51 → 0.1.52
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/es/KgCopilot/CopiCanvas/document-viewer/wps-file-viewer/lib/web-office-sdk-solution-v2.0.7.es.mjs +854 -0
- package/dist/es/KgCopilot/CopiCanvas/document-viewer/wps-file-viewer/testWPS.vue.mjs +7 -0
- package/dist/es/KgCopilot/CopiCanvas/document-viewer/wps-file-viewer/testWPS.vue2.mjs +121 -0
- package/dist/es/KgCopilot/CopiCanvas/document-viewer/wps-file-viewer/testWPS.vue3.mjs +4 -0
- package/dist/es/KgCopilot/CopiCanvas/document-viewer/wps-file-viewer/wps-ai-integration2/AiBar.vue.mjs +7 -0
- package/dist/es/KgCopilot/CopiCanvas/document-viewer/wps-file-viewer/wps-ai-integration2/AiBar.vue2.mjs +125 -0
- package/dist/es/KgCopilot/CopiCanvas/document-viewer/wps-file-viewer/wps-ai-integration2/AiBar.vue3.mjs +4 -0
- package/dist/es/KgCopilot/CopiCanvas/document-viewer/wps-file-viewer/wps-ai-integration2/AiInput.vue.mjs +7 -0
- package/dist/es/KgCopilot/CopiCanvas/document-viewer/wps-file-viewer/wps-ai-integration2/AiInput.vue2.mjs +124 -0
- package/dist/es/KgCopilot/CopiCanvas/document-viewer/wps-file-viewer/wps-ai-integration2/AiInput.vue3.mjs +4 -0
- package/dist/es/KgCopilot/CopiCanvas/document-viewer/wps-file-viewer/wps-ai-integration2/index.vue.mjs +71 -0
- package/dist/es/KgCopilot/CopiCanvas/document-viewer/wps-file-viewer/wps-ai-integration2/index.vue2.mjs +4 -0
- package/dist/es/KgCopilot/CopiCanvas/index.vue.mjs +1 -1
- package/dist/es/KgCopilot/CopiCanvas/index.vue2.mjs +3 -4
- package/dist/es/KgCopilot/CopiCanvas/index.vue3.mjs +2 -2
- package/dist/es/api/copilot.mjs +0 -8
- package/dist/es/node_modules/.pnpm/@iconify-icons_ep@1.2.7/node_modules/@iconify-icons/ep/refresh.mjs +8 -0
- package/dist/es/node_modules/.pnpm/@vueuse_core@9.13.0_vue@3.2.45/node_modules/@vueuse/core/index.mjs +105 -2
- package/dist/es/node_modules/.pnpm/@vueuse_shared@9.13.0_vue@3.2.45/node_modules/@vueuse/shared/index.mjs +13 -2
- package/dist/es/store/modules/copilot.mjs +38 -1
- package/dist/es/style.css +1 -1
- package/package.json +124 -116
- package/dist/es/KgCopilot/CopiCanvas/FilePreview.vue.mjs +0 -7
- package/dist/es/KgCopilot/CopiCanvas/FilePreview.vue2.mjs +0 -295
- package/dist/es/KgCopilot/CopiCanvas/FilePreview.vue3.mjs +0 -4
- package/dist/es/KgCopilot/CopiCanvas/FileSkeletion.vue.mjs +0 -96
- package/dist/es/KgCopilot/CopiCanvas/FileSkeletion.vue2.mjs +0 -4
- package/dist/es/KgCopilot/CopiCanvas/InitWrap.vue.mjs +0 -7
- package/dist/es/KgCopilot/CopiCanvas/InitWrap.vue2.mjs +0 -41
- package/dist/es/KgCopilot/CopiCanvas/InitWrap.vue3.mjs +0 -4
- package/dist/es/_virtual/_commonjs-dynamic-modules.mjs +0 -6
- package/dist/es/_virtual/jszip.min.mjs +0 -13
- package/dist/es/assets/empty.png.mjs +0 -4
- package/dist/es/node_modules/.pnpm/@iconify-icons_ep@1.2.7/node_modules/@iconify-icons/ep/folder-opened.mjs +0 -8
- package/dist/es/node_modules/.pnpm/@iconify-icons_ri@1.2.3/node_modules/@iconify-icons/ri/file-damage-line.mjs +0 -8
- package/dist/es/node_modules/.pnpm/docx-preview@0.3.3/node_modules/docx-preview/dist/docx-preview.mjs +0 -3877
- package/dist/es/node_modules/.pnpm/jszip@3.10.1/node_modules/jszip/dist/jszip.min.mjs +0 -2649
@@ -0,0 +1,7 @@
|
|
1
|
+
import _sfc_main from "./testWPS.vue2.mjs";
|
2
|
+
import "./testWPS.vue3.mjs";
|
3
|
+
import _export_sfc from "../../../../_virtual/_plugin-vue_export-helper.mjs";
|
4
|
+
const testWPS = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-7408280b"]]);
|
5
|
+
export {
|
6
|
+
testWPS as default
|
7
|
+
};
|
@@ -0,0 +1,121 @@
|
|
1
|
+
import { defineComponent, ref, onMounted, openBlock, createElementBlock, Fragment, createVNode, pushScopeId, popScopeId, createElementVNode } from "vue";
|
2
|
+
import k from "./lib/web-office-sdk-solution-v2.0.7.es.mjs";
|
3
|
+
import _sfc_main$1 from "./wps-ai-integration2/index.vue.mjs";
|
4
|
+
import { wpsAiOpt } from "../../../../store/modules/copilot.mjs";
|
5
|
+
import { useThrottleFn } from "../../../../node_modules/.pnpm/@vueuse_shared@9.13.0_vue@3.2.45/node_modules/@vueuse/shared/index.mjs";
|
6
|
+
const _withScopeId = (n) => (pushScopeId("data-v-7408280b"), n = n(), popScopeId(), n);
|
7
|
+
const _hoisted_1 = /* @__PURE__ */ _withScopeId(() => /* @__PURE__ */ createElementVNode("div", {
|
8
|
+
id: "office-container",
|
9
|
+
class: "preview-box"
|
10
|
+
}, null, -1));
|
11
|
+
const _sfc_main = /* @__PURE__ */ defineComponent({
|
12
|
+
__name: "testWPS",
|
13
|
+
setup(__props) {
|
14
|
+
let app;
|
15
|
+
let jssdk;
|
16
|
+
const appId = ref("SX20250506WZKTKR");
|
17
|
+
const fileId = ref(123);
|
18
|
+
const selContextIndex = ref([0, 0]);
|
19
|
+
const selContext = ref("");
|
20
|
+
const selContextPreStr = ref("");
|
21
|
+
const selContextNextStr = ref("");
|
22
|
+
const allWord = ref("");
|
23
|
+
const wpsAiBarPos = ref({ x: 0, y: 0 });
|
24
|
+
const wpsAiInputPos = ref({ x: 0, y: 0, w: 0, h: 0 });
|
25
|
+
onMounted(() => {
|
26
|
+
jssdk = k.init({
|
27
|
+
officeType: k.OfficeType.Writer,
|
28
|
+
appId: appId.value,
|
29
|
+
fileId: fileId.value,
|
30
|
+
mount: document.getElementById("office-container")
|
31
|
+
// 挂载点 DOM
|
32
|
+
});
|
33
|
+
async function handleSelectChange(e) {
|
34
|
+
const { begin, end } = e;
|
35
|
+
const range = await app.ActiveDocument.Range(begin, end);
|
36
|
+
selContextIndex.value = [begin, end];
|
37
|
+
const text = await range.Text;
|
38
|
+
selContext.value = text;
|
39
|
+
const preRange = await app.ActiveDocument.Range(begin - 30 > 0 ? begin - 30 : 0, begin);
|
40
|
+
selContextPreStr.value = await preRange.Text;
|
41
|
+
const nextRange = await app.ActiveDocument.Range(end, end + 30);
|
42
|
+
selContextNextStr.value = await nextRange.Text;
|
43
|
+
const docRange = await app.ActiveDocument.GetDocumentRange();
|
44
|
+
allWord.value = await docRange.Text;
|
45
|
+
let offsetX = 0;
|
46
|
+
let offsetY = 0;
|
47
|
+
let rectH = 0;
|
48
|
+
let rectW = 0;
|
49
|
+
const officeEl = document.getElementById("office-container");
|
50
|
+
if (officeEl) {
|
51
|
+
const rect = officeEl.getBoundingClientRect();
|
52
|
+
offsetX = rect.left + window.scrollX;
|
53
|
+
offsetY = rect.top + window.scrollY;
|
54
|
+
rectH = rect.height;
|
55
|
+
rectW = rect.width;
|
56
|
+
}
|
57
|
+
let startPos = await getSelectionPos(app, begin);
|
58
|
+
let endPos = await getSelectionPos(app, end);
|
59
|
+
let x = startPos.x;
|
60
|
+
let y = startPos.y;
|
61
|
+
if (startPos.y === endPos.y) {
|
62
|
+
y = endPos.y + 95;
|
63
|
+
}
|
64
|
+
wpsAiBarPos.value = { x: x + offsetX, y: y + offsetY };
|
65
|
+
let wpsAiInputPosY = endPos.y + 70;
|
66
|
+
const h = 220;
|
67
|
+
if (endPos.y + h > rectH) {
|
68
|
+
wpsAiInputPosY = startPos.y - h;
|
69
|
+
}
|
70
|
+
wpsAiInputPos.value = { x: offsetX + 4, y: wpsAiInputPosY, w: rectW - 14, h };
|
71
|
+
}
|
72
|
+
async function getSelectionPos(app2, index) {
|
73
|
+
let rangeIdx = await index;
|
74
|
+
let relativeBodyPos = await app2.ActiveDocument.ActiveWindow.Selection.GetRelativePosByGcp(rangeIdx);
|
75
|
+
await app2.ActiveDocument.ActiveWindow.Selection.GetPosByGcp(rangeIdx);
|
76
|
+
let pos = relativeBodyPos;
|
77
|
+
return {
|
78
|
+
x: pos.x ? pos.x : pos.X,
|
79
|
+
y: pos.y ? pos.y : pos.Y
|
80
|
+
};
|
81
|
+
}
|
82
|
+
const handleSelectChangeFn = useThrottleFn((e) => {
|
83
|
+
handleSelectChange(e);
|
84
|
+
}, 200);
|
85
|
+
jssdk.ready().then(async () => {
|
86
|
+
app = jssdk == null ? void 0 : jssdk.Application;
|
87
|
+
app.Sub.WindowSelectionChange = handleSelectChangeFn;
|
88
|
+
});
|
89
|
+
});
|
90
|
+
async function insertText(app2, oldText, newText) {
|
91
|
+
const findResult = await app2.ActiveDocument.Find.Execute(oldText, false);
|
92
|
+
const { pos } = findResult[0];
|
93
|
+
const range = await app2.ActiveDocument.Range.SetRange(pos + oldText.length, pos + oldText.length);
|
94
|
+
range.Text = newText;
|
95
|
+
}
|
96
|
+
const handleAiAction = (payload) => {
|
97
|
+
switch (payload.type) {
|
98
|
+
case wpsAiOpt.insert:
|
99
|
+
insertText(app, selContext.value, payload.text);
|
100
|
+
break;
|
101
|
+
}
|
102
|
+
};
|
103
|
+
return (_ctx, _cache) => {
|
104
|
+
return openBlock(), createElementBlock(Fragment, null, [
|
105
|
+
_hoisted_1,
|
106
|
+
createVNode(_sfc_main$1, {
|
107
|
+
"selected-text": selContext.value,
|
108
|
+
allWord: allWord.value,
|
109
|
+
wpsAiBarPos: wpsAiBarPos.value,
|
110
|
+
wpsAiInputPos: wpsAiInputPos.value,
|
111
|
+
onInsert: handleAiAction,
|
112
|
+
onRewrite: handleAiAction,
|
113
|
+
onCancelOpt: handleAiAction
|
114
|
+
}, null, 8, ["selected-text", "allWord", "wpsAiBarPos", "wpsAiInputPos"])
|
115
|
+
], 64);
|
116
|
+
};
|
117
|
+
}
|
118
|
+
});
|
119
|
+
export {
|
120
|
+
_sfc_main as default
|
121
|
+
};
|
@@ -0,0 +1,7 @@
|
|
1
|
+
import _sfc_main from "./AiBar.vue2.mjs";
|
2
|
+
import "./AiBar.vue3.mjs";
|
3
|
+
import _export_sfc from "../../../../../_virtual/_plugin-vue_export-helper.mjs";
|
4
|
+
const AiBar = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-be20e070"]]);
|
5
|
+
export {
|
6
|
+
AiBar as default
|
7
|
+
};
|
@@ -0,0 +1,125 @@
|
|
1
|
+
import { defineComponent, ref, computed, onMounted, openBlock, createElementBlock, normalizeStyle, unref, createElementVNode, createTextVNode, createCommentVNode, createVNode, Transition, withCtx, withDirectives, vShow, pushScopeId, popScopeId } from "vue";
|
2
|
+
import { onClickOutside } from "../../../../../node_modules/.pnpm/@vueuse_core@9.13.0_vue@3.2.45/node_modules/@vueuse/core/index.mjs";
|
3
|
+
const _withScopeId = (n) => (pushScopeId("data-v-be20e070"), n = n(), popScopeId(), n);
|
4
|
+
const _hoisted_1 = { class: "ai-bar__buttons flex items-center" };
|
5
|
+
const _hoisted_2 = /* @__PURE__ */ _withScopeId(() => /* @__PURE__ */ createElementVNode("div", { class: "logo mr-2" }, "➤", -1));
|
6
|
+
const _hoisted_3 = { class: "flex gap-2" };
|
7
|
+
const _hoisted_4 = { class: "dropdown-wrapper" };
|
8
|
+
const _hoisted_5 = /* @__PURE__ */ _withScopeId(() => /* @__PURE__ */ createElementVNode("span", { class: "arrow" }, [
|
9
|
+
/* @__PURE__ */ createElementVNode("svg", {
|
10
|
+
width: "12",
|
11
|
+
height: "12",
|
12
|
+
viewBox: "0 0 16 16",
|
13
|
+
fill: "none",
|
14
|
+
"stroke-width": "1.5"
|
15
|
+
}, [
|
16
|
+
/* @__PURE__ */ createElementVNode("g", {
|
17
|
+
id: "group-0",
|
18
|
+
stroke: "#757575",
|
19
|
+
fill: "#757575"
|
20
|
+
}, [
|
21
|
+
/* @__PURE__ */ createElementVNode("path", {
|
22
|
+
d: "M4.25 6.49994L7.99327 9.99357C7.99711 9.99716 8.00307 9.99716 8.00691 9.99357L11.75 6.49994",
|
23
|
+
"stroke-linecap": "round",
|
24
|
+
"stroke-linejoin": "miter",
|
25
|
+
fill: "none",
|
26
|
+
"vector-effect": "non-scaling-stroke"
|
27
|
+
})
|
28
|
+
])
|
29
|
+
])
|
30
|
+
], -1));
|
31
|
+
const _hoisted_6 = {
|
32
|
+
key: 0,
|
33
|
+
class: "dropdown"
|
34
|
+
};
|
35
|
+
const _hoisted_7 = { class: "ai-bar__input flex-col" };
|
36
|
+
const _hoisted_8 = ["data-placeholder"];
|
37
|
+
const _hoisted_9 = /* @__PURE__ */ _withScopeId(() => /* @__PURE__ */ createElementVNode("div", { class: "send flex justify-end" }, "➤", -1));
|
38
|
+
const _sfc_main = /* @__PURE__ */ defineComponent({
|
39
|
+
__name: "AiBar",
|
40
|
+
props: {
|
41
|
+
position: null
|
42
|
+
},
|
43
|
+
emits: ["rewrite", "polish", "continue", "polish-mode"],
|
44
|
+
setup(__props, { emit }) {
|
45
|
+
const props = __props;
|
46
|
+
const containerRef = ref();
|
47
|
+
const showDropdown = ref(false);
|
48
|
+
const positionStyle = computed(() => ({
|
49
|
+
left: `${props.position.x}px`,
|
50
|
+
top: `${props.position.y - 90}px`
|
51
|
+
}));
|
52
|
+
onClickOutside(containerRef, () => {
|
53
|
+
showDropdown.value = false;
|
54
|
+
});
|
55
|
+
const showInput = ref(false);
|
56
|
+
onMounted(() => {
|
57
|
+
if (!containerRef.value)
|
58
|
+
return;
|
59
|
+
const { width } = containerRef.value.getBoundingClientRect();
|
60
|
+
containerRef.value.style.transform = `translateX(-${width / 2}px)`;
|
61
|
+
});
|
62
|
+
function toggleInput() {
|
63
|
+
showInput.value = !showInput.value;
|
64
|
+
}
|
65
|
+
return (_ctx, _cache) => {
|
66
|
+
return openBlock(), createElementBlock("div", {
|
67
|
+
ref_key: "containerRef",
|
68
|
+
ref: containerRef,
|
69
|
+
class: "ai-bar",
|
70
|
+
style: normalizeStyle(unref(positionStyle))
|
71
|
+
}, [
|
72
|
+
createElementVNode("div", _hoisted_1, [
|
73
|
+
_hoisted_2,
|
74
|
+
createElementVNode("div", _hoisted_3, [
|
75
|
+
createElementVNode("button", {
|
76
|
+
onClick: _cache[0] || (_cache[0] = ($event) => emit("continue"))
|
77
|
+
}, "续写"),
|
78
|
+
createElementVNode("div", _hoisted_4, [
|
79
|
+
createElementVNode("button", {
|
80
|
+
class: "flex items-center",
|
81
|
+
onClick: _cache[1] || (_cache[1] = ($event) => showDropdown.value = !showDropdown.value)
|
82
|
+
}, [
|
83
|
+
createTextVNode(" 润色 "),
|
84
|
+
_hoisted_5
|
85
|
+
]),
|
86
|
+
showDropdown.value ? (openBlock(), createElementBlock("div", _hoisted_6, [
|
87
|
+
createElementVNode("button", {
|
88
|
+
onClick: _cache[2] || (_cache[2] = ($event) => {
|
89
|
+
emit("polish-mode", "official");
|
90
|
+
showDropdown.value = false;
|
91
|
+
})
|
92
|
+
}, "党政风"),
|
93
|
+
createElementVNode("button", {
|
94
|
+
onClick: _cache[3] || (_cache[3] = ($event) => {
|
95
|
+
emit("polish-mode", "casual");
|
96
|
+
showDropdown.value = false;
|
97
|
+
})
|
98
|
+
}, "口语化")
|
99
|
+
])) : createCommentVNode("", true)
|
100
|
+
]),
|
101
|
+
createElementVNode("button", { onClick: toggleInput }, "自定义")
|
102
|
+
])
|
103
|
+
]),
|
104
|
+
createVNode(Transition, { name: "expand" }, {
|
105
|
+
default: withCtx(() => [
|
106
|
+
withDirectives(createElementVNode("div", _hoisted_7, [
|
107
|
+
createElementVNode("div", {
|
108
|
+
class: "editable flex-1 overflow-y-auto overflow-x-hidden p-2 rounded border border-gray-300 text-sm leading-relaxed",
|
109
|
+
contenteditable: "true",
|
110
|
+
"data-placeholder": "请输入要求..."
|
111
|
+
}, null, 8, _hoisted_8),
|
112
|
+
_hoisted_9
|
113
|
+
], 512), [
|
114
|
+
[vShow, showInput.value]
|
115
|
+
])
|
116
|
+
]),
|
117
|
+
_: 1
|
118
|
+
})
|
119
|
+
], 4);
|
120
|
+
};
|
121
|
+
}
|
122
|
+
});
|
123
|
+
export {
|
124
|
+
_sfc_main as default
|
125
|
+
};
|
@@ -0,0 +1,7 @@
|
|
1
|
+
import _sfc_main from "./AiInput.vue2.mjs";
|
2
|
+
import "./AiInput.vue3.mjs";
|
3
|
+
import _export_sfc from "../../../../../_virtual/_plugin-vue_export-helper.mjs";
|
4
|
+
const AiInput = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-ca7f2210"]]);
|
5
|
+
export {
|
6
|
+
AiInput as default
|
7
|
+
};
|
@@ -0,0 +1,124 @@
|
|
1
|
+
import { defineComponent, ref, computed, onMounted, resolveComponent, openBlock, createElementBlock, normalizeStyle, unref, createElementVNode, toDisplayString, createVNode, createTextVNode, pushScopeId, popScopeId } from "vue";
|
2
|
+
import { onClickOutside } from "../../../../../node_modules/.pnpm/@vueuse_core@9.13.0_vue@3.2.45/node_modules/@vueuse/core/index.mjs";
|
3
|
+
import { useCopilotStoreHook, aiBarBtnType, wpsAiOpt } from "../../../../../store/modules/copilot.mjs";
|
4
|
+
import data from "../../../../../node_modules/.pnpm/@iconify-icons_ep@1.2.7/node_modules/@iconify-icons/ep/refresh.mjs";
|
5
|
+
const _withScopeId = (n) => (pushScopeId("data-v-ca7f2210"), n = n(), popScopeId(), n);
|
6
|
+
const _hoisted_1 = { class: "textarea overflow-y-auto text-gray-800 text-base border-2 border-blue-500 rounded-xl p-3 mb-2 font-serif select-text" };
|
7
|
+
const _hoisted_2 = { class: "flex justify-between items-center mt-4" };
|
8
|
+
const _hoisted_3 = /* @__PURE__ */ _withScopeId(() => /* @__PURE__ */ createElementVNode("div", { class: "text-sm text-gray-500 mr-2" }, [
|
9
|
+
/* @__PURE__ */ createElementVNode("span", null, "上述文本是由 AI 自动生成")
|
10
|
+
], -1));
|
11
|
+
const _hoisted_4 = { class: "flex items-center gap-1" };
|
12
|
+
const _hoisted_5 = /* @__PURE__ */ _withScopeId(() => /* @__PURE__ */ createElementVNode("span", { class: "mr-0.5" }, [
|
13
|
+
/* @__PURE__ */ createElementVNode("svg", {
|
14
|
+
xmlns: "http://www.w3.org/2000/svg",
|
15
|
+
width: "16",
|
16
|
+
height: "16",
|
17
|
+
viewBox: "0 0 1024 1024"
|
18
|
+
}, [
|
19
|
+
/* @__PURE__ */ createElementVNode("path", {
|
20
|
+
fill: "currentColor",
|
21
|
+
d: "M160 256H96a32 32 0 0 1 0-64h256V95.936a32 32 0 0 1 32-32h256a32 32 0 0 1 32 32V192h256a32 32 0 1 1 0 64h-64v672a32 32 0 0 1-32 32H192a32 32 0 0 1-32-32zm448-64v-64H416v64zM224 896h576V256H224zm192-128a32 32 0 0 1-32-32V416a32 32 0 0 1 64 0v320a32 32 0 0 1-32 32m192 0a32 32 0 0 1-32-32V416a32 32 0 0 1 64 0v320a32 32 0 0 1-32 32"
|
22
|
+
})
|
23
|
+
])
|
24
|
+
], -1));
|
25
|
+
const _hoisted_6 = /* @__PURE__ */ _withScopeId(() => /* @__PURE__ */ createElementVNode("div", { class: "h-4 w-px bg-gray-300 ml-1 mr-2" }, null, -1));
|
26
|
+
const _sfc_main = /* @__PURE__ */ defineComponent({
|
27
|
+
__name: "AiInput",
|
28
|
+
props: {
|
29
|
+
position: null,
|
30
|
+
selectedText: null,
|
31
|
+
type: null,
|
32
|
+
allWord: null
|
33
|
+
},
|
34
|
+
setup(__props, { emit }) {
|
35
|
+
const props = __props;
|
36
|
+
const CopilotStore = useCopilotStoreHook();
|
37
|
+
const { getCanvasAiRes } = CopilotStore;
|
38
|
+
const displayedContent = ref("");
|
39
|
+
const positionStyle = computed(() => ({
|
40
|
+
left: `${props.position.x}px`,
|
41
|
+
top: `${props.position.y}px`,
|
42
|
+
width: `${props.position.w}px`,
|
43
|
+
height: `${props.position.h}px`
|
44
|
+
}));
|
45
|
+
onMounted(async () => {
|
46
|
+
let prompt = "";
|
47
|
+
if (props.type === aiBarBtnType.continue) {
|
48
|
+
prompt = `在'${props.selectedText}'后插入几句话,不超过150字。`;
|
49
|
+
}
|
50
|
+
prompt += `参考当前文章内容:${props.allWord}`;
|
51
|
+
const mockResponse = await fetchAiContent(prompt);
|
52
|
+
typewriterEffect(mockResponse);
|
53
|
+
});
|
54
|
+
const fetchAiContent = async (text) => {
|
55
|
+
const res = await getCanvasAiRes(text, props.type);
|
56
|
+
return res;
|
57
|
+
};
|
58
|
+
const typewriterEffect = (text) => {
|
59
|
+
let index = 0;
|
60
|
+
const timer = setInterval(() => {
|
61
|
+
displayedContent.value += text[index];
|
62
|
+
if (++index === text.length)
|
63
|
+
clearInterval(timer);
|
64
|
+
}, 50);
|
65
|
+
};
|
66
|
+
[
|
67
|
+
{ label: "插入", action: wpsAiOpt.insert },
|
68
|
+
{ label: "重新生成", action: wpsAiOpt.rewrite },
|
69
|
+
{ label: "弃用", action: wpsAiOpt.cancelOpt }
|
70
|
+
];
|
71
|
+
function handleAction(action) {
|
72
|
+
emit(action, { type: action, text: displayedContent.value });
|
73
|
+
}
|
74
|
+
const aiInputRef = ref(null);
|
75
|
+
onClickOutside(aiInputRef, () => {
|
76
|
+
emit("close");
|
77
|
+
});
|
78
|
+
return (_ctx, _cache) => {
|
79
|
+
const _component_IconifyIconOffline = resolveComponent("IconifyIconOffline");
|
80
|
+
return openBlock(), createElementBlock("div", {
|
81
|
+
class: "ai-input bg-white rounded-2xl shadow-xl p-2",
|
82
|
+
style: normalizeStyle(unref(positionStyle))
|
83
|
+
}, [
|
84
|
+
createElementVNode("div", {
|
85
|
+
class: "flex-col",
|
86
|
+
ref_key: "aiInputRef",
|
87
|
+
ref: aiInputRef
|
88
|
+
}, [
|
89
|
+
createElementVNode("div", _hoisted_1, toDisplayString(displayedContent.value), 1),
|
90
|
+
createElementVNode("div", _hoisted_2, [
|
91
|
+
_hoisted_3,
|
92
|
+
createElementVNode("div", _hoisted_4, [
|
93
|
+
createElementVNode("button", {
|
94
|
+
class: "flex items-center text-gray-600 hover:text-black border-none",
|
95
|
+
onClick: _cache[0] || (_cache[0] = ($event) => handleAction(unref(wpsAiOpt).rewrite))
|
96
|
+
}, [
|
97
|
+
createVNode(_component_IconifyIconOffline, {
|
98
|
+
class: "mr-0.5",
|
99
|
+
icon: unref(data)
|
100
|
+
}, null, 8, ["icon"]),
|
101
|
+
createTextVNode(" 重写 ")
|
102
|
+
]),
|
103
|
+
createElementVNode("button", {
|
104
|
+
class: "flex items-center text-gray-600 hover:text-black border-none",
|
105
|
+
onClick: _cache[1] || (_cache[1] = ($event) => handleAction(unref(wpsAiOpt).cancelOpt))
|
106
|
+
}, [
|
107
|
+
_hoisted_5,
|
108
|
+
createTextVNode(" 弃用 ")
|
109
|
+
]),
|
110
|
+
_hoisted_6,
|
111
|
+
createElementVNode("button", {
|
112
|
+
class: "border !bg-[#8854f4] text-white border-[#ddd] !px-4 py-1 rounded-full",
|
113
|
+
onClick: _cache[2] || (_cache[2] = ($event) => handleAction(unref(wpsAiOpt).insert))
|
114
|
+
}, " 插入 ")
|
115
|
+
])
|
116
|
+
])
|
117
|
+
], 512)
|
118
|
+
], 4);
|
119
|
+
};
|
120
|
+
}
|
121
|
+
});
|
122
|
+
export {
|
123
|
+
_sfc_main as default
|
124
|
+
};
|
@@ -0,0 +1,71 @@
|
|
1
|
+
import { defineComponent, computed, ref, onMounted, onBeforeUnmount, watch, openBlock, createElementBlock, Fragment, unref, createBlock, createCommentVNode } from "vue";
|
2
|
+
import { aiBarBtnType } from "../../../../../store/modules/copilot.mjs";
|
3
|
+
import AiBar from "./AiBar.vue.mjs";
|
4
|
+
import AiInput from "./AiInput.vue.mjs";
|
5
|
+
const _sfc_main = /* @__PURE__ */ defineComponent({
|
6
|
+
__name: "index",
|
7
|
+
props: {
|
8
|
+
selectedText: null,
|
9
|
+
wpsAiBarPos: null,
|
10
|
+
wpsAiInputPos: null,
|
11
|
+
allWord: null
|
12
|
+
},
|
13
|
+
emits: ["insert", "rewrite", "cancelOpt"],
|
14
|
+
setup(__props, { emit }) {
|
15
|
+
const props = __props;
|
16
|
+
const aiBarShow = computed(() => props.selectedText.length > 0 && !aiAreaInputShow.value);
|
17
|
+
const aiAreaInputShow = ref(false);
|
18
|
+
const aiAreaInputText = ref("");
|
19
|
+
const aiAreaInputType = ref(aiBarBtnType.rewrite);
|
20
|
+
const isMouseDown = ref(false);
|
21
|
+
const handleAction = async (type) => {
|
22
|
+
aiAreaInputType.value = type;
|
23
|
+
aiAreaInputText.value = "";
|
24
|
+
aiAreaInputShow.value = true;
|
25
|
+
};
|
26
|
+
const handleWpsAction = (payload) => {
|
27
|
+
emit(payload.type, payload);
|
28
|
+
};
|
29
|
+
const handleMouseDown = () => isMouseDown.value = true;
|
30
|
+
const handleMouseUp = () => isMouseDown.value = false;
|
31
|
+
onMounted(() => {
|
32
|
+
document.addEventListener("mousedown", handleMouseDown);
|
33
|
+
document.addEventListener("mouseup", handleMouseUp);
|
34
|
+
});
|
35
|
+
onBeforeUnmount(() => {
|
36
|
+
document.removeEventListener("mousedown", handleMouseDown);
|
37
|
+
document.removeEventListener("mouseup", handleMouseUp);
|
38
|
+
});
|
39
|
+
watch(() => props.selectedText, (newValue) => {
|
40
|
+
if (!newValue || newValue.length === 0) {
|
41
|
+
if (aiAreaInputShow.value)
|
42
|
+
aiAreaInputShow.value = false;
|
43
|
+
}
|
44
|
+
});
|
45
|
+
return (_ctx, _cache) => {
|
46
|
+
return openBlock(), createElementBlock(Fragment, null, [
|
47
|
+
unref(aiBarShow) ? (openBlock(), createBlock(AiBar, {
|
48
|
+
key: 0,
|
49
|
+
position: __props.wpsAiBarPos,
|
50
|
+
onRewrite: _cache[0] || (_cache[0] = ($event) => handleAction(unref(aiBarBtnType).rewrite)),
|
51
|
+
onPolish: _cache[1] || (_cache[1] = ($event) => handleAction(unref(aiBarBtnType).polish)),
|
52
|
+
onContinue: _cache[2] || (_cache[2] = ($event) => handleAction(unref(aiBarBtnType).continue))
|
53
|
+
}, null, 8, ["position"])) : createCommentVNode("", true),
|
54
|
+
aiAreaInputShow.value ? (openBlock(), createBlock(AiInput, {
|
55
|
+
key: 1,
|
56
|
+
position: __props.wpsAiInputPos,
|
57
|
+
"selected-text": __props.selectedText,
|
58
|
+
type: aiAreaInputType.value,
|
59
|
+
allWord: __props.allWord,
|
60
|
+
onInsert: handleWpsAction,
|
61
|
+
onRewrite: handleWpsAction,
|
62
|
+
onCancelOpt: handleWpsAction,
|
63
|
+
onClose: _cache[3] || (_cache[3] = ($event) => aiAreaInputShow.value = false)
|
64
|
+
}, null, 8, ["position", "selected-text", "type", "allWord"])) : createCommentVNode("", true)
|
65
|
+
], 64);
|
66
|
+
};
|
67
|
+
}
|
68
|
+
});
|
69
|
+
export {
|
70
|
+
_sfc_main as default
|
71
|
+
};
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import _sfc_main from "./index.vue2.mjs";
|
2
2
|
import "./index.vue3.mjs";
|
3
3
|
import _export_sfc from "../../_virtual/_plugin-vue_export-helper.mjs";
|
4
|
-
const CopiCanvas = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-
|
4
|
+
const CopiCanvas = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-369c0c9d"]]);
|
5
5
|
export {
|
6
6
|
CopiCanvas as default
|
7
7
|
};
|
@@ -1,9 +1,8 @@
|
|
1
|
-
import { defineComponent, resolveComponent, openBlock, createElementBlock, normalizeClass, unref, createElementVNode, createVNode, toDisplayString,
|
1
|
+
import { defineComponent, resolveComponent, openBlock, createElementBlock, normalizeClass, unref, createElementVNode, createVNode, toDisplayString, createCommentVNode } from "vue";
|
2
2
|
import { storeToRefs } from "pinia";
|
3
3
|
import data from "../../node_modules/.pnpm/@iconify-icons_ep@1.2.7/node_modules/@iconify-icons/ep/reading.mjs";
|
4
4
|
import { useCopilotStoreHook } from "../../store/modules/copilot.mjs";
|
5
|
-
import
|
6
|
-
import InitWrap from "./InitWrap.vue.mjs";
|
5
|
+
import testWPS from "./document-viewer/wps-file-viewer/testWPS.vue.mjs";
|
7
6
|
const _hoisted_1 = { class: "canvas-icon" };
|
8
7
|
const _hoisted_2 = { class: "canvas-content" };
|
9
8
|
const _hoisted_3 = {
|
@@ -39,7 +38,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
39
38
|
createElementVNode("h3", null, toDisplayString(__props.title), 1)
|
40
39
|
]),
|
41
40
|
createElementVNode("div", _hoisted_5, [
|
42
|
-
|
41
|
+
createVNode(testWPS)
|
43
42
|
])
|
44
43
|
])) : createCommentVNode("", true)
|
45
44
|
])
|
@@ -1,4 +1,4 @@
|
|
1
|
-
const
|
1
|
+
const index_vue_vue_type_style_index_0_scoped_369c0c9d_lang = "";
|
2
2
|
export {
|
3
|
-
|
3
|
+
index_vue_vue_type_style_index_0_scoped_369c0c9d_lang as default
|
4
4
|
};
|
package/dist/es/api/copilot.mjs
CHANGED
@@ -78,18 +78,10 @@ const updataHistoryRecord = (data) => {
|
|
78
78
|
timeout: 6e4
|
79
79
|
});
|
80
80
|
};
|
81
|
-
const getDocxFileByUrl = (url) => {
|
82
|
-
return http.request("get", url, {
|
83
|
-
responseType: "blob",
|
84
|
-
timeout: 60 * 1e3 * 10,
|
85
|
-
needHeader: true
|
86
|
-
});
|
87
|
-
};
|
88
81
|
export {
|
89
82
|
createHistoryInfo,
|
90
83
|
createHistoryRecord,
|
91
84
|
deleteHistoryRecord,
|
92
|
-
getDocxFileByUrl,
|
93
85
|
getHistoryInfo,
|
94
86
|
getHistoryRecordList,
|
95
87
|
getReport,
|
@@ -0,0 +1,8 @@
|
|
1
|
+
const data = {
|
2
|
+
"width": 1024,
|
3
|
+
"height": 1024,
|
4
|
+
"body": '<path fill="currentColor" d="M771.776 794.88A384 384 0 0 1 128 512h64a320 320 0 0 0 555.712 216.448H654.72a32 32 0 1 1 0-64h149.056a32 32 0 0 1 32 32v148.928a32 32 0 1 1-64 0v-50.56zM276.288 295.616h92.992a32 32 0 0 1 0 64H220.16a32 32 0 0 1-32-32V178.56a32 32 0 0 1 64 0v50.56A384 384 0 0 1 896.128 512h-64a320 320 0 0 0-555.776-216.384z"/>'
|
5
|
+
};
|
6
|
+
export {
|
7
|
+
data as default
|
8
|
+
};
|