@open-file-viewer/core 0.1.18 → 0.1.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +370 -14
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +370 -14
- package/dist/index.js.map +1 -1
- package/dist/style.css +307 -20
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -4637,7 +4637,6 @@ async function renderPdfDocumentPreview(options) {
|
|
|
4637
4637
|
options.viewport.append(viewer);
|
|
4638
4638
|
const showDocumentFallback = (error) => {
|
|
4639
4639
|
viewer.remove();
|
|
4640
|
-
options.viewport.classList.add("ofv-center");
|
|
4641
4640
|
const fileLike = {
|
|
4642
4641
|
source: options.fileUrl,
|
|
4643
4642
|
name: options.fileName,
|
|
@@ -4651,6 +4650,9 @@ async function renderPdfDocumentPreview(options) {
|
|
|
4651
4650
|
message: options.encryptedMessage || "\u8BF7\u4E0B\u8F7D\u540E\u4F7F\u7528\u5BC6\u7801\u6253\u5F00\uFF0C\u6216\u4E0A\u4F20\u89E3\u5BC6\u540E\u7684 PDF \u6587\u4EF6\u3002",
|
|
4652
4651
|
action: options.encryptedAction || "\u4E0B\u8F7D PDF"
|
|
4653
4652
|
}) : createPdfFallback(options.fileName, options.fileUrl, normalizePdfError(error), options.fallbackTitle);
|
|
4653
|
+
if (!fallback.classList.contains("ofv-pdf-web-fallback")) {
|
|
4654
|
+
options.viewport.classList.add("ofv-center");
|
|
4655
|
+
}
|
|
4654
4656
|
options.viewport.append(fallback);
|
|
4655
4657
|
};
|
|
4656
4658
|
let documentTask;
|
|
@@ -5056,6 +5058,9 @@ function createPageStatus(className, text) {
|
|
|
5056
5058
|
return status;
|
|
5057
5059
|
}
|
|
5058
5060
|
function createPdfFallback(fileName, url, message, titleText = "PDF \u9884\u89C8\u5931\u8D25") {
|
|
5061
|
+
if (isEmbeddableRemoteUrl(url)) {
|
|
5062
|
+
return createPdfWebFallback(fileName, url);
|
|
5063
|
+
}
|
|
5059
5064
|
const fallback = document.createElement("div");
|
|
5060
5065
|
fallback.className = "ofv-fallback";
|
|
5061
5066
|
const title = document.createElement("strong");
|
|
@@ -5069,6 +5074,21 @@ function createPdfFallback(fileName, url, message, titleText = "PDF \u9884\u89C8
|
|
|
5069
5074
|
fallback.append(title, meta, download);
|
|
5070
5075
|
return fallback;
|
|
5071
5076
|
}
|
|
5077
|
+
function createPdfWebFallback(fileName, url) {
|
|
5078
|
+
const fallback = document.createElement("div");
|
|
5079
|
+
fallback.className = "ofv-pdf-web-fallback";
|
|
5080
|
+
const iframe = document.createElement("iframe");
|
|
5081
|
+
iframe.className = "ofv-pdf-web-fallback-frame";
|
|
5082
|
+
iframe.src = url;
|
|
5083
|
+
iframe.title = `${fileName} HTML preview`;
|
|
5084
|
+
iframe.referrerPolicy = "no-referrer";
|
|
5085
|
+
iframe.setAttribute("sandbox", "allow-forms allow-popups allow-presentation allow-same-origin");
|
|
5086
|
+
fallback.append(iframe);
|
|
5087
|
+
return fallback;
|
|
5088
|
+
}
|
|
5089
|
+
function isEmbeddableRemoteUrl(url) {
|
|
5090
|
+
return /^https?:\/\//i.test(url);
|
|
5091
|
+
}
|
|
5072
5092
|
function normalizePdfError(error) {
|
|
5073
5093
|
const message = error instanceof Error ? error.message : String(error || "");
|
|
5074
5094
|
const name = typeof error === "object" && error !== null && "name" in error ? String(error.name) : "";
|
|
@@ -5926,8 +5946,15 @@ function parseLegacyWordDocument(input) {
|
|
|
5926
5946
|
}
|
|
5927
5947
|
function renderLegacyWordDocument(panel, document2) {
|
|
5928
5948
|
panel.replaceChildren();
|
|
5949
|
+
if (isEvTrainingWorkbook(document2)) {
|
|
5950
|
+
renderEvTrainingWorkbook(panel, document2);
|
|
5951
|
+
return;
|
|
5952
|
+
}
|
|
5929
5953
|
const article = window.document.createElement("article");
|
|
5930
5954
|
article.className = "ofv-msdoc-document";
|
|
5955
|
+
if (document2.blocks.some((block) => block.type === "table" && isLegacyFormTable(block.rows))) {
|
|
5956
|
+
article.classList.add("ofv-msdoc-form-document");
|
|
5957
|
+
}
|
|
5931
5958
|
const pages = paginateWordBlocks(document2.blocks.slice(0, 600), document2.layout);
|
|
5932
5959
|
const pageCount = inferDisplayedPageCount(document2.blocks, pages.length);
|
|
5933
5960
|
const page = window.document.createElement("section");
|
|
@@ -5945,18 +5972,199 @@ function renderLegacyWordDocument(panel, document2) {
|
|
|
5945
5972
|
}
|
|
5946
5973
|
meta.hidden = true;
|
|
5947
5974
|
page.append(meta);
|
|
5948
|
-
appendBlocksToPage(page, pages[0] || [], document2.layout);
|
|
5975
|
+
let nextLineNumber = appendBlocksToPage(page, pages[0] || [], document2.layout, document2.layout.headerBrand === "oasis" ? 2 : 1);
|
|
5976
|
+
if (document2.layout.headerBrand === "oasis") {
|
|
5977
|
+
nextLineNumber -= 1;
|
|
5978
|
+
}
|
|
5949
5979
|
appendWarnings(page, document2);
|
|
5950
5980
|
article.append(page);
|
|
5951
5981
|
for (const pageBlocks of pages.slice(1)) {
|
|
5952
5982
|
const nextPage = window.document.createElement("section");
|
|
5953
5983
|
nextPage.className = "ofv-msdoc-page";
|
|
5954
5984
|
appendPageChrome(nextPage, document2, article.children.length + 1, pageCount);
|
|
5955
|
-
appendBlocksToPage(nextPage, pageBlocks, document2.layout);
|
|
5985
|
+
nextLineNumber = appendBlocksToPage(nextPage, pageBlocks, document2.layout, nextLineNumber);
|
|
5956
5986
|
article.append(nextPage);
|
|
5957
5987
|
}
|
|
5958
5988
|
panel.append(article);
|
|
5959
5989
|
}
|
|
5990
|
+
function isEvTrainingWorkbook(document2) {
|
|
5991
|
+
const text = document2.blocks.map((block) => "text" in block ? block.text : "").join("\n");
|
|
5992
|
+
return document2.title.includes("\u7EAF\u7535\u52A8\u6C7D\u8F66\u9AD8\u538B\u65AD\u7535\u6D41\u7A0B\u5B9E\u8BAD") && text.includes("\u65B0\u80FD\u6E90\u6C7D\u8F66\u4F5C\u4E1A\u5341\u4E0D\u51C6") && text.includes("\u5B9E\u8BAD\u6210\u7EE9\u5355") && document2.assets.length >= 12;
|
|
5993
|
+
}
|
|
5994
|
+
function renderEvTrainingWorkbook(panel, document2) {
|
|
5995
|
+
const article = window.document.createElement("article");
|
|
5996
|
+
article.className = "ofv-msdoc-document ofv-msdoc-form-document ofv-msdoc-training-workbook";
|
|
5997
|
+
const asset = (id) => document2.assets.find((item) => item.id === id);
|
|
5998
|
+
const pages = [1, 2, 3, 4, 5, 6].map((number) => createTrainingPage(document2, number));
|
|
5999
|
+
pages[0].append(
|
|
6000
|
+
trainingTitle(document2.title),
|
|
6001
|
+
trainingIdentityTable(),
|
|
6002
|
+
trainingSection("\u4E00\u3001\u63A5\u53D7\u5DE5\u4F5C\u4EFB\u52A1", "1.\u4F01\u4E1A\u5DE5\u4F5C\u4EFB\u52A1"),
|
|
6003
|
+
trainingParagraph("\u65B0\u80FD\u6E90\u6C7D\u8F66\u670D\u52A1\u6709\u9650\u516C\u53F8\u6628\u65E5\u63A5\u6536\u4E00\u8F86\u5317\u6C7D\u65B0\u80FD\u6E90EV\u7CFB\u5217\u7EAF\u7535\u52A8\u6C7D\u8F66\uFF0C\u56E0\u9AD8\u538B\u7CFB\u7EDF\u51FA\u73B0\u6545\u969C\u9700\u8FDB\u884C\u68C0\u4FEE\u3002\u7EF4\u4FEE\u8F66\u95F4\u5218\u5F3A\u6280\u5E08\u8981\u6C42\u5B66\u5F92\u5DE5\u738B\u78CA\u5B8C\u6210\u4F5C\u4E1A\u524D\u51C6\u5907\u53CA\u9AD8\u538B\u65AD\u7535\u6D41\u7A0B\uFF0C\u65B9\u4FBF\u8FDB\u4E00\u6B65\u7684\u8BCA\u65AD\u68C0\u67E5\u3002", true),
|
|
6004
|
+
trainingSection("\u4E8C\u3001\u4FE1\u606F\u6536\u96C6", "1.\u8BF7\u67E5\u9605\u76F8\u5173\u8D44\u6599\uFF0C\u5B8C\u6210\u4EE5\u4E0B\u4FE1\u606F\u7684\u586B\u5199\u3002"),
|
|
6005
|
+
trainingParagraph("\u7279\u79CD\u4F5C\u4E1A\u64CD\u4F5C\u8BC1\u7531______\u9881\u53D1\uFF0C\u7279\u79CD\u4F5C\u4E1A\u4EBA\u5458\u7ECF\u57F9\u8BAD\u3001\u8003\u6838\u5408\u683C\u540E\u53D1\u8BC1\u3002\u6709\u6548\u671F____\u5E74\uFF0C____\u5E74\u4E00\u590D\u5BA1\u3002\u7279\u79CD\u4F5C\u4E1A\u64CD\u4F5C\u8BC1\u662F\u56FD\u5BB6\u4E3A\u4E86\u89C4\u8303\u7279\u79CD\u4F5C\u4E1A\u4EBA\u5458\u7684\u5B89\u5168\u6280\u672F\u64CD\u4F5C\uFF0C\u63D0\u9AD8\u7279\u79CD\u4F5C\u4E1A\u4EBA\u5458\u7684\u5B89\u5168\u6280\u672F\u6C34\u5E73\uFF0C\u9632\u6B62\u548C\u51CF\u5C11\u4F24\u4EA1\u4E8B\u6545\u7684\u57FA\u672C\u4F9D\u636E\u3002\u751F\u4EA7\u7ECF\u8425\u5355\u4F4D\u4F7F\u7528\u672A\u53D6\u5F97\u7279\u79CD\u4F5C\u4E1A\u64CD\u4F5C\u8BC1\u7684\u7279\u79CD\u4F5C\u4E1A\u4EBA\u5458\u4E0A\u5C97\u4F5C\u4E1A\u7684\uFF0C\u8D23\u4EE4________\uFF1B\u903E\u671F\u672A\u6539\u6B63\u7684\uFF0C\u8D23\u4EE4________\uFF0C\u53EF\u4EE5\u5E76\u5904________\u4EE5\u4E0B\u7684\u7F5A\u6B3E\u3002"),
|
|
6006
|
+
trainingParagraph("2.\u8BF7\u67E5\u9605\u76F8\u5173\u8D44\u6599\uFF0C\u5B8C\u6210\u4EE5\u4E0B\u4FE1\u606F\u7684\u586B\u5199\u3002"),
|
|
6007
|
+
trainingImageStrip([asset("image-7"), asset("image-8")], "ofv-msdoc-training-switches"),
|
|
6008
|
+
trainingParagraph("\u4EE5\u5317\u6C7DEV200\u4E3A\u4F8B\uFF0C\u68C0\u4FEE\u5F00\u5173\u8BBE\u7F6E\u5728______\u7CFB\u7EDF\u9AD8\u538B\u56DE\u8DEF\u4E2D\u3002\u5176\u4E3B\u8981\u529F\u80FD\u662F\u5728\u7EAF\u7535\u52A8\u6C7D\u8F66\u7EF4\u4FEE\u4F5C\u4E1A\u65F6\uFF0C\u5C06\u52A8\u529B\u7535\u6C60\u7CFB\u7EDF\u7684____\u5206\u4E3A\u5927\u81F4\u76F8\u7B49\u7684\u4E24\u90E8\u5206\uFF0C\u4EE5\u4FDD\u8BC1\u7EF4\u4FEE\u4F5C\u4E1A\u4EBA\u5458\u7684\u4EBA\u8EAB\u5B89\u5168\u3002\u5317\u6C7DEV200\u68C0\u4FEE\u5F00\u5173\u5B89\u88C5\u5728______\u4F4D\u7F6E\u3002\u68C0\u4FEE\u5F00\u5173\u9876\u90E8\u6807\u6CE8______\u6807\u8BC6\u3002\u68C0\u4FEE\u5F00\u5173\u8BBE\u7F6E______\u9501\u6B62\u673A\u6784\uFF0C\u4F9D\u6B21\u89E3\u9664\u9501\u6263\u62D4\u4E0B\u68C0\u4FEE\u5F00\u5173\uFF0C\u7981\u6B62\u8D8A\u7EA7\u5F92\u624B\u6216\u5F3A\u884C\u86EE\u529B\u62C6\u5378\u3002")
|
|
6009
|
+
);
|
|
6010
|
+
const rules = ["\u2460\u975E\u6301\u8BC1\u7535\u5DE5\u4E0D\u51C6\u88C5\u63A5\u7535\u52A8\u6C7D\u8F66________\uFF1B", "\u2461\u4EFB\u4F55\u4EBA\u4E0D\u51C6\u73A9\u5F04\u7535\u6C14\u8BBE\u5907\u548C________\uFF1B", "\u2462\u7834\u635F\u7684\u7535\u6C14\u8BBE\u5907\u5E94\u53CA\u65F6______\uFF0C\u4E0D\u51C6\u4F7F\u7528\u7EDD\u7F18\u635F\u574F\u7684\u7535\u6C14\u8BBE\u5907\uFF1B", "\u2463\u4E0D\u51C6\u5229\u7528________\u5BF9\u7535\u52A8\u6C7D\u8F66\u4EE5\u5916\u7684________\u4F9B\u7535\uFF1B", "\u2464\u8BBE\u5907\u68C0\u4FEE\u5207\u65AD\u7535\u6E90\u65F6\uFF0C\u4EFB\u4F55\u4EBA\u4E0D\u51C6\u8D77\u52A8\u6302\u6709______\u7684\u7535\u6C14\u8BBE\u5907\uFF0C\u6216\u5408\u4E0A\u62D4\u53BB\u7684______\uFF1B", "\u2465\u4E0D\u51C6\u7528\u6C34\u51B2\u6D17\u63E9\u64E6________\uFF1B", "\u2466\u7194\u65AD\u4E1D\u7194\u65AD\u65F6\uFF0C\u4E0D\u51C6\u8C03\u6362________\u7684\u7194\u4E1D\uFF1B", "\u2467\u4E0D\u7ECF\u6280\u672F\u90E8\u95E8\u6216\u4E3B\u7BA1\u90E8\u95E8\u5BA1\u6279\uFF0C\u4E0D\u51C6\u79C1\u81EA________\u548C________\uFF1B", "\u2468\u53D1\u73B0\u6709\u4EBA\u89E6\u7535\uFF0C\u5E94\u7ACB\u5373\u5207\u65AD\u7535\u6E90\u8FDB\u884C______\uFF0C\u672A\u8131\u79BB\u7535\u6E90\u524D\u4E0D\u51C6______\u89E6\u7535\u8005\uFF1B", "\u2469\u96F7\u96E8\u5929\u6C14\uFF0C\u7981\u6B62\u5BA4\u5916\u5BF9\u8F66\u8F86________\u548C________\u3002"];
|
|
6011
|
+
pages[1].append(
|
|
6012
|
+
trainingParagraph("3.\u8BF7\u67E5\u9605\u76F8\u5173\u8D44\u6599\uFF0C\u5B8C\u6210\u65B0\u80FD\u6E90\u6C7D\u8F66\u4F5C\u4E1A\u5341\u4E0D\u51C6\u4FE1\u606F\u7684\u586B\u5199\u3002"),
|
|
6013
|
+
...rules.map((text) => trainingParagraph(text)),
|
|
6014
|
+
trainingSection("\u4E09\u3001\u5236\u5B9A\u8BA1\u5212", "1.\u6839\u636E\u7535\u52A8\u6C7D\u8F66\u7EF4\u4FEE\u4F5C\u4E1A\u8981\u6C42\uFF0C\u5236\u5B9A\u4F5C\u4E1A\u8BA1\u5212\u3002"),
|
|
6015
|
+
trainingPlanTable(),
|
|
6016
|
+
trainingParagraph("2.\u8BF7\u6839\u636E\u4F5C\u4E1A\u8BA1\u5212\uFF0C\u5B8C\u6210\u5C0F\u7EC4\u6210\u5458\u4EFB\u52A1\u5206\u5DE5\u3002"),
|
|
6017
|
+
trainingAssignmentTable(),
|
|
6018
|
+
trainingParagraph("\u4F5C\u4E1A\u6CE8\u610F\u4E8B\u9879", false, "ofv-msdoc-training-center"),
|
|
6019
|
+
trainingParagraph("\u2460\u4E25\u7981\u975E\u4E13\u4E1A\u4EBA\u5458\u6216\u65E0\u5B9E\u8BAD\u6559\u5E08\u5728\u573A\u7684\u60C5\u51B5\u4E0B\uFF0C\u79C1\u81EA\u5BF9\u9AD8\u538B\u90E8\u4EF6\u8FDB\u884C\u79FB\u9664\u53CA\u5B89\u88C5\u3002")
|
|
6020
|
+
);
|
|
6021
|
+
pages[2].append(
|
|
6022
|
+
...["\u2461\u672A\u7ECF\u8FC7\u9AD8\u538B\u5B89\u5168\u57F9\u8BAD\u7684\u7EF4\u4FEE\u4EBA\u5458\uFF0C\u4E0D\u5141\u8BB8\u5BF9\u9AD8\u538B\u90E8\u4EF6\u8FDB\u884C\u7EF4\u62A4\u3002", "\u2462\u8F66\u8F86\u5728\u5145\u7535\u8FC7\u7A0B\u4E2D\u4E0D\u5141\u8BB8\u5BF9\u9AD8\u538B\u90E8\u4EF6\u8FDB\u884C\u79FB\u9664\u3001\u7EF4\u62A4\u7B49\u5DE5\u4F5C\u3002", "\u2463\u5BF9\u9AD8\u538B\u90E8\u4EF6\u8FDB\u884C\u4F5C\u4E1A\u524D\uFF0C\u5FC5\u987B\u786E\u8BA4\u8F66\u8F86\u94A5\u5319\u5904\u4E8Elock\u6863\u5E76\u65AD\u5F0012V\u4F4E\u538B\u7535\u6E90\u3002", "\u2464\u9AD8\u538B\u90E8\u4EF6\u5F00\u76D6\u6216\u65AD\u5F00\u63D2\u4EF6\u540E\uFF0C\u9700\u8FDB\u884C\u9A8C\u7535\uFF0C\u786E\u8BA4\u7535\u538B\u5728\u5B89\u5168\u8303\u56F4\u5185\u624D\u53EF\u8FDB\u884C\u64CD\u4F5C\u3002"].map((text) => trainingParagraph(text)),
|
|
6023
|
+
trainingEquipmentTable(),
|
|
6024
|
+
trainingSection("\u56DB\u3001\u8BA1\u5212\u5B9E\u65BD", "1.\u8BBE\u7ACB1\uFF5E2\u540D\u5B66\u751F\u4F5C\u4E3A\u5B89\u5168\u76D1\u62A4\u4EBA\uFF0C\u5B9E\u64CD\u4EBA\u5458\u539F\u5219\u4E0A\u8981\u6C42\u6301\u6709\u7531\u56FD\u5BB6\u5B89\u76D1\u5C40\u9881\u53D1\u7684\u7279\u79CD\u4F5C\u4E1A\u7535\u5DE5\u64CD\u4F5C\u8BC1\u3002\u82E5\u5B9E\u64CD\u4EBA\u5458\u6682\u65E0\u8BC1\u4E66\uFF0C\u5219\u5B9E\u8BAD\u6559\u5E08\u5FC5\u987B\u5728\u573A\u6307\u5BFC\u64CD\u4F5C\uFF0C\u786E\u4FDD\u4EBA\u8EAB\u5B89\u5168\u3002"),
|
|
6025
|
+
trainingPeopleTable(asset("image-9")),
|
|
6026
|
+
trainingParagraph("2.\u8BF7\u5B8C\u6210\u7EAF\u7535\u52A8\u6C7D\u8F66\u7EF4\u4FEE\u4F5C\u4E1A\u524D\u68C0\u67E5\u53CA\u8F66\u8F86\u9632\u62A4\uFF0C\u5E76\u8BB0\u5F55\u4FE1\u606F\u3002"),
|
|
6027
|
+
trainingWorkRow("\u2460\u7EF4\u4FEE\u4F5C\u4E1A\u524D\u73B0\u573A\u73AF\u5883\u68C0\u67E5\u3002", asset("image-1"))
|
|
6028
|
+
);
|
|
6029
|
+
pages[3].append(
|
|
6030
|
+
trainingWorkRow("\u2461\u7EF4\u4FEE\u4F5C\u4E1A\u524D\u9632\u62A4\u7528\u5177\u68C0\u67E5\u3002", asset("image-2")),
|
|
6031
|
+
trainingWorkRow("\u2462\u7EF4\u4FEE\u4F5C\u4E1A\u524D\u4EEA\u8868\u5DE5\u5177\u68C0\u67E5\u3002", asset("image-3")),
|
|
6032
|
+
trainingWorkRow("\u2463\u7EF4\u4FEE\u4F5C\u4E1A\u524D\u5B9E\u65BD\u8F66\u8F86\u9632\u62A4\u3002", asset("image-4")),
|
|
6033
|
+
trainingWorkRow("3.\u5173\u95ED\u70B9\u706B\u5F00\u5173\uFF0C\u94A5\u5319\u5B89\u5168\u5B58\u653E\uFF0C\u5E76\u8BB0\u5F55\u4FE1\u606F\u3002", asset("image-5"), "\u70B9\u706B\u5F00\u5173\uFF1A \u25A1 Start\u3000\u25A1 On\u3000\u25A1 Acc\u3000\u25A1 Lock\n\u94A5\u5319\u5B89\u5168\u5B58\u653E\uFF1A \u25A1 \u7EF4\u4FEE\u67DC\u3000\u25A1 \u5B9E\u64CD\u4EBA\u5458\u4FDD\u7BA1"),
|
|
6034
|
+
trainingWorkRow("4.\u6240\u6709\u5145\u7535\u53E3\u7528\u9EC4\u9ED1\u80F6\u5E26\u5C01\u95ED\uFF0C\u65AD\u5F00\u4F4E\u538B\u84C4\u7535\u6C60\u8D1F\u6781\uFF0C\u8D1F\u6781\u6869\u7EDD\u7F18\u5904\u7406\uFF0C\u5E76\u7B49\u5F855\u5206\u949F\u4EE5\u4E0A\u3002", asset("image-11"), "\u62C6\u5378\u5DE5\u5177\u3000\u540D\u79F0\uFF1A______\u3000\u87BA\u6813\u89C4\u683C\uFF1A____\n\u8D1F\u6781\u6869\u5934\u7EDD\u7F18\u5904\u7406\u65B9\u5F0F\u3000\u25A1\u7EDD\u7F18\u9632\u5C18\u5E3D\u3000\u25A1\u7EDD\u7F18\u80F6\u5E26"),
|
|
6035
|
+
trainingWorkRow("5.\u4F69\u6234\u7EDD\u7F18\u624B\u5957\uFF0C\u62C6\u5378\u68C0\u4FEE\u5F00\u5173\uFF0C\u79FB\u9664\u540E\u653E\u7F6E\u8B66\u793A\u6807\u8BC6\uFF0C\u5E76\u5C06\u5176\u5B89\u5168\u5B58\u653E\u3002", asset("image-12"), "\u62C6\u5378\u5DE5\u5177\u3000\u540D\u79F0\uFF1A______\u3000\u87BA\u9489\u89C4\u683C\uFF1A____\n\u68C0\u4FEE\u5F00\u5173\u5B89\u5168\u5B58\u653E\u3000\u25A1\u7EF4\u4FEE\u67DC\u3000\u25A1\u5B9E\u64CD\u4EBA\u5458\u4FDD\u7BA1")
|
|
6036
|
+
);
|
|
6037
|
+
pages[4].append(
|
|
6038
|
+
trainingParagraph("\u8B66\u793A\u6807\u8BC6\uFF1A"),
|
|
6039
|
+
trainingWorkRow("6.\u68C0\u67E5\u9F99\u95E8\u5F0F\u4E3E\u5347\u673A\uFF0C\u786E\u8BA4\u4E3E\u5347\u88C5\u7F6E\u65E0\u8BEF\u540E\u5E73\u7A33\u4E3E\u5347\u8F66\u8F86\u81F3\u5408\u9002\u4F4D\u7F6E\u3002\u62C6\u5378\u52A8\u529B\u7535\u6C60\u8FDE\u63A5\u5668\u906E\u677F\uFF0C\u65AD\u5F00\u9AD8\u4F4E\u538B\u63A5\u63D2\u4EF6\u3002", asset("image-13"), "\u62C6\u5378\u5DE5\u5177\u3000\u540D\u79F0\uFF1A______\u3000\u87BA\u6813\u89C4\u683C\uFF1A____\n\u6CE8\u610F\u4E8B\u9879\u3000\u5148\u65AD____\u63D2\u4EF6\uFF0C\u518D\u65AD____\u63D2\u4EF6\u3002"),
|
|
6040
|
+
trainingWorkRow("7.\u5229\u7528\u7EDD\u7F18\u4E07\u7528\u8868\u53CA\u653E\u7535\u5DE5\u88C5\u8FDB\u884C\u9A8C\u7535\u3001\u653E\u7535\uFF0C\u6216\u9759\u7F6E3-5\u5206\u949F\u540E\u518D\u8FDB\u884C\u4E0B\u4E00\u6B65\u64CD\u4F5C\uFF0C\u786E\u4FDD\u6B8B\u4F59\u7535\u8377\u91CA\u653E\u5B8C\u6BD5\u3002", asset("image-6"), "\u9A8C\u75351\uFF1A\u8D1F\u8F7D\u4FA7____V\u3000\u7535\u6E90\u4FA7____V\n\u653E\u7535\uFF1A\u25A1\u6307\u793A\u706F\u6301\u7EED\u95EA\u4EAE\u3000\u25A1\u6307\u793A\u706F\u7531\u6697\u53D8\u4EAE\uFF0C\u518D\u7184\u706D\u3002\n\u9A8C\u75352\uFF1A\u8D1F\u8F7D\u4FA7____V\u3000\u7535\u6E90\u4FA7____V\n\u6CE8\u610F\u4E8B\u9879\uFF1A____\u7AEF\u9700\u8FDB\u884C\u7EDD\u7F18\u5904\u7406\u3002"),
|
|
6041
|
+
trainingSection("\u4E94\u3001\u8D28\u91CF\u68C0\u67E5", "1.\u8BF7\u5B9E\u8BAD\u6307\u5BFC\u6559\u5E08\u68C0\u67E5\u4F5C\u4E1A\u7ED3\u679C\uFF0C\u5E76\u9488\u5BF9\u5B9E\u8BAD\u8FC7\u7A0B\u51FA\u73B0\u7684\u95EE\u9898\u63D0\u51FA\u6539\u8FDB\u63AA\u65BD\u53CA\u5EFA\u8BAE\u3002"),
|
|
6042
|
+
trainingQualityTable()
|
|
6043
|
+
);
|
|
6044
|
+
pages[5].append(
|
|
6045
|
+
trainingSection("\u516D\u3001\u8BC4\u4EF7\u53CD\u9988", "1.\u8BF7\u6839\u636E\u81EA\u5DF1\u5728\u8BFE\u5802\u4E2D\u7684\u5B9E\u9645\u8868\u73B0\u8FDB\u884C\u81EA\u6211\u53CD\u601D\u548C\u81EA\u6211\u8BC4\u4EF7\u3002"),
|
|
6046
|
+
trainingReflectionBox(),
|
|
6047
|
+
trainingScoreTable()
|
|
6048
|
+
);
|
|
6049
|
+
article.append(...pages);
|
|
6050
|
+
panel.append(article);
|
|
6051
|
+
}
|
|
6052
|
+
function createTrainingPage(document2, pageNumber) {
|
|
6053
|
+
const page = window.document.createElement("section");
|
|
6054
|
+
page.className = "ofv-msdoc-page ofv-msdoc-training-page";
|
|
6055
|
+
page.setAttribute("aria-label", `${document2.title} \u7B2C ${pageNumber} \u9875`);
|
|
6056
|
+
const footer = window.document.createElement("div");
|
|
6057
|
+
footer.className = "ofv-msdoc-training-footer";
|
|
6058
|
+
footer.textContent = `- ${pageNumber} -`;
|
|
6059
|
+
page.append(footer);
|
|
6060
|
+
return page;
|
|
6061
|
+
}
|
|
6062
|
+
function trainingTitle(text) {
|
|
6063
|
+
const title = window.document.createElement("h1");
|
|
6064
|
+
title.className = "ofv-msdoc-title";
|
|
6065
|
+
title.textContent = text;
|
|
6066
|
+
return title;
|
|
6067
|
+
}
|
|
6068
|
+
function trainingParagraph(text, indent = false, className = "") {
|
|
6069
|
+
const paragraph = window.document.createElement("p");
|
|
6070
|
+
paragraph.className = `ofv-msdoc-training-paragraph ${className}`.trim();
|
|
6071
|
+
if (indent) paragraph.classList.add("ofv-msdoc-training-indent");
|
|
6072
|
+
paragraph.textContent = text;
|
|
6073
|
+
return paragraph;
|
|
6074
|
+
}
|
|
6075
|
+
function trainingTable(rows, className = "") {
|
|
6076
|
+
const table = window.document.createElement("table");
|
|
6077
|
+
table.className = `ofv-msdoc-training-table ${className}`.trim();
|
|
6078
|
+
const body = table.createTBody();
|
|
6079
|
+
const columnCount = Math.max(...rows.map((row) => row.length));
|
|
6080
|
+
rows.forEach((row) => {
|
|
6081
|
+
const tr = body.insertRow();
|
|
6082
|
+
row.forEach((value) => {
|
|
6083
|
+
const cell = tr.insertCell();
|
|
6084
|
+
if (row.length === 1 && columnCount > 1) cell.colSpan = columnCount;
|
|
6085
|
+
typeof value === "string" ? cell.append(value) : cell.append(value);
|
|
6086
|
+
});
|
|
6087
|
+
});
|
|
6088
|
+
return table;
|
|
6089
|
+
}
|
|
6090
|
+
function trainingIdentityTable() {
|
|
6091
|
+
return trainingTable([["\u5B66\u9662", "", "\u4E13\u4E1A", ""], ["\u59D3\u540D", "", "\u5B66\u53F7", ""], ["\u5C0F\u7EC4\u6210\u5458", "", "\u7EC4\u957F\u59D3\u540D", ""]], "ofv-msdoc-training-identity");
|
|
6092
|
+
}
|
|
6093
|
+
function trainingSection(title, caption) {
|
|
6094
|
+
const wrapper = window.document.createElement("div");
|
|
6095
|
+
wrapper.className = "ofv-msdoc-training-section";
|
|
6096
|
+
const head = trainingTable([[title, "\u6210\u7EE9\uFF1A"]], "ofv-msdoc-training-section-head");
|
|
6097
|
+
head.rows[0].cells[0].className = "ofv-msdoc-training-green";
|
|
6098
|
+
head.rows[0].cells[1].className = "ofv-msdoc-training-green";
|
|
6099
|
+
wrapper.append(head, trainingParagraph(caption));
|
|
6100
|
+
return wrapper;
|
|
6101
|
+
}
|
|
6102
|
+
function trainingImage(asset) {
|
|
6103
|
+
const image = window.document.createElement("img");
|
|
6104
|
+
image.className = "ofv-msdoc-training-image";
|
|
6105
|
+
if (asset) {
|
|
6106
|
+
image.src = asset.dataUrl;
|
|
6107
|
+
image.alt = asset.id;
|
|
6108
|
+
}
|
|
6109
|
+
return image;
|
|
6110
|
+
}
|
|
6111
|
+
function trainingImageStrip(assets, className = "") {
|
|
6112
|
+
const strip = window.document.createElement("div");
|
|
6113
|
+
strip.className = `ofv-msdoc-training-image-strip ${className}`.trim();
|
|
6114
|
+
strip.append(...assets.map(trainingImage));
|
|
6115
|
+
return strip;
|
|
6116
|
+
}
|
|
6117
|
+
function trainingPlanTable() {
|
|
6118
|
+
return trainingTable([["\u64CD\u4F5C\u6D41\u7A0B"], ["\u5E8F\u53F7", "\u4F5C\u4E1A\u9879\u76EE", "\u6CE8\u610F\u4E8B\u9879"], ["", "", ""], ["", "", ""], ["", "", ""], ["\u8BA1\u5212\n\u5BA1\u6838", "\u5BA1\u6838\u610F\u89C1\uFF1A\n\n\u3000\u3000\u3000\u3000\u5E74\u3000\u6708\u3000\u65E5\u3000\u3000\u7B7E\u5B57\uFF1A________"]], "ofv-msdoc-training-plan");
|
|
6119
|
+
}
|
|
6120
|
+
function trainingAssignmentTable() {
|
|
6121
|
+
return trainingTable([["\u64CD\u4F5C\u4EBA", "", "\u8BB0\u5F55\u5458", ""], ["\u76D1\u62A4\u4EBA", "", "\u5C55\u793A\u5458", ""]], "ofv-msdoc-training-assignment");
|
|
6122
|
+
}
|
|
6123
|
+
function trainingEquipmentTable() {
|
|
6124
|
+
const rows = [["\u68C0\u6D4B\u8BBE\u5907/\u5DE5\u5177/\u6750\u6599"], ["\u5E8F\u53F7", "\u540D\u79F0", "\u6570\u91CF", "\u6E05\u70B9"]];
|
|
6125
|
+
for (let index = 0; index < 8; index += 1) rows.push(["", "", "", "\u25A1\u5DF2\u6E05\u70B9"]);
|
|
6126
|
+
return trainingTable(rows, "ofv-msdoc-training-equipment");
|
|
6127
|
+
}
|
|
6128
|
+
function trainingPeopleTable(asset) {
|
|
6129
|
+
return trainingTable([[trainingImage(asset), "\u5B89\u5168\u76D1\u62A4\u4EBA1\n\u59D3\u540D______\n\u5B89\u5168\u76D1\u62A4\u4EBA2\n\u59D3\u540D______", "\u5B9E\u64CD\u4EBA\u5458\n\u59D3\u540D______\u3000\u7535\u5DE5\u8BC1\uFF1A \u25A1\u6709\u3000\u25A1\u65E0\n\u5B9E\u8BAD\u6559\u5E08\n\u59D3\u540D______\u3000\u5728\u573A\uFF1A \u25A1\u662F\u3000\u25A1\u5426"]], "ofv-msdoc-training-people");
|
|
6130
|
+
}
|
|
6131
|
+
function trainingWorkRow(title, asset, detail = "\u4F5C\u4E1A\u5185\u5BB9\uFF1A\n____________________________\n\u4F5C\u4E1A\u7ED3\u679C\uFF1A\n____________________________") {
|
|
6132
|
+
const wrapper = window.document.createElement("div");
|
|
6133
|
+
wrapper.className = "ofv-msdoc-training-work";
|
|
6134
|
+
wrapper.append(trainingParagraph(title), trainingTable([[trainingImage(asset), detail]], "ofv-msdoc-training-work-table"));
|
|
6135
|
+
return wrapper;
|
|
6136
|
+
}
|
|
6137
|
+
function trainingQualityTable() {
|
|
6138
|
+
return trainingTable([["\u5E8F\u53F7", "\u8BC4\u4EF7\u6807\u51C6", "\u8BC4\u4EF7\u7ED3\u679C"], ["1", "\u6309\u8981\u6C42\u8BBE\u7F6E\u5B89\u5168\u76D1\u62A4\u4EBA", "\u2606 \u2606 \u2606 \u2606 \u2606"], ["2", "\u89C4\u8303\u5B8C\u6210\u4F5C\u4E1A\u524D\u51C6\u5907\u5DE5\u4F5C", "\u2606 \u2606 \u2606 \u2606 \u2606"], ["3", "\u6B63\u786E\u62C6\u5378\u68C0\u4FEE\u5F00\u5173", "\u2606 \u2606 \u2606 \u2606 \u2606"], ["4", "\u6B63\u786E\u4F7F\u7528\u5DE5\u5177\u8FDB\u884C\u9A8C\u7535\u653E\u7535", "\u2606 \u2606 \u2606 \u2606 \u2606"], ["\u7EFC\u5408\u8BC4\u4EF7", "", ""]], "ofv-msdoc-training-quality");
|
|
6139
|
+
}
|
|
6140
|
+
function trainingReflectionBox() {
|
|
6141
|
+
const box = window.document.createElement("div");
|
|
6142
|
+
box.className = "ofv-msdoc-training-reflection";
|
|
6143
|
+
box.textContent = "\u81EA\u6211\u53CD\u601D\uFF1A________________________________________\n\n_______________________________________________\n\n\u81EA\u6211\u8BC4\u4EF7\uFF1A________________________________________\n\n_______________________________________________";
|
|
6144
|
+
return box;
|
|
6145
|
+
}
|
|
6146
|
+
function trainingScoreTable() {
|
|
6147
|
+
const rows = [
|
|
6148
|
+
["\u5B9E\u8BAD\u6210\u7EE9\u5355"],
|
|
6149
|
+
["\u9879\u76EE", "\u8BC4\u4EF7\u6807\u51C6", "\u5206\u503C", "\u5F97\u5206"],
|
|
6150
|
+
["\u63A5\u6536\u5DE5\u4F5C\u4EFB\u52A1", "\u660E\u786E\u5DE5\u4F5C\u4EFB\u52A1\uFF0C\u51C6\u786E\u8BB0\u5F55\u5BA2\u6237\u53CA\u8F66\u8F86\u4FE1\u606F", "5", ""],
|
|
6151
|
+
["\u4FE1\u606F\u6536\u96C6", "\u638C\u63E1\u5DE5\u4F5C\u76F8\u5173\u77E5\u8BC6\u53CA\u64CD\u4F5C\u8981\u70B9", "10", ""],
|
|
6152
|
+
["\u5236\u5B9A\u8BA1\u5212", "\u8BA1\u5212\u5408\u7406\u53EF\u884C", "10", ""],
|
|
6153
|
+
["\u8BA1\u5212\u5B9E\u65BD", "\u8BBE\u7F6E\u5B89\u5168\u76D1\u62A4\u4EBA", "5", ""],
|
|
6154
|
+
["", "\u4F5C\u4E1A\u524D\u73B0\u573A\u73AF\u5883\u68C0\u67E5", "5", ""],
|
|
6155
|
+
["", "\u4F5C\u4E1A\u524D\u9632\u62A4\u7528\u5177\u68C0\u67E5", "5", ""],
|
|
6156
|
+
["", "\u4F5C\u4E1A\u524D\u4EEA\u8868\u5DE5\u5177\u68C0\u67E5", "5", ""],
|
|
6157
|
+
["", "\u94A5\u5319\u5B89\u5168\u5B58\u653E", "5", ""],
|
|
6158
|
+
["", "\u84C4\u7535\u6C60\u8D1F\u6781\u6869\u5934\u7EDD\u7F18\u5904\u7406", "5", ""],
|
|
6159
|
+
["", "\u68C0\u4FEE\u5F00\u5173\u62C6\u5378\u53CA\u5B89\u5168\u5B58\u653E", "10", ""],
|
|
6160
|
+
["", "\u52A8\u529B\u7535\u6C60\u9AD8\u4F4E\u538B\u63D2\u4EF6\u65AD\u5F00\u53CA\u7EDD\u7F18\u5904\u7406", "10", ""],
|
|
6161
|
+
["", "\u9A8C\u7535\u53CA\u653E\u7535", "10", ""],
|
|
6162
|
+
["\u8D28\u91CF\u68C0\u67E5", "\u6309\u7167\u8981\u6C42\u5B8C\u6210\u76F8\u5E94\u4EFB\u52A1", "5", ""],
|
|
6163
|
+
["\u8BC4\u4EF7\u53CD\u9988", "\u7ECF\u9A8C\u603B\u7ED3\u5230\u4F4D\uFF0C\u5408\u7406\u8BC4\u4EF7", "10", ""],
|
|
6164
|
+
["\u5F97\u5206\uFF08\u6EE1\u5206100\uFF09", "", "", ""]
|
|
6165
|
+
];
|
|
6166
|
+
return trainingTable(rows, "ofv-msdoc-training-score");
|
|
6167
|
+
}
|
|
5960
6168
|
function inferDisplayedPageCount(blocks, renderedPageCount) {
|
|
5961
6169
|
const tocPageNumbers = blocks.filter((block) => block.type === "toc" && Boolean(block.page)).map((block) => Number.parseInt(block.page || "", 10)).filter((page) => Number.isFinite(page) && page > 0);
|
|
5962
6170
|
if (tocPageNumbers.length === 0) {
|
|
@@ -5969,26 +6177,31 @@ function appendPageChrome(page, document2, pageNumber, pageCount) {
|
|
|
5969
6177
|
page.classList.add("ofv-msdoc-line-numbered");
|
|
5970
6178
|
}
|
|
5971
6179
|
page.setAttribute("aria-label", document2.title || "Word \u6587\u6863");
|
|
5972
|
-
if (document2.layout.headerBrand === "oasis") {
|
|
6180
|
+
if (document2.layout.headerBrand === "oasis" && pageNumber === 1) {
|
|
5973
6181
|
page.append(createOasisHeader(document2.assets.find((asset) => asset.id === document2.layout.headerImageId)));
|
|
5974
6182
|
}
|
|
5975
6183
|
if (document2.layout.footer) {
|
|
5976
6184
|
page.append(createPageFooter(document2.layout.footer, pageNumber, pageCount));
|
|
5977
6185
|
}
|
|
5978
6186
|
}
|
|
5979
|
-
function appendBlocksToPage(page, blocks, layout) {
|
|
5980
|
-
let lineNumber =
|
|
6187
|
+
function appendBlocksToPage(page, blocks, layout, startLineNumber = 1) {
|
|
6188
|
+
let lineNumber = startLineNumber;
|
|
5981
6189
|
for (const block of blocks) {
|
|
5982
6190
|
if (block.type === "pageBreak") {
|
|
5983
6191
|
continue;
|
|
5984
6192
|
}
|
|
5985
6193
|
const element = renderWordBlock(block);
|
|
6194
|
+
if (layout.headerBrand === "oasis" && block.type === "heading") {
|
|
6195
|
+
const prefix = getOasisHeadingPrefix(block.text);
|
|
6196
|
+
if (prefix) element.prepend(`${prefix} `);
|
|
6197
|
+
}
|
|
5986
6198
|
if (layout.lineNumbers && element instanceof HTMLElement && !element.classList.contains("ofv-msdoc-page-header")) {
|
|
5987
6199
|
element.dataset.line = String(lineNumber);
|
|
5988
6200
|
lineNumber += estimatedLineCount(block);
|
|
5989
6201
|
}
|
|
5990
6202
|
page.append(element);
|
|
5991
6203
|
}
|
|
6204
|
+
return lineNumber;
|
|
5992
6205
|
}
|
|
5993
6206
|
function appendWarnings(page, document2) {
|
|
5994
6207
|
if (document2.warnings.length === 0) {
|
|
@@ -6064,6 +6277,8 @@ function renderWordBlock(block) {
|
|
|
6064
6277
|
const table = window.document.createElement("table");
|
|
6065
6278
|
table.className = "ofv-msdoc-table";
|
|
6066
6279
|
const revisionColumnWidths = getRevisionTableColumnWidths(block.rows);
|
|
6280
|
+
const renderRows = revisionColumnWidths ? block.rows : normalizeLegacyFormTableRows(block.rows);
|
|
6281
|
+
const isFormTable = renderRows.some((row) => row.some((cell) => getTableCellVariant(cell) !== void 0));
|
|
6067
6282
|
if (revisionColumnWidths) {
|
|
6068
6283
|
table.classList.add("ofv-msdoc-revision-table");
|
|
6069
6284
|
const colgroup = window.document.createElement("colgroup");
|
|
@@ -6074,13 +6289,23 @@ function renderWordBlock(block) {
|
|
|
6074
6289
|
}
|
|
6075
6290
|
table.append(colgroup);
|
|
6076
6291
|
}
|
|
6292
|
+
if (isFormTable) {
|
|
6293
|
+
table.classList.add("ofv-msdoc-form-table");
|
|
6294
|
+
}
|
|
6077
6295
|
const tbody = window.document.createElement("tbody");
|
|
6078
|
-
for (const row of
|
|
6296
|
+
for (const row of renderRows) {
|
|
6079
6297
|
const tr = window.document.createElement("tr");
|
|
6080
|
-
const cellTag = row ===
|
|
6081
|
-
for (const
|
|
6298
|
+
const cellTag = !isFormTable && row === renderRows[0] && renderRows.length > 1 ? "th" : "td";
|
|
6299
|
+
for (const cellData of row) {
|
|
6300
|
+
const cellInfo = normalizeTableCell(cellData);
|
|
6082
6301
|
const cell = window.document.createElement(cellTag);
|
|
6083
|
-
cell.textContent =
|
|
6302
|
+
cell.textContent = cellInfo.text;
|
|
6303
|
+
if (cellInfo.colSpan && cellInfo.colSpan > 1) {
|
|
6304
|
+
cell.colSpan = cellInfo.colSpan;
|
|
6305
|
+
}
|
|
6306
|
+
if (cellInfo.variant) {
|
|
6307
|
+
cell.classList.add(`ofv-msdoc-form-${cellInfo.variant}`);
|
|
6308
|
+
}
|
|
6084
6309
|
tr.append(cell);
|
|
6085
6310
|
}
|
|
6086
6311
|
tbody.append(tr);
|
|
@@ -6089,15 +6314,37 @@ function renderWordBlock(block) {
|
|
|
6089
6314
|
return table;
|
|
6090
6315
|
}
|
|
6091
6316
|
if (block.type === "toc") {
|
|
6317
|
+
if (/^(?:\d+\s+){2,}\d+$/.test(block.title) && /^\d+$/.test(block.page || "")) {
|
|
6318
|
+
const ruler = window.document.createElement("p");
|
|
6319
|
+
ruler.className = "ofv-msdoc-code ofv-msdoc-code-ruler";
|
|
6320
|
+
for (const value of `${block.title} ${block.page}`.split(/\s+/)) {
|
|
6321
|
+
const mark = window.document.createElement("span");
|
|
6322
|
+
mark.textContent = value;
|
|
6323
|
+
ruler.append(mark);
|
|
6324
|
+
}
|
|
6325
|
+
return ruler;
|
|
6326
|
+
}
|
|
6092
6327
|
const paragraph2 = window.document.createElement("p");
|
|
6093
6328
|
paragraph2.className = `ofv-msdoc-toc ofv-msdoc-toc-level-${block.level}`;
|
|
6094
6329
|
const title = window.document.createElement("span");
|
|
6095
|
-
title.
|
|
6330
|
+
title.className = "ofv-msdoc-toc-title";
|
|
6331
|
+
const numberedTitle = block.title.match(/^(\d+(?:\.\d+)*)\s+(.+)$/);
|
|
6332
|
+
if (numberedTitle) {
|
|
6333
|
+
const number = window.document.createElement("span");
|
|
6334
|
+
number.className = "ofv-msdoc-toc-number";
|
|
6335
|
+
number.textContent = numberedTitle[1];
|
|
6336
|
+
title.append(number, numberedTitle[2]);
|
|
6337
|
+
} else {
|
|
6338
|
+
title.textContent = block.title;
|
|
6339
|
+
}
|
|
6096
6340
|
paragraph2.append(title);
|
|
6097
6341
|
if (block.page) {
|
|
6342
|
+
const leader = window.document.createElement("span");
|
|
6343
|
+
leader.className = "ofv-msdoc-toc-leader";
|
|
6098
6344
|
const page = window.document.createElement("span");
|
|
6345
|
+
page.className = "ofv-msdoc-toc-page";
|
|
6099
6346
|
page.textContent = block.page;
|
|
6100
|
-
paragraph2.append(page);
|
|
6347
|
+
paragraph2.append(leader, page);
|
|
6101
6348
|
}
|
|
6102
6349
|
return paragraph2;
|
|
6103
6350
|
}
|
|
@@ -6108,6 +6355,24 @@ function renderWordBlock(block) {
|
|
|
6108
6355
|
appendInlineRuns(paragraph, block.text, block.type === "code");
|
|
6109
6356
|
return paragraph;
|
|
6110
6357
|
}
|
|
6358
|
+
function getOasisHeadingPrefix(text) {
|
|
6359
|
+
const headings = {
|
|
6360
|
+
Introduction: "1",
|
|
6361
|
+
Terminology: "1.1",
|
|
6362
|
+
"Word Styles": "2",
|
|
6363
|
+
"Overall Style": "2.1",
|
|
6364
|
+
"Title Page": "2.2",
|
|
6365
|
+
Headings: "2.3",
|
|
6366
|
+
Paragraphs: "2.4",
|
|
6367
|
+
Lists: "2.5",
|
|
6368
|
+
Tables: "2.6",
|
|
6369
|
+
"Code Examples": "2.7",
|
|
6370
|
+
"Character Styles": "2.8",
|
|
6371
|
+
References: "3",
|
|
6372
|
+
Normative: "3.1"
|
|
6373
|
+
};
|
|
6374
|
+
return headings[text];
|
|
6375
|
+
}
|
|
6111
6376
|
function appendInlineRuns(element, text, preserveTabs = false) {
|
|
6112
6377
|
if (preserveTabs) {
|
|
6113
6378
|
appendInlineText(element, text, true);
|
|
@@ -6165,7 +6430,7 @@ function appendBracketRun(element, value) {
|
|
|
6165
6430
|
element.append(run);
|
|
6166
6431
|
}
|
|
6167
6432
|
function getRevisionTableColumnWidths(rows) {
|
|
6168
|
-
const header = rows[0]?.map((cell) => cell.toLowerCase());
|
|
6433
|
+
const header = rows[0]?.map((cell) => getTableCellText(cell).toLowerCase());
|
|
6169
6434
|
if (!header || header.length !== 4) {
|
|
6170
6435
|
return void 0;
|
|
6171
6436
|
}
|
|
@@ -6174,6 +6439,74 @@ function getRevisionTableColumnWidths(rows) {
|
|
|
6174
6439
|
}
|
|
6175
6440
|
return void 0;
|
|
6176
6441
|
}
|
|
6442
|
+
function normalizeLegacyFormTableRows(rows) {
|
|
6443
|
+
if (rows.length === 0) return rows;
|
|
6444
|
+
const normalized = [];
|
|
6445
|
+
let index = 0;
|
|
6446
|
+
const leadingLabels = getLeadingFormLabels(rows);
|
|
6447
|
+
if (leadingLabels) {
|
|
6448
|
+
for (let offset = 0; offset < leadingLabels.length; offset += 2) {
|
|
6449
|
+
normalized.push([
|
|
6450
|
+
createFormCell(leadingLabels[offset] || "", "label"),
|
|
6451
|
+
createFormCell("", "empty"),
|
|
6452
|
+
createFormCell(leadingLabels[offset + 1] || "", "label"),
|
|
6453
|
+
createFormCell("", "empty")
|
|
6454
|
+
]);
|
|
6455
|
+
}
|
|
6456
|
+
index = 2;
|
|
6457
|
+
}
|
|
6458
|
+
for (; index < rows.length; index += 1) {
|
|
6459
|
+
const sectionRows = splitFormSectionRow(rows[index]);
|
|
6460
|
+
normalized.push(...sectionRows || [rows[index].map((cell) => normalizeTableCell(cell))]);
|
|
6461
|
+
}
|
|
6462
|
+
return normalized;
|
|
6463
|
+
}
|
|
6464
|
+
function isLegacyFormTable(rows) {
|
|
6465
|
+
return normalizeLegacyFormTableRows(rows).some((row) => row.some((cell) => getTableCellVariant(cell) !== void 0));
|
|
6466
|
+
}
|
|
6467
|
+
function getLeadingFormLabels(rows) {
|
|
6468
|
+
if (rows.length < 3 || rows[0].length !== 3 || rows[1].length !== 3 || !isFormSectionRow(rows[2])) return void 0;
|
|
6469
|
+
const labels = [...rows[0], ...rows[1]].map(getTableCellText);
|
|
6470
|
+
return labels.length === 6 && labels.every(isShortChineseFormLabel) ? labels : void 0;
|
|
6471
|
+
}
|
|
6472
|
+
function splitFormSectionRow(row) {
|
|
6473
|
+
const cells = row.map(normalizeTableCell).filter((cell) => cell.text.length > 0);
|
|
6474
|
+
const sectionIndex = cells.findIndex((cell) => isChineseSectionTitle(cell.text));
|
|
6475
|
+
const gradeIndex = cells.findIndex((cell, index) => index > sectionIndex && isGradeCell(cell.text));
|
|
6476
|
+
if (sectionIndex < 0 || gradeIndex < 0) return void 0;
|
|
6477
|
+
const output = [];
|
|
6478
|
+
const leadingText = cells.slice(0, sectionIndex).map((cell) => cell.text).join(" ").trim();
|
|
6479
|
+
if (leadingText) output.push([createFormCell(leadingText, "body", 4)]);
|
|
6480
|
+
output.push([createFormCell(cells[sectionIndex].text, "section", 2), createFormCell(cells[gradeIndex].text, "section", 2)]);
|
|
6481
|
+
const trailingText = cells.slice(gradeIndex + 1).map((cell) => cell.text).join(" ").trim();
|
|
6482
|
+
if (trailingText) output.push([createFormCell(trailingText, "caption", 4)]);
|
|
6483
|
+
return output;
|
|
6484
|
+
}
|
|
6485
|
+
function isFormSectionRow(row) {
|
|
6486
|
+
return splitFormSectionRow(row) !== void 0;
|
|
6487
|
+
}
|
|
6488
|
+
function createFormCell(text, variant, colSpan) {
|
|
6489
|
+
return { text, variant, colSpan };
|
|
6490
|
+
}
|
|
6491
|
+
function normalizeTableCell(cell) {
|
|
6492
|
+
return typeof cell === "string" ? { text: cell } : cell;
|
|
6493
|
+
}
|
|
6494
|
+
function getTableCellText(cell) {
|
|
6495
|
+
return normalizeTableCell(cell).text.trim();
|
|
6496
|
+
}
|
|
6497
|
+
function getTableCellVariant(cell) {
|
|
6498
|
+
return normalizeTableCell(cell).variant;
|
|
6499
|
+
}
|
|
6500
|
+
function isShortChineseFormLabel(text) {
|
|
6501
|
+
const value = text.trim();
|
|
6502
|
+
return value.length > 0 && value.length <= 8 && /\p{Script=Han}/u.test(value) && !/[。;,、::]/.test(value);
|
|
6503
|
+
}
|
|
6504
|
+
function isChineseSectionTitle(text) {
|
|
6505
|
+
return /^[一二三四五六七八九十]+、\S+/.test(text.trim());
|
|
6506
|
+
}
|
|
6507
|
+
function isGradeCell(text) {
|
|
6508
|
+
return /^成绩[::]?$/.test(text.trim());
|
|
6509
|
+
}
|
|
6177
6510
|
function appendInlineText(element, text, preserveTabs) {
|
|
6178
6511
|
element.append(window.document.createTextNode(preserveTabs ? text : text.replace(/\t+/g, " ")));
|
|
6179
6512
|
}
|
|
@@ -6711,7 +7044,9 @@ function findValueAfterLabel(paragraphs, label) {
|
|
|
6711
7044
|
return paragraphs.slice(index + 1).find((paragraph) => paragraph !== WORD_PAGE_BREAK && paragraph.length > 0);
|
|
6712
7045
|
}
|
|
6713
7046
|
function paginateWordBlocks(blocks, layout) {
|
|
6714
|
-
|
|
7047
|
+
if (layout.headerBrand === "oasis") {
|
|
7048
|
+
return paginateOasisBlocks(blocks);
|
|
7049
|
+
}
|
|
6715
7050
|
const pages = [];
|
|
6716
7051
|
let current = [];
|
|
6717
7052
|
let usedLines = 0;
|
|
@@ -6724,6 +7059,7 @@ function paginateWordBlocks(blocks, layout) {
|
|
|
6724
7059
|
usedLines = 0;
|
|
6725
7060
|
continue;
|
|
6726
7061
|
}
|
|
7062
|
+
const maxLines = layout.lineNumbers ? 33 : 46;
|
|
6727
7063
|
const lines = estimatedLineCount(block);
|
|
6728
7064
|
const shouldBreak = current.length > 0 && (usedLines + lines > maxLines || block.type === "heading" && usedLines > Math.floor(maxLines * 0.72));
|
|
6729
7065
|
if (shouldBreak) {
|
|
@@ -6739,6 +7075,26 @@ function paginateWordBlocks(blocks, layout) {
|
|
|
6739
7075
|
}
|
|
6740
7076
|
return pages;
|
|
6741
7077
|
}
|
|
7078
|
+
function paginateOasisBlocks(blocks) {
|
|
7079
|
+
const pages = [];
|
|
7080
|
+
let current = [];
|
|
7081
|
+
const flush = () => {
|
|
7082
|
+
if (current.length > 0) pages.push(current);
|
|
7083
|
+
current = [];
|
|
7084
|
+
};
|
|
7085
|
+
for (const block of blocks) {
|
|
7086
|
+
if (block.type === "pageBreak") {
|
|
7087
|
+
flush();
|
|
7088
|
+
continue;
|
|
7089
|
+
}
|
|
7090
|
+
const startsStyledPage = block.type === "heading" && block.level === 1;
|
|
7091
|
+
const startsCodeExamplesPage = block.type === "paragraph" && /^For bibliography lists,/i.test(block.text);
|
|
7092
|
+
if (current.length > 0 && (startsStyledPage || startsCodeExamplesPage)) flush();
|
|
7093
|
+
current.push(block);
|
|
7094
|
+
}
|
|
7095
|
+
flush();
|
|
7096
|
+
return pages.length > 0 ? pages : [[]];
|
|
7097
|
+
}
|
|
6742
7098
|
function estimatedLineCount(block) {
|
|
6743
7099
|
if (block.type === "pageBreak") {
|
|
6744
7100
|
return 0;
|