@antscorp/antsomi-ui 1.3.3-beta.4 → 1.3.3-beta.41

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.
Files changed (197) hide show
  1. package/es/assets/images/iphone-top-bar.png +0 -0
  2. package/es/assets/images/iphone.png +0 -0
  3. package/es/assets/images/stars_slider.png +0 -0
  4. package/es/components/atoms/Input/Input.d.ts +3 -0
  5. package/es/components/atoms/Input/Input.js +4 -3
  6. package/es/components/atoms/InputDynamic/EditCaretPositioning.d.ts +2 -0
  7. package/es/components/atoms/InputDynamic/EditCaretPositioning.js +89 -0
  8. package/es/components/atoms/InputDynamic/InputDynamic.d.ts +30 -0
  9. package/es/components/atoms/InputDynamic/InputDynamic.js +320 -0
  10. package/es/components/atoms/InputDynamic/PopupShortLink.d.ts +16 -0
  11. package/es/components/atoms/InputDynamic/PopupShortLink.js +85 -0
  12. package/es/components/atoms/InputDynamic/index.d.ts +2 -0
  13. package/es/components/atoms/InputDynamic/index.js +1 -0
  14. package/es/components/atoms/InputDynamic/styled.d.ts +12 -0
  15. package/es/components/atoms/InputDynamic/styled.js +281 -0
  16. package/es/components/atoms/InputDynamic/utils.d.ts +22 -0
  17. package/es/components/atoms/InputDynamic/utils.js +751 -0
  18. package/es/components/atoms/MobileFrame/MobileFrame.d.ts +4 -0
  19. package/es/components/atoms/MobileFrame/MobileFrame.js +22 -0
  20. package/es/components/atoms/MobileFrame/constants.d.ts +4 -0
  21. package/es/components/atoms/MobileFrame/constants.js +4 -0
  22. package/es/components/atoms/MobileFrame/index.d.ts +2 -0
  23. package/es/components/atoms/MobileFrame/index.js +1 -0
  24. package/es/components/atoms/MobileFrame/styled.d.ts +3 -0
  25. package/es/components/atoms/MobileFrame/styled.js +33 -0
  26. package/es/components/atoms/Pagination/index.d.ts +1 -0
  27. package/es/components/atoms/PreviewTabs/PreviewTabs.d.ts +7 -0
  28. package/es/components/atoms/PreviewTabs/PreviewTabs.js +67 -0
  29. package/es/components/atoms/PreviewTabs/index.d.ts +2 -0
  30. package/es/components/atoms/PreviewTabs/index.js +1 -0
  31. package/es/components/atoms/PreviewTabs/styled.d.ts +6 -0
  32. package/es/components/atoms/PreviewTabs/styled.js +79 -0
  33. package/es/components/atoms/RateV2/RateV2.d.ts +18 -0
  34. package/es/components/atoms/RateV2/RateV2.js +73 -0
  35. package/es/components/atoms/RateV2/index.d.ts +1 -0
  36. package/es/components/atoms/RateV2/index.js +1 -0
  37. package/es/components/atoms/RequiredLabel/index.d.ts +1 -0
  38. package/es/components/atoms/RequiredLabel/index.js +4 -3
  39. package/es/components/atoms/Slider/index.d.ts +2 -1
  40. package/es/components/atoms/Slider/index.js +7 -14
  41. package/es/components/atoms/SliderV2/index.d.ts +6 -0
  42. package/es/components/atoms/SliderV2/index.js +21 -0
  43. package/es/components/atoms/Spin/Spin.d.ts +2 -1
  44. package/es/components/atoms/Spin/styled.d.ts +1 -1
  45. package/es/components/atoms/index.d.ts +7 -0
  46. package/es/components/atoms/index.js +5 -0
  47. package/es/components/common/ConfigProvider/GlobalStyle.js +66 -2
  48. package/es/components/icons/ArrowGrowIcon.d.ts +2 -1
  49. package/es/components/icons/AudioRecordIcon.d.ts +2 -1
  50. package/es/components/icons/BugIcon.d.ts +2 -1
  51. package/es/components/icons/CameraIcon.d.ts +2 -1
  52. package/es/components/icons/CaptureIcon.d.ts +2 -1
  53. package/es/components/icons/CheckSlimIcon.d.ts +2 -1
  54. package/es/components/icons/CloseIcon.d.ts +2 -1
  55. package/es/components/icons/CommentIcon.d.ts +2 -1
  56. package/es/components/icons/EventIcon.d.ts +2 -1
  57. package/es/components/icons/FreeDrawIcon.d.ts +2 -1
  58. package/es/components/icons/GPTIcon.d.ts +2 -1
  59. package/es/components/icons/GPTIconV2.d.ts +2 -1
  60. package/es/components/icons/GPTIconV3.d.ts +2 -1
  61. package/es/components/icons/HighlightIcon.d.ts +2 -1
  62. package/es/components/icons/IdeaIcon.d.ts +2 -1
  63. package/es/components/icons/InvisibleIcon.d.ts +2 -1
  64. package/es/components/icons/MuteIcon.d.ts +2 -1
  65. package/es/components/icons/OpenUrlIcon.d.ts +2 -1
  66. package/es/components/icons/PauseIcon.d.ts +2 -1
  67. package/es/components/icons/PlaneIcon.d.ts +2 -1
  68. package/es/components/icons/RequestIcon.d.ts +2 -1
  69. package/es/components/icons/StopRecordIcon.d.ts +2 -1
  70. package/es/components/icons/UserIcon.d.ts +2 -1
  71. package/es/components/icons/VerticalDotsIcon.d.ts +2 -1
  72. package/es/components/icons/WarningIcon.d.ts +2 -1
  73. package/es/components/molecules/CaptureScreen/CaptureScreen.d.ts +2 -1
  74. package/es/components/molecules/CaptureScreen/components/CommentBox/CommentBox.d.ts +2 -1
  75. package/es/components/molecules/CaptureScreen/components/Cursor/Cursor.d.ts +2 -1
  76. package/es/components/molecules/FontSetting/constants.d.ts +3 -0
  77. package/es/components/molecules/FontSetting/constants.js +22 -0
  78. package/es/components/molecules/FontSetting/index.d.ts +10 -4
  79. package/es/components/molecules/FontSetting/index.js +36 -35
  80. package/es/components/molecules/FontSetting/types.d.ts +1 -1
  81. package/es/components/molecules/Modal/Modal.d.ts +2 -2
  82. package/es/components/molecules/Modal/index.d.ts +1 -0
  83. package/es/components/molecules/Modal/styled.d.ts +1 -1
  84. package/es/components/molecules/ModalV2/ModalV2.d.ts +5 -0
  85. package/es/components/molecules/ModalV2/ModalV2.js +26 -0
  86. package/es/components/molecules/ModalV2/index.d.ts +2 -0
  87. package/es/components/molecules/ModalV2/index.js +1 -0
  88. package/es/components/molecules/ModalV2/styled.d.ts +7 -0
  89. package/es/components/molecules/ModalV2/styled.js +22 -0
  90. package/es/components/molecules/PreviewModal/PreviewModal.d.ts +7 -0
  91. package/es/components/molecules/PreviewModal/PreviewModal.js +30 -0
  92. package/es/components/molecules/PreviewModal/index.d.ts +2 -0
  93. package/es/components/molecules/PreviewModal/index.js +1 -0
  94. package/es/components/molecules/PreviewModal/styled.d.ts +4 -0
  95. package/es/components/molecules/PreviewModal/styled.js +39 -0
  96. package/es/components/molecules/ResizeGrid/ResizeGrid.d.ts +3 -0
  97. package/es/components/molecules/ResizeGrid/ResizeGrid.js +719 -0
  98. package/es/components/molecules/ResizeGrid/components/Cell/Cell.d.ts +3 -0
  99. package/es/components/molecules/ResizeGrid/components/Cell/Cell.js +86 -0
  100. package/es/components/molecules/ResizeGrid/components/Cell/index.d.ts +1 -0
  101. package/es/components/molecules/ResizeGrid/components/Cell/index.js +1 -0
  102. package/es/components/molecules/ResizeGrid/components/Cell/styled.d.ts +3 -0
  103. package/es/components/molecules/ResizeGrid/components/Cell/styled.js +80 -0
  104. package/es/components/molecules/ResizeGrid/constant.d.ts +35 -0
  105. package/es/components/molecules/ResizeGrid/constant.js +111 -0
  106. package/es/components/molecules/ResizeGrid/index.d.ts +2 -0
  107. package/es/components/molecules/ResizeGrid/index.js +1 -0
  108. package/es/components/molecules/ResizeGrid/styled.d.ts +10 -0
  109. package/es/components/molecules/ResizeGrid/styled.js +56 -0
  110. package/es/components/molecules/ResizeGrid/types.d.ts +147 -0
  111. package/es/components/molecules/ResizeGrid/types.js +1 -0
  112. package/es/components/molecules/RichMenu/RichMenuBlock/RichMenuBlock.d.ts +9 -0
  113. package/es/components/molecules/RichMenu/RichMenuBlock/RichMenuBlock.js +49 -0
  114. package/es/components/molecules/RichMenu/RichMenuBlock/RichMenuCell/index.d.ts +10 -0
  115. package/es/components/molecules/RichMenu/RichMenuBlock/RichMenuCell/index.js +47 -0
  116. package/es/components/molecules/RichMenu/RichMenuBlock/RichMenuCell/styled.d.ts +8 -0
  117. package/es/components/molecules/RichMenu/RichMenuBlock/RichMenuCell/styled.js +36 -0
  118. package/es/components/molecules/RichMenu/RichMenuBlock/constants.d.ts +2 -0
  119. package/es/components/molecules/RichMenu/RichMenuBlock/constants.js +765 -0
  120. package/es/components/molecules/RichMenu/RichMenuBlock/index.d.ts +3 -0
  121. package/es/components/molecules/RichMenu/RichMenuBlock/index.js +2 -0
  122. package/es/components/molecules/RichMenu/RichMenuBlock/styled.d.ts +9 -0
  123. package/es/components/molecules/RichMenu/RichMenuBlock/styled.js +17 -0
  124. package/es/components/molecules/RichMenu/RichMenuChatBar/RichMenuChatBar.d.ts +10 -0
  125. package/es/components/molecules/RichMenu/RichMenuChatBar/RichMenuChatBar.js +32 -0
  126. package/es/components/molecules/RichMenu/RichMenuChatBar/TypingChat/index.d.ts +6 -0
  127. package/es/components/molecules/RichMenu/RichMenuChatBar/TypingChat/index.js +15 -0
  128. package/es/components/molecules/RichMenu/RichMenuChatBar/TypingChat/styled.d.ts +4 -0
  129. package/es/components/molecules/RichMenu/RichMenuChatBar/TypingChat/styled.js +47 -0
  130. package/es/components/molecules/RichMenu/RichMenuChatBar/index.d.ts +2 -0
  131. package/es/components/molecules/RichMenu/RichMenuChatBar/index.js +1 -0
  132. package/es/components/molecules/RichMenu/RichMenuChatBar/styled.d.ts +9 -0
  133. package/es/components/molecules/RichMenu/RichMenuChatBar/styled.js +37 -0
  134. package/es/components/molecules/RichMenu/RichMenuMobileView/RichMenuMobileView.d.ts +10 -0
  135. package/es/components/molecules/RichMenu/RichMenuMobileView/RichMenuMobileView.js +37 -0
  136. package/es/components/molecules/RichMenu/RichMenuMobileView/index.d.ts +1 -0
  137. package/es/components/molecules/RichMenu/RichMenuMobileView/index.js +1 -0
  138. package/es/components/molecules/RichMenu/RichMenuMobileView/styled.d.ts +6 -0
  139. package/es/components/molecules/RichMenu/RichMenuMobileView/styled.js +20 -0
  140. package/es/components/molecules/RichMenu/index.d.ts +3 -0
  141. package/es/components/molecules/RichMenu/index.js +3 -0
  142. package/es/components/molecules/Select/Select.d.ts +4 -2
  143. package/es/components/molecules/Select/Test.d.ts +2 -1
  144. package/es/components/molecules/TreeSelect/TreeSelect.d.ts +4 -2
  145. package/es/components/molecules/UploadImage/MediaIcon.d.ts +2 -1
  146. package/es/components/molecules/index.d.ts +6 -0
  147. package/es/components/molecules/index.js +4 -0
  148. package/es/components/organism/Help/styled.d.ts +6 -2
  149. package/es/constants/index.d.ts +1 -0
  150. package/es/constants/index.js +1 -0
  151. package/es/constants/richMenu.d.ts +19 -0
  152. package/es/constants/richMenu.js +19 -0
  153. package/es/constants/storybook.d.ts +2 -1
  154. package/es/constants/theme.js +13 -2
  155. package/es/hooks/useDeepCompareEffect.d.ts +1 -0
  156. package/es/hooks/useDeepCompareEffect.js +21 -0
  157. package/es/locales/en/translation.json +3 -1
  158. package/es/locales/i18n.d.ts +3 -0
  159. package/es/locales/translations.d.ts +2 -0
  160. package/es/locales/vi/translation.json +2 -1
  161. package/es/test.d.ts +2 -1
  162. package/es/test.js +164 -66
  163. package/es/types/index.d.ts +12 -0
  164. package/es/types/index.js +2 -1
  165. package/es/types/richMenu.d.ts +191 -0
  166. package/es/types/richMenu.js +1 -0
  167. package/es/types/variables.d.ts +2 -0
  168. package/es/types/variables.js +1 -0
  169. package/es/utils/common.d.ts +2 -0
  170. package/es/utils/common.js +16 -0
  171. package/es/utils/handleError.d.ts +32 -2
  172. package/es/utils/handleError.js +42 -4
  173. package/package.json +8 -6
  174. package/dist/0173b5993573afa04880.woff +0 -0
  175. package/dist/0dfb9214dfd945cd7290.png +0 -1
  176. package/dist/2883cad25a2b4e87ce5f.eot +0 -0
  177. package/dist/4f54a37971347e3d7122.png +0 -1
  178. package/dist/574b7bee0563a9fe9a29.png +0 -1
  179. package/dist/6b586356e837581204dc.svg +0 -1
  180. package/dist/72eec5c1c786b45a667f.ttf +0 -0
  181. package/dist/bc6bf11c6f5e6743aa4c.png +0 -1
  182. package/dist/dbc405edd6e0806efbc9.svg +0 -1
  183. package/dist/e32f09119052a55cce3c.png +0 -1
  184. package/dist/e3851b9384a984c6fdb5.png +0 -1
  185. package/dist/index.js +0 -2
  186. package/dist/index.js.LICENSE.txt +0 -69
  187. package/dist/main.css +0 -69
  188. package/dist/public/icons/2d496b55d85a9545d7311c073af442bb.png +0 -0
  189. package/dist/public/icons/2fbb4e0927d18e3f8e5c6511ab88d5b3.png +0 -0
  190. package/dist/public/icons/725a52bd91a3ce534b10833df510e5fa.png +0 -0
  191. package/dist/public/icons/7d037e0b378e87a82804443636cd0e13.svg +0 -346
  192. package/dist/public/icons/90553767e0a05b9585a54797cfd9ce51.png +0 -0
  193. package/dist/public/icons/bb64e23a1ff390a416d765ee556096ab.svg +0 -87
  194. package/dist/public/icons/d327b24e9c5d8f486f08d253aab58ce6.png +0 -0
  195. package/dist/public/icons/f1cf266d0a0a53ce07f2dbb859869b7a.png +0 -0
  196. package/dist/public/icons/placeholder-image.png +0 -0
  197. package/dist/public/icons/transparent.svg +0 -1
@@ -0,0 +1,751 @@
1
+ /* eslint-disable array-callback-return */
2
+ /* eslint-disable no-sequences */
3
+ /* eslint-disable no-cond-assign */
4
+ /* eslint-disable no-var */
5
+ /* eslint-disable eqeqeq */
6
+ /* eslint-disable vars-on-top */
7
+ /* eslint-disable @typescript-eslint/no-unused-expressions */
8
+ /* eslint-disable block-scoped-var */
9
+ /* eslint-disable prefer-destructuring */
10
+ // Libraries
11
+ import { get } from 'lodash';
12
+ import { decode } from 'html-entities';
13
+ // Utils
14
+ import { getObjectPropSafely, random } from '@antscorp/antsomi-ui/es/utils';
15
+ export function validateURL(string) {
16
+ // eslint-disable-next-line no-useless-escape
17
+ const regexp = /^((([A-Za-z]{3,9}:(?:\/\/)?)(?:[\-;:&=\+\$,\w]+@)?[A-Za-z0-9\.\-]+|(?:www\.|[\-;:&=\+\$,\w]+@)[A-Za-z0-9\.\-]+)((?:\/[\+~%\/\.\w\-_]*)?\??(?:[\-\+=&;%@\.\w_]*)#?(?:[\.\!\/\\\w]*))?)/;
18
+ return regexp.test(string);
19
+ }
20
+ export const getInsertPatternWithAppendSpaceEnd = (id, code, label, bgColor) => `<button id="${id}" contenteditable="false" class="insert-word" style="max-width: 250px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; padding: 5px 8px; color: white; font-size: inherit; outline: none; border: 1px solid transparent; border-radius: 1.2rem; margin-top: 2px; cursor: pointer; background: ${bgColor}; height: auto" value=${code
21
+ .replace(/\s/gm, '&nbsp;')
22
+ .replace(/"/gm, '&quot;')}><span style="line-height: 20px;margin-right: 8px;pointer-events:none;">${label}</span><em class="editor-icon-remove" style="color: white;font-style: normal; marign-left: 4px; position: relative; z-index: 1;font-size: 1rem;font-weight: bold">x</em></button>&nbsp;`;
23
+ export const genShortLinkValue = (url, type) => {
24
+ const id = random(5);
25
+ let keyTag = 'shortlink';
26
+ if (type === 'general') {
27
+ keyTag = 'shortlink_static';
28
+ }
29
+ return {
30
+ id,
31
+ value: `#{${keyTag}(${url})}`,
32
+ label: `https://ants.ly/${id}`,
33
+ };
34
+ };
35
+ export const getInsertPattern = (id, code, label, bgColor) => `<button id="${id}" contenteditable="false" class="insert-word" style="padding: 5px 8px; color: white; font-size: inherit; outline: none; border: 1px solid transparent; border-radius: 1.2rem; height: auto; margin-top: 2px; cursor: pointer; background: ${bgColor}" value=${code
36
+ .replace(/\s/gm, '&nbsp;')
37
+ .replace(/"/gm, '&quot;')}><span style="line-height: 20px;margin-right: 8px;pointer-events:none;">${label}</span><em class="editor-icon-remove" style="color: white;font-style: normal; marign-left: 4px; position: relative; z-index: 1;font-size: 1rem;font-weight: bold">x</em></button>`;
38
+ export const convertHtmlText = (htmlText, format = 'raw', state, objectWidgetInput = {}, type = '', init = '') => {
39
+ const result = htmlText;
40
+ try {
41
+ if (format && format.toLowerCase() === 'raw') {
42
+ // pattern find all button insert word
43
+ const regexInsertPattern = type === 'input'
44
+ ? /<button .*?class="insert-word.*?".*? value="([^"]*?)".*?>(.*?)<\/button>/gim
45
+ : /<button .*?class="insert-word.*?".*? value=(.*?)>(.*?)<\/button>/gim;
46
+ // pattern find all symbol `"`
47
+ const regexQuot = /&quot;/gm;
48
+ const regexSpace = /&nbsp;/gm;
49
+ const regexSpaceV2 = /nbsp;/gm;
50
+ const regexShortLink = /#{shortlink\(.*?\)}/;
51
+ const regexShortLinkStatic = /#{shortlink_static\(.*?\)}/;
52
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
53
+ const replacer = (match, p1, p2, p3, offset, string) => {
54
+ const newPlacer = p1
55
+ .replace(/"/gm, '')
56
+ .replace(regexQuot, '"')
57
+ .replace(regexSpace, ' ')
58
+ .replace(regexSpaceV2, ' ');
59
+ if (!regexShortLink.test(newPlacer) || !regexShortLinkStatic.test(newPlacer)) {
60
+ return newPlacer.replace(/&amp;/gm, '');
61
+ }
62
+ return newPlacer;
63
+ };
64
+ // replace `"` from value -> replace &quot; -> replace &nbsp;
65
+ if (result === null || result === undefined) {
66
+ return htmlText;
67
+ }
68
+ try {
69
+ return result.replace(regexInsertPattern, replacer);
70
+ }
71
+ catch (error) {
72
+ // eslint-disable-next-line no-console
73
+ console.log('error', error);
74
+ return htmlText;
75
+ }
76
+ }
77
+ if (format && format.toLowerCase() === 'html') {
78
+ const insertPattern = /#{.*?}/gm;
79
+ if (insertPattern.test(htmlText)) {
80
+ const htmlReplacer = (matcher) => {
81
+ // const regex = /(\w+.\w+)|(\(\w+)\)|"(.*?)"/gmi;
82
+ // const regex = /(\w+.\w+)|(\(\w+)\)|"(.*?)"/gim;
83
+ // const regex = /(\w+)|(\(\w+)\)|"(.*?)"/gim;
84
+ // const found = matcher.match(regex);
85
+ const found = matcher.replace(/#|{|}|/g, '').split('.');
86
+ const foundLink = found[0].split('(');
87
+ if (found && found.length) {
88
+ let bgColor = '#ccc';
89
+ // console.log(found);
90
+ if (found[0] === 'customer') {
91
+ bgColor = '#3C39BA';
92
+ }
93
+ else if (found[0] === 'visitor') {
94
+ bgColor = '#009000';
95
+ }
96
+ else if (found[0] === 'event') {
97
+ bgColor = '#FBAC00';
98
+ }
99
+ else if (found[0] === 'objectWidget') {
100
+ bgColor = '#24abb9';
101
+ }
102
+ else if (found[0] === 'productTemplate') {
103
+ bgColor = '#9238b5';
104
+ }
105
+ else if (found[0] === 'promotion_code' ||
106
+ foundLink[0] === 'nontrackurl' ||
107
+ foundLink[0] === 'shortlink' ||
108
+ foundLink[0] === 'shortlink_static') {
109
+ bgColor = '#6750A7';
110
+ }
111
+ else if (found[0] === 'custom') {
112
+ bgColor = '#BBEFBE';
113
+ }
114
+ let label = getObjectPropSafely(() => {
115
+ const foundAttribute = '';
116
+ let codeTag = '';
117
+ if (found.length === 2) {
118
+ if (found[0] === 'objectWidget' && found[1].startsWith('custom_')) {
119
+ bgColor = '#1890F0';
120
+ const contentWidget = found[1].substring(7);
121
+ // remove custom_ for get right content
122
+ if (contentWidget.length > 0) {
123
+ if (objectWidgetInput[contentWidget] !== undefined) {
124
+ return objectWidgetInput[contentWidget].name;
125
+ }
126
+ bgColor = '#ccc';
127
+ // return contentWidget;
128
+ return 'Unknow Widget';
129
+ }
130
+ }
131
+ else {
132
+ codeTag = found[1].split('||')[0];
133
+ }
134
+ }
135
+ else if (found.length === 3) {
136
+ if (found[0] === 'promotion_code') {
137
+ codeTag = found[1];
138
+ }
139
+ else {
140
+ const splitString = found[2].split('||');
141
+ codeTag = `${found[1]}.${splitString[0]}`;
142
+ }
143
+ }
144
+ // console.log('foundAttribute', found, foundAttribute, codeTag);
145
+ if (foundAttribute) {
146
+ return foundAttribute.label;
147
+ }
148
+ // bgColor = '#ccc';
149
+ // return `${found[0]}.${codeTag}`;
150
+ return `${codeTag}`;
151
+ });
152
+ if (foundLink[0] === 'nontrackurl') {
153
+ label = 'Non tracking Link';
154
+ }
155
+ if (foundLink[0] === 'shortlink' || foundLink[0] === 'shortlink_static') {
156
+ const url = get(matcher.match(/\((.*?)\)/), '.1', '');
157
+ label = genShortLinkValue(url).label;
158
+ }
159
+ // console.log(type);
160
+ if (type === 'input') {
161
+ if (init === 'add') {
162
+ return getInsertPatternWithAppendSpaceEnd(random(8), matcher, label || found[0], bgColor);
163
+ }
164
+ return getInsertPattern(random(8), matcher, label || found[0], bgColor);
165
+ }
166
+ return getInsertPattern(random(8), matcher, label || found[0], bgColor);
167
+ }
168
+ return matcher;
169
+ };
170
+ try {
171
+ return `${result.replace(insertPattern, htmlReplacer)}`;
172
+ }
173
+ catch (error) {
174
+ // eslint-disable-next-line no-console
175
+ console.log(error);
176
+ return htmlText;
177
+ }
178
+ }
179
+ }
180
+ }
181
+ catch (error) {
182
+ // eslint-disable-next-line no-console
183
+ console.log('error', error);
184
+ }
185
+ return result;
186
+ };
187
+ export const handleUpdateInputPersonalization = (listIconRemove, listBtnElement) => {
188
+ listIconRemove.forEach((each) => {
189
+ each.innerHTML = '';
190
+ each.innerHTML = '&#x2715';
191
+ const styleBtnRemove = each.style;
192
+ styleBtnRemove.fontSize = '13px';
193
+ styleBtnRemove.color = '#305FB8';
194
+ styleBtnRemove.marginLeft = '-12px';
195
+ styleBtnRemove.marginTop = '1px';
196
+ styleBtnRemove.lineHeight = '18px';
197
+ styleBtnRemove.position = 'absolute';
198
+ styleBtnRemove.backgroundColor = '#fff';
199
+ styleBtnRemove.padding = '0 3px';
200
+ styleBtnRemove.borderRadius = '50%';
201
+ styleBtnRemove.top = '50%';
202
+ styleBtnRemove.transform = 'translate(-50%, -50%)';
203
+ styleBtnRemove.left = '100%';
204
+ });
205
+ listBtnElement.forEach((each) => {
206
+ const styleBtnElement = each.style;
207
+ styleBtnElement.position = 'relative';
208
+ styleBtnElement.color = '#000';
209
+ styleBtnElement.padding = '3px 8px';
210
+ styleBtnElement.paddingRight = '2px';
211
+ if (each.value.includes('shortlink_static')) {
212
+ styleBtnElement.backgroundColor = '#CAE5FE';
213
+ }
214
+ });
215
+ };
216
+ export function removeHtmlTag(text) {
217
+ text = `${text}`.replace(/(<([^>]+)>)/gi, '');
218
+ text = text.replace(/&nbsp;/gm, ' ');
219
+ return decode(text.trim());
220
+ }
221
+ export function convertBreakTag(text) {
222
+ return text.replace(/(<|&lt;)br\s*\/*(>|&gt;)/g, '\n');
223
+ }
224
+ export function convertDivToBreakTag(text) {
225
+ return text.replace(/<div>/gi, '<br>').replace(/<\/div>/gi, '');
226
+ }
227
+ export const pasteHtmlAtCaret = (html, selectPastedContent, callback) => {
228
+ try {
229
+ // console.log('callback', callback, typeof callback);
230
+ if (typeof callback === 'function') {
231
+ callback();
232
+ }
233
+ let sel;
234
+ let range;
235
+ if (window.getSelection) {
236
+ // IE9 and non-IE
237
+ sel = window.getSelection();
238
+ if (sel.getRangeAt && sel.rangeCount) {
239
+ range = sel.getRangeAt(0);
240
+ range.deleteContents();
241
+ // Range.createContextualFragment() would be useful here but is
242
+ // only relatively recently standardized and is not supported in
243
+ // some browsers (IE9, for one)
244
+ const el = document.createElement('div');
245
+ el.innerHTML = html;
246
+ const frag = document.createDocumentFragment();
247
+ let node;
248
+ let lastNode;
249
+ // eslint-disable-next-line no-cond-assign
250
+ while ((node = el.firstChild)) {
251
+ lastNode = frag.appendChild(node);
252
+ }
253
+ const firstNode = frag.firstChild;
254
+ range.insertNode(frag);
255
+ // Preserve the selection
256
+ if (lastNode) {
257
+ range = range.cloneRange();
258
+ range.setStartAfter(lastNode);
259
+ if (selectPastedContent) {
260
+ range.setStartBefore(firstNode);
261
+ }
262
+ else {
263
+ range.collapse(true);
264
+ }
265
+ sel.removeAllRanges();
266
+ sel.addRange(range);
267
+ }
268
+ }
269
+ // eslint-disable-next-line no-cond-assign
270
+ }
271
+ else if ((sel = document.selection) && sel.type !== 'Control') {
272
+ // IE < 9
273
+ const originalRange = sel.createRange();
274
+ originalRange.collapse(true);
275
+ sel.createRange().pasteHTML(html);
276
+ if (selectPastedContent) {
277
+ range = sel.createRange();
278
+ range.setEndPoint('StartToStart', originalRange);
279
+ range.select();
280
+ }
281
+ }
282
+ }
283
+ catch (error) {
284
+ // eslint-disable-next-line no-console
285
+ console.log(error);
286
+ }
287
+ };
288
+ export const getInsertLinkPatternWithAppendSpaceEnd = (id, value, label) => `<button id="${id}" contenteditable="false" class="insert-word" style="padding: 5px 8px; color: #000; font-size: inherit; outline: none; border: 1px solid transparent; border-radius: 1.2rem; margin-top: 2px; cursor: pointer; height: auto; background-color: #CAE5FE" value=${value
289
+ .replace(/\s/gm, '&nbsp;')
290
+ .replace(/"/gm, '&quot;')}><span style="line-height: 20px;margin-right: 8px;pointer-events:none;">${label}</span><em class="editor-icon-remove" style="color: white;font-style: normal; marign-left: 4px; position: relative; z-index: 999;font-size: 1rem;font-weight: bold">x</em></button>&nbsp;`;
291
+ // eslint-disable-next-line func-names
292
+ export const validateHTMLTags = (function () {
293
+ const e = [
294
+ '<a ',
295
+ '<a>',
296
+ '</a>',
297
+ '<abbr>',
298
+ '<abbr ',
299
+ '</abbr>',
300
+ '<acronym>',
301
+ '<acronym ',
302
+ '</acronym>',
303
+ '<address>',
304
+ '<address ',
305
+ '</address>',
306
+ '<applet>',
307
+ '<applet ',
308
+ '</applet>',
309
+ '<area>',
310
+ '<area ',
311
+ '</area>',
312
+ '<article>',
313
+ '</article>',
314
+ '<article ',
315
+ '<aside>',
316
+ '<aside ',
317
+ '</aside>',
318
+ '<audio>',
319
+ '<audio ',
320
+ '</audio>',
321
+ '<b>',
322
+ '</b>',
323
+ '<base>',
324
+ '<base ',
325
+ '</base>',
326
+ '<basefont>',
327
+ '<basefont ',
328
+ '</basefont>',
329
+ '<bdi>',
330
+ '</bdi>',
331
+ '<bdi ',
332
+ '<bdo>',
333
+ '</bdo>',
334
+ '<bdo ',
335
+ '<big>',
336
+ '<big ',
337
+ '</big>',
338
+ '<blockquote>',
339
+ '<blockquote ',
340
+ '</blockquote>',
341
+ '<body>',
342
+ '<body ',
343
+ '</body>',
344
+ '<br ',
345
+ '<br />',
346
+ '<br>',
347
+ '<br/>',
348
+ '</br>',
349
+ '<button>',
350
+ '<button ',
351
+ '</button>',
352
+ '<canvas>',
353
+ '</canvas>',
354
+ '<canvas ',
355
+ '<caption>',
356
+ '<caption ',
357
+ '</caption>',
358
+ '<center>',
359
+ '<center ',
360
+ '</center>',
361
+ '<cite>',
362
+ '<cite ',
363
+ '</cite>',
364
+ '<code>',
365
+ '<code ',
366
+ '</code>',
367
+ '<col>',
368
+ '<col ',
369
+ '</col>',
370
+ '<colgroup>',
371
+ '<colgroup ',
372
+ '</colgroup>',
373
+ '<datalist>',
374
+ '<datalist ',
375
+ '</datalist>',
376
+ '<dd>',
377
+ '</dd>',
378
+ '<dd ',
379
+ '<del>',
380
+ '<del ',
381
+ '</del>',
382
+ '<details>',
383
+ '<details ',
384
+ '</details>',
385
+ '<dfn>',
386
+ '</dfn>',
387
+ '<dfn ',
388
+ '<dialog>',
389
+ '<dialog ',
390
+ '</dialog>',
391
+ '<dir>',
392
+ '</dir>',
393
+ '<dir ',
394
+ '<div>',
395
+ '<div ',
396
+ '</div>',
397
+ '<dl>',
398
+ '</dl>',
399
+ '<dl ',
400
+ '<dt>',
401
+ '</dt>',
402
+ '<dt ',
403
+ '<em>',
404
+ '<em ',
405
+ '</em>',
406
+ '<embed>',
407
+ '</embed>',
408
+ '<embed ',
409
+ '<fieldset>',
410
+ '<fieldset ',
411
+ '</fieldset>',
412
+ '<figcaption>',
413
+ '</figcaption>',
414
+ '<figcaption ',
415
+ '<figure>',
416
+ '<figure ',
417
+ '</figure>',
418
+ '<font ',
419
+ '</font>',
420
+ '<font>',
421
+ '<footer>',
422
+ '</footer>',
423
+ '<footer ',
424
+ '<form>',
425
+ '</form>',
426
+ '<form ',
427
+ '<frame>',
428
+ '</frame>',
429
+ '<frame ',
430
+ '<frameset>',
431
+ '<frameset ',
432
+ '</frameset>',
433
+ '<h1>',
434
+ '</h1>',
435
+ '<h1 ',
436
+ '<h2>',
437
+ '</h2>',
438
+ '<h2 ',
439
+ '<h3>',
440
+ '</h3>',
441
+ '<h3 ',
442
+ '<h4>',
443
+ '</h4>',
444
+ '<h4 ',
445
+ '<h5>',
446
+ '</h5>',
447
+ '<h5 ',
448
+ '<h6>',
449
+ '</h6>',
450
+ '<h6 ',
451
+ '<head>',
452
+ '</head>',
453
+ '<head ',
454
+ '<header>',
455
+ '<header ',
456
+ '</header>',
457
+ '<hr>',
458
+ '<hr ',
459
+ '</hr>',
460
+ '<html>',
461
+ '</html>',
462
+ '<html ',
463
+ '<i>',
464
+ '</i>',
465
+ '<iframe>',
466
+ '<iframe ',
467
+ '</iframe>',
468
+ '<img>',
469
+ '</img>',
470
+ '<img ',
471
+ '<input>',
472
+ '</input>',
473
+ '<input ',
474
+ '<ins>',
475
+ '<ins ',
476
+ '</ins>',
477
+ '</kbd>',
478
+ '<kbd>',
479
+ '<kbd ',
480
+ '<label>',
481
+ '<label ',
482
+ '</label>',
483
+ '<legend>',
484
+ '<legend ',
485
+ '</legend>',
486
+ '<li ',
487
+ '<li>',
488
+ '</li>',
489
+ '<link>',
490
+ '<link ',
491
+ '</link>',
492
+ '<main>',
493
+ '<main ',
494
+ '</main>',
495
+ '<map>',
496
+ '</map>',
497
+ '<map ',
498
+ '<mark>',
499
+ '</mark>',
500
+ '<mark ',
501
+ '<meta>',
502
+ '</meta>',
503
+ '<meta ',
504
+ '<meter>',
505
+ '</meter>',
506
+ '<meter ',
507
+ '<nav>',
508
+ '</nav>',
509
+ '<nav ',
510
+ '<noframes>',
511
+ '</noframes>',
512
+ '<noframes ',
513
+ '<noscript>',
514
+ '<noscript ',
515
+ '</noscript>',
516
+ '<object>',
517
+ '<object ',
518
+ '</object>',
519
+ '<ol>',
520
+ '</ol>',
521
+ '<ol ',
522
+ '<optgroup>',
523
+ '</optgroup>',
524
+ '<optgroup ',
525
+ '<option>',
526
+ '</option>',
527
+ '<option ',
528
+ '<output>',
529
+ '<output ',
530
+ '</output>',
531
+ '<p>',
532
+ '</p>',
533
+ '<p ',
534
+ '<param>',
535
+ '<param ',
536
+ '</param>',
537
+ '<pre>',
538
+ '</pre>',
539
+ '<pre ',
540
+ '<progress>',
541
+ '<progress ',
542
+ '</progress>',
543
+ '<q>',
544
+ '</q>',
545
+ '<q ',
546
+ '<rp>',
547
+ '</rp>',
548
+ '<rp ',
549
+ '<rt>',
550
+ '<rt ',
551
+ '</rt>',
552
+ '<ruby>',
553
+ '</ruby>',
554
+ '<ruby ',
555
+ '<s>',
556
+ '</s>',
557
+ '<s ',
558
+ '<samp>',
559
+ '</samp>',
560
+ '<samp ',
561
+ '<section>',
562
+ '</section>',
563
+ '<section ',
564
+ '<select>',
565
+ '</select>',
566
+ '<select ',
567
+ '<small>',
568
+ '<small ',
569
+ '</small>',
570
+ '<source>',
571
+ '</source>',
572
+ '<source ',
573
+ '<span>',
574
+ '<span ',
575
+ '</span>',
576
+ '<strike>',
577
+ '</strike>',
578
+ '<strike ',
579
+ '<strong>',
580
+ '<strong ',
581
+ '</strong>',
582
+ '<style>',
583
+ '</style>',
584
+ '<style ',
585
+ '<sub>',
586
+ '<sub ',
587
+ '</sub>',
588
+ '<summary>',
589
+ '</summary>',
590
+ '<summary ',
591
+ '<sup>',
592
+ '<sup ',
593
+ '</sup>',
594
+ '<table ',
595
+ '<table>',
596
+ '</table>',
597
+ '<tbody>',
598
+ '</tbody>',
599
+ '<tbody ',
600
+ '<td>',
601
+ '<td ',
602
+ '</td>',
603
+ '<textarea>',
604
+ '<textarea ',
605
+ '</textarea>',
606
+ '<tfoot>',
607
+ '</tfoot>',
608
+ '<tfoot ',
609
+ '<th>',
610
+ '</th>',
611
+ '<th ',
612
+ '<thead>',
613
+ '</thead>',
614
+ '<thead ',
615
+ '<time>',
616
+ '<time ',
617
+ '</time>',
618
+ '<title>',
619
+ '</title>',
620
+ '<title ',
621
+ '<tr>',
622
+ '<tr ',
623
+ '</tr>',
624
+ '<track>',
625
+ '</track>',
626
+ '<track ',
627
+ '<tt>',
628
+ '</tt>',
629
+ '<tt ',
630
+ '<u>',
631
+ '</u>',
632
+ '<ul ',
633
+ '<ul>',
634
+ '</ul>',
635
+ '<var>',
636
+ '<var ',
637
+ '</var>',
638
+ '<video>',
639
+ '</video>',
640
+ '<video ',
641
+ '<wbr>',
642
+ '<wbr ',
643
+ '</wbr>',
644
+ ];
645
+ const t = {
646
+ escapeCustomTags(t) {
647
+ if (!t || typeof t !== 'string')
648
+ return t;
649
+ for (var r = 0, a = [], i = [], o = [], s = t, n = 0; n <= t.length; n++)
650
+ t[n] == '<'
651
+ ? i.push({ index: n, type: 'lt' })
652
+ : t[n] == '>' && i.push({ index: n, type: 'gt' });
653
+ for (n = 0; n <= t.length; n++) {
654
+ var d = t.indexOf('<', r);
655
+ if (d === -1)
656
+ break;
657
+ const l = t.indexOf(' ', d + 1);
658
+ const p = t.indexOf('/>', d + 1);
659
+ var u = t.indexOf('>', d + 1);
660
+ const b = [];
661
+ l != -1 && b.push(l), p != -1 && b.push(p), u != -1 && b.push(u);
662
+ var f;
663
+ const m = Math.min(...b);
664
+ var h = t.substring(d, m + 1);
665
+ (f = e.some(e => {
666
+ if (h === e)
667
+ return a.push({ index: d, type: 'lt' }, { index: u, type: 'gt' }), !0;
668
+ })),
669
+ (n = m),
670
+ f ? (r = m) : (r += 1);
671
+ }
672
+ for (n = 0; n < i.length; n++) {
673
+ a.some((e) => e.index === i[n].index) || o.push(i[n]);
674
+ }
675
+ for (n = o.length - 1; n >= 0; n--)
676
+ o[n].type == 'lt'
677
+ ? (s = `${s.substring(0, o[n].index)}&lt;${s.substring(o[n].index + 1)}`)
678
+ : o[n].type == 'gt' &&
679
+ (s = `${s.substring(0, o[n].index)}&gt;${s.substring(o[n].index + 1)}`);
680
+ return s;
681
+ },
682
+ isCustomTag(t) {
683
+ if (!t || typeof t !== 'string')
684
+ return !1;
685
+ for (var r = !1, a = 0, i = 0; i <= t.length;) {
686
+ const o = t.indexOf('<', a);
687
+ if (o == -1)
688
+ break;
689
+ const s = t.indexOf(' ', o + 1);
690
+ const n = t.indexOf('/>', o + 1);
691
+ const d = t.indexOf('>', o + 1);
692
+ const l = [];
693
+ s != -1 && l.push(s), n != -1 && l.push(n), d != -1 && l.push(d);
694
+ const p = Math.min(...l);
695
+ var u = t.substring(o, p + 1);
696
+ if ((e.some((t, a) => {
697
+ if (u === t)
698
+ return !0;
699
+ a + 1 == e.length && (r = !0);
700
+ }),
701
+ r))
702
+ break;
703
+ (i = p), (a = p);
704
+ }
705
+ return r;
706
+ },
707
+ isValidTag(t) {
708
+ if (!t || typeof t !== 'string')
709
+ return !1;
710
+ for (var r = !1, a = 0, i = 0; i <= t.length;) {
711
+ const o = t.indexOf('<', a);
712
+ if (o == -1)
713
+ break;
714
+ const s = t.indexOf(' ', o + 1);
715
+ const n = t.indexOf('/>', o + 1);
716
+ const d = t.indexOf('>', o + 1);
717
+ const l = [];
718
+ s != -1 && l.push(s), n != -1 && l.push(n), d != -1 && l.push(d);
719
+ const p = Math.min(...l);
720
+ var u = t.substring(o, p + 1);
721
+ if ((r = e.some(e => u === e)))
722
+ break;
723
+ (i = p), r ? (a = p) : (a += 1);
724
+ }
725
+ return r;
726
+ },
727
+ };
728
+ return t;
729
+ })();
730
+ // Fix bug con trỏ input check text Value đã có thẻ <br/>
731
+ export const spacingNonTracking = (data) => {
732
+ // eslint-disable-next-line prefer-regex-literals
733
+ const regexHasBannedPrefix = new RegExp(/<br\s*\/?>/gi);
734
+ if (typeof data === 'string' && regexHasBannedPrefix.test(data)) {
735
+ return true;
736
+ }
737
+ return false;
738
+ };
739
+ export const initialValue = (initValue) => {
740
+ try {
741
+ const newTextValue = convertHtmlText(initValue, 'html', {}, {}, 'input', '');
742
+ if (newTextValue && !newTextValue.endsWith('&nbsp;')) {
743
+ return `${newTextValue}&nbsp;`;
744
+ }
745
+ return newTextValue;
746
+ }
747
+ catch (err) {
748
+ // eslint-disable-next-line no-console
749
+ console.log(err);
750
+ }
751
+ };