Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-filerobot-image-editor

Package Overview
Dependencies
Maintainers
0
Versions
146
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-filerobot-image-editor - npm Package Compare versions

Comparing version 5.0.0-beta.41 to 5.0.0-beta.42

2

lib/components/Layers/DesignLayer/AnnotationNodes/TextNode/TextNode.styled.js

@@ -1,1 +0,1 @@

import styled from"styled-components";var StyledTextNodeContentTextarea=styled.div.withConfig({componentId:"sc-4tf56w-0"})(function(a){var b=a.$opacity,c=a.$textAlign,d=a.$width,e=a.$height;return"\n background: transparent;\n opacity: ".concat(b,";\n text-align: ").concat(c,";\n width: ").concat(d,"px;\n height: ").concat(e,"px;\n border: none;\n outline: 3px solid #000;\n border-radius: 2px;\n resize: none;\n padding: 0;\n margin: 0;\n overflow: visible auto;\n cursor: text;\n overflow-wrap: break-word;\n word-break: normal;\n user-select: text;\n\n mark, mark * {\n background: rgba(40, 90, 195, 0.75) !important;\n color: #fff !important;\n }\n")});export{StyledTextNodeContentTextarea};
import styled from"styled-components";var StyledTextNodeContentTextarea=styled.div.withConfig({componentId:"sc-4tf56w-0"})(function(a){var b=a.$opacity,c=a.$textAlign,d=a.$width,e=a.$height;return"\n background: transparent;\n opacity: ".concat(b,";\n text-align: ").concat(c,";\n width: ").concat(d,"px;\n height: ").concat(e,"px;\n border: none;\n outline: 3px solid #000;\n border-radius: 2px;\n resize: none;\n padding: 0;\n margin: 0;\n overflow: visible auto;\n cursor: text;\n overflow-wrap: break-word;\n word-break: normal;\n user-select: text;\n\n > * {\n vertical-align: text-top;\n }\n\n mark, mark * {\n background: rgba(40, 90, 195, 0.75) !important;\n color: #fff !important;\n }\n")});export{StyledTextNodeContentTextarea};

@@ -1,1 +0,1 @@

