react-native-nitro-input 0.3.1 → 0.3.3
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.
- package/CHANGELOG.md +114 -0
- package/README.md +75 -3
- package/android/src/main/cpp/JMaskEngine.cpp +45 -0
- package/android/src/main/cpp/JMaskEngine.hpp +9 -0
- package/android/src/main/java/com/margelo/nitro/nitroinput/HybridNitroInputView.kt +49 -4
- package/android/src/main/java/com/margelo/nitro/nitroinput/MaskEngine.kt +16 -0
- package/android/src/main/java/com/margelo/nitro/nitroinput/NitroInputView.kt +266 -8
- package/android/src/main/java/com/margelo/nitro/nitroinput/UnmountHandoffs.kt +57 -0
- package/cpp/MaskEngine.cpp +294 -33
- package/cpp/MaskEngine.hpp +68 -0
- package/ios/HybridNitroInputView.swift +37 -4
- package/ios/NitroInputCommands.mm +10 -0
- package/ios/NitroInputView.swift +474 -20
- package/lib/commonjs/nitrogen/generated/shared/json/NitroInputViewConfig.json +8 -0
- package/lib/commonjs/src/NitroInput.js +116 -15
- package/lib/module/nitrogen/generated/shared/json/NitroInputViewConfig.json +8 -0
- package/lib/module/src/NitroInput.js +117 -16
- package/lib/typescript/src/NitroInput.d.ts +55 -1
- package/lib/typescript/src/index.d.ts +1 -1
- package/lib/typescript/src/specs/NitroInput.nitro.d.ts +65 -0
- package/nitrogen/generated/android/c++/JHybridNitroInputViewSpec.cpp +124 -0
- package/nitrogen/generated/android/c++/JHybridNitroInputViewSpec.hpp +17 -0
- package/nitrogen/generated/android/c++/JNitroInputCharacterMapping.hpp +61 -0
- package/nitrogen/generated/android/c++/JNitroInputMaskAffinity.hpp +64 -0
- package/nitrogen/generated/android/c++/JNitroInputTextCase.hpp +61 -0
- package/nitrogen/generated/android/c++/views/JHybridNitroInputViewStateUpdater.cpp +40 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroinput/HybridNitroInputViewSpec.kt +52 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroinput/NitroInputCharacterMapping.kt +56 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroinput/NitroInputMaskAffinity.kt +25 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroinput/NitroInputTextCase.kt +24 -0
- package/nitrogen/generated/ios/NitroInput-Swift-Cxx-Bridge.hpp +25 -11
- package/nitrogen/generated/ios/NitroInput-Swift-Cxx-Umbrella.hpp +9 -0
- package/nitrogen/generated/ios/c++/HybridNitroInputViewSpecSwift.hpp +68 -0
- package/nitrogen/generated/ios/c++/views/HybridNitroInputViewComponent.mm +48 -0
- package/nitrogen/generated/ios/swift/HybridNitroInputViewSpec.swift +9 -0
- package/nitrogen/generated/ios/swift/HybridNitroInputViewSpec_cxx.swift +111 -0
- package/nitrogen/generated/ios/swift/NitroInputCharacterMapping.swift +34 -0
- package/nitrogen/generated/ios/swift/NitroInputMaskAffinity.swift +48 -0
- package/nitrogen/generated/ios/swift/NitroInputTextCase.swift +44 -0
- package/nitrogen/generated/shared/c++/HybridNitroInputViewSpec.cpp +17 -0
- package/nitrogen/generated/shared/c++/HybridNitroInputViewSpec.hpp +26 -0
- package/nitrogen/generated/shared/c++/NitroInputCharacterMapping.hpp +87 -0
- package/nitrogen/generated/shared/c++/NitroInputMaskAffinity.hpp +84 -0
- package/nitrogen/generated/shared/c++/NitroInputTextCase.hpp +80 -0
- package/nitrogen/generated/shared/c++/views/HybridNitroInputViewComponent.cpp +16 -0
- package/nitrogen/generated/shared/c++/views/HybridNitroInputViewComponent.hpp +27 -0
- package/nitrogen/generated/shared/json/NitroInputViewConfig.json +8 -0
- package/package.json +2 -2
- package/src/NitroInput.tsx +190 -11
- package/src/index.ts +3 -0
- package/src/specs/NitroInput.nitro.ts +68 -0
package/cpp/MaskEngine.cpp
CHANGED
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
#include "AmountFormatter.hpp"
|
|
9
9
|
|
|
10
10
|
#include <algorithm>
|
|
11
|
+
#include <climits>
|
|
11
12
|
#include <optional>
|
|
12
13
|
|
|
13
14
|
namespace margelo::nitro::nitroinput {
|
|
@@ -20,8 +21,67 @@ bool isDigit(uint32_t c) {
|
|
|
20
21
|
return c >= '0' && c <= '9';
|
|
21
22
|
}
|
|
22
23
|
|
|
24
|
+
/// Letters a `[A]`/`[a]` slot takes: ASCII and the alphabetic blocks of the
|
|
25
|
+
/// scripts people type into forms (Latin with its diacritics, Greek,
|
|
26
|
+
/// Cyrillic, Armenian, Hebrew, Arabic, Devanagari, Thai, Hangul, kana and CJK
|
|
27
|
+
/// ideographs). Not a full Unicode letter table - that would outweigh the
|
|
28
|
+
/// engine - but no longer ASCII only, which refused every Cyrillic name.
|
|
23
29
|
bool isLetter(uint32_t c) {
|
|
24
|
-
|
|
30
|
+
if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z')) return true;
|
|
31
|
+
if (c < 0xC0) return false;
|
|
32
|
+
if (c <= 0x24F) return c != 0xD7 && c != 0xF7; // Latin-1 letters, Latin Extended-A/B
|
|
33
|
+
if (c >= 0x370 && c <= 0x3FF) return c >= 0x386 && c != 0x387 && c != 0x3F6; // Greek
|
|
34
|
+
if (c >= 0x400 && c <= 0x52F) return (c < 0x482 || c > 0x489); // Cyrillic (+ supplement)
|
|
35
|
+
if (c >= 0x531 && c <= 0x587) return c <= 0x556 || c >= 0x561; // Armenian
|
|
36
|
+
if (c >= 0x5D0 && c <= 0x5EA) return true; // Hebrew
|
|
37
|
+
if (c >= 0x620 && c <= 0x64A) return true; // Arabic
|
|
38
|
+
if (c >= 0x904 && c <= 0x939) return true; // Devanagari
|
|
39
|
+
if (c >= 0xE01 && c <= 0xE30) return true; // Thai
|
|
40
|
+
if (c >= 0x1E00 && c <= 0x1EFF) return true; // Latin Extended Additional (Vietnamese)
|
|
41
|
+
if (c >= 0x3041 && c <= 0x30FA) return c != 0x30A0; // Hiragana, Katakana
|
|
42
|
+
if (c >= 0x4E00 && c <= 0x9FFF) return true; // CJK ideographs
|
|
43
|
+
if (c >= 0xAC00 && c <= 0xD7A3) return true; // Hangul syllables
|
|
44
|
+
return false;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/// Upper- and lower-case counterparts for the cased scripts `isLetter` knows.
|
|
48
|
+
/// Anything else maps to itself.
|
|
49
|
+
uint32_t toUpper(uint32_t c) {
|
|
50
|
+
if (c >= 'a' && c <= 'z') return c - 32;
|
|
51
|
+
if (c < 0xE0) return c;
|
|
52
|
+
if (c == 0xFF) return 0x178; // ÿ → Ÿ
|
|
53
|
+
if (c <= 0xFE) return c == 0xF7 ? c : c - 32; // Latin-1
|
|
54
|
+
if (c >= 0x100 && c <= 0x17F) { // Latin Extended-A
|
|
55
|
+
if ((c >= 0x139 && c <= 0x148) || (c >= 0x179 && c <= 0x17E)) return (c % 2 == 0) ? c - 1 : c;
|
|
56
|
+
if (c == 0x131 || c == 0x138 || c == 0x149 || c == 0x17F) return c;
|
|
57
|
+
return (c % 2 == 1) ? c - 1 : c;
|
|
58
|
+
}
|
|
59
|
+
if (c >= 0x3B1 && c <= 0x3C9) return c == 0x3C2 ? 0x3A3 : c - 32; // Greek (final sigma → Σ)
|
|
60
|
+
if (c >= 0x430 && c <= 0x44F) return c - 32; // Cyrillic
|
|
61
|
+
if (c >= 0x450 && c <= 0x45F) return c - 80;
|
|
62
|
+
if ((c >= 0x460 && c <= 0x481) || (c >= 0x48A && c <= 0x4BF)) return (c % 2 == 1) ? c - 1 : c;
|
|
63
|
+
if (c >= 0x561 && c <= 0x586) return c - 48; // Armenian
|
|
64
|
+
if (c >= 0x1E00 && c <= 0x1EFF) return (c % 2 == 1) ? c - 1 : c; // Vietnamese and co.
|
|
65
|
+
return c;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
uint32_t toLower(uint32_t c) {
|
|
69
|
+
if (c >= 'A' && c <= 'Z') return c + 32;
|
|
70
|
+
if (c < 0xC0) return c;
|
|
71
|
+
if (c <= 0xDE) return c == 0xD7 ? c : c + 32; // Latin-1
|
|
72
|
+
if (c == 0x178) return 0xFF; // Ÿ → ÿ
|
|
73
|
+
if (c >= 0x100 && c <= 0x17F) { // Latin Extended-A
|
|
74
|
+
if ((c >= 0x139 && c <= 0x148) || (c >= 0x179 && c <= 0x17E)) return (c % 2 == 1) ? c + 1 : c;
|
|
75
|
+
if (c == 0x130 || c == 0x131 || c == 0x138 || c == 0x149 || c == 0x17F) return c;
|
|
76
|
+
return (c % 2 == 0) ? c + 1 : c;
|
|
77
|
+
}
|
|
78
|
+
if (c >= 0x391 && c <= 0x3A9 && c != 0x3A2) return c + 32; // Greek
|
|
79
|
+
if (c >= 0x410 && c <= 0x42F) return c + 32; // Cyrillic
|
|
80
|
+
if (c >= 0x400 && c <= 0x40F) return c + 80;
|
|
81
|
+
if ((c >= 0x460 && c <= 0x481) || (c >= 0x48A && c <= 0x4BF)) return (c % 2 == 0) ? c + 1 : c;
|
|
82
|
+
if (c >= 0x531 && c <= 0x556) return c + 48; // Armenian
|
|
83
|
+
if (c >= 0x1E00 && c <= 0x1EFF) return (c % 2 == 0) ? c + 1 : c;
|
|
84
|
+
return c;
|
|
25
85
|
}
|
|
26
86
|
|
|
27
87
|
constexpr uint32_t kEllipsis = 0x2026; // …
|
|
@@ -244,8 +304,12 @@ void normalizeBlock(const CodePoints& block, std::vector<CodePoints>* out) {
|
|
|
244
304
|
if (!run.empty()) runs.push_back(run);
|
|
245
305
|
|
|
246
306
|
for (CodePoints& piece : runs) {
|
|
247
|
-
// Mandatory before optional, order otherwise preserved
|
|
248
|
-
|
|
307
|
+
// Mandatory before optional, order otherwise preserved - and an ellipsis
|
|
308
|
+
// always last: it repeats the slot in front of it, so `[9…]` moved to
|
|
309
|
+
// `[…9]` would repeat nothing and take letters (upstream sorts by code,
|
|
310
|
+
// which leaves `…` last for the same reason).
|
|
311
|
+
const auto rank = [](uint32_t c) { return c == kEllipsis ? 2 : isOptionalSlot(c) ? 1 : 0; };
|
|
312
|
+
std::stable_sort(piece.begin(), piece.end(), [&](uint32_t a, uint32_t b) { return rank(a) < rank(b); });
|
|
249
313
|
CodePoints wrapped;
|
|
250
314
|
wrapped.reserve(piece.size() + 2);
|
|
251
315
|
wrapped.push_back('[');
|
|
@@ -396,31 +460,91 @@ bool MaskEngine::setFormat(const std::string& format) {
|
|
|
396
460
|
return setFormat(format, staged_);
|
|
397
461
|
}
|
|
398
462
|
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
if (format.empty()) return
|
|
463
|
+
std::shared_ptr<const MaskEngine::Compiled> MaskEngine::compileFormat(const std::string& format,
|
|
464
|
+
const std::vector<Notation>& notations) {
|
|
465
|
+
if (format.empty()) return nullptr;
|
|
402
466
|
|
|
403
|
-
auto next = std::
|
|
467
|
+
auto next = std::make_shared<Compiled>();
|
|
404
468
|
next->notations = notations;
|
|
405
469
|
|
|
406
470
|
// A notation may not redefine a built-in slot character - the compiler would
|
|
407
471
|
// never reach it, so the caller's intent could not be honoured.
|
|
408
472
|
for (const Notation& notation : next->notations) {
|
|
409
|
-
if (isReservedSlot(notation.character) || notation.characterSet.empty()) return
|
|
473
|
+
if (isReservedSlot(notation.character) || notation.characterSet.empty()) return nullptr;
|
|
410
474
|
}
|
|
411
475
|
|
|
412
476
|
CodePoints sanitized;
|
|
413
|
-
if (!sanitize(AmountFormatter::decode(format), &sanitized)) return
|
|
477
|
+
if (!sanitize(AmountFormatter::decode(format), &sanitized)) return nullptr;
|
|
414
478
|
|
|
415
479
|
bool ok = true;
|
|
416
480
|
const State* initial = compile(*next, sanitized, 0, false, false, 0, &ok);
|
|
417
|
-
if (!ok || initial == nullptr) return
|
|
418
|
-
|
|
481
|
+
if (!ok || initial == nullptr) return nullptr;
|
|
419
482
|
next->initial = initial;
|
|
420
|
-
|
|
483
|
+
|
|
484
|
+
// What the format can hold, for the capacity strategies and the paste rule.
|
|
485
|
+
bool leading = true;
|
|
486
|
+
for (const State* s = initial; s != nullptr && s->slot != Slot::EndOfLine; s = s->child) {
|
|
487
|
+
if (s->elliptical) {
|
|
488
|
+
next->textCapacity = kUnbounded;
|
|
489
|
+
next->valueCapacity = kUnbounded;
|
|
490
|
+
break;
|
|
491
|
+
}
|
|
492
|
+
if (s->slot == Slot::Free || s->slot == Slot::Fixed) {
|
|
493
|
+
if (leading) next->leadingConstants.push_back(s->ownCharacter);
|
|
494
|
+
next->textCapacity += 1;
|
|
495
|
+
if (s->slot == Slot::Fixed) next->valueCapacity += 1;
|
|
496
|
+
} else {
|
|
497
|
+
leading = false;
|
|
498
|
+
next->textCapacity += 1;
|
|
499
|
+
next->valueCapacity += 1;
|
|
500
|
+
}
|
|
501
|
+
}
|
|
502
|
+
return next;
|
|
503
|
+
}
|
|
504
|
+
|
|
505
|
+
bool MaskEngine::setFormat(const std::string& format, const std::vector<Notation>& notations) {
|
|
506
|
+
compiled_.reset();
|
|
507
|
+
alternatives_.clear();
|
|
508
|
+
compiled_ = compileFormat(format, notations);
|
|
509
|
+
if (compiled_ == nullptr) return false;
|
|
510
|
+
for (const std::string& alternative : stagedAffinityFormats_) {
|
|
511
|
+
if (auto compiled = compileFormat(alternative, notations)) alternatives_.push_back(std::move(compiled));
|
|
512
|
+
}
|
|
421
513
|
return true;
|
|
422
514
|
}
|
|
423
515
|
|
|
516
|
+
void MaskEngine::clearAffinityFormats() {
|
|
517
|
+
stagedAffinityFormats_.clear();
|
|
518
|
+
}
|
|
519
|
+
|
|
520
|
+
void MaskEngine::addAffinityFormat(const std::string& format) {
|
|
521
|
+
stagedAffinityFormats_.push_back(format);
|
|
522
|
+
}
|
|
523
|
+
|
|
524
|
+
void MaskEngine::setAffinityStrategy(int strategy) {
|
|
525
|
+
affinityStrategy_ = std::clamp(strategy, kAffinityWholeString, kAffinityExtractedValueCapacity);
|
|
526
|
+
}
|
|
527
|
+
|
|
528
|
+
void MaskEngine::setTextCase(int textCase) {
|
|
529
|
+
textCase_ = std::clamp(textCase, kTextCaseNone, kTextCaseLower);
|
|
530
|
+
}
|
|
531
|
+
|
|
532
|
+
void MaskEngine::clearCharacterMap() {
|
|
533
|
+
characterMap_.clear();
|
|
534
|
+
}
|
|
535
|
+
|
|
536
|
+
void MaskEngine::addCharacterMapping(const std::string& from, const std::string& to) {
|
|
537
|
+
const CodePoints source = AmountFormatter::decode(from);
|
|
538
|
+
if (source.empty()) return;
|
|
539
|
+
const CodePoints target = AmountFormatter::decode(to);
|
|
540
|
+
characterMap_.emplace_back(source[0], target.empty() ? 0 : target[0]);
|
|
541
|
+
}
|
|
542
|
+
|
|
543
|
+
void MaskEngine::setSlotPlaceholder(const std::string& character) {
|
|
544
|
+
const CodePoints decoded = AmountFormatter::decode(character);
|
|
545
|
+
slotPlaceholder_ = decoded.empty() ? 0 : decoded[0];
|
|
546
|
+
}
|
|
547
|
+
|
|
424
548
|
// MARK: - Applying
|
|
425
549
|
|
|
426
550
|
MaskEngine::Result MaskEngine::apply(const std::string& text, int caret, bool caretForward, bool autocomplete,
|
|
@@ -443,11 +567,123 @@ MaskEngine::Result MaskEngine::apply(const std::string& text, int caret, bool ca
|
|
|
443
567
|
return apply(text, caret, caretForward, false, autoSkip);
|
|
444
568
|
}
|
|
445
569
|
|
|
446
|
-
|
|
447
|
-
|
|
570
|
+
int caretPosition = std::clamp(caret, 0, AmountFormatter::codePointCount(text));
|
|
571
|
+
CodePoints input = prepareInput(AmountFormatter::decode(text), &caretPosition);
|
|
572
|
+
|
|
573
|
+
if (alternatives_.empty()) {
|
|
574
|
+
return applyCompiled(*compiled_, input, caretPosition, caretForward, autocomplete, autoSkip);
|
|
575
|
+
}
|
|
576
|
+
|
|
577
|
+
// With several formats the text still carries the separators whichever one
|
|
578
|
+
// won last time inserted: "3782 8224 6" typed under 4-4-4-4 would count its
|
|
579
|
+
// spaces against the Amex 4-6-5 format and never let it take over. So every
|
|
580
|
+
// format re-masks the value characters alone; each puts its own literals back.
|
|
581
|
+
const std::vector<Notation>& notations = compiled_->notations;
|
|
582
|
+
const auto isValueCharacter = [&](uint32_t c) {
|
|
583
|
+
if (isDigit(c) || isLetter(c)) return true;
|
|
584
|
+
return std::any_of(notations.begin(), notations.end(), [c](const Notation& n) {
|
|
585
|
+
return std::find(n.characterSet.begin(), n.characterSet.end(), c) != n.characterSet.end();
|
|
586
|
+
});
|
|
587
|
+
};
|
|
588
|
+
CodePoints values;
|
|
589
|
+
values.reserve(input.size());
|
|
590
|
+
const int originalCaret = caretPosition;
|
|
591
|
+
for (size_t i = 0; i < input.size(); ++i) {
|
|
592
|
+
if (isValueCharacter(input[i])) {
|
|
593
|
+
values.push_back(input[i]);
|
|
594
|
+
} else if (static_cast<int>(i) < originalCaret) {
|
|
595
|
+
caretPosition -= 1;
|
|
596
|
+
}
|
|
597
|
+
}
|
|
598
|
+
|
|
599
|
+
// Ties go to the format that keeps more of what the field already shows -
|
|
600
|
+
// the one whose output shares the longer prefix with the text. The text
|
|
601
|
+
// still carries the separators of whichever format is showing, so that is
|
|
602
|
+
// the incumbent: a 4-6-5 card does not flip back to 4-4-4-4 at the 11th and
|
|
603
|
+
// 12th digit, where the two score the same. With nothing to tell them apart
|
|
604
|
+
// (an empty field, or text both lay out alike) the primary keeps it.
|
|
605
|
+
const auto sharedPrefix = [&](const Result& result) {
|
|
606
|
+
const CodePoints formatted = AmountFormatter::decode(result.formattedText);
|
|
607
|
+
size_t shared = 0;
|
|
608
|
+
while (shared < formatted.size() && shared < input.size() && formatted[shared] == input[shared]) shared++;
|
|
609
|
+
return static_cast<int>(shared);
|
|
610
|
+
};
|
|
611
|
+
Result best = applyCompiled(*compiled_, values, caretPosition, caretForward, autocomplete, autoSkip);
|
|
612
|
+
int bestScore = score(*compiled_, best, input, values);
|
|
613
|
+
int bestShared = sharedPrefix(best);
|
|
614
|
+
for (size_t i = 0; i < alternatives_.size(); ++i) {
|
|
615
|
+
Result candidate = applyCompiled(*alternatives_[i], values, caretPosition, caretForward, autocomplete, autoSkip);
|
|
616
|
+
const int candidateScore = score(*alternatives_[i], candidate, input, values);
|
|
617
|
+
const int candidateShared = sharedPrefix(candidate);
|
|
618
|
+
if (candidateScore > bestScore || (candidateScore == bestScore && candidateShared > bestShared)) {
|
|
619
|
+
bestScore = candidateScore;
|
|
620
|
+
bestShared = candidateShared;
|
|
621
|
+
best = std::move(candidate);
|
|
622
|
+
best.formatIndex = static_cast<int>(i) + 1;
|
|
623
|
+
}
|
|
624
|
+
}
|
|
625
|
+
return best;
|
|
626
|
+
}
|
|
627
|
+
|
|
628
|
+
std::vector<uint32_t> MaskEngine::prepareInput(const std::vector<uint32_t>& input, int* caret) const {
|
|
629
|
+
if (textCase_ == kTextCaseNone && characterMap_.empty()) return input;
|
|
630
|
+
CodePoints out;
|
|
631
|
+
out.reserve(input.size());
|
|
632
|
+
const int originalCaret = *caret;
|
|
633
|
+
for (size_t i = 0; i < input.size(); ++i) {
|
|
634
|
+
uint32_t c = input[i];
|
|
635
|
+
for (const auto& [from, to] : characterMap_) {
|
|
636
|
+
if (c == from) {
|
|
637
|
+
c = to;
|
|
638
|
+
break;
|
|
639
|
+
}
|
|
640
|
+
}
|
|
641
|
+
if (c == 0) {
|
|
642
|
+
// Dropped: everything after it moves left, the caret with it.
|
|
643
|
+
if (static_cast<int>(i) < originalCaret) *caret -= 1;
|
|
644
|
+
continue;
|
|
645
|
+
}
|
|
646
|
+
if (textCase_ == kTextCaseUpper) c = toUpper(c);
|
|
647
|
+
if (textCase_ == kTextCaseLower) c = toLower(c);
|
|
648
|
+
out.push_back(c);
|
|
649
|
+
}
|
|
650
|
+
return out;
|
|
651
|
+
}
|
|
652
|
+
|
|
653
|
+
/// `text` is the input as typed (case-folded and mapped), `values` the same
|
|
654
|
+
/// with its separators taken out. Prefix and capacity measure what was typed;
|
|
655
|
+
/// value capacity counts what would have to fit, which the result itself
|
|
656
|
+
/// cannot tell - it has already dropped whatever overflowed.
|
|
657
|
+
int MaskEngine::score(const Compiled& compiled, const Result& result, const std::vector<uint32_t>& text,
|
|
658
|
+
const std::vector<uint32_t>& values) const {
|
|
659
|
+
switch (affinityStrategy_) {
|
|
660
|
+
case kAffinityPrefix: {
|
|
661
|
+
const CodePoints formatted = AmountFormatter::decode(result.formattedText);
|
|
662
|
+
size_t shared = 0;
|
|
663
|
+
while (shared < formatted.size() && shared < text.size() && formatted[shared] == text[shared]) shared++;
|
|
664
|
+
return static_cast<int>(shared);
|
|
665
|
+
}
|
|
666
|
+
case kAffinityCapacity: {
|
|
667
|
+
const int length = static_cast<int>(text.size());
|
|
668
|
+
return length > compiled.textCapacity ? INT_MIN : length - compiled.textCapacity;
|
|
669
|
+
}
|
|
670
|
+
case kAffinityExtractedValueCapacity: {
|
|
671
|
+
const int length = static_cast<int>(values.size());
|
|
672
|
+
return length > compiled.valueCapacity ? INT_MIN : length - compiled.valueCapacity;
|
|
673
|
+
}
|
|
674
|
+
default:
|
|
675
|
+
return result.affinity;
|
|
676
|
+
}
|
|
677
|
+
}
|
|
448
678
|
|
|
679
|
+
MaskEngine::Result MaskEngine::applyCompiled(const Compiled& compiled, const std::vector<uint32_t>& input,
|
|
680
|
+
int caretPosition, bool caretForward, bool autocomplete,
|
|
681
|
+
bool autoSkip) const {
|
|
449
682
|
const auto insertionAffectsCaret = [&](size_t at) {
|
|
450
|
-
|
|
683
|
+
// RedMadRobot's gravity: typing (forward) moves the caret past a constant
|
|
684
|
+
// inserted right at it, so "11|" + "1" under "[00]{.}[00]" lands after the
|
|
685
|
+
// dot; deleting (backward) leaves the caret in front of it.
|
|
686
|
+
return caretForward ? static_cast<int>(at) <= caretPosition : static_cast<int>(at) < caretPosition;
|
|
451
687
|
};
|
|
452
688
|
const auto deletionAffectsCaret = [&](size_t at) { return static_cast<int>(at) < caretPosition; };
|
|
453
689
|
|
|
@@ -455,7 +691,7 @@ MaskEngine::Result MaskEngine::apply(const std::string& text, int caret, bool ca
|
|
|
455
691
|
CodePoints extracted;
|
|
456
692
|
int modifiedCaret = caretPosition;
|
|
457
693
|
int affinity = 0;
|
|
458
|
-
const State* state =
|
|
694
|
+
const State* state = compiled.initial;
|
|
459
695
|
std::vector<Step> autocompletionStack;
|
|
460
696
|
|
|
461
697
|
size_t at = 0;
|
|
@@ -502,21 +738,9 @@ MaskEngine::Result MaskEngine::apply(const std::string& text, int caret, bool ca
|
|
|
502
738
|
|
|
503
739
|
// Trailing constants are filled in once the caret has reached the end of the
|
|
504
740
|
// input - typing "212" into "+1 ([000]) [000]" leaves "+1 (212) " with the
|
|
505
|
-
// caret after the space, ready for the next digit.
|
|
506
|
-
//
|
|
507
|
-
//
|
|
508
|
-
// is `index < caret` under forward gravity. The walk only ends when the index
|
|
509
|
-
// has reached the end of the input, and the caret can never be past that, so
|
|
510
|
-
// that test is always false and its loop is unreachable: constants only turn
|
|
511
|
-
// up retroactively, when the next value character arrives. Running both side
|
|
512
|
-
// by side on "+1 ([000]) [000]-[0000]":
|
|
513
|
-
//
|
|
514
|
-
// typed reference here
|
|
515
|
-
// 212 "+1 (212" "+1 (212) "
|
|
516
|
-
// 212555 "+1 (212) 555" "+1 (212) 555-"
|
|
517
|
-
//
|
|
518
|
-
// Gate it on the caret instead, which is the behaviour that was always
|
|
519
|
-
// described (and their issues #148 and #31).
|
|
741
|
+
// caret after the space, ready for the next digit. That is RedMadRobot's
|
|
742
|
+
// `insertionAffectsCaret` at the end of the input (`index <= caret` under
|
|
743
|
+
// forward gravity), spelled out.
|
|
520
744
|
const bool caretAtEnd = caretPosition >= static_cast<int>(input.size());
|
|
521
745
|
while (autocomplete && caretAtEnd) {
|
|
522
746
|
const std::optional<Step> step = autocompleteOf(state);
|
|
@@ -566,7 +790,7 @@ MaskEngine::Result MaskEngine::apply(const std::string& text, int caret, bool ca
|
|
|
566
790
|
} else if (s->elliptical) {
|
|
567
791
|
break;
|
|
568
792
|
} else {
|
|
569
|
-
placeholderTail.push_back(s->placeholderCharacter());
|
|
793
|
+
placeholderTail.push_back(slotPlaceholder_ != 0 ? slotPlaceholder_ : s->placeholderCharacter());
|
|
570
794
|
}
|
|
571
795
|
s = s->child;
|
|
572
796
|
}
|
|
@@ -580,7 +804,8 @@ MaskEngine::Result MaskEngine::applyEdit(const std::string& current, int start,
|
|
|
580
804
|
const int count = static_cast<int>(text.size());
|
|
581
805
|
start = std::clamp(start, 0, count);
|
|
582
806
|
end = std::clamp(end, start, count);
|
|
583
|
-
|
|
807
|
+
CodePoints inserted = AmountFormatter::decode(replacement);
|
|
808
|
+
if (inserted.size() > 1 && isActive()) inserted = withoutRepeatedPrefix(text, start, end, inserted);
|
|
584
809
|
|
|
585
810
|
CodePoints spliced(text.begin(), text.begin() + start);
|
|
586
811
|
spliced.insert(spliced.end(), inserted.begin(), inserted.end());
|
|
@@ -593,4 +818,40 @@ MaskEngine::Result MaskEngine::applyEdit(const std::string& current, int start,
|
|
|
593
818
|
return apply(AmountFormatter::encode(spliced), caret, !deleting, !deleting && autocomplete, deleting && autoSkip);
|
|
594
819
|
}
|
|
595
820
|
|
|
821
|
+
std::vector<uint32_t> MaskEngine::withoutRepeatedPrefix(const std::vector<uint32_t>& text, int start, int end,
|
|
822
|
+
const std::vector<uint32_t>& inserted) const {
|
|
823
|
+
// A paste or autofill that repeats the mask's own leading constants -
|
|
824
|
+
// "+63 912 345 6789" into "+63 [000] [000] [0000]", whose "+63 " the field
|
|
825
|
+
// already shows - would have its "63" taken as the first two digits and its
|
|
826
|
+
// last two cut off. Drop the repeat, but only when the paste lands inside
|
|
827
|
+
// those constants and keeping it would overflow the mask: a value that
|
|
828
|
+
// merely starts with the same digits, and fits, is left alone.
|
|
829
|
+
const auto isValueCharacter = [](uint32_t c) { return isDigit(c) || isLetter(c); };
|
|
830
|
+
const CodePoints& leading = compiled_->leadingConstants;
|
|
831
|
+
if (start > static_cast<int>(leading.size())) return inserted;
|
|
832
|
+
|
|
833
|
+
CodePoints repeated;
|
|
834
|
+
for (uint32_t c : leading) {
|
|
835
|
+
if (isValueCharacter(c)) repeated.push_back(c);
|
|
836
|
+
}
|
|
837
|
+
if (repeated.empty()) return inserted;
|
|
838
|
+
|
|
839
|
+
const auto countValue = [&](auto from, auto to) {
|
|
840
|
+
return static_cast<int>(std::count_if(from, to, isValueCharacter));
|
|
841
|
+
};
|
|
842
|
+
const int incoming = countValue(inserted.begin(), inserted.end()) + countValue(text.begin() + end, text.end());
|
|
843
|
+
if (incoming <= compiled_->valueCapacity) return inserted;
|
|
844
|
+
|
|
845
|
+
size_t matched = 0;
|
|
846
|
+
for (size_t i = 0; i < inserted.size(); ++i) {
|
|
847
|
+
const uint32_t c = inserted[i];
|
|
848
|
+
if (!isValueCharacter(c)) continue; // "+", spaces, brackets
|
|
849
|
+
if (c != repeated[matched]) return inserted;
|
|
850
|
+
if (++matched == repeated.size()) {
|
|
851
|
+
return CodePoints(inserted.begin() + static_cast<long>(i) + 1, inserted.end());
|
|
852
|
+
}
|
|
853
|
+
}
|
|
854
|
+
return inserted;
|
|
855
|
+
}
|
|
856
|
+
|
|
596
857
|
} // namespace margelo::nitro::nitroinput
|
package/cpp/MaskEngine.hpp
CHANGED
|
@@ -21,6 +21,14 @@
|
|
|
21
21
|
// \ escapes the next character
|
|
22
22
|
// plus any number of caller-supplied `Notation`s.
|
|
23
23
|
//
|
|
24
|
+
// Around the walk
|
|
25
|
+
// - Input is case-folded and character-mapped first (`setTextCase`,
|
|
26
|
+
// `addCharacterMapping`), so the caret never moves because of it.
|
|
27
|
+
// - Alternative formats (`addAffinityFormat`) are each tried and the one
|
|
28
|
+
// the `AffinityStrategy` scores best wins; the primary wins ties.
|
|
29
|
+
// - A paste that repeats the mask's own leading constants ("+63…" into
|
|
30
|
+
// "+63 [000]…") loses them, when keeping them would overflow the mask.
|
|
31
|
+
//
|
|
24
32
|
// The algorithm follows RedMadRobot's input-mask (MIT), by way of
|
|
25
33
|
// react-native-advanced-input-mask. It differs from both in three ways that
|
|
26
34
|
// matter: it works in code points rather than UTF-16 units (so an astral
|
|
@@ -62,8 +70,26 @@ public:
|
|
|
62
70
|
bool complete = false;
|
|
63
71
|
/// How well the input fitted: +1 per accepted character, -1 per rejected.
|
|
64
72
|
int affinity = 0;
|
|
73
|
+
/// Which format produced this: 0 the primary, 1… the affinity formats in
|
|
74
|
+
/// the order they were added.
|
|
75
|
+
int formatIndex = 0;
|
|
65
76
|
};
|
|
66
77
|
|
|
78
|
+
/// How input letters are cased before masking.
|
|
79
|
+
static constexpr int kTextCaseNone = 0;
|
|
80
|
+
static constexpr int kTextCaseUpper = 1;
|
|
81
|
+
static constexpr int kTextCaseLower = 2;
|
|
82
|
+
|
|
83
|
+
/// How the best of several formats is chosen (RedMadRobot's strategies).
|
|
84
|
+
/// Whole string: accepted minus rejected characters.
|
|
85
|
+
static constexpr int kAffinityWholeString = 0;
|
|
86
|
+
/// Prefix: how many leading characters the input and the result share.
|
|
87
|
+
static constexpr int kAffinityPrefix = 1;
|
|
88
|
+
/// Capacity: fits the formatted text into the format, best the fullest.
|
|
89
|
+
static constexpr int kAffinityCapacity = 2;
|
|
90
|
+
/// Extracted value capacity: the same for the extracted value.
|
|
91
|
+
static constexpr int kAffinityExtractedValueCapacity = 3;
|
|
92
|
+
|
|
67
93
|
/// Freely copyable: a compiled mask is immutable and shared, so a copy is a
|
|
68
94
|
/// refcount bump. That also lets Swift and Kotlin hold one as a plain value.
|
|
69
95
|
MaskEngine();
|
|
@@ -90,6 +116,25 @@ public:
|
|
|
90
116
|
/// `characterSet` is every character that slot accepts.
|
|
91
117
|
void addNotation(const std::string& character, const std::string& characterSet, bool isOptional);
|
|
92
118
|
|
|
119
|
+
/// Stages alternative formats for the next `setFormat`, compiled with the
|
|
120
|
+
/// same notations. A malformed one is skipped rather than failing the rest.
|
|
121
|
+
void clearAffinityFormats();
|
|
122
|
+
void addAffinityFormat(const std::string& format);
|
|
123
|
+
/// One of the `kAffinity…` constants. Default: whole string.
|
|
124
|
+
void setAffinityStrategy(int strategy);
|
|
125
|
+
|
|
126
|
+
/// One of the `kTextCase…` constants, applied to input before masking.
|
|
127
|
+
void setTextCase(int textCase);
|
|
128
|
+
/// Replaces `from` with `to` in the input before masking, e.g. a Cyrillic
|
|
129
|
+
/// "С" with a Latin "C", or "," with "." for a decimal mask. Each is one
|
|
130
|
+
/// character (its first code point); an empty `to` drops the character.
|
|
131
|
+
void clearCharacterMap();
|
|
132
|
+
void addCharacterMapping(const std::string& from, const std::string& to);
|
|
133
|
+
|
|
134
|
+
/// The character the tail placeholder shows for each empty slot, e.g. "_".
|
|
135
|
+
/// Empty (the default): the slot's own notation character ("0", "a", "-").
|
|
136
|
+
void setSlotPlaceholder(const std::string& character);
|
|
137
|
+
|
|
93
138
|
/// False until a valid format has been set; `apply` then passes text through.
|
|
94
139
|
bool isActive() const;
|
|
95
140
|
|
|
@@ -121,7 +166,24 @@ private:
|
|
|
121
166
|
std::vector<std::unique_ptr<State>> arena;
|
|
122
167
|
const State* initial = nullptr;
|
|
123
168
|
std::vector<Notation> notations;
|
|
169
|
+
/// Characters the format can hold at most (literals included), and value
|
|
170
|
+
/// characters; `kUnbounded` with an ellipsis.
|
|
171
|
+
int textCapacity = 0;
|
|
172
|
+
int valueCapacity = 0;
|
|
173
|
+
/// The constants before the first slot, e.g. "+63 " for "+63 [000]".
|
|
174
|
+
std::vector<uint32_t> leadingConstants;
|
|
124
175
|
};
|
|
176
|
+
static constexpr int kUnbounded = 1 << 30;
|
|
177
|
+
|
|
178
|
+
static std::shared_ptr<const Compiled> compileFormat(const std::string& format,
|
|
179
|
+
const std::vector<Notation>& notations);
|
|
180
|
+
Result applyCompiled(const Compiled& compiled, const std::vector<uint32_t>& input, int caret, bool caretForward,
|
|
181
|
+
bool autocomplete, bool autoSkip) const;
|
|
182
|
+
std::vector<uint32_t> prepareInput(const std::vector<uint32_t>& input, int* caret) const;
|
|
183
|
+
int score(const Compiled& compiled, const Result& result, const std::vector<uint32_t>& text,
|
|
184
|
+
const std::vector<uint32_t>& values) const;
|
|
185
|
+
std::vector<uint32_t> withoutRepeatedPrefix(const std::vector<uint32_t>& text, int start, int end,
|
|
186
|
+
const std::vector<uint32_t>& inserted) const;
|
|
125
187
|
|
|
126
188
|
static const State* compile(Compiled& out, const std::vector<uint32_t>& format, size_t index, bool valuable,
|
|
127
189
|
bool fixed, uint32_t lastCharacter, bool* ok);
|
|
@@ -130,7 +192,13 @@ private:
|
|
|
130
192
|
const Notation** notation);
|
|
131
193
|
|
|
132
194
|
std::shared_ptr<const Compiled> compiled_;
|
|
195
|
+
std::vector<std::shared_ptr<const Compiled>> alternatives_;
|
|
133
196
|
std::vector<Notation> staged_;
|
|
197
|
+
std::vector<std::string> stagedAffinityFormats_;
|
|
198
|
+
int affinityStrategy_ = kAffinityWholeString;
|
|
199
|
+
int textCase_ = kTextCaseNone;
|
|
200
|
+
std::vector<std::pair<uint32_t, uint32_t>> characterMap_; // to == 0: drop
|
|
201
|
+
uint32_t slotPlaceholder_ = 0;
|
|
134
202
|
};
|
|
135
203
|
|
|
136
204
|
} // namespace margelo::nitro::nitroinput
|
|
@@ -94,6 +94,12 @@ final class HybridNitroInputView: HybridNitroInputViewSpec, RecyclableView {
|
|
|
94
94
|
var maskNotations: [NitroInputNotation] = [] { didSet { markConfigDirty() } }
|
|
95
95
|
var maskAutocomplete: Bool = true { didSet { markConfigDirty() } }
|
|
96
96
|
var maskAutoSkip: Bool = false { didSet { markConfigDirty() } }
|
|
97
|
+
var maskAffinityFormats: [String] = [] { didSet { markConfigDirty() } }
|
|
98
|
+
var maskAffinityStrategy: NitroInputMaskAffinity = .wholestring { didSet { markConfigDirty() } }
|
|
99
|
+
var maskTextCase: NitroInputTextCase = .none { didSet { markConfigDirty() } }
|
|
100
|
+
var maskCharacterMap: [NitroInputCharacterMapping] = [] { didSet { markConfigDirty() } }
|
|
101
|
+
var maskSlotPlaceholder: String = "" { didSet { markConfigDirty() } }
|
|
102
|
+
var keepPlaceholder: Bool = false { didSet { markConfigDirty() } }
|
|
97
103
|
var plain: Bool = false { didSet { markConfigDirty() } }
|
|
98
104
|
var fractionDigits: Double = 2 { didSet { markConfigDirty() } }
|
|
99
105
|
var maxIntegerDigits: Double = 15 { didSet { markConfigDirty() } }
|
|
@@ -151,6 +157,8 @@ final class HybridNitroInputView: HybridNitroInputViewSpec, RecyclableView {
|
|
|
151
157
|
var showSoftInputOnFocus: Bool = true { didSet { markConfigDirty() } }
|
|
152
158
|
var selectTextOnFocus: Bool = false { didSet { markConfigDirty() } }
|
|
153
159
|
var clearTextOnFocus: Bool = false { didSet { markConfigDirty() } }
|
|
160
|
+
var keyboardHandoffMs: Double = 0 { didSet { markConfigDirty() } }
|
|
161
|
+
var returnKeyBar: Bool = true { didSet { markConfigDirty() } }
|
|
154
162
|
var contextMenuHidden: Bool = false { didSet { markConfigDirty() } }
|
|
155
163
|
var spellCheck: Bool = true { didSet { markConfigDirty() } }
|
|
156
164
|
var selectionStart: Double = -1 { didSet { markSelectionDirty() } }
|
|
@@ -189,6 +197,10 @@ final class HybridNitroInputView: HybridNitroInputViewSpec, RecyclableView {
|
|
|
189
197
|
onMain { self.inputView.blur() }
|
|
190
198
|
}
|
|
191
199
|
|
|
200
|
+
func prepareForUnmount() throws {
|
|
201
|
+
onMain { self.inputView.handOffKeyboardIfFocused() }
|
|
202
|
+
}
|
|
203
|
+
|
|
192
204
|
func clear() throws {
|
|
193
205
|
onMain {
|
|
194
206
|
self.flushConfigIfNeeded()
|
|
@@ -296,6 +308,12 @@ final class HybridNitroInputView: HybridNitroInputViewSpec, RecyclableView {
|
|
|
296
308
|
maskNotations = []
|
|
297
309
|
maskAutocomplete = true
|
|
298
310
|
maskAutoSkip = false
|
|
311
|
+
maskAffinityFormats = []
|
|
312
|
+
maskAffinityStrategy = .wholestring
|
|
313
|
+
maskTextCase = .none
|
|
314
|
+
maskCharacterMap = []
|
|
315
|
+
maskSlotPlaceholder = ""
|
|
316
|
+
keepPlaceholder = false
|
|
299
317
|
fractionDigits = 2
|
|
300
318
|
maxIntegerDigits = 15
|
|
301
319
|
groupingSeparator = ","
|
|
@@ -352,6 +370,8 @@ final class HybridNitroInputView: HybridNitroInputViewSpec, RecyclableView {
|
|
|
352
370
|
showSoftInputOnFocus = true
|
|
353
371
|
selectTextOnFocus = false
|
|
354
372
|
clearTextOnFocus = false
|
|
373
|
+
keyboardHandoffMs = 0
|
|
374
|
+
returnKeyBar = true
|
|
355
375
|
contextMenuHidden = false
|
|
356
376
|
spellCheck = true
|
|
357
377
|
selectionStart = -1
|
|
@@ -424,17 +444,22 @@ final class HybridNitroInputView: HybridNitroInputViewSpec, RecyclableView {
|
|
|
424
444
|
inputView.setSelection(start: start, end: end)
|
|
425
445
|
}
|
|
426
446
|
|
|
427
|
-
/// The `text` prop handshake:
|
|
428
|
-
///
|
|
429
|
-
///
|
|
447
|
+
/// The `text` prop handshake: once JS has seen every native edit
|
|
448
|
+
/// (`mostRecentEventCount` caught up with the native count), the field shows
|
|
449
|
+
/// `text`, like React Native's own `TextInput`. Compared with what the field
|
|
450
|
+
/// shows, not just the last value applied: a controlled parent that keeps
|
|
451
|
+
/// its value while the user types (a rejected edit) puts its text back.
|
|
452
|
+
/// `setText` leaves the field (and the caret) alone when the formatted
|
|
453
|
+
/// value is already what it shows. An uncontrolled field sends a count of 0,
|
|
454
|
+
/// so its initial text is never re-applied over what the user typed.
|
|
430
455
|
private func applyTextIfNeeded() {
|
|
431
456
|
guard textDirty else { return }
|
|
432
457
|
textDirty = false
|
|
433
|
-
guard text != lastAppliedText else { return }
|
|
434
458
|
snapshotLock.lock()
|
|
435
459
|
let nativeCount = snapshot.eventCount
|
|
436
460
|
snapshotLock.unlock()
|
|
437
461
|
guard mostRecentEventCount.isFinite, Int(mostRecentEventCount) >= nativeCount else { return }
|
|
462
|
+
guard text != lastAppliedText || text != inputView.text else { return }
|
|
438
463
|
lastAppliedText = text
|
|
439
464
|
inputView.setText(text, reason: .prop)
|
|
440
465
|
}
|
|
@@ -498,6 +523,12 @@ final class HybridNitroInputView: HybridNitroInputViewSpec, RecyclableView {
|
|
|
498
523
|
}
|
|
499
524
|
format.maskAutocomplete = maskAutocomplete
|
|
500
525
|
format.maskAutoSkip = maskAutoSkip
|
|
526
|
+
format.maskAffinityFormats = maskAffinityFormats
|
|
527
|
+
format.maskAffinityStrategy = Int(maskAffinityStrategy.rawValue)
|
|
528
|
+
format.maskTextCase = Int(maskTextCase.rawValue)
|
|
529
|
+
format.maskCharacterMap = maskCharacterMap.map { NitroInputView.MaskMapping(from: $0.from, to: $0.to) }
|
|
530
|
+
format.maskSlotPlaceholder = maskSlotPlaceholder
|
|
531
|
+
format.keepPlaceholder = keepPlaceholder
|
|
501
532
|
format.fractionDigits = Self.clampInt(fractionDigits, 0, 9, fallback: 2)
|
|
502
533
|
format.maxIntegerDigits = Self.clampInt(maxIntegerDigits, 1, 30, fallback: 15)
|
|
503
534
|
format.groupingSeparator = groupingSeparator
|
|
@@ -565,6 +596,8 @@ final class HybridNitroInputView: HybridNitroInputViewSpec, RecyclableView {
|
|
|
565
596
|
traits.showSoftInputOnFocus = showSoftInputOnFocus
|
|
566
597
|
traits.selectTextOnFocus = selectTextOnFocus
|
|
567
598
|
traits.clearTextOnFocus = clearTextOnFocus
|
|
599
|
+
traits.keyboardHandoffMs = keyboardHandoffMs.isFinite ? max(0, keyboardHandoffMs) : 0
|
|
600
|
+
traits.returnKeyBar = returnKeyBar
|
|
568
601
|
traits.contextMenuHidden = contextMenuHidden
|
|
569
602
|
traits.spellCheck = spellCheck && autoCorrect
|
|
570
603
|
|
|
@@ -50,6 +50,16 @@ static BOOL NitroInputEditorIsEditable(UIView *editor)
|
|
|
50
50
|
|
|
51
51
|
- (void)handleCommand:(const NSString *)commandName args:(const NSArray *)args
|
|
52
52
|
{
|
|
53
|
+
// The field's own focus()/blur(): they retry a declined focus, hold a focus
|
|
54
|
+
// asked for while the view has no window, and let a held keyboard go.
|
|
55
|
+
UIView *host = self.contentView;
|
|
56
|
+
SEL own = [(NSString *)commandName isEqualToString:@"focus"] ? NSSelectorFromString(@"nitroFocus")
|
|
57
|
+
: [(NSString *)commandName isEqualToString:@"blur"] ? NSSelectorFromString(@"nitroBlur")
|
|
58
|
+
: nil;
|
|
59
|
+
if (own != nil && [host respondsToSelector:own]) {
|
|
60
|
+
((void (*)(id, SEL))[host methodForSelector:own])(host, own);
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
53
63
|
UIView *editor = NitroInputFindEditor(self.contentView);
|
|
54
64
|
if (editor == nil) {
|
|
55
65
|
return;
|