Skip to content

Commit

Permalink
remove some features that have been moved to other plugins & add a no…
Browse files Browse the repository at this point in the history
…tification modal
  • Loading branch information
RyotaUshio committed Dec 19, 2023
1 parent 3d21a69 commit f844d5a
Show file tree
Hide file tree
Showing 8 changed files with 64 additions and 567 deletions.
16 changes: 5 additions & 11 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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();
}
Expand Down Expand Up @@ -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));
Expand Down
61 changes: 59 additions & 2 deletions src/notice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -15,7 +72,7 @@ export class RenameNoticeModal extends Modal {

onOpen() {
this.plugin.addChild(this.component)

const { contentEl, titleEl } = this;
contentEl.empty();

Expand Down Expand Up @@ -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(),
Expand Down
9 changes: 0 additions & 9 deletions src/patches/link-completion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}


}
}
}));
Expand Down
Loading

0 comments on commit f844d5a

Please sign in to comment.