Fix "Blank Space" When Editing Text With Floating Image at Beginning of Text #175
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The Issue
We identified an issue with our image integration, which restricts images to be only represented as "inline images": Given a structure like:
It gets rendered with a virtual "paragraph" initially by CKEditor, causing a "surprising blank space" to be shown above the "Text":
This issue got reproduced:
The issue extends to even more problems, like not being able to add text before the floating image.
Suggested Solution
The suggested solution is to also support block images, and get closer to the well-paved path in CKEditor 5, where both types are supported.
This again requires some deep changes, as we currently have a strong dependency on
ImageInline
and also break with the (undocumented) CKEditor 5 contracts, that each and every image must have asrc
attribute set in model layer (see ckeditor/ckeditor5#15653).More to come, if we follow this track, like adapting our data-processing. The suggested approach is, to identify an image being the only element within a
<p>
tag as "block image" (toView
) and later again transform it intoData
mapping to a structure<p><img/></p>
.To-Do
Remove
src
attribute already indataDowncast
Add
toData
data-processing from incoming structure for block-level images.Possibly not even required, if we ensure, that on
dataDowncast
thedata-xlink-href
is stored at the image and not at the figure.Add
toView
data-processing to prepare some<figure>
element.We may need to learn, which attributes (also) go to the
<figure>
element. Current observation is, that someclass
attribute values (here: alignment) are duplicated.Example representation of a block-level image in data view layer:
where the data only represent the data BLOB, that is irrelevant in data layer.