Skip to content

Commit

Permalink
docs: update rspress, add SourceCode
Browse files Browse the repository at this point in the history
  • Loading branch information
Yukiniro committed Dec 19, 2023
1 parent 866740e commit cc930dd
Show file tree
Hide file tree
Showing 4 changed files with 1,064 additions and 1,388 deletions.
22 changes: 22 additions & 0 deletions site/docs/en/api/index.mdx
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
# API

import { SourceCode } from 'rspress/theme'

## subscribe

<SourceCode href='https://github.com/Yukiniro/toukey/blob/master/src/index.ts#L107' />

Subscribe the key's keyboard event.

- Params
Expand Down Expand Up @@ -30,6 +34,8 @@ unsubscribe();

## on

<SourceCode href='https://github.com/Yukiniro/toukey/blob/master/src/index.ts#L251' />

`on` is an alias for `subscribe`.

:::info
Expand All @@ -38,6 +44,8 @@ Why is there an alias? Because `on` and `off` is more in line with the semantics

## off

<SourceCode href='https://github.com/Yukiniro/toukey/blob/master/src/index.ts#L262' />

`off` could cancel the event listener.

- Params
Expand All @@ -55,6 +63,8 @@ If the `handler` and `options` is not set, all event listeners of the key will b

## getScope

<SourceCode href='https://github.com/Yukiniro/toukey/blob/master/src/index.ts#L187' />

Get the scope of the current keyboard event.

```javascript
Expand All @@ -65,6 +75,8 @@ const scope = getScope();

## setScope

<SourceCode href='https://github.com/Yukiniro/toukey/blob/master/src/index.ts#L195' />

Set the scope of the current keyboard event.

- Params
Expand All @@ -78,6 +90,8 @@ setScope("scope");

## deleteScope

<SourceCode href='https://github.com/Yukiniro/toukey/blob/master/src/index.ts#L206' />

Delete the scope of the current keyboard event.

- Params
Expand All @@ -91,6 +105,8 @@ deleteScope("scope");

## enable

<SourceCode href='https://github.com/Yukiniro/toukey/blob/master/src/index.ts#L226' />

Enable the key event.

```javascript
Expand All @@ -101,6 +117,8 @@ enable();

## disable

<SourceCode href='https://github.com/Yukiniro/toukey/blob/master/src/index.ts#L233' />

Disable the key event.

```javascript
Expand All @@ -111,6 +129,8 @@ disable();

## isEnable

<SourceCode href='https://github.com/Yukiniro/toukey/blob/master/src/index.ts#L240' />

Get the status of the key event.

```javascript
Expand All @@ -121,6 +141,8 @@ const status = isEnable();

## clearAll

<SourceCode href='https://github.com/Yukiniro/toukey/blob/master/src/index.ts#L216' />

Clear all key events.

```javascript
Expand Down
22 changes: 22 additions & 0 deletions site/docs/zh/api/index.mdx
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
# API

import { SourceCode } from 'rspress/theme'

## subscribe

<SourceCode href='https://github.com/Yukiniro/toukey/blob/master/src/index.ts#L107' />

订阅键盘事件。

- 参数
Expand Down Expand Up @@ -30,6 +34,8 @@ unsubscribe();

## on

<SourceCode href='https://github.com/Yukiniro/toukey/blob/master/src/index.ts#L251' />

`on``subscribe` 的别名。

:::info
Expand All @@ -38,6 +44,8 @@ unsubscribe();

## off

<SourceCode href='https://github.com/Yukiniro/toukey/blob/master/src/index.ts#L262' />

`off` 可以取消事件监听器。

- Params
Expand All @@ -55,6 +63,8 @@ unsubscribe();

## getScope

<SourceCode href='https://github.com/Yukiniro/toukey/blob/master/src/index.ts#L187' />

获取当前键盘事件的范围。

```javascript
Expand All @@ -65,6 +75,8 @@ const scope = getScope();

## setScope

<SourceCode href='https://github.com/Yukiniro/toukey/blob/master/src/index.ts#L195' />

设置当前键盘事件的范围。

- 参数
Expand All @@ -78,6 +90,8 @@ setScope("scope");

## deleteScope

<SourceCode href='https://github.com/Yukiniro/toukey/blob/master/src/index.ts#L206' />

删除指定键盘事件的范围。

- Params
Expand All @@ -91,6 +105,8 @@ deleteScope("scope");

## enable

<SourceCode href='https://github.com/Yukiniro/toukey/blob/master/src/index.ts#L226' />

启用键盘事件。

```javascript
Expand All @@ -101,6 +117,8 @@ enable();

## disable

<SourceCode href='https://github.com/Yukiniro/toukey/blob/master/src/index.ts#L233' />

禁用键盘事件。

```javascript
Expand All @@ -111,6 +129,8 @@ disable();

## isEnable

<SourceCode href='https://github.com/Yukiniro/toukey/blob/master/src/index.ts#L240' />

获取键盘事件的状态。

```javascript
Expand All @@ -121,6 +141,8 @@ const status = isEnable();

## clearAll

<SourceCode href='https://github.com/Yukiniro/toukey/blob/master/src/index.ts#L216' />

清除所有键盘事件。

```javascript
Expand Down
2 changes: 1 addition & 1 deletion site/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"preview": "rspress preview"
},
"dependencies": {
"rspress": "^1.7.5"
"rspress": "^1.8.3"
},
"devDependencies": {
"@types/node": "^16"
Expand Down
Loading

0 comments on commit cc930dd

Please sign in to comment.