- npm: Update devDeps
- Fix: Enforce stylesheet ordering sequence - Fix: Ensure SVG-edit hidden until stylesheets loaded - Fix: Avoid abandoning stylesheet loading if one load fails
This commit is contained in:
8
editor/external/load-stylesheets/index-es.js
vendored
8
editor/external/load-stylesheets/index-es.js
vendored
@@ -1,6 +1,7 @@
|
|||||||
function loadStylesheets(stylesheets, {
|
function loadStylesheets(stylesheets, {
|
||||||
before: beforeDefault, after: afterDefault, favicon: faviconDefault,
|
before: beforeDefault, after: afterDefault, favicon: faviconDefault,
|
||||||
canvas: canvasDefault, image: imageDefault = true
|
canvas: canvasDefault, image: imageDefault = true,
|
||||||
|
acceptErrors
|
||||||
} = {}) {
|
} = {}) {
|
||||||
stylesheets = Array.isArray(stylesheets) ? stylesheets : [stylesheets];
|
stylesheets = Array.isArray(stylesheets) ? stylesheets : [stylesheets];
|
||||||
|
|
||||||
@@ -28,6 +29,11 @@ function loadStylesheets(stylesheets, {
|
|||||||
|
|
||||||
const link = document.createElement('link');
|
const link = document.createElement('link');
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
|
if (acceptErrors) {
|
||||||
|
reject = typeof acceptErrors === 'function' ? error => {
|
||||||
|
acceptErrors({ error, stylesheetURL, options, resolve, reject });
|
||||||
|
} : resolve;
|
||||||
|
}
|
||||||
if (stylesheetURL.endsWith('.css')) {
|
if (stylesheetURL.endsWith('.css')) {
|
||||||
favicon = false;
|
favicon = false;
|
||||||
} else if (stylesheetURL.endsWith('.ico')) {
|
} else if (stylesheetURL.endsWith('.ico')) {
|
||||||
|
|||||||
@@ -38,6 +38,8 @@
|
|||||||
<title>SVG-edit</title>
|
<title>SVG-edit</title>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|
||||||
|
<div id="svg_container" style="visibility: hidden;">
|
||||||
<div id="svg_editor">
|
<div id="svg_editor">
|
||||||
<div id="rulers">
|
<div id="rulers">
|
||||||
<div id="ruler_corner"></div>
|
<div id="ruler_corner"></div>
|
||||||
@@ -762,5 +764,7 @@
|
|||||||
<li><a href="#merge_down">Merge Down</a></li>
|
<li><a href="#merge_down">Merge Down</a></li>
|
||||||
<li><a href="#merge_all">Merge All</a></li>
|
<li><a href="#merge_all">Merge All</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
|
</div>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
@@ -39,6 +39,8 @@
|
|||||||
<title>SVG-edit</title>
|
<title>SVG-edit</title>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|
||||||
|
<div id="svg_container" style="visibility: hidden;">
|
||||||
<div id="svg_editor">
|
<div id="svg_editor">
|
||||||
<div id="rulers">
|
<div id="rulers">
|
||||||
<div id="ruler_corner"></div>
|
<div id="ruler_corner"></div>
|
||||||
@@ -763,5 +765,7 @@
|
|||||||
<li><a href="#merge_down">Merge Down</a></li>
|
<li><a href="#merge_down">Merge Down</a></li>
|
||||||
<li><a href="#merge_all">Merge All</a></li>
|
<li><a href="#merge_all">Merge All</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
|
</div>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
@@ -1013,7 +1013,28 @@ editor.init = function () {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
let stylesheets = $.loadingStylesheets;
|
function getStylesheetPriority (stylesheet) {
|
||||||
|
switch (stylesheet) {
|
||||||
|
case 'jgraduate/css/jPicker.css':
|
||||||
|
return 1;
|
||||||
|
case 'jgraduate/css/jgraduate.css':
|
||||||
|
return 2;
|
||||||
|
case 'svg-editor.css':
|
||||||
|
return 3;
|
||||||
|
case 'spinbtn/JQuerySpinBtn.css':
|
||||||
|
return 4;
|
||||||
|
default:
|
||||||
|
return Infinity;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
let stylesheets = $.loadingStylesheets.sort((a, b) => {
|
||||||
|
const priorityA = getStylesheetPriority(a);
|
||||||
|
const priorityB = getStylesheetPriority(b);
|
||||||
|
if (priorityA === priorityB) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return priorityA > priorityB;
|
||||||
|
});
|
||||||
if (curConfig.stylesheets.length) {
|
if (curConfig.stylesheets.length) {
|
||||||
// Ensure a copy with unique items
|
// Ensure a copy with unique items
|
||||||
stylesheets = [...new Set(curConfig.stylesheets)];
|
stylesheets = [...new Set(curConfig.stylesheets)];
|
||||||
@@ -1022,7 +1043,14 @@ editor.init = function () {
|
|||||||
stylesheets.splice(idx, 1, ...$.loadingStylesheets);
|
stylesheets.splice(idx, 1, ...$.loadingStylesheets);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
loadStylesheets(stylesheets).then(() => {
|
loadStylesheets(stylesheets, {acceptErrors: ({stylesheetURL, reject, resolve}) => {
|
||||||
|
if ($.loadingStylesheets.includes(stylesheetURL)) {
|
||||||
|
reject(new Error(`Missing expected stylesheet: ${stylesheetURL}`));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
resolve();
|
||||||
|
}}).then(() => {
|
||||||
|
$('#svg_container')[0].style.visibility = 'visible';
|
||||||
editor.runCallbacks();
|
editor.runCallbacks();
|
||||||
|
|
||||||
setTimeout(function () {
|
setTimeout(function () {
|
||||||
|
|||||||
24
package-lock.json
generated
24
package-lock.json
generated
@@ -2099,9 +2099,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"eslint-plugin-promise": {
|
"eslint-plugin-promise": {
|
||||||
"version": "3.7.0",
|
"version": "3.8.0",
|
||||||
"resolved": "https://registry.npmjs.org/eslint-plugin-promise/-/eslint-plugin-promise-3.7.0.tgz",
|
"resolved": "https://registry.npmjs.org/eslint-plugin-promise/-/eslint-plugin-promise-3.8.0.tgz",
|
||||||
"integrity": "sha512-2WO+ZFh7vxUKRfR0cOIMrWgYKdR6S1AlOezw6pC52B6oYpd5WFghN+QHxvrRdZMtbo8h3dfUZ2o1rWb0UPbKtg==",
|
"integrity": "sha512-JiFL9UFR15NKpHyGii1ZcvmtIqa3UTwiDAGb8atSffe43qJ3+1czVGN6UtkklpcJ2DVnqvTMzEKRaJdBkAL2aQ==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"eslint-plugin-qunit": {
|
"eslint-plugin-qunit": {
|
||||||
@@ -4169,9 +4169,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"load-stylesheets": {
|
"load-stylesheets": {
|
||||||
"version": "0.4.0",
|
"version": "0.5.0",
|
||||||
"resolved": "https://registry.npmjs.org/load-stylesheets/-/load-stylesheets-0.4.0.tgz",
|
"resolved": "https://registry.npmjs.org/load-stylesheets/-/load-stylesheets-0.5.0.tgz",
|
||||||
"integrity": "sha512-TdQ1o1VoEeWHroccgJiQrH9q/ospM3gjEEJRgmYSzvtmdNDMeaKHMJGbrMh2XIIvBvST79e9ZZq4BXIjO6V/bw==",
|
"integrity": "sha512-ij2m0dWH8BUPDgfzAJEyFjrfAlLUDg7Xme8okc7ruijjzBpNa0Eh+SzjdbxYtKW5hj+hid+otXCibUDYqz+NRA==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"locate-path": {
|
"locate-path": {
|
||||||
@@ -5369,9 +5369,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"rollup": {
|
"rollup": {
|
||||||
"version": "0.59.2",
|
"version": "0.59.4",
|
||||||
"resolved": "https://registry.npmjs.org/rollup/-/rollup-0.59.2.tgz",
|
"resolved": "https://registry.npmjs.org/rollup/-/rollup-0.59.4.tgz",
|
||||||
"integrity": "sha512-lu+yLa4xXMccYCKCQLIcGp4Rw2ZefFvJJUjuGQuFhZpCtggwe4SI0RYq2mV9/YDwYFXBYB7z3HrSxq1tSnzjkw==",
|
"integrity": "sha512-ISiMqq/aJa+57QxX2MRcvLESHdJ7wSavmr6U1euMr+6UgFe6KM+3QANrYy8LQofwhTC1I7BcAdlLnDiaODs1BA==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"@types/estree": "0.0.39",
|
"@types/estree": "0.0.39",
|
||||||
@@ -5751,9 +5751,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"sinon-test": {
|
"sinon-test": {
|
||||||
"version": "2.1.3",
|
"version": "2.2.0",
|
||||||
"resolved": "https://registry.npmjs.org/sinon-test/-/sinon-test-2.1.3.tgz",
|
"resolved": "https://registry.npmjs.org/sinon-test/-/sinon-test-2.2.0.tgz",
|
||||||
"integrity": "sha512-8hGEAOj5maRRDhcWv81uAOmSZQwQXd+ymvB3h5NnwYDOQYRx1CFE/LORYI7T4mDgNpUJJ30ruu1pjN3+k34Vsw==",
|
"integrity": "sha512-CWHb3fDDJZ9844ZwP3mWRw4XFdbyYyqhLHN+HegYtBwhMjeDgHA8/+YbN28A3zjgx1icHy1tMP/HCvQXptd3iw==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"slash": {
|
"slash": {
|
||||||
|
|||||||
@@ -54,15 +54,15 @@
|
|||||||
"eslint-config-standard": "11.0.0",
|
"eslint-config-standard": "11.0.0",
|
||||||
"eslint-plugin-import": "2.12.0",
|
"eslint-plugin-import": "2.12.0",
|
||||||
"eslint-plugin-node": "6.0.1",
|
"eslint-plugin-node": "6.0.1",
|
||||||
"eslint-plugin-promise": "3.7.0",
|
"eslint-plugin-promise": "3.8.0",
|
||||||
"eslint-plugin-qunit": "^3.2.1",
|
"eslint-plugin-qunit": "^3.2.1",
|
||||||
"eslint-plugin-standard": "3.1.0",
|
"eslint-plugin-standard": "3.1.0",
|
||||||
"imageoptim-cli": "^2.0.2",
|
"imageoptim-cli": "^2.0.2",
|
||||||
"load-stylesheets": "^0.4.0",
|
"load-stylesheets": "^0.5.0",
|
||||||
"node-static": "^0.7.10",
|
"node-static": "^0.7.10",
|
||||||
"opn-cli": "^3.1.0",
|
"opn-cli": "^3.1.0",
|
||||||
"qunit": "^2.6.1",
|
"qunit": "^2.6.1",
|
||||||
"rollup": "0.59.2",
|
"rollup": "0.59.4",
|
||||||
"rollup-plugin-babel": "^3.0.4",
|
"rollup-plugin-babel": "^3.0.4",
|
||||||
"rollup-plugin-commonjs": "^9.1.3",
|
"rollup-plugin-commonjs": "^9.1.3",
|
||||||
"rollup-plugin-json": "^3.0.0",
|
"rollup-plugin-json": "^3.0.0",
|
||||||
@@ -71,7 +71,7 @@
|
|||||||
"rollup-plugin-re": "^1.0.7",
|
"rollup-plugin-re": "^1.0.7",
|
||||||
"rollup-plugin-uglify": "^4.0.0",
|
"rollup-plugin-uglify": "^4.0.0",
|
||||||
"sinon": "^5.0.10",
|
"sinon": "^5.0.10",
|
||||||
"sinon-test": "^2.1.3",
|
"sinon-test": "^2.2.0",
|
||||||
"uglify-es": "^3.3.9"
|
"uglify-es": "^3.3.9"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user