oasis-editor 0.0.125 → 0.0.127

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.
@@ -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
- breakType?: "nextPage" | "continuous";
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
@@ -122,6 +122,8 @@ export interface EditorParagraphStyle {
122
122
  */
123
123
  /** `w:suppressLineNumbers/@w:val`: omit this paragraph from section line numbering. */
124
124
  suppressLineNumbers?: boolean;
125
+ /** `w:suppressAutoHyphens/@w:val`: disable auto-hyphenation for this paragraph. */
126
+ suppressAutoHyphens?: boolean;
125
127
  /** `w:bidi/@w:val`: paragraph flows right-to-left. */
126
128
  bidi?: boolean;
127
129
  /** `w:kinsoku/@w:val`: East Asian line-breaking rule (default on). */
@@ -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-CZVAf0XI.js").then((m) => {
2626
+ import("./OasisEditorApp-3vvH6KOz.js").then((m) => {
2627
2627
  cancelled = true;
2628
2628
  setProgress(1);
2629
2629
  setTimeout(() => setApp(() => m.OasisEditorApp), 180);
@@ -3367,6 +3367,7 @@ const DEFAULT_PARAGRAPH_STYLE = asRequired({
3367
3367
  textDirection: null,
3368
3368
  outlineLevel: null,
3369
3369
  suppressLineNumbers: false,
3370
+ suppressAutoHyphens: false,
3370
3371
  bidi: false,
3371
3372
  kinsoku: true,
3372
3373
  wordWrap: true,
@@ -14498,7 +14499,11 @@ function composeMeasuredParagraphLines(options) {
14498
14499
  var _a;
14499
14500
  const { paragraph, fragments, styles, contentWidth, defaultTabStop } = options;
14500
14501
  const exclusions = options.exclusions ?? [];
14501
- const hyphenation = options.hyphenation;
14502
+ const effectiveParagraphStyle = resolveEffectiveParagraphStyle(
14503
+ paragraph.style,
14504
+ styles
14505
+ );
14506
+ const hyphenation = effectiveParagraphStyle.suppressAutoHyphens ? void 0 : options.hyphenation;
14502
14507
  const measuredChars = buildMeasuredChars(paragraph, fragments, styles);
14503
14508
  const tokens = tokenizeMeasuredChars(measuredChars);
14504
14509
  const charByOffset = new Map(
@@ -34270,6 +34275,7 @@ function normalizeImportedParagraphStyle(style2) {
34270
34275
  textDirection: style2.textDirection ?? void 0,
34271
34276
  outlineLevel: style2.outlineLevel ?? void 0,
34272
34277
  suppressLineNumbers: style2.suppressLineNumbers !== void 0 || effective.suppressLineNumbers !== defaultEffective.suppressLineNumbers ? effective.suppressLineNumbers : void 0,
34278
+ suppressAutoHyphens: style2.suppressAutoHyphens !== void 0 || effective.suppressAutoHyphens !== defaultEffective.suppressAutoHyphens ? effective.suppressAutoHyphens : void 0,
34273
34279
  bidi: style2.bidi !== void 0 || effective.bidi !== defaultEffective.bidi ? effective.bidi : void 0,
34274
34280
  kinsoku: style2.kinsoku !== void 0 || effective.kinsoku !== defaultEffective.kinsoku ? effective.kinsoku : void 0,
34275
34281
  wordWrap: style2.wordWrap !== void 0 || effective.wordWrap !== defaultEffective.wordWrap ? effective.wordWrap : void 0,
@@ -34494,6 +34500,13 @@ function parseParagraphStyle$1(paragraphProperties, colors) {
34494
34500
  if (suppressLineNumbers !== void 0) {
34495
34501
  style2.suppressLineNumbers = suppressLineNumbers;
34496
34502
  }
34503
+ const suppressAutoHyphens = parseOnOffProperty(
34504
+ paragraphProperties,
34505
+ "suppressAutoHyphens"
34506
+ );
34507
+ if (suppressAutoHyphens !== void 0) {
34508
+ style2.suppressAutoHyphens = suppressAutoHyphens;
34509
+ }
34497
34510
  const bidi = parseOnOffProperty(paragraphProperties, "bidi");
34498
34511
  if (bidi !== void 0) {
34499
34512
  style2.bidi = bidi;
@@ -34882,6 +34895,30 @@ function parseSectionProperties(sectPr) {
34882
34895
  getAttributeValue(docGrid, "linePitch"),
34883
34896
  Number.NaN
34884
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");
34885
34922
  return {
34886
34923
  pageSettings,
34887
34924
  headerRIds,
@@ -34893,7 +34930,11 @@ function parseSectionProperties(sectPr) {
34893
34930
  // Latin line height; treating it as a grid floored every body line to the
34894
34931
  // pitch (e.g. 360 twips = 24px), inflating spacing well beyond Word.
34895
34932
  docGridMode: docGridType === "lines" || docGridType === "linesAndChars" ? "explicit" : void 0,
34896
- docGridType
34933
+ docGridType,
34934
+ breakType,
34935
+ pageNumbering,
34936
+ verticalAlignment,
34937
+ bidi
34897
34938
  };
34898
34939
  }
34899
34940
  function parsePageSettings(body) {
@@ -37008,7 +37049,7 @@ function parseCommentsXml(commentsXml, commentsExtendedXml) {
37008
37049
  return byDocxId;
37009
37050
  }
37010
37051
  async function importDocxToEditorDocument(buffer, options = {}) {
37011
- 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;
37012
37053
  (_a = options.onProgress) == null ? void 0 : _a.call(options, "opening-docx");
37013
37054
  const zip = await JSZip.loadAsync(buffer);
37014
37055
  const documentXml = await ((_b = zip.file("word/document.xml")) == null ? void 0 : _b.async("string"));
@@ -37116,6 +37157,17 @@ async function importDocxToEditorDocument(buffer, options = {}) {
37116
37157
  if (parsedParagraph.pageBreakAfter) {
37117
37158
  pendingPageBreakBefore = true;
37118
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
+ }
37119
37171
  reportBodyProgress();
37120
37172
  } else if (element.localName === "tbl") {
37121
37173
  appendBodyBlock(
@@ -37247,6 +37299,10 @@ async function importDocxToEditorDocument(buffer, options = {}) {
37247
37299
  }
37248
37300
  };
37249
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;
37250
37306
  sections.push({
37251
37307
  id: `section:${i + 1}`,
37252
37308
  blocks: blocks.length > 0 ? blocks : [createEditorParagraphFromRuns([{ text: "" }])],
@@ -37256,10 +37312,14 @@ async function importDocxToEditorDocument(buffer, options = {}) {
37256
37312
  evenPageHeader: evenPageHeader.length > 0 ? evenPageHeader : void 0,
37257
37313
  footer: footer.length > 0 ? footer : void 0,
37258
37314
  firstPageFooter: firstPageFooter.length > 0 ? firstPageFooter : void 0,
37259
- 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 } : {}
37260
37320
  });
37261
37321
  }
37262
- const footnotesXml = await ((_k = zip.file("word/footnotes.xml")) == null ? void 0 : _k.async("string")) ?? null;
37322
+ const footnotesXml = await ((_l = zip.file("word/footnotes.xml")) == null ? void 0 : _l.async("string")) ?? null;
37263
37323
  const footnotesPartRels = footnotesXml ? await loadPartRelationships(zip, "word/footnotes.xml") : /* @__PURE__ */ new Map();
37264
37324
  const parsedFootnotes = await parseFootnotesXml(
37265
37325
  footnotesXml,
@@ -37274,7 +37334,7 @@ async function importDocxToEditorDocument(buffer, options = {}) {
37274
37334
  }
37275
37335
  const editorFootnotes = Object.keys(parsedFootnotes.footnotes.items).length > 0 || parsedFootnotes.footnotes.separator || parsedFootnotes.footnotes.continuationSeparator || parsedFootnotes.footnotes.settings ? parsedFootnotes.footnotes : void 0;
37276
37336
  remapImportedFootnoteRefsInSections(sections, parsedFootnotes.byDocxId);
37277
- const endnotesXml = await ((_l = zip.file("word/endnotes.xml")) == null ? void 0 : _l.async("string")) ?? null;
37337
+ const endnotesXml = await ((_m = zip.file("word/endnotes.xml")) == null ? void 0 : _m.async("string")) ?? null;
37278
37338
  const endnotesPartRels = endnotesXml ? await loadPartRelationships(zip, "word/endnotes.xml") : /* @__PURE__ */ new Map();
37279
37339
  const parsedEndnotes = await parseEndnotesXml(
37280
37340
  endnotesXml,
@@ -37291,14 +37351,14 @@ async function importDocxToEditorDocument(buffer, options = {}) {
37291
37351
  remapImportedEndnoteRefsInSections(sections, parsedEndnotes.byDocxId);
37292
37352
  const editorBookmarks = extractBookmarksFromSections(sections);
37293
37353
  const commentRanges = extractCommentRangesFromSections(sections);
37294
- const commentsXml = await ((_m = zip.file("word/comments.xml")) == null ? void 0 : _m.async("string")) ?? null;
37295
- const commentsExtendedXml = await ((_n = zip.file("word/commentsExtended.xml")) == null ? void 0 : _n.async("string")) ?? null;
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;
37296
37356
  const commentBodies = parseCommentsXml(commentsXml, commentsExtendedXml);
37297
37357
  const editorComments = buildEditorComments(commentRanges, commentBodies);
37298
37358
  const shouldPreserveSections = sections.length > 1 || sections.some(
37299
37359
  (section) => {
37300
37360
  var _a2, _b2, _c2, _d2, _e2, _f2;
37301
- 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;
37302
37362
  }
37303
37363
  );
37304
37364
  const hasAssets = Object.keys(assets.assets).length > 0;
@@ -37501,7 +37561,7 @@ function importDocxInWorker(buffer, options = {}) {
37501
37561
  const worker = new Worker(
37502
37562
  new URL(
37503
37563
  /* @vite-ignore */
37504
- "" + new URL("assets/importDocxWorker-C9tO3vbp.js", import.meta.url).href,
37564
+ "" + new URL("assets/importDocxWorker-DdpdjbOY.js", import.meta.url).href,
37505
37565
  import.meta.url
37506
37566
  ),
37507
37567
  {
@@ -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-JfmhzLRe.js";
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,