@@ -163,6 +163,19 @@ function resultCallback (recognizerContext, model, configuration, res, mimeType)
163163 handleSuccess ( recognizerContext . editor , modelReference , Constants . EventType . EXPORTED , Constants . EventType . IDLE )
164164 }
165165}
166+
167+ function callPostMessage ( recognizerContext , model , mimeType ) {
168+ const configuration = recognizerContext . editor . configuration
169+ return postMessage ( '/api/v4.0/iink/batch' , recognizerContext , model , buildData , configuration . restConversionState , mimeType )
170+ . then ( ( res ) => {
171+ resultCallback ( recognizerContext , model , configuration , res , mimeType )
172+ return model
173+ } )
174+ . catch ( ( err ) => {
175+ handleError ( recognizerContext . editor , err )
176+ return err
177+ } )
178+ }
166179
167180/**
168181 * Export content
@@ -171,30 +184,16 @@ function resultCallback (recognizerContext, model, configuration, res, mimeType)
171184 * @param {Array } requestedMimeTypes
172185 */
173186export function export_ ( recognizerContext , model , requestedMimeTypes ) {
174- const configuration = recognizerContext . editor . configuration
175-
176- function callPostMessage ( mimeType ) {
177- return postMessage ( '/api/v4.0/iink/batch' , recognizerContext , model , buildData , configuration . restConversionState , mimeType )
178- . then ( ( res ) => {
179- resultCallback ( recognizerContext , model , configuration , res , mimeType )
180- return model
181- } )
182- . catch ( ( err ) => {
183- handleError ( recognizerContext . editor , err )
184- return err
185- } )
186- }
187-
188187 if ( requestedMimeTypes ) {
189- return Promise . all ( requestedMimeTypes . map ( mimeType => callPostMessage ( mimeType ) ) )
188+ return Promise . all ( requestedMimeTypes . map ( mimeType => callPostMessage ( recognizerContext , model , mimeType ) ) )
190189 } else if ( configuration . recognitionParams . type === 'TEXT' ) {
191- return Promise . all ( configuration . recognitionParams . iink . text . mimeTypes . map ( mimeType => callPostMessage ( mimeType ) ) )
190+ return Promise . all ( configuration . recognitionParams . iink . text . mimeTypes . map ( mimeType => callPostMessage ( recognizerContext , model , mimeType ) ) )
192191 } else if ( configuration . recognitionParams . type === 'DIAGRAM' ) {
193- return Promise . all ( configuration . recognitionParams . iink . diagram . mimeTypes . map ( mimeType => callPostMessage ( mimeType ) ) )
192+ return Promise . all ( configuration . recognitionParams . iink . diagram . mimeTypes . map ( mimeType => callPostMessage ( recognizerContext , model , mimeType ) ) )
194193 } else if ( configuration . recognitionParams . type === 'MATH' ) {
195- return Promise . all ( configuration . recognitionParams . iink . math . mimeTypes . map ( mimeType => callPostMessage ( mimeType ) ) )
194+ return Promise . all ( configuration . recognitionParams . iink . math . mimeTypes . map ( mimeType => callPostMessage ( recognizerContext , model , mimeType ) ) )
196195 } else if ( configuration . recognitionParams . type === 'Raw Content' ) {
197- return Promise . all ( configuration . recognitionParams . iink [ 'raw-content' ] . mimeTypes . map ( mimeType => callPostMessage ( mimeType ) ) )
196+ return Promise . all ( configuration . recognitionParams . iink [ 'raw-content' ] . mimeTypes . map ( mimeType => callPostMessage ( recognizerContext , model , mimeType ) ) )
198197 }
199198 return Promise . reject ( new Error ( 'Export failed' ) )
200199}
@@ -210,3 +209,12 @@ export function convert (recognizerContext, model) {
210209 . then ( res => resultCallback ( model , configuration , res ) )
211210 . catch ( err => handleError ( recognizerContext . editor , err ) )
212211}
212+
213+ /**
214+ * Resize
215+ * @param {RecognizerContext } recognizerContext Current recognition context
216+ * @param {Model } model Current model
217+ */
218+ export function resize ( recognizerContext , model ) {
219+ export_ ( recognizerContext , model )
220+ }
0 commit comments