diff --git a/app/src/assets/scss/protyle/_wysiwyg.scss b/app/src/assets/scss/protyle/_wysiwyg.scss index 320b008a9..b556971b4 100644 --- a/app/src/assets/scss/protyle/_wysiwyg.scss +++ b/app/src/assets/scss/protyle/_wysiwyg.scss @@ -86,16 +86,16 @@ & > div { padding-left: 100%; position: relative; - height: 26px; + min-height: 1.625em; &::after { position: absolute; content: " "; - height: 1px; + height: calc(1em / 16); background-color: var(--b3-theme-background-light); width: calc(100% - 1px); left: 0; - top: 13px; + top: calc(1.625em / 2); } } } diff --git a/app/src/plugin/index.ts b/app/src/plugin/index.ts index 0c5fff472..7a4aa8712 100644 --- a/app/src/plugin/index.ts +++ b/app/src/plugin/index.ts @@ -233,7 +233,7 @@ export class Plugin { if (!this.setting) { return; } - this.setting.open(this.name); + this.setting.open(this.displayName || this.name); } public loadData(storageName: string) { diff --git a/kernel/model/transaction.go b/kernel/model/transaction.go index 18ab0d7da..7851dd191 100644 --- a/kernel/model/transaction.go +++ b/kernel/model/transaction.go @@ -961,10 +961,8 @@ func (tx *Transaction) syncDelete2Block(node *ast.Node, nodeTree *parse.Tree) (c pushBroadcastAttrTransactions(oldAttrs, toChangNode) } - nodeTreeID := nodeTree.ID for _, tree := range trees { - self := nodeTreeID == tree.ID - if !self { + if nodeTree.ID != tree.ID { indexWriteTreeUpsertQueue(tree) } } @@ -1461,6 +1459,11 @@ func (tx *Transaction) doUpdate(operation *Operation) (ret *TxErr) { updatedNode.Tokens = []byte(strings.Join(newLines, "\n")) } + removedNodes := getRemovedNodes(oldNode, updatedNode) + for _, n := range removedNodes { + syncDelete2AvBlock(n, tree, tx) + } + // 替换为新节点 oldNode.InsertAfter(updatedNode) oldNode.Unlink() @@ -1520,6 +1523,30 @@ func getRefDefIDs(node *ast.Node) (refDefIDs []string) { return } +func getRemovedNodes(oldNode, newNode *ast.Node) (ret []*ast.Node) { + oldNodes := map[string]*ast.Node{} + ast.Walk(oldNode, func(n *ast.Node, entering bool) ast.WalkStatus { + if !entering || !n.IsBlock() { + return ast.WalkContinue + } + oldNodes[n.ID] = n + return ast.WalkContinue + }) + ast.Walk(newNode, func(n *ast.Node, entering bool) ast.WalkStatus { + if !entering || !n.IsBlock() { + return ast.WalkContinue + } + if _, ok := oldNodes[n.ID]; ok { + delete(oldNodes, n.ID) + } + return ast.WalkContinue + }) + for _, n := range oldNodes { + ret = append(ret, n) + } + return +} + func upsertAvBlockRel(node *ast.Node) { var affectedAvIDs []string ast.Walk(node, func(n *ast.Node, entering bool) ast.WalkStatus { diff --git a/kernel/treenode/heading.go b/kernel/treenode/heading.go index b8b49cfd2..26ebd8102 100644 --- a/kernel/treenode/heading.go +++ b/kernel/treenode/heading.go @@ -86,13 +86,24 @@ func GetHeadingFold(nodes []*ast.Node) (ret []*ast.Node) { } func IsUnderFoldedHeading(node *ast.Node) bool { + currentLevel := 7 + if ast.NodeHeading == node.Type { + currentLevel = node.HeadingLevel + } for n := node.Previous; nil != n; n = n.Previous { - if ast.NodeHeading == n.Type && "1" == n.IALAttr("fold") { - if ast.NodeHeading != node.Type { - return true + if ast.NodeHeading == n.Type { + if n.HeadingLevel >= currentLevel { + break } - if n.HeadingLevel > node.HeadingLevel { - return true + currentLevel = n.HeadingLevel + + if "1" == n.IALAttr("fold") { + if ast.NodeHeading != node.Type { + return true + } + if n.HeadingLevel > node.HeadingLevel { + return true + } } } }