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/ChillMainBundle/Resources/public/module/ckeditor5/index.ts b/src/Bundle/ChillMainBundle/Resources/public/module/ckeditor5/index.ts index 9a14cec01..163ab012f 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