SimpleMachines/SMF2.1 — pull request #1962 by Underdog-01 (2014-06-27 19:15:00+00:00)
Title: allow hooked BBcodes to use WYSIWYG/Source toggle

Mod author paramters for the bbc array:

- includes backward compatibility for previous bbc array keys (code, description, before, after)
- mod authors must include code (<-name), description, before (and after if applicable) keys into bbc array
- if they want to use the WYSIWYG editor to toggle their BBCode
they must include new keys of "html", "allowed_children" (<- defaults to null)
and "block_lvl" (<- defaults to inline if 0 or not included in array)
- for the WYSIWYG editor to ignore toggling the BBC html,
the "html" key should be empty or not included in the bbc array
- code works for all BBCode types
- the key of allowed_children defaults to null which allows all children unless otherwise specified within the array
the # can be entered for this setting which will allow all text but will not execute a BBcode placed within.
- other default BBC with the custom tag posted within will behave normally.
- setting for allowed_children examples:
empty or null -> allow all children BBC's,
# -> treat other BBC's contained within as text,
b, url, hr -> execute specific BBC HTML only (separated by commas)

- url's within custom bbc tags will not toggle to url, img, etc.
unless those specific bbc tags are included ( :) <-- preferred behavior!!!)

--------------------------------------------------

Explanation of behavior:

I will suggest that some general information about the SCEditor is provided in the SMF wiki
for mod authors regarding the use of the SCEditor within the SMF infrastructure.
ie. for custom BBC mods they need to be informed that if they intend to enable WYSIWYG for their mod
that it should be tested for conflicts with existing BBC's
else give their admin menu an option to enable/disable the feature with specific help text for that option.

This edit takes advantage of css styling elements and an existing sce css class
to provide the desired effect within the html class function.
Meaning that the existing format class function for custom BBCodes added via the hook is ignored
as it uses css style/class elements within the html class function for the desired effect.
It behaves very similar to the existing behavior of the form/html class
(as executed within ../jquery.sceditor.bbcode.js).
The author has informed me via email that changes are pending regarding the above type of behavior
or at least the ability to control it using the format class function (if I understood the response correctly).
This is because currently for SMF 2.1 the default behavior of the editor will change those to [img] and [url] BBC tags
as it is hard coded into it via functions within jquery.sceditor.smf.js
although this is not a desired effect for custom BBCodes.

----------------------------------------------------

Undesired effects of SCEditor within SMF 2.1 (this is default behavior without this edit):
- posting html within posts does not get converted to BBC renderring the usage of source/WYSIWYG toggling
within the editor as only converting existing BBC to source and back again.
- meaning that people posting html into posts does not get converted to BBC (although smileys text still gets converted)
- disabled BBcodes are still controlled by the SCEditor which is incorrect behavior
(needs $.sceditor.plugins.bbcode.bbcode.remove("[BBCODE]"); function added)
- remove formatting option does not seem to function?

Notes:
$.sceditor.plugins.bbcode.bbcode.set(format: ...) (specifically the format class)
can actually be removed from the custom bbc hook edit as it currently does nothing.
Adding before, after & html attributes to the BBC array for existing default SMF BBCodes
will change their behavior (if desired) as they will use the conditions of the edit.