Wysiwyg: preserves line feeds in code block mode - #3246
Conversation
- Updated code content to get specific text selection instead of using node-based handling which could return the whole document when multiple top-level nodes were in selection. - Simplified how code gets applied into the page to not be node based but use native editor methods to replace the selection. Allows creation from half-way through a block. Tested on chrome+Firefox on Fedora 35. Builds upon changes in #3246. For #3200.
|
Thank you once again @Julesdevops! This change was definitely an improvement to preserve the newlines. When the selection spanned across multiple top-level nodes, inserting a code block would attempt to (and breakingly) convert the whole page into a code block. You would also see all text within the code content editor popup. This was due to my usages of BookStack/resources/js/components/wysiwyg-editor.js Lines 139 to 148 in 815f8d7 When multiple top-level nodes are selected this would resolve to the shared parent body, hence we would fetch all text from those and attempt to replace the whole body with code on code-block-save. I found a handy I followed up your changes with b2f863e which uses this method and simplifies the strange stuff I was doing to set the code block, to make the selection replacement more accurate. |
|
Indeed a far better solution! thanks for following up on this |
Fix #3200