Repository navigation
Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
…ocale. Changing the cursors styling in playground to demonstrate
|
Let give background: The #4457 (multi line selection is broken) is happening because the createRectsFromDOMRange function is using This might be related: w3c/csswg-drafts#7155 |
|
Hi @hamza512b, I've tried to address issue with overlapping collab selection, and looks like it can be fixed by adjusting this part: to const singleElementRects = [];
const selectionRectsLength = selectionRects.length;
for (let i = 0; i < selectionRectsLength; i++) {
const selectionRect = selectionRects[i];
if (selectionRect.width + rootPadding < rootRect.width) {
singleElementRects.push(selectionRect);
}
}
let prevRect = null;
const nonOverlappingRects = [];
const singleElementRectsLength = singleElementRects.length;
for (let i = 0; i < singleElementRectsLength; i++) {
const selectionRect = singleElementRects[i];
const isOverlappingRect =
prevRect != null &&
prevRect.top <= selectionRect.top &&
prevRect.top + prevRect.height > selectionRect.top &&
prevRect.left + prevRect.width > selectionRect.left;
prevRect = selectionRect;
if (!isOverlappingRect) {
nonOverlappingRects.push(selectionRect);
}
}
return nonOverlappingRects;Where we should filter out rects that span across multiple elements first, and only after that remove overlapping ones |
|
Related to other parts of the PR: I think providing optional class name for collab cursor makes sense, but I'd have as an addition to inline styles that are defined in core, not as a replacement. Which means we always apply inline css text regardless of theme class (e.g. here we should not apply different cssText if theme class provided). |
This wont work, maybe it could work on chrome but it will not work on firefox because the #5657 (comment)
I think we need to aproach this in different way completly without using Range.getClientRects() Log the getClientRects output to see for yourself in firefox, chrome vs safari. It is behaving differently. |
…k to the old way if it is safari webkit.
|
I have pushed new commit. Before there was issues where it would show the selection incorrectly if anchor or focus node were on end of paragraph node. Related to the optional classnames, I will make these changes in the next commit. |
…lacement. Removed unnecessary collaboration classes.
|
I am thinking about the optional classnames, It might not be very good idea because we have by default inline styles and it is hard to override inlines styles. We would have to write !important on the properities we would like to override. Just letting you know. But maybe your way is better for backward compatibility too. |
|
Yeah overriding inline styles can be a bit hard. Maybe what can be done for that is that each of the property that is currently added in the inline style by default can be added as a CSS variable instead of an actual property & value. And then there can be a default className which implements those in the theme CSS file. What do you all think? |
|
Hi @amanharwara ! Unless you mean the playground CSS file which is not part of the actual library. In that case I have already done that until I changed as requested. |
Ah yes, you are right, my bad. That was basically what I was suggesting, too. But I guess that wouldn't actually be backwards-compatible, since you'd need to have those styles defined outside the core. Maybe if a className is passed, then the inline styles shouldn't get added? That would allow having easy control over the styling of those elements. That being said, I think overall having to use |
|
As I see right now, the first part of the PR is far more complicated than imagined. I tried finding solution, implementing an alternative for It is not pratical having cursors as absolutely positioned. Instead this could have been much simpiler if we had a way to make selections inline within the content editable text. So I have reverted the first part of the part and keep the second part. *Note I update the Pull request details so it is more relavent |
|
Closing this PR due to staleness! If there are new updates, please reopen the PR. |
While I was using Lexical for my side project. I come accross these problems with cursors in collabaration.
They do not work with line mutli line selection.In this pr I intend to fix these issues or at least some of them.