Issue #2730Opened April 22, 2020by Lerdouille0 reactions

[Question] Update Traits properties on a plugin

Question

Hi,

is it possible to change easily some properties in the Traits configuration of a plugin ? I"m trying to translate some strings in the grapesjs-echarts plugin, and i kindy stucked after reading your documentation and looking for the functions to do so...

Could please tell me if it's possible to change some options plugins when it's not implemented by default ?

Regards

Answers (3)

artfApril 23, 20200 reactions

You should be able to do it via i18n module

editor.I18n.addMessages({
        en: {
          traitManager: {
            labels: {
				title: 'My Title', // `title` is the name of the trait
			}
          },
        }
      });
LerdouilleApril 24, 20200 reactions

Hi,

thank you for the answer. I agree with you, it changes indeed the default labels on Traits (.

But what about a plugin, or a component not added in the i18n module ? For example, the type "map" include in your initial javascript, how can i update without override your plugin it's properties defined below : type: 'map', src: '', void: 0, mapUrl: 'https://maps.google.com/maps', tagName: 'iframe', mapType: 'q', address: '', zoom: '1', attributes: { frameborder: 0 }, toolbar: Component__WEBPACK_IMPORTED_MODULE_2_["default"].prototype.defaults.toolbar, traits: [{ label: 'Address', name: 'address', placeholder: 'eg. London, UK', changeProp: 1 }, { type: 'select', label: 'Map type', name: 'mapType', changeProp: 1, options: [{ value: 'q', name: 'Roadmap' }, { value: 'w', name: 'Satellite' }] }, { label: 'Zoom', name: 'zoom', type: 'range', min: '1', max: '20', changeProp: 1 }]

Basically, i would like to update some properties for any type of component after the editor initialization. I know there is a function editor.DomComponents.addType to implement a new type or completely replace the component with it's ID. Is there a editor.DomComponents.updateType where i could juste change label name ?

Regards

LerdouilleApril 27, 20200 reactions

Hi again,

any idea to help me to update traits default properties after the plugin initialization ? In my previous sampe, i have a hard coded type 'map' in my grapes.js , i would like to update some traits properties in my html page with some translation and custom values.

Best regards

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.