#9330 closed Bug (fixed)
CKEditor Paste From Word strips anchor tags
Reported by: | Jake Berkes | Owned by: | Piotrek Koszuliński |
---|---|---|---|
Priority: | Normal | Milestone: | CKEditor 4.2.1 |
Component: | Plugin : Paste from Word | Version: | 3.0 |
Keywords: | IBM | Cc: | monahant@… |
Description
When using Paste From Word option, anchor tags (<a name=...>) are stripped from the code.
I have set PasteFromWordRemoveFontStyles="false" and PasteFromWordRemoveStyles="false". The only way to retain these tags is to skip cleanup using PasteFromWordPromptCleanup="true" and choose no at the prompt.
Attached file contains an anchor and hyperlink. Pasting the content into CKEditor without cleanup results in the following:
<a name="Anchor1"><span style="font-size:12.0pt;font-family: "Times New Roman","serif"">Anchor for text above.</span></a><span style="font-size:12.0pt;font-family:"Times New Roman","serif""><o:p></o:p></span></p>
Pasting with cleanup strips the <a name=..> tag completely:
<span style="font-family:times new roman,serif;"><span style="font-size:12.0pt;">Anchor for text above.</span></span>
Attachments (1)
Change History (16)
Changed 12 years ago by
Attachment: | Sample Anchor Document.docx added |
---|
comment:1 Changed 12 years ago by
Keywords: | paste word anchor removed |
---|---|
Resolution: | → invalid |
Status: | new → closed |
I have tried your sample file on demo page and in latest CKEditor 3.6.4 and anchor was never removed.
Please use latest version of CKEditor and if you have done any customizations please check if they are not causing this error.
I'm closing this issue as invalid. If you think otherwise please provide detailed TC explaining step by step what to do to get this error (Perhaps configuration setting also matter).
comment:2 Changed 12 years ago by
I have updated to 3.6.4 as well as tested on the demo page, and am able to reproduce the issue still on both. The following steps will show the error:
- Using the attached "Sample Anchor Document.docx" file, select all and copy.
- Using http://ckeditor.com/demo page, paste the text using Paste From Word.
- The problem is immediately evident visibly - the line "Anchor for text above." should be preceded by an anchor tag; it is not.
Also evident in the source code view; the following line:
<p>Anchor for text above.</p>
Should be:
<p><a name="Anchor1">Anchor for text above.</a></p>
comment:3 Changed 12 years ago by
I was able to locate the function that is causing this behavior in the pastefromword filter default.js file:
a:function(O){var P=O.attributes;if(P&&!P.href&&P.name)delete O.name;else if(CKEDITOR.env.webkit&&P.href&&P.href.match(/file:\/\/\/[\S]+#/i))P.href=P.href.replace(/file:\/\/\/[^#]+/i,'');}
if an <a> tag is pasted with a name and no href, it deletes the name. Is this behavior intentional? If so, can you supply the reasoning behind this?
comment:4 Changed 12 years ago by
Resolution: | invalid |
---|---|
Status: | closed → reopened |
comment:5 Changed 12 years ago by
Status: | reopened → confirmed |
---|---|
Version: | 3.6.2 → 3.0 |
In source version of this file \ckeditor\_source\plugins\pastefromword\filter\default.js There is a comment saying that anchors with content are dropped due to #3582.
This issue is now fixed thus pasteFromWord filter should also allow for anchors with text.
I think that current way how filter works is invalid. Filter should not remove anchors with but instead let them go through and if user decides to remove (putting text in anchor is probably not very popular) or edit text of such anchor he should have this possibility through anchor dialog (#9406).
comment:6 Changed 12 years ago by
@jberkes I think that workaround for you is to remove this part of code:
if(P&&!P.href&&P.name)delete O.name;else
that way you will be able to paste such tags.
If you get any errors after this change it would be nice if you could report them here.
comment:7 Changed 12 years ago by
I have applied the workaround as recommended and can confirm that it does work properly. I apologize if this is an unnecessary comment but I wanted to provide confirmation in case it might help others.
comment:8 Changed 12 years ago by
Cc: | monahant@… added |
---|---|
Keywords: | IBM added |
Can a fix for this be incorporated into an official release? Anchors are still getting removed from content pasted from Word in CKEditor 4.x builds.
comment:9 Changed 12 years ago by
Milestone: | → CKEditor 4.2.1 |
---|
It looks like the code that is filtering these anchors is a bit outdated. It's there because of #3582, which is not any more an issue.
This needs to be reviewed and we should be able to have anchors working at that point.
comment:10 Changed 12 years ago by
Component: | General → Core : Pasting |
---|
comment:11 Changed 11 years ago by
Owner: | set to Piotrek Koszuliński |
---|---|
Status: | confirmed → assigned |
comment:12 Changed 11 years ago by
Status: | assigned → review |
---|
comment:13 Changed 11 years ago by
Status: | review → review_passed |
---|
Only Opera filters anchor and pastes below:
<p><a href="#Anchor1">Link to text below.</a></p> <p>Anchor for text above.</p>
instead of pasting:
<p><a href="#Anchor1">Link to text below.</a></p> <p><a name="Anchor1">Anchor for text above.</a></p>
as explained by @Reinmar this will be gone when official Opera on Blink engine will be released.
comment:14 Changed 11 years ago by
Resolution: | → fixed |
---|---|
Status: | review_passed → closed |
Fixed on master with git:bde01c9 and f029dec on tests.
comment:15 Changed 11 years ago by
Component: | Core : Pasting → Plugin : Paste from Word |
---|
Simple document with link and anchor