summernote / summernote

Super simple WYSIWYG editor
https://summernote.org
MIT License
11.39k stars 2.24k forks source link

image insert outside the editor when code is '<p></p><br> ' please help... #4618

Closed KimDongUk93 closed 2 months ago

KimDongUk93 commented 2 months ago

Checklist

Steps to reproduce

https://summernote.org/

  1. check codeview mode
  2. write <p></p>{enter}<br>

    2 image

    스크린샷 2024-03-05 오후 3 13 30

  3. insert image using insert image button
  4. image is outside the editor

    4 image

    스크린샷 2024-03-05 오후 3 12 50

Expected behavior

image must be in .note-editable

Current behavior

image is not insert .note-editable

Minimal example reproducing the issue

No response

Environment

1der1 commented 2 months ago

Summernote and no other HTML tool ever generate the code <p></p><br>

However, there is generally a possibility that a picture insert happens outside of the editable area. There should be a test, and your given code is a simple, reproducible test case.

DennisSuitters commented 2 months ago

The content isn't added outside the editor, it's added outside of the editable area. Not sure why though, it's definitely something to investigate.

1der1 commented 2 months ago

We added the following check to createFromSelection:

if(!$(sc).closest(".note-editable").length) {return null;}

KimDongUk93 commented 2 months ago

Summernote and no other HTML tool ever generate the code <p></p><br>

However, there is generally a possibility that a picture insert happens outside of the editable area. There should be a test, and your given code is a simple, reproducible test case.

<p></p>
<br>
<img src=“…”>
<p></p>

here is my customer code

i think the reason of this error is p tag is duplicated isnt?

1der1 commented 2 months ago

The p tag should have content.

DennisSuitters commented 2 months ago

@1der1 is correct, the <p/> being empty isn't helping the issue. You can have images outside of the paragraph tag, and ideally, within a <figure/> parent element, it's not paramount, but rather good practise, as it helps screen readers distinguish between different content elements for accessibility. Also, to note, some of the placement, or rather changing of placement, like auto closing tags, is handled via the Browser, more so than the Summernote API, which explains why we often have inconsistencies between behaviours depending on the Browser being used.