diff --git a/.changes/unreleased/Feature-20250523-133341.yaml b/.changes/unreleased/Feature-20250523-133341.yaml new file mode 100644 index 000000000..1a5513a0d --- /dev/null +++ b/.changes/unreleased/Feature-20250523-133341.yaml @@ -0,0 +1,6 @@ +kind: Feature +body: Add Emoji and Fullscreen feature to ckeditor configuration +time: 2025-05-23T13:33:41.645095128+02:00 +custom: + Issue: "" + SchemaChange: No schema change diff --git a/.changes/unreleased/Feature-20250523-133434.yaml b/.changes/unreleased/Feature-20250523-133434.yaml new file mode 100644 index 000000000..31dced03a --- /dev/null +++ b/.changes/unreleased/Feature-20250523-133434.yaml @@ -0,0 +1,6 @@ +kind: Feature +body: Create editor which allow us to toggle between rich and simple text editor +time: 2025-05-23T13:34:34.56795603+02:00 +custom: + Issue: "321" + SchemaChange: No schema change diff --git a/package.json b/package.json index 15697def7..f8489c27d 100644 --- a/package.json +++ b/package.json @@ -20,7 +20,7 @@ "bindings": "^1.5.0", "bootstrap": "5.2.3", "chokidar": "^3.5.1", - "ckeditor5": "^44.1.0", + "ckeditor5": "^45.1.0", "dompurify": "^3.1.0", "eslint": "^9.14.0", "eslint-config-prettier": "^9.1.0", diff --git a/src/Bundle/ChillActivityBundle/Resources/public/vuejs/Activity/index.js b/src/Bundle/ChillActivityBundle/Resources/public/vuejs/Activity/index.js index 2c0a903e5..44f0192df 100644 --- a/src/Bundle/ChillActivityBundle/Resources/public/vuejs/Activity/index.js +++ b/src/Bundle/ChillActivityBundle/Resources/public/vuejs/Activity/index.js @@ -41,9 +41,7 @@ const i18nGendoc = _createI18n({}); document.querySelectorAll("div[data-docgen-template-picker]").forEach((el) => { fetchTemplates(el.dataset.entityClass).then((templates) => { const picker = { - template: - '', + template: ``, components: { PickTemplate, }, @@ -54,7 +52,7 @@ document.querySelectorAll("div[data-docgen-template-picker]").forEach((el) => { }; }, methods: { - generateDoc({ event, link, template }) { + generateDoc({ link, template }) { console.log("generateDoc"); console.log("link", link); console.log("template", template); diff --git a/src/Bundle/ChillMainBundle/Resources/public/module/ckeditor5/editor_config.ts b/src/Bundle/ChillMainBundle/Resources/public/module/ckeditor5/editor_config.ts index cddb5707f..a396da295 100644 --- a/src/Bundle/ChillMainBundle/Resources/public/module/ckeditor5/editor_config.ts +++ b/src/Bundle/ChillMainBundle/Resources/public/module/ckeditor5/editor_config.ts @@ -8,6 +8,9 @@ import { Heading, Link, List, + Emoji, + Mention, + Fullscreen, } from "ckeditor5"; import coreTranslations from "ckeditor5/translations/fr.js"; @@ -26,6 +29,11 @@ export default { Link, List, Paragraph, + // both Emoji and Mention are required for Emoji feature + Emoji, + Mention, + // to enable fullscreen + Fullscreen, ], toolbar: { items: [ @@ -37,8 +45,13 @@ export default { "bulletedList", "numberedList", "blockQuote", + "|", + "emoji", + "|", "undo", "redo", + "|", + "fullscreen", ], }, translations: [coreTranslations], diff --git a/src/Bundle/ChillMainBundle/Resources/public/module/ckeditor5/index.ts b/src/Bundle/ChillMainBundle/Resources/public/module/ckeditor5/index.ts index 9a14cec01..25ab1f55e 100644 --- a/src/Bundle/ChillMainBundle/Resources/public/module/ckeditor5/index.ts +++ b/src/Bundle/ChillMainBundle/Resources/public/module/ckeditor5/index.ts @@ -1,12 +1,32 @@ -import config from "./editor_config"; -import { ClassicEditor } from "ckeditor5"; +import { createApp } from "vue"; +import CommentEditor from "ChillMainAssets/vuejs/_components/CommentEditor/CommentEditor.vue"; const ckeditorFields: NodeListOf = document.querySelectorAll("textarea[ckeditor]"); ckeditorFields.forEach((field: HTMLTextAreaElement): void => { - ClassicEditor.create(field, config).catch((error) => { - console.error(error.stack); - throw error; - }); + const content = field.value; + const div = document.createElement("div"); + + if (field.parentNode !== null) { + field.parentNode.insertBefore(div, field); + } else { + throw "parent is null"; + } + + createApp({ + components: { CommentEditor }, + template: ``, + data() { + return { + content, + }; + }, + methods: { + handleInput() { + field.value = this.content; + }, + }, + }).mount(div); + + field.style.display = "none"; }); -//Fields.push.apply(Fields, document.querySelectorAll('.cf-fields textarea')); diff --git a/src/Bundle/ChillMainBundle/Resources/public/vuejs/_components/CommentEditor/CommentEditor.vue b/src/Bundle/ChillMainBundle/Resources/public/vuejs/_components/CommentEditor/CommentEditor.vue new file mode 100644 index 000000000..7ebd78cf1 --- /dev/null +++ b/src/Bundle/ChillMainBundle/Resources/public/vuejs/_components/CommentEditor/CommentEditor.vue @@ -0,0 +1,121 @@ + + + + + diff --git a/src/Bundle/ChillMainBundle/translations/messages.fr.yml b/src/Bundle/ChillMainBundle/translations/messages.fr.yml index 4313da429..c883cb91c 100644 --- a/src/Bundle/ChillMainBundle/translations/messages.fr.yml +++ b/src/Bundle/ChillMainBundle/translations/messages.fr.yml @@ -915,3 +915,7 @@ multiselect: select_group_label: Appuyer sur "Entrée" pour sélectionner ce groupe deselect_group_label: Appuyer sur "Entrée" pour désélectionner ce groupe selected_label: Sélectionné' + +editor: + switch_to_simple: Éditeur simple + switch_to_complex: Éditeur riche diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/Comment.vue b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/Comment.vue index f063b7b8f..ec8cf1444 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/Comment.vue +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/Comment.vue @@ -13,14 +13,7 @@ $t("comment.label") }} - +