2016-02-16 12:17:22 -05:00
|
|
|
import { withPluginApi } from 'discourse/lib/plugin-api';
|
2015-11-30 05:32:01 -05:00
|
|
|
|
2016-06-16 09:25:18 -04:00
|
|
|
function initializeDetails(api) {
|
|
|
|
api.decorateCooked($elem => $("details", $elem).details());
|
|
|
|
|
|
|
|
api.addToolbarPopupMenuOptionsCallback(() => {
|
|
|
|
return {
|
|
|
|
action: 'insertDetails',
|
|
|
|
icon: 'caret-right',
|
|
|
|
label: 'details.title'
|
|
|
|
};
|
|
|
|
});
|
|
|
|
|
2016-06-14 14:31:51 -04:00
|
|
|
const ComposerController = api.container.lookup("controller:composer");
|
2016-06-16 09:25:18 -04:00
|
|
|
ComposerController.reopen({
|
|
|
|
actions: {
|
|
|
|
insertDetails() {
|
|
|
|
this.get("toolbarEvent").applySurround(
|
2016-06-19 20:43:12 -04:00
|
|
|
`[details=${I18n.t("composer.details_title")}]`,
|
|
|
|
"[/details]",
|
|
|
|
"details_text")
|
2016-06-16 09:25:18 -04:00
|
|
|
;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2015-11-30 05:32:01 -05:00
|
|
|
export default {
|
|
|
|
name: "apply-details",
|
2016-06-14 14:31:51 -04:00
|
|
|
after: 'inject-objects',
|
2015-11-30 05:32:01 -05:00
|
|
|
|
2016-02-12 15:46:36 -05:00
|
|
|
initialize() {
|
2016-06-30 21:25:37 -04:00
|
|
|
withPluginApi('0.5', initializeDetails);
|
2015-11-30 05:32:01 -05:00
|
|
|
}
|
|
|
|
};
|