oasis-editor 0.0.71 → 0.0.73

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, i as isInlineObjectRun, e as createEditorStyledRun, f as getParagraphText, h as getActiveZone, j as getActiveSectionIndex, p as positionToParagraphOffset, k as paragraphOffsetToPosition, l as clampPosition, m as findParagraphIndex, o as createCollapsedSelection, q as isSelectionCollapsed, E as EMU_PER_PX, r as assertNever, s as createEditorParagraph, t as getBlockParagraphs, u as createEditorFootnote, v as createFootnoteReferenceRun, w as renumberFootnotes, x as iterateFootnoteReferenceRuns, y as getFootnoteDisplayMarker, z as findParagraphTableLocation, A as buildTableCellLayout, B as createSignal, C as createEffect, D as onCleanup, F as buildCanvasLayoutSnapshot, G as on, H as onMount, I as debounce, J as unwrap, K as getDocumentParagraphs, P as PT_PER_PX, L as createEditorTableCell, M as createEditorTableRow, N as createEditorTable, O as getDocumentSectionsCanonical, Q as createEditorDocument, R as getPageContentWidth, S as getDocumentPageSettings, T as getTableCellContentWidthForParagraph, U as resolveResizedDimensions, V as resolveImageSrc, W as resolveTextBoxRenderHeight, X as TWIPS_PER_POINT, Y as PX_PER_INCH, Z as TWIPS_PER_INCH, _ as resolveEffectiveParagraphStyle, $ as resolveEffectiveTextStyleForParagraph, a0 as EMU_PER_PT, a1 as iterateEndnoteReferenceRuns, a2 as imageContentTypeDefaults, a3 as JSZip, a4 as imageExtensionFromMime, a5 as pxToPt$1, a6 as resolveFloatingObjectRect, a7 as getTextBoxFloatingGeometry, a8 as getPresetPathSegments, a9 as projectBlocksLayout, aa as buildListLabels, ab as textStyleToFontSizePt, ac as PX_PER_POINT, ad as DEFAULT_FONT_SIZE_PX, ae as isDoubleUnderlineStyle, af as isWavyUnderlineStyle, ag as underlineStyleLineWidthPx, ah as underlineStyleDashArray, ai as resolveListLabel, aj as getListLabelInset, ak as getAlignedListLabelInset, al as getParagraphBorderInsets, am as buildSegmentTable, an as buildCanvasTableLayout, ao as normalizeFamily, ap as ROBOTO_FONT_FILES, aq as loadFontAsset, ar as OFFICE_COMPAT_FONT_FAMILIES, as as buildSfnt, at as defaultFontDecoderRegistry, au as SfntFontProgram, av as collectPdfFontFamilies, aw as projectDocumentLayout, ax as getPageHeaderZoneTop, ay as getPageBodyTop, az as getPageColumnRects, aA as findFootnoteReference, aB as FOOTNOTE_MARKER_GUTTER_PX, aC as resolveImporterForFile, aD as createEditorStateFromDocument, aE as getDocumentParagraphsCanonical, aF as getToolbarStyleState, aG as STANDARD_FONT_SIZES_PT, aH as fontSizePxToPt, aI as probeLocalFontFamilies, aJ as createInitialEditorState, aK as parseFontSizePtToPx, aL as formatFontSizePt, aM as underlineStyleToCssDecorationStyle, aN as listKindForTag, aO as isParagraphTag, aP as collectInlineRuns, aQ as parseParagraphStyle, aR as getCachedCanvasImage, aS as getHeadingLevel, aT as preciseFontModeVersion, aU as isPreciseFontModeEnabled, aV as togglePreciseFontMode, aW as nextFontSizePt, aX as previousFontSizePt, aY as fontSizePtToPx, aZ as createDefaultToolbarPreset, a_ as MenuRegistry, a$ as createToolbarRegistry, b0 as Editor, b1 as resolveCommandRef, b2 as commandRefName, b3 as InlineShell, b4 as BalloonShell, b5 as DocumentShell, b6 as createMemo, b7 as getCaretRectFromSnapshot, b8 as getParagraphRectFromSnapshot, b9 as createComponent, ba as CaretOverlay, bb as Show, bc as createRenderEffect, bd as style, be as setAttribute, bf as setStyleProperty, bg as memo, bh as template, bi as useI18n, bj as insert, bk as use, bl as addEventListener, bm as Dialog, bn as delegateEvents, bo as className, bp as For, bq as UNDERLINE_STYLE_OPTIONS, br as Tabs, bs as measureParagraphMinContentWidthPx, bt as getEditableBlocksForZone, bu as findParagraphLocation, bv as createSectionBoundaryParagraph, bw as normalizePageSettings, bx as DEFAULT_EDITOR_PAGE_SETTINGS, by as markStart, bz as markEnd, bA as getParagraphEntries, bB as getParagraphById, bC as PluginUiHost, bD as OasisEditorEditor, bE as perfTimer, bF as OasisBrandMark, bG as setPreciseFontPreference, bH as setWelcomeSeen, bI as enablePreciseFontMode, bJ as createOasisEditorClient, bK as createEditorZoom, bL as startLongTaskObserver, bM as installGlobalReport, bN as applyStoredPreciseFontPreference, bO as getWelcomeSeen, bP as isLocalFontAccessSupported, bQ as EDITOR_SCROLL_PADDING_PX, bR as Toolbar, bS as OasisEditorLoading, bT as I18nProvider, bU as createEditorLogger, bV as createTranslator, bW as registerDomStatsSurface } from "./index-BBQr5P8i.js";
4
+ import { n as normalizeSelection, g as getParagraphs, a as assertNever, c as createEditorParagraphFromRuns, b as getParagraphLength, d as createEditorRun, e as getDocumentSections, i as isInlineObjectRun, f as createEditorStyledRun, h as getParagraphText, j as getActiveZone, k as getActiveSectionIndex, p as positionToParagraphOffset, l as paragraphOffsetToPosition, m as clampPosition, o as findParagraphIndex, q as createCollapsedSelection, r as isSelectionCollapsed, E as EMU_PER_PX, s as createEditorParagraph, t as getBlockParagraphs, u as createEditorFootnote, v as createFootnoteReferenceRun, w as renumberFootnotes, x as iterateFootnoteReferenceRuns, y as getFootnoteDisplayMarker, z as findParagraphTableLocation, A as buildTableCellLayout, B as createSignal, C as createEffect, D as onCleanup, F as buildCanvasLayoutSnapshot, G as on, H as onMount, I as debounce, J as unwrap, K as getDocumentParagraphs, P as PT_PER_PX, L as createEditorTableCell, M as createEditorTableRow, N as createEditorTable, O as getDocumentSectionsCanonical, Q as createEditorDocument, R as getPageContentWidth, S as getDocumentPageSettings, T as getTableCellContentWidthForParagraph, U as resolveResizedDimensions, V as resolveImageSrc, W as resolveTextBoxRenderHeight, X as TWIPS_PER_POINT, Y as PX_PER_INCH, Z as TWIPS_PER_INCH, _ as resolveEffectiveParagraphStyle, $ as resolveEffectiveTextStyleForParagraph, a0 as EMU_PER_PT, a1 as iterateEndnoteReferenceRuns, a2 as imageContentTypeDefaults, a3 as JSZip, a4 as imageExtensionFromMime, a5 as pxToPt$1, a6 as resolveFloatingObjectRect, a7 as getTextBoxFloatingGeometry, a8 as getPresetPathSegments, a9 as projectBlocksLayout, aa as buildListLabels, ab as textStyleToFontSizePt, ac as PX_PER_POINT, ad as DEFAULT_FONT_SIZE_PX, ae as isDoubleUnderlineStyle, af as isWavyUnderlineStyle, ag as underlineStyleLineWidthPx, ah as underlineStyleDashArray, ai as resolveListLabel, aj as getListLabelInset, ak as getAlignedListLabelInset, al as getParagraphBorderInsets, am as buildSegmentTable, an as buildCanvasTableLayout, ao as normalizeFamily, ap as ROBOTO_FONT_FILES, aq as loadFontAsset, ar as OFFICE_COMPAT_FONT_FAMILIES, as as buildSfnt, at as defaultFontDecoderRegistry, au as SfntFontProgram, av as collectPdfFontFamilies, aw as projectDocumentLayout, ax as getPageHeaderZoneTop, ay as getPageBodyTop, az as getPageColumnRects, aA as findFootnoteReference, aB as FOOTNOTE_MARKER_GUTTER_PX, aC as resolveImporterForFile, aD as createEditorStateFromDocument, aE as getDocumentParagraphsCanonical, aF as getToolbarStyleState, aG as STANDARD_FONT_SIZES_PT, aH as fontSizePxToPt, aI as probeLocalFontFamilies, aJ as createInitialEditorState, aK as parseFontSizePtToPx, aL as formatFontSizePt, aM as underlineStyleToCssDecorationStyle, aN as listKindForTag, aO as isParagraphTag, aP as collectInlineRuns, aQ as parseParagraphStyle, aR as getCachedCanvasImage, aS as getHeadingLevel, aT as preciseFontModeVersion, aU as isPreciseFontModeEnabled, aV as togglePreciseFontMode, aW as nextFontSizePt, aX as previousFontSizePt, aY as fontSizePtToPx, aZ as createDefaultToolbarPreset, a_ as MenuRegistry, a$ as createToolbarRegistry, b0 as Editor, b1 as resolveCommandRef, b2 as commandRefName, b3 as InlineShell, b4 as BalloonShell, b5 as DocumentShell, b6 as createMemo, b7 as getCaretRectFromSnapshot, b8 as getParagraphRectFromSnapshot, b9 as createComponent, ba as CaretOverlay, bb as Show, bc as createRenderEffect, bd as style, be as setAttribute, bf as setStyleProperty, bg as memo, bh as template, bi as useI18n, bj as insert, bk as use, bl as addEventListener, bm as Dialog, bn as delegateEvents, bo as className, bp as For, bq as UNDERLINE_STYLE_OPTIONS, br as Tabs, bs as measureParagraphMinContentWidthPx, bt as getEditableBlocksForZone, bu as findParagraphLocation, bv as createSectionBoundaryParagraph, bw as normalizePageSettings, bx as DEFAULT_EDITOR_PAGE_SETTINGS, by as markStart, bz as markEnd, bA as getParagraphEntries, bB as getParagraphById, bC as PluginUiHost, bD as OasisEditorEditor, bE as perfTimer, bF as OasisBrandMark, bG as setPreciseFontPreference, bH as setWelcomeSeen, bI as enablePreciseFontMode, bJ as createOasisEditorClient, bK as createEditorZoom, bL as startLongTaskObserver, bM as installGlobalReport, bN as applyStoredPreciseFontPreference, bO as getWelcomeSeen, bP as isLocalFontAccessSupported, bQ as EDITOR_SCROLL_PADDING_PX, bR as Toolbar, bS as OasisEditorLoading, bT as I18nProvider, bU as createEditorLogger, bV as createTranslator, bW as registerDomStatsSurface } from "./index-ByZZP8TQ.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) {
@@ -157,34 +157,38 @@ function cloneParagraphs(paragraphs) {
157
157
  }
158
158
  function cloneBlocks(blocks) {
159
159
  return blocks.map((block) => {
160
- if (block.type === "paragraph") {
161
- return cloneParagraph(block);
162
- }
163
- return {
164
- ...block,
165
- style: block.style ? {
166
- ...block.style,
167
- defaultCellMargins: block.style.defaultCellMargins ? { ...block.style.defaultCellMargins } : void 0,
168
- floating: block.style.floating ? { ...block.style.floating } : void 0,
169
- revisionXml: block.style.revisionXml ? [...block.style.revisionXml] : void 0
170
- } : void 0,
171
- tblGridChangeXml: block.tblGridChangeXml,
172
- rows: block.rows.map((row) => ({
173
- ...row,
174
- style: row.style ? {
175
- ...row.style,
176
- revisionXml: row.style.revisionXml ? [...row.style.revisionXml] : void 0
177
- } : void 0,
178
- cells: row.cells.map((cell) => ({
179
- ...cell,
180
- style: cell.style ? {
181
- ...cell.style,
182
- revisionXml: cell.style.revisionXml ? [...cell.style.revisionXml] : void 0
160
+ switch (block.type) {
161
+ case "paragraph":
162
+ return cloneParagraph(block);
163
+ case "table":
164
+ return {
165
+ ...block,
166
+ style: block.style ? {
167
+ ...block.style,
168
+ defaultCellMargins: block.style.defaultCellMargins ? { ...block.style.defaultCellMargins } : void 0,
169
+ floating: block.style.floating ? { ...block.style.floating } : void 0,
170
+ revisionXml: block.style.revisionXml ? [...block.style.revisionXml] : void 0
183
171
  } : void 0,
184
- blocks: cloneParagraphs(cell.blocks)
185
- }))
186
- }))
187
- };
172
+ tblGridChangeXml: block.tblGridChangeXml,
173
+ rows: block.rows.map((row) => ({
174
+ ...row,
175
+ style: row.style ? {
176
+ ...row.style,
177
+ revisionXml: row.style.revisionXml ? [...row.style.revisionXml] : void 0
178
+ } : void 0,
179
+ cells: row.cells.map((cell) => ({
180
+ ...cell,
181
+ style: cell.style ? {
182
+ ...cell.style,
183
+ revisionXml: cell.style.revisionXml ? [...cell.style.revisionXml] : void 0
184
+ } : void 0,
185
+ blocks: cloneParagraphs(cell.blocks)
186
+ }))
187
+ }))
188
+ };
189
+ default:
190
+ return assertNever(block, "block");
191
+ }
188
192
  });
189
193
  }
190
194
  const IMAGE_CAPTION_STYLE_ID = "Caption";
@@ -306,25 +310,26 @@ function renumberImageCaptionParagraphs(paragraphs) {
306
310
  }
307
311
  function renumberBlocks(blocks, sequence) {
308
312
  return blocks.map((block) => {
309
- if (block.type === "paragraph") {
310
- if (!isImageCaptionParagraph(block)) {
311
- return cloneParagraph(block);
312
- }
313
- return renumberCaptionParagraph(block, sequence.next++);
313
+ switch (block.type) {
314
+ case "paragraph":
315
+ return isImageCaptionParagraph(block) ? renumberCaptionParagraph(block, sequence.next++) : cloneParagraph(block);
316
+ case "table":
317
+ return {
318
+ ...block,
319
+ rows: block.rows.map((row) => ({
320
+ ...row,
321
+ cells: row.cells.map((cell) => ({
322
+ ...cell,
323
+ blocks: renumberBlocks(
324
+ cell.blocks,
325
+ sequence
326
+ )
327
+ }))
328
+ }))
329
+ };
330
+ default:
331
+ return assertNever(block, "block");
314
332
  }
315
- return {
316
- ...block,
317
- rows: block.rows.map((row) => ({
318
- ...row,
319
- cells: row.cells.map((cell) => ({
320
- ...cell,
321
- blocks: renumberBlocks(
322
- cell.blocks,
323
- sequence
324
- )
325
- }))
326
- }))
327
- };
328
333
  });
329
334
  }
330
335
  function renumberImageCaptionsInDocument(document2) {
@@ -9671,32 +9676,39 @@ async function drawTextBoxContent(writer, textBox, ctx, xPx, yPx, widthPx, heigh
9671
9676
  );
9672
9677
  let cursorY = innerY;
9673
9678
  for (const block of blocks) {
9674
- if (block.sourceBlock.type === "paragraph" && block.layout) {
9675
- await drawers.drawParagraph(
9676
- writer,
9677
- ctx.pageIndex,
9678
- block.sourceBlock,
9679
- block.layout.lines,
9680
- ctx.document,
9681
- innerX,
9682
- cursorY,
9683
- ctx.fontRegistry,
9684
- listOrdinals,
9685
- drawers
9686
- );
9687
- } else if (block.sourceBlock.type === "table") {
9688
- await drawers.drawTableBlock(
9689
- writer,
9690
- ctx.pageIndex,
9691
- block,
9692
- ctx.document,
9693
- innerX,
9694
- cursorY,
9695
- innerWidth,
9696
- ctx.fontRegistry,
9697
- listOrdinals,
9698
- drawers
9699
- );
9679
+ switch (block.sourceBlock.type) {
9680
+ case "paragraph":
9681
+ if (block.layout) {
9682
+ await drawers.drawParagraph(
9683
+ writer,
9684
+ ctx.pageIndex,
9685
+ block.sourceBlock,
9686
+ block.layout.lines,
9687
+ ctx.document,
9688
+ innerX,
9689
+ cursorY,
9690
+ ctx.fontRegistry,
9691
+ listOrdinals,
9692
+ drawers
9693
+ );
9694
+ }
9695
+ break;
9696
+ case "table":
9697
+ await drawers.drawTableBlock(
9698
+ writer,
9699
+ ctx.pageIndex,
9700
+ block,
9701
+ ctx.document,
9702
+ innerX,
9703
+ cursorY,
9704
+ innerWidth,
9705
+ ctx.fontRegistry,
9706
+ listOrdinals,
9707
+ drawers
9708
+ );
9709
+ break;
9710
+ default:
9711
+ assertNever(block.sourceBlock, "block");
9700
9712
  }
9701
9713
  cursorY += Math.max(0, block.estimatedHeight);
9702
9714
  }