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";
|
2024-11-20 04:45:18 +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(
|
2024-11-20 04:45:18 +08:00
|
|
|
"\n" + `[details="${i18n("composer.details_title")}"]` + "\n",
|
2023-10-06 07:43:40 +08:00
|
|
|
"\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
|
|
|
},
|
|
|
|
};
|