mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-17 15:10:12 +01:00
🎨 Support for export RTF Fix https://github.com/siyuan-note/siyuan/issues/8132
This commit is contained in:
parent
847be4b939
commit
05d2a5147d
5 changed files with 31 additions and 0 deletions
|
|
@ -711,6 +711,17 @@ export const exportMd = (id: string) => {
|
|||
openByMobile(response.data.zip);
|
||||
});
|
||||
}
|
||||
}, {
|
||||
label: "RTF",
|
||||
click: () => {
|
||||
const msgId = showMessage(window.siyuan.languages.exporting, -1);
|
||||
fetchPost("/api/export/exportRTF", {
|
||||
id,
|
||||
}, response => {
|
||||
hideMessage(msgId);
|
||||
openByMobile(response.data.zip);
|
||||
});
|
||||
}
|
||||
},
|
||||
]
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,6 +31,23 @@ import (
|
|||
"github.com/siyuan-note/siyuan/kernel/util"
|
||||
)
|
||||
|
||||
func exportRTF(c *gin.Context) {
|
||||
ret := gulu.Ret.NewResult()
|
||||
defer c.JSON(http.StatusOK, ret)
|
||||
|
||||
arg, ok := util.JsonArg(c, ret)
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
|
||||
id := arg["id"].(string)
|
||||
name, zipPath := model.ExportPandocConvertZip(id, "rtf", ".rtf")
|
||||
ret.Data = map[string]interface{}{
|
||||
"name": name,
|
||||
"zip": zipPath,
|
||||
}
|
||||
}
|
||||
|
||||
func exportODT(c *gin.Context) {
|
||||
ret := gulu.Ret.NewResult()
|
||||
defer c.JSON(http.StatusOK, ret)
|
||||
|
|
|
|||
|
|
@ -252,6 +252,7 @@ func ServeAPI(ginServer *gin.Engine) {
|
|||
ginServer.Handle("POST", "/api/export/exportOrgMode", model.CheckAuth, exportOrgMode)
|
||||
ginServer.Handle("POST", "/api/export/exportMediaWiki", model.CheckAuth, exportMediaWiki)
|
||||
ginServer.Handle("POST", "/api/export/exportODT", model.CheckAuth, exportODT)
|
||||
ginServer.Handle("POST", "/api/export/exportRTF", model.CheckAuth, exportRTF)
|
||||
|
||||
ginServer.Handle("POST", "/api/import/importStdMd", model.CheckAuth, model.CheckReadonly, importStdMd)
|
||||
ginServer.Handle("POST", "/api/import/importData", model.CheckAuth, model.CheckReadonly, importData)
|
||||
|
|
|
|||
|
|
@ -1997,6 +1997,7 @@ func exportPandocConvertZip(boxID, baseFolderName string, docPaths []string,
|
|||
box := Conf.Box(boxID)
|
||||
|
||||
exportFolder := filepath.Join(util.TempDir, "export", baseFolderName+ext)
|
||||
os.RemoveAll(exportFolder)
|
||||
if err := os.MkdirAll(exportFolder, 0755); nil != err {
|
||||
logging.LogErrorf("create export temp folder failed: %s", err)
|
||||
return
|
||||
|
|
|
|||
|
|
@ -35,6 +35,7 @@ func Pandoc(from, to, o, content string) (ret string, err error) {
|
|||
args := []string{
|
||||
"--from", from,
|
||||
"--to", to,
|
||||
"-s",
|
||||
}
|
||||
|
||||
if "" != o {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue