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<
23
23
) : Selection < BSchema , I , S > | undefined {
24
24
const state = editor . _tiptapEditor . state ;
25
25
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
+
26
31
const $startBlockBeforePos = state . doc . resolve (
27
32
getNearestBlockPos ( state . doc , state . selection . from ) . posBeforeNode
28
33
) ;
29
34
const $endBlockBeforePos = state . doc . resolve (
30
35
getNearestBlockPos ( state . doc , state . selection . to ) . posBeforeNode
31
36
) ;
32
37
33
- // Return undefined if anchor and head are in the same block.
34
- if ( $startBlockBeforePos . pos === $endBlockBeforePos . pos ) {
35
- return undefined ;
36
- }
37
-
38
38
// Converts the node at the given index and depth around `$startBlockBeforePos`
39
39
// to a block. Used to get blocks at given indices at the shared depth and
40
40
// at the depth of `$startBlockBeforePos`.
Original file line number Diff line number Diff line change @@ -66,12 +66,12 @@ export const CreateLinkButton = () => {
66
66
}
67
67
} ;
68
68
69
- editor . prosemirrorView . dom . addEventListener ( "keydown" , callback ) ;
69
+ editor . prosemirrorView ? .dom . addEventListener ( "keydown" , callback ) ;
70
70
71
71
return ( ) => {
72
- editor . prosemirrorView . dom . removeEventListener ( "keydown" , callback ) ;
72
+ editor . prosemirrorView ? .dom . removeEventListener ( "keydown" , callback ) ;
73
73
} ;
74
- } , [ editor . prosemirrorView . dom ] ) ;
74
+ } , [ editor . prosemirrorView ? .dom ] ) ;
75
75
76
76
const update = useCallback (
77
77
( url : string , text : string ) => {
You can’t perform that action at this time.
0 commit comments