How to get the 'live preview' status within the TypeScript code for plugin development

Given view is a MarkdownView, view.getState() gives you that information.

  • { mode: "preview", ... }: reading view
  • { mode: "source", source: false, ... }: live preview
  • { mode: "source", source: true, ... }: source mode

For changing the state, use view.setState.