@threedddplus/logoeditor 0.0.21 → 0.0.22

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -3149,8 +3149,12 @@ var converterSlice = function converterSlice(set, get) {
3149
3149
  });
3150
3150
  var topColors = sortedFillColors.slice(0, colorValue);
3151
3151
  topColors.map(function (e) {
3152
- var _C = get().RGBToHex(e);
3153
- _Fills.push(_C);
3152
+ if (e.search("#") === -1) {
3153
+ var _C = get().RGBToHex(e);
3154
+ _Fills.push(_C);
3155
+ } else {
3156
+ _Fills.push(e);
3157
+ }
3154
3158
  });
3155
3159
  //@ts-ignore
3156
3160
  set({
@@ -3289,16 +3293,30 @@ var converterSlice = function converterSlice(set, get) {
3289
3293
  }
3290
3294
  return tiffConvert;
3291
3295
  }(),
3292
- imageToSVG: function imageToSVG(data) {
3296
+ imageToSVG: function imageToSVG(data, isSVG) {
3297
+ if (isSVG === void 0) {
3298
+ isSVG = false;
3299
+ }
3293
3300
  use3dddPlus.setState({
3294
3301
  uploadImageModalDisplay: true
3295
3302
  });
3296
- ImageTracer.imageToSVG(data, function (svgstr) {
3297
- use3dddPlus.setState({
3298
- imageData: svgstr
3303
+ if (isSVG) {
3304
+ var reader = new FileReader();
3305
+ reader.onload = function (e) {
3306
+ use3dddPlus.setState({
3307
+ imageData: e.target.result
3308
+ });
3309
+ processImage(e.target.result, 8);
3310
+ };
3311
+ reader.readAsText(data);
3312
+ } else {
3313
+ ImageTracer.imageToSVG(data, function (svgstr) {
3314
+ use3dddPlus.setState({
3315
+ imageData: svgstr
3316
+ });
3317
+ processImage(svgstr, 8);
3299
3318
  });
3300
- processImage(svgstr, 8);
3301
- });
3319
+ }
3302
3320
  },
3303
3321
  refreshColor: function refreshColor(colorValue) {
3304
3322
  processImage(use3dddPlus.getState().imageData, colorValue);
@@ -4241,16 +4259,18 @@ var canvas = function canvas() {
4241
4259
  var canvasRef = React.useRef(null);
4242
4260
  var resizeCanvas = function resizeCanvas() {
4243
4261
  var canvas = use3dddPlus.getState().fabricCanvas;
4244
- var outerCanvasContainer = document.getElementById('fabCanvas').parentElement;
4245
- var containerWidth = outerCanvasContainer.clientWidth;
4246
- var scale = containerWidth / canvas.getWidth();
4247
- var zoom = canvas.getZoom() * scale;
4248
- canvas.setWidth(containerWidth);
4249
- //@ts-ignore
4250
- canvas.setHeight(parseInt(outerCanvasContainer.clientHeight));
4251
- console.log('--->', canvas.getHeight(), canvas.getHeight());
4252
- canvas.setViewportTransform([zoom, 0, 0, zoom, 0, 0]);
4253
- canvas.renderAll();
4262
+ if (document.getElementById('fabCanvas')) {
4263
+ var outerCanvasContainer = document.getElementById('fabCanvas').parentElement;
4264
+ var containerWidth = outerCanvasContainer.clientWidth;
4265
+ var scale = containerWidth / canvas.getWidth();
4266
+ var zoom = canvas.getZoom() * scale;
4267
+ canvas.setWidth(containerWidth);
4268
+ //@ts-ignore
4269
+ canvas.setHeight(parseInt(outerCanvasContainer.clientHeight));
4270
+ console.log('--->', canvas.getHeight(), canvas.getHeight());
4271
+ canvas.setViewportTransform([zoom, 0, 0, zoom, 0, 0]);
4272
+ canvas.renderAll();
4273
+ }
4254
4274
  };
4255
4275
  React__default.useEffect(function () {
4256
4276
  var canv = initCanvas();
@@ -4405,6 +4425,7 @@ var FileUploadButton = function FileUploadButton(_ref) {
4405
4425
  if (selectedFile) {
4406
4426
  onFileSelect(selectedFile);
4407
4427
  }
4428
+ fileInputRef.current.value = null;
4408
4429
  };
4409
4430
  var handleDragEnter = function handleDragEnter(event) {
4410
4431
  event.preventDefault();
@@ -4749,17 +4770,19 @@ var PopUpCanvas = function PopUpCanvas() {
4749
4770
  setIsRefresh(true);
4750
4771
  };
4751
4772
  var resizeCanvas = function resizeCanvas() {
4752
- var canvas = use3dddPlus.getState().popupCanv;
4753
- var outerCanvasContainer = document.getElementById('imageCanvas').parentElement;
4754
- console.log(outerCanvasContainer);
4755
- var containerWidth = outerCanvasContainer.clientWidth;
4756
- var scale = containerWidth / canvas.getWidth();
4757
- var zoom = canvas.getZoom() * scale;
4758
- canvas.setWidth(containerWidth);
4759
- //@ts-ignore
4760
- canvas.setHeight(parseInt(outerCanvasContainer.clientHeight));
4761
- canvas.setViewportTransform([zoom, 0, 0, zoom, 0, 0]);
4762
- canvas.renderAll();
4773
+ if (document.getElementById('imageCanvas')) {
4774
+ var _canvas = use3dddPlus.getState().popupCanv;
4775
+ var outerCanvasContainer = document.getElementById('imageCanvas').parentElement;
4776
+ console.log(outerCanvasContainer);
4777
+ var containerWidth = outerCanvasContainer.clientWidth;
4778
+ var scale = containerWidth / _canvas.getWidth();
4779
+ var zoom = _canvas.getZoom() * scale;
4780
+ _canvas.setWidth(containerWidth);
4781
+ //@ts-ignore
4782
+ _canvas.setHeight(parseInt(outerCanvasContainer.clientHeight));
4783
+ _canvas.setViewportTransform([zoom, 0, 0, zoom, 0, 0]);
4784
+ _canvas.renderAll();
4785
+ }
4763
4786
  };
4764
4787
  React.useEffect(function () {
4765
4788
  var popupCanv = Initpopup();
@@ -4785,11 +4808,18 @@ var PopUpCanvas = function PopUpCanvas() {
4785
4808
  });
4786
4809
  });
4787
4810
  }, []);
4788
- // const popupCanvasCancel = () => {
4789
- // use3dddPlus.setState({ uploadImageModalDisplay: false });
4790
- // console.log(popupCanvas.getObjects()[0]);
4791
- // popupCanvas.remove(...popupCanvas.getObjects());
4792
- // };
4811
+ var popupCanvasCancel = function popupCanvasCancel() {
4812
+ use3dddPlus.setState({
4813
+ uploadImageModalDisplay: false
4814
+ });
4815
+ popupCanvas.remove.apply(popupCanvas, popupCanvas.getObjects());
4816
+ use3dddPlus.setState({
4817
+ colorFill: {}
4818
+ });
4819
+ use3dddPlus.setState({
4820
+ popupCanvasStoreHistory: []
4821
+ });
4822
+ };
4793
4823
  var popupCanvasContinue = function popupCanvasContinue() {
4794
4824
  //@ts-ignore
4795
4825
  use3dddPlus.setState({
@@ -5069,12 +5099,19 @@ var PopUpCanvas = function PopUpCanvas() {
5069
5099
  size: "1rem"
5070
5100
  })));
5071
5101
  })), React__default.createElement("div", {
5072
- className: " flex flex-col"
5102
+ className: " flex flex-col content"
5073
5103
  }, React__default.createElement("button", {
5074
5104
  type: "button",
5075
5105
  onClick: popupCanvasContinue,
5076
5106
  className: "mt-3 inline-flex w-full justify-center bg-white px-[110px] py-2 text-sm font-medium text-[#E11A38] shadow-sm ring-1 ring-inset ring-[#E11A38] hover:bg-gray-50 sm:mt-0 sm:w-auto"
5077
- }, "Continue"))))))))));
5107
+ }, "Continue"), React__default.createElement("button", {
5108
+ type: "button",
5109
+ onClick: popupCanvasCancel,
5110
+ className: "mt-3 inline-flex w-full justify-center bg-white px-[110px] py-2 text-sm font-medium text-[#E11A38] shadow-sm ring-1 ring-inset ring-[#E11A38] hover:bg-gray-50 sm:mt-0 sm:w-auto",
5111
+ style: {
5112
+ marginTop: '10px'
5113
+ }
5114
+ }, "Cancel"))))))))));
5078
5115
  };
