Lifecycle

Initialization

Receiving Messages

  • goes into detail about initialization actions in the webview

  • this sends a MESSAGE_DISPATCHER_READY signal

  • PreviewFactory (Private)

    • this tells the panel to send refresh message to the webview
case MESSAGE_DISPATCHER_READY {
    note = getActiveNote
    if note PreviewPanelFactory.sendRefreshMessage
}

Start anchor send-refresh-message not found

onDidChangeActiveTextEditor

Whenever the active text editor changes

VSCode Logic

triggerNotePreviewUpdate(document) {
    maybeNote = tryGetNoteFromDocument(document)
    if (maybeNote) showPreviewAndUpdate(maybeNote)
}
showPreviewAndUpdate {
    ...
    sendRefreshMessage(note)
}

// tell webview to update with the new note
sendRefreshMessage(note) {
    @panel.postMessage(
        ON_DID_CHANGE_ACTIVE_TEXT_EDITOR,
        note,
        syncChangedNote: true
    )
}

This leads the view to execute Change Active Editor hook

View Logic

App receives the Change Active Editor event

The Note Preview renders contents based on the active editor

useRenderedNoteBody(id) {
	engineSlice.renderNote(id)
}

renderNote(id) {
	api.noteRender(id)
}

hide

hide { 
    dispose
}

dispose {
    if _panel {
        this._panel.dispose();
    }
}

Common

Send Refresh Message

// tell webview to update with the new note
sendRefreshMessage(note) {
    @panel.postMessage(
        ON_DID_CHANGE_ACTIVE_TEXT_EDITOR,
        note,
        syncChangedNote: true
    )
}

This leads the view to execute Change Active Editor hook


Children
  1. On Click

Backlinks