samclarke / SCEditor

A lightweight HTML and BBCode WYSIWYG editor
http://www.sceditor.com/
Other
661 stars 187 forks source link

Android, Chrome, line break does not move cursor to new line #824

Open alekseyderyugin opened 3 years ago

alekseyderyugin commented 3 years ago

Android 9 chrome 88.0.4324.93 with gboard Android 10 chrome 87.0.4280.101 with gboard

If iframe contains

<p>
  <font color="#1e92f7">some text</font>
</p>

or

<p>
   <b>some text</b>
</p>

line break (enter) not move cursor to new line.

Demo from https://issuetracker.google.com/issues/177757645: https://drive.google.com/file/d/15sVf_TrDo1WRAU1fFrR8YnuTVUbSAjFU/view

If <p> replace to <div> - cursor move, its ok.

This is not an editor problem, this is a chrome problem. But it needs to be solved somehow.

Why this is a chrome problem...

Run next code on android device with gboard. Place cursor at end of line and touch 'enter'. ```html

```

I found next links: https://github.com/quilljs/quill/issues/3240 https://issuetracker.google.com/issues/177757645 (issue from quill developer)

I can replace <p> with <div> but i not shure that it not break something. Also, I'm not sure that I can guarantee that <p> wont never be inserted in iframe content.

This is an annoying problem. How can I solve it?

samclarke commented 3 years ago

Thanks for reporting, that is a very annoying bug.

I can replace <p> with <div> but i not shure that it not break something. Also, I'm not sure that I can guarantee that <p> wont never be inserted in iframe content.

That shouldn't break anything. You would need to modify the editor, to replace all <p> tags as it auto inserts some <p> tags if there aren't any in the body and also to add a newline after a block element.

alekseyderyugin commented 3 years ago

Thanks for your reply!

I created the list of places, where <p> should be replace with<div> in jquery.sceditor.bbcode.js, version 3.0.0:

  1. var _templates = { .. html: 1748
  2. base.insertHTML 3160
  3. base.selectedHtml 3359
  4. function wrapInlines 3989
  5. autofocus = function () { 4916
  6. base.setWysiwygEditorValue 5985
  7. appendNewLine = function () { 6447
  8. base.clearBlockFormatting 7267

    This list is correct?

samclarke commented 3 years ago

That looks correct to me.