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
Should br
break inline elements?
#1068
Comments
From technical perspective it's a question whether |
cc @Comandeer |
HTML specification allows using line break inside inline elements (or – to be more precise – inside phrasing content; block and inline elements were defined in HTML 4, HTML LS/5.x defines several other elements categories). OTOH link is no longer only phrasing content, it's also flow one now, as it can contain flow content like |
Whether HTML specification allows line breaks inside phrasing content wasn't (I think) the question here. The question is – do we need that? From a semantic standpoint I can see cases where the content should contain e.g. |
I noticed this behavior as well. And for the reason when removing the selection it would be nice to see the link disappear at once. |
Is there any current work-around for this or progress being made? From my example (an event listing), ideally the output would be:
But currently if you highlight multiple lines and create a link you get:
The main issue in my case is visual, as the hover effect is applied individually to each line when applying it to the whole block would make more sense. |
We would really benefit from having this fixed, it's affecting our product development. |
There are 3 part to this ticket. 1. Extending softBreaks schemaAdding 2. Fixing ShiftEnterCommandAdding to the ShiftEnterCommand this bit:
This will ensure that TODO: Check whether In case, 3. Fixing the selection attributes' discoveryFixing the selection attributes discovery code that it reads attributes also from inline elements. Currently, it does not: (Note: There are no selection attributes listed in the right pane) Scope of this ticketLet's cover the points 1 and 2 in this ticket. The 3rd part (selection attrs discovery) is tricky and hence, worth moving to a separate issue. The result of not fixing this will not be very visible anyway. |
Other considerations:
|
Taken the other findings, it's hard to figure out what's the MVP here. Some of the "other findings" would also need to be included in the MVP. Thus, the complexity grows. |
Since this is not a quick win and I don't know the ETA for a complete resolution of this issue (in a way that we may accept in the core) I'd like to propose a simple workaround for all of you dealing with data migration from e.g. CKEditor 4. The solution is really simple – you just need to load an additional plugin to the editor. The plugin looks like this: class LinkableBRs {
constructor( editor ) {
this.editor = editor;
}
init() {
this.editor.model.schema.extend( 'softBreak', {
allowAttributesOf: '$text'
} );
}
} It has no external dependencies so it can be added even to a build via It makes the editor keep |
The LinkableBRs plugin provided by @Reinmar is useful if you edit the source code, but it doesn't fix the Shift+Enter issue. It's probably more difficult to modify the ShiftEnterCommand's insertBreak method by a plugin as described, right? |
@rgpublic, I think you would need to listen for |
I am using Drupal 9/10 and CKeditor5 is built into core, does anyone know how to add the proposed class LinkableBRs {} in drupal? Current I am trying to use |
Have you found the solution for this? I also got this issue.. Drupal 10.2.2 |
Was unable to find a solution yet |
@jonmenard @arfanseptianto could you reach Drupal community on Slack? I'm not an expert in their ecosystem, I assume you could just load somehow the plugin into the editor's plugins list. |
The solution provided by @danielkorte worked perfectly! Here's an overview of my project structure to give you a clearer picture. The cdlsimod represents our custom module, and custom_linkablebrs is the cloned environment with the provided repository's contents. To integrate the solution, I executed the following commands:
Alternatively, if you prefer a GUI approach, you can enable the module and clear the caches directly through the website's administrative interface. |
Yes, works like a charm. Thank you @danielkorte |
At this moment if you press Shift + Enter inside an inline element,
<br>
element won't be inserted as a chidren of the inline element. The<br>
will break the inline element:I'm not sure how it should behave. Is it correct? What if we would like to have the same link in both lines? Editing inline styles (like bold, highlights, font size, etc.) is not a problem. The issue appears if we would like to edit links that are split by the
<br>
element. But there is the separate ticket for it – https://github.com/ckeditor/ckeditor5-link/issues/192.EDIT: See the workaround in this post.
The text was updated successfully, but these errors were encountered: