From bbeb4e25f333fc86a60be4610a721aa266eeb162 Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Mon, 16 Jun 2025 22:01:05 +0300 Subject: [PATCH] refactor(ckeditor): use vite environment variables for inspector --- apps/client/.env.development | 2 ++ apps/client/.env.production | 1 + apps/client/src/vite-env.d.ts | 2 ++ apps/client/src/widgets/type_widgets/editable_text.ts | 4 +--- 4 files changed, 6 insertions(+), 3 deletions(-) create mode 100644 apps/client/.env.production diff --git a/apps/client/.env.development b/apps/client/.env.development index f3a28cd09..b0273c58e 100644 --- a/apps/client/.env.development +++ b/apps/client/.env.development @@ -1,3 +1,5 @@ +VITE_CKEDITOR_ENABLE_INSPECTOR=false + # The development license key for premium CKEditor features. # Note: This key is for development purposes only and should not be used in production. # Expires on: 2025-09-13 diff --git a/apps/client/.env.production b/apps/client/.env.production new file mode 100644 index 000000000..dc6392a2f --- /dev/null +++ b/apps/client/.env.production @@ -0,0 +1 @@ +VITE_CKEDITOR_ENABLE_INSPECTOR=false \ No newline at end of file diff --git a/apps/client/src/vite-env.d.ts b/apps/client/src/vite-env.d.ts index cb1584238..d6d562031 100644 --- a/apps/client/src/vite-env.d.ts +++ b/apps/client/src/vite-env.d.ts @@ -7,6 +7,8 @@ interface ViteTypeOptions { interface ImportMetaEnv { /** The license key for CKEditor premium features. */ readonly VITE_CKEDITOR_KEY?: string; + /** Whether to enable the CKEditor inspector (see https://ckeditor.com/docs/ckeditor5/latest/framework/develpment-tools/inspector.html). */ + readonly VITE_CKEDITOR_ENABLE_INSPECTOR?: "true" | "false"; } interface ImportMeta { diff --git a/apps/client/src/widgets/type_widgets/editable_text.ts b/apps/client/src/widgets/type_widgets/editable_text.ts index b1ff62751..329e59824 100644 --- a/apps/client/src/widgets/type_widgets/editable_text.ts +++ b/apps/client/src/widgets/type_widgets/editable_text.ts @@ -19,8 +19,6 @@ import { PopupEditor, ClassicEditor, EditorWatchdog, type CKTextEditor, type Men import "@triliumnext/ckeditor5/index.css"; import { normalizeMimeTypeForCKEditor } from "@triliumnext/commons"; -const ENABLE_INSPECTOR = true; - const mentionSetup: MentionFeed[] = [ { marker: "@", @@ -278,7 +276,7 @@ export default class EditableTextTypeWidget extends AbstractTextTypeWidget { editor.model.document.on("change:data", () => this.spacedUpdate.scheduleUpdate()); - if (glob.isDev && ENABLE_INSPECTOR) { + if (import.meta.env.VITE_CKEDITOR_ENABLE_INSPECTOR === "true") { const CKEditorInspector = (await import("@ckeditor/ckeditor5-inspector")).default; CKEditorInspector.attach(editor); }