# ph4zel/persiantextedit architecture

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

- Interactive diagram: https://gitdiagram.com/ph4zel/persiantextedit
- Repository: https://github.com/ph4zel/persiantextedit

## Overview

This project is a Godot Engine plugin designed to enhance text editing capabilities in Persian by adding custom nodes (PersianTextEdit, PersianLabel, and PersianButton) along with additional resources like custom fonts, styles, and supporting scenes. The asset’s purpose is clearly defined in the README and is supported by the file structure, which adheres to Godot’s plugin conventions.

##### Main Components
- Godot Engine: The runtime environment in which the plugin operates.
- Plugin Loader/Manager: Represented by the “plugin.cfg” and the project settings that load the plugin.
- Plugin Core ("PersianTextEdit"): Contains all the custom nodes and scripts.
- Nodes:
- PersianTextEdit: Custom text editing node with signal (text_chaged) and logic for Persian text processing.
- PersianLabel: Displays Persian text with additional options (like right-to-left text formatting and reloading behavior).
- PersianButton: Custom button node inheriting functionality from PersianLabel.
- Supporting Resources:
- Scripts: All the custom GDscript files (CustomTextEdit.gd, Persian.gd, PersianButton.gd, etc.) implementing behaviors.
- Child Scenes: Under the “Childs” directory are scene files like RichTextLabel.tscn and TextEdit.tscn which serve as templates or extended controls.
- Fonts and Styles: Resources in the “Fonts” and “Style” folders which provide configurations for the asset’s visual appearance.
- Example Scene: A demonstration (Example.tscn) showing an implementation of the plugin.

##### Relationships and Interactions
- The Godot Engine initializes the project and reads the “project.godot” and “default_env.tres” configurations.
- The Plugin Manager in the engine triggers the loading of “plugin.cfg” found in the addons/PersianTextEdit folder.
- Upon activation, the custom nodes (PersianTextEdit, PersianLabel, PersianButton) become available in the Node creation list.
- When a developer adds one of these nodes to a scene, the associated scripts (located in the Scripts folder) are invoked to handle behavior such as text input processing, RTL (right-to-left) formatting, and signal emission.
- The Childs subdirectory provides alternative or customizable scene templates that can be used to alter the default behavior or appearance.
- Fonts and Style resources are loaded dynamically by the nodes based on settings, ensuring the Persian text is rendered correctly.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Godot Engine Layer
    subgraph "Godot Engine"
        G1("project.godot"):::engine
        G2("default_env.tres"):::engine
    end

    %% Plugin Loader/Manager Layer
    subgraph "Plugin Loader/Manager"
        L1("plugin.cfg"):::loader
        L2("PersianTextEditPlugin.gd"):::loader
    end

    %% Plugin Core Layer
    subgraph "Plugin Core"
        P1("PersianTextEdit.tscn"):::core
        P2("PersianTextEdit.gd"):::core
    end

    %% Custom Nodes and their Scripts
    subgraph "Custom Nodes"
        C1("PersianTextEdit Node"):::node
        S1("CustomTextEdit.gd"):::node
        S2("Persian.gd"):::node
        C2("PersianLabel Node"):::node
        C3("PersianButton Node"):::node
    end

    %% Resources Layer
    subgraph "Resources"
        R1("Font Resource"):::resource
        R2("Style1.tres"):::resource
        R3("transparent.tres"):::resource
        R4("RichTextLabel Scene"):::resource
        R5("TextEdit Scene"):::resource
    end

    %% Example Scene
    subgraph "Example"
        E1("Example Scene"):::scene
    end

    %% Connections
    G1 --> L1
    G2 --> L1
    L1 --> P1
    L2 --> P1
    P1 --> C1
    P1 --> C2
    P1 --> C3
    C1 --> S1
    C1 --> S2
    C3 -->|"inherits"| C2
    P1 --> R4
    P1 --> R5
    C1 -->|"loads"| R1
    C1 -->|"loads"| R2
    C1 -->|"loads"| R3
    C2 -->|"loads"| R1
    C2 -->|"loads"| R2
    C2 -->|"loads"| R3
    C3 -->|"loads"| R1
    C3 -->|"loads"| R2
    C3 -->|"loads"| R3
    E1 --> C1

    %% Click Events
    click G1 "https://github.com/ph4zel/persiantextedit/blob/main/project.godot"
    click G2 "https://github.com/ph4zel/persiantextedit/blob/main/default_env.tres"
    click L1 "https://github.com/ph4zel/persiantextedit/blob/main/addons/PersianTextEdit/plugin.cfg"
    click L2 "https://github.com/ph4zel/persiantextedit/blob/main/addons/PersianTextEdit/Scripts/PersianTextEditPlugin.gd"
    click P1 "https://github.com/ph4zel/persiantextedit/blob/main/addons/PersianTextEdit/PersianTextEdit.tscn"
    click P2 "https://github.com/ph4zel/persiantextedit/blob/main/addons/PersianTextEdit/Scripts/PersianTextEdit.gd"
    click S1 "https://github.com/ph4zel/persiantextedit/blob/main/addons/PersianTextEdit/Scripts/CustomTextEdit.gd"
    click S2 "https://github.com/ph4zel/persiantextedit/blob/main/addons/PersianTextEdit/Scripts/Persian.gd"
    click C2 "https://github.com/ph4zel/persiantextedit/blob/main/addons/PersianTextEdit/Scripts/PersianLabel.gd"
    click C3 "https://github.com/ph4zel/persiantextedit/blob/main/addons/PersianTextEdit/Scripts/PersianButton.gd"
    click R1 "https://github.com/ph4zel/persiantextedit/blob/main/addons/PersianTextEdit/Fonts/Font.tres"
    click R2 "https://github.com/ph4zel/persiantextedit/blob/main/addons/PersianTextEdit/Style/Style1.tres"
    click R3 "https://github.com/ph4zel/persiantextedit/blob/main/addons/PersianTextEdit/Style/transparent.tres"
    click R4 "https://github.com/ph4zel/persiantextedit/blob/main/addons/PersianTextEdit/Childs/RichTextLabel.tscn"
    click R5 "https://github.com/ph4zel/persiantextedit/blob/main/addons/PersianTextEdit/Childs/TextEdit.tscn"
    click E1 "https://github.com/ph4zel/persiantextedit/blob/main/Example.tscn"

    %% Styles
    classDef engine fill:#f9c,stroke:#333,stroke-width:2px;
    classDef loader fill:#bbf,stroke:#333,stroke-width:2px;
    classDef core fill:#9f9,stroke:#333,stroke-width:2px;
    classDef node fill:#ff9,stroke:#333,stroke-width:2px;
    classDef resource fill:#fc9,stroke:#333,stroke-width:2px;
    classDef scene fill:#cdf,stroke:#333,stroke-width:2px;
```
