oasis-editor 0.0.46 → 0.0.47

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.
@@ -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, E as EMU_PER_PX, q as createEditorParagraph, r as getBlockParagraphs, s as createEditorFootnote, t as createFootnoteReferenceRun, u as renumberFootnotes, v as iterateFootnoteReferenceRuns, w as getFootnoteDisplayMarker, x as findParagraphTableLocation, y as buildTableCellLayout, z as createSignal, A as createEffect, B as onCleanup, C as buildCanvasLayoutSnapshot, D as on, F as onMount, G as debounce, H as unwrap, I as getDocumentParagraphs, P as PT_PER_PX, J as createEditorTableCell, K as createEditorTableRow, L as createEditorTable, M as getDocumentSectionsCanonical, N as createEditorDocument, O as getPageContentWidth, Q as getDocumentPageSettings, R as getTableCellContentWidthForParagraph, S as resolveResizedDimensions, T as resolveImageSrc, U as resolveTextBoxRenderHeight, V as TWIPS_PER_POINT, W as PX_PER_INCH, X as TWIPS_PER_INCH, Y as resolveEffectiveParagraphStyle, Z as resolveEffectiveTextStyleForParagraph, _ as EMU_PER_PT, $ as iterateEndnoteReferenceRuns, a0 as JSZip, a1 as imageContentTypeDefaults, a2 as imageExtensionFromMime, a3 as pxToPt$1, a4 as resolveFloatingObjectRect, a5 as getTextBoxFloatingGeometry, a6 as getPresetPathSegments, a7 as projectBlocksLayout, a8 as buildListLabels, a9 as textStyleToFontSizePt, aa as PX_PER_POINT, ab as DEFAULT_FONT_SIZE_PX, ac as isDoubleUnderlineStyle, ad as isWavyUnderlineStyle, ae as underlineStyleLineWidthPx, af as underlineStyleDashArray, ag as resolveListLabel, ah as getListLabelInset, ai as getAlignedListLabelInset, aj as getParagraphBorderInsets, ak as buildSegmentTable, al as buildCanvasTableLayout, am as normalizeFamily, an as ROBOTO_FONT_FILES, ao as loadFontAsset, ap as OFFICE_COMPAT_FONT_FAMILIES, aq as buildSfnt, ar as defaultFontDecoderRegistry, as as SfntFontProgram, at as collectPdfFontFamilies, au as projectDocumentLayout, av as getPageHeaderZoneTop, aw as getPageBodyTop, ax as getPageColumnRects, ay as findFootnoteReference, az as FOOTNOTE_MARKER_GUTTER_PX, aA as resolveImporterForFile, aB as createEditorStateFromDocument, aC as getDocumentParagraphsCanonical, aD as getToolbarStyleState, aE as STANDARD_FONT_SIZES_PT, aF as fontSizePxToPt, aG as probeLocalFontFamilies, aH as createInitialEditorState, aI as parseFontSizePtToPx, aJ as formatFontSizePt, aK as underlineStyleToCssDecorationStyle, aL as listKindForTag, aM as isParagraphTag, aN as collectInlineRuns, aO as parseParagraphStyle, aP as getCachedCanvasImage, aQ as getHeadingLevel, aR as preciseFontModeVersion, aS as isPreciseFontModeEnabled, aT as togglePreciseFontMode, aU as nextFontSizePt, aV as previousFontSizePt, aW as fontSizePtToPx, aX as createDefaultToolbarPreset, aY as MenuRegistry, aZ as createToolbarRegistry, a_ as Editor, a$ as resolveCommandRef, b0 as commandRefName, b1 as InlineShell, b2 as BalloonShell, b3 as DocumentShell, b4 as createMemo, b5 as getCaretRectFromSnapshot, b6 as getParagraphRectFromSnapshot, b7 as createComponent, b8 as CaretOverlay, b9 as Show, ba as createRenderEffect, bb as style, bc as setAttribute, bd as setStyleProperty, be as memo, bf as template, bg as useI18n, bh as insert, bi as use, bj as addEventListener, bk as Dialog, bl as delegateEvents, bm as className, bn as For, bo as UNDERLINE_STYLE_OPTIONS, bp as Tabs, bq as measureParagraphMinContentWidthPx, br as getEditableBlocksForZone, bs as findParagraphLocation, bt as createSectionBoundaryParagraph, bu as normalizePageSettings, bv as DEFAULT_EDITOR_PAGE_SETTINGS, bw as markStart, bx as markEnd, by as getParagraphEntries, bz as getParagraphById, bA as PluginUiHost, bB as OasisEditorEditor, bC as perfTimer, bD as OasisBrandMark, bE as setPreciseFontPreference, bF as setWelcomeSeen, bG as enablePreciseFontMode, bH as createOasisEditorClient, bI as createEditorZoom, bJ as startLongTaskObserver, bK as installGlobalReport, bL as applyStoredPreciseFontPreference, bM as getWelcomeSeen, bN as isLocalFontAccessSupported, bO as EDITOR_SCROLL_PADDING_PX, bP as Toolbar, bQ as OasisEditorLoading, bR as I18nProvider, bS as createEditorLogger, bT as createTranslator, bU as registerDomStatsSurface } from "./index-Cz7QAkQ8.js";
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, E as EMU_PER_PX, q as createEditorParagraph, r as getBlockParagraphs, s as createEditorFootnote, t as createFootnoteReferenceRun, u as renumberFootnotes, v as iterateFootnoteReferenceRuns, w as getFootnoteDisplayMarker, x as findParagraphTableLocation, y as buildTableCellLayout, z as createSignal, A as createEffect, B as onCleanup, C as buildCanvasLayoutSnapshot, D as on, F as onMount, G as debounce, H as unwrap, I as getDocumentParagraphs, P as PT_PER_PX, J as createEditorTableCell, K as createEditorTableRow, L as createEditorTable, M as getDocumentSectionsCanonical, N as createEditorDocument, O as getPageContentWidth, Q as getDocumentPageSettings, R as getTableCellContentWidthForParagraph, S as resolveResizedDimensions, T as resolveImageSrc, U as resolveTextBoxRenderHeight, V as TWIPS_PER_POINT, W as PX_PER_INCH, X as TWIPS_PER_INCH, Y as resolveEffectiveParagraphStyle, Z as resolveEffectiveTextStyleForParagraph, _ as EMU_PER_PT, $ as iterateEndnoteReferenceRuns, a0 as JSZip, a1 as imageContentTypeDefaults, a2 as imageExtensionFromMime, a3 as pxToPt$1, a4 as resolveFloatingObjectRect, a5 as getTextBoxFloatingGeometry, a6 as getPresetPathSegments, a7 as projectBlocksLayout, a8 as buildListLabels, a9 as textStyleToFontSizePt, aa as PX_PER_POINT, ab as DEFAULT_FONT_SIZE_PX, ac as isDoubleUnderlineStyle, ad as isWavyUnderlineStyle, ae as underlineStyleLineWidthPx, af as underlineStyleDashArray, ag as resolveListLabel, ah as getListLabelInset, ai as getAlignedListLabelInset, aj as getParagraphBorderInsets, ak as buildSegmentTable, al as buildCanvasTableLayout, am as normalizeFamily, an as ROBOTO_FONT_FILES, ao as loadFontAsset, ap as OFFICE_COMPAT_FONT_FAMILIES, aq as buildSfnt, ar as defaultFontDecoderRegistry, as as SfntFontProgram, at as collectPdfFontFamilies, au as projectDocumentLayout, av as getPageHeaderZoneTop, aw as getPageBodyTop, ax as getPageColumnRects, ay as findFootnoteReference, az as FOOTNOTE_MARKER_GUTTER_PX, aA as resolveImporterForFile, aB as createEditorStateFromDocument, aC as getDocumentParagraphsCanonical, aD as getToolbarStyleState, aE as STANDARD_FONT_SIZES_PT, aF as fontSizePxToPt, aG as probeLocalFontFamilies, aH as createInitialEditorState, aI as parseFontSizePtToPx, aJ as formatFontSizePt, aK as underlineStyleToCssDecorationStyle, aL as listKindForTag, aM as isParagraphTag, aN as collectInlineRuns, aO as parseParagraphStyle, aP as getCachedCanvasImage, aQ as getHeadingLevel, aR as preciseFontModeVersion, aS as isPreciseFontModeEnabled, aT as togglePreciseFontMode, aU as nextFontSizePt, aV as previousFontSizePt, aW as fontSizePtToPx, aX as createDefaultToolbarPreset, aY as MenuRegistry, aZ as createToolbarRegistry, a_ as Editor, a$ as resolveCommandRef, b0 as commandRefName, b1 as InlineShell, b2 as BalloonShell, b3 as DocumentShell, b4 as createMemo, b5 as getCaretRectFromSnapshot, b6 as getParagraphRectFromSnapshot, b7 as createComponent, b8 as CaretOverlay, b9 as Show, ba as createRenderEffect, bb as style, bc as setAttribute, bd as setStyleProperty, be as memo, bf as template, bg as useI18n, bh as insert, bi as use, bj as addEventListener, bk as Dialog, bl as delegateEvents, bm as className, bn as For, bo as UNDERLINE_STYLE_OPTIONS, bp as Tabs, bq as measureParagraphMinContentWidthPx, br as getEditableBlocksForZone, bs as findParagraphLocation, bt as createSectionBoundaryParagraph, bu as normalizePageSettings, bv as DEFAULT_EDITOR_PAGE_SETTINGS, bw as markStart, bx as markEnd, by as getParagraphEntries, bz as getParagraphById, bA as PluginUiHost, bB as OasisEditorEditor, bC as perfTimer, bD as OasisBrandMark, bE as setPreciseFontPreference, bF as setWelcomeSeen, bG as enablePreciseFontMode, bH as createOasisEditorClient, bI as createEditorZoom, bJ as startLongTaskObserver, bK as installGlobalReport, bL as applyStoredPreciseFontPreference, bM as getWelcomeSeen, bN as isLocalFontAccessSupported, bO as EDITOR_SCROLL_PADDING_PX, bP as Toolbar, bQ as OasisEditorLoading, bR as I18nProvider, bS as createEditorLogger, bT as createTranslator, bU as registerDomStatsSurface } from "./index-o6IKPcPL.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) {
@@ -2219,6 +2219,96 @@ function rejectRevisionsInSelection(state) {
2219
2219
  }
