oasis-editor 0.0.95 → 0.0.96
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-C_Ao4zIF.js → OasisEditorApp-CMTq6BTy.js} +71 -7
- package/dist/assets/{importDocxWorker-DAbfLHtp.js → importDocxWorker-M34STPYy.js} +1 -1
- package/dist/core/model/index.d.ts +1 -1
- package/dist/core/model/types/primitives.d.ts +24 -0
- package/dist/core/model/types/styles.d.ts +5 -1
- package/dist/export/pdf/writer/pdfTypes.d.ts +4 -0
- package/dist/import/docx/xmlHelpers.d.ts +8 -0
- package/dist/{index-BQEtsRa0.js → index-D0bOD23M.js} +156 -5
- package/dist/oasis-editor.js +1 -1
- package/dist/oasis-editor.umd.cjs +4 -4
- 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 { v as visitRun, a as assertNever, c as createSignal, b as createEditorStateFromDocument, d as createInitialEditorState, S as STANDARD_FONT_SIZES_PT, f as fontSizePxToPt, p as probeLocalFontFamilies, e as createEditorParagraphFromRuns, i as isInlineObjectRun, g as createEditorStyledRun, h as getParagraphLength, j as getParagraphText, k as getActiveZone, l as getDocumentSections, m as getActiveSectionIndex, n as getParagraphs, o as normalizeSelection, q as positionToParagraphOffset, r as paragraphOffsetToPosition, s as clampPosition, t as findParagraphIndex, u as createCollapsedSelection, w as isSelectionCollapsed, x as parseFontSizePtToPx, y as formatFontSizePt, z as createEditorParagraph, A as getBlockParagraphs, B as findParagraphTableLocation, C as buildTableCellLayout, P as PT_PER_PX, D as createEditorTableCell, E as createEditorTableRow, F as createEditorTable, G as underlineStyleToCssDecorationStyle, H as resolveImageSrc, I as listKindForTag, J as isParagraphTag, K as collectInlineRuns, L as parseParagraphStyle, M as getRunImage, N as InlineShell, O as BalloonShell, Q as DocumentShell, R as createMemo, T as buildCanvasLayoutSnapshot, U as getCaretRectFromSnapshot, V as getParagraphRectFromSnapshot, W as createComponent, X as CaretOverlay, Y as Show, Z as createRenderEffect, _ as style, $ as setAttribute, a0 as setStyleProperty, a1 as memo, a2 as template, a3 as useI18n, a4 as createEffect, a5 as insert, a6 as use, a7 as addEventListener, a8 as Dialog, a9 as delegateEvents, aa as className, ab as For, ac as UNDERLINE_STYLE_OPTIONS, ad as Tabs, ae as onMount, af as onCleanup, ag as PluginUiHost, ah as OasisEditorEditor, ai as OasisBrandMark, aj as setPreciseFontPreference, ak as setWelcomeSeen, al as enablePreciseFontMode, am as TWIPS_PER_POINT, an as PX_PER_INCH, ao as TWIPS_PER_INCH, ap as resolveEffectiveParagraphStyle, aq as resolveEffectiveTextStyleForParagraph, ar as EMU_PER_PX, as as EMU_PER_PT, at as getRunFootnoteReference, au as getRunEndnoteReference, av as iterateFootnoteReferenceRuns, aw as iterateEndnoteReferenceRuns, ax as imageContentTypeDefaults, ay as getRunFieldChar, az as getRunFieldInstruction, aA as createEditorRun, aB as JSZip, aC as imageExtensionFromMime, aD as pxToPt$1, aE as resolveFloatingObjectRect, aF as getTextBoxFloatingGeometry, aG as getPresetPathSegments, aH as projectBlocksLayout, aI as buildListLabels, aJ as getImageFloatingGeometry, aK as textStyleToFontSizePt, aL as PX_PER_POINT, aM as DEFAULT_FONT_SIZE_PX, aN as isDoubleUnderlineStyle, aO as isWavyUnderlineStyle, aP as underlineStyleLineWidthPx, aQ as underlineStyleDashArray, aR as resolveListLabel, aS as getListLabelInset, aT as getAlignedListLabelInset, aU as getParagraphBorderInsets, aV as buildSegmentTable, aW as buildCanvasTableLayout, aX as resolveCanvasTableWidth, aY as resolveFloatingTableRect, aZ as normalizeFamily, a_ as ROBOTO_FONT_FILES, a$ as loadFontAsset, b0 as OFFICE_COMPAT_FONT_FAMILIES, b1 as buildSfnt, b2 as defaultFontDecoderRegistry, b3 as SfntFontProgram, b4 as collectPdfFontFamilies, b5 as projectDocumentLayout, b6 as getPageContentWidth, b7 as getPageHeaderZoneTop, b8 as getPageBodyTop, b9 as getPageColumnRects, ba as findFootnoteReference, bb as FOOTNOTE_MARKER_GUTTER_PX, bc as resolveImporterForFile, bd as getDocumentSectionsCanonical, be as getDocumentParagraphsCanonical, bf as getDocumentParagraphs, bg as getDocumentPageSettings, bh as getTableCellContentWidthForParagraph, bi as on, bj as debounce, bk as unwrap, bl as perfTimer, bm as getRunTextBox, bn as createEditorDocument, bo as resolveResizedDimensions, bp as resolveTextBoxRenderHeight, bq as getToolbarStyleState, br as getCachedCanvasImage, 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 createEditorFootnote, bD as createFootnoteReferenceRun, bE as renumberFootnotes, bF as getFootnoteDisplayMarker, bG as getHeadingLevel, bH as preciseFontModeVersion, bI as isPreciseFontModeEnabled, bJ as resolveNamedTextStyle, bK as togglePreciseFontMode, bL as nextFontSizePt, bM as previousFontSizePt, bN as fontSizePtToPx, bO as createDefaultToolbarPreset, bP as MenuRegistry, bQ as createToolbarRegistry, bR as Editor, bS as resolveCommandRef, bT as commandRefName, bU as createOasisEditorClient, bV as createEditorZoom, bW as startLongTaskObserver, bX as installGlobalReport, bY as applyStoredPreciseFontPreference, bZ as getWelcomeSeen, b_ as isLocalFontAccessSupported, b$ as EDITOR_SCROLL_PADDING_PX, c0 as Toolbar, c1 as OasisEditorLoading, c2 as I18nProvider, c3 as createTranslator, c4 as createEditorLogger, c5 as registerDomStatsSurface } from "./index-
|
|
4
|
+
import { v as visitRun, a as assertNever, c as createSignal, b as createEditorStateFromDocument, d as createInitialEditorState, S as STANDARD_FONT_SIZES_PT, f as fontSizePxToPt, p as probeLocalFontFamilies, e as createEditorParagraphFromRuns, i as isInlineObjectRun, g as createEditorStyledRun, h as getParagraphLength, j as getParagraphText, k as getActiveZone, l as getDocumentSections, m as getActiveSectionIndex, n as getParagraphs, o as normalizeSelection, q as positionToParagraphOffset, r as paragraphOffsetToPosition, s as clampPosition, t as findParagraphIndex, u as createCollapsedSelection, w as isSelectionCollapsed, x as parseFontSizePtToPx, y as formatFontSizePt, z as createEditorParagraph, A as getBlockParagraphs, B as findParagraphTableLocation, C as buildTableCellLayout, P as PT_PER_PX, D as createEditorTableCell, E as createEditorTableRow, F as createEditorTable, G as underlineStyleToCssDecorationStyle, H as resolveImageSrc, I as listKindForTag, J as isParagraphTag, K as collectInlineRuns, L as parseParagraphStyle, M as getRunImage, N as InlineShell, O as BalloonShell, Q as DocumentShell, R as createMemo, T as buildCanvasLayoutSnapshot, U as getCaretRectFromSnapshot, V as getParagraphRectFromSnapshot, W as createComponent, X as CaretOverlay, Y as Show, Z as createRenderEffect, _ as style, $ as setAttribute, a0 as setStyleProperty, a1 as memo, a2 as template, a3 as useI18n, a4 as createEffect, a5 as insert, a6 as use, a7 as addEventListener, a8 as Dialog, a9 as delegateEvents, aa as className, ab as For, ac as UNDERLINE_STYLE_OPTIONS, ad as Tabs, ae as onMount, af as onCleanup, ag as PluginUiHost, ah as OasisEditorEditor, ai as OasisBrandMark, aj as setPreciseFontPreference, ak as setWelcomeSeen, al as enablePreciseFontMode, am as TWIPS_PER_POINT, an as PX_PER_INCH, ao as TWIPS_PER_INCH, ap as resolveEffectiveParagraphStyle, aq as resolveEffectiveTextStyleForParagraph, ar as EMU_PER_PX, as as EMU_PER_PT, at as getRunFootnoteReference, au as getRunEndnoteReference, av as iterateFootnoteReferenceRuns, aw as iterateEndnoteReferenceRuns, ax as imageContentTypeDefaults, ay as getRunFieldChar, az as getRunFieldInstruction, aA as createEditorRun, aB as JSZip, aC as imageExtensionFromMime, aD as pxToPt$1, aE as resolveFloatingObjectRect, aF as getTextBoxFloatingGeometry, aG as getPresetPathSegments, aH as projectBlocksLayout, aI as buildListLabels, aJ as getImageFloatingGeometry, aK as textStyleToFontSizePt, aL as PX_PER_POINT, aM as DEFAULT_FONT_SIZE_PX, aN as isDoubleUnderlineStyle, aO as isWavyUnderlineStyle, aP as underlineStyleLineWidthPx, aQ as underlineStyleDashArray, aR as resolveListLabel, aS as getListLabelInset, aT as getAlignedListLabelInset, aU as getParagraphBorderInsets, aV as buildSegmentTable, aW as buildCanvasTableLayout, aX as resolveCanvasTableWidth, aY as resolveFloatingTableRect, aZ as normalizeFamily, a_ as ROBOTO_FONT_FILES, a$ as loadFontAsset, b0 as OFFICE_COMPAT_FONT_FAMILIES, b1 as buildSfnt, b2 as defaultFontDecoderRegistry, b3 as SfntFontProgram, b4 as collectPdfFontFamilies, b5 as projectDocumentLayout, b6 as getPageContentWidth, b7 as getPageHeaderZoneTop, b8 as getPageBodyTop, b9 as getPageColumnRects, ba as findFootnoteReference, bb as FOOTNOTE_MARKER_GUTTER_PX, bc as resolveImporterForFile, bd as getDocumentSectionsCanonical, be as getDocumentParagraphsCanonical, bf as getDocumentParagraphs, bg as getDocumentPageSettings, bh as getTableCellContentWidthForParagraph, bi as on, bj as debounce, bk as unwrap, bl as perfTimer, bm as getRunTextBox, bn as createEditorDocument, bo as resolveResizedDimensions, bp as resolveTextBoxRenderHeight, bq as getToolbarStyleState, br as getCachedCanvasImage, 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 createEditorFootnote, bD as createFootnoteReferenceRun, bE as renumberFootnotes, bF as getFootnoteDisplayMarker, bG as getHeadingLevel, bH as preciseFontModeVersion, bI as isPreciseFontModeEnabled, bJ as resolveNamedTextStyle, bK as togglePreciseFontMode, bL as nextFontSizePt, bM as previousFontSizePt, bN as fontSizePtToPx, bO as createDefaultToolbarPreset, bP as MenuRegistry, bQ as createToolbarRegistry, bR as Editor, bS as resolveCommandRef, bT as commandRefName, bU as createOasisEditorClient, bV as createEditorZoom, bW as startLongTaskObserver, bX as installGlobalReport, bY as applyStoredPreciseFontPreference, bZ as getWelcomeSeen, b_ as isLocalFontAccessSupported, b$ as EDITOR_SCROLL_PADDING_PX, c0 as Toolbar, c1 as OasisEditorLoading, c2 as I18nProvider, c3 as createTranslator, c4 as createEditorLogger, c5 as registerDomStatsSurface } from "./index-D0bOD23M.js";
|
|
5
5
|
function cloneStyle(style2) {
|
|
6
6
|
return style2 ? { ...style2 } : void 0;
|
|
7
7
|
}
|
|
@@ -29574,6 +29574,23 @@ function textRunStylesToCss(style2) {
|
|
|
29574
29574
|
if (featureSettings) {
|
|
29575
29575
|
parts.push(`font-feature-settings:${featureSettings}`);
|
|
29576
29576
|
}
|
|
29577
|
+
if (style2.textFill) {
|
|
29578
|
+
if (style2.textFill.type === "solid") {
|
|
29579
|
+
parts.push(`color:${style2.textFill.color}`);
|
|
29580
|
+
} else if (style2.textFill.type === "gradient" && style2.textFill.stops.length >= 2) {
|
|
29581
|
+
const cssAngle = ((90 - (style2.textFill.angle ?? 0)) % 360 + 360) % 360;
|
|
29582
|
+
const stopsCss = style2.textFill.stops.map((s) => `${s.color} ${Math.round(s.position * 100)}%`).join(",");
|
|
29583
|
+
parts.push(`background:linear-gradient(${cssAngle}deg,${stopsCss})`);
|
|
29584
|
+
parts.push("-webkit-background-clip:text");
|
|
29585
|
+
parts.push("background-clip:text");
|
|
29586
|
+
parts.push("color:transparent");
|
|
29587
|
+
}
|
|
29588
|
+
}
|
|
29589
|
+
if (style2.textOutline) {
|
|
29590
|
+
const widthPx = style2.textOutline.widthPt * (96 / 72);
|
|
29591
|
+
const color = style2.textOutline.color ?? "#000000";
|
|
29592
|
+
parts.push(`-webkit-text-stroke:${widthPx.toFixed(2)}px ${color}`);
|
|
29593
|
+
}
|
|
29577
29594
|
const decorations = [];
|
|
29578
29595
|
if (style2.underline || style2.link) {
|
|
29579
29596
|
decorations.push("underline");
|
|
@@ -33748,6 +33765,8 @@ function materializeRunStyle(run, paragraphStyleId, styles) {
|
|
|
33748
33765
|
fontFamily: effective.fontFamily,
|
|
33749
33766
|
fontSize: effective.fontSize,
|
|
33750
33767
|
color: effective.color,
|
|
33768
|
+
textFill: effective.textFill,
|
|
33769
|
+
textOutline: effective.textOutline,
|
|
33751
33770
|
highlight: effective.highlight,
|
|
33752
33771
|
shading: effective.shading,
|
|
33753
33772
|
language: effective.language
|
|
@@ -33935,6 +33954,34 @@ const DOCX_HIGHLIGHT_HEX_ALIASES = {
|
|
|
33935
33954
|
};
|
|
33936
33955
|
const OOXML_PERCENT_DENOMINATOR = 1e5;
|
|
33937
33956
|
const OOXML_ROTATION_UNITS = 6e4;
|
|
33957
|
+
const MC_NS = "http://schemas.openxmlformats.org/markup-compatibility/2006";
|
|
33958
|
+
function serializeW14SolidFillXml(color) {
|
|
33959
|
+
const hex = normalizeDocxColor(color);
|
|
33960
|
+
return `<w14:solidFill><w14:srgbClr w14:val="${hex}"/></w14:solidFill>`;
|
|
33961
|
+
}
|
|
33962
|
+
function serializeW14FillXml(fill) {
|
|
33963
|
+
if (fill.type === "solid") {
|
|
33964
|
+
return serializeW14SolidFillXml(fill.color);
|
|
33965
|
+
}
|
|
33966
|
+
const gsXml = fill.stops.map((s) => {
|
|
33967
|
+
const hex = normalizeDocxColor(s.color);
|
|
33968
|
+
const pos = Math.round(s.position * 1e5);
|
|
33969
|
+
const alphaXml = s.alpha !== void 0 ? `<w14:alpha w14:val="${Math.round(s.alpha * 1e5)}"/>` : "";
|
|
33970
|
+
return `<w14:gs w14:pos="${pos}"><w14:srgbClr w14:val="${hex}">${alphaXml}</w14:srgbClr></w14:gs>`;
|
|
33971
|
+
}).join("");
|
|
33972
|
+
const angVal = Math.round((fill.angle ?? 0) * 6e4);
|
|
33973
|
+
return `<w14:gradFill><w14:gsLst>${gsXml}</w14:gsLst><w14:lin w14:ang="${angVal}" w14:scaled="0"/></w14:gradFill>`;
|
|
33974
|
+
}
|
|
33975
|
+
function serializeTextFillMC(fill, fallbackColor) {
|
|
33976
|
+
const fillXml = serializeW14FillXml(fill);
|
|
33977
|
+
const fbHex = normalizeDocxColor(fallbackColor ?? "000000");
|
|
33978
|
+
return `<mc:AlternateContent xmlns:mc="${MC_NS}"><mc:Choice Requires="w14"><w14:textFill>${fillXml}</w14:textFill></mc:Choice><mc:Fallback><w:color w:val="${fbHex}"/></mc:Fallback></mc:AlternateContent>`;
|
|
33979
|
+
}
|
|
33980
|
+
function serializeTextOutlineMC(outline) {
|
|
33981
|
+
const widthEmu = Math.round(Math.max(0, outline.widthPt) * 12700);
|
|
33982
|
+
const fillXml = outline.fill ? serializeW14FillXml(outline.fill) : outline.color ? serializeW14SolidFillXml(outline.color) : "";
|
|
33983
|
+
return `<mc:AlternateContent xmlns:mc="${MC_NS}"><mc:Choice Requires="w14"><w14:textOutline w14:w="${widthEmu}" w14:cap="flat" w14:cmpd="sng" w14:algn="ctr">` + fillXml + `</w14:textOutline></mc:Choice><mc:Fallback><w:outline/></mc:Fallback></mc:AlternateContent>`;
|
|
33984
|
+
}
|
|
33938
33985
|
function pointsToSignedTwips(value) {
|
|
33939
33986
|
if (value === void 0 || value === null || !Number.isFinite(value)) {
|
|
33940
33987
|
return null;
|
|
@@ -34101,11 +34148,17 @@ function serializeRunProperties(styles) {
|
|
|
34101
34148
|
parts.push(`<w:sz w:val="${size}"/>`, `<w:szCs w:val="${size}"/>`);
|
|
34102
34149
|
}
|
|
34103
34150
|
}
|
|
34104
|
-
if (styles.
|
|
34151
|
+
if (styles.textFill) {
|
|
34152
|
+
const fallback = styles.textFill.type === "solid" ? styles.textFill.color : styles.color;
|
|
34153
|
+
parts.push(serializeTextFillMC(styles.textFill, fallback ?? null));
|
|
34154
|
+
} else if (styles.color) {
|
|
34105
34155
|
parts.push(
|
|
34106
34156
|
`<w:color w:val="${escapeXml(styles.color.replace(/^#/, ""))}"/>`
|
|
34107
34157
|
);
|
|
34108
34158
|
}
|
|
34159
|
+
if (styles.textOutline) {
|
|
34160
|
+
parts.push(serializeTextOutlineMC(styles.textOutline));
|
|
34161
|
+
}
|
|
34109
34162
|
if (styles.highlight) {
|
|
34110
34163
|
parts.push(
|
|
34111
34164
|
`<w:highlight w:val="${escapeXml(normalizeHighlightForDocx(styles.highlight))}"/>`
|
|
@@ -36474,7 +36527,7 @@ async function drawInlineTextBoxFragment(writer, pageIndex, line, fragment, docu
|
|
|
36474
36527
|
);
|
|
36475
36528
|
}
|
|
36476
36529
|
async function drawFragmentText(writer, pageIndex, paragraph, line, fragment, document2, originX, originY, fontRegistry, drawers) {
|
|
36477
|
-
var _a;
|
|
36530
|
+
var _a, _b, _c;
|
|
36478
36531
|
if (fragment.image) {
|
|
36479
36532
|
if (fragment.image.floating) {
|
|
36480
36533
|
return;
|
|
@@ -36586,7 +36639,7 @@ async function drawFragmentText(writer, pageIndex, paragraph, line, fragment, do
|
|
|
36586
36639
|
characterSpacing: styles.characterSpacing ?? 0,
|
|
36587
36640
|
horizontalScale: styles.characterScale ?? 100
|
|
36588
36641
|
};
|
|
36589
|
-
const mainColor = styles.color ?? "#000000";
|
|
36642
|
+
const mainColor = ((_b = styles.textFill) == null ? void 0 : _b.type) === "solid" ? styles.textFill.color : ((_c = styles.textFill) == null ? void 0 : _c.type) === "gradient" && styles.textFill.stops[0] ? styles.textFill.stops[0].color : styles.color ?? "#000000";
|
|
36590
36643
|
const offsetPt = pxToPt$1(1);
|
|
36591
36644
|
const emitChunk = (leftPx, text2) => {
|
|
36592
36645
|
if (styles.emboss || styles.imprint) {
|
|
@@ -36608,13 +36661,18 @@ async function drawFragmentText(writer, pageIndex, paragraph, line, fragment, do
|
|
|
36608
36661
|
color: "#808080"
|
|
36609
36662
|
});
|
|
36610
36663
|
}
|
|
36664
|
+
const textOutline = styles.textOutline;
|
|
36611
36665
|
writer.drawText(pageIndex, {
|
|
36612
36666
|
...baseTextOptions,
|
|
36613
36667
|
x: pxToPt$1(leftPx),
|
|
36614
36668
|
y: pxToPt$1(baselineY),
|
|
36615
36669
|
text: text2,
|
|
36616
36670
|
color: mainColor,
|
|
36617
|
-
|
|
36671
|
+
...textOutline ? {
|
|
36672
|
+
renderMode: 2,
|
|
36673
|
+
strokeColor: textOutline.color ?? mainColor,
|
|
36674
|
+
strokeWidth: textOutline.widthPt
|
|
36675
|
+
} : { renderMode: styles.outline ? 1 : 0 }
|
|
36618
36676
|
});
|
|
36619
36677
|
};
|
|
36620
36678
|
const chunks = paragraphAlign === "justify" ? groupSlotChunksByWhitespace(chars) : groupSlotChunksByOffsetGaps(chars);
|
|
@@ -37609,8 +37667,14 @@ class PdfContentStream {
|
|
|
37609
37667
|
colorCommand(options.color, "rg", [0, 0, 0]),
|
|
37610
37668
|
`/${fontResourceName} ${formatNumber(options.fontSize ?? 12)} Tf`,
|
|
37611
37669
|
...options.renderMode && options.renderMode !== 0 ? [
|
|
37612
|
-
colorCommand(
|
|
37613
|
-
|
|
37670
|
+
colorCommand(
|
|
37671
|
+
options.strokeColor ?? options.color,
|
|
37672
|
+
"RG",
|
|
37673
|
+
[0, 0, 0]
|
|
37674
|
+
),
|
|
37675
|
+
`${formatNumber(
|
|
37676
|
+
options.strokeWidth ?? Math.max(0.3, (options.fontSize ?? 12) * 0.03)
|
|
37677
|
+
)} w`,
|
|
37614
37678
|
`${options.renderMode} Tr`
|
|
37615
37679
|
] : [],
|
|
37616
37680
|
...options.horizontalScale && options.horizontalScale > 0 && options.horizontalScale !== 100 ? [`${formatNumber(options.horizontalScale)} Tz`] : [],
|