Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature(ckeditor): Upgrade CKEditor 5 to 37.0.1 #145

Merged
merged 248 commits into from
May 8, 2023

Conversation

JensDallmann
Copy link
Contributor

@JensDallmann JensDallmann commented Mar 21, 2023

Main Purpose

Upgrade CKEditor 5 to 37.x.

CKEditor 37.x ships with its own typings. Thus, we do not need to depend on sometimes outdated, sometimes not fully compatible typings provided at DefinitelyTyped.

The goal of this PR is to update to CKEditor 5 37.x as well as to benefit from new typings and subsequently ease integration into CoreMedia Studio from a developer perspective (thus, not having to maintain typing dependencies along with CKEditor dependencies).

Full Changelog

While some more third-party updates are directly related to the CKEditor 5 update, we also decided to update all third-party dependencies where feasible.

Dependency Updates

Types: ⏫ Major; 🔼 Minor; 🩹 Patch

Dependency Was Is Type Comment
@babel/cli 7.18.10 7.21.0 🔼
@babel/core 7.19.0 7.21.4 🔼
@babel/plugin-transform-arrow-functions 7.18.6 7.20.7 🔼
@babel/plugin-transform-computed-properties 7.18.9 7.20.7 🔼
@babel/plugin-transform-for-of 7.18.8 7.21.0 🔼
@babel/plugin-transform-parameters 7.18.8 7.21.3 🔼
@babel/plugin-transform-typescript 7.19.0 7.21.3 🔼
@babel/preset-env 7.19.0 7.21.4 🔼
@babel/preset-typescript 7.18.6 7.21.4 🔼
@ckeditor/ckeditor5-* 36.0.1 37.0.1
@ckeditor/ckeditor5-dev-utils 30.5.0 36.0.1
@types/express 4.17.13 4.17.17 🩹
@types/jest 28.1.8 29.5.0
@types/jest 28.1.8 29.5.0
@types/node 18.7.16 18.15.11 🔼 Left-over from partial manual update.
@types/node 18.8.1 18.15.11 🔼
@types/webpack 5.28.0 5.28.1 🩹
@typescript-eslint/eslint-plugin 5.36.2 5.58.0 🔼
@typescript-eslint/parser 5.36.2 5.58.0 🔼
babel-jest 28.1.3 29.5.0
css-loader 6.7.1 6.7.3 🩹
enhanced-resolve 5.10.0 5.12.0 🔼
eslint-config-prettier 8.5.0 8.8.0 🔼
eslint-plugin-import 2.26.0 2.27.5 🔼
eslint-plugin-jsdoc 39.3.6 41.1.1
eslint-plugin-tsdoc 0.2.16 0.2.17 🩹
eslint 8.23.0 8.38.0 🔼
express 4.18.1 4.18.2 🩹
jest-circus 28.1.3 29.5.0
jest-config 28.1.3 29.5.0
jest-each 28.1.3 29.5.0
jest-environment-jsdom 28.1.3 29.5.0
jest-environment-node 28.1.3 29.5.0
jest-playwright-preset 2.0.0 3.0.1
jest-runner 28.1.3 29.5.0
jest 28.1.3 29.5.0
playwright-core 1.25.2 1.32.3 🔼
playwright 1.25.2 1.32.3 🔼
postcss-loader 7.0.1 7.2.4 🔼 Required by ckeditor5-dev-utils
postcss 8.4.16 8.4.21 🩹 Required by ckeditor5-dev-utils
prettier 2.7.1 2.8.7 🔼
rimraf 3.0.2 5.0.0
rxjs 7.5.6 7.8.0 🔼 Aligned with CoreMedia Studio
style-loader 3.3.1 3.3.2 🩹
terser-webpack-plugin 5.3.6 5.3.7 🩹
ts-loader 9.3.1 9.4.2 🔼
tslib 2.4.0 2.5.0 🔼
typedoc 0.23.14 0.24.6 🩹
typescript 4.8.2 4.9.5 🔼 Aligned with CoreMedia Studio
webpack-cli 4.10.0 5.0.1
webpack 5.74.0 5.78.0 🔼
xml-formatter 2.6.1 3.3.2 🔼 Required for proper typings.

Dependency To-dos

  • @ckeditor/ckeditor5-dev-webpack-plugin is marked as deprecated. We should review the deprecation and possibly adapt.

Required Changes

