Correct handling of pasting tiddlers (#7215)

* First Pass Implementation

* Fix Check

* Fix Style

* Update drag-drop interop example to support copy tiddlers to clipboard

---------

Co-authored-by: jeremy@jermolene.com <jeremy@jermolene.com>
This commit is contained in:
GameDungeon
2023-05-06 14:02:16 +01:00
committed by GitHub
co-authored by jeremy@jermolene.com
parent 474b73bdbe
commit e66e791944
3 changed files with 69 additions and 3 deletions
@@ -15,6 +15,10 @@
<div id="draggable" draggable="true">
Drag me to a TiddlyWiki window
</div>
<button id="copy">
Click to copy two tiddlers to the clipboard
</button>
</body>
<script>
@@ -30,6 +34,18 @@
event.stopPropagation();
return false;
});
document.getElementById("copy").addEventListener("click",function(event) {
function listener(event) {
event.clipboardData.setData("URL","data:text/vnd.tiddler," + encodeURIComponent(JSON.stringify(tiddlerData)));
event.preventDefault();
}
document.addEventListener("copy",listener);
document.execCommand("copy");
document.removeEventListener("copy",listener);
});
</script>
</html>