One or two receiving applications and web-pages are not good at making intelligent use of the Bike PasteBoard contents (Bike and OPML flavours of XML, plus utf8 plain text).
Here in a Discourse editing field for example, if I copy a line or two in Bike, and paste them here, Discourse makes a fool of itself and offers a message about uploads:
Perhaps, for such contexts, a more restrictive Copy option, like:
Edit > Copy > Copy as Plain Text
?
In the meanwhile, of course, we could write a Paste As Plain Text
macro for Keyboard Maestro, perhaps preceding the Paste action with a snippet which reduces the pasteBoard content, for these less intelligent apps and webpages, from 2 * XML (Bike, OPML) + TXT to just utf8
.txt
Expand disclosure triangle to view JS Source
(() => {
"use strict";
// Recopy any plain UTF8 in the clipboard,
// dropping other formats.
ObjC.import("AppKit");
const main = () =>
bindLR(
clipTextLR()
)(
copyText
);
// ----------------------- JXA -----------------------
// clipTextLR :: () -> Either String String
const clipTextLR = () => (
v => Boolean(v) && 0 < v.length ? (
Right(v)
) : Left("No utf8-plain-text found in clipboard.")
)(
ObjC.unwrap($.NSPasteboard.generalPasteboard
.stringForType($.NSPasteboardTypeString))
);
// copyText :: String -> IO String
const copyText = s => {
// ObjC.import("AppKit");
const pb = $.NSPasteboard.generalPasteboard;
return (
pb.clearContents,
pb.setStringForType(
$(s),
$.NSPasteboardTypeString
),
s
);
};
// --------------------- GENERIC ---------------------
// Left :: a -> Either a b
const Left = x => ({
type: "Either",
Left: x
});
// Right :: b -> Either a b
const Right = x => ({
type: "Either",
Right: x
});
// bindLR (>>=) :: Either a ->
// (a -> Either b) -> Either b
const bindLR = m =>
mf => m.Left ? (
m
) : mf(m.Right);
return main();
})();
Here’s a general ⌘⇧V Paste as Plain Text
macro for Keyboard Maestro – it’s something which I use for pasting code, but it works in this context too:
Paste as plain text.kmmacros.zip (2.1 KB)