mirror of
https://github.com/Nystik-gh/ignis.git
synced 2026-06-17 04:35:53 +00:00
clipboard reccursion fix
This commit is contained in:
22
packages/shim/src/electron/remote/native-clipboard.js
Normal file
22
packages/shim/src/electron/remote/native-clipboard.js
Normal file
@@ -0,0 +1,22 @@
|
||||
// Obsidian points navigator.clipboard.writeText at electron.clipboard, which already points at this shim.
|
||||
// To avoid recursion, use the untouched native prototype methods.
|
||||
const proto = typeof Clipboard !== "undefined" ? Clipboard.prototype : null;
|
||||
|
||||
// Returns a native-backed clipboard facade, or null in insecure (non-localhost http) contexts.
|
||||
export function getClipboard() {
|
||||
const clip =
|
||||
typeof navigator !== "undefined" ? navigator.clipboard : undefined;
|
||||
|
||||
if (!proto || !clip) {
|
||||
console.warn(
|
||||
"[shim:clipboard] clipboard API unavailable (insecure context?)",
|
||||
);
|
||||
return null;
|
||||
}
|
||||
|
||||
return {
|
||||
writeText: (text) => proto.writeText.call(clip, text),
|
||||
write: (items) => proto.write.call(clip, items),
|
||||
read: () => proto.read.call(clip),
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user