@fibrae/semi-ui-svelte 0.9.1 → 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -4
- package/README.zh-CN.md +8 -4
- package/dist/components/anchor/interface.d.ts +14 -0
- package/dist/components/audio-player/interface.d.ts +5 -0
- package/dist/components/auto-complete/interface.d.ts +29 -0
- package/dist/components/avatar/interface.d.ts +24 -0
- package/dist/components/backtop/interface.d.ts +2 -0
- package/dist/components/badge/interface.d.ts +7 -0
- package/dist/components/banner/interface.d.ts +7 -0
- package/dist/components/breadcrumb/interface.d.ts +10 -0
- package/dist/components/button/interface.d.ts +18 -0
- package/dist/components/calendar/interface.d.ts +16 -0
- package/dist/components/card/interface.d.ts +18 -0
- package/dist/components/carousel/interface.d.ts +16 -0
- package/dist/components/cascader/interface.d.ts +57 -0
- package/dist/components/checkbox/interface.d.ts +19 -0
- package/dist/components/code-highlight/interface.d.ts +3 -0
- package/dist/components/collapse/interface.d.ts +16 -0
- package/dist/components/collapsible/interface.d.ts +10 -0
- package/dist/components/color-picker/interface.d.ts +10 -0
- package/dist/components/config-provider/interface.d.ts +7 -0
- package/dist/components/cropper/interface.d.ts +11 -0
- package/dist/components/date-picker/interface.d.ts +47 -0
- package/dist/components/descriptions/interface.d.ts +6 -0
- package/dist/components/divider/interface.d.ts +4 -0
- package/dist/components/dropdown/interface.d.ts +8 -0
- package/dist/components/empty/interface.d.ts +7 -0
- package/dist/components/feedback/interface.d.ts +16 -0
- package/dist/components/float-button/interface.d.ts +14 -0
- package/dist/components/form/interface.d.ts +47 -0
- package/dist/components/grid/interface.d.ts +13 -0
- package/dist/components/highlight/interface.d.ts +7 -0
- package/dist/components/hot-keys/interface.d.ts +3 -0
- package/dist/components/image/interface.d.ts +59 -0
- package/dist/components/input/interface.d.ts +67 -0
- package/dist/components/input-number/interface.d.ts +24 -0
- package/dist/components/json-viewer/interface.d.ts +7 -0
- package/dist/components/layout/interface.d.ts +3 -0
- package/dist/components/list/interface.d.ts +18 -0
- package/dist/components/locale/interface.d.ts +4 -0
- package/dist/components/lottie/interface.d.ts +2 -0
- package/dist/components/markdown-render/interface.d.ts +5 -0
- package/dist/components/modal/interface.d.ts +29 -0
- package/dist/components/navigation/interface.d.ts +47 -0
- package/dist/components/overflow-list/interface.d.ts +11 -0
- package/dist/components/pagination/interface.d.ts +12 -0
- package/dist/components/pincode/interface.d.ts +8 -0
- package/dist/components/popconfirm/interface.d.ts +12 -0
- package/dist/components/popover/interface.d.ts +30 -0
- package/dist/components/progress/interface.d.ts +13 -0
- package/dist/components/radio/interface.d.ts +22 -0
- package/dist/components/rating/interface.d.ts +12 -0
- package/dist/components/resizable/interface.d.ts +30 -0
- package/dist/components/scroll-list/interface.d.ts +6 -0
- package/dist/components/select/interface.d.ts +63 -0
- package/dist/components/side-sheet/interface.d.ts +19 -0
- package/dist/components/skeleton/interface.d.ts +7 -0
- package/dist/components/slider/interface.d.ts +23 -0
- package/dist/components/space/interface.d.ts +4 -0
- package/dist/components/spin/interface.d.ts +7 -0
- package/dist/components/steps/interface.d.ts +9 -0
- package/dist/components/switch/interface.d.ts +7 -0
- package/dist/components/table/interface.d.ts +48 -0
- package/dist/components/tabs/interface.d.ts +29 -0
- package/dist/components/tag/interface.d.ts +22 -0
- package/dist/components/tag-input/interface.d.ts +29 -0
- package/dist/components/time-picker/interface.d.ts +31 -0
- package/dist/components/timeline/interface.d.ts +5 -0
- package/dist/components/tooltip/interface.d.ts +20 -0
- package/dist/components/transfer/interface.d.ts +18 -0
- package/dist/components/tree/interface.d.ts +45 -0
- package/dist/components/tree-select/interface.d.ts +55 -0
- package/dist/components/typography/interface.d.ts +33 -0
- package/dist/components/upload/interface.d.ts +64 -0
- package/dist/components/user-guide/interface.d.ts +15 -0
- package/dist/components/video-player/interface.d.ts +22 -0
- package/docs/advanced/dark-mode.md +288 -0
- package/docs/basic/button.md +605 -0
- package/docs/basic/divider.md +103 -0
- package/docs/basic/float-button.md +246 -0
- package/docs/basic/grid.md +427 -0
- package/docs/basic/layout.md +459 -0
- package/docs/basic/resizable.md +584 -0
- package/docs/basic/space.md +163 -0
- package/docs/basic/tokens.md +425 -0
- package/docs/basic/typography.md +615 -0
- package/docs/changes-from-semi.md +105 -0
- package/docs/ecosystem/tailwind.md +210 -0
- package/docs/experience/accessibility.md +82 -0
- package/docs/experience/content-guidelines.md +819 -0
- package/docs/experience/internationalization.md +7 -0
- package/docs/feedback/banner.md +198 -0
- package/docs/feedback/feedback.md +294 -0
- package/docs/feedback/notification.md +401 -0
- package/docs/feedback/popconfirm.md +243 -0
- package/docs/feedback/progress.md +389 -0
- package/docs/feedback/skeleton.md +388 -0
- package/docs/feedback/spin.md +172 -0
- package/docs/feedback/toast.md +393 -0
- package/docs/input/auto-complete.md +399 -0
- package/docs/input/cascader.md +1558 -0
- package/docs/input/checkbox.md +408 -0
- package/docs/input/color-picker.md +175 -0
- package/docs/input/date-picker.md +942 -0
- package/docs/input/form.md +2550 -0
- package/docs/input/input-number.md +451 -0
- package/docs/input/input.md +640 -0
- package/docs/input/pincode.md +191 -0
- package/docs/input/radio.md +337 -0
- package/docs/input/rating.md +214 -0
- package/docs/input/select.md +1230 -0
- package/docs/input/slider.md +347 -0
- package/docs/input/switch.md +206 -0
- package/docs/input/tag-input.md +465 -0
- package/docs/input/time-picker.md +358 -0
- package/docs/input/transfer.md +1061 -0
- package/docs/input/tree-select.md +1300 -0
- package/docs/input/upload.md +1811 -0
- package/docs/llms.txt +147 -0
- package/docs/navigation/anchor.md +377 -0
- package/docs/navigation/backtop.md +100 -0
- package/docs/navigation/breadcrumb.md +284 -0
- package/docs/navigation/navigation.md +851 -0
- package/docs/navigation/pagination.md +217 -0
- package/docs/navigation/steps.md +315 -0
- package/docs/navigation/tabs.md +754 -0
- package/docs/navigation/tree.md +1956 -0
- package/docs/other/config-provider.md +599 -0
- package/docs/other/locale.md +353 -0
- package/docs/plus/audio-player.md +155 -0
- package/docs/plus/code-highlight.md +150 -0
- package/docs/plus/drag-move.md +214 -0
- package/docs/plus/hot-keys.md +174 -0
- package/docs/plus/json-viewer.md +392 -0
- package/docs/plus/lottie.md +176 -0
- package/docs/plus/markdown-render.md +240 -0
- package/docs/plus/video-player.md +325 -0
- package/docs/show/avatar.md +475 -0
- package/docs/show/badge.md +276 -0
- package/docs/show/calendar.md +352 -0
- package/docs/show/card.md +485 -0
- package/docs/show/carousel.md +592 -0
- package/docs/show/collapse.md +289 -0
- package/docs/show/collapsible.md +216 -0
- package/docs/show/cropper.md +285 -0
- package/docs/show/descriptions.md +325 -0
- package/docs/show/dropdown.md +466 -0
- package/docs/show/empty.md +225 -0
- package/docs/show/highlight.md +144 -0
- package/docs/show/image.md +433 -0
- package/docs/show/list.md +927 -0
- package/docs/show/modal.md +517 -0
- package/docs/show/overflow-list.md +272 -0
- package/docs/show/popover.md +534 -0
- package/docs/show/scroll-list.md +156 -0
- package/docs/show/side-sheet.md +274 -0
- package/docs/show/table.md +5437 -0
- package/docs/show/tag.md +428 -0
- package/docs/show/timeline.md +277 -0
- package/docs/show/tooltip.md +442 -0
- package/docs/show/user-guide.md +419 -0
- package/docs/start/getting-started.md +234 -0
- package/docs/start/introduction.md +57 -0
- package/docs/start/overview.md +21 -0
- package/package.json +5 -4
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
# Markdown Render
|
|
2
|
+
|
|
3
|
+
> Instantly render Markdown and MDX in web pages
|
|
4
|
+
|
|
5
|
+
Package: `@fibrae/semi-ui-svelte`. Web page: https://semi-design-next.pages.dev/en-US/svelte/plus/markdown-render/
|
|
6
|
+
|
|
7
|
+
## When to use
|
|
8
|
+
|
|
9
|
+
Markdown is a document markup language that can implement basic common rich text functions such as titles, pictures, tables, links, bolding, etc. through simple tags. MDX is based on Markdown and allows the introduction of JSX to achieve more complex and customized document writing and display requirements.
|
|
10
|
+
|
|
11
|
+
The `MarkdownRender` component provided by Semi supports rendering Markdown and MDX. No special configuration is required. By passing in plain text, rich text content that conforms to Semi style specifications can be rendered. Code blocks are highlighted by [CodeHighlight](../plus/code-highlight.md); register the languages they use with `CodeHighlight.register` first, an unregistered language is shown as plain text.
|
|
12
|
+
|
|
13
|
+
Usually used in the following scenarios:
|
|
14
|
+
|
|
15
|
+
- Document site writing and rendering
|
|
16
|
+
- Front-end rendering when the server dynamically generates rich text content
|
|
17
|
+
- A light interactive website that focuses on content display
|
|
18
|
+
|
|
19
|
+
## Demos
|
|
20
|
+
|
|
21
|
+
### How to import
|
|
22
|
+
|
|
23
|
+
```svelte
|
|
24
|
+
<script lang="ts">
|
|
25
|
+
import { MarkdownRender } from '@fibrae/semi-ui-svelte';
|
|
26
|
+
</script>
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
### Basic usage
|
|
30
|
+
|
|
31
|
+
After importing MarkdownRender, just pass in Markdown or MDX plain text directly.
|
|
32
|
+
|
|
33
|
+
Note that symbols such as `<` and `{` are valid JSX syntax and are treated as code, so they cannot be rendered directly and must be escaped with `\`. If you only need to render pure Markdown, see the Simple Markdown section below.
|
|
34
|
+
|
|
35
|
+
```svelte
|
|
36
|
+
<script lang="ts">
|
|
37
|
+
import { MarkdownRender } from '@fibrae/semi-ui-svelte';
|
|
38
|
+
|
|
39
|
+
const raw = `
|
|
40
|
+
正文内容是普通的文本,也可以**加粗**~~删除线~~和<u>下划线</u> [超链接](https://semi-design-next.pages.dev/) 等 Markdown 与 HTML 的基本语法所支持的富文本,也支持 emoji 🍰
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
部分符号需要转义 \\{\\} \\<\\> ...
|
|
44
|
+
|
|
45
|
+
<br/>
|
|
46
|
+
<br/>
|
|
47
|
+
---
|
|
48
|
+
#### Semi Design Next 主题
|
|
49
|
+
Semi Design Next 用 --semi-* 变量定制主题,支持全局、组件级别的样式定制\\
|
|
50
|
+
适用于各种规模的团队,无论你是需要简化工作流程,提高团队协作,还是增加生产力,我们都有适合你的功能
|
|
51
|
+
|
|
52
|
+
##### 中大型企业
|
|
53
|
+
- 多达 3000+ Design Token,深入每一处细节的定制可能,色彩,阴影,边距,圆角,动效,渲染结构均可自由定制,告别 ~~CSS 硬编码~~
|
|
54
|
+
- 功能强大,经过大量项目验证过的 UI lib,轻松应对各类复杂场景
|
|
55
|
+
- A11y 无障碍友好,国际化功能完备
|
|
56
|
+
- 面向社区建设,完全开源,无使用限制
|
|
57
|
+
- 从 designOps 到 devOps,自动化工作流,UI Kit 一键刷入主题,生成 Style Guideline,研发一行 npm 代码配置接入
|
|
58
|
+
|
|
59
|
+
##### 初创企业
|
|
60
|
+
- 无需从 0 到 1 投入大量研发资源,快速复用开源社区优秀方案, 低成本快速定制具备品牌特色的设计系统。
|
|
61
|
+
- 一键支持暗色模式生成,支持根据品牌色快速生成包含 320 个全色阶、兼容深/浅两种模式的色彩系统,并支持动态切换
|
|
62
|
+
- 不断进化,Semi Design Next 组件由<u>社区维护团队</u>专业维护,持续迭代,值得信赖
|
|
63
|
+
|
|
64
|
+
##### 自由设计师/个人开发者
|
|
65
|
+
- 低成本快速创建风格各异的设计系统,更少时间,更快交付
|
|
66
|
+
- 研发接入友好,无需反复沟通,交付npm包产物,一键完成代码接入
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+

|
|
70
|
+
|
|
71
|
+
---
|
|
72
|
+
|
|
73
|
+
#### MarkdownRender 渲染列表语法
|
|
74
|
+
- 好好地吃饭
|
|
75
|
+
- 好好地睡觉
|
|
76
|
+
- 好好地游玩
|
|
77
|
+
- 好好地学习
|
|
78
|
+
- 好好地聊天
|
|
79
|
+
- 好好地吵架
|
|
80
|
+
- 过着平凡普通的每日
|
|
81
|
+
|
|
82
|
+
| 支持 | Markdown 表格 | c | d |
|
|
83
|
+
| - | :- | -: | :-: |
|
|
84
|
+
| 1 | 2 | 3 | 4 |
|
|
85
|
+
| 21 | 22 | 23 | 24 |
|
|
86
|
+
| 31 | 32 | 33 | 34 |
|
|
87
|
+
| 41 | 42 | 43 | 44 |
|
|
88
|
+
|
|
89
|
+
`;
|
|
90
|
+
</script>
|
|
91
|
+
|
|
92
|
+
<MarkdownRender {raw} />
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
### Modify element style
|
|
96
|
+
|
|
97
|
+
You can arbitrarily replace the display effect of document elements in Markdown or MDX documents. Just pass your Svelte component override to the `components` prop. An element's attributes (such as `class` and `colspan`) reach the component as props, and its content is rendered by the `children` snippet. The component also receives `node`, the compiled element; destructure it out before spreading the props onto a DOM element.
|
|
98
|
+
|
|
99
|
+
For example, now you need to set the color of all level 2 headings to the main color
|
|
100
|
+
|
|
101
|
+
```svelte
|
|
102
|
+
<script lang="ts">
|
|
103
|
+
import { MarkdownRender, type MarkdownRenderComponents } from '@fibrae/semi-ui-svelte';
|
|
104
|
+
import PrimaryTitle from './parts/primary-title.svelte';
|
|
105
|
+
|
|
106
|
+
const components: MarkdownRenderComponents = { h2: PrimaryTitle };
|
|
107
|
+
</script>
|
|
108
|
+
|
|
109
|
+
<MarkdownRender {components} raw="## 从 Semi Design 到 Any Design 快速定义你的设计系统,并应用在设计稿和代码中" />
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
Any element tag that Markdown generates can be overridden; the common ones are `a blockquote br code del em h1 h2 h3 h4 h5 h6 hr img li ol p pre strong ul table`
|
|
113
|
+
|
|
114
|
+
### Simple Markdown
|
|
115
|
+
|
|
116
|
+
When the Markdown you render is just pure markdown without any JSX code, you can pass `format="md"` to enable Markdown-only mode. In this mode, you don't need to escape special characters.
|
|
117
|
+
|
|
118
|
+
```svelte
|
|
119
|
+
<script lang="ts">
|
|
120
|
+
import { MarkdownRender } from '@fibrae/semi-ui-svelte';
|
|
121
|
+
</script>
|
|
122
|
+
|
|
123
|
+
<MarkdownRender format="md" raw="无需转义的符号{'{}'}<> ..." />
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
`format="md"` renders through a [unified](https://unifiedjs.com/) pipeline: remark-parse parses the source, remark-gfm (when `remarkGfm` is true) and `remarkPlugins` run in order, remark-rehype turns it into an HTML syntax tree, `rehypePlugins` run, and a node tree is created, which Svelte renders with `components` applied. No code is generated or evaluated, so it renders under a CSP without `unsafe-eval`, and the MDX compiler is never loaded.
|
|
127
|
+
|
|
128
|
+
`format="mdx"` compiles the source to code with @mdx-js/mdx and evaluates it at runtime, so the CSP has to allow `unsafe-eval`; @mdx-js/mdx is loaded on demand the first time MDX is rendered.
|
|
129
|
+
|
|
130
|
+
> **HTML tags handling in format='md' mode**
|
|
131
|
+
>
|
|
132
|
+
> In `format="md"` mode, raw HTML embedded in Markdown (such as `<div>`, `<span style="color:red">`, etc.) is handed to `rehypePlugins` as raw nodes; whatever is still a raw node after the plugins is removed and will not be rendered on the page.
|
|
133
|
+
>
|
|
134
|
+
> If you need to preserve HTML tag rendering in `format="md"` mode, you can pass the rehype-raw plugin via rehypePlugins:
|
|
135
|
+
|
|
136
|
+
```svelte
|
|
137
|
+
<script lang="ts">
|
|
138
|
+
import { MarkdownRender } from '@fibrae/semi-ui-svelte';
|
|
139
|
+
import rehypeRaw from 'rehype-raw';
|
|
140
|
+
|
|
141
|
+
const rehypePlugins = [rehypeRaw];
|
|
142
|
+
</script>
|
|
143
|
+
|
|
144
|
+
<MarkdownRender format="md" raw={'<span style="color:red">Red text</span>'} {rehypePlugins} />
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
### Add custom components
|
|
148
|
+
|
|
149
|
+
By passing in custom components to the `components` prop, you can write JSX directly in Markdown, and the component will be rendered to the final page, supporting JS events. The default Markdown components can be obtained from `MarkdownRender.defaultComponents` and can be used for secondary packaging.
|
|
150
|
+
|
|
151
|
+
JSX attributes in MDX reach the component as props, and children are rendered by the `children` snippet. Event attributes arrive as written in the MDX (such as `onClick`) and the component binds them itself; on native elements `onClick` becomes `onclick` and a style object becomes a string. The component also receives `node`, the compiled element `{ type, props }`: pass it on when forwarding to `MarkdownRender.defaultComponents.*`, and destructure it out before spreading onto a DOM element.
|
|
152
|
+
|
|
153
|
+
> **Note**
|
|
154
|
+
>
|
|
155
|
+
> Try to ensure that the JSX code in the rendered Markdown is trustworthy to prevent XSS. 
|
|
156
|
+
|
|
157
|
+
```svelte
|
|
158
|
+
<script lang="ts">
|
|
159
|
+
import { MarkdownRender, type MarkdownRenderComponents } from '@fibrae/semi-ui-svelte';
|
|
160
|
+
import MyButton from './parts/my-button.svelte';
|
|
161
|
+
|
|
162
|
+
// The MDX source refers to the component by name
|
|
163
|
+
const components: MarkdownRenderComponents = { ...MarkdownRender.defaultComponents, MyButton };
|
|
164
|
+
|
|
165
|
+
const raw = `
|
|
166
|
+
#### 下面是一个渲染在 Markdown 中的按钮
|
|
167
|
+
<MyButton onClick={()=>alert("点击了 MyButton")}>MyButton 点我</MyButton>
|
|
168
|
+
|
|
169
|
+
直接在 Markdown 中书写 JSX 即可
|
|
170
|
+
`;
|
|
171
|
+
</script>
|
|
172
|
+
|
|
173
|
+
<MarkdownRender {components} {raw} />
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
When you replace the built-in `code` component, the source of a fenced block is in `node.props.children`; the `children` snippet cannot give its text. Pass it to `codeText` to get the source as is, with the trailing newline and without trimming:
|
|
177
|
+
|
|
178
|
+
```ts
|
|
179
|
+
import { codeText } from '@fibrae/semi-ui-svelte';
|
|
180
|
+
|
|
181
|
+
const source = codeText(node.props.children);
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
### Add plugins
|
|
185
|
+
|
|
186
|
+
Remark and Rehype plugins of the unified ecosystem are supported through `remarkPlugins` `rehypePlugins`, please refer to [MDXJS](https://mdxjs.com/docs/extending-mdx/) and [unified](https://unifiedjs.com/explore/) for details
|
|
187
|
+
|
|
188
|
+
The source compiles again when `raw`, `format`, `remarkGfm` or an entry of a plugin array changes; a `components` change only renders again. Plugin arrays are compared entry by entry. The options object of a `[plugin, options]` entry is compared by reference too: a literal that is created anew each time the source is evaluated compiles again, so define it at the top level of `<script>` to keep it stable:
|
|
189
|
+
|
|
190
|
+
```svelte
|
|
191
|
+
<script lang="ts">
|
|
192
|
+
import { MarkdownRender, type MarkdownRenderProps } from '@fibrae/semi-ui-svelte';
|
|
193
|
+
import remarkToc from 'remark-toc';
|
|
194
|
+
|
|
195
|
+
const { raw }: { raw: string } = $props();
|
|
196
|
+
|
|
197
|
+
const remarkPlugins: MarkdownRenderProps['remarkPlugins'] = [[remarkToc, { heading: 'Contents' }]];
|
|
198
|
+
</script>
|
|
199
|
+
|
|
200
|
+
<MarkdownRender format="md" {raw} {remarkPlugins} />
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
### Compile errors
|
|
204
|
+
|
|
205
|
+
When the MDX has a syntax error or a plugin throws, the last successfully rendered content stays on the page and the error is logged with `console.error` in development; no unhandled Promise rejection is left behind.
|
|
206
|
+
|
|
207
|
+
### Accessibility
|
|
208
|
+
|
|
209
|
+
With `aria-label` or `aria-labelledby` and no `role`, the root element gets `role="group"`; a `role` you pass takes precedence. An image inside a link cannot be previewed, so the link is the only interactive element; the caption under an image is hidden from assistive technology and the image's name comes from `alt` alone.
|
|
210
|
+
|
|
211
|
+
### API
|
|
212
|
+
|
|
213
|
+
**Props**
|
|
214
|
+
|
|
215
|
+
| Property | Description | Type | Default |
|
|
216
|
+
| - | - | - | - |
|
|
217
|
+
| components | Overrides Markdown elements and adds the custom components MDX sources refer to. Values are Svelte components or HTML tag names; an element key such as h1 takes a component or its own tag name. Merged over MarkdownRender.defaultComponents; a change only renders again, it does not compile again. Besides the `children` snippet, a component receives `node`, the compiled element. | `MarkdownRenderComponents` | - |
|
|
218
|
+
| format | Format of raw: md is plain Markdown, mdx allows embedded JSX. Compiles again on change. | `'md' \| 'mdx'` | `"mdx"` |
|
|
219
|
+
| raw | Markdown or MDX source text. Compiles again on change. | `string` | - |
|
|
220
|
+
| rehypePlugins | Custom Rehype plugins. Compiles again when an entry changes. | `MarkdownRenderBaseProps['rehypePlugins']` | - |
|
|
221
|
+
| remarkGfm | Whether to enable GitHub GFM syntax. Compiles again on change. | `boolean` | `true` |
|
|
222
|
+
| remarkPlugins | Custom Remark plugins. Compiles again when an entry changes. | `MarkdownRenderBaseProps['remarkPlugins']` | - |
|
|
223
|
+
|
|
224
|
+
`class`, `style` and native attributes and events (such as `id`, `data-*` and `onclick`) land on the root `div`.
|
|
225
|
+
|
|
226
|
+
## Design Token
|
|
227
|
+
|
|
228
|
+
The design token table of this component is on the web page: <https://semi-design-next.pages.dev/en-US/svelte/plus/markdown-render/>
|
|
229
|
+
|
|
230
|
+
## Changes from Semi Design
|
|
231
|
+
|
|
232
|
+
From the project release notes (written in Chinese). Your knowledge of Semi Design does not cover these.
|
|
233
|
+
|
|
234
|
+
- `format="md"` 改用 unified 管线,不在运行时执行代码,可在禁用 `unsafe-eval` 的 CSP 下使用,`@mdx-js/mdx` 只在 `format="mdx"` 时加载;md 下 `components.wrapper` 不再生效;`remarkPlugins`、`rehypePlugins` 按元素比较,`[插件, 配置对象]` 需用 `useMemo` 保持引用稳定。
|
|
235
|
+
- 破坏性(类型):`components` 改为 `MarkdownRenderComponents`,值必须是 React 组件或 HTML 标签名,元素键只接受组件或自身标签名,Chat、AIChatDialogue 传入的 components 同样受约束。默认 `table` 保留 GFM 列对齐且不再分页(需要时经 `components.table` 传 `pagination`);`defaultComponents` 新增 `pre`,无语言的代码由 `span` 改为 `code` 元素。
|
|
236
|
+
- 有语言的代码块被 rehype 插件拆成元素(不交给 CodeHighlight)时保留外层 `pre`,原来会去掉 `pre`,空白折叠,依赖 `pre code` 的高亮样式不生效。
|
|
237
|
+
- React、Vue、Svelte:`pre` 按标记识别整块渲染的 `code` 组件,替换 `components.code` 并自行渲染块级结构(如带语言栏的 div)时,React 给组件加静态属性 `elementType: 'MarkdownRender.Code'`,Vue 在 `defineOptions` 写同名选项,Svelte 在模块加载时调用 `@fibrae/semi-ui-svelte/markdown-render/components/tree` 的 `markCodeBlock(组件)`;有语言且未被拆分的代码块随之去掉外层 `pre`。
|
|
238
|
+
- `format="md"` 在首次渲染(含服务端渲染)同步编译,服务端 HTML 与首个提交即有内容(含 GFM 表格);`mdx` 与依赖异步插件的 md 仍在挂载后编译,服务端 HTML 中根节点为空。
|
|
239
|
+
- Svelte:`components` 的值是 Svelte 组件或标签名;MDX 原生元素上的 `onClick` 转为 `onclick`,style 对象转为字符串。
|
|
240
|
+
- Svelte:默认用 Semi 组件渲染 `a`、`img`、`p`、`pre`、`code`、`h1` 至 `h6`、`table`,经 `MarkdownRender.defaultComponents` 暴露,`components` 里传的值覆盖默认项;`components` 里的组件除 `children` snippet 外还收到 `node`(编译后的元素 `{ type, props }`),自定义 `code` 用 `codeText(node.props.children)` 取源码,转发给 `defaultComponents` 时要带上 `node`,展开到 DOM 元素前要先解构掉 `node`。
|
|
@@ -0,0 +1,325 @@
|
|
|
1
|
+
# VideoPlayer
|
|
2
|
+
|
|
3
|
+
> Used to play video
|
|
4
|
+
|
|
5
|
+
Package: `@fibrae/semi-ui-svelte`. Web page: https://semi-design-next.pages.dev/en-US/svelte/plus/video-player/
|
|
6
|
+
|
|
7
|
+
## Demos
|
|
8
|
+
|
|
9
|
+
### How to import
|
|
10
|
+
|
|
11
|
+
```svelte
|
|
12
|
+
<script lang="ts">
|
|
13
|
+
import { VideoPlayer } from '@fibrae/semi-ui-svelte';
|
|
14
|
+
</script>
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
### Basic Usage
|
|
18
|
+
|
|
19
|
+
For basic usage, pass the video address through `src` and pass the video cover address through `poster`
|
|
20
|
+
|
|
21
|
+
```svelte
|
|
22
|
+
<script lang="ts">
|
|
23
|
+
import { VideoPlayer } from '@fibrae/semi-ui-svelte';
|
|
24
|
+
|
|
25
|
+
const src = '/assets/video/vchart-show-video.mp4';
|
|
26
|
+
const poster = '/assets/poster2.jpeg';
|
|
27
|
+
</script>
|
|
28
|
+
|
|
29
|
+
<VideoPlayer height={630} {poster} {src} />
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
### Set controls list
|
|
33
|
+
|
|
34
|
+
Set the display items of the menu bar through `controlsList`. The accepted value is an array. The default value is `['play', 'next', 'time', 'volume', 'playbackRate', 'quality', 'route', 'mirror', 'fullscreen', 'pictureInPicture']`
|
|
35
|
+
|
|
36
|
+
A control shows when `controlsList` allows it and the prop it depends on is provided: `next` needs `onNext`, `quality` needs a non-empty `qualityList`, and `route` needs a non-empty `routeList`; the other controls depend only on `controlsList`.
|
|
37
|
+
|
|
38
|
+
`onNext` is a function prop. Passing it, with `next` in `controlsList`, shows the Next button, and clicking the button calls it.
|
|
39
|
+
|
|
40
|
+
```svelte
|
|
41
|
+
<script lang="ts">
|
|
42
|
+
import { VideoPlayer } from '@fibrae/semi-ui-svelte';
|
|
43
|
+
|
|
44
|
+
const src = '/assets/video/vchart-show-video.mp4';
|
|
45
|
+
const poster = '/assets/poster2.jpeg';
|
|
46
|
+
</script>
|
|
47
|
+
|
|
48
|
+
<VideoPlayer controlsList={['play', 'time', 'volume', 'playbackRate', 'fullscreen']} height={630} {poster} {src} />
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
### Loop playback
|
|
52
|
+
|
|
53
|
+
Use `loop` to set loop playback
|
|
54
|
+
|
|
55
|
+
```svelte
|
|
56
|
+
<script lang="ts">
|
|
57
|
+
import { VideoPlayer } from '@fibrae/semi-ui-svelte';
|
|
58
|
+
|
|
59
|
+
const src = '/assets/video/vchart-show-video.mp4';
|
|
60
|
+
const poster = '/assets/poster2.jpeg';
|
|
61
|
+
</script>
|
|
62
|
+
|
|
63
|
+
<VideoPlayer height={630} loop {poster} {src} />
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
### Fast forward and rewind
|
|
67
|
+
|
|
68
|
+
Use `seekTime` to set the fast forward and rewind time, and use the left and right keys on the keyboard to fast forward and rewind.
|
|
69
|
+
|
|
70
|
+
```svelte
|
|
71
|
+
<script lang="ts">
|
|
72
|
+
import { Select, VideoPlayer } from '@fibrae/semi-ui-svelte';
|
|
73
|
+
|
|
74
|
+
let seekTime = $state<number | undefined>(5);
|
|
75
|
+
|
|
76
|
+
const src = '/assets/video/vchart-show-video.mp4';
|
|
77
|
+
const poster = '/assets/poster2.jpeg';
|
|
78
|
+
const optionList = [
|
|
79
|
+
{ label: '5s', value: 5 },
|
|
80
|
+
{ label: '10s', value: 10 },
|
|
81
|
+
{ label: '15s', value: 15 },
|
|
82
|
+
];
|
|
83
|
+
</script>
|
|
84
|
+
|
|
85
|
+
<div>
|
|
86
|
+
<div>
|
|
87
|
+
<span style="margin-bottom: 10px">请选择快进快退时间</span>
|
|
88
|
+
<Select aria-label="请选择快进快退时间" onChange={(value) => (seekTime = typeof value === 'number' ? value : undefined)} {optionList} placeholder="请选择快进快退时间" style="width: 100px; margin-left: 10px" value={seekTime} />
|
|
89
|
+
</div>
|
|
90
|
+
<VideoPlayer height={630} {poster} {seekTime} {src} style="margin-top: 10px" />
|
|
91
|
+
</div>
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
### Playback rate
|
|
95
|
+
|
|
96
|
+
Set the rate selection list through `playbackRateList`. The rate, quality and route controls are native buttons that open their menu when focused with Tab; see "Keyboard and focus" for the keys. Each button is named by what it sets followed by the current option (such as "Playback speed 1.0x"), and its menu items are radio items
|
|
97
|
+
|
|
98
|
+
```svelte
|
|
99
|
+
<script lang="ts">
|
|
100
|
+
import { VideoPlayer } from '@fibrae/semi-ui-svelte';
|
|
101
|
+
|
|
102
|
+
const playbackRateList = [
|
|
103
|
+
{ label: '0.5x', value: 0.5 },
|
|
104
|
+
{ label: '1.0x', value: 1 },
|
|
105
|
+
{ label: '1.5x', value: 1.5 },
|
|
106
|
+
{ label: '2.0x', value: 2 },
|
|
107
|
+
];
|
|
108
|
+
const src = '/assets/video/vchart-show-video.mp4';
|
|
109
|
+
const poster = '/assets/poster2.jpeg';
|
|
110
|
+
</script>
|
|
111
|
+
|
|
112
|
+
<VideoPlayer height={630} {playbackRateList} {poster} {src} />
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
### Volume setting
|
|
116
|
+
|
|
117
|
+
Use `volume` to set the initial volume, the value range is 0 - 100, set `muted` to `true` to play silently. `onVolumeChange` is called when the user adjusts the volume
|
|
118
|
+
|
|
119
|
+
```svelte
|
|
120
|
+
<script lang="ts">
|
|
121
|
+
import { VideoPlayer } from '@fibrae/semi-ui-svelte';
|
|
122
|
+
|
|
123
|
+
const src = '/assets/video/vchart-show-video.mp4';
|
|
124
|
+
const poster = '/assets/poster2.jpeg';
|
|
125
|
+
</script>
|
|
126
|
+
|
|
127
|
+
<VideoPlayer height={630} muted {poster} {src} />
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
### Clarity switching
|
|
131
|
+
|
|
132
|
+
Use `qualityList` to set the clarity selection list, `defaultQuality` to set the initial selected clarity, and update `src` in `onQualityChange`.
|
|
133
|
+
|
|
134
|
+
Similarly for route switching, use `routeList` to set the route selection list, `defaultRoute` to set the initial selected route, and update `src` in `onRouteChange`.
|
|
135
|
+
|
|
136
|
+
```svelte
|
|
137
|
+
<script lang="ts">
|
|
138
|
+
import { VideoPlayer } from '@fibrae/semi-ui-svelte';
|
|
139
|
+
|
|
140
|
+
const playList = [
|
|
141
|
+
{
|
|
142
|
+
src: '/assets/video/vchart-show-video.mp4',
|
|
143
|
+
quality: '1080p',
|
|
144
|
+
},
|
|
145
|
+
{
|
|
146
|
+
src: '/assets/video/vchart-show-video.mp4',
|
|
147
|
+
quality: '480p',
|
|
148
|
+
},
|
|
149
|
+
];
|
|
150
|
+
const poster = '/assets/poster2.jpeg';
|
|
151
|
+
const qualityList = [
|
|
152
|
+
{ label: '1080p', value: '1080p' },
|
|
153
|
+
{ label: '480p', value: '480p' },
|
|
154
|
+
];
|
|
155
|
+
|
|
156
|
+
let src = $state(playList[0].src);
|
|
157
|
+
|
|
158
|
+
const onQualityChange = (quality: string) => {
|
|
159
|
+
console.log('quality change', quality);
|
|
160
|
+
const source = playList.find((item) => item.quality === quality);
|
|
161
|
+
if (source) src = source.src;
|
|
162
|
+
};
|
|
163
|
+
</script>
|
|
164
|
+
|
|
165
|
+
<VideoPlayer defaultQuality="1080p" height={630} {onQualityChange} {poster} {qualityList} {src} />
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
### Chapter markers
|
|
169
|
+
|
|
170
|
+
Set chapter markers via `markers`
|
|
171
|
+
|
|
172
|
+
```svelte
|
|
173
|
+
<script lang="ts">
|
|
174
|
+
import { VideoPlayer } from '@fibrae/semi-ui-svelte';
|
|
175
|
+
|
|
176
|
+
const src = '/assets/video/vchart-show-video.mp4';
|
|
177
|
+
const poster = '/assets/poster2.jpeg';
|
|
178
|
+
const markers = [
|
|
179
|
+
{ start: 0, title: '片头' },
|
|
180
|
+
{ start: 4, title: '功能介绍' },
|
|
181
|
+
{ start: 38, title: 'Theming' },
|
|
182
|
+
{ start: 51, title: '片尾' },
|
|
183
|
+
];
|
|
184
|
+
</script>
|
|
185
|
+
|
|
186
|
+
<VideoPlayer height={630} {markers} {poster} {src} />
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
### Theme
|
|
190
|
+
|
|
191
|
+
Set the theme via `theme`, the theme only affects the background color
|
|
192
|
+
|
|
193
|
+
```svelte
|
|
194
|
+
<script lang="ts">
|
|
195
|
+
import { VideoPlayer } from '@fibrae/semi-ui-svelte';
|
|
196
|
+
|
|
197
|
+
const src = '/assets/video/vchart-show-video.mp4';
|
|
198
|
+
const poster = '/assets/poster2.jpeg';
|
|
199
|
+
</script>
|
|
200
|
+
|
|
201
|
+
<VideoPlayer height={630} {poster} {src} theme="light" />
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
### Using ref for control
|
|
205
|
+
|
|
206
|
+
Bind the component with `bind:this` and call its `getVideo()` method, which returns the native video element, for more flexible control such as synchronized playback/pause of multiple videos. It returns `undefined` before mount
|
|
207
|
+
|
|
208
|
+
```svelte
|
|
209
|
+
<script lang="ts">
|
|
210
|
+
import { Button, VideoPlayer } from '@fibrae/semi-ui-svelte';
|
|
211
|
+
|
|
212
|
+
const src = '/assets/video/vchart-show-video.mp4';
|
|
213
|
+
const poster = '/assets/poster2.jpeg';
|
|
214
|
+
|
|
215
|
+
let player1 = $state<ReturnType<typeof VideoPlayer>>();
|
|
216
|
+
let player2 = $state<ReturnType<typeof VideoPlayer>>();
|
|
217
|
+
|
|
218
|
+
const handlePlayAll = () => {
|
|
219
|
+
void player1?.getVideo()?.play();
|
|
220
|
+
void player2?.getVideo()?.play();
|
|
221
|
+
};
|
|
222
|
+
|
|
223
|
+
const handlePauseAll = () => {
|
|
224
|
+
player1?.getVideo()?.pause();
|
|
225
|
+
player2?.getVideo()?.pause();
|
|
226
|
+
};
|
|
227
|
+
</script>
|
|
228
|
+
|
|
229
|
+
<div>
|
|
230
|
+
<div style="margin-bottom: 12px">
|
|
231
|
+
<Button style="margin-right: 8px" onclick={handlePlayAll}>同时播放</Button>
|
|
232
|
+
<Button onclick={handlePauseAll}>同时暂停</Button>
|
|
233
|
+
</div>
|
|
234
|
+
<div style="display: flex; gap: 12px">
|
|
235
|
+
<VideoPlayer bind:this={player1} height={315} {poster} {src} width="50%" />
|
|
236
|
+
<VideoPlayer bind:this={player2} height={315} {poster} {src} width="50%" />
|
|
237
|
+
</div>
|
|
238
|
+
</div>
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+
### Keyboard and focus
|
|
242
|
+
|
|
243
|
+
- While focus is inside the player, Space toggles play and pause, except on a button or an input control, which keeps the key; the left and right arrow keys rewind and fast forward by `seekTime`, except inside an input control, the progress bar or a menu, which keep the keys. Combinations with Alt, Ctrl or Meta are ignored.
|
|
244
|
+
- The progress bar is a slider (`role="slider"`): the arrow keys move it by `seekTime`, PageUp and PageDown by a tenth of the duration, and Home and End jump to either end. Screen readers announce "current time / total time".
|
|
245
|
+
- The playback rate, quality and route buttons open their menu when focused with Tab; the down and up arrow keys move focus to the first and last item. In the menu, the up and down arrow keys, Home and End move focus, Enter or Space selects, and Esc closes the menu and returns to the button.
|
|
246
|
+
- The volume popover opens when the volume button receives focus, and Enter or Space toggles mute; the down arrow key moves focus into the popover, where the volume slider takes the arrow keys.
|
|
247
|
+
- When the pointer leaves the player during playback, the control bar stays visible while it holds keyboard focus.
|
|
248
|
+
|
|
249
|
+
### API
|
|
250
|
+
|
|
251
|
+
**Props**
|
|
252
|
+
|
|
253
|
+
| Property | Description | Type | Default |
|
|
254
|
+
| - | - | - | - |
|
|
255
|
+
| autoPlay | Whether to play automatically. | `boolean` | `false` |
|
|
256
|
+
| captionsSrc | Captions source URL; the captions are shown by default once set. | `string` | - |
|
|
257
|
+
| clickToPlay | Whether clicking the video toggles playback. | `boolean` | `true` |
|
|
258
|
+
| controlsList | Controls shown in the control bar, all by default. A control also needs the prop it depends on to show. | `VideoControl[]` | `["play", "next", "time", "volume", "playbackRate", "quality", "route", "mirror", "fullscreen", "pictureInPicture"]` |
|
|
259
|
+
| crossOrigin | CORS setting of the video element: anonymous or use-credentials; an empty string means anonymous. | `'' \| 'anonymous' \| 'use-credentials'` | - |
|
|
260
|
+
| defaultPlaybackRate | Initial playback rate, read once when the player mounts. | `number` | `1` |
|
|
261
|
+
| defaultQuality | Initial quality, read once when the player mounts. | `string` | - |
|
|
262
|
+
| defaultRoute | Initial route, read once when the player mounts. | `string` | - |
|
|
263
|
+
| height | Player height; a number is in pixels, a string is used as is. | `number \| string` | - |
|
|
264
|
+
| loop | Whether to loop playback. | `boolean` | `false` |
|
|
265
|
+
| markers | Chapter markers, each with a start time in seconds and a title. | `VideoPlayerMarker[]` | - |
|
|
266
|
+
| muted | Whether to start muted, read once when the player mounts. | `boolean` | `false` |
|
|
267
|
+
| onNext | Called by the next button, which shows only when this is set and controlsList includes next. | `() => void` | - |
|
|
268
|
+
| onPause | Called when playback pauses. | `() => void` | - |
|
|
269
|
+
| onPlay | Called when playback starts. | `() => void` | - |
|
|
270
|
+
| onQualityChange | Called when the quality changes, with the selected quality value. | `(quality: string) => void` | - |
|
|
271
|
+
| onRateChange | Called when the playback rate changes, with the selected rate. | `(rate: number) => void` | - |
|
|
272
|
+
| onRouteChange | Called when the route changes, with the selected route value. | `(route: string) => void` | - |
|
|
273
|
+
| onVolumeChange | Called when the user drags the volume slider or toggles mute, with the new volume (0 when muted); not called on initialization. | `(volume: number) => void` | - |
|
|
274
|
+
| playbackRateList | Playback rate options, by default 2.0, 1.5, 1.25, 1.0 and 0.75. | `VideoPlayerOption<number>[]` | - |
|
|
275
|
+
| poster | Poster image URL. | `string` | - |
|
|
276
|
+
| qualityList | Quality options; the quality control shows only when this is non-empty. | `VideoPlayerOption<string>[]` | - |
|
|
277
|
+
| routeList | Route options; the route control shows only when this is non-empty. | `VideoPlayerOption<string>[]` | - |
|
|
278
|
+
| seekTime | Seconds a fast forward or rewind moves. | `number` | `10` |
|
|
279
|
+
| src | Video URL. Without it a missing-resource message shows; removing it keeps the previous source on the video element. | `string` | - |
|
|
280
|
+
| theme | Theme, affecting only the background color: dark or light. | `VideoPlayerTheme` | `"dark"` |
|
|
281
|
+
| volume | Initial volume from 0 to 100, read once when the player mounts. | `number` | `100` |
|
|
282
|
+
| width | Player width; a number is in pixels, a string is used as is. | `number \| string` | - |
|
|
283
|
+
|
|
284
|
+
**Methods**
|
|
285
|
+
|
|
286
|
+
| Method | Description | Type |
|
|
287
|
+
| - | - | - |
|
|
288
|
+
| getVideo | Returns the native video element, undefined before mount. | `() => HTMLVideoElement \| undefined` |
|
|
289
|
+
|
|
290
|
+
`class` (a string, array or object) and native attributes fall through to the root `div`, `style` is a string, and a width or height in `style` overrides the `width` and `height` props. When the root has `aria-label` or `aria-labelledby` it gets `role="group"`, and a `role` you pass takes precedence. Media events (`ontimeupdate`, `onended` and so on) do not bubble to the root, so listening to them on the component is not supported; get the native element through `getVideo()` and listen on it instead.
|
|
291
|
+
|
|
292
|
+
#### Marker
|
|
293
|
+
|
|
294
|
+
| Properties | Description | Type | Default Value |
|
|
295
|
+
| - | - | - | - |
|
|
296
|
+
| start | start time point | number | - |
|
|
297
|
+
| title | title | string | - |
|
|
298
|
+
|
|
299
|
+
#### VideoPlayerOption
|
|
300
|
+
|
|
301
|
+
The option type of `playbackRateList` is `VideoPlayerOption<number>`, and the option type of `qualityList` and `routeList` is `VideoPlayerOption<string>`. The type of `value` is the generic parameter.
|
|
302
|
+
|
|
303
|
+
| Properties | Description | Type | Default Value |
|
|
304
|
+
| - | - | - | - |
|
|
305
|
+
| label | Name shown in the menu | `string` | - |
|
|
306
|
+
| value | Option value, passed to the callback | `T` | - |
|
|
307
|
+
|
|
308
|
+
## Design Token
|
|
309
|
+
|
|
310
|
+
The design token table of this component is on the web page: <https://semi-design-next.pages.dev/en-US/svelte/plus/video-player/>
|
|
311
|
+
|
|
312
|
+
## Changes from Semi Design
|
|
313
|
+
|
|
314
|
+
From the project release notes (written in Chinese). Your knowledge of Semi Design does not cover these.
|
|
315
|
+
|
|
316
|
+
- 破坏性(类型):Props 不再接受 `onTimeUpdate`、`onEnded` 等 23 个 React 媒体事件回调及 Capture 变体(从不触发);VideoPlayer 的 `controlsList` 收窄为 `VideoControl[]`,`theme` 收窄为 `'dark' | 'light'`;删除无效的 `forwardRef`,改用 `ref`。
|
|
317
|
+
- VideoPlayer 进度条手柄用 `translate` 居中,`VideoProgressFoundation.getHandleLeft` 返回纯百分比(原 `calc(<百分比> - 8px)`)。
|
|
318
|
+
- 破坏性(深路径导入):删除 `semi-ui-react/video-player/utils`,改从 `@fibrae/semi-foundation/video-player/utils` 导入。
|
|
319
|
+
- VideoPlayer 新增 `onNext`,「下一个」按钮只在传了 `onNext` 且 `controlsList` 允许时显示(原来默认显示);静音改由 `muted` 承载,不再把音量写成 0;`onVolumeChange` 在拖动音量或切换静音时触发。AudioPlayer 时间统一为 `mm:ss`,超 1 小时为 `h:mm:ss`(原 `75:00`),封面不再可预览。AudioPlayer 挂载前音频元数据已加载完(服务端渲染后 hydration、缓存命中)时,挂载时直接读出时长,进度条可拖动、可点击跳转(原来时长停在 0,拖到哪里都跳回开头)。
|
|
320
|
+
- AudioPlayer 进度条圆点与 VideoPlayer 一致,中心对准进度末端,两端时盖住轨道圆角(原来圆点限制在轨道内),进度条两侧留出半个圆点的间距,圆点不压住时间文字;指针按下进度条不再显示键盘焦点环。VideoPlayer 音量与菜单弹层改为不透明深灰底,音量弹层底部增加 12px 留白(高度 160px 改为 168px);两者的弹层与菜单项样式不再依赖样式表加载顺序(原来可能被 Dropdown、Popover 的默认底色与文字色覆盖)。
|
|
321
|
+
- VideoPlayer 进度条圆点在悬停、键盘聚焦或拖动时显示,与轨道同心,进度为 0 时也显示(原来只在悬停播放头所在分段时显示,进度为 0 时不显示,拖动后移出可能一直残留);轨道悬停变粗改为以中心线上下对称的高度过渡;时间预览 Tooltip 不再拦截指针(原来箭头伸进进度条热区,指针移到箭头下时悬停中断,轨道粗细闪烁)。
|
|
322
|
+
- VideoPlayer 的初始 `volume` 取整并夹到不小于 0,音量为 0 时同时静音;销毁时清除计时器,重新显示时按当前状态重新应用音量与倍速。
|
|
323
|
+
- VideoPlayer 传了 `captionsSrc` 时 Safari 也默认显示字幕(原来 Safari 按系统字幕偏好不启用 `default` 字幕轨,播放器又没有字幕开关,字幕始终不显示)。
|
|
324
|
+
- Svelte:`class` 接受 clsx 值,`style` 只接受字符串;媒体事件(play、pause 等)不再透传到根元素,AudioPlayer 没有回调 props;VideoPlayer 的回调为 `onPlay`、`onPause`、`onQualityChange`、`onRateChange`、`onRouteChange`、`onVolumeChange`、`onNext`,经 `bind:this` 后调用 `getVideo()` 取得原生 `<video>`。
|
|
325
|
+
- Svelte:`defaultPlaybackRate`、`defaultQuality`、`defaultRoute` 只在挂载时读取一次,之后变化不再生效;进度条和按钮的 Tooltip 通过 `child` snippet 接入,按钮外层没有额外的 span。
|