oasis-editor 0.0.8 → 0.0.10
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-PbwiUucf.js → OasisEditorApp-B31W8Nmj.js} +186 -3
- package/dist/app/controllers/EditorCommandsController.d.ts +3 -0
- package/dist/core/commands/builtinCommands.d.ts +1 -1
- package/dist/core/commands/publicCommandTypes.d.ts +5 -0
- package/dist/core/commands/text.d.ts +15 -0
- package/dist/i18n/locales/en.d.ts +9 -0
- package/dist/i18n/locales/pt-BR.d.ts +9 -0
- package/dist/{index-BlQocUZB.js → index--RsWcVrx.js} +274 -147
- package/dist/oasis-editor.js +54 -54
- package/dist/oasis-editor.umd.cjs +4 -4
- package/dist/plugins/internal/createEssentialsPlugin.d.ts +9 -0
- package/dist/plugins/internal/essentialsCommandGroups.d.ts +4 -2
- package/dist/ui/fontSizeUnits.d.ts +4 -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 createEditorStyledRun, b as getParagraphLength, d as getParagraphText, e as getActiveZone, f as getDocumentSections, h as getActiveSectionIndex, p as positionToParagraphOffset, i as paragraphOffsetToPosition, j as clampPosition, k as findParagraphIndex, l as createCollapsedSelection, m as isSelectionCollapsed, o as createEditorParagraph, q as getBlockParagraphs, r as findParagraphTableLocation, s as buildTableCellLayout, t as createEditorTableCell, u as createEditorTable, v as createEditorTableRow, w as underlineStyleToCssDecorationStyle, x as resolveImageSrc, y as createEditorFootnote, z as createFootnoteReferenceRun, A as renumberFootnotes, B as iterateFootnoteReferenceRuns, C as getFootnoteDisplayMarker, D as createSignal, E as createEffect, F as onCleanup, G as buildCanvasLayoutSnapshot, H as on, I as onMount, J as debounce, K as unwrap, L as getDocumentParagraphs, M as getDocumentSectionsCanonical, N as createEditorDocument, O as getPageContentWidth, P as getDocumentPageSettings, Q as getTableCellContentWidthForParagraph, R as resolveResizedDimensions, S as resolveTextBoxRenderHeight, T as resolveEffectiveParagraphStyle, U as resolveEffectiveTextStyleForParagraph, V as iterateEndnoteReferenceRuns, W as JSZip, X as imageContentTypeDefaults, Y as imageExtensionFromMime, Z as pxToPt$1, _ as textStyleToFontSizePt, $ as PX_PER_POINT, a0 as DEFAULT_FONT_SIZE_PX, a1 as isDoubleUnderlineStyle, a2 as isWavyUnderlineStyle, a3 as underlineStyleLineWidthPx, a4 as underlineStyleDashArray, a5 as getListLabelInset, a6 as getParagraphBorderInsets, a7 as buildSegmentTable, a8 as buildCanvasTableLayout, a9 as normalizeFamily, aa as ROBOTO_FONT_FILES, ab as loadFontAsset, ac as OFFICE_COMPAT_FONT_FAMILIES, ad as buildSfnt, ae as defaultFontDecoderRegistry, af as SfntFontProgram, ag as collectPdfFontFamilies, ah as projectDocumentLayout, ai as getPageHeaderZoneTop, aj as getPageBodyTop, ak as findFootnoteReference, al as FOOTNOTE_MARKER_GUTTER_PX, am as resolveImporterForFile, an as createEditorStateFromDocument, ao as getDocumentParagraphsCanonical, ap as getToolbarStyleState, aq as STANDARD_FONT_SIZES_PT, ar as fontSizePxToPt, as as probeLocalFontFamilies, at as createInitialEditorState, au as parseFontSizePtToPx, av as formatFontSizePt, aw as listKindForTag, ax as isParagraphTag, ay as collectInlineRuns, az as parseParagraphStyle, aA as t, aB as preciseFontModeVersion, aC as isPreciseFontModeEnabled, aD as togglePreciseFontMode, aE as
|
|
4
|
+
import { n as normalizeSelection, g as getParagraphs, c as createEditorParagraphFromRuns, a as createEditorStyledRun, b as getParagraphLength, d as getParagraphText, e as getActiveZone, f as getDocumentSections, h as getActiveSectionIndex, p as positionToParagraphOffset, i as paragraphOffsetToPosition, j as clampPosition, k as findParagraphIndex, l as createCollapsedSelection, m as isSelectionCollapsed, o as createEditorParagraph, q as getBlockParagraphs, r as findParagraphTableLocation, s as buildTableCellLayout, t as createEditorTableCell, u as createEditorTable, v as createEditorTableRow, w as underlineStyleToCssDecorationStyle, x as resolveImageSrc, y as createEditorFootnote, z as createFootnoteReferenceRun, A as renumberFootnotes, B as iterateFootnoteReferenceRuns, C as getFootnoteDisplayMarker, D as createSignal, E as createEffect, F as onCleanup, G as buildCanvasLayoutSnapshot, H as on, I as onMount, J as debounce, K as unwrap, L as getDocumentParagraphs, M as getDocumentSectionsCanonical, N as createEditorDocument, O as getPageContentWidth, P as getDocumentPageSettings, Q as getTableCellContentWidthForParagraph, R as resolveResizedDimensions, S as resolveTextBoxRenderHeight, T as resolveEffectiveParagraphStyle, U as resolveEffectiveTextStyleForParagraph, V as iterateEndnoteReferenceRuns, W as JSZip, X as imageContentTypeDefaults, Y as imageExtensionFromMime, Z as pxToPt$1, _ as textStyleToFontSizePt, $ as PX_PER_POINT, a0 as DEFAULT_FONT_SIZE_PX, a1 as isDoubleUnderlineStyle, a2 as isWavyUnderlineStyle, a3 as underlineStyleLineWidthPx, a4 as underlineStyleDashArray, a5 as getListLabelInset, a6 as getParagraphBorderInsets, a7 as buildSegmentTable, a8 as buildCanvasTableLayout, a9 as normalizeFamily, aa as ROBOTO_FONT_FILES, ab as loadFontAsset, ac as OFFICE_COMPAT_FONT_FAMILIES, ad as buildSfnt, ae as defaultFontDecoderRegistry, af as SfntFontProgram, ag as collectPdfFontFamilies, ah as projectDocumentLayout, ai as getPageHeaderZoneTop, aj as getPageBodyTop, ak as findFootnoteReference, al as FOOTNOTE_MARKER_GUTTER_PX, am as resolveImporterForFile, an as createEditorStateFromDocument, ao as getDocumentParagraphsCanonical, ap as getToolbarStyleState, aq as STANDARD_FONT_SIZES_PT, ar as fontSizePxToPt, as as probeLocalFontFamilies, at as createInitialEditorState, au as parseFontSizePtToPx, av as formatFontSizePt, aw as listKindForTag, ax as isParagraphTag, ay as collectInlineRuns, az as parseParagraphStyle, aA as t, aB as preciseFontModeVersion, aC as isPreciseFontModeEnabled, aD as togglePreciseFontMode, aE as nextFontSizePt, aF as previousFontSizePt, aG as fontSizePtToPx, aH as createDefaultToolbarPreset, aI as defaultMenuItems, aJ as MenuRegistry, aK as createToolbarRegistry, aL as Editor, aM as resolveCommandRef, aN as commandRefName, aO as InlineShell, aP as BalloonShell, aQ as DocumentShell, aR as createMemo, aS as getCaretRectFromSnapshot, aT as getParagraphRectFromSnapshot, aU as createComponent, aV as CaretOverlay, aW as Show, aX as createRenderEffect, aY as style, aZ as setAttribute, a_ as setStyleProperty, a$ as memo, b0 as template, b1 as insert, b2 as use, b3 as addEventListener, b4 as Dialog, b5 as delegateEvents, b6 as className, b7 as For, b8 as UNDERLINE_STYLE_OPTIONS, b9 as Tabs, ba as measureParagraphMinContentWidthPx, bb as getEditableBlocksForZone, bc as findParagraphLocation, bd as createSectionBoundaryParagraph, be as normalizePageSettings, bf as DEFAULT_EDITOR_PAGE_SETTINGS, bg as markStart, bh as markEnd, bi as getParagraphEntries, bj as getParagraphById, bk as PluginUiHost, bl as OasisEditorEditor, bm as perfTimer, bn as OasisBrandMark, bo as setPreciseFontPreference, bp as setWelcomeSeen, bq as enablePreciseFontMode, br as createOasisEditorClient, bs as setLocale, bt as startLongTaskObserver, bu as installGlobalReport, bv as applyStoredPreciseFontPreference, bw as getWelcomeSeen, bx as isLocalFontAccessSupported, by as EDITOR_SCROLL_PADDING_PX, bz as Toolbar, bA as OasisEditorLoading, bB as createEditorLogger, bC as getCachedCanvasImage, bD as registerDomStatsSurface } from "./index--RsWcVrx.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) {
|
|
@@ -1739,6 +1739,121 @@ function toggleTextStyle(state, key) {
|
|
|
1739
1739
|
preserveSelectionByParagraphOffsets(nextParagraphs, normalized)
|
|
1740
1740
|
);
|
|
1741
1741
|
}
|
|
1742
|
+
function isLetter(char) {
|
|
1743
|
+
return new RegExp("\\p{L}", "u").test(char);
|
|
1744
|
+
}
|
|
1745
|
+
function toSentenceCase(text) {
|
|
1746
|
+
let result = "";
|
|
1747
|
+
let capitalizeNext = true;
|
|
1748
|
+
for (const char of text.toLowerCase()) {
|
|
1749
|
+
if (capitalizeNext && isLetter(char)) {
|
|
1750
|
+
result += char.toUpperCase();
|
|
1751
|
+
capitalizeNext = false;
|
|
1752
|
+
} else {
|
|
1753
|
+
result += char;
|
|
1754
|
+
if (char === "." || char === "!" || char === "?") {
|
|
1755
|
+
capitalizeNext = true;
|
|
1756
|
+
}
|
|
1757
|
+
}
|
|
1758
|
+
}
|
|
1759
|
+
return result;
|
|
1760
|
+
}
|
|
1761
|
+
function toCapitalizedWords(text) {
|
|
1762
|
+
let result = "";
|
|
1763
|
+
let prevIsLetter = false;
|
|
1764
|
+
for (const char of text) {
|
|
1765
|
+
const letter = isLetter(char);
|
|
1766
|
+
result += letter && !prevIsLetter ? char.toUpperCase() : char;
|
|
1767
|
+
prevIsLetter = letter;
|
|
1768
|
+
}
|
|
1769
|
+
return result;
|
|
1770
|
+
}
|
|
1771
|
+
function toToggledCase(text) {
|
|
1772
|
+
let result = "";
|
|
1773
|
+
for (const char of text) {
|
|
1774
|
+
const upper = char.toUpperCase();
|
|
1775
|
+
const lower = char.toLowerCase();
|
|
1776
|
+
if (char === lower && char !== upper) {
|
|
1777
|
+
result += upper;
|
|
1778
|
+
} else if (char === upper && char !== lower) {
|
|
1779
|
+
result += lower;
|
|
1780
|
+
} else {
|
|
1781
|
+
result += char;
|
|
1782
|
+
}
|
|
1783
|
+
}
|
|
1784
|
+
return result;
|
|
1785
|
+
}
|
|
1786
|
+
function applyCaseTransform(text, mode) {
|
|
1787
|
+
switch (mode) {
|
|
1788
|
+
case "lower":
|
|
1789
|
+
return text.toLowerCase();
|
|
1790
|
+
case "upper":
|
|
1791
|
+
return text.toUpperCase();
|
|
1792
|
+
case "capitalize":
|
|
1793
|
+
return toCapitalizedWords(text);
|
|
1794
|
+
case "toggle":
|
|
1795
|
+
return toToggledCase(text);
|
|
1796
|
+
case "sentence":
|
|
1797
|
+
default:
|
|
1798
|
+
return toSentenceCase(text);
|
|
1799
|
+
}
|
|
1800
|
+
}
|
|
1801
|
+
function transformSelectedText(state, transform) {
|
|
1802
|
+
const normalized = normalizeSelection(state);
|
|
1803
|
+
if (normalized.isCollapsed) {
|
|
1804
|
+
return state;
|
|
1805
|
+
}
|
|
1806
|
+
const paragraphs = getParagraphs(state);
|
|
1807
|
+
const nextParagraphs = paragraphs.map((paragraph, paragraphIndex) => {
|
|
1808
|
+
if (paragraphIndex < normalized.startIndex || paragraphIndex > normalized.endIndex) {
|
|
1809
|
+
return paragraph;
|
|
1810
|
+
}
|
|
1811
|
+
const startOffset = paragraphIndex === normalized.startIndex ? normalized.startParagraphOffset : 0;
|
|
1812
|
+
const endOffset = paragraphIndex === normalized.endIndex ? normalized.endParagraphOffset : getParagraphLength(paragraph);
|
|
1813
|
+
const selectedText = sliceRuns(paragraph, startOffset, endOffset).map((run) => run.text).join("");
|
|
1814
|
+
const transformed = transform(selectedText);
|
|
1815
|
+
let cursor = 0;
|
|
1816
|
+
return mapRunsInRange(paragraph, startOffset, endOffset, (run) => {
|
|
1817
|
+
const length = run.text.length;
|
|
1818
|
+
const nextText = transformed.slice(cursor, cursor + length);
|
|
1819
|
+
cursor += length;
|
|
1820
|
+
return { ...run, text: nextText };
|
|
1821
|
+
});
|
|
1822
|
+
});
|
|
1823
|
+
return cloneStateWithParagraphs(
|
|
1824
|
+
state,
|
|
1825
|
+
nextParagraphs,
|
|
1826
|
+
preserveSelectionByParagraphOffsets(nextParagraphs, normalized)
|
|
1827
|
+
);
|
|
1828
|
+
}
|
|
1829
|
+
function changeSelectedTextCase(state, mode) {
|
|
1830
|
+
return transformSelectedText(state, (text) => applyCaseTransform(text, mode));
|
|
1831
|
+
}
|
|
1832
|
+
function clearSelectedTextFormatting(state) {
|
|
1833
|
+
const normalized = normalizeSelection(state);
|
|
1834
|
+
if (normalized.isCollapsed) {
|
|
1835
|
+
return state;
|
|
1836
|
+
}
|
|
1837
|
+
const paragraphs = getParagraphs(state);
|
|
1838
|
+
const nextParagraphs = paragraphs.map((paragraph, paragraphIndex) => {
|
|
1839
|
+
if (paragraphIndex < normalized.startIndex || paragraphIndex > normalized.endIndex) {
|
|
1840
|
+
return paragraph;
|
|
1841
|
+
}
|
|
1842
|
+
const startOffset = paragraphIndex === normalized.startIndex ? normalized.startParagraphOffset : 0;
|
|
1843
|
+
const endOffset = paragraphIndex === normalized.endIndex ? normalized.endParagraphOffset : getParagraphLength(paragraph);
|
|
1844
|
+
return mapRunsInRange(paragraph, startOffset, endOffset, (run) => {
|
|
1845
|
+
var _a;
|
|
1846
|
+
const link = (_a = run.styles) == null ? void 0 : _a.link;
|
|
1847
|
+
const styles = link != null && link !== "" ? { link } : {};
|
|
1848
|
+
return { ...run, styles };
|
|
1849
|
+
});
|
|
1850
|
+
});
|
|
1851
|
+
return cloneStateWithParagraphs(
|
|
1852
|
+
state,
|
|
1853
|
+
nextParagraphs,
|
|
1854
|
+
preserveSelectionByParagraphOffsets(nextParagraphs, normalized)
|
|
1855
|
+
);
|
|
1856
|
+
}
|
|
1742
1857
|
function setTextStyleValue(state, key, value) {
|
|
1743
1858
|
const normalized = normalizeSelection(state);
|
|
1744
1859
|
if (normalized.isCollapsed) {
|
|
@@ -3934,6 +4049,28 @@ function createEditorCommandsController(deps) {
|
|
|
3934
4049
|
);
|
|
3935
4050
|
focusInput();
|
|
3936
4051
|
};
|
|
4052
|
+
const applyChangeTextCaseCommand = (mode) => {
|
|
4053
|
+
if (selectionCollapsed()) {
|
|
4054
|
+
return;
|
|
4055
|
+
}
|
|
4056
|
+
clearPreferredColumn();
|
|
4057
|
+
resetTransactionGrouping();
|
|
4058
|
+
applySelectionAwareTextCommand(
|
|
4059
|
+
(current) => changeSelectedTextCase(current, mode)
|
|
4060
|
+
);
|
|
4061
|
+
focusInput();
|
|
4062
|
+
};
|
|
4063
|
+
const applyClearFormattingCommand = () => {
|
|
4064
|
+
if (selectionCollapsed()) {
|
|
4065
|
+
return;
|
|
4066
|
+
}
|
|
4067
|
+
clearPreferredColumn();
|
|
4068
|
+
resetTransactionGrouping();
|
|
4069
|
+
applySelectionAwareTextCommand(
|
|
4070
|
+
(current) => clearSelectedTextFormatting(current)
|
|
4071
|
+
);
|
|
4072
|
+
focusInput();
|
|
4073
|
+
};
|
|
3937
4074
|
const applyParagraphStyleCommand = (key, value) => {
|
|
3938
4075
|
clearPreferredColumn();
|
|
3939
4076
|
resetTransactionGrouping();
|
|
@@ -4083,6 +4220,8 @@ function createEditorCommandsController(deps) {
|
|
|
4083
4220
|
return {
|
|
4084
4221
|
applyBooleanStyleCommand,
|
|
4085
4222
|
applyValueStyleCommand,
|
|
4223
|
+
applyChangeTextCaseCommand,
|
|
4224
|
+
applyClearFormattingCommand,
|
|
4086
4225
|
applyParagraphStyleCommand,
|
|
4087
4226
|
toggleParagraphFlagCommand,
|
|
4088
4227
|
applyParagraphListCommand,
|
|
@@ -39935,11 +40074,13 @@ function numOrNull(payload) {
|
|
|
39935
40074
|
function buildCoreFormattingCommands({
|
|
39936
40075
|
gate,
|
|
39937
40076
|
style: style2,
|
|
40077
|
+
selection,
|
|
39938
40078
|
history,
|
|
39939
40079
|
formatting,
|
|
39940
40080
|
link,
|
|
39941
40081
|
command,
|
|
39942
|
-
valueCommand
|
|
40082
|
+
valueCommand,
|
|
40083
|
+
actionCommand
|
|
39943
40084
|
}) {
|
|
39944
40085
|
const s = style2.state;
|
|
39945
40086
|
return {
|
|
@@ -40040,6 +40181,18 @@ function buildCoreFormattingCommands({
|
|
|
40040
40181
|
},
|
|
40041
40182
|
() => formatFontSizePt(s().fontSize)
|
|
40042
40183
|
),
|
|
40184
|
+
increaseFontSize: command("increaseFontSize", formatting.increaseFontSize),
|
|
40185
|
+
decreaseFontSize: command("decreaseFontSize", formatting.decreaseFontSize),
|
|
40186
|
+
changeTextCase: actionCommand(
|
|
40187
|
+
"changeTextCase",
|
|
40188
|
+
(p) => {
|
|
40189
|
+
formatting.changeTextCase(p ?? "sentence");
|
|
40190
|
+
},
|
|
40191
|
+
() => ({
|
|
40192
|
+
isEnabled: gate.isCommandEnabled("changeTextCase") && !selection.isCollapsed()
|
|
40193
|
+
})
|
|
40194
|
+
),
|
|
40195
|
+
clearFormatting: command("clearFormatting", formatting.clearFormatting),
|
|
40043
40196
|
setColor: valueCommand(
|
|
40044
40197
|
"setColor",
|
|
40045
40198
|
(p) => formatting.setColor(p ?? null),
|
|
@@ -40327,11 +40480,13 @@ function createEssentialsPlugin(deps) {
|
|
|
40327
40480
|
...buildCoreFormattingCommands({
|
|
40328
40481
|
gate: deps.gate,
|
|
40329
40482
|
style: deps.style,
|
|
40483
|
+
selection: deps.selection,
|
|
40330
40484
|
history: deps.history,
|
|
40331
40485
|
formatting: deps.formatting,
|
|
40332
40486
|
link: deps.link,
|
|
40333
40487
|
command,
|
|
40334
|
-
valueCommand
|
|
40488
|
+
valueCommand,
|
|
40489
|
+
actionCommand
|
|
40335
40490
|
}),
|
|
40336
40491
|
...buildDocumentAndBrowserCommands({
|
|
40337
40492
|
gate: deps.gate,
|
|
@@ -40364,6 +40519,21 @@ function createEditorEssentialsRuntimePlugin(options) {
|
|
|
40364
40519
|
const essentialsStyle = {
|
|
40365
40520
|
state: () => options.styleController.toolbarStyleState()
|
|
40366
40521
|
};
|
|
40522
|
+
const essentialsSelection = {
|
|
40523
|
+
isCollapsed: () => isSelectionCollapsed(options.state().selection)
|
|
40524
|
+
};
|
|
40525
|
+
const stepFontSize = (direction) => {
|
|
40526
|
+
const currentPx = Number(
|
|
40527
|
+
options.styleController.toolbarStyleState().fontSize
|
|
40528
|
+
);
|
|
40529
|
+
const currentPt = Number.isFinite(currentPx) && currentPx > 0 ? fontSizePxToPt(currentPx) : 11;
|
|
40530
|
+
const nextPt = direction === "increase" ? nextFontSizePt(currentPt) : previousFontSizePt(currentPt);
|
|
40531
|
+
options.styleController.applyToolbarValueStyleCommand(
|
|
40532
|
+
"fontSize",
|
|
40533
|
+
fontSizePtToPx(nextPt)
|
|
40534
|
+
);
|
|
40535
|
+
return true;
|
|
40536
|
+
};
|
|
40367
40537
|
const essentialsHistory = {
|
|
40368
40538
|
canUndo: () => options.undoStack().length > 0,
|
|
40369
40539
|
canRedo: () => options.redoStack().length > 0,
|
|
@@ -40453,6 +40623,18 @@ function createEditorEssentialsRuntimePlugin(options) {
|
|
|
40453
40623
|
value
|
|
40454
40624
|
), true),
|
|
40455
40625
|
setFontSize: (value) => (options.styleController.applyToolbarValueStyleCommand("fontSize", value), true),
|
|
40626
|
+
increaseFontSize: () => stepFontSize("increase"),
|
|
40627
|
+
decreaseFontSize: () => stepFontSize("decrease"),
|
|
40628
|
+
changeTextCase: (mode) => (options.commandsController.applyChangeTextCaseCommand(mode), true),
|
|
40629
|
+
clearFormatting: () => {
|
|
40630
|
+
if (isSelectionCollapsed(options.state().selection)) {
|
|
40631
|
+
options.styleController.clearPendingCaretTextStyle();
|
|
40632
|
+
options.focusInput();
|
|
40633
|
+
return true;
|
|
40634
|
+
}
|
|
40635
|
+
options.commandsController.applyClearFormattingCommand();
|
|
40636
|
+
return true;
|
|
40637
|
+
},
|
|
40456
40638
|
setColor: (value) => (options.styleController.applyToolbarValueStyleCommand("color", value), true),
|
|
40457
40639
|
setHighlight: (value) => (options.styleController.applyToolbarValueStyleCommand("highlight", value), true),
|
|
40458
40640
|
setTextShading: (value) => (options.styleController.applyToolbarValueStyleCommand("shading", value), true),
|
|
@@ -40708,6 +40890,7 @@ function createEditorEssentialsRuntimePlugin(options) {
|
|
|
40708
40890
|
return createEssentialsPlugin({
|
|
40709
40891
|
gate: essentialsGate,
|
|
40710
40892
|
style: essentialsStyle,
|
|
40893
|
+
selection: essentialsSelection,
|
|
40711
40894
|
history: essentialsHistory,
|
|
40712
40895
|
formatting: essentialsFormatting,
|
|
40713
40896
|
document: essentialsDocument,
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { EditorParagraphListStyle, EditorParagraphStyle, EditorSection, EditorState, EditorTextStyle } from '../../../../core/model.js';
|
|
2
|
+
import { TextCaseMode } from '../../../../core/commands/text.js';
|
|
2
3
|
import { EditorTransactionOptions } from '../../../../ui/editorHistory.js';
|
|
3
4
|
import { BooleanStyleKey, ParagraphStyleKey, ToolbarStyleState } from '../../../../ui/toolbarStyleState.js';
|
|
4
5
|
import { EditorLogger } from '../../../../utils/logger.js';
|
|
@@ -24,6 +25,8 @@ export interface EditorCommandsControllerDeps {
|
|
|
24
25
|
export declare function createEditorCommandsController(deps: EditorCommandsControllerDeps): {
|
|
25
26
|
applyBooleanStyleCommand: (key: BooleanStyleKey) => void;
|
|
26
27
|
applyValueStyleCommand: <K extends "fontFamily" | "fontSize" | "color" | "highlight" | "shading" | "language" | "textEffect" | "link" | "underlineStyle">(key: K, value: EditorTextStyle[K] | null) => void;
|
|
28
|
+
applyChangeTextCaseCommand: (mode: TextCaseMode) => void;
|
|
29
|
+
applyClearFormattingCommand: () => void;
|
|
27
30
|
applyParagraphStyleCommand: <K extends ParagraphStyleKey>(key: K, value: EditorParagraphStyle[K] | null) => void;
|
|
28
31
|
toggleParagraphFlagCommand: (key: "pageBreakBefore" | "keepWithNext") => void;
|
|
29
32
|
applyParagraphListCommand: (kind: NonNullable<EditorParagraphListStyle["kind"]>) => void;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const OASIS_BUILTIN_COMMANDS: readonly ["selectAll", "insertFootnote", "pastePlainText", "bold", "italic", "underline", "strike", "superscript", "subscript", "link", "unlink", "alignLeft", "alignCenter", "alignRight", "alignJustify", "orderedList", "bulletList", "find", "replace", "toggleTrackChanges", "acceptRevisions", "rejectRevisions", "toggleShowMargins", "toggleShowParagraphMarks", "togglePreciseFonts", "undo", "redo", "pageBreak", "lineBreak", "splitBlock", "setFontFamily", "setFontSize", "setColor", "setHighlight", "setTextShading", "setStyleId", "setUnderlineStyle", "documentStyles", "print", "copy", "exportDocx", "exportPdf", "importDocument", "insertImage", "editImageAlt", "outdent", "indent", "togglePageBreakBefore", "toggleKeepWithNext", "setSpacingAfter", "setSpacingBefore", "setIndentLeft", "setIndentRight", "setIndentFirstLine", "setIndentHanging", "setParagraphShading", "applyParagraphBorders", "setLineHeight", "setListFormat", "setListStartAt", "toggleOrientation", "sectionBreakNextPage", "sectionBreakContinuous", "setPageMargins", "tableContext", "tableMerge", "tableSplit", "tableInsertColumnBefore", "tableInsertColumnAfter", "tableDeleteColumn", "tableInsertRowBefore", "tableInsertRowAfter", "tableDeleteRow", "tableCellShading", "tableCellBorders", "tableCellNoBorders", "tableWidth100", "tableAlignLeft", "tableAlignCenter", "tableAlignRight", "tableSetCellWidth", "insertTable"];
|
|
1
|
+
export declare const OASIS_BUILTIN_COMMANDS: readonly ["selectAll", "insertFootnote", "pastePlainText", "bold", "italic", "underline", "strike", "superscript", "subscript", "link", "unlink", "alignLeft", "alignCenter", "alignRight", "alignJustify", "orderedList", "bulletList", "find", "replace", "toggleTrackChanges", "acceptRevisions", "rejectRevisions", "toggleShowMargins", "toggleShowParagraphMarks", "togglePreciseFonts", "undo", "redo", "pageBreak", "lineBreak", "splitBlock", "setFontFamily", "setFontSize", "increaseFontSize", "decreaseFontSize", "changeTextCase", "clearFormatting", "setColor", "setHighlight", "setTextShading", "setStyleId", "setUnderlineStyle", "documentStyles", "print", "copy", "exportDocx", "exportPdf", "importDocument", "insertImage", "editImageAlt", "outdent", "indent", "togglePageBreakBefore", "toggleKeepWithNext", "setSpacingAfter", "setSpacingBefore", "setIndentLeft", "setIndentRight", "setIndentFirstLine", "setIndentHanging", "setParagraphShading", "applyParagraphBorders", "setLineHeight", "setListFormat", "setListStartAt", "toggleOrientation", "sectionBreakNextPage", "sectionBreakContinuous", "setPageMargins", "tableContext", "tableMerge", "tableSplit", "tableInsertColumnBefore", "tableInsertColumnAfter", "tableDeleteColumn", "tableInsertRowBefore", "tableInsertRowAfter", "tableDeleteRow", "tableCellShading", "tableCellBorders", "tableCellNoBorders", "tableWidth100", "tableAlignLeft", "tableAlignCenter", "tableAlignRight", "tableSetCellWidth", "insertTable"];
|
|
2
2
|
export type OasisBuiltinCommand = (typeof OASIS_BUILTIN_COMMANDS)[number];
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { CommandRef } from '../../CommandRef.js';
|
|
2
2
|
import { EditorPageMargins } from '../../../model.js';
|
|
3
|
+
import { TextCaseMode } from '../../text.js';
|
|
3
4
|
|
|
4
5
|
export interface InsertTablePayload {
|
|
5
6
|
rows: number;
|
|
@@ -43,6 +44,10 @@ export interface OasisCommandPayloads {
|
|
|
43
44
|
splitBlock: undefined;
|
|
44
45
|
setFontFamily: string | null;
|
|
45
46
|
setFontSize: SetFontSizePayload | number | string | null;
|
|
47
|
+
increaseFontSize: undefined;
|
|
48
|
+
decreaseFontSize: undefined;
|
|
49
|
+
changeTextCase: TextCaseMode;
|
|
50
|
+
clearFormatting: undefined;
|
|
46
51
|
setColor: string | null;
|
|
47
52
|
setHighlight: string | null;
|
|
48
53
|
setTextShading: string | null;
|
|
@@ -9,4 +9,19 @@ export declare function insertPlainTextAtSelection(state: EditorState, text: str
|
|
|
9
9
|
export declare function deleteBackward(state: EditorState): EditorState;
|
|
10
10
|
export declare function deleteForward(state: EditorState): EditorState;
|
|
11
11
|
export declare function toggleTextStyle(state: EditorState, key: ToggleableTextStyleKey): EditorState;
|
|
12
|
+
export type TextCaseMode = "sentence" | "lower" | "upper" | "capitalize" | "toggle";
|
|
13
|
+
/**
|
|
14
|
+
* Transforms the text of the selected runs in place. The transform must return
|
|
15
|
+
* a string of the same length so per-run boundaries (and thus styles) are
|
|
16
|
+
* preserved. The transform is applied to each paragraph's selected text
|
|
17
|
+
* independently so sentence/word boundaries reset at paragraph breaks.
|
|
18
|
+
*/
|
|
19
|
+
export declare function transformSelectedText(state: EditorState, transform: (text: string) => string): EditorState;
|
|
20
|
+
/** Change the letter case of the selected text, preserving runs and styles. */
|
|
21
|
+
export declare function changeSelectedTextCase(state: EditorState, mode: TextCaseMode): EditorState;
|
|
22
|
+
/**
|
|
23
|
+
* Remove direct (local) text formatting from the selected runs, preserving the
|
|
24
|
+
* text content, revisions, and links.
|
|
25
|
+
*/
|
|
26
|
+
export declare function clearSelectedTextFormatting(state: EditorState): EditorState;
|
|
12
27
|
export declare function setTextStyleValue<K extends ValueTextStyleKey>(state: EditorState, key: K, value: EditorTextStyle[K] | null): EditorState;
|
|
@@ -46,6 +46,15 @@ export declare const en: {
|
|
|
46
46
|
"toolbar.font": string;
|
|
47
47
|
"toolbar.fontSize": string;
|
|
48
48
|
"toolbar.size": string;
|
|
49
|
+
"toolbar.increaseFontSize": string;
|
|
50
|
+
"toolbar.decreaseFontSize": string;
|
|
51
|
+
"toolbar.changeCase": string;
|
|
52
|
+
"toolbar.clearFormatting": string;
|
|
53
|
+
"toolbar.caseSentence": string;
|
|
54
|
+
"toolbar.caseLower": string;
|
|
55
|
+
"toolbar.caseUpper": string;
|
|
56
|
+
"toolbar.caseCapitalize": string;
|
|
57
|
+
"toolbar.caseToggle": string;
|
|
49
58
|
"toolbar.color": string;
|
|
50
59
|
"toolbar.highlight": string;
|
|
51
60
|
"toolbar.textShading": string;
|
|
@@ -46,6 +46,15 @@ export declare const ptBR: {
|
|
|
46
46
|
"toolbar.font": string;
|
|
47
47
|
"toolbar.fontSize": string;
|
|
48
48
|
"toolbar.size": string;
|
|
49
|
+
"toolbar.increaseFontSize": string;
|
|
50
|
+
"toolbar.decreaseFontSize": string;
|
|
51
|
+
"toolbar.changeCase": string;
|
|
52
|
+
"toolbar.clearFormatting": string;
|
|
53
|
+
"toolbar.caseSentence": string;
|
|
54
|
+
"toolbar.caseLower": string;
|
|
55
|
+
"toolbar.caseUpper": string;
|
|
56
|
+
"toolbar.caseCapitalize": string;
|
|
57
|
+
"toolbar.caseToggle": string;
|
|
49
58
|
"toolbar.color": string;
|
|
50
59
|
"toolbar.highlight": string;
|
|
51
60
|
"toolbar.textShading": string;
|