@chialab/pdfjs-lib 1.0.0-alpha.45 → 1.0.0-alpha.46

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -29849,42 +29849,16 @@ async function createTextLayer(page, {
29849
29849
  }
29850
29850
  if (oldTextItem?.glyphs.length) {
29851
29851
  if (newTextItem) {
29852
- const text = oldTextItem.glyphs.map((g) => g[0].unicode).join("") || "";
29853
- const dir = bidi(text).dir;
29854
- const firstGlyph = oldTextItem.glyphs[0];
29855
- const lastGlyph = oldTextItem.glyphs.at(-1);
29856
- const scale = oldTextItem.scaleX * oldTextItem.fontSize;
29857
29852
  const top = oldTextItem.top;
29858
29853
  const bottom = oldTextItem.top + oldTextItem.fontSize;
29859
- const left = oldTextItem.left;
29860
- const right = oldTextItem.left + (lastGlyph[1] + lastGlyph[2]) * scale;
29861
29854
  const nextTop = newTextItem.top;
29862
29855
  const nextBottom = newTextItem.top + newTextItem.fontSize;
29863
- switch (dir) {
29864
- case "ltr": {
29865
- if (newTextItem.left - right < lastGlyph[2] * scale) {
29866
- if (nextTop > top && nextTop < bottom || nextBottom > top && nextBottom < bottom) {
29867
- return;
29868
- }
29869
- if (checkNewLine(oldTextItem, newTextItem, true)) {
29870
- appendNewLineAsNeeded();
29871
- return;
29872
- }
29873
- }
29874
- break;
29875
- }
29876
- case "rtl": {
29877
- if (left - newTextItem.left < firstGlyph[2] * scale) {
29878
- if (nextTop > top && nextTop < bottom || nextBottom > top && nextBottom < bottom) {
29879
- return;
29880
- }
29881
- if (checkNewLine(oldTextItem, newTextItem, true)) {
29882
- appendNewLineAsNeeded();
29883
- return;
29884
- }
29885
- }
29886
- break;
29887
- }
29856
+ if (nextTop > top && nextTop < bottom || nextBottom > top && nextBottom < bottom || nextTop <= top && nextBottom >= bottom) {
29857
+ return;
29858
+ }
29859
+ if (checkNewLine(oldTextItem, newTextItem, true)) {
29860
+ appendNewLineAsNeeded();
29861
+ return;
29888
29862
  }
29889
29863
  }
29890
29864
  closeMarkedContent();
@@ -28450,42 +28450,16 @@ async function createTextLayer(page, {
28450
28450
  }
28451
28451
  if (oldTextItem?.glyphs.length) {
28452
28452
  if (newTextItem) {
28453
- const text = oldTextItem.glyphs.map((g) => g[0].unicode).join("") || "";
28454
- const dir = bidi(text).dir;
28455
- const firstGlyph = oldTextItem.glyphs[0];
28456
- const lastGlyph = oldTextItem.glyphs.at(-1);
28457
- const scale = oldTextItem.scaleX * oldTextItem.fontSize;
28458
28453
  const top = oldTextItem.top;
28459
28454
  const bottom = oldTextItem.top + oldTextItem.fontSize;
28460
- const left = oldTextItem.left;
28461
- const right = oldTextItem.left + (lastGlyph[1] + lastGlyph[2]) * scale;
28462
28455
  const nextTop = newTextItem.top;
28463
28456
  const nextBottom = newTextItem.top + newTextItem.fontSize;
28464
- switch (dir) {
28465
- case "ltr": {
28466
- if (newTextItem.left - right < lastGlyph[2] * scale) {
28467
- if (nextTop > top && nextTop < bottom || nextBottom > top && nextBottom < bottom) {
28468
- return;
28469
- }
28470
- if (checkNewLine(oldTextItem, newTextItem, true)) {
28471
- appendNewLineAsNeeded();
28472
- return;
28473
- }
28474
- }
28475
- break;
28476
- }
28477
- case "rtl": {
28478
- if (left - newTextItem.left < firstGlyph[2] * scale) {
28479
- if (nextTop > top && nextTop < bottom || nextBottom > top && nextBottom < bottom) {
28480
- return;
28481
- }
28482
- if (checkNewLine(oldTextItem, newTextItem, true)) {
28483
- appendNewLineAsNeeded();
28484
- return;
28485
- }
28486
- }
28487
- break;
28488
- }
28457
+ if (nextTop > top && nextTop < bottom || nextBottom > top && nextBottom < bottom || nextTop <= top && nextBottom >= bottom) {
28458
+ return;
28459
+ }
28460
+ if (checkNewLine(oldTextItem, newTextItem, true)) {
28461
+ appendNewLineAsNeeded();
28462
+ return;
28489
28463
  }
28490
28464
  }
28491
28465
  closeMarkedContent();
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@chialab/pdfjs-lib",
3
3
  "description": "A custom Mozilla's PDF.js build with better Node support and extras.",
4
- "version": "1.0.0-alpha.45",
4
+ "version": "1.0.0-alpha.46",
5
5
  "type": "module",
6
6
  "author": "Chialab <dev@chialab.it>",
7
7
  "license": "MIT",