pds-dev-kit-web-test 2.7.505 → 2.7.507

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.
@@ -177,7 +177,6 @@ function ContentsCarousel(props) {
177
177
  } }, { children: (0, jsx_runtime_1.jsx)(ContentsCarouselCore_1.default, __assign({ ref: swiperRef, className: "cb-contentscarousel", allowTouchMove: mode !== 'EDIT' ? true : false, onSwiper: onSwiper, onSlideChangeTransitionEnd: onSlideChangeTransitionEnd, onAutoplayTimeLeft: onAutoplayTimeLeft, slidesPerView: displayCounts, styles: isHovered ? contentsCarouselHoverStyle : contentsCarouselNormalStyle, effect: CB_EFFECT_PROP_CONTENTSCAROUSEL_SPEC_TRANSITIONTYPE === null || CB_EFFECT_PROP_CONTENTSCAROUSEL_SPEC_TRANSITIONTYPE === void 0 ? void 0 : CB_EFFECT_PROP_CONTENTSCAROUSEL_SPEC_TRANSITIONTYPE.toLowerCase(), loop: loop, displayCounts: displayCounts }, { children: (0, createCompositions_1.createCompositions)({
178
178
  valueType: CB_CONTENT_PROP_CONTENTSCAROUSEL_SPEC_VALUETYPE,
179
179
  queryPath: queryPath,
180
- // limit: displayCounts,
181
180
  limit: CB_CONTENT_PROP_CONTENTSCAROUSEL_SPEC_VALUETYPE === 'VALUE'
182
181
  ? displayCounts
183
182
  : CB_CONTENT_PROP_CONTENTSCAROUSEL_SPEC_ITEMCOUNTS,
@@ -131,6 +131,9 @@ function Text(props) {
131
131
  };
132
132
  var getTruncatedText = function (text) {
133
133
  var maxLength = props.CB_STYLE_PROP_TEXT.CB_STYLE_PROP_TEXT_SPEC_ELLIPSIS;
134
+ if (isRichText(text)) {
135
+ return domstringToPlain(text, maxLength, true);
136
+ }
134
137
  if (!maxLength) {
135
138
  return text;
136
139
  }
@@ -189,3 +192,41 @@ function getTextOptionStyles(props, device) {
189
192
  });
190
193
  }
191
194
  exports.getTextOptionStyles = getTextOptionStyles;
195
+ /**
196
+ * 텍스트가 Rich Text(HTML)인지 Plain Text인지 판별합니다.
197
+ * @param {string} text - 확인할 문자열
198
+ * @returns {boolean} - HTML 태그가 포함되어 있으면 true
199
+ */
200
+ var isRichText = function (text) {
201
+ if (typeof text !== 'string')
202
+ return false;
203
+ // HTML 태그를 찾는 정규 표현식
204
+ var htmlRegex = /<[a-z][\s\S]*>/i;
205
+ return htmlRegex.test(text);
206
+ };
207
+ function domstringToPlain(domstring, ellipsis, useEnter) {
208
+ var tempDivElement = document.createElement('div');
209
+ tempDivElement.innerHTML = domstring;
210
+ var plainText = tempDivElement.textContent || tempDivElement.innerText;
211
+ // NOTE: 두개 이상의 공백을 ' '로 변경합니다.
212
+ var processedText = plainText.replace(/\s{2,}/gi, ' ');
213
+ if (ellipsis) {
214
+ return processedText.length > ellipsis
215
+ ? "".concat(processedText.slice(0, ellipsis), "...")
216
+ : processedText;
217
+ }
218
+ // NOTE: \n을 ' '으로 변경할지 여부를 확인합니다.
219
+ if (useEnter) {
220
+ processedText = tempDivElement.innerHTML
221
+ .replace(/<br\s*\/?>/gi, '\n') // <br> 태그를 \n으로 변환
222
+ .replace(/<\/p>/gi, '\n') // <p> 종료 태그를 \n으로 변환
223
+ .replace(/&gt;/gi, '>') // &gt;를 > 으로 변환
224
+ .replace(/&lt;/gi, '<') // &lt;를 <으로 변환
225
+ .replace(/&amp;/gi, '&') // &amp;를 &으로 변환
226
+ .replace(/<p[^>]*>/gi, ''); // <p> 태그 제거
227
+ }
228
+ else {
229
+ processedText = processedText.replace(/\n/gi, '<br>');
230
+ }
231
+ return processedText;
232
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pds-dev-kit-web-test",
3
- "version": "2.7.505",
3
+ "version": "2.7.507",
4
4
  "license": "MIT",
5
5
  "private": false,
6
6
  "main": "dist/index.js",