Changes dispatched to editor in Reading mode don't update the source markdown

Steps to reproduce

  1. Make a note with the text value

In my plugin I am using the following code to update a line in the source markdown:

function updateText(){
	const markdownView =;
	  if (markdownView instanceof MarkdownView) {
		const editor = markdownView.editor;
                const value = "new value";
		updateEditorLine(editor, 0, 5, value); 

export const updateEditorText = (
	editor: Editor,
        from: number,
        to: number,
	text: string
) => {
	const cm = (editor as any).cm;
	const state = cm.state.doc;
		changes: {
		    insert: text,
		scrollIntoView: false,

This code will update the source markdown while in editing mode, but if I got into reading mode, nothing is updated

//Editing mode
//markdown before
//markdown after
new value

//Reading mode
//markdown before

//markdown after

Expected result

Since the markdownView.editor object isn’t null, and I can dispatch calls to the editor and also call in reading mode, I expect it to update the source markdown

Actual result

The source markdown is not updated


  • Operating system:
    Mac OS Big Sur - 11.6.4
  • Debug info:
    Obsidian version: v0.15.9
    Installer version: v0.15.8
    Operating system: Darwin Kernel Version 20.6.0: Wed Jan 12 22:22:45 PST 2022; root:xnu-7195.141.19~2/RELEASE_ARM64_T8101 20.6.0
    Login status: not logged in
    Insider build toggle: off
    Live preview: on
    Legacy editor: off
    Base theme: light
    Community theme: none
    Snippets enabled: 0
    Restricted mode: off
    Plugins installed: 9
    Plugins enabled: 1
    1: Sample Plugin v1.0.0

Community plugins: for bugs, please first try updating all your plugins to latest. If still not fixed, please try to make the issue happen in the Sandbox Vault or disable community plugins.

Additional information

moved to developers and api.