Load project data losing head.

by artur_arseniev

HTML

<script src="https://unpkg.com/grapesjs"></script>
<link rel="stylesheet" href="https://unpkg.com/grapesjs/dist/css/grapes.min.css">
<script src="https://unpkg.com/grapesjs-blocks-basic"></script>

<div id="gjs">
</div>
<pre id="log"></pre>

CSS

body, html {
  margin: 0;
  height: 100%;
}

#gjs {
  width: 100;
  height: 300px;
  display: none;
}

Babel + JSX

const editor = grapesjs.init({
	container: document.getElementById('gjs'),
  storageManager: { type: 0 },
  height: '300px',
  plugins: ['gjs-blocks-basic']
});

const htmlTemplate = `
<!doctype html>
<html>
  <head>
    <title>ABCDEF</title>
  </head>
  <body>
    <span>test</span>
  </body>
</html>
`
const log = document.getElementById('log');
function append(message, data) {
	if (typeof data === "undefined") {
  	data = editor.getHtml();
  }
	log.innerText += `> ${message}\n\n< ${data}\n\n`;
}

editor.setComponents(htmlTemplate, {asDocument: true});

append("Loading editor content via setComponents with pure HTML:");

const data = editor.getProjectData();

append("Stringified project data, note it does contain the title ", JSON.stringify(data));

editor.loadProjectData(data);

append("Reloaded the data via loadProjectData")

append("Stringified project data, note it does NOT contain the title ", JSON.stringify(editor.getProjectData()));