Issue #1887πŸ’¬ AnsweredOpened March 13, 2019by sakshigarg90 reactions

Get JSON of specific gjs-data-type

Quick answerby prashant2018

Could you please include the file name which contains this code snippet ? If I am not wrong it is in panels/index.js

Read full answer below ↓

Question

I want to export JSON of only a specific gjs-data-type="img" I'm trying this but it doesn't give any result:

id: "show-json",
          className: "btn-show-json",
          label: "JSON",
          context: "show-json",
          command(editor) {
            editor.Modal.setTitle("Components JSON")
              .setContent(
                `<textarea style="width:100%; height: 500px;">
            ${JSON.stringify(editor.getType('img')}
          </textarea>`
              )
              .open();
          }

Answers (3)

prashant2018β€’ March 14, 2019

Could you please include the file name which contains this code snippet ? If I am not wrong it is in panels/index.js

sakshigarg9β€’ March 15, 2019

Yes

sakshigarg9β€’ March 15, 2019

thanks @prashant2018 using editor.DomComponents.componentById.image I was able to get the desired JSON

Related Questions and Answers

Continue research with similar issue discussions.

Paid Plugins That Match This Issue

Curated by issue keywords and label relevance to help you ship faster.

View all plugins

Loading paid plugin recommendations...

Free option

Check the open-source GrapesJS plugins on GitHub or run a quick search in our free catalog.

Browse free plugins β†’
Premium option

Premium plugins ship with support, regular updates, and production-ready features β€” save days of integration work.

Browse premium plugins β†’

Related tutorials

In-depth guides on the same topic.

All tutorials β†’

Browse Plugin Categories

Jump directly to plugin category pages on the marketplace.