@coco-vexel/coco-office-editor 1.0.0 → 1.0.2
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/README.md +33 -1
- package/THIRD_PARTY_NOTICES.md +3 -3
- package/dist/index.cjs +352 -99
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +5 -4
- package/dist/index.d.ts +5 -4
- package/dist/index.js +353 -101
- package/dist/index.js.map +1 -1
- package/dist/{model-DB6aN6uJ.d.cts → model-DNNBhhCB.d.cts} +4 -3
- package/dist/{model-DB6aN6uJ.d.ts → model-DNNBhhCB.d.ts} +4 -3
- package/dist/{native-B6B649CC.d.ts → native-OrEUvS8p.d.ts} +5 -1
- package/dist/native-TMv552dv.d.cts +317 -0
- package/dist/native-TMv552dv.d.ts +317 -0
- package/dist/{native-Ct9nN06K.d.cts → native-f2y3N8N5.d.cts} +5 -1
- package/dist/ppt-native.cjs +129 -59
- package/dist/ppt-native.cjs.map +1 -1
- package/dist/ppt-native.d.cts +1 -1
- package/dist/ppt-native.d.ts +1 -1
- package/dist/ppt-native.js +130 -60
- package/dist/ppt-native.js.map +1 -1
- package/dist/ppt.cjs +129 -58
- package/dist/ppt.cjs.map +1 -1
- package/dist/ppt.d.cts +3 -306
- package/dist/ppt.d.ts +3 -306
- package/dist/ppt.js +130 -60
- package/dist/ppt.js.map +1 -1
- package/dist/read-only-1_LQCO1d.d.cts +7 -0
- package/dist/read-only-1_LQCO1d.d.ts +7 -0
- package/dist/spreadsheet.cjs +114 -17
- package/dist/spreadsheet.cjs.map +1 -1
- package/dist/spreadsheet.d.cts +15 -3
- package/dist/spreadsheet.d.ts +15 -3
- package/dist/spreadsheet.js +114 -18
- package/dist/spreadsheet.js.map +1 -1
- package/dist/word-editing.d.cts +1 -1
- package/dist/word-editing.d.ts +1 -1
- package/dist/word-native.cjs +132 -23
- package/dist/word-native.cjs.map +1 -1
- package/dist/word-native.d.cts +2 -2
- package/dist/word-native.d.ts +2 -2
- package/dist/word-native.js +132 -23
- package/dist/word-native.js.map +1 -1
- package/dist/word-prosemirror.d.cts +1 -1
- package/dist/word-prosemirror.d.ts +1 -1
- package/dist/word.cjs +145 -23
- package/dist/word.cjs.map +1 -1
- package/dist/word.d.cts +5 -4
- package/dist/word.d.ts +5 -4
- package/dist/word.js +145 -24
- package/dist/word.js.map +1 -1
- package/package.json +10 -10
- package/src/styles/editor.css +1 -0
package/dist/spreadsheet.d.cts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
export { E as EditorReadOnlyError } from './read-only-1_LQCO1d.cjs';
|
|
1
2
|
import { ExcelSheetModel, ExcelStylesModel, ExcelCellKind, ExcelCellValue, ExcelCellModel, ExcelRowModel, ExcelColumnModel, ExcelMergedRangeModel, SpreadsheetFormulaResult, ExcelPaneModel, ExcelBorderModel, ExcelWorkbook, ExcelWorkbookLoadOptions, ExcelWorkbookModel, ExcelHistoryApplyResult, ExcelTransactionGroupOptions, ExcelAgentTransactionGroupOptions, ExcelTransactionGroupSummary, ExcelWorkbookDiff, ExcelColorModel, SpreadsheetFormulaEngine } from '@coco-vexel/coco-office/excel';
|
|
2
3
|
|
|
3
4
|
interface SpreadsheetPoint {
|
|
@@ -322,6 +323,9 @@ declare function spreadsheetRowsForFilter(model: SpreadsheetSheetRenderModel, ra
|
|
|
322
323
|
declare function spreadsheetRowsForColumnFilters(model: SpreadsheetSheetRenderModel, range: SpreadsheetRange, filters: readonly SpreadsheetColumnFilter[]): number[];
|
|
323
324
|
declare function spreadsheetSortRows(model: SpreadsheetSheetRenderModel, range: SpreadsheetRange, column: number, direction: SpreadsheetSortDirection): number[];
|
|
324
325
|
|
|
326
|
+
interface SpreadsheetEditorRuntimeOptions {
|
|
327
|
+
readOnly?: boolean;
|
|
328
|
+
}
|
|
325
329
|
interface SpreadsheetEditorRuntimeState {
|
|
326
330
|
workbook: ExcelWorkbook;
|
|
327
331
|
model: ExcelWorkbookModel;
|
|
@@ -377,9 +381,12 @@ declare class SpreadsheetEditorRuntime {
|
|
|
377
381
|
private activeTransaction;
|
|
378
382
|
private activeTransactionSource;
|
|
379
383
|
private transactionNeedsRefresh;
|
|
384
|
+
private readOnlyValue;
|
|
380
385
|
private constructor();
|
|
381
|
-
static fromZip(bytes: Uint8Array | ArrayBuffer, options?: ExcelWorkbookLoadOptions): Promise<SpreadsheetEditorRuntime>;
|
|
382
|
-
static fromWorkbook(workbook: ExcelWorkbook): Promise<SpreadsheetEditorRuntime>;
|
|
386
|
+
static fromZip(bytes: Uint8Array | ArrayBuffer, options?: ExcelWorkbookLoadOptions & SpreadsheetEditorRuntimeOptions): Promise<SpreadsheetEditorRuntime>;
|
|
387
|
+
static fromWorkbook(workbook: ExcelWorkbook, options?: SpreadsheetEditorRuntimeOptions): Promise<SpreadsheetEditorRuntime>;
|
|
388
|
+
isReadOnly(): boolean;
|
|
389
|
+
setReadOnly(readOnly: boolean): void;
|
|
383
390
|
workbook(): ExcelWorkbook;
|
|
384
391
|
model(): ExcelWorkbookModel;
|
|
385
392
|
activeSheetName(): string;
|
|
@@ -450,6 +457,7 @@ declare class SpreadsheetEditorRuntime {
|
|
|
450
457
|
private runWorksheetStructureMutation;
|
|
451
458
|
private cellStyleId;
|
|
452
459
|
private runScopedTransaction;
|
|
460
|
+
private assertWritable;
|
|
453
461
|
private cellEditHistoryGroup;
|
|
454
462
|
private range;
|
|
455
463
|
}
|
|
@@ -617,6 +625,8 @@ interface SpreadsheetEditorCellState {
|
|
|
617
625
|
}
|
|
618
626
|
interface SpreadsheetEditorOptions {
|
|
619
627
|
workbookId?: string;
|
|
628
|
+
/** Allows navigation, selection and copy while blocking every workbook mutation. */
|
|
629
|
+
readOnly?: boolean;
|
|
620
630
|
onChange?: (event: SpreadsheetEditorChangeEvent) => void | Promise<void>;
|
|
621
631
|
showSheetTabs?: boolean;
|
|
622
632
|
/** Isolates editor internals from host-page CSS. Shadow DOM is enabled by default. */
|
|
@@ -626,6 +636,8 @@ interface SpreadsheetEditorOptions {
|
|
|
626
636
|
}
|
|
627
637
|
interface SpreadsheetEditor {
|
|
628
638
|
runtime(): SpreadsheetEditorRuntime;
|
|
639
|
+
isReadOnly(): boolean;
|
|
640
|
+
setReadOnly(readOnly: boolean): void;
|
|
629
641
|
selection(): SpreadsheetSelectionState;
|
|
630
642
|
cellState(address: string): SpreadsheetEditorCellState;
|
|
631
643
|
freezeState(): SpreadsheetFreezeState;
|
|
@@ -673,4 +685,4 @@ interface SpreadsheetEditor {
|
|
|
673
685
|
*/
|
|
674
686
|
declare function renderSpreadsheetEditor(host: HTMLElement, bytes: Uint8Array | ArrayBuffer, options?: SpreadsheetEditorOptions): Promise<SpreadsheetEditor>;
|
|
675
687
|
|
|
676
|
-
export { type BuildSpreadsheetRenderModelOptions, SPREADSHEET_COLUMN_RESIZE_MIN, SPREADSHEET_RESIZE_HIT_TOLERANCE, SPREADSHEET_ROW_RESIZE_MIN, type SpreadsheetAgentAction, type SpreadsheetAgentActionApplyResult, type SpreadsheetAgentActionContext, type SpreadsheetAgentActionPreview, type SpreadsheetAgentTransactionPreview, type SpreadsheetAgentTransactionRunner, type SpreadsheetAutoFillCell, type SpreadsheetAutoFillDirection, type SpreadsheetAutoFillPlan, SpreadsheetCanvasRenderer, type SpreadsheetCanvasRendererOptions, type SpreadsheetCellEditHistoryOptions, SpreadsheetCellEditor, type SpreadsheetCellEditorOptions, type SpreadsheetClipboardMerge, type SpreadsheetClipboardPayload, type SpreadsheetColumnFilter, type SpreadsheetEditor, type SpreadsheetEditorCellState, type SpreadsheetEditorChangeEvent, type SpreadsheetEditorOptions, SpreadsheetEditorRuntime, type SpreadsheetEditorRuntimeState, type SpreadsheetEditorStateEvent, type SpreadsheetFindMatch, type SpreadsheetFindOptions, type SpreadsheetFreezeState, type SpreadsheetHitCell, type SpreadsheetHitColumnHeader, type SpreadsheetHitCorner, type SpreadsheetHitNone, type SpreadsheetHitResult, type SpreadsheetHitRowHeader, SpreadsheetLayout, type SpreadsheetLayoutOptions, type SpreadsheetMergeInfo, type SpreadsheetMixedValue, type SpreadsheetPasteMode, type SpreadsheetPasteOptions, type SpreadsheetPoint, type SpreadsheetPreviewCellChangeSummary, type SpreadsheetPreviewDiffSummary, type SpreadsheetRange, type SpreadsheetRect, type SpreadsheetRenderCell, type SpreadsheetReplaceTarget, type SpreadsheetResizeDragState, type SpreadsheetResizeHandle, type SpreadsheetResolvedCellStyle, type SpreadsheetScrollState, type SpreadsheetScrollbarGeometry, type SpreadsheetScrollbarState, type SpreadsheetSelectionFormatState, type SpreadsheetSelectionState, type SpreadsheetSheetRenderModel, type SpreadsheetSize, type SpreadsheetSortDirection, type SpreadsheetUserTransactionOptions, type SpreadsheetViewport, type SpreadsheetViewportKind, SpreadsheetViewportManager, type SpreadsheetViewportManagerOptions, type SpreadsheetViewportState, applySpreadsheetAgentAction, applyWheelDelta, buildSpreadsheetAutoFillPlan, buildSpreadsheetClipboardPayload, buildSpreadsheetReplacePlan, buildSpreadsheetSheetRenderModel, clampScroll, clearSpreadsheetRange, computeScrollbarState, createColumnRangeSelection, createColumnSelection, createRowRangeSelection, createRowSelection, createSelection, cssPixelsToExcelColumnWidth, excelColumnWidthToCssPixels, expandRangeForMergedRanges, expandSelectionForMergedRanges, extendSelection, findSpreadsheetMatches, formatSpreadsheetDisplayValue, freezeStateFromPane, freezeStateFromSheet, getRenderCell, hitSpreadsheetResizeHandle, moveSelection, nextSpreadsheetMatch, normalizeSelectionRange, parseTsv, previewSpreadsheetAgentAction, rangeAddressForMatrix, rangeForSpreadsheetMatch, renderSpreadsheetEditor, resolveSpreadsheetCellStyle, resolveSpreadsheetRangeBorder, rowColumnKey, scrollFromThumbPosition, selectionAfterColumnDeletion, selectionAfterRowDeletion, serializeRangeToTsv, setSpreadsheetCellFormula, setSpreadsheetCellValue, setSpreadsheetColumnWidth, setSpreadsheetRangeValues, setSpreadsheetRowHeight, spreadsheetFilterValues, spreadsheetRowsForColumnFilters, spreadsheetRowsForFilter, spreadsheetSortRows, spreadsheetVisibleFilterValues, startSpreadsheetResizeDrag, summarizeSpreadsheetSelectionFormat, supportsSpreadsheetAutoFill, updateSpreadsheetResizeDrag };
|
|
688
|
+
export { type BuildSpreadsheetRenderModelOptions, SPREADSHEET_COLUMN_RESIZE_MIN, SPREADSHEET_RESIZE_HIT_TOLERANCE, SPREADSHEET_ROW_RESIZE_MIN, type SpreadsheetAgentAction, type SpreadsheetAgentActionApplyResult, type SpreadsheetAgentActionContext, type SpreadsheetAgentActionPreview, type SpreadsheetAgentTransactionPreview, type SpreadsheetAgentTransactionRunner, type SpreadsheetAutoFillCell, type SpreadsheetAutoFillDirection, type SpreadsheetAutoFillPlan, SpreadsheetCanvasRenderer, type SpreadsheetCanvasRendererOptions, type SpreadsheetCellEditHistoryOptions, SpreadsheetCellEditor, type SpreadsheetCellEditorOptions, type SpreadsheetClipboardMerge, type SpreadsheetClipboardPayload, type SpreadsheetColumnFilter, type SpreadsheetEditor, type SpreadsheetEditorCellState, type SpreadsheetEditorChangeEvent, type SpreadsheetEditorOptions, SpreadsheetEditorRuntime, type SpreadsheetEditorRuntimeOptions, type SpreadsheetEditorRuntimeState, type SpreadsheetEditorStateEvent, type SpreadsheetFindMatch, type SpreadsheetFindOptions, type SpreadsheetFreezeState, type SpreadsheetHitCell, type SpreadsheetHitColumnHeader, type SpreadsheetHitCorner, type SpreadsheetHitNone, type SpreadsheetHitResult, type SpreadsheetHitRowHeader, SpreadsheetLayout, type SpreadsheetLayoutOptions, type SpreadsheetMergeInfo, type SpreadsheetMixedValue, type SpreadsheetPasteMode, type SpreadsheetPasteOptions, type SpreadsheetPoint, type SpreadsheetPreviewCellChangeSummary, type SpreadsheetPreviewDiffSummary, type SpreadsheetRange, type SpreadsheetRect, type SpreadsheetRenderCell, type SpreadsheetReplaceTarget, type SpreadsheetResizeDragState, type SpreadsheetResizeHandle, type SpreadsheetResolvedCellStyle, type SpreadsheetScrollState, type SpreadsheetScrollbarGeometry, type SpreadsheetScrollbarState, type SpreadsheetSelectionFormatState, type SpreadsheetSelectionState, type SpreadsheetSheetRenderModel, type SpreadsheetSize, type SpreadsheetSortDirection, type SpreadsheetUserTransactionOptions, type SpreadsheetViewport, type SpreadsheetViewportKind, SpreadsheetViewportManager, type SpreadsheetViewportManagerOptions, type SpreadsheetViewportState, applySpreadsheetAgentAction, applyWheelDelta, buildSpreadsheetAutoFillPlan, buildSpreadsheetClipboardPayload, buildSpreadsheetReplacePlan, buildSpreadsheetSheetRenderModel, clampScroll, clearSpreadsheetRange, computeScrollbarState, createColumnRangeSelection, createColumnSelection, createRowRangeSelection, createRowSelection, createSelection, cssPixelsToExcelColumnWidth, excelColumnWidthToCssPixels, expandRangeForMergedRanges, expandSelectionForMergedRanges, extendSelection, findSpreadsheetMatches, formatSpreadsheetDisplayValue, freezeStateFromPane, freezeStateFromSheet, getRenderCell, hitSpreadsheetResizeHandle, moveSelection, nextSpreadsheetMatch, normalizeSelectionRange, parseTsv, previewSpreadsheetAgentAction, rangeAddressForMatrix, rangeForSpreadsheetMatch, renderSpreadsheetEditor, resolveSpreadsheetCellStyle, resolveSpreadsheetRangeBorder, rowColumnKey, scrollFromThumbPosition, selectionAfterColumnDeletion, selectionAfterRowDeletion, serializeRangeToTsv, setSpreadsheetCellFormula, setSpreadsheetCellValue, setSpreadsheetColumnWidth, setSpreadsheetRangeValues, setSpreadsheetRowHeight, spreadsheetFilterValues, spreadsheetRowsForColumnFilters, spreadsheetRowsForFilter, spreadsheetSortRows, spreadsheetVisibleFilterValues, startSpreadsheetResizeDrag, summarizeSpreadsheetSelectionFormat, supportsSpreadsheetAutoFill, updateSpreadsheetResizeDrag };
|
package/dist/spreadsheet.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
export { E as EditorReadOnlyError } from './read-only-1_LQCO1d.js';
|
|
1
2
|
import { ExcelSheetModel, ExcelStylesModel, ExcelCellKind, ExcelCellValue, ExcelCellModel, ExcelRowModel, ExcelColumnModel, ExcelMergedRangeModel, SpreadsheetFormulaResult, ExcelPaneModel, ExcelBorderModel, ExcelWorkbook, ExcelWorkbookLoadOptions, ExcelWorkbookModel, ExcelHistoryApplyResult, ExcelTransactionGroupOptions, ExcelAgentTransactionGroupOptions, ExcelTransactionGroupSummary, ExcelWorkbookDiff, ExcelColorModel, SpreadsheetFormulaEngine } from '@coco-vexel/coco-office/excel';
|
|
2
3
|
|
|
3
4
|
interface SpreadsheetPoint {
|
|
@@ -322,6 +323,9 @@ declare function spreadsheetRowsForFilter(model: SpreadsheetSheetRenderModel, ra
|
|
|
322
323
|
declare function spreadsheetRowsForColumnFilters(model: SpreadsheetSheetRenderModel, range: SpreadsheetRange, filters: readonly SpreadsheetColumnFilter[]): number[];
|
|
323
324
|
declare function spreadsheetSortRows(model: SpreadsheetSheetRenderModel, range: SpreadsheetRange, column: number, direction: SpreadsheetSortDirection): number[];
|
|
324
325
|
|
|
326
|
+
interface SpreadsheetEditorRuntimeOptions {
|
|
327
|
+
readOnly?: boolean;
|
|
328
|
+
}
|
|
325
329
|
interface SpreadsheetEditorRuntimeState {
|
|
326
330
|
workbook: ExcelWorkbook;
|
|
327
331
|
model: ExcelWorkbookModel;
|
|
@@ -377,9 +381,12 @@ declare class SpreadsheetEditorRuntime {
|
|
|
377
381
|
private activeTransaction;
|
|
378
382
|
private activeTransactionSource;
|
|
379
383
|
private transactionNeedsRefresh;
|
|
384
|
+
private readOnlyValue;
|
|
380
385
|
private constructor();
|
|
381
|
-
static fromZip(bytes: Uint8Array | ArrayBuffer, options?: ExcelWorkbookLoadOptions): Promise<SpreadsheetEditorRuntime>;
|
|
382
|
-
static fromWorkbook(workbook: ExcelWorkbook): Promise<SpreadsheetEditorRuntime>;
|
|
386
|
+
static fromZip(bytes: Uint8Array | ArrayBuffer, options?: ExcelWorkbookLoadOptions & SpreadsheetEditorRuntimeOptions): Promise<SpreadsheetEditorRuntime>;
|
|
387
|
+
static fromWorkbook(workbook: ExcelWorkbook, options?: SpreadsheetEditorRuntimeOptions): Promise<SpreadsheetEditorRuntime>;
|
|
388
|
+
isReadOnly(): boolean;
|
|
389
|
+
setReadOnly(readOnly: boolean): void;
|
|
383
390
|
workbook(): ExcelWorkbook;
|
|
384
391
|
model(): ExcelWorkbookModel;
|
|
385
392
|
activeSheetName(): string;
|
|
@@ -450,6 +457,7 @@ declare class SpreadsheetEditorRuntime {
|
|
|
450
457
|
private runWorksheetStructureMutation;
|
|
451
458
|
private cellStyleId;
|
|
452
459
|
private runScopedTransaction;
|
|
460
|
+
private assertWritable;
|
|
453
461
|
private cellEditHistoryGroup;
|
|
454
462
|
private range;
|
|
455
463
|
}
|
|
@@ -617,6 +625,8 @@ interface SpreadsheetEditorCellState {
|
|
|
617
625
|
}
|
|
618
626
|
interface SpreadsheetEditorOptions {
|
|
619
627
|
workbookId?: string;
|
|
628
|
+
/** Allows navigation, selection and copy while blocking every workbook mutation. */
|
|
629
|
+
readOnly?: boolean;
|
|
620
630
|
onChange?: (event: SpreadsheetEditorChangeEvent) => void | Promise<void>;
|
|
621
631
|
showSheetTabs?: boolean;
|
|
622
632
|
/** Isolates editor internals from host-page CSS. Shadow DOM is enabled by default. */
|
|
@@ -626,6 +636,8 @@ interface SpreadsheetEditorOptions {
|
|
|
626
636
|
}
|
|
627
637
|
interface SpreadsheetEditor {
|
|
628
638
|
runtime(): SpreadsheetEditorRuntime;
|
|
639
|
+
isReadOnly(): boolean;
|
|
640
|
+
setReadOnly(readOnly: boolean): void;
|
|
629
641
|
selection(): SpreadsheetSelectionState;
|
|
630
642
|
cellState(address: string): SpreadsheetEditorCellState;
|
|
631
643
|
freezeState(): SpreadsheetFreezeState;
|
|
@@ -673,4 +685,4 @@ interface SpreadsheetEditor {
|
|
|
673
685
|
*/
|
|
674
686
|
declare function renderSpreadsheetEditor(host: HTMLElement, bytes: Uint8Array | ArrayBuffer, options?: SpreadsheetEditorOptions): Promise<SpreadsheetEditor>;
|
|
675
687
|
|
|
676
|
-
export { type BuildSpreadsheetRenderModelOptions, SPREADSHEET_COLUMN_RESIZE_MIN, SPREADSHEET_RESIZE_HIT_TOLERANCE, SPREADSHEET_ROW_RESIZE_MIN, type SpreadsheetAgentAction, type SpreadsheetAgentActionApplyResult, type SpreadsheetAgentActionContext, type SpreadsheetAgentActionPreview, type SpreadsheetAgentTransactionPreview, type SpreadsheetAgentTransactionRunner, type SpreadsheetAutoFillCell, type SpreadsheetAutoFillDirection, type SpreadsheetAutoFillPlan, SpreadsheetCanvasRenderer, type SpreadsheetCanvasRendererOptions, type SpreadsheetCellEditHistoryOptions, SpreadsheetCellEditor, type SpreadsheetCellEditorOptions, type SpreadsheetClipboardMerge, type SpreadsheetClipboardPayload, type SpreadsheetColumnFilter, type SpreadsheetEditor, type SpreadsheetEditorCellState, type SpreadsheetEditorChangeEvent, type SpreadsheetEditorOptions, SpreadsheetEditorRuntime, type SpreadsheetEditorRuntimeState, type SpreadsheetEditorStateEvent, type SpreadsheetFindMatch, type SpreadsheetFindOptions, type SpreadsheetFreezeState, type SpreadsheetHitCell, type SpreadsheetHitColumnHeader, type SpreadsheetHitCorner, type SpreadsheetHitNone, type SpreadsheetHitResult, type SpreadsheetHitRowHeader, SpreadsheetLayout, type SpreadsheetLayoutOptions, type SpreadsheetMergeInfo, type SpreadsheetMixedValue, type SpreadsheetPasteMode, type SpreadsheetPasteOptions, type SpreadsheetPoint, type SpreadsheetPreviewCellChangeSummary, type SpreadsheetPreviewDiffSummary, type SpreadsheetRange, type SpreadsheetRect, type SpreadsheetRenderCell, type SpreadsheetReplaceTarget, type SpreadsheetResizeDragState, type SpreadsheetResizeHandle, type SpreadsheetResolvedCellStyle, type SpreadsheetScrollState, type SpreadsheetScrollbarGeometry, type SpreadsheetScrollbarState, type SpreadsheetSelectionFormatState, type SpreadsheetSelectionState, type SpreadsheetSheetRenderModel, type SpreadsheetSize, type SpreadsheetSortDirection, type SpreadsheetUserTransactionOptions, type SpreadsheetViewport, type SpreadsheetViewportKind, SpreadsheetViewportManager, type SpreadsheetViewportManagerOptions, type SpreadsheetViewportState, applySpreadsheetAgentAction, applyWheelDelta, buildSpreadsheetAutoFillPlan, buildSpreadsheetClipboardPayload, buildSpreadsheetReplacePlan, buildSpreadsheetSheetRenderModel, clampScroll, clearSpreadsheetRange, computeScrollbarState, createColumnRangeSelection, createColumnSelection, createRowRangeSelection, createRowSelection, createSelection, cssPixelsToExcelColumnWidth, excelColumnWidthToCssPixels, expandRangeForMergedRanges, expandSelectionForMergedRanges, extendSelection, findSpreadsheetMatches, formatSpreadsheetDisplayValue, freezeStateFromPane, freezeStateFromSheet, getRenderCell, hitSpreadsheetResizeHandle, moveSelection, nextSpreadsheetMatch, normalizeSelectionRange, parseTsv, previewSpreadsheetAgentAction, rangeAddressForMatrix, rangeForSpreadsheetMatch, renderSpreadsheetEditor, resolveSpreadsheetCellStyle, resolveSpreadsheetRangeBorder, rowColumnKey, scrollFromThumbPosition, selectionAfterColumnDeletion, selectionAfterRowDeletion, serializeRangeToTsv, setSpreadsheetCellFormula, setSpreadsheetCellValue, setSpreadsheetColumnWidth, setSpreadsheetRangeValues, setSpreadsheetRowHeight, spreadsheetFilterValues, spreadsheetRowsForColumnFilters, spreadsheetRowsForFilter, spreadsheetSortRows, spreadsheetVisibleFilterValues, startSpreadsheetResizeDrag, summarizeSpreadsheetSelectionFormat, supportsSpreadsheetAutoFill, updateSpreadsheetResizeDrag };
|
|
688
|
+
export { type BuildSpreadsheetRenderModelOptions, SPREADSHEET_COLUMN_RESIZE_MIN, SPREADSHEET_RESIZE_HIT_TOLERANCE, SPREADSHEET_ROW_RESIZE_MIN, type SpreadsheetAgentAction, type SpreadsheetAgentActionApplyResult, type SpreadsheetAgentActionContext, type SpreadsheetAgentActionPreview, type SpreadsheetAgentTransactionPreview, type SpreadsheetAgentTransactionRunner, type SpreadsheetAutoFillCell, type SpreadsheetAutoFillDirection, type SpreadsheetAutoFillPlan, SpreadsheetCanvasRenderer, type SpreadsheetCanvasRendererOptions, type SpreadsheetCellEditHistoryOptions, SpreadsheetCellEditor, type SpreadsheetCellEditorOptions, type SpreadsheetClipboardMerge, type SpreadsheetClipboardPayload, type SpreadsheetColumnFilter, type SpreadsheetEditor, type SpreadsheetEditorCellState, type SpreadsheetEditorChangeEvent, type SpreadsheetEditorOptions, SpreadsheetEditorRuntime, type SpreadsheetEditorRuntimeOptions, type SpreadsheetEditorRuntimeState, type SpreadsheetEditorStateEvent, type SpreadsheetFindMatch, type SpreadsheetFindOptions, type SpreadsheetFreezeState, type SpreadsheetHitCell, type SpreadsheetHitColumnHeader, type SpreadsheetHitCorner, type SpreadsheetHitNone, type SpreadsheetHitResult, type SpreadsheetHitRowHeader, SpreadsheetLayout, type SpreadsheetLayoutOptions, type SpreadsheetMergeInfo, type SpreadsheetMixedValue, type SpreadsheetPasteMode, type SpreadsheetPasteOptions, type SpreadsheetPoint, type SpreadsheetPreviewCellChangeSummary, type SpreadsheetPreviewDiffSummary, type SpreadsheetRange, type SpreadsheetRect, type SpreadsheetRenderCell, type SpreadsheetReplaceTarget, type SpreadsheetResizeDragState, type SpreadsheetResizeHandle, type SpreadsheetResolvedCellStyle, type SpreadsheetScrollState, type SpreadsheetScrollbarGeometry, type SpreadsheetScrollbarState, type SpreadsheetSelectionFormatState, type SpreadsheetSelectionState, type SpreadsheetSheetRenderModel, type SpreadsheetSize, type SpreadsheetSortDirection, type SpreadsheetUserTransactionOptions, type SpreadsheetViewport, type SpreadsheetViewportKind, SpreadsheetViewportManager, type SpreadsheetViewportManagerOptions, type SpreadsheetViewportState, applySpreadsheetAgentAction, applyWheelDelta, buildSpreadsheetAutoFillPlan, buildSpreadsheetClipboardPayload, buildSpreadsheetReplacePlan, buildSpreadsheetSheetRenderModel, clampScroll, clearSpreadsheetRange, computeScrollbarState, createColumnRangeSelection, createColumnSelection, createRowRangeSelection, createRowSelection, createSelection, cssPixelsToExcelColumnWidth, excelColumnWidthToCssPixels, expandRangeForMergedRanges, expandSelectionForMergedRanges, extendSelection, findSpreadsheetMatches, formatSpreadsheetDisplayValue, freezeStateFromPane, freezeStateFromSheet, getRenderCell, hitSpreadsheetResizeHandle, moveSelection, nextSpreadsheetMatch, normalizeSelectionRange, parseTsv, previewSpreadsheetAgentAction, rangeAddressForMatrix, rangeForSpreadsheetMatch, renderSpreadsheetEditor, resolveSpreadsheetCellStyle, resolveSpreadsheetRangeBorder, rowColumnKey, scrollFromThumbPosition, selectionAfterColumnDeletion, selectionAfterRowDeletion, serializeRangeToTsv, setSpreadsheetCellFormula, setSpreadsheetCellValue, setSpreadsheetColumnWidth, setSpreadsheetRangeValues, setSpreadsheetRowHeight, spreadsheetFilterValues, spreadsheetRowsForColumnFilters, spreadsheetRowsForFilter, spreadsheetSortRows, spreadsheetVisibleFilterValues, startSpreadsheetResizeDrag, summarizeSpreadsheetSelectionFormat, supportsSpreadsheetAutoFill, updateSpreadsheetResizeDrag };
|
package/dist/spreadsheet.js
CHANGED
|
@@ -20,8 +20,31 @@ var __spreadValues = (a, b) => {
|
|
|
20
20
|
};
|
|
21
21
|
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
22
22
|
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
23
|
+
var __objRest = (source, exclude) => {
|
|
24
|
+
var target = {};
|
|
25
|
+
for (var prop in source)
|
|
26
|
+
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
27
|
+
target[prop] = source[prop];
|
|
28
|
+
if (source != null && __getOwnPropSymbols)
|
|
29
|
+
for (var prop of __getOwnPropSymbols(source)) {
|
|
30
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
31
|
+
target[prop] = source[prop];
|
|
32
|
+
}
|
|
33
|
+
return target;
|
|
34
|
+
};
|
|
23
35
|
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
24
36
|
|
|
37
|
+
// src/read-only.ts
|
|
38
|
+
var _EditorReadOnlyError = class _EditorReadOnlyError extends Error {
|
|
39
|
+
constructor(editor) {
|
|
40
|
+
super(`${editor} editor is read-only`);
|
|
41
|
+
__publicField(this, "code", "EDITOR_READ_ONLY");
|
|
42
|
+
this.name = "EditorReadOnlyError";
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
__name(_EditorReadOnlyError, "EditorReadOnlyError");
|
|
46
|
+
var EditorReadOnlyError = _EditorReadOnlyError;
|
|
47
|
+
|
|
25
48
|
// src/spreadsheet/types.ts
|
|
26
49
|
function rowColumnKey(row, column) {
|
|
27
50
|
return `${row}:${column}`;
|
|
@@ -1601,17 +1624,20 @@ __name(spreadsheetSortRows, "spreadsheetSortRows");
|
|
|
1601
1624
|
|
|
1602
1625
|
// src/spreadsheet/runtime.ts
|
|
1603
1626
|
var _SpreadsheetEditorRuntime = class _SpreadsheetEditorRuntime {
|
|
1604
|
-
constructor(state) {
|
|
1627
|
+
constructor(state, options = {}) {
|
|
1605
1628
|
__publicField(this, "state", state);
|
|
1606
1629
|
__publicField(this, "activeTransaction", null);
|
|
1607
1630
|
__publicField(this, "activeTransactionSource", null);
|
|
1608
1631
|
__publicField(this, "transactionNeedsRefresh", false);
|
|
1632
|
+
__publicField(this, "readOnlyValue");
|
|
1633
|
+
this.readOnlyValue = options.readOnly === true;
|
|
1609
1634
|
}
|
|
1610
1635
|
static async fromZip(bytes, options = {}) {
|
|
1611
|
-
const
|
|
1612
|
-
|
|
1636
|
+
const _a = options, { readOnly } = _a, loadOptions = __objRest(_a, ["readOnly"]);
|
|
1637
|
+
const workbook = await ExcelWorkbook.fromZip(bytes, loadOptions);
|
|
1638
|
+
return _SpreadsheetEditorRuntime.fromWorkbook(workbook, { readOnly });
|
|
1613
1639
|
}
|
|
1614
|
-
static async fromWorkbook(workbook) {
|
|
1640
|
+
static async fromWorkbook(workbook, options = {}) {
|
|
1615
1641
|
const model = await workbook.toModel();
|
|
1616
1642
|
const firstSheet = model.sheets[0];
|
|
1617
1643
|
if (!firstSheet) throw new Error("SpreadsheetEditorRuntime: workbook has no sheets");
|
|
@@ -1624,9 +1650,17 @@ var _SpreadsheetEditorRuntime = class _SpreadsheetEditorRuntime {
|
|
|
1624
1650
|
formulaResults,
|
|
1625
1651
|
formulaEngine,
|
|
1626
1652
|
activeSheet: buildSpreadsheetSheetRenderModel(firstSheet, model.styles, { formulaResults })
|
|
1627
|
-
});
|
|
1653
|
+
}, options);
|
|
1654
|
+
}
|
|
1655
|
+
isReadOnly() {
|
|
1656
|
+
return this.readOnlyValue;
|
|
1657
|
+
}
|
|
1658
|
+
setReadOnly(readOnly) {
|
|
1659
|
+
if (this.activeTransaction) throw new Error("SpreadsheetEditorRuntime: cannot change read-only state during a transaction");
|
|
1660
|
+
this.readOnlyValue = readOnly;
|
|
1628
1661
|
}
|
|
1629
1662
|
workbook() {
|
|
1663
|
+
this.assertWritable();
|
|
1630
1664
|
return this.state.workbook;
|
|
1631
1665
|
}
|
|
1632
1666
|
model() {
|
|
@@ -1639,24 +1673,27 @@ var _SpreadsheetEditorRuntime = class _SpreadsheetEditorRuntime {
|
|
|
1639
1673
|
return this.state.activeSheet;
|
|
1640
1674
|
}
|
|
1641
1675
|
canUndo() {
|
|
1642
|
-
return this.state.workbook.history().canUndo();
|
|
1676
|
+
return !this.readOnlyValue && this.state.workbook.history().canUndo();
|
|
1643
1677
|
}
|
|
1644
1678
|
canRedo() {
|
|
1645
|
-
return this.state.workbook.history().canRedo();
|
|
1679
|
+
return !this.readOnlyValue && this.state.workbook.history().canRedo();
|
|
1646
1680
|
}
|
|
1647
1681
|
async undo() {
|
|
1682
|
+
this.assertWritable();
|
|
1648
1683
|
const result = await this.state.workbook.history().undo();
|
|
1649
1684
|
if (!result) return null;
|
|
1650
1685
|
await this.refresh();
|
|
1651
1686
|
return result;
|
|
1652
1687
|
}
|
|
1653
1688
|
async redo() {
|
|
1689
|
+
this.assertWritable();
|
|
1654
1690
|
const result = await this.state.workbook.history().redo();
|
|
1655
1691
|
if (!result) return null;
|
|
1656
1692
|
await this.refresh();
|
|
1657
1693
|
return result;
|
|
1658
1694
|
}
|
|
1659
1695
|
async runUserTransaction(options, run) {
|
|
1696
|
+
this.assertWritable();
|
|
1660
1697
|
return this.runScopedTransaction(
|
|
1661
1698
|
"user",
|
|
1662
1699
|
(apply) => this.state.workbook.history().runGroup(__spreadProps(__spreadValues({}, options), { source: "user" }), apply),
|
|
@@ -1664,6 +1701,7 @@ var _SpreadsheetEditorRuntime = class _SpreadsheetEditorRuntime {
|
|
|
1664
1701
|
);
|
|
1665
1702
|
}
|
|
1666
1703
|
async runAgentTransaction(options, run) {
|
|
1704
|
+
this.assertWritable();
|
|
1667
1705
|
return this.runScopedTransaction(
|
|
1668
1706
|
"agent",
|
|
1669
1707
|
(apply) => this.state.workbook.history().runAgentGroup(options, apply),
|
|
@@ -2219,6 +2257,7 @@ var _SpreadsheetEditorRuntime = class _SpreadsheetEditorRuntime {
|
|
|
2219
2257
|
);
|
|
2220
2258
|
}
|
|
2221
2259
|
async runUserMutation(options, mutate) {
|
|
2260
|
+
this.assertWritable();
|
|
2222
2261
|
if (this.activeTransaction) {
|
|
2223
2262
|
await mutate(this.activeTransaction);
|
|
2224
2263
|
this.transactionNeedsRefresh = true;
|
|
@@ -2235,6 +2274,7 @@ var _SpreadsheetEditorRuntime = class _SpreadsheetEditorRuntime {
|
|
|
2235
2274
|
);
|
|
2236
2275
|
}
|
|
2237
2276
|
async runWorksheetStructureMutation(recordAgentMutation, mutate) {
|
|
2277
|
+
this.assertWritable();
|
|
2238
2278
|
if (this.activeTransactionSource === "agent" && this.activeTransaction) {
|
|
2239
2279
|
await recordAgentMutation(this.activeTransaction);
|
|
2240
2280
|
this.transactionNeedsRefresh = true;
|
|
@@ -2249,6 +2289,7 @@ var _SpreadsheetEditorRuntime = class _SpreadsheetEditorRuntime {
|
|
|
2249
2289
|
return (_a = (await this.state.workbook.worksheets.getItem(this.state.activeSheetName).getRange(address).styleIds())[0]) == null ? void 0 : _a[0];
|
|
2250
2290
|
}
|
|
2251
2291
|
async runScopedTransaction(source, execute, run) {
|
|
2292
|
+
this.assertWritable();
|
|
2252
2293
|
if (this.activeTransaction) {
|
|
2253
2294
|
await run();
|
|
2254
2295
|
this.transactionNeedsRefresh = true;
|
|
@@ -2276,6 +2317,9 @@ var _SpreadsheetEditorRuntime = class _SpreadsheetEditorRuntime {
|
|
|
2276
2317
|
this.transactionNeedsRefresh = previousNeedsRefresh;
|
|
2277
2318
|
}
|
|
2278
2319
|
}
|
|
2320
|
+
assertWritable() {
|
|
2321
|
+
if (this.readOnlyValue) throw new EditorReadOnlyError("spreadsheet");
|
|
2322
|
+
}
|
|
2279
2323
|
cellEditHistoryGroup(label, address, options) {
|
|
2280
2324
|
var _a;
|
|
2281
2325
|
const base = { label };
|
|
@@ -2773,6 +2817,7 @@ var _NativeSpreadsheetEditor = class _NativeSpreadsheetEditor {
|
|
|
2773
2817
|
__publicField(this, "lastStateKey", "");
|
|
2774
2818
|
__publicField(this, "transactionDepth", 0);
|
|
2775
2819
|
__publicField(this, "transactionChanged", false);
|
|
2820
|
+
__publicField(this, "readOnlyValue");
|
|
2776
2821
|
__publicField(this, "handleClick", /* @__PURE__ */ __name((event) => {
|
|
2777
2822
|
if (this.eventPathContains(event, this.contextMenu) || this.eventPathContains(event, this.filterMenu)) return;
|
|
2778
2823
|
if (this.filterMenu.style.display === "block") this.hideFilterMenu();
|
|
@@ -2792,6 +2837,7 @@ var _NativeSpreadsheetEditor = class _NativeSpreadsheetEditor {
|
|
|
2792
2837
|
const hit = this.viewport.hitTest(this.eventPoint(event));
|
|
2793
2838
|
if (hit.kind !== "cell" && hit.kind !== "rowHeader" && hit.kind !== "columnHeader") return;
|
|
2794
2839
|
if (hit.kind === "cell" && hit.row === 1 && this.isFilterIconHit(hit.column, event)) {
|
|
2840
|
+
if (this.isReadOnly()) return;
|
|
2795
2841
|
this.openFilterMenu(hit.column, event.clientX, event.clientY);
|
|
2796
2842
|
event.preventDefault();
|
|
2797
2843
|
return;
|
|
@@ -2808,6 +2854,10 @@ var _NativeSpreadsheetEditor = class _NativeSpreadsheetEditor {
|
|
|
2808
2854
|
}, "handleClick"));
|
|
2809
2855
|
__publicField(this, "handleFilterMenuClick", /* @__PURE__ */ __name((event) => {
|
|
2810
2856
|
var _a;
|
|
2857
|
+
if (this.isReadOnly()) {
|
|
2858
|
+
this.hideFilterMenu();
|
|
2859
|
+
return;
|
|
2860
|
+
}
|
|
2811
2861
|
const target = event.target;
|
|
2812
2862
|
const action = (_a = target.closest("[data-filter-action]")) == null ? void 0 : _a.dataset.filterAction;
|
|
2813
2863
|
if (!action || this.filterMenuColumn === null) return;
|
|
@@ -2833,6 +2883,10 @@ var _NativeSpreadsheetEditor = class _NativeSpreadsheetEditor {
|
|
|
2833
2883
|
const hit = this.viewport.hitTest(this.eventPoint(event));
|
|
2834
2884
|
if (hit.kind !== "cell") return;
|
|
2835
2885
|
this.selectionState = expandSelectionForMergedRanges(createSelection(hit.row, hit.column), this.runtime().activeSheet());
|
|
2886
|
+
if (this.isReadOnly()) {
|
|
2887
|
+
this.render();
|
|
2888
|
+
return;
|
|
2889
|
+
}
|
|
2836
2890
|
this.openCellEditor();
|
|
2837
2891
|
event.preventDefault();
|
|
2838
2892
|
}, "handleDoubleClick"));
|
|
@@ -2847,6 +2901,11 @@ var _NativeSpreadsheetEditor = class _NativeSpreadsheetEditor {
|
|
|
2847
2901
|
const chartHit = this.chartAtPoint(point);
|
|
2848
2902
|
if (chartHit) {
|
|
2849
2903
|
this.selectedChartIndex = chartHit.chartIndex;
|
|
2904
|
+
if (this.isReadOnly()) {
|
|
2905
|
+
this.render();
|
|
2906
|
+
event.preventDefault();
|
|
2907
|
+
return;
|
|
2908
|
+
}
|
|
2850
2909
|
this.chartDrag = {
|
|
2851
2910
|
chartIndex: chartHit.chartIndex,
|
|
2852
2911
|
pointer: point,
|
|
@@ -2860,7 +2919,7 @@ var _NativeSpreadsheetEditor = class _NativeSpreadsheetEditor {
|
|
|
2860
2919
|
}
|
|
2861
2920
|
this.selectedChartIndex = null;
|
|
2862
2921
|
const resizeHandle = hitSpreadsheetResizeHandle(this.layout, this.viewport.viewports, point);
|
|
2863
|
-
if (resizeHandle) {
|
|
2922
|
+
if (resizeHandle && !this.isReadOnly()) {
|
|
2864
2923
|
this.resizeDrag = startSpreadsheetResizeDrag(resizeHandle, event);
|
|
2865
2924
|
this.host.setPointerCapture(event.pointerId);
|
|
2866
2925
|
this.host.style.cursor = resizeHandle.kind === "column" ? "col-resize" : "row-resize";
|
|
@@ -2870,7 +2929,7 @@ var _NativeSpreadsheetEditor = class _NativeSpreadsheetEditor {
|
|
|
2870
2929
|
}
|
|
2871
2930
|
const selectionRange = normalizeSelectionRange(this.selectionState.range);
|
|
2872
2931
|
const fillHandle = (_a = this.renderer) == null ? void 0 : _a.fillHandleRect(this.layout, this.viewport, selectionRange);
|
|
2873
|
-
if (fillHandle && containsPoint2(fillHandle, point) && supportsSpreadsheetAutoFill(this.runtime().activeSheet(), selectionRange)) {
|
|
2932
|
+
if (!this.isReadOnly() && fillHandle && containsPoint2(fillHandle, point) && supportsSpreadsheetAutoFill(this.runtime().activeSheet(), selectionRange)) {
|
|
2874
2933
|
this.autoFillDrag = { source: selectionRange, preview: null };
|
|
2875
2934
|
this.host.setPointerCapture(event.pointerId);
|
|
2876
2935
|
event.preventDefault();
|
|
@@ -2907,7 +2966,7 @@ var _NativeSpreadsheetEditor = class _NativeSpreadsheetEditor {
|
|
|
2907
2966
|
return;
|
|
2908
2967
|
}
|
|
2909
2968
|
if (!this.resizeDrag && !this.autoFillDrag && !this.selecting && !this.editingCell) {
|
|
2910
|
-
const resizeHandle = hitSpreadsheetResizeHandle(this.layout, this.viewport.viewports, this.eventPoint(event));
|
|
2969
|
+
const resizeHandle = this.isReadOnly() ? null : hitSpreadsheetResizeHandle(this.layout, this.viewport.viewports, this.eventPoint(event));
|
|
2911
2970
|
this.host.style.cursor = resizeHandle ? resizeHandle.kind === "column" ? "col-resize" : "row-resize" : "";
|
|
2912
2971
|
}
|
|
2913
2972
|
if (this.resizeDrag) {
|
|
@@ -3004,6 +3063,7 @@ var _NativeSpreadsheetEditor = class _NativeSpreadsheetEditor {
|
|
|
3004
3063
|
if (this.editingCell) return;
|
|
3005
3064
|
const { row, column } = this.selectionState.active;
|
|
3006
3065
|
if (event.key === "F2" || event.key === "Enter") {
|
|
3066
|
+
if (this.isReadOnly()) return;
|
|
3007
3067
|
event.preventDefault();
|
|
3008
3068
|
this.openCellEditor();
|
|
3009
3069
|
return;
|
|
@@ -3035,6 +3095,10 @@ var _NativeSpreadsheetEditor = class _NativeSpreadsheetEditor {
|
|
|
3035
3095
|
}, "handleCopy"));
|
|
3036
3096
|
__publicField(this, "handlePaste", /* @__PURE__ */ __name((event) => {
|
|
3037
3097
|
var _a, _b, _c, _d, _e;
|
|
3098
|
+
if (this.isReadOnly()) {
|
|
3099
|
+
event.preventDefault();
|
|
3100
|
+
return;
|
|
3101
|
+
}
|
|
3038
3102
|
const text = (_b = (_a = event.clipboardData) == null ? void 0 : _a.getData("text/plain")) != null ? _b : "";
|
|
3039
3103
|
if (!text) return;
|
|
3040
3104
|
event.preventDefault();
|
|
@@ -3078,7 +3142,11 @@ var _NativeSpreadsheetEditor = class _NativeSpreadsheetEditor {
|
|
|
3078
3142
|
}
|
|
3079
3143
|
if (hit.kind !== "cell" && hit.kind !== "rowHeader" && hit.kind !== "columnHeader") return;
|
|
3080
3144
|
event.preventDefault();
|
|
3081
|
-
this.renderContextMenu(
|
|
3145
|
+
this.renderContextMenu(
|
|
3146
|
+
event.clientX,
|
|
3147
|
+
event.clientY,
|
|
3148
|
+
this.isReadOnly() ? void 0 : hit.kind === "columnHeader" ? hit.column : void 0
|
|
3149
|
+
);
|
|
3082
3150
|
}, "handleContextMenu"));
|
|
3083
3151
|
__publicField(this, "handleDocumentPointerDown", /* @__PURE__ */ __name((event) => {
|
|
3084
3152
|
const path = event.composedPath();
|
|
@@ -3093,6 +3161,7 @@ var _NativeSpreadsheetEditor = class _NativeSpreadsheetEditor {
|
|
|
3093
3161
|
this.setScroll(next.x, next.y);
|
|
3094
3162
|
}, "handleWheel"));
|
|
3095
3163
|
var _a;
|
|
3164
|
+
this.readOnlyValue = options.readOnly === true;
|
|
3096
3165
|
host.replaceChildren();
|
|
3097
3166
|
this.renderRoot = options.styleIsolation === "none" ? host : (_a = host.shadowRoot) != null ? _a : host.attachShadow({ mode: "open" });
|
|
3098
3167
|
this.renderRoot.replaceChildren();
|
|
@@ -3220,6 +3289,24 @@ var _NativeSpreadsheetEditor = class _NativeSpreadsheetEditor {
|
|
|
3220
3289
|
if (!this.runtimeValue) throw new Error("SpreadsheetEditor: workbook is not loaded");
|
|
3221
3290
|
return this.runtimeValue;
|
|
3222
3291
|
}
|
|
3292
|
+
isReadOnly() {
|
|
3293
|
+
return this.readOnlyValue;
|
|
3294
|
+
}
|
|
3295
|
+
setReadOnly(readOnly) {
|
|
3296
|
+
if (this.disposed || this.isReadOnly() === readOnly) return;
|
|
3297
|
+
this.cellEditor.cancel();
|
|
3298
|
+
this.resizeDrag = null;
|
|
3299
|
+
this.autoFillDrag = null;
|
|
3300
|
+
this.chartDrag = null;
|
|
3301
|
+
this.selecting = false;
|
|
3302
|
+
this.hideResizeGuide();
|
|
3303
|
+
this.hideContextMenu();
|
|
3304
|
+
this.hideFilterMenu();
|
|
3305
|
+
this.runtime().setReadOnly(readOnly);
|
|
3306
|
+
this.readOnlyValue = readOnly;
|
|
3307
|
+
this.host.setAttribute("aria-readonly", String(readOnly));
|
|
3308
|
+
this.render();
|
|
3309
|
+
}
|
|
3223
3310
|
selection() {
|
|
3224
3311
|
return this.selectionState;
|
|
3225
3312
|
}
|
|
@@ -3388,8 +3475,10 @@ var _NativeSpreadsheetEditor = class _NativeSpreadsheetEditor {
|
|
|
3388
3475
|
if (previous) await previous.dispose();
|
|
3389
3476
|
this.runtimeValue = await SpreadsheetEditorRuntime.fromZip(bytes, {
|
|
3390
3477
|
workbookId: this.options.workbookId,
|
|
3391
|
-
mode: "inline"
|
|
3478
|
+
mode: "inline",
|
|
3479
|
+
readOnly: this.readOnlyValue
|
|
3392
3480
|
});
|
|
3481
|
+
this.host.setAttribute("aria-readonly", String(this.isReadOnly()));
|
|
3393
3482
|
this.renderTabs();
|
|
3394
3483
|
this.render();
|
|
3395
3484
|
}
|
|
@@ -3482,13 +3571,14 @@ var _NativeSpreadsheetEditor = class _NativeSpreadsheetEditor {
|
|
|
3482
3571
|
this.scroll
|
|
3483
3572
|
);
|
|
3484
3573
|
renderer.resize(width, height);
|
|
3485
|
-
|
|
3486
|
-
renderer.
|
|
3574
|
+
const headerFiltersEnabled = this.options.enableHeaderFilters === true && !this.isReadOnly();
|
|
3575
|
+
renderer.setHeaderFiltersEnabled(headerFiltersEnabled);
|
|
3576
|
+
renderer.setHeaderFilterColumns(headerFiltersEnabled ? Array.from({ length: layout.columnCount }, (_, index) => index + 1) : null);
|
|
3487
3577
|
renderer.setActiveHeaderFilterColumns(Array.from(this.columnFilters.keys()));
|
|
3488
3578
|
renderer.render(layout, viewport);
|
|
3489
3579
|
const selectionRange = normalizeSelectionRange(this.selectionState.range);
|
|
3490
3580
|
renderer.renderSelection(layout, viewport, selectionRange, {
|
|
3491
|
-
showFillHandle: supportsSpreadsheetAutoFill(runtime.activeSheet(), selectionRange)
|
|
3581
|
+
showFillHandle: !this.isReadOnly() && supportsSpreadsheetAutoFill(runtime.activeSheet(), selectionRange)
|
|
3492
3582
|
});
|
|
3493
3583
|
this.updateCellEditorPosition();
|
|
3494
3584
|
if ((_a = this.autoFillDrag) == null ? void 0 : _a.preview) {
|
|
@@ -3538,7 +3628,7 @@ var _NativeSpreadsheetEditor = class _NativeSpreadsheetEditor {
|
|
|
3538
3628
|
textAlign: "center",
|
|
3539
3629
|
font: "13px Arial, sans-serif",
|
|
3540
3630
|
lineHeight: "1.4",
|
|
3541
|
-
cursor: ((_c = this.chartDrag) == null ? void 0 : _c.chartIndex) === chartIndex ? "grabbing" : "move",
|
|
3631
|
+
cursor: this.isReadOnly() ? "default" : ((_c = this.chartDrag) == null ? void 0 : _c.chartIndex) === chartIndex ? "grabbing" : "move",
|
|
3542
3632
|
border: this.selectedChartIndex === chartIndex ? "2px solid #2563eb" : "1px dashed #94a3b8",
|
|
3543
3633
|
boxShadow: this.selectedChartIndex === chartIndex ? "0 0 0 1px rgba(37, 99, 235, 0.18)" : "none"
|
|
3544
3634
|
});
|
|
@@ -3601,7 +3691,7 @@ var _NativeSpreadsheetEditor = class _NativeSpreadsheetEditor {
|
|
|
3601
3691
|
this.resizeGuide.style.display = "none";
|
|
3602
3692
|
}
|
|
3603
3693
|
renderContextMenu(x, y, columnHeader) {
|
|
3604
|
-
const items = [
|
|
3694
|
+
const items = this.isReadOnly() ? [{ label: "Copy", action: /* @__PURE__ */ __name(() => this.copySelection(), "action") }] : [
|
|
3605
3695
|
{ label: "Undo", disabled: !this.canUndo(), action: /* @__PURE__ */ __name(() => this.undo(), "action") },
|
|
3606
3696
|
{ label: "Redo", disabled: !this.canRedo(), action: /* @__PURE__ */ __name(() => this.redo(), "action") },
|
|
3607
3697
|
{ label: "Copy", action: /* @__PURE__ */ __name(() => this.copySelection(), "action") },
|
|
@@ -3730,6 +3820,7 @@ var _NativeSpreadsheetEditor = class _NativeSpreadsheetEditor {
|
|
|
3730
3820
|
await this.sortColumn(this.selectionState.active.column, direction);
|
|
3731
3821
|
}
|
|
3732
3822
|
async filterColumn(column, values) {
|
|
3823
|
+
this.assertWritable();
|
|
3733
3824
|
if (values === null) this.columnFilters.delete(column);
|
|
3734
3825
|
else this.columnFilters.set(column, [...values]);
|
|
3735
3826
|
await this.applyColumnFilters();
|
|
@@ -3835,6 +3926,7 @@ var _NativeSpreadsheetEditor = class _NativeSpreadsheetEditor {
|
|
|
3835
3926
|
}
|
|
3836
3927
|
openCellEditor() {
|
|
3837
3928
|
var _a, _b;
|
|
3929
|
+
if (this.isReadOnly()) return;
|
|
3838
3930
|
if (!this.layout || !this.viewport) return;
|
|
3839
3931
|
const cell = this.selectionState.active;
|
|
3840
3932
|
const viewport = this.viewport.findViewport({
|
|
@@ -3874,6 +3966,7 @@ var _NativeSpreadsheetEditor = class _NativeSpreadsheetEditor {
|
|
|
3874
3966
|
this.editingCellStyle = null;
|
|
3875
3967
|
this.formulaReferenceRanges = [];
|
|
3876
3968
|
if (!cell) return;
|
|
3969
|
+
this.assertWritable();
|
|
3877
3970
|
const address = formatCellAddress(cell.row, cell.column);
|
|
3878
3971
|
if (value.startsWith("=")) await this.runtime().setCellFormula(address, value.slice(1), { mergeUndo: true });
|
|
3879
3972
|
else await this.runtime().setCellValue(address, coerceEditorValue(value), { mergeUndo: true });
|
|
@@ -3884,6 +3977,9 @@ var _NativeSpreadsheetEditor = class _NativeSpreadsheetEditor {
|
|
|
3884
3977
|
const rect = this.host.getBoundingClientRect();
|
|
3885
3978
|
return { x: event.clientX - rect.left, y: event.clientY - rect.top };
|
|
3886
3979
|
}
|
|
3980
|
+
assertWritable() {
|
|
3981
|
+
if (this.isReadOnly()) throw new EditorReadOnlyError("spreadsheet");
|
|
3982
|
+
}
|
|
3887
3983
|
eventPathContains(event, node) {
|
|
3888
3984
|
return event.composedPath().includes(node);
|
|
3889
3985
|
}
|
|
@@ -4208,6 +4304,6 @@ function formulaReferenceCell(value) {
|
|
|
4208
4304
|
}
|
|
4209
4305
|
__name(formulaReferenceCell, "formulaReferenceCell");
|
|
4210
4306
|
|
|
4211
|
-
export { SPREADSHEET_COLUMN_RESIZE_MIN, SPREADSHEET_RESIZE_HIT_TOLERANCE, SPREADSHEET_ROW_RESIZE_MIN, SpreadsheetCanvasRenderer, SpreadsheetCellEditor, SpreadsheetEditorRuntime, SpreadsheetLayout, SpreadsheetViewportManager, applySpreadsheetAgentAction, applyWheelDelta, buildSpreadsheetAutoFillPlan, buildSpreadsheetClipboardPayload, buildSpreadsheetReplacePlan, buildSpreadsheetSheetRenderModel, clampScroll, clearSpreadsheetRange, computeScrollbarState, createColumnRangeSelection, createColumnSelection, createRowRangeSelection, createRowSelection, createSelection, cssPixelsToExcelColumnWidth, excelColumnWidthToCssPixels, expandRangeForMergedRanges, expandSelectionForMergedRanges, extendSelection, findSpreadsheetMatches, formatSpreadsheetDisplayValue, freezeStateFromPane, freezeStateFromSheet, getRenderCell, hitSpreadsheetResizeHandle, moveSelection, nextSpreadsheetMatch, normalizeSelectionRange, parseTsv, previewSpreadsheetAgentAction, rangeAddressForMatrix, rangeForSpreadsheetMatch, renderSpreadsheetEditor, resolveSpreadsheetCellStyle, resolveSpreadsheetRangeBorder, rowColumnKey, scrollFromThumbPosition, selectionAfterColumnDeletion, selectionAfterRowDeletion, serializeRangeToTsv, setSpreadsheetCellFormula, setSpreadsheetCellValue, setSpreadsheetColumnWidth, setSpreadsheetRangeValues, setSpreadsheetRowHeight, spreadsheetFilterValues, spreadsheetRowsForColumnFilters, spreadsheetRowsForFilter, spreadsheetSortRows, spreadsheetVisibleFilterValues, startSpreadsheetResizeDrag, summarizeSpreadsheetSelectionFormat, supportsSpreadsheetAutoFill, updateSpreadsheetResizeDrag };
|
|
4307
|
+
export { EditorReadOnlyError, SPREADSHEET_COLUMN_RESIZE_MIN, SPREADSHEET_RESIZE_HIT_TOLERANCE, SPREADSHEET_ROW_RESIZE_MIN, SpreadsheetCanvasRenderer, SpreadsheetCellEditor, SpreadsheetEditorRuntime, SpreadsheetLayout, SpreadsheetViewportManager, applySpreadsheetAgentAction, applyWheelDelta, buildSpreadsheetAutoFillPlan, buildSpreadsheetClipboardPayload, buildSpreadsheetReplacePlan, buildSpreadsheetSheetRenderModel, clampScroll, clearSpreadsheetRange, computeScrollbarState, createColumnRangeSelection, createColumnSelection, createRowRangeSelection, createRowSelection, createSelection, cssPixelsToExcelColumnWidth, excelColumnWidthToCssPixels, expandRangeForMergedRanges, expandSelectionForMergedRanges, extendSelection, findSpreadsheetMatches, formatSpreadsheetDisplayValue, freezeStateFromPane, freezeStateFromSheet, getRenderCell, hitSpreadsheetResizeHandle, moveSelection, nextSpreadsheetMatch, normalizeSelectionRange, parseTsv, previewSpreadsheetAgentAction, rangeAddressForMatrix, rangeForSpreadsheetMatch, renderSpreadsheetEditor, resolveSpreadsheetCellStyle, resolveSpreadsheetRangeBorder, rowColumnKey, scrollFromThumbPosition, selectionAfterColumnDeletion, selectionAfterRowDeletion, serializeRangeToTsv, setSpreadsheetCellFormula, setSpreadsheetCellValue, setSpreadsheetColumnWidth, setSpreadsheetRangeValues, setSpreadsheetRowHeight, spreadsheetFilterValues, spreadsheetRowsForColumnFilters, spreadsheetRowsForFilter, spreadsheetSortRows, spreadsheetVisibleFilterValues, startSpreadsheetResizeDrag, summarizeSpreadsheetSelectionFormat, supportsSpreadsheetAutoFill, updateSpreadsheetResizeDrag };
|
|
4212
4308
|
//# sourceMappingURL=spreadsheet.js.map
|
|
4213
4309
|
//# sourceMappingURL=spreadsheet.js.map
|