mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-12-11 08:11:15 -05:00
35 lines
765 B
JavaScript
35 lines
765 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'
|
|
};
|
|
});
|
|
|
|
const ComposerController = api.container.lookup("controller:composer");
|
|
|
|
ComposerController.reopen({
|
|
actions: {
|
|
insertDetails() {
|
|
this.get("toolbarEvent").applySurround(
|
|
"[details=",
|
|
`]${I18n.t("composer.details_text")}[/details]`,
|
|
"details_title")
|
|
;
|
|
}
|
|
}
|
|
});
|
|
}
|
|
|
|
export default {
|
|
name: "apply-details",
|
|
|
|
initialize() {
|
|
withPluginApi('0.1', initializeDetails);
|
|
}
|
|
};
|