Skip to content
This repository has been archived by the owner on Oct 30, 2023. It is now read-only.

Commit

Permalink
Add deprecation notice
Browse files Browse the repository at this point in the history
  • Loading branch information
dbarenholz committed Oct 27, 2023
1 parent 2c30a6e commit c82d75b
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 5 deletions.
4 changes: 2 additions & 2 deletions manifest.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"id": "obsidian-plaintext",
"name": "Plaintext",
"version": "0.3.0",
"version": "0.4.0",
"minAppVersion": "0.15.9",
"description": "Open any file as if it was plaintext directly in Obsidian.",
"description": "[Deprecated] Open any file as if it was plaintext directly in Obsidian.",
"author": "dbarenholz",
"authorUrl": "https://github.com/dbarenholz/dbarenholz",
"isDesktopOnly": false
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "obsidian-plaintext",
"version": "0.3.0",
"description": "Open any file as if it was plaintext directly in Obsidian.",
"version": "0.4.0",
"description": "[Deprecated] Open any file as if it was plaintext directly in Obsidian.",
"main": "main.js",
"scripts": {
"dev": "node esbuild.config.mjs",
Expand Down
25 changes: 24 additions & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
TFolder,
TAbstractFile,
normalizePath,
Notice,
} from "obsidian";
import {
removeObsidianExtensions,
Expand Down Expand Up @@ -49,6 +50,7 @@ export default class PlaintextPlugin extends Plugin {
id: "new-plaintext-file",
name: "Create new plaintext file",
callback: () => {
this.showDeprecationMessage();
this.createNewFile(app.vault.getRoot());
},
});
Expand All @@ -63,13 +65,34 @@ export default class PlaintextPlugin extends Plugin {
menu.addItem((item) => {
item.setTitle("New plaintext file")
.setIcon("file-plus")
.onClick(async () => this.createNewFile(file));
.onClick(async () => {
this.showDeprecationMessage();
this.createNewFile(file);
});
});
})
);

// 4. Other initialization
this.registerViewsForExtensions(this.settings.extensions);

// Show the deprecation message.
this.showDeprecationMessage();

}

deprecationFragment() {
// Use a DocumentFragmet to put a link in a notice.
const documentFragment = new DocumentFragment();
documentFragment.createEl("span", { text: "Plaintext will soon be deprecated and removed from the community store." })
documentFragment.createEl("span", { text: " Please use " })
documentFragment.createEl("a", { text: "Obsidian VSCode Editor", href: "obsidian://show-plugin?id=vscode-editor" })
documentFragment.createEl("span", { text: " instead!" })
return documentFragment;
}

showDeprecationMessage() {
new Notice(this.deprecationFragment(), 0);
}

onunload(): void {
Expand Down
5 changes: 5 additions & 0 deletions src/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,11 @@ export class PlaintextSettingTab extends PluginSettingTab {
// Write the title of the settings page.
containerEl.createEl("h2", { text: "Plaintext" });

// Add deprecation message here too
new Setting(containerEl)
.setName("Notice")
.setDesc(this.plugin.deprecationFragment());

// Add extension setting
new Setting(containerEl)
.setName("Extensions")
Expand Down
1 change: 1 addition & 0 deletions versions.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"0.4.0": "0.15.9",
"0.3.0": "0.15.9",
"0.2.0": "0.15.9",
"0.1.0": "0.13.14",
Expand Down

0 comments on commit c82d75b

Please sign in to comment.