forked from mbk-lab/rui_orig
2
0
Fork 0

bug fixing

This commit is contained in:
Alexei Anoshenko 2022-04-17 11:21:01 +03:00
parent 71993fd8b7
commit 47ca08717d
4 changed files with 30 additions and 10 deletions

View File

@ -538,7 +538,7 @@ For the properties "width", "height", "min-width", "min-height", "max-width", "m
func GetMaxWidth(view View, subviewID string) SizeUnit
func GetMaxHeight(view View, subviewID string) SizeUnit
### "margin" и "padding" properties
### "margin" and "padding" properties
The "margin" property determines the outer margins from this View to its neighbors.
The "padding" property sets the padding from the border of the View to the content.
@ -621,7 +621,7 @@ equivalent to
view.Set(rui.Margin, rui.Bounds{Top: rui.Px(12), Right: rui.Px(8), Bottom: rui.Px(8), Left: rui.Px(8)})
### Свойство "border"
### "border" property
The "border" property defines a border around the View. The frame line is described by three attributes:
line style, thickness and color.
@ -3136,7 +3136,7 @@ The "checkbox" properties allow you to add a checkbox to each item in the list w
you can select several items in the list. The "checkbox" int property (ItemCheckbox constant)
can take the following values
| Value | Constant | Name | Checkbox view |
| Value | Constant | Name | Checkbox view |
|:--------:|------------------|------------|----------------------------------------------------|
| 0 | NoneCheckbox | "none" | There is no checkbox. Default value |
| 1 | SingleCheckbox | "single" | ◉ A checkbox that allows you to mark only one item |

View File

@ -190,6 +190,12 @@ func (imageView *imageViewData) htmlProperties(self View, buffer *strings.Builde
buffer.WriteString(`"`)
}
}
if text := GetImageViewAltText(imageView, ""); text != "" {
buffer.WriteString(` alt="`)
buffer.WriteString(textToJS(text))
buffer.WriteString(`"`)
}
}
func (imageView *imageViewData) cssStyle(self View, builder cssBuilder) {

View File

@ -1058,7 +1058,7 @@ func (table *tableViewData) htmlSubviews(self View, buffer *strings.Builder) {
switch value := adapter.Cell(row, column).(type) {
case string:
buffer.WriteString(value)
buffer.WriteString(textToJS(value))
case View:
viewHTML(value, buffer)
@ -1071,10 +1071,10 @@ func (table *tableViewData) htmlSubviews(self View, buffer *strings.Builder) {
buffer.WriteString(value.String())
case fmt.Stringer:
buffer.WriteString(value.String())
buffer.WriteString(textToJS(value.String()))
case rune:
buffer.WriteRune(value)
buffer.WriteString(textToJS(string(value)))
case float32:
buffer.WriteString(fmt.Sprintf("%g", float64(value)))

View File

@ -123,16 +123,30 @@ func (textView *textViewData) textOverflowUpdated() {
updateCSSProperty(textView.htmlID(), TextOverflow, "", session)
}
func textToJS(text string) string {
for _, ch := range []struct{ old, new string }{
{old: "\\", new: `\\`},
{old: "\"", new: `\"`},
{old: "'", new: `\'`},
{old: "\n", new: `\n`},
{old: "\r", new: `\r`},
{old: "\t", new: `\t`},
{old: "\x00", new: `\x00`},
} {
if strings.Contains(text, ch.old) {
text = strings.ReplaceAll(text, ch.old, ch.new)
}
}
return text
}
func (textView *textViewData) htmlSubviews(self View, buffer *strings.Builder) {
if value, ok := stringProperty(textView, Text, textView.Session()); ok {
if !GetNotTranslate(textView, "") {
value, _ = textView.session.GetString(value)
}
text := strings.ReplaceAll(value, `"`, `\"`)
text = strings.ReplaceAll(text, "\n", `\n`)
text = strings.ReplaceAll(text, "\r", `\r`)
buffer.WriteString(strings.ReplaceAll(text, `'`, `\'`))
buffer.WriteString(textToJS(value))
}
}