Hi @pklaschka !
I did this thing:
My function is 
function createText(text, { color = "white" } = {}) {
const { selection} = require("scenegraph");
const { Text, Color } = require("scenegraph");
const text = document.querySelector('#txt_bx').value;
const newText = new Text(text);
newText.fill = new Color(color);
selection.insertionParent.addChild(newText);
newText.placeInParentCoordinates({x: 0, y: 0}, selection.insertionParent.localCenterPoint);
return newText;
}
And I called them by using :
document.querySelector("#txt-b").addEventListener("click", createText);
#txt-b is the id of Insert button in my plugin!

What am I missing? Or what is the error ?
Full code is here :
let dialog;
const commands = require("commands");
function quickStuff() {
const html = `<style>
#title{
margin-bottom: 20px;
font-weight: strong;
}
</style>
<form method="dialog" id="main">
<header class="row" id="title">
<span font-size="30px">Quick Stuff</span>
</header>
</br>
<section>
<div class="row break">
<label class="row" id="bg">
<span>Choose Background</span>
<button id="bg-b" type="button" uxp-variant="cta">Choose</button>
</label>
</br>
</section>
<section>
<div class="row break">
<label class="row" id="fg">
<span>Choose Foreground</span>
<button id="fg-b" type="button" uxp-variant="cta">Choose</button>
</label>
</br>
</section>
<section>
<div class="row break">
<label class="row" id="txt">
<span>Foreground Text</span>
<input type="text" uxp-quiet="true" id="txt_bx" value="" placeholder=""/>
<button id="txt-b" type="button" uxp-variant="cta">Insert</button>
</label>
</br>
</section>
</div>
</div>
<footer>
<button id="ok" type="submit" uxp-variant="primary">Create</button>
<button id="cancel" type="submit" uxp-variant="secondary" background-color:"#E54C4C" >Cancel</button>
</footer>
</form>
`
async function bgImage () {
// User picks an image file
const storage = require("uxp").storage;
const fs = storage.localFileSystem;
let imageFile = await fs.getFileForOpening({ types: storage.fileTypes.images });
// Create ImageFill for this image
const ImageFill = require("scenegraph").ImageFill;
let fill = new ImageFill(imageFile);
const {Rectangle} = require("scenegraph");
const rect = new Rectangle();
rect.width = 1920;
rect.height = 1080;
// Set fill of first selected item
rect.fill = fill;
const { selection} = require("scenegraph");
selection.insertionParent.addChild(rect);
selection.items = [rect];
}
async function fgImage () {
// User picks an image file
const storage = require("uxp").storage;
const fs = storage.localFileSystem;
let imageFile = await fs.getFileForOpening({ types: storage.fileTypes.images });
// Create ImageFill for this image
const ImageFill = require("scenegraph").ImageFill;
let fill = new ImageFill(imageFile);
const {Rectangle} = require("scenegraph");
const rect = new Rectangle();
rect.width = 1920;
rect.height = 1080;
// Set fill of first selected item
rect.fill = fill;
const { selection} = require("scenegraph");
selection.insertionParent.addChild(rect);
selection.items = [rect];
}
function createText(text, { color = "white" } = {}) {
const { selection} = require("scenegraph");
const { Text, Color } = require("scenegraph");
const text = document.querySelector('#txt_bx').value;
const newText = new Text(text);
newText.fill = new Color(color);
selection.insertionParent.addChild(newText);
newText.placeInParentCoordinates({x: 0, y: 0}, selection.insertionParent.localCenterPoint);
return newText;
}
function parallaxFinal(){
}
if (!dialog) {
dialog = document.createElement("dialog");
dialog.innerHTML = html;
document.appendChild(dialog);
document.querySelector("#bg-b").addEventListener("click", bgImage);
document.querySelector("#fg-b").addEventListener("click", fgImage);
document.querySelector('#txt-b').addEventListener('click', evt => createText(evt.target.value));
document.querySelector("#ok").addEventListener("click", parallaxFinal);
}
return dialog.showModal()
}
module.exports = {
commands: {
quickStuff
}
};