6

I have an issue where the cursor jumps to wrong place when user clicks inside of contenteditable div but outside of the actual text. It seems to be a problem only in newer versions of Chrome (and also Opera): coincidentally I tested my example in an older browser (Chrome version 55) and the issue was not present at all. No problem in Edge/IE11/FireFox either.

The issue occurs only when user clicks behind a line of text or on an empty line that sits between the two yellow divs with class pagebreak. The cursor ends up above the first pagebreak div. And whether or not it is directly related, I don't know, but the problem disappears when the div with class flowbox is removed. Unfortunately I can not remove this div with class flowbox from the App.

I have put together an example showing my problem in this fiddle: https://jsfiddle.net/dymcn1ao/

<div class="textframe a">
    <div class="flowbox"></div>
    <article contenteditable="true">
        <p>
            <span>
                <span>Foo bar baz</span>
                <br>
                <span class="pagebreak" contenteditable="false" style="min-height: 80px"></span>
                <span>Foo bar baz</span>
                <br>
                <span>Lorem ipsum dolor sit amet, consectetur adi piscing elit.</span>
                <br>
                <br>
                <span class="pagebreak" contenteditable="false" style="min-height: 80px"></span>
                <br>
                <span>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</span>
            </span>
        </p>
    </article>
</div>

The textfield on the left has the problem, the one on the right works as expected because the .flowbox div has been removed.

Edit 1:

I have created a new example that maybe is easier to understand. The other elements in the .textframe (like the pagebreak and flowbox elements) do actually have specific purposes so they can not be disregarded. Here is the link to the improved demo: https://jsfiddle.net/q4pu37dn/15/

HelgeFox
  • 349
  • 2
  • 13

5 Answers5

1

The issue is with the display, I am also new to this but when I changed your span to div it worked fine, do let me know if it is right or I was not able to understand your question rightly.

Now I am not sure why this was happening, so not able to provide you with an in-depth explanation.

Note - Usage of span and div will not be proper after this, so will have to change to div at other places too.

.title {
  left: 20px;
}
.container {
  float: left;
  width: 400px;
}
.textframe {
  width: 311px;
  height: 650px;
  outline: 2px dotted lightblue;
  overflow: hidden;
  margin: 0 15px 0 0;
}
.textframe.b {
  left: 380px;
}
.textframe article {
  position: relative;
  height: 650px;
}
article p {
  margin: 0;
}
.pagebreak {
  display: block;
  position: relative;
  background: yellow;
}
.flowbox {
  width: 2px;
  height: 650px;
  float: right;
  clear: right;
  outline: 1px solid red;
}
<div class="container">
  <h4>
    With problem:
  </h4>
  <div class="textframe a">
    <div class="flowbox"></div>
    <article contenteditable="true">
      <p>
        <span>
          <span>Foo bar baz</span>
          <br>
          <span class="pagebreak" contenteditable="false" style="min-height: 80px"></span>
          <div>Foo bar baz</div>
          <br>
          <div>Lorem ipsum dolor sit amet, consectetur adi piscing elit.</div>
          <br>
          <br>
          <span class="pagebreak" contenteditable="false" style="min-height: 80px"></span>
          <br>
          <span>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</span>
        </span>
      </p>
    </article>
  </div>
</div>
<div class="container">
  <h4>
    Without problem:
  </h4>
  <div class="textframe b">
    <article contenteditable="true">
      <p>
        <span>
          <span>Foo bar baz</span>
          <br>
          <span class="pagebreak" contenteditable="false" style="min-height: 80px"></span>
          <div>Foo bar baz</div>
          <br>
          <div>Lorem ipsum dolor sit amet, consectetur adi piscing elit.</div>
          <br>
          <br>
          <span class="pagebreak" contenteditable="false" style="min-height: 80px"></span>
          <br>
          <span>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</span>
        </span>
      </p>
    </article>
  </div>
