mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-17 07:00:12 +01:00
🎨 Export preview mode supports focus use https://github.com/siyuan-note/siyuan/issues/15340
This commit is contained in:
parent
3cb666d397
commit
cf6c905930
3 changed files with 20 additions and 8 deletions
|
|
@ -277,8 +277,9 @@ export class Preview {
|
|||
this.processZHTable(copyElement);
|
||||
} else if (type === "yuque") {
|
||||
fetchPost("/api/lute/copyStdMarkdown", {
|
||||
id: protyle.block.rootID,
|
||||
id: protyle.block.id || protyle.options.blockId || protyle.block.parentID,
|
||||
assetsDestSpace2Underscore: true,
|
||||
adjustHeadingLevel: true,
|
||||
}, (response) => {
|
||||
writeText(response.data);
|
||||
showMessage(`${window.siyuan.languages.pasteToYuque}`);
|
||||
|
|
|
|||
|
|
@ -48,7 +48,13 @@ func copyStdMarkdown(c *gin.Context) {
|
|||
if nil != arg["assetsDestSpace2Underscore"] {
|
||||
assetsDestSpace2Underscore = arg["assetsDestSpace2Underscore"].(bool)
|
||||
}
|
||||
ret.Data = model.ExportStdMarkdown(id, assetsDestSpace2Underscore)
|
||||
|
||||
adjustHeadingLevel := false
|
||||
if nil != arg["adjustHeadingLevel"] {
|
||||
adjustHeadingLevel = arg["adjustHeadingLevel"].(bool)
|
||||
}
|
||||
|
||||
ret.Data = model.ExportStdMarkdown(id, assetsDestSpace2Underscore, adjustHeadingLevel)
|
||||
}
|
||||
|
||||
func html2BlockDOM(c *gin.Context) {
|
||||
|
|
|
|||
|
|
@ -268,7 +268,7 @@ func Export2Liandi(id string) (err error) {
|
|||
|
||||
title := path.Base(tree.HPath)
|
||||
tags := tree.Root.IALAttr("tags")
|
||||
content := exportMarkdownContent0(tree, util.GetCloudForumAssetsServer()+time.Now().Format("2006/01")+"/siyuan/"+Conf.GetUser().UserId+"/", true,
|
||||
content := exportMarkdownContent0(id, tree, util.GetCloudForumAssetsServer()+time.Now().Format("2006/01")+"/siyuan/"+Conf.GetUser().UserId+"/", true, false,
|
||||
".md", 3, 1, 1,
|
||||
"#", "#",
|
||||
"", "",
|
||||
|
|
@ -1457,7 +1457,7 @@ func processPDFLinkEmbedAssets(pdfCtx *model.Context, assetDests []string, remov
|
|||
}
|
||||
}
|
||||
|
||||
func ExportStdMarkdown(id string, assetsDestSpace2Underscore bool) string {
|
||||
func ExportStdMarkdown(id string, assetsDestSpace2Underscore, adjustHeadingLevel bool) string {
|
||||
tree, err := LoadTreeByBlockID(id)
|
||||
if err != nil {
|
||||
logging.LogErrorf("load tree by block id [%s] failed: %s", id, err)
|
||||
|
|
@ -1495,7 +1495,7 @@ func ExportStdMarkdown(id string, assetsDestSpace2Underscore bool) string {
|
|||
}
|
||||
defBlockIDs = gulu.Str.RemoveDuplicatedElem(defBlockIDs)
|
||||
|
||||
return exportMarkdownContent0(tree, cloudAssetsBase, assetsDestSpace2Underscore,
|
||||
return exportMarkdownContent0(id, tree, cloudAssetsBase, assetsDestSpace2Underscore, adjustHeadingLevel,
|
||||
".md", Conf.Export.BlockRefMode, Conf.Export.BlockEmbedMode, Conf.Export.FileAnnotationRefMode,
|
||||
Conf.Export.TagOpenMarker, Conf.Export.TagCloseMarker,
|
||||
Conf.Export.BlockRefTextLeft, Conf.Export.BlockRefTextRight,
|
||||
|
|
@ -1989,7 +1989,7 @@ func ExportMarkdownContent(id string, refMode, embedMode int, addYfm, fillCSSVar
|
|||
|
||||
tree := prepareExportTree(bt)
|
||||
hPath = tree.HPath
|
||||
exportedMd = exportMarkdownContent0(tree, "", false,
|
||||
exportedMd = exportMarkdownContent0(id, tree, "", false, false,
|
||||
".md", refMode, embedMode, Conf.Export.FileAnnotationRefMode,
|
||||
Conf.Export.TagOpenMarker, Conf.Export.TagCloseMarker,
|
||||
Conf.Export.BlockRefTextLeft, Conf.Export.BlockRefTextRight,
|
||||
|
|
@ -2008,7 +2008,7 @@ func exportMarkdownContent(id, ext string, exportRefMode int, defBlockIDs []stri
|
|||
return
|
||||
}
|
||||
isEmpty = nil == tree.Root.FirstChild.FirstChild
|
||||
exportedMd = exportMarkdownContent0(tree, "", false,
|
||||
exportedMd = exportMarkdownContent0(id, tree, "", false, false,
|
||||
ext, exportRefMode, Conf.Export.BlockEmbedMode, Conf.Export.FileAnnotationRefMode,
|
||||
Conf.Export.TagOpenMarker, Conf.Export.TagCloseMarker,
|
||||
Conf.Export.BlockRefTextLeft, Conf.Export.BlockRefTextRight,
|
||||
|
|
@ -2021,7 +2021,7 @@ func exportMarkdownContent(id, ext string, exportRefMode int, defBlockIDs []stri
|
|||
return
|
||||
}
|
||||
|
||||
func exportMarkdownContent0(tree *parse.Tree, cloudAssetsBase string, assetsDestSpace2Underscore bool,
|
||||
func exportMarkdownContent0(id string, tree *parse.Tree, cloudAssetsBase string, assetsDestSpace2Underscore, adjustHeadingLv bool,
|
||||
ext string, blockRefMode, blockEmbedMode, fileAnnotationRefMode int,
|
||||
tagOpenMarker, tagCloseMarker string, blockRefTextLeft, blockRefTextRight string,
|
||||
addTitle, inlineMemo bool, defBlockIDs []string, singleFile, fillCSSVar bool, treeCache *map[string]*parse.Tree) (ret string) {
|
||||
|
|
@ -2030,6 +2030,11 @@ func exportMarkdownContent0(tree *parse.Tree, cloudAssetsBase string, assetsDest
|
|||
tagOpenMarker, tagCloseMarker,
|
||||
blockRefTextLeft, blockRefTextRight,
|
||||
addTitle, inlineMemo, 0 < len(defBlockIDs), singleFile, treeCache)
|
||||
if adjustHeadingLv {
|
||||
bt := treenode.GetBlockTree(id)
|
||||
adjustHeadingLevel(bt, tree)
|
||||
}
|
||||
|
||||
luteEngine := NewLute()
|
||||
luteEngine.SetFootnotes(true)
|
||||
luteEngine.SetKramdownIAL(false)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue