# HG changeset patch # User souliane # Date 1392284549 -3600 # Node ID 58b4568ed4f2ba1fb7d648a3fc047ded6ba402c2 # Parent f8681a7fd834a588aa2a857a0e2c649349017348 frontends: add COMMANDS constant for Wysiwyg edition + add "image" button info for the syntaxes diff -r f8681a7fd834 -r 58b4568ed4f2 frontends/src/tools/composition.py --- a/frontends/src/tools/composition.py Wed Feb 12 21:46:48 2014 +0100 +++ b/frontends/src/tools/composition.py Thu Feb 13 10:42:29 2014 +0100 @@ -35,7 +35,8 @@ "numberedlist": {"tip": "Numbered List", "icon": "media/icons/dokuwiki/toolbar/16/ol.png"}, "list": {"tip": "List", "icon": "media/icons/dokuwiki/toolbar/16/ul.png"}, "link": {"tip": "Link", "icon": "media/icons/dokuwiki/toolbar/16/linkextern.png"}, - "horizontalrule": {"tip": "Horizontal rule", "icon": "media/icons/dokuwiki/toolbar/16/hr.png"} + "horizontalrule": {"tip": "Horizontal rule", "icon": "media/icons/dokuwiki/toolbar/16/hr.png"}, + "image": {"tip": "Image", "icon": "media/icons/dokuwiki/toolbar/16/image.png"}, } # Define here your rich text syntaxes, the key must match the ones used in button. @@ -44,43 +45,65 @@ # suffix to the selection or cursor position. # FIXME: must not be hard-coded like this RICH_SYNTAXES = {"markdown": {"bold": ("**", "bold", "**"), - "italic": ("*", "italic", "*"), - "code": ("`", "code", "`"), - "heading": ("\n# ", "Heading 1", "\n## Heading 2\n"), - "list": ("\n* ", "item", "\n + subitem\n"), - "link": ("[desc](", "link", ")"), - "horizontalrule": ("\n***\n", "", "") + "italic": ("*", "italic", "*"), + "code": ("`", "code", "`"), + "heading": ("\n# ", "Heading 1", "\n## Heading 2\n"), + "link": ("[desc](", "link", ")"), + "list": ("\n* ", "item", "\n + subitem\n"), + "horizontalrule": ("\n***\n", "", ""), + "image": ("![desc](", "path", ")"), }, "bbcode": {"bold": ("[b]", "bold", "[/b]"), "italic": ("[i]", "italic", "[/i]"), "underline": ("[u]", "underline", "[/u]"), + "code": ("[code]", "code", "[/code]"), "strikethrough": ("[s]", "strikethrough", "[/s]"), - "code": ("[code]", "code", "[/code]"), "link": ("[url=", "link", "]desc[/url]"), - "list": ("\n[list] [*]", "item 1", " [*]item 2 [/list]\n") + "list": ("\n[list] [*]", "item 1", " [*]item 2 [/list]\n"), + "image": ("[img alt=\"desc\]", "path", "[/img]"), }, "dokuwiki": {"bold": ("**", "bold", "**"), "italic": ("//", "italic", "//"), "underline": ("__", "underline", "__"), + "code": ("", "code", ""), "strikethrough": ("", "strikethrough", ""), - "code": ("", "code", ""), "heading": ("\n==== ", "Heading 1", " ====\n=== Heading 2 ===\n"), "link": ("[[", "link", "|desc]]"), "list": ("\n * ", "item\n", "\n * subitem\n"), - "horizontalrule": ("\n----\n", "", "") + "horizontalrule": ("\n----\n", "", ""), + "image": ("{{", "path", " |desc}}"), }, "XHTML": {"bold": ("", "bold", ""), - "italic": ("", "italic", ""), - "underline": ("", "underline", ""), - "strikethrough": ("", "strikethrough", ""), - "code": ("
", "code", "
"), - "heading": ("\n

", "Heading 1", "

\n

Heading 2

\n"), - "link": ("desc"), - "list": ("\n\n"), - "horizontalrule": ("\n
\n", "", "") - } + "italic": ("", "italic", ""), + "underline": ("", "underline", ""), + "code": ("
", "code", "
"), + "strikethrough": ("", "strikethrough", ""), + "heading": ("\n

", "Heading 1", "

\n

Heading 2

\n"), + "link": ("desc"), + "list": ("\n\n"), + "horizontalrule": ("\n
\n", "", ""), + "image": ("\"desc\"/"), + } + } - } +# Define here the commands that are supported by the WYSIWYG edition. +# Keys must be the same than the ones used in RICH_SYNTAXES["XHTML"]. +# Values will be used to call execCommand(cmd, False, arg), they can be: +# - a string used for cmd and arg is assumed empty +# - a tuple (cmd, prompt, arg) with cmd the name of the command, +# prompt the text to display for asking a user input and arg is the +# value to use directly without asking the user if prompt is empty. +COMMANDS = {"bold": "bold", + "italic": "italic", + "underline": "underline", + "code": ("formatBlock", "", "pre"), + "strikethrough": "strikeThrough", + "heading": ("heading", "Please specify the heading level (h1, h2, h3...)", ""), + "link": ("createLink", "Please specify an URL", ""), + "list": "insertUnorderedList", + "horizontalrule": "insertHorizontalRule", + "image": ("insertImage", "Please specify an image path", ""), + } # These values should be equal to the ones in plugin_misc_text_syntaxes # FIXME: should the plugin import them from here to avoid duplicity? Importing