From 1b6a06a4d79ad5c58593a7844e306c25848979ea Mon Sep 17 00:00:00 2001 From: Jermolene Date: Sat, 16 Dec 2017 10:58:33 +0000 Subject: [PATCH] Add copy-to-clipboard macro And use it in the tw5.com example documentation --- core/language/en-GB/Buttons.multids | 2 ++ core/wiki/macros/copy-to-clipboard.tid | 17 +++++++++++++++++ .../macros/copy-to-clipboard Macro.tid | 19 +++++++++++++++++++ .../copy-to-clipboard Macro (Examples).tid | 8 ++++++++ .../tw5.com/tiddlers/system/doc-macros.tid | 2 ++ .../tiddlers/system/wikitext-macros.tid | 4 ++++ 6 files changed, 52 insertions(+) create mode 100644 core/wiki/macros/copy-to-clipboard.tid create mode 100644 editions/tw5.com/tiddlers/macros/copy-to-clipboard Macro.tid create mode 100644 editions/tw5.com/tiddlers/macros/examples/copy-to-clipboard Macro (Examples).tid diff --git a/core/language/en-GB/Buttons.multids b/core/language/en-GB/Buttons.multids index 5c8398f6d..3a22529fc 100644 --- a/core/language/en-GB/Buttons.multids +++ b/core/language/en-GB/Buttons.multids @@ -14,6 +14,8 @@ CloseOthers/Caption: close others CloseOthers/Hint: Close other tiddlers ControlPanel/Caption: control panel ControlPanel/Hint: Open control panel +CopyToClipboard/Caption: copy to clipboard +CopyToClipboard/Hint: Copy this text to the clipboard Delete/Caption: delete Delete/Hint: Delete this tiddler Edit/Caption: edit diff --git a/core/wiki/macros/copy-to-clipboard.tid b/core/wiki/macros/copy-to-clipboard.tid new file mode 100644 index 000000000..8d1408255 --- /dev/null +++ b/core/wiki/macros/copy-to-clipboard.tid @@ -0,0 +1,17 @@ +title: $:/core/macros/copy-to-clipboard +tags: $:/tags/Macro + +\define copy-to-clipboard(src,class:"tc-btn-invisible",style) +<$button class=<<__class__>> style=<<__style__>> message="tm-copy-to-clipboard" param=<<__src__>> tooltip={{$:/language/Buttons/CopyToClipboard/Hint}}> +{{$:/core/images/copy-clipboard}} <$text text={{$:/language/Buttons/CopyToClipboard/Caption}}/> + +\end + +\define copy-to-clipboard-above-right(src,class:"tc-btn-invisible",style) +
+
+<$macrocall $name="copy-to-clipboard" src=<<__src__>> class=<<__class__>> style=<<__style__>>/> +
+
+\end + diff --git a/editions/tw5.com/tiddlers/macros/copy-to-clipboard Macro.tid b/editions/tw5.com/tiddlers/macros/copy-to-clipboard Macro.tid new file mode 100644 index 000000000..a9ef91dce --- /dev/null +++ b/editions/tw5.com/tiddlers/macros/copy-to-clipboard Macro.tid @@ -0,0 +1,19 @@ +caption: colour +created: 20171216104754967 +modified: 20171216104941967 +tags: Macros [[Core Macros]] +title: copy-to-clipboard Macro +type: text/vnd.tiddlywiki + +The <<.def copy-to-clipboard>> [[macro|Macros]] displays a button that copies specified text to the clipboard. A notification is displayed if the operation is successful; some browsers do not permit the operation. + +!! Parameters + +;src +: The text to be copied to the clipboard +;class +: Optional CSS classes to be assigned to the button (defaults to `tc-btn-invisible`) +;style +: Optional CSS styles to be assigned to the button + +<<.macro-examples "copy-to-clipboard">> diff --git a/editions/tw5.com/tiddlers/macros/examples/copy-to-clipboard Macro (Examples).tid b/editions/tw5.com/tiddlers/macros/examples/copy-to-clipboard Macro (Examples).tid new file mode 100644 index 000000000..098bac367 --- /dev/null +++ b/editions/tw5.com/tiddlers/macros/examples/copy-to-clipboard Macro (Examples).tid @@ -0,0 +1,8 @@ +created: 20171216104946277 +modified: 20171216105109641 +tags: [[copy-to-clipboard Macro]] [[Macro Examples]] +title: copy-to-clipboard Macro (Examples) +type: text/vnd.tiddlywiki + +<$macrocall $name=".example" n="1" eg="""<>"""/> +<$macrocall $name=".example" n="2" eg="""<$macrocall $name="copy-to-clipboard" src={{$:/SiteTitle}}/>"""/> diff --git a/editions/tw5.com/tiddlers/system/doc-macros.tid b/editions/tw5.com/tiddlers/system/doc-macros.tid index 86c31e6ea..c6abc6931 100644 --- a/editions/tw5.com/tiddlers/system/doc-macros.tid +++ b/editions/tw5.com/tiddlers/system/doc-macros.tid @@ -80,10 +80,12 @@ This is an example tiddler. See [[Table-of-Contents Macros (Examples)]]. \define .example(n,eg,egvar:NO-SUCH-VAR)
<$reveal default="$egvar$" type="match" text="NO-SUCH-VAR"> + <$macrocall $name="copy-to-clipboard-above-right" src="""$eg$"""/> <$codeblock code="""$eg$"""/> <$reveal default="$egvar$" type="nomatch" text="NO-SUCH-VAR"> + <$macrocall $name="copy-to-clipboard-above-right" src=<<$egvar$>>/> <$codeblock code=<<$egvar$>>/> <$list filter="[title<.state-prefix>addsuffix{!!title}addsuffix[/]addsuffix[$n$]]" variable=".state"> diff --git a/editions/tw5.com/tiddlers/system/wikitext-macros.tid b/editions/tw5.com/tiddlers/system/wikitext-macros.tid index 932ff581d..c609205ab 100644 --- a/editions/tw5.com/tiddlers/system/wikitext-macros.tid +++ b/editions/tw5.com/tiddlers/system/wikitext-macros.tid @@ -6,6 +6,8 @@ tags: $:/tags/Macro \define wikitext-example(src)
+<$macrocall $name="copy-to-clipboard-above-right" src=<<__src__>>/> + ``` $src$ ``` @@ -25,6 +27,8 @@ $$$ \define wikitext-example-without-html(src)
+<$macrocall $name="copy-to-clipboard-above-right" src=<<__src__>>/> + ``` $src$ ```