Mercurial > libervia-web
comparison src/browser/sat_browser/editor_widget.py @ 803:89a0cd2aa763
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 <br />
- method expandNewLinesToXHTML in backend finds the best out both editing styles
author | souliane <souliane@mailoo.org> |
---|---|
date | Thu, 10 Dec 2015 13:30:27 +0100 |
parents | f3cd261ea12f |
children | f8a7a046ff9c |
comparison
equal
deleted
inserted
replaced
802:8faaaa6ec7ca | 803:89a0cd2aa763 |
---|---|
223 | 223 |
224 | 224 |
225 class SimpleTextEditor(BaseTextEditor, FocusHandler, keyb.KeyboardHandler, ClickHandler): | 225 class SimpleTextEditor(BaseTextEditor, FocusHandler, keyb.KeyboardHandler, ClickHandler): |
226 """Base class for manage a simple text editor.""" | 226 """Base class for manage a simple text editor.""" |
227 | 227 |
228 CONVERT_NEW_LINES = True | |
229 | |
228 def __init__(self, content=None, modifiedCb=None, afterEditCb=None, options=None): | 230 def __init__(self, content=None, modifiedCb=None, afterEditCb=None, options=None): |
229 """ | 231 """ |
230 @param content | 232 @param content |
231 @param modifiedCb | 233 @param modifiedCb |
232 @param afterEditCb | 234 @param afterEditCb |
287 text = self._original_content['text'] | 289 text = self._original_content['text'] |
288 if not self.options['no_xhtml']: | 290 if not self.options['no_xhtml']: |
289 text = strings.addURLToImage(text) | 291 text = strings.addURLToImage(text) |
290 if self.options['enhance_display']: | 292 if self.options['enhance_display']: |
291 text = strings.addURLToText(text) | 293 text = strings.addURLToText(text) |
292 self.display.setHTML(html_tools.convertNewLinesToXHTML(text)) | 294 if self.CONVERT_NEW_LINES: |
295 text = html_tools.convertNewLinesToXHTML(text) | |
296 self.display.setHTML(text) | |
293 | 297 |
294 def setFocus(self, focus): | 298 def setFocus(self, focus): |
295 raise NotImplementedError | 299 raise NotImplementedError |
296 | 300 |
297 def onKeyDown(self, sender, keycode, modifiers): | 301 def onKeyDown(self, sender, keycode, modifiers): |
323 | 327 |
324 | 328 |
325 class HTMLTextEditor(SimpleTextEditor, HTML, FocusHandler, keyb.KeyboardHandler): | 329 class HTMLTextEditor(SimpleTextEditor, HTML, FocusHandler, keyb.KeyboardHandler): |
326 """Manage a simple text editor with the HTML 5 "contenteditable" property.""" | 330 """Manage a simple text editor with the HTML 5 "contenteditable" property.""" |
327 | 331 |
332 CONVERT_NEW_LINES = False # overwrite definition in SimpleTextEditor | |
333 | |
328 def __init__(self, content=None, modifiedCb=None, afterEditCb=None, options=None): | 334 def __init__(self, content=None, modifiedCb=None, afterEditCb=None, options=None): |
329 HTML.__init__(self) | 335 HTML.__init__(self) |
330 SimpleTextEditor.__init__(self, content, modifiedCb, afterEditCb, options) | 336 SimpleTextEditor.__init__(self, content, modifiedCb, afterEditCb, options) |
331 self.textarea = self.display = self | 337 self.textarea = self.display = self |
332 | 338 |