Skip to content

Commit bf73fc4

Browse files
authored
docs(cndocs): sync latest upstream docs (#1028)
1 parent 2e9ee68 commit bf73fc4

6 files changed

Lines changed: 215 additions & 21 deletions

File tree

cndocs/accessibility.md

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ title: 无障碍功能
44
description: 使用 React Native 面向 Android 和 iOS 的无障碍 API,构建可被辅助技术访问的移动应用。
55
---
66

7-
import ExperimentalAPIWarning from './_experimental-api-warning.mdx';
7+
import ExperimentalAPIWarning from './\_experimental-api-warning.mdx';
88

99
Android 和 iOS 都提供了与辅助技术集成的能力,例如系统自带的读屏器 VoiceOver(iOS)和 TalkBack(Android)。React Native 提供了配套 API,帮助你的应用更好地服务所有用户。
1010

@@ -191,13 +191,13 @@ large content viewer 显示时使用的标题文本。
191191

192192
`accessibilityState` 是对象,包含:
193193

194-
| Name | Description | Type | Required |
195-
| -------- | ------------------------------------------------------------------------------------------------------------------------------------- | ------------------ | -------- |
196-
| disabled | 元素是否禁用。 | boolean | No |
197-
| selected | 可选元素当前是否选中。 | boolean | No |
198-
| checked | 可勾选元素状态。可为布尔值,或字符串 `"mixed"`(混合状态)。 | boolean or 'mixed' | No |
199-
| busy | 元素当前是否忙碌。 | boolean | No |
200-
| expanded | 可展开元素当前是展开还是折叠。 | boolean | No |
194+
| Name | Description | Type | Required |
195+
| -------- | ------------------------------------------------------------ | ------------------ | -------- |
196+
| disabled | 元素是否禁用。 | boolean | No |
197+
| selected | 可选元素当前是否选中。 | boolean | No |
198+
| checked | 可勾选元素状态。可为布尔值,或字符串 `"mixed"`(混合状态)。 | boolean or 'mixed' | No |
199+
| busy | 元素当前是否忙碌。 | boolean | No |
200+
| expanded | 可展开元素当前是展开还是折叠。 | boolean | No |
201201

202202
使用时,将 `accessibilityState` 设为符合上述结构的对象。
203203

@@ -207,12 +207,12 @@ large content viewer 显示时使用的标题文本。
207207

208208
`accessibilityValue` 是对象,包含:
209209

210-
| Name | Description | Type | Required |
211-
| ---- | ---------------------------------------------------------------------------------------------- | ------- | ------------------------- |
212-
| min | 范围最小值。 | integer | Required if `now` is set. |
213-
| max | 范围最大值。 | integer | Required if `now` is set. |
214-
| now | 当前值。 | integer | No |
215-
| text | 值的文本描述。若设置该字段,会覆盖 `min``now``max` | string | No |
210+
| Name | Description | Type | Required |
211+
| ---- | -------------------------------------------------------- | ------- | ------------------------- |
212+
| min | 范围最小值。 | integer | Required if `now` is set. |
213+
| max | 范围最大值。 | integer | Required if `now` is set. |
214+
| now | 当前值。 | integer | No |
215+
| text | 值的文本描述。若设置该字段,会覆盖 `min``now``max`| string | No |
216216

217217
### `accessibilityViewIsModal` <div className="label ios">iOS</div>
218218

@@ -520,13 +520,13 @@ large content viewer 显示时使用的标题文本。
520520
- `'magicTap'` - iOS only - VoiceOver 焦点在组件上/内部时,用户双指双击。
521521
- `'escape'` - iOS only - VoiceOver 焦点在组件上/内部时,用户执行双指擦拭手势(左、右、左)。
522522
- `'activate'` - 激活动作。应与普通(非辅助技术)操作保持一致;读屏用户双击组件时触发。
523-
- `'increment'` - 增加可调整组件值。iOS 上,当角色为 `'adjustable'` 且用户上滑时触发;Android 上,当用户聚焦后按音量加键触发
524-
- `'decrement'` - 减少可调整组件值。iOS 上,当角色为 `'adjustable'` 且用户下滑时触发;Android 上,当用户聚焦后按音量减键触发
523+
- `'increment'` - 增加可调整组件值。iOS 上,当组件角色为 `'adjustable'` 且用户聚焦后向上轻扫时,VoiceOver 会生成此动作。Android 上,在 TalkBack 8.1 及更早版本中,用户聚焦组件并按下音量加键时会生成此动作;在 TalkBack 9.1 及更高版本中,它已被“调整阅读控件”手势(在聚焦的控件上向上轻扫)取代
524+
- `'decrement'` - 减少可调整组件值。iOS 上,当组件角色为 `'adjustable'` 且用户聚焦后向下轻扫时,VoiceOver 会生成此动作。Android 上,在 TalkBack 8.2 及更早版本中,用户聚焦组件并按下音量减键时会生成此动作;在 TalkBack 9.2 及更高版本中,它已被“调整阅读控件”手势(在聚焦的控件上向下轻扫)取代
525525
- `'longpress'` - Android only - 用户聚焦后双击并按住触发;应与普通长按行为一致。
526526
- `'expand'` - Android only - 展开组件,TalkBack 会播报“已展开”提示。
527527
- `'collapse'` - Android only - 折叠组件,TalkBack 会播报“已折叠”提示。
528528

529-
`label` 对标准动作通常不会被辅助技术使用;对自定义动作,`label` 应是本地化字符串,用于向用户描述该动作。
529+
`label` 字段对标准动作是可选的,辅助技术会用它来描述某个动作的具体结果。例如,TalkBack 会使用该字段将默认的“双击即可激活”播报替换为类似“双击打开聊天”的自定义描述。对于自定义动作,`label` 是一个本地化字符串,用于向用户描述该动作。
530530

531531
处理动作请求时,实现 `onAccessibilityAction`,其参数事件中包含动作名。示例:
532532

cndocs/linking.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,15 +91,15 @@ import Tabs from '@theme/Tabs'; import TabItem from '@theme/TabItem'; import con
9191
<TabItem value="swift">
9292
9393
```swift title="AppDelegate.swift"
94-
override func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool {
94+
func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool {
9595
return RCTLinkingManager.application(app, open: url, options: options)
9696
}
9797
```
9898

9999
如果你的 app 用了 [Universal Links](https://developer.apple.com/ios/universal-links/),需要正确的把下述代码添加进去:
100100

101101
```swift title="AppDelegate.swift"
102-
override func application(
102+
func application(
103103
_ application: UIApplication,
104104
continue userActivity: NSUserActivity,
105105
restorationHandler: @escaping ([UIUserActivityRestoring]?) -> Void) -> Bool {

cnwebsite/package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,12 @@
5252
"@docusaurus/plugin-google-gtag": "3.10.1",
5353
"@docusaurus/plugin-pwa": "3.10.1",
5454
"@docusaurus/preset-classic": "3.10.1",
55+
"@docusaurus/theme-mermaid": "3.10.1",
56+
"docusaurus-plugin-copy-page-button": "^0.6.2",
5557
"docusaurus-plugin-sass": "^0.2.6",
5658
"react": "^19.2.6",
5759
"react-dom": "^19.2.6",
58-
"react-github-btn": "^1.4.0",
59-
"@docusaurus/theme-mermaid": "3.10.1"
60+
"react-github-btn": "^1.4.0"
6061
},
6162
"devDependencies": {
6263
"@docusaurus/module-type-aliases": "3.10.1",

cnwebsite/src/css/customTheme.scss

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,9 +103,14 @@
103103

104104
body {
105105
font-family: var(--ifm-font-family-base);
106+
scrollbar-gutter: stable;
106107
}
107108

108109
html[data-theme="light"] {
110+
body {
111+
scrollbar-color: var(--subtle) var(--ifm-background-color);
112+
}
113+
109114
--ifm-link-color: #357da1;
110115
}
111116

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
/**
2+
* Copyright (c) Meta Platforms, Inc. and affiliates.
3+
*
4+
* This source code is licensed under the MIT license found in the
5+
* LICENSE file in the root directory of this source tree.
6+
*/
7+
8+
import React, {type ReactNode} from 'react';
9+
import clsx from 'clsx';
10+
import {useWindowSize} from '@docusaurus/theme-common';
11+
import {useDoc} from '@docusaurus/plugin-content-docs/client';
12+
import CopyPageButton from 'docusaurus-plugin-copy-page-button/react';
13+
import DocItemPaginator from '@theme/DocItem/Paginator';
14+
import DocVersionBanner from '@theme/DocVersionBanner';
15+
import DocVersionBadge from '@theme/DocVersionBadge';
16+
import DocItemFooter from '@theme/DocItem/Footer';
17+
import DocItemTOCMobile from '@theme/DocItem/TOC/Mobile';
18+
import DocItemTOCDesktop from '@theme/DocItem/TOC/Desktop';
19+
import DocItemContent from '@theme/DocItem/Content';
20+
import DocBreadcrumbs from '@theme/DocBreadcrumbs';
21+
import ContentVisibility from '@theme/ContentVisibility';
22+
import type {Props} from '@theme/DocItem/Layout';
23+
24+
import styles from './styles.module.css';
25+
26+
function DocItemCopyPageButton({className}: {className?: string}) {
27+
return (
28+
<div className={clsx(styles.copyPageAction, className)}>
29+
<CopyPageButton
30+
customStyles={{
31+
container: {className: styles.copyPageButtonContainer},
32+
button: {
33+
className: styles.copyPageButton,
34+
style: {marginBottom: 0},
35+
},
36+
dropdown: {className: styles.copyPageDropdown},
37+
}}
38+
/>
39+
</div>
40+
);
41+
}
42+
43+
/**
44+
* Decide if the toc should be rendered, on mobile or desktop viewports
45+
*/
46+
function useDocTOC() {
47+
const {frontMatter, toc} = useDoc();
48+
const windowSize = useWindowSize();
49+
50+
const hidden = frontMatter.hide_table_of_contents;
51+
const canRender = !hidden && toc.length > 0;
52+
53+
const mobile = canRender ? <DocItemTOCMobile /> : undefined;
54+
55+
const desktop =
56+
canRender && (windowSize === 'desktop' || windowSize === 'ssr') ? (
57+
<DocItemTOCDesktop />
58+
) : undefined;
59+
60+
return {
61+
canRender,
62+
hidden,
63+
mobile,
64+
desktop,
65+
};
66+
}
67+
68+
export default function DocItemLayout({children}: Props): ReactNode {
69+
const docTOC = useDocTOC();
70+
const {metadata} = useDoc();
71+
return (
72+
<div className="row">
73+
<div className={clsx('col', !docTOC.hidden && styles.docItemCol)}>
74+
<ContentVisibility metadata={metadata} />
75+
<DocVersionBanner />
76+
<div className={styles.docItemContainer}>
77+
<article>
78+
<DocBreadcrumbs />
79+
<div className={styles.docHeaderContainer}>
80+
<DocVersionBadge />
81+
<DocItemCopyPageButton
82+
className={clsx(
83+
styles.copyPageArticleAction,
84+
docTOC.canRender && styles.copyPageArticleActionWithToc
85+
)}
86+
/>
87+
</div>
88+
{docTOC.mobile}
89+
<DocItemContent>{children}</DocItemContent>
90+
<DocItemFooter />
91+
</article>
92+
<DocItemPaginator />
93+
</div>
94+
</div>
95+
{docTOC.desktop && (
96+
<div className="col col--3">
97+
<DocItemCopyPageButton className={styles.copyPageAsideAction} />
98+
{docTOC.desktop}
99+
</div>
100+
)}
101+
</div>
102+
);
103+
}
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
/**
2+
* Copyright (c) Meta Platforms, Inc. and affiliates.
3+
*
4+
* This source code is licensed under the MIT license found in the
5+
* LICENSE file in the root directory of this source tree.
6+
*/
7+
8+
.docItemContainer header + *,
9+
.docItemContainer article > *:first-child {
10+
margin-top: 0;
11+
}
12+
13+
.docHeaderContainer {
14+
display: flex;
15+
justify-content: space-between;
16+
align-items: center;
17+
}
18+
19+
.copyPageAsideAction {
20+
margin-bottom: 1rem;
21+
}
22+
23+
div[class^="copyPageArticleAction"] {
24+
margin-bottom: 0;
25+
}
26+
27+
button[class^="copyPageButton"] {
28+
border-radius: var(--ifm-global-radius);
29+
border-color: var(--ifm-color-gray-500);
30+
31+
&:hover {
32+
background-color: var(--ifm-menu-color-background-hover) !important;
33+
border-color: var(--ifm-color-gray-400) !important;
34+
}
35+
36+
svg {
37+
opacity: 0.75;
38+
}
39+
}
40+
41+
div[class^="copyPageDropdown"] {
42+
border-color: var(--ifm-table-border-color) !important;
43+
44+
button[class^="dropdownItem"] {
45+
border-bottom-color: var(--ifm-table-border-color) !important;
46+
47+
&:hover {
48+
background-color: var(--ifm-menu-color-background-hover);
49+
}
50+
}
51+
52+
div[class^="itemDescription"] {
53+
font-weight: 300;
54+
font-size: 12px;
55+
}
56+
}
57+
58+
[data-theme="dark"] {
59+
button[class^="copyPageButton"] {
60+
&:hover {
61+
background-color: var(--dark) !important;
62+
border-color: var(--ifm-color-gray-800) !important;
63+
}
64+
}
65+
66+
button[class^="dropdownItem"] {
67+
&:hover {
68+
background-color: var(--dark);
69+
}
70+
}
71+
72+
div[class^="copyPageDropdown"] {
73+
background-color: var(--ifm-navbar-background-color);
74+
}
75+
}
76+
77+
@media (min-width: 997px) {
78+
.docItemCol {
79+
max-width: 75% !important;
80+
}
81+
82+
.copyPageArticleActionWithToc {
83+
display: none;
84+
}
85+
}

0 commit comments

Comments
 (0)