This documentation is for a version that has reached its End Of Life. Such versions are no longer supported and don't receive security updates. Consider updating to a newer version.
With the Image Editor, users can do basic image modifications.
You can configure the Image Editor's default appearance or behavior.
You can also extend it by adding custom features.
The following example shows how to extend the Image Editor
by adding a button that draws a dot at a random location on the image.
importReact,{useContext}from'react';importPropTypesfrom'prop-types';const{ibexa}=window;constIDENTIFIER='dot';constDot=()=>{return(<divclassName="c-image-editor-dot"><buttontype="button"className="btn btn-secondary">Adddot</button></div>);};Dot.propTypes={};Dot.defaultProps={};exportdefaultDot;ibexa.addConfig('imageEditor.actions.dot',// The ID ("dot") must match the one from the configuration yaml file{label:'Dot',component:Dot,icon:ibexa.helpers.icon.getIconPath('radio-button'),// Path to an icon that will be displayed in the UIidentifier:IDENTIFIER,// The identifier must match the one from the configuration yaml file},true,);
The code doesn't perform any action yet, you add the action in the following steps.
Once you create and configure the React component, you must add an entry to the Webpack configuration.
In the root directory of your project, modify the webpack.config.js file by adding the following code:
When you create a React-based extension of the Image Editor, you can use a number of contexts that have the following functions:
CanvasContext - stores a canvas that displays the image, on which you can modify the image
ImageHistoryContext - stores the image history used by the Undo/Redo feature
AdditionalDataContext - stores additional data that is attached to the image, for example, focal point coordinates
TechnicalCanvasContext - stores a canvas, which you can use to draw elements that help modify the image, for example, a crop area or a grid, without interrupting with the actual image