diff --git a/internal_packages/composer-spellcheck/lib/draft-extension.coffee b/internal_packages/composer-spellcheck/lib/draft-extension.coffee index db81297ee..3caa00a84 100644 --- a/internal_packages/composer-spellcheck/lib/draft-extension.coffee +++ b/internal_packages/composer-spellcheck/lib/draft-extension.coffee @@ -19,6 +19,12 @@ class SpellcheckDraftStoreExtension extends DraftStoreExtension @walkTreeNodes.push(editableNode) @walkTreesDebounced() + @onLearnSpelling: (editableNode, word) -> + delete SpellcheckCache[word] + @ensureSetup() + @walkTreeNodes.push(editableNode) + @walkTreesDebounced() + @onSubstitutionPerformed: (editableNode) -> @ensureSetup() @walkTreeNodes.push(editableNode) diff --git a/internal_packages/composer/lib/contenteditable-component.cjsx b/internal_packages/composer/lib/contenteditable-component.cjsx index 85c4fc55f..fe1f52d03 100644 --- a/internal_packages/composer/lib/contenteditable-component.cjsx +++ b/internal_packages/composer/lib/contenteditable-component.cjsx @@ -646,6 +646,12 @@ class ContenteditableComponent extends React.Component if extension.onSubstitutionPerformed extension.onSubstitutionPerformed(@_editableNode()) + learnSpelling = => + spellchecker.add(text) + for extension in DraftStore.extensions() + if extension.onLearnSpelling + extension.onLearnSpelling(@_editableNode(), text) + cut = => clipboard.writeText(text) apply('') @@ -663,9 +669,12 @@ class ContenteditableComponent extends React.Component if corrections.length > 0 corrections.forEach (correction) -> menu.append(new MenuItem({ label: correction, click:( -> apply(correction))})) - menu.append(new MenuItem({ type: 'separator' })) - menu.append(new MenuItem({ label: 'Learn Spelling', click:( -> spellchecker.add(text))})) - menu.append(new MenuItem({ type: 'separator' })) + else + menu.append(new MenuItem({ label: 'No Guesses Found', enabled: false})) + + menu.append(new MenuItem({ type: 'separator' })) + menu.append(new MenuItem({ label: 'Learn Spelling', click: learnSpelling})) + menu.append(new MenuItem({ type: 'separator' })) menu.append(new MenuItem({ label: 'Cut', click:cut})) menu.append(new MenuItem({ label: 'Copy', click:copy}))