From f02c9ebba3a95117baa8e55220ab79e18d84edef Mon Sep 17 00:00:00 2001 From: Saq Imtiaz Date: Sun, 26 Jan 2025 13:25:01 +0100 Subject: [PATCH 1/4] feat: support for avif images (#8911) --- boot/boot.js | 1 + core/modules/parsers/imageparser.js | 1 + 2 files changed, 2 insertions(+) diff --git a/boot/boot.js b/boot/boot.js index 7570dade5..2efa58b1d 100644 --- a/boot/boot.js +++ b/boot/boot.js @@ -2463,6 +2463,7 @@ $tw.boot.initStartup = function(options) { $tw.utils.registerFileType("image/webp","base64",".webp",{flags:["image"]}); $tw.utils.registerFileType("image/heic","base64",".heic",{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/vnd.microsoft.icon","base64",".ico",{flags:["image"]}); $tw.utils.registerFileType("image/x-icon","base64",".ico",{flags:["image"]}); diff --git a/core/modules/parsers/imageparser.js b/core/modules/parsers/imageparser.js index a964a4ba8..d594803b2 100644 --- a/core/modules/parsers/imageparser.js +++ b/core/modules/parsers/imageparser.js @@ -40,6 +40,7 @@ exports["image/gif"] = ImageParser; exports["image/webp"] = ImageParser; exports["image/heic"] = ImageParser; exports["image/heif"] = ImageParser; +exports["image/avif"] = ImageParser; exports["image/x-icon"] = ImageParser; exports["image/vnd.microsoft.icon"] = ImageParser; From 42c22acba629030e3a016cd4a758a3cb17ac453a Mon Sep 17 00:00:00 2001 From: Saq Imtiaz Date: Mon, 27 Jan 2025 12:00:07 +0100 Subject: [PATCH 2/4] Cleans up cruft from edit widget (#8897) * chore: cleanup cruft from edit widget * chore: cleanup cruft from edit widget * chore: cleanup cruft from edit widget --- core/modules/widgets/edit.js | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/core/modules/widgets/edit.js b/core/modules/widgets/edit.js index eb7758e90..e4433e1da 100644 --- a/core/modules/widgets/edit.js +++ b/core/modules/widgets/edit.js @@ -43,15 +43,6 @@ EditWidget.prototype.execute = function() { // Get our parameters this.editTitle = this.getAttribute("tiddler",this.getVariable("currentTiddler")); 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 this.editorType = this.getEditorType(); // 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) { var changedAttributes = this.computeAttributes(); - // Refresh if an attribute has changed, or the type associated with the target tiddler has changed - if(changedAttributes.tiddler || changedAttributes.field || changedAttributes.index || changedAttributes.tabindex || changedAttributes.cancelPopups || changedAttributes.inputActions || changedAttributes.refreshTitle || changedAttributes.autocomplete || (this.getEditorType() !== this.editorType)) { + // Refresh if the editor type has changed + if(changedAttributes.tiddler || changedAttributes.field || (this.getEditorType() !== this.editorType)) { this.refreshSelf(); return true; } else { From b1843837ea2eecd26a8691d42517f447611bb31c Mon Sep 17 00:00:00 2001 From: Saq Imtiaz Date: Mon, 27 Jan 2025 12:00:26 +0100 Subject: [PATCH 3/4] Fixes unnecessary refresh in Genesis widget (#8895) * fix: handle attributes correctly in genesis widget * fix: handle attributes correctly in genesis widget --- core/modules/widgets/genesis.js | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/core/modules/widgets/genesis.js b/core/modules/widgets/genesis.js index 299be1e48..a527553ad 100644 --- a/core/modules/widgets/genesis.js +++ b/core/modules/widgets/genesis.js @@ -23,15 +23,21 @@ Inherit from the base widget class */ 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 */ GenesisWidget.prototype.render = function(parent,nextSibling) { this.parentDomNode = parent; - this.computeAttributes({filterFn: function(name) { - // Only compute our own attributes which start with a single dollar - return name.charAt(0) === "$" && name.charAt(1) !== "$"; - }}); + this.computeAttributes(); this.execute(); this.renderChildren(parent,nextSibling); }; From 67e8670c73a944c4c9dab8bb101704878c6ff4cc Mon Sep 17 00:00:00 2001 From: Leilei332 Date: Tue, 28 Jan 2025 00:45:26 +0800 Subject: [PATCH 4/4] Extend copy to clipborad function to support customized mime types (#8912) * Extend copy to clipborad function to support customized mime types * Remove function default parameter syntax * Add plainText option * Use plainText name * Set "text/plain" data only when it exists * Docs update * Docs update --- core/modules/startup/rootwidget.js | 5 +++-- core/modules/utils/dom/dom.js | 15 +++++++++++---- core/wiki/macros/copy-to-clipboard.tid | 18 ++++++++++-------- .../macros/copy-to-clipboard Macro.tid | 6 +++++- .../copy-to-clipboard Macro (Examples).tid | 10 ++++++++-- .../WidgetMessage_ tm-copy-to-clipboard.tid | 4 +++- 6 files changed, 40 insertions(+), 18 deletions(-) diff --git a/core/modules/startup/rootwidget.js b/core/modules/startup/rootwidget.js index d96d569c3..8496b48df 100644 --- a/core/modules/startup/rootwidget.js +++ b/core/modules/startup/rootwidget.js @@ -77,8 +77,9 @@ exports.startup = function() { $tw.rootWidget.addEventListener("tm-copy-to-clipboard",function(event) { $tw.utils.copyToClipboard(event.param,{ 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 $tw.rootWidget.addEventListener("tm-focus-selector",function(event) { diff --git a/core/modules/utils/dom/dom.js b/core/modules/utils/dom/dom.js index 0b71e128c..5f33bbeea 100644 --- a/core/modules/utils/dom/dom.js +++ b/core/modules/utils/dom/dom.js @@ -268,9 +268,10 @@ exports.copyStyles = function(srcDomNode,dstDomNode) { /* Copy plain text to the clipboard on browsers that support it */ -exports.copyToClipboard = function(text,options) { - options = options || {}; - text = text || ""; +exports.copyToClipboard = function(text,options,type) { + var text = text || ""; + var options = options || {}; + var type = type || "text/plain"; var textArea = document.createElement("textarea"); textArea.style.position = "fixed"; textArea.style.top = 0; @@ -283,10 +284,16 @@ exports.copyToClipboard = function(text,options) { textArea.style.outline = "none"; textArea.style.boxShadow = "none"; textArea.style.background = "transparent"; - textArea.value = text; document.body.appendChild(textArea); textArea.select(); 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; try { succeeded = document.execCommand("copy"); diff --git a/core/wiki/macros/copy-to-clipboard.tid b/core/wiki/macros/copy-to-clipboard.tid index d05d014e2..f299cf955 100644 --- a/core/wiki/macros/copy-to-clipboard.tid +++ b/core/wiki/macros/copy-to-clipboard.tid @@ -3,9 +3,11 @@ tags: $:/tags/Macro \whitespace trim -\procedure copy-to-clipboard(src,class:"tc-btn-invisible",style) -<$button message="tm-copy-to-clipboard" - param=<> +\procedure copy-to-clipboard(src,class:"tc-btn-invisible",style,type:"text/plain",plain) +\procedure copy-to-clipboard-actions() +<$action-sendmessage $message="tm-copy-to-clipboard" $param=<> type=<> plainText=<>/> +\end copy-to-clipboard-actions +<$button actions=<> class=<> style=<