How to make a word wrap in the text of an element (Text, Label, displayField) with ExtJS 4.2.1? - extjs

Must show a text that is greater than the component in which it is inserted. Currently, the text does not wrap automatically.
I've tried using the following components: Text, Label and Display Field

Have you tried a text that contains white space? A single word that is too long won't be wrapped ever, but multiple shorter, space-delimited words maybe will, depending on the component you use.
If you want to show a long text, use a container and put the text into the html configuration, and it will auto-wrap.
The components you named also have their usage, but not for simple long text:
text is from the draw package, and good for specialized formatting.
displayfield is good inside a form whenever you want to display (read-only) some value that is part of the record that you load into the form. displayfield won't wrap at all - try textareafield with readonly configuration for that.
label is good as the label of a form field, but only if used via the labelable mixin, which does most of the work. A label should make its content wrap around if you provide a fixed width or maxWidth, but it does not automatically adhere to the parent object layout.

you can simply add styles to extjs components (you can use any of them):
word-wrap: break-word;
There are some ways to apply custom css styles to ext's elements
style: {
"word-wrap": 'break-word'
}
Also you can do this:
Ext.get('txtElement').setStyle('word-wrap', 'break-word');

Related

Displaying Quill editor content with correct style

I am using the Quill editor (via ngx-quill) to give my user the ability to edit documents. When the documents are displayed I show them like this:
<div [innerHTML]="doc.text"></div>
This works reliably, but the styling of the content of the div tag is quite different from what you see in the Quill editor window. What I want to do is apply the Quill content stylesheet to my div tag, but I haven't been able to find any document to do that. Does anyone here know how to do that?
I know one alternative is to invoke a Quill editor in read-only mode and without a tool-bar. That's my fall-back but I would prefer not to do that.
I was facing the same issue. Some inline styles are displayed, but the styles applied from the Quill.js class are not applied. post-content is class of div containing the content:
let content=document.querySelector('.post-content')
content.innerHTML=content.innerText

react-select: Prevent long text from overlapping

I am using react-select-virtualized component and I modified one of their sandbox examples to include the large text of around 235 characters in the dropdown list.
The modified codesandbox can be accessed from here
And it's showing like this:
How can I fix this? I have a requirement to display large text in the dropdown and wondering if I could improve it somehow.
That's because every option has a long string value and they all wrap and overlap each other. To prevent it, add the below style to change of your option's text wrapping behavior:
.fast-option {
white-space: nowrap;
}

Add an icon inside a Codename One TextModeLayout

My problem is that I didn't find any way to properly add an icon near a TextComponent, inside a TextModeLayout, to mask/unmask a password.
It's a layout problem only, because the code of the ActionListener to mask/unmask the password works correctly at least in the Simulator (it's taken from Codename One - Mask and Unmask Password Field on iOS).
On iPhone skin, the InputComponents labels and text fields are not aligned correctly:
On Android skin, the text is not aligned correctly if it doesn't valide:
About my code, instead of adding the InputComponent (of the password) directly to the TextModeLayout container, I enclosed the InputComponent and the Button inside a BorderLayout, and then I added the BorderLayout container to the TextModeLayout container.
When you do that the text mode layout stops working for that component as it's unaware of the layout in the hierarchy. The hierarchy in the border layout is the responsibility of that layout.
The solution is to extend the TextComponent and add that functionality to Codename One. As a workaround we might be able to rely on the behavior of the current component since the field is already in a border layout component. So something like this might work:
TextField tf = myTextComponent.getField();
Container b = tf.getParent();
b.add(EAST, unmask);

Change span label font size in codenameone

I want to show a multiline text so I use a span label. I am trying to set the font size from the gui but it does not change.
I also trying to set the color dynamicaly using the next code:
this.gui_Span_Info.getAllStyles().setFgColor(HTMLElement.COLOR_RED);
but nothing happens.
What should I do?
SpanLabel is a composite component which means it's built from 2 or more separate components one of which is a Container.
You can determine the UIID of the text using setTextUIID it defaults to the Label UIID.

Finite Icon Colors in Draftail Editor

I am trying to implement a finite number of colors (like square icons) on the Draftail editor itself. What will be the best way to approach this?
It should be similar to how Microsoft Word displays the font color or something along those lines.
Thanks in advance.
I'm not sure if it's the best approach but here is what I came up with:
https://gist.github.com/benoitvogel/46022124d46de03ed2078603fb24ca97
This defines a new inline style which encloses the selected text between <span class="mycustomclass"></span> (change feature_name according to the CSS class you want to use).
Then, you just have to define the corresponding .mycustomstyle CSS class in your frontend as usual:
.mycustomstyle {
color: purple;
}
You can also modify control['style'] to change the way this style will be displayed in the editor.
You will get 1 icon/label per CSS class, so it's not really like in Word as you won't get a proper selector. I haven't tried it myself, but according to Wagtail docs icon can reference SVG, so you might be able to display color squares instead of labels.
Hope it fits your needs.

Resources