- Fix (Embedded API): Cross-domain may fail to even access `origin` or `contentDocument`
- Fix (Embedded API): Avoid adding URL to iframe src if there are no arguments - Fix (Cross-domain usage): Recover from exceptions with `localStorage` - Docs (JSDoc): Missing functionmaster
parent
f2b1a1ff0c
commit
d173df34d2
|
@ -19832,6 +19832,11 @@ var SvgCanvas = function SvgCanvas(container, config) {
|
|||
$$9('#cmenu_canvas').enableContextMenuItems('#paste,#paste_in_place');
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {"in_place"|"point"|undefined} type
|
||||
* @param {Number|undefined} x Expected if type is "point"
|
||||
* @param {Number|undefined} y Expected if type is "point"
|
||||
*/
|
||||
this.pasteElements = function (type, x, y) {
|
||||
var cb = JSON.parse(localStorage.getItem('svgedit_clipboard'));
|
||||
var len = cb.length;
|
||||
|
@ -30302,11 +30307,21 @@ editor.init = function () {
|
|||
$$b('#cmenu_canvas li').disableContextMenu();
|
||||
canvMenu.enableContextMenuItems('#delete,#cut,#copy');
|
||||
|
||||
canvMenu[(localStorage.getItem('svgedit_clipboard') ? 'en' : 'dis') + 'ableContextMenuItems']('#paste,#paste_in_place');
|
||||
window.addEventListener('storage', function (e) {
|
||||
if (e.key !== 'svgedit_clipboard') return;
|
||||
function enableOrDisableClipboard() {
|
||||
var svgeditClipboard = void 0;
|
||||
try {
|
||||
svgeditClipboard = localStorage.getItem('svgedit_clipboard');
|
||||
} catch (err) {}
|
||||
canvMenu[(svgeditClipboard ? 'en' : 'dis') + 'ableContextMenuItems']('#paste,#paste_in_place');
|
||||
}
|
||||
enableOrDisableClipboard();
|
||||
|
||||
canvMenu[(localStorage.getItem('svgedit_clipboard') ? 'en' : 'dis') + 'ableContextMenuItems']('#paste,#paste_in_place');
|
||||
window.addEventListener('storage', function (e) {
|
||||
if (e.key !== 'svgedit_clipboard') {
|
||||
return;
|
||||
}
|
||||
|
||||
enableOrDisableClipboard();
|
||||
});
|
||||
|
||||
window.addEventListener('beforeunload', function (e) {
|
||||
|
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -19838,6 +19838,11 @@
|
|||
$$9('#cmenu_canvas').enableContextMenuItems('#paste,#paste_in_place');
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {"in_place"|"point"|undefined} type
|
||||
* @param {Number|undefined} x Expected if type is "point"
|
||||
* @param {Number|undefined} y Expected if type is "point"
|
||||
*/
|
||||
this.pasteElements = function (type, x, y) {
|
||||
var cb = JSON.parse(localStorage.getItem('svgedit_clipboard'));
|
||||
var len = cb.length;
|
||||
|
@ -30308,11 +30313,21 @@
|
|||
$$b('#cmenu_canvas li').disableContextMenu();
|
||||
canvMenu.enableContextMenuItems('#delete,#cut,#copy');
|
||||
|
||||
canvMenu[(localStorage.getItem('svgedit_clipboard') ? 'en' : 'dis') + 'ableContextMenuItems']('#paste,#paste_in_place');
|
||||
window.addEventListener('storage', function (e) {
|
||||
if (e.key !== 'svgedit_clipboard') return;
|
||||
function enableOrDisableClipboard() {
|
||||
var svgeditClipboard = void 0;
|
||||
try {
|
||||
svgeditClipboard = localStorage.getItem('svgedit_clipboard');
|
||||
} catch (err) {}
|
||||
canvMenu[(svgeditClipboard ? 'en' : 'dis') + 'ableContextMenuItems']('#paste,#paste_in_place');
|
||||
}
|
||||
enableOrDisableClipboard();
|
||||
|
||||
canvMenu[(localStorage.getItem('svgedit_clipboard') ? 'en' : 'dis') + 'ableContextMenuItems']('#paste,#paste_in_place');
|
||||
window.addEventListener('storage', function (e) {
|
||||
if (e.key !== 'svgedit_clipboard') {
|
||||
return;
|
||||
}
|
||||
|
||||
enableOrDisableClipboard();
|
||||
});
|
||||
|
||||
window.addEventListener('beforeunload', function (e) {
|
||||
|
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -62,13 +62,21 @@ $('#exportPNG').click(exportPNG);
|
|||
$('#exportPDF').click(exportPDF);
|
||||
|
||||
const iframe = $('<iframe src="svg-editor-es.html?extensions=ext-xdomain-messaging.js' +
|
||||
window.location.href.replace(/\?(.*)$/, '&$1') + // Append arguments to this file onto the iframe
|
||||
(location.href.includes('?')
|
||||
? location.href.replace(/\?(.*)$/, '&$1')
|
||||
: '') + // Append arguments to this file onto the iframe
|
||||
'" width="900px" height="600px" id="svgedit""></iframe>'
|
||||
);
|
||||
iframe[0].addEventListener('load', function () {
|
||||
svgCanvas = new EmbeddedSVGEdit(frame);
|
||||
// Hide main button, as we will be controlling new, load, save, etc. from the host document
|
||||
const doc = frame.contentDocument || frame.contentWindow.document;
|
||||
let doc;
|
||||
try {
|
||||
doc = frame.contentDocument || frame.contentWindow.document;
|
||||
} catch (err) {
|
||||
console.log('Blocked from accessing document');
|
||||
return;
|
||||
}
|
||||
const mainButton = doc.getElementById('main_button');
|
||||
mainButton.style.display = 'none';
|
||||
});
|
||||
|
|
|
@ -297,7 +297,12 @@ class EmbeddedSVGEdit {
|
|||
* made compatile with all API functionality
|
||||
*/
|
||||
// We accept and post strings for the sake of IE9 support
|
||||
if (window.location.origin === t.frame.contentWindow.location.origin) {
|
||||
let sameOrigin = false;
|
||||
try {
|
||||
sameOrigin = window.location.origin === t.frame.contentWindow.location.origin;
|
||||
} catch (err) {}
|
||||
|
||||
if (sameOrigin) {
|
||||
// Although we do not really need this API if we are working same
|
||||
// domain, it could allow us to write in a way that would work
|
||||
// cross-domain as well, assuming we stick to the argument limitations
|
||||
|
|
|
@ -4951,15 +4951,21 @@ editor.init = function () {
|
|||
$('#cmenu_canvas li').disableContextMenu();
|
||||
canvMenu.enableContextMenuItems('#delete,#cut,#copy');
|
||||
|
||||
canvMenu[(localStorage.getItem('svgedit_clipboard') ? 'en' : 'dis') + 'ableContextMenuItems'](
|
||||
'#paste,#paste_in_place'
|
||||
);
|
||||
window.addEventListener('storage', function (e) {
|
||||
if (e.key !== 'svgedit_clipboard') return;
|
||||
|
||||
canvMenu[(localStorage.getItem('svgedit_clipboard') ? 'en' : 'dis') + 'ableContextMenuItems'](
|
||||
function enableOrDisableClipboard () {
|
||||
let 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) {
|
||||
|
|
|
@ -5270,6 +5270,11 @@ this.copySelectedElements = function () {
|
|||
$('#cmenu_canvas').enableContextMenuItems('#paste,#paste_in_place');
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {"in_place"|"point"|undefined} type
|
||||
* @param {Number|undefined} x Expected if type is "point"
|
||||
* @param {Number|undefined} y Expected if type is "point"
|
||||
*/
|
||||
this.pasteElements = function (type, x, y) {
|
||||
let cb = JSON.parse(localStorage.getItem('svgedit_clipboard'));
|
||||
let len = cb.length;
|
||||
|
|
Loading…
Reference in New Issue