I have a CakePHP 2.3 app that for years has had whatever version CK Editor.
I'm working in developing mode, hoping to upgrade it to CKEditor 5.
I easily and quickly got rid of all old code and files to make ckeditor5 work just fine in its most basic version.
This was a go!
However, I do need tables. I'm now working on getting the table feature set up and just cannot get it working.
Here's their doc on this: https://docs.ckeditor.com/ckeditor5/latest/features/table.html
npm install --save @ckeditor/ckeditor5-table
has run successfully. The files are in my repo.
However, the import Table from '@ckeditor/ckeditor5-table/src/table';
and import TableToolbar from '@ckeditor/ckeditor5-table/src/tabletoolbar';
statements make things break.
I have tried moving the @ckeditor
folder out of the main project and into the app's app/webroot/js
folder.
I have tried calling the scripts in different ways.
I am currently trying to figure out if require.js
is the answer for loading these modules, but can't seem to understand how to make it all come together.
Basically, the big question is:
For CakePHP 2.3 specifically,
where should the @ckeditor
folder be
and how do those files/modules get imported into Views
without generating
Uncaught SyntaxError: Unexpected identifier
or
Uncaught Error: Module name 'Table' has not been loaded yet for context:
errors?
And a little question:
Has anyone put out content on how to get the CKEditor 5 working with its table feature in a CakePHP app, yet? I can't seem to find it.
ndm's answer led me to look into
webpack
closely. I knew nothing about. It was much more suited for this job thanrequire.js
.I must say that I still don't understand all of the inner workings of each thing below, but I got the ckeditor 5 working with tables, as needed.
I had to:
src/ckeditor.js
file itself before runningnpm run build
. I could not get it working from theHTML
, because I could not getjs
to recognize the names and classes. I kept gettingUnexpected identifier
errors until I just gave up and called it directly fromsrc/ckeditor.js
. This is fine for my case, because all of my app's CK Editor boxes can be the same. If you need variation, I'm not sure how to make that work.Finally, I should point out that for all of my command line actions, I worked directly from
CakePHP
'sapp/webroot/js
directory, so things were installed in such a way that in the end, my script call is:<script src="/js/ckeditor5-build-classic/build/ckeditor.js"></script>
, so my code for creating the box is:If someone needs this reference, here's EXACTLY what my
src/ckeditor.js
looks like: