Add right-click Copy Image to diagrams

This commit is contained in:
Ian Gulliver
2026-10-23 09:08:21 -07:00
parent 41335867ef
commit fe86916ce6
3 changed files with 57 additions and 13 deletions
+19
View File
@@ -31,6 +31,16 @@ func copyToClipboard(_ text: String) {
NSPasteboard.general.setString(text, forType: .string)
}
@MainActor
func copyToClipboard(_ image: PlatformImage) {
NSPasteboard.general.clearContents()
NSPasteboard.general.writeObjects([image])
}
func platformImage(_ cg: CGImage) -> PlatformImage {
NSImage(cgImage: cg, size: NSSize(width: cg.width / 2, height: cg.height / 2))
}
@MainActor
func openExternal(_ url: URL) {
NSWorkspace.shared.open(url)
@@ -96,6 +106,15 @@ func copyToClipboard(_ text: String) {
UIPasteboard.general.string = text
}
@MainActor
func copyToClipboard(_ image: PlatformImage) {
UIPasteboard.general.image = image
}
func platformImage(_ cg: CGImage) -> PlatformImage {
UIImage(cgImage: cg, scale: 2, orientation: .up)
}
@MainActor
func openExternal(_ url: URL) {
UIApplication.shared.open(url)