diff --git a/packages/editor/src/classes/bootstrap/BootstrapDialog.js b/packages/editor/src/classes/bootstrap/BootstrapDialog.js index 33099fd5..848ebeb4 100644 --- a/packages/editor/src/classes/bootstrap/BootstrapDialog.js +++ b/packages/editor/src/classes/bootstrap/BootstrapDialog.js @@ -114,7 +114,7 @@ class BootstrapDialog extends Options { return header; } - onAcceptClick() { + onAcceptClick(event) { throw new Error('Unsupported operation'); } @@ -122,7 +122,7 @@ class BootstrapDialog extends Options { // Overwrite default behaviour ... } - onRemoveClick() { + onRemoveClick(event) { throw new Error('Unsupported operation'); } diff --git a/packages/mindplot/src/components/widget/NoteEditor.js b/packages/mindplot/src/components/widget/NoteEditor.ts similarity index 87% rename from packages/mindplot/src/components/widget/NoteEditor.js rename to packages/mindplot/src/components/widget/NoteEditor.ts index 3d127996..b7691e49 100644 --- a/packages/mindplot/src/components/widget/NoteEditor.js +++ b/packages/mindplot/src/components/widget/NoteEditor.ts @@ -20,8 +20,13 @@ import $ from 'jquery'; import BootstrapDialog from '../../../../editor/src/classes/bootstrap/BootstrapDialog'; import { $msg } from '../Messages'; +interface NoteEditorModel { + getValue(): string; + setValue(value: string): void; +} + class NoteEditor extends BootstrapDialog { - constructor(model) { + constructor(model: NoteEditorModel) { $assert(model, 'model can not be null'); super($msg('NOTE'), { cancelButton: true, @@ -30,13 +35,12 @@ class NoteEditor extends BootstrapDialog { removeButton: typeof model.getValue() !== 'undefined', onEventData: { model }, }); - this._model = model; this.css({ margin: '150px auto' }); const panel = this._buildPanel(model); this.setContent(panel); } - _buildPanel(model) { + _buildPanel(model: NoteEditorModel) { const result = $('
').css('padding-top', '5px'); const form = $('').attr({ @@ -68,20 +72,20 @@ class NoteEditor extends BootstrapDialog { return result; } - onAcceptClick(event) { + onAcceptClick(event): void { event.data.dialog._submitForm(event.data.model); } - _submitForm(model) { + _submitForm(model: NoteEditorModel) { const textarea = this._native.find('textarea'); if (textarea.val()) { - model.setValue(textarea.val()); + model.setValue(textarea.val() as string); } this.close(); } onDialogShown() { - $(this).find('textarea').focus(); + $(this).find('textarea').trigger('focus'); } onRemoveClick(event) {