svgedit/dist/editor/extensions/ext-helloworld/ext-helloworld.js.map

1 line
3.9 KiB
Plaintext

{"version":3,"file":"ext-helloworld.js","sources":["../../../../src/editor/extensions/ext-helloworld/ext-helloworld.js"],"sourcesContent":["/**\n * @file ext-helloworld.js\n *\n * @license MIT\n *\n * @copyright 2010 Alexis Deveria\n *\n */\n\n/**\n* This is a very basic SVG-Edit extension. It adds a \"Hello World\" button in\n* the left (\"mode\") panel. Clicking on the button, and then the canvas\n* will show the user the point on the canvas that was clicked on.\n*/\nexport default {\n name: 'helloworld',\n async init ({$, importLocale}) {\n const svgEditor = this;\n // eslint-disable-next-line node/no-unsupported-features/es-syntax\n const {default: strings} = await import(`./locale/${svgEditor.curPrefs.lang}.js`);\n const svgCanvas = svgEditor.canvas;\n return {\n name: strings.name,\n // For more notes on how to make an icon file, see the source of\n // the helloworld-icon.xml\n svgicons: 'helloworld-icon.xml',\n\n // Multiple buttons can be added in this array\n buttons: [{\n // Must match the icon ID in helloworld-icon.xml\n id: 'hello_world',\n\n // Fallback, e.g., for `file:///` access\n icon: 'helloworld.png',\n\n // This indicates that the button will be added to the \"mode\"\n // button panel on the left side\n type: 'mode',\n\n // Tooltip text\n title: strings.buttons[0].title,\n\n // Events\n events: {\n click () {\n // The action taken when the button is clicked on.\n // For \"mode\" buttons, any other button will\n // automatically be de-pressed.\n svgCanvas.setMode('hello_world');\n }\n }\n }],\n // This is triggered when the main mouse button is pressed down\n // on the editor canvas (not the tool panels)\n mouseDown () {\n // Check the mode on mousedown\n if (svgCanvas.getMode() === 'hello_world') {\n // The returned object must include \"started\" with\n // a value of true in order for mouseUp to be triggered\n return {started: true};\n }\n return undefined;\n },\n\n // This is triggered from anywhere, but \"started\" must have been set\n // to true (see above). Note that \"opts\" is an object with event info\n mouseUp (opts) {\n // Check the mode on mouseup\n if (svgCanvas.getMode() === 'hello_world') {\n const zoom = svgCanvas.getZoom();\n\n // Get the actual coordinate by dividing by the zoom value\n const x = opts.mouse_x / zoom;\n const y = opts.mouse_y / zoom;\n\n // We do our own formatting\n let {text} = strings;\n [\n ['x', x],\n ['y', y]\n ].forEach(([prop, val]) => {\n text = text.replace('{' + prop + '}', val);\n });\n\n // Show the text using the custom alert function\n $.alert(text);\n }\n }\n };\n }\n};\n"],"names":["name","init","$","importLocale","svgEditor","_this","import","curPrefs","lang","strings","svgCanvas","canvas","svgicons","buttons","id","icon","type","title","events","click","setMode","mouseDown","getMode","started","mouseUp","opts","zoom","getZoom","x","mouse_x","y","mouse_y","text","forEach","prop","val","replace","alert"],"mappings":";;;;;;;;gIAcA,MAAe,CACbA,KAAM,aACAC,udAAOC,IAAAA,IAAGC,aACRC,EAAYC,WAEeC,0BAAmBF,EAAUG,SAASC,oCAAvDC,YACVC,EAAYN,EAAUO,yBACrB,CACLX,KAAMS,EAAQT,KAGdY,SAAU,sBAGVC,QAAS,CAAC,CAERC,GAAI,cAGJC,KAAM,iBAINC,KAAM,OAGNC,MAAOR,EAAQI,QAAQ,GAAGI,MAG1BC,OAAQ,CACNC,uBAIET,EAAUU,QAAQ,mBAMxBC,kCAE8B,gBAAxBX,EAAUY,gBAGL,CAACC,SAAS,IAOrBC,yBAASC,MAEqB,gBAAxBf,EAAUY,UAA6B,KACnCI,EAAOhB,EAAUiB,UAGjBC,EAAIH,EAAKI,QAAUH,EACnBI,EAAIL,EAAKM,QAAUL,EAGpBM,EAAQvB,EAARuB,MAEH,CAAC,IAAKJ,GACN,CAAC,IAAKE,IACNG,SAAQ,sCAAEC,OAAMC,OAChBH,EAAOA,EAAKI,QAAQ,IAAMF,EAAO,IAAKC,MAIxCjC,EAAEmC,MAAML"}