').append(btn.title);
+ }
+ } else if (btn.list) {
+ // Add button to list
+ button.addClass('push_button');
+ $$c('#' + btn.list + '_opts').append(button);
+
+ if (btn.isDefault) {
+ $$c('#cur_' + btn.list).append(button.children().clone());
+
+ var _svgicon = btn.svgicon || btn.id;
+
+ placementObj['#cur_' + btn.list] = _svgicon;
+ }
+ } else if (btn.includeWith) {
+ // Add to flyout menu / make flyout menu
+ var opts = btn.includeWith; // opts.button, default, position
+
+ refBtn = $$c(opts.button);
+ flyoutHolder = refBtn.parent(); // Create a flyout menu if there isn't one already
+
+ var _tlsId;
+
+ if (!refBtn.parent().hasClass('tools_flyout')) {
+ // Create flyout placeholder
+ _tlsId = refBtn[0].id.replace('tool_', 'tools_');
+ showBtn = refBtn.clone().attr('id', _tlsId + '_show').append($$c('
', {
+ "class": 'flyout_arrow_horiz'
+ }));
+ refBtn.before(showBtn); // Create a flyout div
+
+ flyoutHolder = makeFlyoutHolder(_tlsId, refBtn);
+ }
+
+ refData = Actions.getButtonData(opts.button);
+
+ if (opts.isDefault) {
+ placementObj['#' + _tlsId + '_show'] = btn.id;
+ } // TODO: Find way to set the current icon using the iconloader if this is not default
+ // Include data for extension button as well as ref button
+
+
+ var curH = holders['#' + flyoutHolder[0].id] = [{
+ sel: '#' + id,
+ fn: btn.events.click,
+ icon: btn.id,
+ key: btn.key,
+ isDefault: Boolean(btn.includeWith && btn.includeWith.isDefault)
+ }, refData]; // {sel:'#tool_rect', fn: clickRect, evt: 'mouseup', key: 4, parent: '#tools_rect', icon: 'rect'}
+
+ var pos = 'position' in opts ? opts.position : 'last';
+ var len = flyoutHolder.children().length; // Add at given position or end
+
+ if (!isNaN(pos) && pos >= 0 && pos < len) {
+ flyoutHolder.children().eq(pos).before(button);
+ } else {
+ flyoutHolder.append(button);
+ curH.reverse();
+ }
+ }
+
+ if (!svgicons) {
+ button.append(icon);
+ }
+
+ if (!btn.list) {
+ // Add given events to button
+ $$c.each(btn.events, function (name, func) {
+ if (name === 'click' && btn.type === 'mode') {
+ // `touch.js` changes `touchstart` to `mousedown`,
+ // so we must map extension click events as well
+ if (isTouch() && name === 'click') {
+ name = 'mousedown';
+ }
+
+ if (btn.includeWith) {
+ button.bind(name, func);
+ } else {
+ button.bind(name, function () {
+ if (toolButtonClick(button)) {
+ func();
+ }
+ });
+ }
+
+ if (btn.key) {
+ $$c(document).bind('keydown', btn.key, func);
+
+ if (btn.title) {
+ button.attr('title', btn.title + ' [' + btn.key + ']');
+ }
+ }
+ } else {
+ button.bind(name, func);
+ }
+ });
+ }
+
+ setupFlyouts(holders);
+ });
+ $$c.each(btnSelects, function () {
+ addAltDropDown(this.elem, this.list, this.callback, {
+ seticon: true
+ });
+ });
+
+ if (!svgicons) {
+ _context5.next = 24;
+ break;
+ }
+
+ return _context5.abrupt("return", new Promise(function (resolve, reject) {
+ // eslint-disable-line promise/avoid-new
+ $$c.svgIcons(svgicons, {
+ w: 24,
+ h: 24,
+ id_match: false,
+ no_img: !isWebkit(),
+ fallback: fallbackObj,
+ placement: placementObj,
+ callback: function callback(icons) {
+ // Non-ideal hack to make the icon match the current size
+ // if (curPrefs.iconsize && curPrefs.iconsize !== 'm') {
+ if (editor.pref('iconsize') !== 'm') {
+ prepResize();
+ }
+
+ runCallback();
+ resolve();
+ }
+ });
+ }));
+
+ case 24:
+ return _context5.abrupt("return", runCallback());
+
+ case 25:
+ case "end":
+ return _context5.stop();
+ }
+ }
+ }, _callee5);
+ }));
+
+ return function extAdded(_x3, _x4) {
+ return _ref12.apply(this, arguments);
+ };
+ }();
+ /**
+ * @param {string} color
+ * @param {Float} opac
+ * @param {string} type
+ * @returns {module:jGraduate~Paint}
+ */
+
+
+ var getPaint = function getPaint(color, opac, type) {
+ // update the editor's fill paint
+ var opts = {
+ alpha: opac
+ };
+
+ if (color.startsWith('url(#')) {
+ var refElem = svgCanvas.getRefElem(color);
+
+ if (refElem) {
+ refElem = refElem.cloneNode(true);
+ } else {
+ refElem = $$c('#' + type + '_color defs *')[0];
+ }
+
+ opts[refElem.tagName] = refElem;
+ } else if (color.startsWith('#')) {
+ opts.solidColor = color.substr(1);
+ } else {
+ opts.solidColor = 'none';
+ }
+
+ return new $$c.jGraduate.Paint(opts);
+ }; // $('#text').focus(function () { textBeingEntered = true; });
+ // $('#text').blur(function () { textBeingEntered = false; });
+ // bind the selected event to our function that handles updates to the UI
+
+
+ svgCanvas.bind('selected', selectedChanged);
+ svgCanvas.bind('transition', elementTransition);
+ svgCanvas.bind('changed', elementChanged);
+ svgCanvas.bind('saved', saveHandler);
+ svgCanvas.bind('exported', exportHandler);
+ svgCanvas.bind('exportedPDF', function (win, data) {
+ if (!data.output) {
+ // Ignore Chrome
+ return;
+ }
+
+ var exportWindowName = data.exportWindowName;
+
+ if (exportWindowName) {
+ exportWindow = window.open('', exportWindowName); // A hack to get the window via JSON-able name without opening a new one
+ }
+
+ if (!exportWindow || exportWindow.closed) {
+ /* await */
+ $$c.alert(uiStrings$1.notification.popupWindowBlocked);
+ return;
+ }
+
+ exportWindow.location.href = data.output;
+ });
+ svgCanvas.bind('zoomed', zoomChanged);
+ svgCanvas.bind('zoomDone', zoomDone);
+ svgCanvas.bind('updateCanvas',
+ /**
+ * @param {external:Window} win
+ * @param {PlainObject} centerInfo
+ * @param {false} centerInfo.center
+ * @param {module:math.XYObject} centerInfo.newCtr
+ * @listens module:svgcanvas.SvgCanvas#event:updateCanvas
+ * @returns {void}
+ */
+ function (win, _ref13) {
+ var center = _ref13.center,
+ newCtr = _ref13.newCtr;
+ updateCanvas(center, newCtr);
+ });
+ svgCanvas.bind('contextset', contextChanged);
+ svgCanvas.bind('extension_added', extAdded);
+ svgCanvas.textActions.setInputElem($$c('#text')[0]);
+ var str = '
';
+ $$c.each(palette, function (i, item) {
+ str += '
';
+ });
+ $$c('#palette').append(str); // Set up editor background functionality
+
+ var colorBlocks = ['#FFF', '#888', '#000', 'chessboard'];
+ str = '';
+ $$c.each(colorBlocks, function (i, e) {
+ if (e === 'chessboard') {
+ str += '
';
+ } else {
+ str += '
';
+ }
+ });
+ $$c('#bg_blocks').append(str);
+ var blocks = $$c('#bg_blocks div');
+ var curBg = 'cur_background';
+ blocks.each(function () {
+ var blk = $$c(this);
+ blk.click(function () {
+ blocks.removeClass(curBg);
+ $$c(this).addClass(curBg);
+ });
+ });
+ setBackground(editor.pref('bkgd_color'), editor.pref('bkgd_url'));
+ $$c('#image_save_opts input').val([editor.pref('img_save')]);
+ /**
+ * @type {module:jQuerySpinButton.ValueCallback}
+ */
+
+ var changeRectRadius = function changeRectRadius(ctl) {
+ svgCanvas.setRectRadius(ctl.value);
+ };
+ /**
+ * @type {module:jQuerySpinButton.ValueCallback}
+ */
+
+
+ var changeFontSize = function changeFontSize(ctl) {
+ svgCanvas.setFontSize(ctl.value);
+ };
+ /**
+ * @type {module:jQuerySpinButton.ValueCallback}
+ */
+
+
+ var changeStrokeWidth = function changeStrokeWidth(ctl) {
+ var val = ctl.value;
+
+ if (val === 0 && selectedElement && ['line', 'polyline'].includes(selectedElement.nodeName)) {
+ val = ctl.value = 1;
+ }
+
+ svgCanvas.setStrokeWidth(val);
+ };
+ /**
+ * @type {module:jQuerySpinButton.ValueCallback}
+ */
+
+
+ var changeRotationAngle = function changeRotationAngle(ctl) {
+ svgCanvas.setRotationAngle(ctl.value);
+ $$c('#tool_reorient').toggleClass('disabled', Number.parseInt(ctl.value) === 0);
+ };
+ /**
+ * @param {external:jQuery.fn.SpinButton} ctl Spin Button
+ * @param {string} [val=ctl.value]
+ * @returns {void}
+ */
+
+
+ var changeOpacity = function changeOpacity(ctl, val) {
+ if (isNullish(val)) {
+ val = ctl.value;
+ }
+
+ $$c('#group_opacity').val(val);
+
+ if (!ctl || !ctl.handle) {
+ $$c('#opac_slider').slider('option', 'value', val);
+ }
+
+ svgCanvas.setOpacity(val / 100);
+ };
+ /**
+ * @param {external:jQuery.fn.SpinButton} ctl Spin Button
+ * @param {string} [val=ctl.value]
+ * @param {boolean} noUndo
+ * @returns {void}
+ */
+
+
+ var changeBlur = function changeBlur(ctl, val, noUndo) {
+ if (isNullish(val)) {
+ val = ctl.value;
+ }
+
+ $$c('#blur').val(val);
+ var complete = false;
+
+ if (!ctl || !ctl.handle) {
+ $$c('#blur_slider').slider('option', 'value', val);
+ complete = true;
+ }
+
+ if (noUndo) {
+ svgCanvas.setBlurNoUndo(val);
+ } else {
+ svgCanvas.setBlur(val, complete);
+ }
+ };
+
+ $$c('#stroke_style').change(function () {
+ svgCanvas.setStrokeAttr('stroke-dasharray', $$c(this).val());
+ operaRepaint();
+ });
+ $$c('#stroke_linejoin').change(function () {
+ svgCanvas.setStrokeAttr('stroke-linejoin', $$c(this).val());
+ operaRepaint();
+ }); // Lose focus for select elements when changed (Allows keyboard shortcuts to work better)
+
+ $$c('select').change(function () {
+ $$c(this).blur();
+ }); // fired when user wants to move elements to another layer
+
+ var promptMoveLayerOnce = false;
+ $$c('#selLayerNames').change( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee6() {
+ var destLayer, confirmStr, moveToLayer, ok;
+ return regeneratorRuntime.wrap(function _callee6$(_context6) {
+ while (1) {
+ switch (_context6.prev = _context6.next) {
+ case 0:
+ destLayer = this.options[this.selectedIndex].value;
+ confirmStr = uiStrings$1.notification.QmoveElemsToLayer.replace('%s', destLayer);
+ /**
+ * @param {boolean} ok
+ * @returns {void}
+ */
+
+ moveToLayer = function moveToLayer(ok) {
+ if (!ok) {
+ return;
+ }
+
+ promptMoveLayerOnce = true;
+ svgCanvas.moveSelectedToLayer(destLayer);
+ svgCanvas.clearSelection();
+ populateLayers();
+ };
+
+ if (!destLayer) {
+ _context6.next = 14;
+ break;
+ }
+
+ if (!promptMoveLayerOnce) {
+ _context6.next = 8;
+ break;
+ }
+
+ moveToLayer(true);
+ _context6.next = 14;
+ break;
+
+ case 8:
+ _context6.next = 10;
+ return $$c.confirm(confirmStr);
+
+ case 10:
+ ok = _context6.sent;
+
+ if (ok) {
+ _context6.next = 13;
+ break;
+ }
+
+ return _context6.abrupt("return");
+
+ case 13:
+ moveToLayer(true);
+
+ case 14:
+ case "end":
+ return _context6.stop();
+ }
+ }
+ }, _callee6, this);
+ })));
+ $$c('#font_family').change(function () {
+ svgCanvas.setFontFamily(this.value);
+ });
+ $$c('#seg_type').change(function () {
+ svgCanvas.setSegType($$c(this).val());
+ });
+ $$c('#text').bind('keyup input', function () {
+ svgCanvas.setTextContent(this.value);
+ });
+ $$c('#image_url').change(function () {
+ setImageURL(this.value);
+ });
+ $$c('#link_url').change(function () {
+ if (this.value.length) {
+ svgCanvas.setLinkURL(this.value);
+ } else {
+ svgCanvas.removeHyperlink();
+ }
+ });
+ $$c('#g_title').change(function () {
+ svgCanvas.setGroupTitle(this.value);
+ });
+ $$c('.attr_changer').change(function () {
+ var attr = this.getAttribute('data-attr');
+ var val = this.value;
+ var valid = isValidUnit(attr, val, selectedElement);
+
+ if (!valid) {
+ this.value = selectedElement.getAttribute(attr);
+ /* await */
+
+ $$c.alert(uiStrings$1.notification.invalidAttrValGiven);
+ return false;
+ }
+
+ if (attr !== 'id' && attr !== 'class') {
+ if (isNaN(val)) {
+ val = svgCanvas.convertToNum(attr, val);
+ } else if (curConfig.baseUnit !== 'px') {
+ // Convert unitless value to one with given unit
+ var unitData = getTypeMap();
+
+ if (selectedElement[attr] || svgCanvas.getMode() === 'pathedit' || attr === 'x' || attr === 'y') {
+ val *= unitData[curConfig.baseUnit];
+ }
+ }
+ } // if the user is changing the id, then de-select the element first
+ // change the ID, then re-select it with the new ID
+
+
+ if (attr === 'id') {
+ var elem = selectedElement;
+ svgCanvas.clearSelection();
+ elem.id = val;
+ svgCanvas.addToSelection([elem], true);
+ } else {
+ svgCanvas.changeSelectedAttribute(attr, val);
+ }
+
+ this.blur();
+ return true;
+ }); // Prevent selection of elements when shift-clicking
+
+ $$c('#palette').mouseover(function () {
+ var inp = $$c('
');
+ $$c(this).append(inp);
+ inp.focus().remove();
+ });
+ $$c('.palette_item').mousedown(function (evt) {
+ // shift key or right click for stroke
+ var picker = evt.shiftKey || evt.button === 2 ? 'stroke' : 'fill';
+ var color = $$c(this).data('rgb');
+ var paint; // Webkit-based browsers returned 'initial' here for no stroke
+
+ if (color === 'none' || color === 'transparent' || color === 'initial') {
+ color = 'none';
+ paint = new $$c.jGraduate.Paint();
+ } else {
+ paint = new $$c.jGraduate.Paint({
+ alpha: 100,
+ solidColor: color.substr(1)
+ });
+ }
+
+ paintBox[picker].setPaint(paint);
+ svgCanvas.setColor(picker, color);
+
+ if (color !== 'none' && svgCanvas.getPaintOpacity(picker) !== 1) {
+ svgCanvas.setPaintOpacity(picker, 1.0);
+ }
+
+ updateToolButtonState();
+ }).bind('contextmenu', function (e) {
+ e.preventDefault();
+ });
+ $$c('#toggle_stroke_tools').on('click', function () {
+ $$c('#tools_bottom').toggleClass('expanded');
+ });
+
+ (function () {
+ var wArea = workarea[0];
+ var lastX = null,
+ lastY = null,
+ panning = false,
+ keypan = false;
+ $$c('#svgcanvas').bind('mousemove mouseup', function (evt) {
+ if (panning === false) {
+ return true;
+ }
+
+ wArea.scrollLeft -= evt.clientX - lastX;
+ wArea.scrollTop -= evt.clientY - lastY;
+ lastX = evt.clientX;
+ lastY = evt.clientY;
+
+ if (evt.type === 'mouseup') {
+ panning = false;
+ }
+
+ return false;
+ }).mousedown(function (evt) {
+ if (evt.button === 1 || keypan === true) {
+ panning = true;
+ lastX = evt.clientX;
+ lastY = evt.clientY;
+ return false;
+ }
+
+ return true;
+ });
+ $$c(window).mouseup(function () {
+ panning = false;
+ });
+ $$c(document).bind('keydown', 'space', function (evt) {
+ svgCanvas.spaceKey = keypan = true;
+ evt.preventDefault();
+ }).bind('keyup', 'space', function (evt) {
+ evt.preventDefault();
+ svgCanvas.spaceKey = keypan = false;
+ }).bind('keydown', 'shift', function (evt) {
+ if (svgCanvas.getMode() === 'zoom') {
+ workarea.css('cursor', zoomOutIcon);
+ }
+ }).bind('keyup', 'shift', function (evt) {
+ if (svgCanvas.getMode() === 'zoom') {
+ workarea.css('cursor', zoomInIcon);
+ }
+ });
+ /**
+ * @function module:SVGEditor.setPanning
+ * @param {boolean} active
+ * @returns {void}
+ */
+
+ editor.setPanning = function (active) {
+ svgCanvas.spaceKey = keypan = active;
+ };
+ })();
+
+ (function () {
+ var button = $$c('#main_icon');
+ var overlay = $$c('#main_icon span');
+ var list = $$c('#main_menu');
+ var onButton = false;
+ var height = 0;
+ var jsHover = true;
+ var setClick = false;
+ /*
+ // Currently unused
+ const hideMenu = function () {
+ list.fadeOut(200);
+ };
+ */
+
+ $$c(window).mouseup(function (evt) {
+ if (!onButton) {
+ button.removeClass('buttondown'); // do not hide if it was the file input as that input needs to be visible
+ // for its change event to fire
+
+ if (evt.target.tagName !== 'INPUT') {
+ list.fadeOut(200);
+ } else if (!setClick) {
+ setClick = true;
+ $$c(evt.target).click(function () {
+ list.css('margin-left', '-9999px').show();
+ });
+ }
+ }
+
+ onButton = false;
+ }).mousedown(function (evt) {
+ // $('.contextMenu').hide();
+ var islib = $$c(evt.target).closest('div.tools_flyout, .contextMenu').length;
+
+ if (!islib) {
+ $$c('.tools_flyout:visible,.contextMenu').fadeOut(250);
+ }
+ });
+ overlay.bind('mousedown', function () {
+ if (!button.hasClass('buttondown')) {
+ // Margin must be reset in case it was changed before;
+ list.css('margin-left', 0).show();
+
+ if (!height) {
+ height = list.height();
+ } // Using custom animation as slideDown has annoying 'bounce effect'
+
+
+ list.css('height', 0).animate({
+ height: height
+ }, 200);
+ onButton = true;
+ } else {
+ list.fadeOut(200);
+ }
+
+ button.toggleClass('buttondown buttonup');
+ }).hover(function () {
+ onButton = true;
+ }).mouseout(function () {
+ onButton = false;
+ });
+ var listItems = $$c('#main_menu li'); // Check if JS method of hovering needs to be used (Webkit bug)
+
+ listItems.mouseover(function () {
+ jsHover = $$c(this).css('background-color') === 'rgba(0, 0, 0, 0)';
+ listItems.unbind('mouseover');
+
+ if (jsHover) {
+ listItems.mouseover(function () {
+ this.style.backgroundColor = '#FFC';
+ }).mouseout(function () {
+ this.style.backgroundColor = 'transparent';
+ return true;
+ });
+ }
+ });
+ })(); // Made public for UI customization.
+ // TODO: Group UI functions into a public editor.ui interface.
+
+ /**
+ * See {@link http://api.jquery.com/bind/#bind-eventType-eventData-handler}.
+ * @callback module:SVGEditor.DropDownCallback
+ * @param {external:jQuery.Event} ev See {@link http://api.jquery.com/Types/#Event}
+ * @listens external:jQuery.Event
+ * @returns {void|boolean} Calls `preventDefault()` and `stopPropagation()`
+ */
+
+ /**
+ * @function module:SVGEditor.addDropDown
+ * @param {Element|string} elem DOM Element or selector
+ * @param {module:SVGEditor.DropDownCallback} callback Mouseup callback
+ * @param {boolean} dropUp
+ * @returns {void}
+ */
+
+
+ editor.addDropDown = function (elem, callback, dropUp) {
+ if (!$$c(elem).length) {
+ return;
+ } // Quit if called on non-existent element
+
+
+ var button = $$c(elem).find('button');
+ var list = $$c(elem).find('ul').attr('id', $$c(elem)[0].id + '-list');
+
+ if (dropUp) {
+ $$c(elem).addClass('dropup');
+ } else {
+ // Move list to place where it can overflow container
+ $$c('#option_lists').append(list);
+ }
+
+ list.find('li').bind('mouseup', callback);
+ var onButton = false;
+ $$c(window).mouseup(function (evt) {
+ if (!onButton) {
+ button.removeClass('down');
+ list.hide();
+ }
+
+ onButton = false;
+ });
+ button.bind('mousedown', function () {
+ if (!button.hasClass('down')) {
+ if (!dropUp) {
+ var pos = $$c(elem).position();
+ list.css({
+ top: pos.top + 24,
+ left: pos.left - 10
+ });
+ }
+
+ list.show();
+ onButton = true;
+ } else {
+ list.hide();
+ }
+
+ button.toggleClass('down');
+ }).hover(function () {
+ onButton = true;
+ }).mouseout(function () {
+ onButton = false;
+ });
+ };
+
+ editor.addDropDown('#font_family_dropdown', function () {
+ $$c('#font_family').val($$c(this).text()).change();
+ });
+ editor.addDropDown('#opacity_dropdown', function () {
+ if ($$c(this).find('div').length) {
+ return;
+ }
+
+ var perc = Number.parseInt($$c(this).text().split('%')[0]);
+ changeOpacity(false, perc);
+ }, true); // For slider usage, see: http://jqueryui.com/demos/slider/
+
+ $$c('#opac_slider').slider({
+ start: function start() {
+ $$c('#opacity_dropdown li:not(.special)').hide();
+ },
+ stop: function stop() {
+ $$c('#opacity_dropdown li').show();
+ $$c(window).mouseup();
+ },
+ slide: function slide(evt, ui) {
+ changeOpacity(ui);
+ }
+ });
+ editor.addDropDown('#blur_dropdown', $$c.noop);
+ var slideStart = false;
+ $$c('#blur_slider').slider({
+ max: 10,
+ step: 0.1,
+ stop: function stop(evt, ui) {
+ slideStart = false;
+ changeBlur(ui);
+ $$c('#blur_dropdown li').show();
+ $$c(window).mouseup();
+ },
+ start: function start() {
+ slideStart = true;
+ },
+ slide: function slide(evt, ui) {
+ changeBlur(ui, null, slideStart);
+ }
+ });
+ editor.addDropDown('#zoom_dropdown', function () {
+ var item = $$c(this);
+ var val = item.data('val');
+
+ if (val) {
+ zoomChanged(window, val);
+ } else {
+ changeZoom({
+ value: Number.parseFloat(item.text())
+ });
+ }
+ }, true);
+ addAltDropDown('#stroke_linecap', '#linecap_opts', function () {
+ setStrokeOpt(this, true);
+ }, {
+ dropUp: true
+ });
+ addAltDropDown('#stroke_linejoin', '#linejoin_opts', function () {
+ setStrokeOpt(this, true);
+ }, {
+ dropUp: true
+ });
+ addAltDropDown('#tool_position', '#position_opts', function () {
+ var letter = this.id.replace('tool_pos', '').charAt(0);
+ svgCanvas.alignSelectedElements(letter, 'page');
+ }, {
+ multiclick: true
+ });
+ /*
+ When a flyout icon is selected
+ (if flyout) {
+ - Change the icon
+ - Make pressing the button run its stuff
+ }
+ - Run its stuff
+ When its shortcut key is pressed
+ - If not current in list, do as above
+ , else:
+ - Just run its stuff
+ */
+ // Unfocus text input when workarea is mousedowned.
+
+ (function () {
+ var inp;
+ /**
+ *
+ * @returns {void}
+ */
+
+ var unfocus = function unfocus() {
+ $$c(inp).blur();
+ };
+
+ $$c('#svg_editor').find('button, select, input:not(#text)').focus(function () {
+ inp = this;
+ uiContext = 'toolbars';
+ workarea.mousedown(unfocus);
+ }).blur(function () {
+ uiContext = 'canvas';
+ workarea.unbind('mousedown', unfocus); // Go back to selecting text if in textedit mode
+
+ if (svgCanvas.getMode() === 'textedit') {
+ $$c('#text').focus();
+ }
+ });
+ })();
+ /**
+ *
+ * @returns {void}
+ */
+
+
+ var clickFHPath = function clickFHPath() {
+ if (toolButtonClick('#tool_fhpath')) {
+ svgCanvas.setMode('fhpath');
+ }
+ };
+ /**
+ *
+ * @returns {void}
+ */
+
+
+ var clickLine = function clickLine() {
+ if (toolButtonClick('#tool_line')) {
+ svgCanvas.setMode('line');
+ }
+ };
+ /**
+ *
+ * @returns {void}
+ */
+
+
+ var clickSquare = function clickSquare() {
+ if (toolButtonClick('#tool_square')) {
+ svgCanvas.setMode('square');
+ }
+ };
+ /**
+ *
+ * @returns {void}
+ */
+
+
+ var clickRect = function clickRect() {
+ if (toolButtonClick('#tool_rect')) {
+ svgCanvas.setMode('rect');
+ }
+ };
+ /**
+ *
+ * @returns {void}
+ */
+
+
+ var clickFHRect = function clickFHRect() {
+ if (toolButtonClick('#tool_fhrect')) {
+ svgCanvas.setMode('fhrect');
+ }
+ };
+ /**
+ *
+ * @returns {void}
+ */
+
+
+ var clickCircle = function clickCircle() {
+ if (toolButtonClick('#tool_circle')) {
+ svgCanvas.setMode('circle');
+ }
+ };
+ /**
+ *
+ * @returns {void}
+ */
+
+
+ var clickEllipse = function clickEllipse() {
+ if (toolButtonClick('#tool_ellipse')) {
+ svgCanvas.setMode('ellipse');
+ }
+ };
+ /**
+ *
+ * @returns {void}
+ */
+
+
+ var clickFHEllipse = function clickFHEllipse() {
+ if (toolButtonClick('#tool_fhellipse')) {
+ svgCanvas.setMode('fhellipse');
+ }
+ };
+ /**
+ *
+ * @returns {void}
+ */
+
+
+ var clickImage = function clickImage() {
+ if (toolButtonClick('#tool_image')) {
+ svgCanvas.setMode('image');
+ }
+ };
+ /**
+ *
+ * @returns {void}
+ */
+
+
+ var clickZoom = function clickZoom() {
+ if (toolButtonClick('#tool_zoom')) {
+ svgCanvas.setMode('zoom');
+ workarea.css('cursor', zoomInIcon);
+ }
+ };
+ /**
+ * @param {Float} multiplier
+ * @returns {void}
+ */
+
+
+ var zoomImage = function zoomImage(multiplier) {
+ var res = svgCanvas.getResolution();
+ multiplier = multiplier ? res.zoom * multiplier : 1; // setResolution(res.w * multiplier, res.h * multiplier, true);
+
+ $$c('#zoom').val(multiplier * 100);
+ svgCanvas.setZoom(multiplier);
+ zoomDone();
+ updateCanvas(true);
+ };
+ /**
+ *
+ * @returns {void}
+ */
+
+
+ var dblclickZoom = function dblclickZoom() {
+ if (toolButtonClick('#tool_zoom')) {
+ zoomImage();
+ setSelectMode();
+ }
+ };
+ /**
+ *
+ * @returns {void}
+ */
+
+
+ var clickText = function clickText() {
+ if (toolButtonClick('#tool_text')) {
+ svgCanvas.setMode('text');
+ }
+ };
+ /**
+ *
+ * @returns {void}
+ */
+
+
+ var clickPath = function clickPath() {
+ if (toolButtonClick('#tool_path')) {
+ svgCanvas.setMode('path');
+ }
+ };
+ /**
+ * Delete is a contextual tool that only appears in the ribbon if
+ * an element has been selected.
+ * @returns {void}
+ */
+
+
+ var deleteSelected = function deleteSelected() {
+ if (!isNullish(selectedElement) || multiselected) {
+ svgCanvas.deleteSelectedElements();
+ }
+ };
+ /**
+ *
+ * @returns {void}
+ */
+
+
+ var cutSelected = function cutSelected() {
+ if (!isNullish(selectedElement) || multiselected) {
+ svgCanvas.cutSelectedElements();
+ }
+ };
+ /**
+ *
+ * @returns {void}
+ */
+
+
+ var copySelected = function copySelected() {
+ if (!isNullish(selectedElement) || multiselected) {
+ svgCanvas.copySelectedElements();
+ }
+ };
+ /**
+ *
+ * @returns {void}
+ */
+
+
+ var pasteInCenter = function pasteInCenter() {
+ var zoom = svgCanvas.getZoom();
+ var x = (workarea[0].scrollLeft + workarea.width() / 2) / zoom - svgCanvas.contentW;
+ var y = (workarea[0].scrollTop + workarea.height() / 2) / zoom - svgCanvas.contentH;
+ svgCanvas.pasteElements('point', x, y);
+ };
+ /**
+ *
+ * @returns {void}
+ */
+
+
+ var moveToTopSelected = function moveToTopSelected() {
+ if (!isNullish(selectedElement)) {
+ svgCanvas.moveToTopSelectedElement();
+ }
+ };
+ /**
+ *
+ * @returns {void}
+ */
+
+
+ var moveToBottomSelected = function moveToBottomSelected() {
+ if (!isNullish(selectedElement)) {
+ svgCanvas.moveToBottomSelectedElement();
+ }
+ };
+ /**
+ * @param {"Up"|"Down"} dir
+ * @returns {void}
+ */
+
+
+ var moveUpDownSelected = function moveUpDownSelected(dir) {
+ if (!isNullish(selectedElement)) {
+ svgCanvas.moveUpDownSelected(dir);
+ }
+ };
+ /**
+ *
+ * @returns {void}
+ */
+
+
+ var convertToPath = function convertToPath() {
+ if (!isNullish(selectedElement)) {
+ svgCanvas.convertToPath();
+ }
+ };
+ /**
+ *
+ * @returns {void}
+ */
+
+
+ var reorientPath = function reorientPath() {
+ if (!isNullish(selectedElement)) {
+ path.reorient();
+ }
+ };
+ /**
+ *
+ * @returns {Promise
} Resolves to `undefined`
+ */
+
+
+ var makeHyperlink = /*#__PURE__*/function () {
+ var _ref15 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee7() {
+ var url;
+ return regeneratorRuntime.wrap(function _callee7$(_context7) {
+ while (1) {
+ switch (_context7.prev = _context7.next) {
+ case 0:
+ if (!(!isNullish(selectedElement) || multiselected)) {
+ _context7.next = 5;
+ break;
+ }
+
+ _context7.next = 3;
+ return $$c.prompt(uiStrings$1.notification.enterNewLinkURL, 'http://');
+
+ case 3:
+ url = _context7.sent;
+
+ if (url) {
+ svgCanvas.makeHyperlink(url);
+ }
+
+ case 5:
+ case "end":
+ return _context7.stop();
+ }
+ }
+ }, _callee7);
+ }));
+
+ return function makeHyperlink() {
+ return _ref15.apply(this, arguments);
+ };
+ }();
+ /**
+ * @param {Float} dx
+ * @param {Float} dy
+ * @returns {void}
+ */
+
+
+ var moveSelected = function moveSelected(dx, dy) {
+ if (!isNullish(selectedElement) || multiselected) {
+ if (curConfig.gridSnapping) {
+ // Use grid snap value regardless of zoom level
+ var multi = svgCanvas.getZoom() * curConfig.snappingStep;
+ dx *= multi;
+ dy *= multi;
+ }
+
+ svgCanvas.moveSelectedElements(dx, dy);
+ }
+ };
+ /**
+ *
+ * @returns {void}
+ */
+
+
+ var linkControlPoints = function linkControlPoints() {
+ $$c('#tool_node_link').toggleClass('push_button_pressed tool_button');
+ var linked = $$c('#tool_node_link').hasClass('push_button_pressed');
+ path.linkControlPoints(linked);
+ };
+ /**
+ *
+ * @returns {void}
+ */
+
+
+ var clonePathNode = function clonePathNode() {
+ if (path.getNodePoint()) {
+ path.clonePathNode();
+ }
+ };
+ /**
+ *
+ * @returns {void}
+ */
+
+
+ var deletePathNode = function deletePathNode() {
+ if (path.getNodePoint()) {
+ path.deletePathNode();
+ }
+ };
+ /**
+ *
+ * @returns {void}
+ */
+
+
+ var addSubPath = function addSubPath() {
+ var button = $$c('#tool_add_subpath');
+ var sp = !button.hasClass('push_button_pressed');
+ button.toggleClass('push_button_pressed tool_button');
+ path.addSubPath(sp);
+ };
+ /**
+ *
+ * @returns {void}
+ */
+
+
+ var opencloseSubPath = function opencloseSubPath() {
+ path.opencloseSubPath();
+ };
+ /**
+ *
+ * @returns {void}
+ */
+
+
+ var selectNext = function selectNext() {
+ svgCanvas.cycleElement(1);
+ };
+ /**
+ *
+ * @returns {void}
+ */
+
+
+ var selectPrev = function selectPrev() {
+ svgCanvas.cycleElement(0);
+ };
+ /**
+ * @param {0|1} cw
+ * @param {Integer} step
+ * @returns {void}
+ */
+
+
+ var rotateSelected = function rotateSelected(cw, step) {
+ if (isNullish(selectedElement) || multiselected) {
+ return;
+ }
+
+ if (!cw) {
+ step *= -1;
+ }
+
+ var angle = Number.parseFloat($$c('#angle').val()) + step;
+ svgCanvas.setRotationAngle(angle);
+ updateContextPanel();
+ };
+ /**
+ * @fires module:svgcanvas.SvgCanvas#event:ext_onNewDocument
+ * @returns {Promise} Resolves to `undefined`
+ */
+
+
+ var clickClear = /*#__PURE__*/function () {
+ var _ref16 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee8() {
+ var _curConfig$dimensions, x, y, ok;
+
+ return regeneratorRuntime.wrap(function _callee8$(_context8) {
+ while (1) {
+ switch (_context8.prev = _context8.next) {
+ case 0:
+ _curConfig$dimensions = _slicedToArray(curConfig.dimensions, 2), x = _curConfig$dimensions[0], y = _curConfig$dimensions[1];
+ _context8.next = 3;
+ return $$c.confirm(uiStrings$1.notification.QwantToClear);
+
+ case 3:
+ ok = _context8.sent;
+
+ if (ok) {
+ _context8.next = 6;
+ break;
+ }
+
+ return _context8.abrupt("return");
+
+ case 6:
+ setSelectMode();
+ svgCanvas.clear();
+ svgCanvas.setResolution(x, y);
+ updateCanvas(true);
+ zoomImage();
+ populateLayers();
+ updateContextPanel();
+ prepPaints();
+ svgCanvas.runExtensions('onNewDocument');
+
+ case 15:
+ case "end":
+ return _context8.stop();
+ }
+ }
+ }, _callee8);
+ }));
+
+ return function clickClear() {
+ return _ref16.apply(this, arguments);
+ };
+ }();
+ /**
+ *
+ * @returns {false}
+ */
+
+
+ var clickBold = function clickBold() {
+ svgCanvas.setBold(!svgCanvas.getBold());
+ updateContextPanel();
+ return false;
+ };
+ /**
+ *
+ * @returns {false}
+ */
+
+
+ var clickItalic = function clickItalic() {
+ svgCanvas.setItalic(!svgCanvas.getItalic());
+ updateContextPanel();
+ return false;
+ };
+ /**
+ *
+ * @returns {void}
+ */
+
+
+ var clickSave = function clickSave() {
+ // In the future, more options can be provided here
+ var saveOpts = {
+ images: editor.pref('img_save'),
+ round_digits: 6
+ };
+ svgCanvas.save(saveOpts);
+ };
+
+ var loadingURL;
+ /**
+ *
+ * @returns {Promise} Resolves to `undefined`
+ */
+
+ var clickExport = /*#__PURE__*/function () {
+ var _ref17 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee9() {
+ var imgType, exportWindowName, openExportWindow, chrome, quality;
+ return regeneratorRuntime.wrap(function _callee9$(_context9) {
+ while (1) {
+ switch (_context9.prev = _context9.next) {
+ case 0:
+ openExportWindow = function _openExportWindow() {
+ var loadingImage = uiStrings$1.notification.loadingImage;
+
+ if (curConfig.exportWindowType === 'new') {
+ editor.exportWindowCt++;
+ }
+
+ exportWindowName = curConfig.canvasName + editor.exportWindowCt;
+ var popHTML, popURL;
+
+ if (loadingURL) {
+ popURL = loadingURL;
+ } else {
+ popHTML = "\n \n \n ".concat(loadingImage, "\n \n ").concat(loadingImage, "
\n ");
+
+ if (typeof URL !== 'undefined' && URL.createObjectURL) {
+ var blob = new Blob([popHTML], {
+ type: 'text/html'
+ });
+ popURL = URL.createObjectURL(blob);
+ } else {
+ popURL = 'data:text/html;base64;charset=utf-8,' + encode64(popHTML);
+ }
+
+ loadingURL = popURL;
+ }
+
+ exportWindow = window.open(popURL, exportWindowName);
+ };
+
+ _context9.next = 3;
+ return $$c.select('Select an image type for export: ', [// See http://kangax.github.io/jstests/toDataUrl_mime_type_test/ for a useful list of MIME types and browser support
+ // 'ICO', // Todo: Find a way to preserve transparency in SVG-Edit if not working presently and do full packaging for x-icon; then switch back to position after 'PNG'
+ 'PNG', 'JPEG', 'BMP', 'WEBP', 'PDF'], function () {
+ var sel = $$c(this);
+
+ if (sel.val() === 'JPEG' || sel.val() === 'WEBP') {
+ if (!$$c('#image-slider').length) {
+ $$c("")).appendTo(sel.parent());
+ }
+ } else {
+ $$c('#image-slider').parent().remove();
+ }
+ });
+
+ case 3:
+ imgType = _context9.sent;
+
+ if (imgType) {
+ _context9.next = 6;
+ break;
+ }
+
+ return _context9.abrupt("return");
+
+ case 6:
+ chrome = isChrome();
+
+ if (!(imgType === 'PDF')) {
+ _context9.next = 12;
+ break;
+ }
+
+ if (!customExportPDF && !chrome) {
+ openExportWindow();
+ }
+
+ svgCanvas.exportPDF(exportWindowName);
+ _context9.next = 16;
+ break;
+
+ case 12:
+ if (!customExportImage) {
+ openExportWindow();
+ }
+
+ quality = Number.parseInt($$c('#image-slider').val()) / 100;
+ /* const results = */
+
+ _context9.next = 16;
+ return svgCanvas.rasterExport(imgType, quality, exportWindowName);
+
+ case 16:
+ case "end":
+ return _context9.stop();
+ }
+ }
+ }, _callee9);
+ }));
+
+ return function clickExport() {
+ return _ref17.apply(this, arguments);
+ };
+ }();
+ /**
+ * By default, svgCanvas.open() is a no-op. It is up to an extension
+ * mechanism (opera widget, etc.) to call `setCustomHandlers()` which
+ * will make it do something.
+ * @returns {void}
+ */
+
+
+ var clickOpen = function clickOpen() {
+ svgCanvas.open();
+ };
+ /**
+ *
+ * @returns {void}
+ */
+
+
+ var clickImport = function clickImport() {
+ /* */
+ };
+ /**
+ *
+ * @returns {void}
+ */
+
+
+ var clickUndo = function clickUndo() {
+ if (undoMgr.getUndoStackSize() > 0) {
+ undoMgr.undo();
+ populateLayers();
+ }
+ };
+ /**
+ *
+ * @returns {void}
+ */
+
+
+ var clickRedo = function clickRedo() {
+ if (undoMgr.getRedoStackSize() > 0) {
+ undoMgr.redo();
+ populateLayers();
+ }
+ };
+ /**
+ *
+ * @returns {void}
+ */
+
+
+ var clickGroup = function clickGroup() {
+ // group
+ if (multiselected) {
+ svgCanvas.groupSelectedElements(); // ungroup
+ } else if (selectedElement) {
+ svgCanvas.ungroupSelectedElement();
+ }
+ };
+ /**
+ *
+ * @returns {void}
+ */
+
+
+ var clickClone = function clickClone() {
+ svgCanvas.cloneSelectedElements(20, 20);
+ };
+ /**
+ *
+ * @returns {void}
+ */
+
+
+ var clickAlign = function clickAlign() {
+ var letter = this.id.replace('tool_align', '').charAt(0);
+ svgCanvas.alignSelectedElements(letter, $$c('#align_relative_to').val());
+ };
+ /**
+ *
+ * @returns {void}
+ */
+
+
+ var clickWireframe = function clickWireframe() {
+ $$c('#tool_wireframe').toggleClass('push_button_pressed tool_button');
+ workarea.toggleClass('wireframe');
+
+ if (supportsNonSS) {
+ return;
+ }
+
+ var wfRules = $$c('#wireframe_rules');
+
+ if (!wfRules.length) {
+ /* wfRules = */
+ $$c('').appendTo('head');
+ } else {
+ wfRules.empty();
+ }
+
+ updateWireFrame();
+ };
+
+ $$c('#svg_docprops_container, #svg_prefs_container').draggable({
+ cancel: 'button,fieldset',
+ containment: 'window'
+ }).css('position', 'absolute');
+ var docprops = false;
+ var preferences = false;
+ /**
+ *
+ * @returns {void}
+ */
+
+ var showDocProperties = function showDocProperties() {
+ if (docprops) {
+ return;
+ }
+
+ docprops = true; // This selects the correct radio button by using the array notation
+
+ $$c('#image_save_opts input').val([editor.pref('img_save')]); // update resolution option with actual resolution
+
+ var res = svgCanvas.getResolution();
+
+ if (curConfig.baseUnit !== 'px') {
+ res.w = convertUnit(res.w) + curConfig.baseUnit;
+ res.h = convertUnit(res.h) + curConfig.baseUnit;
+ }
+
+ $$c('#canvas_width').val(res.w);
+ $$c('#canvas_height').val(res.h);
+ $$c('#canvas_title').val(svgCanvas.getDocumentTitle());
+ $$c('#svg_docprops').show();
+ };
+ /**
+ *
+ * @returns {void}
+ */
+
+
+ var showPreferences = function showPreferences() {
+ if (preferences) {
+ return;
+ }
+
+ preferences = true;
+ $$c('#main_menu').hide(); // Update background color with current one
+
+ var canvasBg = curPrefs.bkgd_color;
+ var url = editor.pref('bkgd_url');
+ blocks.each(function () {
+ var blk = $$c(this);
+ var isBg = blk.data('bgcolor') === canvasBg;
+ blk.toggleClass(curBg, isBg);
+ });
+
+ if (!canvasBg) {
+ blocks.eq(0).addClass(curBg);
+ }
+
+ if (url) {
+ $$c('#canvas_bg_url').val(url);
+ }
+
+ $$c('#grid_snapping_on').prop('checked', curConfig.gridSnapping);
+ $$c('#grid_snapping_step').attr('value', curConfig.snappingStep);
+ $$c('#grid_color').attr('value', curConfig.gridColor);
+ $$c('#svg_prefs').show();
+ };
+ /**
+ *
+ * @returns {void}
+ */
+
+
+ var openHomePage = function openHomePage() {
+ window.open(homePage, '_blank');
+ };
+ /**
+ *
+ * @returns {void}
+ */
+
+
+ var hideSourceEditor = function hideSourceEditor() {
+ $$c('#svg_source_editor').hide();
+ editingsource = false;
+ $$c('#svg_source_textarea').blur();
+ };
+ /**
+ *
+ * @returns {Promise} Resolves to `undefined`
+ */
+
+
+ var saveSourceEditor = /*#__PURE__*/function () {
+ var _ref18 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee10() {
+ var saveChanges, ok;
+ return regeneratorRuntime.wrap(function _callee10$(_context10) {
+ while (1) {
+ switch (_context10.prev = _context10.next) {
+ case 0:
+ if (editingsource) {
+ _context10.next = 2;
+ break;
+ }
+
+ return _context10.abrupt("return");
+
+ case 2:
+ saveChanges = function saveChanges() {
+ svgCanvas.clearSelection();
+ hideSourceEditor();
+ zoomImage();
+ populateLayers();
+ updateTitle();
+ prepPaints();
+ };
+
+ if (svgCanvas.setSvgString($$c('#svg_source_textarea').val())) {
+ _context10.next = 11;
+ break;
+ }
+
+ _context10.next = 6;
+ return $$c.confirm(uiStrings$1.notification.QerrorsRevertToSource);
+
+ case 6:
+ ok = _context10.sent;
+
+ if (ok) {
+ _context10.next = 9;
+ break;
+ }
+
+ return _context10.abrupt("return");
+
+ case 9:
+ saveChanges();
+ return _context10.abrupt("return");
+
+ case 11:
+ saveChanges();
+ setSelectMode();
+
+ case 13:
+ case "end":
+ return _context10.stop();
+ }
+ }
+ }, _callee10);
+ }));
+
+ return function saveSourceEditor() {
+ return _ref18.apply(this, arguments);
+ };
+ }();
+ /**
+ *
+ * @returns {void}
+ */
+
+
+ var hideDocProperties = function hideDocProperties() {
+ $$c('#svg_docprops').hide();
+ $$c('#canvas_width,#canvas_height').removeAttr('disabled');
+ $$c('#resolution')[0].selectedIndex = 0;
+ $$c('#image_save_opts input').val([editor.pref('img_save')]);
+ docprops = false;
+ };
+ /**
+ *
+ * @returns {void}
+ */
+
+
+ var hidePreferences = function hidePreferences() {
+ $$c('#svg_prefs').hide();
+ preferences = false;
+ };
+ /**
+ *
+ * @returns {boolean} Whether there were problems saving the document properties
+ */
+
+
+ var saveDocProperties = function saveDocProperties() {
+ // set title
+ var newTitle = $$c('#canvas_title').val();
+ updateTitle(newTitle);
+ svgCanvas.setDocumentTitle(newTitle); // update resolution
+
+ var width = $$c('#canvas_width'),
+ w = width.val();
+ var height = $$c('#canvas_height'),
+ h = height.val();
+
+ if (w !== 'fit' && !isValidUnit('width', w)) {
+ width.parent().addClass('error');
+ /* await */
+
+ $$c.alert(uiStrings$1.notification.invalidAttrValGiven);
+ return false;
+ }
+
+ width.parent().removeClass('error');
+
+ if (h !== 'fit' && !isValidUnit('height', h)) {
+ height.parent().addClass('error');
+ /* await */
+
+ $$c.alert(uiStrings$1.notification.invalidAttrValGiven);
+ return false;
+ }
+
+ height.parent().removeClass('error');
+
+ if (!svgCanvas.setResolution(w, h)) {
+ /* await */
+ $$c.alert(uiStrings$1.notification.noContentToFitTo);
+ return false;
+ } // Set image save option
+
+
+ editor.pref('img_save', $$c('#image_save_opts :checked').val());
+ updateCanvas();
+ hideDocProperties();
+ return true;
+ };
+ /**
+ * Save user preferences based on current values in the UI.
+ * @function module:SVGEditor.savePreferences
+ * @returns {Promise}
+ */
+
+
+ var savePreferences = editor.savePreferences = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee11() {
+ var color, lang, _yield$editor$putLoca2, langParam, langData;
+
+ return regeneratorRuntime.wrap(function _callee11$(_context11) {
+ while (1) {
+ switch (_context11.prev = _context11.next) {
+ case 0:
+ // Set background
+ color = $$c('#bg_blocks div.cur_background').data('bgcolor') || '#FFF';
+ setBackground(color, $$c('#canvas_bg_url').val()); // set language
+
+ lang = $$c('#lang_select').val();
+
+ if (!(lang && lang !== editor.pref('lang'))) {
+ _context11.next = 11;
+ break;
+ }
+
+ _context11.next = 6;
+ return editor.putLocale(lang, goodLangs, curConfig);
+
+ case 6:
+ _yield$editor$putLoca2 = _context11.sent;
+ langParam = _yield$editor$putLoca2.langParam;
+ langData = _yield$editor$putLoca2.langData;
+ _context11.next = 11;
+ return setLang(langParam, langData);
+
+ case 11:
+ // set icon size
+ setIconSize($$c('#iconsize').val()); // set grid setting
+
+ curConfig.gridSnapping = $$c('#grid_snapping_on')[0].checked;
+ curConfig.snappingStep = $$c('#grid_snapping_step').val();
+ curConfig.gridColor = $$c('#grid_color').val();
+ curConfig.showRulers = $$c('#show_rulers')[0].checked;
+ $$c('#rulers').toggle(curConfig.showRulers);
+
+ if (curConfig.showRulers) {
+ updateRulers();
+ }
+
+ curConfig.baseUnit = $$c('#base_unit').val();
+ svgCanvas.setConfig(curConfig);
+ updateCanvas();
+ hidePreferences();
+
+ case 22:
+ case "end":
+ return _context11.stop();
+ }
+ }
+ }, _callee11);
+ }));
+
+ var resetScrollPos = $$c.noop;
+ /**
+ *
+ * @returns {Promise} Resolves to `undefined`
+ */
+
+ var cancelOverlays = /*#__PURE__*/function () {
+ var _ref20 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee12() {
+ var ok;
+ return regeneratorRuntime.wrap(function _callee12$(_context12) {
+ while (1) {
+ switch (_context12.prev = _context12.next) {
+ case 0:
+ $$c('#dialog_box').hide();
+
+ if (!(!editingsource && !docprops && !preferences)) {
+ _context12.next = 4;
+ break;
+ }
+
+ if (curContext) {
+ svgCanvas.leaveContext();
+ }
+
+ return _context12.abrupt("return");
+
+ case 4:
+ if (!editingsource) {
+ _context12.next = 15;
+ break;
+ }
+
+ if (!(origSource !== $$c('#svg_source_textarea').val())) {
+ _context12.next = 12;
+ break;
+ }
+
+ _context12.next = 8;
+ return $$c.confirm(uiStrings$1.notification.QignoreSourceChanges);
+
+ case 8:
+ ok = _context12.sent;
+
+ if (ok) {
+ hideSourceEditor();
+ }
+
+ _context12.next = 13;
+ break;
+
+ case 12:
+ hideSourceEditor();
+
+ case 13:
+ _context12.next = 16;
+ break;
+
+ case 15:
+ if (docprops) {
+ hideDocProperties();
+ } else if (preferences) {
+ hidePreferences();
+ }
+
+ case 16:
+ resetScrollPos();
+
+ case 17:
+ case "end":
+ return _context12.stop();
+ }
+ }
+ }, _callee12);
+ }));
+
+ return function cancelOverlays() {
+ return _ref20.apply(this, arguments);
+ };
+ }();
+
+ var winWh = {
+ width: $$c(window).width(),
+ height: $$c(window).height()
+ }; // Fix for Issue 781: Drawing area jumps to top-left corner on window resize (IE9)
+
+ if (isIE()) {
+ resetScrollPos = function resetScrollPos() {
+ if (workarea[0].scrollLeft === 0 && workarea[0].scrollTop === 0) {
+ workarea[0].scrollLeft = curScrollPos.left;
+ workarea[0].scrollTop = curScrollPos.top;
+ }
+ };
+
+ curScrollPos = {
+ left: workarea[0].scrollLeft,
+ top: workarea[0].scrollTop
+ };
+ $$c(window).resize(resetScrollPos);
+ editor.ready(function () {
+ // TODO: Find better way to detect when to do this to minimize
+ // flickering effect
+ return new Promise(function (resolve, reject) {
+ // eslint-disable-line promise/avoid-new
+ setTimeout(function () {
+ resetScrollPos();
+ resolve();
+ }, 500);
+ });
+ });
+ workarea.scroll(function () {
+ curScrollPos = {
+ left: workarea[0].scrollLeft,
+ top: workarea[0].scrollTop
+ };
+ });
+ }
+
+ $$c(window).resize(function (evt) {
+ $$c.each(winWh, function (type, val) {
+ var curval = $$c(window)[type]();
+ workarea[0]['scroll' + (type === 'width' ? 'Left' : 'Top')] -= (curval - val) / 2;
+ winWh[type] = curval;
+ });
+ setFlyoutPositions();
+ });
+ workarea.scroll(function () {
+ // TODO: jQuery's scrollLeft/Top() wouldn't require a null check
+ if ($$c('#ruler_x').length) {
+ $$c('#ruler_x')[0].scrollLeft = workarea[0].scrollLeft;
+ }
+
+ if ($$c('#ruler_y').length) {
+ $$c('#ruler_y')[0].scrollTop = workarea[0].scrollTop;
+ }
+ });
+ $$c('#url_notice').click(function () {
+ /* await */
+ $$c.alert(this.title);
+ });
+ $$c('#change_image_url').click(promptImgURL); // added these event handlers for all the push buttons so they
+ // behave more like buttons being pressed-in and not images
+
+ (function () {
+ var toolnames = ['clear', 'open', 'save', 'source', 'delete', 'delete_multi', 'paste', 'clone', 'clone_multi', 'move_top', 'move_bottom'];
+ var curClass = 'tool_button_current';
+ var allTools = '';
+ $$c.each(toolnames, function (i, item) {
+ allTools += (i ? ',' : '') + '#tool_' + item;
+ });
+ $$c(allTools).mousedown(function () {
+ $$c(this).addClass(curClass);
+ }).bind('mousedown mouseout', function () {
+ $$c(this).removeClass(curClass);
+ });
+ $$c('#tool_undo, #tool_redo').mousedown(function () {
+ if (!$$c(this).hasClass('disabled')) {
+ $$c(this).addClass(curClass);
+ }
+ }).bind('mousedown mouseout', function () {
+ $$c(this).removeClass(curClass);
+ });
+ })(); // switch modifier key in tooltips if mac
+ // NOTE: This code is not used yet until I can figure out how to successfully bind ctrl/meta
+ // in Opera and Chrome
+
+
+ if (isMac() && !window.opera) {
+ var shortcutButtons = ['tool_clear', 'tool_save', 'tool_source', 'tool_undo', 'tool_redo', 'tool_clone'];
+ var _i = shortcutButtons.length;
+
+ while (_i--) {
+ var button = document.getElementById(shortcutButtons[_i]);
+
+ if (button) {
+ var title = button.title;
+ var index = title.indexOf('Ctrl+');
+ button.title = [title.substr(0, index), 'Cmd+', title.substr(index + 5)].join('');
+ }
+ }
+ }
+ /**
+ * @param {external:jQuery} elem
+ * @todo Go back to the color boxes having white background-color and then setting
+ * background-image to none.png (otherwise partially transparent gradients look weird)
+ * @returns {void}
+ */
+
+
+ var colorPicker = function colorPicker(elem) {
+ var picker = elem.attr('id') === 'stroke_color' ? 'stroke' : 'fill'; // const opacity = (picker == 'stroke' ? $('#stroke_opacity') : $('#fill_opacity'));
+
+ var title = picker === 'stroke' ? uiStrings$1.ui.pick_stroke_paint_opacity : uiStrings$1.ui.pick_fill_paint_opacity; // let wasNone = false; // Currently unused
+
+ var pos = elem.offset();
+ var paint = paintBox[picker].paint;
+ $$c('#color_picker').draggable({
+ cancel: '.jGraduate_tabs, .jGraduate_colPick, .jGraduate_gradPick, .jPicker',
+ containment: 'window'
+ }).css(curConfig.colorPickerCSS || {
+ left: pos.left - 140,
+ bottom: 40
+ }).jGraduate({
+ paint: paint,
+ window: {
+ pickerTitle: title
+ },
+ images: {
+ clientPath: curConfig.jGraduatePath
+ },
+ newstop: 'inverse'
+ }, function (p) {
+ paint = new $$c.jGraduate.Paint(p);
+ paintBox[picker].setPaint(paint);
+ svgCanvas.setPaint(picker, paint);
+ $$c('#color_picker').hide();
+ }, function () {
+ $$c('#color_picker').hide();
+ });
+ };
+ /**
+ * Paint box class.
+ */
+
+
+ var PaintBox = /*#__PURE__*/function () {
+ /**
+ * @param {string|Element|external:jQuery} container
+ * @param {"fill"} type
+ */
+ function PaintBox(container, type) {
+ _classCallCheck(this, PaintBox);
+
+ var cur = curConfig[type === 'fill' ? 'initFill' : 'initStroke']; // set up gradients to be used for the buttons
+
+ var svgdocbox = new DOMParser().parseFromString(""), 'text/xml');
+ var docElem = svgdocbox.documentElement;
+ docElem = $$c(container)[0].appendChild(document.importNode(docElem, true));
+ docElem.setAttribute('width', 16.5);
+ this.rect = docElem.firstElementChild;
+ this.defs = docElem.getElementsByTagName('defs')[0];
+ this.grad = this.defs.firstElementChild;
+ this.paint = new $$c.jGraduate.Paint({
+ solidColor: cur.color
+ });
+ this.type = type;
+ }
+ /**
+ * @param {module:jGraduate~Paint} paint
+ * @param {boolean} apply
+ * @returns {void}
+ */
+
+
+ _createClass(PaintBox, [{
+ key: "setPaint",
+ value: function setPaint(paint, apply) {
+ this.paint = paint;
+ var ptype = paint.type;
+ var opac = paint.alpha / 100;
+ var fillAttr = 'none';
+
+ switch (ptype) {
+ case 'solidColor':
+ fillAttr = paint[ptype] !== 'none' ? '#' + paint[ptype] : paint[ptype];
+ break;
+
+ case 'linearGradient':
+ case 'radialGradient':
+ {
+ this.grad.remove();
+ this.grad = this.defs.appendChild(paint[ptype]);
+ var id = this.grad.id = 'gradbox_' + this.type;
+ fillAttr = 'url(#' + id + ')';
+ break;
+ }
+ }
+
+ this.rect.setAttribute('fill', fillAttr);
+ this.rect.setAttribute('opacity', opac);
+
+ if (apply) {
+ svgCanvas.setColor(this.type, this._paintColor, true);
+ svgCanvas.setPaintOpacity(this.type, this._paintOpacity, true);
+ }
+ }
+ /**
+ * @param {boolean} apply
+ * @returns {void}
+ */
+
+ }, {
+ key: "update",
+ value: function update(apply) {
+ if (!selectedElement) {
+ return;
+ }
+
+ var type = this.type;
+
+ switch (selectedElement.tagName) {
+ case 'use':
+ case 'image':
+ case 'foreignObject':
+ // These elements don't have fill or stroke, so don't change
+ // the current value
+ return;
+
+ case 'g':
+ case 'a':
+ {
+ var childs = selectedElement.getElementsByTagName('*');
+ var gPaint = null;
+
+ for (var _i2 = 0, len = childs.length; _i2 < len; _i2++) {
+ var elem = childs[_i2];
+ var p = elem.getAttribute(type);
+
+ if (_i2 === 0) {
+ gPaint = p;
+ } else if (gPaint !== p) {
+ gPaint = null;
+ break;
+ }
+ }
+
+ if (gPaint === null) {
+ // No common color, don't update anything
+ this._paintColor = null;
+ return;
+ }
+
+ this._paintColor = gPaint;
+ this._paintOpacity = 1;
+ break;
+ }
+
+ default:
+ {
+ this._paintOpacity = Number.parseFloat(selectedElement.getAttribute(type + '-opacity'));
+
+ if (Number.isNaN(this._paintOpacity)) {
+ this._paintOpacity = 1.0;
+ }
+
+ var defColor = type === 'fill' ? 'black' : 'none';
+ this._paintColor = selectedElement.getAttribute(type) || defColor;
+ }
+ }
+
+ if (apply) {
+ svgCanvas.setColor(type, this._paintColor, true);
+ svgCanvas.setPaintOpacity(type, this._paintOpacity, true);
+ }
+
+ this._paintOpacity *= 100;
+ var paint = getPaint(this._paintColor, this._paintOpacity, type); // update the rect inside #fill_color/#stroke_color
+
+ this.setPaint(paint);
+ }
+ /**
+ * @returns {void}
+ */
+
+ }, {
+ key: "prep",
+ value: function prep() {
+ var ptype = this.paint.type;
+
+ switch (ptype) {
+ case 'linearGradient':
+ case 'radialGradient':
+ {
+ var paint = new $$c.jGraduate.Paint({
+ copy: this.paint
+ });
+ svgCanvas.setPaint(this.type, paint);
+ break;
+ }
+ }
+ }
+ }]);
+
+ return PaintBox;
+ }();
+
+ PaintBox.ctr = 0;
+ paintBox.fill = new PaintBox('#fill_color', 'fill');
+ paintBox.stroke = new PaintBox('#stroke_color', 'stroke');
+ $$c('#stroke_width').val(curConfig.initStroke.width);
+ $$c('#group_opacity').val(curConfig.initOpacity * 100); // Use this SVG elem to test vectorEffect support
+
+ var testEl = paintBox.fill.rect.cloneNode(false);
+ testEl.setAttribute('style', 'vector-effect:non-scaling-stroke');
+ var supportsNonSS = testEl.style.vectorEffect === 'non-scaling-stroke';
+ testEl.removeAttribute('style');
+ var svgdocbox = paintBox.fill.rect.ownerDocument; // Use this to test support for blur element. Seems to work to test support in Webkit
+
+ var blurTest = svgdocbox.createElementNS(NS.SVG, 'feGaussianBlur');
+
+ if (blurTest.stdDeviationX === undefined) {
+ $$c('#tool_blur').hide();
+ }
+
+ $$c(blurTest).remove(); // Test for zoom icon support
+
+ (function () {
+ var pre = '-' + uaPrefix.toLowerCase() + '-zoom-';
+ var zoom = pre + 'in';
+ workarea.css('cursor', zoom);
+
+ if (workarea.css('cursor') === zoom) {
+ zoomInIcon = zoom;
+ zoomOutIcon = pre + 'out';
+ }
+
+ workarea.css('cursor', 'auto');
+ })(); // Test for embedImage support (use timeout to not interfere with page load)
+
+
+ setTimeout(function () {
+ svgCanvas.embedImage('images/logo.png', function (datauri) {
+ if (!datauri) {
+ // Disable option
+ $$c('#image_save_opts [value=embed]').attr('disabled', 'disabled');
+ $$c('#image_save_opts input').val(['ref']);
+ editor.pref('img_save', 'ref');
+ $$c('#image_opt_embed').css('color', '#666').attr('title', uiStrings$1.notification.featNotSupported);
+ }
+ });
+ }, 1000);
+ $$c('#fill_color, #tool_fill .icon_label').click(function () {
+ colorPicker($$c('#fill_color'));
+ updateToolButtonState();
+ });
+ $$c('#stroke_color, #tool_stroke .icon_label').click(function () {
+ colorPicker($$c('#stroke_color'));
+ updateToolButtonState();
+ });
+ $$c('#group_opacityLabel').click(function () {
+ $$c('#opacity_dropdown button').mousedown();
+ $$c(window).mouseup();
+ });
+ $$c('#zoomLabel').click(function () {
+ $$c('#zoom_dropdown button').mousedown();
+ $$c(window).mouseup();
+ });
+ $$c('#tool_move_top').mousedown(function (evt) {
+ $$c('#tools_stacking').show();
+ evt.preventDefault();
+ });
+ $$c('.layer_button').mousedown(function () {
+ $$c(this).addClass('layer_buttonpressed');
+ }).mouseout(function () {
+ $$c(this).removeClass('layer_buttonpressed');
+ }).mouseup(function () {
+ $$c(this).removeClass('layer_buttonpressed');
+ });
+ $$c('.push_button').mousedown(function () {
+ if (!$$c(this).hasClass('disabled')) {
+ $$c(this).addClass('push_button_pressed').removeClass('push_button');
+ }
+ }).mouseout(function () {
+ $$c(this).removeClass('push_button_pressed').addClass('push_button');
+ }).mouseup(function () {
+ $$c(this).removeClass('push_button_pressed').addClass('push_button');
+ }); // ask for a layer name
+
+ $$c('#layer_new').click( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee13() {
+ var uniqName, i, newName;
+ return regeneratorRuntime.wrap(function _callee13$(_context13) {
+ while (1) {
+ switch (_context13.prev = _context13.next) {
+ case 0:
+ i = svgCanvas.getCurrentDrawing().getNumLayers();
+
+ do {
+ uniqName = uiStrings$1.layers.layer + ' ' + ++i;
+ } while (svgCanvas.getCurrentDrawing().hasLayer(uniqName));
+
+ _context13.next = 4;
+ return $$c.prompt(uiStrings$1.notification.enterUniqueLayerName, uniqName);
+
+ case 4:
+ newName = _context13.sent;
+
+ if (newName) {
+ _context13.next = 7;
+ break;
+ }
+
+ return _context13.abrupt("return");
+
+ case 7:
+ if (!svgCanvas.getCurrentDrawing().hasLayer(newName)) {
+ _context13.next = 10;
+ break;
+ }
+
+ /* await */
+ $$c.alert(uiStrings$1.notification.dupeLayerName);
+ return _context13.abrupt("return");
+
+ case 10:
+ svgCanvas.createLayer(newName);
+ updateContextPanel();
+ populateLayers();
+
+ case 13:
+ case "end":
+ return _context13.stop();
+ }
+ }
+ }, _callee13);
+ })));
+ /**
+ *
+ * @returns {void}
+ */
+
+ function deleteLayer() {
+ if (svgCanvas.deleteCurrentLayer()) {
+ updateContextPanel();
+ populateLayers(); // This matches what SvgCanvas does
+ // TODO: make this behavior less brittle (svg-editor should get which
+ // layer is selected from the canvas and then select that one in the UI)
+
+ $$c('#layerlist tr.layer').removeClass('layersel');
+ $$c('#layerlist tr.layer:first').addClass('layersel');
+ }
+ }
+ /**
+ *
+ * @returns {Promise}
+ */
+
+
+ function cloneLayer() {
+ return _cloneLayer.apply(this, arguments);
+ }
+ /**
+ *
+ * @returns {void}
+ */
+
+
+ function _cloneLayer() {
+ _cloneLayer = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee19() {
+ var name, newName;
+ return regeneratorRuntime.wrap(function _callee19$(_context19) {
+ while (1) {
+ switch (_context19.prev = _context19.next) {
+ case 0:
+ name = svgCanvas.getCurrentDrawing().getCurrentLayerName() + ' copy';
+ _context19.next = 3;
+ return $$c.prompt(uiStrings$1.notification.enterUniqueLayerName, name);
+
+ case 3:
+ newName = _context19.sent;
+
+ if (newName) {
+ _context19.next = 6;
+ break;
+ }
+
+ return _context19.abrupt("return");
+
+ case 6:
+ if (!svgCanvas.getCurrentDrawing().hasLayer(newName)) {
+ _context19.next = 9;
+ break;
+ }
+
+ /* await */
+ $$c.alert(uiStrings$1.notification.dupeLayerName);
+ return _context19.abrupt("return");
+
+ case 9:
+ svgCanvas.cloneLayer(newName);
+ updateContextPanel();
+ populateLayers();
+
+ case 12:
+ case "end":
+ return _context19.stop();
+ }
+ }
+ }, _callee19);
+ }));
+ return _cloneLayer.apply(this, arguments);
+ }
+
+ function mergeLayer() {
+ if ($$c('#layerlist tr.layersel').index() === svgCanvas.getCurrentDrawing().getNumLayers() - 1) {
+ return;
+ }
+
+ svgCanvas.mergeLayer();
+ updateContextPanel();
+ populateLayers();
+ }
+ /**
+ * @param {Integer} pos
+ * @returns {void}
+ */
+
+
+ function moveLayer(pos) {
+ var total = svgCanvas.getCurrentDrawing().getNumLayers();
+ var curIndex = $$c('#layerlist tr.layersel').index();
+
+ if (curIndex > 0 || curIndex < total - 1) {
+ curIndex += pos;
+ svgCanvas.setCurrentLayerPosition(total - curIndex - 1);
+ populateLayers();
+ }
+ }
+
+ $$c('#layer_delete').click(deleteLayer);
+ $$c('#layer_up').click(function () {
+ moveLayer(-1);
+ });
+ $$c('#layer_down').click(function () {
+ moveLayer(1);
+ });
+ $$c('#layer_rename').click( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee14() {
+ var oldName, newName;
+ return regeneratorRuntime.wrap(function _callee14$(_context14) {
+ while (1) {
+ switch (_context14.prev = _context14.next) {
+ case 0:
+ // const curIndex = $('#layerlist tr.layersel').prevAll().length; // Currently unused
+ oldName = $$c('#layerlist tr.layersel td.layername').text();
+ _context14.next = 3;
+ return $$c.prompt(uiStrings$1.notification.enterNewLayerName, '');
+
+ case 3:
+ newName = _context14.sent;
+
+ if (newName) {
+ _context14.next = 6;
+ break;
+ }
+
+ return _context14.abrupt("return");
+
+ case 6:
+ if (!(oldName === newName || svgCanvas.getCurrentDrawing().hasLayer(newName))) {
+ _context14.next = 9;
+ break;
+ }
+
+ /* await */
+ $$c.alert(uiStrings$1.notification.layerHasThatName);
+ return _context14.abrupt("return");
+
+ case 9:
+ svgCanvas.renameCurrentLayer(newName);
+ populateLayers();
+
+ case 11:
+ case "end":
+ return _context14.stop();
+ }
+ }
+ }, _callee14);
+ })));
+ var SIDEPANEL_MAXWIDTH = 300;
+ var SIDEPANEL_OPENWIDTH = 150;
+ var sidedrag = -1,
+ sidedragging = false,
+ allowmove = false;
+ /**
+ * @param {Float} delta
+ * @fires module:svgcanvas.SvgCanvas#event:ext_workareaResized
+ * @returns {void}
+ */
+
+ var changeSidePanelWidth = function changeSidePanelWidth(delta) {
+ var rulerX = $$c('#ruler_x');
+ $$c('#sidepanels').width('+=' + delta);
+ $$c('#layerpanel').width('+=' + delta);
+ rulerX.css('right', Number.parseInt(rulerX.css('right')) + delta);
+ workarea.css('right', Number.parseInt(workarea.css('right')) + delta);
+ svgCanvas.runExtensions('workareaResized');
+ };
+ /**
+ * @param {Event} evt
+ * @returns {void}
+ */
+
+
+ var resizeSidePanel = function resizeSidePanel(evt) {
+ if (!allowmove) {
+ return;
+ }
+
+ if (sidedrag === -1) {
+ return;
+ }
+
+ sidedragging = true;
+ var deltaX = sidedrag - evt.pageX;
+ var sideWidth = $$c('#sidepanels').width();
+
+ if (sideWidth + deltaX > SIDEPANEL_MAXWIDTH) {
+ deltaX = SIDEPANEL_MAXWIDTH - sideWidth; // sideWidth = SIDEPANEL_MAXWIDTH;
+ } else if (sideWidth + deltaX < 2) {
+ deltaX = 2 - sideWidth; // sideWidth = 2;
+ }
+
+ if (deltaX === 0) {
+ return;
+ }
+
+ sidedrag -= deltaX;
+ changeSidePanelWidth(deltaX);
+ };
+ /**
+ * If width is non-zero, then fully close it; otherwise fully open it.
+ * @param {boolean} close Forces the side panel closed
+ * @returns {void}
+ */
+
+
+ var toggleSidePanel = function toggleSidePanel(close) {
+ var dpr = window.devicePixelRatio || 1;
+ var w = $$c('#sidepanels').width();
+ var isOpened = (dpr < 1 ? w : w / dpr) > 2;
+ var zoomAdjustedSidepanelWidth = (dpr < 1 ? 1 : dpr) * SIDEPANEL_OPENWIDTH;
+ var deltaX = (isOpened || close ? 0 : zoomAdjustedSidepanelWidth) - w;
+ changeSidePanelWidth(deltaX);
+ };
+
+ $$c('#sidepanel_handle').mousedown(function (evt) {
+ sidedrag = evt.pageX;
+ $$c(window).mousemove(resizeSidePanel);
+ allowmove = false; // Silly hack for Chrome, which always runs mousemove right after mousedown
+
+ setTimeout(function () {
+ allowmove = true;
+ }, 20);
+ }).mouseup(function (evt) {
+ if (!sidedragging) {
+ toggleSidePanel();
+ }
+
+ sidedrag = -1;
+ sidedragging = false;
+ });
+ $$c(window).mouseup(function () {
+ sidedrag = -1;
+ sidedragging = false;
+ $$c('#svg_editor').unbind('mousemove', resizeSidePanel);
+ });
+ populateLayers(); // function changeResolution (x,y) {
+ // const {zoom} = svgCanvas.getResolution();
+ // setResolution(x * zoom, y * zoom);
+ // }
+
+ var centerCanvas = function centerCanvas() {
+ // this centers the canvas vertically in the workarea (horizontal handled in CSS)
+ workarea.css('line-height', workarea.height() + 'px');
+ };
+
+ $$c(window).bind('load resize', centerCanvas);
+ /**
+ * @type {module:jQuerySpinButton.StepCallback}
+ */
+
+ function stepFontSize(elem, step) {
+ var origVal = Number(elem.value);
+ var sugVal = origVal + step;
+ var increasing = sugVal >= origVal;
+
+ if (step === 0) {
+ return origVal;
+ }
+
+ if (origVal >= 24) {
+ if (increasing) {
+ return Math.round(origVal * 1.1);
+ }
+
+ return Math.round(origVal / 1.1);
+ }
+
+ if (origVal <= 1) {
+ if (increasing) {
+ return origVal * 2;
+ }
+
+ return origVal / 2;
+ }
+
+ return sugVal;
+ }
+ /**
+ * @type {module:jQuerySpinButton.StepCallback}
+ */
+
+
+ function stepZoom(elem, step) {
+ var origVal = Number(elem.value);
+
+ if (origVal === 0) {
+ return 100;
+ }
+
+ var sugVal = origVal + step;
+
+ if (step === 0) {
+ return origVal;
+ }
+
+ if (origVal >= 100) {
+ return sugVal;
+ }
+
+ if (sugVal >= origVal) {
+ return origVal * 2;
+ }
+
+ return origVal / 2;
+ } // function setResolution (w, h, center) {
+ // updateCanvas();
+ // // w -= 0; h -= 0;
+ // // $('#svgcanvas').css({width: w, height: h});
+ // // $('#canvas_width').val(w);
+ // // $('#canvas_height').val(h);
+ // //
+ // // if (center) {
+ // // const wArea = workarea;
+ // // const scrollY = h/2 - wArea.height()/2;
+ // // const scrollX = w/2 - wArea.width()/2;
+ // // wArea[0].scrollTop = scrollY;
+ // // wArea[0].scrollLeft = scrollX;
+ // // }
+ // }
+
+
+ $$c('#resolution').change(function () {
+ var wh = $$c('#canvas_width,#canvas_height');
+
+ if (!this.selectedIndex) {
+ if ($$c('#canvas_width').val() === 'fit') {
+ wh.removeAttr('disabled').val(100);
+ }
+ } else if (this.value === 'content') {
+ wh.val('fit').attr('disabled', 'disabled');
+ } else {
+ var dims = this.value.split('x');
+ $$c('#canvas_width').val(dims[0]);
+ $$c('#canvas_height').val(dims[1]);
+ wh.removeAttr('disabled');
+ }
+ }); // Prevent browser from erroneously repopulating fields
+
+ $$c('input,select').attr('autocomplete', 'off');
+ var dialogSelectors = ['#tool_source_cancel', '#tool_docprops_cancel', '#tool_prefs_cancel', '.overlay'];
+ /* eslint-disable jsdoc/require-property */
+
+ /**
+ * Associate all button actions as well as non-button keyboard shortcuts.
+ * @namespace {PlainObject} module:SVGEditor~Actions
+ */
+
+ var Actions = function () {
+ /* eslint-enable jsdoc/require-property */
+
+ /**
+ * @typedef {PlainObject} module:SVGEditor.ToolButton
+ * @property {string} sel The CSS selector for the tool
+ * @property {external:jQuery.Function} fn A handler to be attached to the `evt`
+ * @property {string} evt The event for which the `fn` listener will be added
+ * @property {module:SVGEditor.Key} [key] [key, preventDefault, NoDisableInInput]
+ * @property {string} [parent] Selector
+ * @property {boolean} [hidekey] Whether to show key value in title
+ * @property {string} [icon] The button ID
+ * @property {boolean} isDefault For flyout holders
+ */
+
+ /**
+ *
+ * @name module:SVGEditor~ToolButtons
+ * @type {module:SVGEditor.ToolButton[]}
+ */
+ var toolButtons = [{
+ sel: '#tool_select',
+ fn: clickSelect,
+ evt: 'click',
+ key: ['V', true]
+ }, {
+ sel: '#tool_fhpath',
+ fn: clickFHPath,
+ evt: 'click',
+ key: ['Q', true]
+ }, {
+ sel: '#tool_line',
+ fn: clickLine,
+ evt: 'click',
+ key: ['L', true],
+ parent: '#tools_line',
+ prepend: true
+ }, {
+ sel: '#tool_rect',
+ fn: clickRect,
+ evt: 'mouseup',
+ key: ['R', true],
+ parent: '#tools_rect',
+ icon: 'rect'
+ }, {
+ sel: '#tool_square',
+ fn: clickSquare,
+ evt: 'mouseup',
+ parent: '#tools_rect',
+ icon: 'square'
+ }, {
+ sel: '#tool_fhrect',
+ fn: clickFHRect,
+ evt: 'mouseup',
+ parent: '#tools_rect',
+ icon: 'fh_rect'
+ }, {
+ sel: '#tool_ellipse',
+ fn: clickEllipse,
+ evt: 'mouseup',
+ key: ['E', true],
+ parent: '#tools_ellipse',
+ icon: 'ellipse'
+ }, {
+ sel: '#tool_circle',
+ fn: clickCircle,
+ evt: 'mouseup',
+ parent: '#tools_ellipse',
+ icon: 'circle'
+ }, {
+ sel: '#tool_fhellipse',
+ fn: clickFHEllipse,
+ evt: 'mouseup',
+ parent: '#tools_ellipse',
+ icon: 'fh_ellipse'
+ }, {
+ sel: '#tool_path',
+ fn: clickPath,
+ evt: 'click',
+ key: ['P', true]
+ }, {
+ sel: '#tool_text',
+ fn: clickText,
+ evt: 'click',
+ key: ['T', true]
+ }, {
+ sel: '#tool_image',
+ fn: clickImage,
+ evt: 'mouseup'
+ }, {
+ sel: '#tool_zoom',
+ fn: clickZoom,
+ evt: 'mouseup',
+ key: ['Z', true]
+ }, {
+ sel: '#tool_clear',
+ fn: clickClear,
+ evt: 'mouseup',
+ key: ['N', true]
+ }, {
+ sel: '#tool_save',
+ fn: function fn() {
+ if (editingsource) {
+ saveSourceEditor();
+ } else {
+ clickSave();
+ }
+ },
+ evt: 'mouseup',
+ key: ['S', true]
+ }, {
+ sel: '#tool_export',
+ fn: clickExport,
+ evt: 'mouseup'
+ }, {
+ sel: '#tool_open',
+ fn: clickOpen,
+ evt: 'mouseup',
+ key: ['O', true]
+ }, {
+ sel: '#tool_import',
+ fn: clickImport,
+ evt: 'mouseup'
+ }, {
+ sel: '#tool_source',
+ fn: showSourceEditor,
+ evt: 'click',
+ key: ['U', true]
+ }, {
+ sel: '#tool_wireframe',
+ fn: clickWireframe,
+ evt: 'click',
+ key: ['F', true]
+ }, {
+ key: ['esc', false, false],
+ fn: function fn() {
+ if (dialogSelectors.every(function (sel) {
+ return $$c(sel + ':hidden').length;
+ })) {
+ svgCanvas.clearSelection();
+ }
+ },
+ hidekey: true
+ }, {
+ sel: dialogSelectors.join(','),
+ fn: cancelOverlays,
+ evt: 'click',
+ key: ['esc', false, false],
+ hidekey: true
+ }, {
+ sel: '#tool_source_save',
+ fn: saveSourceEditor,
+ evt: 'click'
+ }, {
+ sel: '#tool_docprops_save',
+ fn: saveDocProperties,
+ evt: 'click'
+ }, {
+ sel: '#tool_docprops',
+ fn: showDocProperties,
+ evt: 'click'
+ }, {
+ sel: '#tool_prefs_save',
+ fn: savePreferences,
+ evt: 'click'
+ }, {
+ sel: '#tool_editor_prefs',
+ fn: showPreferences,
+ evt: 'click'
+ }, {
+ sel: '#tool_editor_homepage',
+ fn: openHomePage,
+ evt: 'click'
+ }, {
+ sel: '#tool_open',
+ fn: function fn() {
+ window.dispatchEvent(new CustomEvent('openImage'));
+ },
+ evt: 'click'
+ }, {
+ sel: '#tool_import',
+ fn: function fn() {
+ window.dispatchEvent(new CustomEvent('importImage'));
+ },
+ evt: 'click'
+ }, {
+ sel: '#tool_delete,#tool_delete_multi',
+ fn: deleteSelected,
+ evt: 'click',
+ key: ['del/backspace', true]
+ }, {
+ sel: '#tool_reorient',
+ fn: reorientPath,
+ evt: 'click'
+ }, {
+ sel: '#tool_node_link',
+ fn: linkControlPoints,
+ evt: 'click'
+ }, {
+ sel: '#tool_node_clone',
+ fn: clonePathNode,
+ evt: 'click'
+ }, {
+ sel: '#tool_node_delete',
+ fn: deletePathNode,
+ evt: 'click'
+ }, {
+ sel: '#tool_openclose_path',
+ fn: opencloseSubPath,
+ evt: 'click'
+ }, {
+ sel: '#tool_add_subpath',
+ fn: addSubPath,
+ evt: 'click'
+ }, {
+ sel: '#tool_move_top',
+ fn: moveToTopSelected,
+ evt: 'click',
+ key: 'ctrl+shift+]'
+ }, {
+ sel: '#tool_move_bottom',
+ fn: moveToBottomSelected,
+ evt: 'click',
+ key: 'ctrl+shift+['
+ }, {
+ sel: '#tool_topath',
+ fn: convertToPath,
+ evt: 'click'
+ }, {
+ sel: '#tool_make_link,#tool_make_link_multi',
+ fn: makeHyperlink,
+ evt: 'click'
+ }, {
+ sel: '#tool_undo',
+ fn: clickUndo,
+ evt: 'click'
+ }, {
+ sel: '#tool_redo',
+ fn: clickRedo,
+ evt: 'click'
+ }, {
+ sel: '#tool_clone,#tool_clone_multi',
+ fn: clickClone,
+ evt: 'click',
+ key: ['D', true]
+ }, {
+ sel: '#tool_group_elements',
+ fn: clickGroup,
+ evt: 'click',
+ key: ['G', true]
+ }, {
+ sel: '#tool_ungroup',
+ fn: clickGroup,
+ evt: 'click'
+ }, {
+ sel: '#tool_unlink_use',
+ fn: clickGroup,
+ evt: 'click'
+ }, {
+ sel: '[id^=tool_align]',
+ fn: clickAlign,
+ evt: 'click'
+ }, // these two lines are required to make Opera work properly with the flyout mechanism
+ // {sel: '#tools_rect_show', fn: clickRect, evt: 'click'},
+ // {sel: '#tools_ellipse_show', fn: clickEllipse, evt: 'click'},
+ {
+ sel: '#tool_bold',
+ fn: clickBold,
+ evt: 'mousedown'
+ }, {
+ sel: '#tool_italic',
+ fn: clickItalic,
+ evt: 'mousedown'
+ }, {
+ sel: '#sidepanel_handle',
+ fn: toggleSidePanel,
+ key: ['X']
+ }, {
+ sel: '#copy_save_done',
+ fn: cancelOverlays,
+ evt: 'click'
+ }, // Shortcuts not associated with buttons
+ {
+ key: 'ctrl+left',
+ fn: function fn() {
+ rotateSelected(0, 1);
+ }
+ }, {
+ key: 'ctrl+right',
+ fn: function fn() {
+ rotateSelected(1, 1);
+ }
+ }, {
+ key: 'ctrl+shift+left',
+ fn: function fn() {
+ rotateSelected(0, 5);
+ }
+ }, {
+ key: 'ctrl+shift+right',
+ fn: function fn() {
+ rotateSelected(1, 5);
+ }
+ }, {
+ key: 'shift+O',
+ fn: selectPrev
+ }, {
+ key: 'shift+P',
+ fn: selectNext
+ }, {
+ key: [modKey + 'up', true],
+ fn: function fn() {
+ zoomImage(2);
+ }
+ }, {
+ key: [modKey + 'down', true],
+ fn: function fn() {
+ zoomImage(0.5);
+ }
+ }, {
+ key: [modKey + ']', true],
+ fn: function fn() {
+ moveUpDownSelected('Up');
+ }
+ }, {
+ key: [modKey + '[', true],
+ fn: function fn() {
+ moveUpDownSelected('Down');
+ }
+ }, {
+ key: ['up', true],
+ fn: function fn() {
+ moveSelected(0, -1);
+ }
+ }, {
+ key: ['down', true],
+ fn: function fn() {
+ moveSelected(0, 1);
+ }
+ }, {
+ key: ['left', true],
+ fn: function fn() {
+ moveSelected(-1, 0);
+ }
+ }, {
+ key: ['right', true],
+ fn: function fn() {
+ moveSelected(1, 0);
+ }
+ }, {
+ key: 'shift+up',
+ fn: function fn() {
+ moveSelected(0, -10);
+ }
+ }, {
+ key: 'shift+down',
+ fn: function fn() {
+ moveSelected(0, 10);
+ }
+ }, {
+ key: 'shift+left',
+ fn: function fn() {
+ moveSelected(-10, 0);
+ }
+ }, {
+ key: 'shift+right',
+ fn: function fn() {
+ moveSelected(10, 0);
+ }
+ }, {
+ key: ['alt+up', true],
+ fn: function fn() {
+ svgCanvas.cloneSelectedElements(0, -1);
+ }
+ }, {
+ key: ['alt+down', true],
+ fn: function fn() {
+ svgCanvas.cloneSelectedElements(0, 1);
+ }
+ }, {
+ key: ['alt+left', true],
+ fn: function fn() {
+ svgCanvas.cloneSelectedElements(-1, 0);
+ }
+ }, {
+ key: ['alt+right', true],
+ fn: function fn() {
+ svgCanvas.cloneSelectedElements(1, 0);
+ }
+ }, {
+ key: ['alt+shift+up', true],
+ fn: function fn() {
+ svgCanvas.cloneSelectedElements(0, -10);
+ }
+ }, {
+ key: ['alt+shift+down', true],
+ fn: function fn() {
+ svgCanvas.cloneSelectedElements(0, 10);
+ }
+ }, {
+ key: ['alt+shift+left', true],
+ fn: function fn() {
+ svgCanvas.cloneSelectedElements(-10, 0);
+ }
+ }, {
+ key: ['alt+shift+right', true],
+ fn: function fn() {
+ svgCanvas.cloneSelectedElements(10, 0);
+ }
+ }, {
+ key: 'a',
+ fn: function fn() {
+ svgCanvas.selectAllInCurrentLayer();
+ }
+ }, {
+ key: modKey + 'a',
+ fn: function fn() {
+ svgCanvas.selectAllInCurrentLayer();
+ }
+ }, // Standard shortcuts
+ {
+ key: modKey + 'z',
+ fn: clickUndo
+ }, {
+ key: modKey + 'shift+z',
+ fn: clickRedo
+ }, {
+ key: modKey + 'y',
+ fn: clickRedo
+ }, {
+ key: modKey + 'x',
+ fn: cutSelected
+ }, {
+ key: modKey + 'c',
+ fn: copySelected
+ }, {
+ key: modKey + 'v',
+ fn: pasteInCenter
+ }]; // Tooltips not directly associated with a single function
+
+ var keyAssocs = {
+ '4/Shift+4': '#tools_rect_show',
+ '5/Shift+5': '#tools_ellipse_show'
+ };
+ return {
+ /** @lends module:SVGEditor~Actions */
+
+ /**
+ * @returns {void}
+ */
+ setAll: function setAll() {
+ var flyouts = {};
+ var keyHandler = {}; // will contain the action for each pressed key
+
+ toolButtons.forEach(function (opts) {
+ // Bind function to button
+ var btn;
+
+ if (opts.sel) {
+ btn = $q$1(opts.sel);
+
+ if (btn === null) {
+ return true;
+ } // Skip if markup does not exist
+
+
+ if (opts.evt) {
+ // `touch.js` changes `touchstart` to `mousedown`,
+ // so we must map tool button click events as well
+ if (isTouch() && opts.evt === 'click') {
+ opts.evt = 'mousedown';
+ }
+
+ btn.addEventListener(opts.evt, opts.fn);
+ } // Add to parent flyout menu, if able to be displayed
+
+
+ if (opts.parent && $$c(opts.parent + '_show').length) {
+ var fH = $$c(opts.parent);
+
+ if (!fH.length) {
+ fH = makeFlyoutHolder(opts.parent.substr(1));
+ }
+
+ if (opts.prepend) {
+ btn.style.margin = 'initial';
+ }
+
+ fH[opts.prepend ? 'prepend' : 'append'](btn);
+
+ if (!Array.isArray(flyouts[opts.parent])) {
+ flyouts[opts.parent] = [];
+ }
+
+ flyouts[opts.parent].push(opts);
+ }
+ } // Bind function to shortcut key
+
+
+ if (opts.key) {
+ // Set shortcut based on options
+ var keyval = opts.key;
+ var pd = false;
+
+ if (Array.isArray(opts.key)) {
+ keyval = opts.key[0];
+
+ if (opts.key.length > 1) {
+ pd = opts.key[1];
+ }
+ }
+
+ keyval = String(keyval);
+ var fn = opts.fn;
+ keyval.split('/').forEach(function (key) {
+ keyHandler[key] = {
+ fn: fn,
+ pd: pd
+ };
+ }); // Put shortcut in title
+
+ if (opts.sel && !opts.hidekey && btn.title) {
+ var newTitle = "".concat(btn.title.split('[')[0], " (").concat(keyval, ")");
+ keyAssocs[keyval] = opts.sel; // Disregard for menu items
+
+ if (btn.closest('#main_menu') === null) {
+ btn.title = newTitle;
+ }
+ }
+ }
+
+ return true;
+ }); // register the keydown event
+
+ document.addEventListener('keydown', function (e) {
+ // only track keyboard shortcuts for the body containing the SVG-Editor
+ if (e.target.nodeName !== 'BODY') return; // normalize key
+
+ var key = "".concat(e.metaKey ? 'meta+' : '').concat(e.ctrlKey ? 'ctrl+' : '').concat(e.key.toLowerCase()); // return if no shortcut defined for this key
+
+ if (!keyHandler[key]) return; // launch associated handler and preventDefault if necessary
+
+ keyHandler[key].fn();
+
+ if (keyHandler[key].pd) {
+ e.preventDefault();
+ }
+ }); // Setup flyouts
+
+ setupFlyouts(flyouts); // Misc additional actions
+ // Make 'return' keypress trigger the change event
+
+ $$c('.attr_changer, #image_url').bind('keydown', 'return', function (evt) {
+ $$c(this).change();
+ evt.preventDefault();
+ });
+ $$c(window).bind('keydown', 'tab', function (e) {
+ if (uiContext === 'canvas') {
+ e.preventDefault();
+ selectNext();
+ }
+ }).bind('keydown', 'shift+tab', function (e) {
+ if (uiContext === 'canvas') {
+ e.preventDefault();
+ selectPrev();
+ }
+ });
+ $$c('#tool_zoom').dblclick(dblclickZoom);
+ },
+
+ /**
+ * @returns {void}
+ */
+ setTitles: function setTitles() {
+ $$c.each(keyAssocs, function (keyval, sel) {
+ var menu = $$c(sel).parents('#main_menu').length;
+ $$c(sel).each(function () {
+ var t;
+
+ if (menu) {
+ t = $$c(this).text().split(' [')[0];
+ } else {
+ t = this.title.split(' [')[0];
+ }
+
+ var keyStr = ''; // Shift+Up
+
+ $$c.each(keyval.split('/'), function (i, key) {
+ var modBits = key.split('+');
+ var mod = '';
+
+ if (modBits.length > 1) {
+ mod = modBits[0] + '+';
+ key = modBits[1];
+ }
+
+ keyStr += (i ? '/' : '') + mod + (uiStrings$1['key_' + key] || key);
+ });
+
+ if (menu) {
+ this.lastChild.textContent = t + ' [' + keyStr + ']';
+ } else {
+ this.title = t + ' [' + keyStr + ']';
+ }
+ });
+ });
+ },
+
+ /**
+ * @param {string} sel Selector to match
+ * @returns {module:SVGEditor.ToolButton}
+ */
+ getButtonData: function getButtonData(sel) {
+ return Object.values(toolButtons).find(function (btn) {
+ return btn.sel === sel;
+ });
+ }
+ };
+ }(); // Select given tool
+
+
+ editor.ready(function () {
+ var tool;
+ var itool = curConfig.initTool,
+ container = $$c('#tools_left, #svg_editor .tools_flyout'),
+ preTool = container.find('#tool_' + itool),
+ regTool = container.find('#' + itool);
+
+ if (preTool.length) {
+ tool = preTool;
+ } else if (regTool.length) {
+ tool = regTool;
+ } else {
+ tool = $$c('#tool_select');
+ }
+
+ tool.click().mouseup();
+
+ if (curConfig.wireframe) {
+ $$c('#tool_wireframe').click();
+ }
+
+ if (curConfig.showlayers) {
+ toggleSidePanel();
+ }
+
+ $$c('#rulers').toggle(Boolean(curConfig.showRulers));
+
+ if (curConfig.showRulers) {
+ $$c('#show_rulers')[0].checked = true;
+ }
+
+ if (curConfig.baseUnit) {
+ $$c('#base_unit').val(curConfig.baseUnit);
+ }
+
+ if (curConfig.gridSnapping) {
+ $$c('#grid_snapping_on')[0].checked = true;
+ }
+
+ if (curConfig.snappingStep) {
+ $$c('#grid_snapping_step').val(curConfig.snappingStep);
+ }
+
+ if (curConfig.gridColor) {
+ $$c('#grid_color').val(curConfig.gridColor);
+ }
+ }); // init SpinButtons
+
+ $$c('#rect_rx').SpinButton({
+ min: 0,
+ max: 1000,
+ stateObj: stateObj,
+ callback: changeRectRadius
+ });
+ $$c('#stroke_width').SpinButton({
+ min: 0,
+ max: 99,
+ smallStep: 0.1,
+ stateObj: stateObj,
+ callback: changeStrokeWidth
+ });
+ $$c('#angle').SpinButton({
+ min: -180,
+ max: 180,
+ step: 5,
+ stateObj: stateObj,
+ callback: changeRotationAngle
+ });
+ $$c('#font_size').SpinButton({
+ min: 0.001,
+ stepfunc: stepFontSize,
+ stateObj: stateObj,
+ callback: changeFontSize
+ });
+ $$c('#group_opacity').SpinButton({
+ min: 0,
+ max: 100,
+ step: 5,
+ stateObj: stateObj,
+ callback: changeOpacity
+ });
+ $$c('#blur').SpinButton({
+ min: 0,
+ max: 10,
+ step: 0.1,
+ stateObj: stateObj,
+ callback: changeBlur
+ });
+ $$c('#zoom').SpinButton({
+ min: 0.001,
+ max: 10000,
+ step: 50,
+ stepfunc: stepZoom,
+ stateObj: stateObj,
+ callback: changeZoom // Set default zoom
+
+ }).val(svgCanvas.getZoom() * 100);
+ $$c('#workarea').contextMenu({
+ menu: 'cmenu_canvas',
+ inSpeed: 0
+ }, function (action, el, pos) {
+ switch (action) {
+ case 'delete':
+ deleteSelected();
+ break;
+
+ case 'cut':
+ cutSelected();
+ break;
+
+ case 'copy':
+ copySelected();
+ break;
+
+ case 'paste':
+ svgCanvas.pasteElements();
+ break;
+
+ case 'paste_in_place':
+ svgCanvas.pasteElements('in_place');
+ break;
+
+ case 'group':
+ case 'group_elements':
+ svgCanvas.groupSelectedElements();
+ break;
+
+ case 'ungroup':
+ svgCanvas.ungroupSelectedElement();
+ break;
+
+ case 'move_front':
+ moveToTopSelected();
+ break;
+
+ case 'move_up':
+ moveUpDownSelected('Up');
+ break;
+
+ case 'move_down':
+ moveUpDownSelected('Down');
+ break;
+
+ case 'move_back':
+ moveToBottomSelected();
+ break;
+
+ default:
+ if (hasCustomHandler(action)) {
+ getCustomHandler(action).call();
+ }
+
+ break;
+ }
+ });
+ /**
+ * Implements {@see module:jQueryContextMenu.jQueryContextMenuListener}.
+ * @param {"dupe"|"delete"|"merge_down"|"merge_all"} action
+ * @param {external:jQuery} el
+ * @param {{x: Float, y: Float, docX: Float, docY: Float}} pos
+ * @returns {void}
+ */
+
+ var lmenuFunc = function lmenuFunc(action, el, pos) {
+ switch (action) {
+ case 'dupe':
+ /* await */
+ cloneLayer();
+ break;
+
+ case 'delete':
+ deleteLayer();
+ break;
+
+ case 'merge_down':
+ mergeLayer();
+ break;
+
+ case 'merge_all':
+ svgCanvas.mergeAllLayers();
+ updateContextPanel();
+ populateLayers();
+ break;
+ }
+ };
+
+ $$c('#layerlist').contextMenu({
+ menu: 'cmenu_layers',
+ inSpeed: 0
+ }, lmenuFunc);
+ $$c('#layer_moreopts').contextMenu({
+ menu: 'cmenu_layers',
+ inSpeed: 0,
+ allowLeft: true
+ }, lmenuFunc);
+ $$c('.contextMenu li').mousedown(function (ev) {
+ ev.preventDefault();
+ });
+ $$c('#cmenu_canvas li').disableContextMenu();
+ canvMenu.enableContextMenuItems('#delete,#cut,#copy');
+ /**
+ * @returns {void}
+ */
+
+ function enableOrDisableClipboard() {
+ var svgeditClipboard;
+
+ try {
+ svgeditClipboard = localStorage.getItem('svgedit_clipboard');
+ } catch (err) {}
+
+ canvMenu[(svgeditClipboard ? 'en' : 'dis') + 'ableContextMenuItems']('#paste,#paste_in_place');
+ }
+
+ enableOrDisableClipboard();
+ window.addEventListener('storage', function (e) {
+ if (e.key !== 'svgedit_clipboard') {
+ return;
+ }
+
+ enableOrDisableClipboard();
+ });
+ window.addEventListener('beforeunload', function (e) {
+ // Suppress warning if page is empty
+ if (undoMgr.getUndoStackSize() === 0) {
+ editor.showSaveWarning = false;
+ } // showSaveWarning is set to 'false' when the page is saved.
+
+
+ if (!curConfig.no_save_warning && editor.showSaveWarning) {
+ // Browser already asks question about closing the page
+ e.returnValue = uiStrings$1.notification.unsavedChanges; // Firefox needs this when beforeunload set by addEventListener (even though message is not used)
+
+ return uiStrings$1.notification.unsavedChanges;
+ }
+
+ return true;
+ });
+ /**
+ * Expose the `uiStrings`.
+ * @function module:SVGEditor.canvas.getUIStrings
+ * @returns {module:SVGEditor.uiStrings}
+ */
+
+ editor.canvas.getUIStrings = function () {
+ return uiStrings$1;
+ };
+ /**
+ * @function module:SVGEditor.openPrep
+ * @returns {boolean|Promise} Resolves to boolean indicating `true` if there were no changes
+ * and `false` after the user confirms.
+ */
+
+
+ editor.openPrep = function () {
+ $$c('#main_menu').hide();
+
+ if (undoMgr.getUndoStackSize() === 0) {
+ return true;
+ }
+
+ return $$c.confirm(uiStrings$1.notification.QwantToOpen);
+ };
+ /**
+ *
+ * @param {Event} e
+ * @returns {void}
+ */
+
+
+ function onDragEnter(e) {
+ e.stopPropagation();
+ e.preventDefault(); // and indicator should be displayed here, such as "drop files here"
+ }
+ /**
+ *
+ * @param {Event} e
+ * @returns {void}
+ */
+
+
+ function onDragOver(e) {
+ e.stopPropagation();
+ e.preventDefault();
+ }
+ /**
+ *
+ * @param {Event} e
+ * @returns {void}
+ */
+
+
+ function onDragLeave(e) {
+ e.stopPropagation();
+ e.preventDefault(); // hypothetical indicator should be removed here
+ } // Use HTML5 File API: http://www.w3.org/TR/FileAPI/
+ // if browser has HTML5 File API support, then we will show the open menu item
+ // and provide a file input to click. When that change event fires, it will
+ // get the text contents of the file and send it to the canvas
+
+
+ if (window.FileReader) {
+ /**
+ * @param {Event} e
+ * @returns {void}
+ */
+ var importImage = function importImage(e) {
+ $$c.process_cancel(uiStrings$1.notification.loadingImage);
+ e.stopPropagation();
+ e.preventDefault();
+ $$c('#workarea').removeAttr('style');
+ $$c('#main_menu').hide();
+ var file = e.type === 'drop' ? e.dataTransfer.files[0] : this.files[0];
+
+ if (!file) {
+ $$c('#dialog_box').hide();
+ return;
+ }
+ /* if (file.type === 'application/pdf') { // Todo: Handle PDF imports
+ }
+ else */
+
+
+ if (!file.type.includes('image')) {
+ return;
+ } // Detected an image
+ // svg handling
+
+
+ var reader;
+
+ if (file.type.includes('svg')) {
+ reader = new FileReader();
+
+ reader.onloadend = function (ev) {
+ var newElement = svgCanvas.importSvgString(ev.target.result, true);
+ svgCanvas.ungroupSelectedElement();
+ svgCanvas.ungroupSelectedElement();
+ svgCanvas.groupSelectedElements();
+ svgCanvas.alignSelectedElements('m', 'page');
+ svgCanvas.alignSelectedElements('c', 'page'); // highlight imported element, otherwise we get strange empty selectbox
+
+ svgCanvas.selectOnly([newElement]);
+ $$c('#dialog_box').hide();
+ };
+
+ reader.readAsText(file);
+ } else {
+ // bitmap handling
+ reader = new FileReader();
+
+ reader.onloadend = function (_ref23) {
+ var result = _ref23.target.result;
+
+ /**
+ * Insert the new image until we know its dimensions.
+ * @param {Float} width
+ * @param {Float} height
+ * @returns {void}
+ */
+ var insertNewImage = function insertNewImage(width, height) {
+ var newImage = svgCanvas.addSVGElementFromJson({
+ element: 'image',
+ attr: {
+ x: 0,
+ y: 0,
+ width: width,
+ height: height,
+ id: svgCanvas.getNextId(),
+ style: 'pointer-events:inherit'
+ }
+ });
+ svgCanvas.setHref(newImage, result);
+ svgCanvas.selectOnly([newImage]);
+ svgCanvas.alignSelectedElements('m', 'page');
+ svgCanvas.alignSelectedElements('c', 'page');
+ updateContextPanel();
+ $$c('#dialog_box').hide();
+ }; // create dummy img so we know the default dimensions
+
+
+ var imgWidth = 100;
+ var imgHeight = 100;
+ var img = new Image();
+ img.style.opacity = 0;
+ img.addEventListener('load', function () {
+ imgWidth = img.offsetWidth || img.naturalWidth || img.width;
+ imgHeight = img.offsetHeight || img.naturalHeight || img.height;
+ insertNewImage(imgWidth, imgHeight);
+ });
+ img.src = result;
+ };
+
+ reader.readAsDataURL(file);
+ }
+ };
+
+ workarea[0].addEventListener('dragenter', onDragEnter);
+ workarea[0].addEventListener('dragover', onDragOver);
+ workarea[0].addEventListener('dragleave', onDragLeave);
+ workarea[0].addEventListener('drop', importImage);
+ var open = $$c('').change( /*#__PURE__*/function () {
+ var _ref24 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee16(e) {
+ var ok, reader;
+ return regeneratorRuntime.wrap(function _callee16$(_context16) {
+ while (1) {
+ switch (_context16.prev = _context16.next) {
+ case 0:
+ _context16.next = 2;
+ return editor.openPrep();
+
+ case 2:
+ ok = _context16.sent;
+
+ if (ok) {
+ _context16.next = 5;
+ break;
+ }
+
+ return _context16.abrupt("return");
+
+ case 5:
+ svgCanvas.clear();
+
+ if (this.files.length === 1) {
+ $$c.process_cancel(uiStrings$1.notification.loadingImage);
+ reader = new FileReader();
+
+ reader.onloadend = /*#__PURE__*/function () {
+ var _ref26 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee15(_ref25) {
+ var target;
+ return regeneratorRuntime.wrap(function _callee15$(_context15) {
+ while (1) {
+ switch (_context15.prev = _context15.next) {
+ case 0:
+ target = _ref25.target;
+ _context15.next = 3;
+ return loadSvgString(target.result);
+
+ case 3:
+ updateCanvas();
+
+ case 4:
+ case "end":
+ return _context15.stop();
+ }
+ }
+ }, _callee15);
+ }));
+
+ return function (_x6) {
+ return _ref26.apply(this, arguments);
+ };
+ }();
+
+ reader.readAsText(this.files[0]);
+ }
+
+ case 7:
+ case "end":
+ return _context16.stop();
+ }
+ }
+ }, _callee16, this);
+ }));
+
+ return function (_x5) {
+ return _ref24.apply(this, arguments);
+ };
+ }());
+ $$c('#tool_open').show();
+ $$c(window).on('openImage', function () {
+ return open.click();
+ });
+ var imgImport = $$c('').change(importImage);
+ $$c('#tool_import').show();
+ $$c(window).on('importImage', function () {
+ return imgImport.click();
+ });
+ }
+
+ updateCanvas(true); // const revnums = 'svg-editor.js ($Rev$) ';
+ // revnums += svgCanvas.getVersion();
+ // $('#copyright')[0].setAttribute('title', revnums);
+
+ var loadedExtensionNames = [];
+ /**
+ * @function module:SVGEditor.setLang
+ * @param {string} lang The language code
+ * @param {module:locale.LocaleStrings} allStrings See {@tutorial LocaleDocs}
+ * @fires module:svgcanvas.SvgCanvas#event:ext_langReady
+ * @fires module:svgcanvas.SvgCanvas#event:ext_langChanged
+ * @returns {Promise} A Promise which resolves to `undefined`
+ */
+
+ var setLang = editor.setLang = /*#__PURE__*/function () {
+ var _ref27 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee17(lang, allStrings) {
+ var oldLayerName, renameLayer, elems;
+ return regeneratorRuntime.wrap(function _callee17$(_context17) {
+ while (1) {
+ switch (_context17.prev = _context17.next) {
+ case 0:
+ editor.langChanged = true;
+ editor.pref('lang', lang);
+ $$c('#lang_select').val(lang);
+
+ if (allStrings) {
+ _context17.next = 5;
+ break;
+ }
+
+ return _context17.abrupt("return");
+
+ case 5:
+ // Todo: Remove `allStrings.lang` property in locale in
+ // favor of just `lang`?
+ document.documentElement.lang = allStrings.lang; // lang;
+ // Todo: Add proper RTL Support!
+ // Todo: Use RTL detection instead and take out of locales?
+ // document.documentElement.dir = allStrings.dir;
+
+ $$c.extend(uiStrings$1, allStrings); // const notif = allStrings.notification; // Currently unused
+ // $.extend will only replace the given strings
+
+ oldLayerName = $$c('#layerlist tr.layersel td.layername').text();
+ renameLayer = oldLayerName === uiStrings$1.common.layer + ' 1';
+ svgCanvas.setUiStrings(allStrings);
+ Actions.setTitles();
+
+ if (renameLayer) {
+ svgCanvas.renameCurrentLayer(uiStrings$1.common.layer + ' 1');
+ populateLayers();
+ } // In case extensions loaded before the locale, now we execute a callback on them
+
+
+ if (!extsPreLang.length) {
+ _context17.next = 18;
+ break;
+ }
+
+ _context17.next = 15;
+ return Promise.all(extsPreLang.map(function (ext) {
+ loadedExtensionNames.push(ext.name);
+ return ext.langReady({
+ lang: lang,
+ uiStrings: uiStrings$1,
+ importLocale: getImportLocale({
+ defaultLang: lang,
+ defaultName: ext.name
+ })
+ });
+ }));
+
+ case 15:
+ extsPreLang.length = 0;
+ _context17.next = 19;
+ break;
+
+ case 18:
+ loadedExtensionNames.forEach(function (loadedExtensionName) {
+ svgCanvas.runExtension(loadedExtensionName, 'langReady',
+ /** @type {module:svgcanvas.SvgCanvas#event:ext_langReady} */
+ {
+ lang: lang,
+ uiStrings: uiStrings$1,
+ importLocale: getImportLocale({
+ defaultLang: lang,
+ defaultName: loadedExtensionName
+ })
+ });
+ });
+
+ case 19:
+ svgCanvas.runExtensions('langChanged',
+ /** @type {module:svgcanvas.SvgCanvas#event:ext_langChanged} */
+ lang); // Update flyout tooltips
+
+ setFlyoutTitles(); // Copy title for certain tool elements
+
+ elems = {
+ '#stroke_color': '#tool_stroke .icon_label, #tool_stroke .color_block',
+ '#fill_color': '#tool_fill label, #tool_fill .color_block',
+ '#linejoin_miter': '#cur_linejoin',
+ '#linecap_butt': '#cur_linecap'
+ };
+ $$c.each(elems, function (source, dest) {
+ $$c(dest).attr('title', $$c(source)[0].title);
+ }); // Copy alignment titles
+
+ $$c('#multiselected_panel div[id^=tool_align]').each(function () {
+ $$c('#tool_pos' + this.id.substr(10))[0].title = this.title;
+ });
+
+ case 24:
+ case "end":
+ return _context17.stop();
+ }
+ }
+ }, _callee17);
+ }));
+
+ return function (_x7, _x8) {
+ return _ref27.apply(this, arguments);
+ };
+ }();
+
+ init$7(
+ /**
+ * @implements {module:locale.LocaleEditorInit}
+ */
+ {
+ /**
+ * Gets an array of results from extensions with a `addLangData` method,
+ * returning an object with a `data` property set to its locales (to be
+ * merged with regular locales).
+ * @param {string} langParam
+ * @fires module:svgcanvas.SvgCanvas#event:ext_addLangData
+ * @todo Can we forego this in favor of `langReady` (or forego `langReady`)?
+ * @returns {module:locale.AddLangExtensionLocaleData[]}
+ */
+ addLangData: function addLangData(langParam) {
+ return svgCanvas.runExtensions('addLangData',
+ /**
+ * @function
+ * @type {module:svgcanvas.ExtensionVarBuilder}
+ * @param {string} name
+ * @returns {module:svgcanvas.SvgCanvas#event:ext_addLangData}
+ */
+ function (name) {
+ // We pass in a function as we don't know the extension name here when defining this `addLangData` method
+ return {
+ lang: langParam,
+ importLocale: getImportLocale({
+ defaultLang: langParam,
+ defaultName: name
+ })
+ };
+ }, true);
+ },
+ curConfig: curConfig
+ }); // Load extensions
+ // Bit of a hack to run extensions in local Opera/IE9
+
+ if (document.location.protocol === 'file:') {
+ setTimeout(extAndLocaleFunc, 100);
+ } else {
+ // Returns a promise (if we wanted to fire 'extensions-loaded' event,
+ // potentially useful to hide interface as some extension locales
+ // are only available after this)
+ extAndLocaleFunc();
+ }
+ };
+ /**
+ * @callback module:SVGEditor.ReadyCallback
+ * @returns {Promise|void}
+ */
+
+ /**
+ * Queues a callback to be invoked when the editor is ready (or
+ * to be invoked immediately if it is already ready--i.e.,
+ * if `runCallbacks` has been run).
+ * @function module:SVGEditor.ready
+ * @param {module:SVGEditor.ReadyCallback} cb Callback to be queued to invoke
+ * @returns {Promise} Resolves when all callbacks, including the supplied have resolved
+ */
+
+
+ editor.ready = function (cb) {
+ // eslint-disable-line promise/prefer-await-to-callbacks
+ return new Promise(function (resolve, reject) {
+ // eslint-disable-line promise/avoid-new
+ if (isReady) {
+ resolve(cb()); // eslint-disable-line node/callback-return, promise/prefer-await-to-callbacks
+
+ return;
+ }
+
+ callbacks.push([cb, resolve, reject]);
+ });
+ };
+ /**
+ * Invokes the callbacks previous set by `svgEditor.ready`
+ * @function module:SVGEditor.runCallbacks
+ * @returns {Promise} Resolves to `undefined` if all callbacks succeeded and rejects otherwise
+ */
+
+
+ editor.runCallbacks = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee20() {
+ return regeneratorRuntime.wrap(function _callee20$(_context20) {
+ while (1) {
+ switch (_context20.prev = _context20.next) {
+ case 0:
+ _context20.prev = 0;
+ _context20.next = 3;
+ return Promise.all(callbacks.map(function (_ref30) {
+ var _ref31 = _slicedToArray(_ref30, 1),
+ cb = _ref31[0];
+
+ return cb(); // eslint-disable-line promise/prefer-await-to-callbacks
+ }));
+
+ case 3:
+ _context20.next = 9;
+ break;
+
+ case 5:
+ _context20.prev = 5;
+ _context20.t0 = _context20["catch"](0);
+ callbacks.forEach(function (_ref32) {
+ var _ref33 = _slicedToArray(_ref32, 3),
+ reject = _ref33[2];
+
+ reject();
+ });
+ throw _context20.t0;
+
+ case 9:
+ callbacks.forEach(function (_ref34) {
+ var _ref35 = _slicedToArray(_ref34, 2),
+ resolve = _ref35[1];
+
+ resolve();
+ });
+ isReady = true;
+
+ case 11:
+ case "end":
+ return _context20.stop();
+ }
+ }
+ }, _callee20, null, [[0, 5]]);
+ }));
+ /**
+ * @function module:SVGEditor.loadFromString
+ * @param {string} str The SVG string to load
+ * @param {PlainObject} [opts={}]
+ * @param {boolean} [opts.noAlert=false] Option to avoid alert to user and instead get rejected promise
+ * @returns {Promise}
+ */
+
+ editor.loadFromString = function (str) {
+ var _ref36 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
+ noAlert = _ref36.noAlert;
+
+ return editor.ready( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee21() {
+ return regeneratorRuntime.wrap(function _callee21$(_context21) {
+ while (1) {
+ switch (_context21.prev = _context21.next) {
+ case 0:
+ _context21.prev = 0;
+ _context21.next = 3;
+ return loadSvgString(str, {
+ noAlert: noAlert
+ });
+
+ case 3:
+ _context21.next = 9;
+ break;
+
+ case 5:
+ _context21.prev = 5;
+ _context21.t0 = _context21["catch"](0);
+
+ if (!noAlert) {
+ _context21.next = 9;
+ break;
+ }
+
+ throw _context21.t0;
+
+ case 9:
+ case "end":
+ return _context21.stop();
+ }
+ }
+ }, _callee21, null, [[0, 5]]);
+ })));
+ };
+ /**
+ * Not presently in use.
+ * @function module:SVGEditor.disableUI
+ * @param {PlainObject} featList
+ * @returns {void}
+ */
+
+
+ editor.disableUI = function (featList) {// $(function () {
+ // $('#tool_wireframe, #tool_image, #main_button, #tool_source, #sidepanels').remove();
+ // $('#tools_top').css('left', 5);
+ // });
+ };
+ /**
+ * @callback module:SVGEditor.URLLoadCallback
+ * @param {boolean} success
+ * @returns {void}
+ */
+
+ /**
+ * @function module:SVGEditor.loadFromURL
+ * @param {string} url URL from which to load an SVG string via Ajax
+ * @param {PlainObject} [opts={}] May contain properties: `cache`, `callback`
+ * @param {boolean} [opts.cache]
+ * @param {boolean} [opts.noAlert]
+ * @returns {Promise} Resolves to `undefined` or rejects upon bad loading of
+ * the SVG (or upon failure to parse the loaded string) when `noAlert` is
+ * enabled
+ */
+
+
+ editor.loadFromURL = function (url) {
+ var _ref38 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
+ cache = _ref38.cache,
+ noAlert = _ref38.noAlert;
+
+ return editor.ready(function () {
+ return new Promise(function (resolve, reject) {
+ // eslint-disable-line promise/avoid-new
+ $$c.ajax({
+ url: url,
+ dataType: 'text',
+ cache: Boolean(cache),
+ beforeSend: function beforeSend() {
+ $$c.process_cancel(uiStrings$1.notification.loadingImage);
+ },
+ success: function success(str) {
+ resolve(loadSvgString(str, {
+ noAlert: noAlert
+ }));
+ },
+ error: function error(xhr, stat, err) {
+ if (xhr.status !== 404 && xhr.responseText) {
+ resolve(loadSvgString(xhr.responseText, {
+ noAlert: noAlert
+ }));
+ return;
+ }
+
+ if (noAlert) {
+ reject(new Error('URLLoadFail'));
+ return;
+ }
+
+ $$c.alert(uiStrings$1.notification.URLLoadFail + ': \n' + err);
+ resolve();
+ },
+ complete: function complete() {
+ $$c('#dialog_box').hide();
+ }
+ });
+ });
+ });
+ };
+ /**
+ * @function module:SVGEditor.loadFromDataURI
+ * @param {string} str The Data URI to base64-decode (if relevant) and load
+ * @param {PlainObject} [opts={}]
+ * @param {boolean} [opts.noAlert]
+ * @returns {Promise} Resolves to `undefined` and rejects if loading SVG string fails and `noAlert` is enabled
+ */
+
+
+ editor.loadFromDataURI = function (str) {
+ var _ref39 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
+ noAlert = _ref39.noAlert;
+
+ return editor.ready(function () {
+ var base64 = false;
+ var pre = str.match(/^data:image\/svg\+xml;base64,/);
+
+ if (pre) {
+ base64 = true;
+ } else {
+ pre = str.match(/^data:image\/svg\+xml(?:;|;utf8)?,/);
+ }
+
+ if (pre) {
+ pre = pre[0];
+ }
+
+ var src = str.slice(pre.length);
+ return loadSvgString(base64 ? decode64(src) : decodeURIComponent(src), {
+ noAlert: noAlert
+ });
+ });
+ };
+ /**
+ * @function module:SVGEditor.addExtension
+ * @param {string} name Used internally; no need for i18n.
+ * @param {module:svgcanvas.ExtensionInitCallback} init Config to be invoked on this module
+ * @param {module:svgcanvas.ExtensionInitArgs} initArgs
+ * @throws {Error} If called too early
+ * @returns {Promise} Resolves to `undefined`
+ */
+
+
+ editor.addExtension = function (name, init, initArgs) {
+ // Note that we don't want this on editor.ready since some extensions
+ // may want to run before then (like server_opensave).
+ // $(function () {
+ if (!svgCanvas) {
+ throw new Error('Extension added too early');
+ }
+
+ return svgCanvas.addExtension.call(this, name, init, initArgs); // });
+ }; // Defer injection to wait out initial menu processing. This probably goes
+ // away once all context menu behavior is brought to context menu.
+
+
+ editor.ready(function () {
+ injectExtendedContextMenuItemsIntoDom();
+ });
+ var extensionsAdded = false;
+ var messageQueue = [];
+ /**
+ * @param {PlainObject} info
+ * @param {any} info.data
+ * @param {string} info.origin
+ * @fires module:svgcanvas.SvgCanvas#event:message
+ * @returns {void}
+ */
+
+ var messageListener = function messageListener(_ref40) {
+ var data = _ref40.data,
+ origin = _ref40.origin;
+ // eslint-disable-line no-shadow
+ // console.log('data, origin, extensionsAdded', data, origin, extensionsAdded);
+ var messageObj = {
+ data: data,
+ origin: origin
+ };
+
+ if (!extensionsAdded) {
+ messageQueue.push(messageObj);
+ } else {
+ // Extensions can handle messages at this stage with their own
+ // canvas `message` listeners
+ svgCanvas.call('message', messageObj);
+ }
+ };
+
+ window.addEventListener('message', messageListener); // Run init once DOM is loaded
+ // jQuery(editor.init);
+
+ _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee22() {
+ return regeneratorRuntime.wrap(function _callee22$(_context22) {
+ while (1) {
+ switch (_context22.prev = _context22.next) {
+ case 0:
+ _context22.prev = 0;
+ _context22.next = 3;
+ return Promise.resolve();
+
+ case 3:
+ editor.init();
+ _context22.next = 9;
+ break;
+
+ case 6:
+ _context22.prev = 6;
+ _context22.t0 = _context22["catch"](0);
+ console.error(_context22.t0); // eslint-disable-line no-console
+
+ case 9:
+ case "end":
+ return _context22.stop();
+ }
+ }
+ }, _callee22, null, [[0, 6]]);
+ }))();
+
+ window.svgEditor = editor;
+ window.svgEditor.modules = false;
+ editor.setConfig({
+ canvasName: 'xdomain',
+ // Namespace this
+ allowedOrigins: ['*']
+ });
+
+}());