oasis-editor 0.0.87 → 0.0.88
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-CE15GH_N.js → OasisEditorApp-Bx4I4GCm.js} +59 -9
- package/dist/app/controllers/EditorCommandsController.d.ts +1 -1
- package/dist/app/controllers/useEditorStyle.d.ts +1 -1
- package/dist/assets/{importDocxWorker-C94l6-O5.js → importDocxWorker-BcELKms0.js} +1 -1
- package/dist/core/commands/builtinCommands.d.ts +1 -1
- package/dist/core/commands/publicCommandTypes.d.ts +1 -0
- package/dist/core/model/types/styles.d.ts +8 -0
- package/dist/core/textStyle/textStyleKeys.d.ts +1 -1
- package/dist/{index-DFKc0jbc.js → index-Ds5uOUe8.js} +330 -120
- package/dist/index.d.ts +3 -1
- package/dist/oasis-editor.css +1 -1
- package/dist/oasis-editor.js +50 -49
- package/dist/oasis-editor.umd.cjs +4 -4
- package/dist/plugins/internal/essentialsCapabilities.d.ts +10 -0
- package/dist/ui/app/createAppCommandsController.d.ts +2 -2
- package/dist/ui/app/createEditorCommandRuntime.d.ts +1 -1
- package/dist/ui/app/createEditorInteractionRuntime.d.ts +1 -1
- package/dist/ui/components/Toolbar/StyleGallery.d.ts +9 -0
- package/dist/ui/components/Toolbar/schema/items.d.ts +17 -1
- package/dist/ui/toolbarStyleState.d.ts +2 -1
- 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 textStyleToFontSizePt, aK as PX_PER_POINT, aL as DEFAULT_FONT_SIZE_PX, aM as isDoubleUnderlineStyle, aN as isWavyUnderlineStyle, aO as underlineStyleLineWidthPx, aP as underlineStyleDashArray, aQ as resolveListLabel, aR as getListLabelInset, aS as getAlignedListLabelInset, aT as getParagraphBorderInsets, aU as buildSegmentTable, aV as buildCanvasTableLayout, aW as normalizeFamily, aX as ROBOTO_FONT_FILES, aY as loadFontAsset, aZ as OFFICE_COMPAT_FONT_FAMILIES, a_ as buildSfnt, a$ as defaultFontDecoderRegistry, b0 as SfntFontProgram, b1 as collectPdfFontFamilies, b2 as projectDocumentLayout, b3 as getPageContentWidth, b4 as getPageHeaderZoneTop, b5 as getPageBodyTop, b6 as getPageColumnRects, b7 as findFootnoteReference, b8 as FOOTNOTE_MARKER_GUTTER_PX, b9 as resolveImporterForFile, ba as getDocumentSectionsCanonical, bb as getDocumentParagraphsCanonical, bc as getDocumentParagraphs, bd as getDocumentPageSettings, be as getTableCellContentWidthForParagraph, bf as on, bg as debounce, bh as unwrap, bi as perfTimer, bj as getRunTextBox, bk as createEditorDocument, bl as resolveResizedDimensions, bm as resolveTextBoxRenderHeight, bn as getToolbarStyleState, bo as getCachedCanvasImage, bp as measureParagraphMinContentWidthPx, bq as getEditableBlocksForZone, br as findParagraphLocation, bs as createSectionBoundaryParagraph, bt as normalizePageSettings, bu as DEFAULT_EDITOR_PAGE_SETTINGS, bv as markStart, bw as markEnd, bx as getParagraphEntries, by as getParagraphById, bz as createEditorFootnote, bA as createFootnoteReferenceRun, bB as renumberFootnotes, bC as getFootnoteDisplayMarker, bD as getHeadingLevel, bE as preciseFontModeVersion, bF as isPreciseFontModeEnabled, bG as
|
|
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 textStyleToFontSizePt, aK as PX_PER_POINT, aL as DEFAULT_FONT_SIZE_PX, aM as isDoubleUnderlineStyle, aN as isWavyUnderlineStyle, aO as underlineStyleLineWidthPx, aP as underlineStyleDashArray, aQ as resolveListLabel, aR as getListLabelInset, aS as getAlignedListLabelInset, aT as getParagraphBorderInsets, aU as buildSegmentTable, aV as buildCanvasTableLayout, aW as normalizeFamily, aX as ROBOTO_FONT_FILES, aY as loadFontAsset, aZ as OFFICE_COMPAT_FONT_FAMILIES, a_ as buildSfnt, a$ as defaultFontDecoderRegistry, b0 as SfntFontProgram, b1 as collectPdfFontFamilies, b2 as projectDocumentLayout, b3 as getPageContentWidth, b4 as getPageHeaderZoneTop, b5 as getPageBodyTop, b6 as getPageColumnRects, b7 as findFootnoteReference, b8 as FOOTNOTE_MARKER_GUTTER_PX, b9 as resolveImporterForFile, ba as getDocumentSectionsCanonical, bb as getDocumentParagraphsCanonical, bc as getDocumentParagraphs, bd as getDocumentPageSettings, be as getTableCellContentWidthForParagraph, bf as on, bg as debounce, bh as unwrap, bi as perfTimer, bj as getRunTextBox, bk as createEditorDocument, bl as resolveResizedDimensions, bm as resolveTextBoxRenderHeight, bn as getToolbarStyleState, bo as getCachedCanvasImage, bp as measureParagraphMinContentWidthPx, bq as getEditableBlocksForZone, br as findParagraphLocation, bs as createSectionBoundaryParagraph, bt as normalizePageSettings, bu as DEFAULT_EDITOR_PAGE_SETTINGS, bv as markStart, bw as markEnd, bx as getParagraphEntries, by as getParagraphById, bz as createEditorFootnote, bA as createFootnoteReferenceRun, bB as renumberFootnotes, bC as getFootnoteDisplayMarker, bD as getHeadingLevel, bE as preciseFontModeVersion, bF as isPreciseFontModeEnabled, bG as resolveNamedTextStyle, bH as togglePreciseFontMode, bI as nextFontSizePt, bJ as previousFontSizePt, bK as fontSizePtToPx, bL as createDefaultToolbarPreset, bM as MenuRegistry, bN as createToolbarRegistry, bO as Editor, bP as resolveCommandRef, bQ as commandRefName, bR as createOasisEditorClient, bS as createEditorZoom, bT as startLongTaskObserver, bU as installGlobalReport, bV as applyStoredPreciseFontPreference, bW as getWelcomeSeen, bX as isLocalFontAccessSupported, bY as EDITOR_SCROLL_PADDING_PX, bZ as Toolbar, b_ as OasisEditorLoading, b$ as I18nProvider, c0 as createTranslator, c1 as createEditorLogger, c2 as registerDomStatsSurface } from "./index-Ds5uOUe8.js";
|
|
5
5
|
function cloneStyle(style2) {
|
|
6
6
|
return style2 ? { ...style2 } : void 0;
|
|
7
7
|
}
|
|
@@ -34291,7 +34291,9 @@ function serializeConditionalTcPr(cond) {
|
|
|
34291
34291
|
["bottom", b.borderBottom],
|
|
34292
34292
|
["right", b.borderRight]
|
|
34293
34293
|
];
|
|
34294
|
-
const borderXml = edges.filter(
|
|
34294
|
+
const borderXml = edges.filter(
|
|
34295
|
+
(entry) => entry[1] != null
|
|
34296
|
+
).map(([name, border]) => `<w:${name} ${serializeDocxBorderAttrs(border)}`).join("");
|
|
34295
34297
|
if (borderXml) {
|
|
34296
34298
|
parts.push(`<w:tcBorders>${borderXml}</w:tcBorders>`);
|
|
34297
34299
|
}
|
|
@@ -34325,6 +34327,22 @@ function serializeNamedStyle(style2) {
|
|
|
34325
34327
|
if (style2.nextStyle) {
|
|
34326
34328
|
parts.push(`<w:next w:val="${escapeXml(style2.nextStyle)}"/>`);
|
|
34327
34329
|
}
|
|
34330
|
+
if (style2.uiPriority !== void 0) {
|
|
34331
|
+
parts.push(
|
|
34332
|
+
`<w:uiPriority w:val="${Math.max(0, Math.floor(style2.uiPriority))}"/>`
|
|
34333
|
+
);
|
|
34334
|
+
}
|
|
34335
|
+
if (style2.qFormat !== void 0) {
|
|
34336
|
+
parts.push(`<w:qFormat w:val="${style2.qFormat ? "1" : "0"}"/>`);
|
|
34337
|
+
}
|
|
34338
|
+
if (style2.semiHidden !== void 0) {
|
|
34339
|
+
parts.push(`<w:semiHidden w:val="${style2.semiHidden ? "1" : "0"}"/>`);
|
|
34340
|
+
}
|
|
34341
|
+
if (style2.unhideWhenUsed !== void 0) {
|
|
34342
|
+
parts.push(
|
|
34343
|
+
`<w:unhideWhenUsed w:val="${style2.unhideWhenUsed ? "1" : "0"}"/>`
|
|
34344
|
+
);
|
|
34345
|
+
}
|
|
34328
34346
|
if (style2.type === "paragraph" || style2.type === "table") {
|
|
34329
34347
|
if (style2.paragraphStyle) {
|
|
34330
34348
|
const pPr = serializeParagraphStyleXml(style2.paragraphStyle);
|
|
@@ -41460,7 +41478,8 @@ function createEditorStyleController(deps) {
|
|
|
41460
41478
|
color: pending.color ?? resolved.color,
|
|
41461
41479
|
highlight: pending.highlight ?? resolved.highlight,
|
|
41462
41480
|
textShading: pending.shading ?? resolved.textShading,
|
|
41463
|
-
link: pending.link ?? resolved.link
|
|
41481
|
+
link: pending.link ?? resolved.link,
|
|
41482
|
+
characterStyleId: pending.styleId !== void 0 && pending.styleId !== null ? String(pending.styleId) : resolved.characterStyleId
|
|
41464
41483
|
};
|
|
41465
41484
|
};
|
|
41466
41485
|
const applyToolbarValueStyleCommand = (key, value) => {
|
|
@@ -46308,6 +46327,11 @@ function buildCoreFormattingCommands({
|
|
|
46308
46327
|
(p) => formatting.setStyleId(String(p)),
|
|
46309
46328
|
() => s().styleId || "normal"
|
|
46310
46329
|
),
|
|
46330
|
+
setCharacterStyleId: valueCommand(
|
|
46331
|
+
"setCharacterStyleId",
|
|
46332
|
+
(p) => formatting.setCharacterStyleId(String(p)),
|
|
46333
|
+
() => s().characterStyleId || ""
|
|
46334
|
+
),
|
|
46311
46335
|
setUnderlineStyle: valueCommand(
|
|
46312
46336
|
"setUnderlineStyle",
|
|
46313
46337
|
(p) => (formatting.setUnderlineStyle(p || null), true),
|
|
@@ -46800,18 +46824,41 @@ function createEditorEssentialsRuntimePlugin(options) {
|
|
|
46800
46824
|
setHighlight: (value) => (options.styleController.applyToolbarValueStyleCommand("highlight", value), true),
|
|
46801
46825
|
setTextShading: (value) => (options.styleController.applyToolbarValueStyleCommand("shading", value), true),
|
|
46802
46826
|
setStyleId: (value) => (options.commandsController.handleStyleChange(value), true),
|
|
46827
|
+
setCharacterStyleId: (value) => (options.styleController.applyToolbarValueStyleCommand(
|
|
46828
|
+
"styleId",
|
|
46829
|
+
value || null
|
|
46830
|
+
), true),
|
|
46803
46831
|
setUnderlineStyle: (value) => options.styleController.applyToolbarValueStyleCommand("underlineStyle", value)
|
|
46804
46832
|
};
|
|
46805
46833
|
const essentialsDocument = {
|
|
46806
46834
|
documentStyles: () => {
|
|
46807
|
-
var _a;
|
|
46808
|
-
|
|
46809
|
-
|
|
46835
|
+
var _a, _b;
|
|
46836
|
+
const document2 = options.state().document;
|
|
46837
|
+
const styles = (document2 == null ? void 0 : document2.styles) ?? {};
|
|
46838
|
+
const usedStyleIds = /* @__PURE__ */ new Set();
|
|
46839
|
+
for (const paragraph of getDocumentParagraphs(document2)) {
|
|
46840
|
+
if ((_a = paragraph.style) == null ? void 0 : _a.styleId) usedStyleIds.add(paragraph.style.styleId);
|
|
46841
|
+
for (const run of paragraph.runs) {
|
|
46842
|
+
if ((_b = run.styles) == null ? void 0 : _b.styleId) usedStyleIds.add(run.styles.styleId);
|
|
46843
|
+
}
|
|
46844
|
+
}
|
|
46845
|
+
return Object.values(styles).map((style2) => {
|
|
46846
|
+
var _a2;
|
|
46847
|
+
const preview = resolveNamedTextStyle(style2.id, styles);
|
|
46810
46848
|
return {
|
|
46811
46849
|
id: style2.id,
|
|
46812
46850
|
name: style2.name,
|
|
46813
|
-
|
|
46814
|
-
|
|
46851
|
+
type: style2.type,
|
|
46852
|
+
qFormat: style2.qFormat,
|
|
46853
|
+
uiPriority: style2.uiPriority,
|
|
46854
|
+
semiHidden: style2.semiHidden,
|
|
46855
|
+
unhideWhenUsed: style2.unhideWhenUsed,
|
|
46856
|
+
isUsed: usedStyleIds.has(style2.id),
|
|
46857
|
+
fontFamily: ((_a2 = preview.fontFamily) == null ? void 0 : _a2.trim()) || void 0,
|
|
46858
|
+
fontSize: typeof preview.fontSize === "number" ? preview.fontSize : void 0,
|
|
46859
|
+
color: preview.color ?? void 0,
|
|
46860
|
+
bold: preview.bold ?? void 0,
|
|
46861
|
+
italic: preview.italic ?? void 0
|
|
46815
46862
|
};
|
|
46816
46863
|
});
|
|
46817
46864
|
},
|
|
@@ -47080,7 +47127,10 @@ function createEditorEssentialsRuntimePlugin(options) {
|
|
|
47080
47127
|
(current) => setTableCellStyleValue(current, "horizontalAlign", "right"),
|
|
47081
47128
|
MERGE_KEYS.tableAlign
|
|
47082
47129
|
),
|
|
47083
|
-
setCellWidth: (width) => apply(
|
|
47130
|
+
setCellWidth: (width) => apply(
|
|
47131
|
+
(current) => setTableCellWidth(current, width),
|
|
47132
|
+
MERGE_KEYS.tableCellWidth
|
|
47133
|
+
),
|
|
47084
47134
|
insert: (rows, cols) => options.tableOps.insertTableCommand(rows, cols)
|
|
47085
47135
|
};
|
|
47086
47136
|
})();
|
|
@@ -17,7 +17,7 @@ export interface EditorCommandsControllerDeps extends EditorTransactionPort, Foc
|
|
|
17
17
|
}
|
|
18
18
|
export declare function createEditorCommandsController(deps: EditorCommandsControllerDeps): {
|
|
19
19
|
applyBooleanStyleCommand: (key: BooleanStyleKey) => void;
|
|
20
|
-
applyValueStyleCommand: <K extends "fontFamily" | "fontSize" | "color" | "highlight" | "shading" | "language" | "textEffect" | "link" | "underlineStyle">(key: K, value: EditorTextStyle[K] | null) => void;
|
|
20
|
+
applyValueStyleCommand: <K extends "styleId" | "fontFamily" | "fontSize" | "color" | "highlight" | "shading" | "language" | "textEffect" | "link" | "underlineStyle">(key: K, value: EditorTextStyle[K] | null) => void;
|
|
21
21
|
applyChangeTextCaseCommand: (mode: TextCaseMode) => void;
|
|
22
22
|
applyClearFormattingCommand: () => void;
|
|
23
23
|
applyParagraphStyleCommand: <K extends ParagraphStyleKey>(key: K, value: EditorParagraphStyle[K] | null) => void;
|
|
@@ -2,7 +2,7 @@ import { EditorState, EditorTextStyle } from '../../core/model.js';
|
|
|
2
2
|
import { ToolbarStyleState, BooleanStyleKey } from '../../ui/toolbarStyleState.js';
|
|
3
3
|
import { createEditorCommandsController } from './EditorCommandsController.js';
|
|
4
4
|
|
|
5
|
-
type ValueStyleKey = "fontFamily" | "fontSize" | "color" | "highlight" | "shading" | "language" | "textEffect" | "link" | "underlineStyle";
|
|
5
|
+
type ValueStyleKey = "styleId" | "fontFamily" | "fontSize" | "color" | "highlight" | "shading" | "language" | "textEffect" | "link" | "underlineStyle";
|
|
6
6
|
export interface UseEditorStyleProps {
|
|
7
7
|
state: () => EditorState;
|
|
8
8
|
commandsController: () => ReturnType<typeof createEditorCommandsController>;
|