mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-11-10 03:49:56 +00:00
fix RSOD if tm-copy-to-clipboard param is empty (#8393)
This commit is contained in:
parent
a4649490de
commit
da8b213be5
@ -270,6 +270,7 @@ Copy plain text to the clipboard on browsers that support it
|
|||||||
*/
|
*/
|
||||||
exports.copyToClipboard = function(text,options) {
|
exports.copyToClipboard = function(text,options) {
|
||||||
options = options || {};
|
options = options || {};
|
||||||
|
text = text || "";
|
||||||
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;
|
||||||
@ -289,7 +290,7 @@ exports.copyToClipboard = function(text,options) {
|
|||||||
var succeeded = false;
|
var succeeded = false;
|
||||||
try {
|
try {
|
||||||
succeeded = document.execCommand("copy");
|
succeeded = document.execCommand("copy");
|
||||||
} catch (err) {
|
} catch(err) {
|
||||||
}
|
}
|
||||||
if(!options.doNotNotify) {
|
if(!options.doNotNotify) {
|
||||||
var successNotification = options.successNotification || "$:/language/Notifications/CopiedToClipboard/Succeeded",
|
var successNotification = options.successNotification || "$:/language/Notifications/CopiedToClipboard/Succeeded",
|
||||||
@ -326,7 +327,7 @@ exports.collectDOMVariables = function(selectedNode,domNode,event) {
|
|||||||
variables["tv-popup-coords"] = Popup.buildCoordinates(Popup.coordinatePrefix.csOffsetParent,nodeRect);
|
variables["tv-popup-coords"] = Popup.buildCoordinates(Popup.coordinatePrefix.csOffsetParent,nodeRect);
|
||||||
|
|
||||||
var absRect = $tw.utils.extend({}, nodeRect);
|
var absRect = $tw.utils.extend({}, nodeRect);
|
||||||
for (var currentNode = selectedNode.offsetParent; currentNode; currentNode = currentNode.offsetParent) {
|
for(var currentNode = selectedNode.offsetParent; currentNode; currentNode = currentNode.offsetParent) {
|
||||||
absRect.left += currentNode.offsetLeft;
|
absRect.left += currentNode.offsetLeft;
|
||||||
absRect.top += currentNode.offsetTop;
|
absRect.top += currentNode.offsetTop;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user