oasis-editor 0.0.126 → 0.0.128
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-DFgUxV_0.js → OasisEditorApp-3vvH6KOz.js} +24 -4
- package/dist/assets/{importDocxWorker-ayg-B322.js → importDocxWorker-DdpdjbOY.js} +1 -1
- package/dist/core/model/index.d.ts +1 -1
- package/dist/core/model/types/document.d.ts +37 -1
- package/dist/import/docx/sectionProperties.d.ts +13 -1
- package/dist/{index-BGUkA0aZ.js → index-Ceyv5JS5.js} +57 -10
- package/dist/oasis-editor.js +1 -1
- package/dist/oasis-editor.umd.cjs +4 -4
- package/package.json +1 -1
|
@@ -15,7 +15,7 @@ export type { EditorFootnote } from './types/documentFootnotes.js';
|
|
|
15
15
|
export type { EditorEndnote } from './types/documentEndnotes.js';
|
|
16
16
|
export type { EditorBookmark, EditorBookmarkAnchor, EditorBookmarks, } from './types/documentBookmarks.js';
|
|
17
17
|
export type { EditorComment, EditorCommentAnchor, EditorComments, } from './types/documentComments.js';
|
|
18
|
-
export type { EditorPageMargins, EditorPageSettings, EditorColumnsSettings, EditorSection, EditorFontInfo, EditorFootnoteSettings, EditorFootnotes, EditorEndnoteSettings, EditorEndnotes, EditorDocument, } from './types/document.js';
|
|
18
|
+
export type { EditorPageMargins, EditorPageSettings, EditorColumnsSettings, EditorSection, EditorPageNumbering, EditorSectionVerticalAlign, EditorFontInfo, EditorFootnoteSettings, EditorFootnotes, EditorEndnoteSettings, EditorEndnotes, EditorDocument, } from './types/document.js';
|
|
19
19
|
export type { EditorPosition, EditorSelection, EditorEditingZone, } from './types/selection.js';
|
|
20
20
|
export type { EditorCaretSlot, EditorLayoutFragmentChar, EditorLayoutFragment, EditorLayoutLine, EditorLayoutParagraph, EditorLayoutBlock, TableCellBlockPosition, EditorLayoutPage, EditorLayoutDocument, } from './types/layout.js';
|
|
21
21
|
export type { EditorState } from './editorState.js';
|
|
@@ -41,6 +41,28 @@ export interface EditorPageSettings {
|
|
|
41
41
|
margins: EditorPageMargins;
|
|
42
42
|
columns?: EditorColumnsSettings;
|
|
43
43
|
}
|
|
44
|
+
/**
|
|
45
|
+
* Page numbering settings for a section (`w:pgNumType`). Preserved for
|
|
46
|
+
* round-trip; `start` is intended to seed PAGE-field numbering in a future
|
|
47
|
+
* pass. The `format` string is stored verbatim from the OOXML `ST_NumberFormat`
|
|
48
|
+
* vocabulary (decimal, upperRoman, lowerLetter, …) so uncommon values survive
|
|
49
|
+
* round-trip even though the editor only renders a subset.
|
|
50
|
+
*/
|
|
51
|
+
export interface EditorPageNumbering {
|
|
52
|
+
/** `w:start` — first page number of this section. */
|
|
53
|
+
start?: number;
|
|
54
|
+
/** `w:fmt` — page number format (OOXML `ST_NumberFormat` value). */
|
|
55
|
+
format?: string;
|
|
56
|
+
/** `w:chapStyle` — heading style id used for chapter-based page numbers. */
|
|
57
|
+
chapterStyle?: string;
|
|
58
|
+
/** `w:chapSep` — separator between chapter number and page number. */
|
|
59
|
+
chapterSeparator?: string;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Vertical justification of a section's page contents (`w:vAlign`).
|
|
63
|
+
* `top` is the Word default and is omitted on export.
|
|
64
|
+
*/
|
|
65
|
+
export type EditorSectionVerticalAlign = "top" | "center" | "both" | "bottom";
|
|
44
66
|
export interface EditorSection {
|
|
45
67
|
id: string;
|
|
46
68
|
blocks: EditorBlockNode[];
|
|
@@ -51,7 +73,21 @@ export interface EditorSection {
|
|
|
51
73
|
footer?: EditorBlockNode[];
|
|
52
74
|
firstPageFooter?: EditorBlockNode[];
|
|
53
75
|
evenPageFooter?: EditorBlockNode[];
|
|
54
|
-
|
|
76
|
+
/**
|
|
77
|
+
* How this section *begins* (a page break, a continuous flow, …). Mirrors the
|
|
78
|
+
* editor's own section-break command. OOXML stores this as `w:type` on the
|
|
79
|
+
* *previous* section's `w:sectPr`; the importer applies the off-by-one so the
|
|
80
|
+
* value describes the section it sits on. `nextPage` is the Word default and
|
|
81
|
+
* is omitted on export. Only `continuous` currently affects layout rendering;
|
|
82
|
+
* `evenPage`/`oddPage`/`nextColumn` are preserved for round-trip.
|
|
83
|
+
*/
|
|
84
|
+
breakType?: "nextPage" | "continuous" | "evenPage" | "oddPage" | "nextColumn";
|
|
85
|
+
/** `w:pgNumType` — page numbering format/start/chapter. Round-trip only. */
|
|
86
|
+
pageNumbering?: EditorPageNumbering;
|
|
87
|
+
/** `w:vAlign` — vertical justification of page contents. Round-trip only. */
|
|
88
|
+
verticalAlignment?: EditorSectionVerticalAlign;
|
|
89
|
+
/** `w:bidi` — right-to-left section layout. Round-trip only. */
|
|
90
|
+
bidi?: boolean;
|
|
55
91
|
}
|
|
56
92
|
/**
|
|
57
93
|
* One `w:font` entry from `word/fontTable.xml`: the document's declaration of a
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Element as XmlElement } from '@xmldom/xmldom';
|
|
2
|
-
import { EditorBlockNode, EditorNamedStyle, EditorPageSettings, EditorParagraphNode } from '../../core/model.js';
|
|
2
|
+
import { EditorBlockNode, EditorNamedStyle, EditorPageNumbering, EditorPageSettings, EditorParagraphNode, EditorSectionVerticalAlign } from '../../core/model.js';
|
|
3
3
|
import { DocxSettings } from './settings.js';
|
|
4
4
|
|
|
5
5
|
export interface SectionProperties {
|
|
@@ -9,6 +9,18 @@ export interface SectionProperties {
|
|
|
9
9
|
docGridLinePitchPx?: number;
|
|
10
10
|
docGridMode?: "explicit";
|
|
11
11
|
docGridType?: string | null;
|
|
12
|
+
/**
|
|
13
|
+
* `w:type` — section break type. In OOXML this sits on the sectPr that
|
|
14
|
+
* *ends* a section and describes how the *following* section begins; the
|
|
15
|
+
* import driver applies the off-by-one when building `EditorSection` objects.
|
|
16
|
+
*/
|
|
17
|
+
breakType?: "nextPage" | "continuous" | "evenPage" | "oddPage" | "nextColumn";
|
|
18
|
+
/** `w:pgNumType` — page numbering format/start/chapter. Round-trip only. */
|
|
19
|
+
pageNumbering?: EditorPageNumbering;
|
|
20
|
+
/** `w:vAlign` — vertical justification of page contents. Round-trip only. */
|
|
21
|
+
verticalAlignment?: EditorSectionVerticalAlign;
|
|
22
|
+
/** `w:bidi` — right-to-left section layout. Round-trip only. */
|
|
23
|
+
bidi?: boolean;
|
|
12
24
|
}
|
|
13
25
|
export declare function parseSectionProperties(sectPr: XmlElement): SectionProperties;
|
|
14
26
|
export declare function parsePageSettings(body: XmlElement | undefined): EditorPageSettings | undefined;
|
|
@@ -2623,7 +2623,7 @@ function OasisEditorAppLazy(props = {}) {
|
|
|
2623
2623
|
onCleanup(() => {
|
|
2624
2624
|
cancelled = true;
|
|
2625
2625
|
});
|
|
2626
|
-
import("./OasisEditorApp-
|
|
2626
|
+
import("./OasisEditorApp-3vvH6KOz.js").then((m) => {
|
|
2627
2627
|
cancelled = true;
|
|
2628
2628
|
setProgress(1);
|
|
2629
2629
|
setTimeout(() => setApp(() => m.OasisEditorApp), 180);
|
|
@@ -34895,6 +34895,30 @@ function parseSectionProperties(sectPr) {
|
|
|
34895
34895
|
getAttributeValue(docGrid, "linePitch"),
|
|
34896
34896
|
Number.NaN
|
|
34897
34897
|
);
|
|
34898
|
+
const typeElement = getFirstChildByTagNameNS(sectPr, WORD_NS, "type");
|
|
34899
|
+
const typeValue = getAttributeValue(typeElement, "val");
|
|
34900
|
+
const breakType = typeValue === "continuous" || typeValue === "nextPage" || typeValue === "evenPage" || typeValue === "oddPage" || typeValue === "nextColumn" ? typeValue : void 0;
|
|
34901
|
+
const pgNumType = getFirstChildByTagNameNS(sectPr, WORD_NS, "pgNumType");
|
|
34902
|
+
let pageNumbering;
|
|
34903
|
+
if (pgNumType) {
|
|
34904
|
+
const startRaw = getAttributeValue(pgNumType, "start");
|
|
34905
|
+
const start = startRaw !== null ? Number.parseInt(startRaw, 10) : void 0;
|
|
34906
|
+
const format = getAttributeValue(pgNumType, "fmt") ?? void 0;
|
|
34907
|
+
const chapterStyle = getAttributeValue(pgNumType, "chapStyle") ?? void 0;
|
|
34908
|
+
const chapterSeparator = getAttributeValue(pgNumType, "chapSep") ?? void 0;
|
|
34909
|
+
if (start !== void 0 && Number.isFinite(start) || format || chapterStyle || chapterSeparator) {
|
|
34910
|
+
pageNumbering = {
|
|
34911
|
+
...start !== void 0 && Number.isFinite(start) ? { start } : {},
|
|
34912
|
+
...format ? { format } : {},
|
|
34913
|
+
...chapterStyle ? { chapterStyle } : {},
|
|
34914
|
+
...chapterSeparator ? { chapterSeparator } : {}
|
|
34915
|
+
};
|
|
34916
|
+
}
|
|
34917
|
+
}
|
|
34918
|
+
const vAlignElement = getFirstChildByTagNameNS(sectPr, WORD_NS, "vAlign");
|
|
34919
|
+
const vAlignValue = getAttributeValue(vAlignElement, "val");
|
|
34920
|
+
const verticalAlignment = vAlignValue === "center" || vAlignValue === "both" || vAlignValue === "bottom" ? vAlignValue : void 0;
|
|
34921
|
+
const bidi = parseOnOffProperty(sectPr, "bidi");
|
|
34898
34922
|
return {
|
|
34899
34923
|
pageSettings,
|
|
34900
34924
|
headerRIds,
|
|
@@ -34906,7 +34930,11 @@ function parseSectionProperties(sectPr) {
|
|
|
34906
34930
|
// Latin line height; treating it as a grid floored every body line to the
|
|
34907
34931
|
// pitch (e.g. 360 twips = 24px), inflating spacing well beyond Word.
|
|
34908
34932
|
docGridMode: docGridType === "lines" || docGridType === "linesAndChars" ? "explicit" : void 0,
|
|
34909
|
-
docGridType
|
|
34933
|
+
docGridType,
|
|
34934
|
+
breakType,
|
|
34935
|
+
pageNumbering,
|
|
34936
|
+
verticalAlignment,
|
|
34937
|
+
bidi
|
|
34910
34938
|
};
|
|
34911
34939
|
}
|
|
34912
34940
|
function parsePageSettings(body) {
|
|
@@ -37021,7 +37049,7 @@ function parseCommentsXml(commentsXml, commentsExtendedXml) {
|
|
|
37021
37049
|
return byDocxId;
|
|
37022
37050
|
}
|
|
37023
37051
|
async function importDocxToEditorDocument(buffer, options = {}) {
|
|
37024
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n;
|
|
37052
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o;
|
|
37025
37053
|
(_a = options.onProgress) == null ? void 0 : _a.call(options, "opening-docx");
|
|
37026
37054
|
const zip = await JSZip.loadAsync(buffer);
|
|
37027
37055
|
const documentXml = await ((_b = zip.file("word/document.xml")) == null ? void 0 : _b.async("string"));
|
|
@@ -37129,6 +37157,17 @@ async function importDocxToEditorDocument(buffer, options = {}) {
|
|
|
37129
37157
|
if (parsedParagraph.pageBreakAfter) {
|
|
37130
37158
|
pendingPageBreakBefore = true;
|
|
37131
37159
|
}
|
|
37160
|
+
const paragraphProperties = getFirstChildByTagNameNS(
|
|
37161
|
+
element,
|
|
37162
|
+
WORD_NS,
|
|
37163
|
+
"pPr"
|
|
37164
|
+
);
|
|
37165
|
+
const inlineSectPr = paragraphProperties ? getFirstChildByTagNameNS(paragraphProperties, WORD_NS, "sectPr") : null;
|
|
37166
|
+
if (inlineSectPr) {
|
|
37167
|
+
sectionProps.push(parseSectionProperties(inlineSectPr));
|
|
37168
|
+
sectionBlocks.push([]);
|
|
37169
|
+
pendingPageBreakBefore = false;
|
|
37170
|
+
}
|
|
37132
37171
|
reportBodyProgress();
|
|
37133
37172
|
} else if (element.localName === "tbl") {
|
|
37134
37173
|
appendBodyBlock(
|
|
@@ -37260,6 +37299,10 @@ async function importDocxToEditorDocument(buffer, options = {}) {
|
|
|
37260
37299
|
}
|
|
37261
37300
|
};
|
|
37262
37301
|
const pageSettings = normalizePageSettings(rawPageSettings);
|
|
37302
|
+
const breakType = i > 0 ? (_k = sectionProps[i - 1]) == null ? void 0 : _k.breakType : void 0;
|
|
37303
|
+
const pageNumbering = props.pageNumbering;
|
|
37304
|
+
const verticalAlignment = props.verticalAlignment;
|
|
37305
|
+
const bidi = props.bidi;
|
|
37263
37306
|
sections.push({
|
|
37264
37307
|
id: `section:${i + 1}`,
|
|
37265
37308
|
blocks: blocks.length > 0 ? blocks : [createEditorParagraphFromRuns([{ text: "" }])],
|
|
@@ -37269,10 +37312,14 @@ async function importDocxToEditorDocument(buffer, options = {}) {
|
|
|
37269
37312
|
evenPageHeader: evenPageHeader.length > 0 ? evenPageHeader : void 0,
|
|
37270
37313
|
footer: footer.length > 0 ? footer : void 0,
|
|
37271
37314
|
firstPageFooter: firstPageFooter.length > 0 ? firstPageFooter : void 0,
|
|
37272
|
-
evenPageFooter: evenPageFooter.length > 0 ? evenPageFooter : void 0
|
|
37315
|
+
evenPageFooter: evenPageFooter.length > 0 ? evenPageFooter : void 0,
|
|
37316
|
+
...breakType ? { breakType } : {},
|
|
37317
|
+
...pageNumbering ? { pageNumbering } : {},
|
|
37318
|
+
...verticalAlignment ? { verticalAlignment } : {},
|
|
37319
|
+
...bidi ? { bidi } : {}
|
|
37273
37320
|
});
|
|
37274
37321
|
}
|
|
37275
|
-
const footnotesXml = await ((
|
|
37322
|
+
const footnotesXml = await ((_l = zip.file("word/footnotes.xml")) == null ? void 0 : _l.async("string")) ?? null;
|
|
37276
37323
|
const footnotesPartRels = footnotesXml ? await loadPartRelationships(zip, "word/footnotes.xml") : /* @__PURE__ */ new Map();
|
|
37277
37324
|
const parsedFootnotes = await parseFootnotesXml(
|
|
37278
37325
|
footnotesXml,
|
|
@@ -37287,7 +37334,7 @@ async function importDocxToEditorDocument(buffer, options = {}) {
|
|
|
37287
37334
|
}
|
|
37288
37335
|
const editorFootnotes = Object.keys(parsedFootnotes.footnotes.items).length > 0 || parsedFootnotes.footnotes.separator || parsedFootnotes.footnotes.continuationSeparator || parsedFootnotes.footnotes.settings ? parsedFootnotes.footnotes : void 0;
|
|
37289
37336
|
remapImportedFootnoteRefsInSections(sections, parsedFootnotes.byDocxId);
|
|
37290
|
-
const endnotesXml = await ((
|
|
37337
|
+
const endnotesXml = await ((_m = zip.file("word/endnotes.xml")) == null ? void 0 : _m.async("string")) ?? null;
|
|
37291
37338
|
const endnotesPartRels = endnotesXml ? await loadPartRelationships(zip, "word/endnotes.xml") : /* @__PURE__ */ new Map();
|
|
37292
37339
|
const parsedEndnotes = await parseEndnotesXml(
|
|
37293
37340
|
endnotesXml,
|
|
@@ -37304,14 +37351,14 @@ async function importDocxToEditorDocument(buffer, options = {}) {
|
|
|
37304
37351
|
remapImportedEndnoteRefsInSections(sections, parsedEndnotes.byDocxId);
|
|
37305
37352
|
const editorBookmarks = extractBookmarksFromSections(sections);
|
|
37306
37353
|
const commentRanges = extractCommentRangesFromSections(sections);
|
|
37307
|
-
const commentsXml = await ((
|
|
37308
|
-
const commentsExtendedXml = await ((
|
|
37354
|
+
const commentsXml = await ((_n = zip.file("word/comments.xml")) == null ? void 0 : _n.async("string")) ?? null;
|
|
37355
|
+
const commentsExtendedXml = await ((_o = zip.file("word/commentsExtended.xml")) == null ? void 0 : _o.async("string")) ?? null;
|
|
37309
37356
|
const commentBodies = parseCommentsXml(commentsXml, commentsExtendedXml);
|
|
37310
37357
|
const editorComments = buildEditorComments(commentRanges, commentBodies);
|
|
37311
37358
|
const shouldPreserveSections = sections.length > 1 || sections.some(
|
|
37312
37359
|
(section) => {
|
|
37313
37360
|
var _a2, _b2, _c2, _d2, _e2, _f2;
|
|
37314
|
-
return (((_a2 = section.header) == null ? void 0 : _a2.length) ?? 0) > 0 || (((_b2 = section.firstPageHeader) == null ? void 0 : _b2.length) ?? 0) > 0 || (((_c2 = section.evenPageHeader) == null ? void 0 : _c2.length) ?? 0) > 0 || (((_d2 = section.footer) == null ? void 0 : _d2.length) ?? 0) > 0 || (((_e2 = section.firstPageFooter) == null ? void 0 : _e2.length) ?? 0) > 0 || (((_f2 = section.evenPageFooter) == null ? void 0 : _f2.length) ?? 0) > 0;
|
|
37361
|
+
return (((_a2 = section.header) == null ? void 0 : _a2.length) ?? 0) > 0 || (((_b2 = section.firstPageHeader) == null ? void 0 : _b2.length) ?? 0) > 0 || (((_c2 = section.evenPageHeader) == null ? void 0 : _c2.length) ?? 0) > 0 || (((_d2 = section.footer) == null ? void 0 : _d2.length) ?? 0) > 0 || (((_e2 = section.firstPageFooter) == null ? void 0 : _e2.length) ?? 0) > 0 || (((_f2 = section.evenPageFooter) == null ? void 0 : _f2.length) ?? 0) > 0 || section.breakType !== void 0 || section.pageNumbering !== void 0 || section.verticalAlignment !== void 0 || section.bidi !== void 0;
|
|
37315
37362
|
}
|
|
37316
37363
|
);
|
|
37317
37364
|
const hasAssets = Object.keys(assets.assets).length > 0;
|
|
@@ -37514,7 +37561,7 @@ function importDocxInWorker(buffer, options = {}) {
|
|
|
37514
37561
|
const worker = new Worker(
|
|
37515
37562
|
new URL(
|
|
37516
37563
|
/* @vite-ignore */
|
|
37517
|
-
"" + new URL("assets/importDocxWorker-
|
|
37564
|
+
"" + new URL("assets/importDocxWorker-DdpdjbOY.js", import.meta.url).href,
|
|
37518
37565
|
import.meta.url
|
|
37519
37566
|
),
|
|
37520
37567
|
{
|
package/dist/oasis-editor.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { cV, a5, aj, az, at, cW, cX, cY, an, cZ, a6, cE, aA, c_, c$, ay, aq, d0, d1, d2, a4, d3, cC, aC, d4, d5, d6, d7, d8, cQ, d9, da, db, aG, aF, dc, ar, dd, de, df, dg, dh, di, av, as, dj, aJ, aB, aI, aH, am, ax, cP, dk, cW as cW2, d0 as d02, d3 as d32, dc as dc2, dd as dd2, di as di2, dl, cG, cB, dm, dn, dp, cD, dq, dr, cF } from "./index-
|
|
1
|
+
import { cV, a5, aj, az, at, cW, cX, cY, an, cZ, a6, cE, aA, c_, c$, ay, aq, d0, d1, d2, a4, d3, cC, aC, d4, d5, d6, d7, d8, cQ, d9, da, db, aG, aF, dc, ar, dd, de, df, dg, dh, di, av, as, dj, aJ, aB, aI, aH, am, ax, cP, dk, cW as cW2, d0 as d02, d3 as d32, dc as dc2, dd as dd2, di as di2, dl, cG, cB, dm, dn, dp, cD, dq, dr, cF } from "./index-Ceyv5JS5.js";
|
|
2
2
|
export {
|
|
3
3
|
cV as ActionRow,
|
|
4
4
|
a5 as BalloonShell,
|