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');

View File

@@ -52,7 +52,7 @@
<script>
import CKEditor from '@ckeditor/ckeditor5-vue';
import ClassicEditor from "ChillMainAssets/module/ckeditor5";
import ClassicEditor from "../../../../../../ChillMainBundle/Resources/public/module/ckeditor5/editor_config";
import { mapState } from "vuex";
export default {

View File

@@ -41,7 +41,7 @@
import Modal from 'ChillMainAssets/vuejs/_components/Modal.vue';
import { makeFetch } from "ChillMainAssets/lib/api/apiMethods";
import CKEditor from '@ckeditor/ckeditor5-vue';
import ClassicEditor from "ChillMainAssets/module/ckeditor5";
import ClassicEditor from "ChillMainAssets/module/ckeditor5/editor_config";
export default {
name: "WriteComment",

View File

@@ -331,7 +331,7 @@
import {mapState, mapGetters,} from 'vuex';
import {dateToISO, ISOToDate, ISOToDatetime} from 'ChillMainAssets/chill/js/date';
import CKEditor from '@ckeditor/ckeditor5-vue';
import ClassicEditor from 'ChillMainAssets/module/ckeditor5/index.js';
import ClassicEditor from 'ChillMainAssets/module/ckeditor5/editor_config';
import AddResult from './components/AddResult.vue';
import AddEvaluation from './components/AddEvaluation.vue';
import AddPersons from 'ChillPersonAssets/vuejs/_components/AddPersons.vue';

View File

@@ -195,7 +195,7 @@
<script>
import {dateToISO, ISOToDate, ISOToDatetime} from 'ChillMainAssets/chill/js/date';
import CKEditor from '@ckeditor/ckeditor5-vue';
import ClassicEditor from 'ChillMainAssets/module/ckeditor5/index.js';
import ClassicEditor from 'ChillMainAssets/module/ckeditor5/editor_config';
import { mapGetters, mapState } from 'vuex';
import PickTemplate from 'ChillDocGeneratorAssets/vuejs/_components/PickTemplate.vue';
import {buildLink} from 'ChillDocGeneratorAssets/lib/document-generator';

View File

@@ -75,7 +75,7 @@ div.participation-details {
import { mapGetters } from 'vuex';
import PersonRenderBox from 'ChillPersonAssets/vuejs/_components/Entity/PersonRenderBox.vue';
import CKEditor from '@ckeditor/ckeditor5-vue';
import ClassicEditor from 'ChillMainAssets/module/ckeditor5/index.js';
import ClassicEditor from 'ChillMainAssets/module/ckeditor5/editor_config';
export default {
name: 'MemberDetails',

View File

@@ -10,7 +10,7 @@
<script>
import CKEditor from '@ckeditor/ckeditor5-vue';
import ClassicEditor from "ChillMainAssets/module/ckeditor5";
import ClassicEditor from "ChillMainAssets/module/ckeditor5/editor_config";
export default {
name: "PersonComment.vue",

View File

@@ -15,7 +15,7 @@ const personMessages = {
person: {
firstname: "Prénom",
lastname: "Nom",
born: (ctx) => {
born: (ctx: {gender: "man"|"woman"|"unknown"}) => {
if (ctx.gender === 'man') {
return 'Né le';
} else if (ctx.gender === 'woman') {