mirror of
https://github.com/anyproto/anytype-heart.git
synced 2025-06-09 09:35:00 +09:00
This commit is contained in:
parent
08479174b3
commit
019b9e0507
2 changed files with 16 additions and 3 deletions
|
@ -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)),
|
||||
},
|
||||
},
|
||||
})
|
||||
|
|
|
@ -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))]
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue