refactor(ckeditor): use vite environment variables for inspector

This commit is contained in:
Elian Doran 2025-06-16 22:01:05 +03:00
parent 88f78f3e32
commit bbeb4e25f3
No known key found for this signature in database
4 changed files with 6 additions and 3 deletions

View File

@ -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

View File

@ -0,0 +1 @@
VITE_CKEDITOR_ENABLE_INSPECTOR=false

View File

@ -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 {

View File

@ -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);
}