</div>
Abhilash Bhargava
  • 574
  • 1
  • 5
  • 17
  • 1
    Yes it helps to make the elements `display: block` as in making them stretch to the full width of its parent. This does not help in the situation of the emtpy lines (the `br`'s) though. – HelgeFox Sep 17 '18 at 10:05
  • @HelgeFox So, we can have the alternative to a br tag, https://stackoverflow.com/questions/10996237/what-is-the-alternative-to-br-if-i-want-to-control-the-height-between-lines You can even use line-height. Most of the people don't recommend using a br tag. – Abhilash Bhargava Sep 18 '18 at 09:34
  • Hmm... So you say I should use an empty `div` or a `p` with `lineHeight` set to it to use as linebreak elements in stead of my `br`'s? – HelgeFox Sep 18 '18 at 09:44
  • No not an empty div or an empty tag(that'll be extremely wrong), just use line-height for both the div and it can increase the height between the lines. What do you basically want to achieve with a br tag? Is it just that you want to give the user an extra blank line to click and start editing? I am sure I am not getting what your real problem is here now. – Abhilash Bhargava Sep 18 '18 at 11:49
  • This element has contenteditable=true on it so we should allow user to type as many empty lines as they'd like. That is what the `br` elements are for, as example for how the textframe could potentially be. And most users like to have a couple of linebreaks in their text. – HelgeFox Sep 18 '18 at 11:51
  • yea, so typing empty lines can be done by pressing Enter, or Shift+Enter(this creates a new div with br tag and the text gets inserted within quotes). At an initial run, what it seems is that you want to convert a br tag into an editable line, which is not possible, as far as I know. But to give the user the feel of clicking at an empty place, we use line-height to increase the area of response. – Abhilash Bhargava Sep 18 '18 at 12:22
  • The only thing I want is for the cursor to end up where the user clicks, just like in Firefox/IE/Edge/Chrome<65. Besides that, everything in my app works as we want it to: user can type and insert linebreaks and all that, though a lot of it is controlled by javascript to make sure we have the proper elements around said typed text. I am really sorry, it is very difficult to explain the complete app without actually showing it... – HelgeFox Sep 18 '18 at 12:36
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/180265/discussion-between-abhilash-bhargava-and-helgefox). – Abhilash Bhargava Sep 18 '18 at 12:43
1

This problem occurs because you use float: right;.

Do not use CSS property float: right; if you do not need it. You could have a lot of problems with it. In your case you do not need it. Instead of this you have use inline-block elements as <div class="flowbox"> and <article contenteditable="true">.

The minimal example with float:right (WITH problem)

.textframe {
    width: 311px;
    height: 650px;
    outline: 2px dotted lightblue;
    overflow: hidden;
    margin: 0 15px 0 0;
}
.flowbox {
    width: 2px;
    height: 650px;
    float: right;
    clear: right;
    outline: 1px solid red;
}
.pagebreak {
    display: block;
    position: relative;
    background: yellow;
}
<div class="container">
  <h4>
    With problem:
  </h4>
  <div class="textframe a">
    <div class="flowbox"></div>
    <article contenteditable="true">
      <p>
        <span>
          <span>Foo bar baz</span>
          <br>
          <span class="pagebreak" contenteditable="false" style="min-height: 80px"></span>
          <span>Foo bar baz</span><br>
          <span>Lorem ipsum CLICK ABOVE THIS WORDS sit amet, consectetur adi piscing elit.</span>
          <br>
          <br>
          <span class="pagebreak" contenteditable="false" style="min-height: 80px"></span>
          <br>
          <span>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</span>
        </span>
      </p>
    </article>
  </div>
</div>

The solution

The minimal example with display:inline-block (without problem)

Note: now I have placed your <div class="flowbox"></div> after <article> element.

.textframe {
    width: 311px;
    height: 650px;
    outline: 2px dotted lightblue;
    overflow: hidden;
    margin: 0 15px 0 0;
}
.flowbox {
    width: 2px;
    height: 650px;
    outline: 1px solid red;
}
.pagebreak {
    display: block;
    position: relative;
    background: yellow;
}
.flowbox, article{display:inline-block;vertical-align:top;}
article{width: 305px;}
<div class="container">
  <h4>
    With problem:
  </h4>
  <div class="textframe a">
    <article contenteditable="true">
      <p>
        <span>
          <span>Foo bar baz</span>
          <br>
          <span class="pagebreak" contenteditable="false" style="min-height: 80px"></span>
          <span>Foo bar baz</span><br>
          <span>Lorem ipsum CLICK ABOVE THIS WORDS sit amet, consectetur adi piscing elit.</span>
          <br>
          <br>
          <span class="pagebreak" contenteditable="false" style="min-height: 80px"></span>
          <br>
          <span>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</span>
        </span>
      </p>
    </article>
    <div class="flowbox"></div>
  </div>
</div>
Bharata
  • 13,509
  • 6
  • 36
  • 50
  • First of all, I need those `.flowbow`divs to be present to force each line of text to break earlier than the parent box would make it. In my example you can see the box on the left breaks the line after the word "consectetur" but in the box on the right, next word "adi" is allowed to flow up one line. Also, in your solution it seems that the `.textframe` box is no longer confined to a specific width; I need that too :) – HelgeFox Sep 17 '18 at 10:29
  • @HelgeFox, now I have added `.textframe` class and it looks now like in your _jsfiddle.net_ example - **with specific width**. `.flowbow` div is placed after `
    ` element. Please do not forget the rools on StackOferflow: only one question (problem) is allowed in one posting.
    – Bharata Sep 17 '18 at 10:57
  • I did not mean to introduce another problem, just clarified the premise of the original problem. I will take a look at your updated answer. – HelgeFox Sep 17 '18 at 12:11
  • Unfortunately I can not set a specific width to the `article` element as you have in your solution. – HelgeFox Sep 17 '18 at 12:23
  • @HelgeFox, please answer me two questions: 1. For what do you use
    ? 2. Why you can not set a specific width to the article element?
    – Bharata Sep 17 '18 at 12:29
  • 1. Because I need the lines of text to break earlier than it would without, like I explained in my first comment. 2. Because it will vary how many `.flowbox`'es are inside of `.textframe`, representing other `article` elements with possibly other calculated widths. Sorry but this is difficult to explain without showing you my complete app. – HelgeFox Sep 17 '18 at 12:43
  • @HelgeFox, 1. I made **[this screenshot](https://i.stack.imgur.com/8e8Hv.png)** of your example on jsfiddle.net and we can see that you have in both cases the same breaking of words. 2. But your parent class `.textframe {width: 311px;}` has a specific width. Your class "flowbox" has a specific width. Why only `article` with specific width? – Bharata Sep 17 '18 at 13:13
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/180204/discussion-between-helgefox-and-bharata). – HelgeFox Sep 17 '18 at 13:30
  • I had similar issue with contenteditable="false" element, in my case, when I clicked on the left of this element within the border but just before the text of the element, the cursor appeared within the border. Adding display:inline-block to the element, got rid of the cursor. Thanks! – codebusta Aug 04 '19 at 20:18
