@antscorp/antsomi-ui 1.3.7-beta.26 → 1.3.7-beta.28
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.
|
@@ -17,7 +17,7 @@ import '@yaireo/tagify/dist/tagify.css';
|
|
|
17
17
|
// Styled
|
|
18
18
|
import { TagTextArea, TagifyWrapper, WrapperPlaceHolder } from './styled';
|
|
19
19
|
// Utils
|
|
20
|
-
import { parseTagStringToTagify, convertInputStringToOriginal, emojiManufacturer, getEmojiTag, isPersonalizeTagType, generateTagContent, unescapeString, hasLineBreak, selectRange, isTagClickable, findURLInTextNodes, getAttributesString, isAnchorNodeChildOfElement, isShortLinkTagType, isCustomTagType, sanitizeTagAttributes, getTagAttributes, applyTagAttributes, getTagContentAttributes, isCaretAtEndOfTextNodeWithNextTag, getCurrentSelectionAndCloneRange, handleEnterWithNextTag, handleTextNodeBackspace, extractTagValues, } from './utils';
|
|
20
|
+
import { parseTagStringToTagify, convertInputStringToOriginal, emojiManufacturer, getEmojiTag, isPersonalizeTagType, generateTagContent, unescapeString, hasLineBreak, selectRange, isTagClickable, findURLInTextNodes, getAttributesString, isAnchorNodeChildOfElement, isShortLinkTagType, isCustomTagType, sanitizeTagAttributes, getTagAttributes, applyTagAttributes, getTagContentAttributes, isCaretAtEndOfTextNodeWithNextTag, getCurrentSelectionAndCloneRange, handleEnterWithNextTag, handleTextNodeBackspace, extractTagValues, preventUndoRedo, } from './utils';
|
|
21
21
|
import { acceptablePatternChecking, detectURLRegex, getCachedRegex, getCustomTagId, getPersonalizeTagInfo, getShortLinkTagInfo, patternHandlers, } from './patternHandlers';
|
|
22
22
|
// Constants
|
|
23
23
|
import { DETECT_LINK, EMOJI, PERSONALIZE_PTN, SHORT_LINK, SHORT_LINK_PTN, SHORT_LINK_V2, TAG_TYPE, UNSUBSCRIBE_WHATSAPP, defaultCssVariables, tagifyDefaultProps, TAG_CUSTOM_ATTRIBUTES, } from './constants';
|
|
@@ -852,7 +852,7 @@ const TagifyInput = forwardRef((props, ref) => {
|
|
|
852
852
|
onContentEditable(!readonlyText);
|
|
853
853
|
}, [readonlyText, onContentEditable]);
|
|
854
854
|
useEffect(() => {
|
|
855
|
-
if (tagifyRef.current && tagLength && _.isFunction(onTagRemove)) {
|
|
855
|
+
if (tagifyRef.current && typeof tagLength === 'number' && _.isFunction(onTagRemove)) {
|
|
856
856
|
// Because the remove tag event is not triggered when the tag is removed with Backspace or drag selection tags
|
|
857
857
|
// we need to listen to the input element to detect when a tag is removed
|
|
858
858
|
let mutationQueue = [];
|
|
@@ -1001,6 +1001,9 @@ const TagifyInput = forwardRef((props, ref) => {
|
|
|
1001
1001
|
tagifyInstance.on('add', onAddTag);
|
|
1002
1002
|
if (onBlur)
|
|
1003
1003
|
tagifyInstance.on('blur', onBlur);
|
|
1004
|
+
if (tagifyInstance.DOM.input) {
|
|
1005
|
+
tagifyInstance.DOM.input.addEventListener('keydown', preventUndoRedo);
|
|
1006
|
+
}
|
|
1004
1007
|
}
|
|
1005
1008
|
// Off listen to Tagify events
|
|
1006
1009
|
return () => {
|
|
@@ -1014,6 +1017,9 @@ const TagifyInput = forwardRef((props, ref) => {
|
|
|
1014
1017
|
tagifyInstance.off('add', onAddTag);
|
|
1015
1018
|
if (onBlur)
|
|
1016
1019
|
tagifyInstance.off('blur', onBlur);
|
|
1020
|
+
if (tagifyInstance.DOM.input) {
|
|
1021
|
+
tagifyInstance.DOM.input.removeEventListener('keydown', preventUndoRedo);
|
|
1022
|
+
}
|
|
1017
1023
|
}
|
|
1018
1024
|
};
|
|
1019
1025
|
}, [
|
|
@@ -204,3 +204,6 @@ export declare const handleTextNodeBackspace: (range: Range) => void;
|
|
|
204
204
|
export declare const handleEnterWithNextTag: (range: Range) => void;
|
|
205
205
|
export declare const removeInvisibleChars: (str: string) => string;
|
|
206
206
|
export declare const extractTagValues: (tagify: Tagify<TagDataCustomize>) => TagValues;
|
|
207
|
+
export declare function preventUndoRedo(e: CustomEvent<Tagify.KeydownEventData<TagDataCustomize>>['detail']['event'], { disableRedo }?: {
|
|
208
|
+
disableRedo?: boolean | undefined;
|
|
209
|
+
}): void;
|
|
@@ -805,3 +805,13 @@ export const extractTagValues = (tagify) => {
|
|
|
805
805
|
value: tagify.getInputValue(),
|
|
806
806
|
};
|
|
807
807
|
};
|
|
808
|
+
export function preventUndoRedo(e, { disableRedo = false } = {}) {
|
|
809
|
+
const key = e.key.toLowerCase();
|
|
810
|
+
const isUndo = (e.ctrlKey || e.metaKey) && key === 'z';
|
|
811
|
+
const isRedo = (disableRedo && (e.ctrlKey || e.metaKey) && key === 'y') ||
|
|
812
|
+
((e.ctrlKey || e.metaKey) && e.shiftKey && key === 'z');
|
|
813
|
+
if (isUndo || isRedo) {
|
|
814
|
+
e.preventDefault();
|
|
815
|
+
e.stopPropagation();
|
|
816
|
+
}
|
|
817
|
+
}
|