439a85efe1df040f587ccaa87164ceda.json 5.31 KB
{"ast":null,"code":"/**\r\n * @author NHN Ent. FE Development Team <dl_javascript@nhn.com>\r\n * @fileoverview Add a shape\r\n */\nimport commandFactory from '../factory/command';\nimport { Promise } from '../util';\nimport { componentNames, commandNames } from '../consts';\nconst {\n  SHAPE\n} = componentNames;\nconst command = {\n  name: commandNames.ADD_SHAPE,\n\n  /**\r\n   * Add a shape\r\n   * @param {Graphics} graphics - Graphics instance\r\n   * @param {string} type - Shape type (ex: 'rect', 'circle', 'triangle')\r\n   * @param {Object} options - Shape options\r\n   *      @param {string} [options.fill] - Shape foreground color (ex: '#fff', 'transparent')\r\n   *      @param {string} [options.stroke] - Shape outline color\r\n   *      @param {number} [options.strokeWidth] - Shape outline width\r\n   *      @param {number} [options.width] - Width value (When type option is 'rect', this options can use)\r\n   *      @param {number} [options.height] - Height value (When type option is 'rect', this options can use)\r\n   *      @param {number} [options.rx] - Radius x value (When type option is 'circle', this options can use)\r\n   *      @param {number} [options.ry] - Radius y value (When type option is 'circle', this options can use)\r\n   *      @param {number} [options.left] - Shape x position\r\n   *      @param {number} [options.top] - Shape y position\r\n   *      @param {number} [options.isRegular] - Whether resizing shape has 1:1 ratio or not\r\n   * @returns {Promise}\r\n   */\n  execute(graphics, type, options) {\n    const shapeComp = graphics.getComponent(SHAPE);\n    return shapeComp.add(type, options).then(objectProps => {\n      this.undoData.object = graphics.getObject(objectProps.id);\n      return objectProps;\n    });\n  },\n\n  /**\r\n   * @param {Graphics} graphics - Graphics instance\r\n   * @returns {Promise}\r\n   */\n  undo(graphics) {\n    graphics.remove(this.undoData.object);\n    return Promise.resolve();\n  }\n\n};\ncommandFactory.register(command);\nexport default command;","map":{"version":3,"sources":["C:/Users/kkwan_000/Desktop/git/2017110269/minsung/src/js/command/addShape.js"],"names":["commandFactory","Promise","componentNames","commandNames","SHAPE","command","name","ADD_SHAPE","execute","graphics","type","options","shapeComp","getComponent","add","then","objectProps","undoData","object","getObject","id","undo","remove","resolve","register"],"mappings":"AAAA;AACA;AACA;AACA;AACA,OAAOA,cAAP,MAA2B,oBAA3B;AACA,SAASC,OAAT,QAAwB,SAAxB;AACA,SAASC,cAAT,EAAyBC,YAAzB,QAA6C,WAA7C;AAEA,MAAM;AAAEC,EAAAA;AAAF,IAAYF,cAAlB;AAEA,MAAMG,OAAO,GAAG;AACdC,EAAAA,IAAI,EAAEH,YAAY,CAACI,SADL;;AAGd;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACEC,EAAAA,OAAO,CAACC,QAAD,EAAWC,IAAX,EAAiBC,OAAjB,EAA0B;AAC/B,UAAMC,SAAS,GAAGH,QAAQ,CAACI,YAAT,CAAsBT,KAAtB,CAAlB;AAEA,WAAOQ,SAAS,CAACE,GAAV,CAAcJ,IAAd,EAAoBC,OAApB,EAA6BI,IAA7B,CAAmCC,WAAD,IAAiB;AACxD,WAAKC,QAAL,CAAcC,MAAd,GAAuBT,QAAQ,CAACU,SAAT,CAAmBH,WAAW,CAACI,EAA/B,CAAvB;AAEA,aAAOJ,WAAP;AACD,KAJM,CAAP;AAKD,GA5Ba;;AA6Bd;AACF;AACA;AACA;AACEK,EAAAA,IAAI,CAACZ,QAAD,EAAW;AACbA,IAAAA,QAAQ,CAACa,MAAT,CAAgB,KAAKL,QAAL,CAAcC,MAA9B;AAEA,WAAOjB,OAAO,CAACsB,OAAR,EAAP;AACD;;AArCa,CAAhB;AAwCAvB,cAAc,CAACwB,QAAf,CAAwBnB,OAAxB;AAEA,eAAeA,OAAf","sourcesContent":["/**\r\n * @author NHN Ent. FE Development Team <dl_javascript@nhn.com>\r\n * @fileoverview Add a shape\r\n */\r\nimport commandFactory from '../factory/command';\r\nimport { Promise } from '../util';\r\nimport { componentNames, commandNames } from '../consts';\r\n\r\nconst { SHAPE } = componentNames;\r\n\r\nconst command = {\r\n  name: commandNames.ADD_SHAPE,\r\n\r\n  /**\r\n   * Add a shape\r\n   * @param {Graphics} graphics - Graphics instance\r\n   * @param {string} type - Shape type (ex: 'rect', 'circle', 'triangle')\r\n   * @param {Object} options - Shape options\r\n   *      @param {string} [options.fill] - Shape foreground color (ex: '#fff', 'transparent')\r\n   *      @param {string} [options.stroke] - Shape outline color\r\n   *      @param {number} [options.strokeWidth] - Shape outline width\r\n   *      @param {number} [options.width] - Width value (When type option is 'rect', this options can use)\r\n   *      @param {number} [options.height] - Height value (When type option is 'rect', this options can use)\r\n   *      @param {number} [options.rx] - Radius x value (When type option is 'circle', this options can use)\r\n   *      @param {number} [options.ry] - Radius y value (When type option is 'circle', this options can use)\r\n   *      @param {number} [options.left] - Shape x position\r\n   *      @param {number} [options.top] - Shape y position\r\n   *      @param {number} [options.isRegular] - Whether resizing shape has 1:1 ratio or not\r\n   * @returns {Promise}\r\n   */\r\n  execute(graphics, type, options) {\r\n    const shapeComp = graphics.getComponent(SHAPE);\r\n\r\n    return shapeComp.add(type, options).then((objectProps) => {\r\n      this.undoData.object = graphics.getObject(objectProps.id);\r\n\r\n      return objectProps;\r\n    });\r\n  },\r\n  /**\r\n   * @param {Graphics} graphics - Graphics instance\r\n   * @returns {Promise}\r\n   */\r\n  undo(graphics) {\r\n    graphics.remove(this.undoData.object);\r\n\r\n    return Promise.resolve();\r\n  },\r\n};\r\n\r\ncommandFactory.register(command);\r\n\r\nexport default command;\r\n"]},"metadata":{},"sourceType":"module"}