Skip to content

Commit

Permalink
Merge pull request #1 from dario-baumberger/feature/release-improvements
Browse files Browse the repository at this point in the history
Feature/release improvements
  • Loading branch information
dario-baumberger authored Oct 20, 2023
2 parents cbf2895 + c12b868 commit b6dbf60
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 39 deletions.
4 changes: 2 additions & 2 deletions manifest.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"id": "json-table",
"name": "JSON table",
"version": "1.0.0",
"version": "1.0.1",
"minAppVersion": "0.15.0",
"description": "Simply switch between JSON and tables. Generate a table from a JSON string or a URL (which returns JSON) in your notes. Generate JSON from a table in your notes.",
"author": "Dario Baumberger",
"authorUrl": "https://github.com/dario-baumberger",
"fundingUrl": "https://www.buymeacoffee.com/dariobaumberger",
"isDesktopOnly": false
}
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "obsidian-json-table",
"version": "1.0.0",
"version": "1.0.1",
"description": "Simply switch between JSON and tables. Generate a table from a JSON string or a URL (which returns JSON) in your notes. Generate JSON from a table in your notes.",
"main": "main.js",
"scripts": {
Expand Down
29 changes: 18 additions & 11 deletions src/main.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {jsonToTable, tableToJson} from "src/functions";
import {Editor, Notice, Plugin} from "obsidian";
import {Editor, Notice, Plugin, requestUrl} from "obsidian";
import {JsonTablePluginSettingTab} from "src/settings";

interface JsonTablePluginSettings {
Expand All @@ -19,6 +19,7 @@ export default class JsonTablePlugin extends Plugin {
this.addCommand({
id: "generate-table-from-selected-json",
name: "Generate table from selected JSON",
icon: "table",
editorCallback: (editor: Editor) => {
if (this.settings.devMode) {
console.log("JSON Table Selection:", editor.getSelection());
Expand All @@ -35,28 +36,34 @@ export default class JsonTablePlugin extends Plugin {
this.addCommand({
id: "generate-table-from-selected-json-url",
name: "Generate table from selected JSON URL",
icon: "link",
editorCallback: async (editor: Editor) => {
const selection = editor.getSelection();
const response = await fetch(selection);

if (!response.ok) {
console.error(response.statusText);
new Notice(response.statusText);
}

const json = await response.json();
try {
const response = await requestUrl(selection);

editor.replaceSelection(jsonToTable(JSON.stringify(json)));
editor.replaceSelection(
jsonToTable(JSON.stringify(response.json))
);

if (this.settings.devMode) {
console.log("JSON Table fetch response:", json);
if (this.settings.devMode) {
console.log(
"JSON Table fetch response:",
response.json
);
}
} catch (error) {
console.error(error);
new Notice(error);
}
}
});

this.addCommand({
id: "generate-json-from-selected-table",
name: "Generate JSON from selected table",
icon: "file-json",
editorCallback: (editor: Editor) => {
if (this.settings.devMode) {
console.log("JSON Table Selection:", editor.getSelection());
Expand Down
23 changes: 0 additions & 23 deletions src/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,29 +14,6 @@ export class JsonTablePluginSettingTab extends PluginSettingTab {

containerEl.empty();

containerEl.createEl("h4", {
text: "Commands"
});

new Setting(containerEl)
.setName("Generate table from selected JSON")
.setDesc(
"Creates a Markdown table based on your selected JSON. The JSON needs to be valid."
);

new Setting(containerEl)
.setName("Generate table from selected JSON URL")
.setDesc(
"Creates a Markdown table based on JSON data from a selected URL. The URL needs to return valid JSON."
);

new Setting(containerEl)
.setName("Generate JSON from selected table")
.setDesc("Creatse JSON based on your selected table.");

containerEl.createEl("h4", {
text: "Debug Logging"
});
new Setting(containerEl)
.setName("Enable debug logging")
.setDesc("If enabled, more will be logged in the console.")
Expand Down
5 changes: 3 additions & 2 deletions versions.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{
"1.0.0": "0.15.0"
}
"1.0.0": "0.15.0",
"1.0.1": "0.15.0"
}

0 comments on commit b6dbf60

Please sign in to comment.