diff --git a/src/javascript/components/DebugView.jsx b/src/javascript/components/DebugView.jsx index 906c793..5878972 100644 --- a/src/javascript/components/DebugView.jsx +++ b/src/javascript/components/DebugView.jsx @@ -101,6 +101,18 @@ export default class DebugView extends React.Component { }); + const transformationMenuItems = []; + var lastItemType; + transformations.forEach((transformation, i) => { + if (lastItemType && transformation.itemType !== lastItemType) { + transformationMenuItems.push(); + } + transformationMenuItems.push( + { transformation.name } + ); + lastItemType = transformation.itemType; + }); + return (
@@ -149,9 +161,7 @@ export default class DebugView extends React.Component { - { transformations.map((transformation, i) => - { transformation.name } - ) } + { transformationMenuItems } diff --git a/src/javascript/models/AppState.jsx b/src/javascript/models/AppState.jsx index de09d62..05b003d 100644 --- a/src/javascript/models/AppState.jsx +++ b/src/javascript/models/AppState.jsx @@ -1,16 +1,17 @@ import { Enum } from 'enumify'; -import CalculateGlobalStats from './transformations/CalculateGlobalStats.jsx'; -import CompactLines from './transformations/CompactLines.jsx'; -import RemoveRepetitiveElements from './transformations/RemoveRepetitiveElements.jsx' -import VerticalToHorizontal from './transformations/VerticalToHorizontal.jsx'; -import DetectTOC from './transformations/DetectTOC.jsx' -import DetectListItems from './transformations/DetectListItems.jsx' +import CalculateGlobalStats from './transformations/textitem/CalculateGlobalStats.jsx'; +import CompactLines from './transformations/textitem/CompactLines.jsx'; +import RemoveRepetitiveElements from './transformations/textitem/RemoveRepetitiveElements.jsx' +import VerticalToHorizontal from './transformations/textitem/VerticalToHorizontal.jsx'; +import DetectTOC from './transformations/textitem/DetectTOC.jsx' +import DetectListItems from './transformations/textitem/DetectListItems.jsx' +// import DetectHeaders from './transformations/textitem/DetectHeaders.jsx' -import GatherBlocks from './transformations/GatherBlocks.jsx' -import DetectCodeQuoteBlocks from './transformations/DetectCodeQuoteBlocks.jsx' -import DetectListLevels from './transformations/DetectListLevels.jsx' -import DetectHeadlines from './transformations/DetectHeadlines.jsx' +import GatherBlocks from './transformations/textitemblock/GatherBlocks.jsx' +import DetectCodeQuoteBlocks from './transformations/textitemblock/DetectCodeQuoteBlocks.jsx' +import DetectListLevels from './transformations/textitemblock/DetectListLevels.jsx' +// import DetectHeadlines from './transformations/textitemblock/DetectHeadlines.jsx' // import DetectFormats from './transformations/DetectFormats.jsx' // import RemoveWhitespaces from './transformations/RemoveWhitespaces.jsx' // import DetectLinks from './transformations/DetectLinks.jsx' @@ -34,11 +35,12 @@ export default class AppState { new VerticalToHorizontal(), new DetectTOC(), new DetectListItems(), + new DetectHeaders(), new GatherBlocks(), new DetectCodeQuoteBlocks(), new DetectListLevels(), - new DetectHeadlines(), + // new DetectHeadlines(), // new DetectFormats(), // new RemoveWhitespaces(), diff --git a/src/javascript/models/transformations/ToMarkdown.jsx b/src/javascript/models/transformations/ToMarkdown.jsx index 2d9415b..4356a05 100644 --- a/src/javascript/models/transformations/ToMarkdown.jsx +++ b/src/javascript/models/transformations/ToMarkdown.jsx @@ -6,7 +6,7 @@ import ParseResult from '../ParseResult.jsx'; export default class ToMarkdown extends Transformation { constructor() { - super("To Markdown"); + super("To Markdown", "String"); } createPageView(page, modificationsOnly) { // eslint-disable-line no-unused-vars diff --git a/src/javascript/models/transformations/ToTextBlocks.jsx b/src/javascript/models/transformations/ToTextBlocks.jsx index f135609..4d090ee 100644 --- a/src/javascript/models/transformations/ToTextBlocks.jsx +++ b/src/javascript/models/transformations/ToTextBlocks.jsx @@ -7,7 +7,7 @@ import { blockToText } from '../ElementType.jsx'; export default class ToTextBlocks extends Transformation { constructor() { - super("To Text Blocks"); + super("To Text Blocks", "TextBlock"); } createPageView(page, modificationsOnly) { // eslint-disable-line no-unused-vars diff --git a/src/javascript/models/transformations/ToTextItemBlockTransformation.jsx b/src/javascript/models/transformations/ToTextItemBlockTransformation.jsx index 2687615..43be1ec 100644 --- a/src/javascript/models/transformations/ToTextItemBlockTransformation.jsx +++ b/src/javascript/models/transformations/ToTextItemBlockTransformation.jsx @@ -1,6 +1,7 @@ import React from 'react'; import Transformation from './Transformation.jsx'; import ParseResult from '../ParseResult.jsx'; +import TextItemBlock from '../TextItemBlock.jsx'; import TextItemBlockPageView from '../../components/debug/TextItemBlockPageView.jsx'; import { REMOVED_ANNOTATION } from '../Annotation.jsx'; @@ -8,7 +9,7 @@ import { REMOVED_ANNOTATION } from '../Annotation.jsx'; export default class ToTextItemBlockTransformation extends Transformation { constructor(name) { - super(name); + super(name, TextItemBlock.name); if (this.constructor === ToTextItemBlockTransformation) { throw new TypeError("Can not construct abstract class."); } diff --git a/src/javascript/models/transformations/ToTextItemTransformation.jsx b/src/javascript/models/transformations/ToTextItemTransformation.jsx index 3514a56..9ae5c1b 100644 --- a/src/javascript/models/transformations/ToTextItemTransformation.jsx +++ b/src/javascript/models/transformations/ToTextItemTransformation.jsx @@ -1,6 +1,7 @@ import React from 'react'; import Transformation from './Transformation.jsx'; import ParseResult from '../ParseResult.jsx'; +import TextItem from '../TextItem.jsx'; import TextItemPageView from '../../components/debug/TextItemPageView.jsx'; import { REMOVED_ANNOTATION } from '../Annotation.jsx'; @@ -8,7 +9,7 @@ import { REMOVED_ANNOTATION } from '../Annotation.jsx'; export default class ToTextItemTransformation extends Transformation { constructor(name) { - super(name); + super(name, TextItem.name); if (this.constructor === ToTextItemTransformation) { throw new TypeError("Can not construct abstract class."); } diff --git a/src/javascript/models/transformations/Transformation.jsx b/src/javascript/models/transformations/Transformation.jsx index b5ff64b..ae31d78 100644 --- a/src/javascript/models/transformations/Transformation.jsx +++ b/src/javascript/models/transformations/Transformation.jsx @@ -3,7 +3,7 @@ import ParseResult from '../ParseResult.jsx'; // A transformation from an PdfPage to an PdfPage export default class Transformation { - constructor(name) { + constructor(name, itemType) { if (this.constructor === Transformation) { throw new TypeError("Can not construct abstract class."); } @@ -11,6 +11,7 @@ export default class Transformation { throw new TypeError("Please implement abstract method 'transform()'."); } this.name = name; + this.itemType = itemType; } showPageSelection() { diff --git a/src/javascript/models/transformations/CalculateGlobalStats.jsx b/src/javascript/models/transformations/textitem/CalculateGlobalStats.jsx similarity index 96% rename from src/javascript/models/transformations/CalculateGlobalStats.jsx rename to src/javascript/models/transformations/textitem/CalculateGlobalStats.jsx index b34d080..c9dc3d6 100644 --- a/src/javascript/models/transformations/CalculateGlobalStats.jsx +++ b/src/javascript/models/transformations/textitem/CalculateGlobalStats.jsx @@ -1,5 +1,5 @@ -import ToTextItemTransformation from './ToTextItemTransformation.jsx'; -import ParseResult from '../ParseResult.jsx'; +import ToTextItemTransformation from '../ToTextItemTransformation.jsx'; +import ParseResult from '../../ParseResult.jsx'; export default class CalculateGlobalStats extends ToTextItemTransformation { diff --git a/src/javascript/models/transformations/CompactLines.jsx b/src/javascript/models/transformations/textitem/CompactLines.jsx similarity index 88% rename from src/javascript/models/transformations/CompactLines.jsx rename to src/javascript/models/transformations/textitem/CompactLines.jsx index ac0ab35..3cc89ad 100644 --- a/src/javascript/models/transformations/CompactLines.jsx +++ b/src/javascript/models/transformations/textitem/CompactLines.jsx @@ -1,11 +1,11 @@ import React from 'react'; -import ToTextItemTransformation from './ToTextItemTransformation.jsx'; -import ParseResult from '../ParseResult.jsx'; -import TextItemLineGrouper from '../TextItemLineGrouper.jsx'; -import TextItemLineCompactor from '../TextItemLineCompactor.jsx'; -import ElementType from '../ElementType.jsx'; -import { REMOVED_ANNOTATION, ADDED_ANNOTATION } from '../Annotation.jsx'; +import ToTextItemTransformation from '../ToTextItemTransformation.jsx'; +import ParseResult from '../../ParseResult.jsx'; +import TextItemLineGrouper from '../../TextItemLineGrouper.jsx'; +import TextItemLineCompactor from '../../TextItemLineCompactor.jsx'; +import ElementType from '../../ElementType.jsx'; +import { REMOVED_ANNOTATION, ADDED_ANNOTATION } from '../../Annotation.jsx'; // gathers text items on the same y line to one text item diff --git a/src/javascript/models/transformations/DetectListItems.jsx b/src/javascript/models/transformations/textitem/DetectListItems.jsx similarity index 88% rename from src/javascript/models/transformations/DetectListItems.jsx rename to src/javascript/models/transformations/textitem/DetectListItems.jsx index c554077..0c99ee2 100644 --- a/src/javascript/models/transformations/DetectListItems.jsx +++ b/src/javascript/models/transformations/textitem/DetectListItems.jsx @@ -1,9 +1,9 @@ -import ToTextItemTransformation from './ToTextItemTransformation.jsx'; -import ParseResult from '../ParseResult.jsx'; -import TextItem from '../TextItem.jsx'; -import { REMOVED_ANNOTATION, ADDED_ANNOTATION, DETECTED_ANNOTATION } from '../Annotation.jsx'; -import ElementType from '../ElementType.jsx'; -import { isListItem, isNumberedListItem, removeLeadingWhitespaces } from '../../functions.jsx'; +import ToTextItemTransformation from '../ToTextItemTransformation.jsx'; +import ParseResult from '../../ParseResult.jsx'; +import TextItem from '../../TextItem.jsx'; +import { REMOVED_ANNOTATION, ADDED_ANNOTATION, DETECTED_ANNOTATION } from '../../Annotation.jsx'; +import ElementType from '../../ElementType.jsx'; +import { isListItem, isNumberedListItem, removeLeadingWhitespaces } from '../../../functions.jsx'; //Detect items starting with -, •, etc... export default class DetectListItems extends ToTextItemTransformation { diff --git a/src/javascript/models/transformations/DetectTOC.jsx b/src/javascript/models/transformations/textitem/DetectTOC.jsx similarity index 94% rename from src/javascript/models/transformations/DetectTOC.jsx rename to src/javascript/models/transformations/textitem/DetectTOC.jsx index 25e6389..140fc2a 100644 --- a/src/javascript/models/transformations/DetectTOC.jsx +++ b/src/javascript/models/transformations/textitem/DetectTOC.jsx @@ -1,11 +1,11 @@ -import ToTextItemTransformation from './ToTextItemTransformation.jsx'; -import ParseResult from '../ParseResult.jsx'; -import TextItem from '../TextItem.jsx'; -import HeadlineFinder from '../HeadlineFinder.jsx'; -import { REMOVED_ANNOTATION, ADDED_ANNOTATION } from '../Annotation.jsx'; -import ElementType from '../ElementType.jsx'; -import { headlineByLevel } from '../ElementType.jsx'; -import { isDigit } from '../../functions.jsx' +import ToTextItemTransformation from '../ToTextItemTransformation.jsx'; +import ParseResult from '../../ParseResult.jsx'; +import TextItem from '../../TextItem.jsx'; +import HeadlineFinder from '../../HeadlineFinder.jsx'; +import { REMOVED_ANNOTATION, ADDED_ANNOTATION } from '../../Annotation.jsx'; +import ElementType from '../../ElementType.jsx'; +import { headlineByLevel } from '../../ElementType.jsx'; +import { isDigit } from '../../../functions.jsx' //Detect table of contents pages export default class DetectTOC extends ToTextItemTransformation { diff --git a/src/javascript/models/transformations/RemoveRepetitiveElements.jsx b/src/javascript/models/transformations/textitem/RemoveRepetitiveElements.jsx similarity index 94% rename from src/javascript/models/transformations/RemoveRepetitiveElements.jsx rename to src/javascript/models/transformations/textitem/RemoveRepetitiveElements.jsx index b5e3a0c..3d56883 100644 --- a/src/javascript/models/transformations/RemoveRepetitiveElements.jsx +++ b/src/javascript/models/transformations/textitem/RemoveRepetitiveElements.jsx @@ -1,8 +1,8 @@ -import ToTextItemTransformation from './ToTextItemTransformation.jsx'; -import ParseResult from '../ParseResult.jsx'; -import { REMOVED_ANNOTATION } from '../Annotation.jsx'; +import ToTextItemTransformation from '../ToTextItemTransformation.jsx'; +import ParseResult from '../../ParseResult.jsx'; +import { REMOVED_ANNOTATION } from '../../Annotation.jsx'; -import { isDigit } from '../../functions.jsx' +import { isDigit } from '../../../functions.jsx' function hashCodeIgnoringSpacesAndNumbers(string) { diff --git a/src/javascript/models/transformations/VerticalToHorizontal.jsx b/src/javascript/models/transformations/textitem/VerticalToHorizontal.jsx similarity index 94% rename from src/javascript/models/transformations/VerticalToHorizontal.jsx rename to src/javascript/models/transformations/textitem/VerticalToHorizontal.jsx index 96fed1f..6290d22 100644 --- a/src/javascript/models/transformations/VerticalToHorizontal.jsx +++ b/src/javascript/models/transformations/textitem/VerticalToHorizontal.jsx @@ -1,7 +1,7 @@ -import ToTextItemTransformation from './ToTextItemTransformation.jsx'; -import ParseResult from '../ParseResult.jsx'; -import TextItem from '../TextItem.jsx'; -import { REMOVED_ANNOTATION, ADDED_ANNOTATION } from '../Annotation.jsx'; +import ToTextItemTransformation from '../ToTextItemTransformation.jsx'; +import ParseResult from '../../ParseResult.jsx'; +import TextItem from '../../TextItem.jsx'; +import { REMOVED_ANNOTATION, ADDED_ANNOTATION } from '../../Annotation.jsx'; // Converts vertical text to horizontal export default class VerticalToHorizontal extends ToTextItemTransformation { diff --git a/src/javascript/models/transformations/DetectCodeQuoteBlocks.jsx b/src/javascript/models/transformations/textitemblock/DetectCodeQuoteBlocks.jsx similarity index 81% rename from src/javascript/models/transformations/DetectCodeQuoteBlocks.jsx rename to src/javascript/models/transformations/textitemblock/DetectCodeQuoteBlocks.jsx index 89a2df4..1f96b88 100644 --- a/src/javascript/models/transformations/DetectCodeQuoteBlocks.jsx +++ b/src/javascript/models/transformations/textitemblock/DetectCodeQuoteBlocks.jsx @@ -1,8 +1,8 @@ -import ToTextItemBlockTransformation from './ToTextItemBlockTransformation.jsx'; -import ParseResult from '../ParseResult.jsx'; -import { DETECTED_ANNOTATION } from '../Annotation.jsx'; -import ElementType from '../ElementType.jsx'; -import { minXFromBlocks } from '../../textItemFunctions.jsx'; +import ToTextItemBlockTransformation from '..//ToTextItemBlockTransformation.jsx'; +import ParseResult from '../../ParseResult.jsx'; +import { DETECTED_ANNOTATION } from '../../Annotation.jsx'; +import ElementType from '../../ElementType.jsx'; +import { minXFromBlocks } from '../../../textItemFunctions.jsx'; //Detect items which are code/quote blocks export default class DetectCodeQuoteBlocks extends ToTextItemBlockTransformation { diff --git a/src/javascript/models/transformations/DetectListLevels.jsx b/src/javascript/models/transformations/textitemblock/DetectListLevels.jsx similarity index 87% rename from src/javascript/models/transformations/DetectListLevels.jsx rename to src/javascript/models/transformations/textitemblock/DetectListLevels.jsx index 9f6458b..e058c2b 100644 --- a/src/javascript/models/transformations/DetectListLevels.jsx +++ b/src/javascript/models/transformations/textitemblock/DetectListLevels.jsx @@ -1,7 +1,7 @@ -import ToTextItemBlockTransformation from './ToTextItemBlockTransformation.jsx'; -import ParseResult from '../ParseResult.jsx'; -import { MODIFIED_ANNOTATION, UNCHANGED_ANNOTATION } from '../Annotation.jsx'; -import ElementType from '../ElementType.jsx'; +import ToTextItemBlockTransformation from '..//ToTextItemBlockTransformation.jsx'; +import ParseResult from '../../ParseResult.jsx'; +import { MODIFIED_ANNOTATION, UNCHANGED_ANNOTATION } from '../../Annotation.jsx'; +import ElementType from '../../ElementType.jsx'; // Cares for proper sub-item spacing/leveling export default class DetectListLevels extends ToTextItemBlockTransformation { diff --git a/src/javascript/models/transformations/GatherBlocks.jsx b/src/javascript/models/transformations/textitemblock/GatherBlocks.jsx similarity index 89% rename from src/javascript/models/transformations/GatherBlocks.jsx rename to src/javascript/models/transformations/textitemblock/GatherBlocks.jsx index 35c92d6..0589739 100644 --- a/src/javascript/models/transformations/GatherBlocks.jsx +++ b/src/javascript/models/transformations/textitemblock/GatherBlocks.jsx @@ -1,8 +1,8 @@ -import ToTextItemBlockTransformation from './ToTextItemBlockTransformation.jsx'; -import ParseResult from '../ParseResult.jsx'; -import TextItemBlock from '../TextItemBlock.jsx'; -import { DETECTED_ANNOTATION } from '../Annotation.jsx'; -import { minXFromTextItems } from '../../textItemFunctions.jsx'; +import ToTextItemBlockTransformation from '../ToTextItemBlockTransformation.jsx'; +import ParseResult from '../../ParseResult.jsx'; +import TextItemBlock from '../../TextItemBlock.jsx'; +import { DETECTED_ANNOTATION } from '../../Annotation.jsx'; +import { minXFromTextItems } from '../../../textItemFunctions.jsx'; // Gathers lines to blocks export default class GatherBlocks extends ToTextItemBlockTransformation {