From 73e061df996dd4a0d558cc3de16df4690d640311 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sven=20Sch=C3=B6ling?= Date: Tue, 5 Mar 2024 11:17:26 +0100 Subject: [PATCH] Ckeditor5: P.textarea(..., rows=x) Funktion wieder hergestellt MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Ckeditor5 übernimmt standardmäßig nicht die Höhe des unterliegenden texarea Elements. Der initializer Code versucht diese Information zu übergeben, kann aber aus dem "rows" Attribute nicht einfach die Höhe ableiten, und leider auch nicht auf die Renderinformationen von sowohl dem textare als auch dem Ckeditor zugreifen. Stattdessen wird als Heuristik ~30px pro Zeile angenommen. --- js/kivi.js | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/js/kivi.js b/js/kivi.js index 16d7cfe0be..2050a3271b 100644 --- a/js/kivi.js +++ b/js/kivi.js @@ -352,11 +352,21 @@ namespace("kivi", function(ns) { // handle initial height const element = $element.get(0); - if (element.style.height) + if (element.style.height || element.rows) editor.editing.view.change((writer) => { + var height = element.style.height; + + if (!height && element.rows) { + // ckeditor does not support height in rows, but ~30px is a good estimate. + // the correct way would be to either configure it, or to add a small dom + // element and get the line height at run-time, which is pretty overkill + // esp. since ckeditor itself has loads of spacing problems at high zoom + editor.editing.view.add + height = (element.rows * 30) + "px"; + } writer.setStyle( "min-height", - element.style.height, + height, editor.editing.view.document.getRoot() ); });