1
0
Fork 0
mirror of https://github.com/anyproto/anytype-heart.git synced 2025-06-09 09:35:00 +09:00
This commit is contained in:
Kirill 2020-05-04 14:35:05 +03:00
parent 08479174b3
commit 019b9e0507
No known key found for this signature in database
GPG key ID: 52B176BB96D272ED
2 changed files with 16 additions and 3 deletions

View file

@ -8,6 +8,8 @@ import (
"regexp"
"strings"
"github.com/anytypeio/go-anytype-middleware/util/slice"
"github.com/anytypeio/go-anytype-library/logging"
"github.com/anytypeio/go-anytype-library/pb/model"
"github.com/anytypeio/go-anytype-middleware/anymark"
@ -20,8 +22,9 @@ import (
)
var (
linkRegexp = regexp.MustCompile(`\[([\s\S]*?)\]\((.*?)\)`)
log = logging.Logger("anytype-import")
linkRegexp = regexp.MustCompile(`\[([\s\S]*?)\]\((.*?)\)`)
log = logging.Logger("anytype-import")
articleIcons = []string{"📓", "📕", "📗", "📘", "📙", "📖", "📔", "📒", "📝", "📄", "📑"}
)
type Import interface {
@ -61,7 +64,7 @@ func (imp *importImpl) ImportMarkdown(ctx *state.Context, req pb.RpcBlockImportM
Details: &types.Struct{
Fields: map[string]*types.Value{
"name": pbtypes.String(fileName),
"iconEmoji": pbtypes.String("📁"),
"iconEmoji": pbtypes.String(slice.GetRangomString(articleIcons)),
},
},
})

View file

@ -1,5 +1,10 @@
package slice
import (
"math/rand"
"time"
)
func FindPos(s []string, v string) int {
for i, sv := range s {
if sv == v {
@ -29,3 +34,8 @@ func Remove(s []string, v string) []string {
}
return s[:n]
}
func GetRangomString(s []string) string {
rand.Seed(time.Now().Unix())
return s[rand.Intn(len(s))]
}