grapes-vue-lite 0.1.2 → 0.1.4

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
@@ -16,8 +16,7 @@ For local validation before publishing:
16
16
 
17
17
  ```bash
18
18
  pnpm build
19
- npm pack
20
- pnpm add ./grapes-vue-lite-0.1.0.tgz
19
+ pnpm check:release
21
20
  ```
22
21
 
23
22
  ## Commands
@@ -26,12 +25,22 @@ pnpm add ./grapes-vue-lite-0.1.0.tgz
26
25
  pnpm install
27
26
  pnpm dev
28
27
  pnpm test:run
28
+ pnpm check:dist-import
29
+ pnpm check:package
30
+ pnpm check:release
31
+ pnpm check:types-consumer
32
+ pnpm pack:dry-run
29
33
  pnpm build:lib
30
34
  pnpm build
31
35
  ```
32
36
 
33
- `pnpm build` runs smoke tests, type checks, the demo app build, and the library build.
37
+ `pnpm check:package` verifies package export paths, generated declaration files, peer dependency shape, and embeddable library CSS.
38
+ `pnpm check:dist-import` verifies the built ESM and UMD/CJS entrypoints can be imported and expose the expected public exports.
39
+ `pnpm check:types-consumer` compiles a temporary TypeScript consumer that imports the built package through `package.json` exports.
40
+ `pnpm pack:dry-run` prints the exact npm tarball file list with a workspace-local npm cache; run it before publishing.
41
+ `pnpm build` runs smoke tests, type checks, the demo app build, the library build, and the package check.
34
42
  `pnpm build:lib` emits the third-party integration package into `dist-lib`.
43
+ `pnpm check:release` runs the full publish gate: default build, built entrypoint import checks, consumer type checks, and npm pack dry-run. It is intentionally separate from `pnpm build` because it exercises npm and TypeScript entrypoints as an external consumer would.
35
44
 
36
45
  ## Third-party Vue Integration
37
46
 
@@ -69,6 +78,15 @@ const options: EditorOptions = {
69
78
  storage: {
70
79
  localKey: "host-app-builder",
71
80
  },
81
+ toolbar: {
82
+ hidden: ["clear", "languageMenu", "themeMenu", "importHtml", "exportCss", "command:paste"],
83
+ commandIds: ["togglePreview", "undo", "redo"],
84
+ },
85
+ initialContent: {
86
+ pageName: "Landing",
87
+ html: '<section class="hero"><h1>Imported from host</h1></section>',
88
+ css: ".hero { padding: 64px; background: #ffffff; } .hero:hover { background: #f3f4f6; }",
89
+ },
72
90
  plugins: [
73
91
  (editor) => {
74
92
  editor.Blocks.add({
@@ -102,6 +120,8 @@ function handleChange(projectJson: string) {
102
120
 
103
121
  The package treats `vue` as a peer dependency, so the host application owns the Vue runtime version.
104
122
 
123
+ ### Embedding Checklist
124
+
105
125
  The editor fills its parent container by default. When embedding it in a dialog, drawer, tab pane, or any constrained area, set the host container height explicitly:
106
126
 
107
127
  ```vue
@@ -119,7 +139,41 @@ The editor fills its parent container by default. When embedding it in a dialog,
119
139
  </style>
