Mailspring/examples/N1-Composer-Templates/lib/main.es6
Drew Regitsky 71328855ee feat(templates-plugin): Add prefs page with template editor, fix bugs.
[Composer Templates / Quick Reply plugin example]

Add a page to preferences with a basic editor for quick reply templates,
allowing add, delete, and edit (HTML and rendered text), with instructions
for how to add variable regions. Add methods to TemplatesStore to enable
these. Fix issues in plugin with quoted text handling, name conflicts,
`this` scoping.
2015-12-02 21:28:49 -08:00

31 lines
1.1 KiB
JavaScript

import {PreferencesUIStore, ComponentRegistry, DraftStore} from 'nylas-exports';
import TemplatePicker from './template-picker';
import TemplateStatusBar from './template-status-bar';
import Extension from './template-draft-extension';
module.exports = {
item: null, // The DOM item the main React component renders into
activate(state = {}) {
this.state = state;
this.preferencesTab = new PreferencesUIStore.TabItem({
tabId: "Quick Replies",
displayName: "Quick Replies",
component: require("./preferences-templates"),
});
ComponentRegistry.register(TemplatePicker, {role: 'Composer:ActionButton'});
ComponentRegistry.register(TemplateStatusBar, {role: 'Composer:Footer'});
PreferencesUIStore.registerPreferencesTab(this.preferencesTab);
return DraftStore.registerExtension(Extension);
},
deactivate() {
ComponentRegistry.unregister(TemplatePicker);
ComponentRegistry.unregister(TemplateStatusBar);
PreferencesUIStore.unregisterPreferencesTab(this.preferencesTab.sectionId);
return DraftStore.unregisterExtension(Extension);
},
serialize() { return this.state; },
};