@searpent/react-image-annotate 2.3.0-cand-2 → 2.3.0

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.
@@ -611,7 +611,7 @@ var examplePhotos = [{
611
611
  "Y1": 0.38327134,
612
612
  "Y2": 0.5264345
613
613
  },
614
- "text": "[{\"label\":\"text\",\"text\":\"Vedle domácíhhhhhhh špičky nebude chybět řada účastníků OH v Tokiu, nad plánovanou účastí dvojnásobné vítězky Venduly Frintové visí otazník. Nejlepší česká triatlonistka měla žaludeční problémy a o jejím startu se rozhodne na poslední chvíli. Vedle Frintové je přihlášena i druhá česká olympionička Petra Kuříková, jejímž karlovarským maximem je předloňské čtvrté místo. Mezi devítkou domácích závodníků je též Jan Čelůstka i nadějní Tereza Zimovjanová (na snímku) s Radimem Grebíkem.\"}]",
614
+ "text": "[{\"label\":\"text\",\"text\":\"Konec vedddlké opravy. Přinesla také teplejší vodu v bazénu. Vedle domácíhhhhhhh špičky nebude chybět řada účastníků OH v Tokiu, nad plánovanou účastí dvojnásobné vítězky Venduly Frintové visí otazník. Nejlepší česká triatlonistka měla žaludeční problémy a o jejím startu se rozhodne na poslední chvíli. Vedle Frintové je přihlášena i druhá česká olympionička Petra Kuříková, jejímž karlovarským maximem je předloňské čtvrté místo. Mezi devítkou domácích závodníků je též Jan Čelůstka i nadějní Tereza Zimovjanová (na snímku) s Radimem Grebíkem.\"}]",
615
615
  "groupId": "4",
616
616
  "id": "346807505487134722"
617
617
  }, {
package/Editor/editor.css CHANGED
@@ -1,8 +1,8 @@
1
1
  .editor-toggle-wrapper {
2
2
  display: flex;
3
- flex-direction: column;
3
+ flex-direction: row;
4
4
  align-items: flex-start;
5
- gap: 0.5rem; /* space between Spellcheck and Edit mode rows */
5
+ gap: 1rem; /* space between Spellcheck and Edit mode toggles */
6
6
  }
7
7
 
8
8
  /* Smaller toggle size only for Editor switches */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@searpent/react-image-annotate",
3
- "version": "2.3.0-cand-2",
3
+ "version": "2.3.0",
4
4
  "dependencies": {
5
5
  "@editorjs/editorjs": "^2.25.0",
6
6
  "@editorjs/paragraph": "^2.8.0",
@@ -225,9 +225,7 @@ var spellcheckEnabled = function () {
225
225
  // Check for environment variable (works in Create React App, Storybook, etc.)
226
226
  if (typeof process !== 'undefined' && process.env && process.env.REACT_APP_SPELLCHECK_ENABLED !== undefined) {
227
227
  var envValue = process.env.REACT_APP_SPELLCHECK_ENABLED;
228
- console.log('[Spellcheck] REACT_APP_SPELLCHECK_ENABLED from env:', envValue);
229
228
  var enabledFromEnv = envValue === 'true' || envValue === '1';
230
- console.log('[Spellcheck] Initial spellcheckEnabled from env:', enabledFromEnv);
231
229
  return enabledFromEnv;
232
230
  }
233
231
  } catch (e) {
@@ -235,7 +233,6 @@ var spellcheckEnabled = function () {
235
233
  console.warn('[Spellcheck] Failed to read REACT_APP_SPELLCHECK_ENABLED from process.env:', e);
236
234
  }
237
235
 
238
- console.log('[Spellcheck] REACT_APP_SPELLCHECK_ENABLED not set, defaulting spellcheckEnabled=false');
239
236
  return false; // Default to disabled for performance
240
237
  }(); // Function to enable/disable spellchecking
241
238
  // Call this from your application to control spellchecking at runtime
@@ -408,6 +405,7 @@ function _findMisspellings() {
408
405
  _step2,
409
406
  w,
410
407
  word,
408
+ isCorrect,
411
409
  _args3 = arguments;
412
410
 
413
411
  return _regeneratorRuntime.wrap(function _callee3$(_context3) {
@@ -459,7 +457,18 @@ function _findMisspellings() {
459
457
  // Word extraction across common Latin + Cyrillic ranges
460
458
  // Matches sequences of letters, allowing internal apostrophes/dashes.
461
459
  // Note: Avoids Unicode property escapes (\p{L}) for compatibility with older Babel toolchain.
462
- wordRegex = /[A-Za-zÀ-ÖØ-öø-ÿЀ-ӿ][A-Za-zÀ-ÖØ-öø-ÿЀ-ӿ'’-]*/g;
460
+ //
461
+ // Character coverage by language:
462
+ // - English (en-US): A-Za-z (Basic Latin)
463
+ // - Czech (cs-CZ): A-Za-z + À-ÿ (Latin-1) + \u0100-\u017F (Latin Extended-A: č, ř, š, ž, ě, ů, ď, ť, ň)
464
+ // - Slovak (sk-SK): A-Za-z + À-ÿ (Latin-1: á, é, í, ó, ú, ý, ä, ô) + \u0100-\u017F (Latin Extended-A: č, ď, ň, š, ť, ž, ĺ, ľ, ŕ)
465
+ // - Portuguese (pt-BR): A-Za-z + À-ÿ (Latin-1: á, à, â, ã, ä, é, ê, ë, í, î, ï, ó, ô, õ, ö, ú, û, ü, ç)
466
+ // - Macedonian (mk-MK): Ѐ-ӿ (Cyrillic: all Cyrillic characters including ѓ, ќ, ѕ, џ, ј)
467
+ //
468
+ // IMPORTANT: Latin Extended-A (U+0100-U+017F) was missing in a previous version, causing:
469
+ // - Czech/Slovak words starting with these characters (like "Přinesla") to be incorrectly marked as misspelled
470
+ // - Words containing them (like "vedddlké") to not be extracted properly for spellchecking
471
+ wordRegex = /[A-Za-zÀ-ÖØ-öø-ÿ\u0100-\u017FЀ-ӿ][A-Za-zÀ-ÖØ-öø-ÿ\u0100-\u017FЀ-ӿ'’-]*/g;
463
472
  words = text.match(wordRegex) || [];
464
473
  miss = new Set();
465
474
  _iteratorNormalCompletion2 = true;
@@ -470,7 +479,7 @@ function _findMisspellings() {
470
479
 
471
480
  case 24:
472
481
  if (_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done) {
473
- _context3.next = 33;
482
+ _context3.next = 34;
474
483
  break;
475
484
  }
476
485
 
@@ -482,66 +491,72 @@ function _findMisspellings() {
482
491
  break;
483
492
  }
484
493
 
485
- return _context3.abrupt("continue", 30);
494
+ return _context3.abrupt("continue", 31);
486
495
 
487
496
  case 29:
488
- if (!spell.correct(word)) miss.add(word);
497
+ isCorrect = spell.correct(word);
489
498
 
490
- case 30:
499
+ if (!isCorrect) {
500
+ miss.add(word); // Debug logging for misspelled words
501
+
502
+ console.log("[Spellcheck] Misspelled word detected: \"".concat(word, "\" (original: \"").concat(w, "\")"));
503
+ }
504
+
505
+ case 31:
491
506
  _iteratorNormalCompletion2 = true;
492
507
  _context3.next = 24;
493
508
  break;
494
509
 
495
- case 33:
496
- _context3.next = 39;
510
+ case 34:
511
+ _context3.next = 40;
497
512
  break;
498
513
 
499
- case 35:
500
- _context3.prev = 35;
514
+ case 36:
515
+ _context3.prev = 36;
501
516
  _context3.t0 = _context3["catch"](22);
502
517
  _didIteratorError2 = true;
503
518
  _iteratorError2 = _context3.t0;
504
519
 
505
- case 39:
506
- _context3.prev = 39;
520
+ case 40:
507
521
  _context3.prev = 40;
522
+ _context3.prev = 41;
508
523
 
509
524
  if (!_iteratorNormalCompletion2 && _iterator2.return != null) {
510
525
  _iterator2.return();
511
526
  }
512
527
 
513
- case 42:
514
- _context3.prev = 42;
528
+ case 43:
529
+ _context3.prev = 43;
515
530
 
516
531
  if (!_didIteratorError2) {
517
- _context3.next = 45;
532
+ _context3.next = 46;
518
533
  break;
519
534
  }
520
535
 
521
536
  throw _iteratorError2;
522
537
 
523
- case 45:
524
- return _context3.finish(42);
525
-
526
538
  case 46:
527
- return _context3.finish(39);
539
+ return _context3.finish(43);
528
540
 
529
541
  case 47:
542
+ return _context3.finish(40);
543
+
544
+ case 48:
530
545
  return _context3.abrupt("return", Array.from(miss));
531
546
 
532
- case 50:
533
- _context3.prev = 50;
547
+ case 51:
548
+ _context3.prev = 51;
534
549
  _context3.t1 = _context3["catch"](3);
535
550
  console.error("[Spellcheck Error] Spellcheck failed for language ".concat(lang, ":"), _context3.t1);
536
551
  console.error("[Spellcheck Error] Stack:", _context3.t1.stack);
537
552
  return _context3.abrupt("return", []);
538
553
 
539
- case 55:
554
+ case 56:
540
555
  case "end":
541
556
  return _context3.stop();
542
557
  }
543
558
  }
544
- }, _callee3, null, [[3, 50], [22, 35, 39, 47], [40,, 42, 46]]);
559
+ }, _callee3, null, [[3, 51], [22, 36, 40, 48], [41,, 43, 47]]);
545
560
  }));
