Before asking for help please read "How to request help" by clicking on that tab above here.
  • Page:
  • 1

TOPIC:

CKeditor removes anchor tags on save 1 week 4 days ago #1

  • superhappybunnycat
  • superhappybunnycat's Avatar Topic Author
  • Offline
  • New
  • New
  • Posts: 9
It does this whether you use the button to put it in or type it manually. Does anyone have a fix for this? A quick google suggests its a long standing issue with it. The fixes suggested elsewhere are years old and don't work :(

Apparently it's to do with a HTML clean up that is done on save. It removes these tags even though they aren't empty

Please Log in or Create an account to join the conversation.

CKeditor removes anchor tags on save 1 week 4 days ago #2

  • fisharebest
  • fisharebest's Avatar
  • Offline
  • Administrator
  • Administrator
  • Posts: 13196
I just went to the demo site - dev.webtrees.net/demo-stable
I logged in as editor / editor
I added an HTML block to the "My page"
I added a link using the CKeditor.
It worked fine.

1) Does it work for you on the demo site?
2) Are you trying to do anything clever (e.g. adding an "onclick" handler to the link?)
Greg Roach - This email address is being protected from spambots. You need JavaScript enabled to view it. - fisharebest.webtrees.net

Please Log in or Create an account to join the conversation.

CKeditor removes anchor tags on save 1 week 4 days ago #3

  • superhappybunnycat
  • superhappybunnycat's Avatar Topic Author
  • Offline
  • New
  • New
  • Posts: 9
It's not regular links, they work fine. It's anchor links.

I'm trying to add a story for an individual and using the editor for the main part of the story. I'm trying to use it to write a bio and put in citations [1] that will link to the references at the bottom of the page. It is fine until you hit save - for whatever reason it keeps deleting the anchor tag at the bottom of the page eg
I can put this at the top of the page without issue: [<a href="#citation01">1</a>], and I can also add this at the bottom with the button or manually: [<a id="citation01" name="citation01">1</a>]
After saving however the first link remains but [<a id="citation01" name="citation01">1</a>] has been removed and changed back to [1]

Please Log in or Create an account to join the conversation.

Last edit: by superhappybunnycat.

CKeditor removes anchor tags on save 1 week 4 days ago #4

The XHTML way of doing this is to use <div> for the target, but the editor removes the id= from the <div> tags when you save.
John Elvin

Please Log in or Create an account to join the conversation.

CKeditor removes anchor tags on save 1 week 4 days ago #5

  • fisharebest
  • fisharebest's Avatar
  • Offline
  • Administrator
  • Administrator
  • Posts: 13196
It seems that this is the default behaviour of HTMLPurifier - htmlpurifier.org/docs/enduser-id.html

The argument goes that allowing user-generated content to contain arbitrary IDs could break your page/site.

It recommends only allowing anchors with a specified prefix.
Greg Roach - This email address is being protected from spambots. You need JavaScript enabled to view it. - fisharebest.webtrees.net

Please Log in or Create an account to join the conversation.

CKeditor removes anchor tags on save 1 week 4 days ago #6

John Elvin

Please Log in or Create an account to join the conversation.

CKeditor removes anchor tags on save 1 week 4 days ago #7

  • superhappybunnycat
  • superhappybunnycat's Avatar Topic Author
  • Offline
  • New
  • New
  • Posts: 9
I tried adding config.removePlugins = 'htmldataprocessor'; to the config file but that didn't work :(, also tried adding config.allowedContent = true; which seemed to preserve the a tag but still removed the name or id from it.

Tried another suggestion I found of adding data-cke-survive="true" to the a tag but that didn't work either.

I'm not sure what "only allowing anchors with a specified prefix" means - can you elaborate?

Unless anyone has any other ideas I might have to just switch off the CKEditor

Please Log in or Create an account to join the conversation.

CKeditor removes anchor tags on save 1 week 4 days ago #8

  • fisharebest
  • fisharebest's Avatar
  • Offline
  • Administrator
  • Administrator
  • Posts: 13196
There are *two* sets of filtering.

1) in the browser (ckeditor). This allows anchor tags. It even has a button to add them.

2) on the server (HTMLPurifier). This strips anchor tags, for the reason give above.

> Unless anyone has any other ideas I might have to just switch off the CKEditor

This won't help. These are being stripped on the *SERVER*, not by ckeditor.

> I'm not sure what "only allowing anchors with a specified prefix" means - can you elaborate?

Only allow anchors that begin with a specified sequence of characters.

e.g.
<div id="prefix_xxxx"></div>
Greg Roach - This email address is being protected from spambots. You need JavaScript enabled to view it. - fisharebest.webtrees.net

Please Log in or Create an account to join the conversation.

Do you need a web hosting solution for your webtrees site?
If you prefer a host that specialises in webtrees, the following page lists some suppliers able to provide one for you: 
  • Page:
  • 1
Powered by Kunena Forum