1
0
mirror of https://github.com/BookStackApp/BookStack.git synced 2025-08-07 23:03:00 +03:00

Lexical: Linked table form to have caption toggle option

This commit is contained in:
Dan Brown
2025-01-22 20:39:15 +00:00
parent 8a66365d48
commit 958b537a49
4 changed files with 42 additions and 7 deletions

View File

@@ -11,7 +11,7 @@ import {el} from "../../utils/dom";
export interface EditorFormFieldDefinition {
label: string;
name: string;
type: 'text' | 'select' | 'textarea';
type: 'text' | 'select' | 'textarea' | 'checkbox';
}
export interface EditorSelectFormFieldDefinition extends EditorFormFieldDefinition {
@@ -42,7 +42,11 @@ export class EditorFormField extends EditorUiElement {
setValue(value: string) {
const input = this.getDOMElement().querySelector('input,select,textarea') as HTMLInputElement;
input.value = value;
if (this.definition.type === 'checkbox') {
input.checked = Boolean(value);
} else {
input.value = value;
}
input.dispatchEvent(new Event('change'));
}
@@ -61,6 +65,8 @@ export class EditorFormField extends EditorUiElement {
input = el('select', {id, name: this.definition.name, class: 'editor-form-field-input'}, optionElems);
} else if (this.definition.type === 'textarea') {
input = el('textarea', {id, name: this.definition.name, class: 'editor-form-field-input'});
} else if (this.definition.type === 'checkbox') {
input = el('input', {id, name: this.definition.name, type: 'checkbox', class: 'editor-form-field-input-checkbox', value: 'true'});
} else {
input = el('input', {id, name: this.definition.name, class: 'editor-form-field-input'});
}