obsidian-plugin-config 1.3.9 → 1.3.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,66 +1,67 @@
1
- import { App, Modal } from "obsidian";
1
+ import { App, Modal } from 'obsidian';
2
2
 
3
3
  export interface ConfirmModalOptions {
4
- title: string;
5
- message: string;
6
- confirmText?: string;
7
- cancelText?: string;
8
- onConfirm: () => void;
9
- onCancel?: () => void;
4
+ title: string;
5
+ message: string;
6
+ confirmText?: string;
7
+ cancelText?: string;
8
+ onConfirm: () => void;
9
+ onCancel?: () => void;
10
10
  }
11
11
 
12
12
  export class GenericConfirmModal extends Modal {
13
- private options: ConfirmModalOptions;
13
+ private options: ConfirmModalOptions;
14
14
 
15
- constructor(app: App, options: ConfirmModalOptions) {
16
- super(app);
17
- this.options = options;
18
- }
15
+ constructor(app: App, options: ConfirmModalOptions) {
16
+ super(app);
17
+ this.options = options;
18
+ }
19
19
 
20
- onOpen(): void {
21
- const { contentEl } = this;
22
- contentEl.empty();
20
+ onOpen(): void {
21
+ const { contentEl } = this;
22
+ contentEl.empty();
23
23
 
24
- const title = this.options.title.charAt(0).toUpperCase() + this.options.title.slice(1);
25
- contentEl.createEl("h2", { text: title });
24
+ const title =
25
+ this.options.title.charAt(0).toUpperCase() + this.options.title.slice(1);
26
+ contentEl.createEl('h2', { text: title });
26
27
 
27
- // Message
28
- contentEl.createEl("p", { text: this.options.message });
28
+ // Message
29
+ contentEl.createEl('p', { text: this.options.message });
29
30
 
30
- // Buttons container
31
- const buttonContainer = contentEl.createDiv("modal-button-container");
31
+ // Buttons container
32
+ const buttonContainer = contentEl.createDiv('modal-button-container');
32
33
 
33
- // Cancel button
34
- const cancelBtn = buttonContainer.createEl("button", {
35
- text: this.options.cancelText || "Cancel",
36
- cls: "mod-cta"
37
- });
38
- cancelBtn.addEventListener("click", () => {
39
- this.options.onCancel?.();
40
- this.close();
41
- });
34
+ // Cancel button
35
+ const cancelBtn = buttonContainer.createEl('button', {
36
+ text: this.options.cancelText || 'Cancel',
37
+ cls: 'mod-cta'
38
+ });
39
+ cancelBtn.addEventListener('click', () => {
40
+ this.options.onCancel?.();
41
+ this.close();
42
+ });
42
43
 
43
- // Confirm button
44
- const confirmBtn = buttonContainer.createEl("button", {
45
- text: this.options.confirmText || "Confirm",
46
- cls: "mod-cta mod-warning"
47
- });
48
- confirmBtn.addEventListener("click", () => {
49
- this.options.onConfirm();
50
- this.close();
51
- });
44
+ // Confirm button
45
+ const confirmBtn = buttonContainer.createEl('button', {
46
+ text: this.options.confirmText || 'Confirm',
47
+ cls: 'mod-cta mod-warning'
48
+ });
49
+ confirmBtn.addEventListener('click', () => {
50
+ this.options.onConfirm();
51
+ this.close();
52
+ });
52
53
 
53
- // Focus on confirm button
54
- confirmBtn.focus();
55
- }
54
+ // Focus on confirm button
55
+ confirmBtn.focus();
56
+ }
56
57
 
57
- onClose(): void {
58
- const { contentEl } = this;
59
- contentEl.empty();
60
- }
58
+ onClose(): void {
59
+ const { contentEl } = this;
60
+ contentEl.empty();
61
+ }
61
62
  }
62
63
 
63
64
  // Utility function for quick usage
