Skip to content

Commit

Permalink
FIX: an option to bypass popclip heading was added.
Browse files Browse the repository at this point in the history
  • Loading branch information
canburaks committed Mar 9, 2024
1 parent 6e730f2 commit b522c92
Show file tree
Hide file tree
Showing 27 changed files with 1,897 additions and 3 deletions.
Binary file modified .DS_Store
Binary file not shown.
1 change: 1 addition & 0 deletions global.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ declare global {
interface CustomSettings {
useFrontmatter: boolean;
useHeader: boolean;
usePopclipHeading: boolean;
useSlugifyFileName?: boolean;
useTable: boolean;
useDatetimeAsFileName: boolean;
Expand Down
16 changes: 15 additions & 1 deletion main.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ var DEFAULT_SETTINGS = {
};
var CUSTOM_SETTINGS = {
useFrontmatter: true,
usePopclipHeading: true,
useHeader: true,
useDatetimeAsFileName: true,
useTable: true
Expand Down Expand Up @@ -152,6 +153,15 @@ var PopclipSettingsTab = class extends import_obsidian2.PluginSettingTab {
await this.plugin.saveSettings();
});
});
new import_obsidian2.Setting(containerEl).setName("Popclip Heading").setDesc(
"IMPORTANT!!! Deactivate this if you got error when using popclip with this plugin. This settings can broke things. Thus, always take a backup before changing this setting."
).addToggle((toggle) => {
toggle.setValue(this.plugin.settings.usePopclipHeading).onChange(async (value) => {
console.log("setting usePopclipHeading", value);
this.plugin.settings.usePopclipHeading = value;
await this.plugin.saveSettings();
});
});
}
};

Expand All @@ -161,7 +171,11 @@ var PopclipPlugin = class extends import_obsidian3.Plugin {
await this.loadSettings();
this.addSettingTab(new PopclipSettingsTab(this.app, this));
this.registerObsidianProtocolHandler(SETTINGS.action, async (ev) => {
if (ev.heading === SETTINGS.actionHeading) {
if (ev == null ? void 0 : ev.heading) {
if ((ev == null ? void 0 : ev.heading) === SETTINGS.actionHeading) {
new FileWriter(this.app, this).writeToFile(JSON.parse(ev.data));
}
} else if (!this.settings.usePopclipHeading) {
new FileWriter(this.app, this).writeToFile(JSON.parse(ev.data));
}
});
Expand Down
8 changes: 6 additions & 2 deletions main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@ export default class PopclipPlugin extends Plugin {
this.addSettingTab(new PopclipSettingsTab(this.app, this));

this.registerObsidianProtocolHandler(SETTINGS.action, async (ev) => {
if (ev.heading === SETTINGS.actionHeading) {
if (ev?.heading) {
if (ev?.heading === SETTINGS.actionHeading) {
new FileWriter(this.app, this).writeToFile(JSON.parse(ev.data));
}
} else if (!this.settings.usePopclipHeading) {
new FileWriter(this.app, this).writeToFile(JSON.parse(ev.data));
}
});
Expand All @@ -34,5 +38,5 @@ export default class PopclipPlugin extends Plugin {
await this.saveData(this.settings);
}

async activateView() {}
async activateView() { }
}
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"build": "tsc -noEmit -skipLibCheck && node esbuild.config.mjs production",
"version": "node version-bump.mjs && git add manifest.json versions.json",
"deploy": "npm run build && cp main.js styles.css manifest.json dist/popclip/",
"deploy:test-vault": "npm run build && cp main.js styles.css manifest.json ./test-vault/.obsidian/plugins/popclip",
"deploy:test": "npm run build && cp main.js styles.css manifest.json ~/Downloads/test/.obsidian/plugins/popclip"
},
"keywords": [],
Expand Down
Loading

0 comments on commit b522c92

Please sign in to comment.