File tree Expand file tree Collapse file tree 2 files changed +8
-8
lines changed
core/src/api/blockManipulation/selections
react/src/components/FormattingToolbar/DefaultButtons Expand file tree Collapse file tree 2 files changed +8
-8
lines changed Original file line number Diff line number Diff line change @@ -23,18 +23,18 @@ export function getSelection<
2323) : Selection < BSchema , I , S > | undefined {
2424 const state = editor . _tiptapEditor . state ;
2525
26+ // Return undefined if the selection is collapsed or a node is selected.
27+ if ( state . selection . empty || "node" in state . selection ) {
28+ return undefined ;
29+ }
30+
2631 const $startBlockBeforePos = state . doc . resolve (
2732 getNearestBlockPos ( state . doc , state . selection . from ) . posBeforeNode
2833 ) ;
2934 const $endBlockBeforePos = state . doc . resolve (
3035 getNearestBlockPos ( state . doc , state . selection . to ) . posBeforeNode
3136 ) ;
3237
33- // Return undefined if anchor and head are in the same block.
34- if ( $startBlockBeforePos . pos === $endBlockBeforePos . pos ) {
35- return undefined ;
36- }
37-
3838 // Converts the node at the given index and depth around `$startBlockBeforePos`
3939 // to a block. Used to get blocks at given indices at the shared depth and
4040 // at the depth of `$startBlockBeforePos`.
Original file line number Diff line number Diff line change @@ -66,12 +66,12 @@ export const CreateLinkButton = () => {
6666 }
6767 } ;
6868
69- editor . prosemirrorView . dom . addEventListener ( "keydown" , callback ) ;
69+ editor . prosemirrorView ? .dom . addEventListener ( "keydown" , callback ) ;
7070
7171 return ( ) => {
72- editor . prosemirrorView . dom . removeEventListener ( "keydown" , callback ) ;
72+ editor . prosemirrorView ? .dom . removeEventListener ( "keydown" , callback ) ;
7373 } ;
74- } , [ editor . prosemirrorView . dom ] ) ;
74+ } , [ editor . prosemirrorView ? .dom ] ) ;
7575
7676 const update = useCallback (
7777 ( url : string , text : string ) => {
You can’t perform that action at this time.
0 commit comments