This sub interface allows to work with CSV data.
Tests the uploaded file result to see if it is a valid CSV file.
The uploaded file result to test.
Optional
checkFileExtension: booleanCheck the file extension as well. Default value is false.
Optional
options: CsvOptionsThe CSV options to use for testing. Default value is null.
True if the uploaded file result is a valid CSV file, and false if it is not.
Helper function to parse a string to a CSV table.
The CSV string to parse.
Optional
options: CsvOptionsThe optional CSV options to use for parsing.
An array of arrays (with the rows and columns) of the parsed result. Note that based on disableNumberConversion the values may be strings or numbers.
Helper function to convert a CSV table to a string.
The CSV table to convert to a string.
Optional
options: CsvOptionsThe optional CSV options to use for stringifying.
The CSV string.
The config sub interface allows to interact with the script configuration.
Merges the script configuration into the passed target. This is useful to define the configuration object with all defaults, and then overwrite the defaults with the script configuration, which will also work partially. Anything not defined will still be the default value.
The target object to merge the script configuration into. This will be usually the full configuration object with all defaults.
The convert sub interface allows to convert between different units.
The text helper sub interface has helper functions to work with text.
Performs variable data replacement on the given field array using the given replacement data. The operation depends on the field type.
The field listing to perform the replacement on.
The replacement data to use with keys (placeholder names) and values (replacement values). This is used for text and barcode fields.
Optional
optionalVariableTags: { The start and end tags for the text replacement.
Optional
optionalImageRetrievalFunction: (() => void)For image fields, this function can be used to retrieve the image data for the given image field. If not specified, the image will not be replaced.
Optional
replaceCaseInvariant: booleanThis flag controls if the replacement should be case invariant. Default value is false.
Optional
textSuppressionMode: TextSuppressionModeThe optional text suppression mode to use. Default value is null meaning no suppression to be used.
Optional
replacementText: stringThe optional replacement text allows to feed in the text to replace for the field from the outside - essentially overriding the field value. Default value is null meaning the field value will be used.
Optional
callback: (() => void)The callback function to trigger once the replacement is complete.
Suppresses segments of the given text based on whether corresponding data is present.
The function identifies segments delimited by the specified start and end tags and checks if each segment's associated key exists in the provided data. If a key is missing, the segment is suppressed according to the specified mode.
The input text that may contain segments eligible for suppression.
An object defining the start and end tags that mark the segments.
An object mapping keys to values; a missing key indicates that its segment should be suppressed.
The suppression mode to apply. Defaults to null (i.e., no suppression) if not provided.
The resulting text after applying the suppression logic.
Maps all given placeholders to the given values. The result will be an object with the placeholder as key and the mapping result as the value. The mapping result will have the index of the best matching value entry in the values array as the mapping index. Or -1 if no value matched. Note that multiple placeholders may be mapped to the same value.
The placeholders to map.
The candidate values to map the placeholders to.
The mapping result.
Returns the index of the best matching item in a list of candidates for a given reference string using the simplified similarity check GetSimilarity.
The reference string to compare the candidates against.
The list of candidates to compare against the reference string.
The index of the best matching item in the list of candidates. If no item matches it will return -1.
Clears a previously triggered timeout based on the timeout id returned by SetTimeOut to avoid the timeout to be triggered.
The timeout id to clear.
Executes a megascript instance, optionally overriding the script and config. Note that this only works server side and cannot be used client side.
The instance name to trigger.
Optional
script: stringOptionally the script to execute. If null, the script configured for the instance will be used.
Optional
config: stringThe optional configuration to overwrite. If null, the configuration configured for the instance will be used.
Boolean flag indicating if the script was executed successfully.
Return the custom field class for a custom field. When registering a custom field type, a custom class can be defined and made accessible through this function. The functions and interface depend fully on the custom script implementation.
The custom field or the custom field type to get the class for.
The custom field class or null if no class is registered for the given field or type.
Gets the DPI of the given image when it is rendered into the given dimensions using the given crop flag.
The width of the area to fit the image into.
The height of the area to fit the image into.
Flag indicating if the image should be cropped to fit the given dimensions fully, or if the entire image should be visible.
The image to fit into the given dimensions.
The DPI of the given image when it is rendered into the given dimensions using the given crop flag.
Get the DPI of the given image when it is rendered for a given Image field using the given crop flag.
The field to test the DPI for.
The image to test the DPI for.
Flag indicating if the image should be cropped to fit the given dimensions fully, or if the entire image should be visible.
Calculates the scale factor required to fit the given diemnsional item (usually a Javascript Image object or a MediaItem) into the given width and height. The crop parameter can be used to specify if the image should be cropped to fit the given dimensions fully, or if the entire image should be visible.
The width of the area to fit the image into.
The height of the area to fit the image into.
Flag indicating if the image should be cropped to fit the given dimensions fully, or if the entire image should be visible.
The image to fit into the given dimensions.
The scale factor required to fit the given image into the given dimensions.
Simplified similarity check for two strings. The higher the value, the more similar the strings are.
The first string to compare.
The second string to compare.
The similarity value >= 0. 0 means the strings are not similar at all. The higher the value, the more similar the strings are.
Escapes the HTML characters in the given text using https://github.com/mathiasbynens/he
The text to escape.
The escaped text.
Unescapes the HTML characters in the given text using https://github.com/mathiasbynens/he. The options parameter can be used to specify additional options for the unescape function - see above Github page for this.
The text to unescape.
Optional
options: UnescapeOptionsThe optional options to use for unescaping.
The unescaped text.
Loads an external script or data set into the editor. The script will be loaded asynchronously and the callback will be triggered once the external resource is loaded.
The URL to load the external resource from.
Optional
callback: ((data?) => void)The callback function to trigger once the external resource is loaded.
Optional
data: unknownOptional
onlyData: booleanIf set to true, the external resource will be loaded as data set and passed to the callback as parameter. If set to false, the URL will be loaded as a Javascript resource and the load event parameter will be passed. Default value is false.
Will measure the given text (width & height) using the given formatting options with the browser engine.
The text to measure.
The font to use for the measurement.
The font size to use for the measurement.
If set, we will use a bold font for the measurement.
If set, we will use an italic font for the measurement.
The leading will be only used if we have not retrieved a calculated height from the browser engine.
The dimensions of the text.
Merges two objects together. This will merge all properties of the source object into the target object. If the current items are arrays, the items will be appended if necessary. If the current items are objects, the properties are merged, potentially overwriting the target properties with the source properties. Note that the objects need to be compatible in that sense that they need to be either array or object types (included nested objects).
The target item to merge the source item into.
The source item to merge into the target item.
Sets a timeout to trigger the given callback after the given timeout in milliseconds within the editor. Server side this will be executed immediately. Once the current calling queue has been emptied.
The callback function to trigger.
The time in milliseconds to wait before triggering the callback (browser only).
The timeout id which can be used to clear the timeout using ClearTimeOut.
Generated using TypeDoc
Interface for a wide range of utility functions.