Bienvenue, Invité
Nom d'utilisateur : Mot de passe :
Before asking for help please read "How to request help" by clicking on that tab above here.
  • Page :
  • 1

SUJET :

CKeditor removes anchor tags on save il y a 1 semaine 4 jours #1

  • superhappybunnycat
  • Portrait de superhappybunnycat Auteur du sujet
  • Hors Ligne
  • New
  • New
  • Messages : 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

Connexion ou Créer un compte pour participer à la conversation.

CKeditor removes anchor tags on save il y a 1 semaine 4 jours #2

  • fisharebest
  • Portrait de fisharebest
  • Hors Ligne
  • Administrator
  • Administrator
  • Messages : 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 - Cette adresse e-mail est protégée contre les robots spammeurs. Vous devez activer le JavaScript pour la visualiser. - fisharebest.webtrees.net

Connexion ou Créer un compte pour participer à la conversation.

CKeditor removes anchor tags on save il y a 1 semaine 4 jours #3

  • superhappybunnycat
  • Portrait de superhappybunnycat Auteur du sujet
  • Hors Ligne
  • New
  • New
  • Messages : 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]

Connexion ou Créer un compte pour participer à la conversation.

Dernière édition: par superhappybunnycat.

CKeditor removes anchor tags on save il y a 1 semaine 4 jours #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

Connexion ou Créer un compte pour participer à la conversation.

CKeditor removes anchor tags on save il y a 1 semaine 4 jours #5

  • fisharebest
  • Portrait de fisharebest
  • Hors Ligne
  • Administrator
  • Administrator
  • Messages : 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 - Cette adresse e-mail est protégée contre les robots spammeurs. Vous devez activer le JavaScript pour la visualiser. - fisharebest.webtrees.net

Connexion ou Créer un compte pour participer à la conversation.

CKeditor removes anchor tags on save il y a 1 semaine 4 jours #6

John Elvin

Connexion ou Créer un compte pour participer à la conversation.

CKeditor removes anchor tags on save il y a 1 semaine 4 jours #7

  • superhappybunnycat
  • Portrait de superhappybunnycat Auteur du sujet
  • Hors Ligne
  • New
  • New
  • Messages : 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

Connexion ou Créer un compte pour participer à la conversation.

CKeditor removes anchor tags on save il y a 1 semaine 4 jours #8

  • fisharebest
  • Portrait de fisharebest
  • Hors Ligne
  • Administrator
  • Administrator
  • Messages : 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 - Cette adresse e-mail est protégée contre les robots spammeurs. Vous devez activer le JavaScript pour la visualiser. - fisharebest.webtrees.net

Connexion ou Créer un compte pour participer à la conversation.

Avez-vous besoin d'une solution d'hébergement web pour votre site webtrees ?
Si vous préférez un hébergeur spécialisé de webtrees, la page suivante en liste quelques-uns capables de vous offrir ce type de service :
  • Page :
  • 1
Propulsé par Kunena