Skip to content

Commit 3ba1f55

Browse files
committed
refactor(showcase): refactor imports in custom canvas and formula showcases
1 parent c89eb9f commit 3ba1f55

File tree

89 files changed

+267896
-22986
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

89 files changed

+267896
-22986
lines changed

components/playground/playground.tsx

Lines changed: 36 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,10 @@ interface IProps {
1212
lang: string
1313
files: Files
1414
preview: ReactNode
15-
options?: {
16-
showCodeEditor?: boolean
17-
}
1815
}
1916

2017
export function Playground(props: IProps) {
21-
const { lang, preview, files, options = {} } = props
22-
23-
const { showCodeEditor = true } = options
18+
const { lang, preview, files } = props
2419

2520
const transformedFiles = Object.keys(files).reduce((acc, key) => {
2621
if (lang === 'zh-CN') {
@@ -37,6 +32,34 @@ export function Playground(props: IProps) {
3732
return acc
3833
}, {} as Files)
3934

35+
transformedFiles['package.json'] = JSON.stringify({
36+
name: 'univer-playground',
37+
version: '1.0.0',
38+
main: 'src/index.ts',
39+
dependencies: {},
40+
}, null, 2)
41+
42+
transformedFiles['index.html'] = `<!doctype html>
43+
<html>
44+
<head>
45+
<title>Univer</title>
46+
<meta charset="UTF-8" />
47+
</head>
48+
<body>
49+
<div id="app"></div>
50+
<script src="index.js"></script>
51+
</body>
52+
</html>
53+
`
54+
transformedFiles['styles.css'] = `html,
55+
body,
56+
#app {
57+
height: 100%;
58+
margin: 0;
59+
padding: 0;
60+
}
61+
`
62+
4063
return (
4164
<section>
4265
<SandpackProvider
@@ -51,15 +74,13 @@ export function Playground(props: IProps) {
5174

5275
<div className="grid grid-cols-12">
5376
<SandpackFileExplorer className="col-span-2" />
54-
{showCodeEditor && (
55-
<SandpackCodeEditor
56-
className="col-span-10 h-180!"
57-
showLineNumbers
58-
readOnly
59-
showReadOnly={false}
60-
showTabs={false}
61-
/>
62-
)}
77+
<SandpackCodeEditor
78+
className="col-span-10 h-180!"
79+
showLineNumbers
80+
readOnly
81+
showReadOnly={false}
82+
showTabs={false}
83+
/>
6384
</div>
6485
</SandpackLayout>
6586
</SandpackProvider>

content/guides/recipes/meta.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@
1010
"architecture/rendering",
1111
"architecture/web-worker",
1212
"---Tutorials---",
13-
"practices/javascript",
14-
"practices/custom-plugin",
15-
"practices/import-docs",
16-
"practices/custom-canvas",
17-
"practices/custom-command",
18-
"practices/custom-formula",
19-
"practices/custom-model",
13+
"tutorials/javascript",
14+
"tutorials/custom-plugin",
15+
"tutorials/import-docs",
16+
"tutorials/custom-canvas",
17+
"tutorials/custom-command",
18+
"tutorials/custom-formula",
19+
"tutorials/custom-model",
2020
"---Best Practices---",
2121
"practices/csv-import-plugin"
2222
]

content/guides/recipes/tutorials/custom-formula.mdx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ title: Custom Formula
44

55
When the existing formulas do not meet your needs, you can register custom formulas in the following ways.
66

7+
<PlaygroundFrame lang="en-US" slug="sheets/custom-formula" clickToShow />
8+
79
## How To Configure Custom Formulas Through Plugin
810

911
Follow the steps below to implement a custom formula `CUSTOMSUM`, configure the formula information into the formula plugin, and register the formula plugin with Univer.

content/guides/recipes/tutorials/custom-formula.zh-CN.mdx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ title: 自定义公式
44

55
当现有公式不满足你需求的时候,可以通过以下多种方式来注册自定义公式。
66

7+
<PlaygroundFrame lang="zh-CN" slug="sheets/custom-formula" clickToShow />
8+
79
## 如何通过插件配置自定义公式
810

911
按照以下步骤来实现一个自定义公式 `CUSTOMSUM`,并将公式信息配置到公式插件中,随着公式插件注册到 Univer 中。

package.json

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -29,37 +29,6 @@
2929
"@radix-ui/react-switch": "^1.2.5",
3030
"@radix-ui/react-tabs": "^1.1.12",
3131
"@radix-ui/react-tooltip": "^1.2.7",
32-
"@univerjs/icons": "^0.4.6",
33-
"class-variance-authority": "^0.7.1",
34-
"clsx": "^2.1.1",
35-
"dayjs": "^1.11.13",
36-
"feed": "^5.1.0",
37-
"fumadocs-core": "15.6.1",
38-
"fumadocs-docgen": "^2.1.0",
39-
"fumadocs-mdx": "11.6.10",
40-
"fumadocs-typescript": "^4.0.6",
41-
"fumadocs-ui": "15.6.1",
42-
"lucide-react": "^0.525.0",
43-
"motion": "^12.23.0",
44-
"next": "15.3.5",
45-
"react": "^19.1.0",
46-
"react-dom": "^19.1.0",
47-
"shiki": "^3.7.0",
48-
"tailwind-merge": "^3.3.1",
49-
"ts-morph": "^26.0.0",
50-
"tw-animate-css": "^1.3.5",
51-
"zod": "^3.25.75"
52-
},
53-
"devDependencies": {
54-
"@antfu/eslint-config": "^4.16.2",
55-
"@commitlint/cli": "^19.8.1",
56-
"@commitlint/config-conventional": "^19.8.1",
57-
"@eslint-react/eslint-plugin": "^1.52.2",
58-
"@tailwindcss/postcss": "^4.1.11",
59-
"@types/mdx": "^2.0.13",
60-
"@types/node": "24.0.10",
61-
"@types/react": "^19.1.8",
62-
"@types/react-dom": "^19.1.6",
6332
"@univerjs-pro/collaboration-client": "^0.9.1",
6433
"@univerjs-pro/collaboration-client-ui": "^0.9.1",
6534
"@univerjs-pro/exchange-client": "^0.9.1",
@@ -77,6 +46,7 @@
7746
"@univerjs/engine-formula": "^0.9.1",
7847
"@univerjs/engine-render": "^0.9.1",
7948
"@univerjs/find-replace": "^0.9.1",
49+
"@univerjs/icons": "^0.4.6",
8050
"@univerjs/preset-docs-advanced": "^0.9.1",
8151
"@univerjs/preset-docs-core": "^0.9.1",
8252
"@univerjs/preset-sheets-advanced": "^0.9.1",
@@ -110,6 +80,36 @@
11080
"@univerjs/thread-comment-ui": "^0.9.1",
11181
"@univerjs/ui": "^0.9.1",
11282
"@univerjs/watermark": "^0.9.1",
83+
"class-variance-authority": "^0.7.1",
84+
"clsx": "^2.1.1",
85+
"dayjs": "^1.11.13",
86+
"feed": "^5.1.0",
87+
"fumadocs-core": "15.6.2",
88+
"fumadocs-docgen": "^2.1.0",
89+
"fumadocs-mdx": "11.6.10",
90+
"fumadocs-typescript": "^4.0.6",
91+
"fumadocs-ui": "15.6.2",
92+
"lucide-react": "^0.525.0",
93+
"motion": "^12.23.0",
94+
"next": "15.3.5",
95+
"react": "^19.1.0",
96+
"react-dom": "^19.1.0",
97+
"shiki": "^3.7.0",
98+
"tailwind-merge": "^3.3.1",
99+
"ts-morph": "^26.0.0",
100+
"tw-animate-css": "^1.3.5",
101+
"zod": "^3.25.76"
102+
},
103+
"devDependencies": {
104+
"@antfu/eslint-config": "^4.16.2",
105+
"@commitlint/cli": "^19.8.1",
106+
"@commitlint/config-conventional": "^19.8.1",
107+
"@eslint-react/eslint-plugin": "^1.52.2",
108+
"@tailwindcss/postcss": "^4.1.11",
109+
"@types/mdx": "^2.0.13",
110+
"@types/node": "24.0.12",
111+
"@types/react": "^19.1.8",
112+
"@types/react-dom": "^19.1.6",
113113
"eslint": "^9.30.1",
114114
"eslint-plugin-better-tailwindcss": "^3.4.4",
115115
"eslint-plugin-format": "^1.0.1",

0 commit comments

Comments
 (0)