From 6458d7881add4e1e0e6aa324acdc4fa4d2c4360e Mon Sep 17 00:00:00 2001 From: Johnny Almonte Date: Mon, 31 Jan 2022 17:02:49 -0400 Subject: [PATCH 1/3] fix: spellcheck control for 3rd-party editors --- .../javascripts/components/NotesOptions/NotesOptions.tsx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/assets/javascripts/components/NotesOptions/NotesOptions.tsx b/app/assets/javascripts/components/NotesOptions/NotesOptions.tsx index 67b85ade949..a2cd0781cc0 100644 --- a/app/assets/javascripts/components/NotesOptions/NotesOptions.tsx +++ b/app/assets/javascripts/components/NotesOptions/NotesOptions.tsx @@ -149,8 +149,10 @@ const SpellcheckOptions: FunctionComponent<{ }> = ({ appState, note }) => { const editor = appState.application.componentManager.editorForNote(note); const spellcheckControllable = Boolean( - !editor || - appState.application.getFeature(editor.identifier)?.spellcheckControl + editor && + (appState.application.getFeature(editor.identifier)?.spellcheckControl || + // Fallback to package_info in case it's a third-party editor + editor.package_info.spellcheckControl) ); const noteSpellcheck = !spellcheckControllable ? true From 33f65ce64b315fa3a87ae5d97e86bb1e7782c82c Mon Sep 17 00:00:00 2001 From: Johnny Almonte Date: Mon, 31 Jan 2022 20:27:31 -0400 Subject: [PATCH 2/3] refactor: spellcheckControllable --- .../components/NotesOptions/NotesOptions.tsx | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/app/assets/javascripts/components/NotesOptions/NotesOptions.tsx b/app/assets/javascripts/components/NotesOptions/NotesOptions.tsx index a2cd0781cc0..3910c300941 100644 --- a/app/assets/javascripts/components/NotesOptions/NotesOptions.tsx +++ b/app/assets/javascripts/components/NotesOptions/NotesOptions.tsx @@ -148,11 +148,15 @@ const SpellcheckOptions: FunctionComponent<{ note: SNNote; }> = ({ appState, note }) => { const editor = appState.application.componentManager.editorForNote(note); - const spellcheckControllable = Boolean( + + const firstPartySpellcheckControl = editor && - (appState.application.getFeature(editor.identifier)?.spellcheckControl || - // Fallback to package_info in case it's a third-party editor - editor.package_info.spellcheckControl) + appState.application.getFeature(editor.identifier)?.spellcheckControl; + const thirdPartySpellcheckControl = + editor && editor.package_info.spellcheckControl; + + const spellcheckControllable = Boolean( + !editor || firstPartySpellcheckControl || thirdPartySpellcheckControl ); const noteSpellcheck = !spellcheckControllable ? true From 01eed080190e786c8f73ce5b8943a46f1d6afbb5 Mon Sep 17 00:00:00 2001 From: Johnny Almonte Date: Tue, 1 Feb 2022 16:12:48 -0400 Subject: [PATCH 3/3] refactor: spellcheckControllable --- .../javascripts/components/NotesOptions/NotesOptions.tsx | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/app/assets/javascripts/components/NotesOptions/NotesOptions.tsx b/app/assets/javascripts/components/NotesOptions/NotesOptions.tsx index 3910c300941..c0d2467d1bd 100644 --- a/app/assets/javascripts/components/NotesOptions/NotesOptions.tsx +++ b/app/assets/javascripts/components/NotesOptions/NotesOptions.tsx @@ -148,15 +148,8 @@ const SpellcheckOptions: FunctionComponent<{ note: SNNote; }> = ({ appState, note }) => { const editor = appState.application.componentManager.editorForNote(note); - - const firstPartySpellcheckControl = - editor && - appState.application.getFeature(editor.identifier)?.spellcheckControl; - const thirdPartySpellcheckControl = - editor && editor.package_info.spellcheckControl; - const spellcheckControllable = Boolean( - !editor || firstPartySpellcheckControl || thirdPartySpellcheckControl + !editor || editor.package_info.spellcheckControl ); const noteSpellcheck = !spellcheckControllable ? true