From f844d5a25da22b2dd78517b2f07be7da2016cf9c Mon Sep 17 00:00:00 2001 From: RyotaUshio Date: Tue, 19 Dec 2023 16:59:25 +0900 Subject: [PATCH] remove some features that have been moved to other plugins & add a notification modal --- src/main.ts | 16 +- src/notice.ts | 61 +++- src/patches/link-completion.ts | 9 - src/render-math-in-callouts.ts | 495 --------------------------------- src/settings/helper.ts | 10 - src/settings/settings.ts | 4 - src/settings/tab.ts | 4 - styles/main.css | 32 --- 8 files changed, 64 insertions(+), 567 deletions(-) delete mode 100644 src/render-math-in-callouts.ts diff --git a/src/main.ts b/src/main.ts index b87eef1..53a2bd1 100644 --- a/src/main.ts +++ b/src/main.ts @@ -12,11 +12,10 @@ import { createTheoremCalloutNumberingViewPlugin } from 'theorem-callouts/view-p import { ContextSettingModal, TheoremCalloutModal } from 'settings/modals'; import { createEquationNumberProcessor } from 'equations/reading-view'; import { createEquationNumberPlugin } from 'equations/live-preview'; -import { mathPreviewInfoField, inlineMathPreview, displayMathPreviewForCallout, displayMathPreviewForQuote, hideDisplayMathPreviewInQuote } from 'render-math-in-callouts'; import { getMarkdownPreviewViewEl, getMarkdownSourceViewEl, isPluginOlderThan } from 'utils/obsidian'; import { getProfile, staticifyEqNumber, insertDisplayMath, insertTheoremCallout, insertProof } from 'utils/plugin'; import { MathIndexManager } from 'index/manager'; -import { DependencyNotificationModal, MigrationModal, RenameNoticeModal } from 'notice'; +import { DependencyNotificationModal, MigrationModal, PluginSplitNoticeModal, RenameNoticeModal } from 'notice'; import { LinkAutocomplete } from 'search/editor-suggest'; import { MathSearchModal } from 'search/modal'; import { TheoremCalloutInfo, createTheoremCalloutsField } from 'theorem-callouts/state-field'; @@ -65,6 +64,10 @@ export default class LatexReferencer extends Plugin { new RenameNoticeModal(this).open(); } + if (v1 || version.localeCompare('2.3.0', undefined, { numeric: true }) < 0) { + new PluginSplitNoticeModal(this).open(); + } + if (!dependenciesOK || v1) { new DependencyNotificationModal(this, dependenciesOK, v1).open(); } @@ -307,15 +310,6 @@ export default class LatexReferencer extends Plugin { // equation numbers this.editorExtensions.push(createEquationNumberPlugin(this)); - // math preview in callouts and quotes - document.body.toggleClass('math-booster-preview-enabled', this.extraSettings.enableMathPreviewInCalloutAndQuote); - if (this.extraSettings.enableMathPreviewInCalloutAndQuote) { - this.editorExtensions.push(mathPreviewInfoField); - this.editorExtensions.push(inlineMathPreview); - this.editorExtensions.push(displayMathPreviewForCallout); - this.editorExtensions.push(displayMathPreviewForQuote); - this.editorExtensions.push(hideDisplayMathPreviewInQuote); - } // proofs if (this.extraSettings.enableProof) { this.editorExtensions.push(createProofDecoration(this)); diff --git a/src/notice.ts b/src/notice.ts index 935bdbd..7989764 100644 --- a/src/notice.ts +++ b/src/notice.ts @@ -5,6 +5,63 @@ import { isPluginOlderThan } from "utils/obsidian"; import { rewriteTheoremCalloutFromV1ToV2 } from "utils/plugin"; +export class PluginSplitNoticeModal extends Modal { + component: Component; + + constructor(public plugin: LatexReferencer) { + super(plugin.app); + this.component = new Component(); + } + + onOpen() { + const { app, plugin, contentEl, titleEl } = this; + plugin.addChild(this.component); + contentEl.empty(); + + titleEl.setText(`${plugin.manifest.name} ver. ${plugin.manifest.version}`); + + new Setting(contentEl) + .setName('Some features of this plugin have been rewritten with a bunch of improvements, and they are now available as the following separate plugins:') + .setHeading(); + + for (const { name, id, desc } of [ + { + name: 'Better Math in Callouts & Blockquotes', + id: 'math-in-callout', + desc: 'Add better Live Preview support for math rendering inside callouts & blockquotes. It renders math expressions in callouts and provides appropriate handling of multi-line equations inside blockquotes.' + }, + { + name: 'Rendered Block Link Suggestions', + id: 'rendered-block-link-suggestions', + desc: 'Render equations and other types of blocks in Obsidian\'s built-in link suggestions' + } + ]) { + const installed = id in (app.plugins as any).manifests; + const enabled = app.plugins.enabledPlugins.has(id); + + new Setting(contentEl) + .setName(name) + .setDesc(desc) + .addButton((button) => { + button + .setButtonText(enabled ? 'Already enabled!' : installed ? 'Enable' : 'Install') + .then((button) => enabled || button.setCta()) + .onClick(() => { + self.open(`obsidian://show-plugin?id=${id}`); + this.component.registerDomEvent(window, 'click', (evt) => { + this.onOpen(); + }) + }); + }) + } + } + + onClose() { + this.contentEl.empty(); + this.component.unload(); + } +} + export class RenameNoticeModal extends Modal { component: Component; @@ -15,7 +72,7 @@ export class RenameNoticeModal extends Modal { onOpen() { this.plugin.addChild(this.component) - + const { contentEl, titleEl } = this; contentEl.empty(); @@ -125,7 +182,7 @@ export class DependencyNotificationModal extends Modal { MarkdownRenderer.render( this.app, -`LaTeX-like Theorem & Equation Referencer (formerly called Math Booster) version 2 introduces a [new format for theorem callouts](https://ryotaushio.github.io/obsidian-latex-theorem-equation-referencer/theorem-callouts/theorem-callouts.html). + `LaTeX-like Theorem & Equation Referencer (formerly called Math Booster) version 2 introduces a [new format for theorem callouts](https://ryotaushio.github.io/obsidian-latex-theorem-equation-referencer/theorem-callouts/theorem-callouts.html). To fully enjoy version 2, click the button below to convert the old theorem format to the new one. Alternatively, you can do it later by running the command "Migrate from version 1".`, this.contentEl.createDiv(), diff --git a/src/patches/link-completion.ts b/src/patches/link-completion.ts index 04ff4a9..36e1318 100644 --- a/src/patches/link-completion.ts +++ b/src/patches/link-completion.ts @@ -54,16 +54,7 @@ export const patchLinkCompletion = (plugin: LatexReferencer) => { }); return; } - } else if (plugin.extraSettings.renderEquationinBuiltin && item.type === "block" && item.node.type === 'math') { - renderInSuggestionTitleEl(el, (suggestionTitleEl) => { - el.addClass('math-booster', 'suggestion-item-equation'); - suggestionTitleEl.replaceChildren(); - suggestionTitleEl.appendChild(renderMath(item.node.value, true)) - }); - return; } - - } } })); diff --git a/src/render-math-in-callouts.ts b/src/render-math-in-callouts.ts deleted file mode 100644 index 44e9b14..0000000 --- a/src/render-math-in-callouts.ts +++ /dev/null @@ -1,495 +0,0 @@ -import { ExtraButtonComponent, renderMath } from "obsidian"; -import { Extension, Transaction, StateField, RangeSetBuilder, EditorState, RangeValue, RangeSet } from '@codemirror/state'; -import { Decoration, DecorationSet, EditorView, PluginValue, ViewPlugin, ViewUpdate, WidgetType } from "@codemirror/view"; -import { syntaxTree } from '@codemirror/language'; - -import { hasOverlap, isSourceMode, nodeText, nodeTextQuoteSymbolTrimmed, rangeSetSome } from './utils/editor'; -import { CALLOUT } from "theorem-callouts/state-field"; - - -const DISPLAY_MATH_BEGIN = "formatting_formatting-math_formatting-math-begin_keyword_math_math-block"; -const INLINE_MATH_BEGIN = "formatting_formatting-math_formatting-math-begin_keyword_math"; -const MATH_END = "formatting_formatting-math_formatting-math-end_keyword_math_math-"; -const ERROR_MATH = "error_math"; -const BLOCKQUOTE = /HyperMD-quote_HyperMD-quote-([1-9][0-9]*)/; - - -class MathPreviewWidget extends WidgetType { - /** It is critical to pass a MathInfo object with a PRE-RENDERED MathJax element - * for decreasing the number of the expensive renderMath() calls */ - constructor(public info: MathInfo) { - super(); - } - - toDOM(view: EditorView): HTMLElement { - this.info.mathEl.classList.add("math-booster-preview"); - if (this.info.display) { - const containerEl = createDiv({ - cls: ["HyperMD-quote", "HyperMD-quote-1", "HyperMD-quote-lazy", "cm-line", "math-booster-preview-container"], - }); - containerEl.createEl("img", { - cls: "cm-widgetBuffer", - attr: { "aria-hidden": "true" } - }); - const cmEmbedBlockEl = containerEl.createDiv({ - cls: ["math", "math-block", "cm-embed-block"], - attr: { - contenteditable: false, - } - }); - cmEmbedBlockEl.appendChild(this.info.mathEl); - const editButton = new ExtraButtonComponent(cmEmbedBlockEl) - .setIcon("code-2") - .setTooltip("Edit this block"); - editButton.extraSettingsEl.addEventListener("click", (ev: MouseEvent) => { - ev.stopPropagation(); - view.dispatch({ selection: { anchor: this.info.from + 2, head: this.info.to - 2 } }); - }) - editButton.extraSettingsEl.classList.add("math-booster-preview-edit-button"); - return containerEl; - } - return this.info.mathEl; - } - - ignoreEvent(event: Event): boolean { - // the rendered MathJax won't respond to clicks without this - return false; - } -} - -class MathInfo extends RangeValue { - mathEl: HTMLElement; - overlap: boolean; // whether this math has an overlap with the main selection - overlapChanged: boolean = true; // whether this.overlap has changed in the last update - - constructor(public mathText: string, public display: boolean, public from: number, public to: number, public insideCallout: boolean) { - super(); - this.render() - } - - async render() { - this.mathEl = renderMath(this.mathText, this.display); - } - - toWidget(): MathPreviewWidget { - return new MathPreviewWidget(this); - } - - toDecoration(which: "replace" | "widget"): Decoration { - return Decoration[which]({ - widget: this.toWidget(), - block: this.display, - side: which == "widget" ? 1 : undefined, // To fix https://github.com/RyotaUshio/obsidian-latex-theorem-equation-referencer/issues/173 - }) - } -} - -export type MathInfoSet = RangeSet; - -function buildMathInfoSet(state: EditorState): MathInfoSet { - - const tree = syntaxTree(state); - const builder = new RangeSetBuilder(); - - let from: number = -1; - let mathText: string; - let insideMath = false; - let display: boolean | undefined; - let quoteContentStart = 0; - let insideCallout = false; - let lastCalloutPos: number; - - tree.iterate({ - enter(node) { - if (node.node.parent?.name == "Document") { - if (insideCallout) { - if (node.from == lastCalloutPos + 1 && node.name.match(BLOCKQUOTE)) { - lastCalloutPos = node.to; - } else { - insideCallout = false; - } - } - if (node.name.match(CALLOUT)) { - insideCallout = true; - lastCalloutPos = node.to; - } - } - - if (nodeText(node, state).trim() == '>' && node.from < quoteContentStart) { - return; - } - if (insideMath) { - if (node.name == MATH_END) { - builder.add( - from, - node.to, - new MathInfo(mathText, display as boolean, from, node.to, insideCallout) - ); - insideMath = false; - display = undefined; - } else if (display && node.name == ERROR_MATH && nodeText(node, state) == "$") { - /** When inserting inline math at the top of "foo $x = 1$ bar", - * the text becomes "$$ foo $x = 1$ bar". - * This "$$" should be interpreted as INLINE_MATH_BEGIN + MATH_END, but - * CodeMirror misundertands it as a single DISPLAY_MATH_BEGIN. - * To handle this exception, here I make use of the fact that - * two "$"s are labeled as ERROR_MATH in this case. - */ - builder.add( - from, - from + 2, // 2 = "$$".length - new MathInfo(mathText, false, from, from + 2, insideCallout) - ); - insideMath = false; - display = undefined; - } else { - const match = node.name.match(BLOCKQUOTE); - if (match) { - const quoteLevel = +match[1]; - if (node.node.firstChild) { - quoteContentStart = node.node.firstChild.to; - mathText += nodeTextQuoteSymbolTrimmed(node.node.firstChild, state, quoteLevel) ?? ""; - } - } else { - if (node.name.contains("math")) { - mathText += nodeText(node, state); - } - } - } - } else { - /** collect mathInfo only inside callouts or blockquotes */ - const match = node.node.parent?.name.match(BLOCKQUOTE); - if (match) { - if (node.name == DISPLAY_MATH_BEGIN) { - insideMath = true; - display = true; - from = node.from; - mathText = ""; - } else if (node.name == INLINE_MATH_BEGIN) { - insideMath = true; - display = false; - from = node.from; - mathText = ""; - } - } - } - } - }); - - if (insideMath && display && from >= 0) { - /** When inserting inline math at the top of "foo $x = 1$ bar", - * the text becomes "$$ foo $x = 1$ bar". - * This "$$" should be interpreted as INLINE_MATH_BEGIN + MATH_END, but - * CodeMirror misundertands it as a single DISPLAY_MATH_BEGIN. - */ - builder.add( - from, - from + 2, // 2 = "$$".length - new MathInfo("", false, from, from + 2, insideCallout) - ); - } - - return builder.finish(); -} - -export type MathPreviewInfo = { - mathInfoSet: MathInfoSet; - isInCalloutsOrQuotes: boolean; - hasOverlappingMath: boolean; - hasOverlappingDisplayMath: boolean; - rerendered: boolean; -} - -export const mathPreviewInfoField = StateField.define({ - create(state: EditorState): MathPreviewInfo { - return { - mathInfoSet: buildMathInfoSet(state), // RangeSet.empty, - isInCalloutsOrQuotes: false, - hasOverlappingMath: false, - hasOverlappingDisplayMath: false, - rerendered: false, - } - }, - - update(prev: MathPreviewInfo, transaction: Transaction): MathPreviewInfo { - // set isInCalloutsOrQuotes - const isInCalloutsOrQuotes = isInBlockquoteOrCallout(transaction.state); - // set hasOverlappingMath - const range = transaction.state.selection.main; - const cursor = prev.mathInfoSet.iter(); - let hasOverlappingMath = false; - let hasOverlappingDisplayMath = false; - while (cursor.value) { - if (range.from <= cursor.to && cursor.from <= range.to) { - hasOverlappingMath = true; - if (cursor.value.display) { - hasOverlappingDisplayMath = true; - } - break; - } - cursor.next(); - } - // set mathInfoSet & rerendered - let mathInfoSet: MathInfoSet; - let rerendered = false; - if (!prev.mathInfoSet.size) { - // rebuild all math info, including rendered MathJax (this should be done more efficiently in the near future) - mathInfoSet = buildMathInfoSet(transaction.state); - rerendered = true; - } else if (isInCalloutsOrQuotes) { - if ( - !prev.isInCalloutsOrQuotes // If newly entered inside a callout or quote - || (prev.hasOverlappingMath && !hasOverlappingMath) // or just got out of math - ) { - // rebuild all math info, including rendered MathJax (this should be done more efficiently in the near future) - mathInfoSet = buildMathInfoSet(transaction.state); - rerendered = true; - } else if (transaction.docChanged) { - if (involvesDollar(transaction) || hasOverlappingDisplayMath) { - mathInfoSet = buildMathInfoSet(transaction.state); - rerendered = true; - } else { - mathInfoSet = prev.mathInfoSet.map(transaction.changes.desc); - } - } else { - mathInfoSet = prev.mathInfoSet; - } - } else { - mathInfoSet = prev.mathInfoSet; - } - - const oldCursor = prev.mathInfoSet.iter(); - const newCursor = mathInfoSet.iter(); - while (oldCursor.value && newCursor.value) { - // NOTE THAT oldCursor.value & newCursor.value can point to the same object!!! - const oldOverlap = oldCursor.value.overlap; - const newOverlap = hasOverlap(range, newCursor); - newCursor.value.overlapChanged = oldOverlap != newOverlap; - newCursor.value.overlap = newOverlap; - oldCursor.next(); - newCursor.next(); - } - - return { mathInfoSet, isInCalloutsOrQuotes, hasOverlappingMath, hasOverlappingDisplayMath, rerendered }; - }, -}); - - -export const inlineMathPreview = ViewPlugin.fromClass( - class implements PluginValue { - decorations: DecorationSet; - - constructor(view: EditorView) { - this.buildDecorations(view); - } - - update(update: ViewUpdate) { - if (update.docChanged || update.viewportChanged || overlapStateChanged(update.state)) { - this.buildDecorations(update.view); - } - } - - buildDecorations(view: EditorView) { - if (isSourceMode(view.state)) { - this.decorations = Decoration.none; - return; - } - - const field = view.state.field(mathPreviewInfoField); - - if (!field.isInCalloutsOrQuotes) { - this.decorations = Decoration.none; - return; - } - - const range = view.state.selection.main; - const builder = new RangeSetBuilder(); - - for (const { from, to } of view.visibleRanges) { - field.mathInfoSet.between( - from, - to, - (from, to, value) => { - if (value.insideCallout && !value.display && !hasOverlap(range, { from, to })) { - /** - * Inline math that is not overlapping with the current selection or cursor - */ - builder.add( - from, - to, - value.toDecoration("replace") - ); - } - } - ); - } - this.decorations = builder.finish(); - } - }, - { decorations: instance => instance.decorations } -); - - -export const displayMathPreviewForCallout = StateField.define({ - create(state: EditorState): DecorationSet { - return Decoration.none; - }, - - update(value: DecorationSet, transaction: Transaction): DecorationSet { - const builder = new RangeSetBuilder(); - const range = transaction.state.selection.main; - const field = transaction.state.field(mathPreviewInfoField); - - if (isSourceMode(transaction.state)) { - return Decoration.none; - } - - if (!transaction.docChanged && !overlapStateChanged(transaction.state)) { - return value; - } - - field.mathInfoSet.between( - 0, - transaction.state.doc.length, - (from, to, value) => { - if (value.display) { - if (!hasOverlap(range, { from, to })) { - if (value.insideCallout && field.isInCalloutsOrQuotes) { - builder.add(from, to, value.toDecoration("replace")); - } - } else { - builder.add(to, to, value.toDecoration("widget")); - } - } - } - ); - return builder.finish(); - }, - - provide(field: StateField): Extension { - return EditorView.decorations.from(field); - }, -}); - - -export const hideDisplayMathPreviewInQuote = ViewPlugin.fromClass( - class implements PluginValue { - constructor(view: EditorView) { - this.impl(view); - } - - update(update: ViewUpdate) { - this.impl(update.view); - } - - impl(view: EditorView) { - const field = view.state.field(mathPreviewInfoField); - - for (const vanillaObsidianMathPreview of view.contentDOM.querySelectorAll( - `.cm-line:not(.HyperMD-quote) .math.math-block.cm-embed-block > mjx-container.MathJax[display="true"]:not(.math-booster-preview)` - )) { - const pos = view.posAtDOM(vanillaObsidianMathPreview); - if (rangeSetSome(field.mathInfoSet, (info) => info.from - 1 <= pos && pos <= info.to)) { - const cmWidgetBuffer = vanillaObsidianMathPreview.previousSibling; - if (cmWidgetBuffer instanceof HTMLElement && cmWidgetBuffer.matches(".cm-widget-buffer")) { - cmWidgetBuffer.remove(); - } - vanillaObsidianMathPreview.remove(); - } - } - } - } -); - - - -function isInBlockquoteOrCallout(state: EditorState): boolean { - const range = state.selection.main; - const tree = syntaxTree(state); - let foundQuote = false; - tree.iterate({ - enter(node) { - const match = node.name.match(BLOCKQUOTE); - if (match) { - if (node.from <= range.to && range.from <= node.to) { - foundQuote = true; - return false; - } - } - } - }); - return foundQuote; -} - -function involvesDollar(transaction: Transaction): boolean { - let ret = false; - transaction.changes.iterChanges( - (fromA, toA, fromB, toB, inserted) => { - const textBefore = transaction.startState.sliceDoc(fromA, toA); - const dollarEdited = textBefore.contains("$"); - const dollarInserted = inserted.toString().contains("$"); - ret = ret || dollarEdited || dollarInserted; - } - ) - return ret; -} - -function overlapStateChanged(state: EditorState): boolean { - const infoSet = state.field(mathPreviewInfoField).mathInfoSet; - return rangeSetSome(infoSet, (info) => info.overlapChanged); -} - - -export const displayMathPreviewForQuote = ViewPlugin.fromClass( - class implements PluginValue { - - constructor(view: EditorView) { - this.impl(view); - } - - update(update: ViewUpdate) { - this.impl(update.view); - } - - impl(view: EditorView) { - if (isSourceMode(view.state)) { - return; - } - - const range = view.state.selection.main; - const field = view.state.field(mathPreviewInfoField); - - let mjxInQuote = Array.from( - view.contentDOM.querySelectorAll( - '.HyperMD-quote.cm-line .math.math-block.cm-embed-block > mjx-container.MathJax:has( > mjx-math[display="true"]):not(.math-booster-preview)' - ) - ); - - const mjxPositions = mjxInQuote.map((el) => view.posAtDOM(el)); - - for (const { from, to } of view.visibleRanges) { - field.mathInfoSet.between( - from, - to, - (from, to, value) => { - if (!hasOverlap(range, { from, to })) { - if (value.display && !value.insideCallout) { - /** - * Display math inside blockquote (not callout) that is not overlapping with the current selection or cursor - */ - for (let i = 0; i < mjxInQuote.length; i++) { - const mjx = mjxInQuote[i]; - const pos = mjxPositions[i]; - if (from - 1 <= pos && pos <= to) { - value.mathEl.classList.add("math-booster-preview"); - mjx.replaceWith(value.mathEl); - } - } - } - } - } - ); - } - } - } -); diff --git a/src/settings/helper.ts b/src/settings/helper.ts index b788b57..ce86d21 100644 --- a/src/settings/helper.ts +++ b/src/settings/helper.ts @@ -367,11 +367,6 @@ export class ExtraSettingsHelper extends SettingsHelper { this.addToggleSetting("showTheoremCalloutEditButton", "Show an edit button on a theorem callout"); this.addToggleSetting("setOnlyTheoremAsMain", "If a note has only one theorem callout, automatically set it as main", 'Regardless of this setting, putting "%% main %%" or "%% main: true %%" in a theorem callout will set it as main one of the note, which means any link to that note will be displayed with the theorem\'s title. Enabling this option implicitly sets a theorem callout as main when it\'s the only one in the note.'); this.addToggleSetting("setLabelInModal", "Show LaTeX/Pandoc label input form in theorem callout insert/edit modal"); - this.addToggleSetting("enableMathPreviewInCalloutAndQuote", "Render equations inside callouts & add multi-line equation support to blockquotes", undefined, () => this.plugin.updateEditorExtensions()) - .then(async (setting) => { - setting.descEl.addClass('math-booster-new-feature'); - await MarkdownRenderer.render(this.plugin.app, '**NOTE:** This feature is planned to be removed from this plugin, and instead, it will be available as a separate plugin [**Better Math in Callouts & Blockquotes**](https://github.com/RyotaUshio/obsidian-math-in-callout), featuring a bunch of improvements. Currently awaiting for approval by the Obsidian team.', setting.descEl, '', this); - }); this.addToggleSetting("enableProof", "Enable proof environment", `For example, you can replace a pair of inline codes \`${DEFAULT_SETTINGS.beginProof}\` & \`${DEFAULT_SETTINGS.endProof}\` with \"${DEFAULT_PROFILES[DEFAULT_SETTINGS.profile].body.proof.begin}\" & \"${DEFAULT_PROFILES[DEFAULT_SETTINGS.profile].body.proof.end}\". You can style it with CSS snippets. See the documentation for the details.`, () => this.plugin.updateEditorExtensions()); // Suggest @@ -393,11 +388,6 @@ export class ExtraSettingsHelper extends SettingsHelper { .setDesc('Configure how this plugin modifies the appearance of Obsidian\'s built-in link auto-completion (the one that pops up when you type "[["). This feature dives deep into Obsidian\'s internals, so it might break when Obsidian is updated. If you encounter any issue, please report it on GitHub.'); this.addToggleSetting("showTheoremTitleinBuiltin", "Show theorem title"); this.addToggleSetting("showTheoremContentinBuiltin", "Show theorem content", "Only effective when \"Show theorem title\" is turned on."); - this.addToggleSetting("renderEquationinBuiltin", "Render equation") - .then(async (setting) => { - setting.descEl.addClass('math-booster-new-feature'); - await MarkdownRenderer.render(this.plugin.app, '**NOTE:** This feature is planned to be removed from this plugin, and instead, it will be available as a separate plugin [**Rendered Block Link Suggestions**](https://github.com/RyotaUshio/obsidian-rendered-block-link-suggestions), which supports all types of blocks not limited to display math. Currently awaiting for approval by the Obsidian team.', setting.descEl, '', this); - }); this.addHeading('Configure this plugin\'s custom editor link auto-completion') .setDesc(`It is recommended to turn off unnecessary auto-completions to improve performance.`); diff --git a/src/settings/settings.ts b/src/settings/settings.ts index 5e9b64a..663d50c 100644 --- a/src/settings/settings.ts +++ b/src/settings/settings.ts @@ -133,7 +133,6 @@ export type ExtraSettings = ImporterSettings & { profiles: Record; showTheoremTitleinBuiltin: boolean; showTheoremContentinBuiltin: boolean; - renderEquationinBuiltin: boolean; triggerSuggest: string; triggerTheoremSuggest: string; triggerEquationSuggest: string; @@ -174,7 +173,6 @@ export type ExtraSettings = ImporterSettings & { setLabelInModal: boolean; excludeExampleCallout: boolean; enableProof: boolean; - enableMathPreviewInCalloutAndQuote: boolean; autocompleteDvQuery: string; // searchModal*: not congigurable from the setting tab, just remenbers the last state searchModalQueryType: QueryType; @@ -230,7 +228,6 @@ export const DEFAULT_EXTRA_SETTINGS: Required = { profiles: DEFAULT_PROFILES, showTheoremTitleinBuiltin: true, showTheoremContentinBuiltin: false, - renderEquationinBuiltin: true, triggerSuggest: "\\ref", triggerTheoremSuggest: "\\tref", triggerEquationSuggest: "\\eqref", @@ -273,7 +270,6 @@ export const DEFAULT_EXTRA_SETTINGS: Required = { setLabelInModal: false, excludeExampleCallout: false, enableProof: true, - enableMathPreviewInCalloutAndQuote: true, autocompleteDvQuery: '', searchModalQueryType: 'both', searchModalRange: 'recent', diff --git a/src/settings/tab.ts b/src/settings/tab.ts index 6ba5ffe..69271ca 100644 --- a/src/settings/tab.ts +++ b/src/settings/tab.ts @@ -60,10 +60,6 @@ export class MathSettingTab extends PluginSettingTab { heading.settingEl, numberingHeading ); - this.containerEl.insertAfter( - extraHelper.settingRefs.enableMathPreviewInCalloutAndQuote.settingEl, - heading.settingEl - ); this.containerEl.insertAfter( extraHelper.settingRefs.enableProof.settingEl, this.containerEl.querySelector('.proof-heading')! diff --git a/styles/main.css b/styles/main.css index 665a29c..b678f45 100644 --- a/styles/main.css +++ b/styles/main.css @@ -75,38 +75,6 @@ padding: var(--size-4-2); } -.math-booster-preview { - cursor: text; -} - -.HyperMD-quote.cm-line.math-booster-preview-container { - text-indent:-15px; - padding-inline-start:19px; -} - -.cm-embed-block .math-booster-preview-edit-button { - padding: var(--size-2-2) var(--size-2-3); - position: absolute; - right: var(--size-2-2); - top: var(--size-2-2); - opacity: 0; - display: flex; - border-radius: var(--radius-s); -} - -.cm-embed-block:hover .math-booster-preview-edit-button { - transition: 0s; - opacity: 1 -} - -/* Unlike in callouts, Obsidian natively renders MathJax in blockquotes. But it is rather buggy -(see https://forum.obsidian.md/t/live-preview-support-math-block-in-quotes/32564/2), -so we need to replace it with this plugin's editor extension. -*/ -.math-booster-preview-enabled .HyperMD-quote.cm-line .math.math-block.cm-embed-block:has(> mjx-container.MathJax[display="true"]:not(.math-booster-preview)) { - display: none; -} - .theorem-callout { position: relative; }