2018-06-15 12:42:20 -04:00
|
|
|
import { withPluginApi } from "discourse/lib/plugin-api";
|
2023-10-18 06:07:09 -04:00
|
|
|
import I18n from "discourse-i18n";
|
2015-11-30 05:32:01 -05:00
|
|
|
|
2016-06-16 09:25:18 -04:00
|
|
|
function initializeDetails(api) {
|
2020-07-20 07:18:00 -04:00
|
|
|
api.decorateCooked(($elem) => $("details", $elem), {
|
2019-06-11 11:21:23 -04:00
|
|
|
id: "discourse-details",
|
|
|
|
});
|
2016-06-16 09:25:18 -04:00
|
|
|
|
2023-10-05 19:43:40 -04:00
|
|
|
api.addComposerToolbarPopupMenuOption({
|
|
|
|
action: function (toolbarEvent) {
|
|
|
|
toolbarEvent.applySurround(
|
|
|
|
"\n" + `[details="${I18n.t("composer.details_title")}"]` + "\n",
|
|
|
|
"\n[/details]\n",
|
|
|
|
"details_text",
|
|
|
|
{ multiline: false }
|
|
|
|
);
|
2016-06-16 09:25:18 -04:00
|
|
|
},
|
2023-10-05 19:43:40 -04:00
|
|
|
icon: "caret-right",
|
|
|
|
label: "details.title",
|
2016-06-16 09:25:18 -04:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2015-11-30 05:32:01 -05:00
|
|
|
export default {
|
|
|
|
name: "apply-details",
|
|
|
|
|
2016-02-12 15:46:36 -05:00
|
|
|
initialize() {
|
2023-10-05 19:43:40 -04:00
|
|
|
withPluginApi("1.14.0", initializeDetails);
|
2015-11-30 05:32:01 -05:00
|
|
|
},
|
|
|
|
};
|