From: Alexander Ebert Date: Mon, 15 Jan 2024 16:54:46 +0000 (+0100) Subject: Improve the name of the exported type X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=6a5093110bf92fa754003a9ce9a151be3c5333c4;p=GitHub%2FWoltLab%2FWCF.git Improve the name of the exported type --- diff --git a/ts/WoltLabSuite/Core/Component/Ckeditor/Autosave.ts b/ts/WoltLabSuite/Core/Component/Ckeditor/Autosave.ts index c0090c5c10..a68e99fc45 100644 --- a/ts/WoltLabSuite/Core/Component/Ckeditor/Autosave.ts +++ b/ts/WoltLabSuite/Core/Component/Ckeditor/Autosave.ts @@ -15,7 +15,7 @@ import { getPhrase } from "../../Language"; import { escapeHTML } from "../../StringUtil"; import { dispatchToCkeditor, listenToCkeditor } from "./Event"; -export type Payload = { +export type AutosavePayload = { html: string; timestamp: number; }; @@ -78,7 +78,7 @@ function saveDraft(element: HTMLElement, identifier: string, html: string): void return; } - const payload: Payload = { + const payload: AutosavePayload = { html, timestamp: Date.now(), }; @@ -93,7 +93,7 @@ function saveDraft(element: HTMLElement, identifier: string, html: string): void } export function setupRestoreDraft(editor: CKEditor5.ClassicEditor.ClassicEditor, identifier: string): void { - let value: Payload | undefined = undefined; + let value: AutosavePayload | undefined = undefined; try { const payload = window.localStorage.getItem(getLocalStorageKey(identifier)); @@ -211,7 +211,7 @@ function removeExpiredDrafts(): void { return; } - let payload: Payload | undefined = undefined; + let payload: AutosavePayload | undefined = undefined; try { payload = JSON.parse(value); } catch { diff --git a/ts/WoltLabSuite/Core/Component/Ckeditor/Event.ts b/ts/WoltLabSuite/Core/Component/Ckeditor/Event.ts index 49814410cb..8761e8321e 100644 --- a/ts/WoltLabSuite/Core/Component/Ckeditor/Event.ts +++ b/ts/WoltLabSuite/Core/Component/Ckeditor/Event.ts @@ -13,10 +13,11 @@ import type { Features } from "./Configuration"; import type { InsertAttachmentPayload, RemoveAttachmentPayload, UploadAttachmentEventPayload } from "./Attachment"; import type { UploadMediaEventPayload } from "./Media"; import type { InsertQuoteEventPayload } from "./Quote"; +import type { AutosavePayload } from "./Autosave"; import type { CKEditor5 } from "@woltlab/editor"; -import { Payload } from "WoltLabSuite/Core/Component/Ckeditor/Autosave"; const enum EventNames { + Autosave = "ckeditor5:autosave", Bbcode = "ckeditor5:bbcode", CollectMetaData = "ckeditor5:collect-meta-data", Destroy = "ckeditor5:destroy", @@ -31,7 +32,6 @@ const enum EventNames { SubmitOnEnter = "ckeditor5:submit-on-enter", UploadAttachment = "ckeditor5:upload-attachment", UploadMedia = "ckeditor5:upload-media", - Autosave = "ckeditor5:autosave", } type BbcodeEventPayload = { bbcode: string; @@ -81,9 +81,9 @@ class EventDispatcher { this.#element.dispatchEvent(new CustomEvent(EventNames.DiscardRecoveredData)); } - autosave(payload: Payload): void { + autosave(payload: AutosavePayload): void { this.#element.dispatchEvent( - new CustomEvent(EventNames.Autosave, { + new CustomEvent(EventNames.Autosave, { detail: payload, }), ); @@ -312,8 +312,8 @@ class EventListener { return this; } - autosave(callback: (payload: Payload) => void): this { - this.#element.addEventListener(EventNames.Autosave, (event: CustomEvent) => { + autosave(callback: (payload: AutosavePayload) => void): this { + this.#element.addEventListener(EventNames.Autosave, (event: CustomEvent) => { callback(event.detail); });