2018-06-15 12:42:20 -04:00
|
|
|
import { withPluginApi } from "discourse/lib/plugin-api";
|
2015-11-30 05:32:01 -05:00
|
|
|
|
2016-06-16 09:25:18 -04:00
|
|
|
function initializeDetails(api) {
|
|
|
|
api.decorateCooked($elem => $("details", $elem).details());
|
|
|
|
|
|
|
|
api.addToolbarPopupMenuOptionsCallback(() => {
|
|
|
|
return {
|
2018-06-15 12:42:20 -04:00
|
|
|
action: "insertDetails",
|
|
|
|
icon: "caret-right",
|
|
|
|
label: "details.title"
|
2016-06-16 09:25:18 -04:00
|
|
|
};
|
|
|
|
});
|
|
|
|
|
2018-06-15 12:42:20 -04:00
|
|
|
api.modifyClass("controller:composer", {
|
2016-06-16 09:25:18 -04:00
|
|
|
actions: {
|
|
|
|
insertDetails() {
|
|
|
|
this.get("toolbarEvent").applySurround(
|
2017-08-24 20:04:46 -04:00
|
|
|
"\n" + `[details="${I18n.t("composer.details_title")}"]` + "\n",
|
2017-06-28 11:45:48 -04:00
|
|
|
"\n[/details]\n",
|
2016-10-14 01:39:00 -04:00
|
|
|
"details_text",
|
2017-11-06 02:03:52 -05:00
|
|
|
{ multiline: false }
|
2016-10-14 01:39:00 -04:00
|
|
|
);
|
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() {
|
2018-06-15 12:42:20 -04:00
|
|
|
withPluginApi("0.8.7", initializeDetails);
|
2015-11-30 05:32:01 -05:00
|
|
|
}
|
|
|
|
};
|