1

Update 3 (Demo 3)


enter image description here

Changes

I noticed that there are no longer any position: relative used in most current OP code which is good, but I believe this was was forgotten:

<span class='pagebreak spacer'contenteditable="false"></span>

I believe that you originally used contenteditable="false" in order to give your .pagebreaks extra functionality and also prevent them from being deleted, so I added them back in.


Comparison

Demo 3 has my solution side by side to OP code to compare behavior. Demo 3 also features 2 buttons (1 for each content editor) which highlights each <span> of text. The following is a list of the classes from OP code (the content editor on the right) and the list of each classes equivalent from my code (content editor on the left.)

  1. div.textframe................section.editor
  2. p.textOutline................article.content
  3. span.flowbox.spacer......mark.vertRule
  4. span.pagebreak.spacer ..mark.breaker

There are 2 requirements that the OP is concerned about:

  1. When the empty areas surrounding the <span>s are clicked, the cursor will jump to the corner of the content area.

  2. The number of characters per line must be consistent with the OP code's current capacity.

This problem has been around for years but the reason why is nebulus, so if you treat this aberration as just behavior, you can just counter it by instilling different behavior.

Demo2 and Demo3 meet these criteria by simply applying the following style rulesets:

Demo 2

article p {display: table;...

Demo 3

.content {display:table-cell;...

The behavior of tables-cells are rigid and well established, and AFAIK are the only non-replaced element that by default conforms to it's content and conforms to the surrounding table elements. As a bonus an element with display: table-cell (not <td>) isn't required to be nested within a <tr> that's within a <table>.


Demo 3

.content { display: table-cell;...

Fiddle

/* Begin Defaults */

* {
  margin: 0;
  padding: 0;
  border: 0;
  box-sizing: border-box;
}

html,
body {
  background: white;
  font: 400 16px/1.45 Arial;
  height: 100%;
  width: 100%;
}

/* End Defaults */

/* Begin Optional Layout */

#page01 {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-evenly;
  align-items: flex-start;
  background: rgba(45, 99, 198, 0.6);
  margin: 0 auto 20px;
  height: fit-content;
  min-width: 100%
}

/* End Optional Layout */

/* Begin Primary Styles */

.editor {
  width: 350px;
  height: 600px;
  border: 1px solid black;
  background: #fff;
}

.vertRule {
  float: right;
  clear: right;
  width: 30px;
  height: 600px;
}

.content {
  display: table-cell;
  word-break: break-word;
}

mark {
  display: block;
  pointer-events: none;
}

.break {
  min-height: 80px;
}

/* End Primary Styles */

/* Begin Control */

/* https://jsfiddle.net/q4pu37dn/15 */

.textframe {
  width: 350px;
  height: 600px;
  border: 1px solid black;
  background: #fff;
}

.flowbox {
  float: right;
  clear: right;
  width: 30px;
  height: 600px;
}

.spacer {
  background: yellow;
}

.pagebreak {
  display: block;
  min-height: 80px;
}

/* End Control */

/* Begin Demo Test */

.btn {
  display: inline-block;
  font: inherit;
  margin: 5px 10px;
  padding: 2px 5px;
  border: 5px outset grey;
  border-radius: 8px;
  color: #000;
  cursor: pointer;
}

[type='checkbox']:checked+label {
  background: rgba(255, 12, 34, 0.75);
  border: 5px inset grey;
  color: #fff;
}

#outline1:checked+label+#outline2+label+hr+#page01>.editor>.content *,
#outline2:checked+label+hr+#page01>.textframe>#textOutline *:not(.spacer) {
  color: #fff;
  background: tomato;
  outline: 2px solid red;
}

#outline1:checked+label+#outline2+label+hr+#page01>.editor>.content>.break,
#outline2:checked+label+hr+#page01>.textframe>#textOutline>.spacer {
  background: yellow;
  outline: none;
}

