oasis-editor 0.0.68 → 0.0.70

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,22 +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 assertNever, r as createEditorParagraph, s as getBlockParagraphs, t as createEditorFootnote, u as createFootnoteReferenceRun, v as renumberFootnotes, w as iterateFootnoteReferenceRuns, x as getFootnoteDisplayMarker, y as findParagraphTableLocation, z as buildTableCellLayout, A as createSignal, B as createEffect, C as onCleanup, D as buildCanvasLayoutSnapshot, F as on, G as onMount, H as debounce, I as unwrap, J as getDocumentParagraphs, P as PT_PER_PX, K as createEditorTableCell, L as createEditorTableRow, M as createEditorTable, N as getDocumentSectionsCanonical, O as createEditorDocument, Q as getPageContentWidth, R as getDocumentPageSettings, S as getTableCellContentWidthForParagraph, T as resolveResizedDimensions, U as resolveImageSrc, V as resolveTextBoxRenderHeight, W as TWIPS_PER_POINT, X as PX_PER_INCH, Y as TWIPS_PER_INCH, Z as resolveEffectiveParagraphStyle, _ as resolveEffectiveTextStyleForParagraph, $ as EMU_PER_PT, a0 as iterateEndnoteReferenceRuns, a1 as imageContentTypeDefaults, a2 as JSZip, a3 as imageExtensionFromMime, a4 as pxToPt$1, a5 as resolveFloatingObjectRect, a6 as getTextBoxFloatingGeometry, a7 as getPresetPathSegments, a8 as projectBlocksLayout, a9 as buildListLabels, aa as textStyleToFontSizePt, ab as PX_PER_POINT, ac as DEFAULT_FONT_SIZE_PX, ad as isDoubleUnderlineStyle, ae as isWavyUnderlineStyle, af as underlineStyleLineWidthPx, ag as underlineStyleDashArray, ah as resolveListLabel, ai as getListLabelInset, aj as getAlignedListLabelInset, ak as getParagraphBorderInsets, al as buildSegmentTable, am as buildCanvasTableLayout, an as normalizeFamily, ao as ROBOTO_FONT_FILES, ap as loadFontAsset, aq as OFFICE_COMPAT_FONT_FAMILIES, ar as buildSfnt, as as defaultFontDecoderRegistry, at as SfntFontProgram, au as collectPdfFontFamilies, av as projectDocumentLayout, aw as getPageHeaderZoneTop, ax as getPageBodyTop, ay as getPageColumnRects, az as findFootnoteReference, aA as FOOTNOTE_MARKER_GUTTER_PX, aB as resolveImporterForFile, aC as createEditorStateFromDocument, aD as getDocumentParagraphsCanonical, aE as getToolbarStyleState, aF as STANDARD_FONT_SIZES_PT, aG as fontSizePxToPt, aH as probeLocalFontFamilies, aI as createInitialEditorState, aJ as parseFontSizePtToPx, aK as formatFontSizePt, aL as underlineStyleToCssDecorationStyle, aM as listKindForTag, aN as isParagraphTag, aO as collectInlineRuns, aP as parseParagraphStyle, aQ as getCachedCanvasImage, aR as getHeadingLevel, aS as preciseFontModeVersion, aT as isPreciseFontModeEnabled, aU as togglePreciseFontMode, aV as nextFontSizePt, aW as previousFontSizePt, aX as fontSizePtToPx, aY as createDefaultToolbarPreset, aZ as MenuRegistry, a_ as createToolbarRegistry, a$ as Editor, b0 as resolveCommandRef, b1 as commandRefName, b2 as InlineShell, b3 as BalloonShell, b4 as DocumentShell, b5 as createMemo, b6 as getCaretRectFromSnapshot, b7 as getParagraphRectFromSnapshot, b8 as createComponent, b9 as CaretOverlay, ba as Show, bb as createRenderEffect, bc as style, bd as setAttribute, be as setStyleProperty, bf as memo, bg as template, bh as useI18n, bi as insert, bj as use, bk as addEventListener, bl as Dialog, bm as delegateEvents, bn as className, bo as For, bp as UNDERLINE_STYLE_OPTIONS, bq as Tabs, br as measureParagraphMinContentWidthPx, bs as getEditableBlocksForZone, bt as findParagraphLocation, bu as createSectionBoundaryParagraph, bv as normalizePageSettings, bw as DEFAULT_EDITOR_PAGE_SETTINGS, bx as markStart, by as markEnd, bz as getParagraphEntries, bA as getParagraphById, bB as PluginUiHost, bC as OasisEditorEditor, bD as perfTimer, bE as OasisBrandMark, bF as setPreciseFontPreference, bG as setWelcomeSeen, bH as enablePreciseFontMode, bI as createOasisEditorClient, bJ as createEditorZoom, bK as startLongTaskObserver, bL as installGlobalReport, bM as applyStoredPreciseFontPreference, bN as getWelcomeSeen, bO as isLocalFontAccessSupported, bP as EDITOR_SCROLL_PADDING_PX, bQ as Toolbar, bR as OasisEditorLoading, bS as I18nProvider, bT as createEditorLogger, bU as createTranslator, bV as registerDomStatsSurface } from "./index-IphSPayO.js";
5
- function getRunKind(run) {
6
- if (run.footnoteReference) return "footnoteReference";
7
- if (run.endnoteReference) return "endnoteReference";
8
- if (run.fieldChar) return "fieldChar";
9
- if (run.fieldInstruction !== void 0) return "fieldInstruction";
10
- if (run.field) return "field";
11
- if (run.textBox) return "textBox";
12
- if (run.image) return "image";
13
- if (run.sym) return "sym";
14
- return "text";
15
- }
16
- function isInlineObjectRun(run) {
17
- const kind = getRunKind(run);
18
- return kind === "image" || kind === "textBox";
19
- }
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";
20
5
  function getSelectedObjectRun(state, predicate) {
21
6
  const normalized = normalizeSelection(state);
22
7
  if (normalized.isCollapsed || normalized.startIndex !== normalized.endIndex || normalized.endParagraphOffset - normalized.startParagraphOffset !== 1) {
@@ -360,9 +345,6 @@ function renumberImageCaptionsInDocument(document2) {
360
345
  function getCaptionSelectionOffset(paragraph) {
361
346
  return getParagraphLength(paragraph);
362
347
  }
363
- function isObjectRun(run) {
364
- return Boolean(run.image || run.textBox);
365
- }
366
348
  function normalizeRuns(runs, fallbackStyles) {
367
349
  const merged = [];
368
350
  for (const run of runs) {
@@ -370,7 +352,7 @@ function normalizeRuns(runs, fallbackStyles) {
370
352
  continue;
371
353
  }
372
354
  const previous = merged[merged.length - 1];
373
- if (previous && !isObjectRun(run) && !isObjectRun(previous) && stylesEqual(previous.styles, run.styles)) {
355
+ if (previous && !isInlineObjectRun(run) && !isInlineObjectRun(previous) && stylesEqual(previous.styles, run.styles)) {
374
356
  previous.text += run.text;
375
357
  continue;
376
358
  }
@@ -519,10 +501,10 @@ function sliceRuns(paragraph, startOffset, endOffset) {
519
501
  const overlapStart = Math.max(start, runStart);
520
502
  const overlapEnd = Math.min(end, runEnd);
521
503
  if (overlapStart < overlapEnd) {
522
- const isObjectRun2 = isInlineObjectRun(run);
504
+ const isObjectRun = isInlineObjectRun(run);
523
505
  const piece = {
524
506
  id: `run:${Math.random().toString(36).slice(2, 9)}`,
525
- text: isObjectRun2 ? "" : run.text.slice(overlapStart - runStart, overlapEnd - runStart)
507
+ text: isObjectRun ? "" : run.text.slice(overlapStart - runStart, overlapEnd - runStart)
526
508
  };
527
509
  if (run.styles) {
528
510
  piece.styles = { ...run.styles };
@@ -10591,63 +10573,72 @@ async function drawBlockList(writer, pageIndex, blocks, document2, originX, orig
10591
10573
  const contentTop = originY;
10592
10574
  let cursorY = originY;
10593
10575
  for (const block of blocks) {
10594
- if (block.sourceBlock.type === "paragraph" && block.layout) {
10595
- const paragraphStyle = resolveEffectiveParagraphStyle(
10596
- block.sourceBlock.style,
10597
- document2.styles
10598
- );
10599
- const spacingBefore = block.layout.startOffset === 0 && cursorY > originY ? paragraphStyle.spacingBefore ?? 0 : 0;
10600
- const boxTop = cursorY + spacingBefore;
10601
- const textTop = boxTop + getParagraphBorderInsets(paragraphStyle).top;
10602
- drawParagraphDecorations(
10603
- writer,
10604
- pageIndex,
10605
- paragraphStyle,
10606
- block.layout.lines,
10607
- originX,
10608
- boxTop,
10609
- contentWidth
10610
- );
10611
- await drawParagraph(
10612
- writer,
10613
- pageIndex,
10614
- block.sourceBlock,
10615
- block.layout.lines,
10616
- document2,
10617
- originX,
10618
- textTop,
10619
- fontRegistry,
10620
- listOrdinals,
10621
- blockDrawers
10622
- );
10623
- if (pageSettings) {
10624
- await drawFloatingTextBoxesForParagraph({
10576
+ switch (block.sourceBlock.type) {
10577
+ case "paragraph": {
10578
+ if (!block.layout) {
10579
+ break;
10580
+ }
10581
+ const paragraphStyle = resolveEffectiveParagraphStyle(
10582
+ block.sourceBlock.style,
10583
+ document2.styles
10584
+ );
10585
+ const spacingBefore = block.layout.startOffset === 0 && cursorY > originY ? paragraphStyle.spacingBefore ?? 0 : 0;
10586
+ const boxTop = cursorY + spacingBefore;
10587
+ const textTop = boxTop + getParagraphBorderInsets(paragraphStyle).top;
10588
+ drawParagraphDecorations(
10625
10589
  writer,
10626
- document: document2,
10590
+ pageIndex,
10591
+ paragraphStyle,
10592
+ block.layout.lines,
10593
+ originX,
10594
+ boxTop,
10595
+ contentWidth
10596
+ );
10597
+ await drawParagraph(
10598
+ writer,
10599
+ pageIndex,
10600
+ block.sourceBlock,
10601
+ block.layout.lines,
10602
+ document2,
10603
+ originX,
10604
+ textTop,
10627
10605
  fontRegistry,
10606
+ listOrdinals,
10607
+ blockDrawers
10608
+ );
10609
+ if (pageSettings) {
10610
+ await drawFloatingTextBoxesForParagraph({
10611
+ writer,
10612
+ document: document2,
10613
+ fontRegistry,
10614
+ pageIndex,
10615
+ lines: block.layout.lines,
10616
+ pageSettings,
10617
+ contentLeft: originX,
10618
+ contentTop,
10619
+ contentWidth,
10620
+ paragraphTop: boxTop,
10621
+ drawers: blockDrawers
10622
+ });
10623
+ }
10624
+ break;
10625
+ }
10626
+ case "table":
10627
+ await drawTableBlock(
10628
+ writer,
10628
10629
  pageIndex,
10629
- lines: block.layout.lines,
10630
- pageSettings,
10631
- contentLeft: originX,
10632
- contentTop,
10630
+ block,
10631
+ document2,
10632
+ originX,
10633
+ cursorY,
10633
10634
  contentWidth,
10634
- paragraphTop: boxTop,
10635
- drawers: blockDrawers
10636
- });
10637
- }
10638
- } else if (block.sourceBlock.type === "table") {
10639
- await drawTableBlock(
10640
- writer,
10641
- pageIndex,
10642
- block,
10643
- document2,
10644
- originX,
10645
- cursorY,
10646
- contentWidth,
10647
- fontRegistry,
10648
- listOrdinals,
10649
- blockDrawers
10650
- );
10635
+ fontRegistry,
10636
+ listOrdinals,
10637
+ blockDrawers
10638
+ );
10639
+ break;
10640
+ default:
10641
+ assertNever(block.sourceBlock, "block");
10651
10642
  }
10652
10643
  cursorY += Math.max(0, block.estimatedHeight);
10653
10644
  }