Skip to content

Commit cfd229f

Browse files
committed
feat: add custom-shortcut playground
1 parent ed4da4e commit cfd229f

File tree

14 files changed

+251
-2
lines changed

14 files changed

+251
-2
lines changed

content/en-US/guides/sheets/features/core/range-selection.mdx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,8 @@ console.log(fRange.getValue()); // The value of the top-left cell in the range
7171
console.log(fRange.getRawValue()); // The raw value of the top-left cell in the range
7272
console.log(fRange.getDisplayValue()); // The displayed value of the top-left cell in the range
7373
console.log(fRange.getCellData()); // The cell data of the top-left cell in the range
74+
console.log(fRange.getRichTextValue()); // The rich text value of the top-left cell in the range
75+
console.log(fRange.getRichTextValue().toPlainText()); // The plain text of the rich text value of the top-left cell in the range
7476
```
7577

7678
Get all cell values in the range
@@ -84,6 +86,7 @@ console.log(fRange.getValues()); // The values of all cells in the range
8486
console.log(fRange.getRawValues()); // The raw values of all cells in the range
8587
console.log(fRange.getDisplayValues()); // The displayed values of all cells in the range
8688
console.log(fRange.getCellDatas()); // The cell data of all cells in the range
89+
console.log(fRange.getRichTextValues()); // The rich text values of all cells in the range
8790
```
8891

8992
Get all formulas in the range

content/en-US/guides/sheets/features/import-export.mdx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,9 @@ UniverSheetsAdvancedPreset({
7171
* 2. Excel does not show formula results unless editing is enabled
7272
* 3. Array formulas with the @ prefix cannot expand calculation results
7373
* Note: The server configuration file needs to set `SSC_SERVER_ENABLED=true`.
74+
* @version 0.8.3+
7475
*/
75-
enableServerSideComputing?: boolean;
76+
enableServerSideComputing?: boolean;
7677
};
7778
})
7879
```
@@ -141,6 +142,7 @@ univer.registerPlugin(UniverExchangeClientPlugin, {
141142
* 2. Excel does not show formula results unless editing is enabled
142143
* 3. Array formulas with the @ prefix cannot expand calculation results
143144
* Note: The server configuration file needs to set `SSC_SERVER_ENABLED=true`.
145+
* @version 0.8.3+
144146
*/
145147
enableServerSideComputing?: boolean;
146148
};

content/en-US/playground/sheets/_meta.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,12 @@ export default {
4747
layout: 'full',
4848
},
4949
},
50+
'custom-shortcut': {
51+
title: 'Custom Shortcut',
52+
theme: {
53+
layout: 'full',
54+
},
55+
},
5056
'uniscript': {
5157
title: 'Uniscript',
5258
theme: {
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Custom Shortcut
2+
3+
import Showcase from '@/showcase/sheets/custom-shortcut'
4+
5+
- [View source](https://github.com/dream-num/univer-documentation/blob/dev/showcase/sheets/custom-shortcut/entry.tsx)
6+
7+
<Showcase lang="en-US" toolbar={{ showCode: true }} />

content/zh-CN/guides/sheets/features/core/range-selection.mdx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,8 @@ console.log(fRange.getValue()); // 范围左上角单元格值
7171
console.log(fRange.getRawValue()); // 范围左上角单元格原始值
7272
console.log(fRange.getDisplayValue()); // 范围左上角单元格显示值
7373
console.log(fRange.getCellData()); // 范围左上角单元格 ICellData 对象
74+
console.log(fRange.getRichTextValue()); // 范围左上角单元格富文本值
75+
console.log(fRange.getRichTextValue().toPlainText()); // 范围左上角单元格富文本值的纯文本
7476
```
7577

7678
获取范围的所有值
@@ -84,6 +86,7 @@ console.log(fRange.getValues()); // 范围所有单元格值
8486
console.log(fRange.getRawValues()); // 范围所有单元格原始值
8587
console.log(fRange.getDisplayValues()); // 范围所有单元格显示值
8688
console.log(fRange.getCellDatas()); // 范围所有单元格 ICellData 对象
89+
console.log(fRange.getRichTextValues()); // 范围所有单元格富文本值
8790
```
8891

8992
获取范围的所有公式

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,9 @@ UniverSheetsAdvancedPreset({
7171
* 2. EXCEL 不启用编辑,无法看到公式计算结果
7272
* 3. 数组公式存在前缀@,导致无法展开计算结果
7373
* 注意,服务端配置文件需要配置 SSC_SERVER_ENABLED=true。
74+
* @version 0.8.3+
7475
*/
75-
enableServerSideComputing?: boolean;
76+
enableServerSideComputing?: boolean;
7677
};
7778
})
7879
```
@@ -141,6 +142,7 @@ univer.registerPlugin(UniverExchangeClientPlugin, {
141142
* 2. EXCEL 不启用编辑,无法看到公式计算结果
142143
* 3. 数组公式存在前缀@,导致无法展开计算结果
143144
* 注意,服务端配置文件需要配置 SSC_SERVER_ENABLED=true。
145+
* @version 0.8.3+
144146
*/
145147
enableServerSideComputing?: boolean;
146148
};

content/zh-CN/playground/sheets/_meta.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,12 @@ export default {
4747
layout: 'full',
4848
},
4949
},
50+
'custom-shortcut': {
51+
title: '自定义快捷键',
52+
theme: {
53+
layout: 'full',
54+
},
55+
},
5056
'uniscript': {
5157
title: 'Uniscript',
5258
theme: {
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# 自定义快捷键
2+
3+
import Showcase from '@/showcase/sheets/custom-shortcut'
4+
5+
- [查看源码](https://github.com/dream-num/univer-documentation/blob/dev/showcase/sheets/custom-shortcut/entry.tsx)
6+
7+
<Showcase lang="zh-CN" toolbar={{ showCode: true }} />
Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
'use client'
2+
3+
import { createUniver, defaultTheme, LocaleType, merge } from '@univerjs/presets'
4+
import { UniverSheetsCorePreset } from '@univerjs/presets/preset-sheets-core'
5+
import sheetsCoreEnUS from '@univerjs/presets/preset-sheets-core/locales/en-US'
6+
import sheetsCoreZhCN from '@univerjs/presets/preset-sheets-core/locales/zh-CN'
7+
import { useTheme } from 'nextra-theme-docs'
8+
import { useEffect, useRef } from 'react'
9+
import { Preview } from '@/components/preview'
10+
import { useCodeHighlight } from '@/hooks/use-code'
11+
import { UniverSheetsCustomShortcutPlugin } from './plugin'
12+
13+
const code = `
14+
import { createUniver, defaultTheme, LocaleType, merge } from '@univerjs/presets'
15+
16+
import { UniverSheetsCorePreset } from '@univerjs/presets/preset-sheets-core'
17+
import sheetsCoreEnUS from '@univerjs/presets/preset-sheets-core/locales/en-US'
18+
import '@univerjs/presets/lib/styles/preset-sheets-core.css'
19+
20+
import { UniverSheetsCustomShortcutPlugin } from './plugin'
21+
22+
const { univerAPI } = createUniver({
23+
locale: LocaleType.EN_US,
24+
locales: {
25+
[LocaleType.EN_US]: merge(
26+
{},
27+
sheetsCoreEnUS,
28+
),
29+
},
30+
theme: defaultTheme,
31+
presets: [
32+
UniverSheetsCorePreset(),
33+
],
34+
plugins: [
35+
UniverSheetsCustomShortcutPlugin,
36+
],
37+
})
38+
39+
univerAPI.createWorkbook({})
40+
`
41+
42+
interface IDemoProps {
43+
lang: 'zh-CN' | 'en-US'
44+
}
45+
46+
const localesMap = {
47+
'zh-CN': {
48+
name: 'ZH_CN',
49+
locale: LocaleType.ZH_CN,
50+
locales: merge({}, sheetsCoreZhCN),
51+
},
52+
'en-US': {
53+
name: 'EN_US',
54+
locale: LocaleType.EN_US,
55+
locales: merge({}, sheetsCoreEnUS),
56+
},
57+
}
58+
59+
export default function Demo(props: IDemoProps) {
60+
const { lang } = props
61+
62+
const containerRef = useRef<HTMLDivElement>(null!)
63+
64+
const { theme } = useTheme()
65+
66+
const { locale, locales } = localesMap[lang]
67+
68+
useEffect(() => {
69+
const { univerAPI } = createUniver({
70+
darkMode: theme === 'dark',
71+
locale,
72+
locales: {
73+
[locale]: locales,
74+
},
75+
theme: defaultTheme,
76+
presets: [
77+
UniverSheetsCorePreset({
78+
container: containerRef.current,
79+
}),
80+
],
81+
plugins: [
82+
UniverSheetsCustomShortcutPlugin,
83+
],
84+
})
85+
86+
univerAPI.createWorkbook({})
87+
88+
return () => {
89+
univerAPI.dispose()
90+
}
91+
}, [])
92+
93+
const codeWithHighlight = useCodeHighlight({
94+
code,
95+
lang,
96+
})
97+
98+
return (
99+
<Preview ref={containerRef} code={codeWithHighlight} />
100+
)
101+
}
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('./entry'), {
6+
ssr: false,
7+
})

0 commit comments

Comments
 (0)