xlsx-svelte-viewer 0.4.6 → 0.5.0
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/dist/XlsxEditor.svelte +5 -3
- package/dist/runtime.d.ts +14 -4
- package/dist/runtime.js +12 -5
- package/package.json +3 -3
package/dist/XlsxEditor.svelte
CHANGED
|
@@ -7,9 +7,10 @@
|
|
|
7
7
|
ondirtychange?: EditorEventHandlers['dirty-change'];
|
|
8
8
|
onreadonlychange?: EditorEventHandlers['readonly-change'];
|
|
9
9
|
onribboncustomize?: EditorEventHandlers['ribbon-customize'];
|
|
10
|
+
oncollaborationchange?: EditorEventHandlers['collaboration-change'];
|
|
10
11
|
onready?: EditorEventHandlers['ready'];
|
|
11
12
|
};
|
|
12
|
-
let { workbook, bytes, src, fileName, readOnly = false, locale = 'en', theme = 'auto', authorName = 'Author', showToolbar = true, showFormulaBar = true, hiddenActions = [], themeColors, onworkbookchange, onworkbookerror, onselectionchange, ondirtychange, onreadonlychange, onribboncustomize, onready }: Props = $props();
|
|
13
|
+
let { workbook, bytes, src, fileName, readOnly = false, locale = 'en', theme = 'auto', authorName = 'Author', showToolbar = true, showFormulaBar = true, hiddenActions = [], themeColors, collaboration, onworkbookchange, onworkbookerror, onselectionchange, ondirtychange, onreadonlychange, onribboncustomize, oncollaborationchange, onready }: Props = $props();
|
|
13
14
|
let binding: EditorBinding | undefined;
|
|
14
15
|
const handle = deferredHandle(() => binding);
|
|
15
16
|
// Live `element` and `dirty`, the same handle vocabulary as the other frameworks (`EDITOR_HANDLE_KEYS`).
|
|
@@ -19,7 +20,7 @@
|
|
|
19
20
|
const dirty = $derived(dirtyState);
|
|
20
21
|
function attach(host: HTMLElement, options: Props) {
|
|
21
22
|
const normalized = (value: Props) => ({ ...pickEditorProps(value),
|
|
22
|
-
...eventOptions({ 'workbook-change': value.onworkbookchange, 'workbook-error': value.onworkbookerror, 'selection-change': value.onselectionchange, 'dirty-change': value.ondirtychange, 'readonly-change': value.onreadonlychange, 'ribbon-customize': value.onribboncustomize, ready: value.onready }) });
|
|
23
|
+
...eventOptions({ 'workbook-change': value.onworkbookchange, 'workbook-error': value.onworkbookerror, 'selection-change': value.onselectionchange, 'dirty-change': value.ondirtychange, 'readonly-change': value.onreadonlychange, 'ribbon-customize': value.onribboncustomize, 'collaboration-change': value.oncollaborationchange, ready: value.onready }) });
|
|
23
24
|
const tracked = (value: Props) => normalized({ ...value, ondirtychange: (next: boolean) => { dirtyState = next; value.ondirtychange?.(next); } });
|
|
24
25
|
binding = mountEditor(host, tracked(options));
|
|
25
26
|
mountedElement = binding.element;
|
|
@@ -35,10 +36,11 @@
|
|
|
35
36
|
export function select(ref: string) { handle.select(ref); }
|
|
36
37
|
export function getSelection() { return handle.getSelection(); }
|
|
37
38
|
export function setActiveSheet(index: number) { handle.setActiveSheet(index); }
|
|
39
|
+
export function share() { handle.share(); }
|
|
38
40
|
/** @deprecated Read the dirty property instead. */
|
|
39
41
|
export function isDirty() { return handle.dirty; }
|
|
40
42
|
/** @deprecated Read the element property instead. */
|
|
41
43
|
export function getElement() { return binding?.element; }
|
|
42
44
|
export { element, dirty };
|
|
43
45
|
</script>
|
|
44
|
-
<div use:attach={{ workbook, bytes, src, fileName, readOnly, locale, theme, authorName, showToolbar, showFormulaBar, hiddenActions, themeColors, onworkbookchange, onworkbookerror, onselectionchange, ondirtychange, onreadonlychange, onribboncustomize, onready }}></div>
|
|
46
|
+
<div use:attach={{ workbook, bytes, src, fileName, readOnly, locale, theme, authorName, showToolbar, showFormulaBar, hiddenActions, themeColors, collaboration, onworkbookchange, onworkbookerror, onselectionchange, ondirtychange, onreadonlychange, onribboncustomize, oncollaborationchange, onready }}></div>
|
package/dist/runtime.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { XlsxEditorElement, EditorLocaleInput, EditorThemeMode, XlsxThemeColors, SelectionChangeDetail } from 'ooxml-ui/xlsx';
|
|
1
|
+
import { XlsxEditorElement, EditorLocaleInput, EditorThemeMode, XlsxThemeColors, XlsxCollaborationOptions, SelectionChangeDetail, XlsxCollaborationState } from 'ooxml-ui/xlsx';
|
|
2
2
|
export * from 'ooxml-ui/xlsx';
|
|
3
3
|
import { Workbook } from '@christophervr/xlsx-core';
|
|
4
4
|
export * from '@christophervr/xlsx-core';
|
|
@@ -29,6 +29,11 @@ interface EditorProps {
|
|
|
29
29
|
hiddenActions?: readonly string[] | undefined;
|
|
30
30
|
/** Theme token overrides, applied as `--xve-*` custom properties. */
|
|
31
31
|
themeColors?: XlsxThemeColors | undefined;
|
|
32
|
+
/**
|
|
33
|
+
* Shares the open workbook in a room while set (room id, server URL or provider, user name and
|
|
34
|
+
* colour); forwarded when a new object is passed, and `undefined` or `null` leaves the room.
|
|
35
|
+
*/
|
|
36
|
+
collaboration?: XlsxCollaborationOptions | null | undefined;
|
|
32
37
|
}
|
|
33
38
|
/** Editor callbacks; each is the framework-neutral form of one entry in `EDITOR_EVENT_NAMES`. */
|
|
34
39
|
interface EditorEventOptions {
|
|
@@ -40,16 +45,18 @@ interface EditorEventOptions {
|
|
|
40
45
|
onReadOnlyChange?: ((readOnly: boolean) => void) | undefined;
|
|
41
46
|
/** The user changed the shown ribbon commands (File > Options > Customize Ribbon). */
|
|
42
47
|
onRibbonCustomize?: ((hiddenActions: string[]) => void) | undefined;
|
|
48
|
+
/** Sharing started or stopped, the connection changed, or someone joined or left. */
|
|
49
|
+
onCollaborationChange?: ((state: XlsxCollaborationState) => void) | undefined;
|
|
43
50
|
/** Called once, after the element is created and attached. */
|
|
44
51
|
onReady?: ((element: XlsxEditorElement) => void) | undefined;
|
|
45
52
|
}
|
|
46
53
|
interface EditorOptions extends EditorProps, EditorEventOptions {
|
|
47
54
|
}
|
|
48
55
|
/** Single source of truth for the prop keys every adapter forwards. */
|
|
49
|
-
declare const EDITOR_PROP_KEYS: readonly ["workbook", "bytes", "src", "fileName", "readOnly", "locale", "theme", "authorName", "showToolbar", "showFormulaBar", "hiddenActions", "themeColors"];
|
|
56
|
+
declare const EDITOR_PROP_KEYS: readonly ["workbook", "bytes", "src", "fileName", "readOnly", "locale", "theme", "authorName", "showToolbar", "showFormulaBar", "hiddenActions", "themeColors", "collaboration"];
|
|
50
57
|
type EditorPropKey = (typeof EDITOR_PROP_KEYS)[number];
|
|
51
58
|
/** Single source of truth for the element events every adapter surfaces. */
|
|
52
|
-
declare const EDITOR_EVENT_NAMES: readonly ["workbook-change", "workbook-error", "selection-change", "dirty-change", "readonly-change", "ribbon-customize"];
|
|
59
|
+
declare const EDITOR_EVENT_NAMES: readonly ["workbook-change", "workbook-error", "selection-change", "dirty-change", "readonly-change", "ribbon-customize", "collaboration-change"];
|
|
53
60
|
type EditorEventName = (typeof EDITOR_EVENT_NAMES)[number];
|
|
54
61
|
/** One handler per bound event (unwrapped payload); a missing key is a compile error in every adapter. */
|
|
55
62
|
interface EditorEventHandlers {
|
|
@@ -59,6 +66,7 @@ interface EditorEventHandlers {
|
|
|
59
66
|
'dirty-change': EditorEventOptions['onDirtyChange'];
|
|
60
67
|
'readonly-change': EditorEventOptions['onReadOnlyChange'];
|
|
61
68
|
'ribbon-customize': EditorEventOptions['onRibbonCustomize'];
|
|
69
|
+
'collaboration-change': EditorEventOptions['onCollaborationChange'];
|
|
62
70
|
ready?: EditorEventOptions['onReady'];
|
|
63
71
|
}
|
|
64
72
|
/** Copies exactly the shared props out of a framework's props/instance object. */
|
|
@@ -78,6 +86,8 @@ interface EditorHandle {
|
|
|
78
86
|
select(ref: string): void;
|
|
79
87
|
getSelection(): string;
|
|
80
88
|
setActiveSheet(index: number): void;
|
|
89
|
+
/** Opens File > Share, where the user starts or stops sharing the workbook. */
|
|
90
|
+
share(): void;
|
|
81
91
|
readonly dirty: boolean;
|
|
82
92
|
}
|
|
83
93
|
interface EditorBinding extends EditorHandle {
|
|
@@ -95,7 +105,7 @@ declare function mountEditor(host: HTMLElement, initial?: EditorOptions): Editor
|
|
|
95
105
|
* The imperative handle every framework exposes (React ref, Vue template ref, Angular component
|
|
96
106
|
* instance, Solid `editorRef`, Svelte component instance). `handle-keys.test.ts` checks each one.
|
|
97
107
|
*/
|
|
98
|
-
declare const EDITOR_HANDLE_KEYS: readonly ["element", "load", "newWorkbook", "save", "saveBytes", "download", "markClean", "select", "getSelection", "setActiveSheet", "dirty"];
|
|
108
|
+
declare const EDITOR_HANDLE_KEYS: readonly ["element", "load", "newWorkbook", "save", "saveBytes", "download", "markClean", "select", "getSelection", "setActiveSheet", "share", "dirty"];
|
|
99
109
|
type EditorHandleKey = (typeof EDITOR_HANDLE_KEYS)[number];
|
|
100
110
|
|
|
101
111
|
export { EDITOR_EVENT_NAMES, EDITOR_HANDLE_KEYS, EDITOR_PROP_KEYS, deferredHandle, eventOptions, mountEditor, pickEditorProps };
|
package/dist/runtime.js
CHANGED
|
@@ -78,14 +78,16 @@ var S = [
|
|
|
78
78
|
"showToolbar",
|
|
79
79
|
"showFormulaBar",
|
|
80
80
|
"hiddenActions",
|
|
81
|
-
"themeColors"
|
|
81
|
+
"themeColors",
|
|
82
|
+
"collaboration"
|
|
82
83
|
], C = [
|
|
83
84
|
"workbook-change",
|
|
84
85
|
"workbook-error",
|
|
85
86
|
"selection-change",
|
|
86
87
|
"dirty-change",
|
|
87
88
|
"readonly-change",
|
|
88
|
-
"ribbon-customize"
|
|
89
|
+
"ribbon-customize",
|
|
90
|
+
"collaboration-change"
|
|
89
91
|
];
|
|
90
92
|
function w(e, t, n) {
|
|
91
93
|
e[n] = t[n];
|
|
@@ -103,6 +105,7 @@ function E(e) {
|
|
|
103
105
|
onDirtyChange: e["dirty-change"],
|
|
104
106
|
onReadOnlyChange: e["readonly-change"],
|
|
105
107
|
onRibbonCustomize: e["ribbon-customize"],
|
|
108
|
+
onCollaborationChange: e["collaboration-change"],
|
|
106
109
|
onReady: e.ready
|
|
107
110
|
};
|
|
108
111
|
}
|
|
@@ -125,6 +128,7 @@ function D(e) {
|
|
|
125
128
|
select: (e) => t().select(e),
|
|
126
129
|
getSelection: () => t().getSelection(),
|
|
127
130
|
setActiveSheet: (e) => t().setActiveSheet(e),
|
|
131
|
+
share: () => t().share(),
|
|
128
132
|
get dirty() {
|
|
129
133
|
return e()?.dirty ?? !1;
|
|
130
134
|
}
|
|
@@ -142,7 +146,8 @@ function O(e, t = {}) {
|
|
|
142
146
|
"selection-change": (e) => r.onSelectionChange?.(e.detail),
|
|
143
147
|
"dirty-change": (e) => r.onDirtyChange?.(e.detail.dirty),
|
|
144
148
|
"readonly-change": (e) => r.onReadOnlyChange?.(e.detail.readOnly),
|
|
145
|
-
"ribbon-customize": (e) => r.onRibbonCustomize?.([...e.detail.hiddenActions])
|
|
149
|
+
"ribbon-customize": (e) => r.onRibbonCustomize?.([...e.detail.hiddenActions]),
|
|
150
|
+
"collaboration-change": (e) => r.onCollaborationChange?.(e.detail)
|
|
146
151
|
}, m = (e) => {
|
|
147
152
|
for (let t of C) {
|
|
148
153
|
let r = p[t];
|
|
@@ -153,7 +158,7 @@ function O(e, t = {}) {
|
|
|
153
158
|
let g = {
|
|
154
159
|
element: n,
|
|
155
160
|
update(e) {
|
|
156
|
-
c || (r = e, l("locale", e.locale) && (n.locale = e.locale ?? "en"), l("readOnly", e.readOnly) && (n.readOnly = e.readOnly ?? !1), l("theme", e.theme) && (n.theme = e.theme ?? "auto"), l("authorName", e.authorName) && (n.authorName = e.authorName ?? "Author"), l("showToolbar", e.showToolbar) && (n.showToolbar = e.showToolbar ?? !0), l("showFormulaBar", e.showFormulaBar) && (n.showFormulaBar = e.showFormulaBar ?? !0), l("hiddenActions", e.hiddenActions, _) && (n.hiddenActions = [...e.hiddenActions ?? []]), l("themeColors", e.themeColors, v) && (n.themeColors = { ...e.themeColors }), l("fileName", e.fileName) && e.fileName !== void 0 && (n.fileName = e.fileName), e.workbook && e.workbook !== i && e.workbook !== a && (f.cancel(), n.workbook = e.workbook), i = e.workbook, e.bytes && e.bytes !== o && (f.cancel(), d(e.bytes, e.fileName)), o = e.bytes, e.src && e.src !== s ? f.fetch(e.src, e.fileName) : !e.src && s && f.cancel(), s = e.src);
|
|
161
|
+
c || (r = e, l("locale", e.locale) && (n.locale = e.locale ?? "en"), l("readOnly", e.readOnly) && (n.readOnly = e.readOnly ?? !1), l("theme", e.theme) && (n.theme = e.theme ?? "auto"), l("authorName", e.authorName) && (n.authorName = e.authorName ?? "Author"), l("showToolbar", e.showToolbar) && (n.showToolbar = e.showToolbar ?? !0), l("showFormulaBar", e.showFormulaBar) && (n.showFormulaBar = e.showFormulaBar ?? !0), l("hiddenActions", e.hiddenActions, _) && (n.hiddenActions = [...e.hiddenActions ?? []]), l("themeColors", e.themeColors, v) && (n.themeColors = { ...e.themeColors }), l("fileName", e.fileName) && e.fileName !== void 0 && (n.fileName = e.fileName), l("collaboration", e.collaboration ?? null) && (n.collaboration = e.collaboration ?? null), e.workbook && e.workbook !== i && e.workbook !== a && (f.cancel(), n.workbook = e.workbook), i = e.workbook, e.bytes && e.bytes !== o && (f.cancel(), d(e.bytes, e.fileName)), o = e.bytes, e.src && e.src !== s ? f.fetch(e.src, e.fileName) : !e.src && s && f.cancel(), s = e.src);
|
|
157
162
|
},
|
|
158
163
|
load: (e, t) => (f.cancel(), n.load(e, t)),
|
|
159
164
|
newWorkbook: () => n.newWorkbook(),
|
|
@@ -164,11 +169,12 @@ function O(e, t = {}) {
|
|
|
164
169
|
select: (e) => n.select(e),
|
|
165
170
|
getSelection: () => n.getSelection(),
|
|
166
171
|
setActiveSheet: (e) => n.setActiveSheet(e),
|
|
172
|
+
share: () => n.share(),
|
|
167
173
|
get dirty() {
|
|
168
174
|
return n.dirty;
|
|
169
175
|
},
|
|
170
176
|
destroy() {
|
|
171
|
-
c || (c = !0, f.cancel(), m(!1), n.remove());
|
|
177
|
+
c || (c = !0, f.cancel(), typeof n.stopCollaboration == "function" && n.stopCollaboration(), m(!1), n.remove());
|
|
172
178
|
}
|
|
173
179
|
};
|
|
174
180
|
return g.update(t), e.append(n), r.onReady?.(n), g;
|
|
@@ -184,6 +190,7 @@ var k = [
|
|
|
184
190
|
"select",
|
|
185
191
|
"getSelection",
|
|
186
192
|
"setActiveSheet",
|
|
193
|
+
"share",
|
|
187
194
|
"dirty"
|
|
188
195
|
], A = /* @__PURE__ */ f({
|
|
189
196
|
LegacyXlsError: () => e,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "xlsx-svelte-viewer",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"description": "Svelte 5 component for the Excel spreadsheet editor. Self-contained: includes the editor, the formula engine and the legacy .xls reader.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"editor",
|
|
@@ -47,8 +47,8 @@
|
|
|
47
47
|
},
|
|
48
48
|
"dependencies": {
|
|
49
49
|
"@christophervr/xlsx-core": "^0.2.9",
|
|
50
|
-
"ooxml-core": "^1.
|
|
51
|
-
"ooxml-ui": "^1.
|
|
50
|
+
"ooxml-core": "^1.2.0",
|
|
51
|
+
"ooxml-ui": "^1.2.0"
|
|
52
52
|
},
|
|
53
53
|
"peerDependencies": {
|
|
54
54
|
"svelte": "^5.0.0"
|