forked from mbk-lab/rui_orig
bug fixing
This commit is contained in:
parent
71993fd8b7
commit
47ca08717d
|
@ -538,7 +538,7 @@ For the properties "width", "height", "min-width", "min-height", "max-width", "m
|
||||||
func GetMaxWidth(view View, subviewID string) SizeUnit
|
func GetMaxWidth(view View, subviewID string) SizeUnit
|
||||||
func GetMaxHeight(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 "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.
|
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)})
|
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:
|
The "border" property defines a border around the View. The frame line is described by three attributes:
|
||||||
line style, thickness and color.
|
line style, thickness and color.
|
||||||
|
|
|
@ -190,6 +190,12 @@ func (imageView *imageViewData) htmlProperties(self View, buffer *strings.Builde
|
||||||
buffer.WriteString(`"`)
|
buffer.WriteString(`"`)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if text := GetImageViewAltText(imageView, ""); text != "" {
|
||||||
|
buffer.WriteString(` alt="`)
|
||||||
|
buffer.WriteString(textToJS(text))
|
||||||
|
buffer.WriteString(`"`)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (imageView *imageViewData) cssStyle(self View, builder cssBuilder) {
|
func (imageView *imageViewData) cssStyle(self View, builder cssBuilder) {
|
||||||
|
|
|
@ -1058,7 +1058,7 @@ func (table *tableViewData) htmlSubviews(self View, buffer *strings.Builder) {
|
||||||
|
|
||||||
switch value := adapter.Cell(row, column).(type) {
|
switch value := adapter.Cell(row, column).(type) {
|
||||||
case string:
|
case string:
|
||||||
buffer.WriteString(value)
|
buffer.WriteString(textToJS(value))
|
||||||
|
|
||||||
case View:
|
case View:
|
||||||
viewHTML(value, buffer)
|
viewHTML(value, buffer)
|
||||||
|
@ -1071,10 +1071,10 @@ func (table *tableViewData) htmlSubviews(self View, buffer *strings.Builder) {
|
||||||
buffer.WriteString(value.String())
|
buffer.WriteString(value.String())
|
||||||
|
|
||||||
case fmt.Stringer:
|
case fmt.Stringer:
|
||||||
buffer.WriteString(value.String())
|
buffer.WriteString(textToJS(value.String()))
|
||||||
|
|
||||||
case rune:
|
case rune:
|
||||||
buffer.WriteRune(value)
|
buffer.WriteString(textToJS(string(value)))
|
||||||
|
|
||||||
case float32:
|
case float32:
|
||||||
buffer.WriteString(fmt.Sprintf("%g", float64(value)))
|
buffer.WriteString(fmt.Sprintf("%g", float64(value)))
|
||||||
|
|
22
textView.go
22
textView.go
|
@ -123,16 +123,30 @@ func (textView *textViewData) textOverflowUpdated() {
|
||||||
updateCSSProperty(textView.htmlID(), TextOverflow, "", session)
|
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) {
|
func (textView *textViewData) htmlSubviews(self View, buffer *strings.Builder) {
|
||||||
if value, ok := stringProperty(textView, Text, textView.Session()); ok {
|
if value, ok := stringProperty(textView, Text, textView.Session()); ok {
|
||||||
if !GetNotTranslate(textView, "") {
|
if !GetNotTranslate(textView, "") {
|
||||||
value, _ = textView.session.GetString(value)
|
value, _ = textView.session.GetString(value)
|
||||||
}
|
}
|
||||||
|
|
||||||
text := strings.ReplaceAll(value, `"`, `\"`)
|
buffer.WriteString(textToJS(value))
|
||||||
text = strings.ReplaceAll(text, "\n", `\n`)
|
|
||||||
text = strings.ReplaceAll(text, "\r", `\r`)
|
|
||||||
buffer.WriteString(strings.ReplaceAll(text, `'`, `\'`))
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue