Skip to content

Commit

Permalink
Merge pull request #681 from idyll-lang/inline-author-view
Browse files Browse the repository at this point in the history
support custom inline component wrapper
  • Loading branch information
mathisonian authored Jan 22, 2021
2 parents 6d66c9e + d17e8c3 commit ddd3ba4
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions packages/idyll-document/src/runtime.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,13 @@ const getRefs = () => {
};

let wrapperKey = 0;
const createWrapper = ({ theme, layout, authorView, userViewComponent }) => {
const createWrapper = ({
theme,
layout,
authorView,
userViewComponent,
userInlineViewComponent
}) => {
return class Wrapper extends React.PureComponent {
constructor(props) {
super(props);
Expand Down Expand Up @@ -218,6 +224,16 @@ const createWrapper = ({ theme, layout, authorView, userViewComponent }) => {
uniqueKey={uniqueKey}
/>
);
} else if (meta.displayType === 'inline') {
const InlineViewComponent = userInlineViewComponent || AuthorTool;
return (
<InlineViewComponent
idyllASTNode={this.props.idyllASTNode}
component={returnComponent}
authorComponent={childComponent}
uniqueKey={uniqueKey}
/>
);
}
}
return returnComponent;
Expand All @@ -244,7 +260,8 @@ class IdyllRuntime extends React.PureComponent {
theme: props.theme,
layout: props.layout,
authorView: props.authorView,
userViewComponent: props.userViewComponent
userViewComponent: props.userViewComponent,
userInlineViewComponent: props.userInlineViewComponent
});

let hasInitialized = false;
Expand Down

0 comments on commit ddd3ba4

Please sign in to comment.