oasis-editor 0.0.50 → 0.0.52

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.
@@ -1,7 +1,7 @@
1
1
  var __defProp = Object.defineProperty;
2
2
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3
3
  var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
4
- import { n as normalizeSelection, g as getParagraphs, c as createEditorParagraphFromRuns, a as getParagraphLength, b as createEditorRun, d as getDocumentSections, e as createEditorStyledRun, f as getParagraphText, h as getActiveZone, i as getActiveSectionIndex, p as positionToParagraphOffset, j as paragraphOffsetToPosition, k as clampPosition, l as findParagraphIndex, m as createCollapsedSelection, o as isSelectionCollapsed, E as EMU_PER_PX, q as createEditorParagraph, r as getBlockParagraphs, s as createEditorFootnote, t as createFootnoteReferenceRun, u as renumberFootnotes, v as iterateFootnoteReferenceRuns, w as getFootnoteDisplayMarker, x as findParagraphTableLocation, y as buildTableCellLayout, z as createSignal, A as createEffect, B as onCleanup, C as buildCanvasLayoutSnapshot, D as on, F as onMount, G as debounce, H as unwrap, I as getDocumentParagraphs, P as PT_PER_PX, J as createEditorTableCell, K as createEditorTableRow, L as createEditorTable, M as getDocumentSectionsCanonical, N as createEditorDocument, O as getPageContentWidth, Q as getDocumentPageSettings, R as getTableCellContentWidthForParagraph, S as resolveResizedDimensions, T as resolveImageSrc, U as resolveTextBoxRenderHeight, V as TWIPS_PER_POINT, W as PX_PER_INCH, X as TWIPS_PER_INCH, Y as resolveEffectiveParagraphStyle, Z as resolveEffectiveTextStyleForParagraph, _ as EMU_PER_PT, $ as iterateEndnoteReferenceRuns, a0 as JSZip, a1 as imageContentTypeDefaults, a2 as imageExtensionFromMime, a3 as pxToPt$1, a4 as resolveFloatingObjectRect, a5 as getTextBoxFloatingGeometry, a6 as getPresetPathSegments, a7 as projectBlocksLayout, a8 as buildListLabels, a9 as textStyleToFontSizePt, aa as PX_PER_POINT, ab as DEFAULT_FONT_SIZE_PX, ac as isDoubleUnderlineStyle, ad as isWavyUnderlineStyle, ae as underlineStyleLineWidthPx, af as underlineStyleDashArray, ag as resolveListLabel, ah as getListLabelInset, ai as getAlignedListLabelInset, aj as getParagraphBorderInsets, ak as buildSegmentTable, al as buildCanvasTableLayout, am as normalizeFamily, an as ROBOTO_FONT_FILES, ao as loadFontAsset, ap as OFFICE_COMPAT_FONT_FAMILIES, aq as buildSfnt, ar as defaultFontDecoderRegistry, as as SfntFontProgram, at as collectPdfFontFamilies, au as projectDocumentLayout, av as getPageHeaderZoneTop, aw as getPageBodyTop, ax as getPageColumnRects, ay as findFootnoteReference, az as FOOTNOTE_MARKER_GUTTER_PX, aA as resolveImporterForFile, aB as createEditorStateFromDocument, aC as getDocumentParagraphsCanonical, aD as getToolbarStyleState, aE as STANDARD_FONT_SIZES_PT, aF as fontSizePxToPt, aG as probeLocalFontFamilies, aH as createInitialEditorState, aI as parseFontSizePtToPx, aJ as formatFontSizePt, aK as underlineStyleToCssDecorationStyle, aL as listKindForTag, aM as isParagraphTag, aN as collectInlineRuns, aO as parseParagraphStyle, aP as getCachedCanvasImage, aQ as getHeadingLevel, aR as preciseFontModeVersion, aS as isPreciseFontModeEnabled, aT as togglePreciseFontMode, aU as nextFontSizePt, aV as previousFontSizePt, aW as fontSizePtToPx, aX as createDefaultToolbarPreset, aY as MenuRegistry, aZ as createToolbarRegistry, a_ as Editor, a$ as resolveCommandRef, b0 as commandRefName, b1 as InlineShell, b2 as BalloonShell, b3 as DocumentShell, b4 as createMemo, b5 as getCaretRectFromSnapshot, b6 as getParagraphRectFromSnapshot, b7 as createComponent, b8 as CaretOverlay, b9 as Show, ba as createRenderEffect, bb as style, bc as setAttribute, bd as setStyleProperty, be as memo, bf as template, bg as useI18n, bh as insert, bi as use, bj as addEventListener, bk as Dialog, bl as delegateEvents, bm as className, bn as For, bo as UNDERLINE_STYLE_OPTIONS, bp as Tabs, bq as measureParagraphMinContentWidthPx, br as getEditableBlocksForZone, bs as findParagraphLocation, bt as createSectionBoundaryParagraph, bu as normalizePageSettings, bv as DEFAULT_EDITOR_PAGE_SETTINGS, bw as markStart, bx as markEnd, by as getParagraphEntries, bz as getParagraphById, bA as PluginUiHost, bB as OasisEditorEditor, bC as perfTimer, bD as OasisBrandMark, bE as setPreciseFontPreference, bF as setWelcomeSeen, bG as enablePreciseFontMode, bH as createOasisEditorClient, bI as createEditorZoom, bJ as startLongTaskObserver, bK as installGlobalReport, bL as applyStoredPreciseFontPreference, bM as getWelcomeSeen, bN as isLocalFontAccessSupported, bO as EDITOR_SCROLL_PADDING_PX, bP as Toolbar, bQ as OasisEditorLoading, bR as I18nProvider, bS as createEditorLogger, bT as createTranslator, bU as registerDomStatsSurface } from "./index-CXzR3Cux.js";
4
+ import { n as normalizeSelection, g as getParagraphs, c as createEditorParagraphFromRuns, a as getParagraphLength, b as createEditorRun, d as getDocumentSections, e as createEditorStyledRun, f as getParagraphText, h as getActiveZone, i as getActiveSectionIndex, p as positionToParagraphOffset, j as paragraphOffsetToPosition, k as clampPosition, l as findParagraphIndex, m as createCollapsedSelection, o as isSelectionCollapsed, E as EMU_PER_PX, q as createEditorParagraph, r as getBlockParagraphs, s as createEditorFootnote, t as createFootnoteReferenceRun, u as renumberFootnotes, v as iterateFootnoteReferenceRuns, w as getFootnoteDisplayMarker, x as findParagraphTableLocation, y as buildTableCellLayout, z as createSignal, A as createEffect, B as onCleanup, C as buildCanvasLayoutSnapshot, D as on, F as onMount, G as debounce, H as unwrap, I as getDocumentParagraphs, P as PT_PER_PX, J as createEditorTableCell, K as createEditorTableRow, L as createEditorTable, M as getDocumentSectionsCanonical, N as createEditorDocument, O as getPageContentWidth, Q as getDocumentPageSettings, R as getTableCellContentWidthForParagraph, S as resolveResizedDimensions, T as resolveImageSrc, U as resolveTextBoxRenderHeight, V as TWIPS_PER_POINT, W as PX_PER_INCH, X as TWIPS_PER_INCH, Y as resolveEffectiveParagraphStyle, Z as resolveEffectiveTextStyleForParagraph, _ as EMU_PER_PT, $ as iterateEndnoteReferenceRuns, a0 as imageContentTypeDefaults, a1 as JSZip, a2 as imageExtensionFromMime, a3 as pxToPt$1, a4 as resolveFloatingObjectRect, a5 as getTextBoxFloatingGeometry, a6 as getPresetPathSegments, a7 as projectBlocksLayout, a8 as buildListLabels, a9 as textStyleToFontSizePt, aa as PX_PER_POINT, ab as DEFAULT_FONT_SIZE_PX, ac as isDoubleUnderlineStyle, ad as isWavyUnderlineStyle, ae as underlineStyleLineWidthPx, af as underlineStyleDashArray, ag as resolveListLabel, ah as getListLabelInset, ai as getAlignedListLabelInset, aj as getParagraphBorderInsets, ak as buildSegmentTable, al as buildCanvasTableLayout, am as normalizeFamily, an as ROBOTO_FONT_FILES, ao as loadFontAsset, ap as OFFICE_COMPAT_FONT_FAMILIES, aq as buildSfnt, ar as defaultFontDecoderRegistry, as as SfntFontProgram, at as collectPdfFontFamilies, au as projectDocumentLayout, av as getPageHeaderZoneTop, aw as getPageBodyTop, ax as getPageColumnRects, ay as findFootnoteReference, az as FOOTNOTE_MARKER_GUTTER_PX, aA as resolveImporterForFile, aB as createEditorStateFromDocument, aC as getDocumentParagraphsCanonical, aD as getToolbarStyleState, aE as STANDARD_FONT_SIZES_PT, aF as fontSizePxToPt, aG as probeLocalFontFamilies, aH as createInitialEditorState, aI as parseFontSizePtToPx, aJ as formatFontSizePt, aK as underlineStyleToCssDecorationStyle, aL as listKindForTag, aM as isParagraphTag, aN as collectInlineRuns, aO as parseParagraphStyle, aP as getCachedCanvasImage, aQ as getHeadingLevel, aR as preciseFontModeVersion, aS as isPreciseFontModeEnabled, aT as togglePreciseFontMode, aU as nextFontSizePt, aV as previousFontSizePt, aW as fontSizePtToPx, aX as createDefaultToolbarPreset, aY as MenuRegistry, aZ as createToolbarRegistry, a_ as Editor, a$ as resolveCommandRef, b0 as commandRefName, b1 as InlineShell, b2 as BalloonShell, b3 as DocumentShell, b4 as createMemo, b5 as getCaretRectFromSnapshot, b6 as getParagraphRectFromSnapshot, b7 as createComponent, b8 as CaretOverlay, b9 as Show, ba as createRenderEffect, bb as style, bc as setAttribute, bd as setStyleProperty, be as memo, bf as template, bg as useI18n, bh as insert, bi as use, bj as addEventListener, bk as Dialog, bl as delegateEvents, bm as className, bn as For, bo as UNDERLINE_STYLE_OPTIONS, bp as Tabs, bq as measureParagraphMinContentWidthPx, br as getEditableBlocksForZone, bs as findParagraphLocation, bt as createSectionBoundaryParagraph, bu as normalizePageSettings, bv as DEFAULT_EDITOR_PAGE_SETTINGS, bw as markStart, bx as markEnd, by as getParagraphEntries, bz as getParagraphById, bA as PluginUiHost, bB as OasisEditorEditor, bC as perfTimer, bD as OasisBrandMark, bE as setPreciseFontPreference, bF as setWelcomeSeen, bG as enablePreciseFontMode, bH as createOasisEditorClient, bI as createEditorZoom, bJ as startLongTaskObserver, bK as installGlobalReport, bL as applyStoredPreciseFontPreference, bM as getWelcomeSeen, bN as isLocalFontAccessSupported, bO as EDITOR_SCROLL_PADDING_PX, bP as Toolbar, bQ as OasisEditorLoading, bR as I18nProvider, bS as createEditorLogger, bT as createTranslator, bU as registerDomStatsSurface } from "./index-BMJs8egS.js";
5
5
  function getSelectedObjectRun(state, predicate) {
6
6
  const normalized = normalizeSelection(state);
7
7
  if (normalized.isCollapsed || normalized.startIndex !== normalized.endIndex || normalized.endParagraphOffset - normalized.startParagraphOffset !== 1) {
@@ -8990,37 +8990,106 @@ function buildStylesXml(styles) {
8990
8990
  const styleElements = Object.values(styles).map(serializeNamedStyle).join("");
8991
8991
  return `<?xml version="1.0" encoding="UTF-8" standalone="yes"?><w:styles xmlns:w="${WORD_NS}" xmlns:w14="${WORD14_NS}">${styleElements}</w:styles>`;
8992
8992
  }
8993
- const DOCUMENT_XMLNS = `xmlns:w="${WORD_NS$1}" xmlns:w14="${WORD14_NS}" xmlns:wp="http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing" xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main" xmlns:pic="http://schemas.openxmlformats.org/drawingml/2006/picture" xmlns:wps="http://schemas.microsoft.com/office/word/2010/wordprocessingShape" xmlns:r="${OFFICE_REL_NS}"`;
8994
- function serializeSectionPropertiesWithReferences(pageSettings, references) {
8995
- var _a, _b, _c, _d, _e, _f, _g, _h, _i;
8996
- const width = pxToTwips(pageSettings.width, 12240);
8997
- const height = pxToTwips(pageSettings.height, 15840);
8998
- const margins = pageSettings.margins;
8999
- const orientationAttr = pageSettings.orientation === "landscape" ? ' w:orient="landscape"' : "";
9000
- const referencesXml = [
9001
- ((_a = references == null ? void 0 : references.header) == null ? void 0 : _a.first) ? `<w:headerReference w:type="first" r:id="${references.header.first.relId}"/>` : "",
9002
- ((_b = references == null ? void 0 : references.header) == null ? void 0 : _b.even) ? `<w:headerReference w:type="even" r:id="${references.header.even.relId}"/>` : "",
9003
- ((_c = references == null ? void 0 : references.header) == null ? void 0 : _c.default) ? `<w:headerReference w:type="default" r:id="${references.header.default.relId}"/>` : "",
9004
- ((_d = references == null ? void 0 : references.footer) == null ? void 0 : _d.first) ? `<w:footerReference w:type="first" r:id="${references.footer.first.relId}"/>` : "",
9005
- ((_e = references == null ? void 0 : references.footer) == null ? void 0 : _e.even) ? `<w:footerReference w:type="even" r:id="${references.footer.even.relId}"/>` : "",
9006
- ((_f = references == null ? void 0 : references.footer) == null ? void 0 : _f.default) ? `<w:footerReference w:type="default" r:id="${references.footer.default.relId}"/>` : ""
9007
- ].join("");
9008
- const titlePageXml = ((_g = references == null ? void 0 : references.header) == null ? void 0 : _g.first) || ((_h = references == null ? void 0 : references.footer) == null ? void 0 : _h.first) ? "<w:titlePg/>" : "";
9009
- const columns = pageSettings.columns;
9010
- let columnsXml = "";
9011
- if (columns && columns.count > 1) {
9012
- const space = pxToTwips(columns.space, 0);
9013
- const sepAttr = columns.separator ? ' w:sep="1"' : "";
9014
- if (columns.equalWidth === false && ((_i = columns.columns) == null ? void 0 : _i.length)) {
9015
- const colsXml = columns.columns.map(
9016
- (col) => `<w:col w:w="${pxToTwips(col.width, 0)}" w:space="${pxToTwips(col.space, 0)}"/>`
9017
- ).join("");
9018
- columnsXml = `<w:cols w:num="${columns.count}" w:space="${space}" w:equalWidth="0"${sepAttr}>${colsXml}</w:cols>`;
9019
- } else {
9020
- columnsXml = `<w:cols w:num="${columns.count}" w:space="${space}"${sepAttr}/>`;
9021
- }
8993
+ function buildContentTypesXml(hasNumbering, imageExtensions, hasSettings, parts, hasFootnotes, hasEndnotes, hasStyles, hasComments) {
8994
+ const overrides = parts.map((part) => {
8995
+ const contentType = part.kind === "header" ? "application/vnd.openxmlformats-officedocument.wordprocessingml.header+xml" : "application/vnd.openxmlformats-officedocument.wordprocessingml.footer+xml";
8996
+ return `<Override PartName="/word/${part.path}" ContentType="${contentType}"/>`;
8997
+ }).join("");
8998
+ return `<?xml version="1.0" encoding="UTF-8" standalone="yes"?><Types xmlns="http://schemas.openxmlformats.org/package/2006/content-types"><Default Extension="rels" ContentType="application/vnd.openxmlformats-package.relationships+xml"/><Default Extension="xml" ContentType="application/xml"/>${imageContentTypeDefaults(
8999
+ imageExtensions
9000
+ )}<Override PartName="/word/document.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml"/>${hasStyles ? '<Override PartName="/word/styles.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.styles+xml"/>' : ""}${hasNumbering ? '<Override PartName="/word/numbering.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.numbering+xml"/>' : ""}${hasSettings ? '<Override PartName="/word/settings.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.settings+xml"/>' : ""}${hasFootnotes ? '<Override PartName="/word/footnotes.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.footnotes+xml"/>' : ""}${hasEndnotes ? '<Override PartName="/word/endnotes.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.endnotes+xml"/>' : ""}${hasComments ? '<Override PartName="/word/comments.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.comments+xml"/><Override PartName="/word/commentsExtended.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.commentsExtended+xml"/>' : ""}${overrides}</Types>`;
9001
+ }
9002
+ function buildRootRelationshipsXml() {
9003
+ return `<?xml version="1.0" encoding="UTF-8" standalone="yes"?><Relationships xmlns="${PACKAGE_REL_NS}"><Relationship Id="rId1" Type="${OFFICE_REL_NS}/officeDocument" Target="word/document.xml"/></Relationships>`;
9004
+ }
9005
+ function buildDocumentRelationshipsXml(hasNumbering, hasSettings, images, hyperlinks, parts, hasFootnotes, hasEndnotes, hasStyles, hasComments) {
9006
+ let rels = "";
9007
+ if (hasStyles)
9008
+ rels += `<Relationship Id="rIdStyles" Type="${OFFICE_REL_NS}/styles" Target="styles.xml"/>`;
9009
+ if (hasNumbering)
9010
+ rels += `<Relationship Id="rIdNum" Type="${OFFICE_REL_NS}/numbering" Target="numbering.xml"/>`;
9011
+ if (hasSettings)
9012
+ rels += `<Relationship Id="rIdSettings" Type="${OFFICE_REL_NS}/settings" Target="settings.xml"/>`;
9013
+ for (const hyperlink of hyperlinks) {
9014
+ rels += `<Relationship Id="${hyperlink.rId}" Type="${OFFICE_REL_NS}/hyperlink" Target="${escapeXml(hyperlink.href)}" TargetMode="External"/>`;
9022
9015
  }
9023
- return `<w:sectPr>${referencesXml}${titlePageXml}<w:pgSz w:w="${width}" w:h="${height}"${orientationAttr}/><w:pgMar w:top="${pxToTwips(margins.top, 1440)}" w:right="${pxToTwips(margins.right, 1440)}" w:bottom="${pxToTwips(margins.bottom, 1440)}" w:left="${pxToTwips(margins.left, 1440)}" w:header="${pxToTwips(margins.header, 720)}" w:footer="${pxToTwips(margins.footer, 720)}" w:gutter="${pxToTwips(margins.gutter, 0)}"/>${columnsXml}</w:sectPr>`;
9016
+ for (const img of images) {
9017
+ const targetMode = img.kind === "linked" ? ' TargetMode="External"' : "";
9018
+ rels += `<Relationship Id="${img.rId}" Type="${OFFICE_REL_NS}/image" Target="${escapeXml(img.target)}"${targetMode}/>`;
9019
+ }
9020
+ for (const part of parts) {
9021
+ const relType = part.kind === "header" ? "header" : "footer";
9022
+ rels += `<Relationship Id="${part.relId}" Type="${OFFICE_REL_NS}/${relType}" Target="${part.path}"/>`;
9023
+ }
9024
+ if (hasFootnotes) {
9025
+ rels += `<Relationship Id="rIdFootnotes" Type="${OFFICE_REL_NS}/footnotes" Target="footnotes.xml"/>`;
9026
+ }
9027
+ if (hasEndnotes) {
9028
+ rels += `<Relationship Id="rIdEndnotes" Type="${OFFICE_REL_NS}/endnotes" Target="endnotes.xml"/>`;
9029
+ }
9030
+ if (hasComments) {
9031
+ rels += `<Relationship Id="rIdComments" Type="${OFFICE_REL_NS}/comments" Target="comments.xml"/>`;
9032
+ rels += `<Relationship Id="rIdCommentsExtended" Type="http://schemas.microsoft.com/office/2011/relationships/commentsExtended" Target="commentsExtended.xml"/>`;
9033
+ }
9034
+ return `<?xml version="1.0" encoding="UTF-8" standalone="yes"?><Relationships xmlns="${PACKAGE_REL_NS}">${rels}</Relationships>`;
9035
+ }
9036
+ const NOTE_NUMBER_FORMATS = {
9037
+ decimal: "decimal",
9038
+ lowerRoman: "lowerRoman",
9039
+ upperRoman: "upperRoman",
9040
+ lowerLetter: "lowerLetter",
9041
+ upperLetter: "upperLetter",
9042
+ symbol: "symbol"
9043
+ };
9044
+ const NOTE_RESTARTS = {
9045
+ continuous: "continuous",
9046
+ eachSection: "eachSect"
9047
+ };
9048
+ function serializeNoteSettings(tagName, settings) {
9049
+ if (!settings) return null;
9050
+ const parts = [];
9051
+ if (settings.numberFormat) {
9052
+ parts.push(
9053
+ `<w:numFmt w:val="${NOTE_NUMBER_FORMATS[settings.numberFormat]}"/>`
9054
+ );
9055
+ }
9056
+ if (settings.startAt !== void 0) {
9057
+ parts.push(`<w:numStart w:val="${Math.max(1, settings.startAt)}"/>`);
9058
+ }
9059
+ if (settings.restart) {
9060
+ parts.push(`<w:numRestart w:val="${NOTE_RESTARTS[settings.restart]}"/>`);
9061
+ }
9062
+ return parts.length > 0 ? `<w:${tagName}>${parts.join("")}</w:${tagName}>` : null;
9063
+ }
9064
+ function buildSettingsXml(hasEvenAndOddHeaders, defaultTabStop, footnoteSettings, endnoteSettings) {
9065
+ const parts = [];
9066
+ const defaultTabStopTwips = pointsToTwips(defaultTabStop);
9067
+ if (defaultTabStopTwips !== null) {
9068
+ parts.push(`<w:defaultTabStop w:val="${defaultTabStopTwips}"/>`);
9069
+ }
9070
+ const footnotePr = serializeNoteSettings("footnotePr", footnoteSettings);
9071
+ if (footnotePr) {
9072
+ parts.push(footnotePr);
9073
+ }
9074
+ const endnotePr = serializeNoteSettings("endnotePr", endnoteSettings);
9075
+ if (endnotePr) {
9076
+ parts.push(endnotePr);
9077
+ }
9078
+ if (hasEvenAndOddHeaders) {
9079
+ parts.push("<w:evenAndOddHeaders/>");
9080
+ }
9081
+ return `<?xml version="1.0" encoding="UTF-8" standalone="yes"?><w:settings xmlns:w="${WORD_NS$1}">${parts.join("")}</w:settings>`;
9082
+ }
9083
+ function buildPartRelationshipsXml(images, hyperlinks) {
9084
+ let rels = "";
9085
+ for (const hyperlink of hyperlinks) {
9086
+ rels += `<Relationship Id="${hyperlink.rId}" Type="${OFFICE_REL_NS}/hyperlink" Target="${escapeXml(hyperlink.href)}" TargetMode="External"/>`;
9087
+ }
9088
+ for (const img of images) {
9089
+ const targetMode = img.kind === "linked" ? ' TargetMode="External"' : "";
9090
+ rels += `<Relationship Id="${img.rId}" Type="${OFFICE_REL_NS}/image" Target="${escapeXml(img.target)}"${targetMode}/>`;
9091
+ }
9092
+ return `<?xml version="1.0" encoding="UTF-8" standalone="yes"?><Relationships xmlns="${PACKAGE_REL_NS}">${rels}</Relationships>`;
9024
9093
  }
9025
9094
  function visitParagraphDeep(paragraph, callback) {
9026
9095
  callback(paragraph);
@@ -9107,6 +9176,70 @@ function buildNumberingContext(document2) {
9107
9176
  }
9108
9177
  return { numberingInfo, definitions };
9109
9178
  }
9179
+ function buildNumberingXml(definitions) {
9180
+ const abstractNums = definitions.map(({ abstractNumId, levels }) => {
9181
+ const levelsXml = levels.sort((a, b) => a.level - b.level).map(
9182
+ ({
9183
+ kind,
9184
+ level,
9185
+ format,
9186
+ startAt,
9187
+ levelText,
9188
+ suffix,
9189
+ alignment,
9190
+ legal,
9191
+ bulletGlyph,
9192
+ bulletFont
9193
+ }) => {
9194
+ const numFmtVal = kind === "bullet" ? "bullet" : format ?? "decimal";
9195
+ const effectiveLevelText = levelText ?? (kind === "bullet" ? bulletGlyph ?? "" : `%${level + 1}.`);
9196
+ const startVal = startAt ?? 1;
9197
+ const fontName = kind === "bullet" ? bulletFont ?? "Symbol" : void 0;
9198
+ const runFonts = fontName ? `<w:rPr><w:rFonts w:ascii="${escapeXml(fontName)}" w:hAnsi="${escapeXml(fontName)}" w:hint="default"/></w:rPr>` : "";
9199
+ const suffixXml = suffix && suffix !== "tab" ? `<w:suff w:val="${suffix}"/>` : "";
9200
+ const legalXml = legal ? "<w:isLgl/>" : "";
9201
+ return `<w:lvl w:ilvl="${level}"><w:start w:val="${startVal}"/><w:numFmt w:val="${numFmtVal}"/><w:lvlText w:val="${escapeXml(effectiveLevelText)}"/><w:lvlJc w:val="${alignment ?? "left"}"/>${suffixXml}${legalXml}${runFonts}</w:lvl>`;
9202
+ }
9203
+ ).join("");
9204
+ return `<w:abstractNum w:abstractNumId="${abstractNumId}">${levelsXml}</w:abstractNum>`;
9205
+ }).join("");
9206
+ const nums = definitions.map(
9207
+ ({ abstractNumId, numId }) => `<w:num w:numId="${numId}"><w:abstractNumId w:val="${abstractNumId}"/></w:num>`
9208
+ ).join("");
9209
+ return `<?xml version="1.0" encoding="UTF-8" standalone="yes"?><w:numbering xmlns:w="${WORD_NS$1}">${abstractNums}${nums}</w:numbering>`;
9210
+ }
9211
+ const DOCUMENT_XMLNS = `xmlns:w="${WORD_NS$1}" xmlns:w14="${WORD14_NS}" xmlns:wp="http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing" xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main" xmlns:pic="http://schemas.openxmlformats.org/drawingml/2006/picture" xmlns:wps="http://schemas.microsoft.com/office/word/2010/wordprocessingShape" xmlns:r="${OFFICE_REL_NS}"`;
9212
+ function serializeSectionPropertiesWithReferences(pageSettings, references) {
9213
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i;
9214
+ const width = pxToTwips(pageSettings.width, 12240);
9215
+ const height = pxToTwips(pageSettings.height, 15840);
9216
+ const margins = pageSettings.margins;
9217
+ const orientationAttr = pageSettings.orientation === "landscape" ? ' w:orient="landscape"' : "";
9218
+ const referencesXml = [
9219
+ ((_a = references == null ? void 0 : references.header) == null ? void 0 : _a.first) ? `<w:headerReference w:type="first" r:id="${references.header.first.relId}"/>` : "",
9220
+ ((_b = references == null ? void 0 : references.header) == null ? void 0 : _b.even) ? `<w:headerReference w:type="even" r:id="${references.header.even.relId}"/>` : "",
9221
+ ((_c = references == null ? void 0 : references.header) == null ? void 0 : _c.default) ? `<w:headerReference w:type="default" r:id="${references.header.default.relId}"/>` : "",
9222
+ ((_d = references == null ? void 0 : references.footer) == null ? void 0 : _d.first) ? `<w:footerReference w:type="first" r:id="${references.footer.first.relId}"/>` : "",
9223
+ ((_e = references == null ? void 0 : references.footer) == null ? void 0 : _e.even) ? `<w:footerReference w:type="even" r:id="${references.footer.even.relId}"/>` : "",
9224
+ ((_f = references == null ? void 0 : references.footer) == null ? void 0 : _f.default) ? `<w:footerReference w:type="default" r:id="${references.footer.default.relId}"/>` : ""
9225
+ ].join("");
9226
+ const titlePageXml = ((_g = references == null ? void 0 : references.header) == null ? void 0 : _g.first) || ((_h = references == null ? void 0 : references.footer) == null ? void 0 : _h.first) ? "<w:titlePg/>" : "";
9227
+ const columns = pageSettings.columns;
9228
+ let columnsXml = "";
9229
+ if (columns && columns.count > 1) {
9230
+ const space = pxToTwips(columns.space, 0);
9231
+ const sepAttr = columns.separator ? ' w:sep="1"' : "";
9232
+ if (columns.equalWidth === false && ((_i = columns.columns) == null ? void 0 : _i.length)) {
9233
+ const colsXml = columns.columns.map(
9234
+ (col) => `<w:col w:w="${pxToTwips(col.width, 0)}" w:space="${pxToTwips(col.space, 0)}"/>`
9235
+ ).join("");
9236
+ columnsXml = `<w:cols w:num="${columns.count}" w:space="${space}" w:equalWidth="0"${sepAttr}>${colsXml}</w:cols>`;
9237
+ } else {
9238
+ columnsXml = `<w:cols w:num="${columns.count}" w:space="${space}"${sepAttr}/>`;
9239
+ }
9240
+ }
9241
+ return `<w:sectPr>${referencesXml}${titlePageXml}<w:pgSz w:w="${width}" w:h="${height}"${orientationAttr}/><w:pgMar w:top="${pxToTwips(margins.top, 1440)}" w:right="${pxToTwips(margins.right, 1440)}" w:bottom="${pxToTwips(margins.bottom, 1440)}" w:left="${pxToTwips(margins.left, 1440)}" w:header="${pxToTwips(margins.header, 720)}" w:footer="${pxToTwips(margins.footer, 720)}" w:gutter="${pxToTwips(margins.gutter, 0)}"/>${columnsXml}</w:sectPr>`;
9242
+ }
9110
9243
  function buildPartContext(blocks, numberingContext, state, document2) {
9111
9244
  const images = [];
9112
9245
  const imageMap = /* @__PURE__ */ new Map();
@@ -9186,38 +9319,6 @@ function buildPartContext(blocks, numberingContext, state, document2) {
9186
9319
  hyperlinkMap
9187
9320
  };
9188
9321
  }
9189
- function buildNumberingXml(definitions) {
9190
- const abstractNums = definitions.map(({ abstractNumId, levels }) => {
9191
- const levelsXml = levels.sort((a, b) => a.level - b.level).map(
9192
- ({
9193
- kind,
9194
- level,
9195
- format,
9196
- startAt,
9197
- levelText,
9198
- suffix,
9199
- alignment,
9200
- legal,
9201
- bulletGlyph,
9202
- bulletFont
9203
- }) => {
9204
- const numFmtVal = kind === "bullet" ? "bullet" : format ?? "decimal";
9205
- const effectiveLevelText = levelText ?? (kind === "bullet" ? bulletGlyph ?? "" : `%${level + 1}.`);
9206
- const startVal = startAt ?? 1;
9207
- const fontName = kind === "bullet" ? bulletFont ?? "Symbol" : void 0;
9208
- const runFonts = fontName ? `<w:rPr><w:rFonts w:ascii="${escapeXml(fontName)}" w:hAnsi="${escapeXml(fontName)}" w:hint="default"/></w:rPr>` : "";
9209
- const suffixXml = suffix && suffix !== "tab" ? `<w:suff w:val="${suffix}"/>` : "";
9210
- const legalXml = legal ? "<w:isLgl/>" : "";
9211
- return `<w:lvl w:ilvl="${level}"><w:start w:val="${startVal}"/><w:numFmt w:val="${numFmtVal}"/><w:lvlText w:val="${escapeXml(effectiveLevelText)}"/><w:lvlJc w:val="${alignment ?? "left"}"/>${suffixXml}${legalXml}${runFonts}</w:lvl>`;
9212
- }
9213
- ).join("");
9214
- return `<w:abstractNum w:abstractNumId="${abstractNumId}">${levelsXml}</w:abstractNum>`;
9215
- }).join("");
9216
- const nums = definitions.map(
9217
- ({ abstractNumId, numId }) => `<w:num w:numId="${numId}"><w:abstractNumId w:val="${abstractNumId}"/></w:num>`
9218
- ).join("");
9219
- return `<?xml version="1.0" encoding="UTF-8" standalone="yes"?><w:numbering xmlns:w="${WORD_NS$1}">${abstractNums}${nums}</w:numbering>`;
9220
- }
9221
9322
  function buildDocumentXml(document2, context, sectionReferences) {
9222
9323
  const sections = getDocumentSections(document2);
9223
9324
  const sectionsXml = sections.map((section, sectionIndex) => {
@@ -9238,107 +9339,6 @@ function buildHeaderFooterXml(kind, blocks, context, styles) {
9238
9339
  const tag = kind === "header" ? "hdr" : "ftr";
9239
9340
  return `<?xml version="1.0" encoding="UTF-8" standalone="yes"?><w:${tag} ${DOCUMENT_XMLNS}>${serializeBlocksXml(blocks, context, styles)}</w:${tag}>`;
9240
9341
  }
9241
- function buildContentTypesXml(hasNumbering, imageExtensions, hasSettings, parts, hasFootnotes, hasEndnotes, hasStyles, hasComments) {
9242
- const overrides = parts.map((part) => {
9243
- const contentType = part.kind === "header" ? "application/vnd.openxmlformats-officedocument.wordprocessingml.header+xml" : "application/vnd.openxmlformats-officedocument.wordprocessingml.footer+xml";
9244
- return `<Override PartName="/word/${part.path}" ContentType="${contentType}"/>`;
9245
- }).join("");
9246
- return `<?xml version="1.0" encoding="UTF-8" standalone="yes"?><Types xmlns="http://schemas.openxmlformats.org/package/2006/content-types"><Default Extension="rels" ContentType="application/vnd.openxmlformats-package.relationships+xml"/><Default Extension="xml" ContentType="application/xml"/>${imageContentTypeDefaults(
9247
- imageExtensions
9248
- )}<Override PartName="/word/document.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml"/>${hasStyles ? '<Override PartName="/word/styles.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.styles+xml"/>' : ""}${hasNumbering ? '<Override PartName="/word/numbering.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.numbering+xml"/>' : ""}${hasSettings ? '<Override PartName="/word/settings.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.settings+xml"/>' : ""}${hasFootnotes ? '<Override PartName="/word/footnotes.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.footnotes+xml"/>' : ""}${hasEndnotes ? '<Override PartName="/word/endnotes.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.endnotes+xml"/>' : ""}${hasComments ? '<Override PartName="/word/comments.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.comments+xml"/><Override PartName="/word/commentsExtended.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.commentsExtended+xml"/>' : ""}${overrides}</Types>`;
9249
- }
9250
- function buildRootRelationshipsXml() {
9251
- return `<?xml version="1.0" encoding="UTF-8" standalone="yes"?><Relationships xmlns="${PACKAGE_REL_NS}"><Relationship Id="rId1" Type="${OFFICE_REL_NS}/officeDocument" Target="word/document.xml"/></Relationships>`;
9252
- }
9253
- function buildDocumentRelationshipsXml(hasNumbering, hasSettings, images, hyperlinks, parts, hasFootnotes, hasEndnotes, hasStyles, hasComments) {
9254
- let rels = "";
9255
- if (hasStyles)
9256
- rels += `<Relationship Id="rIdStyles" Type="${OFFICE_REL_NS}/styles" Target="styles.xml"/>`;
9257
- if (hasNumbering)
9258
- rels += `<Relationship Id="rIdNum" Type="${OFFICE_REL_NS}/numbering" Target="numbering.xml"/>`;
9259
- if (hasSettings)
9260
- rels += `<Relationship Id="rIdSettings" Type="${OFFICE_REL_NS}/settings" Target="settings.xml"/>`;
9261
- for (const hyperlink of hyperlinks) {
9262
- rels += `<Relationship Id="${hyperlink.rId}" Type="${OFFICE_REL_NS}/hyperlink" Target="${escapeXml(hyperlink.href)}" TargetMode="External"/>`;
9263
- }
9264
- for (const img of images) {
9265
- const targetMode = img.kind === "linked" ? ' TargetMode="External"' : "";
9266
- rels += `<Relationship Id="${img.rId}" Type="${OFFICE_REL_NS}/image" Target="${escapeXml(img.target)}"${targetMode}/>`;
9267
- }
9268
- for (const part of parts) {
9269
- const relType = part.kind === "header" ? "header" : "footer";
9270
- rels += `<Relationship Id="${part.relId}" Type="${OFFICE_REL_NS}/${relType}" Target="${part.path}"/>`;
9271
- }
9272
- if (hasFootnotes) {
9273
- rels += `<Relationship Id="rIdFootnotes" Type="${OFFICE_REL_NS}/footnotes" Target="footnotes.xml"/>`;
9274
- }
9275
- if (hasEndnotes) {
9276
- rels += `<Relationship Id="rIdEndnotes" Type="${OFFICE_REL_NS}/endnotes" Target="endnotes.xml"/>`;
9277
- }
9278
- if (hasComments) {
9279
- rels += `<Relationship Id="rIdComments" Type="${OFFICE_REL_NS}/comments" Target="comments.xml"/>`;
9280
- rels += `<Relationship Id="rIdCommentsExtended" Type="http://schemas.microsoft.com/office/2011/relationships/commentsExtended" Target="commentsExtended.xml"/>`;
9281
- }
9282
- return `<?xml version="1.0" encoding="UTF-8" standalone="yes"?><Relationships xmlns="${PACKAGE_REL_NS}">${rels}</Relationships>`;
9283
- }
9284
- function buildSettingsXml(hasEvenAndOddHeaders, defaultTabStop, footnoteSettings, endnoteSettings) {
9285
- const parts = [];
9286
- const defaultTabStopTwips = pointsToTwips(defaultTabStop);
9287
- if (defaultTabStopTwips !== null) {
9288
- parts.push(`<w:defaultTabStop w:val="${defaultTabStopTwips}"/>`);
9289
- }
9290
- const footnotePr = serializeNoteSettings("footnotePr", footnoteSettings);
9291
- if (footnotePr) {
9292
- parts.push(footnotePr);
9293
- }
9294
- const endnotePr = serializeNoteSettings("endnotePr", endnoteSettings);
9295
- if (endnotePr) {
9296
- parts.push(endnotePr);
9297
- }
9298
- if (hasEvenAndOddHeaders) {
9299
- parts.push("<w:evenAndOddHeaders/>");
9300
- }
9301
- return `<?xml version="1.0" encoding="UTF-8" standalone="yes"?><w:settings xmlns:w="${WORD_NS$1}">${parts.join("")}</w:settings>`;
9302
- }
9303
- const NOTE_NUMBER_FORMATS = {
9304
- decimal: "decimal",
9305
- lowerRoman: "lowerRoman",
9306
- upperRoman: "upperRoman",
9307
- lowerLetter: "lowerLetter",
9308
- upperLetter: "upperLetter",
9309
- symbol: "symbol"
9310
- };
9311
- const NOTE_RESTARTS = {
9312
- continuous: "continuous",
9313
- eachSection: "eachSect"
9314
- };
9315
- function serializeNoteSettings(tagName, settings) {
9316
- if (!settings) return null;
9317
- const parts = [];
9318
- if (settings.numberFormat) {
9319
- parts.push(
9320
- `<w:numFmt w:val="${NOTE_NUMBER_FORMATS[settings.numberFormat]}"/>`
9321
- );
9322
- }
9323
- if (settings.startAt !== void 0) {
9324
- parts.push(`<w:numStart w:val="${Math.max(1, settings.startAt)}"/>`);
9325
- }
9326
- if (settings.restart) {
9327
- parts.push(`<w:numRestart w:val="${NOTE_RESTARTS[settings.restart]}"/>`);
9328
- }
9329
- return parts.length > 0 ? `<w:${tagName}>${parts.join("")}</w:${tagName}>` : null;
9330
- }
9331
- function buildPartRelationshipsXml(images, hyperlinks) {
9332
- let rels = "";
9333
- for (const hyperlink of hyperlinks) {
9334
- rels += `<Relationship Id="${hyperlink.rId}" Type="${OFFICE_REL_NS}/hyperlink" Target="${escapeXml(hyperlink.href)}" TargetMode="External"/>`;
9335
- }
9336
- for (const img of images) {
9337
- const targetMode = img.kind === "linked" ? ' TargetMode="External"' : "";
9338
- rels += `<Relationship Id="${img.rId}" Type="${OFFICE_REL_NS}/image" Target="${escapeXml(img.target)}"${targetMode}/>`;
9339
- }
9340
- return `<?xml version="1.0" encoding="UTF-8" standalone="yes"?><Relationships xmlns="${PACKAGE_REL_NS}">${rels}</Relationships>`;
9341
- }
9342
9342
  async function exportEditorDocumentToDocx(document2) {
9343
9343
  var _a, _b, _c, _d, _e, _f;
9344
9344
  document2 = renumberImageCaptionsInDocument(document2);
@@ -0,0 +1,10 @@
1
+ import { EditorBlockNode, EditorParagraphNode } from '../../core/model.js';
2
+
3
+ /**
4
+ * Depth-first paragraph traversal used by the DOCX export to register numbering
5
+ * definitions and image/hyperlink relationships. Recurses into text-box bodies
6
+ * and table cells so nested content participates too. Shared leaf so both the
7
+ * numbering-context and part-context builders can use it.
8
+ */
9
+ export declare function visitParagraphDeep(paragraph: EditorParagraphNode, callback: (paragraph: EditorParagraphNode) => void): void;
10
+ export declare function visitBlocks(blocks: EditorBlockNode[], callback: (paragraph: EditorParagraphNode) => void): void;
@@ -0,0 +1,10 @@
1
+ import { EditorDocument } from '../../core/model.js';
2
+ import { NumberingContext, NumberingDefinition } from './docxTypes.js';
3
+
4
+ /**
5
+ * Walks the document (including headers/footers and nested content) collecting
6
+ * list paragraphs into abstract numbering definitions and a per-paragraph
7
+ * numId/level map. Extracted from exportEditorDocumentToDocx (S2).
8
+ */
9
+ export declare function buildNumberingContext(document: EditorDocument): NumberingContext;
10
+ export declare function buildNumberingXml(definitions: NumberingDefinition[]): string;
@@ -0,0 +1,8 @@
1
+ import { EditorFootnoteSettings } from '../../core/model.js';
2
+ import { DocContext, PartDefinition } from './docxTypes.js';
3
+
4
+ export declare function buildContentTypesXml(hasNumbering: boolean, imageExtensions: Iterable<string>, hasSettings: boolean, parts: PartDefinition[], hasFootnotes: boolean, hasEndnotes: boolean, hasStyles: boolean, hasComments: boolean): string;
5
+ export declare function buildRootRelationshipsXml(): string;
6
+ export declare function buildDocumentRelationshipsXml(hasNumbering: boolean, hasSettings: boolean, images: DocContext["images"], hyperlinks: DocContext["hyperlinks"], parts: PartDefinition[], hasFootnotes: boolean, hasEndnotes: boolean, hasStyles: boolean, hasComments: boolean): string;
7
+ export declare function buildSettingsXml(hasEvenAndOddHeaders: boolean, defaultTabStop?: number, footnoteSettings?: EditorFootnoteSettings, endnoteSettings?: EditorFootnoteSettings): string;
8
+ export declare function buildPartRelationshipsXml(images: DocContext["images"], hyperlinks: DocContext["hyperlinks"]): string;
@@ -2483,7 +2483,7 @@ function OasisEditorAppLazy(props = {}) {
2483
2483
  onCleanup(() => {
2484
2484
  cancelled = true;
2485
2485
  });
2486
- import("./OasisEditorApp-C7bDMr2_.js").then((m) => {
2486
+ import("./OasisEditorApp-2ji5OaBy.js").then((m) => {
2487
2487
  cancelled = true;
2488
2488
  setProgress(1);
2489
2489
  setTimeout(() => setApp(() => m.OasisEditorApp), 180);
@@ -39898,8 +39898,8 @@ export {
39898
39898
  EMU_PER_PT as _,
39899
39899
  getParagraphLength as a,
39900
39900
  resolveCommandRef as a$,
39901
- JSZip as a0,
39902
- imageContentTypeDefaults as a1,
39901
+ imageContentTypeDefaults as a0,
39902
+ JSZip as a1,
39903
39903
  imageExtensionFromMime as a2,
39904
39904
  pxToPt as a3,
39905
39905
  resolveFloatingObjectRect as a4,
@@ -1,4 +1,4 @@
1
- import { b2, bV, bW, bX, bY, bZ, bk, b_, b3, a_, b$, c0, c1, b1, c2, aY, c3, c4, c5, c6, c7, bQ, c8, c9, ca, cb, cc, cd, ce, cf, cg, ch, ci, bp, cj, bP, ck, bX as bX2, c0 as c02, c2 as c22, cb as cb2, cd as cd2, ci as ci2, cl, b0, aX, cm, cn, co, aZ, cp, cq, a$ } from "./index-CXzR3Cux.js";
1
+ import { b2, bV, bW, bX, bY, bZ, bk, b_, b3, a_, b$, c0, c1, b1, c2, aY, c3, c4, c5, c6, c7, bQ, c8, c9, ca, cb, cc, cd, ce, cf, cg, ch, ci, bp, cj, bP, ck, bX as bX2, c0 as c02, c2 as c22, cb as cb2, cd as cd2, ci as ci2, cl, b0, aX, cm, cn, co, aZ, cp, cq, a$ } from "./index-BMJs8egS.js";
2
2
  export {
3
3
  b2 as BalloonShell,
4
4
  bV as Button,