2023-11-28 17:53:38 +08:00
|
|
|
import $ from "jquery";
|
2018-06-16 00:42:20 +08:00
|
|
|
import { withPluginApi } from "discourse/lib/plugin-api";
|
2023-10-18 18:07:09 +08:00
|
|
|
import I18n from "discourse-i18n";
|
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
|
|
|
|
2023-10-06 07:43:40 +08: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 21:25:18 +08:00
|
|
|
},
|
2023-10-06 07:43:40 +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",
|
|
|
|
|
2016-02-13 04:46:36 +08:00
|
|
|
initialize() {
|
2023-10-06 07:43:40 +08:00
|
|
|
withPluginApi("1.14.0", initializeDetails);
|
2015-11-30 18:32:01 +08:00
|
|
|
},
|
|
|
|
};
|