diff --git a/src/@types/index.ts b/src/@types/index.ts index 245b796..67cfc0f 100644 --- a/src/@types/index.ts +++ b/src/@types/index.ts @@ -33,6 +33,7 @@ export interface ISettingsData { injectColor: boolean; parseTitles: boolean; allowMSSyntax: boolean; + livePreviewMS: boolean; } export type AdmonitionIconDefinition = { diff --git a/src/main.ts b/src/main.ts index 4cda8c5..047a30f 100644 --- a/src/main.ts +++ b/src/main.ts @@ -118,7 +118,8 @@ const DEFAULT_APP_SETTINGS: ISettingsData = { enableMarkdownProcessor: false, injectColor: true, parseTitles: true, - allowMSSyntax: true + allowMSSyntax: true, + livePreviewMS: true }; export default class ObsidianAdmonition extends Plugin { @@ -524,6 +525,7 @@ export default class ObsidianAdmonition extends Plugin { } update(update: ViewUpdate) { + if (!self.data.livePreviewMS) return; const md = update.view.state.field(editorViewField); if (!md.leaf?.view) return; const { state } = md.leaf?.getViewState() ?? {}; @@ -554,6 +556,8 @@ export default class ObsidianAdmonition extends Plugin { destroy() {} build(view: EditorView) { + if (!self.data.allowMSSyntax) return; + if (!self.data.livePreviewMS) return; const targetElements: TokenSpec[] = []; const md = view.state.field(editorViewField); const { state } = md.leaf.getViewState() ?? {}; diff --git a/src/settings.ts b/src/settings.ts index 6c681ad..4241044 100644 --- a/src/settings.ts +++ b/src/settings.ts @@ -144,9 +144,34 @@ export default class AdmonitionSetting extends PluginSettingTab { .addToggle((t) => { t.setValue(this.plugin.data.allowMSSyntax).onChange((v) => { this.plugin.data.allowMSSyntax = v; + this.display(); this.plugin.saveSettings(); }); }); + if (this.plugin.data.allowMSSyntax) { + new Setting(containerEl) + .setName("Render Microsoft Document Syntax in Live Preview") + .setDesc( + createFragment((e) => { + e.createSpan({ + text: "The plugin will render blockquotes created using the " + }); + e.createEl("a", { + href: "https://docs.microsoft.com/en-us/contribute/markdown-reference", + text: "Microsoft Document Syntax" + }); + e.createSpan({ + text: " in live preview mode." + }); + }) + ) + .addToggle((t) => { + t.setValue(this.plugin.data.livePreviewMS).onChange((v) => { + this.plugin.data.livePreviewMS = v; + this.plugin.saveSettings(); + }); + }); + } const publish = new Setting(containerEl) .setName("Generate JS for Publish")