This commit is contained in:
Liang Ding 2023-05-11 09:21:32 +08:00
parent 847be4b939
commit 05d2a5147d
No known key found for this signature in database
GPG key ID: 136F30F901A2231D
5 changed files with 31 additions and 0 deletions

View file

@ -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);
});
}
},
]
}

View file

@ -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)

View file

@ -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)

View file

@ -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

View file

@ -35,6 +35,7 @@ func Pandoc(from, to, o, content string) (ret string, err error) {
args := []string{
"--from", from,
"--to", to,
"-s",
}
if "" != o {