comparison browser_side/base_panels.py @ 356:b95099a1d11b

browser_side: do not use addURLToText to display Microblog XHTML content
author souliane <souliane@mailoo.org>
date Thu, 13 Feb 2014 12:53:07 +0100
parents f488692c4903
children df743589bb8c
comparison
equal deleted inserted replaced
355:9bb78c09e9fc 356:b95099a1d11b
416 416
417 417
418 class LightTextEditor(BaseTextEditor, HTML, FocusHandler, KeyboardHandler): 418 class LightTextEditor(BaseTextEditor, HTML, FocusHandler, KeyboardHandler):
419 """Manage a simple text editor whith the HTML 5 "contenteditable" property.""" 419 """Manage a simple text editor whith the HTML 5 "contenteditable" property."""
420 420
421 def __init__(self, content=None, modifiedCb=None, afterEditCb=None, single_line=False): 421 def __init__(self, content=None, modifiedCb=None, afterEditCb=None, single_line=False, enhance_display=True):
422 """ 422 """
423 @param content 423 @param content
424 @param modifiedCb 424 @param modifiedCb
425 @param afterEditCb 425 @param afterEditCb
426 @param single_line: set to True to manage a single line editor. In that case 426 @param single_line: set to True to manage a single line editor. In that case
427 the edition would be terminated when the focus is lost or <enter> key is pressed. 427 the edition would be terminated when the focus is lost or <enter> key is pressed.
428 @param enhance_display: if True, the display text will be enhanced with addURLToText
428 """ 429 """
429 HTML.__init__(self) 430 HTML.__init__(self)
430 if single_line: 431 if single_line:
431 FocusHandler.__init__(self) 432 FocusHandler.__init__(self)
432 KeyboardHandler.__init__(self) 433 KeyboardHandler.__init__(self)
433 self.__single_line = single_line 434 self.__single_line = single_line
435 self.__enhance_display = enhance_display
434 strproc = lambda text: html_sanitize(html_strip(text)) if self.__single_line else html_strip(text) 436 strproc = lambda text: html_sanitize(html_strip(text)) if self.__single_line else html_strip(text)
435 BaseTextEditor.__init__(self, content, strproc, modifiedCb, afterEditCb) 437 BaseTextEditor.__init__(self, content, strproc, modifiedCb, afterEditCb)
436 438
437 def setContent(self, content=None): 439 def setContent(self, content=None):
438 BaseTextEditor.setContent(self, content) 440 BaseTextEditor.setContent(self, content)
457 self.removeFocusListener(self) 459 self.removeFocusListener(self)
458 if self in self._keyboardListeners: 460 if self in self._keyboardListeners:
459 self.removeKeyboardListener(self) 461 self.removeKeyboardListener(self)
460 462
461 def setDisplayContent(self): 463 def setDisplayContent(self):
462 self.setHTML(addURLToText(self._original_content['text'])) 464 self.setHTML(addURLToText(self._original_content['text']) if self.__enhance_display else self._original_content['text'])
463 465
464 def setFocus(self, focus): 466 def setFocus(self, focus):
465 if focus: 467 if focus:
466 self.getElement().focus() 468 self.getElement().focus()
467 else: 469 else: