2016-02-17 01:17:22 +08:00
|
|
|
import { withPluginApi } from 'discourse/lib/plugin-api';
|
2015-11-30 18:32:01 +08:00
|
|
|
|
2016-06-16 21:25:18 +08:00
|
|
|
function initializeDetails(api) {
|
|
|
|
api.decorateCooked($elem => $("details", $elem).details());
|
|
|
|
|
|
|
|
api.addToolbarPopupMenuOptionsCallback(() => {
|
|
|
|
return {
|
|
|
|
action: 'insertDetails',
|
|
|
|
icon: 'caret-right',
|
|
|
|
label: 'details.title'
|
|
|
|
};
|
|
|
|
});
|
|
|
|
|
2016-07-01 01:55:44 +08:00
|
|
|
const ComposerController = api.container.lookupFactory("controller:composer");
|
2016-06-16 21:25:18 +08:00
|
|
|
ComposerController.reopen({
|
|
|
|
actions: {
|
|
|
|
insertDetails() {
|
|
|
|
this.get("toolbarEvent").applySurround(
|
2016-06-20 08:43:12 +08:00
|
|
|
`[details=${I18n.t("composer.details_title")}]`,
|
|
|
|
"[/details]",
|
2016-10-14 13:39:00 +08:00
|
|
|
"details_text",
|
|
|
|
{ multiline: false }
|
|
|
|
);
|
2016-12-20 00:19:10 +08:00
|
|
|
this.set('optionsVisible', false);
|
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() {
|
2016-07-01 09:25:37 +08:00
|
|
|
withPluginApi('0.5', initializeDetails);
|
2015-11-30 18:32:01 +08:00
|
|
|
}
|
|
|
|
};
|