/* End Demo Test */
<!-- Begin Demo Test -->

<input id="outline1" type='checkbox' hidden>
<label for='outline1' class='btn'>Outline 1</label>

<input id="outline2" type='checkbox' hidden>
<label for='outline2' class='btn'>Outline 2</label>

<hr>

<!-- End Demo Test -->

<!-- Begin Optional Layout Part 1 -->

<main id='page01'>

  <!-- End Optional Layout Part 1 -->

  <!-- Begin Primary Markup -->

  <section class="editor" contenteditable='true'>
    <mark class="vertRule" contenteditable='false'></mark>
    <article class='content'>
      <span>
      Clicking here is not a problem
    </span>
      <br>
      <br>
      <span>
      Lorem ipsum
    </span>
      <mark class="break" contenteditable='false'></mark>
      <span>
      Clicking here (on empty space, not directly on text) will put the caret above the first .break element.
    </span>
      <br>
      <br>
      <span>
      Lorem ipsum
    </span>
      <mark class="break" contenteditable='false'></mark>
      <br>
      <span>
      Clicking here is not a problem
    </span>
      <br>
      <br>
    </article>
  </section>

  <!-- End Primary Markup -->

  <!-- Begin Control -->

  <div class="textframe" contenteditable>

    <p id='textOutline'>

      <span class="spacer flowbox"></span>
      <span>
      Clicking here is not a problem
    </span>
      <br>
      <br>
      <span>
      Lorem ipsum
    </span>
      <span class="spacer pagebreak"></span>
      <span>
      Clicking here (on empty space, not directly on text) will put the caret above the first .pagebreak element.
    </span>
      <br>
      <br>
      <span>
      Lorem ipsum
    </span>
      <span class="spacer pagebreak"></span>
      <br>
      <span>
      Clicking here is not a problem
    </span>
      <br>
      <br>
    </p>
  </div>

  <!-- End Control -->

  <!-- Begin Optional Layout Part 2 -->

