mirror of
https://github.com/Foundry376/Mailspring.git
synced 2025-01-01 13:14:16 +08:00
fix(composer): Show "No Guesses Found" for misspellings without corrections, invalidate cache when learning spelling
This commit is contained in:
parent
089aba0b22
commit
53252fcb97
2 changed files with 18 additions and 3 deletions
|
@ -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)
|
||||
|
|
|
@ -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}))
|
||||
|
|
Loading…
Reference in a new issue