Issue #1146💬 AnsweredOpened May 30, 2018by sura2k1 reactions

Adding traits to wrapper

快速解答by artf1

But I had to add other wrapper configs such as emovable, copyable, etc. Since wrapper is only a config element I hope this is the default behavior. However if there is a way to just add traits[] without other properties, how it could be done? If you do it via init config, this is the way and you have to specify all ot...

Read full answer below ↓

Question

I found a way to add traits to wrapper via init function,

domComponents: {
	wrapper: {
            emovable: false,
	    copyable: false,
	    draggable: false,
            traits: [...]
        }
}

But I had to add other wrapper configs such as emovable, copyable, etc. Since wrapper is only a config element I hope this is the default behavior. However if there is a way to just add traits[] without other properties, how it could be done?

Also I did following. DomComponents.getWrapper().get('traits').add({'name':'test', 'type': 'text', 'label':'Test'})

When I click on wrapper element, I get following error message. image

Anyway I'm going to go with the config setting, the first one I described. If there is a better way of doing it, please give me some information.

Thanks.

Answers (3)

artfMay 31, 2018

But I had to add other wrapper configs such as emovable, copyable, etc. Since wrapper is only a config element I hope this is the default behavior. However if there is a way to just add traits[] without other properties, how it could be done?

If you do it via init config, this is the way and you have to specify all other properties if you need them.

Also I did following. DomComponents.getWrapper().get('traits').add({'name':'test', 'type': 'text', 'label':'Test'}) When I click on wrapper element, I get following error message.

Just tried the same code on the demo and it worked as expected (try to update to the latest version)

sura2kMay 31, 2018

I was using 0.14.5. It is working nicely with 0.14.15. Thanks for the tip and sorry to bother without testing it against latest version.

betacarNovember 24, 2018

@sura2k How did you extracted the wrapper's trait values after they're set? /cc. @artf

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...

Free option

Check the open-source GrapesJS plugins on GitHub or run a quick search in our free catalog.

Browse free plugins →
Premium option

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.

All tutorials →

Browse Plugin Categories

Jump directly to plugin category pages on the marketplace.