• Links in TextEdit

    From Martin S Taylor@21:1/5 to All on Sun Jan 8 19:47:16 2023
    I'm in TextEdit.

    I can insert a link to a URL by dragging it from the title bar of Safari directly into the TextEdit document.

    I can insert a link to an email I've received by dragging it from Mail into
    the TextEdit document.

    I can insert a link to a file by a) Selecting "Add Link..." from TextEdit's Edit menu; then b) dragging the file into the dialog box which appears (this puts the URL of the file into the dialog box); then c) adding "file://"
    before the URL in the dialog box.

    There must be an easier way, surely?

    Martin S Taylor

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Bruce Horrocks@21:1/5 to Martin S Taylor on Mon Jan 9 01:42:00 2023
    On 08/01/2023 19:47, Martin S Taylor wrote:
    I'm in TextEdit.

    I can insert a link to a URL by dragging it from the title bar of Safari directly into the TextEdit document.

    I can insert a link to an email I've received by dragging it from Mail into the TextEdit document.

    I can insert a link to a file by a) Selecting "Add Link..." from TextEdit's Edit menu; then b) dragging the file into the dialog box which appears (this puts the URL of the file into the dialog box); then c) adding "file://" before the URL in the dialog box.

    There must be an easier way, surely?

    Martin S Taylor

    Drag the file into Safari and then drag the file:// URL from Safari into TextEdit?

    --
    Bruce Horrocks
    Surrey, England

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Bernd Froehlich@21:1/5 to All on Mon Jan 9 07:37:10 2023
    On 9. Jan 2023 at 02:42:00 CET, "Bruce Horrocks" <[email protected]>
    wrote:

    I can insert a link to a file by a) Selecting "Add Link..." from TextEdit's >> Edit menu; then b) dragging the file into the dialog box which appears (this >> puts the URL of the file into the dialog box); then c) adding "file://"
    before the URL in the dialog box.

    There must be an easier way, surely?

    Just tried this in BBEdit.
    If you hold down cmd while dragging a file it inserts the path.
    You still have to insert the "file://" yourself but maybe you can use a
    macro for that?

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Martin S Taylor@21:1/5 to Bruce Horrocks on Mon Jan 9 10:19:03 2023
    On 9 Jan 2023, Bruce Horrocks wrote
    (in article<[email protected]>):

    I can insert a link to a file by a) Selecting "Add Link..." from TextEdit's Edit menu; then b) dragging the file into the dialog box which appears (this
    puts the URL of the file into the dialog box); then c) adding "file://" before the URL in the dialog box.

    There must be an easier way, surely?

    Martin S Taylor

    Drag the file into Safari and then drag the file:// URL from Safari into TextEdit?

    That's not a lot easier, really.

    Furthermore, if I select TextEdit's "Add Link..." I can at least link it to words already in the document. So, for example, if the words "this picture" appear in the TextEdit document, I can select them, "Add Link..." and the
    link is then linked to the words "this picture", and not a great ugly URL in the middle of my text.

    Cheers,

    MST

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Martin S Taylor@21:1/5 to Bernd Froehlich on Mon Jan 9 10:15:41 2023
    On 9 Jan 2023, Bernd Froehlich wrote
    (in article <[email protected]>):

    I can insert a link to a file by a) Selecting "Add Link..." from TextEdit's
    Edit menu; then b) dragging the file into the dialog box which appears (this
    puts the URL of the file into the dialog box); then c) adding "file://" before the URL in the dialog box.

    There must be an easier way, surely?

    Just tried this in BBEdit.
    If you hold down cmd while dragging a file it inserts the path.
    You still have to insert the "file://" yourself but maybe you can use a
    macro for that?

    I don't have BBEdit, but inserting the path (eg. by dragging it from the Finder's Get Info box) doesn't create a link, even if you manually insert the "file://". You have to create a link using TextEdit's "Add Link...".

    Or do it the way Bruce suggested further up this thread.

    MST

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Bruce Horrocks@21:1/5 to Martin S Taylor on Mon Jan 9 21:37:07 2023
    On 09/01/2023 10:19, Martin S Taylor wrote:
    On 9 Jan 2023, Bruce Horrocks wrote (in article<[email protected]>):

    I can insert a link to a file by a) Selecting "Add Link..." from
    TextEdit's Edit menu; then b) dragging the file into the dialog
    box which appears (this puts the URL of the file into the dialog
    box); then c) adding "file://" before the URL in the dialog box.

    There must be an easier way, surely?

    Martin S Taylor

    Drag the file into Safari and then drag the file:// URL from Safari
    into TextEdit?

    That's not a lot easier, really.

    Ah, well, you asked for "easier" not "a lot easier" ;-)

    Furthermore, if I select TextEdit's "Add Link..." I can at least link
    it to words already in the document. So, for example, if the words
    "this picture" appear in the TextEdit document, I can select them,
    "Add Link..." and the link is then linked to the words "this
    picture", and not a great ugly URL in the middle of my text.

    Try this bit of AppleScript. It will prompt for various permissions the
    first time as it needs to use Accessibility to be able to type into
    TextEdit.

    -- start of script
    -- Save this AppleScript as a .app file.
    -- To use, highlight a word in TextEdit and then drop a file onto this
    script in the Finder.
    -- The highlighted word will be replaced with a link to the file that
    was dropped.
    on open someItems
    set theItem to item 1 of someItems
    tell application "TextEdit"
    activate
    tell application "System Events"
    set theFileURL to URL of (theItem as alias)
    keystroke "k" using command down
    keystroke theFileURL
    -- keystroke return
    end tell
    end tell
    end open
    -- end of script

    The "keystroke return" line is commented out so you can see what text
    will be behind the link before you press return. If you are confident
    then you can uncomment the line and you can save yourself a keypress.

    --
    Bruce Horrocks
    Surrey, England

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Martin S Taylor@21:1/5 to Bruce Horrocks on Tue Jan 10 08:36:59 2023
    On 9 Jan 2023, Bruce Horrocks wrote
    (in article<[email protected]>):

    Try this bit of AppleScript. It will prompt for various permissions the
    first time as it needs to use Accessibility to be able to type into
    TextEdit.

    Terrific! Thank you.

    MST

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)