ed3bc04fcf992ca0eec87551ed72738f.json 6.23 KB
{"ast":null,"code":"/**\r\n * @author NHN. FE Development Team <dl_javascript@nhn.com>\r\n * @fileoverview Selection modification helper\r\n */\nimport { extend } from 'tui-code-snippet/src/js/object';\n/**\r\n * Cached selection's info\r\n * @type {Array}\r\n * @private\r\n */\n\nlet cachedUndoDataForChangeDimension = null;\n/**\r\n * Set cached undo data\r\n * @param {Array} undoData - selection object\r\n * @private\r\n */\n\nexport function setCachedUndoDataForDimension(undoData) {\n  cachedUndoDataForChangeDimension = undoData;\n}\n/**\r\n * Get cached undo data\r\n * @returns {Object} cached undo data\r\n * @private\r\n */\n\nexport function getCachedUndoDataForDimension() {\n  return cachedUndoDataForChangeDimension;\n}\n/**\r\n * Make undo data\r\n * @param {fabric.Object} obj - selection object\r\n * @param {Function} undoDatumMaker - make undo datum\r\n * @returns {Array} undoData\r\n * @private\r\n */\n\nexport function makeSelectionUndoData(obj, undoDatumMaker) {\n  let undoData;\n\n  if (obj.type === 'activeSelection') {\n    undoData = obj.getObjects().map(item => {\n      const {\n        angle,\n        left,\n        top,\n        scaleX,\n        scaleY,\n        width,\n        height\n      } = item;\n      obj.realizeTransform(item);\n      const result = undoDatumMaker(item);\n      item.set({\n        angle,\n        left,\n        top,\n        width,\n        height,\n        scaleX,\n        scaleY\n      });\n      return result;\n    });\n  } else {\n    undoData = [undoDatumMaker(obj)];\n  }\n\n  return undoData;\n}\n/**\r\n * Make undo datum\r\n * @param {number} id - object id\r\n * @param {fabric.Object} obj - selection object\r\n * @param {boolean} isSelection - whether or not object is selection\r\n * @returns {Object} undo datum\r\n * @private\r\n */\n\nexport function makeSelectionUndoDatum(id, obj, isSelection) {\n  return isSelection ? {\n    id,\n    width: obj.width,\n    height: obj.height,\n    top: obj.top,\n    left: obj.left,\n    angle: obj.angle,\n    scaleX: obj.scaleX,\n    scaleY: obj.scaleY\n  } : extend({\n    id\n  }, obj);\n}","map":{"version":3,"sources":["C:/Users/kkwan_000/Desktop/git/2017110269/minsung/src/js/helper/selectionModifyHelper.js"],"names":["extend","cachedUndoDataForChangeDimension","setCachedUndoDataForDimension","undoData","getCachedUndoDataForDimension","makeSelectionUndoData","obj","undoDatumMaker","type","getObjects","map","item","angle","left","top","scaleX","scaleY","width","height","realizeTransform","result","set","makeSelectionUndoDatum","id","isSelection"],"mappings":"AAAA;AACA;AACA;AACA;AAEA,SAASA,MAAT,QAAuB,gCAAvB;AAEA;AACA;AACA;AACA;AACA;;AACA,IAAIC,gCAAgC,GAAG,IAAvC;AAEA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASC,6BAAT,CAAuCC,QAAvC,EAAiD;AACtDF,EAAAA,gCAAgC,GAAGE,QAAnC;AACD;AAED;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASC,6BAAT,GAAyC;AAC9C,SAAOH,gCAAP;AACD;AAED;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASI,qBAAT,CAA+BC,GAA/B,EAAoCC,cAApC,EAAoD;AACzD,MAAIJ,QAAJ;;AAEA,MAAIG,GAAG,CAACE,IAAJ,KAAa,iBAAjB,EAAoC;AAClCL,IAAAA,QAAQ,GAAGG,GAAG,CAACG,UAAJ,GAAiBC,GAAjB,CAAsBC,IAAD,IAAU;AACxC,YAAM;AAAEC,QAAAA,KAAF;AAASC,QAAAA,IAAT;AAAeC,QAAAA,GAAf;AAAoBC,QAAAA,MAApB;AAA4BC,QAAAA,MAA5B;AAAoCC,QAAAA,KAApC;AAA2CC,QAAAA;AAA3C,UAAsDP,IAA5D;AAEAL,MAAAA,GAAG,CAACa,gBAAJ,CAAqBR,IAArB;AACA,YAAMS,MAAM,GAAGb,cAAc,CAACI,IAAD,CAA7B;AAEAA,MAAAA,IAAI,CAACU,GAAL,CAAS;AACPT,QAAAA,KADO;AAEPC,QAAAA,IAFO;AAGPC,QAAAA,GAHO;AAIPG,QAAAA,KAJO;AAKPC,QAAAA,MALO;AAMPH,QAAAA,MANO;AAOPC,QAAAA;AAPO,OAAT;AAUA,aAAOI,MAAP;AACD,KAjBU,CAAX;AAkBD,GAnBD,MAmBO;AACLjB,IAAAA,QAAQ,GAAG,CAACI,cAAc,CAACD,GAAD,CAAf,CAAX;AACD;;AAED,SAAOH,QAAP;AACD;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASmB,sBAAT,CAAgCC,EAAhC,EAAoCjB,GAApC,EAAyCkB,WAAzC,EAAsD;AAC3D,SAAOA,WAAW,GACd;AACED,IAAAA,EADF;AAEEN,IAAAA,KAAK,EAAEX,GAAG,CAACW,KAFb;AAGEC,IAAAA,MAAM,EAAEZ,GAAG,CAACY,MAHd;AAIEJ,IAAAA,GAAG,EAAER,GAAG,CAACQ,GAJX;AAKED,IAAAA,IAAI,EAAEP,GAAG,CAACO,IALZ;AAMED,IAAAA,KAAK,EAAEN,GAAG,CAACM,KANb;AAOEG,IAAAA,MAAM,EAAET,GAAG,CAACS,MAPd;AAQEC,IAAAA,MAAM,EAAEV,GAAG,CAACU;AARd,GADc,GAWdhB,MAAM,CAAC;AAAEuB,IAAAA;AAAF,GAAD,EAASjB,GAAT,CAXV;AAYD","sourcesContent":["/**\r\n * @author NHN. FE Development Team <dl_javascript@nhn.com>\r\n * @fileoverview Selection modification helper\r\n */\r\n\r\nimport { extend } from 'tui-code-snippet/src/js/object';\r\n\r\n/**\r\n * Cached selection's info\r\n * @type {Array}\r\n * @private\r\n */\r\nlet cachedUndoDataForChangeDimension = null;\r\n\r\n/**\r\n * Set cached undo data\r\n * @param {Array} undoData - selection object\r\n * @private\r\n */\r\nexport function setCachedUndoDataForDimension(undoData) {\r\n  cachedUndoDataForChangeDimension = undoData;\r\n}\r\n\r\n/**\r\n * Get cached undo data\r\n * @returns {Object} cached undo data\r\n * @private\r\n */\r\nexport function getCachedUndoDataForDimension() {\r\n  return cachedUndoDataForChangeDimension;\r\n}\r\n\r\n/**\r\n * Make undo data\r\n * @param {fabric.Object} obj - selection object\r\n * @param {Function} undoDatumMaker - make undo datum\r\n * @returns {Array} undoData\r\n * @private\r\n */\r\nexport function makeSelectionUndoData(obj, undoDatumMaker) {\r\n  let undoData;\r\n\r\n  if (obj.type === 'activeSelection') {\r\n    undoData = obj.getObjects().map((item) => {\r\n      const { angle, left, top, scaleX, scaleY, width, height } = item;\r\n\r\n      obj.realizeTransform(item);\r\n      const result = undoDatumMaker(item);\r\n\r\n      item.set({\r\n        angle,\r\n        left,\r\n        top,\r\n        width,\r\n        height,\r\n        scaleX,\r\n        scaleY,\r\n      });\r\n\r\n      return result;\r\n    });\r\n  } else {\r\n    undoData = [undoDatumMaker(obj)];\r\n  }\r\n\r\n  return undoData;\r\n}\r\n\r\n/**\r\n * Make undo datum\r\n * @param {number} id - object id\r\n * @param {fabric.Object} obj - selection object\r\n * @param {boolean} isSelection - whether or not object is selection\r\n * @returns {Object} undo datum\r\n * @private\r\n */\r\nexport function makeSelectionUndoDatum(id, obj, isSelection) {\r\n  return isSelection\r\n    ? {\r\n        id,\r\n        width: obj.width,\r\n        height: obj.height,\r\n        top: obj.top,\r\n        left: obj.left,\r\n        angle: obj.angle,\r\n        scaleX: obj.scaleX,\r\n        scaleY: obj.scaleY,\r\n      }\r\n    : extend({ id }, obj);\r\n}\r\n"]},"metadata":{},"sourceType":"module"}