mirror of
https://github.com/Foundry376/Mailspring.git
synced 2025-01-10 10:11:25 +08:00
20c522ed39
[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.
30 lines
1.1 KiB
JavaScript
30 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; },
|
|
};
|