@kg-ui/kg-ui-plus 0.0.15 → 0.0.17

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. package/dist/es/KgCopilot/CopiFooter/SearchInput/SelectPluginByKey.vue.mjs +1 -1
  2. package/dist/es/KgCopilot/CopiFooter/SearchInput/SelectPluginByKey.vue2.mjs +79 -47
  3. package/dist/es/KgCopilot/CopiFooter/SearchInput/SelectPluginByKey.vue3.mjs +2 -2
  4. package/dist/es/KgCopilot/CopiFooter/SearchInput/index.vue.mjs +1 -1
  5. package/dist/es/KgCopilot/CopiFooter/SearchInput/index.vue2.mjs +212 -77
  6. package/dist/es/KgCopilot/CopiFooter/SearchInput/index.vue3.mjs +2 -2
  7. package/dist/es/KgCopilot/CopiFooter/index.vue.mjs +1 -1
  8. package/dist/es/KgCopilot/CopiFooter/index.vue3.mjs +2 -2
  9. package/dist/es/KgCopilot/dialogue/index.vue.mjs +1 -1
  10. package/dist/es/KgCopilot/dialogue/index.vue2.mjs +78 -63
  11. package/dist/es/KgCopilot/dialogue/index.vue3.mjs +2 -2
  12. package/dist/es/KgCopilot/dialogue/messageParse/edit.vue.mjs +7 -0
  13. package/dist/es/KgCopilot/dialogue/messageParse/edit.vue2.mjs +148 -0
  14. package/dist/es/KgCopilot/dialogue/messageParse/edit.vue3.mjs +4 -0
  15. package/dist/es/KgCopilot/dialogue/messageParse/index.vue.mjs +7 -0
  16. package/dist/es/KgCopilot/dialogue/messageParse/index.vue2.mjs +105 -0
  17. package/dist/es/KgCopilot/dialogue/messageParse/index.vue3.mjs +4 -0
  18. package/dist/es/KgCopilot/dialogue/messageParse/readMd.vue.mjs +7 -0
  19. package/dist/es/KgCopilot/dialogue/{readMd.vue2.mjs → messageParse/readMd.vue2.mjs} +15 -9
  20. package/dist/es/KgCopilot/dialogue/messageParse/readMd.vue3.mjs +4 -0
  21. package/dist/es/KgCopilot/index.vue.mjs +1 -1
  22. package/dist/es/KgCopilot/index.vue3.mjs +2 -2
  23. package/dist/es/api/copilot.mjs +13 -0
  24. package/dist/es/directives/heighlight/index.mjs +4 -0
  25. package/dist/es/node_modules/.pnpm/@iconify-icons_ph@1.2.5/node_modules/@iconify-icons/ph/caret-down-fill.mjs +8 -0
  26. package/dist/es/node_modules/.pnpm/@iconify-icons_ph@1.2.5/node_modules/@iconify-icons/ph/note-pencil-bold.mjs +8 -0
  27. package/dist/es/node_modules/.pnpm/@vueuse_core@9.13.0_vue@3.2.45/node_modules/@vueuse/core/index.mjs +111 -0
  28. package/dist/es/node_modules/.pnpm/@vueuse_shared@9.13.0_vue@3.2.45/node_modules/@vueuse/shared/index.mjs +15 -0
  29. package/dist/es/store/modules/copilot.mjs +144 -61
  30. package/dist/es/style.css +1 -1
  31. package/dist/es/utils/home.mjs +9 -10
  32. package/package.json +2 -1
  33. package/dist/es/KgCopilot/CopiFooter/SearchInput/SelectPlugin.vue.mjs +0 -7
  34. package/dist/es/KgCopilot/CopiFooter/SearchInput/SelectPlugin.vue2.mjs +0 -113
  35. package/dist/es/KgCopilot/CopiFooter/SearchInput/SelectPlugin.vue3.mjs +0 -4
  36. package/dist/es/KgCopilot/dialogue/readMd.vue.mjs +0 -7
  37. package/dist/es/KgCopilot/dialogue/readMd.vue3.mjs +0 -4
  38. /package/dist/es/KgCopilot/dialogue/{mdInCode.mjs → messageParse/mdInCode.mjs} +0 -0
