feat(editor): Overhaul node insert position computation in new canvas (no-changelog) (#10637)

This commit is contained in:
Alex Grozav
2024-09-03 15:11:44 +03:00
committed by GitHub
parent e5aba60aff
commit 32ce65c1af
15 changed files with 805 additions and 483 deletions

View File

@@ -23,7 +23,7 @@ const LazyNodeCreator = defineAsyncComponent(
);
const props = withDefaults(defineProps<Props>(), {
createNodeActive: false,
createNodeActive: false, // Determines if the node creator is open
});
const emit = defineEmits<{
@@ -88,13 +88,15 @@ function addStickyNote() {
emit('addNodes', getAddedNodesAndConnections([{ type: STICKY_NODE_TYPE, position }]));
}
function closeNodeCreator() {
emit('toggleNodeCreator', { createNodeActive: false });
function closeNodeCreator(hasAddedNodes = false) {
if (props.createNodeActive) {
emit('toggleNodeCreator', { createNodeActive: false, hasAddedNodes });
}
}
function nodeTypeSelected(nodeTypes: string[]) {
emit('addNodes', getAddedNodesAndConnections(nodeTypes.map((type) => ({ type }))));
closeNodeCreator();
closeNodeCreator(true);
}
</script>