Despite some changes triggered by new ESLint and Prettier versions, we also had to adapt to the new API:

  • Mixin Approach: CKEditor 5 now uses one of the suggested approaches for mixins in TyeScript. As this also fixes corresponding linter issues, we applied these adaptations as well by extending, for example, ObservableMixin.

  • Prefer index.ts import: As stated by CKSource their public API contract is now provided by index.ts. Any usages of API not referenced here are subject to change, i.e., may be changed without further notice between CKEditor 5 upgrades.

    We applied these changes and notes, where we had to violate them (and reported) these usages to CKSource, so that in the long run we may come to a pure public API approach.

    For the CKEditor 5 plugins provided by this workspace, we also decided to ship an index.ts, but the contract may need further review. Note, that for augmentation support (see below), you need to use index.ts.

  • Introduce augmentation.ts: As convenient pattern introduced for CKEditor 5 and meanwhile part of the standard plugin creation wizard, we added augmentation.ts, so that, for example, plugins or commands retrieved via editor instance automatically provide proper typing (not relevant for constructor-based access in PluginsMap, though).

  • Remove @ckeditor/ckeditor5-dev-webpack-plugin: As building the example application failed, we had to replace our previous webpack integration and align it with the way, how CKEditor 5 packs their editor builds (such as for classic editor). Having this, we got rid (and had to get rid) off the deprecated dependency @ckeditor/ckeditor5-dev-webpack-plugin.

    Possibly Required Studio Integration Change: This change may need to be adapted for the CoreMedia Studio Workspace.

Todos

  • Identify FontMapper Test Issues

    Test had to be disabled for now (it.skip). Already identified, that Jest, Jest-Playwright and Playwright updates alone did not trigger the issue. Current debugging shows, that the issue is that in headless mode, the clipboard is not updated as expected, and, thus, subsequently the paste action fails. Works in headed mode, though.

    We may decide to do this as follow-up task, but we should do it, as the test is an important integration test for CKEditor updates.

  • Analyse and Decide on Typing Issues

    There are still some TODOs, we should review, try to find alternatives (like new Config API with generics).

  • Announce CKEditor 5 Walk-Throughs

    We may want to announce the new "walk-through" section as "lightweight" documentation approach.

See Also

@JensDallmann JensDallmann force-pushed the feature/upgrade-ckeditor-to-37.0.0 branch from e3a17e7 to 6814925 Compare March 21, 2023 15:05
@mmichaelis mmichaelis force-pushed the feature/upgrade-ckeditor-to-37.0.0 branch 2 times, most recently from e94b5fc to 388a5eb Compare April 6, 2023 10:55
Updating to CKEditor 37.0.1. As it now ships with its own
typings, there is no need for typings provided by
DefinitelyTypes anymore.
@mmichaelis mmichaelis force-pushed the feature/upgrade-ckeditor-to-37.0.0 branch from 388a5eb to 458218c Compare April 6, 2023 11:05
@ckeditor/ckeditor5-dev-utils (dev) ... 30.5.0 ❯ 36.0.1

Also updated required peer dependency postcss:

postcss (dev) .......... 8.4.16 ❯ 8.4.21
postcss-loader (dev) ...  7.0.1 ❯ 7.2.4
@ckeditor/ckeditor5-dev-webpack-plugin (dev) ... 30.5.0 ❯ 31.1.13
@babel/cli (dev)                            7.18.10 ❯ 7.21.0
@babel/core                                  7.19.0 ❯ 7.21.4
@babel/plugin-transform-arrow-functions      7.18.6 ❯ 7.20.7
@babel/plugin-transform-computed-properties  7.18.9 ❯ 7.20.7
@babel/plugin-transform-for-of               7.18.8 ❯ 7.21.0
@babel/plugin-transform-parameters           7.18.8 ❯ 7.21.3
@babel/plugin-transform-typescript           7.19.0 ❯ 7.21.3
@babel/preset-env                            7.19.0 ❯ 7.21.4
@babel/preset-typescript                     7.18.6 ❯ 7.21.4

Skipped jest for now, as we have to see, if it works with
recent jest-playwright.
@types/node (dev)            18.8.1 ❯ 18.15.11
@types/node (dev)           18.7.16 ❯ 18.15.11
@types/express (dev) 4.17.13 ❯ 4.17.17
express (dev)         4.18.1 ❯ 4.18.2
@types/webpack (dev)                          5.28.0 ❯ 5.28.1
terser-webpack-plugin (dev)                    5.3.6 ❯ 5.3.7
webpack (dev)                                 5.74.0 ❯ 5.78.0
webpack-cli (dev)                             4.10.0 ❯ 5.0.1
@typescript-eslint/eslint-plugin (dev) 5.36.2 ❯ 5.57.1
@typescript-eslint/parser (dev)        5.36.2 ❯ 5.57.1
eslint (dev)                           8.23.0 ❯ 8.37.0
eslint-config-prettier (dev)            8.5.0 ❯ 8.8.0
eslint-plugin-import (dev)             2.26.0 ❯ 2.27.5
eslint-plugin-jsdoc (dev)              39.3.6 ❯ 40.1.1
eslint-plugin-tsdoc (dev)              0.2.16 ❯ 0.2.17
css-loader (dev) 6.7.1 ❯ 6.7.3
enhanced-resolve 5.10.0 ❯ 5.12.0
prettier (dev) 2.7.1 ❯ 2.8.7
rimraf (dev) 3.0.2 ❯ 4.4.1
rxjs 7.5.6 ❯ 7.8.0

