import { App, Editor, Modal, Plugin } from 'obsidian'; export default class WheelDecide extends Plugin { wheelOptions: string[]; async onload() { this.addCommand({ id: 'create-decision-wheel', name: 'Create decision wheel', editorCallback: (editor: Editor) => { const wheelOptions: string[] = []; const startLine = editor.getCursor("from").line; const endLine = editor.getCursor("to").line; for (let i = startLine; i < endLine + 1; i++) { wheelOptions.push(editor.getLine(i)) } new WheelModal(this.app, wheelOptions).open() } }); } } class WheelModal extends Modal { wheelOptions: string[]; constructor(app: App, wheelOptions: string[]) { super(app); this.wheelOptions = wheelOptions; } onOpen() { const { contentEl } = this; const wheelUrl = new URL("https://wheeldecide.com/e.php?"); for (let i = 0; i < this.wheelOptions.length; i++) { wheelUrl.searchParams.append(`c${i + 1}`, this.wheelOptions[i]) } contentEl.innerHTML += `` } onClose() { const { contentEl } = this; contentEl.empty(); } }