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
I am working on a plugin for etherpad, where I try to limit selections to certain parts of the pad content. This includes some lines, where I do not want the caret to be placeable. I added a contentEditable=false tag to the corresponding html-elements. With this, it is no longer possible to navigate the caret to these lines with the arrow keys. However, one can still place it there with a mouse click. The caret is invisible but there and can be used to edit the content.
I have successfully worked with the ace_setSelection method of the editorInfo object for extended selections. However, if I only have a caret position, I did not succeed in moving the caret with ace_setSelection.
I figured out that this behavior is caused by repeated calls of the setSelection method in ace2_inner.jshere resulting in a race condition. This in turn in caused by the call of updateBrowserSelectionFromRephere since selectionAffected was set to true by the incorporateUserChanges method here, which is ultimately called by the idleWorkTimer.
(Note: I work with EP version 1.8.9, but there are no major differences in the codebits I am talking about, I checked that beforehand)
After this lengthy introduction (sorry!) I try to understand why this condition is used to the selectionAffected to true: if (selection && (domChanges || isCaret())) {.
Can someone kindly explain to me, why the selection is affected if there is a selection object and we have a caret rather than an extended selection?
I experimented a bit with the code and if I just remove the isCaret() from the condition, I get the expected behavior and could not identify a case, where other operations break (at least in Firefox 96).
I hope someone can point me into the right direction to understand this better.
Thank you in advance!
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hi All,
I am working on a plugin for etherpad, where I try to limit selections to certain parts of the pad content. This includes some lines, where I do not want the caret to be placeable. I added a
contentEditable=false
tag to the corresponding html-elements. With this, it is no longer possible to navigate the caret to these lines with the arrow keys. However, one can still place it there with a mouse click. The caret is invisible but there and can be used to edit the content.I have successfully worked with the
ace_setSelection
method of theeditorInfo
object for extended selections. However, if I only have a caret position, I did not succeed in moving the caret withace_setSelection
.I figured out that this behavior is caused by repeated calls of the
setSelection
method inace2_inner.js
here resulting in a race condition. This in turn in caused by the call ofupdateBrowserSelectionFromRep
here sinceselectionAffected
was set totrue
by theincorporateUserChanges
method here, which is ultimately called by theidleWorkTimer
.(Note: I work with EP version 1.8.9, but there are no major differences in the codebits I am talking about, I checked that beforehand)
After this lengthy introduction (sorry!) I try to understand why this condition is used to the
selectionAffected
to true:if (selection && (domChanges || isCaret())) {
.Can someone kindly explain to me, why the selection is affected if there is a selection object and we have a caret rather than an extended selection?
I experimented a bit with the code and if I just remove the isCaret() from the condition, I get the expected behavior and could not identify a case, where other operations break (at least in Firefox 96).
I hope someone can point me into the right direction to understand this better.
Thank you in advance!
Beta Was this translation helpful? Give feedback.
All reactions