Skip to content

Conversation

@KarlHeitmann
Copy link

Summary

Converts text-editor.tsx into a folder with an index file to orchestrate
all TextEditor related components living under the new folder named
text-editor/

Pull Request

This is a proposal to simplify the big file text-editor.tsx (1000+ lines) into smaller chunks.

This is an idea I had some years ago meant to simplify big files. I call it "fractal refactor". I call it fractal refactor because it reminds me of fractals (or Matryoshka dolls).

When using a composable API like React Hooks or Vue Composition API (function calls) and you have a big file (1000+ lines), there are good chances you have related code you can move into a single file.

How can you achieve this without having a folder with countless files, and their names are colliding? Just create a folder with the name of your big file (remove the extension), move your big file inside this folder and rename it as index.tsx. Now you can move the related code into their own files living inside this new folder. The index.tsx will be the orchestra conductor that will import its sibling files and compose the big file.

If one of the sibling files grows big in number of lines, you can repeat the process: create a new folder with its name, and move the sibling file inside and rename it as index.tsx. That's why I call it "fractal refactor" (Matryoshka dolls)

Description

I created a new folder: src/components/editor/core/text-editor, renamed the src/components/editor/core/text-editor.tsx file as index.tsx and moved it inside the folder: src/components/editor/core/text-editor/index.tsx.

I moved all the other files inside the folder src/components/editor/core/ into this new folder, because I figured out these files were used only by text-editor.tsx, so they are tied to this component. (line-based-editor.tsx, editor-layers.tsx and keyboard-shortcuts.ts)

I think all commits can be squashed into one, but I decided to keep them for clarity (maybe if they are squashed it can be easier to understand 😄 )

Related Issues

None

Converts text-editor.tsx into a folder with an index file to orchestrate
all TextEditor related components living under the new folder named
text-editor/
@mehmetozguldev mehmetozguldev self-requested a review October 29, 2025 23:57
@mehmetozguldev mehmetozguldev added type: improvement An improvement to existing feature area: editor Specific to editor labels Oct 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: editor Specific to editor type: improvement An improvement to existing feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants