SAP / ui5-webcomponents

UI5 Web Components - the enterprise-flavored sugar on top of native APIs! Build SAP Fiori user interfaces with the technology of your choice.
https://sap.github.io/ui5-webcomponents/
Apache License 2.0
1.51k stars 262 forks source link

Support for \n (new line) in the Text web component. #5330

Closed mdasari84 closed 1 year ago

mdasari84 commented 2 years ago

Feature Request Description

Support for \n (new line) in the Text web component.

Proposed Solution

We need something that SAPUI5 Text control already supports. Please check https://snippix.only.sap/#68876 image

Proposed Alternatives

No existing web component that supports \n

Additional Context

Add other context or screenshots related to the feature request here.

Priority

A clear and concise description of the impact/urgency of the required feature.

Stakeholder Info (if applicable)

ilhan007 commented 2 years ago

Hello @mdasari84 do you think you can use the Label web component (as we don't offer a Text web component - a counterpart of sap.m.Text) like that:

<ui5-label>Hello<br>World</ui5-label>
Screenshot 2022-06-07 at 17 06 06
mdasari84 commented 2 years ago

hi @ilhan007 ,

Thanks for the reply! We need to replace \n (new line) with tags. I don't think "Hello
World
" would be a proper solution.

We are looking for something like https://sapui5.hana.ondemand.com/#/entity/sap.m.FormattedText/sample/sap.m.sample.FormattedText (SAPUI5) control which supports certain tags.

Thanks, Madhu

ilhan007 commented 2 years ago

Hello @mdasari84 sorry but I can't entirely understand the need for this component. In OpenUI5 we have the FormattedText because app developers do not have access to the DOM and can't write HTML in XML views, but in your case you can add whatever tags needed directly in your page without restriction.

Maybe you can give more details about the use-case, why you need a component like the Formatted Text Control, where you will use it and for what, so that I can understand the better the need.

Best, ilhan

mdasari84 commented 2 years ago

hi @ilhan007 ,

Ok, got it. We need something that supports \n in the text like https://snippix.only.sap/#68876.

<ui5-label>Hello<br>World</ui5-label> won't work because \n needs to be replaced with <br> before rendering.

Thanks, Madhu

mdasari84 commented 2 years ago

@ilhan007, would you please provide an update. Thanks!!

github-actions[bot] commented 2 years ago

Hello, everyone! The issue has been inactive for 21 days. If there are still questions or comments, please feel free to continue the discussion. Inactive issues will be closed after 7 days!

stoehr commented 1 year ago

@mdasari84, if the requirement is simply to transform new-line characters within already encoded HTML, then something like html.replace(/\n|\r\n?/g, '<br>') would be a way to achieve the requirement.

ilhan007 commented 1 year ago

Related to: https://github.com/SAP/ui5-webcomponents/issues/6788

ilhan007 commented 1 year ago

Hello @mdasari84 is the request still relevant, does @stoehr's suggestion work for you?

github-actions[bot] commented 1 year ago

Hello, everyone! The issue has been inactive for 21 days. If there are still questions or comments, please feel free to continue the discussion. Inactive issues will be closed after 7 days!

github-actions[bot] commented 1 year ago

Hello, everyone! The issue has been inactive for 28 days, so I am closing the issue.