546
561
  return _findMisspellings.apply(this, arguments);
547
562
  }
@@ -635,8 +650,9 @@ function _highlightMisspellingsInHtml() {
635
650
  try {
636
651
  for (var _iterator3 = miss[Symbol.iterator](), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) {
637
652
  var m = _step3.value;
638
- // Use word boundaries instead of Unicode property escapes for compatibility
639
- var re = new RegExp("\\b".concat(escapeRegExp(m), "\\b"), 'gi');
653
+ // Use Unicode-aware word boundary pattern to support accented characters
654
+ // Standard \b doesn't work well with Unicode characters like é, č, ř, etc.
655
+ var re = createUnicodeWordBoundaryRegex(m);
640
656
  out = out.replace(re, "<span class=\"spell-error\">$&</span>");
641
657
  }
642
658
  } catch (err) {
@@ -676,4 +692,17 @@ function _highlightMisspellingsInHtml() {
676
692
 
677
693
  function escapeRegExp(s) {
678
694
  return s.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
695
+ } // Create a Unicode-aware word boundary pattern
696
+ // This works better than \b for Unicode characters like é, č, ř, etc.
697
+
698
+
699
+ function createUnicodeWordBoundaryRegex(word) {
700
+ // Escape special regex characters in the word
701
+ var escaped = escapeRegExp(word); // Use a pattern that matches word boundaries with Unicode support
702
+ // Matches: start of string, non-word-char, or word-char before the word
703
+ // And: end of string, non-word-char, or word-char after the word
704
+ // The (?<=...) and (?=...) are lookbehind/lookahead assertions
705
+ // We use [^A-Za-zÀ-ÖØ-öø-ÿ\u0100-\u017FЀ-ӿ] to match non-word characters
706
+
707
+ return new RegExp("(?<=^|[^A-Za-z\xC0-\xD6\xD8-\xF6\xF8-\xFF\\u0100-\\u017F\u0400-\u04FF])".concat(escaped, "(?=[^A-Za-z\xC0-\xD6\xD8-\xF6\xF8-\xFF\\u0100-\\u017F\u0400-\u04FF]|$)"), 'giu');
679
708
  }