mirror of
https://github.com/discourse/discourse.git
synced 2024-12-02 06:54:15 +08:00
4ad77f3382
Still supported in plugins though.
39 lines
842 B
JavaScript
39 lines
842 B
JavaScript
import I18n from "I18n";
|
|
import { withPluginApi } from "discourse/lib/plugin-api";
|
|
|
|
function initializeDetails(api) {
|
|
api.decorateCooked(($elem) => $("details", $elem), {
|
|
id: "discourse-details",
|
|
});
|
|
|
|
api.addToolbarPopupMenuOptionsCallback(() => {
|
|
return {
|
|
action: "insertDetails",
|
|
icon: "caret-right",
|
|
label: "details.title",
|
|
};
|
|
});
|
|
|
|
api.modifyClass("controller:composer", {
|
|
pluginId: "discourse-details",
|
|
actions: {
|
|
insertDetails() {
|
|
this.toolbarEvent.applySurround(
|
|
"\n" + `[details="${I18n.t("composer.details_title")}"]` + "\n",
|
|
"\n[/details]\n",
|
|
"details_text",
|
|
{ multiline: false }
|
|
);
|
|
},
|
|
},
|
|
});
|
|
}
|
|
|
|
export default {
|
|
name: "apply-details",
|
|
|
|
initialize() {
|
|
withPluginApi("0.8.7", initializeDetails);
|
|
},
|
|
};
|