Skip to content

Commit 41fe35f

Browse files
committed
main: revert paragraph text work
This was experimental code that accidentally made it onto the main branch. Revert.
1 parent 82f3c97 commit 41fe35f

File tree

1 file changed

+7
-15
lines changed

1 file changed

+7
-15
lines changed

src/main.ts

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import { App, Modal, TFile, Plugin, Editor, MarkdownView, WorkspaceLeaf, FileVie
22
import { SupernotePluginSettings, SupernoteSettingTab, DEFAULT_SETTINGS } from './settings';
33
import { SupernoteX, fetchMirrorFrame } from 'supernote-typescript';
44
import { DownloadListModal, UploadListModal } from './FileListModal';
5-
import { ParagraphGrouper } from './textflow';
65
import { jsPDF } from 'jspdf';
76
import { SupernoteWorkerMessage, SupernoteWorkerResponse } from './myworker.worker';
87
import Worker from 'myworker.worker';
@@ -145,8 +144,8 @@ class VaultWriter {
145144

146145
for (let i = 0; i < sn.pages.length; i++) {
147146
content += `## Page ${i + 1}\n\n`
148-
if (sn.pages[i].paragraphs !== undefined && sn.pages[i].paragraphs.length > 0) {
149-
content += `${sn.pages[i].paragraphs}\n`;
147+
if (sn.pages[i].text !== undefined && sn.pages[i].text.length > 0) {
148+
content += `${sn.pages[i].text}\n`;
150149
}
151150
if (imgs) {
152151
let subpath = '';
@@ -223,10 +222,10 @@ class VaultWriter {
223222
pdf.addPage();
224223
}
225224

226-
if (sn.pages[i].paragraphs !== undefined && sn.pages[i].paragraphs.length > 0) {
225+
if (sn.pages[i].text !== undefined && sn.pages[i].text.length > 0) {
227226
pdf.setFontSize(100);
228227
pdf.setTextColor(0, 0, 0, 0); // Transparent text
229-
pdf.text(sn.pages[i].paragraphs, 20, 20, { maxWidth: sn.pageWidth });
228+
pdf.text(sn.pages[i].text, 20, 20, { maxWidth: sn.pageWidth });
230229
pdf.setTextColor(0, 0, 0, 1);
231230
}
232231

@@ -337,26 +336,19 @@ export class SupernoteView extends FileView {
337336
}
338337

339338
// Show the text of the page, if any
340-
if (sn.pages[i].paragraphs !== undefined && sn.pages[i].paragraphs.length > 0) {
339+
if (sn.pages[i].text !== undefined && sn.pages[i].text.length > 0) {
341340
let text;
342341

343-
let paragraphs;
344-
345-
const grouper = new ParagraphGrouper();
346-
const markdownText = grouper.convertToMarkdown(
347-
grouper.groupIntoParagraphs(sn.pages[i].recognitionElements[0])
348-
);
349-
350342
// If Collapse Text setting is enabled, place the text into an HTML `details` element
351343
if (this.settings.collapseRecognizedText) {
352344
text = pageContainer.createEl('details', {
353-
text: '\n' + sn.pages[i].paragraphs,
345+
text: '\n' + sn.pages[i].text,
354346
cls: 'page-recognized-text',
355347
});
356348
text.createEl('summary', { text: `Page ${i + 1} Recognized Text` });
357349
} else {
358350
text = pageContainer.createEl('div', {
359-
text: sn.pages[i].paragraphs,
351+
text: sn.pages[i].text,
360352
cls: 'page-recognized-text',
361353
});
362354
}

0 commit comments

Comments
 (0)