fix: Fixed issue where autocapitalization wouldn't work on iOS for newly created Super notes
This commit is contained in:
@@ -130,12 +130,6 @@ export const PlainEditor = forwardRef<PlainEditorInterface, Props>(
|
||||
}
|
||||
}, [])
|
||||
|
||||
useEffect(() => {
|
||||
if (controller.isTemplateNote && controller.templateNoteOptions?.autofocusBehavior === 'editor') {
|
||||
focusEditor()
|
||||
}
|
||||
}, [controller, focusEditor])
|
||||
|
||||
useEffect(() => {
|
||||
const shouldFocus = controller.isTemplateNote && controller.templateNoteOptions?.autofocusBehavior === 'editor'
|
||||
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
import { useApplication } from '@/Components/ApplicationProvider'
|
||||
import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext'
|
||||
import { Platform } from '@standardnotes/snjs'
|
||||
import { useEffect, useState } from 'react'
|
||||
|
||||
export default function AutoFocusPlugin({ isTemplateNote }: { isTemplateNote: boolean }) {
|
||||
const application = useApplication()
|
||||
const [editor] = useLexicalComposerContext()
|
||||
const [didInitialFocus, setDidInitialFocus] = useState(false)
|
||||
|
||||
useEffect(() => {
|
||||
if (!isTemplateNote) {
|
||||
return
|
||||
}
|
||||
if (application.platform !== Platform.Ios) {
|
||||
editor.focus()
|
||||
return
|
||||
}
|
||||
return editor.registerUpdateListener(() => {
|
||||
if (didInitialFocus) {
|
||||
return
|
||||
}
|
||||
const rootElement = editor.getRootElement()
|
||||
if (!rootElement) {
|
||||
return
|
||||
}
|
||||
rootElement.focus()
|
||||
setDidInitialFocus(true)
|
||||
})
|
||||
}, [application.platform, didInitialFocus, editor, isTemplateNote])
|
||||
|
||||
return null
|
||||
}
|
||||
@@ -39,7 +39,6 @@ import { SUPER_SHOW_MARKDOWN_PREVIEW } from '@standardnotes/ui-services'
|
||||
import { SuperNoteMarkdownPreview } from './SuperNoteMarkdownPreview'
|
||||
import { ExportPlugin } from './Plugins/ExportPlugin/ExportPlugin'
|
||||
import GetMarkdownPlugin, { GetMarkdownPluginInterface } from './Plugins/GetMarkdownPlugin/GetMarkdownPlugin'
|
||||
import { AutoFocusPlugin } from '@lexical/react/LexicalAutoFocusPlugin'
|
||||
import { getPlaintextFontSize } from '@/Utils/getPlaintextFontSize'
|
||||
import ReadonlyPlugin from './Plugins/ReadonlyPlugin/ReadonlyPlugin'
|
||||
import { SuperSearchContextProvider } from './Plugins/SearchPlugin/Context'
|
||||
@@ -49,6 +48,7 @@ import MobileToolbarPlugin from './Plugins/MobileToolbarPlugin/MobileToolbarPlug
|
||||
import CodeOptionsPlugin from './Plugins/CodeOptionsPlugin/CodeOptions'
|
||||
import RemoteImagePlugin from './Plugins/RemoteImagePlugin/RemoteImagePlugin'
|
||||
import NotEntitledBanner from '../ComponentView/NotEntitledBanner'
|
||||
import AutoFocusPlugin from './Plugins/AutoFocusPlugin'
|
||||
|
||||
export const SuperNotePreviewCharLimit = 160
|
||||
|
||||
@@ -242,7 +242,7 @@ export const SuperEditor: FunctionComponent<Props> = ({
|
||||
<NodeObserverPlugin nodeType={FileNode} onRemove={handleBubbleRemove} />
|
||||
<ExportPlugin />
|
||||
<ReadonlyPlugin note={note.current} />
|
||||
{controller.isTemplateNote ? <AutoFocusPlugin /> : null}
|
||||
<AutoFocusPlugin isTemplateNote={controller.isTemplateNote} />
|
||||
<SuperSearchContextProvider>
|
||||
<SearchPlugin />
|
||||
</SuperSearchContextProvider>
|
||||
|
||||
Reference in New Issue
Block a user