Is it possible to 'toggle' a button added within Panel from function outside of GJS?
Question
Hi Guys, Firstly awesome project, have really enjoyed extending GJS to work with our use case - and am excited for what's in store looking at some of the issues/features in-progress... So, I'm using GJS to with custom buttons added into the Panel via addButton (like so): Now all works as expected when you toggle/untoggle the button - however I want to run the toggleCropMarkers() function which is called when the button is toggled, outside of the editor - (in this case I'm calling the function when the document is loaded) - and I would like to manually set the state of the button to 'toggled'....
Answers (2)
Hi @ned-kelly try this:
const cropBtn = editor.Panels.getButton('options', 'cropmarks');
cropBtn.set('active', 1)
cheers!
@pouyamiralayi, you're amazing - sorry for asking what's seemingly a simple question - couldn't find any previous GitHub issues or comments about this in the documentation!
Related Questions and Answers
Continue research with similar issue discussions.
Issue #2194
CKEditor blocks is not editable[QUESTION]
Hi guys, I added the custom CKEditor blocks and its working fine. but the actual issues is I can't able to delete, move or add the traits i...
Issue #886
[HELP WANTED]: questions about some customization.
Hey Guys, first thank you very much for your work, this project seems really promising. I have a few question for a website i'm building. I...
Issue #2350
[Question] How do I add elements/sectors to views container using a custom button in the Panel
I have added a custom button to the Panel as below: const pm = editor.Panels; pm.addButton('views', { id: 'customButton', className: '', co...
Issue #2814
[QUESTION] Custom panel button that dynamically Enable/Disable user scripts
Hello and thanks for sharing such a good project. I'm trying to customize some things in the editor but I have some questions that I would...
Paid Plugins That Match This Issue
Curated by issue keywords and label relevance to help you ship faster.
Loading paid plugin recommendations...
Check the open-source GrapesJS plugins on GitHub or run a quick search in our free catalog.
Browse free plugins →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.
Tutorial
How to Build a Production GrapesJS Editor: The Complete Walkthrough of Brief, Preset, Plugins, and Services
A complete walkthrough of building a production GrapesJS editor: how to choose a preset, pick plugins, and scope setup services without burning a sprint.
Tutorial
GrapesJS Inline RTE Plugins Update: CKEditor 5 v0.1.4 and Froala Inline Text Editor
CKEditor 5 Inline for GrapesJS v0.1.4 fixes Studio SDK toolbar clipping, iframe injection and link balloon bugs. Compare with Froala Inline — both $69.
Tutorial
Embed GrapesJS in Your SaaS: A Weekend Guide
Embed GrapesJS in your SaaS and ship a white-label page builder over a weekend. Honest tradeoffs, real code, and the plugins that close the UX gap.
Browse Plugin Categories
Jump directly to plugin category pages on the marketplace.