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

35 lines
757 B
Plaintext
Raw Normal View History

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'
};
});
2017-06-13 15:52:08 -04:00
api.modifyClass('controller:composer', {
2016-06-16 09:25:18 -04:00
actions: {
insertDetails() {
this.get("toolbarEvent").applySurround(
"\n" + `[details="${I18n.t("composer.details_title")}"]` + "\n",
"\n[/details]\n",
"details_text",
{ multiline: false }
);
2016-06-16 09:25:18 -04:00
}
}
});
}
2015-11-30 05:32:01 -05:00
export default {
name: "apply-details",
initialize() {
2017-06-13 15:52:08 -04:00
withPluginApi('0.8.7', initializeDetails);
2015-11-30 05:32:01 -05:00
}
};