oasis-editor 0.0.84 → 0.0.86
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/{OasisEditorApp-lNYRC99y.js → OasisEditorApp-CE15GH_N.js} +1 -1
- package/dist/assets/{importDocxWorker-8fivvDCX.js → importDocxWorker-C94l6-O5.js} +1 -1
- package/dist/core/endnotes.d.ts +0 -5
- package/dist/core/footnotes.d.ts +0 -5
- package/dist/core/noteTraversal.d.ts +77 -0
- package/dist/{index-9_ibx79n.js → index-DFKc0jbc.js} +195 -271
- package/dist/layoutProjection/footnotePagination.d.ts +2 -2
- package/dist/layoutProjection/headerFooterFootnotes.d.ts +3 -3
- package/dist/layoutProjection/headerFooterLayoutContext.d.ts +14 -0
- package/dist/layoutProjection/headerFooterProjection.d.ts +2 -1
- package/dist/layoutProjection/sectionPagination.d.ts +2 -2
- package/dist/oasis-editor.js +1 -1
- package/dist/oasis-editor.umd.cjs +4 -4
- package/package.json +1 -1
|
@@ -2483,7 +2483,7 @@ function OasisEditorAppLazy(props = {}) {
|
|
|
2483
2483
|
onCleanup(() => {
|
|
2484
2484
|
cancelled = true;
|
|
2485
2485
|
});
|
|
2486
|
-
import("./OasisEditorApp-
|
|
2486
|
+
import("./OasisEditorApp-CE15GH_N.js").then((m) => {
|
|
2487
2487
|
cancelled = true;
|
|
2488
2488
|
setProgress(1);
|
|
2489
2489
|
setTimeout(() => setApp(() => m.OasisEditorApp), 180);
|
|
@@ -5201,14 +5201,16 @@ function projectFootnoteBlocksForPage(document2, footnoteReferenceIds, page, tot
|
|
|
5201
5201
|
if (!footnote) continue;
|
|
5202
5202
|
const projected = projectBlocks(
|
|
5203
5203
|
footnote.blocks,
|
|
5204
|
-
|
|
5205
|
-
|
|
5206
|
-
|
|
5207
|
-
|
|
5208
|
-
|
|
5209
|
-
|
|
5210
|
-
|
|
5211
|
-
|
|
5204
|
+
{
|
|
5205
|
+
pageIndex: page.index,
|
|
5206
|
+
totalPages,
|
|
5207
|
+
measuredHeights,
|
|
5208
|
+
measuredParagraphLayouts,
|
|
5209
|
+
styles: document2.styles,
|
|
5210
|
+
contentWidth,
|
|
5211
|
+
measurer,
|
|
5212
|
+
defaultTabStop: (_c = document2.settings) == null ? void 0 : _c.defaultTabStop
|
|
5213
|
+
}
|
|
5212
5214
|
);
|
|
5213
5215
|
for (const block of projected) {
|
|
5214
5216
|
blocks.push({
|
|
@@ -12773,7 +12775,16 @@ function estimateTableBlockHeight(table, styles, contentWidth, measurer = domTex
|
|
|
12773
12775
|
defaultTabStop
|
|
12774
12776
|
);
|
|
12775
12777
|
}
|
|
12776
|
-
function projectHeaderFooterBlocksWithDependencies(blocks, deps,
|
|
12778
|
+
function projectHeaderFooterBlocksWithDependencies(blocks, deps, context2 = {}) {
|
|
12779
|
+
const {
|
|
12780
|
+
pageIndex,
|
|
12781
|
+
totalPages,
|
|
12782
|
+
measuredHeights,
|
|
12783
|
+
styles,
|
|
12784
|
+
contentWidth,
|
|
12785
|
+
measurer,
|
|
12786
|
+
defaultTabStop
|
|
12787
|
+
} = context2;
|
|
12777
12788
|
return blocks.map((block, index) => {
|
|
12778
12789
|
if (block.type === "paragraph") {
|
|
12779
12790
|
const layout = deps.projectParagraphLayout(
|
|
@@ -12812,7 +12823,7 @@ function projectHeaderFooterBlocksWithDependencies(blocks, deps, pageIndex, tota
|
|
|
12812
12823
|
};
|
|
12813
12824
|
});
|
|
12814
12825
|
}
|
|
12815
|
-
function projectHeaderFooterBlocks(blocks,
|
|
12826
|
+
function projectHeaderFooterBlocks(blocks, context2 = {}) {
|
|
12816
12827
|
return projectHeaderFooterBlocksWithDependencies(
|
|
12817
12828
|
blocks,
|
|
12818
12829
|
{
|
|
@@ -12820,14 +12831,10 @@ function projectHeaderFooterBlocks(blocks, pageIndex, totalPages, measuredHeight
|
|
|
12820
12831
|
estimateTableBlockHeight,
|
|
12821
12832
|
getProjectedParagraphBlockHeight
|
|
12822
12833
|
},
|
|
12823
|
-
|
|
12824
|
-
|
|
12825
|
-
|
|
12826
|
-
|
|
12827
|
-
styles,
|
|
12828
|
-
contentWidth,
|
|
12829
|
-
measurer,
|
|
12830
|
-
defaultTabStop
|
|
12834
|
+
{
|
|
12835
|
+
...context2,
|
|
12836
|
+
measurer: context2.measurer ?? domTextMeasurer
|
|
12837
|
+
}
|
|
12831
12838
|
);
|
|
12832
12839
|
}
|
|
12833
12840
|
const MAX_COLUMN_BALANCE_ITERATIONS = 100;
|
|
@@ -13827,14 +13834,16 @@ function resolveEffectiveVerticalMetrics(pageSettings, headerBlocks, footerBlock
|
|
|
13827
13834
|
function createHeaderFooterVariantProjector(context2) {
|
|
13828
13835
|
return (blocks, contentWidth, pageIndex, totalPageCount) => blocks ? context2.projectHeaderFooterBlocks(
|
|
13829
13836
|
blocks,
|
|
13830
|
-
|
|
13831
|
-
|
|
13832
|
-
|
|
13833
|
-
|
|
13834
|
-
|
|
13835
|
-
|
|
13836
|
-
|
|
13837
|
-
|
|
13837
|
+
{
|
|
13838
|
+
pageIndex,
|
|
13839
|
+
totalPages: totalPageCount,
|
|
13840
|
+
measuredHeights: context2.measuredHeights,
|
|
13841
|
+
measuredParagraphLayouts: context2.measuredParagraphLayouts,
|
|
13842
|
+
styles: context2.documentStyles,
|
|
13843
|
+
contentWidth,
|
|
13844
|
+
measurer: context2.measurer,
|
|
13845
|
+
defaultTabStop: context2.defaultTabStop
|
|
13846
|
+
}
|
|
13838
13847
|
) : void 0;
|
|
13839
13848
|
}
|
|
13840
13849
|
function projectTallestHeaderVariant(section, contentWidth, projectHeaderFooterVariant) {
|
|
@@ -14000,7 +14009,7 @@ function projectDocumentSections(context2, reservedHeightByPageIndex) {
|
|
|
14000
14009
|
)
|
|
14001
14010
|
};
|
|
14002
14011
|
}
|
|
14003
|
-
function*
|
|
14012
|
+
function* iterateNoteReferenceRuns(document2, runKind) {
|
|
14004
14013
|
const sections = getDocumentSectionsCanonical(document2);
|
|
14005
14014
|
for (const section of sections) {
|
|
14006
14015
|
const zones = [
|
|
@@ -14016,7 +14025,7 @@ function* iterateFootnoteReferenceRuns(document2) {
|
|
|
14016
14025
|
for (const block of blocks) {
|
|
14017
14026
|
for (const paragraph of getBlockParagraphs(block)) {
|
|
14018
14027
|
for (const run of paragraph.runs) {
|
|
14019
|
-
if (run.kind ===
|
|
14028
|
+
if (run.kind === runKind) {
|
|
14020
14029
|
yield { paragraph, run };
|
|
14021
14030
|
}
|
|
14022
14031
|
}
|
|
@@ -14025,103 +14034,56 @@ function* iterateFootnoteReferenceRuns(document2) {
|
|
|
14025
14034
|
}
|
|
14026
14035
|
}
|
|
14027
14036
|
}
|
|
14028
|
-
|
|
14029
|
-
const ROMAN_NUMERALS = [
|
|
14030
|
-
[1e3, "m"],
|
|
14031
|
-
[900, "cm"],
|
|
14032
|
-
[500, "d"],
|
|
14033
|
-
[400, "cd"],
|
|
14034
|
-
[100, "c"],
|
|
14035
|
-
[90, "xc"],
|
|
14036
|
-
[50, "l"],
|
|
14037
|
-
[40, "xl"],
|
|
14038
|
-
[10, "x"],
|
|
14039
|
-
[9, "ix"],
|
|
14040
|
-
[5, "v"],
|
|
14041
|
-
[4, "iv"],
|
|
14042
|
-
[1, "i"]
|
|
14043
|
-
];
|
|
14044
|
-
function toRoman(value) {
|
|
14045
|
-
if (value <= 0) return String(value);
|
|
14046
|
-
let remaining = value;
|
|
14047
|
-
let result = "";
|
|
14048
|
-
for (const [size, glyph] of ROMAN_NUMERALS) {
|
|
14049
|
-
while (remaining >= size) {
|
|
14050
|
-
result += glyph;
|
|
14051
|
-
remaining -= size;
|
|
14052
|
-
}
|
|
14053
|
-
}
|
|
14054
|
-
return result;
|
|
14055
|
-
}
|
|
14056
|
-
function toLetters(value) {
|
|
14057
|
-
if (value <= 0) return String(value);
|
|
14058
|
-
let remaining = value;
|
|
14059
|
-
let result = "";
|
|
14060
|
-
while (remaining > 0) {
|
|
14061
|
-
const digit = (remaining - 1) % 26;
|
|
14062
|
-
result = LOWER_LETTERS[digit] + result;
|
|
14063
|
-
remaining = Math.floor((remaining - 1) / 26);
|
|
14064
|
-
}
|
|
14065
|
-
return result;
|
|
14066
|
-
}
|
|
14067
|
-
const SYMBOL_MARKS = ["*", "†", "‡", "§", "¶", "#"];
|
|
14068
|
-
function getFootnoteDisplayMarker(oneBasedIndex, format = "decimal") {
|
|
14069
|
-
switch (format) {
|
|
14070
|
-
case "lowerRoman":
|
|
14071
|
-
return toRoman(oneBasedIndex);
|
|
14072
|
-
case "upperRoman":
|
|
14073
|
-
return toRoman(oneBasedIndex).toUpperCase();
|
|
14074
|
-
case "lowerLetter":
|
|
14075
|
-
return toLetters(oneBasedIndex);
|
|
14076
|
-
case "upperLetter":
|
|
14077
|
-
return toLetters(oneBasedIndex).toUpperCase();
|
|
14078
|
-
case "symbol": {
|
|
14079
|
-
const slot = (oneBasedIndex - 1) % SYMBOL_MARKS.length;
|
|
14080
|
-
const cycles = Math.floor((oneBasedIndex - 1) / SYMBOL_MARKS.length) + 1;
|
|
14081
|
-
return SYMBOL_MARKS[slot].repeat(cycles);
|
|
14082
|
-
}
|
|
14083
|
-
case "decimal":
|
|
14084
|
-
default:
|
|
14085
|
-
return String(oneBasedIndex);
|
|
14086
|
-
}
|
|
14087
|
-
}
|
|
14088
|
-
function findFootnoteReference(document2, footnoteId) {
|
|
14037
|
+
function findNoteReference(document2, traversal, noteId) {
|
|
14089
14038
|
var _a;
|
|
14090
|
-
for (const entry of
|
|
14091
|
-
if (((_a =
|
|
14039
|
+
for (const entry of iterateNoteReferenceRuns(document2, traversal.runKind)) {
|
|
14040
|
+
if (((_a = traversal.getRef(entry.run)) == null ? void 0 : _a.id) === noteId) {
|
|
14092
14041
|
return entry;
|
|
14093
14042
|
}
|
|
14094
14043
|
}
|
|
14095
14044
|
return null;
|
|
14096
14045
|
}
|
|
14097
|
-
function
|
|
14098
|
-
|
|
14099
|
-
const
|
|
14100
|
-
|
|
14101
|
-
|
|
14046
|
+
function listReferencedNotes(document2, traversal) {
|
|
14047
|
+
const seen = /* @__PURE__ */ new Set();
|
|
14048
|
+
const result = [];
|
|
14049
|
+
let counter2 = 0;
|
|
14050
|
+
for (const { run } of iterateNoteReferenceRuns(document2, traversal.runKind)) {
|
|
14051
|
+
const ref = traversal.getRef(run);
|
|
14052
|
+
if (!ref) continue;
|
|
14053
|
+
if (seen.has(ref.id)) continue;
|
|
14054
|
+
seen.add(ref.id);
|
|
14055
|
+
if (!ref.customMark) {
|
|
14056
|
+
counter2 += 1;
|
|
14057
|
+
}
|
|
14058
|
+
result.push({
|
|
14059
|
+
id: ref.id,
|
|
14060
|
+
customMark: ref.customMark,
|
|
14061
|
+
index: ref.customMark ? 0 : counter2
|
|
14062
|
+
});
|
|
14102
14063
|
}
|
|
14103
|
-
|
|
14104
|
-
|
|
14064
|
+
return result;
|
|
14065
|
+
}
|
|
14066
|
+
function computeNoteRenumber(document2, collection, traversal) {
|
|
14067
|
+
var _a, _b;
|
|
14068
|
+
const format = ((_a = collection.settings) == null ? void 0 : _a.numberFormat) ?? "decimal";
|
|
14069
|
+
const startAt = ((_b = collection.settings) == null ? void 0 : _b.startAt) ?? 1;
|
|
14105
14070
|
const referenced = /* @__PURE__ */ new Set();
|
|
14106
|
-
const
|
|
14071
|
+
const markerById = /* @__PURE__ */ new Map();
|
|
14107
14072
|
let autoCounter = startAt - 1;
|
|
14108
|
-
for (const { run } of
|
|
14109
|
-
const ref =
|
|
14073
|
+
for (const { run } of iterateNoteReferenceRuns(document2, traversal.runKind)) {
|
|
14074
|
+
const ref = traversal.getRef(run);
|
|
14110
14075
|
if (!ref) continue;
|
|
14111
|
-
referenced.add(ref.
|
|
14076
|
+
referenced.add(ref.id);
|
|
14112
14077
|
if (ref.customMark) {
|
|
14113
|
-
|
|
14078
|
+
markerById.set(ref.id, ref.customMark);
|
|
14114
14079
|
continue;
|
|
14115
14080
|
}
|
|
14116
|
-
if (!
|
|
14081
|
+
if (!markerById.has(ref.id)) {
|
|
14117
14082
|
autoCounter += 1;
|
|
14118
|
-
|
|
14119
|
-
ref.footnoteId,
|
|
14120
|
-
getFootnoteDisplayMarker(autoCounter, format)
|
|
14121
|
-
);
|
|
14083
|
+
markerById.set(ref.id, traversal.formatMarker(autoCounter, format));
|
|
14122
14084
|
}
|
|
14123
14085
|
}
|
|
14124
|
-
let
|
|
14086
|
+
let sectionsChanged = false;
|
|
14125
14087
|
const sections = getDocumentSectionsCanonical(document2).map((section) => {
|
|
14126
14088
|
const rewriteBlocks = (blocks) => {
|
|
14127
14089
|
if (!blocks) return blocks;
|
|
@@ -14129,7 +14091,11 @@ function renumberFootnotes(document2) {
|
|
|
14129
14091
|
const nextBlocks = blocks.map((block) => {
|
|
14130
14092
|
switch (block.type) {
|
|
14131
14093
|
case "paragraph": {
|
|
14132
|
-
const updated = rewriteParagraphMarkers
|
|
14094
|
+
const updated = rewriteParagraphMarkers(
|
|
14095
|
+
block,
|
|
14096
|
+
traversal,
|
|
14097
|
+
markerById
|
|
14098
|
+
);
|
|
14133
14099
|
if (updated !== block) blockChanged = true;
|
|
14134
14100
|
return updated;
|
|
14135
14101
|
}
|
|
@@ -14140,9 +14106,10 @@ function renumberFootnotes(document2) {
|
|
|
14140
14106
|
const nextCells = row.cells.map((cell) => {
|
|
14141
14107
|
let cellChanged = false;
|
|
14142
14108
|
const nextCellBlocks = cell.blocks.map((p) => {
|
|
14143
|
-
const updated = rewriteParagraphMarkers
|
|
14109
|
+
const updated = rewriteParagraphMarkers(
|
|
14144
14110
|
p,
|
|
14145
|
-
|
|
14111
|
+
traversal,
|
|
14112
|
+
markerById
|
|
14146
14113
|
);
|
|
14147
14114
|
if (updated !== p) cellChanged = true;
|
|
14148
14115
|
return updated;
|
|
@@ -14164,7 +14131,7 @@ function renumberFootnotes(document2) {
|
|
|
14164
14131
|
}
|
|
14165
14132
|
});
|
|
14166
14133
|
if (!blockChanged) return blocks;
|
|
14167
|
-
|
|
14134
|
+
sectionsChanged = true;
|
|
14168
14135
|
return nextBlocks;
|
|
14169
14136
|
};
|
|
14170
14137
|
return {
|
|
@@ -14180,31 +14147,21 @@ function renumberFootnotes(document2) {
|
|
|
14180
14147
|
});
|
|
14181
14148
|
const nextItems = {};
|
|
14182
14149
|
let itemsChanged = false;
|
|
14183
|
-
for (const [id,
|
|
14150
|
+
for (const [id, body] of Object.entries(collection.items)) {
|
|
14184
14151
|
if (referenced.has(id)) {
|
|
14185
|
-
nextItems[id] =
|
|
14152
|
+
nextItems[id] = body;
|
|
14186
14153
|
} else {
|
|
14187
14154
|
itemsChanged = true;
|
|
14188
14155
|
}
|
|
14189
14156
|
}
|
|
14190
|
-
|
|
14191
|
-
return document2;
|
|
14192
|
-
}
|
|
14193
|
-
return {
|
|
14194
|
-
...document2,
|
|
14195
|
-
sections: mutatedSections ? sections : document2.sections,
|
|
14196
|
-
footnotes: {
|
|
14197
|
-
...footnotes,
|
|
14198
|
-
items: itemsChanged ? nextItems : footnotes.items
|
|
14199
|
-
}
|
|
14200
|
-
};
|
|
14157
|
+
return { sections, sectionsChanged, nextItems, itemsChanged };
|
|
14201
14158
|
}
|
|
14202
|
-
function rewriteParagraphMarkers
|
|
14159
|
+
function rewriteParagraphMarkers(paragraph, traversal, markerById) {
|
|
14203
14160
|
let runChanged = false;
|
|
14204
14161
|
const nextRuns = paragraph.runs.map((run) => {
|
|
14205
|
-
const ref =
|
|
14162
|
+
const ref = traversal.getRef(run);
|
|
14206
14163
|
if (!ref) return run;
|
|
14207
|
-
const desired =
|
|
14164
|
+
const desired = markerById.get(ref.id);
|
|
14208
14165
|
if (desired === void 0) return run;
|
|
14209
14166
|
if (run.text === desired) return run;
|
|
14210
14167
|
runChanged = true;
|
|
@@ -14213,167 +14170,134 @@ function rewriteParagraphMarkers$1(paragraph, markerByFootnoteId) {
|
|
|
14213
14170
|
if (!runChanged) return paragraph;
|
|
14214
14171
|
return { ...paragraph, runs: nextRuns };
|
|
14215
14172
|
}
|
|
14216
|
-
function
|
|
14217
|
-
|
|
14218
|
-
|
|
14219
|
-
|
|
14220
|
-
|
|
14221
|
-
|
|
14222
|
-
|
|
14223
|
-
|
|
14224
|
-
|
|
14225
|
-
|
|
14226
|
-
|
|
14227
|
-
|
|
14228
|
-
|
|
14229
|
-
|
|
14230
|
-
|
|
14231
|
-
|
|
14232
|
-
|
|
14233
|
-
|
|
14234
|
-
|
|
14235
|
-
|
|
14236
|
-
|
|
14237
|
-
|
|
14173
|
+
function iterateFootnoteReferenceRuns(document2) {
|
|
14174
|
+
return iterateNoteReferenceRuns(document2, "footnoteReference");
|
|
14175
|
+
}
|
|
14176
|
+
const LOWER_LETTERS = "abcdefghijklmnopqrstuvwxyz";
|
|
14177
|
+
const ROMAN_NUMERALS = [
|
|
14178
|
+
[1e3, "m"],
|
|
14179
|
+
[900, "cm"],
|
|
14180
|
+
[500, "d"],
|
|
14181
|
+
[400, "cd"],
|
|
14182
|
+
[100, "c"],
|
|
14183
|
+
[90, "xc"],
|
|
14184
|
+
[50, "l"],
|
|
14185
|
+
[40, "xl"],
|
|
14186
|
+
[10, "x"],
|
|
14187
|
+
[9, "ix"],
|
|
14188
|
+
[5, "v"],
|
|
14189
|
+
[4, "iv"],
|
|
14190
|
+
[1, "i"]
|
|
14191
|
+
];
|
|
14192
|
+
function toRoman(value) {
|
|
14193
|
+
if (value <= 0) return String(value);
|
|
14194
|
+
let remaining = value;
|
|
14195
|
+
let result = "";
|
|
14196
|
+
for (const [size, glyph] of ROMAN_NUMERALS) {
|
|
14197
|
+
while (remaining >= size) {
|
|
14198
|
+
result += glyph;
|
|
14199
|
+
remaining -= size;
|
|
14238
14200
|
}
|
|
14239
14201
|
}
|
|
14202
|
+
return result;
|
|
14240
14203
|
}
|
|
14241
|
-
function
|
|
14242
|
-
|
|
14243
|
-
|
|
14244
|
-
let
|
|
14245
|
-
|
|
14246
|
-
const
|
|
14247
|
-
|
|
14248
|
-
|
|
14249
|
-
seen.add(ref.endnoteId);
|
|
14250
|
-
if (!ref.customMark) {
|
|
14251
|
-
counter2 += 1;
|
|
14252
|
-
}
|
|
14253
|
-
result.push({
|
|
14254
|
-
endnoteId: ref.endnoteId,
|
|
14255
|
-
customMark: ref.customMark,
|
|
14256
|
-
index: ref.customMark ? 0 : counter2
|
|
14257
|
-
});
|
|
14204
|
+
function toLetters(value) {
|
|
14205
|
+
if (value <= 0) return String(value);
|
|
14206
|
+
let remaining = value;
|
|
14207
|
+
let result = "";
|
|
14208
|
+
while (remaining > 0) {
|
|
14209
|
+
const digit = (remaining - 1) % 26;
|
|
14210
|
+
result = LOWER_LETTERS[digit] + result;
|
|
14211
|
+
remaining = Math.floor((remaining - 1) / 26);
|
|
14258
14212
|
}
|
|
14259
14213
|
return result;
|
|
14260
14214
|
}
|
|
14261
|
-
|
|
14262
|
-
|
|
14263
|
-
|
|
14264
|
-
|
|
14215
|
+
const SYMBOL_MARKS = ["*", "†", "‡", "§", "¶", "#"];
|
|
14216
|
+
function getFootnoteDisplayMarker(oneBasedIndex, format = "decimal") {
|
|
14217
|
+
switch (format) {
|
|
14218
|
+
case "lowerRoman":
|
|
14219
|
+
return toRoman(oneBasedIndex);
|
|
14220
|
+
case "upperRoman":
|
|
14221
|
+
return toRoman(oneBasedIndex).toUpperCase();
|
|
14222
|
+
case "lowerLetter":
|
|
14223
|
+
return toLetters(oneBasedIndex);
|
|
14224
|
+
case "upperLetter":
|
|
14225
|
+
return toLetters(oneBasedIndex).toUpperCase();
|
|
14226
|
+
case "symbol": {
|
|
14227
|
+
const slot = (oneBasedIndex - 1) % SYMBOL_MARKS.length;
|
|
14228
|
+
const cycles = Math.floor((oneBasedIndex - 1) / SYMBOL_MARKS.length) + 1;
|
|
14229
|
+
return SYMBOL_MARKS[slot].repeat(cycles);
|
|
14230
|
+
}
|
|
14231
|
+
case "decimal":
|
|
14232
|
+
default:
|
|
14233
|
+
return String(oneBasedIndex);
|
|
14234
|
+
}
|
|
14235
|
+
}
|
|
14236
|
+
const footnoteTraversal = {
|
|
14237
|
+
runKind: "footnoteReference",
|
|
14238
|
+
getRef: (run) => {
|
|
14239
|
+
const ref = getRunFootnoteReference(run);
|
|
14240
|
+
return ref ? { id: ref.footnoteId, customMark: ref.customMark } : void 0;
|
|
14241
|
+
},
|
|
14242
|
+
formatMarker: getFootnoteDisplayMarker
|
|
14243
|
+
};
|
|
14244
|
+
function findFootnoteReference(document2, footnoteId) {
|
|
14245
|
+
return findNoteReference(document2, footnoteTraversal, footnoteId);
|
|
14246
|
+
}
|
|
14247
|
+
function renumberFootnotes(document2) {
|
|
14248
|
+
const footnotes = document2.footnotes;
|
|
14249
|
+
if (!footnotes || Object.keys(footnotes.items).length === 0) {
|
|
14265
14250
|
return document2;
|
|
14266
14251
|
}
|
|
14267
|
-
const
|
|
14268
|
-
|
|
14269
|
-
|
|
14270
|
-
const markerByEndnoteId = /* @__PURE__ */ new Map();
|
|
14271
|
-
let autoCounter = startAt - 1;
|
|
14272
|
-
for (const { run } of iterateEndnoteReferenceRuns(document2)) {
|
|
14273
|
-
const ref = getRunEndnoteReference(run);
|
|
14274
|
-
if (!ref) continue;
|
|
14275
|
-
referenced.add(ref.endnoteId);
|
|
14276
|
-
if (ref.customMark) {
|
|
14277
|
-
markerByEndnoteId.set(ref.endnoteId, ref.customMark);
|
|
14278
|
-
continue;
|
|
14279
|
-
}
|
|
14280
|
-
if (!markerByEndnoteId.has(ref.endnoteId)) {
|
|
14281
|
-
autoCounter += 1;
|
|
14282
|
-
markerByEndnoteId.set(
|
|
14283
|
-
ref.endnoteId,
|
|
14284
|
-
getFootnoteDisplayMarker(autoCounter, format)
|
|
14285
|
-
);
|
|
14286
|
-
}
|
|
14252
|
+
const { sections, sectionsChanged, nextItems, itemsChanged } = computeNoteRenumber(document2, footnotes, footnoteTraversal);
|
|
14253
|
+
if (!sectionsChanged && !itemsChanged) {
|
|
14254
|
+
return document2;
|
|
14287
14255
|
}
|
|
14288
|
-
|
|
14289
|
-
|
|
14290
|
-
|
|
14291
|
-
|
|
14292
|
-
|
|
14293
|
-
|
|
14294
|
-
switch (block.type) {
|
|
14295
|
-
case "paragraph": {
|
|
14296
|
-
const updated = rewriteParagraphMarkers(block, markerByEndnoteId);
|
|
14297
|
-
if (updated !== block) blockChanged = true;
|
|
14298
|
-
return updated;
|
|
14299
|
-
}
|
|
14300
|
-
case "table": {
|
|
14301
|
-
let tableChanged = false;
|
|
14302
|
-
const nextRows = block.rows.map((row) => {
|
|
14303
|
-
let rowChanged = false;
|
|
14304
|
-
const nextCells = row.cells.map((cell) => {
|
|
14305
|
-
let cellChanged = false;
|
|
14306
|
-
const nextCellBlocks = cell.blocks.map((p) => {
|
|
14307
|
-
const updated = rewriteParagraphMarkers(p, markerByEndnoteId);
|
|
14308
|
-
if (updated !== p) cellChanged = true;
|
|
14309
|
-
return updated;
|
|
14310
|
-
});
|
|
14311
|
-
if (!cellChanged) return cell;
|
|
14312
|
-
rowChanged = true;
|
|
14313
|
-
return { ...cell, blocks: nextCellBlocks };
|
|
14314
|
-
});
|
|
14315
|
-
if (!rowChanged) return row;
|
|
14316
|
-
tableChanged = true;
|
|
14317
|
-
return { ...row, cells: nextCells };
|
|
14318
|
-
});
|
|
14319
|
-
if (!tableChanged) return block;
|
|
14320
|
-
blockChanged = true;
|
|
14321
|
-
return { ...block, rows: nextRows };
|
|
14322
|
-
}
|
|
14323
|
-
default:
|
|
14324
|
-
return assertNever(block, "block");
|
|
14325
|
-
}
|
|
14326
|
-
});
|
|
14327
|
-
if (!blockChanged) return blocks;
|
|
14328
|
-
mutatedSections = true;
|
|
14329
|
-
return nextBlocks;
|
|
14330
|
-
};
|
|
14331
|
-
return {
|
|
14332
|
-
...section,
|
|
14333
|
-
blocks: rewriteBlocks(section.blocks) ?? section.blocks,
|
|
14334
|
-
header: rewriteBlocks(section.header),
|
|
14335
|
-
firstPageHeader: rewriteBlocks(section.firstPageHeader),
|
|
14336
|
-
evenPageHeader: rewriteBlocks(section.evenPageHeader),
|
|
14337
|
-
footer: rewriteBlocks(section.footer),
|
|
14338
|
-
firstPageFooter: rewriteBlocks(section.firstPageFooter),
|
|
14339
|
-
evenPageFooter: rewriteBlocks(section.evenPageFooter)
|
|
14340
|
-
};
|
|
14341
|
-
});
|
|
14342
|
-
const nextItems = {};
|
|
14343
|
-
let itemsChanged = false;
|
|
14344
|
-
for (const [id, endnote] of Object.entries(endnotes.items)) {
|
|
14345
|
-
if (referenced.has(id)) {
|
|
14346
|
-
nextItems[id] = endnote;
|
|
14347
|
-
} else {
|
|
14348
|
-
itemsChanged = true;
|
|
14256
|
+
return {
|
|
14257
|
+
...document2,
|
|
14258
|
+
sections: sectionsChanged ? sections : document2.sections,
|
|
14259
|
+
footnotes: {
|
|
14260
|
+
...footnotes,
|
|
14261
|
+
items: itemsChanged ? nextItems : footnotes.items
|
|
14349
14262
|
}
|
|
14263
|
+
};
|
|
14264
|
+
}
|
|
14265
|
+
const endnoteTraversal = {
|
|
14266
|
+
runKind: "endnoteReference",
|
|
14267
|
+
getRef: (run) => {
|
|
14268
|
+
const ref = getRunEndnoteReference(run);
|
|
14269
|
+
return ref ? { id: ref.endnoteId, customMark: ref.customMark } : void 0;
|
|
14270
|
+
},
|
|
14271
|
+
formatMarker: getFootnoteDisplayMarker
|
|
14272
|
+
};
|
|
14273
|
+
function iterateEndnoteReferenceRuns(document2) {
|
|
14274
|
+
return iterateNoteReferenceRuns(document2, "endnoteReference");
|
|
14275
|
+
}
|
|
14276
|
+
function listReferencedEndnotes(document2) {
|
|
14277
|
+
return listReferencedNotes(document2, endnoteTraversal).map((info) => ({
|
|
14278
|
+
endnoteId: info.id,
|
|
14279
|
+
customMark: info.customMark,
|
|
14280
|
+
index: info.index
|
|
14281
|
+
}));
|
|
14282
|
+
}
|
|
14283
|
+
function renumberEndnotes(document2) {
|
|
14284
|
+
const endnotes = document2.endnotes;
|
|
14285
|
+
if (!endnotes || Object.keys(endnotes.items).length === 0) {
|
|
14286
|
+
return document2;
|
|
14350
14287
|
}
|
|
14351
|
-
|
|
14288
|
+
const { sections, sectionsChanged, nextItems, itemsChanged } = computeNoteRenumber(document2, endnotes, endnoteTraversal);
|
|
14289
|
+
if (!sectionsChanged && !itemsChanged) {
|
|
14352
14290
|
return document2;
|
|
14353
14291
|
}
|
|
14354
14292
|
return {
|
|
14355
14293
|
...document2,
|
|
14356
|
-
sections:
|
|
14294
|
+
sections: sectionsChanged ? sections : document2.sections,
|
|
14357
14295
|
endnotes: {
|
|
14358
14296
|
...endnotes,
|
|
14359
14297
|
items: itemsChanged ? nextItems : endnotes.items
|
|
14360
14298
|
}
|
|
14361
14299
|
};
|
|
14362
14300
|
}
|
|
14363
|
-
function rewriteParagraphMarkers(paragraph, markerByEndnoteId) {
|
|
14364
|
-
let runChanged = false;
|
|
14365
|
-
const nextRuns = paragraph.runs.map((run) => {
|
|
14366
|
-
const ref = getRunEndnoteReference(run);
|
|
14367
|
-
if (!ref) return run;
|
|
14368
|
-
const desired = markerByEndnoteId.get(ref.endnoteId);
|
|
14369
|
-
if (desired === void 0) return run;
|
|
14370
|
-
if (run.text === desired) return run;
|
|
14371
|
-
runChanged = true;
|
|
14372
|
-
return { ...run, text: desired };
|
|
14373
|
-
});
|
|
14374
|
-
if (!runChanged) return paragraph;
|
|
14375
|
-
return { ...paragraph, runs: nextRuns };
|
|
14376
|
-
}
|
|
14377
14301
|
const FLOW_ID_PREFIX = "endnote-flow";
|
|
14378
14302
|
function makeMarkerRun(endnoteId, marker) {
|
|
14379
14303
|
return {
|
|
@@ -35709,7 +35633,7 @@ function importDocxInWorker(buffer, options = {}) {
|
|
|
35709
35633
|
const worker = new Worker(
|
|
35710
35634
|
new URL(
|
|
35711
35635
|
/* @vite-ignore */
|
|
35712
|
-
"" + new URL("assets/importDocxWorker-
|
|
35636
|
+
"" + new URL("assets/importDocxWorker-C94l6-O5.js", import.meta.url).href,
|
|
35713
35637
|
import.meta.url
|
|
35714
35638
|
),
|
|
35715
35639
|
{
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { EditorDocument, EditorLayoutPage, EditorLayoutParagraph } from '../core/model.js';
|
|
2
2
|
import { ITextMeasurer } from '../core/engine.js';
|
|
3
|
+
import { HeaderFooterBlockProjector } from './headerFooterLayoutContext.js';
|
|
3
4
|
|
|
4
5
|
export declare const FOOTNOTE_SEPARATOR_HEIGHT = 10;
|
|
5
6
|
export declare const FOOTNOTE_BLOCK_GAP = 2;
|
|
6
7
|
export declare const FOOTNOTE_MARKER_GUTTER_PX = 24;
|
|
7
8
|
export declare const MAX_FOOTNOTE_LAYOUT_ITERATIONS = 4;
|
|
8
|
-
export type HeaderFooterBlockProjector = (blocks: EditorBlockNode[], pageIndex?: number, totalPages?: number, measuredHeights?: Record<string, number>, measuredParagraphLayouts?: Record<string, EditorLayoutParagraph>, styles?: EditorDocument["styles"], contentWidth?: number, measurer?: ITextMeasurer, defaultTabStop?: number) => EditorLayoutBlock[];
|
|
9
9
|
export declare function collectPageFootnoteReferenceIds(page: EditorLayoutPage): string[];
|
|
10
10
|
export interface FootnotePaginationContext {
|
|
11
11
|
document: EditorDocument;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { EditorBlockNode, EditorLayoutBlock
|
|
2
|
-
import {
|
|
1
|
+
import { EditorBlockNode, EditorLayoutBlock } from '../core/model.js';
|
|
2
|
+
import { HeaderFooterLayoutContext } from './headerFooterLayoutContext.js';
|
|
3
3
|
|
|
4
|
-
export declare function projectHeaderFooterBlocks(blocks: EditorBlockNode[],
|
|
4
|
+
export declare function projectHeaderFooterBlocks(blocks: EditorBlockNode[], context?: HeaderFooterLayoutContext): EditorLayoutBlock[];
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { EditorBlockNode, EditorLayoutBlock, EditorLayoutParagraph, EditorNamedStyle } from '../core/model.js';
|
|
2
|
+
import { ITextMeasurer } from '../core/engine.js';
|
|
3
|
+
|
|
4
|
+
export interface HeaderFooterLayoutContext {
|
|
5
|
+
pageIndex?: number;
|
|
6
|
+
totalPages?: number;
|
|
7
|
+
measuredHeights?: Record<string, number>;
|
|
8
|
+
measuredParagraphLayouts?: Record<string, EditorLayoutParagraph>;
|
|
9
|
+
styles?: Record<string, EditorNamedStyle>;
|
|
10
|
+
contentWidth?: number;
|
|
11
|
+
measurer?: ITextMeasurer;
|
|
12
|
+
defaultTabStop?: number;
|
|
13
|
+
}
|
|
14
|
+
export type HeaderFooterBlockProjector = (blocks: EditorBlockNode[], context?: HeaderFooterLayoutContext) => EditorLayoutBlock[];
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { EditorBlockNode, EditorLayoutBlock, EditorLayoutParagraph, EditorNamedStyle, EditorParagraphNode } from '../core/model.js';
|
|
2
2
|
import { ITextMeasurer } from '../core/engine.js';
|
|
3
|
+
import { HeaderFooterLayoutContext } from './headerFooterLayoutContext.js';
|
|
3
4
|
|
|
4
5
|
type ProjectParagraphLayoutFn = (paragraph: EditorParagraphNode, pageIndex?: number, totalPages?: number, styles?: Record<string, EditorNamedStyle>, contentWidth?: number, measurer?: ITextMeasurer, defaultTabStop?: number) => EditorLayoutParagraph;
|
|
5
6
|
type EstimateTableBlockHeightFn = (block: Extract<EditorBlockNode, {
|
|
@@ -10,5 +11,5 @@ export declare function projectHeaderFooterBlocksWithDependencies(blocks: Editor
|
|
|
10
11
|
projectParagraphLayout: ProjectParagraphLayoutFn;
|
|
11
12
|
estimateTableBlockHeight: EstimateTableBlockHeightFn;
|
|
12
13
|
getProjectedParagraphBlockHeight: GetProjectedParagraphBlockHeightFn;
|
|
13
|
-
},
|
|
14
|
+
}, context?: HeaderFooterLayoutContext): EditorLayoutBlock[];
|
|
14
15
|
export {};
|