-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
The upcast conversion can't properly handle inline objects without $text accepting context #7753
Comments
Original issue #6698 |
We talked about Option 1. f2f and it wasn't looking good in terms of code. It'd add complexity and I wasn't even able to understand if it'd work. Option 2. seems to be a hack. That we don't know what to do so we make a method overridable :D Do we open other Option 3. I'm leaning for this option the most. To rephrase Kuba's proposal – the idea is that the engine knows about paragraphs anyway. It's the default block to be used when something's wrong (e.g. in Option 4. I think it's a no go because of the performance aspect. The conversion performance is already a problem so we should avoid making it worse. Finally, it's unclear to me who would be firing these events. It'd most likely be a huge breaking change. Plus, it'd add more complexity to something that's already too complex. |
I think we can rule out option 4. Performance is one thing, complexity is another. We want to make things easier in CKE5 :D. I think that option 1 is closest to what the auto-paragraphing is about, however, I don't understand this drawback:
Isn't auto-paragraphing about trying to put a thing in a paragraph and check if it would be allowed this way? I don't like option 2 because it looks like we are introducing "overwriting" only to solve one concrete problem. I can't see how this method would be further expanded, or how custom (3rd party code) would want to expand it. For me, it is option 1 or option 3. If option 3 is simpler, I can go with option 3. It couples One thing that I don't like though is that |
I had some hard times parsing this all together. However your comments shine some light on this. Option 1: 😶 I'm not sure what this should do. But it feels like adding more hacks to a hack (paragraph as a separate plugin). Option 2: 👎 I'm with @scofalik on this - we can't decorate every single method in the API if we see some problems. I think that decorating should be done with extra care. We have too many events IMO. Option 3: 👍 but as all-together:
I was briefly thinking about converting such things to a generi Option 4: 👎 try to write a guide for that ;) |
Cool, so it seems that we have a conclusion – let's merge autoparagraphing into the engine :) Biggest benefit: decreased complexity. |
This was also affecting Expected model result: Actual result: |
Fix (engine): Upcast conversion will now try to wrap text and inline elements in paragraph if such content is converted in a place where is not allowed but a paragraph is allowed. Closes #7753. Closes #6698. Internal (paragraph): Auto-paragraphing content conversion moved to the engine package. Tests (table): Added tests for upcasting inline elements inside a table cell.
The upcast conversion and auto-paragraphing
Technical Story:
Context and Problem Statement
Context
Inline objects that are allowed only where
$text
, can't be properly auto-paragraphed and it results as broken upcast.This happens because of a mistake in the auto-paragraphing code (view element is used to check
schema.checkChild()
)ckeditor5/packages/ckeditor5-paragraph/src/paragraph.js
Line 196 in 50e3509
This error can be easily reproduced using the placeholder widget like this:
span
element can't be converted becausesplitToAllowedParent
can't find a proper insertion position.span
view element to check if it's allowed by the schema.Problem
Auto-paragraphing doesn't know what would be the model element after converting view element so can't properly check if it would convert properly if it would be auto-paragraphed.
Considered Options
paragraph
element (without checking if the resulting model element is allowed in the context by the schema) and afterward check if it is compliant with schema.conversionApi.splitToAllowedParent()
to verify if the converted model element would be allowed if auto-paragraphed (it could insert paragraph there and return position inside that paragraph).conversionApi.splitToAllowedParent()
.'element:span:match'
- testing if view item should be handled'element:span:create'
- creating a model element from the view element (getModelElement()
)'element:span:insert'
- finding a proper position and inserting a model element (splitToAllowedParent()
andwriter.insert()
)'element:span:children'
-convertChildren()
'element:span:updatecursors'
-updateConversionResult()
Pros and Cons of the Options
Option 1: Auto-paragraphing and checking afterward
model.deleteContent()
).Option 2: "Decorating"
splitToAllowedParent()
to extend it with auto-paragraphingProbably to maintain consistency with conversion API it should be a dedicated event that would also provide
conversionApi
object.splitToAllowedParent()
from external plugins (i.e., paragraph is a separate plugin) so auto-paragraphing would stay in one place.Option 3: Auto-paragraphing elements directly inside
splitToAllowedParent()
Currently, parts of the paragraph functionality are highly incorporated into the engine (example:
model.deleteContent()
is auto-paragraphing if needed.splitToAllowedParent
is not the best name for it.Option 4: Splitting the conversion process to a series of events
The text was updated successfully, but these errors were encountered: