Skip to content

Commit

Permalink
2.12.1
Browse files Browse the repository at this point in the history
  • Loading branch information
Fi1osof committed Sep 19, 2019
1 parent 9a7888c commit 4d5d5e9
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 46 deletions.
4 changes: 4 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
2.12.1
=================================
- Added ContentEditor::render_toolbar

2.12.0
=================================
- Added EditableObject::create_as_a_child_of
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@prisma-cms/front-editor",
"version": "2.12.0",
"version": "2.12.1",
"private": false,
"main": "lib/App.js",
"scripts": {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import React, { Component, Fragment, createContext } from 'react';
import React from 'react';
import PropTypes from 'prop-types';

// import ViewIcon from "material-ui-icons/ViewModule";

import EditorComponent from '../../../../..';
import ListView from '..';
// import ListView from '..';
import DefaultValue from '../../Fields/NamedField/DefaultValue';


Expand All @@ -14,16 +14,17 @@ class Iterable extends EditorComponent {
static Name = "Iterable"

static propTypes = {
// eslint-disable-next-line react/forbid-foreign-prop-types
...EditorComponent.propTypes,
items: PropTypes.array,
ObjectContext: PropTypes.object,
}


constructor(props) {
// constructor(props) {

super(props);
}
// super(props);
// }


renderPanelView(content) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { Component, Fragment, createContext, Children } from 'react';
import PropTypes from 'prop-types';
import React, { createContext } from 'react';
// import PropTypes from 'prop-types';

import ViewIcon from "material-ui-icons/ViewModule";
import Connector, { ConnectorContext } from '..';
Expand Down Expand Up @@ -100,17 +100,17 @@ class ListView extends EditorComponent {

renderChildren() {

const {
style,
...other
// } = this.getRenderProps();
} = this.getComponentProps(this);
// const {
// style,
// ...other
// // } = this.getRenderProps();
// } = this.getComponentProps(this);



const {
Grid,
} = this.context;
// const {
// Grid,
// } = this.context;



Expand Down Expand Up @@ -146,8 +146,8 @@ class ListView extends EditorComponent {
Так как в некоторых случаях нам надо вывести полученные данные без лишних оберток,
проверяем является ли дочерний элемент производным от Iterable.
Если является таковым, то рендерим в него все полученные объекты
if (children.length === 1 && children[0].__proto__.isPrototypeOf(Iterable))
*/
{/* if (children.length === 1 && children[0].__proto__.isPrototypeOf(Iterable)) { */ }
if (children.length === 1 && children[0]
&& (
Iterable.isPrototypeOf(children[0].type)
Expand Down Expand Up @@ -199,15 +199,6 @@ class ListView extends EditorComponent {
output = children.filter(n => n && n.type === DefaultValue);
}


{/* output = <Grid
container
{...other}
>
{}
</Grid>; */}
}

return output;
Expand Down
49 changes: 29 additions & 20 deletions src/components/App/components/public/ContentEditor/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import PropTypes from "prop-types";

import { HtmlTag } from '../Tag';
import EditorComponent from '../..';
import EditableObject from '../form/EditableObject';

import withStyles from 'material-ui/styles/withStyles';
import IconButton from 'material-ui/IconButton';
Expand Down Expand Up @@ -424,6 +423,7 @@ export class TagEditor extends HtmlTag {

const {
classes,
render_toolbar,
} = this.props;

const buttons = this.getToolbarButtons();
Expand All @@ -432,7 +432,7 @@ export class TagEditor extends HtmlTag {
return null;
}

return <div
return render_toolbar ? <div
className={classes.toolbar}
>
<Grid
Expand All @@ -443,7 +443,7 @@ export class TagEditor extends HtmlTag {
{this.renderToolbarButtons(buttons)}

</Grid>
</div>
</div> : null

}

Expand Down Expand Up @@ -652,6 +652,7 @@ export class ContentEditor extends EditorComponent {
components: PropTypes.array.isRequired,
})),
TagEditor: PropTypes.func.isRequired,
render_toolbar: PropTypes.bool.isRequired,
}

static defaultProps = {
Expand Down Expand Up @@ -684,6 +685,8 @@ export class ContentEditor extends EditorComponent {
}],

TagEditor,
hide_wrapper_in_default_mode: true,
render_toolbar: true,
}


Expand Down Expand Up @@ -719,10 +722,10 @@ export class ContentEditor extends EditorComponent {
}


canBeParent(parent) {
// canBeParent(parent) {

return super.canBeParent(parent) && this.findInParent(parent, parent => parent instanceof EditableObject);
}
// return super.canBeParent(parent) && this.findInParent(parent, parent => parent instanceof EditableObject);
// }


canBeChild(child) {
Expand Down Expand Up @@ -757,6 +760,7 @@ export class ContentEditor extends EditorComponent {
initialContent,
read_only,
TagEditor,
render_toolbar,
} = this.getComponentProps(this);


Expand All @@ -767,20 +771,25 @@ export class ContentEditor extends EditorComponent {

const editable = inEditMode && !read_only ? true : false;

return <ContentProxyStyled
key={editable.toString()}
updateObject={(data) => {

// console.log("components", components);

this.updateObject(data);

}}
components={components}
editable={editable}
initialContent={initialContent}
TagEditor={TagEditor}
/>;
return editable
?
<ContentProxyStyled
key={editable.toString()}
updateObject={(data) => {

// console.log("components", components);

this.updateObject(data);

}}
components={components}
editable={editable}
initialContent={initialContent}
TagEditor={TagEditor}
render_toolbar={render_toolbar}
/>
:
super.renderChildren();
}

}
Expand Down

0 comments on commit 4d5d5e9

Please sign in to comment.