In order to rebuild the application you need to install all dependencies first. To do it, open the terminal in the project directory and type:
npm install
Make sure that you have the node
and npm
installed first. If not, then follow the instructions on the Node.js documentation page.
You can add new plugin by two common ways that have the same result:
-
Use
npm install
command, e.g:npm install @ckeditor/ckeditor5-highlight@41.2.1 --save
-
Or manually add the plugin to the dependencies section of the
packages/ckeditor5-build/package.json
"dependencies": { //other dependencies ... "@ckeditor/ckeditor5-highlight": "^41.2.1" }
To remove the plugin, simply remove it out of the dependencies section and run npm install
command
You can import any installed plugins to CKEDITOR build by following steps:
- Locate the
ckeditor5.ts
underpackages/ckeditor5-build/src
- Add import statement to the
ckeditor5.ts
, e.g:import { Highlight } from '@ckeditor/ckeditor5-highlight';
If you have already done the Installation and Adding or removing plugins steps, you're ready to rebuild the editor by running the following command:
npm run build
This will build the CKEditor 5 to the build
directory. You can open your browser and you should be able to see the changes you've made in the code. If not, then try to refresh also the browser cache by typing Ctrl + R
or Cmd + R
depending on your system.
To develop CKEditor5 build and plugins and make them available to use in your Magnolia instance
-
Install and build the package:
npm install && npm run build
-
npm run start
, now the package is accessible via http://127.0.0.1:9090/ckeditor5.js or http://localhost:9090/ckeditor5.js
-
Inject the build to Magnolia Rich Text Field powered by CkEditor 5
- Configure the microprofile property
magnolia.ckeditor5.build
with the url to the running package, e.g:magnolia.ckeditor5.build=http://localhost:9090/ckeditor5.js
. Note that, any change to your build will be watched and be in time updated. - Run your instance
The application will be rebuilt on-the-fly after any change. Please note that
build/ckeditor.js
is only rebuilt when runningnpm run build
. - Configure the microprofile property
To customize CKEditor5 build and plugins and make it available to use in your Magnolia instance
- Install and build the package
npm install && npm run build
- Inject the build to Magnolia Rich Text Field powered by CkEditor 5
- Find the
ckeditor5.js
file underpackages/ckeditor5-build/build
- Place the
ckeditor5.js
file in yourlight-module/websresources
. E.glight-modules/module-lm/webresources/
- Config the
magnolia.ckeditor5.build
property with the path to the ckeditor5.js. E.g:-Dmagnolia.ckeditor5.build=light-module/module-lm/webresources/ckeditor5.js
- Find the
- Run your instance
To debug the CKEditor 5 instance on your browser, you need to attach that instance to the ckeditor-inspector.
Prerequisite: https://unpkg.com/@ckeditor/ckeditor5-inspector/build/inspector.js
is attached to the field.
- In the browser, create a bookmark on the Bookmark bar
- In the
Name
field, fill anything you want, e.g.CKEditor Inspector
- In the
Url
field, copy and paste the code below
javascript:(function(){
let script=document.createElement('script');
script.src='https://unpkg.com/@ckeditor/ckeditor5-inspector/build/inspector.js';
script.onload=()=> {
CKEditorInspector.attachToAll();
setTimeout(() => {
const inspectorContainer = document.querySelector('.ck-inspector');
if (inspectorContainer) {
inspectorContainer.style.zIndex = '10000';
}
}, 1000);
};
document.head.appendChild(script);
})()
- Then click
Save
- Open the form, which contains ckeditor5 fields, then click to the saved bookmark, let's says
CKEditor Inspector
, et voila, you will notice there is a small toolbar at the bottom of the page.