vue-wswg-editor 0.0.9 → 0.0.11

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 (56) hide show
  1. package/README.md +493 -20
  2. package/dist/style.css +1 -1
  3. package/dist/vue-wswg-editor.es.js +2431 -1895
  4. package/package.json +15 -8
  5. package/src/assets/styles/_mixins.scss +12 -17
  6. package/src/components/AddBlockItem/AddBlockItem.vue +5 -5
  7. package/src/components/BlockBrowser/BlockBrowser.vue +33 -3
  8. package/src/components/BlockEditorFieldNode/BlockEditorFieldNode.vue +79 -34
  9. package/src/components/BlockEditorFields/BlockEditorFields.vue +15 -6
  10. package/src/components/BlockImageFieldNode/BlockImageNode.vue +373 -0
  11. package/src/components/BlockMarginFieldNode/BlockMarginNode.vue +6 -4
  12. package/src/components/BlockRepeaterFieldNode/BlockRepeaterNode.vue +4 -2
  13. package/src/components/BrowserNavigation/BrowserNavigation.vue +2 -2
  14. package/src/components/EmptyState/EmptyState.vue +1 -1
  15. package/src/components/PageBlockList/PageBlockList.vue +1 -9
  16. package/src/components/PageBuilderSidebar/PageBuilderSidebar.vue +29 -10
  17. package/src/components/PageBuilderToolbar/PageBuilderToolbar.vue +4 -4
  18. package/src/components/PageRenderer/PageRenderer.vue +76 -24
  19. package/src/components/PageRenderer/blockModules.ts +32 -3
  20. package/src/components/PageRenderer/layoutModules.ts +32 -0
  21. package/src/components/PageSettings/PageSettings.vue +19 -11
  22. package/src/components/ResizeHandle/ResizeHandle.vue +10 -10
  23. package/src/components/WswgJsonEditor/WswgJsonEditor.vue +323 -117
  24. package/src/index.ts +2 -2
  25. package/src/style.css +10 -3
  26. package/src/types/Block.d.ts +1 -1
  27. package/src/util/fieldConfig.ts +29 -0
  28. package/src/util/registry.ts +30 -23
  29. package/src/util/validation.ts +178 -23
  30. package/src/vite-plugin.ts +27 -2
  31. package/types/vue-wswg-editor.d.ts +161 -0
  32. package/dist/types/components/AddBlockItem/AddBlockItem.vue.d.ts +0 -6
  33. package/dist/types/components/BlockBrowser/BlockBrowser.vue.d.ts +0 -2
  34. package/dist/types/components/BlockComponent/BlockComponent.vue.d.ts +0 -15
  35. package/dist/types/components/BlockEditorFieldNode/BlockEditorFieldNode.vue.d.ts +0 -15
  36. package/dist/types/components/BlockEditorFields/BlockEditorFields.vue.d.ts +0 -15
  37. package/dist/types/components/BlockMarginFieldNode/BlockMarginNode.vue.d.ts +0 -23
  38. package/dist/types/components/BlockRepeaterFieldNode/BlockRepeaterNode.vue.d.ts +0 -15
  39. package/dist/types/components/BrowserNavigation/BrowserNavigation.vue.d.ts +0 -5
  40. package/dist/types/components/EmptyState/EmptyState.vue.d.ts +0 -15
  41. package/dist/types/components/PageBlockList/PageBlockList.vue.d.ts +0 -19
  42. package/dist/types/components/PageBuilderSidebar/PageBuilderSidebar.vue.d.ts +0 -30
  43. package/dist/types/components/PageBuilderToolbar/PageBuilderToolbar.vue.d.ts +0 -28
  44. package/dist/types/components/PageRenderer/PageRenderer.vue.d.ts +0 -6
  45. package/dist/types/components/PageRenderer/blockModules.d.ts +0 -1
  46. package/dist/types/components/PageSettings/PageSettings.vue.d.ts +0 -15
  47. package/dist/types/components/ResizeHandle/ResizeHandle.vue.d.ts +0 -6
  48. package/dist/types/components/WswgJsonEditor/WswgJsonEditor.test.d.ts +0 -1
  49. package/dist/types/components/WswgJsonEditor/WswgJsonEditor.vue.d.ts +0 -40
  50. package/dist/types/index.d.ts +0 -7
  51. package/dist/types/util/fieldConfig.d.ts +0 -82
  52. package/dist/types/util/helpers.d.ts +0 -28
  53. package/dist/types/util/registry.d.ts +0 -20
  54. package/dist/types/util/validation.d.ts +0 -15
  55. package/dist/types/vite-plugin.d.ts +0 -9
  56. package/dist/vite-plugin.js +0 -53
