@casualoffice/sheets 0.11.0 → 0.11.1
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/embed/embed.html
CHANGED
|
@@ -5,16 +5,30 @@
|
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
6
6
|
<title>Casual Sheets (embed)</title>
|
|
7
7
|
<style>
|
|
8
|
-
html,
|
|
9
|
-
|
|
8
|
+
html,
|
|
9
|
+
body {
|
|
10
|
+
margin: 0;
|
|
11
|
+
padding: 0;
|
|
12
|
+
height: 100%;
|
|
13
|
+
background: #fff;
|
|
14
|
+
overflow: hidden;
|
|
15
|
+
}
|
|
16
|
+
#casual-embed-root {
|
|
17
|
+
width: 100%;
|
|
18
|
+
height: 100%;
|
|
19
|
+
}
|
|
10
20
|
/* Preview-mode chrome hiding — v0.5.x ties these to component
|
|
11
21
|
props; v0.5.0 lands the wire end-to-end and uses CSS gates. */
|
|
12
|
-
[data-view-mode=
|
|
13
|
-
[data-view-mode=
|
|
14
|
-
[data-view-mode=
|
|
15
|
-
[data-view-mode=
|
|
22
|
+
[data-view-mode='preview'] [data-toolbar],
|
|
23
|
+
[data-view-mode='preview'] [data-formula-bar],
|
|
24
|
+
[data-view-mode='preview'] [data-status-bar],
|
|
25
|
+
[data-view-mode='preview'] [data-sheet-tabs] {
|
|
26
|
+
display: none !important;
|
|
27
|
+
}
|
|
16
28
|
</style>
|
|
17
|
-
|
|
29
|
+
<!-- No external stylesheet: tsup's `injectStyle` inlines Univer's CSS
|
|
30
|
+
into embed-runtime.js, which appends it as a <style> tag at runtime.
|
|
31
|
+
A <link> here would just 404 (no .css is emitted). -->
|
|
18
32
|
</head>
|
|
19
33
|
<body>
|
|
20
34
|
<div id="casual-embed-root"></div>
|
package/package.json
CHANGED
|
@@ -5,16 +5,30 @@
|
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
6
6
|
<title>Casual Sheets (embed)</title>
|
|
7
7
|
<style>
|
|
8
|
-
html,
|
|
9
|
-
|
|
8
|
+
html,
|
|
9
|
+
body {
|
|
10
|
+
margin: 0;
|
|
11
|
+
padding: 0;
|
|
12
|
+
height: 100%;
|
|
13
|
+
background: #fff;
|
|
14
|
+
overflow: hidden;
|
|
15
|
+
}
|
|
16
|
+
#casual-embed-root {
|
|
17
|
+
width: 100%;
|
|
18
|
+
height: 100%;
|
|
19
|
+
}
|
|
10
20
|
/* Preview-mode chrome hiding — v0.5.x ties these to component
|
|
11
21
|
props; v0.5.0 lands the wire end-to-end and uses CSS gates. */
|
|
12
|
-
[data-view-mode=
|
|
13
|
-
[data-view-mode=
|
|
14
|
-
[data-view-mode=
|
|
15
|
-
[data-view-mode=
|
|
22
|
+
[data-view-mode='preview'] [data-toolbar],
|
|
23
|
+
[data-view-mode='preview'] [data-formula-bar],
|
|
24
|
+
[data-view-mode='preview'] [data-status-bar],
|
|
25
|
+
[data-view-mode='preview'] [data-sheet-tabs] {
|
|
26
|
+
display: none !important;
|
|
27
|
+
}
|
|
16
28
|
</style>
|
|
17
|
-
|
|
29
|
+
<!-- No external stylesheet: tsup's `injectStyle` inlines Univer's CSS
|
|
30
|
+
into embed-runtime.js, which appends it as a <style> tag at runtime.
|
|
31
|
+
A <link> here would just 404 (no .css is emitted). -->
|
|
18
32
|
</head>
|
|
19
33
|
<body>
|
|
20
34
|
<div id="casual-embed-root"></div>
|
|
@@ -24,6 +24,7 @@ import { EmbedTransport } from '../embed/EmbedTransport';
|
|
|
24
24
|
import type { CasualApp } from '../embed/protocol';
|
|
25
25
|
import { CasualSheets } from '../sheets/CasualSheets';
|
|
26
26
|
import { xlsxToWorkbookData } from '../xlsx';
|
|
27
|
+
import { EMBED_LOCALES } from './locale';
|
|
27
28
|
import type { IWorkbookData } from '@univerjs/core';
|
|
28
29
|
|
|
29
30
|
interface EmbedUrlConfig {
|
|
@@ -224,6 +225,13 @@ function EmbeddedSheets({
|
|
|
224
225
|
key={viewMode}
|
|
225
226
|
initialData={data}
|
|
226
227
|
ui={ui}
|
|
228
|
+
// Seed the en-US string bundle. Without `locales`, Univer's
|
|
229
|
+
// LocaleService throws "Locale not initialized" and the workbench
|
|
230
|
+
// canvas never paints (data still loads, so a snapshot round-trips,
|
|
231
|
+
// but the grid is blank). The React `<CasualSheets>` host path gets
|
|
232
|
+
// this from the host's `locales` prop; the iframe has no host to
|
|
233
|
+
// pass one, so the self-contained runtime bundles a minimal set.
|
|
234
|
+
locales={EMBED_LOCALES}
|
|
227
235
|
// The embed runtime is bundled as ONE self-contained file (tsup
|
|
228
236
|
// `noExternal: /.*/`). Lazy plugins would emit per-feature dynamic
|
|
229
237
|
// chunks into dist/embed/, breaking that single-file deployment, so the
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Minimal en-US locale bundle for the in-iframe runtime.
|
|
3
|
+
*
|
|
4
|
+
* The embed runtime mounts the MINIMAL editor (`lazyPlugins={false}`):
|
|
5
|
+
* render + formula engines, UI, docs/docs-ui, sheets, sheets-ui,
|
|
6
|
+
* sheets-formula-ui, numfmt (+ ui). Univer's `LocaleService` throws
|
|
7
|
+
* `Locale not initialized` and the workbench canvas never paints if the
|
|
8
|
+
* `locales` map is empty — so we MUST seed the string bundle for exactly
|
|
9
|
+
* those plugins. (The React `<CasualSheets>` host path supplies its own
|
|
10
|
+
* `locales` prop; the iframe has no host to pass one, so it bundles this.)
|
|
11
|
+
*
|
|
12
|
+
* Kept narrow on purpose: only the plugins the minimal runtime registers.
|
|
13
|
+
* Adding strings for plugins it never loads is dead weight in the
|
|
14
|
+
* self-contained iframe bundle.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
import { LocaleType, Tools } from '@univerjs/core';
|
|
18
|
+
|
|
19
|
+
import UniverSheetsEnUS from '@univerjs/sheets/locale/en-US';
|
|
20
|
+
import UniverSheetsUIEnUS from '@univerjs/sheets-ui/locale/en-US';
|
|
21
|
+
import UniverSheetsFormulaUIEnUS from '@univerjs/sheets-formula-ui/locale/en-US';
|
|
22
|
+
import UniverSheetsNumfmtUIEnUS from '@univerjs/sheets-numfmt-ui/locale/en-US';
|
|
23
|
+
import UniverDocsUIEnUS from '@univerjs/docs-ui/locale/en-US';
|
|
24
|
+
import UniverUIEnUS from '@univerjs/ui/locale/en-US';
|
|
25
|
+
|
|
26
|
+
const enUS = Tools.deepMerge(
|
|
27
|
+
{},
|
|
28
|
+
UniverUIEnUS,
|
|
29
|
+
UniverDocsUIEnUS,
|
|
30
|
+
UniverSheetsEnUS,
|
|
31
|
+
UniverSheetsUIEnUS,
|
|
32
|
+
UniverSheetsFormulaUIEnUS,
|
|
33
|
+
UniverSheetsNumfmtUIEnUS,
|
|
34
|
+
);
|
|
35
|
+
|
|
36
|
+
export const EMBED_LOCALES = {
|
|
37
|
+
[LocaleType.EN_US]: enUS,
|
|
38
|
+
};
|