@easy-editor/materials-dashboard-text 0.0.14 → 0.0.16

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.
@@ -0,0 +1,384 @@
1
+ /**
2
+ * Text Configure
3
+ * 文本组件配置 - 使用新的三 Tab 结构
4
+ */
5
+
6
+ import type { Configure, FieldConfig } from '@easy-editor/core'
7
+
8
+ /** 创建折叠组配置 */
9
+ const createCollapseGroup = (title: string, items: FieldConfig[], props?: Record<string, unknown>): FieldConfig => ({
10
+ type: 'group',
11
+ title,
12
+ setter: {
13
+ componentName: 'CollapseSetter',
14
+ props: {
15
+ icon: false,
16
+ ...props,
17
+ },
18
+ },
19
+ items,
20
+ })
21
+
22
+ const globalConfigGroup: FieldConfig = {
23
+ name: 'nodeInfo',
24
+ title: '节点信息',
25
+ setter: 'NodeInfoSetter',
26
+ extraProps: {
27
+ // @ts-expect-error label is not a valid extra prop
28
+ label: false,
29
+ },
30
+ }
31
+
32
+ /** 基础配置 - 所有组件通用 */
33
+ const basicConfigGroup: FieldConfig = createCollapseGroup('基础配置', [
34
+ {
35
+ name: 'title',
36
+ title: '标题',
37
+ setter: 'StringSetter',
38
+ extraProps: {
39
+ getValue(target) {
40
+ return target.getExtraPropValue('title')
41
+ },
42
+ setValue(target, value) {
43
+ target.setExtraPropValue('title', value)
44
+ },
45
+ },
46
+ },
47
+ {
48
+ name: 'rect',
49
+ title: '位置尺寸',
50
+ setter: 'RectSetter',
51
+ extraProps: {
52
+ getValue(target) {
53
+ return target.getExtraPropValue('$dashboard.rect')
54
+ },
55
+ setValue(target, value) {
56
+ target.setExtraPropValue('$dashboard.rect', value)
57
+ },
58
+ },
59
+ },
60
+ {
61
+ name: 'rotation',
62
+ title: '旋转角度',
63
+ setter: {
64
+ componentName: 'SliderSetter',
65
+ props: {
66
+ min: 0,
67
+ max: 360,
68
+ suffix: '°',
69
+ },
70
+ },
71
+ extraProps: {
72
+ defaultValue: 0,
73
+ },
74
+ },
75
+ {
76
+ name: 'opacity',
77
+ title: '不透明度',
78
+ setter: {
79
+ componentName: 'SliderSetter',
80
+ props: {
81
+ min: 0,
82
+ max: 100,
83
+ suffix: '%',
84
+ },
85
+ },
86
+ extraProps: {
87
+ defaultValue: 100,
88
+ },
89
+ },
90
+ {
91
+ name: 'background',
92
+ title: '背景颜色',
93
+ setter: 'ColorSetter',
94
+ extraProps: {
95
+ defaultValue: 'transparent',
96
+ },
97
+ },
98
+ ])
99
+
100
+ /** 组件配置 - 文本组件独有 */
101
+ const componentConfigGroup: FieldConfig = createCollapseGroup(
102
+ '组件配置',
103
+ [
104
+ {
105
+ type: 'group',
106
+ title: '组件配置',
107
+ setter: 'SubTabSetter',
108
+ items: [
109
+ // 内容 Tab
110
+ {
111
+ type: 'group',
112
+ key: 'content',
113
+ title: '内容',
114
+ items: [
115
+ {
116
+ name: 'isLink',
117
+ title: '作为链接',
118
+ setter: 'SwitchSetter',
119
+ extraProps: {
120
+ defaultValue: false,
121
+ },
122
+ },
123
+ {
124
+ name: 'href',
125
+ title: '链接地址',
126
+ setter: 'StringSetter',
127
+ },
128
+ {
129
+ name: 'target',
130
+ title: '打开方式',
131
+ setter: {
132
+ componentName: 'SelectSetter',
133
+ props: {
134
+ options: [
135
+ { label: '新窗口', value: '_blank' },
136
+ { label: '当前窗口', value: '_self' },
137
+ ],
138
+ },
139
+ },
140
+ extraProps: {
141
+ defaultValue: '_blank',
142
+ },
143
+ },
144
+ ],
145
+ },
146
+ // 字体 Tab
147
+ {
148
+ type: 'group',
149
+ key: 'font',
150
+ title: '字体',
151
+ items: [
152
+ {
153
+ name: 'fontSize',
154
+ title: '字体大小',
155
+ setter: 'NumberSetter',
156
+ extraProps: {
157
+ defaultValue: 16,
158
+ },
159
+ },
160
+ {
161
+ name: 'fontWeight',
162
+ title: '字体粗细',
163
+ setter: {
164
+ componentName: 'SelectSetter',
165
+ props: {
166
+ options: [
167
+ { label: '正常', value: 'normal' },
168
+ { label: '粗体', value: 'bold' },
169
+ ],
170
+ },
171
+ },
172
+ extraProps: {
173
+ defaultValue: 'normal',
174
+ },
175
+ },
176
+ {
177
+ name: 'color',
178
+ title: '颜色',
179
+ setter: 'ColorSetter',
180
+ extraProps: {
181
+ defaultValue: '#ffffff',
182
+ },
183
+ },
184
+ {
185
+ name: 'lineHeight',
186
+ title: '行高',
187
+ setter: 'NumberSetter',
188
+ extraProps: {
189
+ defaultValue: 1.5,
190
+ },
191
+ },
192
+ ],
193
+ },
194
+ // 对齐 Tab
195
+ {
196
+ type: 'group',
197
+ key: 'align',
198
+ title: '对齐',
199
+ items: [
200
+ {
201
+ name: 'textAlign',
202
+ title: '水平对齐',
203
+ setter: {
204
+ componentName: 'SegmentedSetter',
205
+ props: {
206
+ options: [
207
+ { label: '左', value: 'left' },
208
+ { label: '中', value: 'center' },
209
+ { label: '右', value: 'right' },
210
+ ],
211
+ },
212
+ },
213
+ extraProps: {
214
+ defaultValue: 'left',
215
+ },
216
+ },
217
+ {
218
+ name: 'verticalAlign',
219
+ title: '垂直对齐',
220
+ setter: {
221
+ componentName: 'SegmentedSetter',
222
+ props: {
223
+ options: [
224
+ { label: '上', value: 'top' },
225
+ { label: '中', value: 'middle' },
226
+ { label: '下', value: 'bottom' },
227
+ ],
228
+ },
229
+ },
230
+ extraProps: {
231
+ defaultValue: 'middle',
232
+ },
233
+ },
234
+ ],
235
+ },
236
+ // 效果 Tab
237
+ {
238
+ type: 'group',
239
+ key: 'effect',
240
+ title: '效果',
241
+ items: [
242
+ {
243
+ name: 'underline',
244
+ title: '下划线',
245
+ setter: 'SwitchSetter',
246
+ extraProps: {
247
+ defaultValue: false,
248
+ },
249
+ },
250
+ {
251
+ name: 'glowEnable',
252
+ title: '发光效果',
253
+ setter: 'SwitchSetter',
254
+ extraProps: {
255
+ defaultValue: false,
256
+ },
257
+ },
258
+ {
259
+ name: 'glowColor',
260
+ title: '发光颜色',
261
+ setter: 'ColorSetter',
262
+ extraProps: {
263
+ defaultValue: '#00d4ff',
264
+ },
265
+ },
266
+ ],
267
+ },
268
+ ],
269
+ },
270
+ ],
271
+ {
272
+ padding: '6px 16px 12px',
273
+ },
274
+ )
275
+
276
+ /** 数据配置 */
277
+ const dataConfigGroup: FieldConfig = {
278
+ name: '$data',
279
+ title: '数据配置',
280
+ setter: {
281
+ componentName: 'DataSetter',
282
+ props: {
283
+ expectedFields: [
284
+ { name: 'text', label: 'text', type: 'string', required: true, description: '文本内容' },
285
+ ],
286
+ showPreview: true,
287
+ previewLimit: 10,
288
+ },
289
+ },
290
+ extraProps: {
291
+ // @ts-ignore
292
+ label: false,
293
+ },
294
+ }
295
+
296
+ /** 事件绑定配置 */
297
+ const eventConfigGroup: FieldConfig = createCollapseGroup('事件绑定', [
298
+ {
299
+ name: 'events',
300
+ title: '事件',
301
+ setter: {
302
+ componentName: 'EventSetter',
303
+ props: {
304
+ events: [
305
+ {
306
+ title: '点击事件',
307
+ children: [
308
+ { label: '点击', value: 'onClick', description: '鼠标点击时触发' },
309
+ { label: '双击', value: 'onDoubleClick', description: '鼠标双击时触发' },
310
+ ],
311
+ },
312
+ {
313
+ title: '鼠标事件',
314
+ children: [
315
+ { label: '鼠标进入', value: 'onMouseEnter', description: '鼠标进入时触发' },
316
+ { label: '鼠标离开', value: 'onMouseLeave', description: '鼠标离开时触发' },
317
+ ],
318
+ },
319
+ ],
320
+ },
321
+ },
322
+ },
323
+ ])
324
+
325
+ /** 高级配置 */
326
+ const advancedConfigGroup: FieldConfig = createCollapseGroup('高级配置', [
327
+ {
328
+ title: '条件渲染',
329
+ setter: 'SwitchSetter',
330
+ extraProps: {
331
+ supportVariable: true,
332
+ getValue(target) {
333
+ return target.getNode().getExtraPropValue('condition')
334
+ },
335
+ setValue(target, value: boolean) {
336
+ target.getNode().setExtraProp('condition', value)
337
+ },
338
+ },
339
+ },
340
+ // {
341
+ // name: 'loop',
342
+ // title: '循环渲染',
343
+ // setter: 'SwitchSetter',
344
+ // extraProps: {
345
+ // defaultValue: false,
346
+ // },
347
+ // },
348
+ ])
349
+
350
+ export const configure: Configure = {
351
+ props: [
352
+ {
353
+ type: 'group',
354
+ title: '属性',
355
+ setter: 'TabSetter',
356
+ items: [
357
+ // 配置 Tab
358
+ {
359
+ type: 'group',
360
+ key: 'config',
361
+ title: '配置',
362
+ items: [globalConfigGroup, basicConfigGroup, componentConfigGroup],
363
+ },
364
+ // 数据 Tab
365
+ {
366
+ type: 'group',
367
+ key: 'data',
368
+ title: '数据',
369
+ items: [globalConfigGroup, dataConfigGroup],
370
+ },
371
+ // 高级 Tab
372
+ {
373
+ type: 'group',
374
+ key: 'advanced',
375
+ title: '高级',
376
+ items: [globalConfigGroup, eventConfigGroup, advancedConfigGroup],
377
+ },
378
+ ],
379
+ },
380
+ ],
381
+ component: {},
382
+ supports: {},
383
+ advanced: {},
384
+ }
@@ -1,16 +1,17 @@
1
- /**
2
- * 物料常量配置
3
- * 统一管理全局变量名等配置,确保 meta.ts 和 rollup.config.js 使用相同的值
4
- */
5
- /**
6
- * UMD 全局变量基础名称
7
- * 用于构建:
8
- * - 元数据:${GLOBAL_NAME}Meta (例如: EasyEditorMaterialsTextMeta)
9
- * - 组件:${GLOBAL_NAME}Component (例如: EasyEditorMaterialsTextComponent)
10
- * - 完整构建:${GLOBAL_NAME} (例如: EasyEditorMaterialsText)
11
- */
12
- export declare const COMPONENT_NAME = "EasyEditorMaterialsText";
13
- /**
14
- * 包名
15
- */
16
- export declare const PACKAGE_NAME = "@easy-editor/materials-dashboard-text";
1
+ /**
2
+ * 物料常量配置
3
+ */
4
+
5
+ /**
6
+ * UMD 全局变量基础名称
7
+ * 用于构建:
8
+ * - 元数据:${GLOBAL_NAME}Meta (例如: EasyEditorMaterialsTextMeta)
9
+ * - 组件:${GLOBAL_NAME}Component (例如: EasyEditorMaterialsTextComponent)
10
+ * - 完整构建:${GLOBAL_NAME} (例如: EasyEditorMaterialsText)
11
+ */
12
+ export const COMPONENT_NAME = 'EasyEditorMaterialsText'
13
+
14
+ /**
15
+ * 包名
16
+ */
17
+ export const PACKAGE_NAME = '@easy-editor/materials-dashboard-text'
package/src/index.tsx ADDED
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Text Entry
3
+ * 文本组件入口
4
+ */
5
+
6
+ export { Text as component } from './component'
7
+ export { meta } from './meta'
package/src/meta.ts ADDED
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Text Meta
3
+ * 文本组件元数据
4
+ */
5
+
6
+ import type { ComponentMetadata } from '@easy-editor/core'
7
+ import { configure } from './configure'
8
+ import { snippets } from './snippets'
9
+ import { COMPONENT_NAME, PACKAGE_NAME } from './constants'
10
+ import { MaterialGroup } from '@easy-editor/materials-shared'
11
+ import pkg from '../package.json'
12
+
13
+ export const meta: ComponentMetadata = {
14
+ componentName: COMPONENT_NAME,
15
+ title: '文本',
16
+ group: MaterialGroup.BASIC,
17
+ devMode: 'proCode',
18
+ npm: {
19
+ package: PACKAGE_NAME,
20
+ version: pkg.version,
21
+ globalName: COMPONENT_NAME,
22
+ componentName: COMPONENT_NAME,
23
+ },
24
+ configure,
25
+ snippets,
26
+ }
@@ -0,0 +1,151 @@
1
+ /**
2
+ * Text Snippets
3
+ * 文本组件代码片段
4
+ */
5
+
6
+ import type { Snippet } from '@easy-editor/core'
7
+ import { COMPONENT_NAME } from './constants'
8
+
9
+ // 生成静态数据源
10
+ const generateStaticDataSource = (text: string) => {
11
+ return {
12
+ sourceType: "static",
13
+ staticData: [
14
+ {
15
+ text: "发光标题"
16
+ }
17
+ ],
18
+ fieldMappings: [
19
+ {
20
+ componentField: "text",
21
+ sourceField: "text"
22
+ }
23
+ ]
24
+ }
25
+ }
26
+
27
+ export const snippets: Snippet[] = [
28
+ {
29
+ title: '普通文本',
30
+ screenshot: '',
31
+ schema: {
32
+ componentName: COMPONENT_NAME,
33
+ title: '普通文本',
34
+ props: {
35
+ fontSize: 16,
36
+ color: '#ffffff',
37
+ rotation: 0,
38
+ opacity: 100,
39
+ background: 'transparent',
40
+ $data: generateStaticDataSource('普通文本'),
41
+ },
42
+ $dashboard: {
43
+ rect: {
44
+ width: 120,
45
+ height: 40,
46
+ },
47
+ },
48
+ },
49
+ },
50
+ {
51
+ title: '标题文本',
52
+ screenshot: '',
53
+ schema: {
54
+ componentName: COMPONENT_NAME,
55
+ title: '标题文本',
56
+ props: {
57
+ fontSize: 32,
58
+ fontWeight: 'bold',
59
+ color: '#ffffff',
60
+ textAlign: 'center',
61
+ rotation: 0,
62
+ opacity: 100,
63
+ background: 'transparent',
64
+ $data: generateStaticDataSource('标题文本'),
65
+ },
66
+ $dashboard: {
67
+ rect: {
68
+ width: 200,
69
+ height: 60,
70
+ },
71
+ },
72
+ },
73
+ },
74
+ {
75
+ title: '发光标题',
76
+ screenshot: '',
77
+ schema: {
78
+ componentName: COMPONENT_NAME,
79
+ title: '发光标题',
80
+ props: {
81
+ fontSize: 36,
82
+ fontWeight: 'bold',
83
+ color: '#00d4ff',
84
+ textAlign: 'center',
85
+ glowEnable: true,
86
+ glowColor: '#00d4ff',
87
+ glowIntensity: 1.5,
88
+ rotation: 0,
89
+ opacity: 100,
90
+ background: 'transparent',
91
+ $data: generateStaticDataSource('发光标题')
92
+ },
93
+ $dashboard: {
94
+ rect: {
95
+ width: 240,
96
+ height: 80,
97
+ },
98
+ },
99
+ },
100
+ },
101
+ {
102
+ title: '链接文本',
103
+ screenshot: '',
104
+ schema: {
105
+ componentName: COMPONENT_NAME,
106
+ title: '链接文本',
107
+ props: {
108
+ fontSize: 16,
109
+ color: '#00d4ff',
110
+ isLink: true,
111
+ href: 'https://easy-editor-docs.vercel.app/',
112
+ target: '_blank',
113
+ underline: true,
114
+ rotation: 0,
115
+ opacity: 100,
116
+ background: 'transparent',
117
+ $data: generateStaticDataSource('点击跳转'),
118
+ },
119
+ $dashboard: {
120
+ rect: {
121
+ width: 120,
122
+ height: 40,
123
+ },
124
+ },
125
+ },
126
+ },
127
+ {
128
+ title: '标签文本',
129
+ screenshot: '',
130
+ schema: {
131
+ componentName: COMPONENT_NAME,
132
+ title: '标签文本',
133
+ props: {
134
+ content: '标签',
135
+ fontSize: 14,
136
+ color: '#ffffff',
137
+ textAlign: 'center',
138
+ verticalAlign: 'middle',
139
+ rotation: 0,
140
+ opacity: 100,
141
+ background: 'rgba(0, 212, 255, 0.2)',
142
+ },
143
+ $dashboard: {
144
+ rect: {
145
+ width: 80,
146
+ height: 32,
147
+ },
148
+ },
149
+ },
150
+ },
151
+ ]
package/src/type.d.ts ADDED
@@ -0,0 +1,8 @@
1
+ /**
2
+ * CSS Modules Type Declarations
3
+ */
4
+
5
+ declare module '*.module.css' {
6
+ const classes: { readonly [key: string]: string }
7
+ export default classes
8
+ }
package/tsconfig.json CHANGED
@@ -1,9 +1,20 @@
1
- {
2
- "compilerOptions": {
3
- "jsx": "react-jsx",
4
- "esModuleInterop": true,
5
- "allowSyntheticDefaultImports": true
6
- },
7
- "extends": "./tsconfig.build.json",
8
- "include": ["./src", "./test"]
9
- }
1
+ {
2
+ "compilerOptions": {
3
+ "emitDeclarationOnly": true,
4
+ "declaration": true,
5
+ "target": "ESNext",
6
+ "newLine": "LF",
7
+ "module": "ESNext",
8
+ "moduleResolution": "Bundler",
9
+ "strict": true,
10
+ "strictNullChecks": true,
11
+ "jsx": "react-jsx",
12
+ "esModuleInterop": true,
13
+ "allowSyntheticDefaultImports": true,
14
+ "strictPropertyInitialization": false,
15
+ "outDir": "./dist",
16
+ "skipLibCheck": true,
17
+ },
18
+ "exclude": ["node_modules", "dist"],
19
+ "include": ["./src"]
20
+ }