mirror of
https://github.com/antos-rde/antosdk-apps.git
synced 2024-12-28 13:08:21 +01:00
1 line
5.5 KiB
Plaintext
1 line
5.5 KiB
Plaintext
|
{"version":3,"file":"ext-helloworld.js","sources":["../../../../src/editor/extensions/ext-helloworld/ext-helloworld.js","../../../../src/editor/extensions/ext-helloworld/locale/en.js","../../../../src/editor/extensions/ext-helloworld/locale/fr.js","../../../../src/editor/extensions/ext-helloworld/locale/tr.js","../../../../src/editor/extensions/ext-helloworld/locale/zh-CN.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*/\n\nconst name = 'helloworld'\n\nconst loadExtensionTranslation = async function (svgEditor) {\n let translationModule\n const lang = svgEditor.configObj.pref('lang')\n try {\n translationModule = await import(`./locale/${lang}.js`)\n } catch (_error) {\n console.warn(`Missing translation (${lang}) for ${name} - using 'en'`)\n translationModule = await import('./locale/en.js')\n }\n svgEditor.i18next.addResourceBundle(lang, name, translationModule.default)\n}\n\nexport default {\n name,\n async init ({ _importLocale }) {\n const svgEditor = this\n await loadExtensionTranslation(svgEditor)\n const { svgCanvas } = svgEditor\n const { $id, $click } = svgCanvas\n return {\n name: svgEditor.i18next.t(`${name}:name`),\n callback () {\n // Add the button and its handler(s)\n const buttonTemplate = document.createElement('template')\n const title = `${name}:buttons.0.title`\n buttonTemplate.innerHTML = `\n <se-button id=\"hello_world\" title=\"${title}\" src=\"hello_world.svg\"></se-button>\n `\n $id('tools_left').append(buttonTemplate.content.cloneNode(true))\n $click($id('hello_world'), () => {\n svgCanvas.setMode('hello_world')\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 const text = svgEditor.i18next.t(`${name}:text`, { x, y })\n // Show the text using the custom alert function\n alert(text)\n }\n }\n }\n }\n}\n","export default {\n name: 'Hello World',\n text: 'Hello World!\\n\\nYou clicked here: {{x}}, {{y}}',\n buttons: [\n {\n title: \"Say 'Hello World'\"\n }\n ]\n}\n","export default {\n name: 'Bonjour le Monde',\n text: 'Bonjour le Monde!\\n\\nVous avez cliqué ici: {{x}}, {{y}}',\n buttons: [\n {\n title: \"Dire 'Bonjour le Monde'\"\n }\n ]\n}\n","export default {\n name: 'Merhaba Dünya',\n text: 'Merhaba Dünya!\\n\\nBuraya Tıkladınız: {{x}}, {{y}}',\n buttons: [\n {\n title: \"'Merhaba Dünya' De\"\n }\n ]\n}\n","export default {\n name: 'Hello World',\n text: 'Hello World!\\n\\n 请点击: {{x}}, {{y}}',\n buttons: [\n {\n title: \"输出 'Hello World'\"\n }\n ]\n}\n"],"names":["name","loadExtensionTranslation","async","svgEditor","translationModule","lang","configObj","pref","__variableDynamicImportRuntime0__","concat","_error","console","warn","Promise",
|