- 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 fixesmaster
parent
07f59ba01a
commit
283ef0b521
16
CHANGES.md
16
CHANGES.md
|
@ -1,16 +1,21 @@
|
||||||
# 3.1.0
|
# 3.1.0
|
||||||
|
|
||||||
- Fix (Embedded editor): (Though embedding cross-origin iframes apparently
|
- Fix (Embedded editor): (Though cross-origin DOM access of iframes apparently
|
||||||
only working now in Chrome if same origin or if https?--at least not
|
doesn't work now in Chrome or Firefox (which we had been using to disable a
|
||||||
localhost of different ports), PDF export has been fixed (we download the
|
button) nor does cross-origin storage access work in Chrome), PDF export has
|
||||||
PDF to workaround data URI limitations in Chrome)
|
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
|
- Fix (Embedded editor): Avoid using same origin shortcut if there is no
|
||||||
global available to use (e.g., if using the modular editor)
|
global available to use (e.g., if using the modular editor)
|
||||||
- Fix (Embedded editor): Add events only after load is complete and
|
- Fix (Embedded editor): Add events only after load is complete and
|
||||||
svgCanvas is available; also log blocked error objects
|
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
|
- Enhancement: For anyone visiting the ES6 modules entrance file without ESM
|
||||||
support, redirect to non-modular version
|
support, redirect to non-modular version
|
||||||
- Enhancement: For PDF export, switch Chrome by default to "save" `outputType`
|
- 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
|
- Refactoring (canvg): Better type-checking on `canvasRGBA_` (but set
|
||||||
correctly by default anyways)
|
correctly by default anyways)
|
||||||
- Refactoring: Avoid redundant use of \*AttributeNS methods with
|
- Refactoring: Avoid redundant use of \*AttributeNS methods with
|
||||||
|
@ -20,7 +25,8 @@
|
||||||
- Refactoring: Line breaks
|
- Refactoring: Line breaks
|
||||||
- Refactoring: Reorder path config to group (non-modular-dependent) image
|
- Refactoring: Reorder path config to group (non-modular-dependent) image
|
||||||
paths together (and correct code comment)
|
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: Versions section (for migrating)
|
||||||
- Docs: More info on `importLocale` for extensions
|
- Docs: More info on `importLocale` for extensions
|
||||||
- Docs: Add code comment re: use of `extIconsPath` in Mathjax
|
- Docs: Add code comment re: use of `extIconsPath` in Mathjax
|
||||||
|
|
|
@ -92,8 +92,8 @@ incorporating SVGEdit.
|
||||||
|
|
||||||
## Recent news
|
## Recent news
|
||||||
|
|
||||||
- 2018-10-24 Published 3.1.0 (Embedded editor fixes and redirect on modular
|
- 2018-10-24 Published 3.1.0 (Redirect on modular page for non-module-support;
|
||||||
page for non-module-support; versions document (for migrating))
|
versions document (for migrating))
|
||||||
- 2018-10-22 Published 3.0.1 (Revert fix affecting polygon selection)
|
- 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
|
- 2018-10-21 Published 3.0.0 (misc. improvements including centering canvas and
|
||||||
key locale fixes since last RC)
|
key locale fixes since last RC)
|
||||||
|
|
|
@ -17417,12 +17417,15 @@ function SvgCanvas(container, config) {
|
||||||
* @param {Float} [quality] Between 0 and 1
|
* @param {Float} [quality] Between 0 and 1
|
||||||
* @param {string} [exportWindowName]
|
* @param {string} [exportWindowName]
|
||||||
* @param {module:svgcanvas.ImageExportedCallback} [cb]
|
* @param {module:svgcanvas.ImageExportedCallback} [cb]
|
||||||
|
* @param {PlainObject} [opts]
|
||||||
|
* @param {boolean} [opts.avoidEvent]
|
||||||
* @fires module:svgcanvas.SvgCanvas#event:exported
|
* @fires module:svgcanvas.SvgCanvas#event:exported
|
||||||
* @todo Confirm/fix ICO type
|
* @todo Confirm/fix ICO type
|
||||||
* @returns {Promise} Resolves to {@link module:svgcanvas.ImageExportedResults}
|
* @returns {Promise} Resolves to {@link module:svgcanvas.ImageExportedResults}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
this.rasterExport = function (imgType, quality, exportWindowName, cb) {
|
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 type = imgType === 'ICO' ? 'BMP' : imgType || 'PNG';
|
||||||
var mimeType = 'image/' + type.toLowerCase();
|
var mimeType = 'image/' + type.toLowerCase();
|
||||||
|
|
||||||
|
@ -17455,7 +17458,10 @@ function SvgCanvas(container, config) {
|
||||||
quality: quality,
|
quality: quality,
|
||||||
exportWindowName: exportWindowName
|
exportWindowName: exportWindowName
|
||||||
};
|
};
|
||||||
call('exported', obj);
|
|
||||||
|
if (!opts.avoidEvent) {
|
||||||
|
call('exported', obj);
|
||||||
|
}
|
||||||
|
|
||||||
if (cb) {
|
if (cb) {
|
||||||
cb(obj);
|
cb(obj);
|
||||||
|
@ -29416,10 +29422,7 @@ editor.init = function () {
|
||||||
var exportHandler = function exportHandler(win, data) {
|
var exportHandler = function exportHandler(win, data) {
|
||||||
var issues = data.issues,
|
var issues = data.issues,
|
||||||
exportWindowName = data.exportWindowName;
|
exportWindowName = data.exportWindowName;
|
||||||
|
exportWindow = window.open(blankPageObjectURL || '', exportWindowName); // A hack to get the window via JSON-able name without opening a new one
|
||||||
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) {
|
if (!exportWindow || exportWindow.closed) {
|
||||||
$$b.alert(uiStrings$1.notification.popupWindowBlocked);
|
$$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
|
@ -17423,12 +17423,15 @@
|
||||||
* @param {Float} [quality] Between 0 and 1
|
* @param {Float} [quality] Between 0 and 1
|
||||||
* @param {string} [exportWindowName]
|
* @param {string} [exportWindowName]
|
||||||
* @param {module:svgcanvas.ImageExportedCallback} [cb]
|
* @param {module:svgcanvas.ImageExportedCallback} [cb]
|
||||||
|
* @param {PlainObject} [opts]
|
||||||
|
* @param {boolean} [opts.avoidEvent]
|
||||||
* @fires module:svgcanvas.SvgCanvas#event:exported
|
* @fires module:svgcanvas.SvgCanvas#event:exported
|
||||||
* @todo Confirm/fix ICO type
|
* @todo Confirm/fix ICO type
|
||||||
* @returns {Promise} Resolves to {@link module:svgcanvas.ImageExportedResults}
|
* @returns {Promise} Resolves to {@link module:svgcanvas.ImageExportedResults}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
this.rasterExport = function (imgType, quality, exportWindowName, cb) {
|
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 type = imgType === 'ICO' ? 'BMP' : imgType || 'PNG';
|
||||||
var mimeType = 'image/' + type.toLowerCase();
|
var mimeType = 'image/' + type.toLowerCase();
|
||||||
|
|
||||||
|
@ -17461,7 +17464,10 @@
|
||||||
quality: quality,
|
quality: quality,
|
||||||
exportWindowName: exportWindowName
|
exportWindowName: exportWindowName
|
||||||
};
|
};
|
||||||
call('exported', obj);
|
|
||||||
|
if (!opts.avoidEvent) {
|
||||||
|
call('exported', obj);
|
||||||
|
}
|
||||||
|
|
||||||
if (cb) {
|
if (cb) {
|
||||||
cb(obj);
|
cb(obj);
|
||||||
|
@ -29422,10 +29428,7 @@
|
||||||
var exportHandler = function exportHandler(win, data) {
|
var exportHandler = function exportHandler(win, data) {
|
||||||
var issues = data.issues,
|
var issues = data.issues,
|
||||||
exportWindowName = data.exportWindowName;
|
exportWindowName = data.exportWindowName;
|
||||||
|
exportWindow = window.open(blankPageObjectURL || '', exportWindowName); // A hack to get the window via JSON-able name without opening a new one
|
||||||
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) {
|
if (!exportWindow || exportWindow.closed) {
|
||||||
$$b.alert(uiStrings$1.notification.popupWindowBlocked);
|
$$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
|
@ -30,11 +30,14 @@ function saveSvg () {
|
||||||
function exportPNG () {
|
function exportPNG () {
|
||||||
svgCanvas.getUIStrings()(function (uiStrings) {
|
svgCanvas.getUIStrings()(function (uiStrings) {
|
||||||
const str = uiStrings.notification.loadingImage;
|
const str = uiStrings.notification.loadingImage;
|
||||||
const exportWindow = window.open(
|
let exportWindow;
|
||||||
'data:text/html;charset=utf-8,' + encodeURIComponent('<title>' + str + '</title><h1>' + str + '</h1>'),
|
if (!isChrome()) {
|
||||||
'svg-edit-exportWindow'
|
exportWindow = window.open(
|
||||||
);
|
'data:text/html;charset=utf-8,' + encodeURIComponent('<title>' + str + '</title><h1>' + str + '</h1>'),
|
||||||
svgCanvas.rasterExport('PNG', null, exportWindow && exportWindow.name);
|
'svg-edit-exportWindow'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
svgCanvas.rasterExport('PNG', null, exportWindow && exportWindow.name)();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -52,6 +55,7 @@ function exportPDF () {
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (isChrome()) {
|
if (isChrome()) {
|
||||||
|
// Chrome will open an extra window if we follow the approach below
|
||||||
svgCanvas.exportPDF();
|
svgCanvas.exportPDF();
|
||||||
} else {
|
} else {
|
||||||
const exportWindow = window.open(
|
const exportWindow = window.open(
|
||||||
|
@ -64,7 +68,7 @@ function exportPDF () {
|
||||||
}
|
}
|
||||||
|
|
||||||
const frameBase = 'https://raw.githack.com/SVG-Edit/svgedit/master';
|
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 framePath = '/editor/xdomain-svg-editor-es.html?extensions=ext-xdomain-messaging.js';
|
||||||
const iframe = $('<iframe width="900px" height="600px" id="svgedit"></iframe>');
|
const iframe = $('<iframe width="900px" height="600px" id="svgedit"></iframe>');
|
||||||
iframe[0].src = frameBase + framePath +
|
iframe[0].src = frameBase + framePath +
|
||||||
|
@ -80,10 +84,12 @@ iframe[0].addEventListener('load', function () {
|
||||||
doc = frame.contentDocument || frame.contentWindow.document;
|
doc = frame.contentDocument || frame.contentWindow.document;
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.log('Blocked from accessing document', err);
|
console.log('Blocked from accessing document', err);
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
const mainButton = doc.getElementById('main_button');
|
if (doc) {
|
||||||
mainButton.style.display = 'none';
|
// 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
|
// Add event handlers now that `svgCanvas` is ready
|
||||||
$('#load').click(loadSvg);
|
$('#load').click(loadSvg);
|
||||||
|
|
|
@ -1738,9 +1738,7 @@ editor.init = function () {
|
||||||
const exportHandler = function (win, data) {
|
const exportHandler = function (win, data) {
|
||||||
const {issues, exportWindowName} = 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
|
||||||
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) {
|
if (!exportWindow || exportWindow.closed) {
|
||||||
$.alert(uiStrings.notification.popupWindowBlocked);
|
$.alert(uiStrings.notification.popupWindowBlocked);
|
||||||
|
|
|
@ -3871,11 +3871,13 @@ let canvg;
|
||||||
* @param {Float} [quality] Between 0 and 1
|
* @param {Float} [quality] Between 0 and 1
|
||||||
* @param {string} [exportWindowName]
|
* @param {string} [exportWindowName]
|
||||||
* @param {module:svgcanvas.ImageExportedCallback} [cb]
|
* @param {module:svgcanvas.ImageExportedCallback} [cb]
|
||||||
|
* @param {PlainObject} [opts]
|
||||||
|
* @param {boolean} [opts.avoidEvent]
|
||||||
* @fires module:svgcanvas.SvgCanvas#event:exported
|
* @fires module:svgcanvas.SvgCanvas#event:exported
|
||||||
* @todo Confirm/fix ICO type
|
* @todo Confirm/fix ICO type
|
||||||
* @returns {Promise} Resolves to {@link module:svgcanvas.ImageExportedResults}
|
* @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 type = imgType === 'ICO' ? 'BMP' : (imgType || 'PNG');
|
||||||
const mimeType = 'image/' + type.toLowerCase();
|
const mimeType = 'image/' + type.toLowerCase();
|
||||||
const {issues, issueCodes} = getIssues();
|
const {issues, issueCodes} = getIssues();
|
||||||
|
@ -3905,7 +3907,9 @@ this.rasterExport = function (imgType, quality, exportWindowName, cb) {
|
||||||
datauri, bloburl, svg, issues, issueCodes, type: imgType,
|
datauri, bloburl, svg, issues, issueCodes, type: imgType,
|
||||||
mimeType, quality, exportWindowName
|
mimeType, quality, exportWindowName
|
||||||
};
|
};
|
||||||
call('exported', obj);
|
if (!opts.avoidEvent) {
|
||||||
|
call('exported', obj);
|
||||||
|
}
|
||||||
if (cb) {
|
if (cb) {
|
||||||
cb(obj);
|
cb(obj);
|
||||||
}
|
}
|
||||||
|
|
|
@ -17420,12 +17420,15 @@
|
||||||
* @param {Float} [quality] Between 0 and 1
|
* @param {Float} [quality] Between 0 and 1
|
||||||
* @param {string} [exportWindowName]
|
* @param {string} [exportWindowName]
|
||||||
* @param {module:svgcanvas.ImageExportedCallback} [cb]
|
* @param {module:svgcanvas.ImageExportedCallback} [cb]
|
||||||
|
* @param {PlainObject} [opts]
|
||||||
|
* @param {boolean} [opts.avoidEvent]
|
||||||
* @fires module:svgcanvas.SvgCanvas#event:exported
|
* @fires module:svgcanvas.SvgCanvas#event:exported
|
||||||
* @todo Confirm/fix ICO type
|
* @todo Confirm/fix ICO type
|
||||||
* @returns {Promise} Resolves to {@link module:svgcanvas.ImageExportedResults}
|
* @returns {Promise} Resolves to {@link module:svgcanvas.ImageExportedResults}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
this.rasterExport = function (imgType, quality, exportWindowName, cb) {
|
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 type = imgType === 'ICO' ? 'BMP' : imgType || 'PNG';
|
||||||
var mimeType = 'image/' + type.toLowerCase();
|
var mimeType = 'image/' + type.toLowerCase();
|
||||||
|
|
||||||
|
@ -17458,7 +17461,10 @@
|
||||||
quality: quality,
|
quality: quality,
|
||||||
exportWindowName: exportWindowName
|
exportWindowName: exportWindowName
|
||||||
};
|
};
|
||||||
call('exported', obj);
|
|
||||||
|
if (!opts.avoidEvent) {
|
||||||
|
call('exported', obj);
|
||||||
|
}
|
||||||
|
|
||||||
if (cb) {
|
if (cb) {
|
||||||
cb(obj);
|
cb(obj);
|
||||||
|
@ -29419,10 +29425,7 @@
|
||||||
var exportHandler = function exportHandler(win, data) {
|
var exportHandler = function exportHandler(win, data) {
|
||||||
var issues = data.issues,
|
var issues = data.issues,
|
||||||
exportWindowName = data.exportWindowName;
|
exportWindowName = data.exportWindowName;
|
||||||
|
exportWindow = window.open(blankPageObjectURL || '', exportWindowName); // A hack to get the window via JSON-able name without opening a new one
|
||||||
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) {
|
if (!exportWindow || exportWindow.closed) {
|
||||||
$$b.alert(uiStrings$1.notification.popupWindowBlocked);
|
$$b.alert(uiStrings$1.notification.popupWindowBlocked);
|
||||||
|
|
|
@ -17420,12 +17420,15 @@
|
||||||
* @param {Float} [quality] Between 0 and 1
|
* @param {Float} [quality] Between 0 and 1
|
||||||
* @param {string} [exportWindowName]
|
* @param {string} [exportWindowName]
|
||||||
* @param {module:svgcanvas.ImageExportedCallback} [cb]
|
* @param {module:svgcanvas.ImageExportedCallback} [cb]
|
||||||
|
* @param {PlainObject} [opts]
|
||||||
|
* @param {boolean} [opts.avoidEvent]
|
||||||
* @fires module:svgcanvas.SvgCanvas#event:exported
|
* @fires module:svgcanvas.SvgCanvas#event:exported
|
||||||
* @todo Confirm/fix ICO type
|
* @todo Confirm/fix ICO type
|
||||||
* @returns {Promise} Resolves to {@link module:svgcanvas.ImageExportedResults}
|
* @returns {Promise} Resolves to {@link module:svgcanvas.ImageExportedResults}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
this.rasterExport = function (imgType, quality, exportWindowName, cb) {
|
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 type = imgType === 'ICO' ? 'BMP' : imgType || 'PNG';
|
||||||
var mimeType = 'image/' + type.toLowerCase();
|
var mimeType = 'image/' + type.toLowerCase();
|
||||||
|
|
||||||
|
@ -17458,7 +17461,10 @@
|
||||||
quality: quality,
|
quality: quality,
|
||||||
exportWindowName: exportWindowName
|
exportWindowName: exportWindowName
|
||||||
};
|
};
|
||||||
call('exported', obj);
|
|
||||||
|
if (!opts.avoidEvent) {
|
||||||
|
call('exported', obj);
|
||||||
|
}
|
||||||
|
|
||||||
if (cb) {
|
if (cb) {
|
||||||
cb(obj);
|
cb(obj);
|
||||||
|
@ -29419,10 +29425,7 @@
|
||||||
var exportHandler = function exportHandler(win, data) {
|
var exportHandler = function exportHandler(win, data) {
|
||||||
var issues = data.issues,
|
var issues = data.issues,
|
||||||
exportWindowName = data.exportWindowName;
|
exportWindowName = data.exportWindowName;
|
||||||
|
exportWindow = window.open(blankPageObjectURL || '', exportWindowName); // A hack to get the window via JSON-able name without opening a new one
|
||||||
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) {
|
if (!exportWindow || exportWindow.closed) {
|
||||||
$$b.alert(uiStrings$1.notification.popupWindowBlocked);
|
$$b.alert(uiStrings$1.notification.popupWindowBlocked);
|
||||||
|
|
Loading…
Reference in New Issue