import _defineProperty from"@babel/runtime/helpers/defineProperty";import _slicedToArray from"@babel/runtime/helpers/slicedToArray";function ownKeys(a,b){var c=Object.keys(a);if(Object.getOwnPropertySymbols){var d=Object.getOwnPropertySymbols(a);b&&(d=d.filter(function(b){return Object.getOwnPropertyDescriptor(a,b).enumerable})),c.push.apply(c,d)}return c}function _objectSpread(a){for(var b,c=1;c<arguments.length;c++)b=null==arguments[c]?{}:arguments[c],c%2?ownKeys(Object(b),!0).forEach(function(c){_defineProperty(a,c,b[c])}):Object.getOwnPropertyDescriptors?Object.defineProperties(a,Object.getOwnPropertyDescriptors(b)):ownKeys(Object(b)).forEach(function(c){Object.defineProperty(a,c,Object.getOwnPropertyDescriptor(b,c))});return a}import{TEXT_EDITOR_ID}from"../../../../../utils/constants";import rgbaToHexWithOpacity from"../../../../../utils/rgbaToHexa";import toPrecisedFloat from"../../../../../utils/toPrecisedFloat";var jsCanvasCssPropToCssTextProp=function(a){return"fill"===a?"color":"baselineShift"===a?"transform":"".concat(a.replaceAll(/[A-Z]/g,function(a){return"-".concat(a.toLowerCase())}))};export var jsStyleToCssText=function(a){return Object.keys(a||{}).map(function(b){return"".concat(jsCanvasCssPropToCssTextProp(b),": ").concat(Number.isFinite(a[b])?"".concat(a[b],"px"):a[b],";")}).join(" ")};export var cssStyleToJsCanvasProps=function(a){var b=1<arguments.length&&void 0!==arguments[1]?arguments[1]:1;if(!a)return{};var c={};return a.split(/;\s*/).forEach(function(a){if(a){var b=a.split(/:\s*/),d=_slicedToArray(b,2),e=d[0],f=d[1],g=e.replaceAll(/-([a-z])/g,function(a,b){return"".concat(b[0].toUpperCase()).concat(b.slice(1))});c[g]=null!==f&&void 0!==f&&f.toLowerCase().endsWith("px")?parseFloat(f):f}}),c.color&&(c.fill=c.color,delete c.color),c.transform&&(c.baselineShift=toPrecisedFloat(-parseFloat(c.transform.match(/\((.*)px\)/)[1])/b,2),delete c.transform),c.letterSpacing&&(c.letterSpacing=toPrecisedFloat(parseFloat(c.letterSpacing)/b,2)),c};export var getNewFormattedContent=function(a,b){var c=[];return Array.from(a.childNodes).forEach(function(a,d){var e,f=a.textContent;if(f){var g=a;if("#text"===a.nodeName){var h,i=a.parentNode;if(null!==(h=i.style)&&void 0!==h&&h.cssText.includes(jsStyleToCssText(b)))return;var j=i.textContent===a.textContent&&(null===i||void 0===i?void 0:i.style)&&"MARK"!==i.nodeName;g=j&&i||document.createElement("span"),j||(g.innerText=f)}return Object.assign(g.style,b),0<d&&f&&g.style.cssText===(null===(e=c[d-1])||void 0===e?void 0:e.style.cssText)?void(c[d-1].textContent="".concat(c[d-1].textContent).concat(f)):void c.push(g)}}),c};var _pushNodeFlattenedContent=function(a,b){var c=2<arguments.length&&arguments[2]!==void 0?arguments[2]:{},d=3<arguments.length&&arguments[3]!==void 0?arguments[3]:{},e=d.originalSourceInitialScale,f=void 0===e?1:e,g="BR"===b.nodeName;if("#text"===b.nodeName&&b.textContent||g){var h,i=a[a.length-1],j=((null===i||void 0===i?void 0:i.endIndex)||-1)+1,k=g?"\n":b.textContent;if(i&&!i.textContent.startsWith("$")&&!k.startsWith("$")&&JSON.stringify(c)===JSON.stringify(i.style))i.textContent="".concat(i.textContent).concat(k),i.endIndex=i.startIndex+i.textContent.replaceAll("\n","").length-1;else{var l=j+(k.replaceAll("\n").length||1)-1;a.push({style:c,textContent:k,startIndex:j,endIndex:l})}var m="MARK"===b.parentNode.nodeName&&b.parentNode||"MARK"===(null===(h=b.parentNode.parentNode)||void 0===h?void 0:h.nodeName)&&b.parentNode.parentNode;return void(m&&(m.textContent.startsWith(b.textContent)&&(m.dataset.startIndex=j),m.textContent.endsWith(b.textContent)&&(m.dataset.endIndex=(parseInt(m.dataset.startIndex,10)||0)+m.textContent.replaceAll("\n","").length-1)))}var n=cssStyleToJsCanvasProps(b.style.cssText,f);b.childNodes.forEach(function(b){(b.textContent||"BR"===b.nodeName)&&_pushNodeFlattenedContent(a,b,_objectSpread(_objectSpread({},c),n),{originalSourceInitialScale:f})})};export{_pushNodeFlattenedContent as pushNodeFlattenedContent};var _recursivelyRemoveCssProperties=function(a){var b=1<arguments.length&&arguments[1]!==void 0?arguments[1]:[];"#text"===a.nodeName||a.childNodes.forEach(function(a){var c;null!==(c=a.style)&&void 0!==c&&c.cssText&&b.forEach(function(b){return a.style.removeProperty(jsCanvasCssPropToCssTextProp(b))}),_recursivelyRemoveCssProperties(a,b)})};export{_recursivelyRemoveCssProperties as recursivelyRemoveCssProperties};var _getCurrentSelectedNodeStyles=function(a){var b=1<arguments.length&&arguments[1]!==void 0?arguments[1]:{},c=2<arguments.length&&arguments[2]!==void 0?arguments[2]:{},d=c.originalSourceInitialScale;if(!a)return b;var e=_objectSpread(_objectSpread({},a.style&&cssStyleToJsCanvasProps(a.style.cssText,d)),b);return a.id===TEXT_EDITOR_ID||"true"===a.contentEditable?(e.fill&&(e.fill="#".concat(rgbaToHexWithOpacity(e.fill).hex)),e):_getCurrentSelectedNodeStyles(a.parentNode,e,{originalSourceInitialScale:d})};export{_getCurrentSelectedNodeStyles as getCurrentSelectedNodeStyles};
import _defineProperty from"@babel/runtime/helpers/defineProperty";import _slicedToArray from"@babel/runtime/helpers/slicedToArray";function ownKeys(a,b){var c=Object.keys(a);if(Object.getOwnPropertySymbols){var d=Object.getOwnPropertySymbols(a);b&&(d=d.filter(function(b){return Object.getOwnPropertyDescriptor(a,b).enumerable})),c.push.apply(c,d)}return c}function _objectSpread(a){for(var b,c=1;c<arguments.length;c++)b=null==arguments[c]?{}:arguments[c],c%2?ownKeys(Object(b),!0).forEach(function(c){_defineProperty(a,c,b[c])}):Object.getOwnPropertyDescriptors?Object.defineProperties(a,Object.getOwnPropertyDescriptors(b)):ownKeys(Object(b)).forEach(function(c){Object.defineProperty(a,c,Object.getOwnPropertyDescriptor(b,c))});return a}import{TEXT_EDITOR_ID}from"../../../../../utils/constants";import rgbaToHexWithOpacity from"../../../../../utils/rgbaToHexa";import toPrecisedFloat from"../../../../../utils/toPrecisedFloat";var jsCanvasCssPropToCssTextProp=function(a){return"fill"===a?"color":"baselineShift"===a?"transform":"".concat(a.replaceAll(/[A-Z]/g,function(a){return"-".concat(a.toLowerCase())}))};export var jsStyleToCssText=function(a){return Object.keys(a||{}).map(function(b){return"".concat(jsCanvasCssPropToCssTextProp(b),": ").concat(Number.isFinite(a[b])?"".concat(a[b],"px"):a[b],";")}).join(" ")};export var cssStyleToJsCanvasProps=function(a){var b=1<arguments.length&&void 0!==arguments[1]?arguments[1]:1;if(!a)return{};var c={};return a.split(/;\s*/).forEach(function(a){if(a){var b=a.split(/:\s*/),d=_slicedToArray(b,2),e=d[0],f=d[1],g=e.replaceAll(/-([a-z])/g,function(a,b){return"".concat(b[0].toUpperCase()).concat(b.slice(1))});c[g]=null!==f&&void 0!==f&&f.toLowerCase().endsWith("px")||/^[0-9]*$/.test(f)?parseFloat(f):null===f||void 0===f?void 0:f.replaceAll("\"","")}}),c.color&&(c.fill=c.color,delete c.color),c.transform&&(c.baselineShift=toPrecisedFloat(-parseFloat(c.transform.match(/\((.*)px\)/)[1])/b,2),delete c.transform),c.letterSpacing&&(c.letterSpacing=toPrecisedFloat(parseFloat(c.letterSpacing)/b,2)),c};export var getNewFormattedContent=function(a,b){var c=[];return Array.from(a.childNodes).forEach(function(a,d){var e,f=a.textContent;if(f){var g=a;if("#text"===a.nodeName){var h,i=a.parentNode;if(null!==(h=i.style)&&void 0!==h&&h.cssText.includes(jsStyleToCssText(b)))return;var j=i.textContent===a.textContent&&(null===i||void 0===i?void 0:i.style)&&"MARK"!==i.nodeName;g=j&&i||document.createElement("span"),j||(g.innerText=f)}return Object.assign(g.style,b),0<d&&f&&g.style.cssText===(null===(e=c[d-1])||void 0===e?void 0:e.style.cssText)?void(c[d-1].textContent="".concat(c[d-1].textContent).concat(f)):void c.push(g)}}),c};var _pushNodeFlattenedContent=function(a,b){var c=2<arguments.length&&arguments[2]!==void 0?arguments[2]:{},d=3<arguments.length&&arguments[3]!==void 0?arguments[3]:{},e=d.originalSourceInitialScale,f=void 0===e?1:e,g="BR"===b.nodeName;if("#text"===b.nodeName&&b.textContent||g){var h,i=a[a.length-1],j=((null===i||void 0===i?void 0:i.endIndex)||-1)+1,k=g?"\n":b.textContent;if(i&&!i.textContent.startsWith("$")&&!k.startsWith("$")&&JSON.stringify(c)===JSON.stringify(i.style))i.textContent="".concat(i.textContent).concat(k),i.endIndex=i.startIndex+i.textContent.replaceAll("\n","").length-1;else{var l=j+(k.replaceAll("\n").length||1)-1;a.push({style:c,textContent:k,startIndex:j,endIndex:l})}var m="MARK"===b.parentNode.nodeName&&b.parentNode||"MARK"===(null===(h=b.parentNode.parentNode)||void 0===h?void 0:h.nodeName)&&b.parentNode.parentNode;return void(m&&(m.textContent.startsWith(b.textContent)&&(m.dataset.startIndex=j),m.textContent.endsWith(b.textContent)&&(m.dataset.endIndex=(parseInt(m.dataset.startIndex,10)||0)+m.textContent.replaceAll("\n","").length-1)))}var n=cssStyleToJsCanvasProps(b.style.cssText,f);b.childNodes.forEach(function(b){(b.textContent||"BR"===b.nodeName)&&_pushNodeFlattenedContent(a,b,_objectSpread(_objectSpread({},c),n),{originalSourceInitialScale:f})})};export{_pushNodeFlattenedContent as pushNodeFlattenedContent};var _recursivelyRemoveCssProperties=function(a){var b=1<arguments.length&&arguments[1]!==void 0?arguments[1]:[];"#text"===a.nodeName||a.childNodes.forEach(function(a){var c;null!==(c=a.style)&&void 0!==c&&c.cssText&&b.forEach(function(b){return a.style.removeProperty(jsCanvasCssPropToCssTextProp(b))}),_recursivelyRemoveCssProperties(a,b)})};export{_recursivelyRemoveCssProperties as recursivelyRemoveCssProperties};var _getCurrentSelectedNodeStyles=function(a){var b=1<arguments.length&&arguments[1]!==void 0?arguments[1]:{},c=2<arguments.length&&arguments[2]!==void 0?arguments[2]:{},d=c.originalSourceInitialScale;if(!a)return b;var e=_objectSpread(_objectSpread({},a.style&&cssStyleToJsCanvasProps(a.style.cssText,d)),b);return a.id===TEXT_EDITOR_ID||"true"===a.contentEditable?(e.fill&&(e.fill="#".concat(rgbaToHexWithOpacity(e.fill).hex)),e):_getCurrentSelectedNodeStyles(a.parentNode,e,{originalSourceInitialScale:d})};export{_getCurrentSelectedNodeStyles as getCurrentSelectedNodeStyles};

