From 864a2957ffca00fdb00a390ae440fa53d26ed327 Mon Sep 17 00:00:00 2001 From: Owen Lynch Date: Mon, 19 Jul 2021 15:46:59 -0700 Subject: [PATCH] if there's only one type of box, just pick that --- javascript/src/EditorState.ts | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/javascript/src/EditorState.ts b/javascript/src/EditorState.ts index 041a5a86..ec1644f1 100644 --- a/javascript/src/EditorState.ts +++ b/javascript/src/EditorState.ts @@ -397,10 +397,16 @@ export class EditorState { */ addBox() { const box_types = [...Object.keys(this.ls.sg.schema.box_types)]; - this.dialogue.modal = { - ty: ModalState.SelectBox, - choices: box_types - }; + if (box_types.length == 1) { + this.ls.addBox(box_types[0], this.cursor.cursor); + } else if (box_types.length == 0) { + // do nothing + } else { + this.dialogue.modal = { + ty: ModalState.SelectBox, + choices: box_types + }; + } } /** Add a new port to the `cursor.hoveredAttachment` box, assuming it's a box */