oasis-editor 0.0.30 → 0.0.31
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.
- package/dist/{OasisEditorApp-Bvkbr1KZ.js → OasisEditorApp-CeDQ_a8-.js} +54 -132
- package/dist/assets/{importDocxWorker-DVvaVtgj.js → importDocxWorker-C8ErVbAl.js} +1 -1
- package/dist/core/model/index.d.ts +1 -0
- package/dist/core/model/listNumbering.d.ts +5 -0
- package/dist/core/model/types/primitives.d.ts +10 -0
- package/dist/export/docx/docxTypes.d.ts +10 -3
- package/dist/export/pdf/draw/drawBlockList.d.ts +1 -1
- package/dist/export/pdf/draw/drawParagraph.d.ts +1 -1
- package/dist/export/pdf/draw/drawTable.d.ts +1 -1
- package/dist/export/pdf/draw/lists.d.ts +2 -2
- package/dist/import/docx/numbering.d.ts +19 -28
- package/dist/{index-BVAzjJsg.js → index-BYqaCJUC.js} +449 -414
- package/dist/oasis-editor.js +54 -54
- package/dist/oasis-editor.umd.cjs +4 -4
- package/dist/ui/canvas/listNumbering.d.ts +2 -1
- package/dist/ui/textMeasurement/indentation.d.ts +2 -0
- package/package.json +1 -1
|
@@ -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, q as createEditorParagraph, r as getBlockParagraphs, s as findParagraphTableLocation, t as buildTableCellLayout, u as createEditorTableCell, v as createEditorTable, w as createEditorTableRow, x as underlineStyleToCssDecorationStyle, y as resolveImageSrc, z as createEditorFootnote, A as createFootnoteReferenceRun, B as renumberFootnotes, C as iterateFootnoteReferenceRuns, D as getFootnoteDisplayMarker, E as createSignal, F as createEffect, G as onCleanup, H as buildCanvasLayoutSnapshot, I as on, J as onMount, K as debounce, L as unwrap, M as getDocumentParagraphs, N as getDocumentSectionsCanonical, O as createEditorDocument, P as getPageContentWidth, Q as getDocumentPageSettings, R as getTableCellContentWidthForParagraph, S as resolveResizedDimensions, T as resolveTextBoxRenderHeight, U as resolveEffectiveParagraphStyle, V as resolveEffectiveTextStyleForParagraph, W as iterateEndnoteReferenceRuns, X as JSZip, Y as imageContentTypeDefaults, Z as imageExtensionFromMime, _ as pxToPt$1, $ as buildSegmentTable, a0 as buildCanvasTableLayout, a1 as resolveFloatingObjectRect, a2 as getTextBoxFloatingGeometry, a3 as getPresetPathSegments, a4 as projectBlocksLayout, a5 as
|
|
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, q as createEditorParagraph, r as getBlockParagraphs, s as findParagraphTableLocation, t as buildTableCellLayout, u as createEditorTableCell, v as createEditorTable, w as createEditorTableRow, x as underlineStyleToCssDecorationStyle, y as resolveImageSrc, z as createEditorFootnote, A as createFootnoteReferenceRun, B as renumberFootnotes, C as iterateFootnoteReferenceRuns, D as getFootnoteDisplayMarker, E as createSignal, F as createEffect, G as onCleanup, H as buildCanvasLayoutSnapshot, I as on, J as onMount, K as debounce, L as unwrap, M as getDocumentParagraphs, N as getDocumentSectionsCanonical, O as createEditorDocument, P as getPageContentWidth, Q as getDocumentPageSettings, R as getTableCellContentWidthForParagraph, S as resolveResizedDimensions, T as resolveTextBoxRenderHeight, U as resolveEffectiveParagraphStyle, V as resolveEffectiveTextStyleForParagraph, W as iterateEndnoteReferenceRuns, X as JSZip, Y as imageContentTypeDefaults, Z as imageExtensionFromMime, _ as pxToPt$1, $ as buildSegmentTable, a0 as buildCanvasTableLayout, a1 as resolveFloatingObjectRect, a2 as getTextBoxFloatingGeometry, a3 as getPresetPathSegments, a4 as projectBlocksLayout, a5 as buildListLabels, a6 as textStyleToFontSizePt, a7 as PX_PER_POINT, a8 as DEFAULT_FONT_SIZE_PX, a9 as isDoubleUnderlineStyle, aa as isWavyUnderlineStyle, ab as underlineStyleLineWidthPx, ac as underlineStyleDashArray, ad as resolveListLabel, ae as getListLabelInset, af as getAlignedListLabelInset, ag as getParagraphBorderInsets, ah as normalizeFamily, ai as ROBOTO_FONT_FILES, aj as loadFontAsset, ak as OFFICE_COMPAT_FONT_FAMILIES, al as buildSfnt, am as defaultFontDecoderRegistry, an as SfntFontProgram, ao as collectPdfFontFamilies, ap as projectDocumentLayout, aq as getPageHeaderZoneTop, ar as getPageBodyTop, as as getPageColumnRects, at as findFootnoteReference, au as FOOTNOTE_MARKER_GUTTER_PX, av as resolveImporterForFile, aw as createEditorStateFromDocument, ax as getDocumentParagraphsCanonical, ay as getToolbarStyleState, az as STANDARD_FONT_SIZES_PT, aA as fontSizePxToPt, aB as probeLocalFontFamilies, aC as createInitialEditorState, aD as parseFontSizePtToPx, aE as formatFontSizePt, aF as listKindForTag, aG as isParagraphTag, aH as collectInlineRuns, aI as parseParagraphStyle, aJ as t, aK as getHeadingLevel, aL as preciseFontModeVersion, aM as isPreciseFontModeEnabled, aN as togglePreciseFontMode, aO as nextFontSizePt, aP as previousFontSizePt, aQ as fontSizePtToPx, aR as createDefaultToolbarPreset, aS as defaultMenuItems, aT as MenuRegistry, aU as createToolbarRegistry, aV as Editor, aW as resolveCommandRef, aX as commandRefName, aY as InlineShell, aZ as BalloonShell, a_ as DocumentShell, a$ as createMemo, b0 as getCaretRectFromSnapshot, b1 as getParagraphRectFromSnapshot, b2 as createComponent, b3 as CaretOverlay, b4 as Show, b5 as createRenderEffect, b6 as style, b7 as setAttribute, b8 as setStyleProperty, b9 as memo, ba as template, bb as insert, bc as use, bd as addEventListener, be as Dialog, bf as delegateEvents, bg as className, bh as For, bi as UNDERLINE_STYLE_OPTIONS, bj as Tabs, bk as measureParagraphMinContentWidthPx, bl as getEditableBlocksForZone, bm as findParagraphLocation, bn as createSectionBoundaryParagraph, bo as normalizePageSettings, bp as DEFAULT_EDITOR_PAGE_SETTINGS, bq as markStart, br as markEnd, bs as getParagraphEntries, bt as getParagraphById, bu as PluginUiHost, bv as OasisEditorEditor, bw as perfTimer, bx as OasisBrandMark, by as setPreciseFontPreference, bz as setWelcomeSeen, bA as enablePreciseFontMode, bB as createOasisEditorClient, bC as setLocale, bD as createEditorZoom, bE as startLongTaskObserver, bF as installGlobalReport, bG as applyStoredPreciseFontPreference, bH as getWelcomeSeen, bI as isLocalFontAccessSupported, bJ as EDITOR_SCROLL_PADDING_PX, bK as Toolbar, bL as OasisEditorLoading, bM as createEditorLogger, bN as getCachedCanvasImage, bO as registerDomStatsSurface } from "./index-BYqaCJUC.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) {
|
|
@@ -9612,18 +9612,27 @@ function buildNumberingContext(document2) {
|
|
|
9612
9612
|
}
|
|
9613
9613
|
const level = Math.max(0, paragraph.list.level ?? 0);
|
|
9614
9614
|
const bulletGlyph = paragraph.list.bulletGlyph ?? "";
|
|
9615
|
-
const key =
|
|
9615
|
+
const key = paragraph.list.instanceId ? `instance:${paragraph.list.instanceId}` : `legacy:${paragraph.list.kind}:${level}:${bulletGlyph}`;
|
|
9616
9616
|
let definition = definitionMap.get(key);
|
|
9617
9617
|
if (!definition) {
|
|
9618
|
-
definition = {
|
|
9618
|
+
definition = {
|
|
9619
|
+
abstractNumId: nextAbstractNumId++,
|
|
9620
|
+
numId: nextNumId++,
|
|
9621
|
+
levels: []
|
|
9622
|
+
};
|
|
9619
9623
|
definitionMap.set(key, definition);
|
|
9620
|
-
definitions.push(
|
|
9624
|
+
definitions.push(definition);
|
|
9625
|
+
}
|
|
9626
|
+
if (!definition.levels.some((candidate) => candidate.level === level)) {
|
|
9627
|
+
definition.levels.push({
|
|
9621
9628
|
kind: paragraph.list.kind,
|
|
9622
9629
|
level,
|
|
9623
|
-
abstractNumId: definition.abstractNumId,
|
|
9624
|
-
numId: definition.numId,
|
|
9625
9630
|
format: paragraph.list.format,
|
|
9626
9631
|
startAt: paragraph.list.startAt,
|
|
9632
|
+
levelText: paragraph.list.levelText,
|
|
9633
|
+
suffix: paragraph.list.suffix,
|
|
9634
|
+
alignment: paragraph.list.alignment,
|
|
9635
|
+
legal: paragraph.list.legal,
|
|
9627
9636
|
bulletGlyph: paragraph.list.bulletGlyph,
|
|
9628
9637
|
bulletFont: paragraph.list.bulletFont
|
|
9629
9638
|
});
|
|
@@ -9733,24 +9742,32 @@ function buildPartContext(blocks, numberingContext, state, document2) {
|
|
|
9733
9742
|
};
|
|
9734
9743
|
}
|
|
9735
9744
|
function buildNumberingXml(definitions) {
|
|
9736
|
-
const abstractNums = definitions.map(
|
|
9737
|
-
(
|
|
9738
|
-
|
|
9739
|
-
|
|
9740
|
-
|
|
9741
|
-
|
|
9742
|
-
|
|
9743
|
-
|
|
9744
|
-
|
|
9745
|
-
|
|
9746
|
-
|
|
9747
|
-
|
|
9748
|
-
|
|
9749
|
-
|
|
9750
|
-
|
|
9751
|
-
|
|
9752
|
-
|
|
9753
|
-
|
|
9745
|
+
const abstractNums = definitions.map(({ abstractNumId, levels }) => {
|
|
9746
|
+
const levelsXml = levels.sort((a, b) => a.level - b.level).map(
|
|
9747
|
+
({
|
|
9748
|
+
kind,
|
|
9749
|
+
level,
|
|
9750
|
+
format,
|
|
9751
|
+
startAt,
|
|
9752
|
+
levelText,
|
|
9753
|
+
suffix,
|
|
9754
|
+
alignment,
|
|
9755
|
+
legal,
|
|
9756
|
+
bulletGlyph,
|
|
9757
|
+
bulletFont
|
|
9758
|
+
}) => {
|
|
9759
|
+
const numFmtVal = kind === "bullet" ? "bullet" : format ?? "decimal";
|
|
9760
|
+
const effectiveLevelText = levelText ?? (kind === "bullet" ? bulletGlyph ?? "" : `%${level + 1}.`);
|
|
9761
|
+
const startVal = startAt ?? 1;
|
|
9762
|
+
const fontName = kind === "bullet" ? bulletFont ?? "Symbol" : void 0;
|
|
9763
|
+
const runFonts = fontName ? `<w:rPr><w:rFonts w:ascii="${escapeXml(fontName)}" w:hAnsi="${escapeXml(fontName)}" w:hint="default"/></w:rPr>` : "";
|
|
9764
|
+
const suffixXml = suffix && suffix !== "tab" ? `<w:suff w:val="${suffix}"/>` : "";
|
|
9765
|
+
const legalXml = legal ? "<w:isLgl/>" : "";
|
|
9766
|
+
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>`;
|
|
9767
|
+
}
|
|
9768
|
+
).join("");
|
|
9769
|
+
return `<w:abstractNum w:abstractNumId="${abstractNumId}">${levelsXml}</w:abstractNum>`;
|
|
9770
|
+
}).join("");
|
|
9754
9771
|
const nums = definitions.map(
|
|
9755
9772
|
({ abstractNumId, numId }) => `<w:num w:numId="${numId}"><w:abstractNumId w:val="${abstractNumId}"/></w:num>`
|
|
9756
9773
|
).join("");
|
|
@@ -10272,7 +10289,7 @@ async function drawTextBoxContent(writer, textBox, ctx, xPx, yPx, widthPx, heigh
|
|
|
10272
10289
|
if (blocks.length === 0) {
|
|
10273
10290
|
return;
|
|
10274
10291
|
}
|
|
10275
|
-
const listOrdinals =
|
|
10292
|
+
const listOrdinals = buildListLabels(ctx.document);
|
|
10276
10293
|
writer.saveGraphicsState(ctx.pageIndex);
|
|
10277
10294
|
writer.clipRect(
|
|
10278
10295
|
ctx.pageIndex,
|
|
@@ -10948,118 +10965,15 @@ async function drawFragmentText(writer, pageIndex, paragraph, line, fragment, do
|
|
|
10948
10965
|
);
|
|
10949
10966
|
}
|
|
10950
10967
|
}
|
|
10951
|
-
const BULLET_GLYPHS = ["•", "○", "▪", "•", "○", "▪"];
|
|
10952
|
-
const ORDERED_DEFAULT_FORMATS = [
|
|
10953
|
-
"decimal",
|
|
10954
|
-
"lowerLetter",
|
|
10955
|
-
"lowerRoman",
|
|
10956
|
-
"decimal",
|
|
10957
|
-
"lowerLetter",
|
|
10958
|
-
"lowerRoman"
|
|
10959
|
-
];
|
|
10960
|
-
function toAlpha(value) {
|
|
10961
|
-
if (value <= 0) {
|
|
10962
|
-
return String(value);
|
|
10963
|
-
}
|
|
10964
|
-
let remaining = value;
|
|
10965
|
-
let output = "";
|
|
10966
|
-
while (remaining > 0) {
|
|
10967
|
-
const rem = (remaining - 1) % 26;
|
|
10968
|
-
output = String.fromCharCode(65 + rem) + output;
|
|
10969
|
-
remaining = Math.floor((remaining - 1) / 26);
|
|
10970
|
-
}
|
|
10971
|
-
return output;
|
|
10972
|
-
}
|
|
10973
|
-
function toRoman(value) {
|
|
10974
|
-
if (value <= 0 || value >= 4e3) {
|
|
10975
|
-
return String(value);
|
|
10976
|
-
}
|
|
10977
|
-
const map = [
|
|
10978
|
-
[1e3, "M"],
|
|
10979
|
-
[900, "CM"],
|
|
10980
|
-
[500, "D"],
|
|
10981
|
-
[400, "CD"],
|
|
10982
|
-
[100, "C"],
|
|
10983
|
-
[90, "XC"],
|
|
10984
|
-
[50, "L"],
|
|
10985
|
-
[40, "XL"],
|
|
10986
|
-
[10, "X"],
|
|
10987
|
-
[9, "IX"],
|
|
10988
|
-
[5, "V"],
|
|
10989
|
-
[4, "IV"],
|
|
10990
|
-
[1, "I"]
|
|
10991
|
-
];
|
|
10992
|
-
let remaining = value;
|
|
10993
|
-
let output = "";
|
|
10994
|
-
for (const [amount, text] of map) {
|
|
10995
|
-
while (remaining >= amount) {
|
|
10996
|
-
output += text;
|
|
10997
|
-
remaining -= amount;
|
|
10998
|
-
}
|
|
10999
|
-
}
|
|
11000
|
-
return output;
|
|
11001
|
-
}
|
|
11002
|
-
function formatOrdinal(value, format) {
|
|
11003
|
-
switch (format) {
|
|
11004
|
-
case "lowerLetter":
|
|
11005
|
-
return toAlpha(value).toLowerCase();
|
|
11006
|
-
case "upperLetter":
|
|
11007
|
-
return toAlpha(value).toUpperCase();
|
|
11008
|
-
case "lowerRoman":
|
|
11009
|
-
return toRoman(value).toLowerCase();
|
|
11010
|
-
case "upperRoman":
|
|
11011
|
-
return toRoman(value).toUpperCase();
|
|
11012
|
-
case "decimal":
|
|
11013
|
-
default:
|
|
11014
|
-
return String(value);
|
|
11015
|
-
}
|
|
11016
|
-
}
|
|
11017
10968
|
function getListOrdinals(document2) {
|
|
11018
|
-
|
|
11019
|
-
const paragraphs = getDocumentParagraphs(document2);
|
|
11020
|
-
let counters = [];
|
|
11021
|
-
let previousWasOrdered = false;
|
|
11022
|
-
for (const paragraph of paragraphs) {
|
|
11023
|
-
const list = paragraph.list;
|
|
11024
|
-
if (!list || list.kind !== "ordered") {
|
|
11025
|
-
counters = [];
|
|
11026
|
-
previousWasOrdered = false;
|
|
11027
|
-
continue;
|
|
11028
|
-
}
|
|
11029
|
-
const level = list.level ?? 0;
|
|
11030
|
-
if (!previousWasOrdered) {
|
|
11031
|
-
counters = [];
|
|
11032
|
-
}
|
|
11033
|
-
if (counters.length > level + 1) {
|
|
11034
|
-
counters.length = level + 1;
|
|
11035
|
-
}
|
|
11036
|
-
while (counters.length <= level) {
|
|
11037
|
-
counters.push(0);
|
|
11038
|
-
}
|
|
11039
|
-
counters[level] = counters[level] === 0 && typeof list.startAt === "number" ? list.startAt : counters[level] + 1;
|
|
11040
|
-
result.set(paragraph.id, counters[level]);
|
|
11041
|
-
previousWasOrdered = true;
|
|
11042
|
-
}
|
|
11043
|
-
return result;
|
|
11044
|
-
}
|
|
11045
|
-
function resolveListPrefix(paragraph, listOrdinals) {
|
|
11046
|
-
if (!paragraph.list) {
|
|
11047
|
-
return "";
|
|
11048
|
-
}
|
|
11049
|
-
const level = Math.max(0, paragraph.list.level ?? 0);
|
|
11050
|
-
if (paragraph.list.kind === "bullet") {
|
|
11051
|
-
return BULLET_GLYPHS[level % BULLET_GLYPHS.length];
|
|
11052
|
-
}
|
|
11053
|
-
const value = listOrdinals.get(paragraph.id) ?? paragraph.list.startAt ?? 1;
|
|
11054
|
-
const format = paragraph.list.format && paragraph.list.format !== "bullet" ? paragraph.list.format : ORDERED_DEFAULT_FORMATS[level % ORDERED_DEFAULT_FORMATS.length];
|
|
11055
|
-
return `${formatOrdinal(value, format)}.`;
|
|
10969
|
+
return buildListLabels(document2);
|
|
11056
10970
|
}
|
|
11057
10971
|
function drawListPrefix(writer, pageIndex, paragraph, line, document2, originX, originY, fontRegistry, listOrdinals) {
|
|
11058
10972
|
var _a;
|
|
11059
10973
|
if (line.index !== 0) {
|
|
11060
10974
|
return;
|
|
11061
10975
|
}
|
|
11062
|
-
const prefix =
|
|
10976
|
+
const prefix = resolveListLabel(paragraph, listOrdinals);
|
|
11063
10977
|
if (!prefix) {
|
|
11064
10978
|
return;
|
|
11065
10979
|
}
|
|
@@ -11078,11 +10992,19 @@ function drawListPrefix(writer, pageIndex, paragraph, line, document2, originX,
|
|
|
11078
10992
|
italic: styles.italic
|
|
11079
10993
|
});
|
|
11080
10994
|
const labelInset = getListLabelInset(paragraph, document2.styles);
|
|
10995
|
+
const fontSizePt = textStyleToFontSizePt(styles);
|
|
10996
|
+
const estimatedLabelWidthPx = prefix.length * fontSizePt * 0.62 * (96 / 72);
|
|
10997
|
+
const alignedInset = getAlignedListLabelInset(
|
|
10998
|
+
paragraph,
|
|
10999
|
+
document2.styles,
|
|
11000
|
+
firstSlot.left,
|
|
11001
|
+
estimatedLabelWidthPx
|
|
11002
|
+
);
|
|
11081
11003
|
writer.drawText(pageIndex, {
|
|
11082
|
-
x: pxToPt$1(originX + Math.max(0, labelInset)),
|
|
11004
|
+
x: pxToPt$1(originX + Math.max(0, alignedInset || labelInset)),
|
|
11083
11005
|
y: pxToPt$1(originY + line.top + line.height * 0.8),
|
|
11084
11006
|
text: prefix,
|
|
11085
|
-
fontSize:
|
|
11007
|
+
fontSize: fontSizePt,
|
|
11086
11008
|
color: styles.color ?? "#000000",
|
|
11087
11009
|
bold: styles.bold,
|
|
11088
11010
|
italic: styles.italic,
|