I'm using CKEditor with BBCode plugin and I need to add custom tags like a spoiler
tag and another one which would provide the possibility to link to a site user's profile.
spoiler
tags would work like blockquote
tags: clicking the button and getting the code. I copied blockquote/plugin.js
and changed all blockquote
strings to spoiler
and quote
to spoil
. Then I added extraPlugins: 'spoiler'
to the configuration and a button on the toolbar. It appears correctly, but it generates a wrong code.
For example, if I click the blockquote button after selecting a text, the following code gets generated:
[quote]some text[/quote]
but when I click my new button, I get the following code:
<p>
<spoiler>
<p>
!!!</p>
</spoiler></p>
So it doesn't work.
I would also like to create a button for linking to a user. It should work like this: after clicking the button, a dialog would show up with a search field (AJAX is not a problem), and the result would be a list of users; when a user would be chosen and the OK
button would be clicked, it would generate a code like the following:
[user=1]Admin[/user]
1 - id of user, Admin - his name.
plugins/bbcode/plugin.js
. There are two variables there, bbcodeMap and convertMap. This plugin turns HTML into BBCode, so you will want to add a new definition for yourspoiler
tag. – Dateline