grapes-vue-lite 0.1.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.
Files changed (39) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +149 -0
  3. package/dist-lib/grapes-vue-lite.js +3468 -0
  4. package/dist-lib/grapes-vue-lite.umd.cjs +30 -0
  5. package/dist-lib/style.css +1 -0
  6. package/dist-lib/types/blocks/basic.d.ts +4 -0
  7. package/dist-lib/types/components/AssetPanel.vue.d.ts +3 -0
  8. package/dist-lib/types/components/BlockPanel.vue.d.ts +3 -0
  9. package/dist-lib/types/components/Canvas.vue.d.ts +3 -0
  10. package/dist-lib/types/components/CodeViewer.vue.d.ts +14 -0
  11. package/dist-lib/types/components/EditorRoot.vue.d.ts +17 -0
  12. package/dist-lib/types/components/LayerPanel.vue.d.ts +3 -0
  13. package/dist-lib/types/components/LayerTreeItem.vue.d.ts +8 -0
  14. package/dist-lib/types/components/PagePanel.vue.d.ts +3 -0
  15. package/dist-lib/types/components/RenderNode.vue.d.ts +7 -0
  16. package/dist-lib/types/components/SelectionToolbar.vue.d.ts +6 -0
  17. package/dist-lib/types/components/SelectorPanel.vue.d.ts +3 -0
  18. package/dist-lib/types/components/StylePanel.vue.d.ts +3 -0
  19. package/dist-lib/types/components/Toolbar.vue.d.ts +3 -0
  20. package/dist-lib/types/components/TraitPanel.vue.d.ts +3 -0
  21. package/dist-lib/types/core/assetManager.d.ts +8 -0
  22. package/dist-lib/types/core/blockManager.d.ts +2 -0
  23. package/dist-lib/types/core/commandManager.d.ts +2 -0
  24. package/dist-lib/types/core/componentManager.d.ts +7 -0
  25. package/dist-lib/types/core/componentTypes.d.ts +13 -0
  26. package/dist-lib/types/core/cssRuleManager.d.ts +8 -0
  27. package/dist-lib/types/core/editor.d.ts +3 -0
  28. package/dist-lib/types/core/exporter.d.ts +8 -0
  29. package/dist-lib/types/core/historyManager.d.ts +2 -0
  30. package/dist-lib/types/core/id.d.ts +1 -0
  31. package/dist-lib/types/core/schema.d.ts +8 -0
  32. package/dist-lib/types/core/selectorManager.d.ts +10 -0
  33. package/dist-lib/types/core/storageManager.d.ts +4 -0
  34. package/dist-lib/types/core/styleManager.d.ts +2 -0
  35. package/dist-lib/types/core/traitManager.d.ts +3 -0
  36. package/dist-lib/types/core/types.d.ts +404 -0
  37. package/dist-lib/types/index.d.ts +4 -0
  38. package/dist-lib/types/styles/presets.d.ts +3 -0
  39. package/package.json +61 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 stevenzxs
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,149 @@
1
+ # grapes-vue-lite
2
+
3
+ Vue 3 + TypeScript page builder inspired by GrapesJS. The project is evolving toward a modular editor core with managers for blocks, components, traits, styles, selectors, CSS rules, assets, storage, commands, and history.
4
+
5
+ This is an independent project and is not affiliated with or endorsed by GrapesJS.
6
+
7
+ ## Installation
8
+
9
+ The npm package is intended to be published as a beta release first:
10
+
11
+ ```bash
12
+ pnpm add grapes-vue-lite@beta
13
+ ```
14
+
15
+ For local validation before publishing:
16
+
17
+ ```bash
18
+ pnpm build
19
+ npm pack
20
+ pnpm add ./grapes-vue-lite-0.1.0.tgz
21
+ ```
22
+
23
+ ## Commands
24
+
25
+ ```bash
26
+ pnpm install
27
+ pnpm dev
28
+ pnpm test:run
29
+ pnpm build:lib
30
+ pnpm build
31
+ ```
32
+
33
+ `pnpm build` runs smoke tests, type checks, the demo app build, and the library build.
34
+ `pnpm build:lib` emits the third-party integration package into `dist-lib`.
35
+
36
+ ## Third-party Vue Integration
37
+
38
+ Install the package in a Vue 3 application, then import the editor component and stylesheet:
39
+
40
+ ```ts
41
+ import { GrapesVueEditor } from "grapes-vue-lite";
42
+ import "grapes-vue-lite/style.css";
43
+ ```
44
+
45
+ Use the component in any Vue page:
46
+
47
+ ```vue
48
+ <script setup lang="ts">
49
+ import { GrapesVueEditor, type EditorContext, type EditorOptions } from "grapes-vue-lite";
50
+ import "grapes-vue-lite/style.css";
51
+
52
+ const options: EditorOptions = {
53
+ selectors: [{ name: "primary-button", label: "Primary button" }],
54
+ storage: {
55
+ localKey: "host-app-builder",
56
+ },
57
+ plugins: [
58
+ (editor) => {
59
+ editor.Blocks.add({
60
+ id: "host-hero",
61
+ label: "Host Hero",
62
+ description: "Hero block registered by the host app",
63
+ category: "Host",
64
+ create: ({ Components }) =>
65
+ Components.createNode("section", {
66
+ name: "Host Hero",
67
+ style: { padding: "64px", background: "#ffffff" },
68
+ }),
69
+ });
70
+ },
71
+ ],
72
+ };
73
+
74
+ function handleReady(editor: EditorContext) {
75
+ console.log(editor.exportProjectJson());
76
+ }
77
+
78
+ function handleChange(projectJson: string) {
79
+ console.log(projectJson);
80
+ }
81
+ </script>
82
+
83
+ <template>
84
+ <GrapesVueEditor :options="options" @ready="handleReady" @change="handleChange" />
85
+ </template>
86
+ ```
87
+
88
+ The package treats `vue` as a peer dependency, so the host application owns the Vue runtime version.
89
+
90
+ ## Current Editor Modules
91
+
92
+ - `Blocks`: block registry and categories.
93
+ - `Components`: component type registry, node creation, and style constraints.
94
+ - `Traits`: common and component-specific attributes.
95
+ - `Styles`: style sectors and style properties.
96
+ - `Selectors`: project-level class registry and class assignment.
97
+ - `CssRules`: class selector style rules with state, component-first scope, and device overrides.
98
+ - `Assets`: image asset registry and image assignment.
99
+ - `Storage`: local and custom storage adapters.
100
+ - `Commands`: command registry and shortcuts.
101
+ - `History`: undo/redo snapshots with bounded history.
102
+
103
+ ## CSS And Export
104
+
105
+ The editor supports both node-level styles and class selector rules.
106
+
107
+ - Node styles are exported as `[data-node-id="..."]` CSS rules.
108
+ - Component types can restrict editable style properties with `stylable` and `unstylable`.
109
+ - Class styles are exported as normal selector rules, for example `.hero-card`.
110
+ - Selector state rules are exported with pseudo classes, for example `.hero-card:hover`.
111
+ - Component-first selector rules are scoped to a node, for example `[data-node-id="hero"].hero-card`.
112
+ - Device overrides are exported as media queries.
113
+ - Canvas preview uses device-flattened node and class CSS so Tablet/Mobile styles apply to the canvas width instead of the browser viewport.
114
+
115
+ Toolbar export options:
116
+
117
+ - `View HTML`: single HTML document with CSS embedded in `<style>`.
118
+ - `View Linked HTML`: HTML document that references `grapes-vue-lite-styles.css`.
119
+ - `View CSS`: current page CSS.
120
+ - `Export JSON`: project data.
121
+ - `Export HTML`: single-file HTML.
122
+ - `Export Linked HTML`: HTML for external CSS deployment.
123
+ - `Export CSS`: standalone CSS file.
124
+
125
+ ## Class Styling Workflow
126
+
127
+ 1. Select a node on the canvas.
128
+ 2. Add a class in the `Classes` panel.
129
+ 3. Click `Style` on the class chip.
130
+ 4. Pick `Base`, `Hover`, `Active`, or `Focus` when styling selector states.
131
+ 5. Enable `Component first` when the class style should only affect the selected node.
132
+ 6. Use the `Style` panel to edit the class rule.
133
+ 7. Switch devices to add device-specific class overrides.
134
+
135
+ Deleting a project class removes it from the registry, all page nodes, and its CSS rule.
136
+
137
+ ## Tests
138
+
139
+ `test/exporter-smoke-test.ts` directly imports the exporter module and verifies:
140
+
141
+ - page CSS includes node styles;
142
+ - page CSS includes media rules;
143
+ - page CSS includes selector rules;
144
+ - page CSS includes selector state and component-first rules;
145
+ - canvas CSS flattens active device node and selector overrides;
146
+ - linked HTML references external CSS;
147
+ - linked HTML does not emit inline styles.
148
+
149
+ The test compiles through `tsconfig.test.json` into `node_modules/.tmp/test-dist` and is executed by `scripts/run-tests.mjs`.