From 75afdbe093b89702fba20f16e1bbb5c30bd26b86 Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Wed, 12 Feb 2025 21:56:58 +0200 Subject: [PATCH] chore(client/ts): port editable_code --- .../{editable_code.js => editable_code.ts} | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) rename src/public/app/widgets/type_widgets/{editable_code.js => editable_code.ts} (82%) diff --git a/src/public/app/widgets/type_widgets/editable_code.js b/src/public/app/widgets/type_widgets/editable_code.ts similarity index 82% rename from src/public/app/widgets/type_widgets/editable_code.js rename to src/public/app/widgets/type_widgets/editable_code.ts index 78a266a57..389eb7ae3 100644 --- a/src/public/app/widgets/type_widgets/editable_code.js +++ b/src/public/app/widgets/type_widgets/editable_code.ts @@ -1,3 +1,5 @@ +import type { EventData } from "../../components/app_context.js"; +import type FNote from "../../entities/fnote.js"; import { t } from "../../services/i18n.js"; import keyboardActionService from "../../services/keyboard_actions.js"; import options from "../../services/options.js"; @@ -10,7 +12,7 @@ const TPL = ` position: relative; height: 100%; } - + .note-detail-code-editor { min-height: 50px; height: 100%; @@ -21,6 +23,9 @@ const TPL = ` `; export default class EditableCodeTypeWidget extends AbstractCodeTypeWidget { + + private $editor!: JQuery; + static getType() { return "editableCode"; } @@ -50,11 +55,11 @@ export default class EditableCodeTypeWidget extends AbstractCodeTypeWidget { this.codeEditor.on("change", () => this.spacedUpdate.scheduleUpdate()); } - async doRefresh(note) { - const blob = await this.note.getBlob(); + async doRefresh(note: FNote) { + const blob = await this.note?.getBlob(); await this.spacedUpdate.allowUpdateWithoutChange(() => { - this._update(note, blob.content); + this._update(note, blob?.content); }); this.show(); @@ -66,7 +71,7 @@ export default class EditableCodeTypeWidget extends AbstractCodeTypeWidget { }; } - async executeWithCodeEditorEvent({ resolve, ntxId }) { + async executeWithCodeEditorEvent({ resolve, ntxId }: EventData<"executeWithCodeEditor">) { if (!this.isNoteContext(ntxId)) { return; }