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

How to add select filed in header bar on editor #55

Closed
desilvaNSP opened this issue Mar 15, 2017 · 4 comments
Closed

How to add select filed in header bar on editor #55

desilvaNSP opened this issue Mar 15, 2017 · 4 comments
Labels

Comments

@desilvaNSP
Copy link

desilvaNSP commented Mar 15, 2017

How can I add select filed on header bar
screenshot from 2017-03-15 13 33 30

please give me a solution for my problem

I want to add custom UI element on your header bar in editor,How can i do it?

@imsaeedafzal
Copy link

imsaeedafzal commented Mar 15, 2017

Please go thru the demo.js file in detail. Scroll to the bottom and modify the following code to add new desired option in top header bar.

,{
id: 'clean-all',
className: 'fa fa-trash icon-blank',
command: function(editor, sender) {
if(sender) sender.set('active',false);
if(confirm('Are you sure to clean the canvas?')){
var comps = editor.DomComponents.clear();
localStorage.setItem('gjs-css', '');
localStorage.setItem('gjs-html', '');
}
},
attributes: { title: 'Empty canvas' }
}

@desilvaNSP
Copy link
Author

I have overide grapejs.init in my code.not in the demo.js


`    var editor = grapesjs.init({
        container: '#gjs',
        fromElement: true,
        plugins: ['gjs-plugin-export'],
        pluginsOpts: {
            'gjs-plugin-export': {
                btnLabel: 'EXPORT',
                preHtml: '<!doctype><html><head><link rel="stylesheet" href="./css/style.css"></head><body>'
            }
        }
    });
`

How I add new element into this.

@artf
Copy link
Member

artf commented Mar 15, 2017

@desilvaNSP if the built-in button interface (illustrated also by @sirsmac) doesn't fit your needs just use your UI components.
Quick example

var selectEl = $('<select> <option>Desktop</option> <option>Tablet</option> </select>');
selectEl.appendTo('#gjs-pn-options .gjs-pn-buttons');
selectEl.on('change', function() {
  // Use GrapesJS's API if you need to
  editor.setDevice(this.value);
});

@artf artf closed this as completed Mar 15, 2017
@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

3 participants