react-filerobot-image-editor
Version:
React component version of filerobot image editor (FIE).
1 lines • 952 B
JavaScript
import _toConsumableArray from"@babel/runtime/helpers/toConsumableArray";import{UPDATE_ANNOTATION_IDS}from"../actions";import restrictNumber from"../utils/restrictNumber";import useDispatch from"./useDispatch";import useStore from"./useStore";var useAnnotationOrdering=function(){var a=useDispatch(),b=useStore(),c=b.annotationIds,d=function(b){a({type:UPDATE_ANNOTATION_IDS,payload:{annotationIds:b}})},e=function(a,b){var d,e=c.filter(function(b,c){return a!==b||(d=c,!1)});return"undefined"!=typeof d&&e.splice(restrictNumber(d+b,0,c.length-1),0,a),e};return{getReorderedAnnotationIds:e,bringToFront:function(a){c.includes(a)&&d([].concat(_toConsumableArray(c.filter(function(b){return a!==b})),[a]))},sendToBack:function(a){c.includes(a)&&d([a].concat(_toConsumableArray(c.filter(function(b){return a!==b}))))},moveBySteps:function(a){var b=1<arguments.length&&arguments[1]!==void 0?arguments[1]:1;d(e(a,b))}}};export default useAnnotationOrdering;