@fileverse-dev/dsheet 3.0.3 → 4.0.1-ref

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.
Files changed (27) hide show
  1. package/dist/editor/components/sidebar/use-right-panels.d.ts +1 -1
  2. package/dist/editor/components/sidebars/named-ranges.d.ts +2 -0
  3. package/dist/editor/utils/defined-names-ydoc.d.ts +31 -0
  4. package/dist/editor/utils/xlsx-defined-names.d.ts +41 -0
  5. package/dist/{executeStringFunction-DVN2p-9G.js → executeStringFunction-CCpEDh3D.js} +6994 -6469
  6. package/dist/formula.js +1 -1
  7. package/dist/{index-T7U1EYEU.js → index-Sxwr9Syr.js} +14777 -14037
  8. package/dist/index.es.js +20 -20
  9. package/dist/jszip.min-DHgf03FP.js +2319 -0
  10. package/dist/sheet-engine/core/context.d.ts +3 -1
  11. package/dist/sheet-engine/core/index.d.ts +2 -2
  12. package/dist/sheet-engine/core/modules/formula-snapshot-eval.d.ts +11 -0
  13. package/dist/sheet-engine/core/modules/formula.d.ts +27 -0
  14. package/dist/sheet-engine/core/modules/image-clipboard.d.ts +8 -0
  15. package/dist/sheet-engine/core/modules/image.d.ts +12 -1
  16. package/dist/sheet-engine/core/modules/index.d.ts +4 -3
  17. package/dist/sheet-engine/core/modules/namedRanges.d.ts +53 -0
  18. package/dist/sheet-engine/core/settings.d.ts +2 -0
  19. package/dist/sheet-engine/core/types.d.ts +19 -0
  20. package/dist/sheet-engine/react/components/NamedRanges/index.d.ts +4 -0
  21. package/dist/style.css +1 -1
  22. package/dist/use-xlsx-import-impl-DV7gsVeb.js +1613 -0
  23. package/dist/xlsx-defined-names-_KUWFAe9.js +117 -0
  24. package/dist/xlsx-export-impl-BCGdJj_E.js +830 -0
  25. package/package.json +5 -2
  26. package/dist/use-xlsx-import-impl-B9Uq_cFK.js +0 -1572
  27. package/dist/xlsx-export-impl-0bnKq9JC.js +0 -3138
@@ -1,4 +1,4 @@
1
- import { SheetConfig, Sheet, Selection, Cell, CommentBox, Rect, Image, Presence, LinkCardProps, FilterOptions, RangeDialogProps, DataRegulationProps, ConditionRulesProps, GlobalCache, CellError } from './types';
1
+ import { SheetConfig, Sheet, Selection, Cell, CommentBox, Rect, Image, Presence, LinkCardProps, FilterOptions, RangeDialogProps, DataRegulationProps, ConditionRulesProps, GlobalCache, CellError, DefinedName } from './types';
2
2
  import { FormulaCache } from './modules';
3
3
  import { FormulaAsyncEvalJob } from './modules/formula-async-eval';
4
4
  import { DateBaseLocale, Hooks } from './settings';
