Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified examples/example.pdf
Binary file not shown.
22 changes: 22 additions & 0 deletions src/PDFTextComponent.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
'use strict';

const PDFTextComponent = function(element) {
this._currentElement = element;
};

const PDFTextComponentMixin = {
mountComponent(transaction, nativeParent, nativeContainerInfo, context) {
// Just return the text value
return this._currentElement;
},
receiveComponent(){},
getHostNode() {},
unmountComponent() {},
};

Object.assign(
PDFTextComponent.prototype,
PDFTextComponentMixin
);

export default PDFTextComponent;
12 changes: 2 additions & 10 deletions src/component.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,7 @@ const PDFRendererComponentMixin = {
return this.node;
},

mountComponent(
transaction,
nativeParent,
nativeContainerInfo,
context
) {
mountComponent(transaction, nativeParent, nativeContainerInfo, context) {
const node = this.node = this._currentElement;
const {children, ...props} = node.props;

Expand All @@ -36,10 +31,7 @@ const PDFRendererComponentMixin = {
context.doc[node.type](children, props);
}

// Naive way of not mounting TextComponent
if (typeof children != 'string') {
this.mountChildren(children, transaction, context);
}
this.mountChildren(children, transaction, context);

return node;
},
Expand Down
5 changes: 5 additions & 0 deletions src/injection.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,17 @@ import ReactHostComponent from 'react/lib/ReactHostComponent';
import ReactDefaultBatchingStrategy from 'react/lib/ReactDefaultBatchingStrategy';
import PDFRendererReconcileTransaction from './reconcileTransaction';
import PDFRendererComponent from './component';
import PDFTextComponent from './PDFTextComponent';

function inject() {
ReactInjection.HostComponent.injectGenericComponentClass(
PDFRendererComponent
);

ReactInjection.HostComponent.injectTextComponentClass(
PDFTextComponent
);

ReactInjection.Updates.injectReconcileTransaction(
PDFRendererReconcileTransaction
);
Expand Down