Update ThemeRepo.plugin.js
This commit is contained in:
parent
86d53e37ec
commit
48c61b2914
|
@ -5,7 +5,7 @@ module.exports = (_ => {
|
||||||
"info": {
|
"info": {
|
||||||
"name": "ThemeRepo",
|
"name": "ThemeRepo",
|
||||||
"author": "DevilBro",
|
"author": "DevilBro",
|
||||||
"version": "2.0.7",
|
"version": "2.0.8",
|
||||||
"description": "Allows you to preview all themes from the theme repo and download them on the fly."
|
"description": "Allows you to preview all themes from the theme repo and download them on the fly."
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -254,8 +254,8 @@ module.exports = (_ => {
|
||||||
render: false,
|
render: false,
|
||||||
children: [
|
children: [
|
||||||
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsItem, {
|
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsItem, {
|
||||||
className: BDFDB.disCN.marginbottom20,
|
|
||||||
type: "Select",
|
type: "Select",
|
||||||
|
margin: 20,
|
||||||
label: "Choose a Generator Theme",
|
label: "Choose a Generator Theme",
|
||||||
basis: "60%",
|
basis: "60%",
|
||||||
value: this.props.currentGenerator && this.props.currentGenerator.value || "-----",
|
value: this.props.currentGenerator && this.props.currentGenerator.value || "-----",
|
||||||
|
@ -341,8 +341,7 @@ module.exports = (_ => {
|
||||||
let varDescription = varStr.join("").replace(/\*\/|\/\*/g, "").replace(/:/g, ": ").replace(/: \//g, ":/").replace(/--/g, " --").replace(/\( --/g, "(--").trim();
|
let varDescription = varStr.join("").replace(/\*\/|\/\*/g, "").replace(/:/g, ": ").replace(/: \//g, ":/").replace(/--/g, " --").replace(/\( --/g, "(--").trim();
|
||||||
this.props.generatorValues[varName] = {value:oldValue, oldValue};
|
this.props.generatorValues[varName] = {value:oldValue, oldValue};
|
||||||
inputRefs.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsItem, {
|
inputRefs.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsItem, {
|
||||||
className: BDFDB.disCN.marginbottom20,
|
dividerBottom: vars[vars.length-1] != varStr,
|
||||||
dividerbottom: vars[vars.length-1] != varStr,
|
|
||||||
type: "TextInput",
|
type: "TextInput",
|
||||||
childProps: {
|
childProps: {
|
||||||
type: childType,
|
type: childType,
|
||||||
|
@ -387,8 +386,8 @@ module.exports = (_ => {
|
||||||
})
|
})
|
||||||
}),
|
}),
|
||||||
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsItem, {
|
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsItem, {
|
||||||
className: BDFDB.disCN.marginbottom20,
|
|
||||||
type: "Switch",
|
type: "Switch",
|
||||||
|
margin: 20,
|
||||||
label: "Preview in light mode",
|
label: "Preview in light mode",
|
||||||
value: this.props.useLightMode,
|
value: this.props.useLightMode,
|
||||||
onChange: (value, instance) => {
|
onChange: (value, instance) => {
|
||||||
|
@ -401,8 +400,8 @@ module.exports = (_ => {
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsItem, {
|
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsItem, {
|
||||||
className: BDFDB.disCN.marginbottom20,
|
|
||||||
type: "Switch",
|
type: "Switch",
|
||||||
|
margin: 20,
|
||||||
label: "Preview with useNormalizer classes",
|
label: "Preview with useNormalizer classes",
|
||||||
value: this.props.useNormalizer,
|
value: this.props.useNormalizer,
|
||||||
onChange: (value, instance) => {
|
onChange: (value, instance) => {
|
||||||
|
@ -415,8 +414,8 @@ module.exports = (_ => {
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsItem, {
|
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsItem, {
|
||||||
className: BDFDB.disCN.marginbottom20,
|
|
||||||
type: "Switch",
|
type: "Switch",
|
||||||
|
margin: 20,
|
||||||
label: "Include Custom CSS in Preview",
|
label: "Include Custom CSS in Preview",
|
||||||
value: this.props.useCustomCSS,
|
value: this.props.useCustomCSS,
|
||||||
onChange: (value, instance) => {
|
onChange: (value, instance) => {
|
||||||
|
@ -431,8 +430,8 @@ module.exports = (_ => {
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsItem, {
|
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsItem, {
|
||||||
className: BDFDB.disCN.marginbottom20,
|
|
||||||
type: "Switch",
|
type: "Switch",
|
||||||
|
margin: 20,
|
||||||
label: "Include ThemeFixer CSS in Preview",
|
label: "Include ThemeFixer CSS in Preview",
|
||||||
value: this.props.useThemeFixer,
|
value: this.props.useThemeFixer,
|
||||||
onChange: (value, instance) => {
|
onChange: (value, instance) => {
|
||||||
|
@ -448,8 +447,8 @@ module.exports = (_ => {
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsItem, {
|
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsItem, {
|
||||||
className: BDFDB.disCN.marginbottom20,
|
|
||||||
type: "Button",
|
type: "Button",
|
||||||
|
margin: 20,
|
||||||
label: "Download ThemeFixer",
|
label: "Download ThemeFixer",
|
||||||
children: "Download",
|
children: "Download",
|
||||||
onClick: _ => {
|
onClick: _ => {
|
||||||
|
@ -528,10 +527,14 @@ module.exports = (_ => {
|
||||||
value: list && list.props.currentTheme && list.props.currentTheme.url == this.props.theme.url,
|
value: list && list.props.currentTheme && list.props.currentTheme.url == this.props.theme.url,
|
||||||
onChange: (value, instance) => {
|
onChange: (value, instance) => {
|
||||||
if (!list) return;
|
if (!list) return;
|
||||||
|
|
||||||
|
if (list.props.currentTheme) for (let ins of BDFDB.ReactUtils.findOwner(this._reactInternalFiber.return, {name:"ThemeCard", all:true}).filter(ins => ins && ins.props && ins.props.theme && ins.props.theme.url == list.props.currentTheme.url)) BDFDB.ReactUtils.forceUpdate(ins);
|
||||||
|
|
||||||
if (value) list.props.currentTheme = this.props.theme;
|
if (value) list.props.currentTheme = this.props.theme;
|
||||||
else delete list.props.currentTheme;
|
else delete list.props.currentTheme;
|
||||||
delete list.props.currentGenerator;
|
delete list.props.currentGenerator;
|
||||||
delete list.props.generatorValues;
|
delete list.props.generatorValues;
|
||||||
|
|
||||||
if (preview) preview.executeJavaScriptSafe(`window.onmessage({
|
if (preview) preview.executeJavaScriptSafe(`window.onmessage({
|
||||||
origin: "ThemeRepo",
|
origin: "ThemeRepo",
|
||||||
reason: "NewTheme",
|
reason: "NewTheme",
|
||||||
|
@ -539,6 +542,7 @@ module.exports = (_ => {
|
||||||
css: ${JSON.stringify(this.props.theme.css || "")}
|
css: ${JSON.stringify(this.props.theme.css || "")}
|
||||||
})`);
|
})`);
|
||||||
else list.openPreview();
|
else list.openPreview();
|
||||||
|
|
||||||
BDFDB.ReactUtils.forceUpdate(this);
|
BDFDB.ReactUtils.forceUpdate(this);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -788,6 +792,7 @@ module.exports = (_ => {
|
||||||
}) : null,
|
}) : null,
|
||||||
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsItem, {
|
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsItem, {
|
||||||
type: "Button",
|
type: "Button",
|
||||||
|
margin: 0,
|
||||||
color: BDFDB.LibraryComponents.Button.Colors.RED,
|
color: BDFDB.LibraryComponents.Button.Colors.RED,
|
||||||
label: "Remove all custom added Themes",
|
label: "Remove all custom added Themes",
|
||||||
onClick: _ => {
|
onClick: _ => {
|
||||||
|
@ -805,6 +810,7 @@ module.exports = (_ => {
|
||||||
collapseStates: collapseStates,
|
collapseStates: collapseStates,
|
||||||
children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsItem, {
|
children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsItem, {
|
||||||
type: "Button",
|
type: "Button",
|
||||||
|
margin: 0,
|
||||||
label: "Force all Themes to be fetched again",
|
label: "Force all Themes to be fetched again",
|
||||||
onClick: _ => {
|
onClick: _ => {
|
||||||
loading = {is:false, timeout:null, amount:0};
|
loading = {is:false, timeout:null, amount:0};
|
||||||
|
@ -1051,7 +1057,7 @@ module.exports = (_ => {
|
||||||
if (url && BDFDB.ArrayUtils.getAllIndexes(foundThemes, url).length < 2) foundThemes.push(url);
|
if (url && BDFDB.ArrayUtils.getAllIndexes(foundThemes, url).length < 2) foundThemes.push(url);
|
||||||
}
|
}
|
||||||
else if (body && body.indexOf("404: Not Found") != 0 && response.statusCode == 200) {
|
else if (body && body.indexOf("404: Not Found") != 0 && response.statusCode == 200) {
|
||||||
let theme = {}, text = body;
|
let theme = {}, text = body.trim();
|
||||||
if ((text.split("*//").length > 1 || text.indexOf("/**") == 0) && text.split("\n").length > 1) {
|
if ((text.split("*//").length > 1 || text.indexOf("/**") == 0) && text.split("\n").length > 1) {
|
||||||
let hasMETAline = text.replace(/\s/g, "").indexOf("//META{");
|
let hasMETAline = text.replace(/\s/g, "").indexOf("//META{");
|
||||||
if (hasMETAline < 20 && hasMETAline > -1) {
|
if (hasMETAline < 20 && hasMETAline > -1) {
|
||||||
|
|
Loading…
Reference in New Issue