Issue #1998Opened May 3, 2019by VM81980 reactions

Extending Link component not working properly.

Question

Code SnippetTEXT
hello @hello @artf 
I am trying to extend the link component and add new traits like href and target the code is given below.

``function loadWithOption(opts) {
      editor.DomComponents.addType('link', {
        model: dModel.extend({
          defaults: Object.assign({}, dModel.prototype.defaults, {
            traits: [
            // strings are automatically converted to text types
            // title,
            {
              type: 'text',
              label: 'text',
              name: 'text',
              },
            {
              type: 'select',
              label: 'Target',
              name: 'target',
              options: [
              { value: '', name: 'This window' },
              { value: '_blank', name: 'New window' },
              ]
            }, 
            {
              type: 'select',
              label: 'Href',
              name: 'href',
              options: [
                {value: 'index.html', name: 'Home'},
                {value: 'index2.html', name: 'Home2'},
                {value: 'index3.html', name: 'Home3'},
                {value: 'index4.html', name: 'Home4'},
              ]
            },
            ],
          }),
        }, {
          isComponent: function (el) {
            if (el.tagName == 'A' || el.tagName == 'LINK') {
              return { type: 'link' };
            }
          },
        }),
        view: dView,
      });  `
`

It is working only after importing the code otherwise nothing changes...
please help

Answers (1)

lock[bot]May 6, 20200 reactions

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.

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.