From 271c4fb670a97e5bd1e2feeff4df6bc877201977 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20B=C3=BCrk?= Date: Tue, 7 Jul 2026 14:30:28 +0200 Subject: [PATCH] [TASK] DPL-177: Make readability bar a lit component The CKEditor "DeepL Write" overlay rendered its readability progress bar with an inline

@@ -152,20 +91,14 @@

-
- - 0% -
+

-
- - 0% -
+
diff --git a/Resources/Private/Core14/Backend/Templates/CkEditor/Edit.html b/Resources/Private/Core14/Backend/Templates/CkEditor/Edit.html index f24dca9..2f1e34d 100644 --- a/Resources/Private/Core14/Backend/Templates/CkEditor/Edit.html +++ b/Resources/Private/Core14/Backend/Templates/CkEditor/Edit.html @@ -4,67 +4,6 @@ xmlns:deeplWrite="http://typo3.org/ns/WebVision/DeeplWrite/ViewHelpers" data-namespace-typo3-fluid="true" > -

@@ -150,20 +89,14 @@

-
- - 0% -
+

-
- - 0% -
+
diff --git a/Resources/Public/JavaScript/Ckeditor/deeplwrite-plugin.js b/Resources/Public/JavaScript/Ckeditor/deeplwrite-plugin.js index 20a1600..3f93b54 100644 --- a/Resources/Public/JavaScript/Ckeditor/deeplwrite-plugin.js +++ b/Resources/Public/JavaScript/Ckeditor/deeplwrite-plugin.js @@ -2,6 +2,8 @@ import {Plugin} from '@ckeditor/ckeditor5-core'; import {ButtonView} from '@ckeditor/ckeditor5-ui'; import AjaxRequest from '@typo3/core/ajax/ajax-request.js'; import Modal from '@typo3/backend/modal.js'; +// Registers the custom element used in the overlay. +import '@web-vision/deepl-write/readability-progress.js'; export class Deeplwrite extends Plugin { static pluginName = 'Deeplwrite'; @@ -119,13 +121,8 @@ export class Deeplwrite extends Plugin { if (readability.score === null || readability.score === undefined) { return; } - const value = Math.max(0, Math.min(100, Number(readability.score) || 0)).toFixed(2); - element.style.setProperty('--value', value); - element.setAttribute('aria-valuenow', String(value)); - const label = element.querySelector('.label'); - if (label) { - label.textContent = `${value}%`; - } + // The component clamps, formats and renders. + element.value = Number(readability.score) || 0; }); } } diff --git a/Resources/Public/JavaScript/Ckeditor/readability-progress.js b/Resources/Public/JavaScript/Ckeditor/readability-progress.js new file mode 100644 index 0000000..bb0b038 --- /dev/null +++ b/Resources/Public/JavaScript/Ckeditor/readability-progress.js @@ -0,0 +1,127 @@ +import {html, LitElement} from 'lit'; +import {styleTag} from '@typo3/core/lit-helper.js'; + +/** + * Readability progress indicator used in the DeepL Write CKEditor overlay. + * + * Renders a full-width rainbow scale with a slim marker and a percentage label + * positioned at the current Flesch reading-ease score (0-100). + * + * Styling lives in the shadow DOM, so it cannot leak into or be influenced by + * other components. Instead of `static styles` (which relies on a constructable + * stylesheet bound to the realm where the module was evaluated), the CSS is + * emitted as a nonce-carrying `