5079
5116
 
5080
5117
  var UploadLogo = function UploadLogo() {
@@ -5102,38 +5139,44 @@ var UploadLogo = function UploadLogo() {
5102
5139
  while (1) switch (_context.prev = _context.next) {
5103
5140
  case 0:
5104
5141
  // canvas.discardActiveObject();
5105
- ext = data.name.substring(data.name.lastIndexOf('.') + 1); // if (ext === 'svg') {
5106
- // imageToSVG(data);
5107
- // } else
5142
+ ext = data.name.substring(data.name.lastIndexOf('.') + 1);
5143
+ if (!(ext === 'svg')) {
5144
+ _context.next = 5;
5145
+ break;
5146
+ }
5147
+ imageToSVG(data, true);
5148
+ _context.next = 21;
5149
+ break;
5150
+ case 5:
5108
5151
  if (!(ext === 'pdf')) {
5109
- _context.next = 8;
5152
+ _context.next = 12;
5110
5153
  break;
5111
5154
  }
5112
- _context.next = 4;
5155
+ _context.next = 8;
5113
5156
  return pdfConverter(data);
5114
- case 4:
5157
+ case 8:
5115
5158
  pdfData = _context.sent;
5116
5159
  imageToSVG(pdfData);
5117
- _context.next = 17;
5160
+ _context.next = 21;
5118
5161
  break;
5119
- case 8:
5162
+ case 12:
5120
5163
  if (!(ext === 'tif' || ext === 'tiff')) {
5121
- _context.next = 15;
5164
+ _context.next = 19;
5122
5165
  break;
5123
5166
  }
5124
- _context.next = 11;
5167
+ _context.next = 15;
5125
5168
  return tiffConvert(data);
5126
- case 11:
5169
+ case 15:
5127
5170
  tiffData = _context.sent;
5128
5171
  imageToSVG(tiffData);
5129
- _context.next = 17;
5172
+ _context.next = 21;
5130
5173
  break;
5131
- case 15:
5174
+ case 19:
5132
5175
  objectURL = URL.createObjectURL(data);
5133
5176
  imageToSVG(objectURL);
5134
- case 17:
5177
+ case 21:
5135
5178
  setSelectedFile(null);
5136
- case 18:
5179
+ case 22:
5137
5180
  case "end":
5138
5181
  return _context.stop();
5139
5182
  }