@@ -1,7 +1,7 @@
1
1
  import _sfc_main from "./SelectPluginByKey.vue2.mjs";
2
2
  import "./SelectPluginByKey.vue3.mjs";
3
3
  import _export_sfc from "../../../_virtual/_plugin-vue_export-helper.mjs";
4
- const SelectPluginByKey = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-04f1b770"]]);
4
+ const SelectPluginByKey = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-ea1e5e2d"]]);
5
5
  export {
6
6
  SelectPluginByKey as default
7
7
  };
@@ -1,75 +1,107 @@
1
- import { defineComponent, ref, watch, openBlock, createBlock, Transition, withCtx, withDirectives, createElementBlock, createElementVNode, unref, Fragment, renderList, normalizeClass, toDisplayString, createCommentVNode } from "vue";
1
+ import { defineComponent, ref, watch, nextTick, resolveComponent, openBlock, createBlock, Transition, withCtx, withDirectives, createElementBlock, normalizeStyle, createElementVNode, Fragment, renderList, normalizeClass, toDisplayString, unref, createVNode, createCommentVNode } from "vue";
2
2
  import { ClickOutside } from "element-plus";
3
- import { debounce } from "../../../utils/home.mjs";
3
+ import data from "../../../node_modules/.pnpm/@iconify-icons_ep@1.2.7/node_modules/@iconify-icons/ep/check.mjs";
4
4
  import { useCopilotStoreHook } from "../../../store/modules/copilot.mjs";
5
5
  import { storeToRefs } from "pinia";
