Files
pdf-to-markdown/oldSrc/javascript/models/LineItem.jsx
2024-03-26 10:52:54 -06:00

30 lines
751 B
JavaScript

import PageItem from './PageItem.jsx'
import Word from './Word.jsx'
//A line within a page
export default class LineItem extends PageItem {
constructor(options) {
super(options);
this.x = options.x;
this.y = options.y;
this.width = options.width;
this.height = options.height;
this.words = options.words || [];
if (options.text && !options.words) {
this.words = options.text.split(" ").filter(string => string.trim().length > 0).map(wordAsString => new Word({
string: wordAsString
}));
}
}
text() {
return this.wordStrings().join(" ");
}
wordStrings() {
return this.words.map(word => word.string);
}
}