@@ -6,7 +6,6 @@ import { useTheme } from '../theme';
66import { useApiService , type Note } from '../services/api' ;
77import { generateEditorStyles } from '../screens/EditNote/styles' ;
88
9- const EDITOR_LOAD_DELAY = 500 ;
109const CSS_INJECTION_DELAY = 100 ;
1110
1211interface UseNoteEditorReturn {
@@ -27,29 +26,25 @@ export function useNoteEditor(noteId?: string): UseNoteEditorReturn {
2726 const editorReadyRef = useRef ( false ) ;
2827 const pendingContentRef = useRef < string | null > ( null ) ;
2928
30- // Initialize editor with TenTapStartKit
3129 const editor = useEditorBridge ( {
3230 autofocus : false ,
3331 avoidIosKeyboard : true ,
3432 initialContent : '<p></p>' ,
3533 bridgeExtensions : TenTapStartKit ,
3634 } ) ;
3735
38- // Generate custom CSS memoized on theme colors
3936 const customCSS = useMemo (
4037 ( ) => generateEditorStyles ( theme . colors ) ,
4138 [ theme . colors ]
4239 ) ;
4340
44- // Handler for when WebView loads - inject CSS at the right time
4541 const handleEditorLoad = useCallback ( ( ) => {
4642 editor . injectCSS ( customCSS , 'theme-css' ) ;
4743
48- // Also inject after a slight delay to ensure it overrides TenTap's default styles
44+ // Inject after delay to override TenTap's default styles
4945 setTimeout ( ( ) => {
5046 editor . injectCSS ( customCSS , 'theme-css' ) ;
5147
52- // Mark editor as ready and set pending content if any
5348 editorReadyRef . current = true ;
5449 if ( pendingContentRef . current !== null ) {
5550 if ( __DEV__ ) {
@@ -61,7 +56,6 @@ export function useNoteEditor(noteId?: string): UseNoteEditorReturn {
6156 } , CSS_INJECTION_DELAY ) ;
6257 } , [ editor , customCSS ] ) ;
6358
64- // Load note content if editing
6559 const loadNote = useCallback ( async ( ) => {
6660 if ( ! noteId ) return ;
6761
@@ -73,7 +67,6 @@ export function useNoteEditor(noteId?: string): UseNoteEditorReturn {
7367
7468 const content = note . content || '' ;
7569
76- // If editor is ready, set content immediately
7770 if ( editorReadyRef . current ) {
7871 setTimeout ( ( ) => {
7972 if ( __DEV__ ) {
@@ -82,7 +75,6 @@ export function useNoteEditor(noteId?: string): UseNoteEditorReturn {
8275 editor . setContent ( content ) ;
8376 } , 100 ) ;
8477 } else {
85- // Otherwise, store content to be set when editor is ready
8678 if ( __DEV__ ) {
8779 console . log ( 'Editor not ready yet, storing content...' ) ;
8880 }
0 commit comments