@ckeditor/ckeditor5-dev-manual-server 56.4.0 → 56.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,6 @@
1
+ /**
2
+ * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
3
+ * For licensing, see LICENSE.md.
4
+ */
5
+ import type { Plugin } from "vite";
6
+ export declare function ckDebugPlugin(): Plugin;
package/dist/index.d.ts CHANGED
@@ -4,6 +4,7 @@
4
4
  */
5
5
  export { manualTestsPlugin } from "./manual-test-plugin/plugin.js";
6
6
  export type { ManualData, ManualTestsPluginOptions } from "./manual-test-plugin/plugin.js";
7
+ export { ckDebugPlugin } from "./debug-plugin/plugin.js";
7
8
  export { refreshPlugin } from "./refresh-plugin/plugin.js";
8
9
  export { rawHtmlPlugin } from "./raw-plugin/plugin.js";
9
10
  export { stringifyValues } from "./utils.js";
package/dist/index.js CHANGED
@@ -106,13 +106,13 @@ function matchFiles(patterns, workspaceRoot) {
106
106
  * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
107
107
  * For licensing, see LICENSE.md.
108
108
  */
109
- const PROCESSED_MANUAL_TEST_EXTENSIONS = new Set([
109
+ const PROCESSED_MANUAL_TEST_EXTENSIONS = /* @__PURE__ */ new Set([
110
110
  ".html",
111
111
  ".js",
112
112
  ".md",
113
113
  ".ts"
114
114
  ]);
115
- const VITE_MODULE_QUERY_PARAMETERS = new Set([
115
+ const VITE_MODULE_QUERY_PARAMETERS = /* @__PURE__ */ new Set([
116
116
  "import",
117
117
  "raw",
118
118
  "url",
@@ -514,6 +514,41 @@ function getRequiredElementByTagName(root, tagName) {
514
514
  return query(root, (candidate) => isElementNode(candidate) && candidate.tagName == tagName);
515
515
  }
516
516
  //#endregion
517
+ //#region src/debug-plugin/plugin.ts
518
+ /**
519
+ * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
520
+ * For licensing, see LICENSE.md.
521
+ */
522
+ const SOURCE_FILE_REGEXP = /\.[cm]?[jt]sx?$/;
523
+ function ckDebugPlugin() {
524
+ const debugFlags = getDebugFlags(process.env.CK_DEBUG);
525
+ const plugin = {
526
+ name: "ck-debug",
527
+ enforce: "pre"
528
+ };
529
+ if (!debugFlags.size) return plugin;
530
+ return {
531
+ ...plugin,
532
+ transform: {
533
+ filter: { id: { include: SOURCE_FILE_REGEXP } },
534
+ handler(code) {
535
+ if (!code.includes("// @if ")) return null;
536
+ const transformedCode = code.replace(/(^[ \t]*)\/\/ @if (!?[\w]+) \/\/(.*)$/gm, (match, indentation, flagName, body) => {
537
+ if (!debugFlags.has(flagName)) return match;
538
+ return `${indentation}/* @if ${flagName} */${body}`;
539
+ });
540
+ return transformedCode === code ? null : transformedCode;
541
+ }
542
+ }
543
+ };
544
+ }
545
+ function getDebugFlags(debugOption = "") {
546
+ if (debugOption === "false") return /* @__PURE__ */ new Set();
547
+ const flags = /* @__PURE__ */ new Set(["CK_DEBUG"]);
548
+ debugOption.split(",").map((flag) => flag.trim()).filter(Boolean).forEach((flag) => flags.add(`CK_DEBUG_${flag.toUpperCase()}`));
549
+ return flags;
550
+ }
551
+ //#endregion
517
552
  //#region src/refresh-plugin/plugin.ts
518
553
  /**
519
554
  * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
@@ -627,4 +662,4 @@ function getFilePathFromId(id) {
627
662
  * For licensing, see LICENSE.md.
628
663
  */
629
664
  //#endregion
630
- export { manualTestsPlugin, rawHtmlPlugin, refreshPlugin, stringifyValues };
665
+ export { ckDebugPlugin, manualTestsPlugin, rawHtmlPlugin, refreshPlugin, stringifyValues };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ckeditor/ckeditor5-dev-manual-server",
3
- "version": "56.4.0",
3
+ "version": "56.6.0",
4
4
  "description": "Used to extend Vite to create a manual test server for CKEditor 5.",
5
5
  "keywords": [],
6
6
  "author": "CKSource (http://cksource.com/)",
package/theme/shell.ts CHANGED
@@ -35,6 +35,8 @@ if ( globalTarget.editor instanceof Element ) {
35
35
  globalTarget.CKEditorInspector ||= CKEditorInspector;
36
36
  globalTarget.CKEDITOR_GLOBAL_LICENSE_KEY ||= LICENSE_KEY;
37
37
 
38
+ autoAttachInspector();
39
+
38
40
  /**
39
41
  * Clones the injected Shell template, fills it with current test metadata,
40
42
  * and prepends it to the page before the test content is wrapped.
@@ -105,6 +107,24 @@ function setupManualRefreshPrompt(): void {
105
107
  } );
106
108
  }
107
109
 
110
+ function autoAttachInspector(): void {
111
+ let editor = globalTarget.editor;
112
+
113
+ Object.defineProperty( globalTarget, 'editor', {
114
+ configurable: true,
115
+ set( value ) {
116
+ editor = value;
117
+
118
+ if ( editor ) {
119
+ CKEditorInspector.attach( editor );
120
+ }
121
+ },
122
+ get() {
123
+ return editor;
124
+ }
125
+ } );
126
+ }
127
+
108
128
  /**
109
129
  * Opens or closes the instructions panel and synchronizes related accessibility state.
110
130
  */