refactor: component props [no ci]
This commit is contained in:
@@ -3,13 +3,13 @@ import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext
|
|||||||
import { Platform } from '@standardnotes/snjs'
|
import { Platform } from '@standardnotes/snjs'
|
||||||
import { useEffect, useState } from 'react'
|
import { useEffect, useState } from 'react'
|
||||||
|
|
||||||
export default function AutoFocusPlugin({ isTemplateNote }: { isTemplateNote: boolean }) {
|
export default function AutoFocusPlugin({ isEnabled }: { isEnabled: boolean }) {
|
||||||
const application = useApplication()
|
const application = useApplication()
|
||||||
const [editor] = useLexicalComposerContext()
|
const [editor] = useLexicalComposerContext()
|
||||||
const [didInitialFocus, setDidInitialFocus] = useState(false)
|
const [didInitialFocus, setDidInitialFocus] = useState(false)
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!isTemplateNote) {
|
if (!isEnabled) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if (application.platform !== Platform.Ios) {
|
if (application.platform !== Platform.Ios) {
|
||||||
@@ -27,7 +27,7 @@ export default function AutoFocusPlugin({ isTemplateNote }: { isTemplateNote: bo
|
|||||||
rootElement.focus()
|
rootElement.focus()
|
||||||
setDidInitialFocus(true)
|
setDidInitialFocus(true)
|
||||||
})
|
})
|
||||||
}, [application.platform, didInitialFocus, editor, isTemplateNote])
|
}, [application.platform, didInitialFocus, editor, isEnabled])
|
||||||
|
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -242,7 +242,7 @@ export const SuperEditor: FunctionComponent<Props> = ({
|
|||||||
<NodeObserverPlugin nodeType={FileNode} onRemove={handleBubbleRemove} />
|
<NodeObserverPlugin nodeType={FileNode} onRemove={handleBubbleRemove} />
|
||||||
<ExportPlugin />
|
<ExportPlugin />
|
||||||
<ReadonlyPlugin note={note.current} />
|
<ReadonlyPlugin note={note.current} />
|
||||||
<AutoFocusPlugin isTemplateNote={controller.isTemplateNote} />
|
<AutoFocusPlugin isEnabled={controller.isTemplateNote} />
|
||||||
<SuperSearchContextProvider>
|
<SuperSearchContextProvider>
|
||||||
<SearchPlugin />
|
<SearchPlugin />
|
||||||
</SuperSearchContextProvider>
|
</SuperSearchContextProvider>
|
||||||
|
|||||||
Reference in New Issue
Block a user