EpicDesigner Documentation

repository·develop·Indexed 20 days ago

https://github.com/kchengz/epic-designer

A Vue 3-based low-code visual designer for building complex UIs via drag-and-drop. It consists of EDesigner for creating JSON configurations and EBuilder for rendering those configurations into functional pages. The ecosystem includes @epic-designer/manager for page and plugin management, @epic-designer/utils for core utility functions, and official support for UI libraries including Element Plus, Ant Design Vue, and Naive UI.

Tokens
49.4K
Snippets
149
Records
217
Agent score
71%

What's inside EpicDesigner

  1. What is EpicDesigner

    develop
    EpicDesigner is a powerful, out-of-the-box drag-and-drop low-code visual designer built on Vue 3. It uses JSON configurations to generate pages, allowing developers to quickly build and customize UIs. It is designed to be highly extensible, supporting custom actions, components, layouts, events, and plugins. It is compatible with multiple UI libraries including Element Plus, Ant Design Vue, and Naive UI.
  2. Key features of EpicDesigner

    develop

    EpicDesigner provides several capabilities for low-code page development:

    • Visual Page Configuration: Drag-and-drop interface for building layouts.
    • Output Options: Support for previewing, saving, generating JSON, and generating executable code.
    • Form Support: Built-in support for form validation.
    • Extensibility:
      • Custom panel configuration.
      • Custom component extensions.
      • Custom component property configurations.
      • Custom component style configurations.
      • Custom component event and action configurations.
    • Layout Management: Supports nested layouts and layout component extensions.
  3. License and usage terms for epic-designer

    develop

    The epic-designer project is licensed under the MIT License. This allows for free use in commercial applications, provided that all copies or substantial portions of the software include the original copyright notice and permission notice.

    Important Note: Users must comply with national laws and regulations. Use of this software for illegal projects is strictly prohibited.

    MIT License
    
    Copyright (c) 2022 kchengz
    
    Permission is hereby granted, free of charge, to any person obtaining a copy
    of this software and associated documentation files (the "Software"), to deal
    in the Software without restriction, including without limitation the rights
    to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
    copies of the Software, and to permit persons to whom the Software is
    furnished to do so, subject to the following conditions:
    
    The above copyright notice and this permission notice shall be included in all
    copies or substantial portions of the Software.
    
    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
    AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
    LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
    OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
    SOFTWARE.
  4. What is the pluginManager and how to use it?

    develop

    The pluginManager is the core component of Epic Designer. It is responsible for managing components, panels, and public methods within the designer. It provides a complete API to register, query, and control the visibility of various designer elements.

    To use it, import it directly from epic-designer:

    import { pluginManager } from 'epic-designer';
    import { pluginManager } from 'epic-designer';
  5. Understand the Epic Designer interface layout

    develop

    The Epic Designer interface is organized into several functional areas to facilitate design and generation tasks:

    • Activity Bar (活动栏): Likely contains primary navigation or tool switching.
    • Sidebar (侧边栏): Typically used for managing project assets, components, or layers.
    • Status Bar (状态栏): Displays current system status, versioning, or configuration info.
    • Editor Area (编辑区域): The main workspace where design and layout work occurs.
    • Right Sidebar (右边侧边栏): Usually reserved for property inspectors, settings, or detailed configuration of selected elements.
    • Page Manager (页面管理器): Used for navigating between different pages or views within a project.
    • Extension Manager (扩展管理器): Used to manage plugins or external extensions for the designer.
    • Custom Scripting (自定义脚本编写): Provides an interface for writing custom logic to extend designer behavior.
  6. Extend component registration with custom styles and icons

    develop

    When registering custom components, you can extend their configuration:

    • Style Panel Extension: Custom components can register configurations to extend the properties/style panel.
    • Icons: Component icons can be extended using the iconify icon library. Note that in newer versions, the icon property should be placed inside the defaultSchema object rather than at the top level of the registration config.
    • Sorting: You can add a sort field to the component registration to control its order.
    • Constraints: Use editConstraints to define constraints for the component's configuration.
    • Fixed Fields: Use the fixedField field to lock a form item's field property, preventing the automatic addition of a UUID.
  7. Use Custom Functions to implement custom logic

    develop

    Custom Functions allow you to implement specific logic and behaviors within the designer. Within a custom function block, you have access to an epic object. You can use this object to interact with the page and its components.

    To make your functions available to the designer's event system (e.g., to be called by a component's change or input event), you must use the defineExpose method to expose them.

    const { defineExpose, find } = epic;
    
    function test(e) {
      // Use find(id) to get a component instance and set its attributes
      find("ho0tpt7i7tc00").setAttr("hidden", e);
    }
    
    function setDisabled(e) {
      find("ho0tpt7i7tc00").setAttr("disabled", e);
    }
    
    // Expose functions to the designer
    defineExpose({
      test,
      setDisabled,
    });
  8. What are EDesigner and EBuilder

    develop

    EpicDesigner is a drag-and-drop low-code designer built on Vue 3 that uses JSON configurations to generate pages. It consists of two primary components:

    1. EDesigner (The Designer): A visual component that allows users to drag and drop components to generate a JSON configuration. It supports real-time preview, component property configuration, event/action binding, and exporting the resulting JSON.
    2. EBuilder (The Builder): A page construction component that consumes the JSON configuration generated by EDesigner. It handles component rendering, event binding, and data echoing to turn the JSON into a functional page.

    This workflow allows developers to bridge the gap between visual design and executable code via a standardized JSON schema.

  9. How EDesigner and EBuilder work together

    develop

    EpicDesigner operates through two core components that form a complete low-code workflow:

    1. EDesigner (The Designer): A visual component that allows users to drag and drop components to create a page. The designer outputs a JSON configuration representing the page structure, properties, and events.
    2. EBuilder (The Builder/Generator): A rendering component that takes the JSON configuration generated by EDesigner and transforms it into a functional page, handling component rendering, event binding, and data binding.

    Workflow: Use EDesigner to create/edit the JSON schema $\rightarrow$ Save the JSON $\rightarrow$ Use EBuilder with that JSON to render the final page in your application.

  10. How useEventBus works for component communication

    develop

    The useEventBus Hook provides a publish-subscribe mechanism for communication between components. It supports two distinct communication channels:

    1. Scope Channel (Default): Used for communication within a specific component tree. This is the standard channel for most component-to-component interactions.
    2. Root Channel: A global channel used for broadcasting events across different component trees.

    Key Features:

    • Event Caching: The bus automatically caches the last 10 emitted events. When a new listener is registered via on or onRoot, it will immediately trigger the callback with the most recent cached event, ensuring no critical events are missed during the registration phase.
    • Automatic Cleanup: Listeners registered with on or onRoot are automatically unsubscribed when the component is unmounted, preventing memory leaks. The channel itself is cleaned up when no listeners remain.
    • Dependency Injection: The event bus is typically created by a builder component via createEventBus and provided to child components via dependency injection.
    <script lang="ts" setup>
    import { useEventBus } from 'epic-designer'
    
    // Access the event bus instance
    const eventBus = useEventBus()
    </script>
  11. What are Public Methods in Epic Designer

    develop

    Public Methods are a key feature that allows developers to provide preset functions to the designer. These methods can be used in two ways:

    1. Action Configuration: Users can select these preset methods within the designer's action configuration UI.
    2. Custom Coding: Developers can call these methods within custom functions, which is useful for exposing utility functions like route instances or user state hooks to the designer environment.
  12. Configure a component with ComponentConfigModel

    develop

    The ComponentConfigModel interface defines how a custom component is integrated into the designer.

    Key properties include:

    • component: The Vue component itself (can be a component object, an async import function, or a string component name).
    • groupName: The category name under which the component appears in the list. Note: If this is not set, the component will be registered but will not appear in the UI list.
    • icon: The icon used for the component in the list.
    • sort: Controls the order in the list (default 1000; lower values appear earlier).
    • defaultSchema: The initial data structure (props and type) used when the component is dragged onto the canvas.
    • bindModel: The name of the v-model variable for input components (defaults to modelValue).
    • editConstraints: Constraints for designer interactions (e.g., immovable, locked).
    • config: Defines the UI for the property panels:
      • attribute: List of properties editable in the Attribute panel.
      • event: List of events available in the Event panel.
      • style: List of style properties available in the Style panel.
      • action: List of executable functions available in the Action panel.
    import { type ComponentConfigModel } from 'epic-designer'
    
    export default {
      component: async () => await import('./index.vue'),
      groupName: "Custom Group",
      icon: "epic-icon-write",
      sort: 900,
      defaultSchema: {
        label: 'My Component',
        type: 'my-type',
        props: {
          label: 'Default Label'
        }
      },
      config: {
        attribute: [
          { label: 'Title', type: 'input', field: 'label', value: 'Default' }
        ],
        event: [
          { type: 'click', description: 'Triggered on click' }
        ],
        style: [
          { label: 'BG Color', type: 'color', field: 'backgroundColor', value: '#f9f9f9' }
        ]
      }
    } as ComponentConfigModel