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.
@@ -3,7 +3,7 @@
3
3
  /**
4
4
  * Obsidian Plugin Config - CLI Entry Point
5
5
  * Global command: obsidian-inject
6
- * Version: 1.3.9
6
+ * Version: 1.3.12
7
7
  */
8
8
 
9
9
  import { execSync } from 'child_process';
@@ -0,0 +1,111 @@
1
+ # LLM Guide — obsidian-plugin-config
2
+
3
+ ## The two distinct roles of this repo
4
+
5
+ ### 1. Local plugin (root)
6
+
7
+ The root of this repo functions as a **local Obsidian plugin** for development and testing purposes.
8
+
9
+ - `src/` — reusable code (modals, utils, helpers) that can be tested locally and exported via NPM
10
+ - `scripts/` — local build/dev scripts for this repo itself (includes `build-npm.ts` for NPM publishing)
11
+ - `package.json` (root) — configuration for this local plugin + NPM package
12
+ - `tsconfig.json` (root) — TypeScript config for this local plugin
13
+ - `eslint.config.mts` (root) — ESLint config for this local plugin
14
+
15
+ Exports from `src/` are available as snippets via the NPM package `obsidian-plugin-config`.
16
+
17
+ ### 2. Injection system (templates/)
18
+
19
+ `templates/` is the **source of truth** for everything injected into target plugins.
20
+
21
+ - `templates/scripts/` — scripts that will be copied into `<target>/scripts/`
22
+ - `templates/package.json` — base deps/scripts merged into `<target>/package.json`
23
+ - `templates/package-sass.json` — additional deps merged when `--sass` flag is used
24
+ - `templates/tsconfig.json` — TypeScript config injected as `<target>/tsconfig.json`
25
+ - `templates/eslint.config.mts` — ESLint config injected into target
26
+ - `templates/.editorconfig`, `templates/.prettierrc`, etc. — config files injected into target
27
+ - `templates/help-plugin.ts` — help script injected as `<target>/scripts/help.ts`
28
+
29
+ The injection logic lives in `scripts/inject-core.ts`, `scripts/inject-path.ts`, `scripts/inject-prompt.ts`.
30
+
31
+ ---
32
+
33
+ ## Critical distinction
34
+
35
+ | | Root | templates/ |
36
+ |---|---|---|
37
+ | Purpose | Local dev + NPM exports | Source for injection |
38
+ | package.json | This repo's own config | Base for target plugins |
39
+ | tsconfig.json | This repo's TS config | Injected into targets |
40
+ | scripts/ | Local scripts (+ build-npm) | Copied into targets |
41
+
42
+ **Never modify root config files thinking it will affect injected plugins. Always modify `templates/`.**
43
+
44
+ **Never read root `package.json` or `tsconfig.json` as a reference for what gets injected.**
45
+
46
+ ---
47
+
48
+ ## What injection does
49
+
50
+ `inject-core.ts → updatePackageJson()` reads `templates/package.json` (and `templates/package-sass.json` if `--sass`) and merges into the target plugin's `package.json`:
51
+ - All `scripts` are overwritten with template values
52
+ - All `devDependencies` from template are added/updated
53
+ - `engines` and `type` are set from template
54
+ - Target plugin's own specific deps are preserved
55
+
56
+ `inject-core.ts → injectScripts()` copies files from `templates/` into the target:
57
+ - `templates/scripts/*` → `<target>/scripts/`
58
+ - `templates/tsconfig.json` → `<target>/tsconfig.json`
59
+ - `templates/eslint.config.mts` → `<target>/eslint.config.mts`
60
+ - `templates/.editorconfig`, `.prettierrc`, `.npmrc`, `.env` → `<target>/`
61
+ - `templates/.github/workflows/*` → `<target>/.github/workflows/`
62
+
63
+ ---
64
+
65
+ ## Scripts: local vs injected
66
+
67
+ Local scripts (`scripts/`) and template scripts (`templates/scripts/`) are **the same scripts**, with one difference:
68
+
69
+ - `scripts/` has extra files: `inject-core.ts`, `inject-path.ts`, `inject-prompt.ts`, `build-npm.ts`, `update-exports.js`, `update-version-config.ts`
70
+ - `templates/scripts/` has only what target plugins need: `esbuild.config.ts`, `acp.ts`, `update-version.ts`, `release.ts`, `utils.ts`, `help.ts`
71
+
72
+ When updating a shared script (e.g. `acp.ts`), update **both** `scripts/acp.ts` and `templates/scripts/acp.ts`.
73
+
74
+ ---
75
+
76
+ ## What NOT to do
77
+
78
+ - ❌ Do not add `obsidian-plugin-config` as a dependency in `templates/package.json` — injected plugins are standalone
79
+ - ❌ Do not use `../obsidian-plugin-config/scripts/...` paths anywhere — that was the old sibling-repo approach, fully removed
80
+ - ❌ Do not hardcode deps/scripts in `inject-core.ts` — they must come from `templates/package.json`
81
+ - ❌ Do not modify root `tsconfig.json` or `package.json` to fix issues in injected plugins — fix `templates/` instead
82
+ - ❌ Do not run `yarn upgrade` on root and expect it to update what gets injected — versions are defined in `templates/package.json`
83
+
84
+ ---
85
+
86
+ ## obsidian-typings paths (current)
87
+
88
+ The correct paths for `obsidian-typings` in `tsconfig.json` (confirmed against installed `node_modules`):
89
+
90
+ ```json
91
+ "types": ["obsidian-typings"],
92
+ "paths": {
93
+ "obsidian-typings/implementations": [
94
+ "./node_modules/obsidian-typings/dist/cjs/implementations.d.cts",
95
+ "./node_modules/obsidian-typings/dist/esm/implementations.mjs"
96
+ ]
97
+ }
98
+ ```
99
+
100
+ These paths are in `templates/tsconfig.json` and must stay in sync with the actual `obsidian-typings` package structure.
101
+
102
+ ---
103
+
104
+ ## docs/ folder
105
+
106
+ - `docs/package-ex.json` — example of a real working injected plugin's `package.json` (reference only)
107
+ - `docs/tsconfig-ex.json` — example of a real working injected plugin's `tsconfig.json` (reference only)
108
+ - `docs/package-versions.json` — archive (reference only, source of truth is `templates/package.json`)
109
+ - `docs/package-versions-sass.json` — archive (reference only, source of truth is `templates/package-sass.json`)
110
+ - `docs/IMPROVEMENT-PLAN-FOR-LLM.md` — historical task list (may be outdated)
111
+ - `docs/LLM-GUIDE.md` — this file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "obsidian-plugin-config",
3
- "version": "1.3.9",
3
+ "version": "1.3.12",
4
4
  "description": "Système d'injection pour plugins Obsidian autonomes",
5
5
  "type": "module",
6
6
  "main": "src/index.ts",
@@ -59,7 +59,7 @@
59
59
  "fs-extra": "^11.2.0",
60
60
  "jiti": "latest",
61
61
  "obsidian": "*",
62
- "obsidian-typings": "^3.9.5",
62
+ "obsidian-typings": "latest",
63
63
  "prettier": "^3.4.0",
64
64
  "semver": "^7.7.2",
65
65
  "tsx": "^4.19.4",
@@ -76,7 +76,7 @@
76
76
  "fs-extra": "^11.2.0",
77
77
  "lodash": "^4.17.21",
78
78
  "obsidian": "*",
79
- "obsidian-typings": "^3.9.5",
79
+ "obsidian-typings": "latest",
80
80
  "semver": "^7.7.2",
81
81
  "tsx": "^4.19.4",
82
82
  "typescript": "^5.8.2"
@@ -204,6 +204,18 @@ function buildAndPublishNpm(): void {
204
204
  );
205
205
 
206
206
  try {
207
+ // Step 0: Check NPM login
208
+ console.log(`🔐 Checking NPM authentication...`);
209
+ try {
210
+ const whoami = execSync('npm whoami --registry https://registry.npmjs.org/', {
211
+ stdio: 'pipe', encoding: 'utf8'
212
+ }).trim();
213
+ console.log(` ✅ Logged in as: ${whoami}\n`);
214
+ } catch {
215
+ console.error(` ❌ Not logged in to NPM. Run: npm login`);
216
+ process.exit(1);
217
+ }
218
+
207
219
  // Step 1: Update version in package.json only
208
220
  // (no commit yet - we'll do one big commit after)
209
221
  console.log(`📋 Step 1/6: Updating version...`);
@@ -212,21 +224,21 @@ function buildAndPublishNpm(): void {
212
224
  });
