11import './dialog.css' assert { type : 'css' } ;
22
3- const CodeMirror = ( await import ( 'codemirror' ) ) . default ;
4- await import ( 'codemirror/mode/stex/stex' ) ; // manual recommendation
5-
63import { VKI_init } from './keyboard/keyboard' ;
7- import { DynamicPanel , KIHMoreDialog , KIHWindow , UnicodeWindow , MatrixWindow , InformationWindow } from "./panels" ;
84import { FileHandler } from "./fileHandling" ;
95
106import { inject } from 'inversify' ;
@@ -17,8 +13,8 @@ import {
1713 parametersId ,
1814 IThemes , themesId ,
1915 IParser , parserId ,
20- IMath , mathId ,
21- IPanels , panelsId } from './interfaces' ;
16+ IMath , mathId , ICodeMirror ,
17+ IPanels , panelsId , matrixWindowId , unicodeWindowId , informationWindowId , moreDialogId , windowId , dynamicPanelId } from './interfaces' ;
2218
2319let console : any ;
2420if ( window . console ) console = window . console ; else console = { log : function ( msg ) { } , error : function ( msg ) { } } ;
@@ -134,7 +130,7 @@ export class KatexInputHelper implements IKatexInputHelper {
134130 windowIsOpenning = false ;
135131 textareaIgnore = false ;
136132 textareaID = null ;
137- codeMirrorEditor = null ;
133+ codeMirrorEditor : ICodeMirror = null ;
138134 codeMirrorTheme = '' ;
139135 platformInfo = null ;
140136 symbolPanelsLoaded = [ ] ;
@@ -157,16 +153,16 @@ export class KatexInputHelper implements IKatexInputHelper {
157153 location = "" ;
158154 documentations = null ;
159155 localizer : ILocalizer = null ;
160- themes = null ;
161- math = null ;
156+ themes : IThemes = null ;
157+ math : IMath = null ;
162158 parameters = null ;
163- utilities = null ;
164- messager = null ;
159+ utilities : IUtilities = null ;
160+ messager : IMessager = null ;
165161 panels : IPanels = null ;
166162 useEasyLoader = true ;
167163 baseLocation = "" ;
168164 fromContextMenu = false ;
169- parser : any = null ;
165+ parser : IParser = null ;
170166 mathTextInput : any = null ;
171167 mathVisualOutput : any = null ;
172168 VKI_show : any = null ;
@@ -221,7 +217,8 @@ export class KatexInputHelper implements IKatexInputHelper {
221217 this . utilities = utilities ;
222218 this . themes = themes ;
223219 this . parser = parser ;
224- this . math = math ; // code mirror per method injection
220+ this . math = math ;
221+ this . codeMirrorEditor = math . codeMirror ;
225222 this . panels = panels ;
226223 this . documentations = new Documentations ( false , this . baseLocation ) ;
227224
@@ -406,27 +403,12 @@ export class KatexInputHelper implements IKatexInputHelper {
406403 * - change handler -> auto update of formula
407404 * - context menu binding
408405 */
409- async initialiseCodeMirror ( ) {
406+ initialiseCodeMirror ( ) {
410407 let vme = this ;
411- vme . codeMirrorEditor = CodeMirror . fromTextArea ( $ ( "#mathTextInput" ) [ 0 ] as HTMLTextAreaElement , {
412- mode : vme . encloseAllFormula ? "text/html" : "text/x-latex" ,
413- autofocus : true ,
414- showCursorWhenSelecting : true ,
415- lineNumbers : true ,
416- lineWrapping : true ,
417- // Unknown property
418- //styleActiveLine: true,
419- //matchBrackets: true,
420- //autoCloseBrackets: true,
421- //autoCloseTags: vme.encloseAllFormula ? true : false,
422- //tabMode: "indent",
423- tabSize : 4 ,
424- indentUnit : 4 ,
425- indentWithTabs : true ,
426- theme : "default" ,
427- inputStyle : vme . platformInfo . isMobile ? 'contenteditable' : 'textarea'
428- } ) ;
429- vme . codeMirrorEditor . on ( "change" , function ( ) { vme . autoUpdateOutput ( ) ; } ) ;
408+ const codeMirrorEditor = this . codeMirrorEditor ;
409+ const option = vme . platformInfo . isMobile ? 'contenteditable' : 'textarea' ;
410+ codeMirrorEditor . setOption ( 'inputStyle' , option ) ;
411+ codeMirrorEditor . on ( "change" , function ( ) { vme . autoUpdateOutput ( ) ; } ) ;
430412
431413 if ( ! vme . platformInfo . isMobile ) {
432414 /* The context menu appears but throws on click or mouse move afterwards:
@@ -436,16 +418,6 @@ export class KatexInputHelper implements IKatexInputHelper {
436418 } else {
437419 $ ( '.CodeMirror' ) . css ( 'fontSize' , '1.3em' ) ;
438420 }
439-
440- this . math . setEditorInstance ( this . codeMirrorEditor ) ;
441-
442- let panelOptions = $ ( '#divMathTextInput' ) . panel ( 'options' ) ;
443- panelOptions . onResize = function ( width : string | number , height : string | number ) {
444- try {
445- vme . codeMirrorEditor . setSize ( width , height ) ;
446- vme . codeMirrorEditor . refresh ( ) ;
447- } catch ( e ) { }
448- } ;
449421 }
450422
451423 /**
@@ -539,7 +511,7 @@ export class KatexInputHelper implements IKatexInputHelper {
539511 case "mEDITOR_PARAMETERS" : await vme . openWindow ( 'wEDITOR_PARAMETERS' ) ; break ;
540512 case "mSTYLE_CHOISE" : await vme . openWindow ( 'wSTYLE_CHOISE' ) ; break ;
541513 case "mLANGUAGE_CHOISE" : await vme . openWindow ( 'wLANGUAGE_CHOISE' ) ; break ;
542- case "mMATRIX" : vme . panels . showWindowGeneric ( MatrixWindow , 'wMATRIX' , 3 , 3 ) ; break ;
514+ case "mMATRIX" : vme . showMatrixWindow ( 3 , 3 ) ; break ;
543515 case "mCOMMUTATIVE_DIAGRAM" : await vme . initialiseUImoreDialogs ( "f_COMMUTATIVE_DIAGRAM" ) ; break ;
544516 case "mCHEMICAL_FORMULAE" : await vme . initialiseUImoreDialogs ( "f_CHEMICAL_FORMULAE" ) ; break ;
545517 case "mSAVE_EQUATION" : vme . saveEquationFile ( ) ; break ;
@@ -548,7 +520,7 @@ export class KatexInputHelper implements IKatexInputHelper {
548520 // No longer functional
549521 //case "mMATH_ML": vme.viewMathML(vme.mathVisualOutput.id); break;
550522 // TODO: complete transfer of functionality to Panels
551- case "mUNICODES_LIST" : await vme . panels . showWindowGeneric ( UnicodeWindow , 'wUNICODES_LIST' , vme . initialiseSymbolContent . bind ( vme ) ) ; break ;
523+ case "mUNICODES_LIST" : await vme . panels . showWindowDI ( unicodeWindowId , 'wUNICODES_LIST' , vme . initialiseSymbolContent . bind ( vme ) ) ; break ;
552524 case "mLATEX_CODES_LIST" : await vme . openWindow ( 'wLATEX_CODES_LIST' ) ; await vme . initialiseLatexMathjaxCodesList ( ) ; break ;
553525 case "mLANG_RESSOURCE_LIST" : await vme . openWindow ( 'wLANGUAGE_LIST' ) ; await vme . initialiseLangRessourcesList ( ) ; break ;
554526 case "mLATEX_DOCUMENTATION" : vme . documentations . showLatexDocumentation ( ) ; break ;
@@ -565,7 +537,7 @@ export class KatexInputHelper implements IKatexInputHelper {
565537 case "f_FR_CHAR" :
566538 case "f_BBB_CHAR" : await vme . initialiseUImoreDialogs ( item . target . id ) ; break ;
567539 case "mEQUATION" : await vme . initialiseUImoreDialogs ( "f_EQUATION" ) ; break ;
568- case "mCUSTOM_EQUATIONS" : await vme . panels . showWindowGeneric ( DynamicPanel , 'wf_CUSTOM_EQUATIONS_MORE' , vme . math ) ; break ;
540+ case "mCUSTOM_EQUATIONS" : await vme . panels . showWindowDI ( dynamicPanelId , 'wf_CUSTOM_EQUATIONS_MORE' , vme . math ) ; break ;
569541 case "mHORIZONTAL_SPACING" : await vme . initialiseUImoreDialogs ( "f_HORIZONTAL_SPACING" ) ; break ;
570542 case "mVERTICAL_SPACING" : await vme . initialiseUImoreDialogs ( "f_VERTICAL_SPACING" ) ; break ;
571543 case "mSPECIAL_CHARACTER" : await vme . initialiseUImoreDialogs ( "f_SPECIAL_CHARACTER" ) ; break ;
@@ -667,7 +639,7 @@ export class KatexInputHelper implements IKatexInputHelper {
667639 * @param numTab - number (index) of the tab (0..3)
668640 */
669641 async openInformationTab ( numTab : number ) {
670- this . panels . showWindowGeneric ( InformationWindow , 'wINFORMATIONS' , numTab ) ;
642+ this . panels . showWindowDI ( informationWindowId , 'wINFORMATIONS' , numTab ) ;
671643 }
672644
673645 /**
@@ -678,7 +650,7 @@ export class KatexInputHelper implements IKatexInputHelper {
678650 async initialiseUImoreDialogs ( fPanelID : string ) {
679651 let vme = this ;
680652 let fPanelMoreID = 'w' + fPanelID + '_MORE' ;
681- await vme . panels . showWindowGeneric ( KIHMoreDialog , fPanelMoreID , vme . initialiseSymbolContent . bind ( vme ) ) ;
653+ await vme . panels . showWindowDI ( moreDialogId , fPanelMoreID , vme . initialiseSymbolContent . bind ( vme ) ) ;
682654 }
683655
684656 /**
@@ -689,7 +661,7 @@ export class KatexInputHelper implements IKatexInputHelper {
689661 * @param id - the HTML id of the window
690662 */
691663 async openWindow ( id : string ) {
692- await this . panels . showWindowGeneric ( KIHWindow , id ) ;
664+ await this . panels . showWindowDI ( windowId , id ) ;
693665 }
694666
695667 /**
@@ -858,7 +830,7 @@ export class KatexInputHelper implements IKatexInputHelper {
858830 * @param cols - the number of matrix columns
859831 */
860832 showMatrixWindow ( rows : number , cols : number ) {
861- this . panels . showWindowGeneric ( MatrixWindow , 'wMATRIX' , rows , cols ) ;
833+ this . panels . showWindowDI ( matrixWindowId , 'wMATRIX' , rows , cols ) ;
862834 }
863835
864836 /**
@@ -1227,7 +1199,7 @@ export class KatexInputHelper implements IKatexInputHelper {
12271199 } ) ;
12281200 let p = $ ( accordionID ) . accordion ( 'getSelected' ) ;
12291201 if ( p ) { p . panel ( 'collapse' , false ) ; }
1230- this . math . updateHeaders ( ) ;
1202+ this . math . updateHeaders ( "" ) ;
12311203 }
12321204
12331205 /**
@@ -1332,7 +1304,7 @@ export class KatexInputHelper implements IKatexInputHelper {
13321304 <table class="inline-table">
13331305 <tr><td><b> ${ vme . versions . version } </b></td><td><b>Katex Input Helper / Visual Math Editor</b>, (This software)</td></tr>
13341306 <tr><td> ${ vme . versions . katexVersion } </td><td>Katex</td></tr>
1335- <tr><td> ${ CodeMirror . version } </td><td>Code Mirror</td></tr>
1307+ <tr><td> ${ vme . codeMirrorEditor . version } </td><td>Code Mirror</td></tr>
13361308 <tr><td> ${ vme . versions . VKI_version } </td><td>Virtual Keyboard</td></tr>
13371309 <tr><td> ${ $ . fn . jquery } </td><td>Jquery</td></tr>
13381310 <tr><td> ${ vme . versions . easyuiVersion } </td><td>Jquery Easyui</td></tr>
0 commit comments