Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

initialize plugins before the formatters #822

Merged
merged 1 commit into from
Jun 25, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 12 additions & 14 deletions src/lib/SCEditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,6 @@ export default function SCEditor(original, userOptions) {
replaceEmoticons,
handleCommand,
initEditor,
initPlugins,
initLocale,
initToolBar,
initOptions,
Expand Down Expand Up @@ -449,12 +448,21 @@ export default function SCEditor(original, userOptions) {

var FormatCtor = SCEditor.formats[options.format];
format = FormatCtor ? new FormatCtor() : {};
/*
* Plugins should be initialized before the formatters since
* they may wish to add or change formatting handlers and
* since the bbcode format caches its handlers,
* such changes must be done first.
*/
pluginManager = new PluginManager(base);
(options.plugins || '').split(',').forEach(function (plugin) {
pluginManager.register(plugin.trim());
});
if ('init' in format) {
format.init.call(base);
}

// create the editor
initPlugins();
initEmoticons();
initToolBar();
initEditor();
Expand Down Expand Up @@ -490,17 +498,6 @@ export default function SCEditor(original, userOptions) {
}
};

initPlugins = function () {
var plugins = options.plugins;

plugins = plugins ? plugins.toString().split(',') : [];
pluginManager = new PluginManager(base);

plugins.forEach(function (plugin) {
pluginManager.register(plugin.trim());
});
};

/**
* Init the locale variable with the specified locale if possible
* @private
Expand Down Expand Up @@ -533,7 +530,8 @@ export default function SCEditor(original, userOptions) {
allowfullscreen: true
});

/* This needs to be done right after they are created because,
/*
* This needs to be done right after they are created because,
* for any reason, the user may not want the value to be tinkered
* by any filters.
*/
Expand Down