mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 18:12:04 +00:00
fix(editor): Fix sticky duplication and position bug (#3755)
* fix bug when inserting sticky * center sticky on insert * export as const
This commit is contained in:
@@ -72,7 +72,7 @@
|
||||
/>
|
||||
<div
|
||||
:class="['add-sticky-button', showStickyButton ? 'visible-button' : '']"
|
||||
@click="nodeTypeSelected(STICKY_NODE_TYPE)"
|
||||
@click="addStickyNote"
|
||||
>
|
||||
<n8n-icon-button
|
||||
size="medium"
|
||||
@@ -154,7 +154,7 @@ import {
|
||||
} from 'jsplumb';
|
||||
import { MessageBoxInputData } from 'element-ui/types/message-box';
|
||||
import { jsPlumb, OnConnectionBindInfo } from 'jsplumb';
|
||||
import { MODAL_CANCEL, MODAL_CLOSE, MODAL_CONFIRMED, NODE_NAME_PREFIX, NODE_OUTPUT_DEFAULT_KEY, PLACEHOLDER_EMPTY_WORKFLOW_ID, QUICKSTART_NOTE_NAME, START_NODE_TYPE, STICKY_NODE_TYPE, VIEWS, WEBHOOK_NODE_TYPE, WORKFLOW_OPEN_MODAL_KEY } from '@/constants';
|
||||
import { DEFAULT_STICKY_HEIGHT, DEFAULT_STICKY_WIDTH, MODAL_CANCEL, MODAL_CLOSE, MODAL_CONFIRMED, NODE_NAME_PREFIX, NODE_OUTPUT_DEFAULT_KEY, PLACEHOLDER_EMPTY_WORKFLOW_ID, QUICKSTART_NOTE_NAME, START_NODE_TYPE, STICKY_NODE_TYPE, VIEWS, WEBHOOK_NODE_TYPE, WORKFLOW_OPEN_MODAL_KEY } from '@/constants';
|
||||
import { copyPaste } from '@/components/mixins/copyPaste';
|
||||
import { externalHooks } from '@/components/mixins/externalHooks';
|
||||
import { genericHelpers } from '@/components/mixins/genericHelpers';
|
||||
@@ -227,6 +227,7 @@ interface AddNodeOptions {
|
||||
dragAndDrop?: boolean;
|
||||
}
|
||||
|
||||
|
||||
export default mixins(
|
||||
copyPaste,
|
||||
externalHooks,
|
||||
@@ -1371,6 +1372,22 @@ export default mixins(
|
||||
this.createNodeActive = false;
|
||||
},
|
||||
|
||||
addStickyNote() {
|
||||
if (document.activeElement) {
|
||||
(document.activeElement as HTMLElement).blur();
|
||||
}
|
||||
|
||||
const offset: [number, number] = [...(this.$store.getters.getNodeViewOffsetPosition as [number, number])];
|
||||
|
||||
const position = CanvasHelpers.getMidCanvasPosition(this.nodeViewScale, offset);
|
||||
position[0] -= DEFAULT_STICKY_WIDTH / 2;
|
||||
position[1] -= DEFAULT_STICKY_HEIGHT / 2;
|
||||
|
||||
this.addNodeButton(STICKY_NODE_TYPE, {
|
||||
position,
|
||||
});
|
||||
},
|
||||
|
||||
nodeTypeSelected (nodeTypeName: string) {
|
||||
this.addNodeButton(nodeTypeName);
|
||||
this.createNodeActive = false;
|
||||
|
||||
Reference in New Issue
Block a user