μλν° νμ₯ κΈ°λ₯μ λ§λ€μλ€λ©΄, μλν° μΈλΆ(μ: λͺ λ Ήμ΄λ 리본 μ‘μ μ ν΅ν΄)μ ν΅μ νκ³ μΆμ μ μμ΅λλ€.
MarkdownViewμμ CodeMirror 6 μλν°μ μ κ·Όν μ μμ΅λλ€. νμ§λ§ Obsidian APIκ° μ€μ λ‘ μλν°λ₯Ό λ
ΈμΆνμ§ μκΈ° λλ¬Έμ TypeScriptμκ² κ·Έκ²μ΄ μ‘΄μ¬νλ€κ³ λ―Ώλλ‘ @ts-expect-error
λ₯Ό μ¬μ©ν΄μΌ ν©λλ€.
import { EditorView } from '@codemirror/view';
// @ts-expect-error, νμ
μ΄ μ μλμ§ μμ
const editorView = view.editor.cm as EditorView;
λ·° νλ¬κ·ΈμΈ
EditorView.plugin()
λ©μλλ₯Ό ν΅ν΄ λ·° νλ¬κ·ΈμΈ μΈμ€ν΄μ€μ μ κ·Όν μ μμ΅λλ€.
this.addCommand({
id: 'example-editor-command',
name: 'μλν° λͺ
λ Ή μμ ',
editorCallback: (editor, view) => {
// @ts-expect-error, νμ
μ΄ μ μλμ§ μμ
const editorView = view.editor.cm as EditorView;
const plugin = editorView.plugin(examplePlugin);
if (plugin) {
plugin.addPointerToSelection(editorView);
}
},
});
μν νλ
μλν° λ·°μμ μ§μ λ³κ²½ μ¬νμ μ λ¬νκ³ μν ν¨κ³Όλ₯Ό μ λ¬ν μ μμ΅λλ€.
this.addCommand({
id: 'example-editor-command',
name: 'μλν° λͺ
λ Ή μμ ',
editorCallback: (editor, view) => {
// @ts-expect-error, νμ
μ΄ μ μλμ§ μμ
const editorView = view.editor.cm as EditorView;
editorView.dispatch({
effects: [
// ...
],
});
},
});