oasis-editor 0.0.18 → 0.0.20
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-Cwoo0WV0.js → OasisEditorApp-YuR1PFAE.js} +71 -17
- package/dist/assets/{importDocxWorker-cjz15bhS.js → importDocxWorker-D4P4_drI.js} +1 -1
- package/dist/core/model/index.d.ts +2 -2
- package/dist/core/model/pageGeometry.d.ts +13 -0
- package/dist/core/model/types/document.d.ts +20 -0
- package/dist/core/model/types/layout.d.ts +5 -0
- package/dist/i18n/locales/en.d.ts +13 -2
- package/dist/i18n/locales/pt-BR.d.ts +13 -2
- package/dist/{index-CBbhzffQ.js → index-CBXD1ygJ.js} +788 -355
- package/dist/layoutProjection/blocksPagination.d.ts +10 -0
- package/dist/oasis-editor.css +1 -1
- package/dist/oasis-editor.js +54 -54
- package/dist/oasis-editor.umd.cjs +4 -4
- package/dist/plugins/internal/createEssentialsPlugin.d.ts +3 -4
- package/dist/ui/components/Toolbar/groups/MarginsGroup.d.ts +7 -0
- package/dist/ui/components/Toolbar/marginPresets.d.ts +34 -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 textStyleToFontSizePt, a6 as PX_PER_POINT, a7 as DEFAULT_FONT_SIZE_PX, a8 as isDoubleUnderlineStyle, a9 as isWavyUnderlineStyle, aa as underlineStyleLineWidthPx, ab as underlineStyleDashArray, ac as getListLabelInset, ad as getParagraphBorderInsets, ae as normalizeFamily, af as ROBOTO_FONT_FILES, ag as loadFontAsset, ah as OFFICE_COMPAT_FONT_FAMILIES, ai as buildSfnt, aj as defaultFontDecoderRegistry, ak as SfntFontProgram, al as collectPdfFontFamilies, am as projectDocumentLayout, an as getPageHeaderZoneTop, ao as getPageBodyTop, ap 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 textStyleToFontSizePt, a6 as PX_PER_POINT, a7 as DEFAULT_FONT_SIZE_PX, a8 as isDoubleUnderlineStyle, a9 as isWavyUnderlineStyle, aa as underlineStyleLineWidthPx, ab as underlineStyleDashArray, ac as getListLabelInset, ad as getParagraphBorderInsets, ae as normalizeFamily, af as ROBOTO_FONT_FILES, ag as loadFontAsset, ah as OFFICE_COMPAT_FONT_FAMILIES, ai as buildSfnt, aj as defaultFontDecoderRegistry, ak as SfntFontProgram, al as collectPdfFontFamilies, am as projectDocumentLayout, an as getPageHeaderZoneTop, ao as getPageBodyTop, ap as getPageColumnRects, aq as findFootnoteReference, ar as FOOTNOTE_MARKER_GUTTER_PX, as as resolveImporterForFile, at as createEditorStateFromDocument, au as getDocumentParagraphsCanonical, av as getToolbarStyleState, aw as STANDARD_FONT_SIZES_PT, ax as fontSizePxToPt, ay as probeLocalFontFamilies, az as createInitialEditorState, aA as parseFontSizePtToPx, aB as formatFontSizePt, aC as listKindForTag, aD as isParagraphTag, aE as collectInlineRuns, aF as parseParagraphStyle, aG as t, aH as preciseFontModeVersion, aI as isPreciseFontModeEnabled, aJ as togglePreciseFontMode, aK as nextFontSizePt, aL as previousFontSizePt, aM as fontSizePtToPx, aN as createDefaultToolbarPreset, aO as defaultMenuItems, aP as MenuRegistry, aQ as createToolbarRegistry, aR as Editor, aS as resolveCommandRef, aT as commandRefName, aU as InlineShell, aV as BalloonShell, aW as DocumentShell, aX as createMemo, aY as getCaretRectFromSnapshot, aZ as getParagraphRectFromSnapshot, a_ as createComponent, a$ as CaretOverlay, b0 as Show, b1 as createRenderEffect, b2 as style, b3 as setAttribute, b4 as setStyleProperty, b5 as memo, b6 as template, b7 as insert, b8 as use, b9 as addEventListener, ba as Dialog, bb as delegateEvents, bc as className, bd as For, be as UNDERLINE_STYLE_OPTIONS, bf as Tabs, bg as measureParagraphMinContentWidthPx, bh as getEditableBlocksForZone, bi as findParagraphLocation, bj as createSectionBoundaryParagraph, bk as normalizePageSettings, bl as DEFAULT_EDITOR_PAGE_SETTINGS, bm as markStart, bn as markEnd, bo as getParagraphEntries, bp as getParagraphById, bq as PluginUiHost, br as OasisEditorEditor, bs as perfTimer, bt as OasisBrandMark, bu as setPreciseFontPreference, bv as setWelcomeSeen, bw as enablePreciseFontMode, bx as createOasisEditorClient, by as setLocale, bz as startLongTaskObserver, bA as installGlobalReport, bB as applyStoredPreciseFontPreference, bC as getWelcomeSeen, bD as isLocalFontAccessSupported, bE as EDITOR_SCROLL_PADDING_PX, bF as Toolbar, bG as OasisEditorLoading, bH as createEditorLogger, bI as getCachedCanvasImage, bJ as registerDomStatsSurface } from "./index-CBXD1ygJ.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) {
|
|
@@ -9538,7 +9538,7 @@ function buildStylesXml(styles) {
|
|
|
9538
9538
|
}
|
|
9539
9539
|
const DOCUMENT_XMLNS = `xmlns:w="${WORD_NS$1}" xmlns:w14="${WORD14_NS}" xmlns:wp="http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing" xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main" xmlns:pic="http://schemas.openxmlformats.org/drawingml/2006/picture" xmlns:wps="http://schemas.microsoft.com/office/word/2010/wordprocessingShape" xmlns:r="${OFFICE_REL_NS}"`;
|
|
9540
9540
|
function serializeSectionPropertiesWithReferences(pageSettings, references) {
|
|
9541
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
9541
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i;
|
|
9542
9542
|
const width = pxToTwips(pageSettings.width, 12240);
|
|
9543
9543
|
const height = pxToTwips(pageSettings.height, 15840);
|
|
9544
9544
|
const margins = pageSettings.margins;
|
|
@@ -9552,7 +9552,21 @@ function serializeSectionPropertiesWithReferences(pageSettings, references) {
|
|
|
9552
9552
|
((_f = references == null ? void 0 : references.footer) == null ? void 0 : _f.default) ? `<w:footerReference w:type="default" r:id="${references.footer.default.relId}"/>` : ""
|
|
9553
9553
|
].join("");
|
|
9554
9554
|
const titlePageXml = ((_g = references == null ? void 0 : references.header) == null ? void 0 : _g.first) || ((_h = references == null ? void 0 : references.footer) == null ? void 0 : _h.first) ? "<w:titlePg/>" : "";
|
|
9555
|
-
|
|
9555
|
+
const columns = pageSettings.columns;
|
|
9556
|
+
let columnsXml = "";
|
|
9557
|
+
if (columns && columns.count > 1) {
|
|
9558
|
+
const space = pxToTwips(columns.space, 0);
|
|
9559
|
+
const sepAttr = columns.separator ? ' w:sep="1"' : "";
|
|
9560
|
+
if (columns.equalWidth === false && ((_i = columns.columns) == null ? void 0 : _i.length)) {
|
|
9561
|
+
const colsXml = columns.columns.map(
|
|
9562
|
+
(col) => `<w:col w:w="${pxToTwips(col.width, 0)}" w:space="${pxToTwips(col.space, 0)}"/>`
|
|
9563
|
+
).join("");
|
|
9564
|
+
columnsXml = `<w:cols w:num="${columns.count}" w:space="${space}" w:equalWidth="0"${sepAttr}>${colsXml}</w:cols>`;
|
|
9565
|
+
} else {
|
|
9566
|
+
columnsXml = `<w:cols w:num="${columns.count}" w:space="${space}"${sepAttr}/>`;
|
|
9567
|
+
}
|
|
9568
|
+
}
|
|
9569
|
+
return `<w:sectPr>${referencesXml}${titlePageXml}<w:pgSz w:w="${width}" w:h="${height}"${orientationAttr}/><w:pgMar w:top="${pxToTwips(margins.top, 1440)}" w:right="${pxToTwips(margins.right, 1440)}" w:bottom="${pxToTwips(margins.bottom, 1440)}" w:left="${pxToTwips(margins.left, 1440)}" w:header="${pxToTwips(margins.header, 720)}" w:footer="${pxToTwips(margins.footer, 720)}" w:gutter="${pxToTwips(margins.gutter, 0)}"/>${columnsXml}</w:sectPr>`;
|
|
9556
9570
|
}
|
|
9557
9571
|
function visitParagraphDeep(paragraph, callback) {
|
|
9558
9572
|
callback(paragraph);
|
|
@@ -12346,18 +12360,48 @@ async function exportEditorDocumentToPdf(document2) {
|
|
|
12346
12360
|
listOrdinals,
|
|
12347
12361
|
page.pageSettings
|
|
12348
12362
|
);
|
|
12349
|
-
|
|
12350
|
-
|
|
12351
|
-
|
|
12352
|
-
page.blocks,
|
|
12353
|
-
document2,
|
|
12354
|
-
originX,
|
|
12355
|
-
page.bodyTop ?? getPageBodyTop(page.pageSettings),
|
|
12356
|
-
contentWidth,
|
|
12357
|
-
fontRegistry,
|
|
12358
|
-
listOrdinals,
|
|
12359
|
-
page.pageSettings
|
|
12363
|
+
const bodyTop = page.bodyTop ?? getPageBodyTop(page.pageSettings);
|
|
12364
|
+
const hasColumns = page.blocks.some(
|
|
12365
|
+
(block) => block.columnIndex !== void 0
|
|
12360
12366
|
);
|
|
12367
|
+
if (hasColumns) {
|
|
12368
|
+
const columnRects = getPageColumnRects(page.pageSettings);
|
|
12369
|
+
const byColumn = /* @__PURE__ */ new Map();
|
|
12370
|
+
for (const block of page.blocks) {
|
|
12371
|
+
const column = block.columnIndex ?? 0;
|
|
12372
|
+
const bucket = byColumn.get(column) ?? [];
|
|
12373
|
+
bucket.push(block);
|
|
12374
|
+
byColumn.set(column, bucket);
|
|
12375
|
+
}
|
|
12376
|
+
for (const [column, columnBlocks] of byColumn) {
|
|
12377
|
+
const rect = columnRects[column] ?? columnRects[0];
|
|
12378
|
+
await drawBlockList(
|
|
12379
|
+
writer,
|
|
12380
|
+
pageIndex,
|
|
12381
|
+
columnBlocks,
|
|
12382
|
+
document2,
|
|
12383
|
+
rect.left,
|
|
12384
|
+
bodyTop,
|
|
12385
|
+
rect.width,
|
|
12386
|
+
fontRegistry,
|
|
12387
|
+
listOrdinals,
|
|
12388
|
+
page.pageSettings
|
|
12389
|
+
);
|
|
12390
|
+
}
|
|
12391
|
+
} else {
|
|
12392
|
+
await drawBlockList(
|
|
12393
|
+
writer,
|
|
12394
|
+
pageIndex,
|
|
12395
|
+
page.blocks,
|
|
12396
|
+
document2,
|
|
12397
|
+
originX,
|
|
12398
|
+
bodyTop,
|
|
12399
|
+
contentWidth,
|
|
12400
|
+
fontRegistry,
|
|
12401
|
+
listOrdinals,
|
|
12402
|
+
page.pageSettings
|
|
12403
|
+
);
|
|
12404
|
+
}
|
|
12361
12405
|
await drawBlockList(
|
|
12362
12406
|
writer,
|
|
12363
12407
|
pageIndex,
|
|
@@ -41189,9 +41233,13 @@ function buildParagraphAndSectionCommands({
|
|
|
41189
41233
|
"sectionBreakContinuous",
|
|
41190
41234
|
() => section.breakContinuous()
|
|
41191
41235
|
),
|
|
41192
|
-
setPageMargins: actionCommand(
|
|
41193
|
-
|
|
41194
|
-
|
|
41236
|
+
setPageMargins: actionCommand(
|
|
41237
|
+
"setPageMargins",
|
|
41238
|
+
(p) => {
|
|
41239
|
+
section.setPageMargins(p ?? {});
|
|
41240
|
+
},
|
|
41241
|
+
() => ({ value: section.getMargins() })
|
|
41242
|
+
)
|
|
41195
41243
|
};
|
|
41196
41244
|
}
|
|
41197
41245
|
function buildTableCommands({
|
|
@@ -41617,6 +41665,12 @@ function createEditorEssentialsRuntimePlugin(options) {
|
|
|
41617
41665
|
},
|
|
41618
41666
|
breakNextPage: () => options.commandsController.applyInsertSectionBreakCommand("nextPage"),
|
|
41619
41667
|
breakContinuous: () => options.commandsController.applyInsertSectionBreakCommand("continuous"),
|
|
41668
|
+
getMargins: () => {
|
|
41669
|
+
var _a, _b;
|
|
41670
|
+
const idx = getActiveSectionIndex(options.state());
|
|
41671
|
+
const section = ((_a = options.state().document.sections) == null ? void 0 : _a[idx]) ?? options.state().document;
|
|
41672
|
+
return (_b = section == null ? void 0 : section.pageSettings) == null ? void 0 : _b.margins;
|
|
41673
|
+
},
|
|
41620
41674
|
setPageMargins: (margins) => {
|
|
41621
41675
|
var _a;
|
|
41622
41676
|
const idx = getActiveSectionIndex(options.state());
|