Issue #2988Opened August 31, 2020by Abhisheknanda13444630 reactions

Trying to override of link trait

Question

Code SnippetTEXT
Hi @artf I am trying to add new types of trait Below is my code.It's updating the values in code also but on reload link trait will set to default.
Here is my code
`editor.DomComponents.addType('link', {
  model: dModel.extend({
    defaults: Object.assign({}, dModel.prototype.defaults, {
      removable: false,
      traits: [
        // strings are automatically converted to text types
        {
          type: 'select',
          label: 'Pages',
          name: 'href',
          changeprop: 1,
          options: [
            {value: 'index.html', name: 'Home'},
            {value: 'index2.html', name: 'Home2'},
            {value: 'index3.html', name: 'Home3'},
            {value: 'index4.html', name: 'Home4'},
          ]
        },
				{
					type: 'href',
          label: 'Pages',
          name: 'href',
          changeprop: 1,
					category: { id: 'general',
          label: 'General', }
				},
				{
					type: 'select',
          label: 'Target',
          changeprop: 1,
          name: 'target',
          options: [
            {value: '', name: 'same'},
						{value: '_blank', name: 'new'},
          ]
        },
      ],
    }),
  }, {
    isComponent: function(el) {
      if(el.tagName == 'A'){
        return {type: 'link'};
      }
    },
  }),

  view: dView,
`});``
After reload when i click the existing one it shows the default one and when i drag new link element to the canvase in that case it shows me the custom one which i made above.
@artf  @ryandeba  Could you please help me on this.
Thanks

Answers (1)

Abhisheknanda1344463August 31, 20200 reactions

It worked after placing a code in plugin.

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.