213
225
 
214
226
  // Step 2: Update exports automatically
215
- console.log(`\n📦 Step 2/6: Updating exports...`);
227
+ console.log(`\n📦 Step 2/7: Updating exports...`);
216
228
  execSync('yarn update-exports', { stdio: 'inherit' });
217
229
 
218
230
  // Step 3: Generate bin file (uses updated version)
219
- console.log(`\n🔧 Step 3/6: Generating bin/obsidian-inject.js...`);
231
+ console.log(`\n🔧 Step 3/7: Generating bin/obsidian-inject.js...`);
220
232
  generateBinFile();
221
233
 
222
234
  // Step 4: Verify package and sync versions.json
223
235
  // (must happen before commit so versions.json is included)
224
- console.log(`\n📋 Step 4/6: Verifying package...`);
236
+ console.log(`\n📋 Step 4/7: Verifying package...`);
225
237
  verifyPackage();
226
238
 
227
239
  // Step 5: Commit and push ALL changes together
228
240
  // (package.json version, bin/, versions.json, exports)
229
- console.log(`\n📤 Step 5/6: Committing and pushing changes...`);
241
+ console.log(`\n📤 Step 5/7: Committing and pushing changes...`);
230
242
  try {
231
243
  execSync(
232
244
  'echo "Publish NPM package" | tsx scripts/acp.ts -b',
@@ -237,7 +249,7 @@ function buildAndPublishNpm(): void {
237
249
  }
238
250
 
239
251
  // Step 6: Publish to NPM
240
- console.log(`\n📤 Step 6/6: Publishing to NPM...`);
252
+ console.log(`\n📤 Step 6/7: Publishing to NPM...`);
241
253
  execSync(
242
254
  'npm publish --registry https://registry.npmjs.org/',
243
255
  { stdio: 'inherit' }
package/scripts/help.ts CHANGED
@@ -29,8 +29,10 @@ INJECTION (Development phase):
29
29
  yarn inject <path> --sass # Injection with SASS support
30
30
  yarn check-plugin <path> # Verification only (dry-run)
31
31
 
32
- NPM PUBLISHING:
33
- yarn npm-publish # Complete NPM workflow (exports + bin + publish)
32
+ NPM PUBLISHING (all-in-one - no acp needed before):
33
+ yarn npm-publish # Full workflow:
34
+ # version → exports → bin
35
+ # → commit+push → publish
34
36
  yarn build-npm # Alias for npm-publish
35
37
 
36
38
  HELP:
@@ -53,21 +55,27 @@ After adding a new module to src/, run:
53
55
 
54
56
  🏗️ ARCHITECTURE
55
57
 
58
+ TWO DISTINCT ROLES:
59
+ Root (src/, scripts/) # Local plugin + NPM snippet exports
60
+ templates/ # Source of truth for injection
61
+
62
+ templates/ → what gets injected:
63
+ templates/package.json # Base deps/scripts for target plugins
64
+ templates/package-sass.json # Extra deps when --sass is used
65
+ templates/tsconfig.json # TypeScript config for target plugins
66
+ templates/scripts/* # Scripts copied to <target>/scripts/
67
+ templates/eslint.config.mts # ESLint config for target plugins
68
+
56
69
  inject-core.ts — shared injection logic:
57
- analyzePlugin() # Analyze target plugin directory
70
+ updatePackageJson() # Reads templates/package.json (not hardcoded)
71
+ injectScripts() # Copies templates/ files to target
58
72
  performInjection() # Main orchestration function
59
- updatePackageJson() # Inject scripts + dependencies
60
- injectScripts() # Copy templates to target
61
- ensurePluginConfigClean() # Auto-commit before injection
62
73
 
63
74
  inject-path.ts — CLI entry point:
64
75
  Parses --yes, --dry-run, --sass flags
65
- Calls performInjection() from inject-core
66
76
 
67
77
  inject-prompt.ts — interactive entry point:
68
78
  Prompts for target path interactively
69
- Supports --sass flag
70
- Calls performInjection() from inject-core
71
79
 
72
80
  ═══════════════════════════════════════════════════════════════════
73
81
 
@@ -82,17 +90,15 @@ Plugin Config Development:
82
90
  6. yarn npm-publish # Publish to NPM
83
91
 
84
92
  Injection Usage:
85
- Recommended structure:
86
- my-plugins/
87
- ├── obsidian-plugin-config/ # This repo
88
- ├── my-plugin-1/
89
- └── my-plugin-2/
90
-
91
- Usage:
92
- yarn inject-prompt ../my-plugin # Interactive (recommended)
93
- yarn inject-path ../my-plugin # Direct injection
94
- yarn inject ../my-plugin --sass # With SASS support
95
- yarn check-plugin ../my-plugin # Verification only
93
+ Usage (from plugin directory or by path):
94
+ obsidian-inject # Inject in current dir
95
+ obsidian-inject ../my-plugin # Inject by path
96
+ obsidian-inject ../my-plugin --sass # With SASS
97
+
98
+ Or with local yarn commands:
99
+ yarn inject-prompt # Interactive
100
+ yarn inject-path ../my-plugin # Direct injection
101
+ yarn check-plugin ../my-plugin # Dry-run only
96
102
 
97
103
  SASS Support (--sass flag):
98
104
  What gets added to the target plugin:
@@ -109,23 +115,22 @@ SASS Support (--sass flag):
109
115
 
110
116
  STANDARD DEVELOPMENT WORKFLOW:
111
117
  1. yarn i # Install dependencies
112
- 2. Make changes to obsidian-plugin-config
113
- 3. yarn update-exports # Update exports if needed
114
- 4. yarn lint:fix # Fix any linting issues
115
- 5. yarn v # Update version + commit + push GitHub
116
- 6. yarn npm-publish # Complete NPM workflow
117
-
118
- AUTOMATED WORKFLOW (One command):
119
- yarn npm-publish # Does EVERYTHING automatically:
120
- # → Update version
118
+ 2. Make changes to src/ or templates/
119
+ 3. yarn lint:fix # Fix any linting issues
120
+ 4. yarn npm-publish # Does EVERYTHING:
121
+ # Ask for version bump type
121
122
  # → Update exports
122
- # → Generate bin/obsidian-inject.js
123
+ # → Generate bin file
123
124
  # → Verify package
125
+ # → Commit + push to GitHub
124
126
  # → Publish to NPM
125
127
 
126
- AFTER NPM PUBLISH - Testing:
128
+ Note: yarn acp is only needed for intermediate commits
129
+ (not required before npm-publish).
130
+
131
+ AFTER NPM PUBLISH - Update global CLI:
127
132
  npm install -g obsidian-plugin-config@latest
128
- obsidian-inject ../test-plugin
133
+ obsidian-inject # Test in current plugin dir
129
134
  obsidian-inject ../test-plugin --sass
130
135
 
131
136
  TESTING AS PLUGIN (Optional):
@@ -229,6 +229,15 @@ export async function cleanOldScripts(scriptsPath: string): Promise<void> {
229
229
  }
230
230
  }
231
231
 
232
+ const obsoleteRootFiles = ["help-plugin.ts"];
233
+ for (const fileName of obsoleteRootFiles) {
234
+ const filePath = path.join(path.dirname(scriptsPath), fileName);
235
+ if (await isValidPath(filePath)) {
236
+ fs.unlinkSync(filePath);
237
+ console.log(`🗑️ Removed obsolete root file: ${fileName}`);
238
+ }
239
+ }
240
+
232
241
  const obsoleteFiles = ["start.mjs", "start.js"];
233
242
  for (const fileName of obsoleteFiles) {
234
243
  const filePath = path.join(scriptsPath, fileName);
@@ -449,6 +458,18 @@ export async function updatePackageJson(
449
458
  try {
450
459
  const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, "utf8"));
451
460
 
461
+ const configRoot = findPluginConfigRoot();
462
+ const templatePkg = JSON.parse(
463
+ fs.readFileSync(path.join(configRoot, "templates/package.json"), "utf8")
464
+ );
465
+
466
+ if (useSass) {
467
+ const sassPkg = JSON.parse(
468
+ fs.readFileSync(path.join(configRoot, "templates/package-sass.json"), "utf8")
469
+ );
470
+ Object.assign(templatePkg.devDependencies, sassPkg.devDependencies);
471
+ }
472
+
452
473
  const obsoleteScripts = ["version"];
453
474
  for (const script of obsoleteScripts) {
454
475
  if (packageJson.scripts?.[script]) {
@@ -459,20 +480,7 @@ export async function updatePackageJson(
459
480
 
460
481
  packageJson.scripts = {
461
482
  ...packageJson.scripts,
462
- start: "yarn install && yarn dev",
463
- dev: "tsx scripts/esbuild.config.ts",
464
- build: "tsc -noEmit -skipLibCheck && tsx scripts/esbuild.config.ts production",
465
- real: "tsx scripts/esbuild.config.ts production real",
466
- acp: "tsx scripts/acp.ts",
467
- bacp: "tsx scripts/acp.ts -b",
468
- "update-version": "tsx scripts/update-version.ts",
469
- v: "tsx scripts/update-version.ts",
470
- release: "tsx scripts/release.ts",
471
- r: "tsx scripts/release.ts",
472
- help: "tsx scripts/help.ts",
473
- h: "tsx scripts/help.ts",
474
- lint: "eslint . --ext .ts",
475
- "lint:fix": "eslint . --ext .ts --fix"
483
+ ...templatePkg.scripts
476
484
  };
477
485
 
478
486
  if (packageJson.dependencies?.["obsidian-plugin-config"]) {
@@ -482,44 +490,24 @@ export async function updatePackageJson(
482
490
 
483
491
  if (!packageJson.devDependencies) packageJson.devDependencies = {};
484
492
 
485
- const requiredDeps: Record<string, string> = {
486
- "@types/eslint": "latest",
487
- "@types/node": "^22.15.26",
488
- "@types/semver": "^7.7.0",
489
- "@typescript-eslint/eslint-plugin": "latest",
490
- "@typescript-eslint/parser": "latest",
491
- "builtin-modules": "3.3.0",
492
- dedent: "^1.6.0",
493
- dotenv: "^16.4.5",
494
- esbuild: "latest",
495
- eslint: "latest",
496
- "eslint-import-resolver-typescript": "latest",
497
- jiti: "latest",
498
- obsidian: "*",
499
- "obsidian-typings": "^3.9.5",
500
- prettier: "^3.4.0",
501
- semver: "^7.7.2",
502
- tsx: "^4.19.4",
503
- typescript: "^5.8.2",
504
- ...(useSass ? { "esbuild-sass-plugin": "^3.3.1" } : {})
505
- };
493
+ const requiredDeps: Record<string, string> = templatePkg.devDependencies;
506
494
 
507
495
  let addedDeps = 0;
508
496
  let updatedDeps = 0;
509
497
  for (const [dep, version] of Object.entries(requiredDeps)) {
510
498
  if (!packageJson.devDependencies[dep]) {
511
- packageJson.devDependencies[dep] = version;
499
+ packageJson.devDependencies[dep] = version as string;
512
500
  addedDeps++;
513
501
  } else if (packageJson.devDependencies[dep] !== version) {
514
- packageJson.devDependencies[dep] = version;
502
+ packageJson.devDependencies[dep] = version as string;
515
503
  updatedDeps++;
516
504
  }
517
505
  }
518
506
 
519
507
  if (!packageJson.engines) packageJson.engines = {};
520
- packageJson.engines.npm = "please-use-yarn";
521
- packageJson.engines.yarn = ">=1.22.0";
522
- packageJson.type = "module";
508
+ packageJson.engines.npm = templatePkg.engines.npm;
509
+ packageJson.engines.yarn = templatePkg.engines.yarn;
510
+ packageJson.type = templatePkg.type;
523
511
 
524
512
  fs.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2), "utf8");
525
513
  console.log(` ✅ Updated package.json (${addedDeps} new, ${updatedDeps} updated dependencies)`);
package/src/main.ts CHANGED
@@ -1,121 +1,118 @@
1
- import {
2
- App,
3
- Plugin,
4
- PluginSettingTab,
5
- Setting,
6
- Notice
7
- } from "obsidian";
8
- import { showConfirmModal } from "./modals/GenericConfirmModal.ts";
1
+ import { App, Plugin, PluginSettingTab, Setting, Notice } from 'obsidian';
2
+ import { showConfirmModal } from './modals/GenericConfirmModal.ts';
9
3
  // import { showTestMessage, getRandomEmoji } from "obsidian-plugin-config/tools";
10
4
 
11
5
  interface MyPluginSettings {
12
- mySetting: string;
6
+ mySetting: string;
13
7
  }
14
8
 
15
9
  const DEFAULT_SETTINGS: MyPluginSettings = {
16
- mySetting: "default"
10
+ mySetting: 'default'
17
11
  };
18
12
 
19
13
  export default class ObsidianPluginConfigPlugin extends Plugin {
20
- settings: MyPluginSettings;
21
-
22
- async onload(): Promise<void> {
23
- console.log("Loading obsidian-plugin-config plugin for testing NPM exports");
24
- await this.loadSettings();
25
-
26
- this.addCommand({
27
- id: 'show-confirmation-modal',
28
- name: 'Test Confirmation Modal (Local)',
29
- callback: () => this.showConfirmationModal()
30
- });
31
-
32
- this.addCommand({
33
- id: 'show-centralized-modal',
34
- name: 'Test Confirmation Modal (Centralized)',
35
- callback: () => this.showCentralizedModal()
36
- });
37
-
38
- this.addCommand({
39
- id: 'test-tools',
40
- name: 'Test Centralized Tools',
41
- callback: () => {
42
- // const message = showTestMessage();
43
- // const emoji = getRandomEmoji();
44
- new Notice(`🎯 Test centralized tools (commented for autonomous mode)`);
45
- }
46
- });
47
-
48
- this.addSettingTab(new PluginConfigSettingTab(this.app, this));
49
- }
50
-
51
- private showConfirmationModal(): void {
52
- showConfirmModal(this.app, {
53
- title: "Confirmation requise",
54
- message: "Êtes-vous sûr de vouloir effectuer cette action ? Cette action ne peut pas être annulée.",
55
- confirmText: "Confirmer",
56
- cancelText: "Annuler",
57
- onConfirm: () => {
58
- new Notice("Action confirmée !");
59
- console.log("Action confirmée par l'utilisateur");
60
- },
61
- onCancel: () => {
62
- new Notice("Action annulée.");
63
- console.log("Action annulée par l'utilisateur");
64
- }
65
- });
66
- }
67
-
68
- private showCentralizedModal(): void {
69
- showConfirmModal(this.app, {
70
- title: "Centralized Modal Test",
71
- message: "This modal comes from the centralized configuration! Pretty cool, right?",
72
- confirmText: "Awesome!",
73
- cancelText: "Not bad",
74
- onConfirm: () => {
75
- new Notice("Centralized modal confirmed! 🎉");
76
- },
77
- onCancel: () => {
78
- new Notice("Centralized modal cancelled 😢");
79
- }
80
- });
81
- }
82
-
83
- async loadSettings(): Promise<void> {
84
- this.settings = Object.assign({}, DEFAULT_SETTINGS, await this.loadData());
85
- }
86
-
87
- async saveSettings(): Promise<void> {
88
- await this.saveData(this.settings);
89
- }
14
+ settings: MyPluginSettings;
15
+
16
+ async onload(): Promise<void> {
17
+ console.log('Loading obsidian-plugin-config plugin for testing NPM exports');
18
+ await this.loadSettings();
19
+
20
+ this.addCommand({
21
+ id: 'show-confirmation-modal',
22
+ name: 'Test Confirmation Modal (Local)',
23
+ callback: () => this.showConfirmationModal()
24
+ });
25
+
26
+ this.addCommand({
27
+ id: 'show-centralized-modal',
28
+ name: 'Test Confirmation Modal (Centralized)',
29
+ callback: () => this.showCentralizedModal()
30
+ });
31
+
32
+ this.addCommand({
33
+ id: 'test-tools',
34
+ name: 'Test Centralized Tools',
35
+ callback: () => {
36
+ // const message = showTestMessage();
37
+ // const emoji = getRandomEmoji();
38
+ new Notice(`🎯 Test centralized tools (commented for autonomous mode)`);
39
+ }
40
+ });
41
+
42
+ this.addSettingTab(new PluginConfigSettingTab(this.app, this));
43
+ }
44
+
45
+ private showConfirmationModal(): void {
46
+ showConfirmModal(this.app, {
47
+ title: 'Confirmation requise',
48
+ message:
49
+ 'Êtes-vous sûr de vouloir effectuer cette action ? Cette action ne peut pas être annulée.',
50
+ confirmText: 'Confirmer',
51
+ cancelText: 'Annuler',
52
+ onConfirm: () => {
53
+ new Notice('Action confirmée !');
54
+ console.log("Action confirmée par l'utilisateur");
55
+ },
56
+ onCancel: () => {
57
+ new Notice('Action annulée.');
58
+ console.log("Action annulée par l'utilisateur");
59
+ }
60
+ });
61
+ }
62
+
63
+ private showCentralizedModal(): void {
64
+ showConfirmModal(this.app, {
65
+ title: 'Centralized Modal Test',
66
+ message:
67
+ 'This modal comes from the centralized configuration! Pretty cool, right?',
68
+ confirmText: 'Awesome!',
69
+ cancelText: 'Not bad',
70
+ onConfirm: () => {
71
+ new Notice('Centralized modal confirmed! 🎉');
72
+ },
73
+ onCancel: () => {
74
+ new Notice('Centralized modal cancelled 😢');
75
+ }
76
+ });
77
+ }
78
+
79
+ async loadSettings(): Promise<void> {
80
+ this.settings = Object.assign({}, DEFAULT_SETTINGS, await this.loadData());
81
+ }
82
+
83
+ async saveSettings(): Promise<void> {
84
+ await this.saveData(this.settings);
85
+ }
90
86
  }
91
87
 
92
88
  class PluginConfigSettingTab extends PluginSettingTab {
93
- plugin: ObsidianPluginConfigPlugin;
94
-
95
- constructor(app: App, plugin: ObsidianPluginConfigPlugin) {
96
- super(app, plugin);
97
- this.plugin = plugin;
98
- }
99
-
100
- display(): void {
101
- const { containerEl } = this;
102
- containerEl.empty();
103
-
104
- containerEl.createEl('h2', { text: 'Obsidian Plugin Config Settings' });
105
- containerEl.createEl('p', {
106
- text: 'This plugin is used for testing NPM exports and development of the obsidian-plugin-config system.'
107
- });
108
-
109
- new Setting(containerEl)
110
- .setName('Test Setting')
111
- .setDesc('A test setting for development purposes')
112
- .addText(text => text
113
- .setPlaceholder('Enter test value')
114
- .setValue(this.plugin.settings.mySetting)
115
- .onChange(async (value) => {
116
- this.plugin.settings.mySetting = value;
117
- await this.plugin.saveSettings();
118
- }));
119
- }
89
+ plugin: ObsidianPluginConfigPlugin;
90
+
91
+ constructor(app: App, plugin: ObsidianPluginConfigPlugin) {
92
+ super(app, plugin);
93
+ this.plugin = plugin;
94
+ }
95
+
96
+ display(): void {
97
+ const { containerEl } = this;
98
+ containerEl.empty();
99
+
100
+ containerEl.createEl('h2', { text: 'Obsidian Plugin Config Settings' });
101
+ containerEl.createEl('p', {
102
+ text: 'This plugin is used for testing NPM exports and development of the obsidian-plugin-config system.'
103
+ });
104
+
105
+ new Setting(containerEl)
106
+ .setName('Test Setting')
107
+ .setDesc('A test setting for development purposes')
108
+ .addText((text) =>
109
+ text
110
+ .setPlaceholder('Enter test value')
111
+ .setValue(this.plugin.settings.mySetting)
112
+ .onChange(async (value) => {
113
+ this.plugin.settings.mySetting = value;
114
+ await this.plugin.saveSettings();
115
+ })
116
+ );
117
+ }
120
118
  }
121
-