Skip to content

Commit

Permalink
Merge pull request #1177 from pjkaufman/master
Browse files Browse the repository at this point in the history
Chore: Swap Off of Deprectated `MarkdownRender.renderMarkdown` to `MarkdownRender.render`
  • Loading branch information
pjkaufman authored Sep 27, 2024
2 parents cba9e51 + 00b31b7 commit 096bd93
Show file tree
Hide file tree
Showing 17 changed files with 280 additions and 24 deletions.
2 changes: 2 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ module.exports = {
'@typescript-eslint',
'jest',
'unicorn',
"deprecation",
],
'rules': {
'camelcase': 'off',
Expand All @@ -37,5 +38,6 @@ module.exports = {
'argsIgnorePattern': '(^_)|(options)',
},
],
"deprecation/deprecation": "warn",
},
};
4 changes: 2 additions & 2 deletions esbuild.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ const mockedPlugins = [replace({
// remove the use of obsidian in the options to allow for docs.js to run
'import {Setting} from \'obsidian\';': '',
// remove the use of obsidian in settings helper to allow for docs.js to run
'import {Component, MarkdownRenderer} from \'obsidian\';': '',
'import {App, Component, MarkdownRenderer} from \'obsidian\';': '',
// remove the use of obsidian in the auto-correct files picker to allow for docs.js to run
'import {Setting, Component, App, TFile, normalizePath, ExtraButtonComponent} from \'obsidian\';': '',
// remove the use of obsidian in add custom row to allow for docs.js to run
'import {Component, Setting} from \'obsidian\';': '',
'import {App, Component, Setting} from \'obsidian\';': '',
// remove the use of obsidian in suggest to allow for docs.js to run
'import {App, ISuggestOwner, Scope} from \'obsidian\';': '',
// remove the use of obsidian in md file suggester to allow for docs.js to run
Expand Down
246 changes: 246 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
"esbuild-plugin-replace": "^1.3.0",
"eslint": "^8.57.0",
"eslint-config-google": "^0.14.0",
"eslint-plugin-deprecation": "^3.0.0",
"eslint-plugin-jest": "^27.9.0",
"eslint-plugin-unicorn": "^51.0.1",
"jest": "^29.3.1",
Expand Down
4 changes: 2 additions & 2 deletions src/option.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ export abstract class Option {
}

protected parseNameAndDescriptionAndRemoveSettingBorder(setting: Setting, plugin: LinterPlugin) {
parseTextToHTMLWithoutOuterParagraph(this.getName(), setting.nameEl, plugin.settingsTab.component);
parseTextToHTMLWithoutOuterParagraph(this.getDescription(), setting.descEl, plugin.settingsTab.component);
parseTextToHTMLWithoutOuterParagraph(plugin.app, this.getName(), setting.nameEl, plugin.settingsTab.component);
parseTextToHTMLWithoutOuterParagraph(plugin.app, this.getDescription(), setting.descEl, plugin.settingsTab.component);

setting.settingEl.addClass('linter-no-border');
}
Expand Down
5 changes: 3 additions & 2 deletions src/ui/components/add-custom-refreshable-row.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {Component, Setting} from 'obsidian';
import {App, Component, Setting} from 'obsidian';
import {parseTextToHTMLWithoutOuterParagraph} from '../helpers';

/**
Expand All @@ -16,6 +16,7 @@ export abstract class AddCustomRefreshableRow {
public warning: string,
private addInputTooltip: string,
private refreshBtnTooltip: string,
protected app: App,
protected saveSettings: () => void,
private onAddInput: () => void,
private onRefresh: () => Promise<void>) {
Expand All @@ -26,7 +27,7 @@ export abstract class AddCustomRefreshableRow {

const descriptionAndWarningContainer = this.containerEl.createDiv({cls: 'setting-item-description'});

parseTextToHTMLWithoutOuterParagraph(this.description, descriptionAndWarningContainer.createEl('p', {cls: 'custom-row-description'}), this.parentComponent);
parseTextToHTMLWithoutOuterParagraph(this.app, this.description, descriptionAndWarningContainer.createEl('p', {cls: 'custom-row-description'}), this.parentComponent);

new Setting(this.containerEl)
.addButton((cb)=>{
Expand Down
5 changes: 3 additions & 2 deletions src/ui/components/add-custom-row.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {Component, Setting} from 'obsidian';
import {App, Component, Setting} from 'obsidian';
import {parseTextToHTMLWithoutOuterParagraph} from '../helpers';

/**
Expand All @@ -15,6 +15,7 @@ export abstract class AddCustomRow {
public description: string,
public warning: string,
private addInputBtnText: string,
protected app: App,
protected saveSettings: () => void,
private onAddInput: () => void) {
}
Expand All @@ -24,7 +25,7 @@ export abstract class AddCustomRow {

const descriptionAndWarningContainer = this.containerEl.createDiv({cls: 'setting-item-description'});

parseTextToHTMLWithoutOuterParagraph(this.description, descriptionAndWarningContainer.createEl('p', {cls: 'custom-row-description'}), this.parentComponent);
parseTextToHTMLWithoutOuterParagraph(this.app, this.description, descriptionAndWarningContainer.createEl('p', {cls: 'custom-row-description'}), this.parentComponent);

new Setting(this.containerEl)
.addButton((cb)=>{
Expand Down
4 changes: 2 additions & 2 deletions src/ui/components/base-setting.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ export abstract class BaseSetting<T> {
}

protected parseNameAndDescription() {
parseTextToHTMLWithoutOuterParagraph(this.name, this.setting.nameEl, this.plugin.settingsTab.component);
parseTextToHTMLWithoutOuterParagraph(this.description, this.setting.descEl, this.plugin.settingsTab.component);
parseTextToHTMLWithoutOuterParagraph(this.plugin.app, this.name, this.setting.nameEl, this.plugin.settingsTab.component);
parseTextToHTMLWithoutOuterParagraph(this.plugin.app, this.description, this.setting.descEl, this.plugin.settingsTab.component);
}

abstract display(): void;
Expand Down
6 changes: 3 additions & 3 deletions src/ui/helpers.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {Component, MarkdownRenderer} from 'obsidian';
import {App, Component, MarkdownRenderer} from 'obsidian';

export function parseTextToHTMLWithoutOuterParagraph(text: string, containerEl: HTMLElement, component: Component) {
void MarkdownRenderer.renderMarkdown(text, containerEl, '', component);
export function parseTextToHTMLWithoutOuterParagraph(app: App, text: string, containerEl: HTMLElement, component: Component) {
void MarkdownRenderer.render(app, text, containerEl, '', component);

let htmlString = containerEl.innerHTML.trim();
if (htmlString.startsWith('<p>')) {
Expand Down
3 changes: 2 additions & 1 deletion src/ui/linter-components/auto-correct-files-picker-option.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export type CustomAutoCorrectContent = {filePath: string, customReplacements: Ma
export class AutoCorrectFilesPickerOption extends AddCustomRefreshableRow {
private selectedFiles: string[] = [];

constructor(containerEl: HTMLElement, parentComponent: Component, public filesPicked: CustomAutoCorrectContent[], private app: App, saveSettings: () => void, name: LanguageStringKey, description: LanguageStringKey) {
constructor(containerEl: HTMLElement, parentComponent: Component, public filesPicked: CustomAutoCorrectContent[], app: App, saveSettings: () => void, name: LanguageStringKey, description: LanguageStringKey) {
super(
containerEl,
parentComponent,
Expand All @@ -19,6 +19,7 @@ export class AutoCorrectFilesPickerOption extends AddCustomRefreshableRow {
getTextInLanguage('options.custom-auto-correct.warning-text').replace('{NAME}', getTextInLanguage('rules.auto-correct-common-misspellings.name')),
getTextInLanguage('options.custom-auto-correct.add-new-replacement-file-tooltip'),
getTextInLanguage('options.custom-auto-correct.refresh-tooltip-text'),
app,
saveSettings,
()=>{
this.selectedFiles = [];
Expand Down
Loading

0 comments on commit 096bd93

Please sign in to comment.