|
@@ -22,6 +22,7 @@ import (
|
|
|
"time"
|
|
|
|
|
|
"github.com/88250/gulu"
|
|
|
+ "github.com/88250/lute"
|
|
|
"github.com/88250/lute/ast"
|
|
|
"github.com/88250/lute/html"
|
|
|
"github.com/88250/lute/lex"
|
|
@@ -105,6 +106,9 @@ func SetBlockAttrs(id string, nameValues map[string]string) (err error) {
|
|
|
return errors.New(fmt.Sprintf(Conf.Language(15), id))
|
|
|
}
|
|
|
|
|
|
+ luteEngine := NewLute()
|
|
|
+ oldDom := lute.RenderNodeBlockDOM(node, luteEngine.ParseOptions, luteEngine.RenderOptions)
|
|
|
+
|
|
|
for name, _ := range nameValues {
|
|
|
for i := 0; i < len(name); i++ {
|
|
|
if !lex.IsASCIILetterNumHyphen(name[i]) {
|
|
@@ -126,9 +130,27 @@ func SetBlockAttrs(id string, nameValues map[string]string) (err error) {
|
|
|
}
|
|
|
IncSync()
|
|
|
cache.PutBlockIAL(id, parse.IAL2Map(node.KramdownIAL))
|
|
|
+
|
|
|
+ dom := lute.RenderNodeBlockDOM(node, luteEngine.ParseOptions, luteEngine.RenderOptions)
|
|
|
+ if oldDom == dom {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ doOp := &Operation{Action: "update", Data: dom, ID: id}
|
|
|
+ undoOp := &Operation{Action: "update", Data: oldDom, ID: id}
|
|
|
+ trans := []*Transaction{{
|
|
|
+ DoOperations: []*Operation{doOp},
|
|
|
+ UndoOperations: []*Operation{undoOp},
|
|
|
+ }}
|
|
|
+ pushBroadcastTransactions(trans)
|
|
|
return
|
|
|
}
|
|
|
|
|
|
+func pushBroadcastTransactions(transactions []*Transaction) {
|
|
|
+ evt := util.NewCmdResult("transactions", 0, util.PushModeBroadcast, util.PushModeBroadcast)
|
|
|
+ evt.Data = transactions
|
|
|
+ util.PushEvent(evt)
|
|
|
+}
|
|
|
+
|
|
|
func ResetBlockAttrs(id string, nameValues map[string]string) (err error) {
|
|
|
tree, err := loadTreeByBlockID(id)
|
|
|
if nil != err {
|