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

1 line
26 KiB
Plaintext
Raw Normal View History

2020-09-04 20:34:30 +00:00
{"version":3,"file":"ext-placemark.js","sources":["../../../src/editor/extensions/ext-placemark.js"],"sourcesContent":["/**\n * @file ext-placemark.js\n *\n *\n * @copyright 2010 CloudCanvas, Inc. All rights reserved\n *\n */\nexport default {\n name: 'placemark',\n async init (S) {\n const svgEditor = this;\n const svgCanvas = svgEditor.canvas;\n const addElem = svgCanvas.addSVGElementFromJson;\n const {$, importLocale} = S; // {svgcontent},\n let\n selElems,\n // editingitex = false,\n // svgdoc = S.svgroot.parentNode.ownerDocument,\n started,\n newPM;\n // edg = 0,\n // newFOG, newFOGParent, newDef, newImageName, newMaskID,\n // undoCommand = 'Not image',\n // modeChangeG, ccZoom, wEl, hEl, wOffset, hOffset, ccRgbEl, brushW, brushH;\n const strings = await importLocale();\n const markerTypes = {\n nomarker: {},\n forwardslash:\n {element: 'path', attr: {d: 'M30,100 L70,0'}},\n reverseslash:\n {element: 'path', attr: {d: 'M30,0 L70,100'}},\n verticalslash:\n {element: 'path', attr: {d: 'M50,0 L50,100'}},\n xmark:\n {element: 'path', attr: {d: 'M20,80 L80,20 M80,80 L20,20'}},\n leftarrow:\n {element: 'path', attr: {d: 'M0,50 L100,90 L70,50 L100,10 Z'}},\n rightarrow:\n {element: 'path', attr: {d: 'M100,50 L0,90 L30,50 L0,10 Z'}},\n box:\n {element: 'path', attr: {d: 'M20,20 L20,80 L80,80 L80,20 Z'}},\n star:\n {element: 'path', attr: {d: 'M10,30 L90,30 L20,90 L50,10 L80,90 Z'}},\n mcircle:\n {element: 'circle', attr: {r: 30, cx: 50, cy: 50}},\n triangle:\n {element: 'path', attr: {d: 'M10,80 L50,20 L80,80 Z'}}\n };\n\n // duplicate shapes to support unfilled (open) marker types with an _o suffix\n ['leftarrow', 'rightarrow', 'box', 'star', 'mcircle', 'triangle'].forEach((v) => {\n markerTypes[v + '_o'] = markerTypes[v];\n });\n\n /**\n *\n * @param {boolean} on\n * @returns {void}\n */\n function showPanel (on) {\n $('#placemark_panel').toggle(on);\n }\n\n /**\n * @param {Element} elem - A graphic element will have an attribute like marker-start\n * @param {\"marker-start\"|\"marker-mid\"|\"marker-end\"} attr\n * @returns {Element} The marker element that is linked to the graphic element\n */\n function getLinked (elem, attr) {\n if (!elem) { return null; }\n const str = elem.getAttribute(attr);\n if (!str) { return null; }\n\n // const m = str.match(/\\(#(?<id>.+)\\)/);\n // if (!m || !m.groups.id) {\n const m = str.match(/\\(#(.*)\\)/);\n if (!m || m.length !== 2) {\n return null;\n }\n return svgCanvas.getElem(m[1]);\n // return svgCanvas.getElem(m.groups.id);\n }\n\n /**\n * Called when text is changed.\n * @param {string} txt\n * @returns {void}\n */\n function updateText (txt) {\n const items = txt.split(';');\n selElems.forEach((elem) => {\n if (elem && elem.getAttribute('class').includes('placemark')) {\n $(elem).children().each((_, i) => {\n const [, , type, n] = i.id.split('_');\n if (type === 'txt') {\n $(i).text(items[n]);\n }\n });\n }\n });\n }\n /**\n * Called when font is changed.\n * @param {string} font\n * @returns {void}\n */\n function updateFont (font) {\n font = font.split(' ');\n const fontSize = Number.parseInt(font.pop());\n font = font.join(' ');\n selElems.forEach((elem) => {\n if (elem && elem.getAttribute('class').includes('placemark')) {\n $(elem).children().each((_, i) => {\n const [, , type] = i.id.split('_');\n if (type === 'txt') {\n $(i).attr({'font-family': font, 'font-size': fontSize});\n }\n });\n }\n });\n }\n /**\n * @param {string} id\n * @param {\"\"|\"\\\\nomarker\"|\"nomarker\"|\"leftarrow\"|\"rightarrow\"|\"text