d3plus / d3plus-text

A smart SVG text box with line wrapping and automatic font size scaling.
MIT License
105 stars 19 forks source link

adds support for configuring the html supported #113

Closed stocksr closed 5 years ago

stocksr commented 5 years ago

Description

Adds a function to TextBox to allow setting the tag lookup object that is used to support html. This will enable users to either override the formatting (my use case) or add additional supported tags.

Types of changes

Checklist

stocksr commented 5 years ago

Please let me know if you want me to make any changes to this.

stocksr commented 5 years ago

Great PR @stocksr! A left a few comments.

Just curious, what was your use-case for needing to disable this?

I don't have a use case for disabling it - just for changing it :-) I am building a preview component that needs to apply the same styling as our mobile apps so I needed this set to: i: 'font-style: italic;', b: 'font-weight: 600;', bi: 'font-style: italic;font-weight: 600;'

I'm wondering if maybe we should combine the html and tagLookup variables into 1, which allows a user to either pass false or a complex object (not just true).

I am happy to tackle this change if you like. I assume you would want the name to be 'html'?

Would this be a breaking change and therefor delay integration? Or should i make this change backwards compatible by special casing true in the setter to put the default value in the variable like this?

 html(_) {
    return arguments.length ? (this._html = typeof _ === "boolean" ? (_ ? defaultHtmlLookup : false)   : _, this) : this._html;
  }