Jump to content

data-ipsTooltip stripped from ckeditor button


Meddysong

Recommended Posts

Posted

I've bitten the bullet and tried my hand at creating a (sort of) plugin, ie adding a button to my editor. What I wanted to achieve was something like this, where a user could add an explanation about a word if it were difficult. (The site is for language learners so articles are supposed to be in easy language.)

Screen-Shot-2014-08-18-at-1_32.45-PM.png.1b697bf56820bce4642f5969d94249aa.png

Here's the code from my button:

<a href='#' title='{option}' data-ipsTooltip>{content}</a>

But what I'm getting is this:

OnPaste.20181117-133025.jpg.6d7f3cf315d2250df97498176de76214.jpg

and the reason is because my data-ipsTooltip isn't present:

OnPaste.20181117-133137.jpg.cdbf3471b1bb78c298ac725334f6c45a.jpg

If I change the code in my browser, then everything is fine:

OnPaste.20181117-133257.jpg.921e49e45b847323ab8d904acb12edda.jpg

So the problem centres on data-ipsTooltip being stripped. Why is that? And how can I work around it?

Posted

The editor is stripping everything what's not whitelisted because of security reasons.

You can whitelist the css and js stuff in your ACP => Customization => Editor Settings

Posted

Thank you, Daniel. I've got CSS working but am not having any luck with JS. I tried entering "data-ipsTooltip" in the JS field, since that seemed the likeliest thing. Do I need to enter it differently?

Posted
3 hours ago, Meddysong said:

Thank you, Daniel. I've got CSS working but am not having any luck with JS. I tried entering "data-ipsTooltip" in the JS field, since that seemed the likeliest thing. Do I need to enter it differently?

The setting lets you specify additional allowed data controllers (e.g. values that can be used in data-controller).

You will need to create a plugin on \IPS\Text\Parser against the _htmlPurifierModifyHtmlDefinition() method to allow any new attributes. You'll probably be looking at something like

	/**
	 * Customize HTML Purifier HTML Definition
	 *
	 * @param	HTMLPurifier_HTMLDefinition	$def	The definition
	 * @return	void
	 */
	protected function _htmlPurifierModifyHtmlDefinition( \HTMLPurifier_HTMLDefinition $def )
	{
		parent::_htmlPurifierModifyHtmlDefinition( $def );

		/* Allow the data-ipstooltip attribute on 'a' tags */
		$def->addAttribute( 'a', 'data-ipstooltip', 'Bool' );
	}

 

Posted
2 minutes ago, bfarber said:

You'll probably be looking at something like

I think I'll probably need to have somebody else looking at that! My first attempt at a "plugin" (ie creating a simple button) seems to have morphed into actually needing a plugin. 

Thank you for the push into the right direction 🙂

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...