🎨 间隔复习界面面包屑不包含标记元素

This commit is contained in:
Liang Ding 2022-12-26 19:28:47 +08:00
parent 855b92f4ca
commit 3db25a7259
No known key found for this signature in database
GPG key ID: 136F30F901A2231D
8 changed files with 38 additions and 17 deletions

View file

@ -189,7 +189,7 @@ func buildBacklink(refID string, refTree *parse.Tree, mentionKeywords []string,
dom := renderBlockDOMByNodes(renderNodes, luteEngine)
ret = &Backlink{
DOM: dom,
BlockPaths: buildBlockBreadcrumb(n),
BlockPaths: buildBlockBreadcrumb(n, nil),
Expand: expand,
}
return

View file

@ -468,7 +468,7 @@ func getEmbeddedBlock(embedBlockID string, trees map[string]*parse.Tree, sqlBloc
}
if breadcrumb && !inSuperBlock {
blockPaths = buildBlockBreadcrumb(def)
blockPaths = buildBlockBreadcrumb(def, nil)
}
if 1 > len(blockPaths) {
blockPaths = []*BlockPath{}

View file

@ -63,7 +63,7 @@ func SetBlockReminder(id string, timed string) (err error) {
if ast.NodeDocument != node.Type && node.IsContainerBlock() {
node = treenode.FirstLeafBlock(node)
}
content := treenode.NodeStaticContent(node)
content := treenode.NodeStaticContent(node, nil)
content = gulu.Str.SubStr(content, 128)
err = SetCloudBlockReminder(id, content, timedMills)
if nil != err {

View file

@ -115,7 +115,7 @@ func getNodeRefText(node *ast.Node) string {
if ast.NodeDocument != node.Type && node.IsContainerBlock() {
node = treenode.FirstLeafBlock(node)
}
ret := renderBlockText(node)
ret := renderBlockText(node, nil)
if Conf.Editor.BlockRefDynamicAnchorTextMaxLen < utf8.RuneCountInString(ret) {
ret = gulu.Str.SubStr(ret, Conf.Editor.BlockRefDynamicAnchorTextMaxLen) + "..."
}
@ -193,7 +193,7 @@ type BlockPath struct {
Children []*BlockPath `json:"children"`
}
func BuildBlockBreadcrumb(id string) (ret []*BlockPath, err error) {
func BuildBlockBreadcrumb(id string, excludeTypes []string) (ret []*BlockPath, err error) {
ret = []*BlockPath{}
tree, err := loadTreeByBlockID(id)
if nil == tree {
@ -205,11 +205,11 @@ func BuildBlockBreadcrumb(id string) (ret []*BlockPath, err error) {
return
}
ret = buildBlockBreadcrumb(node)
ret = buildBlockBreadcrumb(node, excludeTypes)
return
}
func buildBlockBreadcrumb(node *ast.Node) (ret []*BlockPath) {
func buildBlockBreadcrumb(node *ast.Node, excludeTypes []string) (ret []*BlockPath) {
ret = []*BlockPath{}
if nil == node {
return
@ -243,9 +243,9 @@ func buildBlockBreadcrumb(node *ast.Node) (ret []*BlockPath) {
} else {
if "" == name {
if ast.NodeListItem == parent.Type {
name = gulu.Str.SubStr(renderBlockText(fc), maxNameLen)
name = gulu.Str.SubStr(renderBlockText(fc, excludeTypes), maxNameLen)
} else {
name = gulu.Str.SubStr(renderBlockText(parent), maxNameLen)
name = gulu.Str.SubStr(renderBlockText(parent, excludeTypes), maxNameLen)
}
}
if ast.NodeHeading == parent.Type {
@ -262,7 +262,7 @@ func buildBlockBreadcrumb(node *ast.Node) (ret []*BlockPath) {
}
if ast.NodeListItem == parent.Type {
if "" == name {
name = gulu.Str.SubStr(renderBlockText(fc), maxNameLen)
name = gulu.Str.SubStr(renderBlockText(fc, excludeTypes), maxNameLen)
}
}
@ -287,7 +287,7 @@ func buildBlockBreadcrumb(node *ast.Node) (ret []*BlockPath) {
}
if ast.NodeHeading == b.Type && headingLevel > b.HeadingLevel {
name = gulu.Str.SubStr(renderBlockText(b), maxNameLen)
name = gulu.Str.SubStr(renderBlockText(b, excludeTypes), maxNameLen)
ret = append([]*BlockPath{{
ID: b.ID,
Name: name,

View file

@ -67,8 +67,8 @@ func renderOutline(node *ast.Node, luteEngine *lute.Lute) (ret string) {
return
}
func renderBlockText(node *ast.Node) (ret string) {
ret = treenode.NodeStaticContent(node)
func renderBlockText(node *ast.Node, excludeTypes []string) (ret string) {
ret = treenode.NodeStaticContent(node, excludeTypes)
ret = strings.TrimSpace(ret)
ret = strings.ReplaceAll(ret, "\n", "")
ret = html.EscapeString(ret)