diff --git a/src/DragDropApp.tsx b/src/DragDropApp.tsx index 52ed3778..03e32239 100644 --- a/src/DragDropApp.tsx +++ b/src/DragDropApp.tsx @@ -94,12 +94,7 @@ export function DragDropApp({ win, plugin }: { win: Window; plugin: KanbanPlugin ); if (inDropArea) { - const parent = getEntityFromPath(stateManager.state, dropPath); - const shouldAppend = - (stateManager.getSetting('new-card-insertion-method') || 'append') === 'append'; - - if (shouldAppend) dropPath.push(parent.children.length); - else dropPath.push(0); + dropPath.push(0); } plugin.app.workspace.trigger( diff --git a/src/components/Item/ItemMenu.ts b/src/components/Item/ItemMenu.ts index 360d6776..027f8056 100644 --- a/src/components/Item/ItemMenu.ts +++ b/src/components/Item/ItemMenu.ts @@ -1,8 +1,8 @@ import { Menu, TFile, TFolder, getLinkpath } from 'obsidian'; -import Preact from 'preact/compat'; -import { Dispatch, StateUpdater } from 'preact/hooks'; +import { Dispatch, StateUpdater, useCallback } from 'preact/hooks'; import { StateManager } from 'src/StateManager'; import { Path } from 'src/dnd/types'; +import { moveEntity } from 'src/dnd/util/data'; import { t } from 'src/lang/helpers'; import { BoardModifiers } from '../../helpers/boardModifiers'; @@ -35,10 +35,10 @@ export function useItemMenu({ boardModifiers, stateManager, }: UseItemMenuParams) { - return Preact.useCallback( + return useCallback( (e: MouseEvent, internalLinkPath?: string) => { if (internalLinkPath) { - (app.workspace as any).onLinkContextMenu( + (stateManager.app.workspace as any).onLinkContextMenu( e, getLinkpath(internalLinkPath), stateManager.file.path @@ -296,6 +296,24 @@ export function useItemMenu({ } } + menu.addSeparator(); + + const lanes = stateManager.state.children; + for (let i = 0, len = lanes.length; i < len; i++) { + menu.addItem((item) => + item + .setIcon('lucide-square-kanban') + .setChecked(path[0] === i) + .setTitle(lanes[i].data.title) + .onClick(() => { + if (path[0] === i) return; + stateManager.setState((boardData) => { + return moveEntity(boardData, path, [i, 0]); + }); + }) + ); + } + menu.showAtPosition(coordinates); } },