grapesjs icon indicating copy to clipboard operation
grapesjs copied to clipboard

conditional traits

Open krunal039 opened this issue 9 years ago • 2 comments

is there way to have conditional traits? if is current component is youtube video then have some traits and if video is non-youtube then shows other traits?

krunal039 avatar Dec 04 '17 12:12 krunal039

Hi @krunal039,

The video component seems to do this already to some extent - see here. If you want to customize the traits further, you could probably do something like this (untested code, but copied and modified from something similar that I've done):

var videoType = editor.DomComponents.getType('video');

editor.DomComponents.addType('video', {
	model: videoType.model.extend({
		getYoutubeTraits() {
			return []; // replace this empty array with your desired traits
		}
	}),
	view: videoType.view
});

ryandeba avatar Dec 04 '17 19:12 ryandeba

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

lock[bot] avatar Sep 18 '19 05:09 lock[bot]