@@ -1,1 +0,1 @@

import _toConsumableArray from"@babel/runtime/helpers/toConsumableArray";import _defineProperty from"@babel/runtime/helpers/defineProperty";import _classCallCheck from"@babel/runtime/helpers/classCallCheck";import _createClass from"@babel/runtime/helpers/createClass";import _possibleConstructorReturn from"@babel/runtime/helpers/possibleConstructorReturn";import _getPrototypeOf from"@babel/runtime/helpers/getPrototypeOf";import _inherits from"@babel/runtime/helpers/inherits";function ownKeys(a,b){var c=Object.keys(a);if(Object.getOwnPropertySymbols){var d=Object.getOwnPropertySymbols(a);b&&(d=d.filter(function(b){return Object.getOwnPropertyDescriptor(a,b).enumerable})),c.push.apply(c,d)}return c}function _objectSpread(a){for(var b,c=1;c<arguments.length;c++)b=null==arguments[c]?{}:arguments[c],c%2?ownKeys(Object(b),!0).forEach(function(c){_defineProperty(a,c,b[c])}):Object.getOwnPropertyDescriptors?Object.defineProperties(a,Object.getOwnPropertyDescriptors(b)):ownKeys(Object(b)).forEach(function(c){Object.defineProperty(a,c,Object.getOwnPropertyDescriptor(b,c))});return a}function _callSuper(a,b,c){return b=_getPrototypeOf(b),_possibleConstructorReturn(a,_isNativeReflectConstruct()?Reflect.construct(b,c||[],_getPrototypeOf(a).constructor):b.apply(a,c))}function _isNativeReflectConstruct(){try{var a=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(a){}return(_isNativeReflectConstruct=function(){return!!a})()}import{Factory}from"konva/lib/Factory";import{_registerNode}from"konva/lib/Global";import{Shape}from"konva/lib/Shape";import{Util}from"konva/lib/Util";import{getNumberOrAutoValidator,getNumberValidator,getBooleanValidator}from"konva/lib/Validators";import toPrecisedFloat from"../../utils/toPrecisedFloat";var dummyContext;function getDummyContext(){return dummyContext?dummyContext:(dummyContext=Util.createCanvasElement().getContext("2d"),dummyContext)}function normalizeFontFamily(a){return a?a.split(",").map(function(a){a=a.trim();var b=0<=a.indexOf(" "),c=0<=a.indexOf("\"")||0<=a.indexOf("'");return b&&!c&&(a="\"".concat(a,"\"")),a}).join(", "):""}var NORMAL="normal",CHANGEABLE_ATTRS=["padding","wrap","lineHeight","letterSpacing","width","height","text","fontSize","fill","fontWeight","fontStyle","fontFamily","verticalAlign"];export var FormattedText=function(a){function b(a){var c;return _classCallCheck(this,b),c=_callSuper(this,b,[a]),CHANGEABLE_ATTRS.forEach(function(a){c.on("".concat(a,"Change.konva"),c.computeTextParts)}),c.computeTextParts(),c}return _inherits(b,a),_createClass(b,[{key:"formatFont",value:function(a){var b,c=this.getDefaultTextPartFormat();return"".concat(a.style.fontStyle||c.fontStyle," ").concat(a.style.fontWeight||c.fontWeight," ").concat(a.style.fontVariant||c.fontVariant," ").concat(null!==(b=a.style.fontSize)&&void 0!==b?b:c.fontSize,"px ").concat(normalizeFontFamily(a.style.fontFamily||c.fontFamily))}},{key:"measurePart",value:function(a){var b=getDummyContext(),c=toPrecisedFloat((a.style.letterSpacing||1)*this.scaleFormatDimensionsBy(),2);b.save(),b.font=this.formatFont(a),b.letterSpacing="".concat(c,"px");var d=b.measureText(a.text),e=d.width;return b.restore(),e}},{key:"getDefaultTextPartFormat",value:function(){return{fontSize:this.fontSize(),fill:this.fill(),fontWeight:this.fontWeight(),fontStyle:this.fontStyle(),baselineShift:0,letterSpacing:this.letterSpacing(),fontVariant:this.fontVariant(),fontFamily:this.fontFamily()}}},{key:"computeTextParts",value:function(){var a,b=this;this.textLines=[],this.visibleLinesStartIndex=0;for(var c=Array.isArray(this.text())?this.text().map(function(){var a=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{},b=a.textContent;return b}).join(""):this.text(),d=c.split("\n"),e=this.attrs.width,f=this.attrs.height,g="auto"!==f&&void 0!==f,h=g&&"top"===this.verticalAlign(),j="none"!==this.wrap(),k="char"!==this.wrap()&&j,l=this.ellipsis(),m="\u2026",n=this.getDefaultTextPartFormat(),o=l?this.measurePart({text:m,style:_objectSpread(_objectSpread({},n),Array.isArray(this.text())&&(null===(a=this.text().slice(-1))||void 0===a?void 0:a.style))}):0,p=function(a,d){return Array.isArray(b.text())&&0<b.text().length?b.text().filter(function(){var b=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{},c=b.startIndex,e=void 0===c?0:c,f=b.endIndex,g=void 0===f?1/0:f;return a>=e&&a<=g||d>=e&&d<=g||e>=a&&g<=d}).map(function(){var b=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{},c=b.textContent,e=b.style,f=void 0===e?{}:e,g=b.startIndex,h=void 0===g?0:g;return{style:_objectSpread(_objectSpread({},n),f),width:0,text:c.replaceAll("\n","").substring(a-h,d-h)}}):[{text:c.replaceAll("\n","").slice(a,d),style:n,width:0}]},q=function(a){return a.reduce(function(a,c){return c.width=b.measurePart(c),a+c.width},0)},r=function(a,b){return q(p(a,b))},s=function(a){return Math.max.apply(Math,_toConsumableArray(a.map(function(a){var c;return(null!==(c=a.style.fontSize)&&void 0!==c?c:b.fontSize)*b.lineHeight()})))},t=0,u=0,v=function(a,c,d){if(g&&t+c>f){if("top"===b.verticalAlign())return;b.visibleLinesStartIndex+=1}b.textLines.push({width:a,parts:d.map(function(a,c){return a.text=0===c?a.text.replace(/^\s{1}/,""):a.text,a.width=0===a.width?b.measurePart(a):a.width,a}),totalHeight:c})},w=d.length,x=0;x<w;x+=1){var y=d[x],z=y,A=r(u,u+z.length),B=void 0;if("auto"!==e&&void 0!==e&&A>e)for(var C=0;0<z.length;){for(var D=0,E=z.length,F="",G=0;D<E;){var H=D+E>>>1,I=z.slice(0,H+1),J=r(u+C,u+C+H+1)+o;J<=e?(D=H+1,F=I,G=J):E=H}if(F){if(k){var K=void 0,L=z[F.length],M=" "===L||"-"===L;K=M&&G<=e?F.length:Math.max(F.lastIndexOf(" "),F.lastIndexOf("-"))+1,0<K&&(D=K,F=F.slice(0,D),G=r(u+C,u+C+D))}var N=p(u+C,u+C+D).filter(function(a){return a.text});if(B=s(N),v(q(N),B,N),t+=B,!j||h&&t+B>f){var O=this.textLines[this.textLines.length-1];if(O&&l){var P=O.parts[O.parts.length-1],Q=this.measurePart(_objectSpread(_objectSpread({},P),{},{text:"".concat(P.text).concat(m)})),R=Q<e;R||(P.text=P.text.slice(0,P.text.length-3)),O.parts.splice(O.parts.length-1,1),O.parts.push(_objectSpread(_objectSpread({},P),{},{width:Q,text:"".concat(P.text).concat(m)}))}break}if(z=z.slice(D),C+=D,0<z.length){var S=p(u+C,u+C+z.length);if(A=q(S),A<=e&&S){var T=s(S);v(A,T,S),t+=T;break}}}else break}else{var U=p(u,u+z.length);B=s(U),v(A,B,U)}if(h&&t+B>f)break;u+=y.length,t+=B}var V="middle"===this.verticalAlign(),W=V?this.visibleLinesStartIndex/2:this.visibleLinesStartIndex;this.linesHeight=this.textLines.slice(Math.floor(W),V?this.textLines.length-Math.ceil(W):void 0).reduce(function(a,b){return a+b.totalHeight},0),this.linesWidth=Math.max.apply(Math,_toConsumableArray(this.textLines.map(function(a){return a.width},0)))}},{key:"getHeight",value:function(){var a="auto"===this.attrs.height||void 0===this.attrs.height;return a?this.linesHeight+2*this.padding():this.attrs.height}},{key:"getWidth",value:function(){var a="auto"===this.attrs.width||void 0===this.attrs.width;return a?this.linesWidth+2*this.padding():this.attrs.width}},{key:"_sceneFunc",value:function(a){var b,c=this;if(0!==this.text().length&&0!==(null===(b=this.textLines)||void 0===b?void 0:b.length)){var d=this.getWidth(),e=this.getHeight();a.setAttr("textBaseline","middle"),a.setAttr("textAlign","left");var f="middle"===this.verticalAlign(),g=this.padding(),h=0;f?h=(e-this.linesHeight-2*g)/2:"bottom"===this.verticalAlign()&&(h=e-this.linesHeight-2*g),a.translate(g,h+g);var i=f?this.visibleLinesStartIndex/2:this.visibleLinesStartIndex,j=this.textLines.slice(Math.floor(i),f?this.textLines.length-Math.ceil(i):void 0),k=this.textLines[0].totalHeight/2,l=0;j.forEach(function(b){var e=l===j.length-1,f=0;a.save(),"right"===c.align()?f+=d-b.width-2*g:"center"===c.align()&&(f+=(d-b.width-2*g)/2),b.parts.forEach(function(h){var i,m,n=toPrecisedFloat(h.style.baselineShift*c.scaleFormatDimensionsBy(),2);if(null!==(i=h.style.textDecoration)&&void 0!==i&&i.includes("underline")){a.save(),a.beginPath(),a.moveTo(f,k+0+Math.round(h.style.fontSize/2)-n);var o=h.text.split(" ").length-1,p="justify"===c.align()&&e&&!(0===o)?d-2*g:h.width;a.lineTo(f+Math.round(p),k+0+Math.round(h.style.fontSize/2)-n),a.lineWidth=h.style.fontSize/15,a.strokeStyle=h.style.fill,a.stroke(),a.restore()}if(null!==(m=h.style.textDecoration)&&void 0!==m&&m.includes("line-through")){a.save(),a.beginPath(),a.moveTo(f,k+0-n);var q=h.text.split(" ").length-1,r="justify"===c.align()&&e&&!(0===q)?d-2*g:h.width;a.lineTo(f+Math.round(r),k+0-n),a.lineWidth=h.style.fontSize/15,a.strokeStyle=h.style.fill,a.stroke(),a.restore()}if(c.fill(h.style.fill),a.setAttr("font",c.formatFont(h)),0!==h.style.letterSpacing||"justify"===c.align())for(var s,t=h.text.split(" ").length-1,u=Array.from(h.text),v=0;v<u.length;v+=1)s=u[v]," "===s&&l!==j.length-1&&"justify"===c.align()&&(f+=(d-2*g-b.width)/t),c.drawState={x:f,y:k+0-n,text:s},a.fillStrokeShape(c),f+=c.measurePart(_objectSpread(_objectSpread({},h),{},{text:s}));else c.drawState={x:f,y:k+0-n,text:h.text},a.fillStrokeShape(c),f+=h.width}),a.restore(),"undefined"!=typeof j[l+1]&&(k+=j[l+1].totalHeight),l+=1})}}},{key:"_fillFunc",value:function(a){a.fillText(this.drawState.text,this.drawState.x,this.drawState.y)}},{key:"_strokeFunc",value:function(a){a.strokeText(this.drawState.text,this.drawState.x,this.drawState.y,void 0)}},{key:"_hitFunc",value:function(a){a.beginPath(),a.rect(0,0,this.getWidth(),this.getHeight()),a.closePath(),a.fillStrokeShape(this)}},{key:"getStrokeScaleEnabled",value:function(){return!0}}])}(Shape);FormattedText.prototype.className="FormattedText",_registerNode(FormattedText),Factory.overWriteSetter(FormattedText,"width",getNumberOrAutoValidator()),Factory.overWriteSetter(FormattedText,"height",getNumberOrAutoValidator()),Factory.addGetterSetter(FormattedText,"padding",0,getNumberValidator()),Factory.addGetterSetter(FormattedText,"align","left"),Factory.addGetterSetter(FormattedText,"verticalAlign","top"),Factory.addGetterSetter(FormattedText,"lineHeight",1,getNumberValidator()),Factory.addGetterSetter(FormattedText,"wrap","word"),Factory.addGetterSetter(FormattedText,"ellipsis",!1,getBooleanValidator()),Factory.addGetterSetter(FormattedText,"letterSpacing",0,getNumberValidator()),Factory.addGetterSetter(FormattedText,"text"),Factory.addGetterSetter(FormattedText,"fontFamily","Arial"),Factory.addGetterSetter(FormattedText,"fontSize",16,getNumberValidator()),Factory.addGetterSetter(FormattedText,"fontVariant","normal"),Factory.addGetterSetter(FormattedText,"fontStyle","normal"),Factory.addGetterSetter(FormattedText,"fontWeight","normal"),Factory.addGetterSetter(FormattedText,"scaleFormatDimensionsBy",1);
import _toConsumableArray from"@babel/runtime/helpers/toConsumableArray";import _defineProperty from"@babel/runtime/helpers/defineProperty";import _classCallCheck from"@babel/runtime/helpers/classCallCheck";import _createClass from"@babel/runtime/helpers/createClass";import _possibleConstructorReturn from"@babel/runtime/helpers/possibleConstructorReturn";import _getPrototypeOf from"@babel/runtime/helpers/getPrototypeOf";import _inherits from"@babel/runtime/helpers/inherits";function ownKeys(a,b){var c=Object.keys(a);if(Object.getOwnPropertySymbols){var d=Object.getOwnPropertySymbols(a);b&&(d=d.filter(function(b){return Object.getOwnPropertyDescriptor(a,b).enumerable})),c.push.apply(c,d)}return c}function _objectSpread(a){for(var b,c=1;c<arguments.length;c++)b=null==arguments[c]?{}:arguments[c],c%2?ownKeys(Object(b),!0).forEach(function(c){_defineProperty(a,c,b[c])}):Object.getOwnPropertyDescriptors?Object.defineProperties(a,Object.getOwnPropertyDescriptors(b)):ownKeys(Object(b)).forEach(function(c){Object.defineProperty(a,c,Object.getOwnPropertyDescriptor(b,c))});return a}function _callSuper(a,b,c){return b=_getPrototypeOf(b),_possibleConstructorReturn(a,_isNativeReflectConstruct()?Reflect.construct(b,c||[],_getPrototypeOf(a).constructor):b.apply(a,c))}function _isNativeReflectConstruct(){try{var a=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(a){}return(_isNativeReflectConstruct=function(){return!!a})()}import{Factory}from"konva/lib/Factory";import{_registerNode}from"konva/lib/Global";import{Shape}from"konva/lib/Shape";import{Util}from"konva/lib/Util";import{getNumberOrAutoValidator,getNumberValidator,getBooleanValidator}from"konva/lib/Validators";import toPrecisedFloat from"../../utils/toPrecisedFloat";var dummyContext;function getDummyContext(){return dummyContext?dummyContext:(dummyContext=Util.createCanvasElement().getContext("2d"),dummyContext)}function normalizeFontFamily(a){return a?a.split(",").map(function(a){a=a.trim();var b=0<=a.indexOf(" "),c=0<=a.indexOf("\"")||0<=a.indexOf("'");return b&&!c&&(a="\"".concat(a,"\"")),a}).join(", "):""}var NORMAL="normal",CHANGEABLE_ATTRS=["padding","wrap","lineHeight","letterSpacing","width","height","text","fontSize","fill","fontWeight","fontStyle","fontFamily","verticalAlign"];export var FormattedText=function(a){function b(a){var c;return _classCallCheck(this,b),c=_callSuper(this,b,[a]),CHANGEABLE_ATTRS.forEach(function(a){c.on("".concat(a,"Change.konva"),c.computeTextParts)}),c.computeTextParts(),c}return _inherits(b,a),_createClass(b,[{key:"formatFont",value:function(a){var b,c=this.getDefaultTextPartFormat();return"".concat(a.style.fontStyle||c.fontStyle," ").concat(a.style.fontWeight||c.fontWeight," ").concat(a.style.fontVariant||c.fontVariant," ").concat(null!==(b=a.style.fontSize)&&void 0!==b?b:c.fontSize,"px ").concat(normalizeFontFamily(a.style.fontFamily||c.fontFamily))}},{key:"measurePart",value:function(a){var b=getDummyContext(),c=toPrecisedFloat((a.style.letterSpacing||1)*this.scaleFormatDimensionsBy(),2);b.save(),b.font=this.formatFont(a),b.letterSpacing="".concat(c,"px");var d=b.measureText(a.text),e=d.width;return b.restore(),e}},{key:"getDefaultTextPartFormat",value:function(){return{fontSize:this.fontSize(),fill:this.fill(),fontWeight:this.fontWeight(),fontStyle:this.fontStyle(),baselineShift:0,letterSpacing:this.letterSpacing(),fontVariant:this.fontVariant(),fontFamily:this.fontFamily()}}},{key:"computeTextParts",value:function(){var a,b=this;this.textLines=[],this.visibleLinesStartIndex=0;for(var c=Array.isArray(this.text())?this.text().map(function(){var a=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{},b=a.textContent;return b}).join(""):this.text(),d=c.split("\n"),e=this.attrs.width,f=this.attrs.height,g="auto"!==f&&void 0!==f,h=g&&"top"===this.verticalAlign(),j="none"!==this.wrap(),k="char"!==this.wrap()&&j,l=this.ellipsis(),m="\u2026",n=this.getDefaultTextPartFormat(),o=l?this.measurePart({text:m,style:_objectSpread(_objectSpread({},n),Array.isArray(this.text())&&(null===(a=this.text().slice(-1))||void 0===a?void 0:a.style))}):0,p=function(a,d){return Array.isArray(b.text())&&0<b.text().length?b.text().filter(function(){var b=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{},c=b.startIndex,e=void 0===c?0:c,f=b.endIndex,g=void 0===f?1/0:f;return a>=e&&a<=g||d>=e&&d<=g||e>=a&&g<=d}).map(function(){var b=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{},c=b.textContent,e=b.style,f=void 0===e?{}:e,g=b.startIndex,h=void 0===g?0:g;return{style:_objectSpread(_objectSpread({},n),f),width:0,text:c.replaceAll("\n","").substring(a-h,d-h)}}):[{text:c.replaceAll("\n","").slice(a,d),style:n,width:0}]},q=function(a){return a.reduce(function(a,c){return c.width=b.measurePart(c),a+c.width},0)},r=function(a,b){return q(p(a,b))},s=function(a){return Math.max.apply(Math,_toConsumableArray(a.map(function(a){var c;return(null!==(c=a.style.fontSize)&&void 0!==c?c:b.fontSize)*b.lineHeight()})))},t=0,u=0,v=function(a,c,d){if(g&&t+c>f){if("top"===b.verticalAlign())return;b.visibleLinesStartIndex+=1}b.textLines.push({width:a,parts:d.map(function(a,c){return a.text=0===c?a.text.replace(/^\s{1}/,""):a.text,a.width=0===a.width?b.measurePart(a):a.width,a}),totalHeight:c})},w=d.length,x=0;x<w;x+=1){var y=d[x],z=y,A=r(u,u+z.length),B=void 0;if("auto"!==e&&void 0!==e&&A>e)for(var C=0;0<z.length;){for(var D=0,E=z.length,F="",G=0;D<E;){var H=D+E>>>1,I=z.slice(0,H+1),J=r(u+C,u+C+H+1)+o;J<=e?(D=H+1,F=I,G=J):E=H}if(F){if(k){var K=void 0,L=z[F.length],M=" "===L||"-"===L;K=M&&G<=e?F.length:Math.max(F.lastIndexOf(" "),F.lastIndexOf("-"))+1,0<K&&(D=K,F=F.slice(0,D),G=r(u+C,u+C+D))}var N=p(u+C,u+C+D).filter(function(a){return a.text});if(B=s(N),v(q(N),B,N),t+=B,!j||h&&t+B>f){var O=this.textLines[this.textLines.length-1];if(O&&l){var P=O.parts[O.parts.length-1],Q=this.measurePart(_objectSpread(_objectSpread({},P),{},{text:"".concat(P.text).concat(m)})),R=Q<e;R||(P.text=P.text.slice(0,P.text.length-3)),O.parts.splice(O.parts.length-1,1),O.parts.push(_objectSpread(_objectSpread({},P),{},{width:Q,text:"".concat(P.text).concat(m)}))}break}if(z=z.slice(D),C+=D,0<z.length){var S=p(u+C,u+C+z.length);if(A=q(S),A<=e&&S){var T=s(S);v(A,T,S),t+=T;break}}}else break}else{var U=p(u,u+z.length);B=s(U),v(A,B,U)}if(h&&t+B>f)break;u+=y.length,t+=B}var V="middle"===this.verticalAlign(),W=V?this.visibleLinesStartIndex/2:this.visibleLinesStartIndex;this.linesHeight=this.textLines.slice(Math.floor(W),V?this.textLines.length-Math.ceil(W):void 0).reduce(function(a,b){return a+b.totalHeight},0),this.linesWidth=Math.max.apply(Math,_toConsumableArray(this.textLines.map(function(a){return a.width},0)))}},{key:"getHeight",value:function(){var a="auto"===this.attrs.height||void 0===this.attrs.height;return a?this.linesHeight+2*this.padding():this.attrs.height}},{key:"getWidth",value:function(){var a="auto"===this.attrs.width||void 0===this.attrs.width;return a?this.linesWidth+2*this.padding():this.attrs.width}},{key:"_sceneFunc",value:function(a){var b,c=this;if(0!==this.text().length&&0!==(null===(b=this.textLines)||void 0===b?void 0:b.length)){var d=this.getWidth(),e=this.getHeight();a.setAttr("textBaseline","alphabetic"),a.setAttr("textAlign","left");var f="middle"===this.verticalAlign(),g=this.padding(),h=0;f?h=(e-this.linesHeight-2*g)/2:"bottom"===this.verticalAlign()&&(h=e-this.linesHeight-2*g),a.translate(g,h+g);var i=f?this.visibleLinesStartIndex/2:this.visibleLinesStartIndex,j=this.textLines.slice(Math.floor(i),f?this.textLines.length-Math.ceil(i):void 0),k=this.textLines[0].totalHeight,l=0;j.forEach(function(b){var e=l===j.length-1,f=0;a.save(),"right"===c.align()?f+=d-b.width-2*g:"center"===c.align()&&(f+=(d-b.width-2*g)/2),b.parts.forEach(function(h){var i,m,n=toPrecisedFloat(h.style.baselineShift*c.scaleFormatDimensionsBy(),2);if(null!==(i=h.style.textDecoration)&&void 0!==i&&i.includes("underline")){a.save(),a.beginPath(),a.moveTo(f,k+0+Math.round(h.style.fontSize/2)-n);var o=h.text.split(" ").length-1,p="justify"===c.align()&&e&&!(0===o)?d-2*g:h.width;a.lineTo(f+Math.round(p),k+0+Math.round(h.style.fontSize/2)-n),a.lineWidth=h.style.fontSize/15,a.strokeStyle=h.style.fill,a.stroke(),a.restore()}if(null!==(m=h.style.textDecoration)&&void 0!==m&&m.includes("line-through")){a.save(),a.beginPath(),a.moveTo(f,k+0-n);var q=h.text.split(" ").length-1,r="justify"===c.align()&&e&&!(0===q)?d-2*g:h.width;a.lineTo(f+Math.round(r),k+0-n),a.lineWidth=h.style.fontSize/15,a.strokeStyle=h.style.fill,a.stroke(),a.restore()}if(c.fill(h.style.fill),a.setAttr("font",c.formatFont(h)),0!==h.style.letterSpacing||"justify"===c.align())for(var s,t=h.text.split(" ").length-1,u=Array.from(h.text),v=0;v<u.length;v+=1)s=u[v]," "===s&&l!==j.length-1&&"justify"===c.align()&&(f+=(d-2*g-b.width)/t),c.drawState={x:f,y:k+0-n,text:s},a.fillStrokeShape(c),f+=c.measurePart(_objectSpread(_objectSpread({},h),{},{text:s}));else c.drawState={x:f,y:k+0-n,text:h.text},a.fillStrokeShape(c),f+=h.width}),a.restore(),"undefined"!=typeof j[l+1]&&(k+=j[l+1].totalHeight),l+=1})}}},{key:"_fillFunc",value:function(a){a.fillText(this.drawState.text,this.drawState.x,this.drawState.y)}},{key:"_strokeFunc",value:function(a){a.strokeText(this.drawState.text,this.drawState.x,this.drawState.y,void 0)}},{key:"_hitFunc",value:function(a){a.beginPath(),a.rect(0,0,this.getWidth(),this.getHeight()),a.closePath(),a.fillStrokeShape(this)}},{key:"getStrokeScaleEnabled",value:function(){return!0}}])}(Shape);FormattedText.prototype.className="FormattedText",_registerNode(FormattedText),Factory.overWriteSetter(FormattedText,"width",getNumberOrAutoValidator()),Factory.overWriteSetter(FormattedText,"height",getNumberOrAutoValidator()),Factory.addGetterSetter(FormattedText,"padding",0,getNumberValidator()),Factory.addGetterSetter(FormattedText,"align","left"),Factory.addGetterSetter(FormattedText,"verticalAlign","top"),Factory.addGetterSetter(FormattedText,"lineHeight",1,getNumberValidator()),Factory.addGetterSetter(FormattedText,"wrap","word"),Factory.addGetterSetter(FormattedText,"ellipsis",!1,getBooleanValidator()),Factory.addGetterSetter(FormattedText,"letterSpacing",0,getNumberValidator()),Factory.addGetterSetter(FormattedText,"text"),Factory.addGetterSetter(FormattedText,"fontFamily","Arial"),Factory.addGetterSetter(FormattedText,"fontSize",16,getNumberValidator()),Factory.addGetterSetter(FormattedText,"fontVariant","normal"),Factory.addGetterSetter(FormattedText,"fontStyle","normal"),Factory.addGetterSetter(FormattedText,"fontWeight","normal"),Factory.addGetterSetter(FormattedText,"scaleFormatDimensionsBy",1);
{
"name": "react-filerobot-image-editor",
"version": "5.0.0-beta.41",
"version": "5.0.0-beta.42",
"license": "MIT",

@@ -47,3 +47,3 @@ "author": "Scaleflex",

},
"gitHead": "9ee61b5fee92b0b4a4291c81dc4c5e700a457577"
"gitHead": "525dda14e29985862b0c3c2a36e7eff29f6fc9f3"
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc