March 2, 2023

AutoHotkey Html Clipboard issue with Confluence

I have fixed last week in bug in my AutoHotkey IntelliPaste feature. This bug only occurred when pasting html formatted links to a Confluence page. It was converted to an image.

Problem Description

When pasting a html formatted clipboard content like below in to a Confluence page Editor:
<a href="https://xxx.sharepoint.com/sites/yyy">xxx</a> > <a href="https://xxx.sharepoint.com/sites/yyy/Freigegebene Dokumente">Freigegebene Dokumente</a> > <a href="https://xxx.sharepoint.com/sites/yyy/Freigegebene Dokumente/_root">_root</a> > <a href="https://xxx.sharepoint.com/sites/yyy/Freigegebene Dokumente/_root/PMT">PMT</a> > <a href="https://xxx.sharepoint.com/sites/yyy/Freigegebene Dokumente/_root/PMT/Trainings">Trainings</a> > <a href="https://xxx.sharepoint.com/sites/yyy/Freigegebene Dokumente/_root/PMT/Trainings/ISO 26262 Introduction to Functional Safety Automotive">ISO 26262 Introduction to Functional Safety Automotive</a> > <a href="https://xxx.sharepoint.com/sites/yyy/Freigegebene Dokumente/_root/PMT/Trainings/ISO 26262 Introduction to Functional Safety Automotive/50_01_Software_20220420.pdf">50_01_Software_20220420.pdf</a>

And after the upload it renders like:


Note: this seems to be really related to the Confluence Editor. 

Pasting in this Blogger editor does not make any issue. 

I couldn't find any mention of such Clipboard issue with Confluence in the Internet.

Solution

I have switched from the Clipboard library WinClip to this function SetClipboardHTML

You can see the new function Clip_PasteHml in my Clip.ahk library.
Extract below:

; -------------------------------------------------------------------------------------------------------------------
Clip_PasteHtml(sHtml,restore := True) {
; Syntax: Clip_PasteHtml(sHtml,restore := True)
; If sHtml is a link (starts with http), the Html link will be wrapped around it i.e. sHtml=<a href="%sHtml%">%sText%</a>
If (restore)
    ClipBackup := ClipboardAll
SetClipboardHTML(sHtml)
WinClip.Paste()  
If (restore)
    Clip_Restore(ClipBackup)
} ; eofun

The function does not have this issue with Confluence.

See also

SetClipboardHTML() - AutoHotkey Community

WinClip - AHKv2 Compatibility - AutoHotkey Community


No comments:

Post a Comment