comparison browser_side/richtext.py @ 234:d4e73d9140af

browser side: rich text: update to follow core implementation
author Goffi <goffi@goffi.org>
date Thu, 31 Oct 2013 17:54:10 +0100
parents 146fc6739951
children 28d3315a8003
comparison
equal deleted inserted replaced
233:146fc6739951 234:d4e73d9140af
44 44
45 # Define here your formats, the key must match the ones used in button. 45 # Define here your formats, the key must match the ones used in button.
46 # Tupples values must have 3 elements : prefix to the selection or cursor 46 # Tupples values must have 3 elements : prefix to the selection or cursor
47 # position, sample text to write if the marker is not applied on a selection, 47 # position, sample text to write if the marker is not applied on a selection,
48 # suffix to the selection or cursor position. 48 # suffix to the selection or cursor position.
49 # FIXME: must be moved in backend and not harcoded like this
49 FORMATS = {"markdown": {"bold": ("**", "bold", "**"), 50 FORMATS = {"markdown": {"bold": ("**", "bold", "**"),
50 "italic": ("*", "italic", "*"), 51 "italic": ("*", "italic", "*"),
51 "code": ("`", "code", "`"), 52 "code": ("`", "code", "`"),
52 "heading": ("\n# ", "Heading 1", "\n## Heading 2\n"), 53 "heading": ("\n# ", "Heading 1", "\n## Heading 2\n"),
53 "list": ("\n* ", "item", "\n + subitem\n"), 54 "list": ("\n* ", "item", "\n + subitem\n"),
70 "heading": ("\n==== ", "Heading 1", " ====\n=== Heading 2 ===\n"), 71 "heading": ("\n==== ", "Heading 1", " ====\n=== Heading 2 ===\n"),
71 "link": ("[[", "link", "|desc]]"), 72 "link": ("[[", "link", "|desc]]"),
72 "list": ("\n * ", "item\n", "\n * subitem\n"), 73 "list": ("\n * ", "item\n", "\n * subitem\n"),
73 "horizontalrule": ("\n----\n", "", "") 74 "horizontalrule": ("\n----\n", "", "")
74 }, 75 },
75 "html": {"bold": ("<b>", "bold", "</b>"), 76 "XHTML": {"bold": ("<b>", "bold", "</b>"),
76 "italic": ("<i>", "italic", "</i>"), 77 "italic": ("<i>", "italic", "</i>"),
77 "underline": ("<u>", "underline", "</u>"), 78 "underline": ("<u>", "underline", "</u>"),
78 "strikethrough": ("<s>", "strikethrough", "</s>"), 79 "strikethrough": ("<s>", "strikethrough", "</s>"),
79 "code": ("<pre>", "code", "</pre>"), 80 "code": ("<pre>", "code", "</pre>"),
80 "heading": ("\n<h3>", "Heading 1", "</h3>\n<h4>Heading 2</h4>\n"), 81 "heading": ("\n<h3>", "Heading 1", "</h3>\n<h4>Heading 2</h4>\n"),
83 "horizontalrule": ("\n<hr/>\n", "", "") 84 "horizontalrule": ("\n<hr/>\n", "", "")
84 } 85 }
85 86
86 } 87 }
87 88
88 FORMAT_PARAM_KEY = "Composition and addressing" 89 PARAM_KEY = "Composition"
89 FORMAT_PARAM_NAME = "Format for rich text message composition" 90 PARAM_NAME = "Syntax"
90 91
91 92
92 class RichTextEditor(FlexTable): 93 class RichTextEditor(FlexTable):
93 """Panel for the rich text editor.""" 94 """Panel for the rich text editor."""
94 95
165 host.richtext.syncFromUniBox() 166 host.richtext.syncFromUniBox()
166 return host.richtext.popup if parent is None else host.richtext 167 return host.richtext.popup if parent is None else host.richtext
167 168
168 def setVisible(self, kwargs): 169 def setVisible(self, kwargs):
169 """Called each time the widget is displayed, after creation or after having been hidden.""" 170 """Called each time the widget is displayed, after creation or after having been hidden."""
170 self.host.bridge.call('asyncGetParamA', self.setToolBar, FORMAT_PARAM_NAME, FORMAT_PARAM_KEY) or self.setToolBar(None) 171 self.host.bridge.call('asyncGetParamA', self.setToolBar, PARAM_NAME, PARAM_KEY) or self.setToolBar(None)
171 FlexTable.setVisible(self, kwargs) 172 FlexTable.setVisible(self, kwargs)
172 173
173 def __close(self): 174 def __close(self):
174 """Remove the widget from parent or close the popup.""" 175 """Remove the widget from parent or close the popup."""
175 if self._parent is None: 176 if self._parent is None: