discourse/plugins/discourse-details/assets/javascripts/initializers/apply-details.js.es6

36 lines
765 B
Plaintext
Raw Normal View History

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'
};
});
const ComposerController = api.container.lookup("controller:composer");
ComposerController.reopen({
actions: {
insertDetails() {
this.get("toolbarEvent").applySurround(
2016-06-20 08:43:12 +08:00
`[details=${I18n.t("composer.details_title")}]`,
"[/details]",
"details_text")
2016-06-16 21:25:18 +08:00
;
}
}
});
}
2015-11-30 18:32:01 +08:00
export default {
name: "apply-details",
initialize() {
2016-06-16 21:25:18 +08:00
withPluginApi('0.1', initializeDetails);
2015-11-30 18:32:01 +08:00
}
};