9cad6d65d780d31d4b75b7cdc17b43b5.json
4.07 KB
{"ast":null,"code":"/**\r\n * @author NHN Ent. FE Development Team <dl_javascript@nhn.com>\r\n * @fileoverview Change a text\r\n */\nimport commandFactory from '../factory/command';\nimport { Promise } from '../util';\nimport { componentNames, rejectMessages, commandNames } from '../consts';\nconst {\n TEXT\n} = componentNames;\nconst command = {\n name: commandNames.CHANGE_TEXT,\n\n /**\r\n * Change a text\r\n * @param {Graphics} graphics - Graphics instance\r\n * @param {number} id - object id\r\n * @param {string} text - Changing text\r\n * @returns {Promise}\r\n */\n execute(graphics, id, text) {\n const textComp = graphics.getComponent(TEXT);\n const targetObj = graphics.getObject(id);\n\n if (!targetObj) {\n return Promise.reject(rejectMessages.noObject);\n }\n\n this.undoData.object = targetObj;\n this.undoData.text = textComp.getText(targetObj);\n return textComp.change(targetObj, text);\n },\n\n /**\r\n * @param {Graphics} graphics - Graphics instance\r\n * @returns {Promise}\r\n */\n undo(graphics) {\n const textComp = graphics.getComponent(TEXT);\n const {\n object: textObj,\n text\n } = this.undoData;\n return textComp.change(textObj, text);\n }\n\n};\ncommandFactory.register(command);\nexport default command;","map":{"version":3,"sources":["C:/Users/kkwan_000/Desktop/git/2017110269/minsung/src/js/command/changeText.js"],"names":["commandFactory","Promise","componentNames","rejectMessages","commandNames","TEXT","command","name","CHANGE_TEXT","execute","graphics","id","text","textComp","getComponent","targetObj","getObject","reject","noObject","undoData","object","getText","change","undo","textObj","register"],"mappings":"AAAA;AACA;AACA;AACA;AACA,OAAOA,cAAP,MAA2B,oBAA3B;AACA,SAASC,OAAT,QAAwB,SAAxB;AACA,SAASC,cAAT,EAAyBC,cAAzB,EAAyCC,YAAzC,QAA6D,WAA7D;AAEA,MAAM;AAAEC,EAAAA;AAAF,IAAWH,cAAjB;AAEA,MAAMI,OAAO,GAAG;AACdC,EAAAA,IAAI,EAAEH,YAAY,CAACI,WADL;;AAGd;AACF;AACA;AACA;AACA;AACA;AACA;AACEC,EAAAA,OAAO,CAACC,QAAD,EAAWC,EAAX,EAAeC,IAAf,EAAqB;AAC1B,UAAMC,QAAQ,GAAGH,QAAQ,CAACI,YAAT,CAAsBT,IAAtB,CAAjB;AACA,UAAMU,SAAS,GAAGL,QAAQ,CAACM,SAAT,CAAmBL,EAAnB,CAAlB;;AAEA,QAAI,CAACI,SAAL,EAAgB;AACd,aAAOd,OAAO,CAACgB,MAAR,CAAed,cAAc,CAACe,QAA9B,CAAP;AACD;;AAED,SAAKC,QAAL,CAAcC,MAAd,GAAuBL,SAAvB;AACA,SAAKI,QAAL,CAAcP,IAAd,GAAqBC,QAAQ,CAACQ,OAAT,CAAiBN,SAAjB,CAArB;AAEA,WAAOF,QAAQ,CAACS,MAAT,CAAgBP,SAAhB,EAA2BH,IAA3B,CAAP;AACD,GAtBa;;AAuBd;AACF;AACA;AACA;AACEW,EAAAA,IAAI,CAACb,QAAD,EAAW;AACb,UAAMG,QAAQ,GAAGH,QAAQ,CAACI,YAAT,CAAsBT,IAAtB,CAAjB;AACA,UAAM;AAAEe,MAAAA,MAAM,EAAEI,OAAV;AAAmBZ,MAAAA;AAAnB,QAA4B,KAAKO,QAAvC;AAEA,WAAON,QAAQ,CAACS,MAAT,CAAgBE,OAAhB,EAAyBZ,IAAzB,CAAP;AACD;;AAhCa,CAAhB;AAmCAZ,cAAc,CAACyB,QAAf,CAAwBnB,OAAxB;AAEA,eAAeA,OAAf","sourcesContent":["/**\r\n * @author NHN Ent. FE Development Team <dl_javascript@nhn.com>\r\n * @fileoverview Change a text\r\n */\r\nimport commandFactory from '../factory/command';\r\nimport { Promise } from '../util';\r\nimport { componentNames, rejectMessages, commandNames } from '../consts';\r\n\r\nconst { TEXT } = componentNames;\r\n\r\nconst command = {\r\n name: commandNames.CHANGE_TEXT,\r\n\r\n /**\r\n * Change a text\r\n * @param {Graphics} graphics - Graphics instance\r\n * @param {number} id - object id\r\n * @param {string} text - Changing text\r\n * @returns {Promise}\r\n */\r\n execute(graphics, id, text) {\r\n const textComp = graphics.getComponent(TEXT);\r\n const targetObj = graphics.getObject(id);\r\n\r\n if (!targetObj) {\r\n return Promise.reject(rejectMessages.noObject);\r\n }\r\n\r\n this.undoData.object = targetObj;\r\n this.undoData.text = textComp.getText(targetObj);\r\n\r\n return textComp.change(targetObj, text);\r\n },\r\n /**\r\n * @param {Graphics} graphics - Graphics instance\r\n * @returns {Promise}\r\n */\r\n undo(graphics) {\r\n const textComp = graphics.getComponent(TEXT);\r\n const { object: textObj, text } = this.undoData;\r\n\r\n return textComp.change(textObj, text);\r\n },\r\n};\r\n\r\ncommandFactory.register(command);\r\n\r\nexport default command;\r\n"]},"metadata":{},"sourceType":"module"}