discourse/plugins/discourse-details/assets/javascripts/initializers/apply-details.js

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

31 lines
705 B
JavaScript
Raw Normal View History

import $ from "jquery";
2018-06-16 00:42:20 +08:00
import { withPluginApi } from "discourse/lib/plugin-api";
import { i18n } from "discourse-i18n";
2015-11-30 18:32:01 +08:00
2016-06-16 21:25:18 +08:00
function initializeDetails(api) {
api.decorateCooked(($elem) => $("details", $elem), {
id: "discourse-details",
});
2016-06-16 21:25:18 +08:00
api.addComposerToolbarPopupMenuOption({
action: function (toolbarEvent) {
toolbarEvent.applySurround(
"\n" + `[details="${i18n("composer.details_title")}"]` + "\n",
"\n[/details]\n",
"details_text",
{ multiline: false }
);
2016-06-16 21:25:18 +08:00
},
icon: "caret-right",
label: "details.title",
2016-06-16 21:25:18 +08:00
});
}
2015-11-30 18:32:01 +08:00
export default {
name: "apply-details",
initialize() {
withPluginApi("1.14.0", initializeDetails);
2015-11-30 18:32:01 +08:00
},
};