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,
|
|
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 && !
|
|
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
|
|
504
|
+
const isObjectRun = isInlineObjectRun(run);
|
|
523
505
|
const piece = {
|
|
524
506
|
id: `run:${Math.random().toString(36).slice(2, 9)}`,
|
|
525
|
-
text:
|
|
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
|
-
|
|
10595
|
-
|
|
10596
|
-
block.
|
|
10597
|
-
|
|
10598
|
-
|
|
10599
|
-
|
|
10600
|
-
|
|
10601
|
-
|
|
10602
|
-
|
|
10603
|
-
|
|
10604
|
-
|
|
10605
|
-
paragraphStyle
|
|
10606
|
-
|
|
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
|
-
|
|
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
|
-
|
|
10630
|
-
|
|
10631
|
-
|
|
10632
|
-
|
|
10630
|
+
block,
|
|
10631
|
+
document2,
|
|
10632
|
+
originX,
|
|
10633
|
+
cursorY,
|
|
10633
10634
|
contentWidth,
|
|
10634
|
-
|
|
10635
|
-
|
|
10636
|
-
|
|
10637
|
-
|
|
10638
|
-
|
|
10639
|
-
|
|
10640
|
-
|
|
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
|
}
|