inkandswitch / livebook

IPython notebook-compatible live coding experiment
202 stars 11 forks source link

Section header applied to following paragraph after delete #51

Open adamwiggins opened 8 years ago

adamwiggins commented 8 years ago

Steps to reproduce:

  1. welcome notebook
  2. select "prose editor" through "csv data and charts"
screen shot 2016-01-25 at 17 16 29
  1. press backspace
  2. now the next paragraph ("Load the...") is a section header -- expect instead it should keep its style (regular paragraph/body text) intact
screen shot 2016-01-25 at 17 16 37
brettimus commented 8 years ago

See replication steps for #26 (i.e., contenteditable is still weird)

brettimus commented 8 years ago

Original p tag is not preserved, making this fairly hard to solve with a validation rule.

Alternative is to short circuit any delete operations and trim the selection by -1 if

  1. The selection has length > 0, &&
  2. The selection has dangling whitespace

The foregoing idea is possibly worth a shot but reeks of unintended consequences.

brettimus commented 8 years ago

So, I have to try to replicate this issue to encounter it. I.e., I have to select the text and then press shift+right arrow.

Is anyone getting this error with standard delete operations?

cc @adamwiggins @luciasantamaria

luciasantamaria commented 8 years ago

@brettimus To replicate: Put cursor before 'Live coding'. Hold Shift, press down arrow 3 times to select until end of 'Prose Editor'. Press delete. Then 'Navigate... ' gets Header style.

brettimus commented 8 years ago

:+1: thanks!

brettimus commented 8 years ago

As of now it’s feeling like we’re bumping into contenteditable weirdness.

I’m not sure mediumeditor gives us enough control over editor contents to fix this. The medium selection API is returning unexpected results when I try debugging in the middle of replicating. :confounded:

brettimus commented 8 years ago

Underlying conditions that cause this bug seem to be that

The focusNode is the node in which the selection ends.

MDN reference on selection api