Skip to content

Commit c82a004

Browse files
authored
Merge pull request #281 from ckeditor/migrate-to-esm
Fix: Use type of the passed `editor` prop rather than generic `Editor` type. Closes #282. Internal: Migrate from webpack and Karma to Vite and Vitest. See ckeditor/ckeditor5#16616. MINOR BREAKING CHANGE: Migrate to ESM. See ckeditor/ckeditor5#16616. MINOR BREAKING CHANGE: Migrate to Composition API. Closes #172. MINOR BREAKING CHANGE: Bump required version to Vue 3.4+. See #282. MINOR BREAKING CHANGE: Export the component as `Ckeditor` instead of `default.component`. Closes #284. MINOR BREAKING CHANGE: Remove argument from the `destroy` event, as it was always `null`. Closes #283.
2 parents e0d7a9e + fae1f55 commit c82a004

37 files changed

+3683
-4658
lines changed

Diff for: .circleci/config.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,11 @@ jobs:
6868
name: Execute ESLint
6969
command: yarn run lint
7070
- run:
71-
name: Run unit tests
72-
command: yarn run coverage --browsers=Chrome,Firefox
71+
name: Run unit tests with coverage
72+
command: yarn run test
7373
- run:
7474
name: Build demo app
75-
command: node ./scripts/test-demo.js
75+
command: yarn run build
7676
- run:
7777
name: Verify the code coverage
7878
command: |

Diff for: .eslintrc.js renamed to .eslintrc.cjs

