@antscorp/antsomi-ui 1.3.3-beta.35 → 1.3.3-beta.37
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/es/components/atoms/Alert/Alert.js +13 -6
- package/es/components/atoms/Button/index.js +1 -1
- package/es/components/atoms/Button/test.js +6 -6
- package/es/components/atoms/DividerPure/DividerPure.js +4 -15
- package/es/components/atoms/DividerPure/styled.js +36 -6
- package/es/components/atoms/Empty/Empty.js +1 -1
- package/es/components/atoms/FloatButton/index.js +1 -1
- package/es/components/atoms/Grid/Grid.js +2 -2
- package/es/components/atoms/Icon/index.js +28 -15
- package/es/components/atoms/Input/Input.js +21 -32
- package/es/components/atoms/Input/styled.js +102 -12
- package/es/components/atoms/InputDynamic/EditCaretPositioning.js +13 -13
- package/es/components/atoms/InputDynamic/InputDynamic.d.ts +2 -1
- package/es/components/atoms/InputDynamic/InputDynamic.js +83 -97
- package/es/components/atoms/InputDynamic/PopupShortLink.js +20 -21
- package/es/components/atoms/InputDynamic/styled.d.ts +1 -1
- package/es/components/atoms/InputDynamic/styled.js +275 -13
- package/es/components/atoms/InputDynamic/utils.js +104 -114
- package/es/components/atoms/InputNumber/InputNumber.js +3 -14
- package/es/components/atoms/MobileFrame/MobileFrame.js +3 -14
- package/es/components/atoms/MobileFrame/constants.js +1 -1
- package/es/components/atoms/MobileFrame/styled.js +29 -8
- package/es/components/atoms/Pagination/Pagination.js +1 -1
- package/es/components/atoms/Popover/Popover.js +1 -1
- package/es/components/atoms/Popover/styled.js +1 -6
- package/es/components/atoms/PreviewTabs/PreviewTabs.js +20 -31
- package/es/components/atoms/PreviewTabs/styled.js +71 -10
- package/es/components/atoms/Progress/Progress.js +1 -1
- package/es/components/atoms/Radio/index.js +18 -8
- package/es/components/atoms/Rate/Rate.js +1 -1
- package/es/components/atoms/RateV2/RateV2.js +24 -30
- package/es/components/atoms/RequiredLabel/index.js +3 -14
- package/es/components/atoms/RequiredLabel/styled.js +5 -7
- package/es/components/atoms/ScrollBox/index.js +14 -25
- package/es/components/atoms/Segmented/Segmented.js +1 -1
- package/es/components/atoms/Skeleton/Skeleton.js +1 -1
- package/es/components/atoms/Slider/index.js +7 -18
- package/es/components/atoms/Slider/styled.js +38 -10
- package/es/components/atoms/SliderV2/index.js +10 -21
- package/es/components/atoms/Space/Space.js +6 -7
- package/es/components/atoms/Spin/Spin.d.ts +2 -1
- package/es/components/atoms/Spin/Spin.js +3 -14
- package/es/components/atoms/Spin/styled.d.ts +1 -1
- package/es/components/atoms/Spin/styled.js +3 -6
- package/es/components/atoms/Statistic/Statistic.js +1 -1
- package/es/components/atoms/Steps/Steps.js +1 -1
- package/es/components/atoms/Switch/Switch.js +1 -1
- package/es/components/atoms/Text/index.js +4 -15
- package/es/components/atoms/Text/styled.js +40 -11
- package/es/components/atoms/Timeline/Timeline.js +1 -1
- package/es/components/atoms/Watermark/Watermark.js +1 -1
- package/es/components/common/ConfigProvider/ConfigProvider.js +4 -15
- package/es/components/common/ConfigProvider/GlobalStyle.js +569 -8
- package/es/components/icons/AccountCircle.js +2 -13
- package/es/components/icons/AddShoppingCart.js +2 -13
- package/es/components/icons/ArrowGrowIcon.d.ts +2 -1
- package/es/components/icons/ArrowGrowIcon.js +2 -13
- package/es/components/icons/AssignmentInd.js +2 -13
- package/es/components/icons/AudioRecordIcon.d.ts +2 -1
- package/es/components/icons/AudioRecordIcon.js +2 -13
- package/es/components/icons/BugIcon.d.ts +2 -1
- package/es/components/icons/BugIcon.js +2 -13
- package/es/components/icons/Call.js +2 -13
- package/es/components/icons/CameraIcon.d.ts +2 -1
- package/es/components/icons/CameraIcon.js +2 -13
- package/es/components/icons/CaptureIcon.d.ts +2 -1
- package/es/components/icons/CaptureIcon.js +2 -13
- package/es/components/icons/Category.js +2 -13
- package/es/components/icons/ChatBubbleOutline.js +2 -13
- package/es/components/icons/CheckSlimIcon.d.ts +2 -1
- package/es/components/icons/CheckSlimIcon.js +2 -13
- package/es/components/icons/CircleNotifications.js +2 -13
- package/es/components/icons/CloseIcon.d.ts +2 -1
- package/es/components/icons/CloseIcon.js +2 -13
- package/es/components/icons/CommentIcon.d.ts +2 -1
- package/es/components/icons/CommentIcon.js +2 -13
- package/es/components/icons/ConfirmationNumber.js +2 -13
- package/es/components/icons/DesktopWindows.js +2 -13
- package/es/components/icons/EventIcon.d.ts +2 -1
- package/es/components/icons/EventIcon.js +2 -13
- package/es/components/icons/FactCheck.js +2 -13
- package/es/components/icons/FreeDrawIcon.d.ts +2 -1
- package/es/components/icons/FreeDrawIcon.js +2 -13
- package/es/components/icons/GPTIcon.d.ts +2 -1
- package/es/components/icons/GPTIcon.js +2 -2
- package/es/components/icons/GPTIconV2.d.ts +2 -1
- package/es/components/icons/GPTIconV2.js +2 -2
- package/es/components/icons/GPTIconV3.d.ts +2 -1
- package/es/components/icons/GPTIconV3.js +2 -13
- package/es/components/icons/HighlightIcon.d.ts +2 -1
- package/es/components/icons/HighlightIcon.js +2 -13
- package/es/components/icons/HightlightAlt.js +2 -13
- package/es/components/icons/HowToReg.js +2 -13
- package/es/components/icons/IdeaIcon.d.ts +2 -1
- package/es/components/icons/IdeaIcon.js +2 -13
- package/es/components/icons/Interactive.js +2 -13
- package/es/components/icons/InvisibleIcon.d.ts +2 -1
- package/es/components/icons/InvisibleIcon.js +2 -13
- package/es/components/icons/List.js +2 -13
- package/es/components/icons/LocalMallIcon.js +2 -13
- package/es/components/icons/MobileFriendly.js +2 -13
- package/es/components/icons/MuteIcon.d.ts +2 -1
- package/es/components/icons/MuteIcon.js +2 -13
- package/es/components/icons/NotificationsActive.js +2 -13
- package/es/components/icons/OpenUrlIcon.d.ts +2 -1
- package/es/components/icons/OpenUrlIcon.js +2 -13
- package/es/components/icons/PauseIcon.d.ts +2 -1
- package/es/components/icons/PauseIcon.js +2 -13
- package/es/components/icons/Payment.js +2 -13
- package/es/components/icons/PersonAddDisabled.js +2 -13
- package/es/components/icons/PhoneCallback.js +2 -13
- package/es/components/icons/PlaneIcon.d.ts +2 -1
- package/es/components/icons/PlaneIcon.js +2 -13
- package/es/components/icons/Preview.js +2 -13
- package/es/components/icons/Redeem.js +2 -13
- package/es/components/icons/RemoveRedEye.js +2 -13
- package/es/components/icons/RemoveShoppingCart.js +2 -13
- package/es/components/icons/RequestIcon.d.ts +2 -1
- package/es/components/icons/RequestIcon.js +2 -13
- package/es/components/icons/Search.js +2 -13
- package/es/components/icons/ShoppingBag.js +2 -13
- package/es/components/icons/ShoppingCart.js +2 -13
- package/es/components/icons/StopRecordIcon.d.ts +2 -1
- package/es/components/icons/StopRecordIcon.js +2 -13
- package/es/components/icons/Store.js +2 -13
- package/es/components/icons/UserIcon.d.ts +2 -1
- package/es/components/icons/UserIcon.js +2 -13
- package/es/components/icons/VerticalDotsIcon.d.ts +2 -1
- package/es/components/icons/VerticalDotsIcon.js +2 -13
- package/es/components/icons/WarningIcon.d.ts +2 -1
- package/es/components/icons/WarningIcon.js +2 -13
- package/es/components/icons/Web.js +2 -13
- package/es/components/icons/WebAsset.js +2 -13
- package/es/components/molecules/AlignSetting/index.js +9 -20
- package/es/components/molecules/AlignSetting/styled.js +5 -6
- package/es/components/molecules/AlignSetting/utils.js +2 -2
- package/es/components/molecules/CaptureScreen/CaptureScreen.d.ts +2 -1
- package/es/components/molecules/CaptureScreen/CaptureScreen.js +240 -269
- package/es/components/molecules/CaptureScreen/components/CommentBox/CommentBox.d.ts +2 -1
- package/es/components/molecules/CaptureScreen/components/CommentBox/CommentBox.js +25 -36
- package/es/components/molecules/CaptureScreen/components/CommentBox/styled.js +129 -15
- package/es/components/molecules/CaptureScreen/components/Cursor/Cursor.d.ts +2 -1
- package/es/components/molecules/CaptureScreen/components/Cursor/Cursor.js +2 -2
- package/es/components/molecules/CaptureScreen/components/Cursor/styled.js +73 -10
- package/es/components/molecules/CaptureScreen/constants.js +7 -7
- package/es/components/molecules/CaptureScreen/hooks/useImageEditor.d.ts +1 -1
- package/es/components/molecules/CaptureScreen/hooks/useImageEditor.js +23 -23
- package/es/components/molecules/CaptureScreen/styled.js +247 -28
- package/es/components/molecules/CaptureScreen/themes/black.js +1 -1
- package/es/components/molecules/CaptureScreen/themes/white.js +1 -1
- package/es/components/molecules/CaptureScreen/utils.js +29 -32
- package/es/components/molecules/Card/Card.js +1 -1
- package/es/components/molecules/ChatBox/ChatBox.js +81 -147
- package/es/components/molecules/ChatBox/MessageItem.js +20 -22
- package/es/components/molecules/ChatBox/constants.js +2 -2
- package/es/components/molecules/ChatBox/styled.js +275 -13
- package/es/components/molecules/Collapse/Collapse.js +3 -4
- package/es/components/molecules/ColorPicker/ChromePicker/index.js +1 -1
- package/es/components/molecules/ColorPicker/ChromePicker/styled.js +11 -6
- package/es/components/molecules/ColorPicker/CustomPicker/index.js +21 -33
- package/es/components/molecules/ColorPicker/CustomPicker/styled.js +95 -14
- package/es/components/molecules/ColorPicker/SketchPicker/index.js +1 -12
- package/es/components/molecules/ColorPicker/SketchPicker/styled.js +6 -6
- package/es/components/molecules/ColorPicker/index.js +17 -17
- package/es/components/molecules/ColorPicker/styled.js +8 -6
- package/es/components/molecules/ColorSetting/index.js +15 -35
- package/es/components/molecules/ColorSetting/styled.js +36 -9
- package/es/components/molecules/DatePicker/DatePicker.js +1 -1
- package/es/components/molecules/DatePicker/components/AdvancedPicker/AdvancedPicker.js +112 -146
- package/es/components/molecules/DatePicker/components/AdvancedPicker/constants.js +10 -10
- package/es/components/molecules/DatePicker/components/AdvancedPicker/styled.js +45 -12
- package/es/components/molecules/DatePicker/components/AdvancedPicker/utils.js +3 -8
- package/es/components/molecules/DatePicker/components/AdvancedRangePicker/AdvancedRangePicker.js +9 -28
- package/es/components/molecules/DatePicker/components/AdvancedRangePicker/constants.js +1 -1
- package/es/components/molecules/Drawer/Drawer.js +1 -1
- package/es/components/molecules/EdgeSetting/index.js +45 -69
- package/es/components/molecules/EdgeSetting/styled.js +13 -8
- package/es/components/molecules/FontFamilySelect/constants.js +1 -1
- package/es/components/molecules/FontFamilySelect/index.js +10 -33
- package/es/components/molecules/FontSetting/constants.js +2 -2
- package/es/components/molecules/FontSetting/index.js +22 -36
- package/es/components/molecules/FontWeightSelect/constants.js +1 -1
- package/es/components/molecules/FontWeightSelect/index.js +9 -32
- package/es/components/molecules/GradientSetting/index.js +35 -55
- package/es/components/molecules/GradientSetting/styled.js +58 -6
- package/es/components/molecules/IconSelection/components/Icon/index.js +8 -19
- package/es/components/molecules/IconSelection/constants.js +31 -37
- package/es/components/molecules/IconSelection/index.js +43 -56
- package/es/components/molecules/IconSelection/styled.js +74 -10
- package/es/components/molecules/IconSelection/types.js +1 -3
- package/es/components/molecules/IconSelection/utils.js +3 -3
- package/es/components/molecules/InputNumber/index.js +12 -23
- package/es/components/molecules/InputNumberWithUnit/index.js +5 -19
- package/es/components/molecules/InputNumberWithUnit/styled.js +15 -6
- package/es/components/molecules/InputSearch/index.js +3 -14
- package/es/components/molecules/InputSearch/styled.js +43 -6
- package/es/components/molecules/Modal/Modal.d.ts +2 -2
- package/es/components/molecules/Modal/Modal.js +8 -23
- package/es/components/molecules/Modal/styled.d.ts +1 -1
- package/es/components/molecules/Modal/styled.js +69 -17
- package/es/components/molecules/ModalV2/ModalV2.js +6 -17
- package/es/components/molecules/ModalV2/styled.d.ts +1 -1
- package/es/components/molecules/ModalV2/styled.js +19 -6
- package/es/components/molecules/Popconfirm/Popconfirm.js +1 -1
- package/es/components/molecules/PopupDraggable/PopupDraggable.js +13 -25
- package/es/components/molecules/PopupDraggable/styled.js +47 -11
- package/es/components/molecules/PreviewModal/PreviewModal.js +5 -16
- package/es/components/molecules/PreviewModal/styled.js +30 -9
- package/es/components/molecules/RadioGroup/index.js +3 -14
- package/es/components/molecules/RadioGroup/styled.js +11 -7
- package/es/components/molecules/ResizeGrid/ResizeGrid.js +275 -338
- package/es/components/molecules/ResizeGrid/components/Cell/Cell.js +23 -37
- package/es/components/molecules/ResizeGrid/components/Cell/styled.js +78 -6
- package/es/components/molecules/ResizeGrid/constant.js +26 -37
- package/es/components/molecules/ResizeGrid/styled.js +54 -9
- package/es/components/molecules/Result/Result.js +1 -1
- package/es/components/molecules/RichMenuBlock/RichMenuBlock.js +23 -34
- package/es/components/molecules/RichMenuBlock/RichMenuCell/index.js +11 -11
- package/es/components/molecules/RichMenuBlock/RichMenuCell/styled.js +34 -18
- package/es/components/molecules/RichMenuBlock/constants.js +1 -1
- package/es/components/molecules/RichMenuBlock/styled.js +15 -16
- package/es/components/molecules/RichMenuChatBar/RichMenuChatBar.js +6 -17
- package/es/components/molecules/RichMenuChatBar/TypingChat/index.js +3 -3
- package/es/components/molecules/RichMenuChatBar/TypingChat/styled.js +43 -8
- package/es/components/molecules/RichMenuChatBar/styled.js +25 -10
- package/es/components/molecules/RichMenuMobileView/RichMenuMobileView.js +7 -22
- package/es/components/molecules/RichMenuMobileView/styled.js +18 -11
- package/es/components/molecules/Select/Select.d.ts +4 -2
- package/es/components/molecules/Select/Select.js +9 -20
- package/es/components/molecules/Select/Test.d.ts +2 -1
- package/es/components/molecules/Select/Test.js +2 -2
- package/es/components/molecules/Select/styled.js +34 -7
- package/es/components/molecules/SettingWrapper/index.js +2 -2
- package/es/components/molecules/SettingWrapper/styled.js +15 -9
- package/es/components/molecules/SettingWrapperPopover/index.js +4 -16
- package/es/components/molecules/SliderWithInputNumber/index.js +8 -19
- package/es/components/molecules/SliderWithInputNumber/styled.js +3 -6
- package/es/components/molecules/TextDecorationSelect/constants.js +1 -1
- package/es/components/molecules/TextDecorationSelect/index.js +9 -32
- package/es/components/molecules/TextTransformSelect/constants.js +1 -1
- package/es/components/molecules/TextTransformSelect/index.js +9 -32
- package/es/components/molecules/TreeSelect/TreeSelect.d.ts +4 -2
- package/es/components/molecules/TreeSelect/TreeSelect.js +1 -1
- package/es/components/molecules/UploadImage/MediaIcon.d.ts +2 -1
- package/es/components/molecules/UploadImage/MediaIcon.js +2 -2
- package/es/components/molecules/UploadImage/index.js +182 -280
- package/es/components/molecules/UploadImage/styled.js +129 -16
- package/es/components/organism/Help/Help.js +422 -530
- package/es/components/organism/Help/constants.js +11 -12
- package/es/components/organism/Help/styled.d.ts +6 -2
- package/es/components/organism/Help/styled.js +257 -48
- package/es/components/organism/Help/utils.js +11 -11
- package/es/components/organism/PositionSetting/config.js +2 -2
- package/es/components/organism/PositionSetting/index.js +15 -27
- package/es/components/organism/PositionSetting/styled.js +1 -6
- package/es/components/organism/Table/CrossTabTable/CrossTabTable.js +10 -10
- package/es/components/organism/Table/CrossTabTable/components/CustomCell/CustomCell.js +6 -6
- package/es/components/organism/Table/CrossTabTable/components/CustomCell/styled.js +12 -6
- package/es/components/organism/Table/CrossTabTable/constants.js +3 -3
- package/es/components/organism/Table/CrossTabTable/styled.js +12 -6
- package/es/components/organism/Table/CrossTabTable/utils.js +1 -1
- package/es/components/organism/Table/ExplorePivotTable/ExplorePivotTable.js +12 -23
- package/es/components/organism/Table/ExplorePivotTable/components/CustomCell/CustomCell.js +8 -8
- package/es/components/organism/Table/ExplorePivotTable/components/CustomCell/styled.js +20 -8
- package/es/components/organism/Table/ExplorePivotTable/constants.js +2 -2
- package/es/components/organism/Table/ExplorePivotTable/styled.js +13 -7
- package/es/components/organism/Table/ExplorePivotTable/utils.js +52 -72
- package/es/constants/gradientSetting.js +4 -4
- package/es/constants/keyCode.js +387 -387
- package/es/constants/richMenu.js +2 -2
- package/es/constants/storybook.d.ts +2 -1
- package/es/constants/storybook.js +2 -2
- package/es/constants/theme.js +6 -6
- package/es/hooks/index.js +1 -1
- package/es/hooks/useDebounce.js +5 -5
- package/es/hooks/useDeepCompareEffect.js +1 -1
- package/es/locales/i18n.js +2 -2
- package/es/locales/translations.js +7 -23
- package/es/models/SavedImage.js +23 -68
- package/es/models/Upload.js +19 -64
- package/es/models/model.js +3 -5
- package/es/services/MediaTemplateDesign/UploadFile/index.js +46 -102
- package/es/services/Ticket.js +48 -89
- package/es/services/constants.js +3 -3
- package/es/services/index.js +19 -30
- package/es/test.d.ts +2 -1
- package/es/test.js +25 -36
- package/es/utils/color.js +22 -22
- package/es/utils/common.js +75 -88
- package/es/utils/handleError.js +8 -49
- package/es/utils/loadable.js +6 -18
- package/es/utils/web.js +20 -26
- package/package.json +2 -2
|
@@ -1,14 +1,3 @@
|
|
|
1
|
-
var __assign = (this && this.__assign) || function () {
|
|
2
|
-
__assign = Object.assign || function(t) {
|
|
3
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
-
s = arguments[i];
|
|
5
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
-
t[p] = s[p];
|
|
7
|
-
}
|
|
8
|
-
return t;
|
|
9
|
-
};
|
|
10
|
-
return __assign.apply(this, arguments);
|
|
11
|
-
};
|
|
12
1
|
// Libraries
|
|
13
2
|
import React, { useState, useLayoutEffect, useEffect, useRef, useCallback, } from 'react';
|
|
14
3
|
import classnames from 'classnames';
|
|
@@ -22,54 +11,53 @@ import { getObjectPropSafely, random, safeParse } from '@antscorp/antsomi-ui/es/
|
|
|
22
11
|
import { convertBreakTag, convertDivToBreakTag, convertHtmlText, genShortLinkValue, getInsertLinkPatternWithAppendSpaceEnd, handleUpdateInputPersonalization, initialValue, pasteHtmlAtCaret, removeHtmlTag, spacingNonTracking, validateHTMLTags, } from './utils';
|
|
23
12
|
// Hooks
|
|
24
13
|
import { useDebounce } from '@antscorp/antsomi-ui/es/hooks/useDebounce';
|
|
25
|
-
|
|
26
|
-
|
|
14
|
+
const PATH = 'src/components/atoms/InputDynamic/InputDynamic.tsx';
|
|
15
|
+
const defaultProps = {
|
|
27
16
|
value: '',
|
|
28
17
|
isViewMode: false,
|
|
29
18
|
errors: [],
|
|
30
19
|
canMultipleLine: false,
|
|
31
|
-
onError:
|
|
32
|
-
onChange:
|
|
33
|
-
addMessageToQueue:
|
|
20
|
+
onError: () => { },
|
|
21
|
+
onChange: () => { },
|
|
22
|
+
addMessageToQueue: () => { },
|
|
34
23
|
};
|
|
35
|
-
export
|
|
36
|
-
|
|
24
|
+
export const InputDynamic = (props) => {
|
|
25
|
+
const { value, isViewMode, errors, disabledOpts, canMultipleLine, onError, onChange, addMessageToQueue, } = props;
|
|
37
26
|
// States
|
|
38
|
-
|
|
39
|
-
|
|
27
|
+
const [textValue, setTextValue] = useState(initialValue(value));
|
|
28
|
+
const [initSelectedProperties, setInitSelectedProperties] = useState({
|
|
40
29
|
keyTag: 'shortlink_static',
|
|
41
30
|
link: '',
|
|
42
31
|
urlDetected: '',
|
|
43
|
-
})
|
|
44
|
-
|
|
45
|
-
|
|
32
|
+
});
|
|
33
|
+
const [popoverOpenShortLink, setPopoverOpenShortLink] = useState(false);
|
|
34
|
+
const [tooltipHoverDebounce, _tooltipHover, setTooltipHover] = useDebounce({ x: 0, y: 0 }, 200);
|
|
46
35
|
// Refs
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
36
|
+
const caretPositionRef = useRef(null);
|
|
37
|
+
const personalizationInputRef = useRef(null);
|
|
38
|
+
const onTriggerChange = (event = null) => {
|
|
50
39
|
var _a;
|
|
51
|
-
if (event === void 0) { event = null; }
|
|
52
40
|
try {
|
|
53
|
-
|
|
41
|
+
let tmp = (_a = personalizationInputRef.current) === null || _a === void 0 ? void 0 : _a.innerHTML;
|
|
54
42
|
if (event !== null) {
|
|
55
43
|
caretPositionRef.current = CaretPositioning.saveSelection(event.currentTarget);
|
|
56
44
|
tmp = event.currentTarget.innerHTML;
|
|
57
45
|
}
|
|
58
46
|
tmp = tmp === null || tmp === void 0 ? void 0 : tmp.replace(
|
|
59
47
|
// replace old non tracking url to detect url
|
|
60
|
-
/<button(?=[^>]*class="insert-word")[^>]*value=['"]#(?:{nontrackurl\()?(https?:\/\/[0-9a-zA-Z-{}|"\./?_=&%:#*@;]+)(?:\)})?['"][^>]*>.*?<\/button>/g,
|
|
61
|
-
|
|
48
|
+
/<button(?=[^>]*class="insert-word")[^>]*value=['"]#(?:{nontrackurl\()?(https?:\/\/[0-9a-zA-Z-{}|"\./?_=&%:#*@;]+)(?:\)})?['"][^>]*>.*?<\/button>/g, match => {
|
|
49
|
+
const url = match.match(/(https?:\/\/[0-9a-zA-Z-\./?_=&%:#*@;]+)/);
|
|
62
50
|
if (url) {
|
|
63
|
-
return
|
|
51
|
+
return `<span id="${random(5)}" class="detect-url">${url[1]}</span>`;
|
|
64
52
|
}
|
|
65
53
|
return match; // If no match found, return the original string
|
|
66
54
|
}).replace(
|
|
67
55
|
// replace url to detect url
|
|
68
|
-
/((?<!class="detect-url">|#{shortlink(?:_static)?\(|<span style="line-height: 20px;margin-right: 8px;pointer-events:none;">)\bhttps*:\/\/[0-9a-zA-Z-{}|"\./?_=&%:#*@;]+)/g,
|
|
56
|
+
/((?<!class="detect-url">|#{shortlink(?:_static)?\(|<span style="line-height: 20px;margin-right: 8px;pointer-events:none;">)\bhttps*:\/\/[0-9a-zA-Z-{}|"\./?_=&%:#*@;]+)/g, match => `<span id="${random(5)}" class="detect-url">${match}</span>`);
|
|
69
57
|
tmp = convertDivToBreakTag(tmp);
|
|
70
58
|
setTextValue(tmp);
|
|
71
|
-
|
|
72
|
-
|
|
59
|
+
const text = convertHtmlText(tmp, 'raw', {}, {}, 'input', 'add');
|
|
60
|
+
const textConverted = convertBreakTag(text);
|
|
73
61
|
onChange(removeHtmlTag(textConverted));
|
|
74
62
|
}
|
|
75
63
|
catch (error) {
|
|
@@ -84,22 +72,22 @@ export var InputDynamic = function (props) {
|
|
|
84
72
|
console.error(error);
|
|
85
73
|
}
|
|
86
74
|
};
|
|
87
|
-
|
|
75
|
+
const callback = (type, data) => {
|
|
88
76
|
var _a, _b;
|
|
89
77
|
switch (type) {
|
|
90
78
|
case 'REPLACE_DETECTED_URL': {
|
|
91
|
-
|
|
79
|
+
const innerHTML = getObjectPropSafely(() => { var _a; return (_a = personalizationInputRef.current) === null || _a === void 0 ? void 0 : _a.innerHTML; }, '');
|
|
92
80
|
if (innerHTML) {
|
|
93
81
|
// remove span url và focus vào vị trí remove để add tag shortlink vào vị trí này.
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
82
|
+
const index = Array.from((_a = personalizationInputRef.current) === null || _a === void 0 ? void 0 : _a.childNodes).findIndex((element) => element.id === data.id);
|
|
83
|
+
const range = document.createRange(); // Tạo một đối tượng Range
|
|
84
|
+
const sel = window.getSelection(); // Lấy đối tượng Selection hiện tại
|
|
97
85
|
range.setStart((_b = personalizationInputRef.current) === null || _b === void 0 ? void 0 : _b.childNodes[index], 0); // Đặt điểm bắt đầu của Range
|
|
98
86
|
range.collapse(true); // Thu gọn Range để tập trung vào điểm bắt đầu
|
|
99
87
|
sel === null || sel === void 0 ? void 0 : sel.removeAllRanges(); // Xóa tất cả các Range hiện có
|
|
100
88
|
sel === null || sel === void 0 ? void 0 : sel.addRange(range); // Thêm Range mới vào Selection
|
|
101
89
|
caretPositionRef.current = CaretPositioning.saveSelection(personalizationInputRef.current);
|
|
102
|
-
|
|
90
|
+
const newDataUpdate = innerHTML.replace(data.outerHTML, '');
|
|
103
91
|
personalizationInputRef.current.innerHTML = newDataUpdate;
|
|
104
92
|
}
|
|
105
93
|
break;
|
|
@@ -108,17 +96,17 @@ export var InputDynamic = function (props) {
|
|
|
108
96
|
break;
|
|
109
97
|
}
|
|
110
98
|
};
|
|
111
|
-
|
|
99
|
+
const onPaste = (e) => {
|
|
112
100
|
// cancel paste
|
|
113
101
|
e.preventDefault();
|
|
114
102
|
// get text representation of clipboard
|
|
115
|
-
|
|
103
|
+
const text = (e.originalEvent || e).clipboardData.getData('text/plain');
|
|
116
104
|
// insert text manually
|
|
117
105
|
document.execCommand('insertHTML', false, text);
|
|
118
106
|
};
|
|
119
|
-
|
|
107
|
+
const handleInsertSortLink = (url, type) => {
|
|
120
108
|
try {
|
|
121
|
-
|
|
109
|
+
const { id, value: linkValue, label: linkLabel } = genShortLinkValue(url, type);
|
|
122
110
|
setPopoverOpenShortLink(false);
|
|
123
111
|
if (personalizationInputRef.current instanceof HTMLElement) {
|
|
124
112
|
CaretPositioning.restoreSelection(personalizationInputRef.current, caretPositionRef.current);
|
|
@@ -138,21 +126,21 @@ export var InputDynamic = function (props) {
|
|
|
138
126
|
}
|
|
139
127
|
}
|
|
140
128
|
};
|
|
141
|
-
|
|
129
|
+
const handleKeyPress = (e) => {
|
|
142
130
|
if (canMultipleLine)
|
|
143
131
|
return;
|
|
144
132
|
if (+e.charCode === 13) {
|
|
145
133
|
e.preventDefault();
|
|
146
134
|
}
|
|
147
135
|
};
|
|
148
|
-
|
|
136
|
+
const getDangerouslySetInnerHTML = (text) => {
|
|
149
137
|
if (text) {
|
|
150
|
-
|
|
151
|
-
|
|
138
|
+
const regex = /<[^<>]+>/g;
|
|
139
|
+
let tag;
|
|
152
140
|
// eslint-disable-next-line no-cond-assign
|
|
153
141
|
while ((tag = regex.exec(text))) {
|
|
154
142
|
if (!validateHTMLTags.isValidTag(tag[0])) {
|
|
155
|
-
|
|
143
|
+
const finalTag = tag[0].replace('<', '<').replace('>', '>');
|
|
156
144
|
text = text.replace(tag[0], finalTag);
|
|
157
145
|
}
|
|
158
146
|
}
|
|
@@ -164,22 +152,22 @@ export var InputDynamic = function (props) {
|
|
|
164
152
|
}
|
|
165
153
|
return '';
|
|
166
154
|
};
|
|
167
|
-
|
|
155
|
+
const toggleShortLinkModal = useCallback(() => {
|
|
168
156
|
setPopoverOpenShortLink(!popoverOpenShortLink);
|
|
169
157
|
}, [popoverOpenShortLink]);
|
|
170
158
|
/**
|
|
171
159
|
* [NOTE:open shortlink modal to edit]
|
|
172
160
|
*/
|
|
173
|
-
useEffect(
|
|
174
|
-
|
|
161
|
+
useEffect(() => {
|
|
162
|
+
const handleClickTag = (e) => {
|
|
175
163
|
try {
|
|
176
164
|
e.stopPropagation();
|
|
177
165
|
if (e.target) {
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
if (
|
|
181
|
-
|
|
182
|
-
setInitSelectedProperties(
|
|
166
|
+
const { value = '' } = e.target;
|
|
167
|
+
const shortLink = value.replace(/#|{|}|/g, '').split('(');
|
|
168
|
+
if (shortLink && shortLink.length >= 2) {
|
|
169
|
+
const link = shortLink[1].substring(0, shortLink[1].length - 1) || '';
|
|
170
|
+
setInitSelectedProperties(prev => (Object.assign(Object.assign({}, prev), { link, keyTag: shortLink[0], urlDetected: e.currentTarget })));
|
|
183
171
|
toggleShortLinkModal();
|
|
184
172
|
}
|
|
185
173
|
}
|
|
@@ -189,77 +177,75 @@ export var InputDynamic = function (props) {
|
|
|
189
177
|
console.log('err', err);
|
|
190
178
|
}
|
|
191
179
|
};
|
|
192
|
-
|
|
180
|
+
const listTags = Array.from(document.querySelectorAll('#ants-ui-input-personalization .input-personal .insert-word'));
|
|
193
181
|
if (listTags && listTags.length > 0) {
|
|
194
|
-
listTags.forEach(
|
|
182
|
+
listTags.forEach((tag) => {
|
|
195
183
|
tag.addEventListener('click', handleClickTag);
|
|
196
184
|
});
|
|
197
185
|
}
|
|
198
|
-
return
|
|
199
|
-
listTags.forEach(
|
|
186
|
+
return () => {
|
|
187
|
+
listTags.forEach((tag) => {
|
|
200
188
|
tag.removeEventListener('click', handleClickTag);
|
|
201
189
|
});
|
|
202
190
|
};
|
|
203
191
|
}, [textValue, toggleShortLinkModal]);
|
|
204
192
|
/** Anchor tooltip */
|
|
205
|
-
useEffect(
|
|
206
|
-
|
|
207
|
-
|
|
193
|
+
useEffect(() => {
|
|
194
|
+
let listElement = [];
|
|
195
|
+
const handleMouseOver = (e, targetRect) => {
|
|
208
196
|
e === null || e === void 0 ? void 0 : e.stopPropagation();
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
197
|
+
const viewportTop = window.pageYOffset;
|
|
198
|
+
const viewportLeft = window.pageXOffset;
|
|
199
|
+
const offsetWidth = targetRect.width / 2;
|
|
200
|
+
const offsetHeight = targetRect.height / 2;
|
|
201
|
+
const tooltipHeight = 16;
|
|
202
|
+
const x = targetRect.left - viewportLeft + offsetWidth;
|
|
203
|
+
const y = targetRect.top - viewportTop - offsetHeight - tooltipHeight;
|
|
216
204
|
setTooltipHover({
|
|
217
|
-
x
|
|
218
|
-
y
|
|
205
|
+
x,
|
|
206
|
+
y,
|
|
219
207
|
});
|
|
220
208
|
};
|
|
221
|
-
|
|
209
|
+
const handleMouseOut = (e) => {
|
|
222
210
|
e === null || e === void 0 ? void 0 : e.stopPropagation();
|
|
223
211
|
setTooltipHover({ x: 0, y: 0 });
|
|
224
212
|
};
|
|
225
|
-
|
|
213
|
+
const handleClickDetectUrl = (e) => {
|
|
226
214
|
e === null || e === void 0 ? void 0 : e.stopPropagation();
|
|
227
|
-
setInitSelectedProperties(
|
|
215
|
+
setInitSelectedProperties(prev => {
|
|
228
216
|
var _a;
|
|
229
|
-
return (
|
|
217
|
+
return (Object.assign(Object.assign({}, prev), { link: ((_a = e === null || e === void 0 ? void 0 : e.currentTarget) === null || _a === void 0 ? void 0 : _a.textContent) || '', urlDetected: e === null || e === void 0 ? void 0 : e.currentTarget }));
|
|
230
218
|
});
|
|
231
219
|
toggleShortLinkModal();
|
|
232
220
|
};
|
|
233
221
|
if (!isViewMode) {
|
|
234
|
-
|
|
222
|
+
const elements = document.querySelectorAll('#ants-ui-input-personalization .detect-url');
|
|
235
223
|
listElement = Array.from(elements);
|
|
236
224
|
if (listElement.length) {
|
|
237
|
-
listElement.forEach(
|
|
238
|
-
element.addEventListener('mouseover',
|
|
239
|
-
return handleMouseOver(e, element.getBoundingClientRect());
|
|
240
|
-
});
|
|
225
|
+
listElement.forEach((element) => {
|
|
226
|
+
element.addEventListener('mouseover', e => handleMouseOver(e, element.getBoundingClientRect()));
|
|
241
227
|
element.addEventListener('mouseout', handleMouseOut);
|
|
242
228
|
/** Open shortlink modal */
|
|
243
229
|
element.addEventListener('click', handleClickDetectUrl);
|
|
244
230
|
});
|
|
245
231
|
}
|
|
246
232
|
}
|
|
247
|
-
return
|
|
248
|
-
listElement.forEach(
|
|
233
|
+
return () => {
|
|
234
|
+
listElement.forEach((element) => {
|
|
249
235
|
element.removeEventListener('mouseover', handleMouseOver);
|
|
250
236
|
element.removeEventListener('mouseout', handleMouseOut);
|
|
251
237
|
});
|
|
252
238
|
};
|
|
253
239
|
}, [textValue, isViewMode, setTooltipHover, toggleShortLinkModal]);
|
|
254
240
|
/** Style & remove for tag shortlink button & icon remove */
|
|
255
|
-
useLayoutEffect(
|
|
241
|
+
useLayoutEffect(() => {
|
|
256
242
|
// get button Els [x] to create hover and style it
|
|
257
|
-
|
|
258
|
-
|
|
243
|
+
const iconRemoveEls = document.querySelectorAll('.editor-icon-remove');
|
|
244
|
+
const listIconRemove = iconRemoveEls && Array.from(iconRemoveEls);
|
|
259
245
|
// get button elements
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
246
|
+
const buttonElement = document.querySelectorAll('.insert-word');
|
|
247
|
+
const listBtnElement = buttonElement && Array.from(buttonElement);
|
|
248
|
+
const handleRemoveTag = (e) => {
|
|
263
249
|
var _a, _b, _c, _d, _e;
|
|
264
250
|
if (e && ((_a = e.target) === null || _a === void 0 ? void 0 : _a.nodeName) === 'EM' && ((_b = e.target) === null || _b === void 0 ? void 0 : _b.className) === 'editor-icon-remove') {
|
|
265
251
|
e.stopPropagation();
|
|
@@ -267,17 +253,17 @@ export var InputDynamic = function (props) {
|
|
|
267
253
|
setTextValue(personalizationInputRef && ((_e = personalizationInputRef.current) === null || _e === void 0 ? void 0 : _e.innerHTML));
|
|
268
254
|
}
|
|
269
255
|
};
|
|
270
|
-
listIconRemove.forEach(
|
|
256
|
+
listIconRemove.forEach(eachIcon => {
|
|
271
257
|
eachIcon.addEventListener('click', handleRemoveTag);
|
|
272
258
|
});
|
|
273
259
|
handleUpdateInputPersonalization(listIconRemove, listBtnElement);
|
|
274
|
-
return
|
|
275
|
-
listIconRemove.forEach(
|
|
260
|
+
return () => {
|
|
261
|
+
listIconRemove.forEach(eachIcon => {
|
|
276
262
|
eachIcon.removeEventListener('click', handleRemoveTag);
|
|
277
263
|
});
|
|
278
264
|
};
|
|
279
265
|
}, [textValue]);
|
|
280
|
-
useLayoutEffect(
|
|
266
|
+
useLayoutEffect(() => {
|
|
281
267
|
try {
|
|
282
268
|
// save caret position
|
|
283
269
|
if (!personalizationInputRef.current) {
|
|
@@ -311,12 +297,12 @@ export var InputDynamic = function (props) {
|
|
|
311
297
|
'input-wrapper-outter': true,
|
|
312
298
|
'styles-input-wrapper': !isViewMode,
|
|
313
299
|
'input-error': (errors === null || errors === void 0 ? void 0 : errors.length) && (errors === null || errors === void 0 ? void 0 : errors.length) > 0,
|
|
314
|
-
}), style:
|
|
300
|
+
}), style: Object.assign(Object.assign({}, (isViewMode && {
|
|
315
301
|
padding: 0,
|
|
316
302
|
minHeight: 0,
|
|
317
303
|
fontSize: 12,
|
|
318
304
|
border: 'none',
|
|
319
|
-
})), { width: '100%' }), onClick:
|
|
305
|
+
})), { width: '100%' }), onClick: () => { var _a; return (_a = personalizationInputRef.current) === null || _a === void 0 ? void 0 : _a.focus(); } },
|
|
320
306
|
React.createElement("div", { className: "input-personal", style: {
|
|
321
307
|
display: textValue && textValue !== '<br>' ? 'inline-block' : undefined,
|
|
322
308
|
}, contentEditable: !isViewMode, onBlur: onTriggerChange, onKeyPress: handleKeyPress, ref: personalizationInputRef,
|
|
@@ -324,7 +310,7 @@ export var InputDynamic = function (props) {
|
|
|
324
310
|
dangerouslySetInnerHTML: {
|
|
325
311
|
__html: getDangerouslySetInnerHTML(textValue),
|
|
326
312
|
}, onPaste: onPaste }),
|
|
327
|
-
React.createElement(Icon, { type: "icon-ants-search-2", onClick:
|
|
313
|
+
React.createElement(Icon, { type: "icon-ants-search-2", onClick: e => {
|
|
328
314
|
e.stopPropagation();
|
|
329
315
|
toggleShortLinkModal();
|
|
330
316
|
}, className: "customize-antsomi-profile", style: { width: 24, height: 24 } })),
|
|
@@ -10,7 +10,7 @@ import { Radio } from '../Radio';
|
|
|
10
10
|
import { InputShortLink, InputWrapper } from './styled';
|
|
11
11
|
// Utils
|
|
12
12
|
import { validateURL } from './utils';
|
|
13
|
-
|
|
13
|
+
const OPTIONS = [
|
|
14
14
|
{
|
|
15
15
|
value: 'individual',
|
|
16
16
|
label: 'Individual',
|
|
@@ -20,50 +20,49 @@ var OPTIONS = [
|
|
|
20
20
|
label: 'General',
|
|
21
21
|
},
|
|
22
22
|
];
|
|
23
|
-
export
|
|
24
|
-
|
|
25
|
-
|
|
23
|
+
export const PopupShortLink = props => {
|
|
24
|
+
const { open, onClose, onOk, disabledOpts, initSelectedProperties, callback } = props;
|
|
25
|
+
const [state, setState] = useImmer({
|
|
26
26
|
link: '',
|
|
27
27
|
type: 'individual',
|
|
28
28
|
error: '',
|
|
29
|
-
})
|
|
30
|
-
useEffect(
|
|
31
|
-
|
|
29
|
+
});
|
|
30
|
+
useEffect(() => {
|
|
31
|
+
let type = 'individual';
|
|
32
32
|
if (initSelectedProperties && initSelectedProperties.keyTag) {
|
|
33
33
|
type = initSelectedProperties.keyTag === 'shortlink' ? 'individual' : 'general';
|
|
34
34
|
}
|
|
35
|
-
setState(
|
|
35
|
+
setState(draft => {
|
|
36
36
|
draft.link = initSelectedProperties.link;
|
|
37
37
|
draft.type = type;
|
|
38
38
|
});
|
|
39
39
|
}, [initSelectedProperties, setState]);
|
|
40
|
-
|
|
41
|
-
setState(
|
|
40
|
+
const handleClose = () => {
|
|
41
|
+
setState(draft => {
|
|
42
42
|
draft.link = '';
|
|
43
43
|
draft.error = '';
|
|
44
44
|
});
|
|
45
45
|
if (onClose)
|
|
46
46
|
onClose();
|
|
47
47
|
};
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
setState(function (draft) {
|
|
48
|
+
const handleValidate = ({ urlString = state.link, afterValidate }) => {
|
|
49
|
+
const isValid = validateURL(urlString);
|
|
50
|
+
setState(draft => {
|
|
52
51
|
draft.error = isValid ? '' : 'Invalid URL';
|
|
53
52
|
});
|
|
54
53
|
if (typeof afterValidate === 'function')
|
|
55
54
|
afterValidate(isValid);
|
|
56
55
|
};
|
|
57
|
-
|
|
56
|
+
const handleOnChange = (value) => {
|
|
58
57
|
if (state.error)
|
|
59
58
|
handleValidate({ urlString: value });
|
|
60
|
-
setState(
|
|
59
|
+
setState(draft => {
|
|
61
60
|
draft.link = value;
|
|
62
61
|
});
|
|
63
62
|
};
|
|
64
|
-
|
|
63
|
+
const handleOnOK = () => {
|
|
65
64
|
handleValidate({
|
|
66
|
-
afterValidate:
|
|
65
|
+
afterValidate: (isValid) => {
|
|
67
66
|
if (isValid && onOk) {
|
|
68
67
|
if (initSelectedProperties.urlDetected) {
|
|
69
68
|
callback('REPLACE_DETECTED_URL', initSelectedProperties.urlDetected);
|
|
@@ -74,8 +73,8 @@ export var PopupShortLink = function (props) {
|
|
|
74
73
|
},
|
|
75
74
|
});
|
|
76
75
|
};
|
|
77
|
-
|
|
78
|
-
setState(
|
|
76
|
+
const onChangeType = (event) => {
|
|
77
|
+
setState(draft => {
|
|
79
78
|
draft.type = event.target.value;
|
|
80
79
|
});
|
|
81
80
|
};
|
|
@@ -87,7 +86,7 @@ export var PopupShortLink = function (props) {
|
|
|
87
86
|
React.createElement(Col, { span: 6 },
|
|
88
87
|
React.createElement("span", { style: { fontSize: 12, color: '#000' } }, "Short link type")),
|
|
89
88
|
React.createElement(Col, { span: 18 },
|
|
90
|
-
React.createElement(Radio.Group, { onChange: onChangeType, value: state.type }, OPTIONS.map(
|
|
89
|
+
React.createElement(Radio.Group, { onChange: onChangeType, value: state.type }, OPTIONS.map(each => (React.createElement(Radio, { key: each.value, disabled: disabledOpts && disabledOpts[each.value], name: "shortlink-type", value: each.value }, each.label)))))),
|
|
91
90
|
React.createElement(Row, null,
|
|
92
91
|
React.createElement(Col, { span: 24 },
|
|
93
92
|
React.createElement(InputWrapper, null,
|
|
@@ -4,7 +4,7 @@ export declare const SpanIcon: import("styled-components").StyledComponent<"span
|
|
|
4
4
|
isDisabled?: boolean | undefined;
|
|
5
5
|
}, never>;
|
|
6
6
|
export declare const InputWrapper: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
7
|
-
export declare const InputShortLink: import("styled-components").StyledComponent<import("react").ComponentType<any> | keyof JSX.IntrinsicElements, any, import("../Input/Input").InputProps, any>;
|
|
7
|
+
export declare const InputShortLink: import("styled-components").StyledComponent<import("react").ComponentType<any> | keyof import("react").JSX.IntrinsicElements, any, import("../Input/Input").InputProps, any>;
|
|
8
8
|
export declare const TooltipHover: import("styled-components").StyledComponent<"div", any, {
|
|
9
9
|
top: number;
|
|
10
10
|
left: number;
|