feat: add build:test script and improve documentation code blocks

- Added a new script `build:test` to generate test cases from documentation code examples.
- Enhanced documentation files by ensuring proper code block formatting and adding missing closing backticks.
- Updated various markdown files to include new code blocks and fixed formatting issues.
This commit is contained in:
Harvey Zhao committed 2026-03-07 15:52:56 +08:00
1 parent 5cc8d14454
commit 7bfee6c6dc
17 files changed
+4857 -19

No files matched your search

@@ -500,4 +500,5 @@ function myPlugin(art) {
art.on('ready', () => {
art.plugins.add(myPlugin);
});
});
```
@@ -132,4 +132,5 @@ Returns the default options for the player.
<div className="run-code">▶ Run Code</div>
```js
console.info(Artplayer.option);
console.info(Artplayer.option);
```
@@ -263,6 +263,8 @@ art.on('error', (error, reconnectTime) => {
console.info(error, reconnectTime);
});
```
## `hover`
Triggered when the mouse enters or leaves the player
@@ -521,6 +523,8 @@ art.on('pip', (state) => {
console.info('pip', state);
});
```
## `screenshot`
Triggered when the player captures a screenshot
@@ -774,6 +778,8 @@ art.on('setting', (state) => {
console.log(state);
});
```
## `muted`
Triggered when the mute state changes
@@ -251,6 +251,8 @@ var art = new Artplayer({
url: '/assets/sample/404.mp4',
});
```
## CONTROL_HIDE_TIME
The delay time in milliseconds for auto-hiding the bottom control bar. Default is `3000`.
@@ -499,6 +501,8 @@ var art = new Artplayer({
art.contextmenu.show = true;
art.setting.show = true;
```
## FULLSCREEN_WEB_IN_BODY
Determines whether to mount the player under the `body` element during web fullscreen mode. Defaults to `true`.
@@ -563,4 +567,5 @@ var art = new Artplayer({
});
// Only destroys the UI, does not actively clear src
art.destroy();
art.destroy();
```
@@ -121,4 +121,5 @@ var art = new Artplayer({
url: '/assets/sample/layer.png'
})
],
});
});
```
@@ -263,6 +263,8 @@ art.on('ready', () => {
}, 3000);
});
```
:::warning Note
`art.switch` and `art.switchUrl` have the same functionality, but the `art.switchUrl` method returns a `Promise`. It `resolve`s when the new URL is playable and `reject`s when the new URL fails to load.
@@ -1024,6 +1026,8 @@ art.on('ready', () => {
}, 3000);
})
```
## `thumbnails`
- Type: `Setter/Getter`
@@ -1068,4 +1072,5 @@ var art = new Artplayer({
art.on('ready', () => {
art.subtitleOffset = 1;
});
});
```
@@ -124,4 +124,5 @@ art.on('ready', () => {
html: 'Your New Menu',
})
}, 3000);
});
});
```
@@ -174,4 +174,5 @@ art.on('ready', () => {
],
});
}, 3000);
});
});
```
@@ -143,4 +143,5 @@ art.on('ready', () => {
},
});
}, 3000);
});
});
```
@@ -168,6 +168,8 @@ var art = new Artplayer({
],
});
```
## Create - Toggle Button
| Property | Type | Description |
@@ -329,4 +331,5 @@ art.on('ready', () => {
switch: false,
});
}, 3000);
});
});
```
@@ -98,4 +98,5 @@ var art = new Artplayer({
Play: 'Your Play'
},
},
});
});
```
@@ -268,6 +268,8 @@ var art = new Artplayer({
autoSize: true,
});
```
## `autoMini`
- Type: `Boolean`
@@ -532,6 +534,8 @@ var art = new Artplayer({
setting: true,
});
```
## `miniProgressBar`
- Type: `Boolean`
@@ -742,6 +746,8 @@ var art = new Artplayer({
],
});
```
:::warning For `Component Configuration`, please refer to:
[/component/controls.html](/component/controls.html)
@@ -943,6 +949,8 @@ var art = new Artplayer({
},
});
```
## `icons`
- Type: `Object`
@@ -1243,4 +1251,5 @@ var art = new Artplayer({
container: '.artplayer-app',
url: '/assets/sample/video.mp4',
proxy: () => document.createElement('video')
});
});
```