@@ -85,7 +85,8 @@ const DocumentEditorPanel = ({
8585 // Resolve the comments Y.Map for this document
8686 const projectState = repository ?. getState ( ) ;
8787 const commentsMap = useMemo (
88- ( ) => ( projectState && config . features . comments ? config . getCommentsMap ( projectState ) : null ) ,
88+ ( ) =>
89+ projectState && config . features . comments ? config . getCommentsMap ( projectState ) : null ,
8990 // Re-derive only when projectState identity changes (Yjs doc swap on project change)
9091 // eslint-disable-next-line react-hooks/exhaustive-deps
9192 [ projectState ] ,
@@ -118,7 +119,9 @@ const DocumentEditorPanel = ({
118119 // Register the editor instance with the parent wrapper
119120 useEffect ( ( ) => {
120121 onEditorCreated ?.( editor ) ;
121- return ( ) => { onEditorCreated ?.( null ) ; } ;
122+ return ( ) => {
123+ onEditorCreated ?.( null ) ;
124+ } ;
122125 } , [ editor , onEditorCreated ] ) ;
123126
124127 // Ready state
@@ -158,7 +161,15 @@ const DocumentEditorPanel = ({
158161 editorElement . style . setProperty ( "--contd-label" , `"${ contdLabel } "` ) ;
159162 editorElement . style . setProperty ( "--more-label" , `"${ moreLabel } "` ) ;
160163
161- const elementKeys = [ "action" , "scene" , "character" , "dialogue" , "parenthetical" , "transition" , "section" ] as const ;
164+ const elementKeys = [
165+ "action" ,
166+ "scene" ,
167+ "character" ,
168+ "dialogue" ,
169+ "parenthetical" ,
170+ "transition" ,
171+ "section" ,
172+ ] as const ;
162173 for ( const key of elementKeys ) {
163174 const m = elementMargins [ key ] ?? DEFAULT_ELEMENT_MARGINS [ key ] ;
164175 // Element CSS vars = page margin + element offset (total from page edge)
@@ -170,8 +181,14 @@ const DocumentEditorPanel = ({
170181 editorElement . style . setProperty ( `--${ key } -align` , s . align ?? "left" ) ;
171182 editorElement . style . setProperty ( `--${ key } -weight` , s . bold ? "bold" : "normal" ) ;
172183 editorElement . style . setProperty ( `--${ key } -style` , s . italic ? "italic" : "normal" ) ;
173- editorElement . style . setProperty ( `--${ key } -decoration` , s . underline ? "underline" : "none" ) ;
174- editorElement . style . setProperty ( `--${ key } -transform` , s . uppercase ? "uppercase" : "none" ) ;
184+ editorElement . style . setProperty (
185+ `--${ key } -decoration` ,
186+ s . underline ? "underline" : "none" ,
187+ ) ;
188+ editorElement . style . setProperty (
189+ `--${ key } -transform` ,
190+ s . uppercase ? "uppercase" : "none" ,
191+ ) ;
175192 }
176193
177194 // Compute startNewPage types from element styles
@@ -197,13 +214,25 @@ const DocumentEditorPanel = ({
197214 right : pageMargins . right * 96 ,
198215 } )
199216 . run ( ) ;
200-
201217 }
202218
203219 if ( isVisible ) {
204220 editor . commands . focus ( ) ;
205221 }
206- } , [ editor , isVisible , config . type , pageFormat , pageMargins , displaySceneNumbers , sceneHeadingSpacing , sceneNumberOnRight , contdLabel , moreLabel , elementMargins , elementStyles ] ) ;
222+ } , [
223+ editor ,
224+ isVisible ,
225+ config . type ,
226+ pageFormat ,
227+ pageMargins ,
228+ displaySceneNumbers ,
229+ sceneHeadingSpacing ,
230+ sceneNumberOnRight ,
231+ contdLabel ,
232+ moreLabel ,
233+ elementMargins ,
234+ elementStyles ,
235+ ] ) ;
207236
208237 // ---- Pagination update (title page only) ----
209238 useEffect ( ( ) => {
@@ -228,9 +257,15 @@ const DocumentEditorPanel = ({
228257 const updateContextMenuRef = useRef ( updateContextMenu ) ;
229258 const updateSuggestionsRef = useRef ( updateSuggestions ) ;
230259
231- useEffect ( ( ) => { selectedElementRef . current = selectedElement ; } , [ selectedElement ] ) ;
232- useEffect ( ( ) => { updateContextMenuRef . current = updateContextMenu ; } , [ updateContextMenu ] ) ;
233- useEffect ( ( ) => { updateSuggestionsRef . current = updateSuggestions ; } , [ updateSuggestions ] ) ;
260+ useEffect ( ( ) => {
261+ selectedElementRef . current = selectedElement ;
262+ } , [ selectedElement ] ) ;
263+ useEffect ( ( ) => {
264+ updateContextMenuRef . current = updateContextMenu ;
265+ } , [ updateContextMenu ] ) ;
266+ useEffect ( ( ) => {
267+ updateSuggestionsRef . current = updateSuggestions ;
268+ } , [ updateSuggestions ] ) ;
234269
235270 const setActiveElement = useCallback (
236271 ( element : ScreenplayElement , applyStyle = true ) => {
@@ -241,7 +276,9 @@ const DocumentEditorPanel = ({
241276 ) ;
242277
243278 const setActiveElementRef = useRef ( setActiveElement ) ;
244- useEffect ( ( ) => { setActiveElementRef . current = setActiveElement ; } , [ setActiveElement ] ) ;
279+ useEffect ( ( ) => {
280+ setActiveElementRef . current = setActiveElement ;
281+ } , [ setActiveElement ] ) ;
245282
246283 useEffect ( ( ) => {
247284 if ( ! editor || config . type !== "screenplay" ) return ;
@@ -258,7 +295,8 @@ const DocumentEditorPanel = ({
258295 if ( event . key === "Backspace" ) {
259296 // Inside a dual_dialogue_column: let the column node handle it.
260297 for ( let d = selection . $anchor . depth ; d >= 1 ; d -- ) {
261- if ( selection . $anchor . node ( d ) . type . name === DUAL_DIALOGUE_COLUMN ) return false ;
298+ if ( selection . $anchor . node ( d ) . type . name === DUAL_DIALOGUE_COLUMN )
299+ return false ;
262300 }
263301 if ( nodeSize === 1 && nodePos === 1 ) {
264302 const tr = view . state . tr . delete ( selection . from - 1 , selection . from ) ;
@@ -269,7 +307,10 @@ const DocumentEditorPanel = ({
269307 }
270308
271309 if ( event . code === "Space" ) {
272- if ( currNode === ScreenplayElement . Action && node . textContent . match ( / ^ \b ( i n t | e x t ) \. / gi) ) {
310+ if (
311+ currNode === ScreenplayElement . Action &&
312+ node . textContent . match ( / ^ \b ( i n t | e x t ) \. / gi)
313+ ) {
273314 setActiveElementRef . current ( ScreenplayElement . Scene ) ;
274315 }
275316 return false ;
@@ -290,7 +331,11 @@ const DocumentEditorPanel = ({
290331 if ( $anchor . node ( d ) . type . name === DUAL_DIALOGUE_COLUMN ) return false ;
291332 }
292333
293- if ( currNode === ScreenplayElement . Dialogue && nodePos > 0 && nodePos < nodeSize ) {
334+ if (
335+ currNode === ScreenplayElement . Dialogue &&
336+ nodePos > 0 &&
337+ nodePos < nodeSize
338+ ) {
294339 const doc = view . state . doc ;
295340 const $anchor = selection . $anchor ;
296341
@@ -302,7 +347,11 @@ const DocumentEditorPanel = ({
302347 charName = child . textContent ;
303348 break ;
304349 }
305- if ( child . attrs . class !== ScreenplayElement . Parenthetical && child . attrs . class !== ScreenplayElement . Dialogue ) break ;
350+ if (
351+ child . attrs . class !== ScreenplayElement . Parenthetical &&
352+ child . attrs . class !== ScreenplayElement . Dialogue
353+ )
354+ break ;
306355 }
307356
308357 const schema = view . state . schema ;
@@ -321,7 +370,9 @@ const DocumentEditorPanel = ({
321370 tr . delete ( $anchor . pos , $anchor . end ( 1 ) ) ;
322371 const insertPos = tr . mapping . map ( $anchor . after ( 1 ) ) ;
323372 tr . insert ( insertPos , [ charNode , newDialogue ] ) ;
324- tr . setSelection ( TextSelection . create ( tr . doc , insertPos + charNode . nodeSize + 1 ) ) ;
373+ tr . setSelection (
374+ TextSelection . create ( tr . doc , insertPos + charNode . nodeSize + 1 ) ,
375+ ) ;
325376 tr . scrollIntoView ( ) ;
326377 view . dispatch ( tr ) ;
327378 return true ;
@@ -390,7 +441,7 @@ const DocumentEditorPanel = ({
390441
391442 addEventListener ( "keydown" , pressedKeyEvent ) ;
392443 return ( ) => removeEventListener ( "keydown" , pressedKeyEvent ) ;
393- } , [ isVisible , config . type ] ) ;
444+ } , [ isVisible , config . type , editor ] ) ;
394445
395446 // ---- Context menu ----
396447 const onEditorContextMenu = useCallback (
@@ -464,7 +515,8 @@ const DocumentEditorPanel = ({
464515 setIsScrolled ( scrollTop > 0 ) ;
465516 } ;
466517
467- const focusType = focusedTypeOverride ?? ( config . type === "screenplay" ? "screenplay" : "title" ) ;
518+ const focusType =
519+ focusedTypeOverride ?? ( config . type === "screenplay" ? "screenplay" : "title" ) ;
468520
469521 const isLocalAccess = isTauri ( ) || isLocalOnly ;
470522 if ( ! isLocalAccess && ( ! membership || isLoading ) ) return < Loading /> ;
@@ -477,8 +529,12 @@ const DocumentEditorPanel = ({
477529 onMouseDown = { handleContainerMouseDown }
478530 onFocus = { ( ) => setFocusedEditorType ( focusType ) }
479531 >
480- < div className = { `${ styles . editor_wrapper } ${ isEndlessScroll ? styles . endless_scroll : "" } ` } >
481- < div className = { join ( styles . editor_shadow , isScrolled ? styles . show_shadow : "" ) } />
532+ < div
533+ className = { `${ styles . editor_wrapper } ${ isEndlessScroll ? styles . endless_scroll : "" } ` }
534+ >
535+ < div
536+ className = { join ( styles . editor_shadow , isScrolled ? styles . show_shadow : "" ) }
537+ />
482538 < div onContextMenu = { onEditorContextMenu } >
483539 < EditorContent editor = { editor } spellCheck = { false } />
484540 </ div >
0 commit comments