-
Notifications
You must be signed in to change notification settings - Fork 39
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
Legal caret positions – invisible text nodes #75
Comments
There was a long discussion about invisible nodes. First I defined them as |
Are those spaces between the two elements? I that case I would argue that it should be possible to place it there, even though the browser may join all those spaces together to be just a single space. We actually had a discussion about that earlier. The "invisible nodes" should never touch text nodes, unless they are in a |
I know – I saw the discussion. If it's OK to say that text nodes are elements, then the definition of invisible elements would be incomplete (as it'd say nothing about text nodes). Therefore, I think that it could be better to cover text nodes and elements separately. I think that browser people would need to make a decision which way is better. Based on that I could try to polish the legal caret positions section. E.g. I also noticed that it may be unclear how |
Hm... I've just realised that these spaces would actually be visible (as one). I need to rethink my initial comment. E.g. which space would be visible in this case And to clarify – I consider this a valid position. In general – I would like to be able to place caret outside inline elements or inside them regardless of their surrounding or contents. PS. CKEditor normalizes all white spaces when loading data, so such situations with white-spaces are unlikely to happen in it. Perhaps we could refer to or define similar normalization in the spec to simplify the rules. |
I think this is stuff the editor has to do. There can be many preferences for how to store spaces in texts and there is no good reason for us to mess with it at this stage. The caret should simply be placeable (programatically) anywhere in text nodes. Rule 1 states that already. So those text nodes do not fall under the definition of invisible. If you don't feel that the commit addresses your concerns, please reopen this issue. |
That's a good point. If an RTE keeps the DOM super clean, then caret won't be able to be placed in those weird locations as e.g.:
So for me that's totally OK. The more places are legal, the more happy I am :). |
Well, the point is just that this is where the the user CAN place the caret programatically (using JS). It doesn't say anything about where the UA SHOULD move the caret next. |
We used to have a basic definition of caret movement, which included something about the caret having to move at least 1px or else repeat the same procedure... But all that is kind of beyond the scope of this spec now and will have to be handled in a future spec. |
Is that a text node with lots of empty spaces before a block ( ) node? No, I don't think that should just happen. If this is because HTML has been loaded into the DOM in some way, then that import process should be changed. |
Yes.
It wouldn't happen in CKEditor as it normalizes white-spaces. But the spec currently says that it's a legal position so if some other editor won't normalizes white-spaces and someone will try to place the caret there by using JS, then (according to the spec) the browser should render such caret. If the browser people are OK with this, then we're fine. BTW. According to the spec there's a difference between:
and
In the first case there's no legal caret position before |
Yes, I think we should stick to this. Otherwise we overcomplicate things and there may be situations we are not thinking of right now where editors actually may want such behavior. |
The following HTML contains many text nodes (
div.firstChild
would be a text node withnodeValue='\n '
):There's a rule saying that caret can be placed:
That would mean that caret can be placed in that first text node, despite the fact that it would be invisible (unless CSS defines differently – e.g.
white-spaces:pre
case).There's a rule already saying that:
Since text nodes are not elements, this rule doesn't apply in this case. So I propose adding another rule (or extending the existing once):
We would also need to define what "invisible text nodes" are (compare: #68).
One additional note: If I understood #74 (comment) correctly, this would mean that the caret cannot be placed anywhere between
<b>
elements in this case:That's because the rules say that the caret can only be placed after/before inline elements which are not followed/preceded by text nodes. If we also say that it cannot be placed in that text node between
<b>
s, then this position will be illegal. This could be clarified by defining #74 as follows:<p><b>x</b>^ </p>
– OK (matches 2nd rule only)<p><b>x</b>^y</p>
– OK (matches 1st rule only)<p><b>x</b>^<b>y</b>
– OK (matches 2nd rule only)<p> ^<b>x</b>
– OK (matches 3rd rule only)<p>x^<b>x</b>
– OK (matches 1st rule only)(BTW. Making these rules exclusive is a challenge :D I'm hope I'm right about the above.)
There's actually one additional node type which complicates this – comments. We could use
previousElementSibling
in the second rule, but it may still not be enough. If we need to worry about comments, perhaps it would be easier to say that this algorithm should totally ignore them.The text was updated successfully, but these errors were encountered: