diff --git a/src/super-tag/type.d.ts b/src/super-tag/type.d.ts index 814363f..3c10c6d 100644 --- a/src/super-tag/type.d.ts +++ b/src/super-tag/type.d.ts @@ -10,6 +10,7 @@ declare module '$:/plugins/linonetwo/super-tag/utils/initEditor.js' { declare module '@json-editor/json-editor' { // copy from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/json-editor/index.d.ts + // add `hideAddProperty` interface JSONEditorOptions { /** @@ -163,6 +164,12 @@ declare module '@json-editor/json-editor' { resolvers: Array<(schema: any) => string>; }; + editors: { + SuperTag: { + hideAddProperty(): void; + } + } + public static plugins: { ace: { theme: string; diff --git a/src/super-tag/widgets/utils/formOnChange.ts b/src/super-tag/widgets/utils/formOnChange.ts index f994f05..ab2b90e 100644 --- a/src/super-tag/widgets/utils/formOnChange.ts +++ b/src/super-tag/widgets/utils/formOnChange.ts @@ -26,6 +26,11 @@ export function formOnChange(currentTiddlerTitle?: string, editor?: JSONEditor.J tiddlerFields = tiddlerFieldsWithoutKey; delete latestFormValue[key]; } + // if it was empty, and user add a new property, close the dialog + if (tiddlerFields[key] === undefined && key in latestFormValue) { + // based on `form_name_root` + editor.editors.SuperTag.hideAddProperty(); + } } }); if (hasChange) {