mirror of
https://github.com/onlyworlds/obsidian-plugin.git
synced 2026-07-22 11:00:31 +00:00
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>
46 lines
No EOL
1.2 KiB
TypeScript
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();
|
|
}
|
|
} |