oasis-editor 0.0.84 → 0.0.85
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-D_hjBUA1.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-CHcJlpsx.js} +160 -245
- package/dist/oasis-editor.js +1 -1
- package/dist/oasis-editor.umd.cjs +4 -4
- package/package.json +1 -1
package/dist/core/endnotes.d.ts
CHANGED
|
@@ -1,10 +1,5 @@
|
|
|
1
1
|
import { EditorBlockNode, EditorDocument, EditorEndnote, EditorEndnotes, EditorParagraphNode, EditorTextRun } from './model.js';
|
|
2
2
|
|
|
3
|
-
/**
|
|
4
|
-
* Iterate every paragraph in document order (endnote bodies excluded), yielding
|
|
5
|
-
* each endnote reference run with its owning paragraph. Order matches reading
|
|
6
|
-
* order, which is what numbering depends on.
|
|
7
|
-
*/
|
|
8
3
|
export declare function iterateEndnoteReferenceRuns(document: EditorDocument): Generator<{
|
|
9
4
|
paragraph: EditorParagraphNode;
|
|
10
5
|
run: EditorTextRun;
|
package/dist/core/footnotes.d.ts
CHANGED
|
@@ -1,10 +1,5 @@
|
|
|
1
1
|
import { EditorBlockNode, EditorDocument, EditorFootnote, EditorFootnoteNumberFormat, EditorFootnotes, EditorParagraphNode, EditorTextRun } from './model.js';
|
|
2
2
|
|
|
3
|
-
/**
|
|
4
|
-
* Iterate every paragraph in document order (sections + footnotes excluded),
|
|
5
|
-
* yielding each footnote reference run along with the owning paragraph. Order
|
|
6
|
-
* matches reading order, which is what numbering depends on.
|
|
7
|
-
*/
|
|
8
3
|
export declare function iterateFootnoteReferenceRuns(document: EditorDocument): Generator<{
|
|
9
4
|
paragraph: EditorParagraphNode;
|
|
10
5
|
run: EditorTextRun;
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { EditorBlockNode, EditorDocument, EditorFootnoteNumberFormat, EditorParagraphNode, EditorSection, EditorTextRun } from './model.js';
|
|
2
|
+
|
|
3
|
+
/** Discriminant of a note reference run. */
|
|
4
|
+
export type NoteReferenceRunKind = "footnoteReference" | "endnoteReference";
|
|
5
|
+
/** Neutral view of a note reference run's data (id + optional custom mark). */
|
|
6
|
+
export interface NoteRef {
|
|
7
|
+
id: string;
|
|
8
|
+
customMark?: string;
|
|
9
|
+
}
|
|
10
|
+
/** Minimal shape of a note body shared by footnotes and endnotes. */
|
|
11
|
+
interface NoteBody {
|
|
12
|
+
blocks: EditorBlockNode[];
|
|
13
|
+
}
|
|
14
|
+
/** Minimal shape of a note collection (footnotes/endnotes registry). */
|
|
15
|
+
interface NoteCollection<TNote extends NoteBody> {
|
|
16
|
+
items: Record<string, TNote>;
|
|
17
|
+
settings?: {
|
|
18
|
+
numberFormat?: EditorFootnoteNumberFormat;
|
|
19
|
+
startAt?: number;
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Describes one note family so the shared algorithm can operate on either.
|
|
24
|
+
*/
|
|
25
|
+
export interface NoteTraversal {
|
|
26
|
+
/** Reference run discriminant for this family. */
|
|
27
|
+
runKind: NoteReferenceRunKind;
|
|
28
|
+
/** Read neutral reference data from a run, or undefined if not this kind. */
|
|
29
|
+
getRef(run: EditorTextRun): NoteRef | undefined;
|
|
30
|
+
/** Map a one-based index + format to display marker text. */
|
|
31
|
+
formatMarker(oneBasedIndex: number, format: EditorFootnoteNumberFormat): string;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Iterate every paragraph in document order (note bodies excluded), yielding
|
|
35
|
+
* each reference run of `runKind` with its owning paragraph. Order matches
|
|
36
|
+
* reading order, which is what numbering depends on.
|
|
37
|
+
*/
|
|
38
|
+
export declare function iterateNoteReferenceRuns(document: EditorDocument, runKind: NoteReferenceRunKind): Generator<{
|
|
39
|
+
paragraph: EditorParagraphNode;
|
|
40
|
+
run: EditorTextRun;
|
|
41
|
+
}, void, void>;
|
|
42
|
+
export declare function collectNoteReferences(document: EditorDocument, runKind: NoteReferenceRunKind): Array<{
|
|
43
|
+
paragraph: EditorParagraphNode;
|
|
44
|
+
run: EditorTextRun;
|
|
45
|
+
}>;
|
|
46
|
+
/** Find the note body that contains the given paragraph id (neutral id). */
|
|
47
|
+
export declare function findNoteBodyByParagraphId<TNote extends NoteBody>(items: Record<string, TNote> | undefined, paragraphId: string): {
|
|
48
|
+
id: string;
|
|
49
|
+
body: TNote;
|
|
50
|
+
} | null;
|
|
51
|
+
/** Find the first reference run for a given note id. */
|
|
52
|
+
export declare function findNoteReference(document: EditorDocument, traversal: NoteTraversal, noteId: string): {
|
|
53
|
+
paragraph: EditorParagraphNode;
|
|
54
|
+
run: EditorTextRun;
|
|
55
|
+
} | null;
|
|
56
|
+
/** Neutral per-reference info (id + custom mark + computed reading-order index). */
|
|
57
|
+
export interface NoteReferenceInfo {
|
|
58
|
+
id: string;
|
|
59
|
+
customMark?: string;
|
|
60
|
+
index: number;
|
|
61
|
+
}
|
|
62
|
+
export declare function listReferencedNotes(document: EditorDocument, traversal: NoteTraversal): NoteReferenceInfo[];
|
|
63
|
+
/** Result of {@link computeNoteRenumber}: rewritten sections + pruned items. */
|
|
64
|
+
export interface NoteRenumberResult<TNote extends NoteBody> {
|
|
65
|
+
sections: EditorSection[];
|
|
66
|
+
sectionsChanged: boolean;
|
|
67
|
+
nextItems: Record<string, TNote>;
|
|
68
|
+
itemsChanged: boolean;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Compute the renumbering of a note family: assign a marker per referenced note
|
|
72
|
+
* in reading order, rewrite reference run text where it differs, and prune note
|
|
73
|
+
* bodies that are no longer referenced. Pure — the caller assembles the new
|
|
74
|
+
* document with the correct collection field.
|
|
75
|
+
*/
|
|
76
|
+
export declare function computeNoteRenumber<TNote extends NoteBody>(document: EditorDocument, collection: NoteCollection<TNote>, traversal: NoteTraversal): NoteRenumberResult<TNote>;
|
|
77
|
+
export {};
|
|
@@ -2483,7 +2483,7 @@ function OasisEditorAppLazy(props = {}) {
|
|
|
2483
2483
|
onCleanup(() => {
|
|
2484
2484
|
cancelled = true;
|
|
2485
2485
|
});
|
|
2486
|
-
import("./OasisEditorApp-
|
|
2486
|
+
import("./OasisEditorApp-D_hjBUA1.js").then((m) => {
|
|
2487
2487
|
cancelled = true;
|
|
2488
2488
|
setProgress(1);
|
|
2489
2489
|
setTimeout(() => setApp(() => m.OasisEditorApp), 180);
|
|
@@ -14000,7 +14000,7 @@ function projectDocumentSections(context2, reservedHeightByPageIndex) {
|
|
|
14000
14000
|
)
|
|
14001
14001
|
};
|
|
14002
14002
|
}
|
|
14003
|
-
function*
|
|
14003
|
+
function* iterateNoteReferenceRuns(document2, runKind) {
|
|
14004
14004
|
const sections = getDocumentSectionsCanonical(document2);
|
|
14005
14005
|
for (const section of sections) {
|
|
14006
14006
|
const zones = [
|
|
@@ -14016,7 +14016,7 @@ function* iterateFootnoteReferenceRuns(document2) {
|
|
|
14016
14016
|
for (const block of blocks) {
|
|
14017
14017
|
for (const paragraph of getBlockParagraphs(block)) {
|
|
14018
14018
|
for (const run of paragraph.runs) {
|
|
14019
|
-
if (run.kind ===
|
|
14019
|
+
if (run.kind === runKind) {
|
|
14020
14020
|
yield { paragraph, run };
|
|
14021
14021
|
}
|
|
14022
14022
|
}
|
|
@@ -14025,103 +14025,56 @@ function* iterateFootnoteReferenceRuns(document2) {
|
|
|
14025
14025
|
}
|
|
14026
14026
|
}
|
|
14027
14027
|
}
|
|
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) {
|
|
14028
|
+
function findNoteReference(document2, traversal, noteId) {
|
|
14089
14029
|
var _a;
|
|
14090
|
-
for (const entry of
|
|
14091
|
-
if (((_a =
|
|
14030
|
+
for (const entry of iterateNoteReferenceRuns(document2, traversal.runKind)) {
|
|
14031
|
+
if (((_a = traversal.getRef(entry.run)) == null ? void 0 : _a.id) === noteId) {
|
|
14092
14032
|
return entry;
|
|
14093
14033
|
}
|
|
14094
14034
|
}
|
|
14095
14035
|
return null;
|
|
14096
14036
|
}
|
|
14097
|
-
function
|
|
14098
|
-
|
|
14099
|
-
const
|
|
14100
|
-
|
|
14101
|
-
|
|
14037
|
+
function listReferencedNotes(document2, traversal) {
|
|
14038
|
+
const seen = /* @__PURE__ */ new Set();
|
|
14039
|
+
const result = [];
|
|
14040
|
+
let counter2 = 0;
|
|
14041
|
+
for (const { run } of iterateNoteReferenceRuns(document2, traversal.runKind)) {
|
|
14042
|
+
const ref = traversal.getRef(run);
|
|
14043
|
+
if (!ref) continue;
|
|
14044
|
+
if (seen.has(ref.id)) continue;
|
|
14045
|
+
seen.add(ref.id);
|
|
14046
|
+
if (!ref.customMark) {
|
|
14047
|
+
counter2 += 1;
|
|
14048
|
+
}
|
|
14049
|
+
result.push({
|
|
14050
|
+
id: ref.id,
|
|
14051
|
+
customMark: ref.customMark,
|
|
14052
|
+
index: ref.customMark ? 0 : counter2
|
|
14053
|
+
});
|
|
14102
14054
|
}
|
|
14103
|
-
|
|
14104
|
-
|
|
14055
|
+
return result;
|
|
14056
|
+
}
|
|
14057
|
+
function computeNoteRenumber(document2, collection, traversal) {
|
|
14058
|
+
var _a, _b;
|
|
14059
|
+
const format = ((_a = collection.settings) == null ? void 0 : _a.numberFormat) ?? "decimal";
|
|
14060
|
+
const startAt = ((_b = collection.settings) == null ? void 0 : _b.startAt) ?? 1;
|
|
14105
14061
|
const referenced = /* @__PURE__ */ new Set();
|
|
14106
|
-
const
|
|
14062
|
+
const markerById = /* @__PURE__ */ new Map();
|
|
14107
14063
|
let autoCounter = startAt - 1;
|
|
14108
|
-
for (const { run } of
|
|
14109
|
-
const ref =
|
|
14064
|
+
for (const { run } of iterateNoteReferenceRuns(document2, traversal.runKind)) {
|
|
14065
|
+
const ref = traversal.getRef(run);
|
|
14110
14066
|
if (!ref) continue;
|
|
14111
|
-
referenced.add(ref.
|
|
14067
|
+
referenced.add(ref.id);
|
|
14112
14068
|
if (ref.customMark) {
|
|
14113
|
-
|
|
14069
|
+
markerById.set(ref.id, ref.customMark);
|
|
14114
14070
|
continue;
|
|
14115
14071
|
}
|
|
14116
|
-
if (!
|
|
14072
|
+
if (!markerById.has(ref.id)) {
|
|
14117
14073
|
autoCounter += 1;
|
|
14118
|
-
|
|
14119
|
-
ref.footnoteId,
|
|
14120
|
-
getFootnoteDisplayMarker(autoCounter, format)
|
|
14121
|
-
);
|
|
14074
|
+
markerById.set(ref.id, traversal.formatMarker(autoCounter, format));
|
|
14122
14075
|
}
|
|
14123
14076
|
}
|
|
14124
|
-
let
|
|
14077
|
+
let sectionsChanged = false;
|
|
14125
14078
|
const sections = getDocumentSectionsCanonical(document2).map((section) => {
|
|
14126
14079
|
const rewriteBlocks = (blocks) => {
|
|
14127
14080
|
if (!blocks) return blocks;
|
|
@@ -14129,7 +14082,11 @@ function renumberFootnotes(document2) {
|
|
|
14129
14082
|
const nextBlocks = blocks.map((block) => {
|
|
14130
14083
|
switch (block.type) {
|
|
14131
14084
|
case "paragraph": {
|
|
14132
|
-
const updated = rewriteParagraphMarkers
|
|
14085
|
+
const updated = rewriteParagraphMarkers(
|
|
14086
|
+
block,
|
|
14087
|
+
traversal,
|
|
14088
|
+
markerById
|
|
14089
|
+
);
|
|
14133
14090
|
if (updated !== block) blockChanged = true;
|
|
14134
14091
|
return updated;
|
|
14135
14092
|
}
|
|
@@ -14140,9 +14097,10 @@ function renumberFootnotes(document2) {
|
|
|
14140
14097
|
const nextCells = row.cells.map((cell) => {
|
|
14141
14098
|
let cellChanged = false;
|
|
14142
14099
|
const nextCellBlocks = cell.blocks.map((p) => {
|
|
14143
|
-
const updated = rewriteParagraphMarkers
|
|
14100
|
+
const updated = rewriteParagraphMarkers(
|
|
14144
14101
|
p,
|
|
14145
|
-
|
|
14102
|
+
traversal,
|
|
14103
|
+
markerById
|
|
14146
14104
|
);
|
|
14147
14105
|
if (updated !== p) cellChanged = true;
|
|
14148
14106
|
return updated;
|
|
@@ -14164,7 +14122,7 @@ function renumberFootnotes(document2) {
|
|
|
14164
14122
|
}
|
|
14165
14123
|
});
|
|
14166
14124
|
if (!blockChanged) return blocks;
|
|
14167
|
-
|
|
14125
|
+
sectionsChanged = true;
|
|
14168
14126
|
return nextBlocks;
|
|
14169
14127
|
};
|
|
14170
14128
|
return {
|
|
@@ -14180,31 +14138,21 @@ function renumberFootnotes(document2) {
|
|
|
14180
14138
|
});
|
|
14181
14139
|
const nextItems = {};
|
|
14182
14140
|
let itemsChanged = false;
|
|
14183
|
-
for (const [id,
|
|
14141
|
+
for (const [id, body] of Object.entries(collection.items)) {
|
|
14184
14142
|
if (referenced.has(id)) {
|
|
14185
|
-
nextItems[id] =
|
|
14143
|
+
nextItems[id] = body;
|
|
14186
14144
|
} else {
|
|
14187
14145
|
itemsChanged = true;
|
|
14188
14146
|
}
|
|
14189
14147
|
}
|
|
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
|
-
};
|
|
14148
|
+
return { sections, sectionsChanged, nextItems, itemsChanged };
|
|
14201
14149
|
}
|
|
14202
|
-
function rewriteParagraphMarkers
|
|
14150
|
+
function rewriteParagraphMarkers(paragraph, traversal, markerById) {
|
|
14203
14151
|
let runChanged = false;
|
|
14204
14152
|
const nextRuns = paragraph.runs.map((run) => {
|
|
14205
|
-
const ref =
|
|
14153
|
+
const ref = traversal.getRef(run);
|
|
14206
14154
|
if (!ref) return run;
|
|
14207
|
-
const desired =
|
|
14155
|
+
const desired = markerById.get(ref.id);
|
|
14208
14156
|
if (desired === void 0) return run;
|
|
14209
14157
|
if (run.text === desired) return run;
|
|
14210
14158
|
runChanged = true;
|
|
@@ -14213,167 +14161,134 @@ function rewriteParagraphMarkers$1(paragraph, markerByFootnoteId) {
|
|
|
14213
14161
|
if (!runChanged) return paragraph;
|
|
14214
14162
|
return { ...paragraph, runs: nextRuns };
|
|
14215
14163
|
}
|
|
14216
|
-
function
|
|
14217
|
-
|
|
14218
|
-
|
|
14219
|
-
|
|
14220
|
-
|
|
14221
|
-
|
|
14222
|
-
|
|
14223
|
-
|
|
14224
|
-
|
|
14225
|
-
|
|
14226
|
-
|
|
14227
|
-
|
|
14228
|
-
|
|
14229
|
-
|
|
14230
|
-
|
|
14231
|
-
|
|
14232
|
-
|
|
14233
|
-
|
|
14234
|
-
|
|
14235
|
-
|
|
14236
|
-
|
|
14237
|
-
|
|
14164
|
+
function iterateFootnoteReferenceRuns(document2) {
|
|
14165
|
+
return iterateNoteReferenceRuns(document2, "footnoteReference");
|
|
14166
|
+
}
|
|
14167
|
+
const LOWER_LETTERS = "abcdefghijklmnopqrstuvwxyz";
|
|
14168
|
+
const ROMAN_NUMERALS = [
|
|
14169
|
+
[1e3, "m"],
|
|
14170
|
+
[900, "cm"],
|
|
14171
|
+
[500, "d"],
|
|
14172
|
+
[400, "cd"],
|
|
14173
|
+
[100, "c"],
|
|
14174
|
+
[90, "xc"],
|
|
14175
|
+
[50, "l"],
|
|
14176
|
+
[40, "xl"],
|
|
14177
|
+
[10, "x"],
|
|
14178
|
+
[9, "ix"],
|
|
14179
|
+
[5, "v"],
|
|
14180
|
+
[4, "iv"],
|
|
14181
|
+
[1, "i"]
|
|
14182
|
+
];
|
|
14183
|
+
function toRoman(value) {
|
|
14184
|
+
if (value <= 0) return String(value);
|
|
14185
|
+
let remaining = value;
|
|
14186
|
+
let result = "";
|
|
14187
|
+
for (const [size, glyph] of ROMAN_NUMERALS) {
|
|
14188
|
+
while (remaining >= size) {
|
|
14189
|
+
result += glyph;
|
|
14190
|
+
remaining -= size;
|
|
14238
14191
|
}
|
|
14239
14192
|
}
|
|
14193
|
+
return result;
|
|
14240
14194
|
}
|
|
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
|
-
});
|
|
14195
|
+
function toLetters(value) {
|
|
14196
|
+
if (value <= 0) return String(value);
|
|
14197
|
+
let remaining = value;
|
|
14198
|
+
let result = "";
|
|
14199
|
+
while (remaining > 0) {
|
|
14200
|
+
const digit = (remaining - 1) % 26;
|
|
14201
|
+
result = LOWER_LETTERS[digit] + result;
|
|
14202
|
+
remaining = Math.floor((remaining - 1) / 26);
|
|
14258
14203
|
}
|
|
14259
14204
|
return result;
|
|
14260
14205
|
}
|
|
14261
|
-
|
|
14262
|
-
|
|
14263
|
-
|
|
14264
|
-
|
|
14206
|
+
const SYMBOL_MARKS = ["*", "†", "‡", "§", "¶", "#"];
|
|
14207
|
+
function getFootnoteDisplayMarker(oneBasedIndex, format = "decimal") {
|
|
14208
|
+
switch (format) {
|
|
14209
|
+
case "lowerRoman":
|
|
14210
|
+
return toRoman(oneBasedIndex);
|
|
14211
|
+
case "upperRoman":
|
|
14212
|
+
return toRoman(oneBasedIndex).toUpperCase();
|
|
14213
|
+
case "lowerLetter":
|
|
14214
|
+
return toLetters(oneBasedIndex);
|
|
14215
|
+
case "upperLetter":
|
|
14216
|
+
return toLetters(oneBasedIndex).toUpperCase();
|
|
14217
|
+
case "symbol": {
|
|
14218
|
+
const slot = (oneBasedIndex - 1) % SYMBOL_MARKS.length;
|
|
14219
|
+
const cycles = Math.floor((oneBasedIndex - 1) / SYMBOL_MARKS.length) + 1;
|
|
14220
|
+
return SYMBOL_MARKS[slot].repeat(cycles);
|
|
14221
|
+
}
|
|
14222
|
+
case "decimal":
|
|
14223
|
+
default:
|
|
14224
|
+
return String(oneBasedIndex);
|
|
14225
|
+
}
|
|
14226
|
+
}
|
|
14227
|
+
const footnoteTraversal = {
|
|
14228
|
+
runKind: "footnoteReference",
|
|
14229
|
+
getRef: (run) => {
|
|
14230
|
+
const ref = getRunFootnoteReference(run);
|
|
14231
|
+
return ref ? { id: ref.footnoteId, customMark: ref.customMark } : void 0;
|
|
14232
|
+
},
|
|
14233
|
+
formatMarker: getFootnoteDisplayMarker
|
|
14234
|
+
};
|
|
14235
|
+
function findFootnoteReference(document2, footnoteId) {
|
|
14236
|
+
return findNoteReference(document2, footnoteTraversal, footnoteId);
|
|
14237
|
+
}
|
|
14238
|
+
function renumberFootnotes(document2) {
|
|
14239
|
+
const footnotes = document2.footnotes;
|
|
14240
|
+
if (!footnotes || Object.keys(footnotes.items).length === 0) {
|
|
14265
14241
|
return document2;
|
|
14266
14242
|
}
|
|
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
|
-
}
|
|
14243
|
+
const { sections, sectionsChanged, nextItems, itemsChanged } = computeNoteRenumber(document2, footnotes, footnoteTraversal);
|
|
14244
|
+
if (!sectionsChanged && !itemsChanged) {
|
|
14245
|
+
return document2;
|
|
14287
14246
|
}
|
|
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;
|
|
14247
|
+
return {
|
|
14248
|
+
...document2,
|
|
14249
|
+
sections: sectionsChanged ? sections : document2.sections,
|
|
14250
|
+
footnotes: {
|
|
14251
|
+
...footnotes,
|
|
14252
|
+
items: itemsChanged ? nextItems : footnotes.items
|
|
14349
14253
|
}
|
|
14254
|
+
};
|
|
14255
|
+
}
|
|
14256
|
+
const endnoteTraversal = {
|
|
14257
|
+
runKind: "endnoteReference",
|
|
14258
|
+
getRef: (run) => {
|
|
14259
|
+
const ref = getRunEndnoteReference(run);
|
|
14260
|
+
return ref ? { id: ref.endnoteId, customMark: ref.customMark } : void 0;
|
|
14261
|
+
},
|
|
14262
|
+
formatMarker: getFootnoteDisplayMarker
|
|
14263
|
+
};
|
|
14264
|
+
function iterateEndnoteReferenceRuns(document2) {
|
|
14265
|
+
return iterateNoteReferenceRuns(document2, "endnoteReference");
|
|
14266
|
+
}
|
|
14267
|
+
function listReferencedEndnotes(document2) {
|
|
14268
|
+
return listReferencedNotes(document2, endnoteTraversal).map((info) => ({
|
|
14269
|
+
endnoteId: info.id,
|
|
14270
|
+
customMark: info.customMark,
|
|
14271
|
+
index: info.index
|
|
14272
|
+
}));
|
|
14273
|
+
}
|
|
14274
|
+
function renumberEndnotes(document2) {
|
|
14275
|
+
const endnotes = document2.endnotes;
|
|
14276
|
+
if (!endnotes || Object.keys(endnotes.items).length === 0) {
|
|
14277
|
+
return document2;
|
|
14350
14278
|
}
|
|
14351
|
-
|
|
14279
|
+
const { sections, sectionsChanged, nextItems, itemsChanged } = computeNoteRenumber(document2, endnotes, endnoteTraversal);
|
|
14280
|
+
if (!sectionsChanged && !itemsChanged) {
|
|
14352
14281
|
return document2;
|
|
14353
14282
|
}
|
|
14354
14283
|
return {
|
|
14355
14284
|
...document2,
|
|
14356
|
-
sections:
|
|
14285
|
+
sections: sectionsChanged ? sections : document2.sections,
|
|
14357
14286
|
endnotes: {
|
|
14358
14287
|
...endnotes,
|
|
14359
14288
|
items: itemsChanged ? nextItems : endnotes.items
|
|
14360
14289
|
}
|
|
14361
14290
|
};
|
|
14362
14291
|
}
|
|
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
14292
|
const FLOW_ID_PREFIX = "endnote-flow";
|
|
14378
14293
|
function makeMarkerRun(endnoteId, marker) {
|
|
14379
14294
|
return {
|
|
@@ -35709,7 +35624,7 @@ function importDocxInWorker(buffer, options = {}) {
|
|
|
35709
35624
|
const worker = new Worker(
|
|
35710
35625
|
new URL(
|
|
35711
35626
|
/* @vite-ignore */
|
|
35712
|
-
"" + new URL("assets/importDocxWorker-
|
|
35627
|
+
"" + new URL("assets/importDocxWorker-C94l6-O5.js", import.meta.url).href,
|
|
35713
35628
|
import.meta.url
|
|
35714
35629
|
),
|
|
35715
35630
|
{
|
package/dist/oasis-editor.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { O, c2, c3, c4, c5, c6, a8, c7, Q, bN, c8, c9, ca, N, cb, bL, cc, cd, ce, cf, cg, bZ, ch, ci, cj, ck, cl, cm, cn, co, cp, cq, cr, ad, cs, bY, ct, c4 as c42, c9 as c92, cb as cb2, ck as ck2, cm as cm2, cr as cr2, cu, bP, bK, cv, cw, cx, bM, cy, cz, bO } from "./index-
|
|
1
|
+
import { O, c2, c3, c4, c5, c6, a8, c7, Q, bN, c8, c9, ca, N, cb, bL, cc, cd, ce, cf, cg, bZ, ch, ci, cj, ck, cl, cm, cn, co, cp, cq, cr, ad, cs, bY, ct, c4 as c42, c9 as c92, cb as cb2, ck as ck2, cm as cm2, cr as cr2, cu, bP, bK, cv, cw, cx, bM, cy, cz, bO } from "./index-CHcJlpsx.js";
|
|
2
2
|
export {
|
|
3
3
|
O as BalloonShell,
|
|
4
4
|
c2 as Button,
|