Text Editor blank space before text is trimmed

I have a diagram with texteditor, when I enter a text and in newline blank space first and followed by text. Now in diagram the blank spaces are trimmed and only the text is showed. Is there any property to keep the text as it is no need to trim any spaces.

Hi Walter,

I tried the one you suggested, but I am getting a ‘-’ when there is a new line with an empty space. As like that in the below image.

What string is being displayed, and how is the TextBlock declared?

This is what I am doing in my end.

diagram.addDiagramListener("TextEdited", function (e) {
        e.subject.text = e.subject.text.split(' ').join(' \u00AD');
    scope.textEdited(e);
});

After this I am seeing an ‘-’ in my empty line.
Original String I entered is “a a”.

You still haven’t shown how the TextBlock is declared.

I’m assuming your listener code is actually:

  "TextEdited": function(e) { e.subject.text = e.subject.text.split(' ').join('\n \u00AD'); }

The \u00AD character is a “soft-hyphen”, so it should not be too surprising if you see a hyphen when a line is broken up into multiple lines. If you don’t want a line to end in a hyphen, don’t use that \u00AD soft-hyphen character.

If I am not using \u00AD then empty space at the start of the line is getting trimmed.

If you don’t tell me what you are asking for, it’s hard to help you.

Only use \u00AD before indentation spaces that precede the regular text to be indented.

Maybe you want to do this instead?

    e.subject.text = e.subject.text.replace('\n ', '\n\u00AD ');

I don’t really know what you want to happen when the user has entered some text.

Hi Walter,

Let me clear it,

I have a diagram with texteditor, texteditor is multi line when user enter the second line and press space at the start of the line the space is getting trimmed when we finish editing. I don’t want the user entered text to be trimmed. You told me to replace space with \u00AD but it fails when there is an empty line with space. When there is a empty line with space ‘-’ is showed in the editor and finished editting. How to get rid of this?

Ideally I don’t any data trimmed is that possible?

Only insert \u00AD when there are nonspace characters following the initial space characters?

Yes, it is by default it is trimmed all blank space, I don’t know why, I need blank space before and end also.