2 Replies Latest reply: Aug 31, 2013 4:51 PM by Hiroto
nazaroony Level 1 Level 1 (0 points)

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)
  • Jerrold Green1 Level 7 Level 7 (29,945 points)

    That appears to be the case. Someone here may know why, but there's not much we can do about how Numbers works. A workaround would be to create the combined text and link in a text editor, or in a Numbers Text Box, and then pasting the combination into the Numbers cell.

     

    Screen Shot 2013-08-30 at 8.47.10 pm.png

     

    Jerry

  • Hiroto Level 5 Level 5 (5,955 points)

    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"