6
- const _hoisted_1 = {
7
- key: 0,
8
- class: "selection"
9
- };
10
- const _hoisted_2 = { class: "input-container" };
11
- const _hoisted_3 = { class: "plugin-content" };
12
- const _hoisted_4 = ["onClick"];
6
+ const _hoisted_1 = { class: "plugin-content" };
7
+ const _hoisted_2 = ["onClick"];
8
+ const _hoisted_3 = { class: "plugin-item-right" };
13
9
  const _sfc_main = /* @__PURE__ */ defineComponent({
14
10
  __name: "SelectPluginByKey",
15
11
  props: {
16
- isShowSelect: { type: Boolean }
12
+ isShowSelect: { type: Boolean },
13
+ activePluInd: null,
14
+ selectPluginList: null,
15
+ modal: null
17
16
  },
18
17
  emits: ["close", "deleteText"],
19
18
  setup(__props, { emit }) {
19
+ const props = __props;
20
20
  const CopilotStore = useCopilotStoreHook();
21
21
  const { setCheckedPluginList } = CopilotStore;
22
- const { plugins, checkedPluginByBtn } = storeToRefs(CopilotStore);
23
- const selectPluginList = ref([]);
22
+ const { checkedPluginByBtn } = storeToRefs(CopilotStore);
23
+ const pluginItem = ref(null);
24
+ const onClickOutside = () => {
25
+ emit("close");
26
+ };
24
27
  watch(
25
- () => plugins.value,
28
+ () => props.activePluInd,
26
29
  () => {
27
- selectPluginList.value = plugins.value;
28
- },
29
- {
30
- immediate: true
30
+ pluginItem.value[props.activePluInd].scrollIntoView({
31
+ block: "nearest",
32
+ behavior: "smooth"
33
+ });
34
+ }
35
+ );
36
+ watch(
37
+ () => props.isShowSelect,
38
+ () => {
39
+ if (props.isShowSelect) {
40
+ nextTick(() => {
41
+ pluginItem.value[props.activePluInd].scrollIntoView({
42
+ block: "nearest",
43
+ behavior: "smooth"
44
+ });
45
+ });
46
+ }
31
47
  }
32
48
  );
33
- const onClickOutside = () => {
34
- emit("close");
35
- };
36
49
  const choosePlugin = (plugin) => {
37
50
  setCheckedPluginList(plugin);
38
- emit("deleteText");
51
+ if (props.modal === "key") {
52
+ emit("deleteText");
53
+ }
39
54
  emit("close");
40
55
  };
41
- const searchPlugin = debounce((event) => {
42
- const target = event.target;
43
- const filteredPlugins = plugins.value.filter(
44
- (item) => item.name.includes(target.value)
45
- );
46
- selectPluginList.value = filteredPlugins.length > 0 ? filteredPlugins : plugins.value;
47
- });
48
56
  return (_ctx, _cache) => {
57
+ const _component_IconifyIconOffline = resolveComponent("IconifyIconOffline");
58
+ const _component_el_popover = resolveComponent("el-popover");
49
59
  return openBlock(), createBlock(Transition, { name: "fade-scale" }, {
50
60
  default: withCtx(() => [
51
- __props.isShowSelect ? withDirectives((openBlock(), createElementBlock("div", _hoisted_1, [
52
- createElementVNode("div", _hoisted_2, [
53
- createElementVNode("input", {
54
- type: "text",
55
- placeholder: "请输入插件名",
56
- class: "select-input",
57
- onInput: _cache[0] || (_cache[0] = //@ts-ignore
58
- (...args) => unref(searchPlugin) && unref(searchPlugin)(...args))
59
- }, null, 32)
60
- ]),
61
- createElementVNode("div", _hoisted_3, [
62
- (openBlock(true), createElementBlock(Fragment, null, renderList(selectPluginList.value, (plugin, index) => {
63
- return openBlock(), createElementBlock("div", {
61
+ __props.isShowSelect ? withDirectives((openBlock(), createElementBlock("div", {
62
+ key: 0,
63
+ class: "selection",
64
+ style: normalizeStyle({ top: __props.modal === "key" ? "-105px" : "-150px" })
65
+ }, [
66
+ createElementVNode("div", _hoisted_1, [
67
+ (openBlock(true), createElementBlock(Fragment, null, renderList(__props.selectPluginList, (plugin, index) => {
68
+ return openBlock(), createBlock(_component_el_popover, {
69
+ offset: 5,
64
70
  key: index,
65
- class: normalizeClass(["plugin-item", { isSel: unref(checkedPluginByBtn).includes(plugin) }]),
66
- onClick: ($event) => choosePlugin(plugin)
67
- }, [
68
- createElementVNode("span", null, toDisplayString(plugin.name), 1)
69
- ], 10, _hoisted_4);
71
+ placement: "right-start",
72
+ title: plugin.name,
73
+ width: 200,
74
+ trigger: "hover",
75
+ content: plugin.describe,
76
+ "show-after": 200,
77
+ "hide-after": 0
78
+ }, {
79
+ reference: withCtx(() => [
80
+ createElementVNode("div", {
81
+ ref_for: true,
82
+ ref_key: "pluginItem",
83
+ ref: pluginItem,
84
+ class: normalizeClass(["plugin-item", { isSel: index === __props.activePluInd }]),
85
+ onClick: ($event) => choosePlugin(plugin)
86
+ }, [
87
+ createElementVNode("span", null, toDisplayString(plugin.name), 1),
88
+ createElementVNode("div", _hoisted_3, [
89
+ createElementVNode("div", {
90
+ class: normalizeClass(["select-radio", { "active-radio": unref(checkedPluginByBtn) === plugin }])
91
+ }, [
92
+ createVNode(_component_IconifyIconOffline, {
93
+ class: normalizeClass([{ hoverIcon: index === __props.activePluInd }, "icon"]),
94
+ icon: unref(data)
95
+ }, null, 8, ["class", "icon"])
96
+ ], 2)
97
+ ])
98
+ ], 10, _hoisted_2)
99
+ ]),
100
+ _: 2
101
+ }, 1032, ["title", "content"]);
70
102
  }), 128))
71
103
  ])
72
- ])), [
104
+ ], 4)), [
73
105
  [unref(ClickOutside), onClickOutside]
74
106
  ]) : createCommentVNode("", true)
75
107
  ]),
@@ -1,4 +1,4 @@
1
- const SelectPluginByKey_vue_vue_type_style_index_0_scoped_04f1b770_lang = "";
1
+ const SelectPluginByKey_vue_vue_type_style_index_0_scoped_ea1e5e2d_lang = "";
2
2
  export {
3
- SelectPluginByKey_vue_vue_type_style_index_0_scoped_04f1b770_lang as default
3
+ SelectPluginByKey_vue_vue_type_style_index_0_scoped_ea1e5e2d_lang as default
4
4
  };
@@ -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 SearchInput = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-3b4bd108"]]);
4
+ const SearchInput = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-b85dc853"]]);
5
5
  export {
6
6
  SearchInput as default
7
7
  };
@@ -1,13 +1,13 @@
1
- import { defineComponent, ref, onMounted, computed, watch, resolveComponent, openBlock, createElementBlock, createElementVNode, createVNode, withModifiers, toDisplayString, normalizeClass, unref, createCommentVNode, withKeys, createTextVNode, normalizeStyle, pushScopeId, popScopeId } from "vue";
1
+ import { defineComponent, ref, onMounted, watch, computed, resolveComponent, openBlock, createElementBlock, createElementVNode, createVNode, withModifiers, toDisplayString, normalizeClass, unref, createCommentVNode, withKeys, normalizeStyle, createTextVNode, pushScopeId, popScopeId } from "vue";
2
2
  import Upload from "./Upload.vue.mjs";
3
3
  import data from "../../../node_modules/.pnpm/@iconify-icons_ep@1.2.7/node_modules/@iconify-icons/ep/promotion.mjs";
4
4
  import NewTheme from "./NewTheme.vue.mjs";
5
+ import { filterPluginByPinyin } from "../../../utils/home.mjs";
5
6
  import SpeechControl from "./SpeechControl.vue.mjs";
6
- import SelectPlugin from "./SelectPlugin.vue.mjs";
7
7
  import SelectPluginByKey from "./SelectPluginByKey.vue.mjs";
8
8
  import { useCopilotStoreHook } from "../../../store/modules/copilot.mjs";
9
9
  import { storeToRefs } from "pinia";
10
- const _withScopeId = (n) => (pushScopeId("data-v-3b4bd108"), n = n(), popScopeId(), n);
10
+ const _withScopeId = (n) => (pushScopeId("data-v-b85dc853"), n = n(), popScopeId(), n);
11
11
  const _hoisted_1 = { class: "control-contain" };
12
12
  const _hoisted_2 = ["onClick"];
13
13
  const _hoisted_3 = /* @__PURE__ */ _withScopeId(() => /* @__PURE__ */ createElementVNode("svg", {
@@ -25,7 +25,7 @@ const _hoisted_4 = [
25
25
  _hoisted_3
26
26
  ];
27
27
  const _hoisted_5 = /* @__PURE__ */ _withScopeId(() => /* @__PURE__ */ createElementVNode("div", { class: "stop-icon" }, null, -1));
28
- const _hoisted_6 = /* @__PURE__ */ _withScopeId(() => /* @__PURE__ */ createElementVNode("span", null, "停止响应", -1));
28
+ const _hoisted_6 = /* @__PURE__ */ _withScopeId(() => /* @__PURE__ */ createElementVNode("span", null, "停止生成", -1));
29
29
  const _hoisted_7 = [
30
30
  _hoisted_5,
31
31
  _hoisted_6
@@ -35,16 +35,17 @@ const _hoisted_9 = {
35
35
  key: 0,
36
36
  class: "plugin-town"
37
37
  };
38
- const _hoisted_10 = {
38
+ const _hoisted_10 = /* @__PURE__ */ _withScopeId(() => /* @__PURE__ */ createElementVNode("span", null, "已选插件:", -1));
39
+ const _hoisted_11 = {
39
40
  class: "input-row",
40
41
  id: "copiFooter"
41
42
  };
42
- const _hoisted_11 = ["onKeydown"];
43
- const _hoisted_12 = { class: "bottom-controls" };
44
- const _hoisted_13 = { class: "bottom-left-controls" };
45
- const _hoisted_14 = { class: "bottom-right-controls" };
46
- const _hoisted_15 = { class: "text-sum" };
47
- const _hoisted_16 = {
43
+ const _hoisted_12 = ["onKeydown"];
44
+ const _hoisted_13 = { class: "bottom-controls" };
45
+ const _hoisted_14 = { class: "bottom-left-controls" };
46
+ const _hoisted_15 = { class: "bottom-right-controls" };
47
+ const _hoisted_16 = { class: "text-sum" };
48
+ const _hoisted_17 = {
48
49
  key: 1,
49
50
  class: "disable",
50
51
  "click.stop": ""
@@ -58,9 +59,16 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
58
59
  isInitCopilot,
59
60
  sendLonding,
60
61
  stopDialogue,
61
- checkedPluginByBtn
62
+ checkedPluginByBtn,
63
+ plugins
62
64
  } = storeToRefs(CopilotStore);
63
- const { setSearchText, sendMsg, setShowNewTheme, cancelRequest } = CopilotStore;
65
+ const {
66
+ setSearchText,
67
+ sendMsg,
68
+ setShowNewTheme,
69
+ cancelRequest,
70
+ setCheckedPluginList
71
+ } = CopilotStore;
64
72
  const coptInput = ref();
65
73
  const bottomFooter = ref();
66
74
  onMounted(() => {
@@ -71,13 +79,25 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
71
79
  const observer = new MutationObserver(() => {
72
80
  clearTimeout(timer);
73
81
  timer = setTimeout(() => {
74
- root.style.setProperty(
75
- "--input-bottom-height",
76
- `${bottomFooter.value.offsetHeight}px`
77
- );
82
+ if (bottomFooter.value) {
83
+ root.style.setProperty(
84
+ "--input-bottom-height",
85
+ `${bottomFooter.value.offsetHeight}px`
86
+ );
87
+ }
78
88
  }, 500);
79
89
  });
80
- const config = { attributes: true, childList: true, subtree: true };
90
+ const config = { childList: true, subtree: true };
91
+ const selectPluginList = ref([]);
92
+ watch(
93
+ () => plugins.value,
94
+ () => {
95
+ selectPluginList.value = plugins.value;
96
+ },
97
+ {
98
+ immediate: true
99
+ }
100
+ );
81
101
  const textLength = computed(() => {
82
102
  const num = searchText.value.length;
83
103
  if (num === 0) {
@@ -85,31 +105,53 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
85
105
  }
86
106
  return num;
87
107
  });
108
+ const isShowSelect = ref(false);
109
+ watch(isShowSelect, (newVal) => {
110
+ if (!newVal) {
111
+ pluginModal.value = "key";
112
+ if (!Object.keys(checkedPluginByBtn.value).length) {
113
+ activePluInd.value = 0;
114
+ } else {
115
+ activePluInd.value = plugins.value.indexOf(checkedPluginByBtn.value);
116
+ }
117
+ selectPluginList.value = plugins.value;
118
+ }
119
+ });
88
120
  const root = document.documentElement;
121
+ let timerCursor;
122
+ const searchPluText = ref("");
123
+ const cursorCurrentPos = ref(0);
89
124
  const inputChange = (e) => {
125
+ if (isShowSelect.value) {
126
+ clearTimeout(timerCursor);
127
+ timerCursor = setTimeout(() => {
128
+ cursorCurrentPos.value = Number(getCursorPosition());
129
+ searchPluText.value = e.target.innerText.substring(
130
+ Number(cursorPos) + 1,
131
+ cursorCurrentPos.value
132
+ );
133
+ searchPlugin(searchPluText.value);
134
+ }, 500);
135
+ }
90
136
  if (e.target.innerText.length >= 2e3) {
91
137
  e.target.innerText = e.target.innerText.substring(0, 2e3);
92
- const range = document.createRange();
93
- range.selectNodeContents(e.target);
94
- range.collapse(false);
95
- const sel = window.getSelection();
96
- sel.removeAllRanges();
97
- sel.addRange(range);
138
+ moveCursorPosition(2e3);
98
139
  }
99
140
  setSearchText(e.target.innerText);
100
141
  };
101
- const isShowSelect = ref(false);
102
- const handlerSendMsg = (e) => {
103
- e.preventDefault();
104
- if (isComposing.value)
105
- return;
106
- const sendText = searchText.value;
107
- if (!sendText)
108
- return;
109
- if (sendLonding.value)
110
- return;
111
- sendMsg(sendText);
112
- initInput();
142
+ const searchPlugin = (str) => {
143
+ if (str) {
144
+ const filteredPlugins = plugins.value.filter(
145
+ (item) => filterPluginByPinyin(item.name, str)
146
+ );
147
+ selectPluginList.value = filteredPlugins;
148
+ activePluInd.value = 0;
149
+ if (!selectPluginList.value.length) {
150
+ isShowSelect.value = false;
151
+ }
152
+ } else {
153
+ selectPluginList.value = plugins.value;
154
+ }
113
155
  };
114
156
  const isComposing = ref(false);
115
157
  const handleCompositionStart = () => {
@@ -118,32 +160,94 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
118
160
  const handleCompositionEnd = (e) => {
119
161
  isComposing.value = false;
120
162
  };
121
- const handleKeyDown = (e) => {
122
- if (e.key === "@") {
123
- selectPluginByKey();
163
+ const handleKeyDown = (event) => {
164
+ switch (event.key) {
165
+ case "@":
166
+ selectPluginByKey();
167
+ break;
168
+ case "ArrowUp":
169
+ event.preventDefault();
170
+ if (isComposing.value)
171
+ return;
172
+ changePlugin("up");
173
+ break;
174
+ case "ArrowDown":
175
+ event.preventDefault();
176
+ if (isComposing.value)
177
+ return;
178
+ changePlugin("down");
179
+ break;
180
+ case "ArrowRight":
181
+ if (isShowSelect.value) {
182
+ event.preventDefault();
183
+ }
184
+ break;
185
+ case "ArrowLeft":
186
+ if (isShowSelect.value) {
187
+ event.preventDefault();
188
+ }
189
+ break;
190
+ case "Backspace":
191
+ if (!isShowSelect.value) {
192
+ const beforeBackspaceText = coptInput.value.innerText.substring(
193
+ Number(getCursorPosition()) - 2,
194
+ Number(getCursorPosition()) - 1
195
+ );
196
+ if (beforeBackspaceText === "@") {
197
+ isShowSelect.value = true;
198
+ cursorPos = Number(getCursorPosition()) - 2;
199
+ }
200
+ } else {
201
+ const delectText = coptInput.value.innerText.substring(
202
+ Number(getCursorPosition()) - 1,
203
+ Number(getCursorPosition())
204
+ );
205
+ if (delectText === "@") {
206
+ isShowSelect.value = false;
207
+ }
208
+ }
209
+ break;
124
210
  }
125
211
  };
126
- const closeSelection = () => {
127
- isShowSelect.value = false;
212
+ const activePluInd = ref(0);
213
+ const changePlugin = (direct) => {
214
+ if (direct === "up" && activePluInd.value === 0)
215
+ return;
216
+ if (direct === "down" && activePluInd.value === plugins.value.length - 1)
217
+ return;
218
+ activePluInd.value = direct === "up" ? activePluInd.value - 1 : activePluInd.value + 1;
128
219
  };
220
+ let cursorPos = 0;
129
221
  const selectPluginByKey = () => {
130
222
  isShowSelect.value = true;
131
- getCursorPosition();
223
+ cursorPos = Number(getCursorPosition());
224
+ };
225
+ const getCursorPosition = () => {
226
+ const selection = window.getSelection();
227
+ const range = selection.getRangeAt(0);
228
+ return range.startOffset.toString();
229
+ };
230
+ const moveCursorPosition = (position) => {
231
+ if (coptInput.value.firstChild) {
232
+ const range = document.createRange();
233
+ range.setStart(coptInput.value.firstChild, position);
234
+ range.setEnd(coptInput.value.firstChild, position);
235
+ const selection = window.getSelection();
236
+ selection.removeAllRanges();
237
+ selection.addRange(range);
238
+ coptInput.value.focus();
239
+ }
132
240
  };
133
241
  const initInput = () => {
134
242
  coptInput.value.innerText = "";
135
243
  setSearchText("");
136
244
  };
137
- let cursorPos = "";
138
245
  const deleteText = () => {
139
246
  const textArr = coptInput.value.innerText.split("");
140
- textArr.splice(parseInt(cursorPos) - 1, 1);
247
+ textArr.splice(cursorPos, cursorCurrentPos.value - cursorPos);
248
+ coptInput.value.innerText = textArr.join("");
141
249
  searchText.value = textArr.join("");
142
- };
143
- const getCursorPosition = () => {
144
- const selection = window.getSelection();
145
- const range = selection.getRangeAt(0);
146
- cursorPos = range.startOffset.toString();
250
+ moveCursorPosition(cursorPos);
147
251
  };
148
252
  const handleClickStopBtn = () => {
149
253
  cancelRequest();
@@ -156,27 +260,53 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
156
260
  });
157
261
  const buttonText = ref("选择插件");
158
262
  const isShowSelection = ref(false);
159
- const outsideClose = ref(false);
160
263
  watch(
161
- checkedPluginByBtn.value,
264
+ checkedPluginByBtn,
162
265
  (val) => {
163
- if (val.length) {
266
+ if (Object.keys(val).length) {
164
267
  buttonText.value = "已选插件";
165
268
  } else {
166
269
  buttonText.value = "选择插件";
167
270
  }
168
271
  },
169
272
  {
170
- immediate: true
273
+ immediate: true,
274
+ deep: true
171
275
  }
172
276
  );
173
- const selectPlugin = () => {
174
- isShowSelection.value = outsideClose.value ? false : true;
175
- outsideClose.value = false;
277
+ const pluginModal = ref("key");
278
+ const openPluDialog = () => {
279
+ pluginModal.value = "btn";
280
+ isShowSelect.value = !isShowSelect.value;
281
+ if (!isShowSelect.value) {
282
+ pluginModal.value = "key";
283
+ }
176
284
  };
177
285
  const closePluginByoutside = () => {
178
- outsideClose.value = true;
179
- isShowSelection.value = false;
286
+ const timeId = setTimeout(() => {
287
+ isShowSelect.value = false;
288
+ clearTimeout(timeId);
289
+ }, 100);
290
+ };
291
+ const handlerSendMsg = (e) => {
292
+ if (e.key === "Enter") {
293
+ e.preventDefault();
294
+ }
295
+ if (isComposing.value)
296
+ return;
297
+ if (isShowSelect.value) {
298
+ setCheckedPluginList(selectPluginList.value[activePluInd.value]);
299
+ deleteText();
300
+ isShowSelect.value = false;
301
+ return;
302
+ }
303
+ const sendText = searchText.value;
304
+ if (!sendText)
305
+ return;
306
+ if (sendLonding.value)
307
+ return;
308
+ sendMsg(sendText);
309
+ initInput();
180
310
  };
181
311
  return (_ctx, _cache) => {
182
312
  const _component_IconifyIconOffline = resolveComponent("IconifyIconOffline");
@@ -186,19 +316,17 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
186
316
  ref: bottomFooter
187
317
  }, [
188
318
  createElementVNode("div", _hoisted_1, [
189
- createVNode(SelectPlugin, {
190
- isShowSelection: isShowSelection.value,
191
- outsideClose: outsideClose.value,
192
- onClosePluginByoutside: closePluginByoutside
193
- }, null, 8, ["isShowSelection", "outsideClose"]),
194
319
  createVNode(SelectPluginByKey, {
195
320
  isShowSelect: isShowSelect.value,
196
- onClose: closeSelection,
321
+ selectPluginList: selectPluginList.value,
322
+ activePluInd: activePluInd.value,
323
+ modal: pluginModal.value,
324
+ onClose: closePluginByoutside,
197
325
  onDeleteText: deleteText
198
- }, null, 8, ["isShowSelect"]),
326
+ }, null, 8, ["isShowSelect", "selectPluginList", "activePluInd", "modal"]),
199
327
  createElementVNode("button", {
200
328
  class: "control-button select-button",
201
- onClick: withModifiers(selectPlugin, ["stop"])
329
+ onClick: withModifiers(openPluDialog, ["stop"])
202
330
  }, [
203
331
  createElementVNode("span", null, toDisplayString(buttonText.value), 1),
204
332
  createElementVNode("div", {
@@ -213,8 +341,11 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
213
341
  }, _hoisted_7)) : createCommentVNode("", true)
214
342
  ]),
215
343
  createElementVNode("div", _hoisted_8, [
216
- unref(checkedPluginByBtn).length !== 0 ? (openBlock(), createElementBlock("div", _hoisted_9, toDisplayString(unref(checkedPluginByBtn).map((item) => item.name).join(" ")) + " ", 1)) : createCommentVNode("", true),
217
- createElementVNode("div", _hoisted_10, [
344
+ Object.keys(unref(checkedPluginByBtn)).length !== 0 ? (openBlock(), createElementBlock("div", _hoisted_9, [
345
+ _hoisted_10,
346
+ createElementVNode("span", null, toDisplayString(unref(checkedPluginByBtn).name), 1)
347
+ ])) : createCommentVNode("", true),
348
+ createElementVNode("div", _hoisted_11, [
218
349
  createElementVNode("div", {
219
350
  ref_key: "coptInput",
220
351
  ref: coptInput,
@@ -222,20 +353,24 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
222
353
  contenteditable: "plaintext-only",
223
354
  placeholder: "有问题请尽管问我。。。",
224
355
  onInput: inputChange,
225
- onKeydown: withKeys(handlerSendMsg, ["enter"]),
226
- onKeyup: handleKeyDown,
356
+ onKeydown: [
357
+ withKeys(handlerSendMsg, ["enter"]),
358
+ handleKeyDown
359
+ ],
227
360
  onCompositionstart: handleCompositionStart,
228
361
  onCompositionend: handleCompositionEnd
229
- }, toDisplayString(unref(searchText)), 41, _hoisted_11),
362
+ }, toDisplayString(unref(searchText)), 41, _hoisted_12),
230
363
  createVNode(SpeechControl)
231
364
  ]),
232
- createElementVNode("div", _hoisted_12, [
233
- createElementVNode("div", _hoisted_13, [
365
+ createElementVNode("div", _hoisted_13, [
366
+ createElementVNode("div", _hoisted_14, [
234
367
  createVNode(Upload, { type: "pic" })
235
368
  ]),
236
- createElementVNode("div", _hoisted_14, [
237
- createElementVNode("span", _hoisted_15, [
238
- createElementVNode("span", null, toDisplayString(unref(textLength)), 1),
369
+ createElementVNode("div", _hoisted_15, [
370
+ createElementVNode("span", _hoisted_16, [
371
+ createElementVNode("span", {
372
+ style: normalizeStyle({ color: unref(textLength) >= 2e3 ? "red" : "#666666" })
373
+ }, toDisplayString(unref(textLength)), 5),
239
374
  createTextVNode("/2000")
240
375
  ]),
241
376
  createElementVNode("button", {
@@ -252,7 +387,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
252
387
  ])
253
388
  ])
254
389
  ]),
255
- unref(stopDialogue) ? (openBlock(), createElementBlock("div", _hoisted_16)) : createCommentVNode("", true)
390
+ unref(stopDialogue) ? (openBlock(), createElementBlock("div", _hoisted_17)) : createCommentVNode("", true)
256
391
  ])
257
392
  ], 512);
258
393
  };
@@ -1,4 +1,4 @@
1
- const index_vue_vue_type_style_index_0_scoped_3b4bd108_lang = "";
1
+ const index_vue_vue_type_style_index_0_scoped_b85dc853_lang = "";
2
2
  export {
3
- index_vue_vue_type_style_index_0_scoped_3b4bd108_lang as default
3
+ index_vue_vue_type_style_index_0_scoped_b85dc853_lang as default
4
4
  };
@@ -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 CopiFooter = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-07622f5d"]]);
4
+ const CopiFooter = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-3166d992"]]);
5
5
  export {
6
6
  CopiFooter as default
7
7
  };
@@ -1,4 +1,4 @@
1
- const index_vue_vue_type_style_index_0_scoped_07622f5d_lang = "";
1
+ const index_vue_vue_type_style_index_0_scoped_3166d992_lang = "";
2
2
  export {
3
- index_vue_vue_type_style_index_0_scoped_07622f5d_lang as default
3
+ index_vue_vue_type_style_index_0_scoped_3166d992_lang as default
4
4
  };
@@ -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 dialogue = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-bea9de75"]]);
4
+ const dialogue = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-dff5947b"]]);
5
5
  export {
6
6
  dialogue as default
7
7
  };