Switch editor to add style mode when id=nonexistentstyle
This commit is contained in:
parent
f746cb1581
commit
9fd067c6e3
6
edit.js
6
edit.js
|
@ -1087,7 +1087,11 @@ function init() {
|
|||
// This is an edit
|
||||
tE("heading", "editStyleHeading", null, false);
|
||||
getStylesSafe({id: params.id}).then(styles => {
|
||||
const style = styles[0];
|
||||
let style = styles[0];
|
||||
if (!style) {
|
||||
style = {id: null, sections: []};
|
||||
history.replaceState({}, document.title, location.pathname);
|
||||
}
|
||||
styleId = style.id;
|
||||
setStyleMeta(style);
|
||||
onload = () => {
|
||||
|
|
|
@ -182,9 +182,13 @@ function filterStyles(options = {}) {
|
|||
|
||||
const styles = id == null
|
||||
? (code ? cachedStyles.list : cachedStyles.noCode)
|
||||
: [code ? cachedStyles.byId.get(id).style : cachedStyles.byId.get(id).noCode];
|
||||
: [(cachedStyles.byId.get(id) || {})[code ? 'style' : 'noCode']];
|
||||
const filtered = asHash ? {} : [];
|
||||
|
||||
if (!styles) {
|
||||
// may happen when users [accidentally] reopen an old URL
|
||||
// of edit.html with a non-existent style id parameter
|
||||
return filtered;
|
||||
}
|
||||
for (let i = 0, style; (style = styles[i]); i++) {
|
||||
if ((enabled == null || style.enabled == enabled)
|
||||
&& (url == null || style.url == url)
|
||||
|
|
Loading…
Reference in New Issue
Block a user