@craftile/editor 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.
@@ -0,0 +1,2 @@
1
+ import { I18n } from '../types';
2
+ export declare const en: I18n;
@@ -0,0 +1,25 @@
1
+ export interface DevicePreset {
2
+ id: string;
3
+ label: string;
4
+ width: number;
5
+ icon?: string;
6
+ }
7
+ interface DevicesState {
8
+ currentDevice: string;
9
+ savedCustomDevices: DevicePreset[];
10
+ }
11
+ export interface DevicesManagerOptions {
12
+ presets?: DevicePreset[];
13
+ default?: string;
14
+ }
15
+ export declare class DevicesManager {
16
+ readonly state: DevicesState;
17
+ readonly devicePresets: DevicePreset[];
18
+ constructor(options?: DevicesManagerOptions);
19
+ getCurrentDeviceData(): DevicePreset;
20
+ setDeviceMode(deviceId: string): void;
21
+ addCustomDevice(device: DevicePreset): void;
22
+ removeCustomDevice(deviceId: string): void;
23
+ getAllDevices(): DevicePreset[];
24
+ }
25
+ export {};
@@ -0,0 +1,28 @@
1
+ import { EventBus } from '@craftile/event-bus';
2
+ import { PreviewManager } from './preview';
3
+ import { UIManager } from './ui';
4
+ export interface InspectorState {
5
+ enabled: boolean;
6
+ hoveredBlockId: string | null;
7
+ hoveredBlockRect: DOMRect | null;
8
+ hoveredParentRect: DOMRect | null;
9
+ parentFlexDirection: 'row' | 'column';
10
+ selectedBlockId: string | null;
11
+ selectedBlockRect: DOMRect | null;
12
+ iframeRect: DOMRect | null;
13
+ }
14
+ export declare class InspectorManager {
15
+ readonly state: InspectorState;
16
+ private events;
17
+ private preview;
18
+ private ui;
19
+ constructor(events: EventBus, preview: PreviewManager, ui: UIManager);
20
+ enable(): void;
21
+ disable(): void;
22
+ toggle(): void;
23
+ setHoveredBlock(blockId: string, blockRect: DOMRect, parentRect?: DOMRect): void;
24
+ setSelectedBlock(blockId: string, blockRect: DOMRect): void;
25
+ clearHoveredBlock(): void;
26
+ clearSelectedBlock(): void;
27
+ setIframeRect(rect: DOMRect): void;
28
+ }
@@ -0,0 +1,12 @@
1
+ import { App } from 'vue';
2
+ import { CraftileEditor } from '../editor';
3
+ import { CraftileEditorPlugin } from '../types/plugin';
4
+ export declare class PluginsManager {
5
+ private editor;
6
+ private plugins;
7
+ constructor(editor: CraftileEditor);
8
+ setupPlugins(vueApp: App): void;
9
+ register(plugin: CraftileEditorPlugin): PluginsManager;
10
+ unregister(plugin: CraftileEditorPlugin): PluginsManager;
11
+ getAllPlugins(): CraftileEditorPlugin[];
12
+ }
@@ -0,0 +1,25 @@
1
+ import { TypedMessage } from '@craftile/messenger';
2
+ import { WindowMessages } from '@craftile/types';
3
+ export interface PreviewState {
4
+ previewUrl: string;
5
+ previewFrame: HTMLIFrameElement | null;
6
+ isIframeReady: boolean;
7
+ messageQueue: TypedMessage[];
8
+ }
9
+ export declare class PreviewManager {
10
+ readonly state: PreviewState;
11
+ private messenger;
12
+ private readyListenerInitialized;
13
+ private readyCallbacks;
14
+ constructor();
15
+ loadUrl(url: string): void;
16
+ loadFromHtml(html: string): void;
17
+ reload(): void;
18
+ getFrame(): HTMLIFrameElement | null;
19
+ _registerFrame(frame: HTMLIFrameElement): void;
20
+ sendMessage<T extends keyof WindowMessages>(type: T, payload?: WindowMessages[T]): void;
21
+ onMessage<T extends keyof WindowMessages>(type: T, handler: (data: WindowMessages[T], event: MessageEvent) => void): () => void;
22
+ onReady(fn: () => void): void;
23
+ runReadyCallbacks(): void;
24
+ private flushMessageQueue;
25
+ }
@@ -0,0 +1,41 @@
1
+ import { createToaster } from '@ark-ui/vue/toast';
2
+ import { EventBus } from '@craftile/event-bus';
3
+ import { ConfigurationPanel, HeaderAction, KeyboardShortcut, ModalConfig, PropertyFieldConfig, SidebarPanel } from './../types/ui';
4
+ export interface UIState {
5
+ activeSidebarPanel: string;
6
+ sidebarPanels: Map<string, SidebarPanel>;
7
+ headerActions: Map<string, HeaderAction>;
8
+ configurationPanels: Map<string, ConfigurationPanel>;
9
+ modals: Map<string, ModalConfig>;
10
+ openModals: string[];
11
+ keyboardShortcuts: Map<string, KeyboardShortcut>;
12
+ propertyFields: Map<string, PropertyFieldConfig>;
13
+ selectedBlockId: string | null;
14
+ layersPanel: {
15
+ expandedBlocks: Set<string>;
16
+ };
17
+ }
18
+ export declare class UIManager {
19
+ private events;
20
+ readonly state: UIState;
21
+ readonly toaster: ReturnType<typeof createToaster>;
22
+ constructor(events: EventBus);
23
+ private generateId;
24
+ setSelectedBlock(blockId: string | null): void;
25
+ clearSelectedBlock(): void;
26
+ toast(titleOrOptions: string | Parameters<typeof this.toaster.create>[0]): void;
27
+ registerSidebarPanel(config: SidebarPanel): void;
28
+ removeSidebarPanel(panelId: string): void;
29
+ registerHeaderAction(config: HeaderAction): void;
30
+ removeHeaderAction(actionId: string): void;
31
+ registerConfigurationPanel(config: ConfigurationPanel): void;
32
+ removeConfigurationPanel(panelId: string): void;
33
+ registerPropertyField(config: PropertyFieldConfig): void;
34
+ removePropertyField(type: string): void;
35
+ registerModal(config: ModalConfig): void;
36
+ unregisterModal(id: string): void;
37
+ openModal(id: string): void;
38
+ closeModal(id: string): void;
39
+ registerKeyboardShortcut(config: KeyboardShortcut): void;
40
+ removeKeyboardShortcut(key: string): void;
41
+ }
@@ -0,0 +1,67 @@
1
+ /**
2
+ * Internationalization (i18n) grouped string definitions for the editor
3
+ */
4
+ export interface I18n {
5
+ header: {
6
+ undo: string;
7
+ redo: string;
8
+ auto: string;
9
+ apply: string;
10
+ devicePreview: string;
11
+ customDeviceSize: string;
12
+ deviceWidthPx: string;
13
+ savedCustomDevices: string;
14
+ enableInspector: string;
15
+ disableInspector: string;
16
+ };
17
+ block: {
18
+ show: string;
19
+ hide: string;
20
+ duplicate: string;
21
+ remove: string;
22
+ moveToNext: string;
23
+ moveToPrevious: string;
24
+ enable: string;
25
+ disable: string;
26
+ };
27
+ layers: {
28
+ title: string;
29
+ header: string;
30
+ collapseAll: string;
31
+ addBlockToBlock: string;
32
+ };
33
+ blocksPopover: {
34
+ searchPlaceholder: string;
35
+ tabBlocks: string;
36
+ tabSaved: string;
37
+ noBlocksAvailable: string;
38
+ noBlocksFound: string;
39
+ };
40
+ configPanels: {
41
+ properties: string;
42
+ selectedBlock: string;
43
+ noProperties: string;
44
+ unknownFieldType: string;
45
+ };
46
+ common: {
47
+ block: string;
48
+ custom: string;
49
+ close: string;
50
+ default: string;
51
+ };
52
+ }
53
+ /**
54
+ * Deep partial type for nested i18n configuration
55
+ */
56
+ type DeepPartial<T> = {
57
+ [P in keyof T]?: T[P] extends object ? DeepPartial<T[P]> : T[P];
58
+ };
59
+ /**
60
+ * Partial i18n configuration - allows users to override only specific strings
61
+ */
62
+ export type I18nConfig = DeepPartial<I18n>;
63
+ /**
64
+ * Type for translation keys using dot notation
65
+ */
66
+ export type TranslationKey = `header.${keyof I18n['header']}` | `block.${keyof I18n['block']}` | `layers.${keyof I18n['layers']}` | `blocksPopover.${keyof I18n['blocksPopover']}` | `configPanels.${keyof I18n['configPanels']}` | `common.${keyof I18n['common']}`;
67
+ export {};
@@ -0,0 +1,3 @@
1
+ export * from './ui';
2
+ export * from './i18n';
3
+ export * from './plugin';
@@ -0,0 +1,7 @@
1
+ import { App } from 'vue';
2
+ import { CraftileEditor } from '../editor';
3
+ export interface PluginContext {
4
+ vueApp: App;
5
+ editor: CraftileEditor;
6
+ }
7
+ export type CraftileEditorPlugin = (context: PluginContext) => void;
@@ -0,0 +1,53 @@
1
+ import { CraftileEditor } from './../editor';
2
+ import { PropertyField } from '@craftile/types';
3
+ import { Component } from 'vue';
4
+ export interface UiRenderFunctionContext {
5
+ editor: CraftileEditor;
6
+ }
7
+ export type UiRenderFunction = Component | string | ((context: UiRenderFunctionContext) => HTMLElement);
8
+ export interface SidebarPanel {
9
+ id?: string;
10
+ title: string;
11
+ render: UiRenderFunction;
12
+ icon?: UiRenderFunction;
13
+ order?: number;
14
+ }
15
+ export interface HeaderActionButton {
16
+ text: string;
17
+ variant?: 'default' | 'primary' | 'destructive' | 'secondary' | 'accent';
18
+ onClick: () => void;
19
+ }
20
+ export interface HeaderAction {
21
+ id?: string;
22
+ slot: 'left' | 'center' | 'right';
23
+ render?: UiRenderFunction;
24
+ button?: HeaderActionButton;
25
+ order?: number;
26
+ }
27
+ export interface ConfigurationPanel {
28
+ id?: string;
29
+ title: string;
30
+ icon?: UiRenderFunction;
31
+ render: UiRenderFunction;
32
+ order?: number;
33
+ }
34
+ export interface ModalConfig {
35
+ id?: string;
36
+ title?: string;
37
+ render: UiRenderFunction;
38
+ size?: 'xs' | 'sm' | 'md' | 'lg' | 'xl' | '2xl' | 'full';
39
+ }
40
+ export interface KeyboardShortcut {
41
+ key: string;
42
+ handler: (context: UiRenderFunctionContext) => void;
43
+ }
44
+ export interface FieldRenderProps {
45
+ field: PropertyField;
46
+ value: unknown;
47
+ onChange: (value: unknown) => void;
48
+ onBlur?: () => void;
49
+ }
50
+ export interface PropertyFieldConfig {
51
+ type: string;
52
+ render: string | Component | ((props: FieldRenderProps) => HTMLElement);
53
+ }
@@ -0,0 +1,7 @@
1
+ import { Component } from 'vue';
2
+ /**
3
+ * Check if a render value is a Vue component
4
+ */
5
+ export declare function isVueComponent(render: any): render is Component;
6
+ export declare function isComponentString(render: any): render is string;
7
+ export declare function isHtmlRenderFunction(render: any): render is (context: any) => HTMLElement;
@@ -0,0 +1,15 @@
1
+ import { Engine } from '@craftile/core';
2
+ import { UpdatesEvent } from '@craftile/types';
3
+ export interface WatchEngineUpdatesOptions {
4
+ debounceMs?: number;
5
+ onUpdates: (updates: UpdatesEvent) => void;
6
+ }
7
+ /**
8
+ * Watch engine events and emit aggregated updates
9
+ *
10
+ * @param engine The Craftile engine instance
11
+ * @param options Configuration options
12
+ *
13
+ * @returns Cleanup function to remove all listeners
14
+ */
15
+ export declare function watchEngineUpdates(engine: Engine, options?: WatchEngineUpdatesOptions): () => void;
package/package.json ADDED
@@ -0,0 +1,68 @@
1
+ {
2
+ "name": "@craftile/editor",
3
+ "version": "0.1.0",
4
+ "description": "Vue.js-based editor UI components for craftile blocks engine",
5
+ "keywords": [
6
+ "craftile",
7
+ "vue",
8
+ "editor",
9
+ "ui",
10
+ "components"
11
+ ],
12
+ "license": "MIT",
13
+ "authors": [
14
+ {
15
+ "name": "Eldo Magan",
16
+ "email": "magan.eldo@gmail.com"
17
+ }
18
+ ],
19
+ "type": "module",
20
+ "main": "./dist/index.cjs",
21
+ "module": "./dist/index.js",
22
+ "types": "./dist/index.d.ts",
23
+ "exports": {
24
+ ".": {
25
+ "types": "./dist/index.d.ts",
26
+ "source": "./src/index.ts",
27
+ "import": "./dist/index.js",
28
+ "require": "./dist/index.cjs"
29
+ }
30
+ },
31
+ "files": [
32
+ "dist"
33
+ ],
34
+ "dependencies": {
35
+ "vue": "^3.5.17",
36
+ "vue-draggable-plus": "^0.6.0",
37
+ "@craftile/core": "0.1.0",
38
+ "@craftile/event-bus": "0.1.0",
39
+ "@craftile/messenger": "0.1.0",
40
+ "@craftile/types": "0.1.0"
41
+ },
42
+ "devDependencies": {
43
+ "@ark-ui/vue": "^5.24.1",
44
+ "@iconify-json/heroicons": "^1.2.2",
45
+ "@tailwindcss/vite": "^4.1.11",
46
+ "@vitejs/plugin-vue": "^6.0.0",
47
+ "postcss-prefixwrap": "^1.56.2",
48
+ "tailwindcss": "^4.1.11",
49
+ "typescript": "~5.8.3",
50
+ "unplugin-auto-import": "^19.3.0",
51
+ "unplugin-icons": "^22.1.0",
52
+ "unplugin-vue-components": "^28.8.0",
53
+ "vite": "^7.0.0",
54
+ "vite-plugin-css-injected-by-js": "^3.5.2",
55
+ "vite-plugin-dts": "^4.5.4"
56
+ },
57
+ "repository": {
58
+ "type": "git",
59
+ "url": "git+https://github.com/craftile/editor.git"
60
+ },
61
+ "publishConfig": {
62
+ "access": "public"
63
+ },
64
+ "scripts": {
65
+ "dev": "tsc && vite build --watch",
66
+ "build": "tsc && vite build"
67
+ }
68
+ }