This is the same version as used in CoreMedia Studio.
style-loader (dev) 3.3.1 ❯ 3.3.2
ts-loader (dev) 9.3.1 ❯ 9.4.2
tslib 2.4.0 ❯ 2.5.0
typedoc (dev) 0.23.14 ❯ 0.23.28
xml-formatter 2.6.1 ❯ 3.3.2
typescript 4.8.2 ❯ 4.9.5
playwright (dev)      1.25.2 ❯ 1.32.2
playwright-core (dev) 1.25.2 ❯ 1.32.2
@types/jest (dev)            28.1.8 ❯ 29.5.0
babel-jest                   28.1.3 ❯ 29.5.0
jest (dev)                   28.1.3 ❯ 29.5.0
jest-circus (dev)            28.1.3 ❯ 29.5.0
jest-config (dev)            28.1.3 ❯ 29.5.0
jest-each (dev)              28.1.3 ❯ 29.5.0
jest-environment-jsdom       28.1.3 ❯ 29.5.0
jest-environment-node (dev)  28.1.3 ❯ 29.5.0
jest-playwright-preset (dev)  2.0.0 ❯ 3.0.1
jest-runner (dev)            28.1.3 ❯ 29.5.0
@mmichaelis mmichaelis force-pushed the feature/upgrade-ckeditor-to-37.0.0 branch from eb67a48 to b34c656 Compare April 6, 2023 12:10
After updating xml-formatter, we need to update the usage
accordingly.
16:45  error  This assertion is unnecessary since it does not
change the type of the expression
@typescript-eslint/no-unnecessary-type-assertion
9:36  error  Replace `typeof·knownNamespacePrefixes` with `(typeof·knownNamespacePrefixes)`  prettier/prettier
JensDallmann and others added 26 commits May 3, 2023 16:46
…tion.

Github runner sometimes are faster, sometimes are slower. We should not cause problems to us due to the variation. Timeouts are only a safety net to not spend too much if something does not progress (e.g. playwright tests).
…h ts

Types are referenced for local development (code completion) with the index.ts but after publication it must reference the index.d.ts.
We decided to switch to building to src/ as this seems to be
common practice and does not trigger error-prone auto-complete
when importing in IDEs, that sometimes suggest the dist/ folder
as the folder to add to the import statement.

Also, we hope, that we get closer to the recommended artifact
setup, as it ships with CKEditor 5 core plugins.

As first step, adapted `rimraf` to respect the new structure,
while still providing an portal to the old setup (just to
clean up our own workspaces, or while still migrating to new
structure).

Also, removed `rimraf` from dependencies but now aligned all
invocations to `npx`, as we already did for removing node_modules.
Get rid of rimraf dependency.
As next step, prior to building to "src/", we have to ignore
these files in `.gitignore`.

Fortunately, we migrated our example app also to TypeScript long
before, so that there are now no `*.js` files left, that must not
be ignored.
Also, we need/should ignore these files when linting, as
reports are not relevant to us.
Also, we need/should ignore these files when linting, as
reports are not relevant to us.
As we don't have a dist/-folder anymore, we also don't
need to copy the theme files (hope, that theming still
works).
Remove copyfiles.
Change reference from dist/ to src/ folder for
artifacts.
Webpack still builds to dist/. In CKEditor 5, it builds
to build/ instead. Don't see any gain in keeping it
that way, thus, reverting to dist/ again for example
application.
Removing outDir configuration in tsconfig.json,
so that now all files are built into the src/
folder, as it is the default.
For node support, we need to specify the JS files as
`main`. While CKEditor 5 comes with publish-tooling to
replace this dynamically, we decide to add it as
extra publishConfig, instead.
Needed to revert. False assumption was, that dependency is not
required using npx. Seems, as if this assumption is wrong.
Switched back to explicit (dev) dependency.
Since rimraf 4.x, --glob option is required to
handle globs. And forgot to "duplicate" pnpm
call in clean-task.

Fixed.
Need to add more "glob" to it for nested paths.
Provide similar pattern as used in CKEditor 5 workspace,
thus, declaring svgs in typings/ folder.
…sted attributes objects.

We may want a better solution but as it not breaking we can still improve later.
@pkliesch pkliesch marked this pull request as ready for review May 8, 2023 14:21
@pkliesch pkliesch merged commit ef75bdd into main May 8, 2023
@pkliesch pkliesch deleted the feature/upgrade-ckeditor-to-37.0.0 branch May 8, 2023 14:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants