Note Preview

Summary

How the Dendron Note Preview gets launched

Entry

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

Log Dump

Calling toggle preview 2x

info {"ctx":"Logger:configure","msg":"exit","logLevel":"debug"}
info {"ctx":"SetupWorkspaceCommand","rootDir":"/var/folders/1l/h5rmxkhs3ldfr3y5fzkkw2v40000gn/T/tmp-83950-CM8m7r0lq3h7","skipOpenWs":true,"workspaceType":"CODE"}
info {"ctx":"SetupWorkspaceCommand:postCreateWorkspace","wsRoot":"/var/folders/1l/h5rmxkhs3ldfr3y5fzkkw2v40000gn/T/tmp-83950-CM8m7r0lq3h7","wsVault":{"fsPath":".","name":"tmp-83950-CM8m7r0lq3h7","selfContained":true}}
info {"ctx":"_activate","stage":"test","isDebug":false,"logLevel":"debug","logPath":"/var/folders/1l/h5rmxkhs3ldfr3y5fzkkw2v40000gn/T/tmp-83950-hvpXsVe2r2iX","extensionPath":"/Users/kevinlin/code/dendron/packages/plugin-core","extensionUri":"/Users/kevinlin/code/dendron/packages/plugin-core","workspaceFile":"/var/folders/1l/h5rmxkhs3ldfr3y5fzkkw2v40000gn/T/tmp-83950-CM8m7r0lq3h7/dendron.code-workspace","workspaceFolders":["/var/folders/1l/h5rmxkhs3ldfr3y5fzkkw2v40000gn/T/tmp-83950-CM8m7r0lq3h7/notes","/var/folders/1l/h5rmxkhs3ldfr3y5fzkkw2v40000gn/T/tmp-83950-CM8m7r0lq3h7"]}
info {"ctx":"DendronExtension","msg":"initialized"}
info {"ctx":"_activate","msg":"initializeWorkspace","wsType":"CODE","currentVersion":"0.101.0","previousGlobalVersion":"0.101.0","extensionInstallStatus":"NO_CHANGE"}
info {"ctx":"WorkspaceActivator.init:postSetupTraits","wsRoot":"/var/folders/1l/h5rmxkhs3ldfr3y5fzkkw2v40000gn/T/tmp-83950-CM8m7r0lq3h7"}
info {"ctx":"runMigrationsIfNecessary","changes":[],"workspaceInstallStatus":"INITIAL_INSTALL"}
info {"ctx":"WorkspaceActivator.init:postMigration","wsRoot":"/var/folders/1l/h5rmxkhs3ldfr3y5fzkkw2v40000gn/T/tmp-83950-CM8m7r0lq3h7"}
info {"ctx":"WorkspaceActivator.init:postWsServiceInitialize","wsRoot":"/var/folders/1l/h5rmxkhs3ldfr3y5fzkkw2v40000gn/T/tmp-83950-CM8m7r0lq3h7"}
info {"ctx":"startServerProcess","msg":"post-start-server","port":57163,"durationStartServer":19}
info {"ctx":"WorkspaceActivator.init:verifyOrStartServerProcess","port":57163}
info {"ctx":"WorkspaceActivator.init:exit"}
info {"ctx":"_activate:postSetupWorkspace","platform":"darwin","extensions":[{"id":"dendron.dendron"},{"id":"dendron.dendron-paste-image"},{"id":"dendron.dendron-markdown-shortcuts"},{"id":"redhat.vscode-yaml"}],"vaults":[{"fsPath":".","selfContained":true,"name":"tmp-83950-CM8m7r0lq3h7"}]}
info {"ctx":"TreeView:getChildren","msg":"reconstructing tree: enter"}
info {"ctx":"TreeView:getChildren","msg":"reconstructing tree: exit"}
info {"ctx":"dendron.reloadIndex:run","msg":"pre-execute"}
info {"ctx":"ReloadIndex.execute","msg":"enter"}
info {"ctx":"ReloadIndex.execute","durationEngineInit":46}
info {"ctx":"ReloadIndex.execute","msg":"exit"}
info {"ctx":"dendron.reloadIndex:run","msg":"post-execute"}
info {"ctx":"reloadWorkspace","msg":"post-ws.reloadWorkspace"}
info {"ctx":"reloadWorkspace","msg":"exit"}
info {"ctx":"postReloadWorkspace","msg":"same wsVersion"}
info {"ctx":"postReloadWorkspace","msg":"exit"}
info {"ctx":"setupViews","msg":"init:treeViewV2"}
info {"ctx":"setupBacklinkTreeView","msg":"init:backlinks"}
info {"ctx":"WorkspaceActivator:activate","msg":"fin startClient","durationReloadWorkspace":53}
info {"ctx":"showWelcomeOrWhatsNew","version":"0.101.0","previousExtensionVersion":"0.0.0"}
info {"ctx":"refreshBacklinksEngineNoteStateChanged"}
info {"ctx":"refreshBacklinksChangeActiveTextEditor"}
info {"ctx":"refreshBacklinksChangeActiveTextEditor"}
info {"ctx":"test:pre:before:run"}
info {"ctx":"dendron.togglePreview:run","msg":"pre-execute"}
info {"ctx":"PreviewPanel:show"}
info {"ctx":"PreviewPanel:show","msg":"panel does not exist"}
info {"ctx":"PreviewPanel:show:postSetupCallbacks"}
info {"ctx":"PreviewPanel:preReveal"}
info {"ctx":"PreviewPanel:show","note":"preview-test"}
info {"ctx":"PreviewPanel:show","msg":"panel exists"}
info {"ctx":"PreviewPanel:show:pre:Refresh"}
info {"ctx":"PreviewPanel:show:post:Refresh"}
info {"ctx":"dendron.togglePreview:run","msg":"post-execute"}
info {"ctx":"test:post:before:run"}
info {"ctx":"test:pre:run"}
info {"ctx":"dendron.togglePreview:run","msg":"pre-execute"}
info {"ctx":"TogglePreview.execute:pre:panelHide"}
info {"ctx":"PreviewPanel:preDispose"}
info {"ctx":"PreviewPanel:onDidDispose"}
info {"ctx":"PreviewPanel:postDispose"}
info {"ctx":"TogglePreview.execute:post:panelHide"}
info {"ctx":"dendron.togglePreview:run","msg":"post-execute"}
info {"ctx":"test:post:run"}
info {"ctx":"sendRefreshMessage:pre:postMessage"}

Lookup


Children
  1. Lifecycle

Backlinks