bustle / ember-mobiledoc-dom-renderer

Render mobiledoc documents in an ember app

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Inject attributes into markup tags.

camerondunford opened this issue · comments

Is it possible to add tags to markup elements?

For example, adding target="_blank" to anchor tags:

_linkTargetBlank(mobiledoc) {
  let markups = mobiledoc.sections[0] || [];

  // new anchor markup sections
  let newMarkups = markups.map(markup => {
    // skip everything but anchors
    if (markup[0] !== 'a') {
      return markup;
    }

    markup.pushObject(['target', '_blank']);
    return markup;
  });

  // replace markup sections
  mobiledoc.sections[0] = newMarkups;
  return mobiledoc;
},

Customizing the rendering of markups is not supported today, though Garth and I have discussed it.

If you want to use target blank, I suggest using JavaScript to capture the clicks on links and open windows that way.

It would be a welcome feature. Thank you for your response & suggested workaround.