fixes: copy/paste

This commit is contained in:
arpitnath 2023-08-09 19:32:38 +05:30
parent 9770df8b3f
commit 537c423e06
2 changed files with 8 additions and 6 deletions

View file

@ -10,6 +10,7 @@ export const EditorKeyHooks = ({
removeMultipleComponents,
}) => {
const handleHotKeysCallback = (key) => {
console.log('---arpit-- hotkeys', { key });
switch (key) {
case 'Escape':
handleEditorEscapeKeyPress();
@ -18,6 +19,7 @@ export const EditorKeyHooks = ({
removeMultipleComponents();
break;
case 'KeyD':
console.log('---arpit-- paste component');
cloneComponents();
break;
case 'KeyC':

View file

@ -575,7 +575,7 @@ function executeActionWithDebounce(_ref, event, mode, customVariables) {
}
case 'switch-page': {
_ref.switchPage(event.pageId, resolveReferences(event.queryParams, getCurrentState(), [], customVariables)); // arpit [switchPage]
_ref.switchPage(event.pageId, resolveReferences(event.queryParams, getCurrentState(), [], customVariables));
return Promise.resolve();
}
}
@ -601,7 +601,7 @@ export async function onEvent(_ref, eventName, options, mode = 'edit') {
},
},
});
runQuery(_ref, queryId, queryName, true, mode, parameters); //arpit [runQuery]
runQuery(_ref, queryId, queryName, true, mode, parameters);
}
if (eventName === 'onCalendarEventSelect') {
@ -1314,7 +1314,8 @@ const updateNewComponents = (pageId, appDefinition, newComponents, updateAppDefi
);
newAppDefinition.pages[pageId].components[newComponent.id] = newComponent;
});
updateAppDefinition(newAppDefinition, { addComponents: true });
updateAppDefinition(newAppDefinition, { componentDefinitionChanged: true });
};
export const cloneComponents = (
@ -1352,13 +1353,13 @@ export const cloneComponents = (
isCut,
};
}
if (isCloning) {
addComponents(currentPageId, appDefinition, updateAppDefinition, undefined, newComponentObj);
toast.success('Component cloned succesfully');
} else if (isCut) {
navigator.clipboard.writeText(JSON.stringify(newComponentObj));
removeSelectedComponent(currentPageId, newDefinition, selectedComponents);
updateAppDefinition(newDefinition);
removeSelectedComponent(currentPageId, newDefinition, selectedComponents, updateAppDefinition);
} else {
navigator.clipboard.writeText(JSON.stringify(newComponentObj));
toast.success('Component copied succesfully');
@ -1430,7 +1431,6 @@ const updateComponentLayout = (components, parentId, isCut = false) => {
};
export const addComponents = (pageId, appDefinition, appDefinitionChanged, parentId = undefined, newComponentObj) => {
console.log({ pageId, newComponentObj });
const finalComponents = [];
let parentComponent = undefined;
const { isCloning, isCut, newComponents: pastedComponent = [] } = newComponentObj;