🐛 The images in the embed blocks are not uploaded to the community hosting https://github.com/siyuan-note/siyuan/issues/10042
This commit is contained in:
parent
fdb0600dbb
commit
275714f017
5 changed files with 46 additions and 2 deletions
|
@ -36,6 +36,7 @@ Below are the detailed changes in this version.
|
|||
* [Reference jump is not located in read-only mode](https://github.com/siyuan-note/siyuan/issues/10028)
|
||||
* [Converting PDF annotation ref to text fails after setting the appearance](https://github.com/siyuan-note/siyuan/issues/10029)
|
||||
* [Pressing the scoring shortcut key immediately after `Alt+F` is invalid](https://github.com/siyuan-note/siyuan/issues/10020)
|
||||
* [The images in the embed blocks are not uploaded to the community hosting](https://github.com/siyuan-note/siyuan/issues/10042)
|
||||
|
||||
### Development
|
||||
|
||||
|
|
|
@ -36,6 +36,7 @@
|
|||
* [唯讀模式下引用跳轉後未定位瀏覽位置](https://github.com/siyuan-note/siyuan/issues/10028)
|
||||
* [無法轉換外觀樣式的 PDF 註解引用為文字](https://github.com/siyuan-note/siyuan/issues/10029)
|
||||
* [`Alt+F` 後快速按下評分快捷鍵失效](https://github.com/siyuan-note/siyuan/issues/10020)
|
||||
* [在嵌入區塊中的圖片未能上傳社群](https://github.com/siyuan-note/siyuan/issues/10042)
|
||||
|
||||
### 開發者
|
||||
|
||||
|
|
|
@ -36,6 +36,7 @@
|
|||
* [只读模式下引用跳转后未定位浏览位置](https://github.com/siyuan-note/siyuan/issues/10028)
|
||||
* [无法转换带外观样式的 PDF 注释引用为文本](https://github.com/siyuan-note/siyuan/issues/10029)
|
||||
* [`Alt+F` 后快速按下评分快捷键失效](https://github.com/siyuan-note/siyuan/issues/10020)
|
||||
* [在嵌入块中的图片未能上传社区](https://github.com/siyuan-note/siyuan/issues/10042)
|
||||
|
||||
### 开发者
|
||||
|
||||
|
|
|
@ -20,6 +20,7 @@ import (
|
|||
"bytes"
|
||||
"errors"
|
||||
"fmt"
|
||||
"github.com/88250/lute/editor"
|
||||
"io"
|
||||
"io/fs"
|
||||
"mime"
|
||||
|
@ -520,6 +521,9 @@ func UploadAssets2Cloud(rootID string) (count int, err error) {
|
|||
}
|
||||
|
||||
assets := assetsLinkDestsInTree(tree)
|
||||
embedAssets := assetsLinkDestsInQueryEmbedNodes(tree)
|
||||
assets = append(assets, embedAssets...)
|
||||
assets = gulu.Str.RemoveDuplicatedElem(assets)
|
||||
err = uploadAssets2Cloud(assets, bizTypeUploadAssets)
|
||||
if nil != err {
|
||||
return
|
||||
|
@ -1053,9 +1057,43 @@ func emojisInTree(tree *parse.Tree) (ret []string) {
|
|||
return
|
||||
}
|
||||
|
||||
func assetsLinkDestsInTree(tree *parse.Tree) (ret []string) {
|
||||
func assetsLinkDestsInQueryEmbedNodes(tree *parse.Tree) (ret []string) {
|
||||
ret = []string{}
|
||||
ast.Walk(tree.Root, func(n *ast.Node, entering bool) ast.WalkStatus {
|
||||
if !entering || ast.NodeBlockQueryEmbedScript != n.Type {
|
||||
return ast.WalkContinue
|
||||
}
|
||||
|
||||
stmt := n.ChildByType(ast.NodeBlockQueryEmbedScript).TokensStr()
|
||||
stmt = html.UnescapeString(stmt)
|
||||
stmt = strings.ReplaceAll(stmt, editor.IALValEscNewLine, "\n")
|
||||
sqlBlocks := sql.SelectBlocksRawStmt(stmt, 1, Conf.Search.Limit)
|
||||
for _, sqlBlock := range sqlBlocks {
|
||||
subtree, _ := loadTreeByBlockID(sqlBlock.ID)
|
||||
if nil == subtree {
|
||||
continue
|
||||
}
|
||||
embedNode := treenode.GetNodeInTree(subtree, sqlBlock.ID)
|
||||
if nil == embedNode {
|
||||
continue
|
||||
}
|
||||
|
||||
ret = append(ret, assetsLinkDestsInNode(embedNode)...)
|
||||
}
|
||||
return ast.WalkContinue
|
||||
})
|
||||
ret = gulu.Str.RemoveDuplicatedElem(ret)
|
||||
return
|
||||
}
|
||||
|
||||
func assetsLinkDestsInTree(tree *parse.Tree) (ret []string) {
|
||||
ret = assetsLinkDestsInNode(tree.Root)
|
||||
return
|
||||
}
|
||||
|
||||
func assetsLinkDestsInNode(node *ast.Node) (ret []string) {
|
||||
ret = []string{}
|
||||
ast.Walk(node, func(n *ast.Node, entering bool) ast.WalkStatus {
|
||||
// 修改以下代码时需要同时修改 database 构造行级元素实现,增加必要的类型
|
||||
if !entering || (ast.NodeLinkDest != n.Type && ast.NodeHTMLBlock != n.Type && ast.NodeInlineHTML != n.Type &&
|
||||
ast.NodeIFrame != n.Type && ast.NodeWidget != n.Type && ast.NodeAudio != n.Type && ast.NodeVideo != n.Type &&
|
||||
|
@ -1112,7 +1150,7 @@ func assetsLinkDestsInTree(tree *parse.Tree) (ret []string) {
|
|||
dest := strings.TrimSpace(string(src))
|
||||
ret = append(ret, dest)
|
||||
} else {
|
||||
logging.LogWarnf("src is missing the closing double quote in tree [%s] ", tree.Box+tree.Path)
|
||||
logging.LogWarnf("src is missing the closing double quote in tree [%s] ", node.Box+node.Path)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -68,6 +68,9 @@ func Export2Liandi(id string) (err error) {
|
|||
}
|
||||
|
||||
assets := assetsLinkDestsInTree(tree)
|
||||
embedAssets := assetsLinkDestsInQueryEmbedNodes(tree)
|
||||
assets = append(assets, embedAssets...)
|
||||
assets = gulu.Str.RemoveDuplicatedElem(assets)
|
||||
err = uploadAssets2Cloud(assets, bizTypeExport2Liandi)
|
||||
if nil != err {
|
||||
return
|
||||
|
|
Loading…
Add table
Reference in a new issue