chore: fix template super note editor icon
This commit is contained in:
@@ -7,13 +7,20 @@ import RoundIconButton from '../Button/RoundIconButton'
|
|||||||
import { getIconAndTintForNoteType } from '@/Utils/Items/Icons/getIconAndTintForNoteType'
|
import { getIconAndTintForNoteType } from '@/Utils/Items/Icons/getIconAndTintForNoteType'
|
||||||
import { CHANGE_EDITOR_COMMAND, keyboardStringForShortcut } from '@standardnotes/ui-services'
|
import { CHANGE_EDITOR_COMMAND, keyboardStringForShortcut } from '@standardnotes/ui-services'
|
||||||
import { useApplication } from '../ApplicationProvider'
|
import { useApplication } from '../ApplicationProvider'
|
||||||
|
import { NoteViewController } from '../NoteView/Controller/NoteViewController'
|
||||||
|
import { noteTypeForEditorIdentifier } from '@standardnotes/snjs'
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
viewControllerManager: ViewControllerManager
|
viewControllerManager: ViewControllerManager
|
||||||
|
noteViewController?: NoteViewController
|
||||||
onClickPreprocessing?: () => Promise<void>
|
onClickPreprocessing?: () => Promise<void>
|
||||||
}
|
}
|
||||||
|
|
||||||
const ChangeEditorButton: FunctionComponent<Props> = ({ viewControllerManager, onClickPreprocessing }: Props) => {
|
const ChangeEditorButton: FunctionComponent<Props> = ({
|
||||||
|
viewControllerManager,
|
||||||
|
noteViewController,
|
||||||
|
onClickPreprocessing,
|
||||||
|
}: Props) => {
|
||||||
const application = useApplication()
|
const application = useApplication()
|
||||||
|
|
||||||
const note = viewControllerManager.notesController.firstSelectedNote
|
const note = viewControllerManager.notesController.firstSelectedNote
|
||||||
@@ -23,10 +30,18 @@ const ChangeEditorButton: FunctionComponent<Props> = ({ viewControllerManager, o
|
|||||||
const [selectedEditor, setSelectedEditor] = useState(() => {
|
const [selectedEditor, setSelectedEditor] = useState(() => {
|
||||||
return note ? application.componentManager.editorForNote(note) : undefined
|
return note ? application.componentManager.editorForNote(note) : undefined
|
||||||
})
|
})
|
||||||
const [selectedEditorIcon, selectedEditorIconTint] = getIconAndTintForNoteType(
|
const noteType = noteViewController?.isTemplateNote
|
||||||
note?.noteType || selectedEditor?.package_info.note_type,
|
? noteTypeForEditorIdentifier(
|
||||||
true,
|
application.geDefaultEditorIdentifier(
|
||||||
)
|
noteViewController.templateNoteOptions?.tag
|
||||||
|
? application.items.findItem(noteViewController.templateNoteOptions.tag)
|
||||||
|
: undefined,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
: note
|
||||||
|
? note.noteType
|
||||||
|
: selectedEditor?.package_info.note_type
|
||||||
|
const [selectedEditorIcon, selectedEditorIconTint] = getIconAndTintForNoteType(noteType, true)
|
||||||
const [isClickOutsideDisabled, setIsClickOutsideDisabled] = useState(false)
|
const [isClickOutsideDisabled, setIsClickOutsideDisabled] = useState(false)
|
||||||
|
|
||||||
const toggleMenu = useCallback(async () => {
|
const toggleMenu = useCallback(async () => {
|
||||||
|
|||||||
@@ -860,6 +860,7 @@ class NoteView extends AbstractComponent<NoteViewProps, State> {
|
|||||||
/>
|
/>
|
||||||
<ChangeEditorButton
|
<ChangeEditorButton
|
||||||
viewControllerManager={this.viewControllerManager}
|
viewControllerManager={this.viewControllerManager}
|
||||||
|
noteViewController={this.controller}
|
||||||
onClickPreprocessing={this.ensureNoteIsInsertedBeforeUIAction}
|
onClickPreprocessing={this.ensureNoteIsInsertedBeforeUIAction}
|
||||||
/>
|
/>
|
||||||
<PinNoteButton
|
<PinNoteButton
|
||||||
|
|||||||
Reference in New Issue
Block a user