Skip to content

Commit 5113b79

Browse files
authored
feat: add notes showcase (#23)
1 parent c60b1a8 commit 5113b79

File tree

11 files changed

+213
-4
lines changed

11 files changed

+213
-4
lines changed

app/[lang]/(home)/page.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,13 +143,13 @@ export default async function Page({ params }: IProps) {
143143

144144
<div className="flex justify-center gap-4">
145145
<RainbowButton asChild>
146-
<Link href={`/${lang}/guides/sheets`}>
146+
<Link href="/guides/sheets">
147147
<BookTextIcon />
148148
{customTranslations[lang]['documentation.title']}
149149
</Link>
150150
</RainbowButton>
151151
<RainbowButton variant="outline" asChild>
152-
<Link href={`/${lang}/showcase`}>
152+
<Link href="/showcase">
153153
<FerrisWheelIcon />
154154
{customTranslations[lang]['showcase.title']}
155155
</Link>

content/guides/sheets/features/import-export.zh-CN.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ downloadFile(file, 'univer', 'xlsx')
262262

263263
## 在 Node.js 服务端进行数据转换
264264

265-
Univer 服务端提供了导入导出的 API,但是服务端转化的数据和 Univer 格式不一致。如果使用我们的前端导入导出插件 `@univerjs-pro/exchange-client'`,数据已经默认转化,无需额外处理,如果你直接使用服务端导入导出 API,需要使用以下方法转化数据。
265+
Univer 服务端提供了导入导出的 API,但是服务端转化的数据和 Univer 格式不一致。如果使用我们的前端导入导出插件 `@univerjs-pro/exchange-client`,数据已经默认转化,无需额外处理,如果你直接使用服务端导入导出 API,需要使用以下方法转化数据。
266266

267267
### Snapshot 转化为 `IWorkbookData`
268268

content/guides/sheets/features/notes.mdx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ icon: PencilLine
2525

2626
Annotations functionality allows users to add comments in spreadsheet cells to record additional information or provide context. It supports various comment styles and operations, helping users better understand and collaborate on data.
2727

28+
<PlaygroundFrame lang="en-US" slug="sheets/notes" clickToShow />
29+
2830
## Preset Mode
2931

3032
### Installation

content/guides/sheets/features/notes.zh-CN.mdx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ icon: PencilLine
2525

2626
批注功能允许用户在电子表格的单元格中添加注释,以便记录额外信息或提供上下文。它支持多种注释样式和操作,帮助用户更好地理解和协作处理数据。
2727

28+
<PlaygroundFrame lang="zh-CN" slug="sheets/notes" clickToShow />
29+
2830
## 预设模式
2931

3032
### 安装

showcase/data.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ export const showcase: Record<string, Promise<{ default: {
2323
'sheets/custom-formula': import('./sheets/custom-formula'),
2424
'sheets/custom-shortcuts': import('./sheets/custom-shortcuts'),
2525
'sheets/images': import('./sheets/images'),
26+
'sheets/notes': import('./sheets/notes'),
2627
'sheets/crosshair-highlighting': import('./sheets/crosshair-highlighting'),
2728
'sheets/watermark': import('./sheets/watermark'),
2829
'sheets/charts': import('./sheets/charts'),

showcase/sheets/images/code/data.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export const WORKBOOK_DATA: Partial<IWorkbookData> = {
77
'SHh40QNCykVZr7CbKqQdv',
88
],
99
name: '',
10-
appVersion: '0.9.3',
10+
appVersion: '0.9.4',
1111
locale: LocaleType.EN_US,
1212
styles: {
1313
'9vlA-A': {

showcase/sheets/notes/code/data.ts

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
import type { IWorkbookData } from '@univerjs/presets'
2+
import { LocaleType } from '@univerjs/presets'
3+
4+
export const WORKBOOK_DATA: Partial<IWorkbookData> = {
5+
id: '8fa7DI',
6+
sheetOrder: [
7+
'OLRIuX3bOBBG69xuhV_lD',
8+
],
9+
name: '',
10+
appVersion: '0.9.4',
11+
locale: LocaleType.EN_US,
12+
styles: {},
13+
sheets: {
14+
OLRIuX3bOBBG69xuhV_lD: {
15+
id: 'OLRIuX3bOBBG69xuhV_lD',
16+
name: 'Sheet1',
17+
tabColor: '',
18+
hidden: 0,
19+
rowCount: 1000,
20+
columnCount: 20,
21+
zoomRatio: 1,
22+
freeze: {
23+
xSplit: 0,
24+
ySplit: 0,
25+
startRow: -1,
26+
startColumn: -1,
27+
},
28+
scrollTop: 0,
29+
scrollLeft: 0,
30+
defaultColumnWidth: 88,
31+
defaultRowHeight: 24,
32+
mergeData: [],
33+
cellData: {
34+
0: {
35+
0: {
36+
v: 'Hover Me!',
37+
t: 1,
38+
},
39+
},
40+
},
41+
rowData: {},
42+
columnData: {},
43+
showGridlines: 1,
44+
rowHeader: {
45+
width: 46,
46+
hidden: 0,
47+
},
48+
columnHeader: {
49+
height: 20,
50+
hidden: 0,
51+
},
52+
rightToLeft: 0,
53+
},
54+
},
55+
resources: [
56+
{
57+
name: 'SHEET_RANGE_PROTECTION_PLUGIN',
58+
data: '',
59+
},
60+
{
61+
name: 'SHEET_AuthzIoMockService_PLUGIN',
62+
data: '{}',
63+
},
64+
{
65+
name: 'SHEET_WORKSHEET_PROTECTION_PLUGIN',
66+
data: '{}',
67+
},
68+
{
69+
name: 'SHEET_WORKSHEET_PROTECTION_POINT_PLUGIN',
70+
data: '{}',
71+
},
72+
{
73+
name: 'SHEET_NOTE_PLUGIN',
74+
data: '{"OLRIuX3bOBBG69xuhV_lD":{"0":{"0":{"width":160,"height":72,"note":"Hello Univer!"}},"3":{"1":{"width":160,"height":72,"note":"Have a nice day :)","show":true}}}}',
75+
},
76+
{
77+
name: 'SHEET_DEFINED_NAME_PLUGIN',
78+
data: '',
79+
},
80+
{
81+
name: 'SHEET_RANGE_THEME_MODEL_PLUGIN',
82+
data: '{}',
83+
},
84+
],
85+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import { UniverSheetsCorePreset } from '@univerjs/preset-sheets-core'
2+
import sheetsCoreEnUS from '@univerjs/preset-sheets-core/locales/en-US'
3+
import { UniverSheetsNotePreset } from '@univerjs/preset-sheets-note'
4+
import sheetsNoteEnUS from '@univerjs/preset-sheets-note/locales/en-US'
5+
import { createUniver, LocaleType, merge } from '@univerjs/presets'
6+
import { WORKBOOK_DATA } from './data'
7+
8+
import './styles.css'
9+
10+
import '@univerjs/preset-sheets-note/lib/index.css'
11+
import '@univerjs/preset-sheets-core/lib/index.css'
12+
13+
const { univerAPI } = createUniver({
14+
locale: LocaleType.EN_US,
15+
locales: {
16+
[LocaleType.EN_US]: merge(
17+
{},
18+
sheetsCoreEnUS,
19+
sheetsNoteEnUS,
20+
),
21+
},
22+
presets: [
23+
UniverSheetsCorePreset({
24+
container: 'app',
25+
}),
26+
UniverSheetsNotePreset(),
27+
],
28+
})
29+
30+
univerAPI.createWorkbook(WORKBOOK_DATA)

showcase/sheets/notes/index.ts

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import fs from 'node:fs'
2+
import path from 'node:path'
3+
import { fileURLToPath } from 'node:url'
4+
import Preview from './preview'
5+
6+
const __dirname = path.dirname(fileURLToPath(import.meta.url))
7+
8+
const metadata = {
9+
title: {
10+
'en-US': 'Annotations',
11+
'zh-CN': '批注',
12+
},
13+
description: {
14+
'en-US': 'Annotations functionality allows users to add comments in spreadsheet cells to record additional information or provide context. It supports various comment styles and operations, helping users better understand and collaborate on data.',
15+
'zh-CN': '批注功能允许用户在电子表格单元格中添加评论,以记录附加信息或提供上下文。它支持各种评论样式和操作,帮助用户更好地理解和协作处理数据。',
16+
},
17+
tags: {
18+
'en-US': ['Univer Sheets', 'Preset Mode'],
19+
'zh-CN': ['Univer Sheets', '预设模式'],
20+
},
21+
}
22+
23+
export const files = {
24+
'/src/index.ts': fs.readFileSync(path.resolve(__dirname, './code/index.ts'), 'utf-8'),
25+
'/src/data.ts': fs.readFileSync(path.resolve(__dirname, './code/data.ts'), 'utf-8'),
26+
}
27+
28+
export default {
29+
metadata,
30+
files,
31+
Preview,
32+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
'use client'
2+
3+
import dynamic from 'next/dynamic'
4+
5+
export default dynamic(() => import('./main'), {
6+
ssr: false,
7+
})

0 commit comments

Comments
 (0)