How remove color picker element from DOM tree
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 #2561
How to add extra options to the block element next to delete option ?
WARNING READ and FOLLOW next 5 steps, then REMOVE them before posting the issueFollow CONTRIBUTING Guidelines https://github.com/artf/grape...
Issue #2333
can't able to remove the added traits properties[QUESTION]
Hi, I can able to add the traits properties dynamically by using the following code. but the following code to remove the type name is not...
Paid Plugins That Match This Issue
Curated by issue keywords and label relevance to help you ship faster.
Loading paid plugin recommendations...
Browse Plugin Categories
Jump directly to plugin category pages on the marketplace.