GrapesJS / grapesjs

Free and Open source Web Builder Framework. Next generation tool for building templates without coding
https://grapesjs.com
BSD 3-Clause "New" or "Revised" License
22.38k stars 4.06k forks source link

Why Text element converted into box ?? #1408

Closed Siddharth-ss42279 closed 6 years ago

Siddharth-ss42279 commented 6 years ago

Hi @artf ,

I am using grapesjs newsletter plugin with ckeditor plugin. I dragged TEXT element in canvas and did some editing with ckeditor. i have connected it to database. when ever i save content in database after reloding the editor i set content value from database field and after that TEXT element get converted into BOX. dont know why TEXT element is changing to BOX and also ckeditor in not loading in that BOX element ?? Please help me out in this.

screen shot 2018-09-06 at 6 47 41 pm

artf commented 6 years ago

What do you store in your database? The HTML and CSS?

Siddharth-ss42279 commented 6 years ago

Hi @artf Actually, i get in-lined html using command editor.Commands.get('gjs-get-inline-html').run(editor) and saving it to database and for rendering content i am using editor.setComponent(content_field)

problem is when i render content from database the TEXT element gets converted into BOX element (only when i edit some text in that text element using ckeditor) and in BOX element ckeditor in not loading.

Either one of the below can solve my problem :

  1. TEXT element should not get converted into BOX
  2. or, BOX element should load ckeditor

step to replicate the issue in grapesjs newsletter demo:

  1. goto: https://grapesjs.com/demo-newsletter-editor.html
  2. drag text element on canvas.
  3. now select some text in that and apply style, bold and color to that text from ckeditor.
  4. hover over the text element you will see it still showing the TEXT on the top screen shot 2018-09-07 at 6 39 19 pm
  5. Now copy the code from view code modal.
  6. again Import that copied code from import button.

observation: now TEXT element has converted to BOX ???? screen shot 2018-09-07 at 6 43 48 pm

and ckeditor in not opening in that box.

any help would be appreciated and Thanks.

artf commented 6 years ago

@Siddharth-ss42279 If you need to EDIT the template created from GrapesJS, you SHOULD NOT USE ITS HTML.... you should import its JSON... so you're doing it WRONG

It's like doing this

el.addEventListener('click', ...);
someOtheEl.innerHTML = el.innerHTML;

and then complaining why your el doesn't have click listener anymore... you're just ripping off all the information created by the editor.

Read here: https://grapesjs.com/docs/modules/Storage.html

lock[bot] commented 5 years ago

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.