64
65
  export function showConfirmModal(app: App, options: ConfirmModalOptions): void {
65
- new GenericConfirmModal(app, options).open();
66
+ new GenericConfirmModal(app, options).open();
66
67
  }
@@ -1,9 +1,9 @@
1
1
  // Simple tools for testing
2
2
  export function showTestMessage(): string {
3
- return "✅ CENTRALIZED TOOLS WORK! This comes from obsidian-plugin-config!";
3
+ return '✅ CENTRALIZED TOOLS WORK! This comes from obsidian-plugin-config!';
4
4
  }
5
5
 
6
6
  export function getRandomEmoji(): string {
7
- const emojis = ["🚀", "🎉", "", "🔥", "💯", "", "🎯", "🌟"];
8
- return emojis[Math.floor(Math.random() * emojis.length)];
7
+ const emojis = ['🚀', '🎉', '', '🔥', '💯', '', '🎯', '🌟'];
8
+ return emojis[Math.floor(Math.random() * emojis.length)];
9
9
  }
@@ -1,102 +1,85 @@
1
- import { Notice } from "obsidian";
1
+ import { Notice } from 'obsidian';
2
2
 
3
3
  /**
4
4
  * Enhanced Notice helper with different types and durations
5
5
  */
6
6
  export class NoticeHelper {
7
- private static readonly DEFAULT_DURATION = 5000;
8
- private static readonly SUCCESS_DURATION = 3000;
9
- private static readonly ERROR_DURATION = 8000;
10
- private static readonly WARNING_DURATION = 6000;
7
+ private static readonly DEFAULT_DURATION = 5000;
8
+ private static readonly SUCCESS_DURATION = 3000;
9
+ private static readonly ERROR_DURATION = 8000;
10
+ private static readonly WARNING_DURATION = 6000;
11
11
 
12
- /**
13
- * Show a success notice with green styling
14
- */
15
- static success(message: string, duration?: number): Notice {
16
- const notice = new Notice(
17
- `✅ ${message}`,
18
- duration ?? this.SUCCESS_DURATION
19
- );
20
- return notice;
21
- }
12
+ /**
13
+ * Show a success notice with green styling
14
+ */
15
+ static success(message: string, duration?: number): Notice {
16
+ const notice = new Notice(`✅ ${message}`, duration ?? this.SUCCESS_DURATION);
17
+ return notice;
18
+ }
22
19
 
23
- /**
24
- * Show an error notice with red styling
25
- */
26
- static error(message: string, duration?: number): Notice {
27
- const notice = new Notice(
28
- `❌ ${message}`,
29
- duration ?? this.ERROR_DURATION
30
- );
31
- return notice;
32
- }
20
+ /**
21
+ * Show an error notice with red styling
22
+ */
23
+ static error(message: string, duration?: number): Notice {
24
+ const notice = new Notice(`❌ ${message}`, duration ?? this.ERROR_DURATION);
25
+ return notice;
26
+ }
33
27
 
34
- /**
35
- * Show a warning notice with yellow styling
36
- */
37
- static warning(message: string, duration?: number): Notice {
38
- const notice = new Notice(
39
- `⚠️ ${message}`,
40
- duration ?? this.WARNING_DURATION
41
- );
42
- return notice;
43
- }
28
+ /**
29
+ * Show a warning notice with yellow styling
30
+ */
31
+ static warning(message: string, duration?: number): Notice {
32
+ const notice = new Notice(`⚠️ ${message}`, duration ?? this.WARNING_DURATION);
33
+ return notice;
34
+ }
44
35
 
45
- /**
46
- * Show an info notice with blue styling
47
- */
48
- static info(message: string, duration?: number): Notice {
49
- const notice = new Notice(
50
- `ℹ️ ${message}`,
51
- duration ?? this.DEFAULT_DURATION
52
- );
53
- return notice;
54
- }
36
+ /**
37
+ * Show an info notice with blue styling
38
+ */
39
+ static info(message: string, duration?: number): Notice {
40
+ const notice = new Notice(`ℹ️ ${message}`, duration ?? this.DEFAULT_DURATION);
41
+ return notice;
42
+ }
55
43
 
56
- /**
57
- * Show a loading notice that can be updated
58
- */
59
- static loading(message: string): Notice {
60
- return new Notice(`⏳ ${message}`, 0); // 0 = permanent until manually hidden
61
- }
44
+ /**
45
+ * Show a loading notice that can be updated
46
+ */
47
+ static loading(message: string): Notice {
48
+ return new Notice(`⏳ ${message}`, 0); // 0 = permanent until manually hidden
49
+ }
62
50
 
63
- /**
64
- * Update a loading notice to success and auto-hide
65
- */
66
- static updateToSuccess(notice: Notice, message: string): void {
67
- notice.setMessage(`✅ ${message}`);
68
- setTimeout(() => notice.hide(), this.SUCCESS_DURATION);
69
- }
51
+ /**
52
+ * Update a loading notice to success and auto-hide
53
+ */
54
+ static updateToSuccess(notice: Notice, message: string): void {
55
+ notice.setMessage(`✅ ${message}`);
56
+ setTimeout(() => notice.hide(), this.SUCCESS_DURATION);
57
+ }
70
58
 
71
- /**
72
- * Update a loading notice to error and auto-hide
73
- */
74
- static updateToError(notice: Notice, message: string): void {
75
- notice.setMessage(`❌ ${message}`);
76
- setTimeout(() => notice.hide(), this.ERROR_DURATION);
77
- }
59
+ /**
60
+ * Update a loading notice to error and auto-hide
61
+ */
62
+ static updateToError(notice: Notice, message: string): void {
63
+ notice.setMessage(`❌ ${message}`);
64
+ setTimeout(() => notice.hide(), this.ERROR_DURATION);
65
+ }
78
66
 
79
- /**
80
- * Show a notice with custom emoji and duration
81
- */
82
- static custom(emoji: string, message: string, duration?: number): Notice {
83
- return new Notice(
84
- `${emoji} ${message}`,
85
- duration ?? this.DEFAULT_DURATION
86
- );
87
- }
67
+ /**
68
+ * Show a notice with custom emoji and duration
69
+ */
70
+ static custom(emoji: string, message: string, duration?: number): Notice {
71
+ return new Notice(`${emoji} ${message}`, duration ?? this.DEFAULT_DURATION);
72
+ }
88
73
 
89
- /**
90
- * Show a progress notice for long operations
91
- */
92
- static progress(message: string, current: number, total: number): Notice {
93
- const percentage = Math.round((current / total) * 100);
94
- const progressBar = "█".repeat(Math.floor(percentage / 5)) +
95
- "░".repeat(20 - Math.floor(percentage / 5));
96
-
97
- return new Notice(
98
- `🔄 ${message}\n[${progressBar}] ${percentage}%`,
99
- 0
100
- );
101
- }
74
+ /**
75
+ * Show a progress notice for long operations
76
+ */
77
+ static progress(message: string, current: number, total: number): Notice {
78
+ const percentage = Math.round((current / total) * 100);
79
+ const progressBar =
80
+ '█'.repeat(Math.floor(percentage / 5)) +
81
+ '░'.repeat(20 - Math.floor(percentage / 5));
82
+
83
+ return new Notice(`🔄 ${message}\n[${progressBar}] ${percentage}%`, 0);
84
+ }
102
85
  }
@@ -1,180 +1,170 @@
1
- import { Setting } from "obsidian";
1
+ import { Setting } from 'obsidian';
2
2
 
3
3
  /**
4
4
  * Helper for creating common setting types with consistent styling
5
5
  */
6
6
  export class SettingsHelper {
7
-
8
- /**
9
- * Create a text input setting
10
- */
11
- static createTextSetting(
12
- containerEl: HTMLElement,
13
- name: string,
14
- desc: string,
15
- value: string,
16
- onChange: (value: string) => void,
17
- placeholder?: string
18
- ): Setting {
19
- return new Setting(containerEl)
20
- .setName(name)
21
- .setDesc(desc)
22
- .addText(text => text
23
- .setPlaceholder(placeholder || "")
24
- .setValue(value)
25
- .onChange(onChange)
26
- );
27
- }
7
+ /**
8
+ * Create a text input setting
9
+ */
10
+ static createTextSetting(
11
+ containerEl: HTMLElement,
12
+ name: string,
13
+ desc: string,
14
+ value: string,
15
+ onChange: (value: string) => void,
16
+ placeholder?: string
17
+ ): Setting {
18
+ return new Setting(containerEl)
19
+ .setName(name)
20
+ .setDesc(desc)
21
+ .addText((text) =>
22
+ text
23
+ .setPlaceholder(placeholder || '')
24
+ .setValue(value)
25
+ .onChange(onChange)
26
+ );
27
+ }
28
28
 
29
- /**
30
- * Create a toggle setting
31
- */
32
- static createToggleSetting(
33
- containerEl: HTMLElement,
34
- name: string,
35
- desc: string,
36
- value: boolean,
37
- onChange: (value: boolean) => void
38
- ): Setting {
39
- return new Setting(containerEl)
40
- .setName(name)
41
- .setDesc(desc)
42
- .addToggle(toggle => toggle
43
- .setValue(value)
44
- .onChange(onChange)
45
- );
46
- }
29
+ /**
30
+ * Create a toggle setting
31
+ */
32
+ static createToggleSetting(
33
+ containerEl: HTMLElement,
34
+ name: string,
35
+ desc: string,
36
+ value: boolean,
37
+ onChange: (value: boolean) => void
38
+ ): Setting {
39
+ return new Setting(containerEl)
40
+ .setName(name)
41
+ .setDesc(desc)
42
+ .addToggle((toggle) => toggle.setValue(value).onChange(onChange));
43
+ }
47
44
 
48
- /**
49
- * Create a dropdown setting
50
- */
51
- static createDropdownSetting(
52
- containerEl: HTMLElement,
53
- name: string,
54
- desc: string,
55
- options: Record<string, string>,
56
- value: string,
57
- onChange: (value: string) => void
58
- ): Setting {
59
- return new Setting(containerEl)
60
- .setName(name)
61
- .setDesc(desc)
62
- .addDropdown(dropdown => {
63
- Object.entries(options).forEach(([key, label]) => {
64
- dropdown.addOption(key, label);
65
- });
66
- dropdown
67
- .setValue(value)
68
- .onChange(onChange);
69
- });
70
- }
45
+ /**
46
+ * Create a dropdown setting
47
+ */
48
+ static createDropdownSetting(
49
+ containerEl: HTMLElement,
50
+ name: string,
51
+ desc: string,
52
+ options: Record<string, string>,
53
+ value: string,
54
+ onChange: (value: string) => void
55
+ ): Setting {
56
+ return new Setting(containerEl)
57
+ .setName(name)
58
+ .setDesc(desc)
59
+ .addDropdown((dropdown) => {
60
+ Object.entries(options).forEach(([key, label]) => {
61
+ dropdown.addOption(key, label);
62
+ });
63
+ dropdown.setValue(value).onChange(onChange);
64
+ });
65
+ }
71
66
 
72
- /**
73
- * Create a number input setting
74
- */
75
- static createNumberSetting(
76
- containerEl: HTMLElement,
77
- name: string,
78
- desc: string,
79
- value: number,
80
- onChange: (value: number) => void,
81
- min?: number,
82
- max?: number,
83
- step?: number
84
- ): Setting {
85
- return new Setting(containerEl)
86
- .setName(name)
87
- .setDesc(desc)
88
- .addText(text => {
89
- text.inputEl.type = "number";
90
- if (min !== undefined) text.inputEl.min = min.toString();
91
- if (max !== undefined) text.inputEl.max = max.toString();
92
- if (step !== undefined) text.inputEl.step = step.toString();
93
-
94
- text
95
- .setValue(value.toString())
96
- .onChange(val => {
97
- const num = parseFloat(val);
98
- if (!isNaN(num)) onChange(num);
99
- });
100
- });
101
- }
67
+ /**
68
+ * Create a number input setting
69
+ */
70
+ static createNumberSetting(
71
+ containerEl: HTMLElement,
72
+ name: string,
73
+ desc: string,
74
+ value: number,
75
+ onChange: (value: number) => void,
76
+ min?: number,
77
+ max?: number,
78
+ step?: number
79
+ ): Setting {
80
+ return new Setting(containerEl)
81
+ .setName(name)
82
+ .setDesc(desc)
83
+ .addText((text) => {
84
+ text.inputEl.type = 'number';
85
+ if (min !== undefined) text.inputEl.min = min.toString();
86
+ if (max !== undefined) text.inputEl.max = max.toString();
87
+ if (step !== undefined) text.inputEl.step = step.toString();
102
88
 
103
- /**
104
- * Create a button setting
105
- */
106
- static createButtonSetting(
107
- containerEl: HTMLElement,
108
- name: string,
109
- desc: string,
110
- buttonText: string,
111
- onClick: () => void
112
- ): Setting {
113
- return new Setting(containerEl)
114
- .setName(name)
115
- .setDesc(desc)
116
- .addButton(button => button
117
- .setButtonText(buttonText)
118
- .onClick(onClick)
119
- );
120
- }
89
+ text.setValue(value.toString()).onChange((val) => {
90
+ const num = parseFloat(val);
91
+ if (!isNaN(num)) onChange(num);
92
+ });
93
+ });
94
+ }
121
95
 
122
- /**
123
- * Create a section header
124
- */
125
- static createHeader(
126
- containerEl: HTMLElement,
127
- title: string,
128
- description?: string
129
- ): void {
130
- const headerEl = containerEl.createEl("h3", { text: title });
131
- headerEl.style.marginTop = "20px";
132
- headerEl.style.marginBottom = "10px";
133
- headerEl.style.borderBottom = "1px solid var(--background-modifier-border)";
134
- headerEl.style.paddingBottom = "5px";
135
-
136
- if (description) {
137
- const descEl = containerEl.createEl("p", { text: description });
138
- descEl.style.marginTop = "0";
139
- descEl.style.marginBottom = "15px";
140
- descEl.style.color = "var(--text-muted)";
141
- descEl.style.fontSize = "0.9em";
142
- }
143
- }
96
+ /**
97
+ * Create a button setting
98
+ */
99
+ static createButtonSetting(
100
+ containerEl: HTMLElement,
101
+ name: string,
102
+ desc: string,
103
+ buttonText: string,
104
+ onClick: () => void
105
+ ): Setting {
106
+ return new Setting(containerEl)
107
+ .setName(name)
108
+ .setDesc(desc)
109
+ .addButton((button) => button.setButtonText(buttonText).onClick(onClick));
110
+ }
144
111
 
145
- /**
146
- * Create a collapsible section
147
- */
148
- static createCollapsibleSection(
149
- containerEl: HTMLElement,
150
- title: string,
151
- isOpen: boolean = false
152
- ): { container: HTMLElement; toggle: () => void } {
153
- const sectionEl = containerEl.createDiv("setting-item");
154
- const headerEl = sectionEl.createDiv("setting-item-info");
155
- const nameEl = headerEl.createDiv("setting-item-name");
156
- nameEl.setText(title);
157
- nameEl.style.cursor = "pointer";
158
- nameEl.style.userSelect = "none";
159
-
160
- const contentEl = containerEl.createDiv("collapsible-content");
161
- contentEl.style.display = isOpen ? "block" : "none";
162
- contentEl.style.marginLeft = "20px";
163
- contentEl.style.marginTop = "10px";
164
-
165
- const arrow = nameEl.createSpan("collapse-icon");
166
- arrow.setText(isOpen ? "▼" : "▶");
167
- arrow.style.marginRight = "8px";
168
- arrow.style.fontSize = "0.8em";
169
-
170
- const toggle = () : void => {
171
- const isCurrentlyOpen = contentEl.style.display !== "none";
172
- contentEl.style.display = isCurrentlyOpen ? "none" : "block";
173
- arrow.setText(isCurrentlyOpen ? "▶" : "▼");
174
- };
175
-
176
- nameEl.addEventListener("click", toggle);
177
-
178
- return { container: contentEl, toggle };
179
- }
112
+ /**
113
+ * Create a section header
114
+ */
115
+ static createHeader(
116
+ containerEl: HTMLElement,
117
+ title: string,
118
+ description?: string
119
+ ): void {
120
+ const headerEl = containerEl.createEl('h3', { text: title });
121
+ headerEl.style.marginTop = '20px';
122
+ headerEl.style.marginBottom = '10px';
123
+ headerEl.style.borderBottom = '1px solid var(--background-modifier-border)';
124
+ headerEl.style.paddingBottom = '5px';
125
+
126
+ if (description) {
127
+ const descEl = containerEl.createEl('p', { text: description });
128
+ descEl.style.marginTop = '0';
129
+ descEl.style.marginBottom = '15px';
130
+ descEl.style.color = 'var(--text-muted)';
131
+ descEl.style.fontSize = '0.9em';
132
+ }
133
+ }
134
+
135
+ /**
136
+ * Create a collapsible section
137
+ */
138
+ static createCollapsibleSection(
139
+ containerEl: HTMLElement,
140
+ title: string,
141
+ isOpen: boolean = false
142
+ ): { container: HTMLElement; toggle: () => void } {
143
+ const sectionEl = containerEl.createDiv('setting-item');
144
+ const headerEl = sectionEl.createDiv('setting-item-info');
145
+ const nameEl = headerEl.createDiv('setting-item-name');
146
+ nameEl.setText(title);
147
+ nameEl.style.cursor = 'pointer';
148
+ nameEl.style.userSelect = 'none';
149
+
150
+ const contentEl = containerEl.createDiv('collapsible-content');
151
+ contentEl.style.display = isOpen ? 'block' : 'none';
152
+ contentEl.style.marginLeft = '20px';
153
+ contentEl.style.marginTop = '10px';
154
+
155
+ const arrow = nameEl.createSpan('collapse-icon');
156
+ arrow.setText(isOpen ? '▼' : '▶');
157
+ arrow.style.marginRight = '8px';
158
+ arrow.style.fontSize = '0.8em';
159
+
160
+ const toggle = (): void => {
161
+ const isCurrentlyOpen = contentEl.style.display !== 'none';
162
+ contentEl.style.display = isCurrentlyOpen ? 'none' : 'block';
163
+ arrow.setText(isCurrentlyOpen ? '▶' : '▼');
164
+ };
165
+
166
+ nameEl.addEventListener('click', toggle);
167
+
168
+ return { container: contentEl, toggle };
169
+ }
180
170
  }
@@ -7,4 +7,8 @@ end_of_line = lf
7
7
  insert_final_newline = true
8
8
  indent_style = tab
9
9
  indent_size = 4
10
- tab_width = 4
10
+ tab_width = 4
11
+
12
+ [*.json]
13
+ indent_style = space
14
+ indent_size = 2
@@ -0,0 +1,5 @@
1
+ {
2
+ "devDependencies": {
3
+ "esbuild-sass-plugin": "^3.3.1"
4
+ }
5
+ }