How remove color picker element from DOM tree
At the moment I don't see any other way to remove it if not manually
Read full answer below ↓Question
When dynamically add sectors with property type of color and following remove it(sector), color picker element not remove from DOM tree. How can i detach it, i worry about memory leaks if i will delete it manually.
I mean element
<div class="sp-container sp-hidden sp-light sp-input-disabled sp-alpha-enabled sp-palette-buttons-disabled sp-initial-disabled gjs-one-bg gjs-two-color">
<div class="sp-palette-container">...</div>
<div class="sp-picker-container">...</div>
</div>
After initialize multiple time property with type color i have in dom tree
<div class="sp-container sp-hidden sp-light sp-input-disabled sp-alpha-enabled sp-palette-buttons-disabled sp-initial-disabled gjs-one-bg gjs-two-color"></div>
<div class="sp-container sp-hidden sp-light sp-input-disabled sp-alpha-enabled sp-palette-buttons-disabled sp-initial-disabled gjs-one-bg gjs-two-color"></div>
<div class="sp-container sp-hidden sp-light sp-input-disabled sp-alpha-enabled sp-palette-buttons-disabled sp-initial-disabled gjs-one-bg gjs-two-color"></div>
<div class="sp-container sp-hidden sp-light sp-input-disabled sp-alpha-enabled sp-palette-buttons-disabled sp-initial-disabled gjs-one-bg gjs-two-color"></div>
Or maybe exists another way to use dynamically sectors ?
export const removeSector = (styleManager, sectorId) => {
styleManager
.getSector(sectorId)
.get('properties')
.models
.forEach(property => styleManager.removeProperty(sectorId, property.id));
styleManager.removeSector(sectorId);
};
import {removeSector} from "path/to/function";
export default (styleManager) => {
return {
addSector: () => {
styleManager
.addSector('border',{
name: 'Button Border',
open: true,
properties: [
{
name: 'Weight',
property: 'border-width',
type: 'integer',
units: [],
unit: 'px',
min: 0,
default: 0,
},
{
name: 'Radius',
property: 'border-radius',
type: 'integer',
units: [],
unit: 'px',
min: 0,
default: 0,
},
{
name: 'Color',
property: 'border-color',
type: 'color',
}
]
})
.off('change:open')
},
removeSector: () => {
removeSector(styleManager, 'border');
}
}
}
Answers (1)
At the moment I don't see any other way to remove it if not manually
Related Questions and Answers
Continue research with similar issue discussions.
Issue #3067
FEAT: remove 'display: block' inline style from Style Manager sectors and properties
What are you trying to add to GrapesJS? Improve visibility for Style Manager sectors and properties. Describe your feature request detailed...
Issue #1393
[Question] Add grapesjs color picker to a new trait type?
I'm building a a new trait type, and would like to be able to include the grapesjs color picker inside it - any suggestions on how to do th...
Issue #5990
When you delete a component, duplicate classes between components will be deleted.
GrapesJS version [X] I confirm to use the latest version of GrapesJS What browser are you using? Chrome 126.0.6478.127(Windows) Reproducibl...
Issue #5154
TS2416: Property '_up' in type 'PropertyStack' is not assignable to the same property in base type 'PropertyComposite<PropertyStackProps>'
GrapesJS version [X] I confirm to use the latest version of GrapesJS What browser are you using? ---- Reproducible demo link https://codesa...
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
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.
Tutorial
Big Updates: TinyMCE 8 and Placeholder 2.0 for GrapesJS
In May we shipped major updates to two of our most popular GrapesJS plugins — TinyMCE Inline Text Editor and Placeholder.
Browse Plugin Categories
Jump directly to plugin category pages on the marketplace.