2017-01-06 20:49:37 +01:00
|
|
|
import { Enum } from 'enumify';
|
|
|
|
|
2017-02-15 07:33:07 +01:00
|
|
|
import CalculateGlobalStats from './transformations/CalculateGlobalStats.jsx';
|
2017-02-17 20:17:04 +01:00
|
|
|
import RemoveRepetitiveElements from './transformations/RemoveRepetitiveElements.jsx'
|
|
|
|
import VerticalToHorizontal from './transformations/VerticalToHorizontal.jsx';
|
2017-02-17 20:19:57 +01:00
|
|
|
import DetectPdfBlocks from './transformations/DetectPdfBlocks.jsx'
|
2017-02-22 23:18:49 +01:00
|
|
|
import DetectFootnotes from './transformations/DetectFootnotes.jsx'
|
2017-02-19 10:20:14 +01:00
|
|
|
import DetectTOC from './transformations/DetectTOC.jsx'
|
2017-02-19 14:23:35 +01:00
|
|
|
import DetectLists from './transformations/DetectLists.jsx'
|
2017-02-17 20:17:04 +01:00
|
|
|
import DetectCodeBlocks from './transformations/DetectCodeBlocks.jsx'
|
2017-02-22 23:18:49 +01:00
|
|
|
// import DetectFormats from './transformations/DetectFormats.jsx'
|
|
|
|
// import CombineSameY from './transformations/CombineSameY.jsx';
|
|
|
|
// import RemoveWhitespaces from './transformations/RemoveWhitespaces.jsx'
|
|
|
|
// import DetectLinks from './transformations/DetectLinks.jsx'
|
|
|
|
// import HeadlineDetector from './transformations/HeadlineDetector.jsx'
|
|
|
|
// import HeadlineToUppercase from './transformations/HeadlineToUppercase.jsx'
|
|
|
|
// import ToBlockSystem from './transformations/ToBlockSystem.jsx';
|
2017-02-17 20:17:04 +01:00
|
|
|
import ToTextBlocks from './transformations/ToTextBlocks.jsx';
|
2017-02-06 19:13:43 +01:00
|
|
|
import ToMarkdown from './transformations/ToMarkdown.jsx'
|
2017-01-07 11:38:06 +01:00
|
|
|
|
2017-01-06 20:49:37 +01:00
|
|
|
// Holds the state of the Application
|
|
|
|
export default class AppState {
|
|
|
|
|
|
|
|
constructor(options) {
|
|
|
|
this.renderFunction = options.renderFunction;
|
|
|
|
this.mainView = View.UPLOAD;
|
2017-01-09 20:08:32 +01:00
|
|
|
this.fileBuffer;
|
2017-01-06 20:49:37 +01:00
|
|
|
this.pdfPages = [];
|
2017-01-27 21:40:49 +01:00
|
|
|
this.transformations = [
|
2017-02-15 07:33:07 +01:00
|
|
|
new CalculateGlobalStats(),
|
2017-01-27 21:40:49 +01:00
|
|
|
new RemoveRepetitiveElements(),
|
2017-02-17 20:17:04 +01:00
|
|
|
new VerticalToHorizontal(),
|
2017-02-17 20:19:57 +01:00
|
|
|
new DetectPdfBlocks(),
|
2017-02-22 23:18:49 +01:00
|
|
|
new DetectFootnotes(),
|
2017-02-19 10:20:14 +01:00
|
|
|
new DetectTOC(),
|
2017-02-19 14:23:35 +01:00
|
|
|
new DetectLists(),
|
2017-02-18 10:50:54 +01:00
|
|
|
new DetectCodeBlocks(),
|
2017-02-21 08:05:00 +01:00
|
|
|
|
2017-02-17 20:17:04 +01:00
|
|
|
// new DetectFormats(),
|
|
|
|
// new CombineSameY(),
|
|
|
|
// new RemoveWhitespaces(),
|
|
|
|
// new DetectLinks(),
|
|
|
|
// new HeadlineDetector(),
|
|
|
|
// new HeadlineToUppercase(),
|
|
|
|
// new ToBlockSystem(),
|
|
|
|
new ToTextBlocks(),
|
2017-02-06 19:13:43 +01:00
|
|
|
new ToMarkdown()];
|
2017-01-06 20:49:37 +01:00
|
|
|
|
|
|
|
//bind functions
|
|
|
|
this.render = this.render.bind(this);
|
2017-01-09 20:08:32 +01:00
|
|
|
this.storeFileBuffer = this.storeFileBuffer.bind(this);
|
|
|
|
this.storePdfPages = this.storePdfPages.bind(this);
|
2017-02-06 19:13:43 +01:00
|
|
|
this.switchMainView = this.switchMainView.bind(this);
|
2017-01-06 20:49:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
render() {
|
|
|
|
this.renderFunction(this)
|
|
|
|
}
|
|
|
|
|
2017-01-09 20:08:32 +01:00
|
|
|
// the uploaded pdf as file buffer
|
|
|
|
storeFileBuffer(fileBuffer:ArrayBuffer) {
|
|
|
|
this.fileBuffer = fileBuffer;
|
2017-01-06 20:49:37 +01:00
|
|
|
this.mainView = View.LOADING;
|
|
|
|
this.render()
|
|
|
|
}
|
|
|
|
|
2017-01-09 20:08:32 +01:00
|
|
|
storePdfPages(pdfPages) {
|
|
|
|
this.pdfPages = pdfPages;
|
|
|
|
this.fileBuffer = null;
|
2017-02-06 19:13:43 +01:00
|
|
|
this.mainView = View.RESULT;
|
|
|
|
this.render();
|
|
|
|
}
|
|
|
|
|
|
|
|
switchMainView(view) {
|
|
|
|
this.mainView = view;
|
2017-01-09 20:08:32 +01:00
|
|
|
this.render();
|
2017-01-06 20:49:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
export class View extends Enum {
|
|
|
|
}
|
2017-02-06 19:13:43 +01:00
|
|
|
View.initEnum(['UPLOAD', 'LOADING', 'RESULT', 'DEBUG'])
|