Skip to content

Commit

Permalink
Ckeditor5: P.textarea(..., rows=x) Funktion wieder hergestellt
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
sschoeling authored and bblessmann committed Mar 6, 2024
1 parent b0c6172 commit 73e061d
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions js/kivi.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()
);
});
Expand Down

0 comments on commit 73e061d

Please sign in to comment.