@easy-editor/materials-dashboard-audio 0.0.2
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/.vite/plugins/vite-plugin-external-deps.ts +224 -0
- package/.vite/plugins/vite-plugin-material-dev.ts +218 -0
- package/CHANGELOG.md +7 -0
- package/LICENSE +9 -0
- package/dist/component.esm.js +165 -0
- package/dist/component.esm.js.map +1 -0
- package/dist/component.js +173 -0
- package/dist/component.js.map +1 -0
- package/dist/component.min.js +2 -0
- package/dist/component.min.js.map +1 -0
- package/dist/index.cjs +456 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.esm.js +453 -0
- package/dist/index.esm.js.map +1 -0
- package/dist/index.js +460 -0
- package/dist/index.js.map +1 -0
- package/dist/index.min.js +2 -0
- package/dist/index.min.js.map +1 -0
- package/dist/meta.esm.js +292 -0
- package/dist/meta.esm.js.map +1 -0
- package/dist/meta.js +303 -0
- package/dist/meta.js.map +1 -0
- package/dist/meta.min.js +2 -0
- package/dist/meta.min.js.map +1 -0
- package/dist/src/component.d.ts +23 -0
- package/dist/src/configure.d.ts +7 -0
- package/dist/src/constants.d.ts +16 -0
- package/dist/src/index.d.ts +6 -0
- package/dist/src/meta.d.ts +7 -0
- package/dist/src/snippets.d.ts +7 -0
- package/package.json +68 -0
- package/rollup.config.js +222 -0
- package/src/component.module.css +104 -0
- package/src/component.tsx +140 -0
- package/src/configure.ts +247 -0
- package/src/constants.ts +18 -0
- package/src/index.tsx +7 -0
- package/src/meta.ts +28 -0
- package/src/snippets.ts +50 -0
- package/src/type.d.ts +8 -0
- package/tsconfig.build.json +12 -0
- package/tsconfig.json +9 -0
- package/tsconfig.test.json +7 -0
- package/vite.config.ts +54 -0
package/src/configure.ts
ADDED
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Audio Configure
|
|
3
|
+
* 音频组件配置
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import type { Configure } from '@easy-editor/core'
|
|
7
|
+
import type { UploadValue } from '@easy-editor/materials-shared'
|
|
8
|
+
|
|
9
|
+
export const configure: Configure = {
|
|
10
|
+
props: [
|
|
11
|
+
{
|
|
12
|
+
type: 'group',
|
|
13
|
+
title: '属性',
|
|
14
|
+
setter: 'TabSetter',
|
|
15
|
+
items: [
|
|
16
|
+
{
|
|
17
|
+
type: 'group',
|
|
18
|
+
key: 'config',
|
|
19
|
+
title: '配置',
|
|
20
|
+
setter: {
|
|
21
|
+
componentName: 'CollapseSetter',
|
|
22
|
+
props: {
|
|
23
|
+
icon: false,
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
items: [
|
|
27
|
+
// 基础配置
|
|
28
|
+
{
|
|
29
|
+
name: 'id',
|
|
30
|
+
title: 'ID',
|
|
31
|
+
setter: 'NodeIdSetter',
|
|
32
|
+
extraProps: {
|
|
33
|
+
// @ts-expect-error label is not a valid extra prop
|
|
34
|
+
label: false,
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
name: 'title',
|
|
39
|
+
title: '标题',
|
|
40
|
+
setter: 'StringSetter',
|
|
41
|
+
extraProps: {
|
|
42
|
+
getValue(target) {
|
|
43
|
+
return target.getExtraPropValue('title')
|
|
44
|
+
},
|
|
45
|
+
setValue(target, value) {
|
|
46
|
+
target.setExtraPropValue('title', value)
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
type: 'group',
|
|
52
|
+
title: '基础属性',
|
|
53
|
+
setter: {
|
|
54
|
+
componentName: 'CollapseSetter',
|
|
55
|
+
props: {
|
|
56
|
+
icon: false,
|
|
57
|
+
},
|
|
58
|
+
},
|
|
59
|
+
items: [
|
|
60
|
+
{
|
|
61
|
+
name: 'rect',
|
|
62
|
+
title: '位置尺寸',
|
|
63
|
+
setter: 'RectSetter',
|
|
64
|
+
extraProps: {
|
|
65
|
+
getValue(target) {
|
|
66
|
+
return target.getExtraPropValue('$dashboard.rect')
|
|
67
|
+
},
|
|
68
|
+
setValue(target, value) {
|
|
69
|
+
target.setExtraPropValue('$dashboard.rect', value)
|
|
70
|
+
},
|
|
71
|
+
},
|
|
72
|
+
},
|
|
73
|
+
],
|
|
74
|
+
},
|
|
75
|
+
// 组件配置
|
|
76
|
+
{
|
|
77
|
+
type: 'group',
|
|
78
|
+
title: '内容',
|
|
79
|
+
setter: {
|
|
80
|
+
componentName: 'CollapseSetter',
|
|
81
|
+
props: {
|
|
82
|
+
icon: false,
|
|
83
|
+
},
|
|
84
|
+
},
|
|
85
|
+
items: [
|
|
86
|
+
{
|
|
87
|
+
name: '__upload',
|
|
88
|
+
title: '上传',
|
|
89
|
+
setter: {
|
|
90
|
+
componentName: 'UploadSetter',
|
|
91
|
+
props: {
|
|
92
|
+
accept: '.mp3,.wav,.ogg',
|
|
93
|
+
},
|
|
94
|
+
},
|
|
95
|
+
extraProps: {
|
|
96
|
+
setValue(target, value: UploadValue) {
|
|
97
|
+
if (value) {
|
|
98
|
+
const { base64, raw } = value
|
|
99
|
+
if (base64) {
|
|
100
|
+
target.parent.setPropValue('src', base64)
|
|
101
|
+
}
|
|
102
|
+
if (raw?.width) {
|
|
103
|
+
target.parent.setExtraPropValue('$dashboard.rect.width', raw.width)
|
|
104
|
+
}
|
|
105
|
+
if (raw?.height) {
|
|
106
|
+
target.parent.setExtraPropValue('$dashboard.rect.height', raw.height)
|
|
107
|
+
}
|
|
108
|
+
} else {
|
|
109
|
+
target.parent.clearPropValue('src')
|
|
110
|
+
}
|
|
111
|
+
},
|
|
112
|
+
},
|
|
113
|
+
},
|
|
114
|
+
{
|
|
115
|
+
name: 'src',
|
|
116
|
+
title: '音频地址',
|
|
117
|
+
setter: 'StringSetter',
|
|
118
|
+
},
|
|
119
|
+
{
|
|
120
|
+
name: 'title',
|
|
121
|
+
title: '标题',
|
|
122
|
+
setter: 'StringSetter',
|
|
123
|
+
extraProps: {
|
|
124
|
+
defaultValue: '音频文件',
|
|
125
|
+
},
|
|
126
|
+
},
|
|
127
|
+
],
|
|
128
|
+
},
|
|
129
|
+
{
|
|
130
|
+
type: 'group',
|
|
131
|
+
title: '播放',
|
|
132
|
+
setter: {
|
|
133
|
+
componentName: 'CollapseSetter',
|
|
134
|
+
props: {
|
|
135
|
+
icon: false,
|
|
136
|
+
},
|
|
137
|
+
},
|
|
138
|
+
items: [
|
|
139
|
+
{
|
|
140
|
+
name: 'autoPlay',
|
|
141
|
+
title: '自动播放',
|
|
142
|
+
setter: 'SwitchSetter',
|
|
143
|
+
extraProps: {
|
|
144
|
+
defaultValue: false,
|
|
145
|
+
},
|
|
146
|
+
},
|
|
147
|
+
{
|
|
148
|
+
name: 'loop',
|
|
149
|
+
title: '循环播放',
|
|
150
|
+
setter: 'SwitchSetter',
|
|
151
|
+
extraProps: {
|
|
152
|
+
defaultValue: false,
|
|
153
|
+
},
|
|
154
|
+
},
|
|
155
|
+
{
|
|
156
|
+
name: 'audioStyle',
|
|
157
|
+
title: '样式类型',
|
|
158
|
+
setter: {
|
|
159
|
+
componentName: 'SelectSetter',
|
|
160
|
+
props: {
|
|
161
|
+
options: [
|
|
162
|
+
{ label: '自定义', value: 'custom' },
|
|
163
|
+
{ label: '原生', value: 'native' },
|
|
164
|
+
],
|
|
165
|
+
},
|
|
166
|
+
},
|
|
167
|
+
extraProps: {
|
|
168
|
+
defaultValue: 'custom',
|
|
169
|
+
},
|
|
170
|
+
},
|
|
171
|
+
{
|
|
172
|
+
name: 'playbackRate',
|
|
173
|
+
title: '播放速度',
|
|
174
|
+
setter: {
|
|
175
|
+
componentName: 'SelectSetter',
|
|
176
|
+
props: {
|
|
177
|
+
options: [
|
|
178
|
+
{ label: '0.5x', value: 0.5 },
|
|
179
|
+
{ label: '0.75x', value: 0.75 },
|
|
180
|
+
{ label: '1x (正常)', value: 1 },
|
|
181
|
+
{ label: '1.25x', value: 1.25 },
|
|
182
|
+
{ label: '1.5x', value: 1.5 },
|
|
183
|
+
{ label: '2x', value: 2 },
|
|
184
|
+
],
|
|
185
|
+
},
|
|
186
|
+
},
|
|
187
|
+
extraProps: {
|
|
188
|
+
defaultValue: 1,
|
|
189
|
+
},
|
|
190
|
+
},
|
|
191
|
+
{
|
|
192
|
+
name: 'volume',
|
|
193
|
+
title: '音量',
|
|
194
|
+
setter: {
|
|
195
|
+
componentName: 'SliderSetter',
|
|
196
|
+
props: {
|
|
197
|
+
min: 0,
|
|
198
|
+
max: 100,
|
|
199
|
+
step: 1,
|
|
200
|
+
suffix: '%',
|
|
201
|
+
},
|
|
202
|
+
},
|
|
203
|
+
extraProps: {
|
|
204
|
+
defaultValue: 100,
|
|
205
|
+
},
|
|
206
|
+
},
|
|
207
|
+
],
|
|
208
|
+
},
|
|
209
|
+
],
|
|
210
|
+
},
|
|
211
|
+
{
|
|
212
|
+
type: 'group',
|
|
213
|
+
key: 'data',
|
|
214
|
+
title: '数据',
|
|
215
|
+
items: [
|
|
216
|
+
{
|
|
217
|
+
name: 'dataBinding',
|
|
218
|
+
title: '数据绑定',
|
|
219
|
+
setter: 'DataBindingSetter',
|
|
220
|
+
},
|
|
221
|
+
],
|
|
222
|
+
},
|
|
223
|
+
{
|
|
224
|
+
type: 'group',
|
|
225
|
+
key: 'advanced',
|
|
226
|
+
title: '高级',
|
|
227
|
+
items: [
|
|
228
|
+
{
|
|
229
|
+
name: 'condition',
|
|
230
|
+
title: '显隐控制',
|
|
231
|
+
setter: 'SwitchSetter',
|
|
232
|
+
extraProps: {
|
|
233
|
+
defaultValue: true,
|
|
234
|
+
supportVariable: true,
|
|
235
|
+
},
|
|
236
|
+
},
|
|
237
|
+
],
|
|
238
|
+
},
|
|
239
|
+
],
|
|
240
|
+
},
|
|
241
|
+
],
|
|
242
|
+
component: {},
|
|
243
|
+
supports: {},
|
|
244
|
+
advanced: {},
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
export default configure
|
package/src/constants.ts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 物料常量配置
|
|
3
|
+
* 统一管理全局变量名等配置,确保 meta.ts 和 rollup.config.js 使用相同的值
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* UMD 全局变量基础名称
|
|
8
|
+
* 用于构建:
|
|
9
|
+
* - 元数据:${GLOBAL_NAME}Meta (例如: EasyEditorMaterialsAudioMeta)
|
|
10
|
+
* - 组件:${GLOBAL_NAME}Component (例如: EasyEditorMaterialsAudioComponent)
|
|
11
|
+
* - 完整构建:${GLOBAL_NAME} (例如: EasyEditorMaterialsAudio)
|
|
12
|
+
*/
|
|
13
|
+
export const COMPONENT_NAME = 'EasyEditorMaterialsAudio'
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* 包名
|
|
17
|
+
*/
|
|
18
|
+
export const PACKAGE_NAME = '@easy-editor/materials-dashboard-audio'
|
package/src/index.tsx
ADDED
package/src/meta.ts
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Audio Meta
|
|
3
|
+
* 音频组件元数据
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import type { ComponentMetadata } from '@easy-editor/core'
|
|
7
|
+
import { MaterialGroup } from '@easy-editor/materials-shared'
|
|
8
|
+
import { COMPONENT_NAME, PACKAGE_NAME } from './constants'
|
|
9
|
+
import configure from './configure'
|
|
10
|
+
import snippets from './snippets'
|
|
11
|
+
import pkg from '../package.json'
|
|
12
|
+
|
|
13
|
+
export const meta: ComponentMetadata = {
|
|
14
|
+
componentName: COMPONENT_NAME,
|
|
15
|
+
title: '音频',
|
|
16
|
+
group: MaterialGroup.MEDIA,
|
|
17
|
+
devMode: 'proCode',
|
|
18
|
+
npm: {
|
|
19
|
+
package: PACKAGE_NAME,
|
|
20
|
+
version: pkg.version,
|
|
21
|
+
globalName: COMPONENT_NAME,
|
|
22
|
+
componentName: COMPONENT_NAME,
|
|
23
|
+
},
|
|
24
|
+
snippets,
|
|
25
|
+
configure,
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export default meta
|
package/src/snippets.ts
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Audio Snippets
|
|
3
|
+
* 音频组件代码片段
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import type { Snippet } from '@easy-editor/core'
|
|
7
|
+
import { COMPONENT_NAME } from './constants'
|
|
8
|
+
|
|
9
|
+
export const snippets: Snippet[] = [
|
|
10
|
+
{
|
|
11
|
+
title: '音频播放器',
|
|
12
|
+
screenshot: '',
|
|
13
|
+
schema: {
|
|
14
|
+
componentName: COMPONENT_NAME,
|
|
15
|
+
props: {
|
|
16
|
+
src: '',
|
|
17
|
+
title: '音频文件',
|
|
18
|
+
autoPlay: false,
|
|
19
|
+
loop: false,
|
|
20
|
+
audioStyle: 'custom',
|
|
21
|
+
},
|
|
22
|
+
$dashboard: {
|
|
23
|
+
rect: {
|
|
24
|
+
width: 300,
|
|
25
|
+
height: 60,
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
title: '原生音频',
|
|
32
|
+
screenshot: '',
|
|
33
|
+
schema: {
|
|
34
|
+
componentName: COMPONENT_NAME,
|
|
35
|
+
props: {
|
|
36
|
+
src: '',
|
|
37
|
+
title: '音频文件',
|
|
38
|
+
audioStyle: 'native',
|
|
39
|
+
},
|
|
40
|
+
$dashboard: {
|
|
41
|
+
rect: {
|
|
42
|
+
width: 300,
|
|
43
|
+
height: 60,
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
]
|
|
49
|
+
|
|
50
|
+
export default snippets
|
package/src/type.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": "../../../../tsconfig.json",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"jsx": "react-jsx",
|
|
5
|
+
"strictPropertyInitialization": false,
|
|
6
|
+
"outDir": "./dist",
|
|
7
|
+
"skipLibCheck": true,
|
|
8
|
+
"esModuleInterop": true,
|
|
9
|
+
"allowSyntheticDefaultImports": true
|
|
10
|
+
},
|
|
11
|
+
"include": ["./src"]
|
|
12
|
+
}
|
package/tsconfig.json
ADDED
package/vite.config.ts
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Vite Configuration for Material Development
|
|
3
|
+
* 物料开发 Vite 配置
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { defineConfig } from 'vite'
|
|
7
|
+
import react from '@vitejs/plugin-react'
|
|
8
|
+
import { materialDevPlugin } from './.vite/plugins/vite-plugin-material-dev'
|
|
9
|
+
import { externalDeps } from './.vite/plugins/vite-plugin-external-deps'
|
|
10
|
+
|
|
11
|
+
export default defineConfig({
|
|
12
|
+
plugins: [
|
|
13
|
+
react(),
|
|
14
|
+
// 外部化 React/ReactDOM,使用父应用提供的实例
|
|
15
|
+
externalDeps({
|
|
16
|
+
externals: ['react', 'react-dom', 'react/jsx-runtime', '@easy-editor/core'],
|
|
17
|
+
globals: {
|
|
18
|
+
react: 'React',
|
|
19
|
+
'react-dom': 'ReactDOM',
|
|
20
|
+
'react/jsx-runtime': 'jsxRuntime',
|
|
21
|
+
'@easy-editor/core': 'EasyEditorCore',
|
|
22
|
+
},
|
|
23
|
+
}),
|
|
24
|
+
materialDevPlugin({
|
|
25
|
+
entry: '/src/index.tsx',
|
|
26
|
+
}),
|
|
27
|
+
],
|
|
28
|
+
server: {
|
|
29
|
+
port: 5001,
|
|
30
|
+
host: 'localhost',
|
|
31
|
+
cors: true,
|
|
32
|
+
hmr: {
|
|
33
|
+
port: 5001,
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
build: {
|
|
37
|
+
target: 'esnext',
|
|
38
|
+
rollupOptions: {
|
|
39
|
+
// 确保生产构建也外部化这些依赖
|
|
40
|
+
external: ['react', 'react-dom', 'react/jsx-runtime', '@easy-editor/core'],
|
|
41
|
+
output: {
|
|
42
|
+
globals: {
|
|
43
|
+
react: 'React',
|
|
44
|
+
'react-dom': 'ReactDOM',
|
|
45
|
+
'react/jsx-runtime': 'jsxRuntime',
|
|
46
|
+
'@easy-editor/core': 'EasyEditorCore',
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
resolve: {
|
|
52
|
+
dedupe: ['react', 'react-dom'],
|
|
53
|
+
},
|
|
54
|
+
})
|