Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Numbers - Can't paste hyperlink into written-in cell

Hi,


When trying to paste a website link into a cell with writing in, all other text is deleted from the cell, and only the link remains.

I am already double-clicking on the cell and making sure my cursor appears, so the paste should not be overriding all content as if i just highlighted the cell.


Any helpers out there? This is really annoying, thanks.

MacBook Air (13-inch Mid 2013)

Posted on Aug 30, 2013 3:45 PM

Reply
2 replies

Aug 31, 2013 4:51 PM in response to nazaroony

Hello


I think it's bug of Numbers. As far as I have tested, Numbers erases existing cell contents as reported when pasting hyperlink in clipboard which is represented by data of types public.url and public.url-name. It is the case when link is copied by, e.g., Safari or TextEdit. Meanwhile, link represented by data of type public.html is pasted properly without destroying existing contents. It is the case when link is copied by, e.g., Firefox.


A workaround is to convert link representation in clipboard. You may try running the following AppleScript script before pasting the link in Numbers cell. It is a simple wrapper of RubyCocoa code which converts link representation in clipboard. You may invoke it from script menu when saved as compiled script in ~/Library/Scripts/Applications/Numbers directory or service menu when saved as Automator service in ~/Library/Services directory.


Tested with Numbers 2.0.5 under 10.6.5.

Hope this may help,

H



do shell script "/usr/bin/ruby <<'EOF'
# 
#     convert [public.url + public.url-name] to [public.html] in clipboard
# 
#     * To represent hyperlink data in clipboard, 
#         [public.url + public.url-name] is used by Safari, TextEdit etc, and
#         [public.html] is used by Firefox.
# 
require 'osx/cocoa'
include OSX

pboard = NSPasteboard.generalPasteboard
pbtype = pboard.availableTypeFromArray(['public.url'])
exit if pbtype == nil
urldata = pboard.dataForType(pbtype)
url = NSString.alloc.objc_send(
    :initWithData, urldata,
    :encoding, NSUTF8StringEncoding)

pbtype = pboard.availableTypeFromArray(['public.url-name'])
urlndata = pbtype ? pboard.dataForType(pbtype) : urldata
urln = NSString.alloc.objc_send(
    :initWithData, urlndata,
    :encoding, NSUTF8StringEncoding)

html = <<EOT
<html>
<head><meta http-equiv=\"content-type\" content=\"text/html; charset=utf-8\"></head>
<body><a href=\"#{url}\">#{urln}</a></body>
</html>
EOT
htmldata = html.to_ns.dataUsingEncoding(NSUTF8StringEncoding)

pbtype = 'public.html'
pboard.objc_send(
    :declareTypes, [pbtype],
    :owner, nil)
pboard.objc_send(
    :setData, htmldata,
    :forType, pbtype)
EOF"

Numbers - Can't paste hyperlink into written-in cell

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.