mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-09-22 00:20:47 +02:00
Compare commits
5 commits
3ba4985126
...
a154ead980
Author | SHA1 | Date | |
---|---|---|---|
![]() |
a154ead980 | ||
![]() |
15f116f344 | ||
![]() |
1c57d0b696 | ||
![]() |
0a079a39ca | ||
![]() |
bf722a142a |
4 changed files with 50 additions and 12 deletions
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue