I am attempting to determine whether the cursor is at the beginning of a container (where contenteditable is true), ignoring whitespace or HTML elements that comes first. For instance:
<div class="layout-container" contenteditable="true">
<div class="slice-content">
<p> Hello World</p>
</div>
</div>
<div class="layout-container" contenteditable="true">
<div class="slice-content">
<p>Hello World</p>
</div>
</div>
<div class="layout-container" contenteditable="true">
<div class="slice-content">
<p> <span style="font-weight: normal;">Hello</span> World</p>
</div>
</div>
Regardless of which ones of these is used to create the following:
I would still want it to return 0.
Currently, I am using the following:
window.getSelection().getRangeAt(0).startOffset;