murdercode / Nova4-TinymceEditor

A TinyMCE Field for Laravel Nova 4
MIT License
15 stars 12 forks source link

Add extra paragraph when displaying content #18

Open kokev opened 1 year ago

kokev commented 1 year ago

Hi, I ran into some problem when I added some simple text to the TinymceEditor field on Laravel Nova. I added this text:

<p>Row one</p>
<p>&nbsp;</p>
<p>Row two</p>

So i pushed an enter between the 2 row, I checked the database and it saved like this there. When I open up the item for editing, then it will return this for me:

<p>Row one</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>Row two</p>

Seems for some reason added 2 more line break. After I hit the save button again in the database I will get this result:

<p>Row one</p>
<br/>
<p>&nbsp;</p>
<br/>
<p>Row two</p>

I tried inserting to the config file something like these: 'forced_root_block' => false, 'force_p_newlines' => false, 'force_br_newlines' => false,

None of them worked, could you give some explanation about this case?

murdercode commented 1 year ago

I am sorry but I cannot replicate the problem: https://github.com/murdercode/Nova4-TinymceEditor/assets/7630252/4967fd49-9901-4af6-a7fa-2e3357c7dc6d

Are you sure it is not some strange configuration you put on the tiny? Have you tried resetting it using the default one?

kokev commented 1 year ago

Hi @murdercode

Thank you for checking and the video, I'm sending more details about the bug. Updated to version: 1.2.0 I'm using the default configuration: nova-tinymce-editor.conf:

    'init' => [
        'menubar' => false,
        'autoresize_bottom_margin' => 40,
        'branding' => false,
        'image_caption' => true,
        'paste_as_text' => true,
        'autosave_interval' => '20s',
        'autosave_retention' => '30m',
        'browser_spellcheck' => true,
        'contextmenu' => false,
    ],
    'plugins' => [
        'advlist',
        'anchor',
        'autolink',
        'autosave',
        'fullscreen',
        'lists',
        'link',
        'image',
        'media',
        'table',
        'code',
        'wordcount',
        'autoresize',
    ],
    'toolbar' => [
        'undo redo restoredraft | h2 h3 h4 |
                 bold italic underline strikethrough blockquote removeformat |
                 align bullist numlist outdent indent | link anchor table | code fullscreen spoiler',
    ]

In the Nove Resource I added the editor like this:

             TinymceEditor::make('Content', 'content')
                ->nullable(),

Steps to recreate the bug:

  1. Create new item
  2. Add these rows:
    <p>row1<br>row2</p>
    <p>row3</p>
    <p>&nbsp;</p>
    <p>row4</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>row5</p>
  3. Save item
  4. Open the item for edit
  5. Then this will be the result:
    <p>row1<br>row2</p>
    <p>&nbsp;</p>
    <p>row3</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>row4</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>row5</p>

    However in the database I have this:

    <p>row1<br>row2</p>
    <p>row3</p>
    <p>&nbsp;</p>
    <p>row4</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>row5</p>
  6. Save without any editing, in the database I will have this result:
    <p>row1<br>row2</p><br/>
    <p>row3</p><br/>
    <p>&nbsp;</p><br/>
    <p>row4</p><br/>
    <p>&nbsp;</p><br/>
    <p>&nbsp;</p><br/>
    <p>row5</p>

It seems giving <br> elements after paragraphs and still a mystery why do I get those extra empty paragraphs. I have everything on default.

murdercode commented 1 year ago

Needs some investigation, I'll try to replicate in next days. Maybe is a TinyMCE issue related