Custom tags in CKEditor BBCode plugin
Asked Answered
G

1

6

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.

Gymkhana answered 3/11, 2012 at 6:7 Comment(2)
Which version of CKEditor are you using?Lulualaba
You most likely want to edit 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 your spoiler tag.Dateline
D
-3

I had many problems with CKEditor. I'm using WYSIWYG Froala. He probably solve your problems.

Dinitrobenzene answered 28/7, 2015 at 12:16 Comment(1)
This does not provide an answer to the question. To critique or request clarification from an author, leave a comment below their post - you can always comment on your own posts, and once you have sufficient reputation you will be able to comment on any post.Synge

© 2022 - 2024 — McMap. All rights reserved.