microsoft / powerbi-visuals-api

Power BI custom visuals API
MIT License
87 stars 46 forks source link

Feat: multiline text #87

Closed luizzappa closed 8 months ago

luizzappa commented 9 months ago

Currently, it is only possible to add text properties to a single line, however, it is a bad experience for the user, especially if needs to break lines.

The property below generates the following field:

// capabilities.json
    "objects": {
      "myProp": {
        "properties": {
          "myProp": {
            "type": { "text": true }
          }
        }
      },

image

It would be cool to be able to use a multiline text like the alt text present in the visuals:

image

JOSBALIN commented 8 months ago

Hello,

I believe this is already supported by the formatting setting TextArea. This class extends the TextInput setting and delivers the layout you show in your second image.

The following is the type declaration

export declare class TextInput extends SimpleSlice<string> { placeholder: string; type?: visuals.FormattingComponent; constructor(object: TextInput); getFormattingComponent?(objectName: string): visuals.TextInput; }

export declare class TextArea extends TextInput { type?: visuals.FormattingComponent; }

The following is an implementation example:

public myText: formattingSettings.TextArea = new formattingSettings.TextArea({ name: 'myText', displayName: 'TextArea', value: '', placeholder: null });

This is what it looks like:

image

The type in the capabilities should be text, as you correctly defined.

luizzappa commented 8 months ago

Works like a charm!