diff --git a/app/assets/javascripts/components/NoteView/NoteView.tsx b/app/assets/javascripts/components/NoteView/NoteView.tsx index 703077b1e7b..b0682b9ed93 100644 --- a/app/assets/javascripts/components/NoteView/NoteView.tsx +++ b/app/assets/javascripts/components/NoteView/NoteView.tsx @@ -963,6 +963,12 @@ export class NoteView extends PureComponent { observer.observe(editor.parentElement as HTMLElement, { childList: true }); }; + ensureNoteIsInsertedBeforeUIAction = async () => { + if (this.controller.isTemplateNote) { + await this.controller.insertTemplatedNote(); + } + }; + render() { if (this.state.showProtectedWarning) { return ( @@ -1072,17 +1078,23 @@ export class NoteView extends PureComponent {
{this.state.noteStatus.desc}
)} - {this.appState.notes.selectedNotesCount > 0 && ( - <> -
- -
- +
+ - - )} +
+ + diff --git a/app/assets/javascripts/components/NotesOptionsPanel.tsx b/app/assets/javascripts/components/NotesOptionsPanel.tsx index 977655ab1e6..72097cbbcbc 100644 --- a/app/assets/javascripts/components/NotesOptionsPanel.tsx +++ b/app/assets/javascripts/components/NotesOptionsPanel.tsx @@ -15,10 +15,11 @@ import { WebApplication } from '@/ui_models/application'; type Props = { application: WebApplication; appState: AppState; + onClickPreprocessing?: () => Promise; }; export const NotesOptionsPanel = observer( - ({ application, appState }: Props) => { + ({ application, appState, onClickPreprocessing }: Props) => { const [open, setOpen] = useState(false); const [position, setPosition] = useState({ top: 0, @@ -37,7 +38,7 @@ export const NotesOptionsPanel = observer( return ( { + onChange={async () => { const rect = buttonRef.current?.getBoundingClientRect(); if (rect) { const { clientHeight } = document.documentElement; @@ -52,7 +53,11 @@ export const NotesOptionsPanel = observer( top: rect.bottom, right: document.body.clientWidth - rect.right, }); - setOpen(!open); + const newOpenState = !open; + if (newOpenState && onClickPreprocessing) { + await onClickPreprocessing(); + } + setOpen(newOpenState); } }} > diff --git a/app/assets/javascripts/components/PinNoteButton.tsx b/app/assets/javascripts/components/PinNoteButton.tsx index 986b4a31047..0f88d5c3f4c 100644 --- a/app/assets/javascripts/components/PinNoteButton.tsx +++ b/app/assets/javascripts/components/PinNoteButton.tsx @@ -7,14 +7,18 @@ import { Icon } from './Icon'; type Props = { appState: AppState; className?: string; + onClickPreprocessing?: () => Promise; }; export const PinNoteButton: FunctionComponent = observer( - ({ appState, className = '' }) => { + ({ appState, className = '', onClickPreprocessing }) => { const notes = Object.values(appState.notes.selectedNotes); const pinned = notes.some((note) => note.pinned); - const togglePinned = () => { + const togglePinned = async () => { + if (onClickPreprocessing) { + await onClickPreprocessing(); + } if (!pinned) { appState.notes.setPinSelectedNotes(true); } else {