generated from VLADIMIR/template
update editor funcs
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package story_service
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
@@ -110,7 +111,7 @@ func (s *StoryService) UpdatePlace(node *GraphNode) error {
|
||||
s.story.Places[i] = &Place{
|
||||
Code: s.story.Places[i].Code,
|
||||
Name: node.Name,
|
||||
Text: node.Text,
|
||||
Text: formatText(node.Text),
|
||||
Applications: applications,
|
||||
}
|
||||
break
|
||||
@@ -181,3 +182,27 @@ func (s *StoryService) GetGraph(ctx context.Context) *Graph {
|
||||
Edges: edges,
|
||||
}
|
||||
}
|
||||
|
||||
func formatText(text string) string {
|
||||
scanner := bufio.NewScanner(strings.NewReader(text))
|
||||
|
||||
scanner.Split(bufio.ScanLines)
|
||||
|
||||
lines := []string{}
|
||||
for scanner.Scan() {
|
||||
lines = append(lines, scanner.Text())
|
||||
}
|
||||
|
||||
res := ""
|
||||
for i, line := range lines {
|
||||
l := strings.TrimSpace(line)
|
||||
if i > 0 {
|
||||
res += "\n"
|
||||
if len(l) > 0 {
|
||||
res += " "
|
||||
}
|
||||
}
|
||||
res += l
|
||||
}
|
||||
return res
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user