utopia-ui 3.0.0-alpha.176 → 3.0.0-alpha.177

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
@@ -2699,16 +2699,16 @@ var OverlayItemsIndexPage = function (_a) {
2699
2699
  }
2700
2700
  });
2701
2701
  }); };
2702
- return (jsxs(Fragment, { children: [jsx(MapOverlayPage, __assign({ className: 'tw-rounded-none tw-overflow-y-auto tw-bg-base-200 !tw-p-4' }, { children: jsxs("div", __assign({ className: 'tw-flex tw-flex-col tw-h-full' }, { children: [jsx("div", __assign({ className: 'tw-flex-none' }, { children: jsxs(Control, __assign({ position: 'topLeft', zIndex: "1000", absolute: false }, { children: [jsx(SearchControl, {}), jsx(TagsControl, {})] })) })), jsxs("div", __assign({ className: "tw-overflow-scroll fade tw-flex-1 tw-grid tw-grid-cols-1 md:tw-grid-cols-2 lg:tw-grid-cols-3 2xl:tw-grid-cols-4 tw-gap-6 tw-pt-4" }, { children: [(_c = (_b = items === null || items === void 0 ? void 0 : items.filter(function (i) { var _a; return ((_a = i.layer) === null || _a === void 0 ? void 0 : _a.name) === layerName; }).filter(function (item) {
2703
- return filterTags.length == 0 ? item : filterTags.every(function (tag) { return getItemTags(item).some(function (filterTag) { return filterTag.name.toLocaleLowerCase() === tag.name.toLocaleLowerCase(); }); });
2704
- })) === null || _b === void 0 ? void 0 : _b.sort(function (a, b) {
2705
- // Convert date_created to milliseconds, handle undefined by converting to lowest possible date (0 milliseconds)
2706
- var dateA = a.date_updated ? new Date(a.date_updated).getTime() : a.date_created ? new Date(a.date_created).getTime() : 0;
2707
- var dateB = b.date_updated ? new Date(b.date_updated).getTime() : b.date_created ? new Date(b.date_created).getTime() : 0;
2708
- return dateB - dateA; // Subtracts milliseconds which are numbers
2709
- })) === null || _c === void 0 ? void 0 : _c.map(function (i, k) {
2710
- return (jsx(ItemCard, { i: i, loading: loading, url: url, parameterField: parameterField, deleteCallback: function () { return deleteItem(i); } }, k));
2711
- }), addItemPopupType == "place" ?
2702
+ return (jsxs(Fragment, { children: [jsx(MapOverlayPage, __assign({ className: 'tw-rounded-none tw-overflow-y-auto tw-bg-base-200 !tw-p-4' }, { children: jsxs("div", __assign({ className: 'tw-flex tw-flex-col tw-h-full' }, { children: [jsx("div", __assign({ className: 'tw-flex-none' }, { children: jsxs(Control, __assign({ position: 'topLeft', zIndex: "1000", absolute: false }, { children: [jsx(SearchControl, {}), jsx(TagsControl, {})] })) })), jsxs("div", __assign({ className: "tw-overflow-scroll fade tw-flex-1" }, { children: [jsx("div", __assign({ className: 'tw-grid tw-grid-cols-1 md:tw-grid-cols-2 lg:tw-grid-cols-3 2xl:tw-grid-cols-4 tw-gap-6 tw-pt-4' }, { children: (_c = (_b = items === null || items === void 0 ? void 0 : items.filter(function (i) { var _a; return ((_a = i.layer) === null || _a === void 0 ? void 0 : _a.name) === layerName; }).filter(function (item) {
2703
+ return filterTags.length == 0 ? item : filterTags.every(function (tag) { return getItemTags(item).some(function (filterTag) { return filterTag.name.toLocaleLowerCase() === tag.name.toLocaleLowerCase(); }); });
2704
+ })) === null || _b === void 0 ? void 0 : _b.sort(function (a, b) {
2705
+ // Convert date_created to milliseconds, handle undefined by converting to lowest possible date (0 milliseconds)
2706
+ var dateA = a.date_updated ? new Date(a.date_updated).getTime() : a.date_created ? new Date(a.date_created).getTime() : 0;
2707
+ var dateB = b.date_updated ? new Date(b.date_updated).getTime() : b.date_created ? new Date(b.date_created).getTime() : 0;
2708
+ return dateB - dateA; // Subtracts milliseconds which are numbers
2709
+ })) === null || _c === void 0 ? void 0 : _c.map(function (i, k) {
2710
+ return (jsx(ItemCard, { i: i, loading: loading, url: url, parameterField: parameterField, deleteCallback: function () { return deleteItem(i); } }, k));
2711
+ }) })), addItemPopupType == "place" ?
2712
2712
  jsx("form", __assign({ ref: tabRef, autoComplete: 'off', onSubmit: function (e) { return submitNewItem(e); } }, { children: jsxs("div", __assign({ className: 'tw-cursor-pointer tw-card tw-border-[1px] tw-border-base-300 tw-card-body tw-shadow-xl tw-bg-base-100 tw-text-base-content tw-p-6 tw-mb-10' }, { children: [jsx("label", __assign({ className: "tw-btn tw-btn-sm tw-rounded-2xl tw-btn-circle tw-btn-ghost hover:tw-bg-transparent tw-absolute tw-right-0 tw-top-0 tw-text-gray-600", onClick: function () {
2713
2713
  setAddItemPopupType("");
2714
2714
  } }, { children: jsx("p", __assign({ className: 'tw-text-center ' }, { children: "\u2715" })) })), jsx(TextInput, { type: "text", placeholder: "Name", dataField: "name", defaultValue: "", inputStyle: '' }), (layer === null || layer === void 0 ? void 0 : layer.itemType.show_start_end_input) &&
@@ -3333,7 +3333,7 @@ var TextView = function (_a) {
3333
3333
  else
3334
3334
  text = ((_b = item === null || item === void 0 ? void 0 : item.layer) === null || _b === void 0 ? void 0 : _b.itemTextField) && item ? getValue(item, (_c = item.layer) === null || _c === void 0 ? void 0 : _c.itemTextField) : "";
3335
3335
  if (item && text && truncate)
3336
- text = truncateString(text, 100, true);
3336
+ text = truncateText(removeMarkdownKeepLinksAndParagraphs(text), 100);
3337
3337
  var replacedText;
3338
3338
  item && text ? replacedText = fixUrls(text) : "";
3339
3339
  replacedText ? replacedText = replacedText.replace(/(?<!\]?\()https?:\/\/[^\s\)]+(?!\))/g, function (url) {
@@ -3405,25 +3405,20 @@ var TextView = function (_a) {
3405
3405
  return (jsx("a", __assign({ style: { color: tag ? tag.color : '#faa', fontWeight: 'bold', cursor: 'pointer' }, onClick: function (e) {
3406
3406
  e.stopPropagation();
3407
3407
  addFilterTag(tag);
3408
- // map.fitBounds(items)
3409
- // map.closePopup();
3410
3408
  } }, { children: decodeTag(children) }), tag ? tag.name + item.id : item.id));
3411
3409
  };
3412
- return (
3413
- //@ts-ignore
3414
- jsx(Markdown, __assign({ className: "tw-text-map tw-leading-map ", remarkPlugins: [remarkBreaks], components: {
3410
+ return (jsx(Markdown, __assign({ className: "tw-text-map tw-leading-map ", remarkPlugins: [remarkBreaks], components: {
3415
3411
  p: CustomParagraph,
3416
3412
  a: function (_a) {
3417
3413
  var href = _a.href, children = _a.children;
3418
- // Prüft, ob der Link ein YouTube-Video ist
3419
3414
  var isYouTubeVideo = href === null || href === void 0 ? void 0 : href.startsWith('https://www.youtube.com/watch?v=');
3420
3415
  if (isYouTubeVideo) {
3421
- var videoId = href === null || href === void 0 ? void 0 : href.split('v=')[1].split('&')[0]; // Extrahiert die Video-ID aus der URL
3416
+ var videoId = href === null || href === void 0 ? void 0 : href.split('v=')[1].split('&')[0];
3422
3417
  var youtubeEmbedUrl = "https://www.youtube-nocookie.com/embed/".concat(videoId);
3423
3418
  return (jsx("iframe", { className: 'tw-w-full', src: youtubeEmbedUrl, allowFullScreen: true }));
3424
3419
  }
3425
3420
  if (href === null || href === void 0 ? void 0 : href.startsWith("#")) {
3426
- var tag = tags.find(function (t) { return t.name.toLowerCase() == decodeURI(href).slice(1).toLowerCase(); });
3421
+ var tag = tags.find(function (t) { return t.name.toLowerCase() === decodeURI(href).slice(1).toLowerCase(); });
3427
3422
  return jsx(CustomHashTagLink, __assign({ tag: tag, item: item }, { children: children }));
3428
3423
  }
3429
3424
  else {
@@ -3442,14 +3437,37 @@ var TextView = function (_a) {
3442
3437
  h6: CustomH6,
3443
3438
  } }, { children: replacedText })));
3444
3439
  };
3445
- function truncateString(str, n, useWordBoundary) {
3446
- if (str.length <= n) {
3447
- return str;
3440
+ function removeMarkdownKeepLinksAndParagraphs(text) {
3441
+ // Remove Markdown syntax using regular expressions but keep links and paragraphs
3442
+ return text
3443
+ .replace(/!\[.*?\]\(.*?\)/g, '') // Remove images
3444
+ .replace(/(`{1,3})(.*?)\1/g, '$2') // Remove inline code
3445
+ .replace(/(\*{1,2}|_{1,2})(.*?)\1/g, '$2') // Remove bold and italic
3446
+ .replace(/(#+)\s+(.*)/g, '$2') // Remove headers
3447
+ .replace(/>\s+(.*)/g, '$1') // Remove blockquotes
3448
+ .replace(/^\s*\n/gm, '\n') // Preserve empty lines
3449
+ .replace(/(\r\n|\n|\r)/gm, '\n'); // Preserve line breaks
3450
+ }
3451
+ function truncateText(text, limit) {
3452
+ if (text.length <= limit) {
3453
+ return text;
3454
+ }
3455
+ var truncated = "";
3456
+ var length = 0;
3457
+ // Split the text by paragraphs
3458
+ var paragraphs = text.split('\n');
3459
+ for (var _i = 0, paragraphs_1 = paragraphs; _i < paragraphs_1.length; _i++) {
3460
+ var paragraph = paragraphs_1[_i];
3461
+ if (length + paragraph.length > limit) {
3462
+ truncated += paragraph.slice(0, limit - length) + '...';
3463
+ break;
3464
+ }
3465
+ else {
3466
+ truncated += paragraph + '\n';
3467
+ length += paragraph.length;
3468
+ }
3448
3469
  }
3449
- var subString = str.slice(0, n - 1); // the original check
3450
- return (useWordBoundary
3451
- ? subString.slice(0, subString.lastIndexOf(" "))
3452
- : subString) + "&hellip;";
3470
+ return truncated.trim();
3453
3471
  }
3454
3472
 
3455
3473
  var ItemViewPopup = React.forwardRef(function (props, ref) {