1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2025-02-02 20:29:10 +00:00

Merge branch 'master' into colour-improvements

This commit is contained in:
Jeremy Ruston 2025-01-27 16:55:03 +00:00
commit efcd23993e
10 changed files with 54 additions and 33 deletions

View File

@ -2463,6 +2463,7 @@ $tw.boot.initStartup = function(options) {
$tw.utils.registerFileType("image/webp","base64",".webp",{flags:["image"]}); $tw.utils.registerFileType("image/webp","base64",".webp",{flags:["image"]});
$tw.utils.registerFileType("image/heic","base64",".heic",{flags:["image"]}); $tw.utils.registerFileType("image/heic","base64",".heic",{flags:["image"]});
$tw.utils.registerFileType("image/heif","base64",".heif",{flags:["image"]}); $tw.utils.registerFileType("image/heif","base64",".heif",{flags:["image"]});
$tw.utils.registerFileType("image/avif","base64",".avif",{flags:["image"]});
$tw.utils.registerFileType("image/svg+xml","utf8",".svg",{flags:["image"]}); $tw.utils.registerFileType("image/svg+xml","utf8",".svg",{flags:["image"]});
$tw.utils.registerFileType("image/vnd.microsoft.icon","base64",".ico",{flags:["image"]}); $tw.utils.registerFileType("image/vnd.microsoft.icon","base64",".ico",{flags:["image"]});
$tw.utils.registerFileType("image/x-icon","base64",".ico",{flags:["image"]}); $tw.utils.registerFileType("image/x-icon","base64",".ico",{flags:["image"]});

View File

@ -40,6 +40,7 @@ exports["image/gif"] = ImageParser;
exports["image/webp"] = ImageParser; exports["image/webp"] = ImageParser;
exports["image/heic"] = ImageParser; exports["image/heic"] = ImageParser;
exports["image/heif"] = ImageParser; exports["image/heif"] = ImageParser;
exports["image/avif"] = ImageParser;
exports["image/x-icon"] = ImageParser; exports["image/x-icon"] = ImageParser;
exports["image/vnd.microsoft.icon"] = ImageParser; exports["image/vnd.microsoft.icon"] = ImageParser;

View File

@ -77,8 +77,9 @@ exports.startup = function() {
$tw.rootWidget.addEventListener("tm-copy-to-clipboard",function(event) { $tw.rootWidget.addEventListener("tm-copy-to-clipboard",function(event) {
$tw.utils.copyToClipboard(event.param,{ $tw.utils.copyToClipboard(event.param,{
successNotification: event.paramObject && event.paramObject.successNotification, successNotification: event.paramObject && event.paramObject.successNotification,
failureNotification: event.paramObject && event.paramObject.failureNotification failureNotification: event.paramObject && event.paramObject.failureNotification,
}); plainText: event.paramObject && event.paramObject.plainText
},event.paramObject.type);
}); });
// Install the tm-focus-selector message // Install the tm-focus-selector message
$tw.rootWidget.addEventListener("tm-focus-selector",function(event) { $tw.rootWidget.addEventListener("tm-focus-selector",function(event) {

View File

@ -268,9 +268,10 @@ exports.copyStyles = function(srcDomNode,dstDomNode) {
/* /*
Copy plain text to the clipboard on browsers that support it Copy plain text to the clipboard on browsers that support it
*/ */
exports.copyToClipboard = function(text,options) { exports.copyToClipboard = function(text,options,type) {
options = options || {}; var text = text || "";
text = text || ""; var options = options || {};
var type = type || "text/plain";
var textArea = document.createElement("textarea"); var textArea = document.createElement("textarea");
textArea.style.position = "fixed"; textArea.style.position = "fixed";
textArea.style.top = 0; textArea.style.top = 0;
@ -283,10 +284,16 @@ exports.copyToClipboard = function(text,options) {
textArea.style.outline = "none"; textArea.style.outline = "none";
textArea.style.boxShadow = "none"; textArea.style.boxShadow = "none";
textArea.style.background = "transparent"; textArea.style.background = "transparent";
textArea.value = text;
document.body.appendChild(textArea); document.body.appendChild(textArea);
textArea.select(); textArea.select();
textArea.setSelectionRange(0,text.length); textArea.setSelectionRange(0,text.length);
textArea.addEventListener("copy",function(event) {
event.preventDefault();
if (options.plainText) {
event.clipboardData.setData("text/plain",options.plainText);
}
event.clipboardData.setData(type,text);
});
var succeeded = false; var succeeded = false;
try { try {
succeeded = document.execCommand("copy"); succeeded = document.execCommand("copy");

View File

@ -43,15 +43,6 @@ EditWidget.prototype.execute = function() {
// Get our parameters // Get our parameters
this.editTitle = this.getAttribute("tiddler",this.getVariable("currentTiddler")); this.editTitle = this.getAttribute("tiddler",this.getVariable("currentTiddler"));
this.editField = this.getAttribute("field","text"); this.editField = this.getAttribute("field","text");
this.editIndex = this.getAttribute("index");
this.editClass = this.getAttribute("class");
this.editPlaceholder = this.getAttribute("placeholder");
this.editTabIndex = this.getAttribute("tabindex");
this.editFocus = this.getAttribute("focus","");
this.editCancelPopups = this.getAttribute("cancelPopups","");
this.editInputActions = this.getAttribute("inputActions");
this.editRefreshTitle = this.getAttribute("refreshTitle");
this.editAutoComplete = this.getAttribute("autocomplete");
// Choose the appropriate edit widget // Choose the appropriate edit widget
this.editorType = this.getEditorType(); this.editorType = this.getEditorType();
// Make the child widgets // Make the child widgets
@ -89,8 +80,8 @@ Selectively refreshes the widget if needed. Returns true if the widget or any of
*/ */
EditWidget.prototype.refresh = function(changedTiddlers) { EditWidget.prototype.refresh = function(changedTiddlers) {
var changedAttributes = this.computeAttributes(); var changedAttributes = this.computeAttributes();
// Refresh if an attribute has changed, or the type associated with the target tiddler has changed // Refresh if the editor type has changed
if(changedAttributes.tiddler || changedAttributes.field || changedAttributes.index || changedAttributes.tabindex || changedAttributes.cancelPopups || changedAttributes.inputActions || changedAttributes.refreshTitle || changedAttributes.autocomplete || (this.getEditorType() !== this.editorType)) { if(changedAttributes.tiddler || changedAttributes.field || (this.getEditorType() !== this.editorType)) {
this.refreshSelf(); this.refreshSelf();
return true; return true;
} else { } else {

View File

@ -23,15 +23,21 @@ Inherit from the base widget class
*/ */
GenesisWidget.prototype = new Widget(); GenesisWidget.prototype = new Widget();
GenesisWidget.prototype.computeAttributes = function(options) {
options = options || Object.create(null);
options.filterFn = function(name) {
// Only compute our own attributes which start with a single dollar
return name.charAt(0) === "$" && name.charAt(1) !== "$";
}
return Widget.prototype.computeAttributes.call(this,options);
};
/* /*
Render this widget into the DOM Render this widget into the DOM
*/ */
GenesisWidget.prototype.render = function(parent,nextSibling) { GenesisWidget.prototype.render = function(parent,nextSibling) {
this.parentDomNode = parent; this.parentDomNode = parent;
this.computeAttributes({filterFn: function(name) { this.computeAttributes();
// Only compute our own attributes which start with a single dollar
return name.charAt(0) === "$" && name.charAt(1) !== "$";
}});
this.execute(); this.execute();
this.renderChildren(parent,nextSibling); this.renderChildren(parent,nextSibling);
}; };

View File

@ -3,9 +3,11 @@ tags: $:/tags/Macro
\whitespace trim \whitespace trim
\procedure copy-to-clipboard(src,class:"tc-btn-invisible",style) \procedure copy-to-clipboard(src,class:"tc-btn-invisible",style,type:"text/plain",plain)
<$button message="tm-copy-to-clipboard" \procedure copy-to-clipboard-actions()
param=<<src>> <$action-sendmessage $message="tm-copy-to-clipboard" $param=<<src>> type=<<type>> plainText=<<plain>>/>
\end copy-to-clipboard-actions
<$button actions=<<copy-to-clipboard-actions>>
class=<<class>> class=<<class>>
style=<<style>> style=<<style>>
tooltip={{$:/language/Buttons/CopyToClipboard/Hint}} tooltip={{$:/language/Buttons/CopyToClipboard/Hint}}
@ -15,12 +17,12 @@ tags: $:/tags/Macro
<$text text={{$:/language/Buttons/CopyToClipboard/Caption}}/> <$text text={{$:/language/Buttons/CopyToClipboard/Caption}}/>
</span> </span>
</$button> </$button>
\end \end copy-to-clipboard
\procedure copy-to-clipboard-above-right(src,class:"tc-btn-invisible",style) \procedure copy-to-clipboard-above-right(src,class:"tc-btn-invisible",style,type:"text/plain")
<div style="position: relative;"> <div style.position="relative">
<div style="position: absolute; bottom: 0; right: 0;"> <div style.position="absolute" style.bottom="0" style.right="0">
<$macrocall $name="copy-to-clipboard" src=<<src>> class=<<class>> style=<<style>>/> <$transclude $variable="copy-to-clipboard" src=<<src>> class=<<class>> style=<<style>> type=<<type>> plain=<<plain>>/>
</div> </div>
</div> </div>
\end \end

View File

@ -1,6 +1,6 @@
caption: copy-to-clipboard caption: copy-to-clipboard
created: 20171216104754967 created: 20171216104754967
modified: 20171216104941967 modified: 20250127133558352
tags: Macros [[Core Macros]] tags: Macros [[Core Macros]]
title: copy-to-clipboard Macro title: copy-to-clipboard Macro
type: text/vnd.tiddlywiki type: text/vnd.tiddlywiki
@ -15,5 +15,9 @@ The <<.def copy-to-clipboard>> [[macro|Macros]] displays a button that copies sp
: Optional CSS classes to be assigned to the button (defaults to `tc-btn-invisible`) : Optional CSS classes to be assigned to the button (defaults to `tc-btn-invisible`)
;style ;style
: Optional CSS styles to be assigned to the button : Optional CSS styles to be assigned to the button
;type
: <<.from-version "5.3.7">> MIME type of the text to be copied, defaults to `text/plain`
;plain
: <<.from-version "5.3.7">> Additional plain text to be copied when `type` attribute isn't `text/plain`
<<.macro-examples "copy-to-clipboard">> <<.macro-examples "copy-to-clipboard">>

View File

@ -1,8 +1,14 @@
created: 20171216104946277 created: 20171216104946277
modified: 20171216105109641 modified: 20250127134344834
tags: [[copy-to-clipboard Macro]] [[Macro Examples]] tags: [[copy-to-clipboard Macro]] [[Macro Examples]]
title: copy-to-clipboard Macro (Examples) title: copy-to-clipboard Macro (Examples)
type: text/vnd.tiddlywiki type: text/vnd.tiddlywiki
<$macrocall $name=".example" n="1" eg="""<<copy-to-clipboard "Mary had a little lamb">>"""/> <$macrocall $name=".example" n="1" eg="""<<copy-to-clipboard "Mary had a little lamb">>"""/>
<$macrocall $name=".example" n="2" eg="""<$macrocall $name="copy-to-clipboard" src={{$:/SiteTitle}}/>"""/> <$macrocall $name=".example" n="2" eg="""<$transclude $variable="copy-to-clipboard" src={{$:/SiteTitle}}/>"""/>
In the following examples, press <kbd>ctrl-V</kbd> / <kbd>cmd-V</kbd> in tiddlywiki after copying to see its effects.
<$macrocall $name=".example" n="3" eg="""<<copy-to-clipboard src:"<em>Test</em>" type:"text/html" plain:"Test">> """/>
<$macrocall $name=".example" n="4" eg="""<<copy-to-clipboard src:"The ''quick'' //brown// __fox__ jumps over a `lazy` @@dog@@." type:"text/vnd.tiddlywiki" plain:"The quick brown box jumps over a lazy dog.">> """/>
<$macrocall $name=".example" n="5" eg="""<$transclude $variable="copy-to-clipboard" src=<<jsontiddlers filter:"[tag[Concepts]]">> type="text/vnd.tiddler"/>"""/>

View File

@ -1,6 +1,6 @@
caption: tm-copy-to-clipboard caption: tm-copy-to-clipboard
created: 20171215150056004 created: 20171215150056004
modified: 20240523174013095 modified: 20250127134445040
tags: Messages tags: Messages
title: WidgetMessage: tm-copy-to-clipboard title: WidgetMessage: tm-copy-to-clipboard
type: text/vnd.tiddlywiki type: text/vnd.tiddlywiki
@ -13,6 +13,8 @@ It requires the following properties on the `event` object:
|param |Text to be copied to the clipboard | |param |Text to be copied to the clipboard |
|successNotification |<<.from-version "5.3.4">> Optional title of tiddler containing notification to be used if the operation succeeds | |successNotification |<<.from-version "5.3.4">> Optional title of tiddler containing notification to be used if the operation succeeds |
|failureNotification |<<.from-version "5.3.4">> Optional title of tiddler containing notification to be used if the operation fails | |failureNotification |<<.from-version "5.3.4">> Optional title of tiddler containing notification to be used if the operation fails |
|type |<<.from-version "5.3.7">> MIME type of the text to be copied, defaults to `text/plain` |
|plainText |<<.from-version "5.3.7">> Additional plain text to be copied when `type` attribute isn't `text/plain` |
This message is usually generated with the ButtonWidget. It is handled by the TiddlyWiki core. This message is usually generated with the ButtonWidget. It is handled by the TiddlyWiki core.