Issue #3662Opened August 2, 2021by aliibrahim1231 reactions

FEAT: style manager text type

Question

grapesjs style manager has so many nice features, but it does not have a text property type, so why do not add it

Answers (2)

artfAugust 2, 20211 reactions

@aliibrahim123 if you don't specify any type, a simple text type property will be created :)

aliibrahim123August 2, 20210 reactions
Code SnippetTEXT
hallo
i made a simple text proporty type
this is the code

styleManager.addType('text', {
   create({ props, change }) {
     const el = document.createElement('div');
     el.innerHTML = '<input type="text" class="my-input" />';
     const inputEl = el.querySelector('.my-input');
     inputEl.addEventListener('change', event => change({ event })); // change will trigger the emit
     inputEl.addEventListener('input', event => change({ event, complete: false }));
     return el;
   },
   emit({ props, updateStyle }, { event, complete }) {
     const { value } = event.target;
     const valueRes = value;
     
     updateStyle(valueRes, { complete });
   },
   update({ value, el }) {
     el.querySelector('.my-input').value = value;
   },
   destroy() {
    
   }
});

Related Questions and Answers

Continue research with similar issue discussions.

Paid Plugins That Match This Issue

Curated by issue keywords and label relevance to help you ship faster.

View all plugins

Loading paid plugin recommendations...

Browse Plugin Categories

Jump directly to plugin category pages on the marketplace.