@@ -116,6 +116,8 @@ export type Context = {
116
116
  currentSheetId: string;
117
117
  calculateSheetId: string;
118
118
  config: SheetConfig;
119
+ /** Workbook-level named ranges (synced via Yjs `${dsheetId}:definedNames`). */
120
+ definedNames: DefinedName[];
119
121
  visibledatarow: number[];
120
122
  visibledatacolumn: number[];
121
123
  ch_width: number;
@@ -7,11 +7,11 @@ export { defaultSettings } from './settings';
7
7
  export type { Settings, Hooks, DateBaseLocale } from './settings';
8
8
  export { handleCopy, handleGlobalKeyDown, handlePaste, handlePasteByClick, fixPositionOnFrozenCells, handleCellAreaMouseDown, handleCellAreaDoubleClick, handleContextMenu, mouseRender, handleOverlayMouseMove, handleOverlayMouseUp, handleRowHeaderMouseDown, handleColumnHeaderMouseDown, handleColSizeHandleMouseDown, handleColSizeHandleDoubleClick, handleRowSizeHandleMouseDown, handleColFreezeHandleMouseDown, handleRowFreezeHandleMouseDown, describeMatchedShortcut, isBrowserZoomShortcut, isOpenShortcutsModalShortcut, isFormulaListShortcut, } from './events';
9
9
  export * from './locale';
10
- export { getBorderInfoComputeRange, getBorderInfoCompute, normalizedCellAttr, normalizedAttr, getCellValue, setCellValue, getRealCellValue, mergeBorder, cancelNormalSelected, updateCell, getRangetxt, getRangeByTxt, isValidRangeText, getInlineStringHTML, applyLinkToSelection, getHyperlinksFromInlineSegments, getUniformLinkFromWindowSelectionInEditor, getHyperlinkAtCaretInContentEditable, getStyleByCell, clearSelectedCellFormat, clearRowsCellsFormat, clearColumnsCellsFormat, clipboard, moveToEnd, getRangeRectsByCharacterOffset, getDateBaseLocale, getCanonicalDateEditFormat, getDateEditFormatForCell, isUsDateBaseLocale, normalizeDateBaseLocale, shouldPreserveDateFormatForEdit, setDateBaseLocale, update, is_date, valueShowEs, isTypedCurrencyDisplayFormat, isCurrencyLikeNumberFormat, buildFiatCurrencyFormat, quoteSsfLiteral, FormulaCache, groupValuesRefresh, execFunctionGroup, runFormulaEvalChunk, applyWorkerFormulaChunkResults, isFormulaEvalPending, FORMULA_ASYNC_CHUNK_SIZE, FORMULA_ASYNC_EVAL_THRESHOLD, FORMULA_WORKER_CHUNK_SIZE, FORMULA_WORKER_THRESHOLD, setCaretPosition, getrangeseleciton, getFormulaEditorOwner, rangeHightlightselected, handleFormulaInput, israngeseleciton, createRangeHightlight, maybeRecoverDirtyRangeSelection, getFormulaRangeIndexAtCaret, isCaretAtValidFormulaRangeInsertionPoint, isLegacyFormulaRangeMode, markRangeSelectionDirty, setFormulaEditorOwner, functionHTMLGenerate, suppressFormulaRangeSelectionForInitialEdit, rangeSetValue, getFormulaRangeIndexForKeyboardSync, createFormulaRangeSelect, isFormulaReferenceInputMode, seedFormulaFuncSelectedRangeFromLastSelection, initFreeze, isInlineStringCell, getInlineStringNoStyle, rowLocation, rowLocationByIndex, colLocation, colLocationByIndex, insertRowCol, deleteRowCol, hideSelected, showSelected, isShowHidenCR, getFilterHiddenRowsUnionFromFilterMap, getFilterHiddenRowsUnion, ensureManualHiddenInitialized, rebuildRowHiddenUnion, scrollToHighlightCell, selectTitlesMap, selectTitlesRange, defaultLuckysheetSelectRanges, normalizeSelection, syncPrimaryCellActiveFromSelection, selectionIsExactlyOneMergeBlock, setPrimaryCellActive, advancePrimaryCellInLastMultiSelection, snapSheetSelectionFocusToCellPreserveMultiRange, moveHighlightCell, deleteSelectedCellText, selectAll, fixRowStyleOverflowInFreeze, fixColumnStyleOverflowInFreeze, calcSelectionInfo, addSheet, deleteSheet, editSheetName, changeSheet, updateFormat, autoSelectionFormula, handleBold, handleItalic, handleStrikeThrough, handleUnderline, handleHorizontalAlign, handleVerticalAlign, handleTextColor, handleTextBackground, handleBorder, handleMerge, mergeSelectionHasValues, handleSort, getRemoveDuplicatesPreview, removeDuplicates, getRemoveDuplicatesErrorMessage, handleFreeze, handleTextSize, handleSum, handleLink, captureLinkEditorOpenSnapshot, isHyperlinkCreationBlocked, toolbarItemClickHandler, toolbarItemSelectedFunc, handleScreenShot, insertImage, showImgChooser, drawArrow, setEditingComment, removeEditingComment, removeOverShowComment, newComment, editComment, deleteComment, showComments, showHideComment, showHideAllComments, onCommentBoxMoveStart, removeActiveImage, cancelActiveImgItem, onImageMoveStart, onImageResizeStart, createDropCellRange, sortSelection, sortSheetBySelectedColumn, searchAll, searchNext, replace, replaceAll, replaceAllScoped, getSearchIndexArr, getSearchIndexArrAsync, getFindRangeOnCurrentSheet, getQuickSearchIndexArr, getQuickSearchHiddenConfig, getCellHyperlinks, getHyperlinkDisplayTextInCell, getInlineLinkPlainRange, getUniformLinkCoveringPlainRange, getUniformLinkAtPlainOffset, removeHyperlinkForLink, updateHyperlinkForLink, syncLinkCardAfterHyperlinkChange, expandCellRectForMerge, shouldQuickSearchUseAsync, runQuickSearchIndexArrAsync, QUICK_SEARCH_ASYNC_ROW_THRESHOLD, parseRangeText, getCellRowColumn, getCellHyperlink, saveHyperlink, removeHyperlink, showLinkCard, goToLink, isLinkValid, createFilterOptions, clearFilter, clearFilterForColumn, toggleViewerFilter, createFilter, applySheetFilterState, getFilterColumnValues, getFilterColumnColors, orderbydatafiler, saveFilter, onCellsMoveStart, cfSplitRange, updateMoreCell, getRegStr, getDataArr, applyLocation, getOptionValue, getSelectRange, getDropdownList, setDropdownValue, confirmMessage, setConditionRules, CF_DATE_DEFAULT_FORMAT, parseCfDateConditionForUi, formatCfDatePresetSnapshot, parseDdMmYyyyToSerial, handleOverlayTouchStart, handleOverlayTouchEnd, MAX_ZOOM_RATIO, MIN_ZOOM_RATIO, jfrefreshgrid, sanitizeDuneUrl, insertDuneChart, onIframeMoveStart, onIframeResizeStart, onIframeMove, onIframeMoveEnd, onIframeResize, onIframeResizeEnd, setCellError, clearCellError, detectDateFormat, isdatatypemulti, diff, isdatetime, isRealNull, isRealNum, isNumericCellType, iscelldata, getcellrange, cancelFunctionrangeSelected, seletedHighlistByindex, spillSortResult, execfunction, insertUpdateFunctionGroup, remapFormulaReferencesByMap, checkCF, getComputeMap, cancelPaintModel, hideCRCount, getdatabyselection, } from './modules';
10
+ export { getBorderInfoComputeRange, getBorderInfoCompute, normalizedCellAttr, normalizedAttr, getCellValue, setCellValue, getRealCellValue, mergeBorder, cancelNormalSelected, updateCell, getRangetxt, getRangeByTxt, isValidRangeText, getInlineStringHTML, applyLinkToSelection, getHyperlinksFromInlineSegments, getUniformLinkFromWindowSelectionInEditor, getHyperlinkAtCaretInContentEditable, getStyleByCell, clearSelectedCellFormat, clearRowsCellsFormat, clearColumnsCellsFormat, clipboard, moveToEnd, getRangeRectsByCharacterOffset, getDateBaseLocale, getCanonicalDateEditFormat, getDateEditFormatForCell, isUsDateBaseLocale, normalizeDateBaseLocale, shouldPreserveDateFormatForEdit, setDateBaseLocale, update, is_date, valueShowEs, isTypedCurrencyDisplayFormat, isCurrencyLikeNumberFormat, buildFiatCurrencyFormat, quoteSsfLiteral, FormulaCache, groupValuesRefresh, execFunctionGroup, runFormulaEvalChunk, applyWorkerFormulaChunkResults, isFormulaEvalPending, FORMULA_ASYNC_CHUNK_SIZE, FORMULA_ASYNC_EVAL_THRESHOLD, FORMULA_WORKER_CHUNK_SIZE, FORMULA_WORKER_THRESHOLD, setCaretPosition, getrangeseleciton, getFormulaEditorOwner, rangeHightlightselected, handleFormulaInput, israngeseleciton, createRangeHightlight, maybeRecoverDirtyRangeSelection, getFormulaRangeIndexAtCaret, isCaretAtValidFormulaRangeInsertionPoint, isLegacyFormulaRangeMode, markRangeSelectionDirty, setFormulaEditorOwner, functionHTMLGenerate, suppressFormulaRangeSelectionForInitialEdit, ensureFormulaRangeToSheet, shouldPreserveFormulaEditOnSheetSwitch, activateSheetForNavigation, returnToFormulaOriginSheet, rangeSetValue, getFormulaRangeIndexForKeyboardSync, createFormulaRangeSelect, isFormulaReferenceInputMode, seedFormulaFuncSelectedRangeFromLastSelection, initFreeze, isInlineStringCell, getInlineStringNoStyle, rowLocation, rowLocationByIndex, colLocation, colLocationByIndex, insertRowCol, deleteRowCol, hideSelected, showSelected, isShowHidenCR, getFilterHiddenRowsUnionFromFilterMap, getFilterHiddenRowsUnion, ensureManualHiddenInitialized, rebuildRowHiddenUnion, scrollToHighlightCell, selectTitlesMap, selectTitlesRange, defaultLuckysheetSelectRanges, normalizeSelection, syncPrimaryCellActiveFromSelection, selectionIsExactlyOneMergeBlock, setPrimaryCellActive, advancePrimaryCellInLastMultiSelection, snapSheetSelectionFocusToCellPreserveMultiRange, moveHighlightCell, deleteSelectedCellText, selectAll, fixRowStyleOverflowInFreeze, fixColumnStyleOverflowInFreeze, calcSelectionInfo, addSheet, deleteSheet, editSheetName, changeSheet, updateFormat, autoSelectionFormula, handleBold, handleItalic, handleStrikeThrough, handleUnderline, handleHorizontalAlign, handleVerticalAlign, handleTextColor, handleTextBackground, handleBorder, handleMerge, mergeSelectionHasValues, handleSort, getRemoveDuplicatesPreview, removeDuplicates, getRemoveDuplicatesErrorMessage, handleFreeze, handleTextSize, handleSum, handleLink, captureLinkEditorOpenSnapshot, isHyperlinkCreationBlocked, toolbarItemClickHandler, toolbarItemSelectedFunc, handleScreenShot, insertImage, showImgChooser, drawArrow, setEditingComment, removeEditingComment, removeOverShowComment, newComment, editComment, deleteComment, showComments, showHideComment, showHideAllComments, onCommentBoxMoveStart, removeActiveImage, copyActiveImage, cutActiveImage, pasteImageItem, loadImageFromFile, getImageClipboard, getImageCutSourceId, cancelActiveImgItem, onImageMoveStart, onImageResizeStart, createDropCellRange, sortSelection, sortSheetBySelectedColumn, searchAll, searchNext, replace, replaceAll, replaceAllScoped, getSearchIndexArr, getSearchIndexArrAsync, getFindRangeOnCurrentSheet, getQuickSearchIndexArr, getQuickSearchHiddenConfig, getCellHyperlinks, getHyperlinkDisplayTextInCell, getInlineLinkPlainRange, getUniformLinkCoveringPlainRange, getUniformLinkAtPlainOffset, removeHyperlinkForLink, updateHyperlinkForLink, syncLinkCardAfterHyperlinkChange, expandCellRectForMerge, shouldQuickSearchUseAsync, runQuickSearchIndexArrAsync, QUICK_SEARCH_ASYNC_ROW_THRESHOLD, parseRangeText, getCellRowColumn, getCellHyperlink, saveHyperlink, removeHyperlink, showLinkCard, goToLink, isLinkValid, createFilterOptions, clearFilter, clearFilterForColumn, toggleViewerFilter, createFilter, applySheetFilterState, getFilterColumnValues, getFilterColumnColors, orderbydatafiler, saveFilter, onCellsMoveStart, cfSplitRange, updateMoreCell, getRegStr, getDataArr, applyLocation, getOptionValue, getSelectRange, getDropdownList, setDropdownValue, confirmMessage, setConditionRules, CF_DATE_DEFAULT_FORMAT, parseCfDateConditionForUi, formatCfDatePresetSnapshot, parseDdMmYyyyToSerial, handleOverlayTouchStart, handleOverlayTouchEnd, MAX_ZOOM_RATIO, MIN_ZOOM_RATIO, jfrefreshgrid, sanitizeDuneUrl, insertDuneChart, onIframeMoveStart, onIframeResizeStart, onIframeMove, onIframeMoveEnd, onIframeResize, onIframeResizeEnd, setCellError, clearCellError, detectDateFormat, isdatatypemulti, diff, isdatetime, isRealNull, isRealNum, isNumericCellType, iscelldata, getcellrange, cancelFunctionrangeSelected, seletedHighlistByindex, spillSortResult, execfunction, insertUpdateFunctionGroup, remapFormulaReferencesByMap, refreshFormulasUsingDefinedNames, checkCF, getComputeMap, isValidDefinedNameIdentifier, getDefinedNameDisplayRange, findDefinedNameForSelection, findDefinedNameByName, resolveDefinedNameForFormula, addDefinedName, updateDefinedName, deleteDefinedName, selectDefinedName, openNamedRangesSidebar, scheduleDefinedNamesSync, shiftDefinedNamesOnInsert, shiftDefinedNamesOnDelete, removeDefinedNamesForSheet, cancelPaintModel, hideCRCount, getdatabyselection, } from './modules';
11
11
  export type { FilterDate, FilterValue, FilterColor } from './modules';
12
12
  export { getFreezeState, toggleFreeze, indexToColumnChar, escapeScriptTag, escapeHTMLTag, getSheetIndex, replaceHtml, isAllowEdit, isAllowEditReadOnly, filterPatch, patchToOp, opToPatch, inverseRowColOptions, } from './utils';
13
13
  export type { PatchOptions, ChangedSheet } from './utils';
14
- export type { Op, Cell, CellWithRowAndCol, CellMatrix, HyperlinkEntry, Selection, Presence, Sheet, GlobalCache, SingleRange, Range, SearchResult, LinkCardProps, LiveQueryData, Freezen, } from './types';
14
+ export type { Op, Cell, CellWithRowAndCol, CellMatrix, HyperlinkEntry, Selection, Presence, Sheet, GlobalCache, SingleRange, Range, SearchResult, LinkCardProps, LiveQueryData, Freezen, DefinedName, } from './types';
15
15
  export type { RemoveDuplicatesColumnOption, RemoveDuplicatesError, RemoveDuplicatesOptions, RemoveDuplicatesPreview, RemoveDuplicatesResult, } from './modules';
16
16
  export type { CheckModes, HyperlinkMap, FindSearchScope, ReplaceScope, SearchHiddenConfig, SearchNextResult, ReplaceAllResult, } from './modules/searchReplace';
17
17
  export { cellFadeAnimator, markCellChanged } from './animate';
@@ -28,6 +28,17 @@ export type SnapshotEvalInput = {
28
28
  f: unknown;
29
29
  }>;
30
30
  formulas: SnapshotFormulaCell[];
31
+ /** Workbook-level named ranges for VARIABLE resolution. */
32
+ definedNames?: Array<{
33
+ name: string;
34
+ sheetId: string;
35
+ range: {
36
+ row: [number, number];
37
+ column: [number, number];
38
+ };
39
+ scope?: 'workbook' | 'sheet';
40
+ localSheetId?: string;
41
+ }>;
31
42
  };
