# guodu888/guodu-tiptap architecture

> Architecture diagram of the GitHub repository guodu888/guodu-tiptap, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-03). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/guodu888/guodu-tiptap
- Repository: https://github.com/guodu888/guodu-tiptap

## Overview

The Guodu Tiptap Editor is a rich-text, WYSIWYG editor built on top of the tiptap framework and implemented with TypeScript. Its goal is to offer an extensive set of editing capabilities via numerous extensions, including both text marks (like bold, italic, underline, etc.) and nodes (like headings, lists, images, tables, etc.). The project also includes additional utility extensions (such as commands, history, and import-word) that enhance the editing experience.

##### Project Overview
- Type & Purpose: As indicated in the README and evidenced by the file structure, this is a frontend library and demo (via the playground) for a rich-text editor. It integrates many tiptap extensions to deliver WYSIWYG editing.
- Key Use Cases: Supporting rich text formatting, markdown support, embedding of media elements, and providing modular, extensible editing functionality.

##### High-Level Component Breakdown
a. Core Editor and Extensions:
- Editor Core: The main editor functionality is wired in src/index.ts and src/Tiptap.vue component, which initializes and configures the tiptap editor.
- Extensions: Located under src/extensions, these files/modules define various plugin functionalities—divided into categories:
- Marks (e.g., bold, italic, underline, code, etc.)
- Nodes (list, table, image, etc.)

b. User Interface Components:
- Menu Commands: Under src/components/MenuCommands and its subdirectories, these components represent UI controls (buttons, popovers, etc.) for text formatting.
- Bubble Menus: Found in src/components/MenuBubble, offering context-sensitive controls.
- Extension Views: In src/components/ExtensionViews, for rendering specialized views (like image or mathematical content).
- Other UI Elements: Additional controls like the MenuBar and GuoduIcon in src/components.

c. Playground/Demo Application:
- Playground: An isolated demo folder containing a Vue-based application (App.vue, pages, composables, etc.) to demonstrate and test the editor’s functionalities.
- This part is crucial for visualizing how the core editor integrates with UI components and how extensions interact in a real-world scenario.

d. Utility and Configuration Files:
- Configurations: Vite (vite.config.ts), tsconfig.json, and unocss.config.ts manage the build and styling.
- Build/CI: .github workflows and package management files (package.json, pnpm-lock.yaml) represent deployment and testing pipelines.
- TypeScript Declarations: auto-imports.d.ts, components.d.ts, shims.d.ts help with development experience.

##### Relationships and Data Flow
- The central Editor Core acts as a hub where numerous extensions are injected, allowing for modular augmentation of the editor’s capabilities.
- UI Components (menu commands, bubble menus) interact with the Editor Core by triggering extension commands or updating the editor state.
- User actions (button clicks, text input) flow through these UI layers and eventually trigger changes in the editor’s state, which then results in visual updates in the content.
- The Playground acts as a sandbox to demonstrate these interactions interactively.

##### Architectural Patterns
- Modular Design: The system is structured into modular extensions (each extension in its own file), making it easy to extend or replace functionality.
- Component-based UI: Utilizing Vue components (as seen in the Playground and src/components) ensures clear separation of concerns between presentation and logic.
- Separation of Concerns: Editor core, UI controls, and extension logic are separated into dedicated directories.

- Labels: Every component should have clear labels (e.g., "Editor Core," "Extension: Bold," "Menu Command: Fullscreen," "Demo App (Playground)").
- Grouping: Group related components (like all UI components or all extensions) together visually for clarity.
- Annotations: Optionally, include annotations to highlight the architectural pattern (modular, component-based) and any significant technology choices.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Editor Core and Extensions
    subgraph "Core & Extensions"
        EditorCore["Editor Core"]:::core
        Extensions["Extensions Modules"]:::extension
    end

    %% UI Components Group
    subgraph "UI Components"
        MenuCommands["Menu Commands"]:::ui
        BubbleMenus["Bubble Menus"]:::ui
        ExtensionViews["Extension Views"]:::ui
        MenuBar["Menu Bar"]:::ui
        GuoduIcon["Guodu Icon"]:::ui
    end

    %% Playground / Demo Application
    Playground["Demo App (Playground)"]:::playground

    %% Utility and Configuration Group
    subgraph "Utility & Configuration"
        BuildConfig["Build/Config Files"]:::config
        TSDeclarations["TypeScript Declarations"]:::config
        CI_CD["CI/CD & Deployment"]:::config
    end

    %% Relationships
    MenuCommands -->|"TriggersCommand"| EditorCore
    BubbleMenus -->|"TriggersCommand"| EditorCore
    ExtensionViews -->|"TriggersCommand"| EditorCore
    MenuBar -->|"InteractsWith"| EditorCore
    GuoduIcon -->|"InteractsWith"| EditorCore

    EditorCore -->|"UsesExtensionAPI"| Extensions
    EditorCore -->|"UpdatesState"| MenuCommands
    EditorCore -->|"UpdatesState"| BubbleMenus
    EditorCore -->|"UpdatesState"| ExtensionViews

    Playground -->|"Integrates"| EditorCore
    Playground -->|"Integrates"| MenuCommands
    Playground -->|"Integrates"| BubbleMenus
    Playground -->|"Integrates"| ExtensionViews
    Playground -->|"Integrates"| MenuBar
    Playground -->|"Integrates"| GuoduIcon

    BuildConfig ---|"Configures"| EditorCore
    BuildConfig ---|"Configures"| Playground
    TSDeclarations ---|"Supports"| EditorCore
    CI_CD ---|"Deploys"| Playground

    %% Click Events
    click EditorCore "https://github.com/guodu888/guodu-tiptap/blob/main/src/Tiptap.vue"
    click Extensions "https://github.com/guodu888/guodu-tiptap/tree/main/src/extensions"
    click MenuCommands "https://github.com/guodu888/guodu-tiptap/tree/main/src/components/MenuCommands"
    click BubbleMenus "https://github.com/guodu888/guodu-tiptap/tree/main/src/components/MenuBubble"
    click ExtensionViews "https://github.com/guodu888/guodu-tiptap/tree/main/src/components/ExtensionViews"
    click MenuBar "https://github.com/guodu888/guodu-tiptap/tree/main/src/components/MenuBar"
    click GuoduIcon "https://github.com/guodu888/guodu-tiptap/blob/main/src/components/GuoduIcon.vue"
    click Playground "https://github.com/guodu888/guodu-tiptap/tree/main/playground"
    click BuildConfig "https://github.com/guodu888/guodu-tiptap/blob/main/vite.config.ts"
    click TSDeclarations "https://github.com/guodu888/guodu-tiptap/blob/main/auto-imports.d.ts"
    click CI_CD "https://github.com/guodu888/guodu-tiptap/blob/main/.github/workflows/test.yml"

    %% Styles
    classDef core fill:#f9e79f,stroke:#d35400,stroke-width:2px;
    classDef extension fill:#aed6f1,stroke:#2471a3,stroke-width:2px;
    classDef ui fill:#d5f5e3,stroke:#27ae60,stroke-width:2px;
    classDef playground fill:#f5b7b1,stroke:#c0392b,stroke-width:2px;
    classDef config fill:#d2b4de,stroke:#8e44ad,stroke-width:2px;
```
