File tree Expand file tree Collapse file tree 1 file changed +9
-9
lines changed
packages/tiptap/src/editor Expand file tree Collapse file tree 1 file changed +9
-9
lines changed Original file line number Diff line number Diff line change @@ -93,17 +93,17 @@ const Editor = forwardRef<{ editor: TiptapEditor | null }, EditorProps>(
9393 const isAtStart = state . selection . $head . pos === 0 ;
9494
9595 const $head = state . selection . $head ;
96- const depth = $head . depth ;
9796 let isInFirstBlock = false ;
9897
99- for ( let d = depth ; d > 0 ; d -- ) {
100- const node = $head . node ( d ) ;
101- if ( node . type . name === "doc" ) continue ;
102- const parentNode = $head . node ( d - 1 ) ;
103- if ( parentNode . type . name === "doc" ) {
104- isInFirstBlock = parentNode . firstChild === node ;
105- break ;
106- }
98+ let node = state . doc . firstChild ;
99+ let firstTextBlockPos = 0 ;
100+ while ( node && ! node . isTextblock ) {
101+ firstTextBlockPos += 1 ;
102+ node = node . firstChild ;
103+ }
104+
105+ if ( node ) {
106+ isInFirstBlock = $head . start ( $head . depth ) === firstTextBlockPos + 1 ;
107107 }
108108
109109 if (
You can’t perform that action at this time.
0 commit comments