motla / vue-document-editor

:page_facing_up: Paper-sized WYSIWYG document editor for Vue apps
https://motla.github.io/vue-document-editor/
MIT License
313 stars 70 forks source link

Infinite Recursion in Word Wrapping for Long Continuous Words #47

Open Yogesh0627 opened 2 months ago

Yogesh0627 commented 2 months ago

Describe the bug

There is a bug in the library related to handling long continuous words that do not contain spaces. When a user types or inputs a continuous word that exceeds the width of the page, the library enters an infinite recursion loop while attempting to fit the content onto the next page. This occurs because the word does not break or wrap properly, causing the library to repeatedly attempt to fit the overflowing content onto subsequent pages.

To Reproduce

  1. Type or Input a Long Continuous Word: Enter a very long word or string without any spaces, exceeding the width of the page or container.

  2. Observe Crash as there are no consoles at this stage so you can't check for inspect: As the content overflows the current page, the library attempts to fit the word onto the next page. Since the word still does not fit, the library continues this process recursively.

  3. Infinite Recursion: The process continues indefinitely as the library is unable to handle the overflow properly, leading to an infinite recursion loop.

Expected behavior

Word Wrapping or Breaking: The library should handle long continuous words gracefully by either breaking the word into smaller parts or applying some form of word wrapping.

Prevent Infinite Recursion: The library should avoid entering an infinite loop and should instead handle the overflow by providing a clear indication or solution, such as a horizontal scrollbar or text overflow handling mechanism.

Infinite Recursion Loop: The library fails to manage the overflow of long continuous words, resulting in an infinite recursion loop as it continuously attempts to fit the word onto the next page, which is also unable to accommodate the word.

Actual Behavior

Infinite Recursion Loop: The library fails to manage the overflow of long continuous words, resulting in an infinite recursion loop as it continuously attempts to fit the word onto the next page, which is also unable to accommodate the word.

Impact

Rendering Issues: Users experience rendering issues when long words are entered, making it impossible to view or interact with the content properly. Performance Problems: The infinite recursion can lead to performance problems, such as excessive CPU usage and potential crashes.

Proposed Solution Implement Word Breaking: Introduce logic to break long continuous words into smaller chunks that can fit within the page width. Word Wrapping: Implement word wrapping techniques to handle long words that exceed the page width. Error Handling: Add error handling to detect and manage cases where content overflow cannot be resolved through normal means, such as providing an option to scroll horizontally or adjust the layout.