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

Countdown not working; how to use JSON? #10

Closed
andrewryan1906 opened this issue Jan 30, 2020 · 3 comments
Closed

Countdown not working; how to use JSON? #10

andrewryan1906 opened this issue Jan 30, 2020 · 3 comments

Comments

@andrewryan1906
Copy link

Referencing what I think is the same issue as described in #3... the countdown works fine in the designer but does not render in my page. It looks as though the Javacript is not getting saved.

You responded; don't use HTML/CSS, use the JSON.

What does that mean? Right now, I'm added the rendered HTML from the GrapesJS to my DOM via an Angular app. Is that wrong? If I'm supposed to be using JSON to render, how do I do that? Is there an example somewhere of an actual rendering of the output created by the GrapesJs designer I could look at?

@artf
Copy link
Member

artf commented Feb 1, 2020

You responded; don't use HTML/CSS, use the JSON.
What does that mean?

I mean you have to save correctly your templates https://grapesjs.com/docs/modules/Storage.html#store-and-load-templates
From docs

So be careful, GrapesJS is able to start from any HTML/CSS but use this approach only for importing already existent HTML templates, once the user starts editing, rely always on JSON objects because the HTML doesn't contain information about your components

@artf artf closed this as completed Feb 1, 2020
@SintoDema
Copy link

Hi @artf

I was using some other editors for template creation in my app & many users are working on that, which is in HTML format. Due to many issues, I changed the editor to GrapesJS.

Now, I'm facing an issue that the attribute like data-gjs-type="countdown" etc are changing to data-gjs-type="default". I have gone through several comments that you have made over this issue. One of them is the above-mentioned comment from the doc.

rely always on JSON objects because the HTML doesn't contain information about your components

I have tested this with saving the JSON by using getComponents() like JSON.stringify(editor.getComponents()). Got this from a fiddle while searching for a fix. As you said, by using this I was able to solve the issue with the component. But at this point, I was losing HTML styles which were added earlier in older templates(saved in DB HTML) and also in the grapesJS countdown.

The thing is that I can't fully rely on JSON, I need HTML with styles also. Is there any way to set component over the rendered HTML templated in grapesJS editor.

@robsonsobral
Copy link

Hi, @SintoDema .

Are you also saving the styles, besides the components?

A little excerpt of my code:

          case x.indexOf('components') !== -1:
            if (data[x]) {
              payload.internal_config.components = data[x];
            }
            break;
          case x.indexOf('style') !== -1:
            if (data[x]) {
              payload.internal_config.style = data[x];
            }
            break;
          case x.indexOf('assets') !== -1:
            if (data[x]) {
              payload.internal_config.assets = data[x];
            }

You should save components, styles and assets.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants