-
Notifications
You must be signed in to change notification settings - Fork 17
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
Clarify what getTargetRanges
should return when all content in an inline element is removed
#158
Comments
Oh, I filed #112 on 2020... |
As far as I've checked for |
|
(Once it's agreed or there should be WPT for considering the final answer, I'll write WPT. However, I'd like to know the opinions before writing tests.) |
Also these proposals are general proposals for how contenteditable/execCommand should work, given that the other browser makers are not willing to have divergent target ranges between contenteditable and EditContext, correct? |
Those two tentative tests test things that are not specified by any specification, correct? Therefore we cannot use these as source of truth. I don't necessarily disagree with browsers behaving this way, but given that the browsers will depend on platform editing behavior, and such behavior may change in the future, I don't see how we can specify that. |
Right, first, (err, but I don't suggest web browsers should change/align the editing result. I just want the normalization rules of target ranges to represent same intentions of browsers with same
I wrote the expectations to conform to the old definition of
No, the result are truly the browsers how the API implemented. It's useful to discuss the clearer definition. (But the expectations are not useful.)
I don't point the differences between platforms (at least in this issue). My point here is, multiple DOM ranges can represent almost same range in the DOM tree. E.g.,
So, there should be a rule to "normalize" target ranges around element boundaries and I'd like the spec clarify the rules. In other words, I'd like to avoid compatibility issues between browsers when they intent to return same target range. |
(And it seems that minimized ranges are same as or similar to current browser implementations. So I think that I don't suggest risky spec changes.) |
@masayuki-nakano If you only take the most central leave node, how would the user remove the link in a case like this?
Hitting backspace once, would create these target ranges, if I understand you right.
If the beforeinput event is not cancelled, the result will then look like this:
The link will be invisible, yet if the user starts typing, the typed text will show up inside the link: 4a. If the user instead uses the arrow keys to move right and left, there will be an empty link stuck there forever, correct? 4b. |
@masayuki-nakano The two tentative tests you created and linked to here seem to say that you want getTargetRanges() to return something other than what is the affected range. See for example this comment:
So you are saying you would want to delete the span as default action, but you don't want to include it in the target range. I don't think I understand why you want want to make a difference there. In the example in my last comment, I think it would be quite bad if an inline element is just left there without any way of being able to remove it.
What performance are we talking about here? The speed of an app that receives typing is naturally limited by the human not being able to type more than at a certain speed. That's why I don't think we have the same kind of speed requirements as for example 3D games, etc. .But maybe I am just not understanding what kind of performance you are thinking of?
I wouldn't like browser's to natively do that. But if they do, I assume the next editing operation will include the insertion of the new piece of content. |
I think there has been some confusion as to whether browsers should or should not reinsert inline dom nodes when typing after deletion. I believe:
|
There was some (TPAC) discussion related to this in w3c/editing#468 to consider to keep the inline element there and remove it later if needed. That will be investigated hopefully soon either by webkit or chromium folks. |
I commented in w3c/editing#468. I think it's impossible to change the default behavior for backward compatibility. However, I'm open for new API to clear the pending style cache.
I wonder, can web developers trust |
From TPAC 2024 minutes:
|
I think that this is the first step to define
getTargetRanges
behavior. (spinning off from #146)Backspace
when<p>ab<span>c[]</span>de</p>
Backspace
when<p>ab<span>c</span>[]de</p>
Delete
when<p>ab<span>[]c</span>de</p>
Delete
when<p>ab[]<span>c</span>de</p>
In all cases, browsers delete
<span>
rather than only"c"
. According to input-events-get-target-ranges-backspace.tentative.html and input-events-get-target-ranges-forwarddelete.tentative.html, browsers (try to) return:<p>ab<span>[c]</span>de</p>
<p>ab<span>[c]</span>de</p>
<p>ab<span>[c]</span>de</p>
<p>ab<span>[c]</span>de</p>
I think that current behavior is better for implementing same behavior in any browsers because if browsers computes the range to delete, they just need to shrink down the range to minimize the range in leaf nodes.
I think that under current definition, the
<span>
should be included, i.e.,<p>ab{<span>c</span>}de</p>
is the expected one. However, it's harder to extend the range from performance point of view. Additionally, even if an inline element which gives a style like<b>
is deleted from the DOM, new typing text could preserve the style. In such case, including parent elements may make web apps confused. Therefore, I believe that it's the best to shrink the target range as far as possible.(Although out of scope of this issue, think
Backspace
when<p>abc</p><p>[]def<br>ghi</p>
case. All browsers tries to return a range around</p><p>
. However, the first text nodedef
and the<br>
in the second paragraph will be moved to the first paragraph, therefore, in strictly conforming to current definition,<p>abc[</p><p>def<br>}ghi</p>
should be included, butdef
will be preserved so that the range is not meaningful for web apps. So, anyway the spec should clarifygetTargetRanges
behavior, and the my recommending behavior makes the rule of this kind of situations simpler too. Since the first line in the second<p>
may be wrapped with some inline elements. Then, browsers do not need to consider whether the range ends before inline elements or at first text.)The text was updated successfully, but these errors were encountered: