onlyworlds_obsidian-plugin/Modals/WorldKeyModal.ts
Titus 3e1725918e 2.2.0: Download World restored, round-trip link integrity, key-format sweep
Save Element creates new elements (create-on-404); Upload World renamed
with real error surfacing; Rename World pushes; Download World returns
(prefixed-key clean) with self-healing Map/Pin/Marker templates; upload
parser ships links as _id/_ids UUIDs; per-world key resolution ends the
wrong-world write class; scoped keys primary in all copy.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-12 13:56:56 +02:00

46 lines
No EOL
1.2 KiB
TypeScript

import { App, Modal } from 'obsidian';
export class WorldKeyModal extends Modal {
onEnter: (value: string) => void;
constructor(app: App, onEnter: (value: string) => void) {
super(app);
this.onEnter = onEnter;
}
onOpen() {
let { contentEl } = this;
contentEl.createEl('h3', { text: 'Enter World Key' });
const input = contentEl.createEl('input', {
type: 'text',
placeholder: 'ow_ key or 10-digit key',
});
const button = contentEl.createEl('button', { text: 'IMPORT' });
button.style.marginLeft = '8px';
button.addEventListener('click', () => {
if (input.value.trim() !== '') {
this.submit(input.value);
}
});
input.addEventListener('keydown', (e: KeyboardEvent) => {
if (e.key === 'Enter') {
this.close();
this.onEnter(input.value);
}
});
input.focus();
}
submit(value: string) {
this.close();
this.onEnter(value.trim());
}
onClose() {
let { contentEl } = this;
contentEl.empty();
}
}