diff --git a/src/DocumentEditor/imports/page-transition-mgmt.js b/src/DocumentEditor/imports/page-transition-mgmt.js
index b00103f..a128a98 100644
--- a/src/DocumentEditor/imports/page-transition-mgmt.js
+++ b/src/DocumentEditor/imports/page-transition-mgmt.js
@@ -25,7 +25,7 @@ function find_sub_child_sibling_node (container, s_tag){
* @param {function(HTMLElement):boolean?} do_not_break Optional function that receives the current child element and should return true if the child should not be split over two pages but rather be moved directly to the next page
* @param {boolean?} not_first_child Should be unset. Used internally to let at least one child in the page
*/
-function move_children_forward_recursively (child, child_sibling, stop_condition, do_not_break, not_first_child) {
+function move_children_forward_recursively(child, child_sibling, stop_condition, do_not_break, not_first_child) {
// if the child still has nodes and the current page still overflows
while(child.childNodes.length && !stop_condition()){
@@ -38,26 +38,44 @@ function move_children_forward_recursively (child, child_sibling, stop_condition
// if it is a text node, move its content to next page word(/space) by word
if(sub_child.nodeType == Node.TEXT_NODE){
- const sub_child_hashes = sub_child.textContent.match(/(\s|\S+)/g);
- const sub_child_continuation = document.createTextNode('');
- child_sibling.prepend(sub_child_continuation);
- const l = sub_child_hashes ? sub_child_hashes.length : 0;
- for(let i = 0; i < l; i++) {
- if(i == l - 1 && !not_first_child) return; // never remove the first word of the page
- sub_child.textContent = sub_child_hashes.slice(0, l - i - 1).join('');
- sub_child_continuation.textContent = sub_child_hashes.slice(l - i - 1, l).join('');
- if(stop_condition()) return;
+ const sub_child_text = sub_child.textContent;
+
+ if (sub_child_text.length > 0) {
+ let sub_child_hashes = sub_child_text.match(/(\s|\S+)/g);
+
+ // Handle long continuous words
+ if (!sub_child_hashes || sub_child_hashes.length === 1) {
+ console.log('Handling long continuous word');
+ const long_word = sub_child_text;
+
+ // Insert space before the last character so it's treated as normal text
+ const long_word_modified = long_word.slice(0, -1) + ' ' + long_word.slice(-1);
+
+ // Move the modified word to the next page in chunks
+ sub_child.textContent = long_word_modified;
+ sub_child_hashes = long_word_modified.match(/(\s|\S+)/g);
+ }
+
+ // Proceed with normal text handling
+ const sub_child_continuation = document.createTextNode('');
+ child_sibling.prepend(sub_child_continuation);
+ const l = sub_child_hashes ? sub_child_hashes.length : 0;
+
+ for (let i = 0; i < l; i++) {
+ if (i == l - 1 && !not_first_child) return;
+
+ // Move content from current page to the next
+ sub_child.textContent = sub_child_hashes.slice(0, l - i - 1).join('');
+ sub_child_continuation.textContent = sub_child_hashes.slice(l - i - 1).join('');
+
+ // Check stop condition and return if met
+ if (stop_condition()) return;
+ }
}
}
-
- // we simply move it to the next page if it is either:
- // - a node with no content (e.g. )
- // - a header title (e.g.