120
140
  ```
121
141
 
122
- For full-screen usage, set the host container to `100dvh`. The library stylesheet avoids forcing `body`, `html`, or `#app` height so it does not override the host application's page layout.
142
+ For full-screen usage, set the host container to `100dvh`. The library stylesheet scopes editor tokens, box sizing, form-control font rules, and overlays under `.app-shell`; it avoids forcing `body`, `html`, `#app`, or viewport-height layout so it does not override the host application's page layout.
143
+
144
+ Keyboard shortcuts are scoped to the active editor instance. Focus or pointer interaction inside an editor marks it active, typing targets are ignored, and multiple editors on the same page do not share command handling. Disable built-in shortcuts when a host application owns all keyboard handling:
145
+
146
+ ```vue
147
+ <GrapesVueEditor :options="options" :shortcuts="false" />
148
+ ```
149
+
150
+ Use `:emit-changes="false"` when the host only needs `@ready` and will pull project JSON manually, for example before saving a larger form.
151
+
152
+ ### Toolbar Customization
153
+
154
+ Host applications can hide toolbar buttons or choose which commands appear as quick actions:
155
+
156
+ ```ts
157
+ const options: EditorOptions = {
158
+ toolbar: {
159
+ hidden: [
160
+ "clear",
161
+ "languageMenu",
162
+ "themeMenu",
163
+ "storageMenu",
164
+ "importJson",
165
+ "importHtml",
166
+ "exportCss",
167
+ "command:paste",
168
+ ],
169
+ commandIds: ["togglePreview", "undo", "redo"],
170
+ },
171
+ };
172
+ ```
173
+
174
+ `hidden` accepts top-level toolbar IDs such as `title`, `selectionStatus`, `save`, `load`, `clear`, `commandsMenu`, `languageMenu`, `themeMenu`, `deviceButtons`, `deviceManager`, `storageMenu`, and `exportMenu`. It also accepts export menu item IDs: `importJson`, `importHtml`, `viewJson`, `viewHtml`, `viewLinkedHtml`, `viewCss`, `exportJson`, `exportHtml`, `exportLinkedHtml`, and `exportCss`.
175
+
176
+ Use `command:<id>` to hide a command everywhere it appears in the toolbar and stop its built-in keyboard shortcut from running. `commandIds` controls the quick command buttons near the selection status and can include host-registered commands. For strict allow-list behavior, use `visible`; include parent menu IDs such as `exportMenu` plus any child IDs that should appear inside the menu.
123
177
 
124
178
  ## Current Editor Modules
125
179
 
@@ -160,6 +214,38 @@ Toolbar export options:
160
214
  - `Export Linked HTML`: HTML for external CSS deployment.
161
215
  - `Export CSS`: standalone CSS file.
162
216
 
217
+ ## Initial Content
218
+
219
+ Hosts can initialize the editor with content instead of the built-in starter page:
220
+
221
+ ```ts
222
+ const options: EditorOptions = {
223
+ initialContent: {
224
+ pageName: "Landing",
225
+ html: '<section class="hero"><h1>Hello</h1><p>Editable content</p></section>',
226
+ css: ".hero { padding: 64px; background: #ffffff; } .hero:hover { background: #f3f4f6; }",
227
+ },
228
+ };
229
+ ```
230
+
231
+ `initialContent.project` accepts either a `ProjectData` object or a serialized project JSON string and takes precedence over `html`/`css`. `initialContent.html` uses the same parser as `Import HTML`. `initialContent.css` currently imports simple class rules such as `.hero { ... }` plus `.hero:hover`, `.hero:active`, and `.hero:focus`.
232
+
233
+ ## Pages And Internal Links
234
+
235
+ Projects can contain multiple pages. Each page has a stable `id` for editor references and a public `path` for preview links and exported markup:
236
+
237
+ ```ts
238
+ editor.addPage();
239
+ editor.updatePagePath(editor.getActivePage().id, "/pricing");
240
+ editor.setActivePage("page-home");
241
+ ```
242
+
243
+ Button and link components support internal page links. Select a button, set `Link type` to `page`, then choose the target page in the `Page` trait. The editor stores the target page id in `data-gv-page-id` and mirrors the page path into `href`, so preview and exported HTML still have normal anchor URLs.
244
+
245
+ In preview mode, clicking an internal page link switches the active editor page with `setActivePage(pageId)`. In edit mode, the same click still selects the component for editing.
246
+
247
+ When a page path changes, internal links pointing at that page are updated automatically. Old project JSON without `path` is still accepted; missing paths are normalized on import.
248
+
163
249
  ## Class Styling Workflow
164
250
 
165
251
  1. Select a node on the canvas.