2220
2220
  return nextState;
2221
2221
  }
2222
+ function isLetter(char) {
2223
+ return new RegExp("\\p{L}", "u").test(char);
2224
+ }
2225
+ function toSentenceCase(text) {
2226
+ let result = "";
2227
+ let capitalizeNext = true;
2228
+ for (const char of text.toLowerCase()) {
2229
+ if (capitalizeNext && isLetter(char)) {
2230
+ result += char.toUpperCase();
2231
+ capitalizeNext = false;
2232
+ } else {
2233
+ result += char;
2234
+ if (char === "." || char === "!" || char === "?") {
2235
+ capitalizeNext = true;
2236
+ }
2237
+ }
2238
+ }
2239
+ return result;
2240
+ }
2241
+ function toCapitalizedWords(text) {
2242
+ let result = "";
2243
+ let prevIsLetter = false;
2244
+ for (const char of text) {
2245
+ const letter = isLetter(char);
2246
+ result += letter && !prevIsLetter ? char.toUpperCase() : char;
2247
+ prevIsLetter = letter;
2248
+ }
2249
+ return result;
2250
+ }
2251
+ function toToggledCase(text) {
2252
+ let result = "";
2253
+ for (const char of text) {
2254
+ const upper = char.toUpperCase();
2255
+ const lower = char.toLowerCase();
2256
+ if (char === lower && char !== upper) {
2257
+ result += upper;
2258
+ } else if (char === upper && char !== lower) {
2259
+ result += lower;
2260
+ } else {
2261
+ result += char;
2262
+ }
2263
+ }
2264
+ return result;
2265
+ }
2266
+ function applyCaseTransform(text, mode) {
2267
+ switch (mode) {
2268
+ case "lower":
2269
+ return text.toLowerCase();
2270
+ case "upper":
2271
+ return text.toUpperCase();
2272
+ case "capitalize":
2273
+ return toCapitalizedWords(text);
2274
+ case "toggle":
2275
+ return toToggledCase(text);
2276
+ case "sentence":
2277
+ default:
2278
+ return toSentenceCase(text);
2279
+ }
2280
+ }
2281
+ function transformSelectedText(state, transform) {
2282
+ const normalized = normalizeSelection(state);
2283
+ if (normalized.isCollapsed) {
2284
+ return state;
2285
+ }
2286
+ const paragraphs = getParagraphs(state);
2287
+ const nextParagraphs = paragraphs.map((paragraph, paragraphIndex) => {
2288
+ if (paragraphIndex < normalized.startIndex || paragraphIndex > normalized.endIndex) {
2289
+ return paragraph;
2290
+ }
2291
+ const startOffset = paragraphIndex === normalized.startIndex ? normalized.startParagraphOffset : 0;
2292
+ const endOffset = paragraphIndex === normalized.endIndex ? normalized.endParagraphOffset : getParagraphLength(paragraph);
2293
+ const selectedText = sliceRuns(paragraph, startOffset, endOffset).map((run) => run.text).join("");
2294
+ const transformed = transform(selectedText);
2295
+ let cursor = 0;
2296
+ return mapRunsInRange(paragraph, startOffset, endOffset, (run) => {
2297
+ const length = run.text.length;
2298
+ const nextText = transformed.slice(cursor, cursor + length);
2299
+ cursor += length;
2300
+ return { ...run, text: nextText };
2301
+ });
2302
+ });
2303
+ return cloneStateWithParagraphs(
2304
+ state,
2305
+ nextParagraphs,
2306
+ preserveSelectionByParagraphOffsets(nextParagraphs, normalized)
2307
+ );
2308
+ }
2309
+ function changeSelectedTextCase(state, mode) {
2310
+ return transformSelectedText(state, (text) => applyCaseTransform(text, mode));
2311
+ }
2222
2312
  function cloneFragmentRuns(runs) {
2223
2313
  return runs.map(cloneRun);
2224
2314
  }
