Skip to content

Commit 389aee6

Browse files
author
Avaer Kazmer
committed
Add paste event handling
1 parent fe08c1b commit 389aee6

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

app.html

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3570,7 +3570,7 @@
35703570
keyboardFocus = null;
35713571
_updateTextureDynamic();
35723572
};
3573-
mesh.click = (intersectionSpec, controllerIndex) => {
3573+
mesh.click = async (intersectionSpec, controllerIndex) => {
35743574
keyboardFocus = null;
35753575

35763576
const {id, href, name} = intersectionSpec;
@@ -3597,6 +3597,20 @@
35973597
while (root.firstChild) {
35983598
root.removeChild(root.firstChild);
35993599
}
3600+
} else if (id === 'action-copy-scene') {
3601+
const s = root.outerHTML.replace(/^(<xr-site) id="root"/, '$1');
3602+
console.log('copy', s);
3603+
clipboard.copy(s);
3604+
} else if (id === 'action-paste-scene') {
3605+
const s = await clipboard.paste();
3606+
const dom = new DOMParser().parseFromString(s, 'text/html');
3607+
console.log('paste', s, dom.body.childNodes[0].nodeName);
3608+
if (dom.body.childNodes.length === 1 && dom.body.childNodes[0].nodeName === 'XR-SITE') {
3609+
console.log('paste ok');
3610+
root.innerHTML = dom.body.childNodes[0].innerHTML;
3611+
} else {
3612+
console.log('paste fail');
3613+
}
36003614
} else if (href) {
36013615
const xrIframe = document.createElement('xr-iframe');
36023616
xrIframe.src = href;

0 commit comments

Comments
 (0)