-
Notifications
You must be signed in to change notification settings - Fork 533
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
Caret Position Rendering in Howling Mad #1138
Comments
Please note that the incorrect absolute positioning with scrolling inside iframes occured when rendering the wikidocs telepointer with tinymce (tinymce replaces a textbox with an iframe). |
Could you please repeat the above, but with current and expected result? |
This is as much as I know: when the Aloha cursor/wikidocs telepointer was rendered inside a TinyMCE iframe that had scrollbars, the place the cursor was rendered at was off approximately by the same distance that you could scroll up and down. You can start tackling this issue by trying to reproduce it: create a new demo wikidocs-api/simple-php/tinymce.php in the wikidocs-api repository and implement it like the ckeditor.php demo, except for TinyMCE. Try to get the scrollbars on the editable somehow (I don't know how), and see if you can make the wikidocs telepointer's absolute positioning to be off by the scrolling distance. Once you can reproduce it with wikidocs, you can try to reproduce it without wikidocs, just using the Aloha selection. |
@deliminator, @petrosalema at first i wanted to tackle this
and this
so what i'm asking about is what is expected result here? : <p>
Donec et mollis dolor. Praesent et diam eget libero egesta
mattis sit amet vitae augue. Nam tincidunt congue enim, u
porta lorem lacinia consectetur. Donec ut libero sed arc
vehicula ultricies a non tortor*[]
</p> or here: <p>{}<br></p> |
@evindor I've added screenshots to the issue. |
@evindor The expected result is most of the times what MS Word does. In the comment above resutl should be:
|
@draftkraft @petrosalema @deliminator thanks guys, i was able to reproduce the issue, digging deeper now. |
So what i got so far is that For visually empty nodes such as |
To make this work in wikidocs I just refactored selections.js to set the properties explicitly (without an Maps.extend) |
@deliminator the commit above fixes
|
Fix Maps.extend (discussed in #1138)
…ents and end of paragraphs
…ents and end of paragraphs
…ents and end of paragraphs
…ents and end of paragraphs
…ents and end of paragraphs
…ents and end of paragraphs
…ents and end of paragraphs
…ents and end of paragraphs
…oid elements and end of paragraphs
…oid elements and end of paragraphs
…oid elements and end of paragraphs
The caret is rendered out of place in the following situations too: <p style="padding:20px">{}<br/></p> and <p style="border:20px solid red">{}<br/></p> The caret is in front of the line/out of the box. #boxmodel |
Also discovered this: <ul>
<li>foo</li>
<li><b>{}<i></i></b></li>
</ul>
bar to also be a problem. Caret is rendered awkwardly to the left of "bar" text instead of above it in the list element under "foo". |
node.getBoundingClientRect/CSS hack → #1199 |
Fixes in #1199:
Also i suppose that replacing offset logic with |
@petrosalema actually if you try to manually place the caret in those two cases - it works. Please look at this commit i just made - tests are passing. I think there is no way to place a cursor like this: |
We still have this issue though. |
@evindor When I go into the sandbox, and place the cursor right at the end of the pink "src" in the H1 heading. My selection becomes: <h1>Aloha Editor: <span style="color:#df215a">src{}</span></h1> When I then hold SHIFT and hit ENTER. A new line is created, and my selection becomes: <h1>Aloha Editor: <span style="color:#df215a">src<br><br>{}</span></h1> You will observe that the caret is at an awkward place. |
If you set the caret to the right end of an list item and do SHIFT+ENTER, same problem. |
@evindor I've discovered another edge-case: <div class="aloha-editable">
one
<div draggable="true" class="aloha-block">Aloha Block</div>{}<div>
<p>two</p>
<p>three</p>
</div>
</div> This is the result when you click to the right of the grey block. |
@petrosalema what do you think about this solution? |
Seems like it's passing tests, and everything works, but i'm worried that this may result in other edge cases. |
this should fix all 3 edge cases mentioned above. |
@evindor, your fix seems to solve the last problem I posted, but does not appear to address the earlier two: #1138 (comment) and #1138 (comment). |
@petrosalema hmm. Are you sure? That block has |
With inline-block positioning it works as expected. |
There are still some problems I encounter. Given this: <div class="aloha-editable">
<p>one</p>
<div draggable="true" class="aloha-block" contenteditable="false">Aloha Block</div>{}<ul><li>two</li><li>three</li></ul>
</div> the caret is rendered thus: This is infact the same issue as this previous one. |
Could you please tell me how to reproduce the last issue? I wasn't able to set the cursor where it stands in your html. Then i used the following html: "<div class="aloha-editable">
<p>one
<br>two
<br></p>
</div>" set cursor after "two", pressed shift+enter, got: "<div class="aloha-editable bm" style="min-height: 1em; cursor: text;">
<p>one
<br>two
<br>{}<br></p>
</div>" with cursor standing where it should stand. |
I'm also confused with // ranges.js:729
- var node = Boundaries.nodeAfter(boundary)
- || Boundaries.nodeBefore(boundary);
+ var node = /*Boundaries.nodeAfter(boundary)
+ || */Boundaries.nodeBefore(boundary);
if (node && !Dom.isTextNode(node)) {
rect = boundingRect(node);
if (rect) {
return {
top : rect.top + topOffset,
- left : rect.left + leftOffset,
+ left : rect.left + rect.width + leftOffset,
width : rect.width,
height : rect.height
};
}
} This is an edge case so i think we should find the property we could check and decide when to |
<p>
).Notice how the caret is rendered (tall black bar) when having clicked to the right of the asterix at "tortor*".
<br>, <hr>, <img>, etc.
).... same problem in empty paragraphs.
The text was updated successfully, but these errors were encountered: