# HG changeset patch # User souliane # Date 1449750627 -3600 # Node ID 89a0cd2aa7631b590f593c9972e9e0cb35334a55 # Parent 8faaaa6ec7ca3525c7c379e3da18b2ad176c6322 browser_side: convertNewLinesToXHTML should only be called on raw text messages: - some people use \n to aerate the text but don't necessarily want to see them as
- method expandNewLinesToXHTML in backend finds the best out both editing styles diff -r 8faaaa6ec7ca -r 89a0cd2aa763 src/browser/sat_browser/editor_widget.py --- a/src/browser/sat_browser/editor_widget.py Thu Dec 10 11:19:46 2015 +0100 +++ b/src/browser/sat_browser/editor_widget.py Thu Dec 10 13:30:27 2015 +0100 @@ -225,6 +225,8 @@ class SimpleTextEditor(BaseTextEditor, FocusHandler, keyb.KeyboardHandler, ClickHandler): """Base class for manage a simple text editor.""" + CONVERT_NEW_LINES = True + def __init__(self, content=None, modifiedCb=None, afterEditCb=None, options=None): """ @param content @@ -289,7 +291,9 @@ text = strings.addURLToImage(text) if self.options['enhance_display']: text = strings.addURLToText(text) - self.display.setHTML(html_tools.convertNewLinesToXHTML(text)) + if self.CONVERT_NEW_LINES: + text = html_tools.convertNewLinesToXHTML(text) + self.display.setHTML(text) def setFocus(self, focus): raise NotImplementedError @@ -325,6 +329,8 @@ class HTMLTextEditor(SimpleTextEditor, HTML, FocusHandler, keyb.KeyboardHandler): """Manage a simple text editor with the HTML 5 "contenteditable" property.""" + CONVERT_NEW_LINES = False # overwrite definition in SimpleTextEditor + def __init__(self, content=None, modifiedCb=None, afterEditCb=None, options=None): HTML.__init__(self) SimpleTextEditor.__init__(self, content, modifiedCb, afterEditCb, options) diff -r 8faaaa6ec7ca -r 89a0cd2aa763 src/browser/sat_browser/html_tools.py --- a/src/browser/sat_browser/html_tools.py Thu Dec 10 11:19:46 2015 +0100 +++ b/src/browser/sat_browser/html_tools.py Thu Dec 10 13:30:27 2015 +0100 @@ -44,6 +44,7 @@ def convertNewLinesToXHTML(text): + """Replace all the \n with
""" return text.replace('\n', '
')