Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions packages/core/src/api/blockManipulation/selections/selection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,18 @@ export function getSelection<
): Selection<BSchema, I, S> | undefined {
const state = editor._tiptapEditor.state;

// Return undefined if the selection is collapsed or a node is selected.
if (state.selection.empty || "node" in state.selection) {
return undefined;
}

const $startBlockBeforePos = state.doc.resolve(
getNearestBlockPos(state.doc, state.selection.from).posBeforeNode
);
const $endBlockBeforePos = state.doc.resolve(
getNearestBlockPos(state.doc, state.selection.to).posBeforeNode
);

// Return undefined if anchor and head are in the same block.
if ($startBlockBeforePos.pos === $endBlockBeforePos.pos) {
return undefined;
}

// Converts the node at the given index and depth around `$startBlockBeforePos`
// to a block. Used to get blocks at given indices at the shared depth and
// at the depth of `$startBlockBeforePos`.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,12 @@ export const CreateLinkButton = () => {
}
};

editor.prosemirrorView.dom.addEventListener("keydown", callback);
editor.prosemirrorView?.dom.addEventListener("keydown", callback);

return () => {
editor.prosemirrorView.dom.removeEventListener("keydown", callback);
editor.prosemirrorView?.dom.removeEventListener("keydown", callback);
};
}, [editor.prosemirrorView.dom]);
}, [editor.prosemirrorView?.dom]);

const update = useCallback(
(url: string, text: string) => {
Expand Down
Loading