@kg-ui/kg-ui-plus 0.0.16 → 0.0.18

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 (39) hide show
  1. package/dist/es/KgCopilot/CopiFooter/SearchInput/SelectPluginByKey.vue.mjs +1 -1
  2. package/dist/es/KgCopilot/CopiFooter/SearchInput/SelectPluginByKey.vue2.mjs +83 -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 +217 -76
  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 +153 -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} +14 -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.vue2.mjs +1 -1
  23. package/dist/es/KgCopilot/index.vue3.mjs +2 -2
  24. package/dist/es/api/copilot.mjs +13 -0
  25. package/dist/es/directives/heighlight/index.mjs +4 -0
  26. package/dist/es/node_modules/.pnpm/@iconify-icons_ph@1.2.5/node_modules/@iconify-icons/ph/caret-down-fill.mjs +8 -0
  27. package/dist/es/node_modules/.pnpm/@iconify-icons_ph@1.2.5/node_modules/@iconify-icons/ph/note-pencil-bold.mjs +8 -0
  28. package/dist/es/node_modules/.pnpm/@vueuse_core@9.13.0_vue@3.2.45/node_modules/@vueuse/core/index.mjs +111 -0
  29. package/dist/es/node_modules/.pnpm/@vueuse_shared@9.13.0_vue@3.2.45/node_modules/@vueuse/shared/index.mjs +15 -0
  30. package/dist/es/store/modules/copilot.mjs +144 -61
  31. package/dist/es/style.css +1 -1
  32. package/dist/es/utils/home.mjs +9 -10
  33. package/package.json +2 -1
  34. package/dist/es/KgCopilot/CopiFooter/SearchInput/SelectPlugin.vue.mjs +0 -7
  35. package/dist/es/KgCopilot/CopiFooter/SearchInput/SelectPlugin.vue2.mjs +0 -113
  36. package/dist/es/KgCopilot/CopiFooter/SearchInput/SelectPlugin.vue3.mjs +0 -4
  37. package/dist/es/KgCopilot/dialogue/readMd.vue.mjs +0 -7
  38. package/dist/es/KgCopilot/dialogue/readMd.vue3.mjs +0 -4
  39. /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-c1c27636"]]);
5
5
  export {
6
6
  SelectPluginByKey as default
7
7
  };
@@ -1,75 +1,111 @@
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
+ if (props.activePluInd !== null) {
31
+ pluginItem.value[props.activePluInd].scrollIntoView({
32
+ block: "nearest",
33
+ behavior: "smooth"
34
+ });
35
+ }
36
+ }
37
+ );
38
+ watch(
39
+ () => props.isShowSelect,
40
+ () => {
41
+ if (props.isShowSelect) {
42
+ if (props.activePluInd !== null) {
43
+ nextTick(() => {
44
+ pluginItem.value[props.activePluInd].scrollIntoView({
45
+ block: "nearest",
46
+ behavior: "smooth"
47
+ });
48
+ });
49
+ }
50
+ }
31
51
  }
32
52
  );
33
- const onClickOutside = () => {
34
- emit("close");
35
- };
36
53
  const choosePlugin = (plugin) => {
37
54
  setCheckedPluginList(plugin);
38
- emit("deleteText");
55
+ if (props.modal === "key") {
56
+ emit("deleteText");
57
+ }
39
58
  emit("close");
40
59
  };
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
60
  return (_ctx, _cache) => {
61
+ const _component_IconifyIconOffline = resolveComponent("IconifyIconOffline");
62
+ const _component_el_popover = resolveComponent("el-popover");
49
63
  return openBlock(), createBlock(Transition, { name: "fade-scale" }, {
50
64
  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", {
65
+ __props.isShowSelect ? withDirectives((openBlock(), createElementBlock("div", {
66
+ key: 0,
67
+ class: "selection",
68
+ style: normalizeStyle({ top: __props.modal === "key" ? "-105px" : "-150px" })
69
+ }, [
70
+ createElementVNode("div", _hoisted_1, [
71
+ (openBlock(true), createElementBlock(Fragment, null, renderList(__props.selectPluginList, (plugin, index) => {
72
+ return openBlock(), createBlock(_component_el_popover, {
73
+ offset: 5,
64
74
  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);
75
+ placement: "right-start",
76
+ title: plugin.name,
77
+ width: 200,
78
+ trigger: "hover",
79
+ content: plugin.describe,
80
+ "show-after": 200,
81
+ "hide-after": 0
82
+ }, {
83
+ reference: withCtx(() => [
84
+ createElementVNode("div", {
85
+ ref_for: true,
86
+ ref_key: "pluginItem",
87
+ ref: pluginItem,
88
+ class: normalizeClass(["plugin-item", { isSel: index === __props.activePluInd }]),
89
+ onClick: ($event) => choosePlugin(plugin)
90
+ }, [
91
+ createElementVNode("span", null, toDisplayString(plugin.name), 1),
92
+ createElementVNode("div", _hoisted_3, [
93
+ createElementVNode("div", {
94
+ class: normalizeClass(["select-radio", { "active-radio": unref(checkedPluginByBtn) === plugin }])
95
+ }, [
96
+ createVNode(_component_IconifyIconOffline, {
97
+ class: normalizeClass([{ hoverIcon: index === __props.activePluInd }, "icon"]),
98
+ icon: unref(data)
99
+ }, null, 8, ["class", "icon"])
100
+ ], 2)
101
+ ])
102
+ ], 10, _hoisted_2)
103
+ ]),
104
+ _: 2
105
+ }, 1032, ["title", "content"]);
70
106
  }), 128))
71
107
  ])
72
- ])), [
108
+ ], 4)), [
73
109
  [unref(ClickOutside), onClickOutside]
74
110
  ]) : createCommentVNode("", true)
