Open gwicke opened 4 years ago
I've tried this with the latest development build but couldn't reproduce it. Could you try it via about:debugging?: https://piro.sakura.ne.jp/xul/xpi/nightly/copy-selected-tabs-to-clipboard.xpi
Steps I did:
%RT%<a title="%TITLE_HTML%" href="%URL_HTML%">%TITLE_HTML%</a>
%RT%
On both steps 7 and 9 I successfully got inserted links. If you still fail, I think it may be a problem of Firefox or the platform itself...
Retried on Mozilla/5.0 (X11; Linux x86_64; rv:77.0) Gecko/20100101 Firefox/77.0.
Neither the nightly, nor the released version of the extension are copying the %RT%
format for Google docs tabs, while other tabs (and other link formats on Google Docs) are working fine.
I stepped through the copy process in the debugger, and the richText HTML string looks correct to me. The execution hits the browser.tabs.executeScript(permittedTabs[0].id path, and tries to inject the event based copy code into the gdocs page, but the clipboard is not updated.
OK I got it why the difference between my result and your result happens. On my case I select multiple tabs including both Google Docs and other services, and the first tab of them is not Google Docs. On the other hand your case looks to have Google Docs as the first tab.
Due to some technical reasons, this addon executes document.execCommand()
and handles it with its own custom event listener, in the first tab of the selection. If you have something another webpage as the first selected tab, the operation succeeds. On the other hand, if the first tab shows Google Docs, document.execCommand()
is executed but the event never been handled by the custom event listener. It possibly that such events have been handled and canceled by scripts of the Google Docs service itself.
There is only one workaround: enabling the native clipboard write API of Firefox itself. Go to about:config
and turn dom.events.asyncClipboard.dataTransfer
to true
, then the API becomes available and this addon will use it to copy rich text data without script execution in webpages. (But I've found that there is a mistake and you need to wait a next release including the commit fc80555.)
I've released the version 1.3.0 with the fix.
Confirmed that rich text copying is now working for gdocs tabs as well with the preference set. Thank you!
One small nit: When the preference is missing, I am getting the HTML string in the clipboard (with <a> tags), rather than the plain text format. Might be nicer to fall back to the user configured plain text format instead.
Short description
Copying the rich text linked title does not work for fully loaded Google Docs tabs, but does work for unloaded ones, and other websites. Other formats (such as separate title & link) work as well.
Steps to reproduce
Expected result
Tab title is copied as linked, rich text.
Actual result
Clipboard was not updated, previous clipboard content is inserted.
Environment