diff --git a/.eslintrc b/.eslintrc index cb7ad48d..647282f8 100644 --- a/.eslintrc +++ b/.eslintrc @@ -17,6 +17,7 @@ "no-var": 2, "prefer-const": 2, "no-extra-semi": 2, - "quote-props": [2, "as-needed"] + "quote-props": [2, "as-needed"], + "object-curly-spacing": ["error", "never"] } } diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md new file mode 100644 index 00000000..9005e2d3 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -0,0 +1,40 @@ +--- +name: Bug report +about: Create a report in case we may be able to help + +--- + +**Describe the bug** +A clear and concise description of what the bug is. + +**To Reproduce** +Steps to reproduce the behavior: +1. Go to '...' +2. Click on '....' +3. Scroll down to '....' +4. See error + +**Expected behavior** +A clear and concise description of what you expected to happen. + +**SVG-Edit environment (IMPORTANT)** +- File for SVG-Edit: [e.g., `svg-editor.html`, `svg-editor-es.html`, `embedapi.html`] +- Version: [e.g. 3.0.0] +- Protocol: [e.g., http, https, file] + +**Desktop (please complete the following information):** + - OS: [e.g. iOS] + - Browser [e.g. chrome, safari] + - Version [e.g. 22] + +**Smartphone (please complete the following information):** + - Device: [e.g. iPhone6] + - OS: [e.g. iOS8.1] + - Browser [e.g. stock browser, safari] + - Version [e.g. 22] + +**Screenshots** +If applicable, add screenshots to help explain your problem. + +**Additional context** +Add any other context about the problem here. diff --git a/CHANGES.md b/CHANGES.md index 578a646c..6b435f3e 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,3 +1,23 @@ +# ? + +- Known regression for 3.\*: Image libraries [broken](https://github.com/SVG-Edit/svgedit/issues/274) +- Breaking change (minor): Change export to check `exportWindowName` + for filename and change default from `download` to `svg.pdf` to + distinguish from other downloads +- Fix: Given lack of support now for dataURI export in Chrome, provide + PDF as export (#273 @cuixiping); fixes #124 and #254 +- Fix (image import): Put src after onload to avoid missing event; + check other width/height properties in case offset is 0; fixes #278 +- Fix (image export): Export in Chrome; fixes #282 +- Fix (Context menus): Avoid showing double shortcuts (#285); add some + missing ones +- npm: Update devDeps +- npm: Point to official sinon-test package now that ES6 Modules + support landed +- Build: Switch to `terser` plugin with `uglify` plugin not + supporting ES6+-capable minifier +- Linting (ESLint): Consistent spacing; new "standard" + # 3.0.0-rc.2 - Fix: Avoid extension `includeWith` button conflicts/redundancies; diff --git a/dist/canvg.js b/dist/canvg.js index 40488aa3..43241cdb 100644 --- a/dist/canvg.js +++ b/dist/canvg.js @@ -4146,6 +4146,7 @@ var canvg = (function (exports) { }; svg.loadXmlDoc = function (ctx, dom) { + var res = void 0; svg.init(ctx); var mapXY = function mapXY(p) { @@ -4293,7 +4294,7 @@ var canvg = (function (exports) { // render if needed if (needUpdate) { - draw(); + draw(res); svg.Mouse.runEvents(); // run and clear our events } }, 1000 / svg.FRAMERATE); @@ -4301,7 +4302,9 @@ var canvg = (function (exports) { if (svg.ImagesLoaded()) { waitingForImages = false; draw(resolve); + return; } + res = resolve; }); }; diff --git a/dist/extensions/ext-markers.js b/dist/extensions/ext-markers.js index fdbbc4f7..19dbc63d 100644 --- a/dist/extensions/ext-markers.js +++ b/dist/extensions/ext-markers.js @@ -640,7 +640,9 @@ var svgEditorExtension_markers = (function () { }, buttons: buildButtonList(), - context_tools: contextTools + context_tools: strings.contextTools.map(function (contextTool, i) { + return Object.assign(contextTools[i], contextTool); + }) }); case 28: diff --git a/dist/extensions/ext-server_moinsave.js b/dist/extensions/ext-server_moinsave.js index 8b6777d6..d3ca996e 100644 --- a/dist/extensions/ext-server_moinsave.js +++ b/dist/extensions/ext-server_moinsave.js @@ -4123,6 +4123,7 @@ var svgEditorExtension_server_moinsave = (function () { }; svg.loadXmlDoc = function (ctx, dom) { + var res = void 0; svg.init(ctx); var mapXY = function mapXY(p) { @@ -4270,7 +4271,7 @@ var svgEditorExtension_server_moinsave = (function () { // render if needed if (needUpdate) { - draw(); + draw(res); svg.Mouse.runEvents(); // run and clear our events } }, 1000 / svg.FRAMERATE); @@ -4278,7 +4279,9 @@ var svgEditorExtension_server_moinsave = (function () { if (svg.ImagesLoaded()) { waitingForImages = false; draw(resolve); + return; } + res = resolve; }); }; diff --git a/dist/extensions/ext-server_opensave.js b/dist/extensions/ext-server_opensave.js index fa7bc54c..e118cf3f 100644 --- a/dist/extensions/ext-server_opensave.js +++ b/dist/extensions/ext-server_opensave.js @@ -4123,6 +4123,7 @@ var svgEditorExtension_server_opensave = (function () { }; svg.loadXmlDoc = function (ctx, dom) { + var res = void 0; svg.init(ctx); var mapXY = function mapXY(p) { @@ -4270,7 +4271,7 @@ var svgEditorExtension_server_opensave = (function () { // render if needed if (needUpdate) { - draw(); + draw(res); svg.Mouse.runEvents(); // run and clear our events } }, 1000 / svg.FRAMERATE); @@ -4278,7 +4279,9 @@ var svgEditorExtension_server_opensave = (function () { if (svg.ImagesLoaded()) { waitingForImages = false; draw(resolve); + return; } + res = resolve; }); }; diff --git a/dist/index-es.js b/dist/index-es.js index a749ac4e..4adeeab8 100644 --- a/dist/index-es.js +++ b/dist/index-es.js @@ -232,6 +232,15 @@ var getReverseNS = function getReverseNS() { return reverseNS; }; +/* globals SVGPathSeg, SVGPathSegMovetoRel, SVGPathSegMovetoAbs, + SVGPathSegMovetoRel, SVGPathSegLinetoRel, SVGPathSegLinetoAbs, + SVGPathSegLinetoHorizontalRel, SVGPathSegLinetoHorizontalAbs, + SVGPathSegLinetoVerticalRel, SVGPathSegLinetoVerticalAbs, + SVGPathSegClosePath, SVGPathSegCurvetoCubicRel, + SVGPathSegCurvetoCubicAbs, SVGPathSegCurvetoCubicSmoothRel, + SVGPathSegCurvetoCubicSmoothAbs, SVGPathSegCurvetoQuadraticRel, + SVGPathSegCurvetoQuadraticAbs, SVGPathSegCurvetoQuadraticSmoothRel, + SVGPathSegCurvetoQuadraticSmoothAbs, SVGPathSegArcRel, SVGPathSegArcAbs */ /** * SVGPathSeg API polyfill * https://github.com/progers/pathseg @@ -1542,11 +1551,11 @@ var getReverseNS = function getReverseNS() { // The second check for appendItem is specific to Firefox 59+ which removed only parts of the // SVGPathSegList API (e.g., appendItem). In this case we need to re-implement the entire API // so the polyfill data (i.e., _list) is used throughout. - if (!('SVGPathSegList' in window) || !('appendItem' in SVGPathSegList.prototype)) { + if (!('SVGPathSegList' in window) || !('appendItem' in window.SVGPathSegList.prototype)) { // Spec: https://www.w3.org/TR/SVG11/single-page.html#paths-InterfaceSVGPathSegList - var _SVGPathSegList = function () { - function _SVGPathSegList(pathElement) { - classCallCheck(this, _SVGPathSegList); + var SVGPathSegList = function () { + function SVGPathSegList(pathElement) { + classCallCheck(this, SVGPathSegList); this._pathElement = pathElement; this._list = this._parsePath(this._pathElement.getAttribute('d')); @@ -1561,7 +1570,7 @@ var getReverseNS = function getReverseNS() { // MutationObservers are not synchronous so we can have pending asynchronous mutations. - createClass(_SVGPathSegList, [{ + createClass(SVGPathSegList, [{ key: '_checkPathSynchronizedToList', value: function _checkPathSynchronizedToList() { this._updateListFromPathMutations(this._pathElementMutationObserver.takeRecords()); @@ -1589,7 +1598,7 @@ var getReverseNS = function getReverseNS() { key: '_writeListToPath', value: function _writeListToPath() { this._pathElementMutationObserver.disconnect(); - this._pathElement.setAttribute('d', _SVGPathSegList._pathSegArrayAsString(this._list)); + this._pathElement.setAttribute('d', SVGPathSegList._pathSegArrayAsString(this._list)); this._pathElementMutationObserver.observe(this._pathElement, this._mutationObserverConfig); } @@ -2066,12 +2075,12 @@ var getReverseNS = function getReverseNS() { return builder.pathSegList; } }]); - return _SVGPathSegList; + return SVGPathSegList; }(); - _SVGPathSegList.prototype.classname = 'SVGPathSegList'; + SVGPathSegList.prototype.classname = 'SVGPathSegList'; - Object.defineProperty(_SVGPathSegList.prototype, 'numberOfItems', { + Object.defineProperty(SVGPathSegList.prototype, 'numberOfItems', { get: function get$$1() { this._checkPathSynchronizedToList(); return this._list.length; @@ -2080,7 +2089,7 @@ var getReverseNS = function getReverseNS() { enumerable: true }); - _SVGPathSegList._pathSegArrayAsString = function (pathSegArray) { + SVGPathSegList._pathSegArrayAsString = function (pathSegArray) { var string = ''; var first = true; pathSegArray.forEach(function (pathSeg) { @@ -2100,7 +2109,7 @@ var getReverseNS = function getReverseNS() { pathSegList: { get: function get$$1() { if (!this._pathSegList) { - this._pathSegList = new _SVGPathSegList(this); + this._pathSegList = new SVGPathSegList(this); } return this._pathSegList; }, @@ -2124,7 +2133,7 @@ var getReverseNS = function getReverseNS() { }, enumerable: true } }); - window.SVGPathSegList = _SVGPathSegList; + window.SVGPathSegList = SVGPathSegList; } })(); @@ -12289,7 +12298,7 @@ if (!window.console) { if (window.opera) { window.console.log = function (str) { - opera.postError(str); + window.opera.postError(str); }; window.console.dir = function (str) {}; } @@ -16409,7 +16418,7 @@ function SvgCanvas(container, config) { * Generates a PDF based on the current image, then calls "exportedPDF" with * an object including the string, the data URL, and any issues found * @function module:svgcanvas.SvgCanvas#exportPDF - * @param {string} exportWindowName + * @param {string} exportWindowName Will also be used for the download file name here * @param {external:jsPDF.OutputType} [outputType="dataurlstring"] * @param {module:svgcanvas.PDFExportedCallback} cb * @fires module:svgcanvas.SvgCanvas#event:exportedPDF @@ -16481,7 +16490,7 @@ function SvgCanvas(container, config) { outputType = outputType || 'dataurlstring'; obj = { svg: svg, issues: issues, issueCodes: issueCodes, exportWindowName: exportWindowName, outputType: outputType }; - obj.output = doc.output(outputType); + obj.output = doc.output(outputType, outputType === 'save' ? exportWindowName || 'svg.pdf' : undefined); if (cb) { cb(obj); } @@ -28394,6 +28403,10 @@ editor.init = function () { 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) { @@ -29214,48 +29227,81 @@ editor.init = function () { $$b.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 (imgType) { - // todo: replace hard-coded msg with uiStrings.notification. - if (!imgType) { - return; - } - // Open placeholder window (prevents popup) - var exportWindowName = void 0; - function openExportWindow() { - var str = uiStrings$1.notification.loadingImage; - if (curConfig.exportWindowType === 'new') { - editor.exportWindowCt++; - } - exportWindowName = curConfig.canvasName + editor.exportWindowCt; - var popHTML = void 0, - popURL = void 0; - if (loadingURL) { - popURL = loadingURL; - } else { - popHTML = '\n
\n \n