grapes-vue-lite 0.1.21 → 0.1.23

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 CHANGED
@@ -262,21 +262,196 @@ Example local `.json` file:
262
262
  }
263
263
  ```
264
264
 
265
+ Supported local component JSON shapes:
266
+
267
+ 1. Standard `ComponentLibraryItemInput` object
268
+
269
+ ```json
270
+ {
271
+ "id": "hero-card",
272
+ "name": "Hero Card",
273
+ "cnName": "英雄卡片",
274
+ "description": "Reusable marketing hero",
275
+ "category": "Marketing",
276
+ "tags": ["hero", "banner"],
277
+ "previewSrc": "https://cdn.example.com/previews/hero-card.png",
278
+ "block": {
279
+ "type": "section",
280
+ "name": "Hero Card",
281
+ "children": [
282
+ {
283
+ "type": "heading",
284
+ "text": "Hero Card"
285
+ },
286
+ {
287
+ "type": "text",
288
+ "text": "Imported from a local JSON component file."
289
+ }
290
+ ]
291
+ }
292
+ }
293
+ ```
294
+
295
+ 2. Raw `ComponentNodeInput` object
296
+
297
+ ```json
298
+ {
299
+ "type": "section",
300
+ "name": "Simple Hero",
301
+ "children": [
302
+ {
303
+ "type": "heading",
304
+ "text": "Simple Hero"
305
+ },
306
+ {
307
+ "type": "text",
308
+ "text": "This file is a raw component node."
309
+ }
310
+ ]
311
+ }
312
+ ```
313
+
314
+ When the root JSON value is a raw node object, the importer uses the filename as the fallback `id` and `name`.
315
+
316
+ 3. `BlockDefinition` object with declarative `content`
317
+
318
+ ```json
319
+ {
320
+ "id": "hero-block",
321
+ "label": "Hero Block",
322
+ "description": "Hero block definition",
323
+ "category": "Marketing",
324
+ "content": {
325
+ "type": "section",
326
+ "children": [
327
+ {
328
+ "type": "heading",
329
+ "text": "Hero Block"
330
+ }
331
+ ]
332
+ }
333
+ }
334
+ ```
335
+
336
+ 4. Array of any supported item shape
337
+
338
+ ```json
339
+ [
340
+ {
341
+ "id": "hero-card",
342
+ "name": "Hero Card",
343
+ "block": {
344
+ "type": "section",
345
+ "children": [
346
+ {
347
+ "type": "heading",
348
+ "text": "Hero Card"
349
+ }
350
+ ]
351
+ }
352
+ },
353
+ {
354
+ "id": "feature-grid",
355
+ "name": "Feature Grid",
356
+ "block": {
357
+ "type": "section",
358
+ "children": [
359
+ {
360
+ "type": "heading",
361
+ "text": "Feature Grid"
362
+ }
363
+ ]
364
+ }
365
+ }
366
+ ]
367
+ ```
368
+
369
+ 5. `svg` component node inside local component JSON
370
+
371
+ ```json
372
+ {
373
+ "id": "weather-icon",
374
+ "name": "Weather Icon",
375
+ "category": "Media",
376
+ "block": {
377
+ "type": "svg",
378
+ "name": "Weather Icon",
379
+ "attributes": {
380
+ "data-gv-svg": "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"32\" height=\"32\" viewBox=\"0 0 32 32\"><path fill=\"currentColor\" d=\"M17 19h4v4h-4zm-6 0h4v4h-4zm6 6h4v4h-4zm-6 0h4v4h-4z\"/><path fill=\"currentColor\" d=\"M24.5 25H24v-2h.5a5.496 5.496 0 0 0 .377-10.98l-.836-.056l-.09-.834a7.998 7.998 0 0 0-15.902 0l-.09.834l-.836.057A5.496 5.496 0 0 0 7.5 23H8v2h-.5a7.496 7.496 0 0 1-1.322-14.876a10 10 0 0 1 19.644 0A7.496 7.496 0 0 1 24.5 25\"/></svg>",
381
+ "aria-label": "Weather icon"
382
+ },
383
+ "style": {
384
+ "width": "64px",
385
+ "height": "64px",
386
+ "color": "#1f2520",
387
+ "display": "inline-flex",
388
+ "alignItems": "center",
389
+ "justifyContent": "center",
390
+ "lineHeight": "0"
391
+ }
392
+ }
393
+ }
394
+ ```
395
+
396
+ For local component JSON with SVG:
397
+
398
+ - use `type: "svg"`
399
+ - put the raw SVG string in `attributes["data-gv-svg"]`
400
+ - control scaling with `style.width` and `style.height`
401
+ - control color with `style.color`
402
+ - prefer `fill="currentColor"` or `stroke="currentColor"` inside the SVG markup
403
+ - hard-coded colors such as `fill="#000"` are not automatically rewritten
404
+
405
+ Recommended minimum fields for local component JSON:
406
+
407
+ - `id`
408
+ - `name`
409
+ - `block`
410
+
411
+ Where `block` should contain declarative component data instead of runtime functions.
412
+
413
+ See [docs/component-library-local-json.md](docs/component-library-local-json.md) for the full local component JSON protocol reference.
414
+
265
415
  Imported component library items are registered into the existing block system. When `persistImported` is enabled, they are also written into project JSON as `customBlocks` and restored when the project is loaded again.
266
416
 
267
417
  The built-in component library panel currently supports:
268
418
 
269
419
  - choosing local `.json` component files
270
420
  - browsing static or paged host-provided sources
271
- - search, category filtering, and load-more pagination
421
+ - per-source search, category filtering, and previous/next pagination
272
422
  - importing an item once and preventing duplicate imports in the browser view
273
423
  - inserting already imported items directly from the library browser
274
424
  - removing imported items from the local project library
275
425
 
276
426
  If a remote source request fails, the browser view exposes a retry action instead of silently failing. When no sources are configured, the panel renders an explicit empty state.
277
427
 
428
+ The built-in image library dialog follows the same paged-browser model for remote `assets.sources`: static sources render as immediate thumbnail grids, while paged sources render a fixed previous/next footer and switch pages instead of appending more thumbnails into the current view.
429
+
278
430
  The package treats `vue` as a peer dependency, so the host application owns the Vue runtime version.
279
431
 
432
+ ## SVG Block
433
+
434
+ The built-in block library includes an `SVG` block for inline icons or illustrations. It is designed for trusted SVG markup that you want to paste directly into the editor and scale on the canvas.
435
+
436
+ Current behavior:
437
+
438
+ - inserts a dedicated `svg` component block
439
+ - stores raw SVG markup in the `data-gv-svg` trait field
440
+ - renders inline SVG on the canvas with `v-html`
441
+ - scales through the component `width` and `height`
442
+ - changes color through the component `color`
443
+
444
+ Recommended SVG format:
445
+
446
+ ```svg
447
+ <svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">
448
+ <path fill="currentColor" d="M17 19h4v4h-4zm-6 0h4v4h-4zm6 6h4v4h-4zm-6 0h4v4h-4z"/>
449
+ <path fill="currentColor" d="M24.5 25H24v-2h.5a5.496 5.496 0 0 0 .377-10.98l-.836-.056l-.09-.834a7.998 7.998 0 0 0-15.902 0l-.09.834l-.836.057A5.496 5.496 0 0 0 7.5 23H8v2h-.5a7.496 7.496 0 0 1-1.322-14.876a10 10 0 0 1 19.644 0A7.496 7.496 0 0 1 24.5 25"/>
450
+ </svg>
451
+ ```
452
+
453
+ Color editing works best when the SVG uses `fill="currentColor"` or `stroke="currentColor"`. Hard-coded colors such as `fill="#000"` are not automatically rewritten by the editor.
454
+
280
455
  Hosts that own application theme state can control the editor theme with the dedicated `theme` prop. The prop accepts the same `ThemeInput` shape as `options.theme`, and updates are applied to the active editor instance without remounting:
281
456
 
282
457
  ```vue
@@ -582,7 +757,7 @@ const options: EditorOptions = {
582
757
  - `I18n`: English and Simplified Chinese UI messages with English as the default locale.
583
758
  - `Theme`: light/dark editor UI themes and host-provided design tokens.
584
759
  - `Assets`: image asset registry and image assignment.
585
- - `EditorOptions.assets.sources`: host-provided third-party image lists that appear in the left asset panel as selectable thumbnails.
760
+ - `EditorOptions.assets.sources`: host-provided third-party image lists that appear in the left asset panel as selectable thumbnails. Paged sources open in the built-in image library dialog with fixed previous/next pagination.
586
761
  - `EditorOptions.assets.allowManual`: keep or hide the manual URL entry form when the host wants only curated assets.
587
762
  - `Storage`: local and custom storage adapters.
588
763
  - `Commands`: command registry and shortcuts.