You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Need to be able to tell if the caret is displayed at the beginning or the end of the line #32
If a caret is at the end of a line that wraps, it's hard to tell where it is on the screen (end of line or beginning of the next line). This is important for being able to control the selection (beforeSelectionChange).
-From MS Office Team
That should work to find out where the caret is yes. So that's a good idea.
How about this part:
This is important for being able to control the selection (beforeSelectionChange).
As I understand it, we should also be able to set the selection at the start or end of the line, right? This would also be useful for manual movement of caret in block direction.
For that, we probably need to add a new event with a sequence of Range objects and a boolean indicating the caret is before or after the line wrap if the range is collapsed (i.e. selection is caret), and probably add a new method on Selection like setCaretPosition(Node node, unsigned long offset, bool beforeLineWrap) that specifies whether the caret should appear before the line wrap or not if the specified DOM position happens to be at a line wrap.
Do we really need to expose beforeLineWrap to web author? It makes user script complicated.
Once we can specify beforeLineWrap in Selection.modify(), e.g. move towards "inline-end" set internal state beforeLineWrap to true.
Once the spec specifies firing selecitonChange event based on caret quad change instead of caret DOM position change, this issue can be resolved.
Well, the use case here is saving and restoring selection after mutating DOM so the author script must be able to tell whether beforeLineWrap is true or false.
Also, right now if you get bounding client rect of a range that is collapsed at a line break, it returns a dom rect, that is on the end of the previous line. That is completely misleading for the case when the caret stays on the start of the next line.
Therefore getBoundingClientRect should return different rects based on beforeLineWrap.
Activity
johanneswilm commentedon Jun 4, 2015
I agree. Very important for manual movement of the caret in block direction.
rniwa commentedon Jun 4, 2015
Should we add new property like
readonly boolean attribute beforeLineWraponSelectioninterface?johanneswilm commentedon Jun 4, 2015
That should work to find out where the caret is yes. So that's a good idea.
How about this part:
As I understand it, we should also be able to set the selection at the start or end of the line, right? This would also be useful for manual movement of caret in block direction.
rniwa commentedon Jun 5, 2015
For that, we probably need to add a new event with a sequence of
Rangeobjects and a boolean indicating the caret is before or after the line wrap if the range is collapsed (i.e. selection is caret), and probably add a new method onSelectionlikesetCaretPosition(Node node, unsigned long offset, bool beforeLineWrap)that specifies whether the caret should appear before the line wrap or not if the specified DOM position happens to be at a line wrap.johanneswilm commentedon Jun 5, 2015
Sounds good!
yosinch commentedon Mar 16, 2016
Do we really need to expose beforeLineWrap to web author? It makes user script complicated.
Once we can specify beforeLineWrap in Selection.modify(), e.g. move towards "inline-end" set internal state
beforeLineWrapto true.Once the spec specifies firing
selecitonChangeevent based on caret quad change instead of caret DOM position change, this issue can be resolved.rniwa commentedon Mar 16, 2016
Well, the use case here is saving and restoring selection after mutating DOM so the author script must be able to tell whether
beforeLineWrapis true or false.rubywwwilde commentedon Sep 12, 2025
Also, right now if you get bounding client rect of a range that is collapsed at a line break, it returns a dom rect, that is on the end of the previous line. That is completely misleading for the case when the caret stays on the start of the next line.
Therefore getBoundingClientRect should return different rects based on
beforeLineWrap.