Add details to popup menu options.

This commit is contained in:
Guo Xiang Tan 2016-06-16 21:25:18 +08:00
parent 95a58b80d7
commit d4f03cc0e1
No known key found for this signature in database
GPG Key ID: 19C321C8952B0F72
2 changed files with 35 additions and 3 deletions

View File

@ -1,11 +1,35 @@
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', api => {
api.decorateCooked($elem => $("details", $elem).details());
});
withPluginApi('0.1', initializeDetails);
}
};

View File

@ -0,0 +1,8 @@
en:
js:
details:
title: Insert Details
composer:
details_title: Summary
details_text: "This text will be hidden"