@limetech/lime-crm-building-blocks 1.75.0 → 1.76.0

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/CHANGELOG.md CHANGED
@@ -1,3 +1,10 @@
1
+ ## [1.76.0](https://github.com/Lundalogik/lime-crm-building-blocks/compare/v1.75.0...v1.76.0) (2025-05-08)
2
+
3
+ ### Features
4
+
5
+
6
+ * **text editor:** fix drafts triggering multiple delete operations ([28f4daf](https://github.com/Lundalogik/lime-crm-building-blocks/commit/28f4daf5581a3b7e46f6f920847b9addb3c059a7))
7
+
1
8
  ## [1.75.0](https://github.com/Lundalogik/lime-crm-building-blocks/compare/v1.74.0...v1.75.0) (2025-05-08)
2
9
 
3
10
  ### Features
@@ -1904,17 +1904,19 @@ const LimeBBTextEditor = class {
1904
1904
  }
1905
1905
  }
1906
1906
  saveDraft() {
1907
- var _a, _b, _c;
1907
+ var _a, _b, _c, _d;
1908
1908
  if (!this.textEditorInnerId) {
1909
1909
  return;
1910
1910
  }
1911
- if ((_a = this.value) === null || _a === void 0 ? void 0 : _a.trim()) {
1912
- // Save the draft
1913
- (_b = this.userDataService) === null || _b === void 0 ? void 0 : _b.set(this.textEditorInnerId, this.value);
1911
+ const currentValue = (_a = this.value) === null || _a === void 0 ? void 0 : _a.trim();
1912
+ const existingDraft = (_b = this.userDataService) === null || _b === void 0 ? void 0 : _b.get(this.textEditorInnerId);
1913
+ // Save draft
1914
+ if (currentValue && currentValue !== existingDraft) {
1915
+ (_c = this.userDataService) === null || _c === void 0 ? void 0 : _c.set(this.textEditorInnerId, currentValue);
1914
1916
  }
1915
- else {
1916
- // Delete the draft
1917
- (_c = this.userDataService) === null || _c === void 0 ? void 0 : _c.set(this.textEditorInnerId, undefined);
1917
+ // Delete draft
1918
+ else if (!currentValue && existingDraft) {
1919
+ (_d = this.userDataService) === null || _d === void 0 ? void 0 : _d.set(this.textEditorInnerId, undefined);
1918
1920
  }
1919
1921
  }
1920
1922
  get userDataService() {
@@ -425,17 +425,19 @@ export class LimeBBTextEditor {
425
425
  }
426
426
  }
427
427
  saveDraft() {
428
- var _a, _b, _c;
428
+ var _a, _b, _c, _d;
429
429
  if (!this.textEditorInnerId) {
430
430
  return;
431
431
  }
432
- if ((_a = this.value) === null || _a === void 0 ? void 0 : _a.trim()) {
433
- // Save the draft
434
- (_b = this.userDataService) === null || _b === void 0 ? void 0 : _b.set(this.textEditorInnerId, this.value);
432
+ const currentValue = (_a = this.value) === null || _a === void 0 ? void 0 : _a.trim();
433
+ const existingDraft = (_b = this.userDataService) === null || _b === void 0 ? void 0 : _b.get(this.textEditorInnerId);
434
+ // Save draft
435
+ if (currentValue && currentValue !== existingDraft) {
436
+ (_c = this.userDataService) === null || _c === void 0 ? void 0 : _c.set(this.textEditorInnerId, currentValue);
435
437
  }
436
- else {
437
- // Delete the draft
438
- (_c = this.userDataService) === null || _c === void 0 ? void 0 : _c.set(this.textEditorInnerId, undefined);
438
+ // Delete draft
439
+ else if (!currentValue && existingDraft) {
440
+ (_d = this.userDataService) === null || _d === void 0 ? void 0 : _d.set(this.textEditorInnerId, undefined);
439
441
  }
440
442
  }
441
443
  get userDataService() {
@@ -1903,17 +1903,19 @@ const LimeBBTextEditor = /*@__PURE__*/ proxyCustomElement(class LimeBBTextEditor
1903
1903
  }
1904
1904
  }
1905
1905
  saveDraft() {
1906
- var _a, _b, _c;
1906
+ var _a, _b, _c, _d;
1907
1907
  if (!this.textEditorInnerId) {
1908
1908
  return;
1909
1909
  }
1910
- if ((_a = this.value) === null || _a === void 0 ? void 0 : _a.trim()) {
1911
- // Save the draft
1912
- (_b = this.userDataService) === null || _b === void 0 ? void 0 : _b.set(this.textEditorInnerId, this.value);
1910
+ const currentValue = (_a = this.value) === null || _a === void 0 ? void 0 : _a.trim();
1911
+ const existingDraft = (_b = this.userDataService) === null || _b === void 0 ? void 0 : _b.get(this.textEditorInnerId);
1912
+ // Save draft
1913
+ if (currentValue && currentValue !== existingDraft) {
1914
+ (_c = this.userDataService) === null || _c === void 0 ? void 0 : _c.set(this.textEditorInnerId, currentValue);
1913
1915
  }
1914
- else {
1915
- // Delete the draft
1916
- (_c = this.userDataService) === null || _c === void 0 ? void 0 : _c.set(this.textEditorInnerId, undefined);
1916
+ // Delete draft
1917
+ else if (!currentValue && existingDraft) {
1918
+ (_d = this.userDataService) === null || _d === void 0 ? void 0 : _d.set(this.textEditorInnerId, undefined);
1917
1919
  }
1918
1920
  }
1919
1921
  get userDataService() {
@@ -1900,17 +1900,19 @@ const LimeBBTextEditor = class {
1900
1900
  }
1901
1901
  }
1902
1902
  saveDraft() {
1903
- var _a, _b, _c;
1903
+ var _a, _b, _c, _d;
1904
1904
  if (!this.textEditorInnerId) {
1905
1905
  return;
1906
1906
  }
1907
- if ((_a = this.value) === null || _a === void 0 ? void 0 : _a.trim()) {
1908
- // Save the draft
1909
- (_b = this.userDataService) === null || _b === void 0 ? void 0 : _b.set(this.textEditorInnerId, this.value);
1907
+ const currentValue = (_a = this.value) === null || _a === void 0 ? void 0 : _a.trim();
1908
+ const existingDraft = (_b = this.userDataService) === null || _b === void 0 ? void 0 : _b.get(this.textEditorInnerId);
1909
+ // Save draft
1910
+ if (currentValue && currentValue !== existingDraft) {
1911
+ (_c = this.userDataService) === null || _c === void 0 ? void 0 : _c.set(this.textEditorInnerId, currentValue);
1910
1912
  }
1911
- else {
1912
- // Delete the draft
1913
- (_c = this.userDataService) === null || _c === void 0 ? void 0 : _c.set(this.textEditorInnerId, undefined);
1913
+ // Delete draft
1914
+ else if (!currentValue && existingDraft) {
1915
+ (_d = this.userDataService) === null || _d === void 0 ? void 0 : _d.set(this.textEditorInnerId, undefined);
1914
1916
  }
1915
1917
  }
1916
1918
  get userDataService() {
@@ -1 +1 @@
1
- import{p as e,b as t}from"./p-b11e09b4.js";export{s as setNonce}from"./p-b11e09b4.js";import{g as i}from"./p-e1255160.js";(()=>{const t=import.meta.url,i={};return""!==t&&(i.resourcesUrl=new URL(".",t).href),e(i)})().then((async e=>(await i(),t([["p-16090238",[[1,"limebb-feed",{platform:[16],context:[16],items:[16],emptyStateMessage:[1,"empty-state-message"],heading:[1],loading:[4],minutesOfProximity:[2,"minutes-of-proximity"],totalCount:[2,"total-count"],direction:[1],lastVisitedTimestamp:[1,"last-visited-timestamp"]}]]],["p-974c3022",[[1,"limebb-kanban",{platform:[16],context:[16],groups:[16]}]]],["p-1ae11e57",[[1,"limebb-chat-list",{platform:[16],context:[16],items:[16],loading:[516],isTypingIndicatorVisible:[516,"is-typing-indicator-visible"],lastVisitedTimestamp:[513,"last-visited-timestamp"],order:[513]},null,{items:["handleItemsChange"]}]]],["p-3ea1399f",[[1,"limebb-text-editor",{platform:[16],context:[16],allowMentioning:[4,"allow-mentioning"],contentType:[1,"content-type"],language:[513],disabled:[516],readonly:[516],helperText:[513,"helper-text"],placeholder:[513],label:[513],invalid:[516],required:[516],selectedContext:[16],ui:[513],allowResize:[4,"allow-resize"],value:[1],draftIdentifier:[1,"draft-identifier"],triggerMap:[16],customElements:[16],allowInlineImages:[4,"allow-inline-images"],items:[32],highlightedItemIndex:[32],editorPickerQuery:[32],searchableLimetypes:[32],isPickerOpen:[32],isSearching:[32]},null,{isPickerOpen:["watchOpen"],editorPickerQuery:["watchQuery"]}]]],["p-543ebe99",[[1,"limebb-date-range",{platform:[16],context:[16],startTime:[16],endTime:[16],startTimeLabel:[1,"start-time-label"],endTimeLabel:[1,"end-time-label"],language:[1],timeFormat:[1,"time-format"],type:[1]}]]],["p-bed2fa73",[[1,"limebb-info-tile-currency-format",{platform:[16],context:[16],value:[16]}]]],["p-063681c6",[[1,"limebb-notification-list",{platform:[16],context:[16],items:[16],loading:[4],lastVisitedTimestamp:[1,"last-visited-timestamp"]},null,{items:["handleItemsChange"]}]]],["p-769e6d21",[[17,"limebb-browser",{platform:[16],context:[16],items:[16],layout:[1],filter:[32]}]]],["p-3310a5aa",[[1,"limebb-component-config",{platform:[16],context:[16],value:[16],required:[4],readonly:[4],disabled:[4],label:[1],helperText:[1,"helper-text"],formInfo:[16],type:[1],nameField:[1,"name-field"],configComponent:[32],configViewType:[32]},null,{formInfo:["watchFormInfo"],configComponent:["watchconfigComponent"]}]]],["p-306b2ff4",[[1,"limebb-component-picker",{platform:[16],context:[16],type:[1],tags:[16],value:[1],copyLabel:[1,"copy-label"],hideCopyButton:[4,"hide-copy-button"],required:[4],readonly:[4],disabled:[4],label:[1],helperText:[1,"helper-text"]}]]],["p-b0203a8c",[[1,"limebb-dashboard-widget",{heading:[513],subheading:[513],supportingText:[513,"supporting-text"],icon:[513]}]]],["p-073910fe",[[1,"limebb-icon-picker",{value:[1],required:[4],readonly:[4],invalid:[4],disabled:[4],label:[1],helperText:[1,"helper-text"]}]]],["p-d8bd4e7f",[[1,"limebb-info-tile",{platform:[16],context:[16],filterId:[513,"filter-id"],disabled:[4],icon:[513],label:[1],prefix:[1],suffix:[1],propertyName:[1,"property-name"],aggregateOperator:[1,"aggregate-operator"],format:[16],config:[32],filters:[32],value:[32],loading:[32],error:[32]},null,{filterId:["watchFilterId"],propertyName:["watchPropertyName"],aggregateOperator:["watchAggregateOperator"]}]]],["p-29c74b32",[[1,"limebb-info-tile-date-format",{value:[16]}]]],["p-a50a02bd",[[1,"limebb-info-tile-decimal-format",{value:[16]}]]],["p-00ca5cd7",[[1,"limebb-info-tile-format",{platform:[16],context:[16],type:[1],value:[16]}]]],["p-fefcc3c1",[[1,"limebb-info-tile-relative-date-format",{value:[16]}]]],["p-95e1d1c3",[[1,"limebb-info-tile-unit-format",{value:[16]}]]],["p-fc97d0d1",[[1,"limebb-limeobject-file-viewer",{platform:[16],context:[16],property:[1],fileTypes:[16],limeobject:[32],limetype:[32]}]]],["p-dc4eef4a",[[1,"limebb-locale-picker",{platform:[16],context:[16],value:[1],required:[4],disabled:[4],label:[1],helperText:[1,"helper-text"],readonly:[4],multipleChoice:[4,"multiple-choice"],allLanguages:[32]}]]],["p-9e2dab17",[[1,"limebb-mention",{limetype:[1],objectid:[2],limeobject:[32]}]]],["p-bd2f82da",[[1,"limebb-mention-group-counter",{count:[2],limetype:[16],helperLabel:[1,"helper-label"]}]]],["p-8ad6edc1",[[1,"limebb-trend-indicator",{platform:[16],context:[16],value:[520],formerValue:[514,"former-value"],suffix:[513],label:[513],invalid:[516],helperText:[513,"helper-text"],reducePresence:[516,"reduce-presence"]},null,{value:["valueChanged"]}]]],["p-e758610c",[[1,"limebb-summary-popover",{triggerDelay:[514,"trigger-delay"],heading:[513],subheading:[513],image:[16],icon:[513],value:[1],openDirection:[513,"open-direction"],popoverMaxWidth:[513,"popover-max-width"],popoverMaxHeight:[513,"popover-max-height"],actions:[16],isPopoverOpen:[32]}],[17,"limebb-navigation-button",{href:[513],tooltipLabel:[513,"tooltip-label"],tooltipHelperLabel:[513,"tooltip-helper-label"],type:[513]}]]],["p-a706c960",[[1,"limebb-kanban-item",{platform:[16],context:[16],item:[16]}]]],["p-a6032d94",[[1,"limebb-kanban-group",{platform:[16],context:[16],identifier:[1],heading:[513],help:[1],items:[16],summary:[1],loading:[516],totalCount:[514,"total-count"]}]]],["p-caa39329",[[1,"limebb-feed-timeline-item",{platform:[16],context:[16],item:[16],ui:[513],isBundled:[516,"is-bundled"],headingCanExpand:[32],isHeadingExpanded:[32],showMore:[32],isTall:[32]}]]],["p-62343f2e",[[1,"limebb-text-editor-picker",{items:[16],open:[516],isSearching:[4,"is-searching"],emptyMessage:[1,"empty-message"]},null,{open:["watchOpen"]}]]],["p-45c6322f",[[1,"limebb-currency-picker",{platform:[16],context:[16],label:[513],currencies:[16],helperText:[513,"helper-text"],required:[516],readonly:[516],invalid:[516],disabled:[516],value:[1]}]]],["p-7a80a8a2",[[1,"limebb-date-picker",{platform:[16],context:[16],disabled:[516],readonly:[516],invalid:[516],label:[513],placeholder:[513],helperText:[513,"helper-text"],required:[516],value:[1],type:[513]}]]],["p-c1a1b28a",[[1,"limebb-notification-item",{platform:[16],context:[16],item:[16]}]]],["p-eb41977d",[[1,"limebb-chat-item",{platform:[16],context:[16],item:[16],helperText:[1,"helper-text"],hasError:[516,"has-error"]}],[1,"limebb-typing-indicator"]]],["p-1a07c942",[[1,"limebb-empty-state",{heading:[513],value:[513],icon:[16]}]]]],e))));
1
+ import{p as e,b as t}from"./p-b11e09b4.js";export{s as setNonce}from"./p-b11e09b4.js";import{g as i}from"./p-e1255160.js";(()=>{const t=import.meta.url,i={};return""!==t&&(i.resourcesUrl=new URL(".",t).href),e(i)})().then((async e=>(await i(),t([["p-16090238",[[1,"limebb-feed",{platform:[16],context:[16],items:[16],emptyStateMessage:[1,"empty-state-message"],heading:[1],loading:[4],minutesOfProximity:[2,"minutes-of-proximity"],totalCount:[2,"total-count"],direction:[1],lastVisitedTimestamp:[1,"last-visited-timestamp"]}]]],["p-974c3022",[[1,"limebb-kanban",{platform:[16],context:[16],groups:[16]}]]],["p-1ae11e57",[[1,"limebb-chat-list",{platform:[16],context:[16],items:[16],loading:[516],isTypingIndicatorVisible:[516,"is-typing-indicator-visible"],lastVisitedTimestamp:[513,"last-visited-timestamp"],order:[513]},null,{items:["handleItemsChange"]}]]],["p-64e2496b",[[1,"limebb-text-editor",{platform:[16],context:[16],allowMentioning:[4,"allow-mentioning"],contentType:[1,"content-type"],language:[513],disabled:[516],readonly:[516],helperText:[513,"helper-text"],placeholder:[513],label:[513],invalid:[516],required:[516],selectedContext:[16],ui:[513],allowResize:[4,"allow-resize"],value:[1],draftIdentifier:[1,"draft-identifier"],triggerMap:[16],customElements:[16],allowInlineImages:[4,"allow-inline-images"],items:[32],highlightedItemIndex:[32],editorPickerQuery:[32],searchableLimetypes:[32],isPickerOpen:[32],isSearching:[32]},null,{isPickerOpen:["watchOpen"],editorPickerQuery:["watchQuery"]}]]],["p-543ebe99",[[1,"limebb-date-range",{platform:[16],context:[16],startTime:[16],endTime:[16],startTimeLabel:[1,"start-time-label"],endTimeLabel:[1,"end-time-label"],language:[1],timeFormat:[1,"time-format"],type:[1]}]]],["p-bed2fa73",[[1,"limebb-info-tile-currency-format",{platform:[16],context:[16],value:[16]}]]],["p-063681c6",[[1,"limebb-notification-list",{platform:[16],context:[16],items:[16],loading:[4],lastVisitedTimestamp:[1,"last-visited-timestamp"]},null,{items:["handleItemsChange"]}]]],["p-769e6d21",[[17,"limebb-browser",{platform:[16],context:[16],items:[16],layout:[1],filter:[32]}]]],["p-3310a5aa",[[1,"limebb-component-config",{platform:[16],context:[16],value:[16],required:[4],readonly:[4],disabled:[4],label:[1],helperText:[1,"helper-text"],formInfo:[16],type:[1],nameField:[1,"name-field"],configComponent:[32],configViewType:[32]},null,{formInfo:["watchFormInfo"],configComponent:["watchconfigComponent"]}]]],["p-306b2ff4",[[1,"limebb-component-picker",{platform:[16],context:[16],type:[1],tags:[16],value:[1],copyLabel:[1,"copy-label"],hideCopyButton:[4,"hide-copy-button"],required:[4],readonly:[4],disabled:[4],label:[1],helperText:[1,"helper-text"]}]]],["p-b0203a8c",[[1,"limebb-dashboard-widget",{heading:[513],subheading:[513],supportingText:[513,"supporting-text"],icon:[513]}]]],["p-073910fe",[[1,"limebb-icon-picker",{value:[1],required:[4],readonly:[4],invalid:[4],disabled:[4],label:[1],helperText:[1,"helper-text"]}]]],["p-d8bd4e7f",[[1,"limebb-info-tile",{platform:[16],context:[16],filterId:[513,"filter-id"],disabled:[4],icon:[513],label:[1],prefix:[1],suffix:[1],propertyName:[1,"property-name"],aggregateOperator:[1,"aggregate-operator"],format:[16],config:[32],filters:[32],value:[32],loading:[32],error:[32]},null,{filterId:["watchFilterId"],propertyName:["watchPropertyName"],aggregateOperator:["watchAggregateOperator"]}]]],["p-29c74b32",[[1,"limebb-info-tile-date-format",{value:[16]}]]],["p-a50a02bd",[[1,"limebb-info-tile-decimal-format",{value:[16]}]]],["p-00ca5cd7",[[1,"limebb-info-tile-format",{platform:[16],context:[16],type:[1],value:[16]}]]],["p-fefcc3c1",[[1,"limebb-info-tile-relative-date-format",{value:[16]}]]],["p-95e1d1c3",[[1,"limebb-info-tile-unit-format",{value:[16]}]]],["p-fc97d0d1",[[1,"limebb-limeobject-file-viewer",{platform:[16],context:[16],property:[1],fileTypes:[16],limeobject:[32],limetype:[32]}]]],["p-dc4eef4a",[[1,"limebb-locale-picker",{platform:[16],context:[16],value:[1],required:[4],disabled:[4],label:[1],helperText:[1,"helper-text"],readonly:[4],multipleChoice:[4,"multiple-choice"],allLanguages:[32]}]]],["p-9e2dab17",[[1,"limebb-mention",{limetype:[1],objectid:[2],limeobject:[32]}]]],["p-bd2f82da",[[1,"limebb-mention-group-counter",{count:[2],limetype:[16],helperLabel:[1,"helper-label"]}]]],["p-8ad6edc1",[[1,"limebb-trend-indicator",{platform:[16],context:[16],value:[520],formerValue:[514,"former-value"],suffix:[513],label:[513],invalid:[516],helperText:[513,"helper-text"],reducePresence:[516,"reduce-presence"]},null,{value:["valueChanged"]}]]],["p-e758610c",[[1,"limebb-summary-popover",{triggerDelay:[514,"trigger-delay"],heading:[513],subheading:[513],image:[16],icon:[513],value:[1],openDirection:[513,"open-direction"],popoverMaxWidth:[513,"popover-max-width"],popoverMaxHeight:[513,"popover-max-height"],actions:[16],isPopoverOpen:[32]}],[17,"limebb-navigation-button",{href:[513],tooltipLabel:[513,"tooltip-label"],tooltipHelperLabel:[513,"tooltip-helper-label"],type:[513]}]]],["p-a706c960",[[1,"limebb-kanban-item",{platform:[16],context:[16],item:[16]}]]],["p-a6032d94",[[1,"limebb-kanban-group",{platform:[16],context:[16],identifier:[1],heading:[513],help:[1],items:[16],summary:[1],loading:[516],totalCount:[514,"total-count"]}]]],["p-caa39329",[[1,"limebb-feed-timeline-item",{platform:[16],context:[16],item:[16],ui:[513],isBundled:[516,"is-bundled"],headingCanExpand:[32],isHeadingExpanded:[32],showMore:[32],isTall:[32]}]]],["p-62343f2e",[[1,"limebb-text-editor-picker",{items:[16],open:[516],isSearching:[4,"is-searching"],emptyMessage:[1,"empty-message"]},null,{open:["watchOpen"]}]]],["p-45c6322f",[[1,"limebb-currency-picker",{platform:[16],context:[16],label:[513],currencies:[16],helperText:[513,"helper-text"],required:[516],readonly:[516],invalid:[516],disabled:[516],value:[1]}]]],["p-7a80a8a2",[[1,"limebb-date-picker",{platform:[16],context:[16],disabled:[516],readonly:[516],invalid:[516],label:[513],placeholder:[513],helperText:[513,"helper-text"],required:[516],value:[1],type:[513]}]]],["p-c1a1b28a",[[1,"limebb-notification-item",{platform:[16],context:[16],item:[16]}]]],["p-eb41977d",[[1,"limebb-chat-item",{platform:[16],context:[16],item:[16],helperText:[1,"helper-text"],hasError:[516,"has-error"]}],[1,"limebb-typing-indicator"]]],["p-1a07c942",[[1,"limebb-empty-state",{heading:[513],value:[513],icon:[16]}]]]],e))));
@@ -1 +1 @@
1
- import{r as t,c as i,h as e,g as r}from"./p-b11e09b4.js";import{P as s,A as n}from"./p-a26d352f.js";import{a as o}from"./p-54d4113a.js";import{A as a,a as h,b as c,E as u,T as f}from"./p-463d3174.js";import{d,b as l,k as v,c as b,s as p,a as m,e as g,U as y,S as j,g as w}from"./p-bcc23575.js";import{i as O,e as S}from"./p-c40a3f4b.js";import{d as k,r as x,S as I,a as A,i as T}from"./p-b31772c8.js";import{d as C,i as M,o as E,g as F,h as P,n as $,a as _}from"./p-5322fd19.js";import{i as N}from"./p-6fd28e32.js";import"./p-22de5a0e.js";var D=/\s/,L=/^\s+/;var R=NaN,U=/^[-+]0x[0-9a-f]+$/i,z=/^0b[01]+$/i,G=/^0o[0-7]+$/i,Q=parseInt;function W(t){if("number"==typeof t)return t;if(O(t))return R;if(k(t)){var i="function"==typeof t.valueOf?t.valueOf():t;t=k(i)?i+"":i}if("string"!=typeof t)return 0===t?t:+t;var e;t=(e=t)?e.slice(0,function(t){for(var i=t.length;i--&&D.test(t.charAt(i)););return i}(e)+1).replace(L,""):e;var r=z.test(t);return r||G.test(t)?Q(t.slice(2),r?2:8):U.test(t)?R:+t}var q=Object.create;const B=function(){function t(){}return function(i){if(!k(i))return{};if(q)return q(i);t.prototype=i;var e=new t;return t.prototype=void 0,e}}();function H(t,i,e){"__proto__"==i&&d?d(t,i,{configurable:!0,enumerable:!0,value:e,writable:!0}):t[i]=e}var K=Object.prototype.hasOwnProperty;function V(t,i,e){var r=t[i];K.call(t,i)&&S(r,e)&&(void 0!==e||i in t)||H(t,i,e)}function J(t,i,e,r){var s=!e;e||(e={});for(var n=-1,o=i.length;++n<o;){var a=i[n],h=r?r(e[a],t[a],a,e,t):void 0;void 0===h&&(h=t[a]),s?H(e,a,h):V(e,a,h)}return e}var X=Object.prototype.hasOwnProperty;function Y(t){return M(t)?l(t,!0):function(t){if(!k(t))return function(t){var i=[];if(null!=t)for(var e in Object(t))i.push(e);return i}(t);var i=C(t),e=[];for(var r in t)("constructor"!=r||!i&&X.call(t,r))&&e.push(r);return e}(t)}const Z=E(Object.getPrototypeOf,Object);var tt="object"==typeof exports&&exports&&!exports.nodeType&&exports,it=tt&&"object"==typeof module&&module&&!module.nodeType&&module,et=it&&it.exports===tt?x.Buffer:void 0,rt=et?et.allocUnsafe:void 0;const st=Object.getOwnPropertySymbols?function(t){for(var i=[];t;)m(i,b(t)),t=Z(t);return i}:p;function nt(t){return g(t,Y,st)}var ot=Object.prototype.hasOwnProperty;function at(t){var i=new t.constructor(t.byteLength);return new y(i).set(new y(t)),i}var ht=/\w*$/,ct=I?I.prototype:void 0,ut=ct?ct.valueOf:void 0,ft="[object Boolean]",dt="[object Date]",lt="[object Map]",vt="[object Number]",bt="[object RegExp]",pt="[object Set]",mt="[object String]",gt="[object Symbol]",yt="[object ArrayBuffer]",jt="[object DataView]",wt="[object Float32Array]",Ot="[object Float64Array]",St="[object Int8Array]",kt="[object Int16Array]",xt="[object Int32Array]",It="[object Uint8Array]",At="[object Uint8ClampedArray]",Tt="[object Uint16Array]",Ct="[object Uint32Array]";var Mt=$&&$.isMap;const Et=Mt?P(Mt):function(t){return A(t)&&"[object Map]"==F(t)};var Ft=$&&$.isSet;const Pt=Ft?P(Ft):function(t){return A(t)&&"[object Set]"==F(t)};var $t=1,_t=2,Nt=4,Dt="[object Arguments]",Lt="[object Function]",Rt="[object GeneratorFunction]",Ut="[object Object]",zt={};function Gt(t,i,e,r,s,n){var o,a=i&$t,h=i&_t,c=i&Nt;if(e&&(o=s?e(t,r,s,n):e(t)),void 0!==o)return o;if(!k(t))return t;var u=T(t);if(u){if(o=function(t){var i=t.length,e=new t.constructor(i);return i&&"string"==typeof t[0]&&ot.call(t,"index")&&(e.index=t.index,e.input=t.input),e}(t),!a)return function(t,i){var e=-1,r=t.length;for(i||(i=Array(r));++e<r;)i[e]=t[e];return i}(t,o)}else{var f=F(t),d=f==Lt||f==Rt;if(_(t))return function(t,i){if(i)return t.slice();var e=t.length,r=rt?rt(e):new t.constructor(e);return t.copy(r),r}(t,a);if(f==Ut||f==Dt||d&&!s){if(o=h||d?{}:function(t){return"function"!=typeof t.constructor||C(t)?{}:B(Z(t))}(t),!a)return h?function(t,i){return J(t,st(t),i)}(t,function(t,i){return t&&J(i,Y(i),t)}(o,t)):function(t,i){return J(t,b(t),i)}(t,function(t,i){return t&&J(i,v(i),t)}(o,t))}else{if(!zt[f])return s?t:{};o=function(t,i,e){var r,s,n=t.constructor;switch(i){case yt:return at(t);case ft:case dt:return new n(+t);case jt:return function(t,i){var e=i?at(t.buffer):t.buffer;return new t.constructor(e,t.byteOffset,t.byteLength)}(t,e);case wt:case Ot:case St:case kt:case xt:case It:case At:case Tt:case Ct:return function(t,i){var e=i?at(t.buffer):t.buffer;return new t.constructor(e,t.byteOffset,t.length)}(t,e);case lt:return new n;case vt:case mt:return new n(t);case bt:return(s=new(r=t).constructor(r.source,ht.exec(r))).lastIndex=r.lastIndex,s;case pt:return new n;case gt:return ut?Object(ut.call(t)):{}}}(t,f,a)}}n||(n=new j);var l=n.get(t);if(l)return l;n.set(t,o),Pt(t)?t.forEach((function(r){o.add(Gt(r,i,e,r,t,n))})):Et(t)&&t.forEach((function(r,s){o.set(s,Gt(r,i,e,s,t,n))}));var p=u?void 0:(c?h?nt:w:h?Y:v)(t);return function(t,i){for(var e=-1,r=null==t?0:t.length;++e<r&&!1!==i(t[e],e););}(p||t,(function(r,s){p&&(r=t[s=r]),V(o,s,Gt(r,i,e,s,t,n))})),o}zt[Dt]=zt["[object Array]"]=zt["[object ArrayBuffer]"]=zt["[object DataView]"]=zt["[object Boolean]"]=zt["[object Date]"]=zt["[object Float32Array]"]=zt["[object Float64Array]"]=zt["[object Int8Array]"]=zt["[object Int16Array]"]=zt["[object Int32Array]"]=zt["[object Map]"]=zt["[object Number]"]=zt[Ut]=zt["[object RegExp]"]=zt["[object Set]"]=zt["[object String]"]=zt["[object Symbol]"]=zt["[object Uint8Array]"]=zt["[object Uint8ClampedArray]"]=zt["[object Uint16Array]"]=zt["[object Uint32Array]"]=!0,zt["[object Error]"]=zt[Lt]=zt["[object WeakMap]"]=!1;const Qt=function(){return x.Date.now()};var Wt=Math.max,qt=Math.min;function Bt(t,i){return t.label===i}function Ht(t,i){return Object.values(t.properties).find((t=>t&&t.relation&&Bt(t.relation.getLimetype(),i)))}function Kt(t,i){const e=Ht(t,i);return!!e&&function(t){return function(t){return t&&["belongsto","hasone","hasmany","hasandbelongstomany"].includes(t.type)}(t)&&!function(t){return t&&["belongsto","hasone"].includes(t.type)}(t)}(e)}class Vt{get limeObjectService(){return this.platform.get(s.LimeObjectRepository)}get queryService(){return this.platform.get(s.Query)}get viewFactoryRegistry(){return this.platform.get(s.ViewFactoryRegistry)}get translator(){var t;return null===(t=this.platform)||void 0===t?void 0:t.get(s.Translate)}get triggerCharacter(){return this._triggerCharacter}get triggerHandler(){return this._triggerHandler}constructor(t,i,e){this.platform=t,this.context=i,this.searchableLimetypes=e,this.groupCounts={},this._triggerCharacter="@",this._triggerHandler={searcher:t=>this.searcher(t),inserter:(t,i)=>this.inserter(t,i),emptySearchMessage:"Start typing a name...",noItemsFoundMessage:"No results for your search...",nodeDefinition:{customElement:{tagName:"limebb-mention",attributes:["limetype","objectid","href"]},mapAttributes:t=>({limetype:t.value.getLimetype().name,objectid:t.value.id,href:`object/${this.context.limetype}/${this.context.id}`})}},this.searcher=async t=>{if(!t)return[];const{objects:i}=await this.limeObjectService.search(t,this.searchableLimetypes,10);return this.createSearchListItems(i)},this.inserter=async(t,i)=>{var e;const r=this.triggerHandler.nodeDefinition;r&&t.insert({node:{tagName:r.customElement.tagName,attributes:r.mapAttributes(i)},children:[null===(e=i.value)||void 0===e?void 0:e.descriptive]})}}async initialize(){await this.loadGroupCounts()}async loadGroupCounts(){const t=this.searchableLimetypes.filter((t=>!Bt(t,"user")&&Kt(t,"user"))).map((t=>this.getGroupCounts(t)));(await Promise.all(t)).forEach((t=>{Object.assign(this.groupCounts,t)}))}async getGroupCounts(t){var i;const e=Ht(t,"user"),r=t.name;try{const t=await this.queryService.execute({limetype:r,responseFormat:{object:{_id:null,[e.name]:{count:{aggregate:{op:n.Count}}}}}});if(!(null===(i=t.objects)||void 0===i?void 0:i.length))return{[r]:{}};const s=this.createGroupCount(t.objects,e.name);return{[r]:s}}catch(i){return console.error(`Error fetching group count for limetype: ${t.name}`,i),{[r]:{}}}}createGroupCount(t,i){const e={};return t.forEach((t=>{const{_id:r,[i]:s}=t;e[r]=s.count})),e}createSearchListItems(t=[]){return t.map((t=>this.createSearchListItem(t))).filter(N)}createSearchListItem(t){const i=this.viewFactoryRegistry.getFactory("search"),e=this.limeObjectService.getObject(t._limetype,t._id);if(!e)return null;const r=i(e,this.context),s=this.getGroupCountComponent(e);return Object.assign(Object.assign({},r),s?{primaryComponent:s}:{})}getGroupCountComponent(t){var i;const e=t.getLimetype(),r=null===(i=this.groupCounts[e.name])||void 0===i?void 0:i[t.id],s=Ht(e,"user");if(void 0!==r&&s)return{name:"limebb-mention-group-counter",props:{count:r,limetype:s.relation.getLimetype(),helperLabel:this.translator.get("webclient.notification-center.members-will-be-notified")}}}}class Jt{constructor(t,i){this.file=t,this.http=i,this.uploadCancelled=!1,this.getUrl=t=>`api/v1/file/${t||""}`}async initialize(){this.uploadService=await this.http.createFileUpload("POST",this.getUrl(),this.file),this.progressCallback&&(this.uploadService.onProgress=this.progressCallback)}async upload(){return this.uploadService.upload()}getFileName(){return this.file.name}cancel(){this.uploadService.cancel(),this.uploadCancelled=!0}set onProgress(t){this.progressCallback=t,this.uploadService&&(this.uploadService.onProgress=t)}}class Xt{constructor(t){this.platform=t}async handleImagePasted(t){const i=null==t?void 0:t.fileInfo;if(!i)return;if(!this.validateImageSize(i))return;t.insertThumbnail();const e=await this.createFileUpload(i),r=null==e?void 0:e.href;return r&&void 0!==(null==e?void 0:e.fileId)?t.insertImage(r):t.insertFailedThumbnail(),e}parseFileIdFromSrc(t){if(t){const i=/\/(\d+)\/contents\/?$/.exec(t);if(i&&i[1])return Number(i[1])}}validateImageSize(t){return!!t.fileContent&&t.fileContent.size<=52428800}async createFileUpload(t){var i;if(!t.fileContent)return;const e=new Jt(t.fileContent,this.http);await e.initialize();const r=Object.assign(Object.assign({},t),{progress:0,file:e,state:"added",fileId:void 0,href:void 0,id:t.id});e.onProgress=t=>{0===r.progress&&(r.state="uploading"),r.progress=t,100===t&&(r.state="finalizing")};const s=await e.upload();return r.fileId=s.id,r.filename=s.filename,r.extension=s.extension,r.contentType=s.contentType,r.size=s.size,r.state="done",r.href=null===(i=s._links)||void 0===i?void 0:i.contents.href,r}get http(){return this.platform.get(s.Http)}}const Yt=class{watchOpen(){this.setupHandlers(),this.setPickerMessage()}watchQuery(){this.setPickerMessage()}constructor(e){var r;t(this,e),this.change=i(this,"change",7),this.metadataChange=i(this,"metadataChange",7),this.allowMentioning=!1,this.contentType="markdown",this.language="en",this.disabled=!1,this.readonly=!1,this.invalid=!1,this.required=!1,this.ui="standard",this.allowResize=!0,this.value="",this.triggerMap={},this.customElements=[],this.allowInlineImages=!1,this.items=[],this.highlightedItemIndex=0,this.isPickerOpen=!1,this.isSearching=!1,this.registeredTriggers=[],this.registeredTriggerMap=this.triggerMap,this.registeredCustomElements=this.customElements,this.activeTrigger=void 0,this.handleMouseClick=t=>{this.textEditorPickerElement&&(t.target===this.textEditorPickerElement||this.resetTriggerAndPicker())},this.handleKeyPress=t=>{if(!this.isPickerOpen||!this.activeTrigger)return;if(![h,c,a,u,f].includes(t.key))return;if(t.stopPropagation(),t.preventDefault(),"keyup"===t.type)return;const i={[h]:this.handleEscapeKey,[u]:this.handleEnterOrTabKey,[f]:this.handleEnterOrTabKey,[a]:this.handleArrowKeyPress,[c]:this.handleArrowKeyPress}[t.key];i&&i(t)},this.handleArrowKeyPress=t=>{this.highlightedItemIndex=this.findNonSeparatorIndex(t.key,this.highlightedItemIndex)},this.findNonSeparatorIndex=(t,i,e=0)=>{if(!this.items.length||e>this.items.length)return i;const r=((t,i,e)=>(i+(t===a?1:-1)+e)%e)(t,i,this.items.length);return this.isListSeparator(this.items[r])?this.findNonSeparatorIndex(t,r,e+1):r},this.handleEscapeKey=()=>{var t;null===(t=this.triggerFunction)||void 0===t||t.stopTrigger(),this.resetTriggerAndPicker()},this.handleEnterOrTabKey=t=>{this.handleItemSelection(t)},this.handleMetadataChange=t=>{t.stopPropagation();const i=t.detail,e=this.getEnhancedImages(i.images||[]),r=Object.assign(Object.assign({},i),{images:e});this.metadataChange.emit(r)},this.handleImagePasted=t=>{t.stopPropagation(),this.allowInlineImages&&this.uploadHandler.handleImagePasted(t.detail)},this.handleTriggerStart=t=>{t.stopPropagation(),this.activeTrigger=t.detail.trigger,this.triggerFunction=t.detail.textEditor,this.isPickerOpen=!0},this.handleTriggerStop=t=>{t.stopPropagation(),this.resetTriggerAndPicker()},this.handleTriggerChange=t=>{var i;t.stopImmediatePropagation(),this.editorPickerQuery=t.detail.value;const e=null===(i=this.registeredTriggerMap[t.detail.trigger])||void 0===i?void 0:i.searcher;e&&(this.isSearching=!0,this.debouncedSearchFn(e,this.editorPickerQuery))},this.resetTriggerAndPicker=()=>{this.isPickerOpen=!1,this.activeTrigger=void 0,this.triggerFunction=void 0,this.isSearching=!1,this.highlightedItemIndex=0,this.items=[]},this.handleItemSelection=t=>{var i;let e;if(t instanceof CustomEvent)e=t.detail;else{if(!(t instanceof KeyboardEvent))return;{const t=this.items[this.highlightedItemIndex];if(this.isListSeparator(t))return;e=t}}if(!this.activeTrigger)return;const r=this.registeredTriggerMap[this.activeTrigger];try{r.inserter(this.triggerFunction,e)}catch(t){console.error("Error inserting",t)}this.resetTriggerAndPicker(),null===(i=this.textEditor)||void 0===i||i.focus()},this.handleVisibilityChange=()=>{"hidden"===document.visibilityState&&this.saveDraft()},this.handleBeforeUnload=()=>{this.saveDraft()},this.portalId="crypto"in window&&"function"==typeof(null===(r=window.crypto)||void 0===r?void 0:r.randomUUID)?"a_"+crypto.randomUUID():String.fromCharCode(97+Math.floor(26*Math.random()))+Math.random().toString(36).substring(2)+Math.random().toString(36).substring(2),this.debouncedSearchFn=function(t,i,e){var r,s,n,o,a,h,c=0,u=!1,f=!1,d=!0;if("function"!=typeof t)throw new TypeError("Expected a function");function l(i){var e=r,n=s;return r=s=void 0,c=i,o=t.apply(n,e)}function v(t){var e=t-h;return void 0===h||e>=i||e<0||f&&t-c>=n}function b(){var t=Qt();if(v(t))return p(t);a=setTimeout(b,function(t){var e=i-(t-h);return f?qt(e,n-(t-c)):e}(t))}function p(t){return a=void 0,d&&r?l(t):(r=s=void 0,o)}function m(){var t=Qt(),e=v(t);if(r=arguments,s=this,h=t,e){if(void 0===a)return function(t){return c=t,a=setTimeout(b,i),u?l(t):o}(h);if(f)return clearTimeout(a),a=setTimeout(b,i),l(h)}return void 0===a&&(a=setTimeout(b,i)),o}return i=W(i)||0,k(e)&&(u=!!e.leading,n=(f="maxWait"in e)?Wt(W(e.maxWait)||0,i):n,d="trailing"in e?!!e.trailing:d),m.cancel=function(){void 0!==a&&clearTimeout(a),c=0,r=h=s=a=void 0},m.flush=function(){return void 0===a?o:p(Qt())},m}((async(t,i)=>{try{const e=await t(i);if(i!==this.editorPickerQuery||!this.activeTrigger)return;this.items=e}catch(t){console.error("Error searching",t)}finally{this.isSearching=!1}}),300)}connectedCallback(){var t,i,e,r;if(this.draftIdentifier){const s=null!==(i=null===(t=this.context)||void 0===t?void 0:t.id)&&void 0!==i?i:"no-limeobject",n=null!==(r=null===(e=this.context)||void 0===e?void 0:e.limetype)&&void 0!==r?r:"no-limetype";this.textEditorInnerId=["text-editor-draft",n,s,this.draftIdentifier].join("-")}this.textEditorInnerId&&(document.addEventListener("visibilitychange",this.handleVisibilityChange),window.addEventListener("beforeunload",this.handleBeforeUnload)),this.uploadHandler=new Xt(this.platform)}componentWillLoad(){this.allowMentioning&&this.registerMentions(),this.registerTriggers(),this.loadDraft()}disconnectedCallback(){document.removeEventListener("visibilitychange",this.handleVisibilityChange),window.removeEventListener("beforeunload",this.handleBeforeUnload),document.removeEventListener("mousedown",this.handleMouseClick),this.saveDraft(),this.host&&(this.host.removeEventListener("keyup",this.handleKeyPress,{capture:!0}),this.host.removeEventListener("keydown",this.handleKeyPress,{capture:!0})),this.debouncedSearchFn&&this.debouncedSearchFn.cancel&&this.debouncedSearchFn.cancel()}registerMentions(){const t=new Vt(this.platform,this.context,this.searchableLimetypes),i=t.triggerHandler.nodeDefinition;i&&(this.registeredCustomElements.push(i.customElement),this.registeredTriggerMap[t.triggerCharacter]=t.triggerHandler,t.initialize())}registerTriggers(){this.registeredTriggers=Object.keys(this.registeredTriggerMap)}setPickerMessage(){var t;if(!this.activeTrigger)return;const i=this.registeredTriggerMap[this.activeTrigger];this.pickerMessage=(null===(t=this.editorPickerQuery)||void 0===t?void 0:t.length)>0?i.noItemsFoundMessage:i.emptySearchMessage}setupHandlers(){this.isPickerOpen?(this.host.addEventListener("keyup",this.handleKeyPress,{capture:!0}),this.host.addEventListener("keydown",this.handleKeyPress,{capture:!0}),document.addEventListener("mousedown",this.handleMouseClick)):(this.host.removeEventListener("keyup",this.handleKeyPress,{capture:!0}),this.host.removeEventListener("keydown",this.handleKeyPress,{capture:!0}),document.removeEventListener("mousedown",this.handleMouseClick))}isListSeparator(t){return"separator"in t&&!0===t.separator}render(){return[e("limel-text-editor",{key:"f8dd8f5bf1da04d2ab540e840297455a73d28bd0",ref:t=>this.textEditor=t,tabindex:this.disabled?-1:0,value:this.value,contentType:this.contentType,customElements:this.registeredCustomElements,"aria-disabled":this.disabled,language:this.language,triggers:this.registeredTriggers,onTriggerStart:this.handleTriggerStart,onTriggerStop:this.handleTriggerStop,onTriggerChange:this.handleTriggerChange,onImagePasted:this.handleImagePasted,onMetadataChange:this.handleMetadataChange,ui:this.ui,allowResize:this.allowResize,required:this.required,disabled:this.disabled,readonly:this.readonly,helperText:this.helperText,placeholder:this.placeholder,label:this.label,invalid:this.invalid}),this.renderPicker()]}renderPicker(){if(this.isPickerOpen)return e("limel-portal",{containerId:this.portalId,visible:this.isPickerOpen,openDirection:"top",inheritParentWidth:!0,anchor:this.textEditor},e("limebb-text-editor-picker",{ref:t=>this.textEditorPickerElement=t,items:(t=this.items,i=this.highlightedItemIndex,t.map(((t,e)=>{const r=Gt(t,5);return Object.assign(Object.assign({},r),{selected:e===i})}))),onItemSelected:this.handleItemSelection,emptyMessage:this.pickerMessage,isSearching:this.isSearching}));var t,i}getEnhancedImages(t){return t.map((t=>{let i;return"success"===t.state&&(i=this.uploadHandler.parseFileIdFromSrc(t.src)),i?Object.assign(Object.assign({},t),{fileId:i}):t}))}loadDraft(){if(!this.userDataService||!this.textEditorInnerId)return;if(this.value)return;const t=this.userDataService.get(this.textEditorInnerId);t&&this.change.emit(t)}saveDraft(){var t,i,e;this.textEditorInnerId&&((null===(t=this.value)||void 0===t?void 0:t.trim())?null===(i=this.userDataService)||void 0===i||i.set(this.textEditorInnerId,this.value):null===(e=this.userDataService)||void 0===e||e.set(this.textEditorInnerId,void 0))}get userDataService(){return this.platform.get(s.UserDataRepository)}get host(){return r(this)}static get watchers(){return{isPickerOpen:["watchOpen"],editorPickerQuery:["watchQuery"]}}};!function(t,i,e,r){var s,n=arguments.length,o=n<3?i:null===r?r=Object.getOwnPropertyDescriptor(i,e):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(t,i,e,r);else for(var a=t.length-1;a>=0;a--)(s=t[a])&&(o=(n<3?s(o):n>3?s(i,e,o):s(i,e))||o);n>3&&o&&Object.defineProperty(i,e,o)}([o({map:[function(t){return Object.values(t).filter((t=>Bt(t,"user")||Kt(t,"user")))}]})],Yt.prototype,"searchableLimetypes",void 0);export{Yt as limebb_text_editor}
1
+ import{r as t,c as i,h as e,g as r}from"./p-b11e09b4.js";import{P as s,A as n}from"./p-a26d352f.js";import{a as o}from"./p-54d4113a.js";import{A as a,a as h,b as c,E as u,T as f}from"./p-463d3174.js";import{d,b as l,k as v,c as b,s as p,a as m,e as g,U as y,S as j,g as w}from"./p-bcc23575.js";import{i as O,e as S}from"./p-c40a3f4b.js";import{d as k,r as x,S as I,a as A,i as T}from"./p-b31772c8.js";import{d as C,i as M,o as E,g as F,h as P,n as $,a as _}from"./p-5322fd19.js";import{i as N}from"./p-6fd28e32.js";import"./p-22de5a0e.js";var D=/\s/,L=/^\s+/;var R=NaN,U=/^[-+]0x[0-9a-f]+$/i,z=/^0b[01]+$/i,G=/^0o[0-7]+$/i,Q=parseInt;function W(t){if("number"==typeof t)return t;if(O(t))return R;if(k(t)){var i="function"==typeof t.valueOf?t.valueOf():t;t=k(i)?i+"":i}if("string"!=typeof t)return 0===t?t:+t;var e;t=(e=t)?e.slice(0,function(t){for(var i=t.length;i--&&D.test(t.charAt(i)););return i}(e)+1).replace(L,""):e;var r=z.test(t);return r||G.test(t)?Q(t.slice(2),r?2:8):U.test(t)?R:+t}var q=Object.create;const B=function(){function t(){}return function(i){if(!k(i))return{};if(q)return q(i);t.prototype=i;var e=new t;return t.prototype=void 0,e}}();function H(t,i,e){"__proto__"==i&&d?d(t,i,{configurable:!0,enumerable:!0,value:e,writable:!0}):t[i]=e}var K=Object.prototype.hasOwnProperty;function V(t,i,e){var r=t[i];K.call(t,i)&&S(r,e)&&(void 0!==e||i in t)||H(t,i,e)}function J(t,i,e,r){var s=!e;e||(e={});for(var n=-1,o=i.length;++n<o;){var a=i[n],h=r?r(e[a],t[a],a,e,t):void 0;void 0===h&&(h=t[a]),s?H(e,a,h):V(e,a,h)}return e}var X=Object.prototype.hasOwnProperty;function Y(t){return M(t)?l(t,!0):function(t){if(!k(t))return function(t){var i=[];if(null!=t)for(var e in Object(t))i.push(e);return i}(t);var i=C(t),e=[];for(var r in t)("constructor"!=r||!i&&X.call(t,r))&&e.push(r);return e}(t)}const Z=E(Object.getPrototypeOf,Object);var tt="object"==typeof exports&&exports&&!exports.nodeType&&exports,it=tt&&"object"==typeof module&&module&&!module.nodeType&&module,et=it&&it.exports===tt?x.Buffer:void 0,rt=et?et.allocUnsafe:void 0;const st=Object.getOwnPropertySymbols?function(t){for(var i=[];t;)m(i,b(t)),t=Z(t);return i}:p;function nt(t){return g(t,Y,st)}var ot=Object.prototype.hasOwnProperty;function at(t){var i=new t.constructor(t.byteLength);return new y(i).set(new y(t)),i}var ht=/\w*$/,ct=I?I.prototype:void 0,ut=ct?ct.valueOf:void 0,ft="[object Boolean]",dt="[object Date]",lt="[object Map]",vt="[object Number]",bt="[object RegExp]",pt="[object Set]",mt="[object String]",gt="[object Symbol]",yt="[object ArrayBuffer]",jt="[object DataView]",wt="[object Float32Array]",Ot="[object Float64Array]",St="[object Int8Array]",kt="[object Int16Array]",xt="[object Int32Array]",It="[object Uint8Array]",At="[object Uint8ClampedArray]",Tt="[object Uint16Array]",Ct="[object Uint32Array]";var Mt=$&&$.isMap;const Et=Mt?P(Mt):function(t){return A(t)&&"[object Map]"==F(t)};var Ft=$&&$.isSet;const Pt=Ft?P(Ft):function(t){return A(t)&&"[object Set]"==F(t)};var $t=1,_t=2,Nt=4,Dt="[object Arguments]",Lt="[object Function]",Rt="[object GeneratorFunction]",Ut="[object Object]",zt={};function Gt(t,i,e,r,s,n){var o,a=i&$t,h=i&_t,c=i&Nt;if(e&&(o=s?e(t,r,s,n):e(t)),void 0!==o)return o;if(!k(t))return t;var u=T(t);if(u){if(o=function(t){var i=t.length,e=new t.constructor(i);return i&&"string"==typeof t[0]&&ot.call(t,"index")&&(e.index=t.index,e.input=t.input),e}(t),!a)return function(t,i){var e=-1,r=t.length;for(i||(i=Array(r));++e<r;)i[e]=t[e];return i}(t,o)}else{var f=F(t),d=f==Lt||f==Rt;if(_(t))return function(t,i){if(i)return t.slice();var e=t.length,r=rt?rt(e):new t.constructor(e);return t.copy(r),r}(t,a);if(f==Ut||f==Dt||d&&!s){if(o=h||d?{}:function(t){return"function"!=typeof t.constructor||C(t)?{}:B(Z(t))}(t),!a)return h?function(t,i){return J(t,st(t),i)}(t,function(t,i){return t&&J(i,Y(i),t)}(o,t)):function(t,i){return J(t,b(t),i)}(t,function(t,i){return t&&J(i,v(i),t)}(o,t))}else{if(!zt[f])return s?t:{};o=function(t,i,e){var r,s,n=t.constructor;switch(i){case yt:return at(t);case ft:case dt:return new n(+t);case jt:return function(t,i){var e=i?at(t.buffer):t.buffer;return new t.constructor(e,t.byteOffset,t.byteLength)}(t,e);case wt:case Ot:case St:case kt:case xt:case It:case At:case Tt:case Ct:return function(t,i){var e=i?at(t.buffer):t.buffer;return new t.constructor(e,t.byteOffset,t.length)}(t,e);case lt:return new n;case vt:case mt:return new n(t);case bt:return(s=new(r=t).constructor(r.source,ht.exec(r))).lastIndex=r.lastIndex,s;case pt:return new n;case gt:return ut?Object(ut.call(t)):{}}}(t,f,a)}}n||(n=new j);var l=n.get(t);if(l)return l;n.set(t,o),Pt(t)?t.forEach((function(r){o.add(Gt(r,i,e,r,t,n))})):Et(t)&&t.forEach((function(r,s){o.set(s,Gt(r,i,e,s,t,n))}));var p=u?void 0:(c?h?nt:w:h?Y:v)(t);return function(t,i){for(var e=-1,r=null==t?0:t.length;++e<r&&!1!==i(t[e],e););}(p||t,(function(r,s){p&&(r=t[s=r]),V(o,s,Gt(r,i,e,s,t,n))})),o}zt[Dt]=zt["[object Array]"]=zt["[object ArrayBuffer]"]=zt["[object DataView]"]=zt["[object Boolean]"]=zt["[object Date]"]=zt["[object Float32Array]"]=zt["[object Float64Array]"]=zt["[object Int8Array]"]=zt["[object Int16Array]"]=zt["[object Int32Array]"]=zt["[object Map]"]=zt["[object Number]"]=zt[Ut]=zt["[object RegExp]"]=zt["[object Set]"]=zt["[object String]"]=zt["[object Symbol]"]=zt["[object Uint8Array]"]=zt["[object Uint8ClampedArray]"]=zt["[object Uint16Array]"]=zt["[object Uint32Array]"]=!0,zt["[object Error]"]=zt[Lt]=zt["[object WeakMap]"]=!1;const Qt=function(){return x.Date.now()};var Wt=Math.max,qt=Math.min;function Bt(t,i){return t.label===i}function Ht(t,i){return Object.values(t.properties).find((t=>t&&t.relation&&Bt(t.relation.getLimetype(),i)))}function Kt(t,i){const e=Ht(t,i);return!!e&&function(t){return function(t){return t&&["belongsto","hasone","hasmany","hasandbelongstomany"].includes(t.type)}(t)&&!function(t){return t&&["belongsto","hasone"].includes(t.type)}(t)}(e)}class Vt{get limeObjectService(){return this.platform.get(s.LimeObjectRepository)}get queryService(){return this.platform.get(s.Query)}get viewFactoryRegistry(){return this.platform.get(s.ViewFactoryRegistry)}get translator(){var t;return null===(t=this.platform)||void 0===t?void 0:t.get(s.Translate)}get triggerCharacter(){return this._triggerCharacter}get triggerHandler(){return this._triggerHandler}constructor(t,i,e){this.platform=t,this.context=i,this.searchableLimetypes=e,this.groupCounts={},this._triggerCharacter="@",this._triggerHandler={searcher:t=>this.searcher(t),inserter:(t,i)=>this.inserter(t,i),emptySearchMessage:"Start typing a name...",noItemsFoundMessage:"No results for your search...",nodeDefinition:{customElement:{tagName:"limebb-mention",attributes:["limetype","objectid","href"]},mapAttributes:t=>({limetype:t.value.getLimetype().name,objectid:t.value.id,href:`object/${this.context.limetype}/${this.context.id}`})}},this.searcher=async t=>{if(!t)return[];const{objects:i}=await this.limeObjectService.search(t,this.searchableLimetypes,10);return this.createSearchListItems(i)},this.inserter=async(t,i)=>{var e;const r=this.triggerHandler.nodeDefinition;r&&t.insert({node:{tagName:r.customElement.tagName,attributes:r.mapAttributes(i)},children:[null===(e=i.value)||void 0===e?void 0:e.descriptive]})}}async initialize(){await this.loadGroupCounts()}async loadGroupCounts(){const t=this.searchableLimetypes.filter((t=>!Bt(t,"user")&&Kt(t,"user"))).map((t=>this.getGroupCounts(t)));(await Promise.all(t)).forEach((t=>{Object.assign(this.groupCounts,t)}))}async getGroupCounts(t){var i;const e=Ht(t,"user"),r=t.name;try{const t=await this.queryService.execute({limetype:r,responseFormat:{object:{_id:null,[e.name]:{count:{aggregate:{op:n.Count}}}}}});if(!(null===(i=t.objects)||void 0===i?void 0:i.length))return{[r]:{}};const s=this.createGroupCount(t.objects,e.name);return{[r]:s}}catch(i){return console.error(`Error fetching group count for limetype: ${t.name}`,i),{[r]:{}}}}createGroupCount(t,i){const e={};return t.forEach((t=>{const{_id:r,[i]:s}=t;e[r]=s.count})),e}createSearchListItems(t=[]){return t.map((t=>this.createSearchListItem(t))).filter(N)}createSearchListItem(t){const i=this.viewFactoryRegistry.getFactory("search"),e=this.limeObjectService.getObject(t._limetype,t._id);if(!e)return null;const r=i(e,this.context),s=this.getGroupCountComponent(e);return Object.assign(Object.assign({},r),s?{primaryComponent:s}:{})}getGroupCountComponent(t){var i;const e=t.getLimetype(),r=null===(i=this.groupCounts[e.name])||void 0===i?void 0:i[t.id],s=Ht(e,"user");if(void 0!==r&&s)return{name:"limebb-mention-group-counter",props:{count:r,limetype:s.relation.getLimetype(),helperLabel:this.translator.get("webclient.notification-center.members-will-be-notified")}}}}class Jt{constructor(t,i){this.file=t,this.http=i,this.uploadCancelled=!1,this.getUrl=t=>`api/v1/file/${t||""}`}async initialize(){this.uploadService=await this.http.createFileUpload("POST",this.getUrl(),this.file),this.progressCallback&&(this.uploadService.onProgress=this.progressCallback)}async upload(){return this.uploadService.upload()}getFileName(){return this.file.name}cancel(){this.uploadService.cancel(),this.uploadCancelled=!0}set onProgress(t){this.progressCallback=t,this.uploadService&&(this.uploadService.onProgress=t)}}class Xt{constructor(t){this.platform=t}async handleImagePasted(t){const i=null==t?void 0:t.fileInfo;if(!i)return;if(!this.validateImageSize(i))return;t.insertThumbnail();const e=await this.createFileUpload(i),r=null==e?void 0:e.href;return r&&void 0!==(null==e?void 0:e.fileId)?t.insertImage(r):t.insertFailedThumbnail(),e}parseFileIdFromSrc(t){if(t){const i=/\/(\d+)\/contents\/?$/.exec(t);if(i&&i[1])return Number(i[1])}}validateImageSize(t){return!!t.fileContent&&t.fileContent.size<=52428800}async createFileUpload(t){var i;if(!t.fileContent)return;const e=new Jt(t.fileContent,this.http);await e.initialize();const r=Object.assign(Object.assign({},t),{progress:0,file:e,state:"added",fileId:void 0,href:void 0,id:t.id});e.onProgress=t=>{0===r.progress&&(r.state="uploading"),r.progress=t,100===t&&(r.state="finalizing")};const s=await e.upload();return r.fileId=s.id,r.filename=s.filename,r.extension=s.extension,r.contentType=s.contentType,r.size=s.size,r.state="done",r.href=null===(i=s._links)||void 0===i?void 0:i.contents.href,r}get http(){return this.platform.get(s.Http)}}const Yt=class{watchOpen(){this.setupHandlers(),this.setPickerMessage()}watchQuery(){this.setPickerMessage()}constructor(e){var r;t(this,e),this.change=i(this,"change",7),this.metadataChange=i(this,"metadataChange",7),this.allowMentioning=!1,this.contentType="markdown",this.language="en",this.disabled=!1,this.readonly=!1,this.invalid=!1,this.required=!1,this.ui="standard",this.allowResize=!0,this.value="",this.triggerMap={},this.customElements=[],this.allowInlineImages=!1,this.items=[],this.highlightedItemIndex=0,this.isPickerOpen=!1,this.isSearching=!1,this.registeredTriggers=[],this.registeredTriggerMap=this.triggerMap,this.registeredCustomElements=this.customElements,this.activeTrigger=void 0,this.handleMouseClick=t=>{this.textEditorPickerElement&&(t.target===this.textEditorPickerElement||this.resetTriggerAndPicker())},this.handleKeyPress=t=>{if(!this.isPickerOpen||!this.activeTrigger)return;if(![h,c,a,u,f].includes(t.key))return;if(t.stopPropagation(),t.preventDefault(),"keyup"===t.type)return;const i={[h]:this.handleEscapeKey,[u]:this.handleEnterOrTabKey,[f]:this.handleEnterOrTabKey,[a]:this.handleArrowKeyPress,[c]:this.handleArrowKeyPress}[t.key];i&&i(t)},this.handleArrowKeyPress=t=>{this.highlightedItemIndex=this.findNonSeparatorIndex(t.key,this.highlightedItemIndex)},this.findNonSeparatorIndex=(t,i,e=0)=>{if(!this.items.length||e>this.items.length)return i;const r=((t,i,e)=>(i+(t===a?1:-1)+e)%e)(t,i,this.items.length);return this.isListSeparator(this.items[r])?this.findNonSeparatorIndex(t,r,e+1):r},this.handleEscapeKey=()=>{var t;null===(t=this.triggerFunction)||void 0===t||t.stopTrigger(),this.resetTriggerAndPicker()},this.handleEnterOrTabKey=t=>{this.handleItemSelection(t)},this.handleMetadataChange=t=>{t.stopPropagation();const i=t.detail,e=this.getEnhancedImages(i.images||[]),r=Object.assign(Object.assign({},i),{images:e});this.metadataChange.emit(r)},this.handleImagePasted=t=>{t.stopPropagation(),this.allowInlineImages&&this.uploadHandler.handleImagePasted(t.detail)},this.handleTriggerStart=t=>{t.stopPropagation(),this.activeTrigger=t.detail.trigger,this.triggerFunction=t.detail.textEditor,this.isPickerOpen=!0},this.handleTriggerStop=t=>{t.stopPropagation(),this.resetTriggerAndPicker()},this.handleTriggerChange=t=>{var i;t.stopImmediatePropagation(),this.editorPickerQuery=t.detail.value;const e=null===(i=this.registeredTriggerMap[t.detail.trigger])||void 0===i?void 0:i.searcher;e&&(this.isSearching=!0,this.debouncedSearchFn(e,this.editorPickerQuery))},this.resetTriggerAndPicker=()=>{this.isPickerOpen=!1,this.activeTrigger=void 0,this.triggerFunction=void 0,this.isSearching=!1,this.highlightedItemIndex=0,this.items=[]},this.handleItemSelection=t=>{var i;let e;if(t instanceof CustomEvent)e=t.detail;else{if(!(t instanceof KeyboardEvent))return;{const t=this.items[this.highlightedItemIndex];if(this.isListSeparator(t))return;e=t}}if(!this.activeTrigger)return;const r=this.registeredTriggerMap[this.activeTrigger];try{r.inserter(this.triggerFunction,e)}catch(t){console.error("Error inserting",t)}this.resetTriggerAndPicker(),null===(i=this.textEditor)||void 0===i||i.focus()},this.handleVisibilityChange=()=>{"hidden"===document.visibilityState&&this.saveDraft()},this.handleBeforeUnload=()=>{this.saveDraft()},this.portalId="crypto"in window&&"function"==typeof(null===(r=window.crypto)||void 0===r?void 0:r.randomUUID)?"a_"+crypto.randomUUID():String.fromCharCode(97+Math.floor(26*Math.random()))+Math.random().toString(36).substring(2)+Math.random().toString(36).substring(2),this.debouncedSearchFn=function(t,i,e){var r,s,n,o,a,h,c=0,u=!1,f=!1,d=!0;if("function"!=typeof t)throw new TypeError("Expected a function");function l(i){var e=r,n=s;return r=s=void 0,c=i,o=t.apply(n,e)}function v(t){var e=t-h;return void 0===h||e>=i||e<0||f&&t-c>=n}function b(){var t=Qt();if(v(t))return p(t);a=setTimeout(b,function(t){var e=i-(t-h);return f?qt(e,n-(t-c)):e}(t))}function p(t){return a=void 0,d&&r?l(t):(r=s=void 0,o)}function m(){var t=Qt(),e=v(t);if(r=arguments,s=this,h=t,e){if(void 0===a)return function(t){return c=t,a=setTimeout(b,i),u?l(t):o}(h);if(f)return clearTimeout(a),a=setTimeout(b,i),l(h)}return void 0===a&&(a=setTimeout(b,i)),o}return i=W(i)||0,k(e)&&(u=!!e.leading,n=(f="maxWait"in e)?Wt(W(e.maxWait)||0,i):n,d="trailing"in e?!!e.trailing:d),m.cancel=function(){void 0!==a&&clearTimeout(a),c=0,r=h=s=a=void 0},m.flush=function(){return void 0===a?o:p(Qt())},m}((async(t,i)=>{try{const e=await t(i);if(i!==this.editorPickerQuery||!this.activeTrigger)return;this.items=e}catch(t){console.error("Error searching",t)}finally{this.isSearching=!1}}),300)}connectedCallback(){var t,i,e,r;if(this.draftIdentifier){const s=null!==(i=null===(t=this.context)||void 0===t?void 0:t.id)&&void 0!==i?i:"no-limeobject",n=null!==(r=null===(e=this.context)||void 0===e?void 0:e.limetype)&&void 0!==r?r:"no-limetype";this.textEditorInnerId=["text-editor-draft",n,s,this.draftIdentifier].join("-")}this.textEditorInnerId&&(document.addEventListener("visibilitychange",this.handleVisibilityChange),window.addEventListener("beforeunload",this.handleBeforeUnload)),this.uploadHandler=new Xt(this.platform)}componentWillLoad(){this.allowMentioning&&this.registerMentions(),this.registerTriggers(),this.loadDraft()}disconnectedCallback(){document.removeEventListener("visibilitychange",this.handleVisibilityChange),window.removeEventListener("beforeunload",this.handleBeforeUnload),document.removeEventListener("mousedown",this.handleMouseClick),this.saveDraft(),this.host&&(this.host.removeEventListener("keyup",this.handleKeyPress,{capture:!0}),this.host.removeEventListener("keydown",this.handleKeyPress,{capture:!0})),this.debouncedSearchFn&&this.debouncedSearchFn.cancel&&this.debouncedSearchFn.cancel()}registerMentions(){const t=new Vt(this.platform,this.context,this.searchableLimetypes),i=t.triggerHandler.nodeDefinition;i&&(this.registeredCustomElements.push(i.customElement),this.registeredTriggerMap[t.triggerCharacter]=t.triggerHandler,t.initialize())}registerTriggers(){this.registeredTriggers=Object.keys(this.registeredTriggerMap)}setPickerMessage(){var t;if(!this.activeTrigger)return;const i=this.registeredTriggerMap[this.activeTrigger];this.pickerMessage=(null===(t=this.editorPickerQuery)||void 0===t?void 0:t.length)>0?i.noItemsFoundMessage:i.emptySearchMessage}setupHandlers(){this.isPickerOpen?(this.host.addEventListener("keyup",this.handleKeyPress,{capture:!0}),this.host.addEventListener("keydown",this.handleKeyPress,{capture:!0}),document.addEventListener("mousedown",this.handleMouseClick)):(this.host.removeEventListener("keyup",this.handleKeyPress,{capture:!0}),this.host.removeEventListener("keydown",this.handleKeyPress,{capture:!0}),document.removeEventListener("mousedown",this.handleMouseClick))}isListSeparator(t){return"separator"in t&&!0===t.separator}render(){return[e("limel-text-editor",{key:"f8dd8f5bf1da04d2ab540e840297455a73d28bd0",ref:t=>this.textEditor=t,tabindex:this.disabled?-1:0,value:this.value,contentType:this.contentType,customElements:this.registeredCustomElements,"aria-disabled":this.disabled,language:this.language,triggers:this.registeredTriggers,onTriggerStart:this.handleTriggerStart,onTriggerStop:this.handleTriggerStop,onTriggerChange:this.handleTriggerChange,onImagePasted:this.handleImagePasted,onMetadataChange:this.handleMetadataChange,ui:this.ui,allowResize:this.allowResize,required:this.required,disabled:this.disabled,readonly:this.readonly,helperText:this.helperText,placeholder:this.placeholder,label:this.label,invalid:this.invalid}),this.renderPicker()]}renderPicker(){if(this.isPickerOpen)return e("limel-portal",{containerId:this.portalId,visible:this.isPickerOpen,openDirection:"top",inheritParentWidth:!0,anchor:this.textEditor},e("limebb-text-editor-picker",{ref:t=>this.textEditorPickerElement=t,items:(t=this.items,i=this.highlightedItemIndex,t.map(((t,e)=>{const r=Gt(t,5);return Object.assign(Object.assign({},r),{selected:e===i})}))),onItemSelected:this.handleItemSelection,emptyMessage:this.pickerMessage,isSearching:this.isSearching}));var t,i}getEnhancedImages(t){return t.map((t=>{let i;return"success"===t.state&&(i=this.uploadHandler.parseFileIdFromSrc(t.src)),i?Object.assign(Object.assign({},t),{fileId:i}):t}))}loadDraft(){if(!this.userDataService||!this.textEditorInnerId)return;if(this.value)return;const t=this.userDataService.get(this.textEditorInnerId);t&&this.change.emit(t)}saveDraft(){var t,i,e,r;if(!this.textEditorInnerId)return;const s=null===(t=this.value)||void 0===t?void 0:t.trim(),n=null===(i=this.userDataService)||void 0===i?void 0:i.get(this.textEditorInnerId);s&&s!==n?null===(e=this.userDataService)||void 0===e||e.set(this.textEditorInnerId,s):!s&&n&&(null===(r=this.userDataService)||void 0===r||r.set(this.textEditorInnerId,void 0))}get userDataService(){return this.platform.get(s.UserDataRepository)}get host(){return r(this)}static get watchers(){return{isPickerOpen:["watchOpen"],editorPickerQuery:["watchQuery"]}}};!function(t,i,e,r){var s,n=arguments.length,o=n<3?i:null===r?r=Object.getOwnPropertyDescriptor(i,e):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(t,i,e,r);else for(var a=t.length-1;a>=0;a--)(s=t[a])&&(o=(n<3?s(o):n>3?s(i,e,o):s(i,e))||o);n>3&&o&&Object.defineProperty(i,e,o)}([o({map:[function(t){return Object.values(t).filter((t=>Bt(t,"user")||Kt(t,"user")))}]})],Yt.prototype,"searchableLimetypes",void 0);export{Yt as limebb_text_editor}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@limetech/lime-crm-building-blocks",
3
- "version": "1.75.0",
3
+ "version": "1.76.0",
4
4
  "description": "A home for shared components meant for use with Lime CRM",
5
5
  "main": "dist/index.cjs.js",
6
6
  "module": "dist/index.js",