32
43
  export type SnapshotEvalOutput = {
33
44
  execFunctionGlobalData: Record<string, {
@@ -31,6 +31,11 @@ export declare class FormulaCache {
31
31
  /** True after arrow/Shift+arrow moved `func_selectedrange` without updating yellow selection. */
32
32
  formulaKeyboardRefSync?: boolean;
33
33
  formulaEditorOwner?: 'cell' | 'fx' | null;
34
+ /**
35
+ * Set when switching sheets while a formula edit stays open so InputBox/Fx
36
+ * can restore focus/caret for continued keyboard ref picking.
37
+ */
38
+ refocusFormulaEditorAfterSheetSwitch?: boolean;
34
39
  functionRangeIndex?: number[];
35
40
  functionRangeGlobalOffset?: number | null;
36
41
  functionlistMap: any;
@@ -80,6 +85,11 @@ export declare function groupValuesRefresh(ctx: Context): void;
80
85
  export declare function applyWorkerFormulaChunkResults(ctx: Context, output: SnapshotEvalOutput, impactedByCircular: Set<string>, cycleNodes: Set<string>, calcChainKeys?: string[], data?: CellMatrix | null): void;
81
86
  /** Run up to `chunkSize` formulas from an async job. Returns true when job is complete. */
82
87
  export declare function runFormulaEvalChunk(ctx: Context, job: FormulaAsyncEvalJob, chunkSize?: number): boolean;
88
+ /**
89
+ * Re-evaluate formula cells that reference the given defined names
90
+ * (e.g. after a named range was edited, shifted, or deleted).
91
+ */
92
+ export declare function refreshFormulasUsingDefinedNames(ctx: Context, names: string[]): void;
83
93
  export declare function execFunctionGroup(ctx: Context, origin_r: number, origin_c: number, value: any, id?: string, data?: any, isForce?: boolean): void;
84
94
  /**
85
95
  * Before the first `moveHighlightCell/Range(..., "rangeOfFormula")` while editing
@@ -102,6 +112,23 @@ export declare function getLastFormulaRangeIndex($editor: HTMLDivElement): numbe
102
112
  export declare function getFormulaRangeIndexAtCaret($editor: HTMLDivElement): number | null;
103
113
  export declare function setFormulaEditorOwner(ctx: Context, owner: 'cell' | 'fx' | null): void;
104
114
  export declare function getFormulaEditorOwner(ctx: Context): 'cell' | 'fx' | null;
115
+ /**
116
+ * Record the sheet where the formula edit started so cross-sheet picks can emit
117
+ * `SheetName!A1` via `rangeSetValue` / `getRangetxt`.
118
+ */
119
+ export declare function ensureFormulaRangeToSheet(ctx: Context): void;
120
+ /** True while an in-cell / fx formula edit should survive sheet-tab switches. */
121
+ export declare function shouldPreserveFormulaEditOnSheetSwitch(ctx: Context): boolean;
122
+ /**
123
+ * Activate another sheet from tab click or Alt/Option+Arrow navigation.
124
+ * Returns whether the sheet changed and whether formula edit was preserved.
125
+ */
126
+ export declare function activateSheetForNavigation(ctx: Context, targetSheetId: string): 'preserved-formula' | 'cancel-edit' | false;
127
+ /**
128
+ * Switch back to the formula's origin sheet (and restore its scroll/selection)
129
+ * before commit or cancel. Returns true when a switch happened.
130
+ */
131
+ export declare function returnToFormulaOriginSheet(ctx: Context): boolean;
105
132
  /**
106
133
  * True when the formula text looks like a truncated A1-style range: LHS has a row
107
134
  * number but RHS after ":" is only column letters (e.g. =A1:A after deleting the
@@ -0,0 +1,8 @@
1
+ import { Image } from '../types';
2
+
3
+ export declare function getImageClipboard(): Image | null;
4
+ export declare function getImageCutSourceId(): string | null;
5
+ export declare function getImageCutSourceSheetId(): string | null;
6
+ export declare function setImageClipboard(img: Image | null, asCut?: boolean, sheetId?: string | null): void;
7
+ export declare function clearImageClipboard(): void;
8
+ export declare function clearImageCutFlag(): void;
@@ -1,6 +1,7 @@
1
1
  import { GlobalCache } from '../types';
2
2
  import { Context } from '../context';
3
3
 
4
+ export { clearImageClipboard, getImageClipboard, getImageCutSourceId, getImageCutSourceSheetId, } from './image-clipboard';
4
5
  type ImageProps = {
5
6
  defaultWidth: number;
6
7
  defaultHeight: number;
@@ -22,6 +23,17 @@ export declare function showImgChooser(): void;
22
23
  export declare function saveImage(ctx: Context): void;
23
24
  export declare function removeActiveImage(ctx: Context): void;
24
25
  export declare function insertImage(ctx: Context, image: HTMLImageElement): void;
26
+ /** Copy/cut the currently selected floating image onto the clipboard. */
27
+ export declare function copyActiveImage(ctx: Context): boolean;
28
+ /**
29
+ * Cut: copy into the clipboard but keep the image on the sheet until paste
30
+ * (same deferred-remove behavior as cell Ctrl/Cmd+X).
31
+ */
32
+ export declare function cutActiveImage(ctx: Context): boolean;
33
+ /** Paste a previously copied floating image (or one encoded in paste HTML). */
34
+ export declare function pasteImageItem(ctx: Context, html?: string): boolean;
35
+ /** Load an image File (e.g. from the system clipboard) as an HTMLImageElement. */
36
+ export declare function loadImageFromFile(file: File): Promise<HTMLImageElement | null>;
25
37
  export declare function cancelActiveImgItem(ctx: Context, globalCache: GlobalCache): void;
26
38
  export declare function onImageMoveStart(ctx: Context, globalCache: GlobalCache, e: MouseEvent): void;
27
39
  export declare function onImageMove(ctx: Context, globalCache: GlobalCache, e: MouseEvent): boolean;
@@ -29,4 +41,3 @@ export declare function onImageMoveEnd(ctx: Context, globalCache: GlobalCache):
29
41
  export declare function onImageResizeStart(globalCache: GlobalCache, e: MouseEvent, resizingSide: string): void;
30
42
  export declare function onImageResize(ctx: Context, globalCache: GlobalCache, e: MouseEvent): boolean;
31
43
  export declare function onImageResizeEnd(ctx: Context, globalCache: GlobalCache): void;
32
- export {};
@@ -4,7 +4,7 @@ export { default as clipboard } from './clipboard';
4
4
  export { moveToEnd, getRangeRectsByCharacterOffset } from './cursor';
5
5
  export { getDateBaseLocale, getCanonicalDateEditFormat, getDateEditFormatForCell, isUsDateBaseLocale, normalizeDateBaseLocale, shouldPreserveDateFormatForEdit, setDateBaseLocale, } from './date-base-locale';
6
6
  export { update, is_date, valueShowEs, isTypedCurrencyDisplayFormat, isCurrencyLikeNumberFormat, buildFiatCurrencyFormat, quoteSsfLiteral, } from './format';
7
- export { FormulaCache, groupValuesRefresh, setCaretPosition, getrangeseleciton, getFormulaEditorOwner, rangeHightlightselected, handleFormulaInput, israngeseleciton, createRangeHightlight, createFormulaRangeSelect, maybeRecoverDirtyRangeSelection, delFunctionGroup, functionHTMLGenerate, onFormulaRangeDragEnd, rangeDrag, rangeSetValue, remapFormulaReferencesByMap, getFormulaRangeIndexAtCaret, isCaretAtValidFormulaRangeInsertionPoint, isLegacyFormulaRangeMode, markRangeSelectionDirty, getFormulaRangeIndexForKeyboardSync, isFormulaReferenceInputMode, seedFormulaFuncSelectedRangeFromLastSelection, functionStrChange, setFormulaEditorOwner, getAllFunctionGroup, suppressFormulaRangeSelectionForInitialEdit, } from './formula';
7
+ export { FormulaCache, groupValuesRefresh, setCaretPosition, getrangeseleciton, getFormulaEditorOwner, rangeHightlightselected, handleFormulaInput, israngeseleciton, createRangeHightlight, createFormulaRangeSelect, maybeRecoverDirtyRangeSelection, delFunctionGroup, functionHTMLGenerate, onFormulaRangeDragEnd, rangeDrag, rangeSetValue, remapFormulaReferencesByMap, getFormulaRangeIndexAtCaret, isCaretAtValidFormulaRangeInsertionPoint, isLegacyFormulaRangeMode, markRangeSelectionDirty, getFormulaRangeIndexForKeyboardSync, isFormulaReferenceInputMode, seedFormulaFuncSelectedRangeFromLastSelection, functionStrChange, setFormulaEditorOwner, getAllFunctionGroup, suppressFormulaRangeSelectionForInitialEdit, ensureFormulaRangeToSheet, shouldPreserveFormulaEditOnSheetSwitch, activateSheetForNavigation, returnToFormulaOriginSheet, } from './formula';
8
8
  export { FORMULA_ASYNC_CHUNK_SIZE, FORMULA_ASYNC_EVAL_THRESHOLD, FORMULA_WORKER_CHUNK_SIZE, FORMULA_WORKER_THRESHOLD, isFormulaEvalPending, } from './formula-async-eval';
9
9
  export type { FormulaAsyncEvalJob } from './formula-async-eval';
10
10
  export { initFreeze } from './freeze';
@@ -17,7 +17,7 @@ export { addSheet, deleteSheet, editSheetName, changeSheet, updateSheet, } from
17
17
  export { updateFormat, autoSelectionFormula, handleBold, handleItalic, handleStrikeThrough, handleUnderline, handleHorizontalAlign, handleVerticalAlign, handleTextColor, handleTextBackground, handleBorder, handleMerge, handleSort, handleFreeze, handleTextSize, handleSum, handleLink, captureLinkEditorOpenSnapshot, isHyperlinkCreationBlocked, toolbarItemClickHandler, toolbarItemSelectedFunc, updateFormatCell, cancelPaintModel, } from './toolbar';
18
18
  export { handleScreenShot } from './screenshot';
19
19
  export { drawArrow, setEditingComment, removeEditingComment, newComment, editComment, deleteComment, showComments, showHideComment, showHideAllComments, getCommentBoxByRC, onCommentBoxMoveStart, onCommentBoxMove, onCommentBoxMoveEnd, onCommentBoxResize, onCommentBoxResizeEnd, removeOverShowComment, } from './comment';
20
- export { showImgChooser, insertImage, removeActiveImage, cancelActiveImgItem, onImageMoveStart, onImageResizeStart, onImageMove, onImageMoveEnd, onImageResize, onImageResizeEnd, } from './image';
20
+ export { showImgChooser, insertImage, removeActiveImage, copyActiveImage, cutActiveImage, pasteImageItem, loadImageFromFile, getImageClipboard, getImageCutSourceId, cancelActiveImgItem, onImageMoveStart, onImageResizeStart, onImageMove, onImageMoveEnd, onImageResize, onImageResizeEnd, } from './image';
21
21
  export { createDropCellRange, dropCellCache, getTypeItemHide, updateDropCell, } from './dropCell';
22
22
  export { mergeCells, mergeSelectionHasValues } from './merge';
23
23
  export { getRemoveDuplicatesPreview, removeDuplicates, getRemoveDuplicatesErrorMessage, } from './removeDuplicates';
@@ -42,6 +42,7 @@ export { sanitizeDuneUrl, insertDuneChart, onIframeMoveStart, onIframeResizeStar
42
42
  export { setCellError, clearCellError, overShowError, } from './error-state-helpers';
43
43
  export { checkCellIsLocked } from './protection';
44
44
  export { detectDateFormat, isdatatypemulti, diff, isdatetime, isRealNull, isRealNum, isNumericCellType, } from './validation';
45
- export { iscelldata, getcellrange, execfunction, execFunctionGroup, runFormulaEvalChunk, applyWorkerFormulaChunkResults, insertUpdateFunctionGroup, functionCopy, } from './formula';
45
+ export { iscelldata, getcellrange, execfunction, execFunctionGroup, refreshFormulasUsingDefinedNames, runFormulaEvalChunk, applyWorkerFormulaChunkResults, insertUpdateFunctionGroup, functionCopy, } from './formula';
46
46
  export { checkCF, getComputeMap } from './ConditionFormat';
47
+ export { isValidDefinedNameIdentifier, getDefinedNameDisplayRange, findDefinedNameForSelection, findDefinedNameByName, resolveDefinedNameForFormula, addDefinedName, updateDefinedName, deleteDefinedName, selectDefinedName, openNamedRangesSidebar, scheduleDefinedNamesSync, shiftDefinedNamesOnInsert, shiftDefinedNamesOnDelete, removeDefinedNamesForSheet, } from './namedRanges';
47
48
  export { getdatabyselection, getQKBorder } from './cell';
@@ -0,0 +1,53 @@
1
+ import { Context } from '../context';
2
+ import { DefinedName, SingleRange } from '../types';
3
+
4
+ /** Excel/Google: names must start with letter/underscore; no spaces; not a cell ref. */
5
+ export declare function isValidDefinedNameIdentifier(name: string): boolean;
6
+ export declare function getDefinedNameDisplayRange(ctx: Context, dn: DefinedName): string;
7
+ export declare function findDefinedNameForSelection(ctx: Context): DefinedName | null;
8
+ export declare function findDefinedNameByName(ctx: Context, name: string, excludeId?: string): DefinedName | null;
9
+ /**
10
+ * Resolve a formula VARIABLE (e.g. `=SUM(Custom)`) to a defined name.
11
+ * Prefers sheet-scoped names matching `formulaSheetId`, then workbook-scoped.
12
+ */
13
+ export declare function resolveDefinedNameForFormula(definedNames: DefinedName[] | undefined | null, name: string, formulaSheetId?: string): DefinedName | null;
14
+ export declare function addDefinedName(ctx: Context, input: {
15
+ name: string;
16
+ sheetId: string;
17
+ range: SingleRange;
18
+ scope?: DefinedName['scope'];
19
+ localSheetId?: string;
20
+ }): {
21
+ ok: true;
22
+ namedRange: DefinedName;
23
+ } | {
24
+ ok: false;
25
+ error: string;
26
+ };
27
+ export declare function updateDefinedName(ctx: Context, id: string, patch: {
28
+ name?: string;
29
+ sheetId?: string;
30
+ range?: SingleRange;
31
+ }): {
32
+ ok: true;
33
+ namedRange: DefinedName;
34
+ } | {
35
+ ok: false;
36
+ error: string;
37
+ };
38
+ export declare function deleteDefinedName(ctx: Context, id: string): boolean;
39
+ /** Jump to a named range (switch sheet if needed) and select its cells. */
40
+ export declare function selectDefinedName(ctx: Context, id: string): boolean;
41
+ export declare function openNamedRangesSidebar(): void;
42
+ /**
43
+ * Defer Yjs sync until after Immer applies the draft (same pattern as
44
+ * sheet-metadata-hooks). Capture the hook fn — not `ctx.hooks` — so the
45
+ * draft proxy is not read after revoke.
46
+ */
47
+ export declare function scheduleDefinedNamesSync(ctx: Context): void;
48
+ /** Shift named ranges on the given sheet after row/col insert. Returns affected names. */
49
+ export declare function shiftDefinedNamesOnInsert(ctx: Context, sheetId: string, type: 'row' | 'column', index: number, count: number, direction: 'lefttop' | 'rightbottom'): string[];
50
+ /** Shift/remove named ranges on the given sheet after row/col delete. */
51
+ export declare function shiftDefinedNamesOnDelete(ctx: Context, sheetId: string, type: 'row' | 'column', start: number, end: number): string[];
52
+ /** Drop named ranges that pointed at a deleted sheet. */
53
+ export declare function removeDefinedNamesForSheet(ctx: Context, deletedSheetId: string): string[];
@@ -22,6 +22,8 @@ export type Hooks = {
22
22
  filterChange?: () => void;
23
23
  cellDataChange?: () => void;
24
24
  hyperlinkChange?: () => void;
25
+ /** Workbook-level named ranges (definedNames) changed — sync to Yjs. */
26
+ definedNamesChange?: () => void;
25
27
  updateCellYdoc?: (changes: SheetChangePath[]) => void;
26
28
  updateAllCell?: (sheetId: string, caller?: string) => void;
27
29
  beforeUpdateCell?: (r: number, c: number, value: any) => boolean;
@@ -147,6 +147,23 @@ export type SheetConfig = {
147
147
  rowReadOnly?: Record<number, number>;
148
148
  colReadOnly?: Record<number, number>;
149
149
  };
150
+ /**
151
+ * Workbook-level named range (Google Sheets / Excel definedNames).
152
+ * Runtime list lives on Context; persisted in Yjs as `${dsheetId}:definedNames`.
153
+ */
154
+ export type DefinedName = {
155
+ id: string;
156
+ name: string;
157
+ sheetId: string;
158
+ range: {
159
+ row: [number, number];
160
+ column: [number, number];
161
+ };
162
+ scope: 'workbook' | 'sheet';
163
+ /** When scope === 'sheet', which sheet owns the name. */
164
+ localSheetId?: string;
165
+ comment?: string;
166
+ };
150
167
  export type Image = {
151
168
  id: string;
152
169
  width: number;
@@ -154,6 +171,8 @@ export type Image = {
154
171
  left: number;
155
172
  top: number;
156
173
  src: string;
174
+ originWidth?: number;
175
+ originHeight?: number;
157
176
  };
158
177
  export type ConditionRulesProps = {
159
178
  editKey?: string | null;
@@ -0,0 +1,4 @@
1
+ import { default as React } from 'react';
2
+
3
+ declare const NamedRanges: React.FC;
4
+ export default NamedRanges;