Skip to content

Commit

Permalink
fix: delete cursor error
Browse files Browse the repository at this point in the history
  • Loading branch information
vincentdchan committed Dec 6, 2023
1 parent ee7a63f commit 7ed2e96
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
17 changes: 14 additions & 3 deletions packages/blocky-core/src/view/controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -410,14 +410,25 @@ export class EditorController {
if (!blockNode) {
return;
}
const { nextSibling, prevSibling } = blockNode;

if (!isUpperCase(blockNode.t)) {
return;
}

new Changeset(this.state).removeNode(blockNode).apply({
refreshCursor: true,
});
let nextCusorState: CursorState | null = null;
if (nextSibling instanceof BlockDataElement) {
nextCusorState = CursorState.collapse(nextSibling.id, 0);
} else if (prevSibling instanceof BlockDataElement) {
nextCusorState = CursorState.collapse(prevSibling.id, 0);
}

new Changeset(this.state)
.removeNode(blockNode)
.setCursorState(nextCusorState)
.apply({
refreshCursor: true,
});
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,9 +139,10 @@ function DefaultSpannerMenu(props: SpannerProps) {
const renderMenu = () => {
return (
<Menu>
{commands.map((command) => {
{commands.map((command, index) => {
return (
<MenuItem
key={`${index}`}
icon={command.icon}
onClick={() => {
if (!isUndefined(command.insertText)) {
Expand Down

0 comments on commit 7ed2e96

Please sign in to comment.