diff --git a/core/block/editor/import/import.go b/core/block/editor/import/import.go index de38139dd..2c1325d0b 100644 --- a/core/block/editor/import/import.go +++ b/core/block/editor/import/import.go @@ -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)), }, }, }) diff --git a/util/slice/slice.go b/util/slice/slice.go index 40003ac9a..3bb853684 100644 --- a/util/slice/slice.go +++ b/util/slice/slice.go @@ -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))] +}