@langeditor/plugin-spreadsheet 0.0.0-stage → 1.1.4

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.
@@ -0,0 +1,57 @@
1
+ declare const en: {
2
+ 'spreadsheet.toolbar.label': string;
3
+ 'spreadsheet.toolbar.import': string;
4
+ 'spreadsheet.toolbar.exportXlsx': string;
5
+ 'spreadsheet.toolbar.exportCsv': string;
6
+ 'spreadsheet.toolbar.exportXlsxShort': string;
7
+ 'spreadsheet.toolbar.exportCsvShort': string;
8
+ 'spreadsheet.toolbar.addRow': string;
9
+ 'spreadsheet.toolbar.addColumn': string;
10
+ 'spreadsheet.toolbar.addSheet': string;
11
+ 'spreadsheet.toolbar.fontFamily': string;
12
+ 'spreadsheet.toolbar.fontSize': string;
13
+ 'spreadsheet.toolbar.bold': string;
14
+ 'spreadsheet.toolbar.italic': string;
15
+ 'spreadsheet.toolbar.underline': string;
16
+ 'spreadsheet.toolbar.fontColor': string;
17
+ 'spreadsheet.toolbar.fillColor': string;
18
+ 'spreadsheet.toolbar.alignLeft': string;
19
+ 'spreadsheet.toolbar.alignCenter': string;
20
+ 'spreadsheet.toolbar.alignRight': string;
21
+ 'spreadsheet.toolbar.wrapText': string;
22
+ 'spreadsheet.toolbar.merge': string;
23
+ 'spreadsheet.toolbar.unmerge': string;
24
+ 'spreadsheet.toolbar.mergeShort': string;
25
+ 'spreadsheet.toolbar.unmergeShort': string;
26
+ 'spreadsheet.toolbar.clearFormatting': string;
27
+ 'spreadsheet.formula.name': string;
28
+ 'spreadsheet.formula.input': string;
29
+ 'spreadsheet.formula.placeholder': string;
30
+ 'spreadsheet.sheet.add': string;
31
+ 'spreadsheet.sheet.select': string;
32
+ 'spreadsheet.sheet.renameHint': string;
33
+ 'spreadsheet.sheet.renameInput': string;
34
+ 'spreadsheet.sheet.renameInvalid': string;
35
+ 'spreadsheet.status.ready': string;
36
+ 'spreadsheet.status.selection': string;
37
+ 'spreadsheet.status.sheet': string;
38
+ 'spreadsheet.status.selectionLabel': string;
39
+ 'spreadsheet.status.cells': string;
40
+ 'spreadsheet.status.count': string;
41
+ 'spreadsheet.status.average': string;
42
+ 'spreadsheet.status.sum': string;
43
+ 'spreadsheet.loading': string;
44
+ 'spreadsheet.error.engine': string;
45
+ 'spreadsheet.error.retry': string;
46
+ 'spreadsheet.error.import': string;
47
+ 'spreadsheet.error.unsupportedOperation': string;
48
+ 'spreadsheet.diagnostic.macros-ignored': string;
49
+ 'spreadsheet.diagnostic.charts-unsupported': string;
50
+ 'spreadsheet.diagnostic.images-unsupported': string;
51
+ 'spreadsheet.diagnostic.styles-partial': string;
52
+ 'spreadsheet.diagnostic.range-truncated': string;
53
+ 'spreadsheet.diagnostic.dismiss': string;
54
+ 'spreadsheet.aria.grid': string;
55
+ 'spreadsheet.aria.cell': string;
56
+ };
57
+ export default en;
@@ -0,0 +1,57 @@
1
+ declare const zh: {
2
+ 'spreadsheet.toolbar.label': string;
3
+ 'spreadsheet.toolbar.import': string;
4
+ 'spreadsheet.toolbar.exportXlsx': string;
5
+ 'spreadsheet.toolbar.exportCsv': string;
6
+ 'spreadsheet.toolbar.exportXlsxShort': string;
7
+ 'spreadsheet.toolbar.exportCsvShort': string;
8
+ 'spreadsheet.toolbar.addRow': string;
9
+ 'spreadsheet.toolbar.addColumn': string;
10
+ 'spreadsheet.toolbar.addSheet': string;
11
+ 'spreadsheet.toolbar.fontFamily': string;
12
+ 'spreadsheet.toolbar.fontSize': string;
13
+ 'spreadsheet.toolbar.bold': string;
14
+ 'spreadsheet.toolbar.italic': string;
15
+ 'spreadsheet.toolbar.underline': string;
16
+ 'spreadsheet.toolbar.fontColor': string;
17
+ 'spreadsheet.toolbar.fillColor': string;
18
+ 'spreadsheet.toolbar.alignLeft': string;
19
+ 'spreadsheet.toolbar.alignCenter': string;
20
+ 'spreadsheet.toolbar.alignRight': string;
21
+ 'spreadsheet.toolbar.wrapText': string;
22
+ 'spreadsheet.toolbar.merge': string;
23
+ 'spreadsheet.toolbar.unmerge': string;
24
+ 'spreadsheet.toolbar.mergeShort': string;
25
+ 'spreadsheet.toolbar.unmergeShort': string;
26
+ 'spreadsheet.toolbar.clearFormatting': string;
27
+ 'spreadsheet.formula.name': string;
28
+ 'spreadsheet.formula.input': string;
29
+ 'spreadsheet.formula.placeholder': string;
30
+ 'spreadsheet.sheet.add': string;
31
+ 'spreadsheet.sheet.select': string;
32
+ 'spreadsheet.sheet.renameHint': string;
33
+ 'spreadsheet.sheet.renameInput': string;
34
+ 'spreadsheet.sheet.renameInvalid': string;
35
+ 'spreadsheet.status.ready': string;
36
+ 'spreadsheet.status.selection': string;
37
+ 'spreadsheet.status.sheet': string;
38
+ 'spreadsheet.status.selectionLabel': string;
39
+ 'spreadsheet.status.cells': string;
40
+ 'spreadsheet.status.count': string;
41
+ 'spreadsheet.status.average': string;
42
+ 'spreadsheet.status.sum': string;
43
+ 'spreadsheet.loading': string;
44
+ 'spreadsheet.error.engine': string;
45
+ 'spreadsheet.error.retry': string;
46
+ 'spreadsheet.error.import': string;
47
+ 'spreadsheet.error.unsupportedOperation': string;
48
+ 'spreadsheet.diagnostic.macros-ignored': string;
49
+ 'spreadsheet.diagnostic.charts-unsupported': string;
50
+ 'spreadsheet.diagnostic.images-unsupported': string;
51
+ 'spreadsheet.diagnostic.styles-partial': string;
52
+ 'spreadsheet.diagnostic.range-truncated': string;
53
+ 'spreadsheet.diagnostic.dismiss': string;
54
+ 'spreadsheet.aria.grid': string;
55
+ 'spreadsheet.aria.cell': string;
56
+ };
57
+ export default zh;
@@ -0,0 +1,10 @@
1
+ export declare const SPREADSHEET_PLUGIN_ID = "@langeditor/plugin-spreadsheet";
2
+ export declare const spreadsheetManifest: {
3
+ id: string;
4
+ version: string;
5
+ coreRange: string;
6
+ requires: string[];
7
+ conflicts: string[];
8
+ provides: string[];
9
+ enhances: string[];
10
+ };
@@ -0,0 +1,55 @@
1
+ import { Model } from '@ironcalc/wasm';
2
+ import { SpreadsheetCellStylePatch, SpreadsheetPluginOptions, SpreadsheetRangeSelection, SpreadsheetSelectionStyle, SpreadsheetSheetSnapshot, SpreadsheetWorkbookSnapshot } from '../types';
3
+ export declare const DEFAULT_ROWS = 200;
4
+ export declare const DEFAULT_COLUMNS = 26;
5
+ export declare const DEFAULT_SELECTION_STYLE: SpreadsheetSelectionStyle;
6
+ export declare function columnLabel(column: number): string;
7
+ export declare function cellAddress(row: number, column: number): string;
8
+ export declare function parseCellAddress(address: string): {
9
+ row: number;
10
+ column: number;
11
+ };
12
+ export declare function rangeAddress(startRow: number, startColumn: number, endRow: number, endColumn: number): string;
13
+ export declare function defaultPageLayout(): SpreadsheetWorkbookSnapshot['pageLayout'];
14
+ export declare function createWorkbookSnapshot(options?: SpreadsheetPluginOptions): SpreadsheetWorkbookSnapshot;
15
+ export declare function isWorkbookSnapshot(value: unknown): value is SpreadsheetWorkbookSnapshot;
16
+ export declare function cloneWorkbookSnapshot(snapshot: SpreadsheetWorkbookSnapshot): SpreadsheetWorkbookSnapshot;
17
+ export declare function clonePageLayout(layout: SpreadsheetWorkbookSnapshot['pageLayout']): SpreadsheetWorkbookSnapshot['pageLayout'];
18
+ export declare function normalizeWorkbookSnapshot(value: SpreadsheetWorkbookSnapshot, options?: SpreadsheetPluginOptions): SpreadsheetWorkbookSnapshot;
19
+ export declare function createSelection(sheet: SpreadsheetSheetSnapshot, startRow: number, startColumn: number, endRow?: number, endColumn?: number): SpreadsheetRangeSelection;
20
+ export declare function sheetBounds(sheet: SpreadsheetSheetSnapshot): {
21
+ maxRow: number;
22
+ maxColumn: number;
23
+ };
24
+ export declare class SpreadsheetWorkbookModel {
25
+ private model;
26
+ private snapshot;
27
+ constructor(model: Model, snapshot: SpreadsheetWorkbookSnapshot);
28
+ static create(ModelConstructor: typeof Model, snapshot: SpreadsheetWorkbookSnapshot): SpreadsheetWorkbookModel;
29
+ get value(): SpreadsheetWorkbookSnapshot;
30
+ get selectedSheetIndex(): number;
31
+ get selectedSheet(): SpreadsheetSheetSnapshot;
32
+ setSnapshot(snapshot: SpreadsheetWorkbookSnapshot): void;
33
+ setSelectedSheet(sheetId: string): void;
34
+ setSelection(selection: SpreadsheetRangeSelection): void;
35
+ setCell(sheetId: string, row: number, column: number, input: string): void;
36
+ getCellInput(sheetId: string, row: number, column: number): string;
37
+ getFormattedValue(sheetId: string, row: number, column: number): string;
38
+ getCellStyle(sheetId: string, row: number, column: number): Record<string, unknown>;
39
+ getSelectionStyle(selection: SpreadsheetRangeSelection): SpreadsheetSelectionStyle;
40
+ setRangeStyle(selection: SpreadsheetRangeSelection, patch: SpreadsheetCellStylePatch): void;
41
+ clearRangeFormatting(selection: SpreadsheetRangeSelection): void;
42
+ mergeRange(selection: SpreadsheetRangeSelection): void;
43
+ unmergeRange(selection: SpreadsheetRangeSelection): void;
44
+ isRangeMerged(selection: SpreadsheetRangeSelection): boolean;
45
+ clearRange(selection: SpreadsheetRangeSelection): void;
46
+ insertRows(sheetId: string, row: number, count: number): void;
47
+ insertColumns(sheetId: string, column: number, count: number): void;
48
+ addSheet(name?: string): SpreadsheetSheetSnapshot;
49
+ renameSheet(sheetId: string, name: string): SpreadsheetSheetSnapshot;
50
+ destroy(): void;
51
+ private requireSheetIndex;
52
+ private uniqueSheetName;
53
+ private rebuildEngine;
54
+ private captureEngineCells;
55
+ }
@@ -0,0 +1 @@
1
+ export declare const unregisterSpreadsheetPlugin: () => void;
@@ -0,0 +1,7 @@
1
+ import { SpreadsheetSheetSnapshot, SpreadsheetWorkbookSnapshot } from '../types';
2
+ export declare function importCsv(text: string, name?: string, delimiter?: string): {
3
+ value: SpreadsheetWorkbookSnapshot;
4
+ diagnostics: any[];
5
+ };
6
+ export declare function exportCsv(sheet: SpreadsheetSheetSnapshot): string;
7
+ export declare function selectedSheet(snapshot: SpreadsheetWorkbookSnapshot): SpreadsheetSheetSnapshot;
@@ -0,0 +1,7 @@
1
+ import { LcDocumentSource } from '../../../..';
2
+ import { SpreadsheetExportFormat, SpreadsheetWorkbookSnapshot } from '../types';
3
+ export declare function importSpreadsheet(source: LcDocumentSource): Promise<{
4
+ value: SpreadsheetWorkbookSnapshot;
5
+ diagnostics: import('..').SpreadsheetImportDiagnostic[];
6
+ }>;
7
+ export declare function exportSpreadsheet(snapshot: SpreadsheetWorkbookSnapshot, format: SpreadsheetExportFormat): Promise<string | ArrayBuffer>;
@@ -0,0 +1,6 @@
1
+ import { LcDocumentSource } from '../../../..';
2
+ import { SpreadsheetImportDiagnostic, SpreadsheetWorkbookSnapshot } from '../types';
3
+ export declare function importDocumentSource(source: LcDocumentSource): Promise<{
4
+ value: SpreadsheetWorkbookSnapshot;
5
+ diagnostics: SpreadsheetImportDiagnostic[];
6
+ }>;
@@ -0,0 +1,6 @@
1
+ import { SpreadsheetImportDiagnostic, SpreadsheetWorkbookSnapshot } from '../types';
2
+ export declare function importXlsx(data: ArrayBuffer | Uint8Array, name?: string): {
3
+ value: SpreadsheetWorkbookSnapshot;
4
+ diagnostics: SpreadsheetImportDiagnostic[];
5
+ };
6
+ export declare function exportXlsx(snapshot: SpreadsheetWorkbookSnapshot): Promise<ArrayBuffer>;
package/dist/style.css ADDED
@@ -0,0 +1,3 @@
1
+ /*! tailwindcss v4.3.3 | MIT License | https://tailwindcss.com */
2
+ @layer properties{@supports (((-webkit-hyphens:none)) and (not (margin-trim:inline))) or ((-moz-orient:inline) and (not (color:rgb(from red r g b)))){*,:before,:after,::backdrop{--tw-space-y-reverse:0;--tw-border-style:solid;--tw-font-weight:initial;--tw-shadow:0 0 #0000;--tw-shadow-color:initial;--tw-shadow-alpha:100%;--tw-inset-shadow:0 0 #0000;--tw-inset-shadow-color:initial;--tw-inset-shadow-alpha:100%;--tw-ring-color:initial;--tw-ring-shadow:0 0 #0000;--tw-inset-ring-color:initial;--tw-inset-ring-shadow:0 0 #0000;--tw-ring-inset:initial;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-offset-shadow:0 0 #0000}}}@layer theme{:root,:host{--font-sans:-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", "Noto Sans", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";--font-mono:ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;--spacing:.25rem;--text-xs:.75rem;--text-xs--line-height:calc(1 / .75);--text-sm:.875rem;--text-sm--line-height:calc(1.25 / .875);--font-weight-medium:500;--font-weight-semibold:600;--default-transition-duration:.15s;--default-transition-timing-function:cubic-bezier(.4, 0, .2, 1);--default-font-family:var(--font-sans);--default-mono-font-family:var(--font-mono)}}@layer base{*,:after,:before,::backdrop{box-sizing:border-box;border:0 solid;margin:0;padding:0}::file-selector-button{box-sizing:border-box;border:0 solid;margin:0;padding:0}html,:host{-webkit-text-size-adjust:100%;tab-size:4;line-height:1.5;font-family:var(--default-font-family,-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", "Noto Sans", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji");font-feature-settings:var(--default-font-feature-settings,normal);font-variation-settings:var(--default-font-variation-settings,normal);-webkit-tap-highlight-color:transparent}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;-webkit-text-decoration:inherit;-webkit-text-decoration:inherit;-webkit-text-decoration:inherit;-webkit-text-decoration:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,samp,pre{font-family:var(--default-mono-font-family,ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace);font-feature-settings:var(--default-mono-font-feature-settings,normal);font-variation-settings:var(--default-mono-font-variation-settings,normal);font-size:1em}small{font-size:80%}sub,sup{vertical-align:baseline;font-size:75%;line-height:0;position:relative}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}:-moz-focusring:where(:not(iframe)){outline:auto}progress{vertical-align:baseline}summary{display:list-item}ol,ul,menu{list-style:none}img,svg,video,canvas,audio,iframe,embed,object{vertical-align:middle;display:block}img,video{max-width:100%;height:auto}button,input,select,optgroup,textarea{font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;color:inherit;opacity:1;background-color:#0000;border-radius:0}::file-selector-button{font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;color:inherit;opacity:1;background-color:#0000;border-radius:0}:where(select:is([multiple],[size])) optgroup{font-weight:bolder}:where(select:is([multiple],[size])) optgroup option{padding-inline-start:20px}::file-selector-button{margin-inline-end:4px}::placeholder{opacity:1}@supports (not ((-webkit-appearance:-apple-pay-button))) or (contain-intrinsic-size:1px){::placeholder{color:currentColor}@supports (color:color-mix(in lab, red, red)){::placeholder{color:color-mix(in oklab, currentcolor 50%, transparent)}}}textarea{resize:vertical}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-date-and-time-value{min-height:1lh;text-align:inherit}::-webkit-datetime-edit{display:inline-flex}::-webkit-datetime-edit-fields-wrapper{padding:0}::-webkit-datetime-edit{padding-block:0}::-webkit-datetime-edit-year-field{padding-block:0}::-webkit-datetime-edit-month-field{padding-block:0}::-webkit-datetime-edit-day-field{padding-block:0}::-webkit-datetime-edit-hour-field{padding-block:0}::-webkit-datetime-edit-minute-field{padding-block:0}::-webkit-datetime-edit-second-field{padding-block:0}::-webkit-datetime-edit-millisecond-field{padding-block:0}::-webkit-datetime-edit-meridiem-field{padding-block:0}::-webkit-calendar-picker-indicator{line-height:1}:-moz-ui-invalid{box-shadow:none}button,input:where([type=button],[type=reset],[type=submit]){appearance:button}::file-selector-button{appearance:button}::-webkit-inner-spin-button{height:auto}::-webkit-outer-spin-button{height:auto}[hidden]:where(:not([hidden=until-found])){display:none!important}}@layer components;@layer utilities{.sr-only{clip-path:inset(50%);white-space:nowrap;border-width:0;width:1px;height:1px;margin:-1px;padding:0;position:absolute;overflow:hidden}.absolute{position:absolute}.relative{position:relative}.static{position:static}.inset-x-0{inset-inline:0}.bottom-0{bottom:0}.mx-1{margin-inline:var(--spacing)}.mt-0\.5{margin-top:calc(var(--spacing) * .5)}.ml-1{margin-left:var(--spacing)}.flex{display:flex}.grid{display:grid}.inline-flex{display:inline-flex}.size-5{width:calc(var(--spacing) * 5);height:calc(var(--spacing) * 5)}.h-0\.5{height:calc(var(--spacing) * .5)}.h-3\.5{height:calc(var(--spacing) * 3.5)}.h-5{height:calc(var(--spacing) * 5)}.h-6{height:calc(var(--spacing) * 6)}.h-8{height:calc(var(--spacing) * 8)}.h-9{height:calc(var(--spacing) * 9)}.h-full{height:100%}.min-h-0{min-height:0}.w-3\.5{width:calc(var(--spacing) * 3.5)}.w-5{width:calc(var(--spacing) * 5)}.w-6{width:calc(var(--spacing) * 6)}.w-9{width:calc(var(--spacing) * 9)}.w-24{width:calc(var(--spacing) * 24)}.w-44{width:calc(var(--spacing) * 44)}.w-\[68px\]{width:68px}.w-\[118px\]{width:118px}.min-w-0{min-width:0}.min-w-6{min-width:calc(var(--spacing) * 6)}.min-w-11{min-width:calc(var(--spacing) * 11)}.flex-1{flex:1}.flex-none{flex:none}.shrink-0{flex-shrink:0}.flex-col{flex-direction:column}.items-center{align-items:center}.items-start{align-items:flex-start}.justify-center{justify-content:center}.gap-0\.5{gap:calc(var(--spacing) * .5)}.gap-2{gap:calc(var(--spacing) * 2)}.gap-3{gap:calc(var(--spacing) * 3)}:where(.space-y-1>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(var(--spacing) * var(--tw-space-y-reverse));margin-block-end:calc(var(--spacing) * calc(1 - var(--tw-space-y-reverse)))}.truncate{text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.overflow-auto{overflow:auto}.overflow-x-auto{overflow-x:auto}.rounded{border-radius:.25rem}.rounded-full{border-radius:2147483647px}.border{border-style:var(--tw-border-style);border-width:1px}.border-0{border-style:var(--tw-border-style);border-width:0}.border-t{border-top-style:var(--tw-border-style);border-top-width:1px}.border-r{border-right-style:var(--tw-border-style);border-right-width:1px}.border-b{border-bottom-style:var(--tw-border-style);border-bottom-width:1px}.border-l{border-left-style:var(--tw-border-style);border-left-width:1px}.px-1{padding-inline:var(--spacing)}.px-2{padding-inline:calc(var(--spacing) * 2)}.px-3{padding-inline:calc(var(--spacing) * 3)}.px-6{padding-inline:calc(var(--spacing) * 6)}.py-1{padding-block:var(--spacing)}.py-2{padding-block:calc(var(--spacing) * 2)}.pl-0\.5{padding-left:calc(var(--spacing) * .5)}.text-center{text-align:center}.text-sm{font-size:var(--text-sm);line-height:var(--tw-leading,var(--text-sm--line-height))}.text-xs{font-size:var(--text-xs);line-height:var(--tw-leading,var(--text-xs--line-height))}.text-\[10px\]{font-size:10px}.font-medium{--tw-font-weight:var(--font-weight-medium);font-weight:var(--font-weight-medium)}.font-semibold{--tw-font-weight:var(--font-weight-semibold);font-weight:var(--font-weight-semibold)}.italic{font-style:italic}.underline{text-decoration-line:underline}.transition-colors{transition-property:color,background-color,border-color,outline-color,text-decoration-color,fill,stroke,--tw-gradient-from,--tw-gradient-via,--tw-gradient-to;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.outline-none{--tw-outline-style:none;outline-style:none}.focus-visible\:ring-2:focus-visible{--tw-ring-shadow:var(--tw-ring-inset,) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color,currentcolor);box-shadow:var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow)}.focus-visible\:outline-none:focus-visible{--tw-outline-style:none;outline-style:none}.focus-visible\:ring-inset:focus-visible{--tw-ring-inset:inset}.disabled\:cursor-not-allowed:disabled{cursor:not-allowed}.disabled\:opacity-50:disabled{opacity:.5}@media (prefers-reduced-motion:reduce){.motion-reduce\:animate-none{animation:none}}}[data-spreadsheet-surface]{--lc-spreadsheet-selection:#2563eb}.dark [data-spreadsheet-surface]{--lc-spreadsheet-selection:#60a5fa}.spreadsheet-sheet-tab:focus-visible{box-shadow:0 0 0 2px hsl(var(--ring))}.spreadsheet-grid{background:hsl(var(--background));contain:strict}.spreadsheet-cell,.spreadsheet-column-header,.spreadsheet-row-header,.spreadsheet-corner{box-sizing:border-box;border-right:1px solid hsl(var(--border));border-bottom:1px solid hsl(var(--border));position:absolute}.spreadsheet-cell{z-index:1;white-space:nowrap;color:var(--spreadsheet-cell-color,hsl(var(--foreground)));background:var(--spreadsheet-cell-fill,hsl(var(--background)));-webkit-user-select:none;user-select:none;align-items:center;padding:4px 7px;font-size:12px;line-height:17px;display:flex;overflow:hidden}.spreadsheet-cell.is-selected{background:var(--lc-spreadsheet-selection)}@supports (color:color-mix(in lab, red, red)){.spreadsheet-cell.is-selected{background:color-mix(in srgb, var(--lc-spreadsheet-selection) 18%, var(--spreadsheet-cell-fill,hsl(var(--background))))}}.spreadsheet-cell.is-active{z-index:2;box-shadow:inset 0 0 0 2px var(--lc-spreadsheet-selection), inset 0 0 0 3px var(--lc-spreadsheet-selection)}@supports (color:color-mix(in lab, red, red)){.spreadsheet-cell.is-active{box-shadow:inset 0 0 0 2px var(--lc-spreadsheet-selection), inset 0 0 0 3px color-mix(in srgb, var(--lc-spreadsheet-selection) 18%, transparent)}}.spreadsheet-column-header,.spreadsheet-row-header,.spreadsheet-corner{z-index:4;color:hsl(var(--muted-foreground));background:hsl(var(--muted));-webkit-user-select:none;user-select:none;justify-content:center;align-items:center;font-size:11px;font-weight:500;display:flex}.spreadsheet-column-header.is-selected,.spreadsheet-row-header.is-selected{color:var(--lc-spreadsheet-selection)}@supports (color:color-mix(in lab, red, red)){.spreadsheet-column-header.is-selected,.spreadsheet-row-header.is-selected{color:color-mix(in srgb, var(--lc-spreadsheet-selection) 82%, hsl(var(--foreground)))}}.spreadsheet-column-header.is-selected,.spreadsheet-row-header.is-selected{background:var(--lc-spreadsheet-selection)}@supports (color:color-mix(in lab, red, red)){.spreadsheet-column-header.is-selected,.spreadsheet-row-header.is-selected{background:color-mix(in srgb, var(--lc-spreadsheet-selection) 15%, hsl(var(--muted)))}}.spreadsheet-column-header.is-selected,.spreadsheet-row-header.is-selected{font-weight:650}.spreadsheet-column-header{height:28px}.spreadsheet-row-header{width:48px}.spreadsheet-corner{z-index:6;width:48px;height:28px}.spreadsheet-inline-editor{z-index:8;box-sizing:border-box;border:2px solid hsl(var(--primary));color:hsl(var(--foreground));background:hsl(var(--background));outline:none;padding:2px 5px;font-size:12px;position:absolute}.spreadsheet-sheet-tab{height:1.75rem;color:hsl(var(--muted-foreground));border-bottom:2px solid #0000;outline:none;flex:none;padding-inline:.75rem;font-size:12px}.spreadsheet-sheet-tab:hover{color:hsl(var(--foreground));background:hsl(var(--accent))}.spreadsheet-sheet-tab[aria-pressed=true]{border-bottom-color:hsl(var(--primary));color:hsl(var(--foreground));background:hsl(var(--background))}.spreadsheet-sheet-rename{border:0;border-bottom:2px solid hsl(var(--primary));width:7.5rem;height:1.75rem;color:hsl(var(--foreground));background:hsl(var(--background));outline:none;flex:none;padding-inline:.75rem;font-size:12px}.spreadsheet-sheet-rename:focus-visible{box-shadow:inset 0 0 0 2px hsl(var(--ring))}.spreadsheet-sheet-rename[aria-invalid=true]{border-bottom-color:hsl(var(--destructive));box-shadow:inset 0 0 0 1px hsl(var(--destructive))}.spreadsheet-sheet-rename:disabled{cursor:not-allowed;opacity:.5}.spreadsheet-loading-indicator{border:2px solid hsl(var(--border));border-top-color:hsl(var(--foreground));border-radius:9999px;width:1rem;height:1rem;animation:.8s linear infinite spreadsheet-spin}@keyframes spreadsheet-spin{to{transform:rotate(360deg)}}@property --tw-space-y-reverse{syntax:"*";inherits:false;initial-value:0}@property --tw-border-style{syntax:"*";inherits:false;initial-value:solid}@property --tw-font-weight{syntax:"*";inherits:false}@property --tw-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-shadow-color{syntax:"*";inherits:false}@property --tw-shadow-alpha{syntax:"<percentage>";inherits:false;initial-value:100%}@property --tw-inset-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-inset-shadow-color{syntax:"*";inherits:false}@property --tw-inset-shadow-alpha{syntax:"<percentage>";inherits:false;initial-value:100%}@property --tw-ring-color{syntax:"*";inherits:false}@property --tw-ring-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-inset-ring-color{syntax:"*";inherits:false}@property --tw-inset-ring-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-ring-inset{syntax:"*";inherits:false}@property --tw-ring-offset-width{syntax:"<length>";inherits:false;initial-value:0}@property --tw-ring-offset-color{syntax:"*";inherits:false;initial-value:#fff}@property --tw-ring-offset-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}
3
+ /*$vite$:1*/
@@ -0,0 +1,176 @@
1
+ import { LcDocumentPageLayout, LcDocumentSelection, LcDocumentSession, LcDocumentSource } from '../../..';
2
+ export interface SpreadsheetCellSnapshot {
3
+ input: string;
4
+ style?: Record<string, unknown>;
5
+ }
6
+ export type SpreadsheetHorizontalAlignment = 'general' | 'left' | 'center' | 'right';
7
+ export type SpreadsheetVerticalAlignment = 'top' | 'center' | 'bottom';
8
+ export interface SpreadsheetCellStylePatch {
9
+ font?: {
10
+ family?: string;
11
+ size?: number;
12
+ bold?: boolean;
13
+ italic?: boolean;
14
+ underline?: boolean;
15
+ color?: string;
16
+ };
17
+ fill?: {
18
+ color?: string;
19
+ };
20
+ alignment?: {
21
+ horizontal?: SpreadsheetHorizontalAlignment;
22
+ vertical?: SpreadsheetVerticalAlignment;
23
+ wrapText?: boolean;
24
+ };
25
+ }
26
+ export interface SpreadsheetSelectionStyle {
27
+ fontFamily: string;
28
+ fontSize: number;
29
+ bold: boolean;
30
+ italic: boolean;
31
+ underline: boolean;
32
+ fontColor: string;
33
+ fillColor: string;
34
+ horizontal: SpreadsheetHorizontalAlignment;
35
+ vertical: SpreadsheetVerticalAlignment;
36
+ wrapText: boolean;
37
+ }
38
+ export interface SpreadsheetMergeSnapshot {
39
+ startRow: number;
40
+ startColumn: number;
41
+ endRow: number;
42
+ endColumn: number;
43
+ }
44
+ export interface SpreadsheetSheetSnapshot {
45
+ id: string;
46
+ name: string;
47
+ cells: Record<string, SpreadsheetCellSnapshot>;
48
+ merges?: SpreadsheetMergeSnapshot[];
49
+ columnWidths?: Record<string, number>;
50
+ rowHeights?: Record<string, number>;
51
+ }
52
+ export interface SpreadsheetWorkbookSnapshot extends Record<string, unknown> {
53
+ kind: 'langeditor-spreadsheet';
54
+ version: 1;
55
+ name: string;
56
+ sheets: SpreadsheetSheetSnapshot[];
57
+ selectedSheetId: string;
58
+ pageLayout: LcDocumentPageLayout;
59
+ metadata?: Record<string, unknown>;
60
+ }
61
+ export interface SpreadsheetRangeSelection extends LcDocumentSelection {
62
+ kind: 'spreadsheet-range';
63
+ sheetId: string;
64
+ sheetName: string;
65
+ startRow: number;
66
+ startColumn: number;
67
+ endRow: number;
68
+ endColumn: number;
69
+ address: string;
70
+ }
71
+ export interface SpreadsheetImportDiagnostic {
72
+ code: 'macros-ignored' | 'charts-unsupported' | 'images-unsupported' | 'styles-partial' | 'range-truncated';
73
+ severity: 'info' | 'warning';
74
+ sheet?: string;
75
+ detail?: string;
76
+ }
77
+ export interface SpreadsheetPluginOptions {
78
+ initialRows?: number;
79
+ initialColumns?: number;
80
+ maxContextCells?: number;
81
+ workbookName?: string;
82
+ }
83
+ export interface SpreadsheetPluginOptionsRoot {
84
+ spreadsheet?: SpreadsheetPluginOptions;
85
+ }
86
+ export type SpreadsheetExportFormat = 'xlsx' | 'csv';
87
+ export type SpreadsheetOperation = {
88
+ type: 'spreadsheet.set-cell';
89
+ payload: {
90
+ sheetId?: string;
91
+ row: number;
92
+ column: number;
93
+ input: string;
94
+ };
95
+ } | {
96
+ type: 'spreadsheet.set-range';
97
+ payload: {
98
+ sheetId?: string;
99
+ row: number;
100
+ column: number;
101
+ values: string[][];
102
+ };
103
+ } | {
104
+ type: 'spreadsheet.clear-range';
105
+ payload?: {
106
+ sheetId?: string;
107
+ };
108
+ } | {
109
+ type: 'spreadsheet.insert-rows';
110
+ payload?: {
111
+ sheetId?: string;
112
+ row?: number;
113
+ count?: number;
114
+ };
115
+ } | {
116
+ type: 'spreadsheet.insert-columns';
117
+ payload?: {
118
+ sheetId?: string;
119
+ column?: number;
120
+ count?: number;
121
+ };
122
+ } | {
123
+ type: 'spreadsheet.add-sheet';
124
+ payload?: {
125
+ name?: string;
126
+ };
127
+ } | {
128
+ type: 'spreadsheet.rename-sheet';
129
+ payload: {
130
+ sheetId?: string;
131
+ name: string;
132
+ };
133
+ } | {
134
+ type: 'spreadsheet.set-style';
135
+ payload: SpreadsheetCellStylePatch;
136
+ } | {
137
+ type: 'spreadsheet.clear-formatting';
138
+ payload?: Record<string, never>;
139
+ } | {
140
+ type: 'spreadsheet.merge-cells';
141
+ payload?: Record<string, never>;
142
+ } | {
143
+ type: 'spreadsheet.unmerge-cells';
144
+ payload?: Record<string, never>;
145
+ } | {
146
+ type: 'spreadsheet.select-range';
147
+ payload: {
148
+ sheetId: string;
149
+ startRow: number;
150
+ startColumn: number;
151
+ endRow: number;
152
+ endColumn: number;
153
+ };
154
+ } | {
155
+ type: 'spreadsheet.import';
156
+ payload: {
157
+ source: LcDocumentSource;
158
+ };
159
+ } | {
160
+ type: 'spreadsheet.export';
161
+ payload: {
162
+ format: SpreadsheetExportFormat;
163
+ };
164
+ };
165
+ export interface SpreadsheetDocumentSession extends LcDocumentSession<SpreadsheetWorkbookSnapshot> {
166
+ getSpreadsheetState: () => {
167
+ value: SpreadsheetWorkbookSnapshot;
168
+ selection: SpreadsheetRangeSelection;
169
+ selectionStyle: SpreadsheetSelectionStyle;
170
+ merged: boolean;
171
+ diagnostics: SpreadsheetImportDiagnostic[];
172
+ };
173
+ setActiveSheet: (sheetId: string) => void;
174
+ setRangeSelection: (selection: SpreadsheetRangeSelection) => void;
175
+ getFormattedCellValue: (sheetId: string, row: number, column: number) => string;
176
+ }
package/package.json CHANGED
@@ -1,6 +1,71 @@
1
1
  {
2
2
  "name": "@langeditor/plugin-spreadsheet",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "version": "1.1.4",
4
+ "description": "Open-source spreadsheet document mode for LangEditor powered by IronCalc.",
5
+ "license": "MIT",
6
+ "type": "module",
7
+ "sideEffects": [
8
+ "./src/index.ts",
9
+ "./src/plugin.ts",
10
+ "./src/styles/index.css",
11
+ "./dist/index.es.js",
12
+ "./dist/style.css"
13
+ ],
14
+ "main": "./dist/index.es.js",
15
+ "module": "./dist/index.es.js",
16
+ "types": "./dist/index.d.ts",
17
+ "exports": {
18
+ ".": {
19
+ "types": "./dist/index.d.ts",
20
+ "import": "./dist/index.es.js"
21
+ },
22
+ "./style.css": "./dist/style.css",
23
+ "./package.json": "./package.json"
24
+ },
25
+ "files": [
26
+ "dist",
27
+ "README.md",
28
+ "PRD.md",
29
+ "LICENSE",
30
+ "package.json"
31
+ ],
32
+ "peerDependencies": {
33
+ "@langeditor/core": "^1.1.4",
34
+ "@lucide/vue": ">=0.468.0",
35
+ "vue": ">=3.5.0"
36
+ },
37
+ "dependencies": {
38
+ "@e965/xlsx": "^0.20.3",
39
+ "@ironcalc/wasm": "^0.8.4",
40
+ "exceljs": "^4.4.0",
41
+ "papaparse": "^5.7.0"
42
+ },
43
+ "devDependencies": {
44
+ "@tailwindcss/vite": "^4.3.3",
45
+ "@types/papaparse": "^5.5.2",
46
+ "@vitejs/plugin-vue": "^6.0.8",
47
+ "tailwindcss": "^4.3.3",
48
+ "typescript": "~6.0.2",
49
+ "vite": "^8.2.2",
50
+ "vite-plugin-dts": "^5.0.3",
51
+ "vue-tsc": "^3.1.0",
52
+ "@langeditor/core": "1.1.4"
53
+ },
54
+ "publishConfig": {
55
+ "access": "public",
56
+ "registry": "https://registry.npmjs.org/"
57
+ },
58
+ "repository": {
59
+ "type": "git",
60
+ "url": "git+https://github.com/tycoding/langeditor.git",
61
+ "directory": "packages/editor-plugin-spreadsheet"
62
+ },
63
+ "homepage": "https://langeditor.cn",
64
+ "bugs": {
65
+ "url": "https://github.com/tycoding/langeditor/issues"
66
+ },
67
+ "scripts": {
68
+ "build": "vite build",
69
+ "typecheck": "vue-tsc --noEmit -p tsconfig.json"
70
+ }
6
71
  }