Create a custom mutation
This is a guide on creating and using Custom
A Custom
Create the callback
Create a new file for the callback which will be used as a CustomMutation. This file needs to return a function.
convertTextCase.js
JavaScript
import CustomMutationResult from 'fontoxml-base-flow/src/CustomMutationResult.js';
export default function convertTextCase(argument, blueprint, format, selection) {
return CustomMutationResult.ok();
}
As the example above shows instead of returning a boolean value to indicate whether the custom mutation was successful Custom
See the Custom
Register the Custom Mutation
Once you are done writing the Custom
install.js
JavaScript
import addCustomMutation from 'fontoxml-base-flow/src/addCustomMutation.js';
import convertTextCase from './convertTextCase.js';
export default function install() {
addCustomMutation('convertTextCase', convertTextCase);
}
Use the Custom Mutation in an operation
Using a Custom
While the example below show the usage of a Custom
operations.json
JavaScript
{
"set-word-casing": {
"label": "UPPER CASE/lower case",
"description": "Converts selected text to all uppercase / all lowercase / capitalize each word",
"keyBinding": "Shift+F2",
"steps": {
"type": "custom-mutation/convertTextCase"
}
}
}