Page tree
Skip to end of metadata
Go to start of metadata

Create a simple content macro for an editor instance with editor.macros.addSimpleMacro().

The simple replacement macro allows you to replace entered text when that text is surrounded by a startString and endString. The callback function can then operate on the matched string, including the startString and endString.

Example

editor.macros.addSimpleMacro(startString, endString, callback)
// Create a macro that replaces text surrounded in double-brackets with a string
var key = editor.macros.addSimpleMacro('[[', ']]', function(str) {
    var newValue = "Macro Triggered!";
    return newValue;
});

Parameters

startStringStringA string pattern to search for signifying the beginning of the macro replacement.
endStringStringA string pattern to search for signifying the end of the macro replacement.
callbackFunctionA function that receives the complete matching string (including start and end) and returns the string to insert instead.

Returns

keyString

A key that identifies this macro in this editor instance.

See Also

Macros: Writing Content-Aware Code

  • No labels