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

1 line
13 KiB
Plaintext
Raw Normal View History

2020-09-06 06:32:10 +00:00
{"version":3,"file":"ext-polygon.js","sources":["../../../../src/editor/extensions/ext-polygon/ext-polygon.js"],"sourcesContent":["/**\n * @file ext-polygon.js\n *\n *\n * @copyright 2010 CloudCanvas, Inc. All rights reserved\n *\n */\n\nexport default {\n name: 'polygon',\n async init (S) {\n const svgEditor = this;\n const svgCanvas = svgEditor.canvas;\n const {$} = S, // {svgcontent}\n // addElem = svgCanvas.addSVGElementFromJson,\n editingitex = false;\n // eslint-disable-next-line node/no-unsupported-features/es-syntax\n const {default: strings} = await import(`./locale/${svgEditor.curPrefs.lang}.js`);\n let selElems,\n // svgdoc = S.svgroot.parentNode.ownerDocument,\n // newFOG, newFOGParent, newDef, newImageName, newMaskID, modeChangeG,\n // edg = 0,\n // undoCommand = 'Not image';\n started, newFO;\n\n // const ccZoom;\n // const wEl, hEl;\n // const wOffset, hOffset;\n // const ccRBG;\n // const ccOpacity;\n // const brushW, brushH;\n\n // const ccDebug = document.getElementById('debugpanel');\n\n /* const properlySourceSizeTextArea = function(){\n // TODO: remove magic numbers here and get values from CSS\n const height = $('#svg_source_container').height() - 80;\n $('#svg_source_textarea').css('height', height);\n }; */\n\n /**\n * @param {boolean} on\n * @returns {void}\n */\n function showPanel (on) {\n let fcRules = $('#fc_rules');\n if (!fcRules.length) {\n fcRules = $('<style id=\"fc_rules\"></style>').appendTo('head');\n }\n fcRules.text(!on ? '' : ' #tool_topath { display: none !important; }');\n $('#polygon_panel').toggle(on);\n }\n\n /*\n function toggleSourceButtons(on){\n $('#tool_source_save, #tool_source_cancel').toggle(!on);\n $('#polygon_save, #polygon_cancel').toggle(on);\n }\n */\n\n /**\n * @param {string} attr\n * @param {string|Float} val\n * @returns {void}\n */\n function setAttr (attr, val) {\n svgCanvas.changeSelectedAttribute(attr, val);\n svgCanvas.call('changed', selElems);\n }\n\n /**\n * @param {Float} n\n * @returns {Float}\n */\n function cot (n) {\n return 1 / Math.tan(n);\n }\n\n /**\n * @param {Float} n\n * @returns {Float}\n */\n function sec (n) {\n return 1 / Math.cos(n);\n }\n\n /**\n * Obtained from http://code.google.com/p/passenger-top/source/browse/instiki/public/svg-edit/editor/extensions/ext-itex.js?r=3\n * This function sets the content of of the currently-selected foreignObject element,\n * based on the itex contained in string.\n * @param {string} tex The itex text.\n * @returns {boolean} This function returns false if the set was unsuccessful, true otherwise.\n */\n /*\n function setItexString(tex) {\n const mathns = 'http://www.w3.org/1998/Math/MathML',\n xmlnsns = 'http://www.w3.org/2000/xmlns/',\n ajaxEndpoint = '../../itex';\n const elt = selElems[0];\n try {\n const math = svgdoc.createElementNS(mathns, 'math');\n math.setAttributeNS(xmlnsns, 'xmlns', mathns);\n math.setAttribute('display', 'inline');\n const semantics = document.createElementNS(mathns, 'semantics');\n const annotation = document.createElementNS(mathns, 'annotation');\n annotation.setAttribute('encoding', 'application/x-tex');\n annotation.textContent = tex;\n const mrow = document.createElementNS(mathns, 'mrow');\n semantics.append(mrow, annotation);\n math.append(semantics);\n // make an AJAX request to the server, to get the MathML\n $.post(ajaxEndpoint, {tex, display: 'inline'}, function(data){\n const children = data.documentElement.childNodes;\n while (children.length > 0) {\n mrow.append(svgdoc.adoptNode(children[0], true));\n }\n svgCanvas.sanitizeSvg(math);\n svgCanvas.call('changed', [elt]);\n });\n elt.firstChild.replaceWith(math);