GrapesJS / grapesjs

Free and Open source Web Builder Framework. Next generation tool for building templates without coding
https://grapesjs.com
BSD 3-Clause "New" or "Revised" License
22.37k stars 4.05k forks source link

[Question] How to add toolbar functionality to the layers panel. #2364

Closed mario-digital closed 3 years ago

mario-digital commented 4 years ago

I am trying to add the toolbar to the layers panel and I am not sure how to go about this.

Is there any way to accomplish this?

toolbar toolbaricons

Where I would like to place them:

layersPannelGrapesJS

Thank you for your response guys!

pouyamiralayi commented 4 years ago

Hi there! what do you mean by toolbar? is this what you are looking for?

mario-digital commented 4 years ago

@pouyamiralayi This is what i mean updatedTBimg

MatthewMariner commented 4 years ago

@artf Is there a way to do this? I was looking at the LayerManager and didn't see any copy/delete methods in the layer manager

artf commented 4 years ago

At the moment, there is no easy way to change/customize navigator items content.

What we could add next is a new callback option in configs that would be executed inside ItemView template and would allow any HTML content (similar to custom render in Blocks)

I don't have any priority on this so PRs are welcome

hashimkhatri commented 3 years ago

/! grapesjs - 0.16.45 / Hello guy I have customized the plugin and add delete feature in layer list,

add css: .gjs-layer-vis{ height: auto !important; width: auto !important; left: 25px; top: 0; padding: 10px 0px 10px 0px; position: absolute; cursor: pointer; z-index: 1; } .gjs-layer-delete{ height: auto !important; width: auto !important; left: 10px; top: 0; padding: 10px 0px 10px 0px; position: absolute; cursor: pointer; z-index: 1; }

//GrapesJS Initialization:

var editor = grapesjs.init({ layerManager: { appendTo: '#sitelayercomponent', deleteable:1, //add this line in your layer manager config. } })

//Package Customization Line (12596): events: { 'mousedown [data-toggle-move]': 'startSort', 'touchstart [data-toggle-move]': 'startSort', 'click [data-toggle-visible]': 'toggleVisibility', 'click [data-toggle-delete]': 'toggleDelete', //Add this line 'click [data-toggle-open]': 'toggleOpening', 'click [data-toggle-select]': 'handleSelect', 'mouseover [data-toggle-select]': 'handleHover', 'mouseout [data-toggle-select]': 'handleHoverOut', 'dblclick [data-name]': 'handleEdit', 'keydown [data-name]': 'handleEditKey', 'focusout [data-name]': 'handleEditEnd' }

Line (12616): replace return with

return "\n ".concat(odl ? "<i class=\""+e+"layer-delete fa fa-trash\" data-toggle-delete>": '').concat("\n ").concat(o ? "<i class=\"".concat(e, "layer-vis fa fa-eye ").concat(this.isVisible() ? '' : 'fa-eye-slash', "\" data-toggle-visible>") : '', "\n ").concat("<div class=\"",c, "\">\n <div class=\"").concat(l, "\" style=\"padding-left: ").concat(f, "\" data-toggle-select>\n <div class=\"").concat(e, "layer-title-inn\">\n <i class=\"").concat(u, "\" data-toggle-open>\n ").concat(g ? "<span class=\"".concat(v, "__icon\">").concat(g, "") : '', "\n <span class=\"").concat(d, "\" data-name>").concat(p, "\n

\n
\n \n <div class=\"").concat(this.clsCount, "\" data-count>").concat(a || '', "\n <div class=\"").concat(this.clsMove, "\" data-toggle-move>\n <i class=\"fa fa-arrows\">\n \n <div class=\"").concat(this.clsChildren, "\">")

Line (12640):
Add this function
toggleDelete: function (t) { t && t.stopPropagation(); var e = this.model, n = this.em, r = '__prev-display', i = e.get(r), o = e.getStyle(), a = o.display; if (confirm("Are you sure you want to delete this component.")) { e.remove() && n.trigger('component:toggled') } else { n.trigger('component:toggled') } }

        **If you confuse due to my English please check attachment (I am attaching the grapes.js file: change file extention)**

grapes.min.txt

artf commented 3 years ago

Actually, it should be possible now to use the layerManager.onRender callback option

Duvan1 commented 1 year ago

How could I do it with layerManager.onRender? @artf