For anyone else working through this, I’ve adapted the Modal dialog in the example plugin, and made use of the createEl methods on the box. I’m still not sure where they come from, but I can make a form and get the results. Here’s my fairly hacky method at the moment:
async onOpen() {
let {contentEl} = this;
let template = await this.plugin.loadTemplate(this.templateName)
console.log("Modal Got template ",template)
const result: Array<Array<any>> = Mustache.parse(template);
console.log(result)
contentEl.createEl('h2', { text: "Create from Template: " + this.templateName });
const titleEl = contentEl.createEl('div');
titleEl.createEl('span',{text:"Title: "});
const titleInput = titleEl.createEl('input');
titleInput.value = "Testing Person"
titleInput.style.cssText = 'float: right;';
const controls:Record<string,HTMLInputElement> = {"title":titleInput}
// Input El
result.forEach( r => {
if( r[0] === "name" && r[1] != "title") {
const id:string = r[1]
const controlEl = contentEl.createEl('div');
controlEl.createEl("span", {text: id})
const input = controlEl.createEl('input');
input.style.cssText = 'float: right;';
controls[id] = input
}
})
const submitButton = contentEl.createEl('button', { text: "Add" });
submitButton.style.cssText = 'float: right;';
submitButton.addEventListener('click', () => {
console.log("Submitted!")
console.log("Calling create")
const data:Record<string,string> = {}
for( const k in controls ) {
data[k] = controls[k].value
}
console.log("Got data! ",data)
this.plugin.createNote(this.templateName,this.targetDir,data['title'],data);
this.close()
});