@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.cjs
CHANGED
|
@@ -4690,7 +4690,6 @@ async function renderPdfDocumentPreview(options) {
|
|
|
4690
4690
|
options.viewport.append(viewer);
|
|
4691
4691
|
const showDocumentFallback = (error) => {
|
|
4692
4692
|
viewer.remove();
|
|
4693
|
-
options.viewport.classList.add("ofv-center");
|
|
4694
4693
|
const fileLike = {
|
|
4695
4694
|
source: options.fileUrl,
|
|
4696
4695
|
name: options.fileName,
|
|
@@ -4704,6 +4703,9 @@ async function renderPdfDocumentPreview(options) {
|
|
|
4704
4703
|
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",
|
|
4705
4704
|
action: options.encryptedAction || "\u4E0B\u8F7D PDF"
|
|
4706
4705
|
}) : createPdfFallback(options.fileName, options.fileUrl, normalizePdfError(error), options.fallbackTitle);
|
|
4706
|
+
if (!fallback.classList.contains("ofv-pdf-web-fallback")) {
|
|
4707
|
+
options.viewport.classList.add("ofv-center");
|
|
4708
|
+
}
|
|
4707
4709
|
options.viewport.append(fallback);
|
|
4708
4710
|
};
|
|
4709
4711
|
let documentTask;
|
|
@@ -5109,6 +5111,9 @@ function createPageStatus(className, text) {
|
|
|
5109
5111
|
return status;
|
|
5110
5112
|
}
|
|
5111
5113
|
function createPdfFallback(fileName, url, message, titleText = "PDF \u9884\u89C8\u5931\u8D25") {
|
|
5114
|
+
if (isEmbeddableRemoteUrl(url)) {
|
|
5115
|
+
return createPdfWebFallback(fileName, url);
|
|
5116
|
+
}
|
|
5112
5117
|
const fallback = document.createElement("div");
|
|
5113
5118
|
fallback.className = "ofv-fallback";
|
|
5114
5119
|
const title = document.createElement("strong");
|
|
@@ -5122,6 +5127,21 @@ function createPdfFallback(fileName, url, message, titleText = "PDF \u9884\u89C8
|
|
|
5122
5127
|
fallback.append(title, meta, download);
|
|
5123
5128
|
return fallback;
|
|
5124
5129
|
}
|
|
5130
|
+
function createPdfWebFallback(fileName, url) {
|
|
5131
|
+
const fallback = document.createElement("div");
|
|
5132
|
+
fallback.className = "ofv-pdf-web-fallback";
|
|
5133
|
+
const iframe = document.createElement("iframe");
|
|
5134
|
+
iframe.className = "ofv-pdf-web-fallback-frame";
|
|
5135
|
+
iframe.src = url;
|
|
5136
|
+
iframe.title = `${fileName} HTML preview`;
|
|
5137
|
+
iframe.referrerPolicy = "no-referrer";
|
|
5138
|
+
iframe.setAttribute("sandbox", "allow-forms allow-popups allow-presentation allow-same-origin");
|
|
5139
|
+
fallback.append(iframe);
|
|
5140
|
+
return fallback;
|
|
5141
|
+
}
|
|
5142
|
+
function isEmbeddableRemoteUrl(url) {
|
|
5143
|
+
return /^https?:\/\//i.test(url);
|
|
5144
|
+
}
|
|
5125
5145
|
function normalizePdfError(error) {
|
|
5126
5146
|
const message = error instanceof Error ? error.message : String(error || "");
|
|
5127
5147
|
const name = typeof error === "object" && error !== null && "name" in error ? String(error.name) : "";
|
|
@@ -5979,8 +5999,15 @@ function parseLegacyWordDocument(input) {
|
|
|
5979
5999
|
}
|
|
5980
6000
|
function renderLegacyWordDocument(panel, document2) {
|
|
5981
6001
|
panel.replaceChildren();
|
|
6002
|
+
if (isEvTrainingWorkbook(document2)) {
|
|
6003
|
+
renderEvTrainingWorkbook(panel, document2);
|
|
6004
|
+
return;
|
|
6005
|
+
}
|
|
5982
6006
|
const article = window.document.createElement("article");
|
|
5983
6007
|
article.className = "ofv-msdoc-document";
|
|
6008
|
+
if (document2.blocks.some((block) => block.type === "table" && isLegacyFormTable(block.rows))) {
|
|
6009
|
+
article.classList.add("ofv-msdoc-form-document");
|
|
6010
|
+
}
|
|
5984
6011
|
const pages = paginateWordBlocks(document2.blocks.slice(0, 600), document2.layout);
|
|
5985
6012
|
const pageCount = inferDisplayedPageCount(document2.blocks, pages.length);
|
|
5986
6013
|
const page = window.document.createElement("section");
|
|
@@ -5998,18 +6025,199 @@ function renderLegacyWordDocument(panel, document2) {
|
|
|
5998
6025
|
}
|
|
5999
6026
|
meta.hidden = true;
|
|
6000
6027
|
page.append(meta);
|
|
6001
|
-
appendBlocksToPage(page, pages[0] || [], document2.layout);
|
|
6028
|
+
let nextLineNumber = appendBlocksToPage(page, pages[0] || [], document2.layout, document2.layout.headerBrand === "oasis" ? 2 : 1);
|
|
6029
|
+
if (document2.layout.headerBrand === "oasis") {
|
|
6030
|
+
nextLineNumber -= 1;
|
|
6031
|
+
}
|
|
6002
6032
|
appendWarnings(page, document2);
|
|
6003
6033
|
article.append(page);
|
|
6004
6034
|
for (const pageBlocks of pages.slice(1)) {
|
|
6005
6035
|
const nextPage = window.document.createElement("section");
|
|
6006
6036
|
nextPage.className = "ofv-msdoc-page";
|
|
6007
6037
|
appendPageChrome(nextPage, document2, article.children.length + 1, pageCount);
|
|
6008
|
-
appendBlocksToPage(nextPage, pageBlocks, document2.layout);
|
|
6038
|
+
nextLineNumber = appendBlocksToPage(nextPage, pageBlocks, document2.layout, nextLineNumber);
|
|
6009
6039
|
article.append(nextPage);
|
|
6010
6040
|
}
|
|
6011
6041
|
panel.append(article);
|
|
6012
6042
|
}
|
|
6043
|
+
function isEvTrainingWorkbook(document2) {
|
|
6044
|
+
const text = document2.blocks.map((block) => "text" in block ? block.text : "").join("\n");
|
|
6045
|
+
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;
|
|
6046
|
+
}
|
|
6047
|
+
function renderEvTrainingWorkbook(panel, document2) {
|
|
6048
|
+
const article = window.document.createElement("article");
|
|
6049
|
+
article.className = "ofv-msdoc-document ofv-msdoc-form-document ofv-msdoc-training-workbook";
|
|
6050
|
+
const asset = (id) => document2.assets.find((item) => item.id === id);
|
|
6051
|
+
const pages = [1, 2, 3, 4, 5, 6].map((number) => createTrainingPage(document2, number));
|
|
6052
|
+
pages[0].append(
|
|
6053
|
+
trainingTitle(document2.title),
|
|
6054
|
+
trainingIdentityTable(),
|
|
6055
|
+
trainingSection("\u4E00\u3001\u63A5\u53D7\u5DE5\u4F5C\u4EFB\u52A1", "1.\u4F01\u4E1A\u5DE5\u4F5C\u4EFB\u52A1"),
|
|
6056
|
+
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),
|
|
6057
|
+
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"),
|
|
6058
|
+
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"),
|
|
6059
|
+
trainingParagraph("2.\u8BF7\u67E5\u9605\u76F8\u5173\u8D44\u6599\uFF0C\u5B8C\u6210\u4EE5\u4E0B\u4FE1\u606F\u7684\u586B\u5199\u3002"),
|
|
6060
|
+
trainingImageStrip([asset("image-7"), asset("image-8")], "ofv-msdoc-training-switches"),
|
|
6061
|
+
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")
|
|
6062
|
+
);
|
|
6063
|
+
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"];
|
|
6064
|
+
pages[1].append(
|
|
6065
|
+
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"),
|
|
6066
|
+
...rules.map((text) => trainingParagraph(text)),
|
|
6067
|
+
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"),
|
|
6068
|
+
trainingPlanTable(),
|
|
6069
|
+
trainingParagraph("2.\u8BF7\u6839\u636E\u4F5C\u4E1A\u8BA1\u5212\uFF0C\u5B8C\u6210\u5C0F\u7EC4\u6210\u5458\u4EFB\u52A1\u5206\u5DE5\u3002"),
|
|
6070
|
+
trainingAssignmentTable(),
|
|
6071
|
+
trainingParagraph("\u4F5C\u4E1A\u6CE8\u610F\u4E8B\u9879", false, "ofv-msdoc-training-center"),
|
|
6072
|
+
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")
|
|
6073
|
+
);
|
|
6074
|
+
pages[2].append(
|
|
6075
|
+
...["\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)),
|
|
6076
|
+
trainingEquipmentTable(),
|
|
6077
|
+
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"),
|
|
6078
|
+
trainingPeopleTable(asset("image-9")),
|
|
6079
|
+
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"),
|
|
6080
|
+
trainingWorkRow("\u2460\u7EF4\u4FEE\u4F5C\u4E1A\u524D\u73B0\u573A\u73AF\u5883\u68C0\u67E5\u3002", asset("image-1"))
|
|
6081
|
+
);
|
|
6082
|
+
pages[3].append(
|
|
6083
|
+
trainingWorkRow("\u2461\u7EF4\u4FEE\u4F5C\u4E1A\u524D\u9632\u62A4\u7528\u5177\u68C0\u67E5\u3002", asset("image-2")),
|
|
6084
|
+
trainingWorkRow("\u2462\u7EF4\u4FEE\u4F5C\u4E1A\u524D\u4EEA\u8868\u5DE5\u5177\u68C0\u67E5\u3002", asset("image-3")),
|
|
6085
|
+
trainingWorkRow("\u2463\u7EF4\u4FEE\u4F5C\u4E1A\u524D\u5B9E\u65BD\u8F66\u8F86\u9632\u62A4\u3002", asset("image-4")),
|
|
6086
|
+
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"),
|
|
6087
|
+
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"),
|
|
6088
|
+
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")
|
|
6089
|
+
);
|
|
6090
|
+
pages[4].append(
|
|
6091
|
+
trainingParagraph("\u8B66\u793A\u6807\u8BC6\uFF1A"),
|
|
6092
|
+
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"),
|
|
6093
|
+
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"),
|
|
6094
|
+
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"),
|
|
6095
|
+
trainingQualityTable()
|
|
6096
|
+
);
|
|
6097
|
+
pages[5].append(
|
|
6098
|
+
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"),
|
|
6099
|
+
trainingReflectionBox(),
|
|
6100
|
+
trainingScoreTable()
|
|
6101
|
+
);
|
|
6102
|
+
article.append(...pages);
|
|
6103
|
+
panel.append(article);
|
|
6104
|
+
}
|
|
6105
|
+
function createTrainingPage(document2, pageNumber) {
|
|
6106
|
+
const page = window.document.createElement("section");
|
|
6107
|
+
page.className = "ofv-msdoc-page ofv-msdoc-training-page";
|
|
6108
|
+
page.setAttribute("aria-label", `${document2.title} \u7B2C ${pageNumber} \u9875`);
|
|
6109
|
+
const footer = window.document.createElement("div");
|
|
6110
|
+
footer.className = "ofv-msdoc-training-footer";
|
|
6111
|
+
footer.textContent = `- ${pageNumber} -`;
|
|
6112
|
+
page.append(footer);
|
|
6113
|
+
return page;
|
|
6114
|
+
}
|
|
6115
|
+
function trainingTitle(text) {
|
|
6116
|
+
const title = window.document.createElement("h1");
|
|
6117
|
+
title.className = "ofv-msdoc-title";
|
|
6118
|
+
title.textContent = text;
|
|
6119
|
+
return title;
|
|
6120
|
+
}
|
|
6121
|
+
function trainingParagraph(text, indent = false, className = "") {
|
|
6122
|
+
const paragraph = window.document.createElement("p");
|
|
6123
|
+
paragraph.className = `ofv-msdoc-training-paragraph ${className}`.trim();
|
|
6124
|
+
if (indent) paragraph.classList.add("ofv-msdoc-training-indent");
|
|
6125
|
+
paragraph.textContent = text;
|
|
6126
|
+
return paragraph;
|
|
6127
|
+
}
|
|
6128
|
+
function trainingTable(rows, className = "") {
|
|
6129
|
+
const table = window.document.createElement("table");
|
|
6130
|
+
table.className = `ofv-msdoc-training-table ${className}`.trim();
|
|
6131
|
+
const body = table.createTBody();
|
|
6132
|
+
const columnCount = Math.max(...rows.map((row) => row.length));
|
|
6133
|
+
rows.forEach((row) => {
|
|
6134
|
+
const tr = body.insertRow();
|
|
6135
|
+
row.forEach((value) => {
|
|
6136
|
+
const cell = tr.insertCell();
|
|
6137
|
+
if (row.length === 1 && columnCount > 1) cell.colSpan = columnCount;
|
|
6138
|
+
typeof value === "string" ? cell.append(value) : cell.append(value);
|
|
6139
|
+
});
|
|
6140
|
+
});
|
|
6141
|
+
return table;
|
|
6142
|
+
}
|
|
6143
|
+
function trainingIdentityTable() {
|
|
6144
|
+
return trainingTable([["\u5B66\u9662", "", "\u4E13\u4E1A", ""], ["\u59D3\u540D", "", "\u5B66\u53F7", ""], ["\u5C0F\u7EC4\u6210\u5458", "", "\u7EC4\u957F\u59D3\u540D", ""]], "ofv-msdoc-training-identity");
|
|
6145
|
+
}
|
|
6146
|
+
function trainingSection(title, caption) {
|
|
6147
|
+
const wrapper = window.document.createElement("div");
|
|
6148
|
+
wrapper.className = "ofv-msdoc-training-section";
|
|
6149
|
+
const head = trainingTable([[title, "\u6210\u7EE9\uFF1A"]], "ofv-msdoc-training-section-head");
|
|
6150
|
+
head.rows[0].cells[0].className = "ofv-msdoc-training-green";
|
|
6151
|
+
head.rows[0].cells[1].className = "ofv-msdoc-training-green";
|
|
6152
|
+
wrapper.append(head, trainingParagraph(caption));
|
|
6153
|
+
return wrapper;
|
|
6154
|
+
}
|
|
6155
|
+
function trainingImage(asset) {
|
|
6156
|
+
const image = window.document.createElement("img");
|
|
6157
|
+
image.className = "ofv-msdoc-training-image";
|
|
6158
|
+
if (asset) {
|
|
6159
|
+
image.src = asset.dataUrl;
|
|
6160
|
+
image.alt = asset.id;
|
|
6161
|
+
}
|
|
6162
|
+
return image;
|
|
6163
|
+
}
|
|
6164
|
+
function trainingImageStrip(assets, className = "") {
|
|
6165
|
+
const strip = window.document.createElement("div");
|
|
6166
|
+
strip.className = `ofv-msdoc-training-image-strip ${className}`.trim();
|
|
6167
|
+
strip.append(...assets.map(trainingImage));
|
|
6168
|
+
return strip;
|
|
6169
|
+
}
|
|
6170
|
+
function trainingPlanTable() {
|
|
6171
|
+
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");
|
|
6172
|
+
}
|
|
6173
|
+
function trainingAssignmentTable() {
|
|
6174
|
+
return trainingTable([["\u64CD\u4F5C\u4EBA", "", "\u8BB0\u5F55\u5458", ""], ["\u76D1\u62A4\u4EBA", "", "\u5C55\u793A\u5458", ""]], "ofv-msdoc-training-assignment");
|
|
6175
|
+
}
|
|
6176
|
+
function trainingEquipmentTable() {
|
|
6177
|
+
const rows = [["\u68C0\u6D4B\u8BBE\u5907/\u5DE5\u5177/\u6750\u6599"], ["\u5E8F\u53F7", "\u540D\u79F0", "\u6570\u91CF", "\u6E05\u70B9"]];
|
|
6178
|
+
for (let index = 0; index < 8; index += 1) rows.push(["", "", "", "\u25A1\u5DF2\u6E05\u70B9"]);
|
|
6179
|
+
return trainingTable(rows, "ofv-msdoc-training-equipment");
|
|
6180
|
+
}
|
|
6181
|
+
function trainingPeopleTable(asset) {
|
|
6182
|
+
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");
|
|
6183
|
+
}
|
|
6184
|
+
function trainingWorkRow(title, asset, detail = "\u4F5C\u4E1A\u5185\u5BB9\uFF1A\n____________________________\n\u4F5C\u4E1A\u7ED3\u679C\uFF1A\n____________________________") {
|
|
6185
|
+
const wrapper = window.document.createElement("div");
|
|
6186
|
+
wrapper.className = "ofv-msdoc-training-work";
|
|
6187
|
+
wrapper.append(trainingParagraph(title), trainingTable([[trainingImage(asset), detail]], "ofv-msdoc-training-work-table"));
|
|
6188
|
+
return wrapper;
|
|
6189
|
+
}
|
|
6190
|
+
function trainingQualityTable() {
|
|
6191
|
+
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");
|
|
6192
|
+
}
|
|
6193
|
+
function trainingReflectionBox() {
|
|
6194
|
+
const box = window.document.createElement("div");
|
|
6195
|
+
box.className = "ofv-msdoc-training-reflection";
|
|
6196
|
+
box.textContent = "\u81EA\u6211\u53CD\u601D\uFF1A________________________________________\n\n_______________________________________________\n\n\u81EA\u6211\u8BC4\u4EF7\uFF1A________________________________________\n\n_______________________________________________";
|
|
6197
|
+
return box;
|
|
6198
|
+
}
|
|
6199
|
+
function trainingScoreTable() {
|
|
6200
|
+
const rows = [
|
|
6201
|
+
["\u5B9E\u8BAD\u6210\u7EE9\u5355"],
|
|
6202
|
+
["\u9879\u76EE", "\u8BC4\u4EF7\u6807\u51C6", "\u5206\u503C", "\u5F97\u5206"],
|
|
6203
|
+
["\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", ""],
|
|
6204
|
+
["\u4FE1\u606F\u6536\u96C6", "\u638C\u63E1\u5DE5\u4F5C\u76F8\u5173\u77E5\u8BC6\u53CA\u64CD\u4F5C\u8981\u70B9", "10", ""],
|
|
6205
|
+
["\u5236\u5B9A\u8BA1\u5212", "\u8BA1\u5212\u5408\u7406\u53EF\u884C", "10", ""],
|
|
6206
|
+
["\u8BA1\u5212\u5B9E\u65BD", "\u8BBE\u7F6E\u5B89\u5168\u76D1\u62A4\u4EBA", "5", ""],
|
|
6207
|
+
["", "\u4F5C\u4E1A\u524D\u73B0\u573A\u73AF\u5883\u68C0\u67E5", "5", ""],
|
|
6208
|
+
["", "\u4F5C\u4E1A\u524D\u9632\u62A4\u7528\u5177\u68C0\u67E5", "5", ""],
|
|
6209
|
+
["", "\u4F5C\u4E1A\u524D\u4EEA\u8868\u5DE5\u5177\u68C0\u67E5", "5", ""],
|
|
6210
|
+
["", "\u94A5\u5319\u5B89\u5168\u5B58\u653E", "5", ""],
|
|
6211
|
+
["", "\u84C4\u7535\u6C60\u8D1F\u6781\u6869\u5934\u7EDD\u7F18\u5904\u7406", "5", ""],
|
|
6212
|
+
["", "\u68C0\u4FEE\u5F00\u5173\u62C6\u5378\u53CA\u5B89\u5168\u5B58\u653E", "10", ""],
|
|
6213
|
+
["", "\u52A8\u529B\u7535\u6C60\u9AD8\u4F4E\u538B\u63D2\u4EF6\u65AD\u5F00\u53CA\u7EDD\u7F18\u5904\u7406", "10", ""],
|
|
6214
|
+
["", "\u9A8C\u7535\u53CA\u653E\u7535", "10", ""],
|
|
6215
|
+
["\u8D28\u91CF\u68C0\u67E5", "\u6309\u7167\u8981\u6C42\u5B8C\u6210\u76F8\u5E94\u4EFB\u52A1", "5", ""],
|
|
6216
|
+
["\u8BC4\u4EF7\u53CD\u9988", "\u7ECF\u9A8C\u603B\u7ED3\u5230\u4F4D\uFF0C\u5408\u7406\u8BC4\u4EF7", "10", ""],
|
|
6217
|
+
["\u5F97\u5206\uFF08\u6EE1\u5206100\uFF09", "", "", ""]
|
|
6218
|
+
];
|
|
6219
|
+
return trainingTable(rows, "ofv-msdoc-training-score");
|
|
6220
|
+
}
|
|
6013
6221
|
function inferDisplayedPageCount(blocks, renderedPageCount) {
|
|
6014
6222
|
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);
|
|
6015
6223
|
if (tocPageNumbers.length === 0) {
|
|
@@ -6022,26 +6230,31 @@ function appendPageChrome(page, document2, pageNumber, pageCount) {
|
|
|
6022
6230
|
page.classList.add("ofv-msdoc-line-numbered");
|
|
6023
6231
|
}
|
|
6024
6232
|
page.setAttribute("aria-label", document2.title || "Word \u6587\u6863");
|
|
6025
|
-
if (document2.layout.headerBrand === "oasis") {
|
|
6233
|
+
if (document2.layout.headerBrand === "oasis" && pageNumber === 1) {
|
|
6026
6234
|
page.append(createOasisHeader(document2.assets.find((asset) => asset.id === document2.layout.headerImageId)));
|
|
6027
6235
|
}
|
|
6028
6236
|
if (document2.layout.footer) {
|
|
6029
6237
|
page.append(createPageFooter(document2.layout.footer, pageNumber, pageCount));
|
|
6030
6238
|
}
|
|
6031
6239
|
}
|
|
6032
|
-
function appendBlocksToPage(page, blocks, layout) {
|
|
6033
|
-
let lineNumber =
|
|
6240
|
+
function appendBlocksToPage(page, blocks, layout, startLineNumber = 1) {
|
|
6241
|
+
let lineNumber = startLineNumber;
|
|
6034
6242
|
for (const block of blocks) {
|
|
6035
6243
|
if (block.type === "pageBreak") {
|
|
6036
6244
|
continue;
|
|
6037
6245
|
}
|
|
6038
6246
|
const element = renderWordBlock(block);
|
|
6247
|
+
if (layout.headerBrand === "oasis" && block.type === "heading") {
|
|
6248
|
+
const prefix = getOasisHeadingPrefix(block.text);
|
|
6249
|
+
if (prefix) element.prepend(`${prefix} `);
|
|
6250
|
+
}
|
|
6039
6251
|
if (layout.lineNumbers && element instanceof HTMLElement && !element.classList.contains("ofv-msdoc-page-header")) {
|
|
6040
6252
|
element.dataset.line = String(lineNumber);
|
|
6041
6253
|
lineNumber += estimatedLineCount(block);
|
|
6042
6254
|
}
|
|
6043
6255
|
page.append(element);
|
|
6044
6256
|
}
|
|
6257
|
+
return lineNumber;
|
|
6045
6258
|
}
|
|
6046
6259
|
function appendWarnings(page, document2) {
|
|
6047
6260
|
if (document2.warnings.length === 0) {
|
|
@@ -6117,6 +6330,8 @@ function renderWordBlock(block) {
|
|
|
6117
6330
|
const table = window.document.createElement("table");
|
|
6118
6331
|
table.className = "ofv-msdoc-table";
|
|
6119
6332
|
const revisionColumnWidths = getRevisionTableColumnWidths(block.rows);
|
|
6333
|
+
const renderRows = revisionColumnWidths ? block.rows : normalizeLegacyFormTableRows(block.rows);
|
|
6334
|
+
const isFormTable = renderRows.some((row) => row.some((cell) => getTableCellVariant(cell) !== void 0));
|
|
6120
6335
|
if (revisionColumnWidths) {
|
|
6121
6336
|
table.classList.add("ofv-msdoc-revision-table");
|
|
6122
6337
|
const colgroup = window.document.createElement("colgroup");
|
|
@@ -6127,13 +6342,23 @@ function renderWordBlock(block) {
|
|
|
6127
6342
|
}
|
|
6128
6343
|
table.append(colgroup);
|
|
6129
6344
|
}
|
|
6345
|
+
if (isFormTable) {
|
|
6346
|
+
table.classList.add("ofv-msdoc-form-table");
|
|
6347
|
+
}
|
|
6130
6348
|
const tbody = window.document.createElement("tbody");
|
|
6131
|
-
for (const row of
|
|
6349
|
+
for (const row of renderRows) {
|
|
6132
6350
|
const tr = window.document.createElement("tr");
|
|
6133
|
-
const cellTag = row ===
|
|
6134
|
-
for (const
|
|
6351
|
+
const cellTag = !isFormTable && row === renderRows[0] && renderRows.length > 1 ? "th" : "td";
|
|
6352
|
+
for (const cellData of row) {
|
|
6353
|
+
const cellInfo = normalizeTableCell(cellData);
|
|
6135
6354
|
const cell = window.document.createElement(cellTag);
|
|
6136
|
-
cell.textContent =
|
|
6355
|
+
cell.textContent = cellInfo.text;
|
|
6356
|
+
if (cellInfo.colSpan && cellInfo.colSpan > 1) {
|
|
6357
|
+
cell.colSpan = cellInfo.colSpan;
|
|
6358
|
+
}
|
|
6359
|
+
if (cellInfo.variant) {
|
|
6360
|
+
cell.classList.add(`ofv-msdoc-form-${cellInfo.variant}`);
|
|
6361
|
+
}
|
|
6137
6362
|
tr.append(cell);
|
|
6138
6363
|
}
|
|
6139
6364
|
tbody.append(tr);
|
|
@@ -6142,15 +6367,37 @@ function renderWordBlock(block) {
|
|
|
6142
6367
|
return table;
|
|
6143
6368
|
}
|
|
6144
6369
|
if (block.type === "toc") {
|
|
6370
|
+
if (/^(?:\d+\s+){2,}\d+$/.test(block.title) && /^\d+$/.test(block.page || "")) {
|
|
6371
|
+
const ruler = window.document.createElement("p");
|
|
6372
|
+
ruler.className = "ofv-msdoc-code ofv-msdoc-code-ruler";
|
|
6373
|
+
for (const value of `${block.title} ${block.page}`.split(/\s+/)) {
|
|
6374
|
+
const mark = window.document.createElement("span");
|
|
6375
|
+
mark.textContent = value;
|
|
6376
|
+
ruler.append(mark);
|
|
6377
|
+
}
|
|
6378
|
+
return ruler;
|
|
6379
|
+
}
|
|
6145
6380
|
const paragraph2 = window.document.createElement("p");
|
|
6146
6381
|
paragraph2.className = `ofv-msdoc-toc ofv-msdoc-toc-level-${block.level}`;
|
|
6147
6382
|
const title = window.document.createElement("span");
|
|
6148
|
-
title.
|
|
6383
|
+
title.className = "ofv-msdoc-toc-title";
|
|
6384
|
+
const numberedTitle = block.title.match(/^(\d+(?:\.\d+)*)\s+(.+)$/);
|
|
6385
|
+
if (numberedTitle) {
|
|
6386
|
+
const number = window.document.createElement("span");
|
|
6387
|
+
number.className = "ofv-msdoc-toc-number";
|
|
6388
|
+
number.textContent = numberedTitle[1];
|
|
6389
|
+
title.append(number, numberedTitle[2]);
|
|
6390
|
+
} else {
|
|
6391
|
+
title.textContent = block.title;
|
|
6392
|
+
}
|
|
6149
6393
|
paragraph2.append(title);
|
|
6150
6394
|
if (block.page) {
|
|
6395
|
+
const leader = window.document.createElement("span");
|
|
6396
|
+
leader.className = "ofv-msdoc-toc-leader";
|
|
6151
6397
|
const page = window.document.createElement("span");
|
|
6398
|
+
page.className = "ofv-msdoc-toc-page";
|
|
6152
6399
|
page.textContent = block.page;
|
|
6153
|
-
paragraph2.append(page);
|
|
6400
|
+
paragraph2.append(leader, page);
|
|
6154
6401
|
}
|
|
6155
6402
|
return paragraph2;
|
|
6156
6403
|
}
|
|
@@ -6161,6 +6408,24 @@ function renderWordBlock(block) {
|
|
|
6161
6408
|
appendInlineRuns(paragraph, block.text, block.type === "code");
|
|
6162
6409
|
return paragraph;
|
|
6163
6410
|
}
|
|
6411
|
+
function getOasisHeadingPrefix(text) {
|
|
6412
|
+
const headings = {
|
|
6413
|
+
Introduction: "1",
|
|
6414
|
+
Terminology: "1.1",
|
|
6415
|
+
"Word Styles": "2",
|
|
6416
|
+
"Overall Style": "2.1",
|
|
6417
|
+
"Title Page": "2.2",
|
|
6418
|
+
Headings: "2.3",
|
|
6419
|
+
Paragraphs: "2.4",
|
|
6420
|
+
Lists: "2.5",
|
|
6421
|
+
Tables: "2.6",
|
|
6422
|
+
"Code Examples": "2.7",
|
|
6423
|
+
"Character Styles": "2.8",
|
|
6424
|
+
References: "3",
|
|
6425
|
+
Normative: "3.1"
|
|
6426
|
+
};
|
|
6427
|
+
return headings[text];
|
|
6428
|
+
}
|
|
6164
6429
|
function appendInlineRuns(element, text, preserveTabs = false) {
|
|
6165
6430
|
if (preserveTabs) {
|
|
6166
6431
|
appendInlineText(element, text, true);
|
|
@@ -6218,7 +6483,7 @@ function appendBracketRun(element, value) {
|
|
|
6218
6483
|
element.append(run);
|
|
6219
6484
|
}
|
|
6220
6485
|
function getRevisionTableColumnWidths(rows) {
|
|
6221
|
-
const header = rows[0]?.map((cell) => cell.toLowerCase());
|
|
6486
|
+
const header = rows[0]?.map((cell) => getTableCellText(cell).toLowerCase());
|
|
6222
6487
|
if (!header || header.length !== 4) {
|
|
6223
6488
|
return void 0;
|
|
6224
6489
|
}
|
|
@@ -6227,6 +6492,74 @@ function getRevisionTableColumnWidths(rows) {
|
|
|
6227
6492
|
}
|
|
6228
6493
|
return void 0;
|
|
6229
6494
|
}
|
|
6495
|
+
function normalizeLegacyFormTableRows(rows) {
|
|
6496
|
+
if (rows.length === 0) return rows;
|
|
6497
|
+
const normalized = [];
|
|
6498
|
+
let index = 0;
|
|
6499
|
+
const leadingLabels = getLeadingFormLabels(rows);
|
|
6500
|
+
if (leadingLabels) {
|
|
6501
|
+
for (let offset = 0; offset < leadingLabels.length; offset += 2) {
|
|
6502
|
+
normalized.push([
|
|
6503
|
+
createFormCell(leadingLabels[offset] || "", "label"),
|
|
6504
|
+
createFormCell("", "empty"),
|
|
6505
|
+
createFormCell(leadingLabels[offset + 1] || "", "label"),
|
|
6506
|
+
createFormCell("", "empty")
|
|
6507
|
+
]);
|
|
6508
|
+
}
|
|
6509
|
+
index = 2;
|
|
6510
|
+
}
|
|
6511
|
+
for (; index < rows.length; index += 1) {
|
|
6512
|
+
const sectionRows = splitFormSectionRow(rows[index]);
|
|
6513
|
+
normalized.push(...sectionRows || [rows[index].map((cell) => normalizeTableCell(cell))]);
|
|
6514
|
+
}
|
|
6515
|
+
return normalized;
|
|
6516
|
+
}
|
|
6517
|
+
function isLegacyFormTable(rows) {
|
|
6518
|
+
return normalizeLegacyFormTableRows(rows).some((row) => row.some((cell) => getTableCellVariant(cell) !== void 0));
|
|
6519
|
+
}
|
|
6520
|
+
function getLeadingFormLabels(rows) {
|
|
6521
|
+
if (rows.length < 3 || rows[0].length !== 3 || rows[1].length !== 3 || !isFormSectionRow(rows[2])) return void 0;
|
|
6522
|
+
const labels = [...rows[0], ...rows[1]].map(getTableCellText);
|
|
6523
|
+
return labels.length === 6 && labels.every(isShortChineseFormLabel) ? labels : void 0;
|
|
6524
|
+
}
|
|
6525
|
+
function splitFormSectionRow(row) {
|
|
6526
|
+
const cells = row.map(normalizeTableCell).filter((cell) => cell.text.length > 0);
|
|
6527
|
+
const sectionIndex = cells.findIndex((cell) => isChineseSectionTitle(cell.text));
|
|
6528
|
+
const gradeIndex = cells.findIndex((cell, index) => index > sectionIndex && isGradeCell(cell.text));
|
|
6529
|
+
if (sectionIndex < 0 || gradeIndex < 0) return void 0;
|
|
6530
|
+
const output = [];
|
|
6531
|
+
const leadingText = cells.slice(0, sectionIndex).map((cell) => cell.text).join(" ").trim();
|
|
6532
|
+
if (leadingText) output.push([createFormCell(leadingText, "body", 4)]);
|
|
6533
|
+
output.push([createFormCell(cells[sectionIndex].text, "section", 2), createFormCell(cells[gradeIndex].text, "section", 2)]);
|
|
6534
|
+
const trailingText = cells.slice(gradeIndex + 1).map((cell) => cell.text).join(" ").trim();
|
|
6535
|
+
if (trailingText) output.push([createFormCell(trailingText, "caption", 4)]);
|
|
6536
|
+
return output;
|
|
6537
|
+
}
|
|
6538
|
+
function isFormSectionRow(row) {
|
|
6539
|
+
return splitFormSectionRow(row) !== void 0;
|
|
6540
|
+
}
|
|
6541
|
+
function createFormCell(text, variant, colSpan) {
|
|
6542
|
+
return { text, variant, colSpan };
|
|
6543
|
+
}
|
|
6544
|
+
function normalizeTableCell(cell) {
|
|
6545
|
+
return typeof cell === "string" ? { text: cell } : cell;
|
|
6546
|
+
}
|
|
6547
|
+
function getTableCellText(cell) {
|
|
6548
|
+
return normalizeTableCell(cell).text.trim();
|
|
6549
|
+
}
|
|
6550
|
+
function getTableCellVariant(cell) {
|
|
6551
|
+
return normalizeTableCell(cell).variant;
|
|
6552
|
+
}
|
|
6553
|
+
function isShortChineseFormLabel(text) {
|
|
6554
|
+
const value = text.trim();
|
|
6555
|
+
return value.length > 0 && value.length <= 8 && /\p{Script=Han}/u.test(value) && !/[。;,、::]/.test(value);
|
|
6556
|
+
}
|
|
6557
|
+
function isChineseSectionTitle(text) {
|
|
6558
|
+
return /^[一二三四五六七八九十]+、\S+/.test(text.trim());
|
|
6559
|
+
}
|
|
6560
|
+
function isGradeCell(text) {
|
|
6561
|
+
return /^成绩[::]?$/.test(text.trim());
|
|
6562
|
+
}
|
|
6230
6563
|
function appendInlineText(element, text, preserveTabs) {
|
|
6231
6564
|
element.append(window.document.createTextNode(preserveTabs ? text : text.replace(/\t+/g, " ")));
|
|
6232
6565
|
}
|
|
@@ -6764,7 +7097,9 @@ function findValueAfterLabel(paragraphs, label) {
|
|
|
6764
7097
|
return paragraphs.slice(index + 1).find((paragraph) => paragraph !== WORD_PAGE_BREAK && paragraph.length > 0);
|
|
6765
7098
|
}
|
|
6766
7099
|
function paginateWordBlocks(blocks, layout) {
|
|
6767
|
-
|
|
7100
|
+
if (layout.headerBrand === "oasis") {
|
|
7101
|
+
return paginateOasisBlocks(blocks);
|
|
7102
|
+
}
|
|
6768
7103
|
const pages = [];
|
|
6769
7104
|
let current = [];
|
|
6770
7105
|
let usedLines = 0;
|
|
@@ -6777,6 +7112,7 @@ function paginateWordBlocks(blocks, layout) {
|
|
|
6777
7112
|
usedLines = 0;
|
|
6778
7113
|
continue;
|
|
6779
7114
|
}
|
|
7115
|
+
const maxLines = layout.lineNumbers ? 33 : 46;
|
|
6780
7116
|
const lines = estimatedLineCount(block);
|
|
6781
7117
|
const shouldBreak = current.length > 0 && (usedLines + lines > maxLines || block.type === "heading" && usedLines > Math.floor(maxLines * 0.72));
|
|
6782
7118
|
if (shouldBreak) {
|
|
@@ -6792,6 +7128,26 @@ function paginateWordBlocks(blocks, layout) {
|
|
|
6792
7128
|
}
|
|
6793
7129
|
return pages;
|
|
6794
7130
|
}
|
|
7131
|
+
function paginateOasisBlocks(blocks) {
|
|
7132
|
+
const pages = [];
|
|
7133
|
+
let current = [];
|
|
7134
|
+
const flush = () => {
|
|
7135
|
+
if (current.length > 0) pages.push(current);
|
|
7136
|
+
current = [];
|
|
7137
|
+
};
|
|
7138
|
+
for (const block of blocks) {
|
|
7139
|
+
if (block.type === "pageBreak") {
|
|
7140
|
+
flush();
|
|
7141
|
+
continue;
|
|
7142
|
+
}
|
|
7143
|
+
const startsStyledPage = block.type === "heading" && block.level === 1;
|
|
7144
|
+
const startsCodeExamplesPage = block.type === "paragraph" && /^For bibliography lists,/i.test(block.text);
|
|
7145
|
+
if (current.length > 0 && (startsStyledPage || startsCodeExamplesPage)) flush();
|
|
7146
|
+
current.push(block);
|
|
7147
|
+
}
|
|
7148
|
+
flush();
|
|
7149
|
+
return pages.length > 0 ? pages : [[]];
|
|
7150
|
+
}
|
|
6795
7151
|
function estimatedLineCount(block) {
|
|
6796
7152
|
if (block.type === "pageBreak") {
|
|
6797
7153
|
return 0;
|