{"version":3,"file":"ext-arrows.js","sources":["../../../src/editor/extensions/ext-arrows.js"],"sourcesContent":["/**\n * @file ext-arrows.js\n *\n * @license MIT\n *\n * @copyright 2010 Alexis Deveria\n *\n */\n\nexport default {\n name: 'arrows',\n async init (S) {\n const strings = await S.importLocale();\n const svgEditor = this;\n const svgCanvas = svgEditor.canvas;\n const // {svgcontent} = S,\n addElem = svgCanvas.addSVGElementFromJson,\n {nonce, $} = S,\n prefix = 'se_arrow_';\n\n let selElems, arrowprefix, randomizeIds = S.randomize_ids;\n\n /**\n * @param {Window} win\n * @param {!(string|Integer)} n\n * @returns {void}\n */\n function setArrowNonce (win, n) {\n randomizeIds = true;\n arrowprefix = prefix + n + '_';\n pathdata.fw.id = arrowprefix + 'fw';\n pathdata.bk.id = arrowprefix + 'bk';\n }\n\n /**\n * @param {Window} win\n * @returns {void}\n */\n function unsetArrowNonce (win) {\n randomizeIds = false;\n arrowprefix = prefix;\n pathdata.fw.id = arrowprefix + 'fw';\n pathdata.bk.id = arrowprefix + 'bk';\n }\n\n svgCanvas.bind('setnonce', setArrowNonce);\n svgCanvas.bind('unsetnonce', unsetArrowNonce);\n\n if (randomizeIds) {\n arrowprefix = prefix + nonce + '_';\n } else {\n arrowprefix = prefix;\n }\n\n const pathdata = {\n fw: {d: 'm0,0l10,5l-10,5l5,-5l-5,-5z', refx: 8, id: arrowprefix + 'fw'},\n bk: {d: 'm10,0l-10,5l10,5l-5,-5l5,-5z', refx: 2, id: arrowprefix + 'bk'}\n };\n\n /**\n * Gets linked element.\n * @param {Element} elem\n * @param {string} attr\n * @returns {Element}\n */\n function getLinked (elem, attr) {\n const str = elem.getAttribute(attr);\n if (!str) { return null; }\n const m = str.match(/\\(#(.*)\\)/);\n // const m = str.match(/\\(#(?.+)\\)/);\n // if (!m || !m.groups.id) {\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 * @param {boolean} on\n * @returns {void}\n */\n function showPanel (on) {\n $('#arrow_panel').toggle(on);\n if (on) {\n const el = selElems[0];\n const end = el.getAttribute('marker-end');\n const start = el.getAttribute('marker-start');\n const mid = el.getAttribute('marker-mid');\n let val;\n if (end && start) {\n val = 'both';\n } else if (end) {\n val = 'end';\n } else if (start) {\n val = 'start';\n } else if (mid) {\n val = 'mid';\n if (mid.includes('bk')) {\n val = 'mid_bk';\n }\n }\n\n if (!start && !mid && !end) {\n val = 'none';\n }\n\n $('#arrow_list').val(val);\n }\n }\n\n /**\n *\n * @returns {void}\n */\n function resetMarker () {\n const el = selElems[0];\n el.removeAttribute('marker-start');\n el.removeAttribute('marker-mid');\n el.removeAttribute('marker-end');\n }\n\n /**\n * @param {\"bk\"|\"fw\"} dir\n * @param {\"both\"|\"mid\"|\"end\"|\"start\"} type\n * @param {string} id\n * @returns {Element}\n */\n function addMarker (dir, type, id) {\n // TODO: Make marker (or use?) per arrow type, since refX can be different\n id = id || arrowprefix + dir;\n\n const data = pathdata[dir];\n\n if (type === 'mid') {\n data.refx = 5;\n }\n\n let marker = svgCanvas.getElem(id);\n if (!marker) {\n marker = addElem({\n element: 'marker',\n attr: {\n viewBox: '0 0 10 10',\n id,\n refY: 5,\n markerUnits: 'strokeWidth',\n markerWidth: 5,\n markerHeight: 5,\n orient: 'auto',\n style: 'pointer-events:none' // Currently needed for Opera\n }\n });\n const arrow = addElem({\n element: 'path',\n attr: {\n d: data.d,\n fill: '#000000'\n }\n });\n marker.append(arrow);\n svgCanvas.findDefs().append(marker);\n }\n\n marker.setAttribute('refX', data.refx);\n\n return marker;\n }\n\n /**\n *\n * @returns {void}\n */\n function setArrow () {\n resetMarker();\n\n let type = this.value;\n if (type === 'none') {\n return;\n }\n\n // Set marker on element\n let dir = 'fw';\n if (type === 'mid_bk') {\n type = 'mid';\n dir = 'bk';\n } else if (type === 'both') {\n addMarker('bk', type);\n svgCanvas.changeSelectedAttribute('marker-start', 'url(#' + pathdata.bk.id + ')');\n type = 'end';\n dir = 'fw';\n } else if (type === 'start') {\n dir = 'bk';\n }\n\n addMarker(dir, type);\n svgCanvas.changeSelectedAttribute('marker-' + type, 'url(#' + pathdata[dir].id + ')');\n svgCanvas.call('changed', selElems);\n }\n\n /**\n * @param {Element} elem\n * @returns {void}\n */\n function colorChanged (elem) {\n const color = elem.getAttribute('stroke');\n const mtypes = ['start', 'mid', 'end'];\n const defs = svgCanvas.findDefs();\n\n $.each(mtypes, function (i, type) {\n const marker = getLinked(elem, 'marker-' + type);\n if (!marker) { return; }\n\n const curColor = $(marker).children().attr('fill');\n const curD = $(marker).children().attr('d');\n if (curColor === color) { return; }\n\n const allMarkers = $(defs).find('marker');\n let newMarker = null;\n // Different color, check if already made\n allMarkers.each(function () {\n const attrs = $(this).children().attr(['fill', 'd']);\n if (attrs.fill === color && attrs.d === curD) {\n // Found another marker with this color and this path\n newMarker = this;\n }\n });\n\n if (!newMarker) {\n // Create a new marker with this color\n const lastId = marker.id;\n const dir = lastId.includes('_fw') ? 'fw' : 'bk';\n\n newMarker = addMarker(dir, type, arrowprefix + dir + allMarkers.length);\n\n $(newMarker).children().attr('fill', color);\n }\n\n $(elem).attr('marker-' + type, 'url(#' + newMarker.id + ')');\n\n // Check if last marker can be removed\n let remove = true;\n $(S.svgcontent).find('line, polyline, path, polygon').each(function () {\n const element = this;\n $.each(mtypes, function (j, mtype) {\n if ($(element).attr('marker-' + mtype) === 'url(#' + marker.id + ')') {\n remove = false;\n return remove;\n }\n return undefined;\n });\n if (!remove) { return false; }\n return undefined;\n });\n\n // Not found, so can safely remove\n if (remove) {\n $(marker).remove();\n }\n });\n }\n\n const contextTools = [\n {\n type: 'select',\n panel: 'arrow_panel',\n id: 'arrow_list',\n defval: 'none',\n events: {\n change: setArrow\n }\n }\n ];\n\n return {\n name: strings.name,\n context_tools: strings.contextTools.map((contextTool, i) => {\n return Object.assign(contextTools[i], contextTool);\n }),\n callback () {\n $('#arrow_panel').hide();\n // Set ID so it can be translated in locale file\n $('#arrow_list option')[0].id = 'connector_no_arrow';\n },\n async addLangData ({lang, importLocale}) {\n const {langList} = await importLocale();\n return {\n data: langList\n };\n },\n selectedChanged (opts) {\n // Use this to update the current selected elements\n selElems = opts.elems;\n\n const markerElems = ['line', 'path', 'polyline', 'polygon'];\n let i = selElems.length;\n while (i--) {\n const elem = selElems[i];\n if (elem && markerElems.includes(elem.tagName)) {\n if (opts.selectedElement && !opts.multiselected) {\n showPanel(true);\n } else {\n showPanel(false);\n }\n } else {\n showPanel(false);\n }\n }\n },\n elementChanged (opts) {\n const elem = opts.elems[0];\n if (elem && (\n elem.getAttribute('marker-start') ||\n elem.getAttribute('marker-mid') ||\n elem.getAttribute('marker-end')\n )) {\n // const start = elem.getAttribute('marker-start');\n // const mid = elem.getAttribute('marker-mid');\n // const end = elem.getAttribute('marker-end');\n // Has marker, so see if it should match color\n colorChanged(elem);\n }\n }\n };\n }\n};\n"],"names":["name","init","S","setArrowNonce","unsetArrowNonce","getLinked","showPanel","resetMarker","addMarker","setArrow","colorChanged","elem","color","getAttribute","mtypes","defs","svgCanvas","findDefs","$","each","i","type","marker","curColor","children","attr","curD","allMarkers","find","newMarker","attrs","fill","d","lastId","id","dir","includes","arrowprefix","length","remove","svgcontent","element","j","mtype","undefined","value","changeSelectedAttribute","pathdata","bk","call","selElems","data","refx","getElem","addElem","viewBox","refY","markerUnits","markerWidth","markerHeight","orient","style","arrow","append","setAttribute","el","removeAttribute","on","toggle","end","start","mid","val","str","m","match","win","randomizeIds","prefix","fw","n","importLocale","strings","svgEditor","canvas","addSVGElementFromJson","nonce","randomize_ids","bind","contextTools","panel","defval","events","change","context_tools","map","contextTool","Object","assign","callback","hide","addLangData","lang","langList","selectedChanged","opts","elems","markerElems","tagName","selectedElement","multiselected","elementChanged"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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