🎨 API /api/block/*
支持插入或更新带有块级 IAL 的空段落块 Fix https://github.com/siyuan-note/siyuan/issues/6713
This commit is contained in:
parent
aafbd204db
commit
c0d1451c7b
7 changed files with 10 additions and 29 deletions
6
app/stage/protyle/js/lute/lute.min.js
vendored
6
app/stage/protyle/js/lute/lute.min.js
vendored
File diff suppressed because one or more lines are too long
|
@ -296,7 +296,7 @@ func broadcastTransactions(transactions []*model.Transaction) {
|
|||
func dataBlockDOM(data string, luteEngine *lute.Lute) (ret string) {
|
||||
luteEngine.SetHTMLTag2TextMark(true) // API `/api/block/**` 无法使用 `<u>foo</u>` 与 `<kbd>bar</kbd>` 插入/更新行内元素 https://github.com/siyuan-note/siyuan/issues/6039
|
||||
|
||||
ret = luteEngine.Md2BlockDOM(data)
|
||||
ret = luteEngine.Md2BlockDOM(data, true)
|
||||
if "" == ret {
|
||||
// 使用 API 插入空字符串出现错误 https://github.com/siyuan-note/siyuan/issues/3931
|
||||
blankParagraph := parse.NewParagraph()
|
||||
|
|
|
@ -6,7 +6,7 @@ require (
|
|||
github.com/88250/clipboard v0.1.5
|
||||
github.com/88250/css v0.1.2
|
||||
github.com/88250/gulu v1.2.3-0.20221117052724-cd06804db798
|
||||
github.com/88250/lute v1.7.5-0.20221124044153-d802c1b13ae6
|
||||
github.com/88250/lute v1.7.5-0.20221125095536-d60bc3a75afb
|
||||
github.com/88250/pdfcpu v0.3.13
|
||||
github.com/88250/vitess-sqlparser v0.0.0-20210205111146-56a2ded2aba1
|
||||
github.com/ConradIrwin/font v0.0.0-20210318200717-ce8d41cc0732
|
||||
|
|
|
@ -17,8 +17,8 @@ github.com/88250/go-sqlite3 v1.14.13-0.20220714142610-fbbda1ee84f5 h1:8HdZozCsXS
|
|||
github.com/88250/go-sqlite3 v1.14.13-0.20220714142610-fbbda1ee84f5/go.mod h1:NyWgC/yNuGj7Q9rpYnZvas74GogHl5/Z4A/KQRfk6bU=
|
||||
github.com/88250/gulu v1.2.3-0.20221117052724-cd06804db798 h1:sR/s/Y9wyl79ZRCUERwLPo9zqaB3KhNRodCMTJ4ozEU=
|
||||
github.com/88250/gulu v1.2.3-0.20221117052724-cd06804db798/go.mod h1:I1qBzsksFL2ciGSuqDE7R3XW4BUMrfDgOvSXEk7FsAI=
|
||||
github.com/88250/lute v1.7.5-0.20221124044153-d802c1b13ae6 h1:bhWVdt7x4ejTrMdHOPO6x63YlPLKrBVjr5YcA1icMzw=
|
||||
github.com/88250/lute v1.7.5-0.20221124044153-d802c1b13ae6/go.mod h1:cEoBGi0zArPqAsp0MdG9SKinvH/xxZZWXU7sRx8vHSA=
|
||||
github.com/88250/lute v1.7.5-0.20221125095536-d60bc3a75afb h1:Yffmrt6FuVZMsrU3StPn1jAxtu69Fk4+67zEEO+qGh0=
|
||||
github.com/88250/lute v1.7.5-0.20221125095536-d60bc3a75afb/go.mod h1:cEoBGi0zArPqAsp0MdG9SKinvH/xxZZWXU7sRx8vHSA=
|
||||
github.com/88250/pdfcpu v0.3.13 h1:touMWMZkCGalMIbEg9bxYp7rETM+zwb9hXjwhqi4I7Q=
|
||||
github.com/88250/pdfcpu v0.3.13/go.mod h1:S5YT38L/GCjVjmB4PB84PymA1qfopjEhfhTNQilLpv4=
|
||||
github.com/88250/vitess-sqlparser v0.0.0-20210205111146-56a2ded2aba1 h1:48T899JQDwyyRu9yXHePYlPdHtpJfrJEUGBMH3SMBWY=
|
||||
|
|
|
@ -469,7 +469,7 @@ func genTreeID(tree *parse.Tree) {
|
|||
return ast.WalkContinue
|
||||
}
|
||||
|
||||
if treenode.IsEmptyBlockIAL(n) {
|
||||
if n.IsEmptyBlockIAL() {
|
||||
// 空段落保留
|
||||
p := &ast.Node{Type: ast.NodeParagraph}
|
||||
p.KramdownIAL = parse.Tokens2IAL(n.Tokens)
|
||||
|
|
|
@ -924,7 +924,7 @@ func CreateDocByMd(boxID, p, title, md string, sorts []string) (err error) {
|
|||
}
|
||||
|
||||
luteEngine := NewLute()
|
||||
dom := luteEngine.Md2BlockDOM(md)
|
||||
dom := luteEngine.Md2BlockDOM(md, false)
|
||||
err = createDoc(box.ID, p, title, dom)
|
||||
if nil != err {
|
||||
return
|
||||
|
@ -943,7 +943,7 @@ func CreateWithMarkdown(boxID, hPath, md string) (id string, err error) {
|
|||
|
||||
WaitForWritingFiles()
|
||||
luteEngine := NewLute()
|
||||
dom := luteEngine.Md2BlockDOM(md)
|
||||
dom := luteEngine.Md2BlockDOM(md, false)
|
||||
id, _, err = createDocsByHPath(box.ID, hPath, dom)
|
||||
return
|
||||
}
|
||||
|
|
|
@ -29,7 +29,6 @@ import (
|
|||
"github.com/88250/lute"
|
||||
"github.com/88250/lute/ast"
|
||||
"github.com/88250/lute/parse"
|
||||
util2 "github.com/88250/lute/util"
|
||||
"github.com/siyuan-note/siyuan/kernel/util"
|
||||
)
|
||||
|
||||
|
@ -86,24 +85,6 @@ func NewTree(boxID, p, hp, title string) *parse.Tree {
|
|||
return ret
|
||||
}
|
||||
|
||||
func IsEmptyBlockIAL(n *ast.Node) bool {
|
||||
if ast.NodeKramdownBlockIAL != n.Type {
|
||||
return false
|
||||
}
|
||||
|
||||
if util2.IsDocIAL(n.Tokens) {
|
||||
return false
|
||||
}
|
||||
|
||||
if nil != n.Previous {
|
||||
if ast.NodeKramdownBlockIAL == n.Previous.Type {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
func IALStr(n *ast.Node) string {
|
||||
if 1 > len(n.KramdownIAL) {
|
||||
return ""
|
||||
|
|
Loading…
Add table
Reference in a new issue