mirror of
https://github.com/keathmilligan/obsidian-paste-reformatter.git
synced 2026-07-22 05:43:44 +00:00
Add toggle for notifications (#15)
This commit is contained in:
parent
b80d494bed
commit
7435a160b7
5 changed files with 24 additions and 5 deletions
|
|
@ -36,7 +36,7 @@ The Paste Reformatter plugin automatically processes content when you paste it i
|
|||
4. Applies Markdown transformations (heading adjustments, line break handling, regex string replacement)
|
||||
5. Inserts the transformed content at the cursor position
|
||||
|
||||
A notification will appear briefly indicating whether HTML or plain text content was reformatted.
|
||||
A notification will appear briefly indicating whether HTML or plain text content was reformatted. This can be disabled in settings.
|
||||
|
||||
### Commands
|
||||
|
||||
|
|
@ -62,6 +62,10 @@ Paste Reformatter can potentially conflict with other Obsidian plugins that over
|
|||
When this setting is enabled, the default behavior of Obsidian's Paste function will be enhanced. Otherwise,
|
||||
**Reformat and Paste** command can be bound to an alternative hot-key to get enhanced paste behavior.
|
||||
|
||||
#### Show paste notifications
|
||||
|
||||
When enabled, a notice appears after reformatting content. Disable this to hide notifications.
|
||||
|
||||
### HTML Transformations
|
||||
|
||||
These settings control how HTML content is processed before being converted to Markdown.
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"id": "paste-reformatter",
|
||||
"name": "Paste Reformatter",
|
||||
"version": "1.3.0",
|
||||
"version": "1.4.0",
|
||||
"minAppVersion": "0.15.0",
|
||||
"description": "Reformat pasted text for precise control.",
|
||||
"author": "Keath Milligan",
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "obsidian-sample-plugin",
|
||||
"version": "1.3.0",
|
||||
"version": "1.4.0",
|
||||
"description": "This is a sample plugin for Obsidian (https://obsidian.md)",
|
||||
"main": "dist/main.js",
|
||||
"scripts": {
|
||||
|
|
|
|||
14
src/main.ts
14
src/main.ts
|
|
@ -12,6 +12,7 @@ interface RegexReplacement {
|
|||
|
||||
interface PasteReformmatterSettings {
|
||||
pasteOverride: boolean; // Whether to override the default paste behavior
|
||||
showPasteNotifications: boolean; // Whether to show a notice after successful paste reformatting
|
||||
maxHeadingLevel: number; // The maximum heading level to allow (1-6, where 1 is disabled)
|
||||
removeEmptyElements: boolean; // Whether to remove empty elements when reformatting pasted content
|
||||
cascadeHeadingLevels: boolean; // Whether to cascade heading levels (e.g., H1→H2→H3 becomes H2→H3→H4 when max level is H2)
|
||||
|
|
@ -25,6 +26,7 @@ interface PasteReformmatterSettings {
|
|||
|
||||
const DEFAULT_SETTINGS: PasteReformmatterSettings = {
|
||||
pasteOverride: true,
|
||||
showPasteNotifications: true,
|
||||
maxHeadingLevel: 1,
|
||||
removeEmptyElements: false,
|
||||
cascadeHeadingLevels: true,
|
||||
|
|
@ -191,7 +193,9 @@ export default class PasteReformatter extends Plugin {
|
|||
if (appliedHTMLTransformations || appliedMarkdownTransformations) {
|
||||
// Replace the current selection with the converted markdown
|
||||
editor.replaceSelection(markdownResult.markdown);
|
||||
if (this.settings.showPasteNotifications) {
|
||||
new Notice(`Reformatted pasted content`);
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
|
|
@ -303,6 +307,16 @@ class PasteReformmatterSettingsTab extends PluginSettingTab {
|
|||
await this.plugin.saveSettings();
|
||||
}));
|
||||
|
||||
new Setting(containerEl)
|
||||
.setName('Show paste notifications')
|
||||
.setDesc('Display a notice when pasted content is reformatted.')
|
||||
.addToggle(toggle => toggle
|
||||
.setValue(this.plugin.settings.showPasteNotifications)
|
||||
.onChange(async (value) => {
|
||||
this.plugin.settings.showPasteNotifications = value;
|
||||
await this.plugin.saveSettings();
|
||||
}));
|
||||
|
||||
// HTML Transformations
|
||||
new Setting(containerEl)
|
||||
.setName('HTML transformations')
|
||||
|
|
|
|||
|
|
@ -5,5 +5,6 @@
|
|||
"1.2.0": "0.15.0",
|
||||
"1.2.1": "0.15.0",
|
||||
"1.2.2": "0.15.0",
|
||||
"1.3.0": "0.15.0"
|
||||
"1.3.0": "0.15.0",
|
||||
"1.4.0": "0.15.0"
|
||||
}
|
||||
Loading…
Reference in a new issue