If you think a bug might affect users in the 57 release, please set the correct tracking and status flags for Release Management.

Setting clipboard data to "text/rtf" doesn't work

NEW
Unassigned

Status

()

Core
Widget: Win32
P4
enhancement
2 years ago
9 months ago

People

(Reporter: support, Unassigned)

Tracking

Firefox Tracking Flags

(Not tracked)

Details

(Whiteboard: tpi:+)

Attachments

(1 attachment)

(Reporter)

Description

2 years ago
User Agent: Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/48.0.2564.103 Safari/537.36

Steps to reproduce:

function onCopy(e){
  e.preventDefault();
  var rtfString = '{\\rtf1\\ansi\\ansicpg936\\deff0\\nouicompat\\deflang1033\\deflangfe2052{\\fonttbl{\\f0\\fnil\\fcharset0 Calibri;}}\\uc1\\pard\\sa200\\sl276\\slmult1\\ul\\b\\i\\f0\\fs22\\lang9 How are you}';
  e.clipboardData.setData('text/rtf', rtfString);
}


Actual results:

On WordPad, it pasted a "{", on Word, it pasted following:

_r_t_f_1_a_n_s_i_a_n_s_i_c_p_g_9_3_6_d_e_f_f_0_n_o_u_i_c_o_m_p_a_t_d_e_f_l_a_n_g_1_0_3_3_d_e_f_l_a_n_g_f_e_2_0_5_2__f_o_n_t_t_b_l__f_0_f_n_i_l_f_c_h_a_r_s_e_t_0_ _C_a_l_i_b_r_i_;___u_c_1_p_a_r_d_s_a_2_0_0_s_l_2_7_6_s_l_m_u_l_t_1_u_l_b_i_f_0_f_s_2_2_l_a_n_g_9_ _H_o_w_ _a_r_e_ _y_o_u_


Expected results:

It should paste "How are you" in bold and underline

Updated

2 years ago
Summary: Setting clipboard data to text/rtf" doesn't work → Setting clipboard data to "text/rtf" doesn't work

Updated

2 years ago
Component: Untriaged → Untriaged
Keywords: testcase-wanted
Product: Firefox → Core
text/rtf is not one of the types explicitly supported in the spec.

Updated

2 years ago
Component: Untriaged → Widget: Win32
Hi reporter,

Could you please provide a full functional test case so I can test this issue on my end? I didn't manage to reproduce this issue with the code you provided in comment 0. Does this reproduce in other browsers as well?

Also, is this still reproducible on your end ? If yes, can you please retest this using latest FF release and latest Nightly build (https://nightly.mozilla.org/) and report back the results ? When doing this, please use a new clean Firefox profile, maybe even safe mode, to eliminate custom settings as a possible cause (https://goo.gl/PNe90E).

Thanks,
Paul.
Flags: needinfo?(support)
(Reporter)

Comment 3

2 years ago
I can still reproduce it in 46.0a2 (2016-03-02) developer edition and 48.0a1 (2016-03-18) nightly.

For now. Firefox is the only browser which support RTF format accessing. Chrome is working on it but still not finished.

Please check this test:
https://jsfiddle.net/Lcaj1aqa/3/

Focus on the red area and press Ctrl+C
Flags: needinfo?(support)

Comment 4

2 years ago
Note that this is not only a Core::Widget:Win32 problem since RTF data is also supported on Mac. To me this looks like the sister bug of bug 938991 which touched various files incl. in Core::Dom:Events.

I'm not sure why comment #2 ask to try this in a Nightly build. There simply is no support for placing RTF data onto the clipboard.

Also see bug 1233162 which requested being able to put RTF data during a paste event.
Severity: normal → enhancement
Status: UNCONFIRMED → NEW
Ever confirmed: true
See Also: → bug 1233162

Comment 5

2 years ago
Created attachment 8732308 [details]
Page from https://jsfiddle.net/Lcaj1aqa/3/

I'm not sure how JSFiddle is supposed to work, so I'm attaching the testcase here.

I can't reproduce what is said in comment #0. For me, nothing is pasted into Wordpad or Word. However, if I look at the Windows clipboard, I can see an "text/rtf" item. But this is not recognised by Wordpad or Word.

If I change the JS to
e.clipboardData.setData('Rich Text Format', rtf);
*then* I get what the reporter says in comment #0.

Overall, some places in FF would need some tweaks to carry the RFT through so it could be pasted into Wordpad or Word on Windows or TextEdit on Mac.

Updated

2 years ago
Keywords: testcase-wanted

Updated

a year ago
Priority: -- → P4
Whiteboard: tpi:+

Comment 6

9 months ago
I can confirm that this is not working in Firefox Beta 51.0b7 (OSX).

I'm trying to help port an extension (ColT) to the new WebExtensions framework, so that Electrolysis can be turned on. This add-on combines the Page URL and Title into a nice RTF link that can be pasted in Google Docs for example. Very useful. Testing with event.clipboardData.setData and 'text/plain' works fine, but not with 'text/rtf'.

I'm confused by this WebExtensions framework. It seems Mozilla is pushing developers to convert their extensions but it looks like it can do a lot less than the previous add-ons frameworks could do.

Comment 7

9 months ago
Seems I can use 'text/html' though, and the result can be pasted in Word, Google Docs, etc. Thanks.
You need to log in before you can comment on or make changes to this bug.