grapesjs icon indicating copy to clipboard operation
grapesjs copied to clipboard

[Feature]: Allow to import HTML documents

Open sankaran85 opened this issue 5 years ago • 8 comments

Hi Team,

We are using grapesjs newsletter plugin in our project for importing and preview the template. We are facing some difficulty in retaining the template structure which we import in to grapesjs editor. Please check the below example

IMPORTED HTML

<!DOCTYPE html>
<html>
<body>
<h1>Grapesjs </h1>
<p>My first grapesjs template.</p>
</body>
</html>  

EXPECTED OUTPUT

<!DOCTYPE html>  
<html>
<body>
<h1>Grapesjs </h1>
<p>My first grapesjs template.</p>
</body>
</html>  

ACTUAL OUTPUT , what we get from editor using the command (editor.runCommand('gjs-get-inlined-html'))

<h1 style="box-sizing: border-box;">Grapesjs</h1>
<p style="box-sizing: border-box;">My first grapesjs template..</p>
<style>..</style>

From the output u can see grapesjs has customised the actual template uploaded, by stripping off the html, head and body tags and adds new style tag in the content, Which we don't want to happen.

Is it possible for grapesjs editor to output html without altering the basic structure of the imported template. We looked for some options but couldn't find any.

Please help us in achieving this. Thanks

sankaran85 avatar Jan 23 '19 13:01 sankaran85

Currently, the editor imports only the content inside the body. To make it understand also other document nodes, it'd require a refactor of the current HTML parser

artf avatar Jan 27 '19 15:01 artf

@artf thanks for reply... can we expect this feature to be in next version? Any information on that.

sankaran85 avatar Jan 28 '19 17:01 sankaran85

can we expect this feature to be in next version?

I'm not sure, but I'm gonna try

artf avatar Feb 05 '19 21:02 artf

Hi, @artf. We've faced a similar issue. It would be great to keep imported html structure as is. Should we wait for next releases of grapejs or this feature won't be implemented? Maybe we can implement it on our poject? Unfortunatelly, I haven't found any information in grapesjs doc. Could you provide more information? Thanks

RuslanShohanov avatar Sep 18 '19 08:09 RuslanShohanov

Hi @RuslanShokhanov currently I have no ETA for this feature and not planning to do it soon

artf avatar Sep 24 '19 21:09 artf

+1 i'm stuck on this issue. when when importing an existing template with head,meta's etc. Grapesjs removed the head element but places the meta's, styles and title inside the body.

wimurk avatar Oct 11 '19 09:10 wimurk

@wimurk you have to remove them manually right now

artf avatar Oct 19 '19 13:10 artf

@artf i am. First get the html with ->getHtml then put it in an dom element. Then extract the body en remove the title, meta, etc from the dom. Then extract the html again. Long live JQuery.

But still would be a great feature to do all that with grapesJS :-)

wimurk avatar Oct 21 '19 06:10 wimurk