vue-wswg-editor 0.0.11 → 0.0.13

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 (72) hide show
  1. package/README.md +23 -8
  2. package/dist/style.css +1 -1
  3. package/dist/types/components/AddBlockItem/AddBlockItem.vue.d.ts +6 -0
  4. package/dist/types/components/BlockBrowser/BlockBrowser.vue.d.ts +2 -0
  5. package/dist/types/components/BlockComponent/BlockComponent.vue.d.ts +15 -0
  6. package/dist/types/components/BlockEditorFieldNode/BlockEditorFieldNode.vue.d.ts +15 -0
  7. package/dist/types/components/BlockEditorFields/BlockEditorFields.vue.d.ts +17 -0
  8. package/dist/types/components/BlockImageFieldNode/BlockImageNode.vue.d.ts +19 -0
  9. package/dist/types/components/BlockMarginFieldNode/BlockMarginNode.vue.d.ts +23 -0
  10. package/dist/types/components/BlockRepeaterFieldNode/BlockRepeaterNode.vue.d.ts +15 -0
  11. package/dist/types/components/BrowserNavigation/BrowserNavigation.vue.d.ts +5 -0
  12. package/dist/types/components/EditorPageRenderer/EditorPageRenderer.vue.d.ts +21 -0
  13. package/dist/types/components/EmptyState/EmptyState.vue.d.ts +9 -0
  14. package/dist/types/components/IframePreview/IframePreview.vue.d.ts +26 -0
  15. package/dist/types/components/IframePreview/iframeContent.d.ts +9 -0
  16. package/dist/types/components/IframePreview/iframePreviewApp.d.ts +36 -0
  17. package/dist/types/components/IframePreview/messageHandler.d.ts +55 -0
  18. package/dist/types/components/IframePreview/types.d.ts +77 -0
  19. package/dist/types/components/PageBlockList/PageBlockList.vue.d.ts +19 -0
  20. package/dist/types/components/PageBuilderSidebar/PageBuilderSidebar.vue.d.ts +37 -0
  21. package/dist/types/components/PageBuilderToolbar/PageBuilderToolbar.vue.d.ts +28 -0
  22. package/dist/types/components/PageRenderer/PageRenderer.vue.d.ts +15 -0
  23. package/dist/types/components/PageSettings/PageSettings.vue.d.ts +19 -0
  24. package/dist/types/components/ResizeHandle/ResizeHandle.vue.d.ts +6 -0
  25. package/dist/types/components/WswgPageBuilder/WswgPageBuilder.test.d.ts +1 -0
  26. package/dist/types/components/WswgPageBuilder/WswgPageBuilder.vue.d.ts +38 -0
  27. package/dist/types/index.d.ts +13 -0
  28. package/dist/types/util/fieldConfig.d.ts +87 -0
  29. package/dist/types/util/helpers.d.ts +28 -0
  30. package/dist/types/util/registry.d.ts +27 -0
  31. package/dist/types/util/theme-registry.d.ts +42 -0
  32. package/dist/types/util/validation.d.ts +26 -0
  33. package/dist/types/vite-plugin.d.ts +9 -0
  34. package/dist/vite-plugin.js +80 -0
  35. package/dist/vue-wswg-editor.es.js +2854 -2006
  36. package/package.json +1 -2
  37. package/src/assets/styles/_mixins.scss +15 -0
  38. package/src/components/AddBlockItem/AddBlockItem.vue +13 -4
  39. package/src/components/BlockBrowser/BlockBrowser.vue +5 -5
  40. package/src/components/BlockComponent/BlockComponent.vue +23 -50
  41. package/src/components/BlockEditorFieldNode/BlockEditorFieldNode.vue +12 -10
  42. package/src/components/BlockEditorFields/BlockEditorFields.vue +24 -4
  43. package/src/components/BlockRepeaterFieldNode/BlockRepeaterNode.vue +9 -4
  44. package/src/components/BrowserNavigation/BrowserNavigation.vue +1 -1
  45. package/src/components/EditorPageRenderer/EditorPageRenderer.vue +641 -0
  46. package/src/components/EmptyState/EmptyState.vue +3 -12
  47. package/src/components/IframePreview/IframePreview.vue +211 -0
  48. package/src/components/IframePreview/iframeContent.ts +210 -0
  49. package/src/components/IframePreview/iframePreviewApp.ts +221 -0
  50. package/src/components/IframePreview/messageHandler.ts +219 -0
  51. package/src/components/IframePreview/types.ts +126 -0
  52. package/src/components/PageBlockList/PageBlockList.vue +8 -6
  53. package/src/components/PageBuilderSidebar/PageBuilderSidebar.vue +5 -3
  54. package/src/components/PageRenderer/PageRenderer.vue +9 -33
  55. package/src/components/PageSettings/PageSettings.vue +10 -6
  56. package/src/components/ResizeHandle/ResizeHandle.vue +68 -10
  57. package/src/components/{WswgJsonEditor/WswgJsonEditor.test.ts → WswgPageBuilder/WswgPageBuilder.test.ts} +8 -8
  58. package/src/components/WswgPageBuilder/WswgPageBuilder.vue +375 -0
  59. package/src/index.ts +10 -2
  60. package/src/shims.d.ts +4 -0
  61. package/src/types/Theme.d.ts +15 -0
  62. package/src/util/registry.ts +2 -2
  63. package/src/util/theme-registry.ts +397 -0
  64. package/src/util/validation.ts +104 -13
  65. package/src/vite-plugin.ts +8 -4
  66. package/types/vue-wswg-editor.d.ts +4 -0
  67. package/src/components/PageRenderer/blockModules-alternative.ts.example +0 -9
  68. package/src/components/PageRenderer/blockModules-manual.ts.example +0 -19
  69. package/src/components/PageRenderer/blockModules-runtime.ts.example +0 -23
  70. package/src/components/PageRenderer/blockModules.ts +0 -32
  71. package/src/components/PageRenderer/layoutModules.ts +0 -32
  72. package/src/components/WswgJsonEditor/WswgJsonEditor.vue +0 -595
@@ -0,0 +1,37 @@
1
+ type __VLS_Props = {
2
+ editable?: boolean;
3
+ blocksKey?: string;
4
+ settingsKey?: string;
5
+ hasPageSettings?: boolean;
6
+ activeSettingsTab?: string;
7
+ };
8
+ type __VLS_PublicProps = __VLS_Props & {
9
+ modelValue?: any;
10
+ "activeBlock"?: any;
11
+ "hoveredBlockId"?: string | null;
12
+ "showPageSettings"?: boolean;
13
+ "showAddBlockMenu"?: boolean;
14
+ "editorViewport"?: "desktop" | "mobile";
15
+ };
16
+ declare const _default: import("vue").DefineComponent<__VLS_PublicProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
17
+ "update:modelValue": (value: any) => any;
18
+ "update:hoveredBlockId": (value: string | null | undefined) => any;
19
+ "update:editorViewport": (value: "desktop" | "mobile" | undefined) => any;
20
+ "update:activeBlock": (value: any) => any;
21
+ "update:showPageSettings": (value: boolean | undefined) => any;
22
+ "update:showAddBlockMenu": (value: boolean | undefined) => any;
23
+ }, string, import("vue").PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
24
+ "onUpdate:modelValue"?: ((value: any) => any) | undefined;
25
+ "onUpdate:hoveredBlockId"?: ((value: string | null | undefined) => any) | undefined;
26
+ "onUpdate:editorViewport"?: ((value: "desktop" | "mobile" | undefined) => any) | undefined;
27
+ "onUpdate:activeBlock"?: ((value: any) => any) | undefined;
28
+ "onUpdate:showPageSettings"?: ((value: boolean | undefined) => any) | undefined;
29
+ "onUpdate:showAddBlockMenu"?: ((value: boolean | undefined) => any) | undefined;
30
+ }>, {
31
+ editable: boolean;
32
+ blocksKey: string;
33
+ settingsKey: string;
34
+ hasPageSettings: boolean;
35
+ activeSettingsTab: string;
36
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
37
+ export default _default;
@@ -0,0 +1,28 @@
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
+ };
@@ -0,0 +1,15 @@
1
+ import type { Block } from "../../types/Block";
2
+ type __VLS_Props = {
3
+ blocks: Block[];
4
+ layout?: string;
5
+ settings?: Record<string, any>;
6
+ withLayout?: boolean;
7
+ theme?: string;
8
+ };
9
+ declare const _default: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
10
+ settings: Record<string, any>;
11
+ layout: string;
12
+ theme: string;
13
+ withLayout: boolean;
14
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
15
+ export default _default;
@@ -0,0 +1,19 @@
1
+ type __VLS_Props = {
2
+ settingsKey?: string;
3
+ activeTab?: string;
4
+ };
5
+ type __VLS_PublicProps = __VLS_Props & {
6
+ modelValue?: any;
7
+ };
8
+ declare const _default: import("vue").DefineComponent<__VLS_PublicProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
9
+ "update:modelValue": (value: any) => any;
10
+ } & {
11
+ close: () => any;
12
+ }, string, import("vue").PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
13
+ onClose?: (() => any) | undefined;
14
+ "onUpdate:modelValue"?: ((value: any) => any) | undefined;
15
+ }>, {
16
+ activeTab: string;
17
+ settingsKey: string;
18
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
19
+ export default _default;
@@ -0,0 +1,6 @@
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;
@@ -0,0 +1,38 @@
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
+ theme?: string;
10
+ };
11
+ type __VLS_PublicProps = __VLS_Props & {
12
+ modelValue?: Record<string, any>;
13
+ };
14
+ declare var __VLS_1: {};
15
+ type __VLS_Slots = {} & {
16
+ loading?: (props: typeof __VLS_1) => any;
17
+ };
18
+ declare const __VLS_component: import("vue").DefineComponent<__VLS_PublicProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
19
+ "update:modelValue": (value: Record<string, any> | undefined) => any;
20
+ }, string, import("vue").PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
21
+ "onUpdate:modelValue"?: ((value: Record<string, any> | undefined) => any) | undefined;
22
+ }>, {
23
+ url: string;
24
+ editable: boolean;
25
+ blocksKey: string;
26
+ settingsKey: string;
27
+ theme: string;
28
+ loading: boolean;
29
+ showBrowserBar: boolean;
30
+ defaultBlockMargin: "none" | "small" | "medium" | "large";
31
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
32
+ declare const _default: __VLS_WithSlots<typeof __VLS_component, __VLS_Slots>;
33
+ export default _default;
34
+ type __VLS_WithSlots<T, S> = T & {
35
+ new (): {
36
+ $slots: S;
37
+ };
38
+ };
@@ -0,0 +1,13 @@
1
+ export { createField } from "./util/fieldConfig";
2
+ export type { EditorFieldConfig, ValidatorFunction } from "./util/fieldConfig";
3
+ export { getLayouts, initialiseRegistry, initialiseLayoutRegistry, initialiseBlockRegistry } from "./util/registry";
4
+ export { validateField, validateAllFields, type ValidationResult } from "./util/validation";
5
+ export { getActiveTheme, setActiveTheme, getThemeThumbnail, getThemes } from "./util/theme-registry";
6
+ export type { Theme } from "./types/Theme";
7
+ export type { Layout } from "./types/Layout";
8
+ export type { Block } from "./types/Block";
9
+ export { default as WswgPageBuilder } from "./components/WswgPageBuilder/WswgPageBuilder.vue";
10
+ export { default as PageRenderer } from "./components/PageRenderer/PageRenderer.vue";
11
+ export { createIframeApp, getIframeAppModuleUrl } from "./components/IframePreview/iframePreviewApp";
12
+ export type { IframeAppState, IframeAppCallbacks } from "./components/IframePreview/iframePreviewApp";
13
+ import "./style.css";
@@ -0,0 +1,87 @@
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" | "info" | "image" | "object" | "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
+ objectFields?: Record<string, EditorFieldConfig>;
45
+ minLength?: number;
46
+ maxLength?: number;
47
+ min?: number;
48
+ max?: number;
49
+ minItems?: number;
50
+ maxItems?: number;
51
+ responsive?: boolean;
52
+ valueSuffix?: string;
53
+ }
54
+ /**
55
+ * Helper function to create editor field configurations
56
+ */
57
+ export declare const createField: {
58
+ custom: (config?: Partial<EditorFieldConfig>) => EditorFieldConfig;
59
+ text: (config?: Partial<EditorFieldConfig>) => EditorFieldConfig;
60
+ textarea: (config?: Partial<EditorFieldConfig>) => EditorFieldConfig;
61
+ number: (config?: Partial<EditorFieldConfig>) => EditorFieldConfig;
62
+ boolean: (config?: Partial<EditorFieldConfig>) => EditorFieldConfig;
63
+ email: (config?: Partial<EditorFieldConfig>) => EditorFieldConfig;
64
+ url: (config?: Partial<EditorFieldConfig>) => EditorFieldConfig;
65
+ select: <T>(options: Array<{
66
+ label: string;
67
+ value: T;
68
+ id: string;
69
+ }>, config?: Partial<Omit<EditorFieldConfig, "options">>) => EditorFieldConfig;
70
+ radio: <T>(options: Array<{
71
+ label: string;
72
+ value: T;
73
+ id: string;
74
+ }>, config?: Partial<Omit<EditorFieldConfig, "options">>) => EditorFieldConfig;
75
+ checkbox: <T>(options: Array<{
76
+ label: string;
77
+ value: T;
78
+ id: string;
79
+ }>, config?: Partial<Omit<EditorFieldConfig, "options">>) => EditorFieldConfig;
80
+ color: (config?: Partial<EditorFieldConfig>) => EditorFieldConfig;
81
+ range: (config?: Partial<EditorFieldConfig>) => EditorFieldConfig;
82
+ repeater: (repeaterFields: Record<string, EditorFieldConfig>, config?: Partial<EditorFieldConfig>) => EditorFieldConfig;
83
+ image: (config?: Partial<EditorFieldConfig>) => EditorFieldConfig;
84
+ margin: (config?: Partial<EditorFieldConfig>) => EditorFieldConfig;
85
+ info: (config?: Partial<EditorFieldConfig>) => EditorFieldConfig;
86
+ object: (objectFields: Record<string, EditorFieldConfig>, config?: Partial<EditorFieldConfig>) => EditorFieldConfig;
87
+ };
@@ -0,0 +1,28 @@
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;
@@ -0,0 +1,27 @@
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
+ /**
11
+ * Extract the default export from a module, handling different module formats
12
+ * Works with both eager and lazy-loaded modules from import.meta.glob
13
+ */
14
+ export declare function getModuleDefault(module: any): any;
15
+ export declare function getBlocks(): Record<string, Block>;
16
+ export declare function getLayouts(): Record<string, Layout>;
17
+ /**
18
+ * Get the thumbnail URL for a block directory
19
+ * @param directory - Block directory path (e.g., "@page-builder/blocks/hero-section")
20
+ * @returns Thumbnail URL or undefined if not found
21
+ */
22
+ export declare function getBlockThumbnailUrl(directory: string | undefined): string | undefined;
23
+ export declare function getBlockComponent(blockType: string): Block | undefined;
24
+ export declare function getLayoutFields(layoutName: string): Record<string, EditorFieldConfig>;
25
+ export declare function initialiseLayoutRegistry(): Promise<void>;
26
+ export declare function initialiseBlockRegistry(): Promise<void>;
27
+ export declare function initialiseRegistry(): Promise<void>;
@@ -0,0 +1,42 @@
1
+ import { type Ref } from "vue";
2
+ import type { Theme } from "../types/Theme";
3
+ import type { Layout } from "../types/Layout";
4
+ import type { Block } from "../types/Block";
5
+ import { EditorFieldConfig } from "./fieldConfig";
6
+ /**
7
+ * Registry of all page builder themes, blocks, layouts, fields & thumbnails
8
+ */
9
+ export declare const pageBuilderThemes: Ref<Record<string, Theme>>;
10
+ export declare const themeLayouts: Ref<Record<string, Layout>>;
11
+ export declare const themeBlocks: Ref<Record<string, Block>>;
12
+ export declare const themeBlockFields: Ref<Record<string, Record<string, EditorFieldConfig>>>;
13
+ export declare const activeThemeId: Ref<string | undefined>;
14
+ /**
15
+ * Extract the default export from a module, handling different module formats
16
+ * Works with both eager and lazy-loaded modules from import.meta.glob
17
+ */
18
+ export declare function getModuleDefault(module: any): any;
19
+ /**************************************************
20
+ * THEMES
21
+ **************************************************/
22
+ export declare function initialiseThemeRegistry(): Promise<void>;
23
+ export declare function getThemes(): Theme[];
24
+ export declare function getActiveTheme(): Theme;
25
+ export declare function setActiveTheme(themeId?: string): Promise<void>;
26
+ export declare function getThemeThumbnail(themeDirectory: string): string | undefined;
27
+ /**************************************************
28
+ * LAYOUTS
29
+ **************************************************/
30
+ export declare function initialiseLayoutRegistry(): Promise<void>;
31
+ export declare function getLayout(layoutType: string): Layout | undefined;
32
+ /**************************************************
33
+ * BLOCKS
34
+ **************************************************/
35
+ export declare function initialiseBlockRegistry(): Promise<void>;
36
+ export declare function getBlock(blockType: string): Block | undefined;
37
+ export declare function getBlockThumbnail(blockDirectory: string): string | undefined;
38
+ /**
39
+ * Initialize the registry with a specific theme
40
+ * @param themeId - The theme ID to load blocks/layouts from
41
+ */
42
+ export declare function initialiseRegistry(themeId?: string, useEditingRegistry?: boolean): Promise<void>;
@@ -0,0 +1,26 @@
1
+ import type { EditorFieldConfig, ValidatorFunction } from "./fieldConfig";
2
+ export declare function validateField(value: any, fieldConfig: EditorFieldConfig): Promise<boolean | string | ValidationResult>;
3
+ export interface ValidationResult {
4
+ title: string;
5
+ isValid: boolean;
6
+ errors: Record<string, string | boolean | ValidationResult>;
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>>;
16
+ /**
17
+ * Creates a generic validator function based on field config properties
18
+ * Handles: required, minLength, maxLength, min, max, minItems, maxItems
19
+ * Returns a ValidatorFunction that can be combined with custom validators
20
+ */
21
+ export declare function createGenericValidator(fieldConfig: EditorFieldConfig): ValidatorFunction | null;
22
+ /**
23
+ * Combines a generic validator (built-in validations) with a custom validator
24
+ * Runs built-in validations first, then custom validator if provided
25
+ */
26
+ export declare function combineValidators(genericValidator: ValidatorFunction | null, customValidator?: ValidatorFunction): ValidatorFunction | undefined;
@@ -0,0 +1,9 @@
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;
@@ -0,0 +1,80 @@
1
+ function a(r) {
2
+ const e = {
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
+ themes: "\0vue-wswg-editor:themes"
8
+ };
9
+ return {
10
+ name: "vue-wswg-editor-glob-plugin",
11
+ enforce: "pre",
12
+ // Run before other plugins to ensure import.meta.glob is processed correctly
13
+ config(t) {
14
+ var l;
15
+ const s = t.optimizeDeps || {}, o = s.exclude;
16
+ let u;
17
+ Array.isArray(o) ? u = [...o] : typeof o == "string" ? u = [o] : u = [];
18
+ const n = [
19
+ "vue-wswg-editor",
20
+ "vue-wswg-editor:layouts",
21
+ "vue-wswg-editor:blocks",
22
+ "vue-wswg-editor:fields",
23
+ "vue-wswg-editor:thumbnails",
24
+ "vue-wswg-editor:themes"
25
+ ];
26
+ for (const i of n)
27
+ u.includes(i) || u.push(i);
28
+ return {
29
+ optimizeDeps: {
30
+ ...s,
31
+ exclude: u,
32
+ esbuildOptions: {
33
+ ...s.esbuildOptions,
34
+ plugins: [
35
+ ...((l = s.esbuildOptions) == null ? void 0 : l.plugins) || [],
36
+ {
37
+ name: "vue-wswg-editor-virtual-modules",
38
+ setup(i) {
39
+ i.onResolve({ filter: /^vue-wswg-editor:/ }, () => ({ external: !0 }));
40
+ }
41
+ }
42
+ ]
43
+ }
44
+ }
45
+ };
46
+ },
47
+ resolveId(t) {
48
+ if (t.startsWith("vue-wswg-editor:")) {
49
+ const o = t.replace("vue-wswg-editor:", "");
50
+ if (o in e)
51
+ return e[o];
52
+ }
53
+ if (Object.values(e).includes(t))
54
+ return t;
55
+ },
56
+ load(t) {
57
+ switch (t) {
58
+ case e.layouts:
59
+ return `export const modules = import.meta.glob("${r.rootDir}/*/layout/**/*.vue", { eager: true });`;
60
+ case e.blocks:
61
+ return `export const modules = import.meta.glob("${r.rootDir}/*/blocks/**/*.vue", { eager: true });`;
62
+ case e.fields:
63
+ return `export const modules = import.meta.glob("${r.rootDir}/*/blocks/**/fields.ts", { eager: true });`;
64
+ case e.thumbnails:
65
+ return `export const modules = import.meta.glob(["${r.rootDir}/*/blocks/**/thumbnail.png", "${r.rootDir}/*/thumbnail.jpg", "${r.rootDir}/*/thumbnail.png"], { eager: true });`;
66
+ case e.themes:
67
+ return `export const modules = import.meta.glob("${r.rootDir}/**/theme.config.js", { eager: true });`;
68
+ default:
69
+ return;
70
+ }
71
+ },
72
+ transform(t, s) {
73
+ if (Object.values(e).includes(s))
74
+ return null;
75
+ }
76
+ };
77
+ }
78
+ export {
79
+ a as vueWswgEditorPlugin
80
+ };