Просмотр исходного кода

Hide editor chrome from Docs PDF export

Skip .of-noprint elements (e.g. the TOC "Update table" tab) and their text runs when exporting Docs to PDF, and hide .doc-toc-frame via CSS while exporting.

Also refine zh-TW/zh-CN PDF Editor strings: "手形" becomes "抓取" and the image source prompt is reworded.
Toby Chui 3 недель назад
Родитель
Сommit
515ef8b16f

+ 1 - 0
src/web/Office/docs/docs.css

@@ -967,3 +967,4 @@ body.doc-exporting #editor span.doc-cmt { background: none; border-bottom: 0; }
 body.doc-exporting #editor ins.doc-ins { color: inherit; text-decoration: inherit; background: none; }
 body.doc-exporting #editor del.doc-del { display: none; }
 body.doc-exporting .doc-hf-lead:empty::before { content: none; }
+body.doc-exporting .doc-toc-frame { display: none !important; }

+ 7 - 3
src/web/Office/docs/docs_pdf.js

@@ -41,8 +41,10 @@ var DocsPdf = (function () {
     var parseFill = C.parseFill, parseColor = C.parseColor;
     var PT = 96 / 72;
 
-    // subtrees that are editor chrome, not page content
-    var SKIP_SELECTOR = "#pageSheets, .doc-fn-measure, .of-img-handle, .doc-autobreak, .doc-toc-frame";
+    // subtrees that are editor chrome, not page content (.of-noprint is the
+    // suite's mark for chrome placed inside the page, such as the table of
+    // contents' "Update table" tab)
+    var SKIP_SELECTOR = "#pageSheets, .doc-fn-measure, .of-img-handle, .doc-autobreak, .doc-toc-frame, .of-noprint";
 
     function skipped(el) {
         return !!(el && el.closest && el.closest(SKIP_SELECTOR));
@@ -193,8 +195,10 @@ var DocsPdf = (function () {
 
         // text, as line fragments at their baselines
         var origin = { left: frame.left, top: frame.top, x: 0, y: 0 };
-        // spaces stay only for the highlight they carry
+        // spaces stay only for the highlight they carry; the text of editor
+        // chrome is left out like its boxes are
         var runs = C.collectRuns(o.pageEl, origin).filter(function (run) {
+            if (skipped(run.node.parentElement)) return false;
             return C.visibleText(run.text).trim() !== "" || !!C.parseFill(run.background);
         });
         runs.forEach(function (run) {

+ 9 - 9
src/web/PDF Editor/locale/pdfeditor.json

@@ -232,7 +232,7 @@
                 "img/newName": "圖片",
                 "img/title": "插入圖片",
                 "img/toPdfTitle": "圖片轉 PDF",
-                "img/where": "圖片在哪裡?",
+                "img/where": "請選擇圖片來源",
                 "kb/arrows": "方向鍵(Shift:10 點)",
                 "kb/copy": "複製、剪下、貼上、再製",
                 "kb/dbl": "按兩下",
@@ -242,7 +242,7 @@
                 "kb/find": "尋找",
                 "kb/firstLast": "第一頁/最後一頁",
                 "kb/fit": "符合寬度",
-                "kb/hand": "手形/選取/編輯 PDF",
+                "kb/hand": "抓取/選取/編輯 PDF",
                 "kb/nudge": "移動選取項目",
                 "kb/open": "開啟",
                 "kb/pages": "上一頁/下一頁",
@@ -387,7 +387,7 @@
                 "rb/fromimages": "從圖片",
                 "rb/frompdf": "從 PDF",
                 "rb/front": "移到最上層",
-                "rb/hand": "手形",
+                "rb/hand": "抓取",
                 "rb/headerfooter": "頁首與頁尾",
                 "rb/highlight": "螢光標記",
                 "rb/image": "圖片",
@@ -783,7 +783,7 @@
                 "img/newName": "圖片",
                 "img/title": "插入圖片",
                 "img/toPdfTitle": "圖片轉 PDF",
-                "img/where": "圖片在哪裡?",
+                "img/where": "請選擇圖片來源",
                 "kb/arrows": "方向鍵(Shift:10 點)",
                 "kb/copy": "複製、剪下、貼上、再製",
                 "kb/dbl": "按兩下",
@@ -793,7 +793,7 @@
                 "kb/find": "尋找",
                 "kb/firstLast": "第一頁/最後一頁",
                 "kb/fit": "符合寬度",
-                "kb/hand": "手形/選取/編輯 PDF",
+                "kb/hand": "抓取/選取/編輯 PDF",
                 "kb/nudge": "移動選取項目",
                 "kb/open": "開啟",
                 "kb/pages": "上一頁/下一頁",
@@ -938,7 +938,7 @@
                 "rb/fromimages": "從圖片",
                 "rb/frompdf": "從 PDF",
                 "rb/front": "移到最上層",
-                "rb/hand": "手形",
+                "rb/hand": "抓取",
                 "rb/headerfooter": "頁首與頁尾",
                 "rb/highlight": "螢光標記",
                 "rb/image": "圖片",
@@ -1334,7 +1334,7 @@
                 "img/newName": "图片",
                 "img/title": "插入图片",
                 "img/toPdfTitle": "图片转 PDF",
-                "img/where": "图片在哪里?",
+                "img/where": "请选择图片来源",
                 "kb/arrows": "方向键(Shift:10 点)",
                 "kb/copy": "复制、剪切、粘贴、再制",
                 "kb/dbl": "双击",
@@ -1344,7 +1344,7 @@
                 "kb/find": "查找",
                 "kb/firstLast": "第一页/最后一页",
                 "kb/fit": "适合宽度",
-                "kb/hand": "手形/选择/编辑 PDF",
+                "kb/hand": "抓取/选择/编辑 PDF",
                 "kb/nudge": "移动所选项",
                 "kb/open": "打开",
                 "kb/pages": "上一页/下一页",
@@ -1489,7 +1489,7 @@
                 "rb/fromimages": "从图片",
                 "rb/frompdf": "从 PDF",
                 "rb/front": "置于顶层",
-                "rb/hand": "手形",
+                "rb/hand": "抓取",
                 "rb/headerfooter": "页眉和页脚",
                 "rb/highlight": "高亮",
                 "rb/image": "图片",