Following from Communicating with editor extensions I was trying to dispatch sort of effect but I don’t get any changes in obsidian.
this.addCommand({
id: 'test-command',
name: 'Testing my command',
editorCallback: (editor, view) => {
// @ts-expect-error, not typed
let editorView = view.editor.cm as EditorView;
editorView.dispatch({
effects: StateEffect.appendConfig.of([
EditorView.decorations.of(
Decoration.set(
Decoration.line(
{attributes: {style: "font-weight: bold"}}
).range(0)
)
),
])
});
}
});
Similar thing works in codemirror
import {Decoration, EditorView} from "@codemirror/view"
import {StateEffect} from "@codemirror/state"
let ev = new EditorView({
doc: "console.log('hello')\n",
extensions: [],
parent: document.body
});
ev.dispatch({
effects: StateEffect.appendConfig.of([
EditorView.decorations.of(Decoration.set(Decoration.line({attributes: {style: "font-weight: bold"}}).range(0))),
])
})
Could anyone help what I’m getting wrong here?