@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.
- package/LICENSE +21 -0
- package/PRD.md +72 -0
- package/README.md +82 -2
- package/dist/chunks/SpreadsheetSurface-C5IFZ3LB.js +1762 -0
- package/dist/chunks/csv-DF3_VfSt.js +506 -0
- package/dist/chunks/exceljs.min-DrDLmZv4.js +32079 -0
- package/dist/chunks/source-BxpnMm0o.js +37 -0
- package/dist/chunks/workbook-CY5eURLn.js +351 -0
- package/dist/chunks/xlsx-DGiNLc4q.js +17499 -0
- package/dist/components/SpreadsheetStatus.vue.d.ts +7 -0
- package/dist/components/SpreadsheetSurface.vue.d.ts +37 -0
- package/dist/components/SpreadsheetToolbar.vue.d.ts +7 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.es.js +647 -0
- package/dist/locales/en.d.ts +57 -0
- package/dist/locales/zh.d.ts +57 -0
- package/dist/manifest.d.ts +10 -0
- package/dist/model/workbook.d.ts +55 -0
- package/dist/plugin.d.ts +1 -0
- package/dist/serializers/csv.d.ts +7 -0
- package/dist/serializers/index.d.ts +7 -0
- package/dist/serializers/source.d.ts +6 -0
- package/dist/serializers/xlsx.d.ts +6 -0
- package/dist/style.css +3 -0
- package/dist/types.d.ts +176 -0
- package/package.json +68 -3
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024-present TyCoding and LangEditor contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/PRD.md
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
# Spreadsheet Document Mode PRD
|
|
2
|
+
|
|
3
|
+
## Purpose
|
|
4
|
+
|
|
5
|
+
Provide a permissively licensed spreadsheet editor as the independently
|
|
6
|
+
installable `@langeditor/plugin-spreadsheet` package. Importing the package
|
|
7
|
+
registers `mode="spreadsheet"`; the grid and format runtimes are downloaded only
|
|
8
|
+
when that mode is mounted.
|
|
9
|
+
|
|
10
|
+
## License and dependencies
|
|
11
|
+
|
|
12
|
+
The package itself is MIT. Runtime dependencies are restricted to permissive
|
|
13
|
+
licenses:
|
|
14
|
+
|
|
15
|
+
- official `@ironcalc/wasm` under MIT/Apache-2.0 for workbook calculation;
|
|
16
|
+
- `@e965/xlsx` under Apache-2.0 for XLSX/ODS import;
|
|
17
|
+
- ExcelJS under MIT for style-preserving XLSX export;
|
|
18
|
+
- Papa Parse under MIT for CSV serialization.
|
|
19
|
+
|
|
20
|
+
Univer, Handsontable, and any dependency requiring a commercial web-use license
|
|
21
|
+
are explicitly out of scope.
|
|
22
|
+
|
|
23
|
+
## Current scope
|
|
24
|
+
|
|
25
|
+
- editable cell grid with keyboard navigation and range selection;
|
|
26
|
+
- formulas calculated by IronCalc;
|
|
27
|
+
- basic cell formatting: font family and size, emphasis, text/fill color,
|
|
28
|
+
horizontal alignment, and wrapping;
|
|
29
|
+
- merge and unmerge selected cell ranges;
|
|
30
|
+
- multiple worksheet tabs with double-click rename;
|
|
31
|
+
- XLSX and CSV import/export;
|
|
32
|
+
- serializable workbook snapshot for `v-model`;
|
|
33
|
+
- spreadsheet selection, AI context, and operation support through
|
|
34
|
+
`LcDocumentSession`;
|
|
35
|
+
- shared LangEditor toolbar/statusbar slots;
|
|
36
|
+
- shared blue document title bar without Word page chrome;
|
|
37
|
+
- Chinese and English UI.
|
|
38
|
+
|
|
39
|
+
## Non-goals
|
|
40
|
+
|
|
41
|
+
The plugin does not claim complete Excel fidelity. Macros, pivot tables,
|
|
42
|
+
embedded charts/images, external workbook links, protected/encrypted workbooks,
|
|
43
|
+
and advanced print areas are not editable. Import returns diagnostics for features
|
|
44
|
+
that cannot be represented safely.
|
|
45
|
+
|
|
46
|
+
## UI placement
|
|
47
|
+
|
|
48
|
+
- `toolbar`: import/export, font formatting, colors, alignment, wrapping,
|
|
49
|
+
merge/unmerge, clear formatting, add row/column, and add sheet.
|
|
50
|
+
- `statusbar-left`: active worksheet and selected range.
|
|
51
|
+
- document surface: formula bar, row/column headers, virtual scrolling grid, and
|
|
52
|
+
worksheet tabs.
|
|
53
|
+
- document title bar: host-owned blue title bar shared with Word and future
|
|
54
|
+
document modes; spreadsheet print metadata does not render Word page chrome.
|
|
55
|
+
|
|
56
|
+
No second toolbar row is created. The grid releases all listeners and the WASM
|
|
57
|
+
model when its document session is destroyed.
|
|
58
|
+
|
|
59
|
+
## AI and collaboration
|
|
60
|
+
|
|
61
|
+
`getAIContext()` returns a bounded snapshot of the selected range including raw
|
|
62
|
+
formula input and formatted values. AI or collaboration changes use validated
|
|
63
|
+
spreadsheet operations rather than direct DOM or engine mutation. Provider
|
|
64
|
+
credentials and document authorization remain outside this browser package.
|
|
65
|
+
|
|
66
|
+
## Failure states
|
|
67
|
+
|
|
68
|
+
- WASM initialization failure: surface error with retry available from the host.
|
|
69
|
+
- unsupported/corrupt import: localized actionable error plus diagnostics.
|
|
70
|
+
- oversized range: AI context is truncated and marked in metadata.
|
|
71
|
+
- unsupported operation: rejected with an explicit error; document state is not
|
|
72
|
+
partially mutated.
|
package/README.md
CHANGED
|
@@ -1,3 +1,83 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @langeditor/plugin-spreadsheet
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Open-source spreadsheet mode for LangEditor. It uses IronCalc for formula
|
|
4
|
+
calculation and keeps XLSX/CSV code behind the document surface's dynamic import.
|
|
5
|
+
|
|
6
|
+
The built-in toolbar supports font family and size, bold/italic/underline,
|
|
7
|
+
text and fill colors, alignment, wrapping, merged cells, row/column insertion,
|
|
8
|
+
worksheet creation, and clearing cell formatting. These changes are persisted in
|
|
9
|
+
the workbook snapshot and included in XLSX export.
|
|
10
|
+
|
|
11
|
+
Double-click a worksheet tab to rename it. Press Enter or move focus away to
|
|
12
|
+
save, and press Escape to cancel. Worksheet renames use the same validated
|
|
13
|
+
document-operation path as toolbar, AI, collaboration, and host changes.
|
|
14
|
+
|
|
15
|
+
## Install
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
pnpm add @langeditor/core @langeditor/plugin-spreadsheet
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
```ts
|
|
22
|
+
import '@langeditor/plugin-spreadsheet'
|
|
23
|
+
import '@langeditor/plugin-spreadsheet/style.css'
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## Vue
|
|
27
|
+
|
|
28
|
+
```vue
|
|
29
|
+
<script setup lang="ts">
|
|
30
|
+
import { ref } from 'vue'
|
|
31
|
+
import { LangEditor } from '@langeditor/core'
|
|
32
|
+
import type { SpreadsheetWorkbookSnapshot } from '@langeditor/plugin-spreadsheet'
|
|
33
|
+
import '@langeditor/plugin-spreadsheet'
|
|
34
|
+
import '@langeditor/plugin-spreadsheet/style.css'
|
|
35
|
+
|
|
36
|
+
const workbook = ref<SpreadsheetWorkbookSnapshot>()
|
|
37
|
+
const source = ref<File>()
|
|
38
|
+
</script>
|
|
39
|
+
|
|
40
|
+
<template>
|
|
41
|
+
<LangEditor
|
|
42
|
+
v-model="workbook"
|
|
43
|
+
:document-source="source"
|
|
44
|
+
mode="spreadsheet"
|
|
45
|
+
:min-height="680"
|
|
46
|
+
/>
|
|
47
|
+
</template>
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
The same `mode`, `documentSource`, `lc-session-ready`, and `getSession()` contract
|
|
51
|
+
works through `@langeditor/core/element` and the React adapter.
|
|
52
|
+
|
|
53
|
+
Formatting and merge commands also use the public document-operation path, so AI,
|
|
54
|
+
collaboration, and host integrations do not need to mutate grid DOM:
|
|
55
|
+
|
|
56
|
+
```ts
|
|
57
|
+
await session.applyOperations([
|
|
58
|
+
{ type: 'spreadsheet.set-style', payload: { font: { bold: true, size: 14 } } },
|
|
59
|
+
{ type: 'spreadsheet.rename-sheet', payload: { name: 'Budget 2027' } },
|
|
60
|
+
{ type: 'spreadsheet.merge-cells' },
|
|
61
|
+
])
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
Programmatic serializers are asynchronous so importing the registration entry
|
|
65
|
+
does not eagerly load XLSX or CSV code:
|
|
66
|
+
|
|
67
|
+
```ts
|
|
68
|
+
import { exportSpreadsheet, importSpreadsheet } from '@langeditor/plugin-spreadsheet'
|
|
69
|
+
|
|
70
|
+
const { value, diagnostics } = await importSpreadsheet(file)
|
|
71
|
+
const xlsx = await exportSpreadsheet(value, 'xlsx')
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
## Supported input
|
|
75
|
+
|
|
76
|
+
- `.xlsx`, `.xlsm` without macro execution, and `.ods` where the serializer can
|
|
77
|
+
read the workbook;
|
|
78
|
+
- `.csv`, `.tsv`, and plain delimited text;
|
|
79
|
+
- `SpreadsheetWorkbookSnapshot` through `v-model`;
|
|
80
|
+
- URL, File, Blob, ArrayBuffer, or Uint8Array through `documentSource`.
|
|
81
|
+
|
|
82
|
+
See [PRD.md](./PRD.md) for fidelity limits and failure behavior. The package is
|
|
83
|
+
MIT and contains no commercial-license dependency.
|