Skip to content

Returning multiple styles from customInlineFn? #154

@betancourtl

Description

@betancourtl

Hi thank you for creating this awesome library!

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

betancourtl/draft-js-custom-styles#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?

let customInline = customInlineFn ? customInlineFn(element, this.inlineCreators) : null;
if (customInline != null) {
switch (customInline.type) {
case 'STYLE': {
style = style.add(customInline.style);
break;
}
case 'ENTITY': {
entityKey = customInline.entityKey;
break;
}
}
} else {

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions