-
-
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
Inserting spaces inside the code element does not work #4169
Comments
I did changes recently in handling multiple spaces so this may be related with the code I was workin with. I'll look at it. For sure we cannot apply a hack like suggested. |
I saw recently, when styling the docs, that whitespaces at the boundaries of
|
If that's the case, then the engine does not need to do anything. I mean – it won't be able to do anything more with this. |
I modified the CSS a little: code:not( .hljs ) {
// It's a darker shade of u-color( 'background-hue' ) so it looks good in info-boxes.
// See ckeditor/ckeditor5#3575.
background: rgba( 202, 205, 207, 0.3 );
padding: u-spacing( -4 ) u-spacing( -3 );
border-radius: 3px;
// See ckeditor/ckeditor5#3571.
&:before,
&:after {
// To reduce the width of that space to 0px.
letter-spacing: -1em;
content: "\00a0";
}
// Fixes the 2nd scenario.
& > br[data-cke-filler] {
display: none;
}
} and now the editor does not blow up! But, we cannot add more than one space before the |
I found another problem – you can type two spaces before closing the <p><i>This</i> <code>is an []</code> <strong>editor</strong> <u>instance</u>.</p> When you press Backspace, you will get: <p><i>This</i> <code>is an []</code> <strong>editor</strong> <u>instance</u>.</p> But the rendered view will not change. If you deselect the editor, then focus once again at the end of the code, then press the Backspace, you will get: <p><i>This</i> <code>is an[] </code> <strong>editor</strong> <u>instance</u>.</p> As a summary: the editor will work but the spaces are incorrect rendered. |
tl;dr here is that after introducing proper styles typing more than one space in a row anywhere in |
Additionally, an error is thrown in Safari when typing spaces at the end of |
We'll approach this from the other side: https://github.com/ckeditor/ckeditor5-engine/issues/1126 |
All scenarios require the
Code
feature which will be introduced in ckeditor/ckeditor5-basic-styles#55.The following scenarios shouldn't crash the editor:
1. Insert a space at the end of
</code>
element.Make an editor with the following content:
Then insert a space. The editor data should looks like:
Now we can notice the first problem – one of the space is not visible, two spaces are next to each other (in DOM).
After inserting another space, the editor will blow up. However, the editor still returns a proper HTML:
Editor crashes on the code related to mutations.
const change = getSingleTextNodeChange( mutation );
– this expression for the specific case isundefined
. When I addedif ( !changes ) { return; }
, the error does not occur but another spaces are not inserted.Temporary solution (thanks to @szymonkups) is replacing this line – https://github.com/ckeditor/ckeditor5-engine/blob/a424116abc84287d49343898d84ac471c4c21932/src/view/renderer.js#L472 with the following code:
but it is an ugly hack.
I wrote the test which confirms that model and view have proper values – https://gist.github.com/pomek/912a7c9b391bb1442b0d825b13d2b17e.
It looks like something is invalid with the
code
element.2. Insert space as a code in empty editor
code
styles.The data stored in the model are correct:
Rendered DOM also is ok but the editor does not look ok. You can compare the editor views' by inserting an empty bolded space instead of the code.
After pasting temporary solution in
engine/view/renderer~Renderer#_updateChildren()
, the error will occur once and the spaces will be inserted.The text was updated successfully, but these errors were encountered: