Upgrade CKEditor and refactor configuration with use of typescript

This commit is contained in:
2024-05-31 21:32:39 +02:00
parent 4b07fe3622
commit dcfa569e3a
12 changed files with 39 additions and 35 deletions

View File

@@ -39,23 +39,5 @@ ClassicEditor.defaultConfig = {
'redo'
]
},
language: 'fr'
language: 'fr',
};
let Fields = [];
Fields.push.apply(Fields, document.querySelectorAll('textarea[ckeditor]'));
// enable for custom fields
//Fields.push.apply(Fields, document.querySelectorAll('.cf-fields textarea'));
Fields.forEach(function(field) {
ClassicEditor
.create( field )
.then( editor => {
//console.log( 'CkEditor was initialized', editor );
})
.catch( error => {
console.error( error.stack );
})
;
});

View File

@@ -0,0 +1,15 @@
import ClassicEditor from "./editor_config";
const ckeditorFields: NodeListOf<HTMLTextAreaElement> = document.querySelectorAll('textarea[ckeditor]');
ckeditorFields.forEach((field: HTMLTextAreaElement): void => {
ClassicEditor
.create( field )
.then( editor => {
//console.log( 'CkEditor was initialized', editor );
})
.catch( error => {
console.error( error.stack );
})
;
});
//Fields.push.apply(Fields, document.querySelectorAll('.cf-fields textarea'));

View File

@@ -1,10 +1,10 @@
const CKEditorWebpackPlugin = require( '@ckeditor/ckeditor5-dev-webpack-plugin' );
const { styles } = require( '@ckeditor/ckeditor5-dev-utils' );
const {CKEditorTranslationsPlugin} = require("@ckeditor/ckeditor5-dev-translations");
buildCKEditor = function(encore)
{
encore
.addPlugin( new CKEditorWebpackPlugin( {
.addPlugin( new CKEditorTranslationsPlugin( {
language: 'fr',
addMainLanguageTranslationsToAllAssets: true,
verbose: !encore.isProduction(),
@@ -65,7 +65,7 @@ module.exports = function(encore, entries)
encore.addEntry('mod_collection', __dirname + '/Resources/public/module/collection/index.ts');
encore.addEntry('mod_forkawesome', __dirname + '/Resources/public/module/forkawesome/index.js');
encore.addEntry('mod_bootstrap', __dirname + '/Resources/public/module/bootstrap/index.js');
encore.addEntry('mod_ckeditor5', __dirname + '/Resources/public/module/ckeditor5/index.js');
encore.addEntry('mod_ckeditor5', __dirname + '/Resources/public/module/ckeditor5/index');
encore.addEntry('mod_disablebuttons', __dirname + '/Resources/public/module/disable-buttons/index.js');
encore.addEntry('mod_blur', __dirname + '/Resources/public/module/blur/index.js');
encore.addEntry('mod_input_address', __dirname + '/Resources/public/vuejs/Address/mod_input_address_index.js');