- Fix: Have export handler, if triggered, always open a window even if no

window name was given (needed in Chrome to avoid opening an extra window)
- Fix (Embedded editor regression): Ensure event handlers are added even if
    document cannot be directly modified
- Enhancement: Add `opts` object to `rasterExport` with `avoidEvent` property
  to avoid calling the `exported` event
- Docs (CHANGES): Update
- Docs (README): Deemphasize unstable embedded editor fixes
master
Brett Zamir 2018-10-24 14:45:52 +08:00
parent 07f59ba01a
commit 283ef0b521
13 changed files with 71 additions and 45 deletions

View File

@ -1,16 +1,21 @@
# 3.1.0
- Fix (Embedded editor): (Though embedding cross-origin iframes apparently
only working now in Chrome if same origin or if https?--at least not
localhost of different ports), PDF export has been fixed (we download the
PDF to workaround data URI limitations in Chrome)
- Fix (Embedded editor): (Though cross-origin DOM access of iframes apparently
doesn't work now in Chrome or Firefox (which we had been using to disable a
button) nor does cross-origin storage access work in Chrome), PDF export has
been fixed (we download the PDF to workaround data URI limitations in Chrome)
and we avoid opening an extra tab in Chrome PNG export
- Fix (Embedded editor): Avoid using same origin shortcut if there is no
global available to use (e.g., if using the modular editor)
- Fix (Embedded editor): Add events only after load is complete and
svgCanvas is available; also log blocked error objects
- Fix: Have export handler, if triggered, always open a window even if no
window name was given (needed in Chrome to avoid opening an extra window)
- Enhancement: For anyone visiting the ES6 modules entrance file without ESM
support, redirect to non-modular version
- Enhancement: For PDF export, switch Chrome by default to "save" `outputType`
- Enhancement: Add `opts` object to `rasterExport` with `avoidEvent` property
to avoid calling the `exported` event
- Refactoring (canvg): Better type-checking on `canvasRGBA_` (but set
correctly by default anyways)
- Refactoring: Avoid redundant use of \*AttributeNS methods with
@ -20,7 +25,8 @@
- Refactoring: Line breaks
- Refactoring: Reorder path config to group (non-modular-dependent) image
paths together (and correct code comment)
- Docs: CHANGES clarifications/fixes
- Docs (CHANGES): clarifications/fixes
- Docs (README): Deemphasize unstable embedded editor fixes
- Docs: Versions section (for migrating)
- Docs: More info on `importLocale` for extensions
- Docs: Add code comment re: use of `extIconsPath` in Mathjax

View File

@ -92,8 +92,8 @@ incorporating SVGEdit.
## Recent news
- 2018-10-24 Published 3.1.0 (Embedded editor fixes and redirect on modular
page for non-module-support; versions document (for migrating))
- 2018-10-24 Published 3.1.0 (Redirect on modular page for non-module-support;
versions document (for migrating))
- 2018-10-22 Published 3.0.1 (Revert fix affecting polygon selection)
- 2018-10-21 Published 3.0.0 (misc. improvements including centering canvas and
key locale fixes since last RC)

9
dist/index-es.js vendored
View File

