draft-js-utils icon indicating copy to clipboard operation
draft-js-utils copied to clipboard

Returning multiple styles from customInlineFn?

Open betancourtl opened this issue 6 years ago • 2 comments

Hi thank you for creating this awesome library!

I am working on fixing an issue on one of my draft-js repos:

https://github.com/webdeveloperpr/draft-js-custom-styles/issues/2

I basically need to use the customStyleFn to return an array of styles to be applied to an element. As of now you can only return 1 style. Would it be possible to make a change that could return an array of styles from the customStyle fn?

https://github.com/sstur/draft-js-utils/blob/c3d6145a13897f9ff7eed2f3a393756f3043c310/packages/draft-js-import-element/src/stateFromElement.js#L340-L352

I need line something like this:

      var customInline = customInlineFn ? customInlineFn(element, this.inlineCreators) : null;
      if (customInline != null) {
        switch (customInline.type) {
          case 'STYLE':
            {
              // Adds strings or arrays as styles.
              [].concat(customInline.style).forEach(x => style = style.add(x));
              break;
            }

Here are the correct styles:

screenshot 2018-12-21 20 53 28

betancourtl avatar Dec 22 '18 01:12 betancourtl

Its been months, can we please get an update on this

mitchellwarr avatar Aug 27 '19 00:08 mitchellwarr

There already is an open PR for this. https://github.com/sstur/draft-js-utils/pull/155

coding-watermelon avatar Sep 10 '19 15:09 coding-watermelon