75
111
  ]),
@@ -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_c1c27636_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_c1c27636_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-027dba91"]]);
4
+ const SearchInput = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-665518fc"]]);
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-027dba91"), n = n(), popScopeId(), n);
10
+ const _withScopeId = (n) => (pushScopeId("data-v-665518fc"), 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", {
@@ -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,48 @@ 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
+ selectPluginList.value = plugins.value;
113
+ }
114
+ });
88
115
  const root = document.documentElement;
116
+ let timerCursor;
117
+ const searchPluText = ref("");
118
+ const cursorCurrentPos = ref(0);
89
119
  const inputChange = (e) => {
120
+ if (isShowSelect.value) {
121
+ clearTimeout(timerCursor);
122
+ timerCursor = setTimeout(() => {
123
+ cursorCurrentPos.value = getCursorPosition();
124
+ searchPluText.value = e.target.innerText.substring(
125
+ Number(cursorPos) + 1,
126
+ cursorCurrentPos.value
127
+ );
128
+ searchPlugin(searchPluText.value);
129
+ }, 500);
130
+ }
90
131
  if (e.target.innerText.length >= 2e3) {
91
132
  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);
133
+ moveCursorPosition(2e3);
98
134
  }
99
135
  setSearchText(e.target.innerText);
100
136
  };
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();
137
+ const searchPlugin = (str) => {
138
+ if (str) {
139
+ const filteredPlugins = plugins.value.filter(
140
+ (item) => filterPluginByPinyin(item.name, str)
141
+ );
142
+ selectPluginList.value = filteredPlugins;
143
+ activePluInd.value = 0;
144
+ if (!selectPluginList.value.length) {
145
+ isShowSelect.value = false;
146
+ }
147
+ } else {
148
+ selectPluginList.value = plugins.value;
149
+ }
113
150
  };
114
151
  const isComposing = ref(false);
