Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HTML Parser does not honor custom added component types #43

Closed
sebastianha opened this issue Feb 23, 2017 · 3 comments
Closed

HTML Parser does not honor custom added component types #43

sebastianha opened this issue Feb 23, 2017 · 3 comments
Labels

Comments

@sebastianha
Copy link

I am currently trying to implement by own custom component type and it seems to me that the html parser does not honor custom component types with their isComponent method and therefore they are not recognized as components. Can you reproduce this?

@artf
Copy link
Member

artf commented Feb 23, 2017

Hi @sebastianha thanks for the hint
I think I forgot to mention one important step in docs.

<div id="gjs">
 ...
 <cutom-element></cutom-element>
 ...
</div>

<script>
 var editor = grapesjs.init({
      container : '#gjs',
      fromElement: true,
  });

  editor.DomComponents.addType('cutom-element-type', {...});
</script>

In the example above the editor will not get the new type from the HTML because the content is already parsed and appended, so it'll get it only with new components (eg. from Blocks)

Solution 1: turn off autorender

<script>
 var editor = grapesjs.init({
      autorender: 0,
      container : '#gjs',
      fromElement: true,
  });

  editor.DomComponents.addType('cutom-element-type', {...});
  
  // after all new types
  editor.render();
</script>

Solution 2: put all the stuff inside a plugin (Creating plugins)

Could you try and let me know? If it's not working please post some reproducible example.

@sebastianha
Copy link
Author

That's it, thank you very much!

@lock
Copy link

lock bot commented Sep 18, 2019

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.

@lock lock bot added the outdated label Sep 18, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Sep 18, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants