plugin fields have with distinct name and label
This commit is contained in:
parent
e52ccc0dbc
commit
95fdba9953
@ -73,15 +73,15 @@
|
|||||||
id: "youtube",
|
id: "youtube",
|
||||||
label: "Youtube",
|
label: "Youtube",
|
||||||
icon: 'video',
|
icon: 'video',
|
||||||
fields: ['video-id'],
|
fields: [{name: 'id', label: 'Youtube Video ID'}],
|
||||||
pattern: /^{{<\s?youtube (\S+)\s?>}}/,
|
pattern: /^{{<\s?youtube (\S+)\s?>}}/,
|
||||||
fromBlock: function(match) {
|
fromBlock: function(match) {
|
||||||
return {
|
return {
|
||||||
"video-id": match[1]
|
id: match[1]
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
toBlock: function(obj) {
|
toBlock: function(obj) {
|
||||||
return '{{< youtube ' + obj['video-id'] + ' >}}';
|
return '{{< youtube ' + obj.id + ' >}}';
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
@ -63,7 +63,7 @@ export default class BlockTypesMenu extends Component {
|
|||||||
handlePluginClick(e, plugin) {
|
handlePluginClick(e, plugin) {
|
||||||
const data = {};
|
const data = {};
|
||||||
plugin.fields.forEach(field => {
|
plugin.fields.forEach(field => {
|
||||||
data[field] = window.prompt(field);
|
data[field.name] = window.prompt(field.label);
|
||||||
});
|
});
|
||||||
this.props.onClickPlugin(plugin.id, data);
|
this.props.onClickPlugin(plugin.id, data);
|
||||||
}
|
}
|
||||||
|
@ -44,7 +44,7 @@ function processEditorPlugins(plugins) {
|
|||||||
<div {...props.attributes} className={className}>
|
<div {...props.attributes} className={className}>
|
||||||
<div className="plugin_icon" contentEditable={false}><Icon type={plugin.icon}/></div>
|
<div className="plugin_icon" contentEditable={false}><Icon type={plugin.icon}/></div>
|
||||||
<div className="plugin_fields" contentEditable={false}>
|
<div className="plugin_fields" contentEditable={false}>
|
||||||
{ plugin.fields.map(field => `${field}: “${node.data.get(field)}”`) }
|
{ plugin.fields.map(field => `${field.label}: “${node.data.get(field.name)}”`) }
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user