mirror of
https://github.com/KoboldAI/KoboldAI-Client.git
synced 2025-06-05 21:59:24 +02:00

Today I learned that the editor only works properly when the last <chunk> tag has a <br> inside it at the end. This last <br> is invisible and is automatically created by all major browsers when you use the enter key to type a newline at the end of a story to "prevent the element from collapsing". When there's more than one <br> at the end of the last <chunk>, only the last of those <br>s is invisible, so if you have three <br>s, they are rendered as two newlines. This only applies to the last <chunk>, so if the second last <chunk> has three <br>s at the end, they are still rendered as three newlines. Since the browser is really insistent on doing this, this commit mostly deals with dynamically creating and deleting <br> tags at the ends of <chunk> tags as needed to provide a consistent experience, and making sure that all <br> tags actually go inside of <chunk> tags to prevent breaking the editor. The latter behaviour was exhibited by Chrome and caused a bug when you added a newline at the end of your story using the editor.