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
Building an AI-Assisted Document Engine with Next.js, GrapesJS, and the AI SDK
Transform your static template editor into an intelligent, generative design workspace with Vercel AI SDK, AI Elements and Next.js.
Tutorial
Ship to Production Faster: Whatβs New in GrapesJS Shadcn
Supercharge your page builder! GrapesJS Shadcn adds live drag previews, rich text / commands, dynamic data, and canvas presets to ship to prod faster.
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.
Browse Plugin Categories
Jump directly to plugin category pages on the marketplace.