2020-06-22 08:36:45 +08:00
|
|
|
import I18n from "I18n";
|
2018-06-16 00:42:20 +08:00
|
|
|
import { withPluginApi } from "discourse/lib/plugin-api";
|
2015-11-30 18:32:01 +08:00
|
|
|
|
2016-06-16 21:25:18 +08:00
|
|
|
function initializeDetails(api) {
|
2020-07-20 19:18:00 +08:00
|
|
|
api.decorateCooked(($elem) => $("details", $elem), {
|
2019-06-11 23:21:23 +08:00
|
|
|
id: "discourse-details",
|
|
|
|
});
|
2016-06-16 21:25:18 +08:00
|
|
|
|
|
|
|
api.addToolbarPopupMenuOptionsCallback(() => {
|
|
|
|
return {
|
2018-06-16 00:42:20 +08:00
|
|
|
action: "insertDetails",
|
|
|
|
icon: "caret-right",
|
|
|
|
label: "details.title",
|
2016-06-16 21:25:18 +08:00
|
|
|
};
|
|
|
|
});
|
|
|
|
|
2018-06-16 00:42:20 +08:00
|
|
|
api.modifyClass("controller:composer", {
|
2021-09-02 02:29:07 +08:00
|
|
|
pluginId: "discourse-details",
|
2016-06-16 21:25:18 +08:00
|
|
|
actions: {
|
|
|
|
insertDetails() {
|
2019-05-27 16:15:39 +08:00
|
|
|
this.toolbarEvent.applySurround(
|
2017-08-25 08:04:46 +08:00
|
|
|
"\n" + `[details="${I18n.t("composer.details_title")}"]` + "\n",
|
2017-06-28 23:45:48 +08:00
|
|
|
"\n[/details]\n",
|
2016-10-14 13:39:00 +08:00
|
|
|
"details_text",
|
2017-11-06 15:03:52 +08:00
|
|
|
{ multiline: false }
|
2016-10-14 13:39:00 +08:00
|
|
|
);
|
2016-06-16 21:25:18 +08:00
|
|
|
},
|
|
|
|
},
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2015-11-30 18:32:01 +08:00
|
|
|
export default {
|
|
|
|
name: "apply-details",
|
|
|
|
|
2016-02-13 04:46:36 +08:00
|
|
|
initialize() {
|
2018-06-16 00:42:20 +08:00
|
|
|
withPluginApi("0.8.7", initializeDetails);
|
2015-11-30 18:32:01 +08:00
|
|
|
},
|
|
|
|
};
|