@@ -2718,96 +2808,6 @@ function toggleTextStyle(state, key) {
2718
2808
  preserveSelectionByParagraphOffsets(nextParagraphs, normalized)
2719
2809
  );
2720
2810
  }
2721
- function isLetter(char) {
2722
- return new RegExp("\\p{L}", "u").test(char);
2723
- }
2724
- function toSentenceCase(text) {
2725
- let result = "";
2726
- let capitalizeNext = true;
2727
- for (const char of text.toLowerCase()) {
2728
- if (capitalizeNext && isLetter(char)) {
2729
- result += char.toUpperCase();
2730
- capitalizeNext = false;
2731
- } else {
2732
- result += char;
2733
- if (char === "." || char === "!" || char === "?") {
2734
- capitalizeNext = true;
2735
- }
2736
- }
2737
- }
2738
- return result;
2739
- }
2740
- function toCapitalizedWords(text) {
2741
- let result = "";
2742
- let prevIsLetter = false;
2743
- for (const char of text) {
2744
- const letter = isLetter(char);
2745
- result += letter && !prevIsLetter ? char.toUpperCase() : char;
2746
- prevIsLetter = letter;
2747
- }
2748
- return result;
2749
- }
2750
- function toToggledCase(text) {
2751
- let result = "";
2752
- for (const char of text) {
2753
- const upper = char.toUpperCase();
2754
- const lower = char.toLowerCase();
2755
- if (char === lower && char !== upper) {
2756
- result += upper;
2757
- } else if (char === upper && char !== lower) {
2758
- result += lower;
2759
- } else {
2760
- result += char;
2761
- }
2762
- }
2763
- return result;
2764
- }
2765
- function applyCaseTransform(text, mode) {
2766
- switch (mode) {
2767
- case "lower":
2768
- return text.toLowerCase();
2769
- case "upper":
2770
- return text.toUpperCase();
2771
- case "capitalize":
2772
- return toCapitalizedWords(text);
2773
- case "toggle":
2774
- return toToggledCase(text);
2775
- case "sentence":
2776
- default:
2777
- return toSentenceCase(text);
2778
- }
2779
- }
2780
- function transformSelectedText(state, transform) {
2781
- const normalized = normalizeSelection(state);
2782
- if (normalized.isCollapsed) {
2783
- return state;
2784
- }
2785
- const paragraphs = getParagraphs(state);
2786
- const nextParagraphs = paragraphs.map((paragraph, paragraphIndex) => {
2787
- if (paragraphIndex < normalized.startIndex || paragraphIndex > normalized.endIndex) {
2788
- return paragraph;
2789
- }
2790
- const startOffset = paragraphIndex === normalized.startIndex ? normalized.startParagraphOffset : 0;
2791
- const endOffset = paragraphIndex === normalized.endIndex ? normalized.endParagraphOffset : getParagraphLength(paragraph);
2792
- const selectedText = sliceRuns(paragraph, startOffset, endOffset).map((run) => run.text).join("");
2793
- const transformed = transform(selectedText);
2794
- let cursor = 0;
2795
- return mapRunsInRange(paragraph, startOffset, endOffset, (run) => {
2796
- const length = run.text.length;
2797
- const nextText = transformed.slice(cursor, cursor + length);
2798
- cursor += length;
2799
- return { ...run, text: nextText };
2800
- });
2801
- });
2802
- return cloneStateWithParagraphs(
2803
- state,
2804
- nextParagraphs,
2805
- preserveSelectionByParagraphOffsets(nextParagraphs, normalized)
2806
- );
2807
- }
2808
- function changeSelectedTextCase(state, mode) {
2809
- return transformSelectedText(state, (text) => applyCaseTransform(text, mode));
2810
- }
2811
2811
  function clearSelectedTextFormatting(state) {
2812
2812
  const normalized = normalizeSelection(state);
2813
2813
  if (normalized.isCollapsed) {
@@ -9,16 +9,7 @@ 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;
12
+ export { type TextCaseMode, transformSelectedText, changeSelectedTextCase, } from './textCase.js';
22
13
  /**
23
14
  * Remove direct (local) text formatting from the selected runs, preserving the
24
15
  * text content, revisions, and links.
@@ -0,0 +1,12 @@
1
+ import { EditorState } from '../model.js';
2
+
3
+ export type TextCaseMode = "sentence" | "lower" | "upper" | "capitalize" | "toggle";
4
+ /**
5
+ * Transforms the text of the selected runs in place. The transform must return
6
+ * a string of the same length so per-run boundaries (and thus styles) are
7
+ * preserved. The transform is applied to each paragraph's selected text
8
+ * independently so sentence/word boundaries reset at paragraph breaks.
9
+ */
10
+ export declare function transformSelectedText(state: EditorState, transform: (text: string) => string): EditorState;
11
+ /** Change the letter case of the selected text, preserving runs and styles. */
12
+ export declare function changeSelectedTextCase(state: EditorState, mode: TextCaseMode): EditorState;
@@ -2483,7 +2483,7 @@ function OasisEditorAppLazy(props = {}) {
2483
2483
  onCleanup(() => {
2484
2484
  cancelled = true;
2485
2485
  });
2486
- import("./OasisEditorApp-ByWoTv0F.js").then((m) => {
2486
+ import("./OasisEditorApp-9bkqRYbl.js").then((m) => {
2487
2487
  cancelled = true;
2488
2488
  setProgress(1);
2489
2489
  setTimeout(() => setApp(() => m.OasisEditorApp), 180);
@@ -1,4 +1,4 @@
1
- import { b2, bV, bW, bX, bY, bZ, bk, b_, b3, a_, b$, c0, c1, b1, c2, aY, c3, c4, c5, c6, c7, bQ, c8, c9, ca, cb, cc, cd, ce, cf, cg, ch, ci, bp, cj, bP, ck, bX as bX2, c0 as c02, c2 as c22, cb as cb2, cd as cd2, ci as ci2, cl, b0, aX, cm, cn, co, aZ, cp, cq, a$ } from "./index-Cz7QAkQ8.js";
1
+ import { b2, bV, bW, bX, bY, bZ, bk, b_, b3, a_, b$, c0, c1, b1, c2, aY, c3, c4, c5, c6, c7, bQ, c8, c9, ca, cb, cc, cd, ce, cf, cg, ch, ci, bp, cj, bP, ck, bX as bX2, c0 as c02, c2 as c22, cb as cb2, cd as cd2, ci as ci2, cl, b0, aX, cm, cn, co, aZ, cp, cq, a$ } from "./index-o6IKPcPL.js";
2
2
  export {
3
3
  b2 as BalloonShell,
4
4
  bV as Button,