+4-4
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,14 @@ module.exports = {
2424
' * For licensing, see LICENSE.md.',
2525
' */'
2626
] } ],
27-
'vue/multi-word-component-names': 'off'
27+
'vue/multi-word-component-names': 'off',
28+
'no-unused-vars': 'off',
29+
'@typescript-eslint/no-unused-vars': [ 'error' ]
2830
},
2931
'overrides': [
3032
{
3133
'files': [
32-
'demo/**/*.js',
33-
'demo/**/*.ts',
34-
'demo/**/*.vue'
34+
'**/*.vue'
3535
],
3636
'rules': {
3737
'ckeditor5-rules/license-header': 'off'

Diff for: README.md

+23-43
Original file line numberDiff line numberDiff line change
@@ -25,78 +25,58 @@ See the ["Rich text editor component for Vue.js"](https://ckeditor.com/docs/cked
2525
After cloning this repository, install necessary dependencies:
2626

2727
```bash
28-
yarn install
28+
npm install
2929
```
3030

31-
### Executing tests
32-
33-
```bash
34-
yarn run test -- [additional options]
35-
# or
36-
yarn t -- [additional options]
37-
```
31+
You can also use [Yarn](https://yarnpkg.com/).
3832

39-
The command accepts the following options:
33+
### Running the development server
4034

41-
* `--coverage` (`-c`) – Whether to generate the code coverage.
42-
* `--source-map` (`-s`) – Whether to attach the source maps.
43-
* `--watch` (`-w`) – Whether to watch test files.
44-
* `--reporter` (`-r`) – Reporter for Karma (default: `mocha`, can be changed to `dots`).
45-
* `--browsers` (`-b`) – Browsers that will be used to run tests (default: `Chrome`, available: `Firefox`).
35+
To manually test the editor integration, you can start the development server using one of the commands below:
4636

47-
If you are going to change the component (`src/ckeditor.js`) or plugin (`src/plugin.js`) files, remember about rebuilding the package. You can use `yarn run develop` in order to do it automatically.
37+
```bash
38+
npm run dev
39+
```
4840

49-
### Building the package
41+
### Executing tests
5042

51-
Build a minified version of the package that is ready to publish:
43+
To test the editor integration against a set of automated tests, run the following command:
5244

5345
```bash
54-
yarn run build
46+
npm run test
5547
```
5648

57-
### Changelog generator
49+
If you want to run the tests in watch mode, use the following command:
5850

5951
```bash
60-
yarn run changelog
52+
npm run test:watch
6153
```
6254

63-
### Testing component with Vue CLI
55+
### Building the package
6456

65-
When symlinking the component in an application generated using [Vue CLI](https://cli.vuejs.org/), make sure your `vue.config.js` file configures webpack in the following way:
57+
To build the package that is ready to publish, use the following command:
6658

67-
```js
68-
module.exports = {
69-
configureWebpack: {
70-
resolve: {
71-
symlinks: false
72-
}
73-
}
74-
};
59+
```bash
60+
npm run build
7561
```
7662

77-
Otherwise, the application will fail to load the component correctly and, as a result, it will throw a build error.
78-
7963
## Releasing package
8064

8165
### Prerequisites
8266

8367
Before releasing a new version, run a demo project to confirm that the integration works in a real-world scenario.
8468

85-
1. Navigate to the `demo` folder.
86-
2. Reinstall the dependencies.
87-
3. Run `yarn dev` to see if the integration works as expected.
88-
4. Run `yarn build` to see if the project with the integration builds without errors.
89-
90-
```Text
91-
Dependencies in the `demo` project need to be reinstalled after any changes to the integration, because in `package.json` we use `file:` instead of `link:` due to Vite limitations. Unlike `link:`, which creates a symlink to the integration, `file:` copies its contents when `yarn install` is run and never updates after that.
92-
```
69+
1. Reinstall the dependencies.
70+
2. Run `npm run dev` to see if the integration works as expected.
71+
3. Run `npm run test` to see if the project passes all automated tests.
72+
4. Run `npm run build` to see if the project with the integration builds without errors.
9373

9474
### Changelog
9575

9676
Before starting the release process, you need to generate the changelog:
9777

9878
```bash
99-
yarn run changelog
79+
npm run changelog
10080
```
10181

10282
### Publishing
@@ -106,13 +86,13 @@ After generating the changelog, you are able to release the package.
10686
First, you need to bump the version:
10787

10888
```bash
109-
yarn run release:prepare-packages
89+
npm run release:prepare-packages
11090
```
11191

11292
After bumping the version, you can publish the changes:
11393

11494
```bash
115-
yarn run release:publish-packages
95+
npm run release:publish-packages
11696
```
11797

11898
Note: The `release/` directory will be published.

Diff for: demo/.gitignore

-2
This file was deleted.

Diff for: demo/src/App.vue renamed to demo/App.vue

+18-20
Original file line numberDiff line numberDiff line change
@@ -38,25 +38,23 @@
3838
<script setup lang="ts">
3939
import { ref, reactive } from 'vue';
4040
import {
41-
ClassicEditor,
42-
Essentials,
43-
Paragraph,
44-
Heading,
45-
Bold,
46-
Italic,
47-
type EventInfo
41+
ClassicEditor,
42+
Essentials,
43+
Paragraph,
44+
Heading,
45+
Bold,
46+
Italic,
47+
type EventInfo
4848
} from 'ckeditor5';
4949
50-
import 'ckeditor5/ckeditor5.css';
51-
5250
class TestEditor extends ClassicEditor {
53-
static builtinPlugins = [
54-
Essentials,
55-
Paragraph,
56-
Heading,
57-
Bold,
58-
Italic,
59-
];
51+
static builtinPlugins = [
52+
Essentials,
53+
Paragraph,
54+
Heading,
55+
Bold,
56+
Italic
57+
];
6058
}
6159
6260
// State
@@ -70,7 +68,7 @@ const config = reactive( {
7068
7169
// Methods
7270
function setEditorData() {
73-
data.value = editorInstance.value?.getData() ?? '';
71+
data.value = editorInstance.value?.getData() ?? '';
7472
}
7573
7674
function toggleTwoWayBinding() {
@@ -82,7 +80,7 @@ function toggleEditorDisabled() {
8280
}
8381
8482
function onReady( editor: TestEditor ) {
85-
editorInstance.value = editor;
83+
editorInstance.value = editor;
8684
8785
console.log( 'Editor is ready.', { editor } );
8886
}
@@ -99,8 +97,8 @@ function onInput( data: string, event: EventInfo, editor: TestEditor ) {
9997
console.log( 'Editor data input.', { event, editor, data } );
10098
}
10199
102-
function onDestroy( editor: TestEditor ) {
103-
console.log( 'Editor destroyed.', { editor } );
100+
function onDestroy() {
101+
console.log( 'Editor destroyed.' );
104102
}
105103
</script>
106104

Diff for: demo/demo.ts

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
/**
2+
* @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
3+
* For licensing, see LICENSE.md.
4+
*/
5+
6+
import { createApp } from 'vue';
7+
import CKEditorPlugin from '../src/plugin.js';
8+
import App from './App.vue';
9+
10+
import 'ckeditor5/ckeditor5.css';
11+
12+
createApp( App )
13+
.use( CKEditorPlugin )
14+
.mount( '#app' );

Diff for: demo/package.json

-22
This file was deleted.

Diff for: demo/src/main.ts

-7
This file was deleted.

Diff for: demo/tsconfig.json

-24
This file was deleted.

Diff for: demo/vite.config.ts

-14
This file was deleted.

0 commit comments

Comments
 (0)