mirror of
https://github.com/core-hn/pseudobsidian-ization.git
synced 2026-07-22 06:57:06 +00:00
fix: address all Obsidian community portal warnings on dev
- Remove detachLeavesOfType from onunload
- Add void to revealLeaf call
- Remove eslint-disable comment, type TransformersModule properly
- window.setInterval/clearInterval in OnnxNerScanner
- Remove unused fs import, type ScopeResolver JSON.parse casts
- Remove unused Setting/RuleLocation imports
- window.setTimeout in OnboardingModal and PseudonymizationView
- Wrap async event listeners with void (async () => {})()
- activeDocument instead of document in OnboardingModal
- FileManager.trashFile() instead of Vault.delete()
- Remove unused catch variable e
- Fix unnecessary escape character
- Replace deprecated activeLeaf with getActiveViewOfType
- Add .github/workflows/release.yml for artifact attestations
This commit is contained in:
parent
42bff2d6da
commit
79bc9fa6d4
10 changed files with 140 additions and 126 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -1,5 +1,6 @@
|
|||
# Notes de développement internes (Claude Code)
|
||||
CLAUDE.md
|
||||
OBSIDIAN_requirements.md
|
||||
|
||||
# Vault de test Obsidian — peut contenir des transcriptions avec données personnelles
|
||||
test_vault/
|
||||
|
|
|
|||
172
main.js
172
main.js
|
|
@ -74,10 +74,10 @@ var init_OnboardingModal = __esm({
|
|||
}
|
||||
onOpen() {
|
||||
this.modalEl.addClass("pseudobs-onboarding");
|
||||
setTimeout(() => this.render(), 0);
|
||||
window.setTimeout(() => this.render(), 0);
|
||||
}
|
||||
scheduleRender() {
|
||||
setTimeout(() => this.render(), 0);
|
||||
window.setTimeout(() => this.render(), 0);
|
||||
}
|
||||
render() {
|
||||
const { contentEl } = this;
|
||||
|
|
@ -151,15 +151,17 @@ var init_OnboardingModal = __esm({
|
|||
});
|
||||
if (this.nerBackend === "transformers-js")
|
||||
selectTfjs.addClass("pseudobs-onboarding-select-btn-active");
|
||||
selectTfjs.addEventListener("click", async () => {
|
||||
this.nerBackend = "transformers-js";
|
||||
await this.saveNerSettings();
|
||||
if (!this.checkWasmFiles()) {
|
||||
const ok = await this.downloadWasmFiles(wasmStatus, selectTfjs);
|
||||
if (!ok)
|
||||
return;
|
||||
}
|
||||
this.scheduleRender();
|
||||
selectTfjs.addEventListener("click", () => {
|
||||
void (async () => {
|
||||
this.nerBackend = "transformers-js";
|
||||
await this.saveNerSettings();
|
||||
if (!this.checkWasmFiles()) {
|
||||
const ok = await this.downloadWasmFiles(wasmStatus, selectTfjs);
|
||||
if (!ok)
|
||||
return;
|
||||
}
|
||||
this.scheduleRender();
|
||||
})();
|
||||
});
|
||||
const noneRow = el.createDiv("pseudobs-onboarding-none-row");
|
||||
const noneBtn = noneRow.createEl("button", {
|
||||
|
|
@ -168,10 +170,12 @@ var init_OnboardingModal = __esm({
|
|||
});
|
||||
if (this.nerBackend === "none")
|
||||
noneBtn.addClass("pseudobs-onboarding-none-btn-active");
|
||||
noneBtn.addEventListener("click", async () => {
|
||||
this.nerBackend = "none";
|
||||
await this.saveNerSettings();
|
||||
this.scheduleRender();
|
||||
noneBtn.addEventListener("click", () => {
|
||||
void (async () => {
|
||||
this.nerBackend = "none";
|
||||
await this.saveNerSettings();
|
||||
this.scheduleRender();
|
||||
})();
|
||||
});
|
||||
}
|
||||
// ---- Utilitaires WASM -----------------------------------------
|
||||
|
|
@ -207,7 +211,7 @@ var init_OnboardingModal = __esm({
|
|||
try {
|
||||
const response = await (0, import_obsidian.requestUrl)({ url: `${WASM_CDN_BASE}/${f}`, method: "GET" });
|
||||
fs.writeFileSync(path.join(dir, f), Buffer.from(response.arrayBuffer));
|
||||
} catch (e) {
|
||||
} catch {
|
||||
statusEl.setText(`\xC9chec pour ${f} \u2014 v\xE9rifiez votre connexion`);
|
||||
statusEl.classList.add("pseudobs-onboarding-test-err");
|
||||
btn.removeAttribute("disabled");
|
||||
|
|
@ -241,12 +245,12 @@ var init_OnboardingModal = __esm({
|
|||
});
|
||||
const importStatus = importRow.createSpan({ cls: "pseudobs-onboarding-test-status" });
|
||||
importBtn.addEventListener("click", () => {
|
||||
const input = document.createElement("input");
|
||||
const input = activeDocument.createElement("input");
|
||||
input.type = "file";
|
||||
input.accept = ".json";
|
||||
input.multiple = true;
|
||||
input.classList.add("pseudobs-hidden-input");
|
||||
document.body.appendChild(input);
|
||||
activeDocument.body.appendChild(input);
|
||||
input.addEventListener("change", () => void this.processDictFiles(input, importStatus));
|
||||
input.click();
|
||||
});
|
||||
|
|
@ -314,9 +318,11 @@ var init_OnboardingModal = __esm({
|
|||
li.createSpan({ text: f.name });
|
||||
const removeBtn = li.createEl("button", { text: "\u2715", cls: "pseudobs-onboarding-dict-remove" });
|
||||
removeBtn.title = "Retirer ce dictionnaire du vault";
|
||||
removeBtn.addEventListener("click", async () => {
|
||||
await this.app.vault.delete(f);
|
||||
this.scheduleRender();
|
||||
removeBtn.addEventListener("click", () => {
|
||||
void (async () => {
|
||||
await this.app.fileManager.trashFile(f);
|
||||
this.scheduleRender();
|
||||
})();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
@ -372,10 +378,12 @@ var init_OnboardingModal = __esm({
|
|||
this.scheduleRender();
|
||||
});
|
||||
} else if (this.currentStep === "summary") {
|
||||
rightBtns.createEl("button", { text: "Commencer \xE0 travailler", cls: "pseudobs-onboarding-next-btn mod-cta" }).addEventListener("click", async () => {
|
||||
this.plugin.settings.onboardingCompleted = true;
|
||||
await this.plugin.saveSettings();
|
||||
this.close();
|
||||
rightBtns.createEl("button", { text: "Commencer \xE0 travailler", cls: "pseudobs-onboarding-next-btn mod-cta" }).addEventListener("click", () => {
|
||||
void (async () => {
|
||||
this.plugin.settings.onboardingCompleted = true;
|
||||
await this.plugin.saveSettings();
|
||||
this.close();
|
||||
})();
|
||||
});
|
||||
} else {
|
||||
rightBtns.createEl("button", { text: "Passer cette \xE9tape", cls: "pseudobs-onboarding-skip-btn" }).addEventListener("click", () => {
|
||||
|
|
@ -32599,8 +32607,7 @@ var PseudonymizationView = class extends import_obsidian7.ItemView {
|
|||
async onFileChange() {
|
||||
if (this._renderingTab)
|
||||
return;
|
||||
const activeLeaf = this.app.workspace.activeLeaf;
|
||||
if (activeLeaf && activeLeaf.view === this)
|
||||
if (this.app.workspace.getActiveViewOfType(import_obsidian7.ItemView) === this)
|
||||
return;
|
||||
const f = this.app.workspace.getActiveFile();
|
||||
if (f && f !== this.lastFile) {
|
||||
|
|
@ -32661,38 +32668,40 @@ var PseudonymizationView = class extends import_obsidian7.ItemView {
|
|||
cls: "pseudobs-view-hint"
|
||||
});
|
||||
}
|
||||
scanBtn.addEventListener("click", async () => {
|
||||
scanBtn.setAttr("disabled", "true");
|
||||
scanBtn.setText("Scan en cours\u2026");
|
||||
try {
|
||||
const content = await this.app.vault.read(file);
|
||||
const rules = await this.plugin.scopeResolver.getRulesFor(file.path);
|
||||
resultsEl.empty();
|
||||
if (rules.length === 0) {
|
||||
resultsEl.createEl("p", {
|
||||
text: 'Aucune r\xE8gle active pour ce fichier. Cr\xE9ez des r\xE8gles via le menu contextuel ou la commande "cr\xE9er une r\xE8gle".',
|
||||
cls: "pseudobs-view-hint"
|
||||
});
|
||||
} else {
|
||||
const occs = scanOccurrences(content, file.path, rules, {
|
||||
caseSensitive: this.plugin.settings.caseSensitive,
|
||||
wholeWordOnly: this.plugin.settings.wholeWordOnly
|
||||
});
|
||||
this.occFile = file;
|
||||
this.occContent = content;
|
||||
this.occurrences = occs;
|
||||
this.occRules = rules;
|
||||
this.occDecisions = /* @__PURE__ */ new Map();
|
||||
this.occCardRefs = /* @__PURE__ */ new Map();
|
||||
for (const occ of occs)
|
||||
this.occDecisions.set(occ.id, "validated");
|
||||
this.occScanned = true;
|
||||
this.renderOccurrenceCards(resultsEl);
|
||||
scanBtn.addEventListener("click", () => {
|
||||
void (async () => {
|
||||
scanBtn.setAttr("disabled", "true");
|
||||
scanBtn.setText("Scan en cours\u2026");
|
||||
try {
|
||||
const content = await this.app.vault.read(file);
|
||||
const rules = await this.plugin.scopeResolver.getRulesFor(file.path);
|
||||
resultsEl.empty();
|
||||
if (rules.length === 0) {
|
||||
resultsEl.createEl("p", {
|
||||
text: 'Aucune r\xE8gle active pour ce fichier. Cr\xE9ez des r\xE8gles via le menu contextuel ou la commande "cr\xE9er une r\xE8gle".',
|
||||
cls: "pseudobs-view-hint"
|
||||
});
|
||||
} else {
|
||||
const occs = scanOccurrences(content, file.path, rules, {
|
||||
caseSensitive: this.plugin.settings.caseSensitive,
|
||||
wholeWordOnly: this.plugin.settings.wholeWordOnly
|
||||
});
|
||||
this.occFile = file;
|
||||
this.occContent = content;
|
||||
this.occurrences = occs;
|
||||
this.occRules = rules;
|
||||
this.occDecisions = /* @__PURE__ */ new Map();
|
||||
this.occCardRefs = /* @__PURE__ */ new Map();
|
||||
for (const occ of occs)
|
||||
this.occDecisions.set(occ.id, "validated");
|
||||
this.occScanned = true;
|
||||
this.renderOccurrenceCards(resultsEl);
|
||||
}
|
||||
} finally {
|
||||
scanBtn.removeAttribute("disabled");
|
||||
scanBtn.setText("Scanner le fichier");
|
||||
}
|
||||
} finally {
|
||||
scanBtn.removeAttribute("disabled");
|
||||
scanBtn.setText("Scanner le fichier");
|
||||
}
|
||||
})();
|
||||
});
|
||||
}
|
||||
renderOccurrenceCards(el) {
|
||||
|
|
@ -32941,9 +32950,9 @@ var PseudonymizationView = class extends import_obsidian7.ItemView {
|
|||
slider.addEventListener("input", () => {
|
||||
scoreDisplay.setText(parseFloat(slider.value).toFixed(2));
|
||||
});
|
||||
slider.addEventListener("change", async () => {
|
||||
slider.addEventListener("change", () => {
|
||||
this.plugin.settings.nerMinScore = parseFloat(slider.value);
|
||||
await this.plugin.saveSettings();
|
||||
void this.plugin.saveSettings();
|
||||
});
|
||||
const fwSection = el.createDiv("pseudobs-ner-section");
|
||||
fwSection.createEl("strong", { text: "Mots fonctionnels exclus" });
|
||||
|
|
@ -32960,27 +32969,31 @@ var PseudonymizationView = class extends import_obsidian7.ItemView {
|
|||
text: "Enregistrer",
|
||||
cls: "pseudobs-view-action-btn"
|
||||
});
|
||||
saveBtn.addEventListener("click", async () => {
|
||||
const words = textarea.value.split("\n").map((w) => w.trim()).filter((w) => w.length > 0);
|
||||
this.plugin.settings.nerFunctionWords = words;
|
||||
await this.plugin.saveSettings();
|
||||
saveBtn.addClass("pseudobs-btn-saved");
|
||||
saveBtn.setText("Enregistr\xE9");
|
||||
setTimeout(() => {
|
||||
saveBtn.removeClass("pseudobs-btn-saved");
|
||||
saveBtn.setText("Enregistrer");
|
||||
}, 2e3);
|
||||
saveBtn.addEventListener("click", () => {
|
||||
void (async () => {
|
||||
const words = textarea.value.split("\n").map((w) => w.trim()).filter((w) => w.length > 0);
|
||||
this.plugin.settings.nerFunctionWords = words;
|
||||
await this.plugin.saveSettings();
|
||||
saveBtn.addClass("pseudobs-btn-saved");
|
||||
saveBtn.setText("Enregistr\xE9");
|
||||
window.setTimeout(() => {
|
||||
saveBtn.removeClass("pseudobs-btn-saved");
|
||||
saveBtn.setText("Enregistrer");
|
||||
}, 2e3);
|
||||
})();
|
||||
});
|
||||
const resetBtn = fwSection.createEl("button", {
|
||||
text: "R\xE9initialiser par d\xE9faut",
|
||||
cls: "pseudobs-view-action-btn"
|
||||
});
|
||||
resetBtn.addClass("pseudobs-ner-reset-btn");
|
||||
resetBtn.addEventListener("click", async () => {
|
||||
const { DEFAULT_SETTINGS: DEFAULT_SETTINGS2 } = await Promise.resolve().then(() => (init_settings(), settings_exports));
|
||||
this.plugin.settings.nerFunctionWords = [...DEFAULT_SETTINGS2.nerFunctionWords];
|
||||
await this.plugin.saveSettings();
|
||||
textarea.value = this.plugin.settings.nerFunctionWords.join("\n");
|
||||
resetBtn.addEventListener("click", () => {
|
||||
void (async () => {
|
||||
const { DEFAULT_SETTINGS: DEFAULT_SETTINGS2 } = await Promise.resolve().then(() => (init_settings(), settings_exports));
|
||||
this.plugin.settings.nerFunctionWords = [...DEFAULT_SETTINGS2.nerFunctionWords];
|
||||
await this.plugin.saveSettings();
|
||||
textarea.value = this.plugin.settings.nerFunctionWords.join("\n");
|
||||
})();
|
||||
});
|
||||
}
|
||||
onClose() {
|
||||
|
|
@ -33030,13 +33043,13 @@ var OnnxNerScanner = class {
|
|||
throw new Error(_loadError);
|
||||
if (_loading) {
|
||||
await new Promise((resolve, reject) => {
|
||||
const timer = setInterval(() => {
|
||||
const timer = window.setInterval(() => {
|
||||
if (_pipeline) {
|
||||
clearInterval(timer);
|
||||
window.clearInterval(timer);
|
||||
resolve();
|
||||
}
|
||||
if (_loadError) {
|
||||
clearInterval(timer);
|
||||
window.clearInterval(timer);
|
||||
reject(new Error(_loadError));
|
||||
}
|
||||
}, 300);
|
||||
|
|
@ -33528,7 +33541,6 @@ var PseudObsPlugin = class extends import_obsidian10.Plugin {
|
|||
);
|
||||
}
|
||||
onunload() {
|
||||
this.app.workspace.detachLeavesOfType(VIEW_TYPE_PSEUDOBS);
|
||||
}
|
||||
async activateView() {
|
||||
const { workspace } = this.app;
|
||||
|
|
@ -33537,7 +33549,7 @@ var PseudObsPlugin = class extends import_obsidian10.Plugin {
|
|||
leaf = workspace.getRightLeaf(false) ?? workspace.getLeaf(true);
|
||||
await leaf.setViewState({ type: VIEW_TYPE_PSEUDOBS, active: true });
|
||||
}
|
||||
workspace.revealLeaf(leaf);
|
||||
void workspace.revealLeaf(leaf);
|
||||
}
|
||||
// --- Coulmont ---
|
||||
// Interroge l'outil de Baptiste Coulmont pour suggérer un prénom équivalent.
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
"id": "pseudonymizer-tool",
|
||||
"name": "Pseudonymizer Tool",
|
||||
"version": "0.0.6",
|
||||
"minAppVersion": "1.6.6",
|
||||
"minAppVersion": "1.7.2",
|
||||
"description": "Pseudonymize and correct interactional transcripts (Jefferson, ICOR, SRT, CHAT/CHA). Designed for qualitative researchers in linguistics and conversation analysis.",
|
||||
"author": "Axelle Abbadie",
|
||||
"authorUrl": "https://cv.hal.science/axelle-abbadie/",
|
||||
|
|
|
|||
2
package-lock.json
generated
2
package-lock.json
generated
|
|
@ -1073,7 +1073,7 @@
|
|||
"@eslint/core": "^0.17.0",
|
||||
"@eslint/plugin-kit": "^0.4.1",
|
||||
"@humanwhocodes/momoa": "^3.3.10",
|
||||
"natural-compare": "^1.6.6"
|
||||
"natural-compare": "^1.4.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": "^18.18.0 || ^20.9.0 || >=21.1.0"
|
||||
|
|
|
|||
|
|
@ -194,9 +194,7 @@ export default class PseudObsPlugin extends Plugin {
|
|||
);
|
||||
}
|
||||
|
||||
onunload(): void {
|
||||
this.app.workspace.detachLeavesOfType(VIEW_TYPE_PSEUDOBS);
|
||||
}
|
||||
onunload(): void {}
|
||||
|
||||
private async activateView(): Promise<void> {
|
||||
const { workspace } = this.app;
|
||||
|
|
@ -205,7 +203,7 @@ export default class PseudObsPlugin extends Plugin {
|
|||
leaf = workspace.getRightLeaf(false) ?? workspace.getLeaf(true);
|
||||
await leaf.setViewState({ type: VIEW_TYPE_PSEUDOBS, active: true });
|
||||
}
|
||||
workspace.revealLeaf(leaf);
|
||||
void workspace.revealLeaf(leaf);
|
||||
}
|
||||
|
||||
// --- Coulmont ---
|
||||
|
|
|
|||
|
|
@ -85,7 +85,7 @@ export class ScopeResolver {
|
|||
for (const child of folder.children) {
|
||||
if (!(child instanceof TFile) || !child.name.endsWith('.mapping.json')) continue;
|
||||
try {
|
||||
const data: MappingFile = JSON.parse(await this.vault.read(child));
|
||||
const data = JSON.parse(await this.vault.read(child)) as MappingFile;
|
||||
const store = MappingStore.fromJSON(data);
|
||||
const applicable = store.getAll().filter((r) => {
|
||||
if (r.scope.type === 'vault') return true;
|
||||
|
|
@ -110,7 +110,7 @@ export class ScopeResolver {
|
|||
const file = this.vault.getAbstractFileByPath(path);
|
||||
if (!(file instanceof TFile)) return [];
|
||||
try {
|
||||
const data: MappingFile = JSON.parse(await this.vault.read(file));
|
||||
const data = JSON.parse(await this.vault.read(file)) as MappingFile;
|
||||
const store = MappingStore.fromJSON(data);
|
||||
return store.getAll().filter((r) => r.status === 'validated');
|
||||
} catch {
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
import { App, FileSystemAdapter, Notice } from 'obsidian';
|
||||
import * as path from 'path';
|
||||
import * as os from 'os';
|
||||
import * as fs from 'fs';
|
||||
import type { EntityCategory, Occurrence } from '../types';
|
||||
|
||||
// Modèle multilingue BERT-NER pré-converti en ONNX via Xenova.
|
||||
|
|
@ -59,9 +58,9 @@ export class OnnxNerScanner {
|
|||
if (_loading) {
|
||||
// Attendre la fin du chargement en cours
|
||||
await new Promise<void>((resolve, reject) => {
|
||||
const timer = setInterval(() => {
|
||||
if (_pipeline) { clearInterval(timer); resolve(); }
|
||||
if (_loadError) { clearInterval(timer); reject(new Error(_loadError)); }
|
||||
const timer = window.setInterval(() => {
|
||||
if (_pipeline) { window.clearInterval(timer); resolve(); }
|
||||
if (_loadError) { window.clearInterval(timer); reject(new Error(_loadError)); }
|
||||
}, 300);
|
||||
});
|
||||
return;
|
||||
|
|
@ -72,15 +71,19 @@ export class OnnxNerScanner {
|
|||
|
||||
try {
|
||||
// Import dynamique pour éviter de charger transformers au démarrage du plugin
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
const t: any = await import('@xenova/transformers');
|
||||
const { env, pipeline } = t as { env: typeof import('@xenova/transformers')['env']; pipeline: typeof import('@xenova/transformers')['pipeline'] };
|
||||
type TransformersModule = {
|
||||
env: typeof import('@xenova/transformers')['env'];
|
||||
pipeline: typeof import('@xenova/transformers')['pipeline'];
|
||||
executionProviders: string[];
|
||||
};
|
||||
const t = await import('@xenova/transformers') as unknown as TransformersModule;
|
||||
const { env, pipeline } = t;
|
||||
|
||||
// En Electron, process.release.name === 'node' ajoute 'cpu' en tête des providers.
|
||||
// Le provider CPU nécessite des binaires natifs non disponibles — on le retire.
|
||||
if (Array.isArray(t.executionProviders)) {
|
||||
const cpuIdx = (t.executionProviders as string[]).indexOf('cpu');
|
||||
if (cpuIdx !== -1) (t.executionProviders as string[]).splice(cpuIdx, 1);
|
||||
const cpuIdx = t.executionProviders.indexOf('cpu');
|
||||
if (cpuIdx !== -1) t.executionProviders.splice(cpuIdx, 1);
|
||||
}
|
||||
|
||||
// Avec platform:browser, RUNNING_LOCALLY=false → env.cacheDir=null.
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import { App, FileSystemAdapter, Modal, Notice, Setting, TFile, requestUrl } from 'obsidian';
|
||||
import { App, FileSystemAdapter, Modal, Notice, TFile, requestUrl } from 'obsidian';
|
||||
import * as fs from 'fs';
|
||||
import * as path from 'path';
|
||||
import type PseudObsPlugin from '../main';
|
||||
|
|
@ -46,12 +46,12 @@ export class OnboardingModal extends Modal {
|
|||
onOpen(): void {
|
||||
this.modalEl.addClass('pseudobs-onboarding');
|
||||
// Différer le premier render pour sortir du cycle d'ouverture du modal
|
||||
setTimeout(() => this.render(), 0);
|
||||
window.setTimeout(() => this.render(), 0);
|
||||
}
|
||||
|
||||
private scheduleRender(): void {
|
||||
// Différer le re-render pour éviter de modifier le DOM pendant un cycle de mesure Obsidian
|
||||
setTimeout(() => this.render(), 0);
|
||||
window.setTimeout(() => this.render(), 0);
|
||||
}
|
||||
|
||||
private render(): void {
|
||||
|
|
@ -137,7 +137,7 @@ export class OnboardingModal extends Modal {
|
|||
});
|
||||
if (this.nerBackend === 'transformers-js') selectTfjs.addClass('pseudobs-onboarding-select-btn-active');
|
||||
|
||||
selectTfjs.addEventListener('click', async () => {
|
||||
selectTfjs.addEventListener('click', () => { void (async () => {
|
||||
this.nerBackend = 'transformers-js';
|
||||
await this.saveNerSettings();
|
||||
|
||||
|
|
@ -147,7 +147,7 @@ export class OnboardingModal extends Modal {
|
|||
}
|
||||
|
||||
this.scheduleRender();
|
||||
});
|
||||
})(); });
|
||||
|
||||
// --- Désactiver ---
|
||||
const noneRow = el.createDiv('pseudobs-onboarding-none-row');
|
||||
|
|
@ -156,11 +156,11 @@ export class OnboardingModal extends Modal {
|
|||
cls: 'pseudobs-onboarding-none-btn',
|
||||
});
|
||||
if (this.nerBackend === 'none') noneBtn.addClass('pseudobs-onboarding-none-btn-active');
|
||||
noneBtn.addEventListener('click', async () => {
|
||||
noneBtn.addEventListener('click', () => { void (async () => {
|
||||
this.nerBackend = 'none';
|
||||
await this.saveNerSettings();
|
||||
this.scheduleRender();
|
||||
});
|
||||
})(); });
|
||||
}
|
||||
|
||||
// ---- Utilitaires WASM -----------------------------------------
|
||||
|
|
@ -203,7 +203,7 @@ export class OnboardingModal extends Modal {
|
|||
try {
|
||||
const response = await requestUrl({ url: `${WASM_CDN_BASE}/${f}`, method: 'GET' });
|
||||
fs.writeFileSync(path.join(dir, f), Buffer.from(response.arrayBuffer));
|
||||
} catch (e) {
|
||||
} catch {
|
||||
statusEl.setText(`Échec pour ${f} — vérifiez votre connexion`);
|
||||
statusEl.classList.add('pseudobs-onboarding-test-err');
|
||||
btn.removeAttribute('disabled');
|
||||
|
|
@ -244,12 +244,12 @@ export class OnboardingModal extends Modal {
|
|||
const importStatus = importRow.createSpan({ cls: 'pseudobs-onboarding-test-status' });
|
||||
|
||||
importBtn.addEventListener('click', () => {
|
||||
const input = document.createElement('input');
|
||||
const input = activeDocument.createElement('input');
|
||||
input.type = 'file';
|
||||
input.accept = '.json';
|
||||
input.multiple = true;
|
||||
input.classList.add('pseudobs-hidden-input');
|
||||
document.body.appendChild(input);
|
||||
activeDocument.body.appendChild(input);
|
||||
input.addEventListener('change', () => void this.processDictFiles(input, importStatus));
|
||||
input.click();
|
||||
});
|
||||
|
|
@ -284,7 +284,7 @@ export class OnboardingModal extends Modal {
|
|||
ok++;
|
||||
} catch {
|
||||
err++;
|
||||
new Notice(`Erreur lors de l\'import de ${f.name} — vérifiez le format .dict.json`);
|
||||
new Notice(`Erreur lors de l'import de ${f.name} — vérifiez le format .dict.json`);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -329,10 +329,10 @@ export class OnboardingModal extends Modal {
|
|||
li.createSpan({ text: f.name });
|
||||
const removeBtn = li.createEl('button', { text: '✕', cls: 'pseudobs-onboarding-dict-remove' });
|
||||
removeBtn.title = 'Retirer ce dictionnaire du vault';
|
||||
removeBtn.addEventListener('click', async () => {
|
||||
await this.app.vault.delete(f);
|
||||
removeBtn.addEventListener('click', () => { void (async () => {
|
||||
await this.app.fileManager.trashFile(f);
|
||||
this.scheduleRender();
|
||||
});
|
||||
})(); });
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -409,11 +409,11 @@ export class OnboardingModal extends Modal {
|
|||
|
||||
} else if (this.currentStep === 'summary') {
|
||||
rightBtns.createEl('button', { text: 'Commencer à travailler', cls: 'pseudobs-onboarding-next-btn mod-cta' })
|
||||
.addEventListener('click', async () => {
|
||||
.addEventListener('click', () => { void (async () => {
|
||||
this.plugin.settings.onboardingCompleted = true;
|
||||
await this.plugin.saveSettings();
|
||||
this.close();
|
||||
});
|
||||
})(); });
|
||||
|
||||
} else {
|
||||
// Étapes intermédiaires : Passer + Suivant
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@ import { resolveSpans, applySpans } from '../pseudonymizer/SpanProtector';
|
|||
import type { ReplacementSpan } from '../types';
|
||||
import { EditRuleModal } from './EditRuleModal';
|
||||
import { RuleModal } from './RuleModal';
|
||||
import type { RuleLocation } from '../mappings/ScopeResolver';
|
||||
|
||||
export const VIEW_TYPE_PSEUDOBS = 'pseudonymization-view';
|
||||
|
||||
|
|
@ -134,8 +133,7 @@ export class PseudonymizationView extends ItemView {
|
|||
// Le panneau lui-même peut devenir la feuille active sans changement de fichier
|
||||
// → éviter une boucle render ↔ active-leaf-change
|
||||
if (this._renderingTab) return;
|
||||
const activeLeaf = this.app.workspace.activeLeaf;
|
||||
if (activeLeaf && (activeLeaf as { view?: unknown }).view === this) return;
|
||||
if (this.app.workspace.getActiveViewOfType(ItemView) === this) return;
|
||||
|
||||
const f = this.app.workspace.getActiveFile();
|
||||
if (f && f !== this.lastFile) {
|
||||
|
|
@ -207,7 +205,7 @@ export class PseudonymizationView extends ItemView {
|
|||
});
|
||||
}
|
||||
|
||||
scanBtn.addEventListener('click', async () => {
|
||||
scanBtn.addEventListener('click', () => { void (async () => {
|
||||
scanBtn.setAttr('disabled', 'true');
|
||||
scanBtn.setText('Scan en cours…');
|
||||
try {
|
||||
|
|
@ -242,7 +240,7 @@ export class PseudonymizationView extends ItemView {
|
|||
scanBtn.removeAttribute('disabled');
|
||||
scanBtn.setText('Scanner le fichier');
|
||||
}
|
||||
});
|
||||
})(); });
|
||||
}
|
||||
|
||||
private renderOccurrenceCards(el: HTMLElement): void {
|
||||
|
|
@ -534,9 +532,9 @@ export class PseudonymizationView extends ItemView {
|
|||
slider.addEventListener('input', () => {
|
||||
scoreDisplay.setText(parseFloat(slider.value).toFixed(2));
|
||||
});
|
||||
slider.addEventListener('change', async () => {
|
||||
slider.addEventListener('change', () => {
|
||||
this.plugin.settings.nerMinScore = parseFloat(slider.value);
|
||||
await this.plugin.saveSettings();
|
||||
void this.plugin.saveSettings();
|
||||
});
|
||||
|
||||
// --- Mots fonctionnels ---
|
||||
|
|
@ -557,7 +555,7 @@ export class PseudonymizationView extends ItemView {
|
|||
text: 'Enregistrer',
|
||||
cls: 'pseudobs-view-action-btn',
|
||||
});
|
||||
saveBtn.addEventListener('click', async () => {
|
||||
saveBtn.addEventListener('click', () => { void (async () => {
|
||||
const words = textarea.value
|
||||
.split('\n')
|
||||
.map((w) => w.trim())
|
||||
|
|
@ -566,20 +564,20 @@ export class PseudonymizationView extends ItemView {
|
|||
await this.plugin.saveSettings();
|
||||
saveBtn.addClass('pseudobs-btn-saved');
|
||||
saveBtn.setText('Enregistré');
|
||||
setTimeout(() => { saveBtn.removeClass('pseudobs-btn-saved'); saveBtn.setText('Enregistrer'); }, 2000);
|
||||
});
|
||||
window.setTimeout(() => { saveBtn.removeClass('pseudobs-btn-saved'); saveBtn.setText('Enregistrer'); }, 2000);
|
||||
})(); });
|
||||
|
||||
const resetBtn = fwSection.createEl('button', {
|
||||
text: 'Réinitialiser par défaut',
|
||||
cls: 'pseudobs-view-action-btn',
|
||||
});
|
||||
resetBtn.addClass('pseudobs-ner-reset-btn');
|
||||
resetBtn.addEventListener('click', async () => {
|
||||
resetBtn.addEventListener('click', () => { void (async () => {
|
||||
const { DEFAULT_SETTINGS } = await import('../settings');
|
||||
this.plugin.settings.nerFunctionWords = [...DEFAULT_SETTINGS.nerFunctionWords];
|
||||
await this.plugin.saveSettings();
|
||||
textarea.value = this.plugin.settings.nerFunctionWords.join('\n');
|
||||
});
|
||||
})(); });
|
||||
}
|
||||
|
||||
onClose(): Promise<void> {
|
||||
|
|
|
|||
|
|
@ -4,5 +4,7 @@
|
|||
"0.0.3": "1.4.0",
|
||||
"0.0.4": "1.4.0",
|
||||
"0.0.5": "1.4.0",
|
||||
"0.0.6": "1.6.6"
|
||||
//"0.0.6": "1.6.6",
|
||||
"0.0.6": "1.7.2"
|
||||
// "0.1.0": "1.7.2"
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue