Merge pull request #12253 from ToolJet/fix/copy-text

Fixed bug causing component definition to be copied on copying text
This commit is contained in:
Johnson Cherian 2025-03-21 12:38:09 +05:30 committed by GitHub
commit fcfe5281a8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -248,6 +248,12 @@ const getSelectedText = () => {
// TODO: Move this function to componentSlice
export const copyComponents = ({ isCut = false, isCloning = false }) => {
const selectedText = window.getSelection()?.toString().trim();
if (selectedText) {
navigator.clipboard.writeText(selectedText);
return;
}
const selectedComponents = useStore.getState().getSelectedComponentsDefinition();
if (selectedComponents.length < 1) return getSelectedText();
const allComponents = useStore.getState().getCurrentPageComponents();