Skip to content

Commit

Permalink
fix: Inline code selection inside custom views
Browse files Browse the repository at this point in the history
  • Loading branch information
areknawo committed May 24, 2024
1 parent 4fe1cef commit 2eb22bc
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion apps/web/src/lib/editor/extensions/element/node.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,12 @@ const Element = BaseElement.extend<
appendTransaction(_, oldState, newState) {
const { customElements } = storage;

if (oldState.selection.eq(newState.selection)) return;
if (
oldState.selection.eq(newState.selection) ||
newState.selection instanceof TextSelection
) {
return;
}

const insideCustomView = (() => {
const { selection } = newState;
Expand Down Expand Up @@ -302,6 +307,7 @@ const Element = BaseElement.extend<

return null;
};
const originalSelection = newState.selection;

let selection = newState.selection as Selection | null;
let i = 0;
Expand All @@ -321,6 +327,8 @@ const Element = BaseElement.extend<
}

if (selection) {
if (selection === originalSelection) return;

return newState.tr.setSelection(selection).scrollIntoView();
} else {
return newState.tr.scrollIntoView();
Expand Down

0 comments on commit 2eb22bc

Please sign in to comment.