diff --git a/manifest.json b/manifest.json index fc40a44..fd355fa 100644 --- a/manifest.json +++ b/manifest.json @@ -6,5 +6,5 @@ "authorUrl": "https://atbug.com", "isDesktopOnly": true, "minAppVersion": "0.11.0", - "version": "0.5.1" + "version": "0.5.2" } diff --git a/package.json b/package.json index 2f9e4eb..77bb985 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "obsidian-image-upload-toolkit", - "version": "0.5.1", + "version": "0.5.2", "description": "", "author": "addozhang", "main": "main.js", diff --git a/src/publish.ts b/src/publish.ts index 2ea6234..ee03deb 100644 --- a/src/publish.ts +++ b/src/publish.ts @@ -15,7 +15,8 @@ import {ImagekitSetting} from "./uploader/imagekit/imagekitUploader"; export interface PublishSettings { imageAltText: boolean; - replaceOriginalDoc: boolean + replaceOriginalDoc: boolean; + ignoreProperties: boolean; attachmentLocation: string; imageStore: string; //Imgur Anonymous setting @@ -27,6 +28,7 @@ export interface PublishSettings { const DEFAULT_SETTINGS: PublishSettings = { imageAltText: true, replaceOriginalDoc: false, + ignoreProperties: true, attachmentLocation: ".", imageStore: ImageStore.IMGUR.id, imgurAnonymousSetting: {clientId: IMGUR_PLUGIN_CLIENT_ID}, diff --git a/src/ui/publishSettingTab.ts b/src/ui/publishSettingTab.ts index 04b5e6a..de192d6 100644 --- a/src/ui/publishSettingTab.ts +++ b/src/ui/publishSettingTab.ts @@ -38,22 +38,31 @@ export default class PublishSettingTab extends PluginSettingTab { }) ); - new Setting((imageStoreTypeDiv)) + new Setting(imageStoreTypeDiv) .setName("Use image name as Alt Text") .setDesc("Whether to use image name as Alt Text with '-' and '_' replaced with space.") .addToggle(toggle => toggle .setValue(this.plugin.settings.imageAltText) - .onChange( value => this.plugin.settings.imageAltText = value) + .onChange(value => this.plugin.settings.imageAltText = value) ); - new Setting((imageStoreTypeDiv)) + new Setting(imageStoreTypeDiv) .setName("Update original document") .setDesc("Whether to replace internal link with store link.") .addToggle(toggle => toggle .setValue(this.plugin.settings.replaceOriginalDoc) - .onChange( value => this.plugin.settings.replaceOriginalDoc = value) + .onChange(value => this.plugin.settings.replaceOriginalDoc = value) + ); + + new Setting(imageStoreTypeDiv) + .setName("Ignore note properties") + .setDesc("Where to ignore note properties when copying to clipboard. This won't affect original note.") + .addToggle(toggle => + toggle + .setValue(this.plugin.settings.ignoreProperties) + .onChange(value => this.plugin.settings.ignoreProperties = value) ); // Image Store diff --git a/src/uploader/imageTagProcessor.ts b/src/uploader/imageTagProcessor.ts index 7ca5695..5eb0070 100644 --- a/src/uploader/imageTagProcessor.ts +++ b/src/uploader/imageTagProcessor.ts @@ -5,6 +5,7 @@ import {PublishSettings} from "../publish"; const MD_REGEX = /\!\[(.*)\]\((.*?\.(png|jpg|jpeg|gif|svg|webp|excalidraw))\)/g; const WIKI_REGEX = /\!\[\[(.*?\.(png|jpg|jpeg|gif|svg|webp|excalidraw))(|.*)?\]\]/g; +const PROPERTIES_REGEX = /^---[\s\S]+?---\n/; interface Image { name: string; @@ -59,6 +60,9 @@ export default class ImageTagProcessor { if (this.settings.replaceOriginalDoc) { this.getEditor()?.setValue(value); } + if (this.settings.ignoreProperties) { + value = value.replace(PROPERTIES_REGEX, ''); + } switch (action) { case ACTION_PUBLISH: navigator.clipboard.writeText(value);