Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 22 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,31 @@ Building into the core is easy, just run
`npm run build`


This will override the `app/assets/javascripts/vendor/ckeditor/*` contents with the newest webpack build. You need to run this before opening a pull request.
This will override the `frontend/src/vendor/ckeditor/*` contents with the newest webpack build. You need to run this before opening a pull request.

> [!important]
> Please ensure that for any changes in this repository, you have a core repository with the output of `npm run build`, so that all core tests can run and confirm your changes. Both pull requests should _always_ be merged at the same time, never alone

The generated output is written to:

`frontend/src/vendor/ckeditor/*`

### TypeScript types for downstream

This package now emits declaration files into `build/types`.
During `npm run build`, those declarations are also copied into:

- `frontend/src/vendor/ckeditor/types.d.ts`
- `frontend/src/vendor/ckeditor/op-ckeditor.d.ts`

Downstream consumers can import shared editor interfaces from:

```ts
import type { ICKEditorInstance, ICKEditorStatic } from '@openproject/commonmark-ckeditor-build/types';
```

The main package entry also exports these interfaces.


### Updating CKEditor

Expand All @@ -54,7 +74,7 @@ We use `patch-package` (https://www.npmjs.com/package/patch-package) to store a

- Run `npm run watch`

Now the webpack development mode is building the files and outputting them to `app/assets/javascripts/vendor/ckeditor/*`, overriding anything in there.
Now the webpack development mode is building the files and outputting them to `frontend/src/vendor/ckeditor/*`, overriding anything in there.



Expand All @@ -67,4 +87,3 @@ As of version 11.2.0, this library no longer uses jQuery internally. All jQuery
**Important for downstream consumers (e.g., OpenProject):** While this library no longer uses jQuery internally, downstream applications should continue to expose the jQuery global if other parts of the application depend on it. Do not remove the jQuery global from the downstream application (OpenProject) yet until all components have been migrated.

For more details on the downstream migration, see: https://github.com/opf/openproject/pull/19429

1 change: 1 addition & 0 deletions babel.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ module.exports = {
},
},
],
"@babel/preset-typescript",
],
plugins: ["@babel/plugin-transform-modules-commonjs"]
}
2 changes: 2 additions & 0 deletions bin/clean.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@ BUILD_FOLDER=$(realpath "${OPENPROJECT_CORE}/frontend/src/vendor/ckeditor/")
echo "Clearing current build folder ${BUILD_FOLDER}"
rm -rf "${BUILD_FOLDER}/ckeditor.*" || true
rm -rf "${BUILD_FOLDER}/translations/" || true
rm -rf "${BUILD_FOLDER}/types.d.ts" || true
rm -rf "${BUILD_FOLDER}/op-ckeditor.d.ts" || true
16 changes: 16 additions & 0 deletions bin/copy-types.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/usr/bin/env bash

set -eu

: ${OPENPROJECT_CORE?"Need to set OPENPROJECT_CORE"}

BUILD_FOLDER=$(realpath "${OPENPROJECT_CORE}/frontend/src/vendor/ckeditor/")
TYPES_FOLDER="build/types"

if [ ! -f "${TYPES_FOLDER}/ckeditor-types.d.ts" ]; then
echo "Missing generated type file: ${TYPES_FOLDER}/ckeditor-types.d.ts"
exit 1
fi

cp "${TYPES_FOLDER}/ckeditor-types.d.ts" "${BUILD_FOLDER}/types.d.ts"
cp "${TYPES_FOLDER}/op-ckeditor.d.ts" "${BUILD_FOLDER}/op-ckeditor.d.ts"
19 changes: 5 additions & 14 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
import globals from "globals";
import eslint from '@eslint/js';
import jestPlugin from 'eslint-plugin-jest';
import tsParser from '@typescript-eslint/parser';

export default [
eslint.configs.recommended,
{
ignores: ["tmp/", "coverage/", "node_modules/"],
ignores: ["tmp/", "coverage/", "node_modules/", "src/**/*.d.ts"],
},
{
files: ["src/**/*.js"],
files: ["src/**/*.ts"],
languageOptions: {
parser: tsParser,
globals: {
...globals.browser,
"jQuery": true,
Expand All @@ -19,18 +21,7 @@ export default [
},
rules: {
"no-cond-assign": "off",
"no-unused-vars": [
"error",
{
// "args": "all",
"argsIgnorePattern": "^_",
// "caughtErrors": "all",
"caughtErrorsIgnorePattern": "^_",
// "destructuredArrayIgnorePattern": "^_",
"varsIgnorePattern": "^_",
// "ignoreRestSiblings": true
}
],
"no-unused-vars": "off",
"no-undef": "error"
}
},
Expand Down
7 changes: 6 additions & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,19 @@ module.exports = {
],
// A map from regular expressions to paths to transformers
transform: {
'^.+\\.js$': 'babel-jest',
'^.+\\.[jt]s$': 'babel-jest',
},
// A map from regular expressions to module names or to arrays of module names that allow to stub out resources with a single module
moduleNameMapper: {
"\\.(css|less|scss|sass)$": "identity-obj-proxy"
},
// The test environment that will be used for testing
testEnvironment: "jsdom",
moduleFileExtensions: [
"ts",
"js",
"json"
],
// The paths to modules that run some code to configure or set up the testing environment before each test
setupFiles: ['<rootDir>/jest.setup.js'],
// An array of regexp pattern strings that are matched against all source file paths, matched files will skip transformation
Expand Down
Loading
Loading