Skip to content

Commit

Permalink
fix: block position when dragged into the editor (AutomaApp#1401)
Browse files Browse the repository at this point in the history
  • Loading branch information
Kholid060 committed Oct 27, 2023
1 parent 109e9a4 commit 6972e06
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/newtab/pages/workflows/[id].vue
Original file line number Diff line number Diff line change
Expand Up @@ -1239,12 +1239,15 @@ function onDragoverEditor({ target }) {
}
function onDropInEditor({ dataTransfer, clientX, clientY, target }) {
const savedBlocks = parseJSON(dataTransfer.getData('savedBlocks'), null);
const editorRect = editor.value.viewportRef.value.getBoundingClientRect();
const position = editor.value.project({
y: clientY - editorRect.top,
x: clientX - editorRect.left,
});
if (savedBlocks && !isPackage) {
if (savedBlocks.settings.asBlock) {
const position = editor.value.project({
x: clientX - 360,
y: clientY - 18,
});
editor.value.addNodes([
{
position,
Expand Down Expand Up @@ -1285,7 +1288,6 @@ function onDropInEditor({ dataTransfer, clientX, clientY, target }) {
return;
}
const position = editor.value.project({ x: clientX - 360, y: clientY - 18 });
const nodeId = nanoid();
const newNode = {
position,
Expand Down

0 comments on commit 6972e06

Please sign in to comment.