@@ -1,15 +0,0 @@
1
- type __VLS_Props = {
2
- editable: boolean;
3
- };
4
- type __VLS_PublicProps = __VLS_Props & {
5
- "showAddBlockMenu"?: boolean;
6
- };
7
- declare const _default: import("vue").DefineComponent<__VLS_PublicProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
8
- "update:showAddBlockMenu": (value: boolean | undefined) => any;
9
- } & {
10
- blockAdded: (blockType: string) => any;
11
- }, string, import("vue").PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
12
- "onUpdate:showAddBlockMenu"?: ((value: boolean | undefined) => any) | undefined;
13
- onBlockAdded?: ((blockType: string) => any) | undefined;
14
- }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
15
- export default _default;
@@ -1,19 +0,0 @@
1
- type __VLS_Props = {
2
- blocksKey: string;
3
- settingsKey: string;
4
- };
5
- type __VLS_PublicProps = __VLS_Props & {
6
- modelValue?: any;
7
- "hoveredBlockId"?: string | null;
8
- };
9
- declare const _default: import("vue").DefineComponent<__VLS_PublicProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
10
- "update:modelValue": (value: any) => any;
11
- "update:hoveredBlockId": (value: string | null | undefined) => any;
12
- } & {
13
- "block-click": (block: any) => any;
14
- }, string, import("vue").PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
15
- "onUpdate:modelValue"?: ((value: any) => any) | undefined;
16
- "onBlock-click"?: ((block: any) => any) | undefined;
17
- "onUpdate:hoveredBlockId"?: ((value: string | null | undefined) => any) | undefined;
18
- }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
19
- export default _default;
@@ -1,30 +0,0 @@
1
- type __VLS_Props = {
2
- editable?: boolean;
3
- blocksKey?: string;
4
- settingsKey?: string;
5
- };
6
- type __VLS_PublicProps = __VLS_Props & {
7
- modelValue?: any;
8
- "activeBlock"?: any;
9
- "hoveredBlockId"?: string | null;
10
- "showPageSettings"?: boolean;
11
- "showAddBlockMenu"?: boolean;
12
- };
13
- declare const _default: import("vue").DefineComponent<__VLS_PublicProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
14
- "update:activeBlock": (value: any) => any;
15
- "update:showPageSettings": (value: boolean | undefined) => any;
16
- "update:modelValue": (value: any) => any;
17
- "update:hoveredBlockId": (value: string | null | undefined) => any;
18
- "update:showAddBlockMenu": (value: boolean | undefined) => any;
19
- }, string, import("vue").PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
20
- "onUpdate:activeBlock"?: ((value: any) => any) | undefined;
21
- "onUpdate:showPageSettings"?: ((value: boolean | undefined) => any) | undefined;
22
- "onUpdate:modelValue"?: ((value: any) => any) | undefined;
23
- "onUpdate:hoveredBlockId"?: ((value: string | null | undefined) => any) | undefined;
24
- "onUpdate:showAddBlockMenu"?: ((value: boolean | undefined) => any) | undefined;
25
- }>, {
26
- editable: boolean;
27
- blocksKey: string;
28
- settingsKey: string;
29
- }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
30
- export default _default;
@@ -1,28 +0,0 @@
1
- type __VLS_Props = {
2
- hasPageSettings: boolean;
3
- };
4
- type __VLS_PublicProps = __VLS_Props & {
5
- "editorViewport"?: "desktop" | "mobile";
6
- "activeBlock"?: any;
7
- "showPageSettings"?: boolean;
8
- };
9
- declare var __VLS_1: {};
10
- type __VLS_Slots = {} & {
11
- default?: (props: typeof __VLS_1) => any;
12
- };
13
- declare const __VLS_component: import("vue").DefineComponent<__VLS_PublicProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
14
- "update:editorViewport": (value: "desktop" | "mobile" | undefined) => any;
15
- "update:activeBlock": (value: any) => any;
16
- "update:showPageSettings": (value: boolean | undefined) => any;
17
- }, string, import("vue").PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
18
- "onUpdate:editorViewport"?: ((value: "desktop" | "mobile" | undefined) => any) | undefined;
19
- "onUpdate:activeBlock"?: ((value: any) => any) | undefined;
20
- "onUpdate:showPageSettings"?: ((value: boolean | undefined) => any) | undefined;
21
- }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
22
- declare const _default: __VLS_WithSlots<typeof __VLS_component, __VLS_Slots>;
23
- export default _default;
24
- type __VLS_WithSlots<T, S> = T & {
25
- new (): {
26
- $slots: S;
27
- };
28
- };
@@ -1,6 +0,0 @@
1
- import type { Block } from "../../types/Block";
2
- type __VLS_Props = {
3
- blocks: Block[];
4
- };
5
- declare const _default: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
6
- export default _default;
@@ -1 +0,0 @@
1
- export declare const blockModules: Record<string, any> | Record<string, string> | Record<string, () => Promise<any>>;
@@ -1,15 +0,0 @@
1
- type __VLS_Props = {
2
- title?: string;
3
- };
4
- type __VLS_PublicProps = __VLS_Props & {
5
- modelValue?: any;
6
- };
7
- declare const _default: import("vue").DefineComponent<__VLS_PublicProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
8
- "update:modelValue": (value: any) => any;
9
- } & {
10
- close: () => any;
11
- }, string, import("vue").PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
12
- onClose?: (() => any) | undefined;
13
- "onUpdate:modelValue"?: ((value: any) => any) | undefined;
14
- }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
15
- export default _default;
@@ -1,6 +0,0 @@
1
- declare const _default: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
2
- sidebarWidth: (width: number) => any;
3
- }, string, import("vue").PublicProps, Readonly<{}> & Readonly<{
4
- onSidebarWidth?: ((width: number) => any) | undefined;
5
- }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
6
- export default _default;
@@ -1,40 +0,0 @@
1
- type __VLS_Props = {
2
- editable?: boolean;
3
- loading?: boolean;
4
- url?: string;
5
- showBrowserBar?: boolean;
6
- blocksKey?: string;
7
- settingsKey?: string;
8
- defaultBlockMargin?: "none" | "small" | "medium" | "large";
9
- };
10
- type __VLS_PublicProps = __VLS_Props & {
11
- modelValue?: any;
12
- };
13
- declare var __VLS_1: {}, __VLS_6: {}, __VLS_8: {};
14
- type __VLS_Slots = {} & {
15
- header?: (props: typeof __VLS_1) => any;
16
- } & {
17
- toolbar?: (props: typeof __VLS_6) => any;
18
- } & {
19
- loading?: (props: typeof __VLS_8) => any;
20
- };
21
- declare const __VLS_component: import("vue").DefineComponent<__VLS_PublicProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
22
- "update:modelValue": (value: any) => any;
23
- }, string, import("vue").PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
24
- "onUpdate:modelValue"?: ((value: any) => any) | undefined;
25
- }>, {
26
- url: string;
27
- editable: boolean;
28
- blocksKey: string;
29
- settingsKey: string;
30
- loading: boolean;
31
- showBrowserBar: boolean;
32
- defaultBlockMargin: "none" | "small" | "medium" | "large";
33
- }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
34
- declare const _default: __VLS_WithSlots<typeof __VLS_component, __VLS_Slots>;
35
- export default _default;
36
- type __VLS_WithSlots<T, S> = T & {
37
- new (): {
38
- $slots: S;
39
- };
40
- };
@@ -1,7 +0,0 @@
1
- export { createField } from "./util/fieldConfig";
2
- export type { EditorFieldConfig, ValidatorFunction } from "./util/fieldConfig";
3
- export { getLayouts } from "./util/registry";
4
- export { validateField, validateAllFields } from "./util/validation";
5
- export { default as WswgJsonEditor } from "./components/WswgJsonEditor/WswgJsonEditor.vue";
6
- export { default as PageRenderer } from "./components/PageRenderer/PageRenderer.vue";
7
- import "./style.css";
@@ -1,82 +0,0 @@
1
- import type { Component } from "vue";
2
- /**
3
- * Validator function that returns:
4
- * - `true` if the value is valid
5
- * - `false` if the value is invalid (generic error)
6
- * - `string` if the value is invalid (specific error message)
7
- */
8
- export type ValidatorFunction = (value: any) => Promise<boolean | string>;
9
- /**
10
- * Editor field types for the page builder sidebar
11
- */
12
- export type EditorFieldType = "text" | "textarea" | "number" | "boolean" | "email" | "url" | "select" | "checkbox" | "radio" | "color" | "range" | "repeater" | "margin" | "custom";
13
- /**
14
- * Simple utility for defining page builder props with editor field metadata
15
- * This approach separates Vue props from editor field configuration
16
- */
17
- export interface EditorFieldConfig {
18
- type: EditorFieldType;
19
- component?: Component;
20
- required?: boolean;
21
- default?: any;
22
- label?: string;
23
- description?: string;
24
- placeholder?: string;
25
- rows?: number;
26
- options?: Array<{
27
- label: string;
28
- value: any;
29
- id: string;
30
- }>;
31
- step?: number;
32
- hidden?: boolean;
33
- group?: string;
34
- clearable?: boolean;
35
- /**
36
- * Validator function that returns:
37
- * - `true` if the value is valid
38
- * - `false` if the value is invalid (generic error)
39
- * - `string` if the value is invalid (specific error message)
40
- */
41
- validator?: ValidatorFunction;
42
- repeaterFields?: Record<string, EditorFieldConfig>;
43
- repeaterFieldLabel?: string;
44
- minLength?: number;
45
- maxLength?: number;
46
- min?: number;
47
- max?: number;
48
- minItems?: number;
49
- maxItems?: number;
50
- responsive?: boolean;
51
- }
52
- /**
53
- * Helper function to create editor field configurations
54
- */
55
- export declare const createField: {
56
- custom: (config?: Partial<EditorFieldConfig>) => EditorFieldConfig;
57
- text: (config?: Partial<EditorFieldConfig>) => EditorFieldConfig;
58
- textarea: (config?: Partial<EditorFieldConfig>) => EditorFieldConfig;
59
- number: (config?: Partial<EditorFieldConfig>) => EditorFieldConfig;
60
- boolean: (config?: Partial<EditorFieldConfig>) => EditorFieldConfig;
61
- email: (config?: Partial<EditorFieldConfig>) => EditorFieldConfig;
62
- url: (config?: Partial<EditorFieldConfig>) => EditorFieldConfig;
63
- select: <T>(options: Array<{
64
- label: string;
65
- value: T;
66
- id: string;
67
- }>, config?: Partial<Omit<EditorFieldConfig, "options">>) => EditorFieldConfig;
68
- radio: <T>(options: Array<{
69
- label: string;
70
- value: T;
71
- id: string;
72
- }>, config?: Partial<Omit<EditorFieldConfig, "options">>) => EditorFieldConfig;
73
- checkbox: <T>(options: Array<{
74
- label: string;
75
- value: T;
76
- id: string;
77
- }>, config?: Partial<Omit<EditorFieldConfig, "options">>) => EditorFieldConfig;
78
- color: (config?: Partial<EditorFieldConfig>) => EditorFieldConfig;
79
- range: (config?: Partial<EditorFieldConfig>) => EditorFieldConfig;
80
- repeater: (repeaterFields: Record<string, EditorFieldConfig>, config?: Partial<EditorFieldConfig>) => EditorFieldConfig;
81
- margin: (config?: Partial<EditorFieldConfig>) => EditorFieldConfig;
82
- };
@@ -1,28 +0,0 @@
1
- /**
2
- * File lookup utility for finding Vue components with flexible naming conventions
3
- *
4
- * This utility handles different naming formats (snake_case, camelCase, kebab-case, PascalCase)
5
- * and various file/folder structures to provide maximum flexibility in component organization.
6
- */
7
- /**
8
- * Converts a string to different naming conventions
9
- */
10
- export declare function generateNameVariations(name: string): string[];
11
- /**
12
- * Generates file path patterns to try for a given block name and optional file name
13
- * If fileName is provided, generates patterns using variations of both blockName (for directory) and fileName (for file)
14
- * If fileName is not provided, uses blockName variations for both directory and file
15
- *
16
- * @param basePath - Base path (e.g., "@page-builder/blocks/")
17
- * @param blockName - Block name in any format (e.g., "heroSection", "hero-section")
18
- * @param fileName - Optional file name (e.g., "options.ts", "fields.ts"). If not provided, uses blockName
19
- * @returns Array of path patterns to try
20
- */
21
- export declare function generateFilePathPatterns(basePath: string, blockName: string, fileName?: string): string[];
22
- /**
23
- * Converts a any type of string to camelCase
24
- * e.g., "hero_section" or "HeroSection" or "hero-section" or "heroSection" -> "HeroSection"
25
- * e.g., "component_not_found" or "ComponentNotFound" or "component-not-found" or "componentNotFound" -> "ComponentNotFound"
26
- */
27
- export declare function toCamelCase(input: string): string;
28
- export declare function toNiceName(input: string): string;
@@ -1,20 +0,0 @@
1
- import { type Ref } from "vue";
2
- import type { EditorFieldConfig } from "./fieldConfig";
3
- import type { Block } from "../types/Block";
4
- import type { Layout } from "../types/Layout";
5
- /**
6
- * Registry of all page builder blocks, layouts & fields
7
- */
8
- export declare const pageBuilderBlocks: Ref<Record<string, Block>>;
9
- export declare const pageBuilderLayouts: Ref<Record<string, Layout>>;
10
- export declare function getBlocks(): Record<string, Block>;
11
- export declare function getLayouts(): Record<string, Layout>;
12
- /**
13
- * Get the thumbnail URL for a block directory
14
- * @param directory - Block directory path (e.g., "@page-builder/blocks/hero-section")
15
- * @returns Thumbnail URL or undefined if not found
16
- */
17
- export declare function getBlockThumbnailUrl(directory: string | undefined): string | undefined;
18
- export declare function getBlockComponent(blockType: string): Block | undefined;
19
- export declare function getLayoutFields(layoutName: string): Record<string, EditorFieldConfig>;
20
- export declare function initialiseRegistry(): Promise<void>;
@@ -1,15 +0,0 @@
1
- import type { ValidatorFunction } from "./fieldConfig";
2
- export declare function validateField(value: any, validator: ValidatorFunction): Promise<string | boolean>;
3
- export interface ValidationResult {
4
- title: string;
5
- isValid: boolean;
6
- errors: Record<string, string | boolean>;
7
- }
8
- /**
9
- * Validate all fields in the value
10
- * @param value - The value to validate
11
- * @param blocksKey - The key of the blocks in the value
12
- * @param settingsKey - The key of the settings in the value
13
- * @returns A record of validation results
14
- */
15
- export declare function validateAllFields(value: any, blocksKey?: string, settingsKey?: string): Promise<Record<string, ValidationResult>>;
@@ -1,9 +0,0 @@
1
- import type { Plugin } from "vite";
2
- export interface VueWswgEditorPluginOptions {
3
- /**
4
- * Root directory in the host project.
5
- * Example: "@/features/homepage"
6
- */
7
- rootDir: string;
8
- }
9
- export declare function vueWswgEditorPlugin(options: VueWswgEditorPluginOptions): Plugin;
@@ -1,53 +0,0 @@
1
- function l(u) {
2
- const t = {
3
- blocks: "\0vue-wswg-editor:blocks",
4
- fields: "\0vue-wswg-editor:fields",
5
- layouts: "\0vue-wswg-editor:layouts",
6
- thumbnails: "\0vue-wswg-editor:thumbnails"
7
- };
8
- return {
9
- name: "vue-wswg-editor-glob-plugin",
10
- enforce: "pre",
11
- // Run before other plugins to ensure import.meta.glob is processed correctly
12
- config(e) {
13
- const s = e.optimizeDeps || {}, r = s.exclude;
14
- let o;
15
- return Array.isArray(r) ? o = [...r] : typeof r == "string" ? o = [r] : o = [], o.includes("vue-wswg-editor") || o.push("vue-wswg-editor"), {
16
- optimizeDeps: {
17
- ...s,
18
- exclude: o
19
- }
20
- };
21
- },
22
- resolveId(e) {
23
- if (e.startsWith("vue-wswg-editor:")) {
24
- const r = e.replace("vue-wswg-editor:", "");
25
- if (r in t)
26
- return t[r];
27
- }
28
- if (Object.values(t).includes(e))
29
- return e;
30
- },
31
- load(e) {
32
- switch (e) {
33
- case t.layouts:
34
- return `export const modules = import.meta.glob("${u.rootDir}/layout/**/*.vue", { eager: true });`;
35
- case t.blocks:
36
- return `export const modules = import.meta.glob("${u.rootDir}/blocks/**/*.vue", { eager: true });`;
37
- case t.fields:
38
- return `export const modules = import.meta.glob("${u.rootDir}/blocks/**/fields.ts", { eager: true });`;
39
- case t.thumbnails:
40
- return `export const modules = import.meta.glob("${u.rootDir}/blocks/**/thumbnail.png", { eager: true });`;
41
- default:
42
- return;
43
- }
44
- },
45
- transform(e, s) {
46
- if (Object.values(t).includes(s))
47
- return null;
48
- }
49
- };
50
- }
51
- export {
52
- l as vueWswgEditorPlugin
53
- };