Get JSON of specific gjs-data-type
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)
Could you please include the file name which contains this code snippet ? If I am not wrong it is in panels/index.js
Yes
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.
Issue #1904
Get change in property float
I'm trying to listen to the change in the 'float' property whether it was shifted to the 'left' or 'right' or 'none' in Style Manager using...
Issue #665
Custom component and save
Sorry, me again ! I'm trying to save my template with my new component "img-link" : But when I save my template using the gjs-get-inlined-h...
Issue #635
is there any way to reload grapes editor explicitly?
I want to reload grapes editor to get specific changes, is there any method to reload grapes editor?
Issue #714
Open Style Manager when selecting an element
trying to do this gives the error this.sender.get is not a function grapesjs.min.js toggleSm Basically I want to open the style manager whe...
Paid Plugins That Match This Issue
Curated by issue keywords and label relevance to help you ship faster.
Loading paid plugin recommendations...
Browse Plugin Categories
Jump directly to plugin category pages on the marketplace.