mirror of
https://github.com/discourse/discourse.git
synced 2024-11-30 13:37:37 +08:00
36 lines
797 B
JavaScript
36 lines
797 B
JavaScript
import { withPluginApi } from 'discourse/lib/plugin-api';
|
|
|
|
function initializeDetails(api) {
|
|
api.decorateCooked($elem => $("details", $elem).details());
|
|
|
|
api.addToolbarPopupMenuOptionsCallback(() => {
|
|
return {
|
|
action: 'insertDetails',
|
|
icon: 'caret-right',
|
|
label: 'details.title'
|
|
};
|
|
});
|
|
|
|
api.modifyClass('controller:composer', {
|
|
actions: {
|
|
insertDetails() {
|
|
this.get("toolbarEvent").applySurround(
|
|
"\n" + `[details=${I18n.t("composer.details_title")}]` + "\n",
|
|
"\n[/details]\n",
|
|
"details_text",
|
|
{ multiline: true }
|
|
);
|
|
this.set('optionsVisible', false);
|
|
}
|
|
}
|
|
});
|
|
}
|
|
|
|
export default {
|
|
name: "apply-details",
|
|
|
|
initialize() {
|
|
withPluginApi('0.8.7', initializeDetails);
|
|
}
|
|
};
|