Mercurial > libervia-backend
comparison frontends/src/tools/composition.py @ 840:58b4568ed4f2
frontends: add COMMANDS constant for Wysiwyg edition + add "image" button info for the syntaxes
author | souliane <souliane@mailoo.org> |
---|---|
date | Thu, 13 Feb 2014 10:42:29 +0100 |
parents | c00d90bce252 |
children | 069ad98b360d |
comparison
equal
deleted
inserted
replaced
839:f8681a7fd834 | 840:58b4568ed4f2 |
---|---|
33 "strikethrough": {"tip": "Strikethrough", "icon": "media/icons/dokuwiki/toolbar/16/strike.png"}, | 33 "strikethrough": {"tip": "Strikethrough", "icon": "media/icons/dokuwiki/toolbar/16/strike.png"}, |
34 "heading": {"tip": "Heading", "icon": "media/icons/dokuwiki/toolbar/16/hequal.png"}, | 34 "heading": {"tip": "Heading", "icon": "media/icons/dokuwiki/toolbar/16/hequal.png"}, |
35 "numberedlist": {"tip": "Numbered List", "icon": "media/icons/dokuwiki/toolbar/16/ol.png"}, | 35 "numberedlist": {"tip": "Numbered List", "icon": "media/icons/dokuwiki/toolbar/16/ol.png"}, |
36 "list": {"tip": "List", "icon": "media/icons/dokuwiki/toolbar/16/ul.png"}, | 36 "list": {"tip": "List", "icon": "media/icons/dokuwiki/toolbar/16/ul.png"}, |
37 "link": {"tip": "Link", "icon": "media/icons/dokuwiki/toolbar/16/linkextern.png"}, | 37 "link": {"tip": "Link", "icon": "media/icons/dokuwiki/toolbar/16/linkextern.png"}, |
38 "horizontalrule": {"tip": "Horizontal rule", "icon": "media/icons/dokuwiki/toolbar/16/hr.png"} | 38 "horizontalrule": {"tip": "Horizontal rule", "icon": "media/icons/dokuwiki/toolbar/16/hr.png"}, |
39 "image": {"tip": "Image", "icon": "media/icons/dokuwiki/toolbar/16/image.png"}, | |
39 } | 40 } |
40 | 41 |
41 # Define here your rich text syntaxes, the key must match the ones used in button. | 42 # Define here your rich text syntaxes, the key must match the ones used in button. |
42 # Tupples values must have 3 elements : prefix to the selection or cursor | 43 # Tupples values must have 3 elements : prefix to the selection or cursor |
43 # position, sample text to write if the marker is not applied on a selection, | 44 # position, sample text to write if the marker is not applied on a selection, |
44 # suffix to the selection or cursor position. | 45 # suffix to the selection or cursor position. |
45 # FIXME: must not be hard-coded like this | 46 # FIXME: must not be hard-coded like this |
46 RICH_SYNTAXES = {"markdown": {"bold": ("**", "bold", "**"), | 47 RICH_SYNTAXES = {"markdown": {"bold": ("**", "bold", "**"), |
47 "italic": ("*", "italic", "*"), | 48 "italic": ("*", "italic", "*"), |
48 "code": ("`", "code", "`"), | 49 "code": ("`", "code", "`"), |
49 "heading": ("\n# ", "Heading 1", "\n## Heading 2\n"), | 50 "heading": ("\n# ", "Heading 1", "\n## Heading 2\n"), |
50 "list": ("\n* ", "item", "\n + subitem\n"), | 51 "link": ("[desc](", "link", ")"), |
51 "link": ("[desc](", "link", ")"), | 52 "list": ("\n* ", "item", "\n + subitem\n"), |
52 "horizontalrule": ("\n***\n", "", "") | 53 "horizontalrule": ("\n***\n", "", ""), |
54 "image": ("![desc](", "path", ")"), | |
53 }, | 55 }, |
54 "bbcode": {"bold": ("[b]", "bold", "[/b]"), | 56 "bbcode": {"bold": ("[b]", "bold", "[/b]"), |
55 "italic": ("[i]", "italic", "[/i]"), | 57 "italic": ("[i]", "italic", "[/i]"), |
56 "underline": ("[u]", "underline", "[/u]"), | 58 "underline": ("[u]", "underline", "[/u]"), |
59 "code": ("[code]", "code", "[/code]"), | |
57 "strikethrough": ("[s]", "strikethrough", "[/s]"), | 60 "strikethrough": ("[s]", "strikethrough", "[/s]"), |
58 "code": ("[code]", "code", "[/code]"), | |
59 "link": ("[url=", "link", "]desc[/url]"), | 61 "link": ("[url=", "link", "]desc[/url]"), |
60 "list": ("\n[list] [*]", "item 1", " [*]item 2 [/list]\n") | 62 "list": ("\n[list] [*]", "item 1", " [*]item 2 [/list]\n"), |
63 "image": ("[img alt=\"desc\]", "path", "[/img]"), | |
61 }, | 64 }, |
62 "dokuwiki": {"bold": ("**", "bold", "**"), | 65 "dokuwiki": {"bold": ("**", "bold", "**"), |
63 "italic": ("//", "italic", "//"), | 66 "italic": ("//", "italic", "//"), |
64 "underline": ("__", "underline", "__"), | 67 "underline": ("__", "underline", "__"), |
68 "code": ("<code>", "code", "</code>"), | |
65 "strikethrough": ("<del>", "strikethrough", "</del>"), | 69 "strikethrough": ("<del>", "strikethrough", "</del>"), |
66 "code": ("<code>", "code", "</code>"), | |
67 "heading": ("\n==== ", "Heading 1", " ====\n=== Heading 2 ===\n"), | 70 "heading": ("\n==== ", "Heading 1", " ====\n=== Heading 2 ===\n"), |
68 "link": ("[[", "link", "|desc]]"), | 71 "link": ("[[", "link", "|desc]]"), |
69 "list": ("\n * ", "item\n", "\n * subitem\n"), | 72 "list": ("\n * ", "item\n", "\n * subitem\n"), |
70 "horizontalrule": ("\n----\n", "", "") | 73 "horizontalrule": ("\n----\n", "", ""), |
74 "image": ("{{", "path", " |desc}}"), | |
71 }, | 75 }, |
72 "XHTML": {"bold": ("<b>", "bold", "</b>"), | 76 "XHTML": {"bold": ("<b>", "bold", "</b>"), |
73 "italic": ("<i>", "italic", "</i>"), | 77 "italic": ("<i>", "italic", "</i>"), |
74 "underline": ("<u>", "underline", "</u>"), | 78 "underline": ("<u>", "underline", "</u>"), |
75 "strikethrough": ("<s>", "strikethrough", "</s>"), | 79 "code": ("<pre>", "code", "</pre>"), |
76 "code": ("<pre>", "code", "</pre>"), | 80 "strikethrough": ("<s>", "strikethrough", "</s>"), |
77 "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"), |
78 "link": ("<a href=\"", "link", "\">desc</a>"), | 82 "link": ("<a href=\"", "link", "\">desc</a>"), |
79 "list": ("\n<ul><li>", "item 1", "</li><li>item 2</li></ul>\n"), | 83 "list": ("\n<ul><li>", "item 1", "</li><li>item 2</li></ul>\n"), |
80 "horizontalrule": ("\n<hr/>\n", "", "") | 84 "horizontalrule": ("\n<hr/>\n", "", ""), |
81 } | 85 "image": ("<img src=\"", "path", "\" alt=\"desc\"/>"), |
86 } | |
87 } | |
82 | 88 |
83 } | 89 # Define here the commands that are supported by the WYSIWYG edition. |
90 # Keys must be the same than the ones used in RICH_SYNTAXES["XHTML"]. | |
91 # Values will be used to call execCommand(cmd, False, arg), they can be: | |
92 # - a string used for cmd and arg is assumed empty | |
93 # - a tuple (cmd, prompt, arg) with cmd the name of the command, | |
94 # prompt the text to display for asking a user input and arg is the | |
95 # value to use directly without asking the user if prompt is empty. | |
96 COMMANDS = {"bold": "bold", | |
97 "italic": "italic", | |
98 "underline": "underline", | |
99 "code": ("formatBlock", "", "pre"), | |
100 "strikethrough": "strikeThrough", | |
101 "heading": ("heading", "Please specify the heading level (h1, h2, h3...)", ""), | |
102 "link": ("createLink", "Please specify an URL", ""), | |
103 "list": "insertUnorderedList", | |
104 "horizontalrule": "insertHorizontalRule", | |
105 "image": ("insertImage", "Please specify an image path", ""), | |
106 } | |
84 | 107 |
85 # These values should be equal to the ones in plugin_misc_text_syntaxes | 108 # These values should be equal to the ones in plugin_misc_text_syntaxes |
86 # FIXME: should the plugin import them from here to avoid duplicity? Importing | 109 # FIXME: should the plugin import them from here to avoid duplicity? Importing |
87 # the plugin's values from here is not possible because Libervia would fail. | 110 # the plugin's values from here is not possible because Libervia would fail. |
88 PARAM_KEY_COMPOSITION = "Composition" | 111 PARAM_KEY_COMPOSITION = "Composition" |