Skip to content

Commit f0b98a0

Browse files
committed
feat: migrate rich text editor to CKEditor
1 parent 04e3ede commit f0b98a0

21 files changed

Lines changed: 1907 additions & 1546 deletions

.env.local.example

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,8 @@ REACT_APP_RASTER_MAP_TILES=https://helsinki-maptiles.dev.hel.ninja/styles/hel-os
2929
REACT_APP_HIGH_CONTRAST_RASTER_MAP_TILES=https://helsinki-maptiles.dev.hel.ninja/styles/turku-osm-high-contrast-pattern-{language}/{z}/{x}/{y}@2x.png
3030
ENABLE_E2E_COVERAGE=false
3131
GENERATE_SOURCEMAPS=false
32+
# CKEditor 5 rich text editor. 'GPL' uses the free open-source build (shows a
33+
# small "Powered by CKEditor" badge); set a commercial license key to remove it.
34+
REACT_APP_CKEDITOR_LICENSE_KEY=GPL
35+
# Backend endpoint for editor image uploads (relative to the API base).
36+
REACT_APP_IMAGE_UPLOAD_ENDPOINT=/v1/image

assets/sass/kerrokantasi/_hearing-form.scss

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -179,9 +179,37 @@ div:has(> .hearing-form-child-modal) {
179179
}
180180

181181
.rich-text-editor {
182-
.DraftEditor-editorContainer {
183-
border: 2px solid $black;
184-
min-height: 90px;
182+
margin-bottom: var(--spacing-s);
183+
184+
.rich-text-editor-extra-controls {
185+
display: flex;
186+
flex-wrap: wrap;
187+
gap: var(--spacing-2-xs);
188+
margin: var(--spacing-2-xs) 0;
189+
}
190+
191+
.rich-text-editor-extra-button {
192+
background: $gray-lighter;
193+
border: 1px solid $black;
194+
padding: 4px 10px;
195+
cursor: pointer;
196+
font-size: 0.875rem;
197+
}
198+
199+
.ck-editor__editable {
200+
min-height: 200px;
201+
}
202+
203+
// Mirror the published-page styling for these block classes inside the editor.
204+
.ck-content {
205+
.lead {
206+
font-weight: bold;
207+
}
208+
209+
.image-caption {
210+
font-size: 0.875rem;
211+
font-style: italic;
212+
}
185213
}
186214
}
187215

package.json

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,7 @@
4242
},
4343
"dependencies": {
4444
"@city-of-helsinki/react-helsinki-notification-manager": "^0.1.0",
45-
"@draft-js-plugins/drag-n-drop": "^4.2.0",
46-
"@draft-js-plugins/editor": "^4.1.0",
47-
"@draft-js-plugins/focus": "^4.1.1",
48-
"@draft-js-plugins/image": "^4.1.1",
49-
"@draft-js-plugins/resizeable": "^5.0.4",
45+
"@ckeditor/ckeditor5-react": "^11.2.0",
5046
"@eslint/js": "^9.25.1",
5147
"@formatjs/intl-relativetimeformat": "^11.2.14",
5248
"@sentry/react": "^9.22.0",
@@ -56,12 +52,10 @@
5652
"alertifyjs": "^1.13.1",
5753
"bootstrap-sass": "3.4.3",
5854
"browser-image-compression": "^2.0.2",
55+
"ckeditor5": "^48.2.0",
5956
"classnames": "^2.3.1",
6057
"dompurify": "^3.4.0",
6158
"dotenv": "^16.4.5",
62-
"draft-convert": "^2.1.10",
63-
"draft-js": "^0.11.7",
64-
"draft-js-export-html": "^1.4.1",
6559
"eslint": "^9.25.1",
6660
"eslint-config-prettier": "^10.1.2",
6761
"eslint-config-vitest-globals": "^2.0.2",

pnpm-lock.yaml

Lines changed: 1091 additions & 243 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/components/RichTextEditor/EditorControls.jsx

Lines changed: 0 additions & 144 deletions
This file was deleted.

src/components/RichTextEditor/Iframe/IframeEntity.jsx

Lines changed: 0 additions & 20 deletions
This file was deleted.

src/components/RichTextEditor/Iframe/__tests__/IframeEntity.test.jsx

Lines changed: 0 additions & 40 deletions
This file was deleted.

src/components/RichTextEditor/Iframe/__tests__/__snapshots__/IframeEntity.test.jsx.snap

Lines changed: 0 additions & 14 deletions
This file was deleted.

src/components/RichTextEditor/Image/ImageCaptionEntity.jsx

Lines changed: 0 additions & 12 deletions
This file was deleted.

src/components/RichTextEditor/Image/ImageEntity.jsx

Lines changed: 0 additions & 17 deletions
This file was deleted.

0 commit comments

Comments
 (0)