frst-components 0.22.15 → 0.22.17
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/dist/index.js
CHANGED
|
@@ -3470,6 +3470,7 @@ const useInputHook = ({ limit, placeholder, onSendMentions, onContentFormat, onC
|
|
|
3470
3470
|
}
|
|
3471
3471
|
countChars();
|
|
3472
3472
|
createFormatAndTextContentToSaveComment();
|
|
3473
|
+
resizeDiv();
|
|
3473
3474
|
}
|
|
3474
3475
|
};
|
|
3475
3476
|
//create a method that increase the size of the div as the scroll height increases
|
|
@@ -3518,20 +3519,23 @@ const useInputHook = ({ limit, placeholder, onSendMentions, onContentFormat, onC
|
|
|
3518
3519
|
return;
|
|
3519
3520
|
// Get the text before the cursor
|
|
3520
3521
|
const completeText = range.startContainer.textContent;
|
|
3521
|
-
textBeforeCursor = range.startContainer.textContent.substring(0, range.startOffset);
|
|
3522
3522
|
// Find the last index of "@" in the text before the cursor
|
|
3523
3523
|
const atIndex = completeText.lastIndexOf('@');
|
|
3524
|
+
textBeforeCursor = range.startContainer.textContent.substring(atIndex, range.startOffset);
|
|
3524
3525
|
hasSpaceBeForeKey = completeText.substring(atIndex - 1, atIndex).trim() === "";
|
|
3525
3526
|
console.log(`teste - completeText = ${completeText}`);
|
|
3526
3527
|
console.log(`teste textBeforeCursor ${textBeforeCursor}`);
|
|
3527
3528
|
console.log(`teste - atIndex = ${atIndex}`);
|
|
3528
3529
|
console.log(`teste - spaceBefore = ${completeText.substring(atIndex - 1, atIndex).trim() === ""}`);
|
|
3529
3530
|
console.log(`teste hasSpaceBeForeKey ${hasSpaceBeForeKey}`);
|
|
3531
|
+
console.log(`teste textBeforeCursor = @ ? ${textBeforeCursor === "@"}`);
|
|
3530
3532
|
if (hasSpaceBeForeKey || textBeforeCursor === "@") {
|
|
3531
3533
|
if (atIndex !== -1) {
|
|
3532
3534
|
// Get the characters after the last "@"
|
|
3533
3535
|
const afterAt = completeText.substring(atIndex);
|
|
3534
|
-
|
|
3536
|
+
console.log(`teste afterAt = ${afterAt}`);
|
|
3537
|
+
if (afterAt.length > 1 || event.key === "@" || textBeforeCursor === "@") {
|
|
3538
|
+
console.log(`teste hasKeyPresent ${hasKeyPresent}`);
|
|
3535
3539
|
hasKeyPresent = true;
|
|
3536
3540
|
}
|
|
3537
3541
|
inputSearch = afterAt.replace('@', '');
|
|
@@ -3554,6 +3558,7 @@ const useInputHook = ({ limit, placeholder, onSendMentions, onContentFormat, onC
|
|
|
3554
3558
|
!!onChange && onChange(inputSearch);
|
|
3555
3559
|
}
|
|
3556
3560
|
else {
|
|
3561
|
+
console.log(`teste resultado foi ${hasSpaceBeForeKey && hasKeyPresent} e textBeforeCursor = @ ${textBeforeCursor === "@"}`);
|
|
3557
3562
|
console.log(`teste, não chamou o backend ${inputSearch}`);
|
|
3558
3563
|
}
|
|
3559
3564
|
countChars();
|
|
@@ -3575,14 +3580,16 @@ const useInputHook = ({ limit, placeholder, onSendMentions, onContentFormat, onC
|
|
|
3575
3580
|
const clearDivContent = () => {
|
|
3576
3581
|
if (!divInputRef.current)
|
|
3577
3582
|
return;
|
|
3578
|
-
console.log(
|
|
3579
|
-
console.log(
|
|
3583
|
+
console.log(`placeholder primeiro if divInputRef.current.childNodes.length === 0 && !focus resultado = ${divInputRef.current.childNodes.length === 0 && !focus}`);
|
|
3584
|
+
console.log(`placeholder segundo if divInputRef.current.childNodes.length >= 1 resultado = ${divInputRef.current.childNodes.length >= 1}`);
|
|
3580
3585
|
if ((divInputRef.current.childNodes.length === 0 && !focus)) {
|
|
3586
|
+
console.log(`placeholder vou incluir o placeholder`);
|
|
3581
3587
|
// create a textnode with the placeholder
|
|
3582
3588
|
divInputRef.current.innerText = placeholder;
|
|
3583
3589
|
setPlaceholder(true);
|
|
3584
3590
|
}
|
|
3585
3591
|
else if (!focus && divInputRef.current.childNodes.length >= 1) {
|
|
3592
|
+
console.log(`placeholder vou incluir o placeholder`);
|
|
3586
3593
|
// loop over all child element and check if they are empty
|
|
3587
3594
|
let isEmpty = true;
|
|
3588
3595
|
divInputRef.current.childNodes.forEach((child) => {
|
|
@@ -3590,6 +3597,10 @@ const useInputHook = ({ limit, placeholder, onSendMentions, onContentFormat, onC
|
|
|
3590
3597
|
isEmpty = false;
|
|
3591
3598
|
setPlaceholder(false);
|
|
3592
3599
|
}
|
|
3600
|
+
else if (child.textContent === placeholder) {
|
|
3601
|
+
console.log(`placeholder child.textContent === placeholder resultado = ${child.textContent === placeholder}`);
|
|
3602
|
+
divInputRef.current.blur();
|
|
3603
|
+
}
|
|
3593
3604
|
});
|
|
3594
3605
|
console.log('placeholder isEmpty = ', isEmpty);
|
|
3595
3606
|
// if they are empty show the placeholder
|
|
@@ -3600,6 +3611,7 @@ const useInputHook = ({ limit, placeholder, onSendMentions, onContentFormat, onC
|
|
|
3600
3611
|
}
|
|
3601
3612
|
}
|
|
3602
3613
|
else if (divInputRef.current.innerText === placeholder) {
|
|
3614
|
+
console.log(`placeholder terceiro divInputRef.current.innerText === placeholder resultado = ${divInputRef.current.innerText === placeholder}`);
|
|
3603
3615
|
// create a paragraph node
|
|
3604
3616
|
divInputRef.current.innerHTML = '';
|
|
3605
3617
|
// clear complete the div
|
|
@@ -3611,6 +3623,7 @@ const useInputHook = ({ limit, placeholder, onSendMentions, onContentFormat, onC
|
|
|
3611
3623
|
divInputRef.current.appendChild(p);
|
|
3612
3624
|
console.log(`placeholder divInputRef.current.innerHtml= ${divInputRef.current.innerHTML}`);
|
|
3613
3625
|
setPlaceholder(false);
|
|
3626
|
+
divInputRef.current.blur();
|
|
3614
3627
|
}
|
|
3615
3628
|
};
|
|
3616
3629
|
React.useEffect(() => {
|
|
@@ -3620,7 +3633,7 @@ const useInputHook = ({ limit, placeholder, onSendMentions, onContentFormat, onC
|
|
|
3620
3633
|
};
|
|
3621
3634
|
}, []);
|
|
3622
3635
|
React.useEffect(() => {
|
|
3623
|
-
if (!replyMentionedUser)
|
|
3636
|
+
if (!replyMentionedUser || !divInputRef?.current)
|
|
3624
3637
|
return;
|
|
3625
3638
|
divInputRef.current?.focus();
|
|
3626
3639
|
const selection = window.getSelection();
|
|
@@ -3632,7 +3645,6 @@ const useInputHook = ({ limit, placeholder, onSendMentions, onContentFormat, onC
|
|
|
3632
3645
|
const spaceNode = document.createTextNode('\u00A0'); // Unicode for non-breaking space
|
|
3633
3646
|
addMentionToRangeAndSpaceNode(range, spaceNode, mentionedUser);
|
|
3634
3647
|
createNewRangeAndMoveCursorToTheEnd(selection, spaceNode);
|
|
3635
|
-
divInputRef.current?.focus();
|
|
3636
3648
|
}
|
|
3637
3649
|
}, [replyMentionedUser]);
|
|
3638
3650
|
React.useEffect(() => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useInputHook.d.ts","sourceRoot":"","sources":["../../../../src/components/input-comment/useInputHook.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAsC,MAAM,OAAO,CAAC;AAE3D,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAE/B,UAAU,UAAU;IAChB,KAAK,EAAE,MAAM,CAAA;IACb,WAAW,EAAE,MAAM,CAAA;IACnB,cAAc,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,IAAI,CAAA;IAC5C,eAAe,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAA;IAC1C,iBAAiB,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAA;IAC5C,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,GAAG,KAAK,IAAI,CAAA;IAC/B,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,kBAAkB,CAAC,EAAE,IAAI,CAAA;CAC5B;AAED,eAAO,MAAM,YAAY,oHAAqH,UAAU;yBA2HxH,mBAAmB;;;;;;;;;8BA/Ed,IAAI;;;;
|
|
1
|
+
{"version":3,"file":"useInputHook.d.ts","sourceRoot":"","sources":["../../../../src/components/input-comment/useInputHook.tsx"],"names":[],"mappings":"AA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