@copilotkit/react-textarea 1.53.1-next.0 → 1.53.1-next.2
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/CHANGELOG.md +17 -0
- package/dist/index.cjs +22 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +22 -0
- package/dist/index.mjs.map +1 -1
- package/dist/index.umd.js +22 -0
- package/dist/index.umd.js.map +1 -1
- package/package.json +4 -4
- package/src/components/hovering-toolbar/hovering-toolbar.tsx +31 -1
- package/src/components/hovering-toolbar/text-insertion-prompt-box/hovering-insertion-prompt-box-core.tsx +3 -0
package/dist/index.mjs
CHANGED
|
@@ -862,6 +862,9 @@ const HoveringInsertionPromptBoxCore = ({ performInsertion, state, insertionOrEd
|
|
|
862
862
|
} else if (e.key === "Enter") {
|
|
863
863
|
e.preventDefault();
|
|
864
864
|
beginGeneratingAdjustment();
|
|
865
|
+
} else if (e.key === "Escape") {
|
|
866
|
+
e.preventDefault();
|
|
867
|
+
setIsDisplayed(false);
|
|
865
868
|
}
|
|
866
869
|
},
|
|
867
870
|
placeholder,
|
|
@@ -1008,6 +1011,25 @@ const HoveringToolbar = (props) => {
|
|
|
1008
1011
|
document.removeEventListener("mousedown", handleClickOutside);
|
|
1009
1012
|
};
|
|
1010
1013
|
}, [ref, setIsDisplayed]);
|
|
1014
|
+
useEffect(() => {
|
|
1015
|
+
const handleEscapeKey = (event) => {
|
|
1016
|
+
if (event.key === "Escape") {
|
|
1017
|
+
event.preventDefault();
|
|
1018
|
+
setIsDisplayed(false);
|
|
1019
|
+
try {
|
|
1020
|
+
ReactEditor.focus(editor);
|
|
1021
|
+
} catch {}
|
|
1022
|
+
}
|
|
1023
|
+
};
|
|
1024
|
+
if (isDisplayed) document.addEventListener("keydown", handleEscapeKey);
|
|
1025
|
+
return () => {
|
|
1026
|
+
document.removeEventListener("keydown", handleEscapeKey);
|
|
1027
|
+
};
|
|
1028
|
+
}, [
|
|
1029
|
+
isDisplayed,
|
|
1030
|
+
setIsDisplayed,
|
|
1031
|
+
editor
|
|
1032
|
+
]);
|
|
1011
1033
|
if (!isShown) return null;
|
|
1012
1034
|
return /* @__PURE__ */ jsx(Portal, { children: /* @__PURE__ */ jsx(Menu, {
|
|
1013
1035
|
ref,
|