API Reference
Accessibility
This class represents MathType accessible class. Converts MathML to accessible text and manages the associated client-side cache.
Construction
new Accessibility() source
Static
Accessibility.mathMLToAccessible(mathML, [language], [data]) → String source
Parameters
-
mathML
String
MathML to be converted to accessible text.
-
[language]
String
Language of the accessible text. 'en' by default.
-
[data]
String[]
Parameters to send to mathml2accessible service.
Returns
String
Accessibility text.
Converts MathML strings to its accessible text representation.
Members
Configuration
This class represents the configuration class. Usually used to retrieve configuration properties generated in the backend into the frontend.
Construction
new Configuration() source
Static
Configuration.addConfiguration(properties) source
Parameters
-
properties
Object
properties to append to current properties.
Adds a properties object to Configuration.properties.
Configuration.get(key) → String source
Parameters
-
key
String
Property key
Returns
String
Property value
Returns the value of a property key.
Constants
This class represents all the constants needed in a MathType integration among different classes. If a constant should be used across different classes should be defined using attribute accessors.
Members
Constants.safeXmlCharacters :Object source
Safe XML special characters. This characters are used instead the standard the standard to parse the MathML if safeXML save mode is enable. Each XML special character have a UTF-8 representation.
ContentManager
This class represents a modal dialog, managing the following:
- The insertion of content into the current instance of the ModalDialog class.
- The actions to be done once the modal object has been submitted (submitAction} method).
- The update of the content when the ModalDialog class is also updated, for example when ModalDialog is re-opened.
- The communication between the ModalDialog class and itself, if the content has been changed (hasChanges} method).
Construction
new ContentManager(contentManagerAttributes) source
Parameters
-
contentManagerAttributes
Object
Object containing all attributes needed to create a new instance.
Static
ContentManager.getURLFromAnchorElement(anchorElement) → String source
Parameters
-
anchorElement
HTMLAnchorElement
Element where extract the url.
Returns
String
Returns the url of the anchor element adding the current port if it is needed.
ContentManager.isEditorLoaded() → Boolean source
Returns
Boolean
Returns true if editor is loaded. Otherwise, false.
ContentManager.isIOS() → Boolean source
Returns
Boolean
Returns true if device is iOS. Otherwise, false.
ContentManager.setHrefToAnchorElement(anchorElement, url) source
Parameters
-
anchorElement
HTMLAnchorElement
Element where set 'url'.
-
url
String
URL to set.
Sets the specified url to the anchor element.
ContentManager.setProtocolToAnchorElement(anchorElement) source
Parameters
-
anchorElement
HTMLAnchorElement
Element where set its protocol.
Sets the current protocol to the anchor element.
Members
contentManager.customEditors :CustomEditors source
CustomEditors instance. Contains the custom editors.
contentManager.editorAttributes :Object source
An object containing MathType editor parameters. See http://docs.wiris.com/en/mathtype/mathtype_web/sdk-api/parameters for further information.
contentManager.editorListener :EditorListener source
EditorListener instance. Manages the changes inside the editor.
contentManager.environment :Object source
Properties
Name | Type | Description |
---|---|---|
editor |
String
|
Editor name. Usually the HTML editor. |
mode |
String
|
Save mode. Xml by default. |
version |
String
|
Plugin version. |
Environment properties. This object contains data about the integration platform.
contentManager.integrationModel :IntegrationModel source
IntegrationModel instance. Needed to call wrapper methods.
contentManager.modalDialogInstance :ModalDialog source
Instance of the ModalDialog class associated with the current ContentManager instance.
Methods
contentManager.addEditorAsExternalDependency() source
Adds script element to the DOM to include editor externally.
contentManager.addListener(listener) source
Parameters
-
listener
Object
The listener to be added.
Adds a new listener to the current ContentManager instance.
contentManager.getToolbar() → String source
Returns
String
- Toolbar identifier.
Returns the editor toolbar, depending on the configuration local or server side.
contentManager.hasChanges() → Boolean source
Returns
Boolean
True if the editor content has been changed. False otherwise.
Returns true if the content of the editor has been changed. The logic of the changes is delegated to EditorListener class.
contentManager.insert() source
Inserts the content into the current ModalDialog instance updating the title and inserting the JavaScript editor.
contentManager.insertEditor() source
Inserts MathType editor into the ModalDialog.contentContainer. It waits until editor's JavaScript is loaded.
contentManager.onFocus() source
Sets the focus to the current instance of ContentManager.editor. Triggered by ModalDialog.focus.
contentManager.onKeyDown(keyboardEvent) source
Parameters
-
keyboardEvent
KeyboardEvent
The keyboard event.
Handle keyboard events detected in modal when elements of this class intervene.
contentManager.onOpen() source
Open event. Triggered by ModalDialog.open. Does the following:
- Updates the ContentManager.editor content (with an empty MathML or an existing formula),
- Updates the ContentManager.editor toolbar.
- Recovers the the focus.
contentManager.setIntegrationModel(integrationModel) source
Sets an instance of IntegrationModel class to the current ContentManager instance.
contentManager.setMathML(mathml, focusDisabled) source
Parameters
-
mathml
String
MathML string.
-
focusDisabled
Boolean
If true editor don't get focus after the MathML is set. False by default.
Sets a MathML into ContentManager.editor instance.
contentManager.setModalDialogInstance(modalDialogInstance) source
Sets the ModalDialog instance into the current ContentManager instance.
contentManager.setToolbar(toolbar) source
Parameters
-
toolbar
String
The toolbar name.
Sets the current ContentManager.editor instance toolbar.
contentManager.submitAction() source
Updates the edition area by calling IntegrationModel.updateFormula. Triggered by ModalDialog.submitAction.
contentManager.updateTitle() source
Updates the current ModalDialog.title. If a CustomEditors is enabled sets the custom editor title. Otherwise sets the default title.
contentManager.updateToolbar() source
Sets the correct toolbar depending if exist other custom toolbars at the same time (e.g: Chemistry).
Core
This class represents MathType integration Core, managing the following:
- Integration initialization.
- Event managing.
- Insertion of formulas into the edit area.
let core = new Core();
core.addListener(listener);
core.language = 'en';
// Initializing Core class.
core.init(configurationService);
Static
Core.addGlobalListener(listener) source
Members
core.customEditors :CustomEditors source
The instance of CustomEditors. By default the only custom editor is the Chemistry editor.
core.editMode :String source
Edit mode, 'images' by default. Admits the following values:
- images
- latex
Methods
core.addListener(listener) source
core.getCustomEditors() → CustomEditors source
Returns the CustomEditors instance.
core.getModalDialog() → ModalDialog source
Returns the current ModalDialog instance.
core.init(serviceParameters) source
Parameters
-
serviceParameters
Object
Service parameters.
Inits the Core class, doing the following:
- Calls asynchronously configuration service, retrieving the backend configuration in a JSON.
- Updates Configuration class with the previous configuration properties.
- Updates the ServiceProvider class using the configuration service path as reference.
- Loads language strings.
- Fires onLoad event.
core.insertElementOnSelection(element, focusElement, windowTarget) source
Parameters
-
element
HTMLElement
The HTMLElement to replace the selection.
-
focusElement
HTMLElement
The HTMLElement to be focused after the replace.
-
windowTarget
Window
The window target.
Replaces a Selection object with an HTMLElement.
core.insertFormula(focusElement, windowTarget, mathml, wirisProperties) → ReturnObject source
Parameters
-
focusElement
HTMLElement
The HTMLElement to be focused after the insertion.
-
windowTarget
Window
The window element where the editable content is.
-
mathml
String
The MathML.
-
wirisProperties
Object[]
The extra attributes for the formula.
Returns
ReturnObject
- Object with the information of the node or latex to insert.
Converts a MathML into it's correspondent image and inserts the image is inserted in a HTMLElement target by creating a new image or updating an existing one.
core.openModalDialog(target, isIframe) source
Parameters
-
target
HTMLElement
The target HTMLElement where formulas should be inserted.
-
isIframe
Boolean
True if the target HTMLElement is an iframe. False otherwise.
Opens a modal dialog containing MathType editor..
core.placeCaretAfterNode(node) source
Parameters
-
node
Node
The Node element.
Sets the caret after a given Node and set the focus to the owner document.
core.setEnvironment(integrationEnvironment) source
Sets the Core.environment property.
core.setIntegrationModel(integrationModel) source
Sets the Core.integrationModel property.
CustomEditors
This class represents the MathType custom editors manager. A custom editor is MathType editor with a custom toolbar. This class associates a CustomEditor to:
- It's own formulas
- A custom toolbar
- An icon to open it from a HTML editor.
- A tooltip for the icon.
- A global variable to enable or disable it globally.
Construction
new CustomEditors() source
Members
Methods
customEditors.addEditor(editorName, editorParams) source
Parameters
-
editorName
String
The editor name.
-
editorParams
CustomEditor
The custom editor parameters.
Adds a CustomEditor to editors array.
customEditors.enable(customEditorName) source
Parameters
-
customEditorName
String
The custom editor name.
Enables a CustomEditor.
customEditors.getActiveEditor() → CustomEditor source
Returns the active editor.
EditorListener
Determines if the content of the MathType Editor has changes.
Construction
new EditorListener() source
- Implements
- EditorListeners
Members
editorListener.waitingForChanges :Boolean source
Indicates if the listener should be waiting for changes in the editor.
Methods
editorListener.contentChanged(editor) source
Parameters
-
editor
JsEditor
editor object.
Determines if the content of an editor has been changed.
editorListener.getIsContentChanged() → Boolean source
Returns
Boolean
Returns true if the content of the editor has been changed, false otherwise.
editorListener.setIsContentChanged(value) source
Parameters
-
value
Boolean
The new vlue.
Sets EditorListener.isContentChanged property.
editorListener.setWaitingForChanges(value) source
Parameters
-
value
Boolean
True if the editor should wait for changes, false otherwise.
Determines if the EditorListener should wait for any changes.
editorListener.styleChanged(editor) source
Parameters
-
editor
JsEditor
The editor instance.
EditorListener method to overwrite
editorListener.transformationReceived(_editor) source
Parameters
-
_editor
JsEditor
The editor instance.
EditorListener method to overwrite
Event
This class represents a custom event. Events should be fired by the Listener class.
let customEvent = new Event();
customEvent.properties = {};
let listeners = new Listeners();
listeners.newListener(eventName, callback);
listeners.fire(eventName, customEvent) *
Members
Methods
Image
This class represents MathType Image class. Contains all the logic related to MathType images manipulation. All MathType images are generated using the appropriate MathType integration service: showimage or createimage.
There are two available image formats:
- svg (default)
- png
There are two formats for the image src attribute:
- A data-uri scheme containing the URL-encoded SVG or a PNG's base64.
- A link to the showimage service.
Static
Image.clone(originImg, destImg) source
Parameters
-
originImg
HTMLImageElement
The original image.
-
destImg
HTMLImageElement
The destination image.
Image.fixAfterResize(img) source
Parameters
-
img
HTMLImageElement
The resized HTMLImageElement.
Calculates the metrics of an image which has been resized. Is used to restore the original metrics of a resized image.
Image.getMetricsFromBytes(bytes) → Array source
Parameters
-
bytes
Bytes[]
png byte array.
Returns
Array
The png metrics.
Returns the metrics (width, height, baseline and dpi) contained in a PNG byte array.
Image.getMetricsFromSvgString(svgString) → Array source
Parameters
-
svgString
String
The SVG image.
Returns
Array
- The image metrics.
Returns the metrics (height, width and baseline) contained in a SVG image generated by the MathType image service. This image contains as an extra custom attribute: the baseline (wrs:baseline).
Image.removeImgDataAttributes(img) source
Parameters
-
img
HTMLImageElement
Image where remove data attributes.
Removes data attributes from an image.
Image.setImgSize(img, uri, jsonResponse) source
Parameters
-
img
HTMLImageElement
The HTMLImageElement.
-
uri
String
The URI generated by the image service: can be a data URI scheme or a URL.
-
jsonResponse
Boolean
True the response of the image service is a JSON object. False otherwise.
Calculates the metrics of a MathType image given the the service response and the image format.
IntegrationModel
This class represents an integration model, allowing the integration script to communicate with Core class. Each integration must extend this class.
Construction
new IntegrationModel(integrationModelProperties) source
Members
IntegrationModel.integrationParameters :Object source
An object containing a list with the overwritable class constructor properties.
integrationModel.callbackMethodArguments source
Object containing the arguments needed by the callback function.
integrationModel.configurationService source
Configuration service path. The integration service is needed by Core class to load all the backend configuration into the frontend and also to create the paths of all services (all services lives in the same route). Mandatory property.
integrationModel.editorObject source
Instance of the integration editor object. Usually the entry point to access the API of a HTML editor.
integrationModel.environment source
Contains information about the integration environment: like the name of the editor, the version, etc.
integrationModel.language source
Language. Needed for accessibility and locales. English by default.
integrationModel.managesLanguage source
Specifies if the integration model exposes the locale strings. false by default.
integrationModel.target source
DOM target in which the plugin works. Needed to associate events, insert formulas, etc. Mandatory property.
integrationModel.temporalImageResizing :boolean source
Indicates if an image is selected. Needed to resize the image to the original size in case the image is resized.
Methods
integrationModel.addEvents() source
Add events to formulas in the DOM target. The events added are the following:
- doubleClickHandler: handles double click event on formulas by opening an editor to edit them.
- mouseDownHandler: handles mouse down event on formulas by saving the size of the formula in case the the formula is resized.
- mouseUpHandler: handles mouse up event on formulas by restoring the saved formula size in case the formula is resized.
integrationModel.callbackFunction() source
integrationModel.doubleClickHandler(element) source
Parameters
-
element
HTMLElement
DOM object target.
Handles a double click on the target element. Opens an editor to re-edit the double-clicked formula.
integrationModel.fillNonLatexNode(event, window, mathml) source
Parameters
-
event
Object
event object.
-
window
Object
dom window object.
-
mathml
string
valid mathml.
Wrapper It fills wrs event object of nonLatex with the desired data.
integrationModel.getBrowserLanguage() → string source
Returns
string
the browser language.
Returns the browser language.
integrationModel.getLanguage() → string source
Returns
string
integration language.
Returns the integration language. By default the browser agent. This method should be overwritten to obtain the integration language, for example using the plugin API of an HTML editor.
integrationModel.getMathmlFromTextNode(textNode, caretPosition) → string source
Parameters
-
textNode
string
text node to extract the MathML.
-
caretPosition
int
caret position inside the text node.
Returns
string
MathML inside the text node.
Wrapper. Extracts mathml of a determined text node. This function is used as a wrapper inside core.js in order to get mathml from a text node that can contain normal LaTeX or other chosen text.
integrationModel.getPath() → string source
Returns
string
- Absolute path for the integration script.
Returns the absolute path of the integration script.
integrationModel.getSelectedItem(target, iframe) source
Parameters
-
target
HTMLElement
target element
-
iframe
boolean
Wrapper. Returns selected item from the target.
integrationModel.getSelection() → Selection source
Returns
Selection
target selection.
Returns the target selection.
integrationModel.getVersion() source
Parameters
-
string
Plugin version
Returns integration model plugin version
integrationModel.init() source
Init function. Usually called from the integration side once the core.js file is loaded.
integrationModel.insertFormula(mathml, editMode) → ReturnObject source
Parameters
-
mathml
string
MathML to generate the formula.
-
editMode
string
Edit Mode (LaTeX or images).
Returns
ReturnObject
- Object with the information of the node or latex to insert.
Wrapper to Core.insertFormula method. Inserts the formula in the specified target, creating a new image (new formula) or updating an existing one.
integrationModel.mousedownHandler(element) source
Parameters
-
element
HTMLElement
target element.
Handles a mouse down event on the target element. Saves the formula size to avoid resizing formulas.
integrationModel.mouseupHandler() source
Handles a mouse up event on the target element. Restores the image size to avoid resizing formulas.
integrationModel.openExistingFormulaEditor() source
Opens formula editor to editing an existing formula. Can be overwritten in order to make some actions from integration part before the formula is edited.
integrationModel.openNewFormulaEditor() source
Opens formula editor to editing a new formula. Can be overwritten in order to make some actions from integration part before the formula is edited.
integrationModel.setEditorObject(editorObject) source
Parameters
-
editorObject
Object
The editor object.
Sets the editor object.
integrationModel.setLanguage(language) source
Parameters
-
language
string
language code.
Sets the language property.
integrationModel.setTarget(target) source
Parameters
-
target
HTMLElement
target object.
Sets the object target and updates the iframe property.
integrationModel.updateFormula(mathml, editMode) source
Parameters
-
mathml
string
MathML to generate the formula.
-
editMode
string
Edit Mode (LaTeX or images).
Wrapper to Core.updateFormula method. Transform a MathML into a image formula. Then the image formula is inserted in the specified target, creating a new image (new formula) or updating an existing one.
Latex
This class represents a LaTeX parser. Manages the services which allows to convert LaTeX into MathML and MathML into LaTeX.
Static
Latex.getLatexFromMathML(mathml) → String source
Parameters
-
mathml
String
MathML String.
Returns
String
LaTeX string generated by the MathML argument.
Converts MathML to LaTeX by calling mathml2latex service. For text services we call a text service with the param mathml2latex.
Latex.getLatexFromTextNode(textNode, caretPosition, latexTags) → Object source
Parameters
-
textNode
Node
textNode to extract the LaTeX
-
caretPosition
Number
Starting position to find LaTeX.
-
latexTags
Object
Optional parameter representing tags between latex is inserted. It has the 'open' attribute for the open tag and the 'close' attribute for the close tag. "$$" by default.
Returns
Object
An object with 3 keys: 'latex', 'start' and 'end'. Null if latex is not found.
Extracts the latex of a determined position in a text.
Latex.getMathMLFromLatex(latex, includeLatexOnSemantics) → String source
Parameters
-
latex
String
String containing a LaTeX formula.
-
includeLatexOnSemantics
Boolean
- If true LaTeX would me included into MathML semantics.
Returns
String
MathML string generated by the LaTeX argument.
Converts LaTeX to MathML by calling latex2mathml service. For text services we call a text service with the param latex2mathml.
Latex.parseMathmlToLatex(content, characters) → String source
Parameters
-
content
String
A string containing MathML valid code.
-
characters
Object
An object containing special characters.
Returns
String
A string containing all MathML annotated occurrences replaced by the corresponding LaTeX code.
Converts all occurrences of MathML code to LaTeX.
The MathML code should containing
Members
Listeners
This class represents a custom listeners manager.
Static
Listeners.newListener(eventName, callback) → object source
Parameters
-
eventName
string
Event name.
-
callback
Object
Callback function.
Returns
object
the listener object.
Creates a new listener object.
Members
Methods
MathML
This class represents a class to manage MathML objects.
Static
MathML.addAnnotation(mathml, content, annotationEncoding) → String source
Parameters
-
mathml
String
valid MathML.
-
content
String
value to put inside annotation tag.
-
annotationEncoding
String
annotation encoding.
Returns
String
- 'mathml' with an annotation that contains 'content' and encoding 'encoding'.
Adds annotation tag in MathML element.
MathML.addCustomEditorClassAttribute(mathml, customEditor) → string source
Parameters
-
mathml
string
a MathML string created with a custom editor, like chemistry.
-
customEditor
string
custom editor name.
Returns
string
MathML string with his class containing the editor toolbar string.
Add a custom editor name with the prefix wrs_ to a MathML class attribute.
MathML.containClass(mathML, className) → boolean source
Parameters
-
mathML
string
input MathML.
-
className
string
className.
Returns
boolean
true if the input MathML contains the input class. false otherwise.
Returns true if a MathML contains a certain class.
MathML.encodeProperties(mathml) → String source
Parameters
-
mathml
String
valid MathML with standard XML tags.
Returns
String
- 'mathml' with property entities encoded.
Encodes html entities inside properties.
MathML.isEmpty(mathml) → boolean source
Parameters
-
mathml
string
valid MathML with standard XML tags.
Returns
boolean
- true if mathml is empty. Otherwise, false.
Returns true if mathml is empty. Otherwise, false.
MathML.isMathmlInAttribute(content, i) → boolean source
Parameters
-
content
string
a string containing MathML code.
-
i
number
search index.
Returns
boolean
true if is inside an HTML attribute. false otherwise.
Checks if the mathml at position i is inside an HTML attribute or not.
MathML.mathMLEntities(mathml) → string source
Parameters
-
mathml
string
MathML string containing - or not - special symbols
Returns
string
MathML with all textual entities replaced.
Converts special symbols (> 128) to entities and replaces all textual entities by its number entities.
MathML.removeAnnotation(mathml, annotationEncoding) → String source
Parameters
-
mathml
String
valid MathML.
-
annotationEncoding
String
annotation encoding to remove.
Returns
String
- 'mathml' without the annotation encoding specified.
Removes specific annotation tag in MathML element. In case of remove the unique annotation, also is removed semantics tag.
MathML.removeCustomEditorClassAttribute(mathml, customEditor) → string source
Parameters
-
mathml
string
a MathML string.
-
customEditor
string
custom editor name.
Returns
string
The input MathML without customEditor name in his class.
Remove a custom editor name from the MathML class attribute.
MathML.removeSemantics(mathml) → string source
Parameters
-
mathml
string
MathML string.
Returns
string
- 'mathml' without semantics tag.
Removes semantics tag to mathml.
MathML.removeSemanticsOcurrences(text, [characters]) → string source
Parameters
-
text
string
string that can contain xml mathml ocurrences.
-
[characters]
Constants
Constant object containing xmlCharacters or safeXmlCharacters relation. xmlCharacters by default.
Returns
string
- 'text' with all xml mathml ocurrences without annotation tag.
Transforms all xml mathml ocurrences that contain semantics to the same xml mathml ocurrences without semantics.
MathML.safeXmlDecode(input) → string source
Parameters
-
input
string
string to be decoded.
Returns
string
decoded string.
Decodes an encoded MathML with standard XML tags. We use these entities because IE doesn't support html entities on its attributes sometimes. Yes, sometimes.
MathML.safeXmlEncode(input) → string source
Parameters
-
input
string
input string to be encoded
Returns
string
encoded string.
Encodes a MathML with standard XML tags to a MMathML encoded with safe XML tags. We use these entities because IE doesn't support html entities on its attributes sometimes.
ModalDialog
This class represents a modal dialog. The modal dialog admits a ContentManager instance to manage the content of the dialog.
Construction
new ModalDialog(modalDialogAttributes) source
Parameters
-
modalDialogAttributes
Object
An object containing all modal dialog attributes.
Members
modalDialog.deviceProperties :DeviceProperties source
modalDialog.rtl :Boolean source
Indicates if directionality of the modal dialog is RTL. false by default.
modalDialog.websiteBeforeLockParameters :Object source
Properties
Name | Type | Description |
---|---|---|
bodyStylePosition |
String
|
Previous body style postion. |
bodyStyleOverflow |
String
|
Previous body style overflow. |
htmlStyleOverflow |
String
|
Previous body style overflow. |
windowScrollX |
String
|
Previous window's scroll Y. |
windowScrollY |
String
|
Previous window's scroll X. |
Object to keep website's style before change it on lock scroll for mobile devices.
Methods
modalDialog.activateResizeStateBR(mouseEvent) source
Parameters
-
mouseEvent
MouseEvent
Mouse event.
Initialize variables for Bottom-Right resize button
modalDialog.activateResizeStateTL(mouseEvent) source
Parameters
-
mouseEvent
MouseEvent
Mouse event.
Initialize variables for Top-Left resize button
modalDialog.addClass(className) source
Parameters
-
className
String
Class name.
Adds a class to all modal ModalDialog DOM elements.
modalDialog.cancelAction() source
This method is called when the modal object has been cancelled. If contentElement has implemented hasChanges method, a confirm popup will be shown if hasChanges returns true.
modalDialog.createSubmitButton(properties, callback) → HTMLButtonElement source
Parameters
-
properties
Object
Input button properties.
-
class
String
Input button class.
-
innerHTML
String
Input button innerHTML.
-
-
callback
Object
Callback function associated to click event.
Returns
HTMLButtonElement
The button element.
Returns a button element.
modalDialog.drag(mouseEvent) source
Parameters
-
mouseEvent
MouseEvent
The mouse event.
Updates dragDataObject with the draggable object coordinates when the draggable object is being moved.
modalDialog.eventClient(mouseEvent) → Object source
Parameters
-
mouseEvent
MouseEvent
Mouse event.
Returns
Object
With the X and Y coordinates.
Returns mouse or touch coordinates (on touch events ev.ClientX doesn't exists)
modalDialog.getContentManager() → ContentManager source
Returns the modal contentElement object.
modalDialog.getElementId(className) → String source
Parameters
-
className
String
The element class name.
Returns
String
A string appending the instance id to the className.
Returns the id of an element, adding the instance number to the element class name: className --> className[idNumber]
modalDialog.getLimitWindow() → Object source
Returns
Object
Object containing mouseX and mouseY coordinates of actual mouse on screen.
Returns the boundaries of actual window to limit modal movement.
modalDialog.getScrollBarWidth() → Number source
Returns
Number
The scrollbar width.
Returns the scrollbar width size of browser
modalDialog.handleClosedIosSoftkeyboard() source
Event handler that change container size when IOS softkeyboard is closed.
modalDialog.handleOpenedIosSoftkeyboard() source
Event handler that change container size when IOS softkeyboard is opened.
modalDialog.initializeResizeProperties(mouseEvent) source
Parameters
-
mouseEvent
MouseEvent
Mouse event.
Common method to initialize variables at resize.
modalDialog.isIE11() → Boolean source
Returns
Boolean
true if the browser is IE11. false otherwise.
Util function to known if browser is IE11.
modalDialog.isRTL() → Boolean source
Returns
Boolean
true if current language is RTL. false otherwise.
Returns if the current language type is RTL.
modalDialog.onKeyDown(keyboardEvent) source
Parameters
-
keyboardEvent
KeyboardEvent
The keyboard event.
Triggers keyboard events:
- Tab key tab to go to submit button.
- Esc key to close the modal dialog.
modalDialog.open() source
This method opens the modal window, restoring the previous state, position and metrics, if exists. By default the modal object opens in stack mode.
modalDialog.orientationChangeAndroidSoftkeyboard() source
Change container sizes when orientation is changed on Android.
modalDialog.orientationChangeIosSoftkeyboard() source
Change container sizes when orientation is changed on iOS.
modalDialog.recalculatePosition() source
Recalculating position for modal dialog when the browser is resized.
modalDialog.removeClass(className) source
Parameters
-
className
String
Class name.
Remove a class from all modal DOM elements.
modalDialog.restoreState() source
Restore previous state, position and size of previous stacked modal dialog.
modalDialog.saveModalProperties() source
Saves position and size parameters of and open ModalDialog. This attributes are needed to restore it on re-open.
modalDialog.setContainerHeight(height) source
Parameters
-
height
Number
New height.
Set iframe container height.
modalDialog.setContentManager(contentManager) source
This method sets an ContentManager instance to ModalDialog. ContentManager manages the logic of ModalDialog content: submit, update, close and changes.
modalDialog.setPosition(bottom, right) source
Parameters
-
bottom
number
bottom attribute.
-
right
number
right attribute.
Sets modal position using bottom and right style attributes.
modalDialog.setResizeButtonsVisibility() source
Enable or disable visibility of resize buttons in modal window depend on state.
modalDialog.setSize(height, width) source
Parameters
-
height
Number
Height of the ModalDialog
-
width
Number
Width of the ModalDialog.
Sets modal size.
modalDialog.setTitle(title) source
Parameters
-
title
String
Modal dialog title.
Sets the tithle of the modal dialog.
modalDialog.startDrag(mouseEvent) source
Parameters
-
mouseEvent
MouseEvent
Touchstart or mousedown event.
Start drag function: set the object dragDataObject with the draggable object offsets coordinates. when drag starts (on touchstart or mousedown events).
modalDialog.submitAction() source
This method is called when the modal object has been submitted. Calls contentElement submitAction method - if exists - and closes the modal object. No logic about the content should be placed here, contentElement.submitAction is the responsible of the content logic.
Parser
This class represent a MahML parser. Converts MathML into formulas depending on the image format (SVG, PNG, base64) and the save mode (XML, safeXML, Image) configured in the backend.
Static
Parser.codeImgTransform(code, mode) → string source
Parameters
-
code
string
HTML code
-
mode
string
base642showimage or img2mathml or img264 transform.
Returns
string
html - code transformed.
Transform html img tags inside a html code to mathml, base64 img tags (i.e with base64 on src) or showimage img tags (i.e with showimage.php on src)
Parser.createImageSrc(mathml, data) → string source
Parameters
-
mathml
string
MathML code.
-
data
Object[]
data object containing service parameters.
Returns
string
the showimage path.
Returns the source to showimage service by calling createimage service. The output of the createimage service is a URL path pointing to showimage service. This method is called when performance is disabled.
Parser.createShowImageSrc(data, language) → Object source
Parameters
-
data
Object[]
object containing showimage service parameters.
-
language
string
string containing the language of the formula.
Returns
Object
JSON object containing showimage response.
Returns the result to call showimage service with the formula md5 as parameter. The result could be:
- {'status' : warning'} : The image associated to the MathML md5 is not in cache.
- {'status' : 'ok' ...} : The image associated to the MathML md5 is in cache.
Parser.endParse(code) → string source
Parameters
-
code
string
HTML to be parsed
Returns
string
the HTML code parsed.
Parses end HTML code. The end HTML code is HTML code with embedded images
or LaTeX formulas created with MathType.
By default this method converts the formula images and LaTeX strings in MathML.
If image mode is enabled the images will not be converted into MathML. For further information see http://www.wiris.com/plugins/docs/full-mathml-mode.
Parser.endParseEditMode(code) → string source
Parameters
-
code
string
HTML code to be parsed.
Returns
string
HTML code parsed.
Parses end HTML code depending on the edit mode.
- LaTeX is an enabled parse mode, all LaTeX occurrences will be converted into MathML.
Parser.endParseSaveMode(code) → string source
Parameters
-
code
string
HTML code to be parsed
Returns
string
HTML code parsed.
Parses end HTML code depending on the save mode. Converts all images into the element determined by the save mode:
- xml: Parses images formulas into MathML.
- safeXml: Parses images formulas into safeMAthML
- base64: Parses images into base64 images.
- image: Parse images into images (no parsing)
Parser.initParse(code, language) → string source
Parameters
-
code
string
HTML code containing MathML data.
-
language
string
language to create image alt text.
Returns
string
HTML code with the original MathML converted into LaTeX and images.
Parses initial HTML code. If the HTML contains data generated by WIRIS, this data would be converted as following:
MathML code: Image containing the corresponding MathML formulas. MathML code with LaTeX annotation : LaTeX string.
Parser.initParseEditMode(code) → string source
Parameters
-
code
string
HTML code containing MathML.
Returns
string
parsed HTML code.
Parses initial HTML code depending on the edit mode. If 'latex' parseMode is enabled all MathML containing an annotation with encoding='LaTeX' will be converted into a LaTeX string instead of an image.
Parser.initParseSaveMode(code, language) → string source
Parameters
-
code
string
HTML code to be parsed
-
language
string
language to create image alt text.
Returns
string
HTML code parsed.
Parses initial HTML code depending on the save mode. Transforms all MathML occurrences for it's correspondent image or LaTeX.
Parser.mathmlToImgObject(creator, mathml, wirisProperties, language) → HTMLImageElement source
Parameters
-
creator
Document
Document object to call createElement method.
-
mathml
string
MathML code
-
wirisProperties
Object[]
object containing WIRIS custom properties
-
language
language
custom language for accessibility.
Returns
HTMLImageElement
the formula image corresponding to initial MathML string.
Converts a MathML string to an img element.
Parser.parseMathmlToImg(content, characters, language) → string source
Parameters
-
content
string
string with valid MathML code. The MathML code doesn't contain semantics.
-
characters
Constants
Constant object containing xmlCharacters or safeXmlCharacters relation.
-
language
string
a valid language code in order to generate formula accessibility.
Returns
string
The input string with all the MathML occurrences replaced by the corresponding image.
Converts all occurrences of MathML to the corresponding image.
PopUpMessage
This class represents a dialog message overlaying a DOM element in order to accept / cancel discard changes. The dialog can be closed i.e the overlay disappears o canceled. In this last case a callback function should be called.
Construction
new PopUpMessage(popupMessageAttributes) source
Parameters
-
popupMessageAttributes
Object
Object containing popup properties.
-
overlayElement
HTMLElement
Element to overlay.
-
callbacks
Object
Contains callback methods for close and cancel actions.
-
strings
Object
Contains all the strings needed.
-
Members
popUpMessage.message source
HTMLElement to display the popup message, close button and cancel button.
popUpMessage.overlayWrapper source
HTMLElement element to wrap all HTML elements inside the popupMessage.
Methods
popUpMessage.cancelAction() source
This method cancels the popupMessage: the dialog disappears revealing the overlaid element. A callback method is called (if defined). For example a method to focus the overlaid element.
popUpMessage.closeAction() source
This method closes the popupMessage: the dialog disappears and the close callback is called. For example to close the overlaid element.
popUpMessage.createButton(parameters, callback-) → HTMLElement source
Parameters
-
parameters
Object
An object containing id, class and innerHTML button text.
-
id
String
Button id.
-
class
String
Button class name.
-
innerHTML
String
Button innerHTML text.
-
-
callback-
Object
Callback method to call on click event.
Returns
HTMLElement
HTML button.
This method create a button with arguments and return button dom object
ServiceProvider
Class representing a serviceProvider. A serviceProvider is a class containing an arbitrary number of services with the correspondent path.
Construction
new ServiceProvider() source
Static
ServiceProvider.addListener(listener) source
Adds a Listener instance to ServiceProvider class.
ServiceProvider.createServiceURI(service) → String source
Parameters
-
service
String
The service name.
Returns
String
The service path.
Returns the URI associated with a certain service.
ServiceProvider.getServerLanguageFromService(service) → String source
Parameters
-
service
String
The configuration service.
Returns
String
- The server technology associated with the configuration service.
Returns the server language of a certain service. The possible values are: php, aspx, java and ruby. This method has backward compatibility purposes.
ServiceProvider.getServerURL() → String source
Returns
String
The client side server path.
Returns the server URL in the form protocol://serverName:serverPort.
ServiceProvider.getService(service, postVariables, get) → String source
Parameters
-
service
String
Service name.
-
postVariables
String
Post variables.
-
get
Boolean
True if the request is GET instead of POST. false otherwise.
Returns
String
Service response text.
Returns the response text of a certain service.
ServiceProvider.getServicePath(serviceName) → String source
Parameters
-
serviceName
String
Service name.
Returns
String
The service path.
Returns the service path for a certain service.
ServiceProvider.init(parameters) source
Parameters
-
parameters
Object
Function parameters.
-
integrationPath
String
Service path.
-
Inits this class. Uses this.integrationPath as base path to generate all backend services paths.
ServiceProvider.setServicePath(service, path) source
Parameters
-
service
String
Service name.
-
path
String
Service path.
Adds a new service to the ServiceProvider.
Members
ServiceProvider._servicePaths source
Properties
Name | Type | Description |
---|---|---|
service |
String
|
The service name. |
path |
String
|
The service path. |
StringManager
This class represents a string manager. It's used to load localized strings.
Construction
new StringManager() source
Static
Members
TelemetryService
Sends and receuives Wiris telemetry data.
Construction
new TelemetryService() source
Static
TelemetryService.composeBody() source
Given 'messages', composes the Telemetry request body as a JSON.
TelemetryService.composeUUID() source
Helper function that generates a random UUID used to identify both the batch and the sender. Wikipedia: A universally unique identifier (UUID) is an identifier standard used in software construction. A UUID is simply a 128-bit value. The meaning of each bit is defined by any of several variants. For human-readable display, many systems use a canonical format using hexadecimal text with inserted hyphen characters.
Members
TelemetryService.deployment source
Composes the deployment id key for 'mathtype-web-*'. It follows the convention defined at the 'doc/adr/XXX-telemetry-deployment-name-convention' TODO: create the 'doc/adr'.
TextCache
This class represent a client-side text cache class. Contains pairs of strings (key/value) which can be retrieved in any moment. Usually used to store AJAX responses for text services like mathml2latex (c.f Latex class) or mathml2accessible (c.f Accessibility class).
Members
Methods
Util
This class represents an utility class.
Static
Util.addArgument(path, parameter, value) source
Parameters
-
path
string
URL path
-
parameter
string
parameter
-
value
string
value
Add a parameter with it's correspondent value to an URL (GET).
Util.addClass(element, className) source
Parameters
-
element
HTMLElement
the HTML element.
-
className
string
the class name.
Adds a class name to a HTMLElement.
Util.addElementEvents(eventTarget, doubleClickHandler, mousedownHandler, mouseupHandler) source
Parameters
-
eventTarget
EventTarget
event target.
-
doubleClickHandler
function
function to run when on dblclick event.
-
mousedownHandler
function
function to run when on mousedown event.
-
mouseupHandler
function
function to run when on mouseup event.
Adds the a callback function, for a certain event target, to the following event types:
- dblclick
- mousedown
- mouseup
Util.addEvent(eventTarget, eventName, callBackFunction) source
Parameters
-
eventTarget
EventTarget
target to add the event.
-
eventName
string
specifies the type of event.
-
callBackFunction
function
callback function.
Cross-browser addEventListener/attachEvent function.
Util.b64ToByteArray(b64String, length) → Object[] source
Parameters
-
b64String
string
base64 string.
-
length
number
dimension of byte array (by default whole string).
Returns
Object[]
the resultant byte array.
Converts a base64 string to a array of bytes.
Util.compareStrings(a, b) → number source
Parameters
-
a
string
first string to compare.
-
b
string
second string to compare.
Returns
number
the difference between a and b
Compare two strings using charCodeAt method
Util.concatenateUrl(path1, path2) → string source
Parameters
-
path1
string
first URL path
-
path2
string
second URL path
Returns
string
new URL.
Concatenates two URL paths.
Util.containsClass(element, className) → boolean source
Parameters
-
element
HTMLElement
the HTML element.
-
className
string
the className.
Returns
boolean
true if the HTMLElement contains the class name. false otherwise.
Checks if a HTMLElement contains a certain class.
Util.convertOldXmlinitialtextAttribute(text) → string source
Parameters
-
text
string
string containing safeXml characters
Returns
string
a string with safeXml characters parsed.
Converts old xml initial text attribute (with «») to the correct one(with §lt;§gt;). It's used to parse old applets.
Util.createElement(tagName, attributes, [creator]) → Element source
Parameters
-
tagName
string
tag name of the wished element.
-
attributes
Object
an object where each key is a wished attribute name and each value is its value.
-
[creator]
Object
if supplied, this function will use the "createElement" method from this param. Otherwise document will be used as creator.
Returns
Element
The DOM element with the specified attributes assigned.
Cross-browser solution for creating new elements.
Util.createHttpRequest() → object|XMLHttpRequest|ActiveXObject source
Returns
-
object
httpRequest request object.
-
XMLHttpRequest
|
ActiveXObject
the proper request object.
Returns a cross-browser http request.
Util.createObject(objectCode) → Element source
Parameters
-
objectCode
string
html code
Returns
Element
the HTML element.
Creates new HTML from it's HTML code as string.
Util.createObjectCode(element) → string source
Parameters
-
element
Element
entry element.
Returns
string
the HTML code of the input element.
Converts an Element to its HTML code.
Util.decode64(character) → number source
Parameters
-
character
string
base64 character.
Returns
number
base64 character numeric value.
Returns the numeric value of a base64 character.
Util.fireEvent(eventTarget, eventName) source
Parameters
-
eventTarget
EventTarget
target where event should be fired.
-
eventName
string
event to fire.
Fires an event in a target.
Util.fixedCharCodeAt(string, idx) → number source
Parameters
-
string
string
input string
-
idx
number
an integer greater than or equal to 0 and less than the length of the string
Returns
number
an integer representing the UTF-16 code of the string at the given index.
Fix charCodeAt() JavaScript function to handle non-Basic-Multilingual-Plane characters.
Util.getElementsByNameFromString(code, name, autoClosed) → Object[] source
Parameters
-
code
string
HTML code.
-
name
string
element name.
-
autoClosed
boolean
true if the elements are autoClosed.
Returns
Object[]
an object containing all HTML elements of code matching the name argument.
Looks for elements that match the given name in a HTML code string. Important: this function is very concrete for WIRIS code. It takes as preconditions lots of behaviors that are not the general case.
Util.getNodeLength(node) → number source
Parameters
-
node
Node
HTML node.
Returns
number
node length.
Gets the node length in characters.
Util.getSelectedItem(target, isIframe, forceGetSelection) → object source
Parameters
-
target
HTMLElement
the editable HTMLElement.
-
isIframe
boolean
specifies if the target is an iframe or not
-
forceGetSelection
boolean
if true, ignores IE system to get the current selection and uses window.getSelection()
Returns
object
an object with the 'node' key set if the item is an element or the keys 'node' and 'caretPosition' if the element is text.
Gets a selected node or text from an editable HTMLElement. If the caret is on a text node, concatenates it with all the previous and next text nodes.
Util.getSelectedItemOnTextarea(textarea) → Object source
Parameters
-
textarea
HTMLTextAreaElement
textarea element.
Returns
Object
An object containing the node, the index of the beginning of the selected text, caret position and the start and end position of the text node.
Returns null if there isn't any item or if it is malformed. Otherwise returns an object containing the node with the MathML image and the cursor position inside the textarea.
Util.getWIRISImageOutput(imgCode, convertToXml, convertToSafeXml) → string source
Parameters
-
imgCode
string
the html code from a formula or a CAS image.
-
convertToXml
boolean
true if the image should be converted to XML.
-
convertToSafeXml
boolean
true if the image should be converted to safeXML.
Returns
string
the XML or safeXML of a WIRIS image.
Converts the HTML of a image into the output code that WIRIS must return. By default returns the MathML stored on data-mahml attribute (if imgCode is a formula) or the Wiriscas attribute of a WIRIS applet.
Util.htmlEntities(input) → string source
Parameters
-
input
string
text to be parsed.
Returns
string
the input text with all their special characters replaced by their entities.
Parses a text and replaces all HTML special characters by their correspondent entities.
Util.htmlEntitiesDecode(input) → string source
Parameters
-
input
string
text to be parsed
Returns
string
the input text with all their entities replaced by characters.
Parses a text and replaces all the HTML entities by their characters.
Util.httpBuildQuery(properties) → string source
Parameters
-
properties
Object[]
a key/value object.
Returns
string
a HTTP query containing all the key value pairs with all the special characters replaced by their entities.
Converts a hash to a HTTP query.
Util.propertiesToString(hash) → string source
Parameters
-
hash
Object[]
a key/value object.
Returns
string
a string with the form key1=value1...keyn=valuen
Convert a hash to string sorting keys to get a deterministic output
Util.readByte(bytes) → number source
Parameters
-
bytes
Object
input byte array.
Returns
number
first byte of the byte array.
Read the first byte from a byte array.
Util.readBytes(bytes, pos, len) → Object[] source
Parameters
-
bytes
Object[]
byte array.
-
pos
number
start position.
-
len
number
number of bytes to read.
Returns
Object[]
the byte array.
Read an arbitrary number of bytes, from a fixed position on a byte array.
Util.readInt32(bytes) → number source
Parameters
-
bytes
Object[]
array of bytes.
Returns
number
the 32-bit signed integer.
Returns the first 32-bit signed integer from a byte array.
Util.removeClass(element, className) source
Parameters
-
element
HTMLElement
the HTML element.
-
className
string
the class name.
Remove a certain class for a HTMLElement.
Util.removeEvent(eventTarget, eventName, callBackFunction) source
Parameters
-
eventTarget
EventTarget
target to add the event.
-
eventName
string
specifies the type of event.
-
callBackFunction
function
function to remove from the event target.
Cross-browser removeEventListener/detachEvent function.
Util.updateExistingTextOnTextarea(textarea, text, start, end) source
Parameters
-
textarea
HTMLTextAreaElement
text area target.
-
text
string
text to add in the textarea. For example, if you want to add the link to the image,you can call this function as Util.updateTextarea(textarea, Parser.createImageSrc(mathml));
-
start
number
beginning index from textarea where it needs to be replaced by text.
-
end
number
ending index from textarea where it needs to be replaced by text
Modifies existing formula on a textarea.
Util.updateTextArea(textarea, text) source
Parameters
-
textarea
HTMLTextAreaElement
textarea target.
-
text
string
text to add in the textarea. For example, to add the link to the image, call this function as (textarea, Parser.createImageSrc(mathml));
Inserts or modifies formulas or CAS on a textarea.
Util.urlEncode(clearString) → string source
Parameters
-
clearString
string
URL string to be encoded
Returns
string
URL with it's special characters replaced.
Returns an encoded URL by replacing each instance of certain characters by one, two, three or four escape sequences using encodeURIComponent method. !'()* . will not be encoded.
Util.urlToAssArray(url) → Object[] source
Parameters
-
url
string
input URL.
Returns
Object[]
an array containing all URL query params.
Returns an URL with it's query params converted into array.