From efc018a27fef41074bad4f765b22526544078b5f Mon Sep 17 00:00:00 2001 From: Liang Ding Date: Wed, 22 Feb 2023 21:11:58 +0800 Subject: [PATCH 1/7] =?UTF-8?q?:art:=20=E5=AF=BC=E5=87=BA=20PDF=20?= =?UTF-8?q?=E6=97=B6=E6=94=AF=E6=8C=81=E5=B0=86=E8=B5=84=E6=BA=90=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E4=BD=9C=E4=B8=BA=E9=99=84=E4=BB=B6=E5=B5=8C=E5=85=A5?= =?UTF-8?q?=20https://github.com/siyuan-note/siyuan/issues/7414?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- kernel/go.mod | 2 +- kernel/go.sum | 4 +- kernel/model/export.go | 219 ++++++++++++++++++++++++++++++++++++----- 3 files changed, 196 insertions(+), 29 deletions(-) diff --git a/kernel/go.mod b/kernel/go.mod index cdb28a6f5..1f107641b 100644 --- a/kernel/go.mod +++ b/kernel/go.mod @@ -7,7 +7,7 @@ require ( github.com/88250/css v0.1.2 github.com/88250/gulu v1.2.3-0.20221117052724-cd06804db798 github.com/88250/lute v1.7.6-0.20230220030205-b0f64d7ba66e - github.com/88250/pdfcpu v0.3.13 + github.com/88250/pdfcpu v0.3.14-0.20230222105639-68297f21b5d2 github.com/88250/vitess-sqlparser v0.0.0-20210205111146-56a2ded2aba1 github.com/ClarkThan/ahocorasick v0.0.0-20230216061320-bccdb98581a3 github.com/ConradIrwin/font v0.0.0-20210318200717-ce8d41cc0732 diff --git a/kernel/go.sum b/kernel/go.sum index cb44b26c3..0fd87b5cc 100644 --- a/kernel/go.sum +++ b/kernel/go.sum @@ -10,8 +10,8 @@ github.com/88250/gulu v1.2.3-0.20221117052724-cd06804db798 h1:sR/s/Y9wyl79ZRCUER github.com/88250/gulu v1.2.3-0.20221117052724-cd06804db798/go.mod h1:I1qBzsksFL2ciGSuqDE7R3XW4BUMrfDgOvSXEk7FsAI= github.com/88250/lute v1.7.6-0.20230220030205-b0f64d7ba66e h1:7UgFzsksh+z6IX2z+BKG3tt1TU7LJNb0zOHDbhLEaUc= github.com/88250/lute v1.7.6-0.20230220030205-b0f64d7ba66e/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/pdfcpu v0.3.14-0.20230222105639-68297f21b5d2 h1:M1JxCmcaLwI7qlQJD5UatAxaIT6tfLvq3GptOsMffn4= +github.com/88250/pdfcpu v0.3.14-0.20230222105639-68297f21b5d2/go.mod h1:S5YT38L/GCjVjmB4PB84PymA1qfopjEhfhTNQilLpv4= github.com/88250/vitess-sqlparser v0.0.0-20210205111146-56a2ded2aba1 h1:48T899JQDwyyRu9yXHePYlPdHtpJfrJEUGBMH3SMBWY= github.com/88250/vitess-sqlparser v0.0.0-20210205111146-56a2ded2aba1/go.mod h1:U3pckKQIgxxkmZjV5yXQjHdGxQK0o/vEZeZ6cQsxfHw= github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= diff --git a/kernel/model/export.go b/kernel/model/export.go index e7642445c..2637c1c61 100644 --- a/kernel/model/export.go +++ b/kernel/model/export.go @@ -764,36 +764,203 @@ func AddPDFOutline(id, p string, merge bool) (err error) { } } - //var assetAbsPaths []string - //for _, dest := range assetDests { - // absPath, _ := GetAssetAbsPath(dest) - // if "" != absPath { - // assetAbsPaths = append(assetAbsPaths, absPath) - // } - //} - // - //if 0 < len(assetAbsPaths) { - // outFile := inFile + ".tmp" - // err = api.AddAttachmentsFile(inFile, outFile, assetAbsPaths, false, nil) - // if nil != err { - // logging.LogErrorf("add attachment failed: %s", err) - // return - // } - // - // err = os.Rename(outFile, inFile) - // if nil != err { - // return - // } - //} - // - //assetLinks, err := api.ListAssetLinks(inFile) - //if nil == err { - // logging.LogInfof("pdf annotation: %+v", assetLinks) - //} + var assetAbsPaths []string + for _, dest := range assetDests { + absPath, _ := GetAssetAbsPath(dest) + if "" != absPath { + assetAbsPaths = append(assetAbsPaths, absPath) + } + } + + if 0 < len(assetAbsPaths) { + //outFile := inFile + ".tmp" + //err = api.AddAttachmentsFile(inFile, outFile, assetAbsPaths, false, nil) + //if nil != err { + // logging.LogErrorf("add attachment failed: %s", err) + // return + //} + // + //err = os.Rename(outFile, inFile) + //if nil != err { + // return + //} + + assetLinks, listErr := api.ListAssetLinks(inFile) + if nil != listErr { + logging.LogErrorf("list asset links failed: %s", listErr) + return + } + + pdfCtx, ctxErr := api.ReadContextFile(inFile) + if nil != ctxErr { + logging.LogErrorf("read pdf context failed: %s", ctxErr) + return + } + + linkMap := map[int][]*pdfcpu.IndirectRef{} + //pdfCtx.RemoveAnnotations(nil, nil, nil, false) + + for i, link := range assetLinks { + link.URI = strings.ReplaceAll(link.URI, "http://127.0.0.1:6806/export/temp/", "") + //if 1 > len(linkMap[link.Page]) { + // linkMap[link.Page] = []pdfcpu.Annotation{link} + //} else { + // linkMap[link.Page] = append(linkMap[link.Page], link) + //} + + absPath, getErr := GetAssetAbsPath(link.URI) + if nil != getErr { + continue + } + + ir, newErr := pdfCtx.XRefTable.NewEmbeddedFileStreamDict(absPath) + if nil != newErr { + logging.LogWarnf("new embedded file stream dict failed: %s", newErr) + continue + } + + fn := filepath.Base(absPath) + fileSpecDict, newErr := pdfCtx.XRefTable.NewFileSpecDict(fn, pdfcpu.EncodeUTF16String(fn), "attached by SiYuan", *ir) + if nil != newErr { + logging.LogWarnf("new file spec dict failed: %s", newErr) + continue + } + + ir, indErr := pdfCtx.XRefTable.IndRefForNewObject(fileSpecDict) + if nil != indErr { + logging.LogWarnf("ind ref for new object failed: %s", indErr) + continue + } + + now := pdfcpu.StringLiteral(pdfcpu.DateString(time.Now())) + mediaBox := pdfcpu.RectForFormat("A4") + r := annotRect(i, mediaBox.Width(), mediaBox.Height(), 30, 80) + d := pdfcpu.Dict( + map[string]pdfcpu.Object{ + "Type": pdfcpu.Name("Annot"), + "Subtype": pdfcpu.Name("FileAttachment"), + "Contents": pdfcpu.StringLiteral("FileAttachment Annotation"), + "Rect": r.Array(), + "P": link.P, + "M": now, + "F": pdfcpu.Integer(0), + "Border": pdfcpu.NewIntegerArray(0, 0, 1), + "C": pdfcpu.NewNumberArray(0.5, 0.0, 0.5), + "CA": pdfcpu.Float(0.95), + "CreationDate": now, + "Name": pdfcpu.Name("FileAttachment"), + "FS": *ir, + "NM": pdfcpu.StringLiteral("SoundFileAttachmentAnnot"), + }, + ) + + ann, indErr := pdfCtx.XRefTable.IndRefForNewObject(d) + if nil != indErr { + logging.LogWarnf("ind ref for new object failed: %s", indErr) + continue + } + + pageDictIndRef, pageErr := pdfCtx.PageDictIndRef(link.Page) + if nil != pageErr { + logging.LogWarnf("page dict ind ref failed: %s", pageErr) + continue + } + + d, defErr := pdfCtx.DereferenceDict(*pageDictIndRef) + if nil != defErr { + logging.LogWarnf("dereference dict failed: %s", defErr) + continue + } + + if 1 > len(linkMap[link.Page]) { + linkMap[link.Page] = []*pdfcpu.IndirectRef{ann} + } else { + linkMap[link.Page] = append(linkMap[link.Page], ann) + } + } + + for page, anns := range linkMap { + pageDictIndRef, pageErr := pdfCtx.PageDictIndRef(page) + if nil != pageErr { + logging.LogWarnf("page dict ind ref failed: %s", pageErr) + continue + } + + pageDict, defErr := pdfCtx.DereferenceDict(*pageDictIndRef) + if nil != defErr { + logging.LogWarnf("dereference dict failed: %s", defErr) + continue + } + + array := pdfcpu.Array{} + for _, ann := range anns { + array = append(array, *ann) + } + + obj, found := pageDict.Find("Annots") + if !found { + pageDict.Insert("Annots", array) + + pdfCtx.EnsureVersionForWriting() + continue + } + + ir, ok := obj.(pdfcpu.IndirectRef) + if !ok { + pageDict.Update("Annots", append(obj.(pdfcpu.Array), array...)) + pdfCtx.EnsureVersionForWriting() + continue + } + + // Annots array is an IndirectReference. + + o, err := pdfCtx.Dereference(ir) + if err != nil || o == nil { + continue + } + + annots, _ := o.(pdfcpu.Array) + entry, ok := pdfCtx.FindTableEntryForIndRef(&ir) + if !ok { + continue + } + entry.Object = append(annots, array...) + pdfCtx.EnsureVersionForWriting() + + //d.Insert("Annots", array) + } + + if writeErr := api.WriteContextFile(pdfCtx, inFile); nil != writeErr { + logging.LogErrorf("write pdf context failed: %s", writeErr) + return + } + } return } +func annotRect(i int, w, h, d, l float64) *pdfcpu.Rectangle { + // d..distance between annotation rectangles + // l..side length of rectangle + + // max number of rectangles fitting into w + xmax := int((w - d) / (l + d)) + + // max number of rectangles fitting into h + ymax := int((h - d) / (l + d)) + + col := float64(i % xmax) + row := float64(i / xmax % ymax) + + llx := d + col*(l+d) + lly := d + row*(l+d) + + urx := llx + l + ury := lly + l + + return pdfcpu.Rect(llx, lly, urx, ury) +} + func ExportStdMarkdown(id string) string { tree, err := loadTreeByBlockID(id) if nil != err { From 8d4519c7df23150f785351950b45656b5750c790 Mon Sep 17 00:00:00 2001 From: Liang Ding Date: Thu, 23 Feb 2023 08:39:37 +0800 Subject: [PATCH 2/7] =?UTF-8?q?:art:=20=E4=BC=98=E5=8C=96=20`=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E5=88=B0=E5=8D=A1=E5=8C=85`=20=E5=AF=B9=E8=AF=9D?= =?UTF-8?q?=E6=A1=86=E5=8D=A1=E5=8C=85=E5=88=97=E8=A1=A8=20https://github.?= =?UTF-8?q?com/siyuan-note/siyuan/issues/7448?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- kernel/model/flashcard.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/kernel/model/flashcard.go b/kernel/model/flashcard.go index 4d55ccd6c..3d118b860 100644 --- a/kernel/model/flashcard.go +++ b/kernel/model/flashcard.go @@ -674,6 +674,10 @@ func GetDecks() (decks []*riff.Deck) { if 1 > len(decks) { decks = []*riff.Deck{} } + + sort.Slice(decks, func(i, j int) bool { + return decks[i].Updated > decks[j].Updated + }) return } From c0c605b664b193b8a84ccb102884fc0f878313a1 Mon Sep 17 00:00:00 2001 From: Liang Ding Date: Thu, 23 Feb 2023 10:20:21 +0800 Subject: [PATCH 3/7] =?UTF-8?q?:bug:=20API=20`/asset/upload`=20=E4=BD=BF?= =?UTF-8?q?=E7=94=A8=E5=AD=90=E6=96=87=E4=BB=B6=E5=A4=B9=E6=97=B6=E8=BF=94?= =?UTF-8?q?=E5=9B=9E=E7=BB=93=E6=9E=9C=E4=B8=8D=E6=AD=A3=E7=A1=AE=20Fix=20?= =?UTF-8?q?https://github.com/siyuan-note/siyuan/issues/7454?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- API.md | 20 ++++++++++---------- API_zh_CN.md | 10 ++++------ kernel/model/export.go | 31 ++++++++++++++----------------- kernel/model/upload.go | 8 +++++--- 4 files changed, 33 insertions(+), 36 deletions(-) diff --git a/API.md b/API.md index 022db8894..0c8ba3877 100644 --- a/API.md +++ b/API.md @@ -457,13 +457,12 @@ View API token in Settings - About, request header: `Authorization: T * `/api/asset/upload` * The parameter is an HTTP Multipart form - * `assetsDirPath`: The folder path where the assets are stored. The arguments have the following three cases + * `assetsDirPath`: The folder path where assets are stored, with the data folder as the root path, for example: + * `"/assets/"`: workspace/data/assets/ folder + * `"/assets/sub/"`: workspace/data/assets/sub/ folder - 1. `"/assets/"`: Workspace/data/assets folder - 2. `"/Test Notebook/assets/"`: Assets folder under `Test Notebook` - 3. `"/Test Notebook/foo/assets/"`: Assets folder under foo folder under `Test notebook` - - It is recommended to use the first one, which is stored in the workspace assets folder uniformly. + Under normal circumstances, it is recommended to use the first method, which is stored in the assets folder + of the workspace. * `file[]`: Uploaded file list * Return value @@ -705,7 +704,7 @@ View API token in Settings - About, request header: `Authorization: T } ``` - * `id`: ID of the block to be got + * `id`: ID of the block to be got * Return value ```json @@ -718,7 +717,7 @@ View API token in Settings - About, request header: `Authorization: T } } ``` - + ## Attributes ### Set block attributes @@ -814,8 +813,9 @@ View API token in Settings - About, request header: `Authorization: T "path": "F:\\SiYuan\\data\\templates\\foo.md" } ``` - * `id`: The ID of the document where the rendering is called - * `path`: Template file absolute path + + * `id`: The ID of the document where the rendering is called + * `path`: Template file absolute path * Return value ```json diff --git a/API_zh_CN.md b/API_zh_CN.md index 93c83d82b..c77c5818b 100644 --- a/API_zh_CN.md +++ b/API_zh_CN.md @@ -454,13 +454,11 @@ * `/api/asset/upload` * 参数为 HTTP Multipart 表单 - * `assetsDirPath`:资源文件存放的文件夹路径,实参有以下三种情况 + * `assetsDirPath`:资源文件存放的文件夹路径,以 data 文件夹作为根路径,比如: + * `"/assets/"`:工作空间/data/assets/ 文件夹 + * `"/assets/sub/"`:工作空间/data/assets/sub/ 文件夹 - 1. `"/assets/"`:工作空间/data/assets 文件夹 - 2. `"/测试笔记本/assets/"`:`测试笔记本`下的 assets 文件夹 - 3. `"/测试笔记本/foo/assets/"`:`测试笔记本`下 foo 文件夹下的 assets 文件夹 - - 建议用第一种,统一存放到工作空间资源文件夹下。 + 常规情况下建议用第一种,统一存放到工作空间资源文件夹下。 * `file[]`:上传的文件列表 * 返回值 diff --git a/kernel/model/export.go b/kernel/model/export.go index 2637c1c61..f0bc3bd61 100644 --- a/kernel/model/export.go +++ b/kernel/model/export.go @@ -665,6 +665,8 @@ func AddPDFOutline(id, p string, merge bool) (err error) { return links[i].Page < links[j].Page }) + pdfcpu.VersionStr = "SiYuan v" + util.Ver + bms := map[string]*pdfcpu.Bookmark{} for _, link := range links { linkID := link.URI[strings.LastIndex(link.URI, "/")+1:] @@ -798,15 +800,11 @@ func AddPDFOutline(id, p string, merge bool) (err error) { } linkMap := map[int][]*pdfcpu.IndirectRef{} - //pdfCtx.RemoveAnnotations(nil, nil, nil, false) - - for i, link := range assetLinks { + pdfCtx.RemoveAnnotations(nil, nil, nil, false) + now := pdfcpu.StringLiteral(pdfcpu.DateString(time.Now())) + for _, link := range assetLinks { link.URI = strings.ReplaceAll(link.URI, "http://127.0.0.1:6806/export/temp/", "") - //if 1 > len(linkMap[link.Page]) { - // linkMap[link.Page] = []pdfcpu.Annotation{link} - //} else { - // linkMap[link.Page] = append(linkMap[link.Page], link) - //} + link.URI, _ = url.PathUnescape(link.URI) absPath, getErr := GetAssetAbsPath(link.URI) if nil != getErr { @@ -832,15 +830,17 @@ func AddPDFOutline(id, p string, merge bool) (err error) { continue } - now := pdfcpu.StringLiteral(pdfcpu.DateString(time.Now())) - mediaBox := pdfcpu.RectForFormat("A4") - r := annotRect(i, mediaBox.Width(), mediaBox.Height(), 30, 80) + lx := link.Rect.LL.X + link.Rect.Width() + ly := link.Rect.LL.Y + link.Rect.Height()/2 + ux := lx + link.Rect.Height()/2 + uy := ly + link.Rect.Height()/2 + d := pdfcpu.Dict( map[string]pdfcpu.Object{ "Type": pdfcpu.Name("Annot"), "Subtype": pdfcpu.Name("FileAttachment"), - "Contents": pdfcpu.StringLiteral("FileAttachment Annotation"), - "Rect": r.Array(), + "Contents": pdfcpu.StringLiteral(""), + "Rect": pdfcpu.Rect(lx, ly, ux, uy).Array(), "P": link.P, "M": now, "F": pdfcpu.Integer(0), @@ -850,7 +850,7 @@ func AddPDFOutline(id, p string, merge bool) (err error) { "CreationDate": now, "Name": pdfcpu.Name("FileAttachment"), "FS": *ir, - "NM": pdfcpu.StringLiteral("SoundFileAttachmentAnnot"), + "NM": pdfcpu.StringLiteral(""), }, ) @@ -900,7 +900,6 @@ func AddPDFOutline(id, p string, merge bool) (err error) { obj, found := pageDict.Find("Annots") if !found { pageDict.Insert("Annots", array) - pdfCtx.EnsureVersionForWriting() continue } @@ -926,8 +925,6 @@ func AddPDFOutline(id, p string, merge bool) (err error) { } entry.Object = append(annots, array...) pdfCtx.EnsureVersionForWriting() - - //d.Insert("Annots", array) } if writeErr := api.WriteContextFile(pdfCtx, inFile); nil != writeErr { diff --git a/kernel/model/upload.go b/kernel/model/upload.go index 1dfaff11e..a3456263b 100644 --- a/kernel/model/upload.go +++ b/kernel/model/upload.go @@ -130,9 +130,11 @@ func Upload(c *gin.Context) { docDirLocalPath := filepath.Join(util.DataDir, bt.BoxID, path.Dir(bt.Path)) assetsDirPath = getAssetsDir(filepath.Join(util.DataDir, bt.BoxID), docDirLocalPath) } + + relAssetsDirPath := "assets" if nil != form.Value["assetsDirPath"] { - assetsDirPath = form.Value["assetsDirPath"][0] - assetsDirPath = filepath.Join(util.DataDir, assetsDirPath) + relAssetsDirPath = form.Value["assetsDirPath"][0] + assetsDirPath = filepath.Join(util.DataDir, relAssetsDirPath) } if !gulu.File.IsExist(assetsDirPath) { if err = os.MkdirAll(assetsDirPath, 0755); nil != err { @@ -187,7 +189,7 @@ func Upload(c *gin.Context) { break } f.Close() - succMap[baseName] = "assets/" + fName + succMap[baseName] = path.Join(relAssetsDirPath, fName) } } From f003aac384517bbe95a67ec41f0a06bf136c2226 Mon Sep 17 00:00:00 2001 From: Liang Ding Date: Thu, 23 Feb 2023 10:50:08 +0800 Subject: [PATCH 4/7] =?UTF-8?q?:art:=20=E5=AF=BC=E5=87=BA=20PDF=20?= =?UTF-8?q?=E6=97=B6=E6=94=AF=E6=8C=81=E5=B0=86=E8=B5=84=E6=BA=90=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E4=BD=9C=E4=B8=BA=E9=99=84=E4=BB=B6=E5=B5=8C=E5=85=A5?= =?UTF-8?q?=20https://github.com/siyuan-note/siyuan/issues/7414?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/util/onGetConfig.ts | 4 ++-- kernel/api/export.go | 4 ++-- kernel/api/router.go | 2 +- kernel/go.mod | 2 +- kernel/go.sum | 4 ++-- kernel/model/export.go | 2 +- 6 files changed, 9 insertions(+), 9 deletions(-) diff --git a/app/src/util/onGetConfig.ts b/app/src/util/onGetConfig.ts index 054e251dc..e63e06a6f 100644 --- a/app/src/util/onGetConfig.ts +++ b/app/src/util/onGetConfig.ts @@ -3,7 +3,7 @@ import {exportLayout, getInstanceById, JSONToLayout, resetLayout, resizeDrag, re import {hotKey2Electron, setStorageVal, updateHotkeyTip} from "../protyle/util/compatibility"; /// #if !BROWSER import {dialog, getCurrentWindow} from "@electron/remote"; -import {webFrame, ipcRenderer, OpenDialogReturnValue} from "electron"; +import {ipcRenderer, OpenDialogReturnValue, webFrame} from "electron"; import * as fs from "fs"; import * as path from "path"; import {afterExport} from "../protyle/export/util"; @@ -418,7 +418,7 @@ export const initWindow = () => { const pdfFilePath = path.join(result.filePaths[0], replaceLocalPath(ipcData.rootTitle) + ".pdf"); fs.writeFileSync(pdfFilePath, pdfData); window.siyuan.printWin.destroy(); - fetchPost("/api/export/addPDFOutline", { + fetchPost("/api/export/processPDF", { id: ipcData.rootId, merge: ipcData.mergeSubdocs, path: pdfFilePath diff --git a/kernel/api/export.go b/kernel/api/export.go index 1985d5eef..e7ccb5845 100644 --- a/kernel/api/export.go +++ b/kernel/api/export.go @@ -311,7 +311,7 @@ func exportHTML(c *gin.Context) { } } -func addPDFOutline(c *gin.Context) { +func processPDF(c *gin.Context) { ret := gulu.Ret.NewResult() defer c.JSON(http.StatusOK, ret) @@ -326,7 +326,7 @@ func addPDFOutline(c *gin.Context) { if nil != arg["merge"] { merge = arg["merge"].(bool) } - err := model.AddPDFOutline(id, path, merge) + err := model.ProcessPDF(id, path, merge) if nil != err { ret.Code = -1 ret.Msg = err.Error() diff --git a/kernel/api/router.go b/kernel/api/router.go index eaf1eec5c..84cfd2191 100644 --- a/kernel/api/router.go +++ b/kernel/api/router.go @@ -233,7 +233,7 @@ func ServeAPI(ginServer *gin.Engine) { ginServer.Handle("POST", "/api/export/exportPreviewHTML", model.CheckAuth, exportPreviewHTML) ginServer.Handle("POST", "/api/export/exportMdHTML", model.CheckAuth, exportMdHTML) ginServer.Handle("POST", "/api/export/exportDocx", model.CheckAuth, exportDocx) - ginServer.Handle("POST", "/api/export/addPDFOutline", model.CheckAuth, addPDFOutline) + ginServer.Handle("POST", "/api/export/processPDF", model.CheckAuth, processPDF) ginServer.Handle("POST", "/api/export/preview", model.CheckAuth, exportPreview) ginServer.Handle("POST", "/api/export/exportAsFile", model.CheckAuth, exportAsFile) ginServer.Handle("POST", "/api/export/exportData", model.CheckAuth, exportData) diff --git a/kernel/go.mod b/kernel/go.mod index 1f107641b..5b5449280 100644 --- a/kernel/go.mod +++ b/kernel/go.mod @@ -7,7 +7,7 @@ require ( github.com/88250/css v0.1.2 github.com/88250/gulu v1.2.3-0.20221117052724-cd06804db798 github.com/88250/lute v1.7.6-0.20230220030205-b0f64d7ba66e - github.com/88250/pdfcpu v0.3.14-0.20230222105639-68297f21b5d2 + github.com/88250/pdfcpu v0.3.14-0.20230223023428-417e2a8897ac github.com/88250/vitess-sqlparser v0.0.0-20210205111146-56a2ded2aba1 github.com/ClarkThan/ahocorasick v0.0.0-20230216061320-bccdb98581a3 github.com/ConradIrwin/font v0.0.0-20210318200717-ce8d41cc0732 diff --git a/kernel/go.sum b/kernel/go.sum index 0fd87b5cc..431469ace 100644 --- a/kernel/go.sum +++ b/kernel/go.sum @@ -10,8 +10,8 @@ github.com/88250/gulu v1.2.3-0.20221117052724-cd06804db798 h1:sR/s/Y9wyl79ZRCUER github.com/88250/gulu v1.2.3-0.20221117052724-cd06804db798/go.mod h1:I1qBzsksFL2ciGSuqDE7R3XW4BUMrfDgOvSXEk7FsAI= github.com/88250/lute v1.7.6-0.20230220030205-b0f64d7ba66e h1:7UgFzsksh+z6IX2z+BKG3tt1TU7LJNb0zOHDbhLEaUc= github.com/88250/lute v1.7.6-0.20230220030205-b0f64d7ba66e/go.mod h1:cEoBGi0zArPqAsp0MdG9SKinvH/xxZZWXU7sRx8vHSA= -github.com/88250/pdfcpu v0.3.14-0.20230222105639-68297f21b5d2 h1:M1JxCmcaLwI7qlQJD5UatAxaIT6tfLvq3GptOsMffn4= -github.com/88250/pdfcpu v0.3.14-0.20230222105639-68297f21b5d2/go.mod h1:S5YT38L/GCjVjmB4PB84PymA1qfopjEhfhTNQilLpv4= +github.com/88250/pdfcpu v0.3.14-0.20230223023428-417e2a8897ac h1:deLsfAbzg+KJy53yJDGNe/+9RZr6RR813rbMKOiW/uI= +github.com/88250/pdfcpu v0.3.14-0.20230223023428-417e2a8897ac/go.mod h1:S5YT38L/GCjVjmB4PB84PymA1qfopjEhfhTNQilLpv4= github.com/88250/vitess-sqlparser v0.0.0-20210205111146-56a2ded2aba1 h1:48T899JQDwyyRu9yXHePYlPdHtpJfrJEUGBMH3SMBWY= github.com/88250/vitess-sqlparser v0.0.0-20210205111146-56a2ded2aba1/go.mod h1:U3pckKQIgxxkmZjV5yXQjHdGxQK0o/vEZeZ6cQsxfHw= github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= diff --git a/kernel/model/export.go b/kernel/model/export.go index f0bc3bd61..6fd1132b2 100644 --- a/kernel/model/export.go +++ b/kernel/model/export.go @@ -654,7 +654,7 @@ func processIFrame(tree *parse.Tree) { } } -func AddPDFOutline(id, p string, merge bool) (err error) { +func ProcessPDF(id, p string, merge bool) (err error) { inFile := p links, err := api.ListToCLinks(inFile) if nil != err { From a5767089164b7abee777b42ed87785c0326732e5 Mon Sep 17 00:00:00 2001 From: Liang Ding Date: Thu, 23 Feb 2023 11:18:05 +0800 Subject: [PATCH 5/7] =?UTF-8?q?:art:=20=E5=AF=BC=E5=87=BA=20PDF=20?= =?UTF-8?q?=E6=97=B6=E6=94=AF=E6=8C=81=E5=B0=86=E8=B5=84=E6=BA=90=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E4=BD=9C=E4=B8=BA=E9=99=84=E4=BB=B6=E5=B5=8C=E5=85=A5?= =?UTF-8?q?=20https://github.com/siyuan-note/siyuan/issues/7414?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/util/onGetConfig.ts | 3 +- kernel/api/export.go | 3 +- kernel/go.mod | 3 +- kernel/go.sum | 2 - kernel/model/export.go | 77 +++++++++++++++++++++++-------------- 5 files changed, 54 insertions(+), 34 deletions(-) diff --git a/app/src/util/onGetConfig.ts b/app/src/util/onGetConfig.ts index e63e06a6f..db7b34fcb 100644 --- a/app/src/util/onGetConfig.ts +++ b/app/src/util/onGetConfig.ts @@ -421,7 +421,8 @@ export const initWindow = () => { fetchPost("/api/export/processPDF", { id: ipcData.rootId, merge: ipcData.mergeSubdocs, - path: pdfFilePath + path: pdfFilePath, + removeAssets: ipcData.removeAssets, }, () => { afterExport(pdfFilePath, msgId); if (ipcData.removeAssets) { diff --git a/kernel/api/export.go b/kernel/api/export.go index e7ccb5845..602fa033f 100644 --- a/kernel/api/export.go +++ b/kernel/api/export.go @@ -326,7 +326,8 @@ func processPDF(c *gin.Context) { if nil != arg["merge"] { merge = arg["merge"].(bool) } - err := model.ProcessPDF(id, path, merge) + removeAssets := arg["removeAssets"].(bool) + err := model.ProcessPDF(id, path, merge, removeAssets) if nil != err { ret.Code = -1 ret.Msg = err.Error() diff --git a/kernel/go.mod b/kernel/go.mod index 5b5449280..9da6b4af7 100644 --- a/kernel/go.mod +++ b/kernel/go.mod @@ -141,6 +141,7 @@ replace github.com/mattn/go-sqlite3 => github.com/88250/go-sqlite3 v1.14.13-0.20 //replace github.com/siyuan-note/httpclient => D:\88250\httpclient //replace github.com/siyuan-note/filelock => D:\88250\filelock //replace github.com/88250/lute => D:\gogogo\src\github.com\88250\lute -//replace github.com/88250/pdfcpu => D:\88250\pdfcpu +replace github.com/88250/pdfcpu => D:\88250\pdfcpu + //replace github.com/88250/gulu => D:\88250\gulu //replace github.com/mattn/go-sqlite3 => D:\88250\go-sqlite3 diff --git a/kernel/go.sum b/kernel/go.sum index 431469ace..be1d02102 100644 --- a/kernel/go.sum +++ b/kernel/go.sum @@ -10,8 +10,6 @@ github.com/88250/gulu v1.2.3-0.20221117052724-cd06804db798 h1:sR/s/Y9wyl79ZRCUER github.com/88250/gulu v1.2.3-0.20221117052724-cd06804db798/go.mod h1:I1qBzsksFL2ciGSuqDE7R3XW4BUMrfDgOvSXEk7FsAI= github.com/88250/lute v1.7.6-0.20230220030205-b0f64d7ba66e h1:7UgFzsksh+z6IX2z+BKG3tt1TU7LJNb0zOHDbhLEaUc= github.com/88250/lute v1.7.6-0.20230220030205-b0f64d7ba66e/go.mod h1:cEoBGi0zArPqAsp0MdG9SKinvH/xxZZWXU7sRx8vHSA= -github.com/88250/pdfcpu v0.3.14-0.20230223023428-417e2a8897ac h1:deLsfAbzg+KJy53yJDGNe/+9RZr6RR813rbMKOiW/uI= -github.com/88250/pdfcpu v0.3.14-0.20230223023428-417e2a8897ac/go.mod h1:S5YT38L/GCjVjmB4PB84PymA1qfopjEhfhTNQilLpv4= github.com/88250/vitess-sqlparser v0.0.0-20210205111146-56a2ded2aba1 h1:48T899JQDwyyRu9yXHePYlPdHtpJfrJEUGBMH3SMBWY= github.com/88250/vitess-sqlparser v0.0.0-20210205111146-56a2ded2aba1/go.mod h1:U3pckKQIgxxkmZjV5yXQjHdGxQK0o/vEZeZ6cQsxfHw= github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= diff --git a/kernel/model/export.go b/kernel/model/export.go index 6fd1132b2..73aafa7ea 100644 --- a/kernel/model/export.go +++ b/kernel/model/export.go @@ -654,7 +654,7 @@ func processIFrame(tree *parse.Tree) { } } -func ProcessPDF(id, p string, merge bool) (err error) { +func ProcessPDF(id, p string, merge, removeAssets bool) (err error) { inFile := p links, err := api.ListToCLinks(inFile) if nil != err { @@ -665,8 +665,6 @@ func ProcessPDF(id, p string, merge bool) (err error) { return links[i].Page < links[j].Page }) - pdfcpu.VersionStr = "SiYuan v" + util.Ver - bms := map[string]*pdfcpu.Bookmark{} for _, link := range links { linkID := link.URI[strings.LastIndex(link.URI, "/")+1:] @@ -774,38 +772,51 @@ func ProcessPDF(id, p string, merge bool) (err error) { } } - if 0 < len(assetAbsPaths) { - //outFile := inFile + ".tmp" - //err = api.AddAttachmentsFile(inFile, outFile, assetAbsPaths, false, nil) - //if nil != err { - // logging.LogErrorf("add attachment failed: %s", err) - // return - //} - // - //err = os.Rename(outFile, inFile) - //if nil != err { - // return - //} + pdfCtx, ctxErr := api.ReadContextFile(inFile) + if nil != ctxErr { + logging.LogErrorf("read pdf context failed: %s", ctxErr) + return + } - assetLinks, listErr := api.ListAssetLinks(inFile) + if 0 < len(assetAbsPaths) { + assetLinks, otherLinks, listErr := api.ListLinks(inFile) if nil != listErr { logging.LogErrorf("list asset links failed: %s", listErr) return } - pdfCtx, ctxErr := api.ReadContextFile(inFile) - if nil != ctxErr { - logging.LogErrorf("read pdf context failed: %s", ctxErr) - return + if _, removeErr := pdfCtx.RemoveAnnotations(nil, nil, nil, false); nil != removeErr { + logging.LogWarnf("remove annotations failed: %s", removeErr) } - linkMap := map[int][]*pdfcpu.IndirectRef{} - pdfCtx.RemoveAnnotations(nil, nil, nil, false) + linkMap := map[int][]pdfcpu.AnnotationRenderer{} + for _, link := range otherLinks { + if 1 > len(linkMap[link.Page]) { + linkMap[link.Page] = []pdfcpu.AnnotationRenderer{link} + } else { + linkMap[link.Page] = append(linkMap[link.Page], link) + } + } + + attachementMap := map[int][]*pdfcpu.IndirectRef{} now := pdfcpu.StringLiteral(pdfcpu.DateString(time.Now())) for _, link := range assetLinks { link.URI = strings.ReplaceAll(link.URI, "http://127.0.0.1:6806/export/temp/", "") link.URI, _ = url.PathUnescape(link.URI) + if !removeAssets { + // 不移除资源文件夹的话将超链接指向资源文件夹 + if 1 > len(linkMap[link.Page]) { + linkMap[link.Page] = []pdfcpu.AnnotationRenderer{link} + } else { + linkMap[link.Page] = append(linkMap[link.Page], link) + } + + continue + } + + // 移除资源文件夹的话使用内嵌附件 + absPath, getErr := GetAssetAbsPath(link.URI) if nil != getErr { continue @@ -873,13 +884,20 @@ func ProcessPDF(id, p string, merge bool) (err error) { } if 1 > len(linkMap[link.Page]) { - linkMap[link.Page] = []*pdfcpu.IndirectRef{ann} + attachementMap[link.Page] = []*pdfcpu.IndirectRef{ann} } else { - linkMap[link.Page] = append(linkMap[link.Page], ann) + attachementMap[link.Page] = append(attachementMap[link.Page], ann) } } - for page, anns := range linkMap { + if 0 < len(linkMap) { + if _, addErr := pdfCtx.AddAnnotationsMap(linkMap, false); nil != addErr { + logging.LogErrorf("add annotations map failed: %s", addErr) + } + } + + // 添加附件注解指向内嵌的附件 + for page, anns := range attachementMap { pageDictIndRef, pageErr := pdfCtx.PageDictIndRef(page) if nil != pageErr { logging.LogWarnf("page dict ind ref failed: %s", pageErr) @@ -926,11 +944,12 @@ func ProcessPDF(id, p string, merge bool) (err error) { entry.Object = append(annots, array...) pdfCtx.EnsureVersionForWriting() } + } - if writeErr := api.WriteContextFile(pdfCtx, inFile); nil != writeErr { - logging.LogErrorf("write pdf context failed: %s", writeErr) - return - } + pdfcpu.VersionStr = "SiYuan v" + util.Ver + if writeErr := api.WriteContextFile(pdfCtx, inFile); nil != writeErr { + logging.LogErrorf("write pdf context failed: %s", writeErr) + return } return From c07a58131f9e4293e643132b09c56dc12f816dca Mon Sep 17 00:00:00 2001 From: Liang Ding Date: Thu, 23 Feb 2023 12:41:50 +0800 Subject: [PATCH 6/7] =?UTF-8?q?:art:=20=E5=AF=BC=E5=87=BA=20PDF=20?= =?UTF-8?q?=E6=97=B6=E6=94=AF=E6=8C=81=E5=B0=86=E8=B5=84=E6=BA=90=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E4=BD=9C=E4=B8=BA=E9=99=84=E4=BB=B6=E5=B5=8C=E5=85=A5?= =?UTF-8?q?=20https://github.com/siyuan-note/siyuan/issues/7414?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- kernel/go.mod | 5 ++--- kernel/go.sum | 2 ++ kernel/model/export.go | 11 ++++++----- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/kernel/go.mod b/kernel/go.mod index 9da6b4af7..f52c69d5b 100644 --- a/kernel/go.mod +++ b/kernel/go.mod @@ -7,7 +7,7 @@ require ( github.com/88250/css v0.1.2 github.com/88250/gulu v1.2.3-0.20221117052724-cd06804db798 github.com/88250/lute v1.7.6-0.20230220030205-b0f64d7ba66e - github.com/88250/pdfcpu v0.3.14-0.20230223023428-417e2a8897ac + github.com/88250/pdfcpu v0.3.14-0.20230223031826-d2ae187e1c38 github.com/88250/vitess-sqlparser v0.0.0-20210205111146-56a2ded2aba1 github.com/ClarkThan/ahocorasick v0.0.0-20230216061320-bccdb98581a3 github.com/ConradIrwin/font v0.0.0-20210318200717-ce8d41cc0732 @@ -141,7 +141,6 @@ replace github.com/mattn/go-sqlite3 => github.com/88250/go-sqlite3 v1.14.13-0.20 //replace github.com/siyuan-note/httpclient => D:\88250\httpclient //replace github.com/siyuan-note/filelock => D:\88250\filelock //replace github.com/88250/lute => D:\gogogo\src\github.com\88250\lute -replace github.com/88250/pdfcpu => D:\88250\pdfcpu - +//replace github.com/88250/pdfcpu => D:\88250\pdfcpu //replace github.com/88250/gulu => D:\88250\gulu //replace github.com/mattn/go-sqlite3 => D:\88250\go-sqlite3 diff --git a/kernel/go.sum b/kernel/go.sum index be1d02102..cfc52a2ba 100644 --- a/kernel/go.sum +++ b/kernel/go.sum @@ -10,6 +10,8 @@ github.com/88250/gulu v1.2.3-0.20221117052724-cd06804db798 h1:sR/s/Y9wyl79ZRCUER github.com/88250/gulu v1.2.3-0.20221117052724-cd06804db798/go.mod h1:I1qBzsksFL2ciGSuqDE7R3XW4BUMrfDgOvSXEk7FsAI= github.com/88250/lute v1.7.6-0.20230220030205-b0f64d7ba66e h1:7UgFzsksh+z6IX2z+BKG3tt1TU7LJNb0zOHDbhLEaUc= github.com/88250/lute v1.7.6-0.20230220030205-b0f64d7ba66e/go.mod h1:cEoBGi0zArPqAsp0MdG9SKinvH/xxZZWXU7sRx8vHSA= +github.com/88250/pdfcpu v0.3.14-0.20230223031826-d2ae187e1c38 h1:MaFRabDTXOpLBrdP4qkZnjFBIUTu/rk8S6fu7hC6jCY= +github.com/88250/pdfcpu v0.3.14-0.20230223031826-d2ae187e1c38/go.mod h1:S5YT38L/GCjVjmB4PB84PymA1qfopjEhfhTNQilLpv4= github.com/88250/vitess-sqlparser v0.0.0-20210205111146-56a2ded2aba1 h1:48T899JQDwyyRu9yXHePYlPdHtpJfrJEUGBMH3SMBWY= github.com/88250/vitess-sqlparser v0.0.0-20210205111146-56a2ded2aba1/go.mod h1:U3pckKQIgxxkmZjV5yXQjHdGxQK0o/vEZeZ6cQsxfHw= github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= diff --git a/kernel/model/export.go b/kernel/model/export.go index 73aafa7ea..b1a14c1c9 100644 --- a/kernel/model/export.go +++ b/kernel/model/export.go @@ -791,6 +791,7 @@ func ProcessPDF(id, p string, merge, removeAssets bool) (err error) { linkMap := map[int][]pdfcpu.AnnotationRenderer{} for _, link := range otherLinks { + link.URI, _ = url.PathUnescape(link.URI) if 1 > len(linkMap[link.Page]) { linkMap[link.Page] = []pdfcpu.AnnotationRenderer{link} } else { @@ -798,7 +799,7 @@ func ProcessPDF(id, p string, merge, removeAssets bool) (err error) { } } - attachementMap := map[int][]*pdfcpu.IndirectRef{} + attachmentMap := map[int][]*pdfcpu.IndirectRef{} now := pdfcpu.StringLiteral(pdfcpu.DateString(time.Now())) for _, link := range assetLinks { link.URI = strings.ReplaceAll(link.URI, "http://127.0.0.1:6806/export/temp/", "") @@ -883,10 +884,10 @@ func ProcessPDF(id, p string, merge, removeAssets bool) (err error) { continue } - if 1 > len(linkMap[link.Page]) { - attachementMap[link.Page] = []*pdfcpu.IndirectRef{ann} + if 1 > len(attachmentMap[link.Page]) { + attachmentMap[link.Page] = []*pdfcpu.IndirectRef{ann} } else { - attachementMap[link.Page] = append(attachementMap[link.Page], ann) + attachmentMap[link.Page] = append(attachmentMap[link.Page], ann) } } @@ -897,7 +898,7 @@ func ProcessPDF(id, p string, merge, removeAssets bool) (err error) { } // 添加附件注解指向内嵌的附件 - for page, anns := range attachementMap { + for page, anns := range attachmentMap { pageDictIndRef, pageErr := pdfCtx.PageDictIndRef(page) if nil != pageErr { logging.LogWarnf("page dict ind ref failed: %s", pageErr) From 15f989f5277e89c15225c5608a48aff8245ab71a Mon Sep 17 00:00:00 2001 From: Liang Ding Date: Thu, 23 Feb 2023 12:50:23 +0800 Subject: [PATCH 7/7] =?UTF-8?q?:art:=20=E5=AF=BC=E5=87=BA=20PDF=20?= =?UTF-8?q?=E6=97=B6=E6=94=AF=E6=8C=81=E5=B0=86=E8=B5=84=E6=BA=90=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E4=BD=9C=E4=B8=BA=E9=99=84=E4=BB=B6=E5=B5=8C=E5=85=A5?= =?UTF-8?q?=20https://github.com/siyuan-note/siyuan/issues/7414?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/appearance/langs/en_US.json | 5 +++-- app/appearance/langs/es_ES.json | 5 +++-- app/appearance/langs/fr_FR.json | 5 +++-- app/appearance/langs/zh_CHT.json | 5 +++-- app/appearance/langs/zh_CN.json | 5 +++-- app/src/protyle/export/index.ts | 8 ++++---- 6 files changed, 19 insertions(+), 14 deletions(-) diff --git a/app/appearance/langs/en_US.json b/app/appearance/langs/en_US.json index 62500b459..887d2eec5 100644 --- a/app/appearance/langs/en_US.json +++ b/app/appearance/langs/en_US.json @@ -199,9 +199,10 @@ "exportPDF1": "Landscape page", "exportPDF2": "Page margins", "exportPDF3": "Page Scale", - "exportPDF4": "Remove assets directory", + "exportPDF4": "Embed assets", "exportPDF5": "Keep folded", - "exportPDF6": "Merge subdocuments", + "mergeSubdocs": "Merge subdocuments", + "removeAssetsFolder": "Remove assets directory", "upload": "Upload", "reminderTip": "The reminder time cannot be less than the current time", "wechatTip": "The content block will be sent to the cloud in clear text, and pushed through the WeChat MP template message when it expires", diff --git a/app/appearance/langs/es_ES.json b/app/appearance/langs/es_ES.json index ba8eba908..a99a523d4 100644 --- a/app/appearance/langs/es_ES.json +++ b/app/appearance/langs/es_ES.json @@ -199,9 +199,10 @@ "exportPDF1": "Página apaisada", "exportPDF2": "Márgenes de la página", "exportPDF3": "Escala de la página", - "exportPDF4": "Eliminar directorio de activos", + "exportPDF4": "Activos incrustados", "exportPDF5": "Mantener doblado", - "exportPDF6": "Fusionar subdocumentos", + "mergeSubdocs": "Fusionar subdocumentos", + "removeAssetsFolder": "Eliminar directorio de activos", "upload": "Subir", "reminderTip": "La hora del recordatorio no puede ser inferior a la hora actual", "wechatTip": "El bloque de contenido se enviará a la nube en texto claro, y se empujará a través del mensaje de plantilla de WeChat MP cuando caduque", diff --git a/app/appearance/langs/fr_FR.json b/app/appearance/langs/fr_FR.json index 9ecc80ca4..d684b5c9e 100644 --- a/app/appearance/langs/fr_FR.json +++ b/app/appearance/langs/fr_FR.json @@ -199,9 +199,10 @@ "exportPDF1": "Page paysage", "exportPDF2": "Marges de page", "exportPDF3": "Échelle de page", - "exportPDF4": "Supprimer le répertoire des actifs", + "exportPDF4": "Incorporer des ressources", "exportPDF5": "Garder plié", - "exportPDF6": "Fusionner les sous-documents", + "mergeSubdocs": "Fusionner les sous-documents", + "removeAssetsFolder": "Supprimer le répertoire des actifs", "upload": "Télécharger", "reminderTip": "The reminder time cannot be less than the current time", "wechatTip": "Le bloc de contenu sera envoyé au cloud en texte clair et transmis au message du modèle de compte officiel WeChat à son expiration.", diff --git a/app/appearance/langs/zh_CHT.json b/app/appearance/langs/zh_CHT.json index 598868c1b..bcff17a8d 100644 --- a/app/appearance/langs/zh_CHT.json +++ b/app/appearance/langs/zh_CHT.json @@ -199,9 +199,10 @@ "exportPDF1": "橫向頁面", "exportPDF2": "頁面邊距", "exportPDF3": "頁面縮放", - "exportPDF4": "移除 assets 目錄", + "exportPDF4": "嵌入資源文件", "exportPDF5": "保持折疊狀態", - "exportPDF6": "合併子文檔", + "mergeSubdocs": "合併子文檔", + "removeAssetsFolder": "移除 assets 目錄", "upload": "上傳", "reminderTip": "提醒時間不能小於當前時間", "wechatTip": "該內容塊將以明文形式發送到雲端,到期時通過微信公眾號模板消息進行推送", diff --git a/app/appearance/langs/zh_CN.json b/app/appearance/langs/zh_CN.json index 5202f15a6..c166b2ee0 100644 --- a/app/appearance/langs/zh_CN.json +++ b/app/appearance/langs/zh_CN.json @@ -199,9 +199,10 @@ "exportPDF1": "横向页面", "exportPDF2": "页面边距", "exportPDF3": "页面缩放", - "exportPDF4": "移除 assets 目录", + "exportPDF4": "嵌入资源文件", "exportPDF5": "保持折叠状态", - "exportPDF6": "合并子文档", + "mergeSubdocs": "合并子文档", + "removeAssetsFolder": "移除 assets 目录", "upload": "上传", "reminderTip": "提醒时间不能小于当前时间", "wechatTip": "该内容块将以明文形式发送到云端,到期时通过微信公众号模板消息进行推送", diff --git a/app/src/protyle/export/index.ts b/app/src/protyle/export/index.ts index e92cf3c1d..1bba90468 100644 --- a/app/src/protyle/export/index.ts +++ b/app/src/protyle/export/index.ts @@ -1,7 +1,7 @@ import {hideMessage, showMessage} from "../../dialog/message"; import {Constants} from "../../constants"; /// #if !BROWSER -import {OpenDialogReturnValue, ipcRenderer} from "electron"; +import {ipcRenderer, OpenDialogReturnValue} from "electron"; import {app, BrowserWindow, dialog, getCurrentWindow} from "@electron/remote"; import * as fs from "fs"; import * as path from "path"; @@ -33,14 +33,14 @@ export const saveExport = (option: { type: string, id: string }) => { content: `