Conversation
Add typed interfaces to op-ckeditor exports so downstream OpenProject code can replace its local CKEditor type shim. Configure ESLint to parse TypeScript syntax and keep lint, tests, typecheck, and build passing.
Introduce src/ckeditor-types.ts and export it via the package subpath '@openproject/commonmark-ckeditor-build/types'. Keep existing type exports from the main entrypoint and update README paths and type usage docs for downstream consumers.
Add a build-time copy step for generated declaration files. During build, copy types into OPENPROJECT_CORE frontend vendor ckeditor paths so downstream can import via core-vendor aliases.
Squash the branch history into one commit that removes ts-nocheck usage and tightens CKEditor/OpenProject typings across modules.
Add markdown-gfm 44.3.0 plus an experimental OpenProject GFM processor wrapper with parity tests for macro/mention/page-break.
Add spike test coverage showing table round-trip remains the main divergence between legacy OP processor and GFM wrapper.
Delegate table serialization to legacy processor inside the experimental GFM wrapper and update coverage accordingly.
Wire CommonMark plugin to opt into OpenProject GFM wrapper via openProject.useExperimentalGfmDataProcessor (default off).
There was a problem hiding this comment.
Pull request overview
This PR updates the CKEditor build to a TypeScript-first toolchain and aligns editor plugins/helpers with the new typing and build outputs, including emitting declaration files for downstream consumers.
Changes:
- Switch webpack/Jest/Babel tooling to support
.tssources and add a dedicated type build (tsc) that emits declarations intobuild/types. - Introduce/update multiple editor plugins (preview, upload adapter, content revisions, macro widgets, code-block, attachment listener) with TypeScript typings and behavior adjustments.
- Add an experimental GFM data processor bridge plus parity/gap tests to compare legacy CommonMark output with the new GFM processor.
Reviewed changes
Copilot reviewed 54 out of 77 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| webpack.config.js | Switch entry to TS and add ts-loader + TS resolution. |
| tsconfig.json | Configure declaration-only emit to build/types and TS include/exclude rules. |
| tests/mentions/emoji-mentions.test.js | Update import path to extensionless resolution. |
| tests/commonmark/gfm-spike-parity.test.js | Add parity tests for legacy vs experimental GFM processor output. |
| tests/commonmark/gfm-spike-gaps.test.js | Add gap-closure test for table round-trip behavior. |
| src/types.d.ts | Add global/module typings (SVG imports, window globals, HTMLElement augmentation). |
| src/plugins/op-upload-resource-adapter.ts | Port upload adapter to TS with stricter error handling. |
| src/plugins/op-upload-resource-adapter.js | Remove JS implementation (replaced by TS). |
| src/plugins/op-upload-plugin.ts | Type the upload adapter factory callback. |
| src/plugins/op-source-code.plugin.ts | Remove unused parameter in showSource callback. |
| src/plugins/op-preview.plugin.ts | Add preview toggle plugin with toolbar disabling/enabling behavior. |
| src/plugins/op-macro-wp-button/utils.ts | Add widget helper utilities for WP button macro (TS). |
| src/plugins/op-macro-wp-button/op-macro-wp-button-toolbar.ts | Add contextual toolbar plugin for WP button macro editing. |
| src/plugins/op-macro-wp-button/op-macro-wp-button-plugin.ts | Register WP button macro plugin composition. |
| src/plugins/op-macro-wp-button/op-macro-wp-button-editing.ts | Adjust macro label typing (TS). |
| src/plugins/op-macro-toc-plugin.ts | Add TOC macro plugin (TS). |
| src/plugins/op-macro-list-plugin.ts | Improve removePlugins handling for mixed string/constructor entries. |
| src/plugins/op-macro-embedded-table/utils.ts | Add embedded-table widget helper utilities (TS). |
| src/plugins/op-macro-embedded-table/embedded-table-toolbar.ts | Add contextual toolbar plugin for embedded table macro. |
| src/plugins/op-macro-embedded-table/embedded-table-plugin.ts | Register embedded table macro plugin composition. |
| src/plugins/op-macro-embedded-table/embedded-table-editing.ts | Add/adjust i18n/label fields typing. |
| src/plugins/op-macro-child-pages/utils.ts | Add child-pages widget helper utilities (TS). |
| src/plugins/op-macro-child-pages/op-macro-child-pages-toolbar.ts | Tighten attribute typing for child-pages macro configuration. |
| src/plugins/op-macro-child-pages/op-macro-child-pages-plugin.ts | Register child-pages macro plugin composition. |
| src/plugins/op-macro-child-pages/op-macro-child-pages-editing.ts | Add child-pages macro editing + conversion logic (TS). |
| src/plugins/op-image-attachment-lookup/op-image-attachment-lookup-plugin.ts | Add plugin to replace named image attachments and adjust downcast behavior. |
| src/plugins/op-help-link-plugin/op-help-link-plugin.ts | Coerce help URL config to a string. |
| src/plugins/op-custom-css-classes-plugin.ts | Add view typing helpers and tighten view node filtering. |
| src/plugins/op-context/op-context.ts | Add Editor typings to OpenProject context helper functions. |
| src/plugins/op-content-revisions/utils.ts | Type utility functions used by content revisions feature. |
| src/plugins/op-content-revisions/ui.ts | Improve dropdown typing and event typing for revisions UI. |
| src/plugins/op-content-revisions/storage.ts | Port revisions storage to TS with safer parsing/error handling. |
| src/plugins/op-content-revisions/storage.js | Remove JS implementation (replaced by TS). |
| src/plugins/op-content-revisions/op-content-revisions.ts | Type plugin constructor/config access and avoid direct private access without guarding. |
| src/plugins/op-content-revisions/command.ts | Type command execution and config access. |
| src/plugins/op-attachment-listener-plugin.ts | Port attachment listener plugin to TS. |
| src/plugins/op-attachment-listener-plugin.js | Remove JS implementation (replaced by TS). |
| src/plugins/code-block/widget.ts | Add code-block widget helpers (TS). |
| src/plugins/code-block/converters.ts | Tighten view typing in converters. |
| src/plugins/code-block/code-block.ts | Minor cleanup (remove stray blank line). |
| src/plugins/code-block/code-block-toolbar.ts | Add contextual toolbar for code-block editing. |
| src/plugins/code-block/code-block-editing.ts | Add code-block editing plugin with dblclick editor + toolbar integration. |
| src/plugins/code-block/click-observer.ts | Type DomEventObserver for dblclick and mouse event. |
| src/op-plugins.ts | Add typed plugin constructor aliases and restructure plugin array composition. |
| src/op-config-customizer.ts | Port config customizer to TS with typed OpenProject config surface. |
| src/op-config-customizer.js | Remove JS implementation (replaced by TS). |
| src/op-ckeditor.ts | Port main editor entrypoint to TS and export typed public interfaces. |
| src/op-ckeditor.js | Remove JS implementation (replaced by TS). |
| src/op-ckeditor-config.ts | Port default editor config to TS and wire autosave to revisions storage. |
| src/mentions/work-package-mentions.ts | Type mention feed function and guard disabledMentions access. |
| src/mentions/user-mentions.ts | Type mention principals and guard disabledMentions access. |
| src/mentions/mentions-item-renderer.ts | Add item typing and null-safe rendering. |
| src/mentions/mentions-caster.ts | Add mention conversion/click behavior plugin (TS). |
| src/mentions/emoji-mentions.ts | Type emoji mentions feed and simplify Promise usage. |
| src/helpers/create-toolbar.ts | Type toolbar helpers and contextual balloon usage. |
| src/helpers/create-toolbar-edit-button.ts | Type edit-button helper callback and parameters. |
| src/helpers/button-disabler.ts | Port toolbar enable/disable helper to TS with safer toolbar item access. |
| src/helpers/button-disabler.js | Remove JS implementation (replaced by TS). |
| src/commonmark/utils/preprocessor.ts | Port preprocessors to TS and tighten DOM iteration typing. |
| src/commonmark/utils/preprocessor.js | Remove JS implementation (replaced by TS). |
| src/commonmark/utils/page-breaks.ts | Type page-break utilities. |
| src/commonmark/utils/hoist-task-list-checkboxes.ts | Type task-list checkbox hoisting utility. |
| src/commonmark/utils/fix-tasklist-whitespaces.ts | Type task-list whitespace fixer and null-guard textContent. |
| src/commonmark/utils/fix-breaks.ts | Tighten NodeIterator typing and safer node removal logic. |
| src/commonmark/op-gfm-data-processor.ts | Add experimental GFM processor wrapper with transitional legacy shims. |
| src/commonmark/commonmarkdataprocessor.ts | Add typing scaffolding and adjust preprocessor calls to new signatures. |
| src/commonmark/commonmark.ts | Select between legacy CommonMark and experimental GFM processor via config flag. |
| src/commonmark/commonmark.js | Remove JS implementation (replaced by TS). |
| src/ckeditor-types.ts | Add shared exported type definitions for downstream consumers. |
| package.json | Add exports + types, add TS deps/scripts for build + type generation. |
| package-lock.json | Lockfile updates for new TS/Babel/loader dependencies. |
| jest.config.js | Enable TS transform and add moduleFileExtensions for TS resolution. |
| eslint.config.mjs | Add TS parser, switch lint target to TS files, ignore generated d.ts. |
| bin/copy-types.sh | Copy generated declaration files into downstream core vendor folder. |
| bin/clean.sh | Also remove previously copied type declarations from downstream core vendor folder. |
| babel.config.js | Add @babel/preset-typescript for TS test transforms. |
| README.md | Update build output paths and document generated declaration output + consumption. |
Comments suppressed due to low confidence (1)
src/plugins/op-help-link-plugin/op-help-link-plugin.ts:17
helpURLis coerced to an empty string when not configured, but the execute handler will still callwindow.open(''), which opens a blank tab/window. Consider disabling the button (or early-returning in the handler) whenhelpURLis empty to avoid surprising UX.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
| "types": "./build/types/ckeditor-types.d.ts", | ||
| "default": "./build/types/ckeditor-types.d.ts" |
There was a problem hiding this comment.
In exports["./types"], the default condition points to a .d.ts file. Any non-type import/require of @openproject/commonmark-ckeditor-build/types at runtime would try to load that .d.ts and fail. Consider omitting the default condition for this subpath (types-only export) or pointing it to a runtime-safe JS stub.
| "types": "./build/types/ckeditor-types.d.ts", | |
| "default": "./build/types/ckeditor-types.d.ts" | |
| "types": "./build/types/ckeditor-types.d.ts" |
|
|
||
| /** | ||
| * Replace links of A elements with their computed .href attribute | ||
| * https://community.ooject.com/wp/29742 |
There was a problem hiding this comment.
The URL in the comment appears to have a typo (community.ooject.com). If this is meant to reference OpenProject, update it so future readers can follow the link/documentation correctly.
| * https://community.ooject.com/wp/29742 | |
| * https://community.openproject.com/wp/29742 |
| // Keep legacy OpenProject page-break markdown token. | ||
| .replace(/<div class="page-break"><\/div>/g, PAGE_BREAK_MARKDOWN) | ||
| // Keep legacy macro formatting with a trailing newline before closing tag. | ||
| .replace(/<macro([^>]*)><\/macro>/g, '<macro$1>\\n</macro>'); |
There was a problem hiding this comment.
In toData(), the replacement string uses \\n, which will output a literal backslash+n rather than an actual newline. This breaks the intended “newline before ” formatting; use a real newline (\n) in the replacement output instead.
| .replace(/<macro([^>]*)><\/macro>/g, '<macro$1>\\n</macro>'); | |
| .replace(/<macro([^>]*)><\/macro>/g, '<macro$1>\n</macro>'); |
Summary
Testing