</main>

<!-- End Optional Layout Part 2 -->


Update 2 (Demo 2)


OP regarding Demo 1:

"you solved it for my contrived example, yes. Unfortunately it is not possible to set those values on the elements in the actual app, the flow gets totally out of wack there."

See Demo 2, it works better than Demo 1. Since it uses only positioned elements, there are no conflicts in flow. In order to adapt Demo 2 to your app, all you need to do is add position:relative to the parent elements. The relevant style is as follows:

article p {display: table;...

It was necessary to assign position:relative to everything nested within .textframe, otherwise the static elements would not interact with the positioned elements. There are rules that tables and table components adhere to that not only apply to its' content but how they interact with their neighboring elements as well.


Demo 2

article p {display: table...

.container {
  width: 400px;
  float: left
}

.textframe {
  width: 350px;
  height: 650px;
  outline: 2px dotted lightblue;
  overflow: hidden;
  margin: 0 15px 0 0;
  /* Needed for long words */
  word-break: break-word;
}

.textframe article {
  position: relative;
  height: 650px; 
}

article p {
  display: table;
  margin: 0;
  position:relative;
}

.flowbox {
  width: 2px;
  height: 650px;
  float: right;
  clear: right;
  outline: 1px solid red;
}

.pagebreak {
  display: block;
  pointer-events:none;
  position:relative;
}
<div class="container">
      <h4>
       article p {display: table; position: relative;}<br>
       all children of .textframe have: position: relative;  
      </h4>
      <div class="textframe a">
        <div class="flowbox"></div>
        <article contenteditable="true">
           <p>
            <span>
              <span>Foo bar baz</span>
            <br>
            <mark class="pagebreak" contenteditable="false" style="min-height: 80px"></mark>
            <span>Foo bar baz</span>
            <br>
            <span>Lorem ipsum dolor sit amet, consectetur adi piscing elit.</span>
            <br>
            <br>
            <mark class="pagebreak" contenteditable="false" style="min-height: 80px"></mark>
            <br>
            <span>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</span>
            </span>
          </p>
          <hr>
        </article>
      </div>
    </div>

Refences

MDN - Float

MDN - Position

CSS Tricks - Absolute Positioning Inside Relative Positioning

CSS Tricks - All About Floats

display: table/table-cell

word-break:break-word


zer00ne
  • 41,936
  • 6
  • 41
  • 68
  • By setting the `article` position to absolute you have effectively removed the function of the right-aligned `.flowbox` elements and then the word "adi" on the second line jumps up like in the example box to the right in my example. – HelgeFox Sep 17 '18 at 12:30
  • It doesn't jump up using the lateset Chrome. Added Demo 2 which also doesn't jump up. – zer00ne Sep 17 '18 at 13:00
  • @HelgeFox Here's a [screen recording](https://storage04.dropshots.com/photos8000/photos/1381926/20180917/091614.mp4) of Demo 1 desired behavior – zer00ne Sep 17 '18 at 13:21
  • @HelgeFox Also `.flowbox` position is unaffected...are you sure you are reviewing my answer and not getting it confused with someone elses? – zer00ne Sep 17 '18 at 13:29
  • Listen, I can see that different browsers and different default fonts make my example difficult to understand. Try to add text to one of the lines and make sure that the `.flowbox` does what it is supposed to: break text to new lines. In your most recent example I get this situation: https://i.imgur.com/qI1sGJE.jpg – HelgeFox Sep 17 '18 at 13:41
  • @HelgeFox that's not what you said originally, see update `p span {position:relative}` was added. Moreever, my font-size, font-weight, font-family, etc. is at browser defaults as should yours. I can only work with what you have provided in your question. – zer00ne Sep 17 '18 at 14:05
  • Excuse me, what did I not say originally? My point is only this, the `.flowbox` was there for a reason. – HelgeFox Sep 17 '18 at 14:12
  • @HelgeFox Added `display:table` to `

    ` and `display:table-cell` to `` review Demo 1, I think that this should work.

    – zer00ne Sep 17 '18 at 14:28
  • Also added `word-break:break-word;` to `textframe` for long words. – zer00ne Sep 17 '18 at 14:38
  • you solved it for my contrived example, yes. Unfortunately it is not possible to set those values on the elements in the actual app, the flow gets totally out of wack there. – HelgeFox Sep 17 '18 at 15:06
  • This is the most promising answer so far, though not yet solved the issue. Unfortunately I have to leave the office now but will continue working on this tomorrow. Thank you for the effort @zer00ne :) – HelgeFox Sep 17 '18 at 15:40
  • @HelgeFox no problem, I like challenges. When you get the chance review **Demo 2**. I believe it can be adapted to your app very easily, if not you can always post an extra Fiddle with the remainder of your app. – zer00ne Sep 17 '18 at 15:56
  • I'm sorry but your **Demo 2** does not account for the function of the `.flowbox` element. I get similar result as in my example box to the right, where text is allowed to flow under/past the `.flowbox` element. – HelgeFox Sep 18 '18 at 09:50
  • @HelgeFox I've tried my damnedest trying to break **Demo 2**, but I couldn't. Please review this [screen recording](https://screencast-o-matic.com/embed?sc=cFQFF2qN0u&v=5&ff=1) – zer00ne Sep 18 '18 at 18:29
  • I have started a chat for us, do you get the link? https://chat.stackoverflow.com/rooms/180217/discussion-between-zer00ne-and-helgefox – HelgeFox Sep 19 '18 at 08:12
  • here is a demo that maybe illustrates the necessity of the `.flowbox` elements and what they are supposed to do – HelgeFox Sep 21 '18 at 15:33
  • Thank you so much for all the effort @zer00ne! – HelgeFox Oct 08 '18 at 11:35
  • You are very welcome, and thank you for the challenge @HelgeFox – zer00ne Oct 08 '18 at 12:19
0

I am using newest version of Chrome on Linux/Ubuntu and this seems to have solved the issue. I have just removed contenteditable from article and put it on spans that you wanted to edit.

<article>
      <p>
        <span>
          <span contenteditable="true">Foo bar baz</span>
          <br>
          <span class="pagebreak" contenteditable="false" style="min-height: 80px"></span>
          <span contenteditable="true">Foo bar baz</span>
          <br>
          <span contenteditable="true">Lorem ipsum dolor sit amet, consectetur adi piscing elit.</span>
          <br>
          <br>
          <span class="pagebreak" contenteditable="false" style="min-height: 80px"></span>
          <br>
          <span contenteditable="true">Lorem ipsum dolor sit amet, consectetur adipiscing elit.</span>
        </span>
      </p>
    </article>
Lazar Nikolic
  • 4,261
  • 1
  • 22
  • 46
  • 1
    Unfortunately, updating Chrome (v68 to v69) on windows did not help. Also, the point is to have the whole `.textframe` editable **with** the possibility to navigate through the linebreaks and pagebreaks using arrow keys. – HelgeFox Sep 17 '18 at 10:52
0

I think issue is with span if you have an empty span in it. I have gone through this issue while working with contenteditable so cursor shows up there but you are not able to make it move.

I will suggest you to Remove span from your p to each paragraph so that if span is empty try to remove it on backspace/delete.

Or refer CKEDITOR as it have solved that problem

article p, article div
{
    line-height: 1.25;
    margin-top: 12px;
    margin-bottom: 12px; /*  margin-bottom: 10px; removed for proper pagebreak 31-1-2017*/
    font-family: Helvetica;
}

.title {
  left: 20px;
}
.container {
  float: left;
  width: 400px;
}
.textframe {
  width: 311px;
  height: 650px;
  outline: 2px dotted lightblue;
  overflow: hidden;
  margin: 0 15px 0 0;
}
.textframe.b {
  left: 380px;
}
.textframe article {
  position: relative;
  height: 650px;
}
article p {
  margin: 0;
}
.pagebreak {
  display: block;
  position: relative;
  background: yellow;
}
.flowbox {
  width: 2px;
  height: 650px;
  float: right;
  clear: right;
  outline: 1px solid red;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="container">
  <h4>
    With problem:
  </h4>
  <div class="textframe a">
    <div class="flowbox"></div>
    <article contenteditable="true">
      <p>
        <span>
          <span>Foo bar baz</span>
          <br>
          <span class="pagebreak" contenteditable="false" style="min-height: 80px"></span>
          <span>Foo bar baz</span>
          <br>
          <span>Lorem ipsum dolor sit amet, consectetur adi piscing elit.</span>
          <br>
          <br>
          <span class="pagebreak" contenteditable="false" style="min-height: 80px"></span>
          <br>
          <span>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</span>
        </span>
      </p>
    </article>
  </div>
</div>
<div class="container">
  <h4>
    Without problem:
  </h4>
  <div class="textframe b">
    <article contenteditable="true">
      <p>
        <span>
          <span>Foo bar baz</span>
          <br>
          <span class="pagebreak" contenteditable="false" style="min-height: 80px"></span>
          <span>Foo bar baz</span>
          <br>
          <span>Lorem ipsum dolor sit amet, consectetur adi piscing elit.</span>
          <br>
          <br>
          <span class="pagebreak" contenteditable="false" style="min-height: 80px"></span>
          <br>
          <span>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</span>
        </span>
      </p>
    </article>
  </div>
</div>
Nikhil Ghuse
  • 1,258
  • 14
  • 31
  • Hmm... I don't understand your answer as there are no empty spans in my example, except the ones with a class `pagebreak` which are there for a purpose. Namely to function as page breaks. If you have better solution for making arbitrary space inside the editable textframe then please do elaborate :) – HelgeFox Sep 17 '18 at 12:15
  • I am talking about the same pagebreak class `span` as it does the same with me if contenteditable finds an empty span in a `p` tag it behave the same as you are getting – Nikhil Ghuse Sep 17 '18 at 12:43
  • As while deleting sometime it strucks in between that span or it randomly goes any where – Nikhil Ghuse Sep 17 '18 at 12:45
  • And CKEditor too have this issue when you insert and Ordered or unordered list it behaves the same – Nikhil Ghuse Sep 17 '18 at 12:46
  • Interesting to hear CKEditor have the same issue. But regarding the `.pagebreak` spans contributing to the issue, yes I know that. Thing is I still need some way of pushing content down so, as I see it, I still need those... – HelgeFox Sep 17 '18 at 12:52
  • I'm sorry but I can't see that your example is working. The cursor still jumps up above the `.pagebreak` element... – HelgeFox Sep 17 '18 at 15:17