oasis-editor 0.0.66 → 0.0.68

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,22 @@
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 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-3oO2RdNy.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 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
+ }
5
20
  function getSelectedObjectRun(state, predicate) {
6
21
  const normalized = normalizeSelection(state);
7
22
  if (normalized.isCollapsed || normalized.startIndex !== normalized.endIndex || normalized.endParagraphOffset - normalized.startParagraphOffset !== 1) {
@@ -504,7 +519,7 @@ function sliceRuns(paragraph, startOffset, endOffset) {
504
519
  const overlapStart = Math.max(start, runStart);
505
520
  const overlapEnd = Math.min(end, runEnd);
506
521
  if (overlapStart < overlapEnd) {
507
- const isObjectRun2 = Boolean(run.image || run.textBox);
522
+ const isObjectRun2 = isInlineObjectRun(run);
508
523
  const piece = {
509
524
  id: `run:${Math.random().toString(36).slice(2, 9)}`,
510
525
  text: isObjectRun2 ? "" : run.text.slice(overlapStart - runStart, overlapEnd - runStart)
@@ -1441,60 +1456,67 @@ function resizeSelectedTextBox(state, width, height, options = {}) {
1441
1456
  );
1442
1457
  }
1443
1458
  function cloneBlock(block) {
1444
- return block.type === "paragraph" ? {
1445
- ...block,
1446
- runs: block.runs.map((run) => ({
1447
- ...run,
1448
- styles: run.styles ? { ...run.styles } : void 0,
1449
- image: run.image ? { ...run.image } : void 0,
1450
- field: run.field ? { ...run.field } : void 0,
1451
- revision: run.revision ? { ...run.revision } : void 0,
1452
- footnoteReference: run.footnoteReference ? { ...run.footnoteReference } : void 0,
1453
- endnoteReference: run.endnoteReference ? { ...run.endnoteReference } : void 0
1454
- })),
1455
- style: block.style ? { ...block.style } : void 0,
1456
- list: block.list ? { ...block.list } : void 0
1457
- } : {
1458
- ...block,
1459
- style: block.style ? {
1460
- ...block.style,
1461
- defaultCellMargins: block.style.defaultCellMargins ? { ...block.style.defaultCellMargins } : void 0,
1462
- floating: block.style.floating ? { ...block.style.floating } : void 0,
1463
- revisionXml: block.style.revisionXml ? [...block.style.revisionXml] : void 0
1464
- } : void 0,
1465
- tblGridChangeXml: block.tblGridChangeXml,
1466
- rows: block.rows.map((row) => ({
1467
- ...row,
1468
- style: row.style ? {
1469
- ...row.style,
1470
- revisionXml: row.style.revisionXml ? [...row.style.revisionXml] : void 0
1471
- } : void 0,
1472
- cells: row.cells.map((cell) => ({
1473
- ...cell,
1474
- colSpan: cell.colSpan ?? void 0,
1475
- rowSpan: cell.rowSpan ?? void 0,
1476
- vMerge: cell.vMerge ?? void 0,
1477
- style: cell.style ? {
1478
- ...cell.style,
1479
- revisionXml: cell.style.revisionXml ? [...cell.style.revisionXml] : void 0
1459
+ switch (block.type) {
1460
+ case "paragraph":
1461
+ return {
1462
+ ...block,
1463
+ runs: block.runs.map((run) => ({
1464
+ ...run,
1465
+ styles: run.styles ? { ...run.styles } : void 0,
1466
+ image: run.image ? { ...run.image } : void 0,
1467
+ field: run.field ? { ...run.field } : void 0,
1468
+ revision: run.revision ? { ...run.revision } : void 0,
1469
+ footnoteReference: run.footnoteReference ? { ...run.footnoteReference } : void 0,
1470
+ endnoteReference: run.endnoteReference ? { ...run.endnoteReference } : void 0
1471
+ })),
1472
+ style: block.style ? { ...block.style } : void 0,
1473
+ list: block.list ? { ...block.list } : void 0
1474
+ };
1475
+ case "table":
1476
+ return {
1477
+ ...block,
1478
+ style: block.style ? {
1479
+ ...block.style,
1480
+ defaultCellMargins: block.style.defaultCellMargins ? { ...block.style.defaultCellMargins } : void 0,
1481
+ floating: block.style.floating ? { ...block.style.floating } : void 0,
1482
+ revisionXml: block.style.revisionXml ? [...block.style.revisionXml] : void 0
1480
1483
  } : void 0,
1481
- blocks: cell.blocks.map((paragraph) => ({
1482
- ...paragraph,
1483
- runs: paragraph.runs.map((run) => ({
1484
- ...run,
1485
- styles: run.styles ? { ...run.styles } : void 0,
1486
- image: run.image ? { ...run.image } : void 0,
1487
- field: run.field ? { ...run.field } : void 0,
1488
- revision: run.revision ? { ...run.revision } : void 0,
1489
- footnoteReference: run.footnoteReference ? { ...run.footnoteReference } : void 0,
1490
- endnoteReference: run.endnoteReference ? { ...run.endnoteReference } : void 0
1491
- })),
1492
- style: paragraph.style ? { ...paragraph.style } : void 0,
1493
- list: paragraph.list ? { ...paragraph.list } : void 0
1484
+ tblGridChangeXml: block.tblGridChangeXml,
1485
+ rows: block.rows.map((row) => ({
1486
+ ...row,
1487
+ style: row.style ? {
1488
+ ...row.style,
1489
+ revisionXml: row.style.revisionXml ? [...row.style.revisionXml] : void 0
1490
+ } : void 0,
1491
+ cells: row.cells.map((cell) => ({
1492
+ ...cell,
1493
+ colSpan: cell.colSpan ?? void 0,
1494
+ rowSpan: cell.rowSpan ?? void 0,
1495
+ vMerge: cell.vMerge ?? void 0,
1496
+ style: cell.style ? {
1497
+ ...cell.style,
1498
+ revisionXml: cell.style.revisionXml ? [...cell.style.revisionXml] : void 0
1499
+ } : void 0,
1500
+ blocks: cell.blocks.map((paragraph) => ({
1501
+ ...paragraph,
1502
+ runs: paragraph.runs.map((run) => ({
1503
+ ...run,
1504
+ styles: run.styles ? { ...run.styles } : void 0,
1505
+ image: run.image ? { ...run.image } : void 0,
1506
+ field: run.field ? { ...run.field } : void 0,
1507
+ revision: run.revision ? { ...run.revision } : void 0,
1508
+ footnoteReference: run.footnoteReference ? { ...run.footnoteReference } : void 0,
1509
+ endnoteReference: run.endnoteReference ? { ...run.endnoteReference } : void 0
1510
+ })),
1511
+ style: paragraph.style ? { ...paragraph.style } : void 0,
1512
+ list: paragraph.list ? { ...paragraph.list } : void 0
1513
+ }))
1514
+ }))
1494
1515
  }))
1495
- }))
1496
- }))
1497
- };
1516
+ };
1517
+ default:
1518
+ return assertNever(block, "block");
1519
+ }
1498
1520
  }
1499
1521
  function cloneSection(section) {
1500
1522
  var _a, _b, _c, _d, _e, _f;
@@ -8632,19 +8654,24 @@ function serializeRunsWithBoundaries(runs, tokens, context, paragraphStyleId, st
8632
8654
  function serializeBlocksXml(blocks, context, styles) {
8633
8655
  return blocks.map((block) => {
8634
8656
  var _a;
8635
- if (block.type === "table") {
8636
- const pageBreakXml = ((_a = block.style) == null ? void 0 : _a.pageBreakBefore) ? '<w:p><w:r><w:br w:type="page"/></w:r></w:p>' : "";
8637
- return pageBreakXml + serializeTableXml(
8638
- block,
8639
- (paragraph, cell) => {
8640
- var _a2;
8641
- return serializeParagraphXml(paragraph, context, styles, {
8642
- align: (_a2 = cell.style) == null ? void 0 : _a2.horizontalAlign
8643
- });
8644
- }
8645
- );
8657
+ switch (block.type) {
8658
+ case "paragraph":
8659
+ return serializeParagraphXml(block, context, styles);
8660
+ case "table": {
8661
+ const pageBreakXml = ((_a = block.style) == null ? void 0 : _a.pageBreakBefore) ? '<w:p><w:r><w:br w:type="page"/></w:r></w:p>' : "";
8662
+ return pageBreakXml + serializeTableXml(
8663
+ block,
8664
+ (paragraph, cell) => {
8665
+ var _a2;
8666
+ return serializeParagraphXml(paragraph, context, styles, {
8667
+ align: (_a2 = cell.style) == null ? void 0 : _a2.horizontalAlign
8668
+ });
8669
+ }
8670
+ );
8671
+ }
8672
+ default:
8673
+ return assertNever(block, "block");
8646
8674
  }
8647
- return serializeParagraphXml(block, context, styles);
8648
8675
  }).join("");
8649
8676
  }
8650
8677
  function serializeParagraphXml(paragraph, context, styles, overrides) {
@@ -9101,16 +9128,21 @@ function visitParagraphDeep(paragraph, callback) {
9101
9128
  }
9102
9129
  function visitBlocks(blocks, callback) {
9103
9130
  for (const block of blocks) {
9104
- if (block.type === "paragraph") {
9105
- visitParagraphDeep(block, callback);
9106
- continue;
9107
- }
9108
- for (const row of block.rows) {
9109
- for (const cell of row.cells) {
9110
- for (const paragraph of cell.blocks) {
9111
- visitParagraphDeep(paragraph, callback);
9131
+ switch (block.type) {
9132
+ case "paragraph":
9133
+ visitParagraphDeep(block, callback);
9134
+ break;
9135
+ case "table":
9136
+ for (const row of block.rows) {
9137
+ for (const cell of row.cells) {
9138
+ for (const paragraph of cell.blocks) {
9139
+ visitParagraphDeep(paragraph, callback);
9140
+ }
9141
+ }
9112
9142
  }
9113
- }
9143
+ break;
9144
+ default:
9145
+ assertNever(block, "block");
9114
9146
  }
9115
9147
  }
9116
9148
  }