Allow dom nodes for plugin settings.

This commit is contained in:
Alexei Stukov 2017-04-30 14:02:42 +03:00 committed by GitHub
parent 8650b376ef
commit eff75f27dc
1 changed files with 9 additions and 3 deletions

View File

@ -3863,6 +3863,7 @@ class V2C_PluginCard extends BDV2.reactComponent {
constructor(props) {
super(props);
let self = this;
self.settingsPanel = self.props.plugin.getSettingsPanel();
self.onChange = self.onChange.bind(self);
self.showSettings = self.showSettings.bind(self);
self.setInitialState();
@ -3877,16 +3878,20 @@ class V2C_PluginCard extends BDV2.reactComponent {
componentDidUpdate() {
if (this.state.settings) {
// this.refs.settingspanel.innerHTML = this.props.plugin.getSettingsPanel();
if (typeof this.settingsPanel === "object") {
this.refs.settingspanel.appendChild(this.settingsPanel);
}
}
}
render() {
let self = this;
let { plugin } = this.props;
let name = plugin.getName();
let author = plugin.getAuthor();
let description = plugin.getDescription();
let version = plugin.getVersion();
let { settingsPanel } = this;
if (this.state.settings) {
return BDV2.react.createElement(
@ -3895,11 +3900,12 @@ class V2C_PluginCard extends BDV2.reactComponent {
BDV2.react.createElement(
"div",
{ style: { float: "right", cursor: "pointer" }, onClick: () => {
this.setState({ 'settings': false });
this.refs.settingspanel.innerHTML = "";self.setState({ 'settings': false });
} },
BDV2.react.createElement(V2Components.XSvg, null)
),
BDV2.react.createElement("div", { ref: "settingspanel", dangerouslySetInnerHTML: { __html: plugin.getSettingsPanel() } })
typeof settingsPanel === 'object' && BDV2.react.createElement("div", { ref: "settingspanel" }),
typeof settingsPanel !== 'object' && BDV2.react.createElement("div", { ref: "settingspanel", dangerouslySetInnerHTML: { __html: plugin.getSettingsPanel() } })
);
}