115
152
  const handleCompositionStart = () => {
@@ -118,32 +155,94 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
118
155
  const handleCompositionEnd = (e) => {
119
156
  isComposing.value = false;
120
157
  };
121
- const handleKeyDown = (e) => {
122
- if (e.key === "@") {
123
- selectPluginByKey();
158
+ const handleKeyDown = (event) => {
159
+ switch (event.key) {
160
+ case "@":
161
+ selectPluginByKey();
162
+ break;
163
+ case "ArrowUp":
164
+ event.preventDefault();
165
+ if (isComposing.value)
166
+ return;
167
+ changePlugin("up");
168
+ break;
169
+ case "ArrowDown":
170
+ event.preventDefault();
171
+ if (isComposing.value)
172
+ return;
173
+ changePlugin("down");
174
+ break;
175
+ case "ArrowRight":
176
+ if (isShowSelect.value) {
177
+ event.preventDefault();
178
+ }
179
+ break;
180
+ case "ArrowLeft":
181
+ if (isShowSelect.value) {
182
+ event.preventDefault();
183
+ }
184
+ break;
185
+ case "Backspace":
186
+ if (!isShowSelect.value) {
187
+ const beforeBackspaceText = coptInput.value.innerText.substring(
188
+ getCursorPosition() - 2,
189
+ getCursorPosition() - 1
190
+ );
191
+ if (beforeBackspaceText === "@") {
192
+ isShowSelect.value = true;
193
+ cursorPos = getCursorPosition() - 2;
194
+ }
195
+ } else {
196
+ const delectText = coptInput.value.innerText.substring(
197
+ getCursorPosition() - 1,
198
+ getCursorPosition()
199
+ );
200
+ if (delectText === "@") {
201
+ isShowSelect.value = false;
202
+ }
203
+ }
204
+ break;
124
205
  }
125
206
  };
126
- const closeSelection = () => {
127
- isShowSelect.value = false;
207
+ const activePluInd = ref(0);
208
+ const changePlugin = (direct) => {
209
+ if (direct === "up" && activePluInd.value === 0)
210
+ return;
211
+ if (direct === "down" && activePluInd.value === plugins.value.length - 1)
212
+ return;
213
+ activePluInd.value = direct === "up" ? activePluInd.value - 1 : activePluInd.value + 1;
128
214
  };
215
+ let cursorPos = 0;
129
216
  const selectPluginByKey = () => {
130
217
  isShowSelect.value = true;
131
- getCursorPosition();
218
+ cursorPos = getCursorPosition();
219
+ };
220
+ const getCursorPosition = () => {
221
+ const selection = window.getSelection();
222
+ const range = selection.getRangeAt(0);
223
+ return Number(range.startOffset.toString());
224
+ };
225
+ const moveCursorPosition = (position) => {
226
+ if (coptInput.value.firstChild) {
227
+ const range = document.createRange();
228
+ range.setStart(coptInput.value.firstChild, position);
229
+ range.setEnd(coptInput.value.firstChild, position);
230
+ const selection = window.getSelection();
231
+ selection.removeAllRanges();
232
+ selection.addRange(range);
233
+ coptInput.value.focus();
234
+ }
132
235
  };
133
236
  const initInput = () => {
134
237
  coptInput.value.innerText = "";
135
238
  setSearchText("");
136
239
  };
137
- let cursorPos = "";
138
240
  const deleteText = () => {
139
241
  const textArr = coptInput.value.innerText.split("");
140
- textArr.splice(parseInt(cursorPos) - 1, 1);
242
+ textArr.splice(cursorPos, cursorCurrentPos.value - cursorPos);
243
+ coptInput.value.innerText = textArr.join("");
141
244
  searchText.value = textArr.join("");
142
- };
143
- const getCursorPosition = () => {
144
- const selection = window.getSelection();
145
- const range = selection.getRangeAt(0);
146
- cursorPos = range.startOffset.toString();
245
+ moveCursorPosition(cursorPos);
147
246
  };
148
247
  const handleClickStopBtn = () => {
149
248
  cancelRequest();
@@ -156,27 +255,64 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
156
255
  });
157
256
  const buttonText = ref("选择插件");
158
257
  const isShowSelection = ref(false);
159
- const outsideClose = ref(false);
160
258
  watch(
161
- checkedPluginByBtn.value,
259
+ checkedPluginByBtn,
162
260
  (val) => {
163
- if (val.length) {
261
+ if (Object.keys(val).length) {
164
262
  buttonText.value = "已选插件";
165
263
  } else {
166
264
  buttonText.value = "选择插件";
167
265
  }
168
266
  },
169
267
  {
170
- immediate: true
268
+ immediate: true,
269
+ deep: true
171
270
  }
172
271
  );
173
- const selectPlugin = () => {
174
- isShowSelection.value = outsideClose.value ? false : true;
175
- outsideClose.value = false;
272
+ const pluginModal = ref("key");
273
+ watch(pluginModal, (newVal) => {
274
+ if (newVal === "btn") {
275
+ activePluInd.value = null;
276
+ } else {
277
+ if (!Object.keys(checkedPluginByBtn.value).length) {
278
+ activePluInd.value = 0;
279
+ } else {
280
+ activePluInd.value = plugins.value.indexOf(checkedPluginByBtn.value);
281
+ }
282
+ }
283
+ });
284
+ const openPluDialog = () => {
285
+ pluginModal.value = "btn";
286
+ isShowSelect.value = !isShowSelect.value;
287
+ if (!isShowSelect.value) {
288
+ pluginModal.value = "key";
289
+ }
176
290
  };
177
291
  const closePluginByoutside = () => {
178
- outsideClose.value = true;
179
- isShowSelection.value = false;
292
+ const timeId = setTimeout(() => {
293
+ isShowSelect.value = false;
294
+ clearTimeout(timeId);
295
+ }, 100);
296
+ };
297
+ const handlerSendMsg = (e) => {
298
+ if (e.key === "Enter") {
299
+ e.preventDefault();
300
+ }
301
+ if (isComposing.value)
302
+ return;
303
+ if (isShowSelect.value) {
304
+ setCheckedPluginList(selectPluginList.value[activePluInd.value]);
305
+ deleteText();
306
+ isShowSelect.value = false;
307
+ return;
308
+ }
309
+ const sendText = searchText.value;
310
+ if (!sendText)
311
+ return;
312
+ if (sendLonding.value)
313
+ return;
314
+ sendMsg(sendText);
315
+ initInput();
180
316
  };
181
317
  return (_ctx, _cache) => {
182
318
  const _component_IconifyIconOffline = resolveComponent("IconifyIconOffline");
@@ -186,19 +322,17 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
186
322
  ref: bottomFooter
187
323
  }, [
188
324
  createElementVNode("div", _hoisted_1, [
189
- createVNode(SelectPlugin, {
190
- isShowSelection: isShowSelection.value,
191
- outsideClose: outsideClose.value,
192
- onClosePluginByoutside: closePluginByoutside
193
- }, null, 8, ["isShowSelection", "outsideClose"]),
194
325
  createVNode(SelectPluginByKey, {
195
326
  isShowSelect: isShowSelect.value,
196
- onClose: closeSelection,
327
+ selectPluginList: selectPluginList.value,
328
+ activePluInd: activePluInd.value,
329
+ modal: pluginModal.value,
330
+ onClose: closePluginByoutside,
197
331
  onDeleteText: deleteText
198
- }, null, 8, ["isShowSelect"]),
332
+ }, null, 8, ["isShowSelect", "selectPluginList", "activePluInd", "modal"]),
199
333
  createElementVNode("button", {
200
334
  class: "control-button select-button",
201
- onClick: withModifiers(selectPlugin, ["stop"])
335
+ onClick: withModifiers(openPluDialog, ["stop"])
202
336
  }, [
203
337
  createElementVNode("span", null, toDisplayString(buttonText.value), 1),
204
338
  createElementVNode("div", {
@@ -213,8 +347,11 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
213
347
  }, _hoisted_7)) : createCommentVNode("", true)
214
348
  ]),
215
349
  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, [
350
+ Object.keys(unref(checkedPluginByBtn)).length !== 0 ? (openBlock(), createElementBlock("div", _hoisted_9, [
351
+ _hoisted_10,
352
+ createElementVNode("span", null, toDisplayString(unref(checkedPluginByBtn).name), 1)
353
+ ])) : createCommentVNode("", true),
354
+ createElementVNode("div", _hoisted_11, [
218
355
  createElementVNode("div", {
219
356
  ref_key: "coptInput",
220
357
  ref: coptInput,
@@ -222,20 +359,24 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
222
359
  contenteditable: "plaintext-only",
223
360
  placeholder: "有问题请尽管问我。。。",
224
361
  onInput: inputChange,
225
- onKeydown: withKeys(handlerSendMsg, ["enter"]),
226
- onKeyup: handleKeyDown,
362
+ onKeydown: [
363
+ withKeys(handlerSendMsg, ["enter"]),
364
+ handleKeyDown
365
+ ],
227
366
  onCompositionstart: handleCompositionStart,
228
367
  onCompositionend: handleCompositionEnd
229
- }, toDisplayString(unref(searchText)), 41, _hoisted_11),
368
+ }, toDisplayString(unref(searchText)), 41, _hoisted_12),
230
369
  createVNode(SpeechControl)
231
370
  ]),
232
- createElementVNode("div", _hoisted_12, [
233
- createElementVNode("div", _hoisted_13, [
371
+ createElementVNode("div", _hoisted_13, [
372
+ createElementVNode("div", _hoisted_14, [
234
373
  createVNode(Upload, { type: "pic" })
235
374
  ]),
236
- createElementVNode("div", _hoisted_14, [
237
- createElementVNode("span", _hoisted_15, [
238
- createElementVNode("span", null, toDisplayString(unref(textLength)), 1),
375
+ createElementVNode("div", _hoisted_15, [
376
+ createElementVNode("span", _hoisted_16, [
377
+ createElementVNode("span", {
378
+ style: normalizeStyle({ color: unref(textLength) >= 2e3 ? "red" : "#666666" })
379
+ }, toDisplayString(unref(textLength)), 5),
239
380
  createTextVNode("/2000")
240
381
  ]),
241
382
  createElementVNode("button", {
@@ -252,7 +393,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
252
393
  ])
253
394
  ])
254
395
  ]),
255
- unref(stopDialogue) ? (openBlock(), createElementBlock("div", _hoisted_16)) : createCommentVNode("", true)
396
+ unref(stopDialogue) ? (openBlock(), createElementBlock("div", _hoisted_17)) : createCommentVNode("", true)
256
397
  ])
257
398
  ], 512);
258
399
  };
@@ -1,4 +1,4 @@
1
- const index_vue_vue_type_style_index_0_scoped_027dba91_lang = "";
1
+ const index_vue_vue_type_style_index_0_scoped_665518fc_lang = "";
2
2
  export {
3
- index_vue_vue_type_style_index_0_scoped_027dba91_lang as default
3
+ index_vue_vue_type_style_index_0_scoped_665518fc_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-318d9fe4"]]);
5
5
  export {
6
6
  dialogue as default
7
7
  };