-
-
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
Enable <img> inside <p> conversion #5092
Comments
Each element which we'll want to "hoist" from incorrect context by breaking its parent(s) will require additional code. So, we'll need a more general solution to this problem than a special handler in the image feature. A way to mark certain elements that even if they are not in the right context, they should be converted and lead to splitting the parents up to a point where they are allowed. OTOH, we don't have other cases in our hands currently, so we can take some shortcuts to speed it up. |
Honestly, I don't know how to approach this issue, when there is that issue: https://github.com/ckeditor/ckeditor5-paragraph/issues/11. Here we want to break paragraph when there is an image inside it, while there we want to make a paragraph on image if it doesn't have it. If we want to come up with something that makes sense we need to agree on some things. Okay now you can say - but this is block-image case and that issue is inline-image case. But how actually are we going to differentiate between them? External HTML won't give you much clue about it. Consider following examples: foo<img />bar
<p>foo<img />bar</p>
<p>foo</p><img /><p>bar</p>
<div>foo<img />bar</div>
<div><p>foo</p><img /><p>bar</p></div> Case 1: Hard to say whether this should be inline or block. In case 5, DOM converted to model, without any magic, should end up like this: In case 1 and 4, after autoparagraphing kicks in, we get the same situation as in case 4. My idea is that if we want inline images, when converting view If we don't want inline images in foreseeable future, we can for now forget about the issue I linked above (or instead of If that's the case let's think how we want to proceed with this. Let's start from noticing, that we could have different kinds of inputs: foo<img />bar
<div>foo<img />bar</div>
<p>foo<img />bar</p> Case 1: Works out of the box (after bare It seems that with proper autoparagraphing we will only have situations where we either have image in root or in a recognized and converted element, like If we want to fix this on view to model conversion* then we could use the same trick as with autoparagraphing (https://github.com/ckeditor/ckeditor5-paragraph/issues/10#issuecomment-293889123). The trick is to convert image anyway. Optionally, check if it will be allowed at any level of * - I've made that comment because I think that it would be also reasonable to do this and even autoparagraphing before view to model conversion. We could use |
Since it took me like 2 hours to write this and you commented in the meantime - I agree that this could be done as more general solution - both as "autohoist" view-to-model converter (same as autoparagraph for text and inline elements) or - as I described later - corrected straight on view (using some hardcoded view/DOM relations).
Shortcuts can lead us to such problems again. We need a good understanding of how incorrect content should be fixed. |
Good that I'm on holidays and the weather is bad so I have a lot of time to read this :D |
Yyy... nope. We don't want to create paragraphs on images because images are allowed in the root while they are not allowed in paragraphs. That's a totally different case than the whole autoparagraphing issues. |
It depends on the features you load to the editor. Currently, we support only block images so the image feature converts only them. If we'll ever support inline images this will be a separate feature. Now, which one of them gets the
Actually, the correct block |
Anyway, for now I can see that all this just boils down to a proper ordering of the listeners. It's sad that this is not trivial, but this is not trivial only if we consider two conflicting features working at the same time – block and inline images. If we considered just one, everything would be simple (EDIT: I should never say that :D). |
Okay, so to sum it up:
|
Yep, looks good. Please, remember that the last point (autop inline stuff) has the lowest priority because we don't have any empty inline elements atm. Although, perhaps this issue and losing inline styling when autoping has the same solution anyway. |
Feature: Introduced support for pasting and loading images in context in which they cannot appear in the editor. For example, if an `<p>foo<img>bar</p>` is pasted, the pasted paragraph will be split (because an image in the editor cannot be contained in a paragraph). Closes #98.
Originally described here: https://github.com/ckeditor/ckeditor5-image/issues/8#issuecomment-263228358
The problem is that
<paragraph>
do not allow<image>
inside it, but it's common to have<p>Foo<img />bar</p>
content in pasted data. Such data should be converted to<paragraph>Foo</paragraph><image></image><paragraph>bar</p>
.The text was updated successfully, but these errors were encountered: