2017-02-17 20:17:04 +01:00
|
|
|
import React from 'react';
|
|
|
|
import Transformation from './Transformation.jsx';
|
|
|
|
import BlockPageView from '../../components/debug/BlockPageView.jsx';
|
|
|
|
import ParseResult from '../ParseResult.jsx';
|
|
|
|
import BlockPage from '../BlockPage.jsx';
|
|
|
|
|
|
|
|
export default class ToTextBlocks extends Transformation {
|
|
|
|
|
|
|
|
constructor() {
|
|
|
|
super("To Text Blocks");
|
|
|
|
}
|
|
|
|
|
|
|
|
createPageView(page, modificationsOnly) { // eslint-disable-line no-unused-vars
|
|
|
|
return <BlockPageView key={ page.index } page={ page } />;
|
|
|
|
}
|
|
|
|
|
|
|
|
transform(parseResult:ParseResult) {
|
|
|
|
const blocks = [];
|
|
|
|
parseResult.content.forEach(page => {
|
|
|
|
page.blocks.forEach(block => {
|
|
|
|
var text = '';
|
|
|
|
block.textItems.forEach(item => {
|
|
|
|
// if (item.markdownElement) {
|
|
|
|
// text = item.markdownElement.transformText(item.text);
|
|
|
|
// }
|
|
|
|
text += '\n' + item.text;
|
|
|
|
});
|
2017-02-18 10:50:54 +01:00
|
|
|
const category = block.type ? block.type : 'Unknown';
|
2017-02-17 20:17:04 +01:00
|
|
|
blocks.push({
|
2017-02-18 10:50:54 +01:00
|
|
|
category: category,
|
2017-02-17 20:17:04 +01:00
|
|
|
text: text
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
});
|
|
|
|
return new ParseResult({
|
|
|
|
...parseResult,
|
|
|
|
content: [new BlockPage({
|
|
|
|
index: 0,
|
|
|
|
blocks: blocks
|
|
|
|
})],
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|