antosdk-apps/SVGEdit/svgedit/extensions/ext-shapes/ext-shapes.js.map
DanyLE 4a62c4d1cf
All checks were successful
gitea-sync/antosdk-apps/pipeline/head This commit looks good
add SVGEdit package
2023-08-17 23:54:41 +02:00

1 line
12 KiB
Plaintext
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

{"version":3,"file":"ext-shapes.js","sources":["../../../../src/editor/extensions/ext-shapes/ext-shapes.js","../../../../src/editor/extensions/ext-shapes/locale/en.js","../../../../src/editor/extensions/ext-shapes/locale/fr.js","../../../../src/editor/extensions/ext-shapes/locale/tr.js","../../../../src/editor/extensions/ext-shapes/locale/zh-CN.js"],"sourcesContent":["/**\n * @file ext-shapes.js\n *\n * @license MIT\n *\n * @copyright 2010 Christian Tzurcanu, 2010 Alexis Deveria\n *\n */\nconst name = 'shapes'\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 () {\n const svgEditor = this\n const canv = svgEditor.svgCanvas\n const { $id, $click } = canv\n const svgroot = canv.getSvgRoot()\n let lastBBox = {}\n await loadExtensionTranslation(svgEditor)\n\n const modeId = 'shapelib'\n const startClientPos = {}\n\n let curShape\n let startX\n let startY\n\n return {\n callback () {\n if ($id('tool_shapelib') === null) {\n const extPath = svgEditor.configObj.curConfig.extPath\n const buttonTemplate = `\n <se-explorerbutton id=\"tool_shapelib\" title=\"${svgEditor.i18next.t(`${name}:buttons.0.title`)}\" lib=\"${extPath}/ext-shapes/shapelib/\"\n src=\"shapelib.svg\"></se-explorerbutton>\n `\n canv.insertChildAtIndex($id('tools_left'), buttonTemplate, 9)\n $click($id('tool_shapelib'), () => {\n if (this.leftPanel.updateLeftPanel('tool_shapelib')) {\n canv.setMode(modeId)\n }\n })\n }\n },\n mouseDown (opts) {\n const mode = canv.getMode()\n if (mode !== modeId) { return undefined }\n\n const currentD = document.getElementById('tool_shapelib').dataset.draw\n startX = opts.start_x\n const x = startX\n startY = opts.start_y\n const y = startY\n const curStyle = canv.getStyle()\n\n startClientPos.x = opts.event.clientX\n startClientPos.y = opts.event.clientY\n\n curShape = canv.addSVGElementsFromJson({\n element: 'path',\n curStyles: true,\n attr: {\n d: currentD,\n id: canv.getNextId(),\n opacity: curStyle.opacity / 2,\n style: 'pointer-events:none'\n }\n })\n\n curShape.setAttribute('transform', 'translate(' + x + ',' + y + ') scale(0.005) translate(' + -x + ',' + -y + ')')\n\n canv.recalculateDimensions(curShape)\n\n lastBBox = curShape.getBBox()\n\n return {\n started: true\n }\n },\n mouseMove (opts) {\n const mode = canv.getMode()\n if (mode !== modeId) { return }\n\n const zoom = canv.getZoom()\n const evt = opts.event\n\n const x = opts.mouse_x / zoom\n const y = opts.mouse_y / zoom\n\n const tlist = curShape.transform.baseVal\n const box = curShape.getBBox()\n const left = box.x; const top = box.y\n\n const newbox = {\n x: Math.min(startX, x),\n y: Math.min(startY, y),\n width: Math.abs(x - startX),\n height: Math.abs(y - startY)\n }\n\n let sx = (newbox.width / lastBBox.width) || 1\n let sy = (newbox.height / lastBBox.height) || 1\n\n // Not perfect, but mostly works...\n let tx = 0\n if (x < startX) {\n tx = lastBBox.width\n }\n let ty = 0\n if (y < startY) {\n ty = lastBBox.height\n }\n\n // update the transform list with translate,scale,translate\n const translateOrigin = svgroot.createSVGTransform()\n const scale = svgroot.createSVGTransform()\n const translateBack = svgroot.createSVGTransform()\n\n translateOrigin.setTranslate(-(left + tx), -(top + ty))\n if (!evt.shiftKey) {\n const max = Math.min(Math.abs(sx), Math.abs(sy))\n\n sx = max * (sx < 0 ? -1 : 1)\n sy = max * (sy < 0 ? -1 : 1)\n }\n scale.setScale(sx, sy)\n\n translateBack.setTranslate(left + tx, top + ty)\n tlist.appendItem(translateBack)\n tlist.appendItem(scale)\n tlist.appendItem(translateOrigin)\n\n canv.recalculateDimensions(curShape)\n\n lastBBox = curShape.getBBox()\n },\n mouseUp (opts) {\n const mode = canv.getMode()\n if (mode !== modeId) { return undefined }\n\n const keepObject = (opts.event.clientX !== startClientPos.x && opts.event.clientY !== startClientPos.y)\n\n return {\n keep: keepObject,\n element: curShape,\n started: false\n }\n }\n }\n }\n}\n","export default {\n loading: 'Loading...',\n categories: {\n basic: 'Basic',\n object: 'Objects',\n symbol: 'Symbols',\n arrow: 'Arrows',\n flowchart: 'Flowchart',\n animal: 'Animals',\n game: 'Cards & Chess',\n dialog_balloon: 'Dialog balloons',\n electronics: 'Electronics',\n math: 'Mathematical',\n music: 'Music',\n misc: 'Miscellaneous',\n raphael_1: 'raphaeljs.com set 1',\n raphael_2: 'raphaeljs.com set 2'\n },\n buttons: [\n {\n title: 'Shape library'\n }\n ]\n}\n","export default {\n loading: 'Chargement...',\n categories: {\n basic: 'Basique',\n object: 'Objets',\n symbol: 'Symboles',\n arrow: 'Flèches',\n flowchart: 'Flowchart',\n animal: 'Animaux',\n game: 'Cartes & Echecs',\n dialog_balloon: 'Dialog balloons',\n electronics: 'Electronique',\n math: 'Mathematiques',\n music: 'Musique',\n misc: 'Divers',\n raphael_1: 'raphaeljs.com set 1',\n raphael_2: 'raphaeljs.com set 2'\n },\n buttons: [\n {\n title: \"Bibliothèque d'images\"\n }\n ]\n}\n","export default {\n loading: 'Yükleniyor...',\n categories: {\n basic: 'Temel',\n object: 'Nesneler',\n symbol: 'Semboller',\n arrow: 'Oklar',\n flowchart: 'Akış Şemaları',\n animal: 'Hayvanlar',\n game: 'Kartlar & Satranç',\n dialog_balloon: 'Diyalog baloncukları',\n electronics: 'Elektronikler',\n math: 'Matematikseller',\n music: 'Müzik',\n misc: 'Diğerleri',\n raphael_1: 'raphaeljs.com set 1',\n raphael_2: 'raphaeljs.com set 2'\n },\n buttons: [\n {\n title: 'Şekil kütüphanesi'\n }\n ]\n}\n","export default {\n loading: '正在加载...',\n categories: {\n basic: '基本',\n object: '对象',\n symbol: '符号',\n arrow: '箭头',\n flowchart: '工作流',\n animal: '动物',\n game: '棋牌',\n dialog_balloon: '会话框',\n electronics: '电子',\n math: '数学',\n music: '音乐',\n misc: '其他',\n raphael_1: 'raphaeljs.com 集合 1',\n raphael_2: 'raphaeljs.com 集合 2'\n },\n buttons: [\n {\n title: '图元库'\n }\n ]\n}\n"],"names":["name","loadExtensionTranslation","async","svgEditor","translationModule","lang","configObj","pref","__variableDynamicImportRuntime0__","concat","_error","console","warn","Promise","resolve","then","en$1","i18next","addResourceBundle","default","extShapes","this","canv","svgCanvas","$id","$click","svgroot","getSvgRoot","lastBBox","modeId","startClientPos","curShape","startX","startY","callback","extPath","curConfig","buttonTemplate","t","insertChildAtIndex","leftPanel","updateLeftPanel","setMode","mouseDown","opts","getMode","currentD","document","getElementById","dataset","draw","start_x","x","start_y","y","curStyle","getStyle","event","clientX","clientY","addSVGElementsFromJson","element","curStyles","attr","d","id","getNextId","opacity","style","setAttribute","recalculateDimensions","getBBox","started","mouseMove","zoom","getZoom","evt","mouse_x","mouse_y","tlist","transform","baseVal","box","left","top","newbox","Math","min","abs","sx","width","sy","height","tx","ty","translateOrigin","createSVGTransform","scale","translateBack","setTranslate","shiftKey","max","setScale","appendItem","mouseUp","keep","loading","categories","basic","object","symbol","arrow","flowchart","animal","game","dialog_balloon","electronics","math","music","misc","raphael_1","raphael_2","buttons","title"],"mappings":";;;;;;;;AAQA,MAAMA,EAAO,SAEPC,yBAA2BC,eAAgBC,GAC/C,IAAIC,EACJ,MAAMC,EAAOF,EAAUG,UAAUC,KAAK,QACtC,IACEH,0hBAA0BI,CAAM,YAAAC,OAAaJ,EAA7C,QACA,MAAOK,GACPC,QAAQC,KAA6BP,wBAAAA,OAAAA,mBAAaL,EAAlD,kBACAI,QAA0BS,QAAAC,UAAAC,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