Procházet zdrojové kódy

Merge pull request #1111 from sharelatex/as-fix-spell-check

Fix bug where read only editor would crash

GitOrigin-RevId: ed8ac8ddcec118b57e20916afaddb50d5062b2cf
Alasdair Smith před 8 roky
rodič
revize
221acb8207

+ 2 - 0
services/web/public/src/ide/editor/directives/aceEditor.js

@@ -594,6 +594,7 @@ define([
         }
         }
 
 
         const initSpellCheck = function() {
         const initSpellCheck = function() {
+          if (!spellCheckManager) return
           spellCheckManager.init()
           spellCheckManager.init()
           editor.on('changeSession', onSessionChangeForSpellCheck)
           editor.on('changeSession', onSessionChangeForSpellCheck)
           onSessionChangeForSpellCheck({ session: editor.getSession() }) // Force initial setup
           onSessionChangeForSpellCheck({ session: editor.getSession() }) // Force initial setup
@@ -601,6 +602,7 @@ define([
         }
         }
 
 
         const tearDownSpellCheck = function() {
         const tearDownSpellCheck = function() {
+          if (!spellCheckManager) return
           editor.off('changeSession', onSessionChangeForSpellCheck)
           editor.off('changeSession', onSessionChangeForSpellCheck)
           return editor.off(
           return editor.off(
             'nativecontextmenu',
             'nativecontextmenu',