@ -17417,12 +17417,15 @@ function SvgCanvas(container, config) {
* @param {Float} [quality] Between 0 and 1
* @param {string} [exportWindowName]
* @param {module:svgcanvas.ImageExportedCallback} [cb]
* @param {PlainObject} [opts]
* @param {boolean} [opts.avoidEvent]
* @fires module:svgcanvas.SvgCanvas#event:exported
* @todo Confirm/fix ICO type
* @returns {Promise} Resolves to {@link module:svgcanvas.ImageExportedResults}
*/
this.rasterExport = function (imgType, quality, exportWindowName, cb) {
var opts = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {};
var type = imgType === 'ICO' ? 'BMP' : imgType || 'PNG';
var mimeType = 'image/' + type.toLowerCase();
@ -17455,7 +17458,10 @@ function SvgCanvas(container, config) {
quality: quality,
exportWindowName: exportWindowName
};
if (!opts.avoidEvent) {
call('exported', obj);
}
if (cb) {
cb(obj);
@ -29416,10 +29422,7 @@ editor.init = function () {
var exportHandler = function exportHandler(win, data) {
var issues = data.issues,
exportWindowName = data.exportWindowName;
if (exportWindowName) {
exportWindow = window.open(blankPageObjectURL || '', exportWindowName); // A hack to get the window via JSON-able name without opening a new one
}
if (!exportWindow || exportWindow.closed) {
$$b.alert(uiStrings$1.notification.popupWindowBlocked);

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

9
dist/index-umd.js vendored
View File

@ -17423,12 +17423,15 @@
* @param {Float} [quality] Between 0 and 1
* @param {string} [exportWindowName]
* @param {module:svgcanvas.ImageExportedCallback} [cb]
* @param {PlainObject} [opts]
* @param {boolean} [opts.avoidEvent]
* @fires module:svgcanvas.SvgCanvas#event:exported
* @todo Confirm/fix ICO type
* @returns {Promise} Resolves to {@link module:svgcanvas.ImageExportedResults}
*/
this.rasterExport = function (imgType, quality, exportWindowName, cb) {
var opts = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {};
var type = imgType === 'ICO' ? 'BMP' : imgType || 'PNG';
var mimeType = 'image/' + type.toLowerCase();
@ -17461,7 +17464,10 @@
quality: quality,
exportWindowName: exportWindowName
};
if (!opts.avoidEvent) {
call('exported', obj);
}
if (cb) {
cb(obj);
@ -29422,10 +29428,7 @@
var exportHandler = function exportHandler(win, data) {
var issues = data.issues,
exportWindowName = data.exportWindowName;
if (exportWindowName) {
exportWindow = window.open(blankPageObjectURL || '', exportWindowName); // A hack to get the window via JSON-able name without opening a new one
}
if (!exportWindow || exportWindow.closed) {
$$b.alert(uiStrings$1.notification.popupWindowBlocked);

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -30,11 +30,14 @@ function saveSvg () {
function exportPNG () {
svgCanvas.getUIStrings()(function (uiStrings) {
const str = uiStrings.notification.loadingImage;
const exportWindow = window.open(
let exportWindow;
if (!isChrome()) {
exportWindow = window.open(
'data:text/html;charset=utf-8,' + encodeURIComponent('<title>' + str + '</title><h1>' + str + '</h1>'),
'svg-edit-exportWindow'
);
svgCanvas.rasterExport('PNG', null, exportWindow && exportWindow.name);
}
svgCanvas.rasterExport('PNG', null, exportWindow && exportWindow.name)();
});
}
@ -52,6 +55,7 @@ function exportPDF () {
*/
if (isChrome()) {
// Chrome will open an extra window if we follow the approach below
svgCanvas.exportPDF();
} else {
const exportWindow = window.open(
@ -64,7 +68,7 @@ function exportPDF () {
}
const frameBase = 'https://raw.githack.com/SVG-Edit/svgedit/master';
// const frameBase = 'http://localhost:8000';
// const frameBase = 'http://localhost:8001';
const framePath = '/editor/xdomain-svg-editor-es.html?extensions=ext-xdomain-messaging.js';
const iframe = $('<iframe width="900px" height="600px" id="svgedit"></iframe>');
iframe[0].src = frameBase + framePath +
@ -80,10 +84,12 @@ iframe[0].addEventListener('load', function () {
doc = frame.contentDocument || frame.contentWindow.document;
} catch (err) {
console.log('Blocked from accessing document', err);
return;
}
if (doc) {
// Todo: Provide a way to get this to occur by `postMessage`
const mainButton = doc.getElementById('main_button');
mainButton.style.display = 'none';
}
// Add event handlers now that `svgCanvas` is ready
$('#load').click(loadSvg);

View File

@ -1738,9 +1738,7 @@ editor.init = function () {
const exportHandler = function (win, data) {
const {issues, exportWindowName} = data;
if (exportWindowName) {
exportWindow = window.open(Utils.blankPageObjectURL || '', exportWindowName); // A hack to get the window via JSON-able name without opening a new one
}
if (!exportWindow || exportWindow.closed) {
$.alert(uiStrings.notification.popupWindowBlocked);

View File

@ -3871,11 +3871,13 @@ let canvg;
* @param {Float} [quality] Between 0 and 1
* @param {string} [exportWindowName]
* @param {module:svgcanvas.ImageExportedCallback} [cb]
* @param {PlainObject} [opts]
* @param {boolean} [opts.avoidEvent]
* @fires module:svgcanvas.SvgCanvas#event:exported
* @todo Confirm/fix ICO type
* @returns {Promise} Resolves to {@link module:svgcanvas.ImageExportedResults}
*/
this.rasterExport = function (imgType, quality, exportWindowName, cb) {
this.rasterExport = function (imgType, quality, exportWindowName, cb, opts = {}) {
const type = imgType === 'ICO' ? 'BMP' : (imgType || 'PNG');
const mimeType = 'image/' + type.toLowerCase();
const {issues, issueCodes} = getIssues();
@ -3905,7 +3907,9 @@ this.rasterExport = function (imgType, quality, exportWindowName, cb) {
datauri, bloburl, svg, issues, issueCodes, type: imgType,
mimeType, quality, exportWindowName
};
if (!opts.avoidEvent) {
call('exported', obj);
}
if (cb) {
cb(obj);
}

View File

@ -17420,12 +17420,15 @@
* @param {Float} [quality] Between 0 and 1
* @param {string} [exportWindowName]
* @param {module:svgcanvas.ImageExportedCallback} [cb]
* @param {PlainObject} [opts]
* @param {boolean} [opts.avoidEvent]
* @fires module:svgcanvas.SvgCanvas#event:exported
* @todo Confirm/fix ICO type
* @returns {Promise} Resolves to {@link module:svgcanvas.ImageExportedResults}
*/
this.rasterExport = function (imgType, quality, exportWindowName, cb) {
var opts = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {};
var type = imgType === 'ICO' ? 'BMP' : imgType || 'PNG';
var mimeType = 'image/' + type.toLowerCase();
@ -17458,7 +17461,10 @@
quality: quality,
exportWindowName: exportWindowName
};
if (!opts.avoidEvent) {
call('exported', obj);
}
if (cb) {
cb(obj);
@ -29419,10 +29425,7 @@
var exportHandler = function exportHandler(win, data) {
var issues = data.issues,
exportWindowName = data.exportWindowName;
if (exportWindowName) {
exportWindow = window.open(blankPageObjectURL || '', exportWindowName); // A hack to get the window via JSON-able name without opening a new one
}
if (!exportWindow || exportWindow.closed) {
$$b.alert(uiStrings$1.notification.popupWindowBlocked);

View File

@ -17420,12 +17420,15 @@
* @param {Float} [quality] Between 0 and 1
* @param {string} [exportWindowName]
* @param {module:svgcanvas.ImageExportedCallback} [cb]
* @param {PlainObject} [opts]
* @param {boolean} [opts.avoidEvent]
* @fires module:svgcanvas.SvgCanvas#event:exported
* @todo Confirm/fix ICO type
* @returns {Promise} Resolves to {@link module:svgcanvas.ImageExportedResults}
*/
this.rasterExport = function (imgType, quality, exportWindowName, cb) {
var opts = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {};
var type = imgType === 'ICO' ? 'BMP' : imgType || 'PNG';
var mimeType = 'image/' + type.toLowerCase();
@ -17458,7 +17461,10 @@
quality: quality,
exportWindowName: exportWindowName
};
if (!opts.avoidEvent) {
call('exported', obj);
}
if (cb) {
cb(obj);
@ -29419,10 +29425,7 @@
var exportHandler = function exportHandler(win, data) {
var issues = data.issues,
exportWindowName = data.exportWindowName;
if (exportWindowName) {
exportWindow = window.open(blankPageObjectURL || '', exportWindowName); // A hack to get the window via JSON-able name without opening a new one
}
if (!exportWindow || exportWindow.closed) {
$$b.alert(uiStrings$1.notification.popupWindowBlocked);