@limetech/lime-crm-building-blocks 1.68.7 → 1.68.8
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 +7 -0
- package/dist/cjs/limebb-text-editor.cjs.entry.js +14 -2
- package/dist/collection/components/text-editor/text-editor.js +14 -2
- package/dist/components/limebb-text-editor.js +14 -2
- package/dist/esm/limebb-text-editor.entry.js +14 -2
- package/dist/lime-crm-building-blocks/lime-crm-building-blocks.esm.js +1 -1
- package/dist/lime-crm-building-blocks/p-04d67f14.entry.js +1 -0
- package/dist/types/components/text-editor/text-editor.d.ts +2 -0
- package/package.json +1 -1
- package/dist/lime-crm-building-blocks/p-3f06cf12.entry.js +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
## [1.68.8](https://github.com/Lundalogik/lime-crm-building-blocks/compare/v1.68.7...v1.68.8) (2025-04-11)
|
|
2
|
+
|
|
3
|
+
### Bug Fixes
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
* **text-editor:** reset trigger and picker when unfocused ([08219b0](https://github.com/Lundalogik/lime-crm-building-blocks/commit/08219b02d127f5451a10af8072f599359f20e849))
|
|
7
|
+
|
|
1
8
|
## [1.68.7](https://github.com/Lundalogik/lime-crm-building-blocks/compare/v1.68.6...v1.68.7) (2025-04-10)
|
|
2
9
|
|
|
3
10
|
### Bug Fixes
|
|
@@ -1302,6 +1302,15 @@ const LimeBBTextEditor = class {
|
|
|
1302
1302
|
}),
|
|
1303
1303
|
},
|
|
1304
1304
|
};
|
|
1305
|
+
this.handleMouseClick = (event) => {
|
|
1306
|
+
if (!this.textEditorPickerElement) {
|
|
1307
|
+
return;
|
|
1308
|
+
}
|
|
1309
|
+
const clickedOnTextEditorPicker = event.target === this.textEditorPickerElement;
|
|
1310
|
+
if (!clickedOnTextEditorPicker) {
|
|
1311
|
+
this.resetTriggerAndPicker();
|
|
1312
|
+
}
|
|
1313
|
+
};
|
|
1305
1314
|
this.handleKeyPress = (event) => {
|
|
1306
1315
|
if (!this.isPickerOpen || !this.activeTrigger) {
|
|
1307
1316
|
return;
|
|
@@ -1473,6 +1482,7 @@ const LimeBBTextEditor = class {
|
|
|
1473
1482
|
this.host.addEventListener('keydown', this.handleKeyPress, {
|
|
1474
1483
|
capture: true,
|
|
1475
1484
|
});
|
|
1485
|
+
document.addEventListener('mousedown', this.handleMouseClick);
|
|
1476
1486
|
}
|
|
1477
1487
|
else {
|
|
1478
1488
|
this.host.removeEventListener('keyup', this.handleKeyPress, {
|
|
@@ -1481,11 +1491,12 @@ const LimeBBTextEditor = class {
|
|
|
1481
1491
|
this.host.removeEventListener('keydown', this.handleKeyPress, {
|
|
1482
1492
|
capture: true,
|
|
1483
1493
|
});
|
|
1494
|
+
document.removeEventListener('mousedown', this.handleMouseClick);
|
|
1484
1495
|
}
|
|
1485
1496
|
}
|
|
1486
1497
|
render() {
|
|
1487
1498
|
return [
|
|
1488
|
-
index.h("limel-text-editor", { key: '
|
|
1499
|
+
index.h("limel-text-editor", { key: '68e52c47841ac14e5204c406ee3b0afc1daa3904', ref: (el) => (this.textEditor = el), tabindex: this.disabled ? -1 : 0, value: this.value, contentType: this.contentType, customElements: this.customElements, "aria-disabled": this.disabled, language: this.language, triggers: this.registeredTriggers, onTriggerStart: this.handleTriggerStart, onTriggerStop: this.handleTriggerStop, onTriggerChange: this.handleTriggerChange, 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 }),
|
|
1489
1500
|
this.renderPicker(),
|
|
1490
1501
|
];
|
|
1491
1502
|
}
|
|
@@ -1493,7 +1504,8 @@ const LimeBBTextEditor = class {
|
|
|
1493
1504
|
if (!this.isPickerOpen) {
|
|
1494
1505
|
return;
|
|
1495
1506
|
}
|
|
1496
|
-
return (index.h("limel-portal", { containerId: this.portalId, visible: this.isPickerOpen, openDirection: "top", inheritParentWidth: true, anchor: this.textEditor }, index.h("limebb-text-editor-picker", {
|
|
1507
|
+
return (index.h("limel-portal", { containerId: this.portalId, visible: this.isPickerOpen, openDirection: "top", inheritParentWidth: true, anchor: this.textEditor }, index.h("limebb-text-editor-picker", { ref: (el) => (this.textEditorPickerElement =
|
|
1508
|
+
el), items: getUpdatedItems(this.items, this.highlightedItemIndex), onItemSelected: this.handleItemSelection, emptyMessage: this.pickerMessage, isSearching: this.isSearching })));
|
|
1497
1509
|
}
|
|
1498
1510
|
async search() {
|
|
1499
1511
|
if (!this.limeObjectService) {
|
|
@@ -141,6 +141,15 @@ export class LimeBBTextEditor {
|
|
|
141
141
|
}),
|
|
142
142
|
},
|
|
143
143
|
};
|
|
144
|
+
this.handleMouseClick = (event) => {
|
|
145
|
+
if (!this.textEditorPickerElement) {
|
|
146
|
+
return;
|
|
147
|
+
}
|
|
148
|
+
const clickedOnTextEditorPicker = event.target === this.textEditorPickerElement;
|
|
149
|
+
if (!clickedOnTextEditorPicker) {
|
|
150
|
+
this.resetTriggerAndPicker();
|
|
151
|
+
}
|
|
152
|
+
};
|
|
144
153
|
this.handleKeyPress = (event) => {
|
|
145
154
|
if (!this.isPickerOpen || !this.activeTrigger) {
|
|
146
155
|
return;
|
|
@@ -312,6 +321,7 @@ export class LimeBBTextEditor {
|
|
|
312
321
|
this.host.addEventListener('keydown', this.handleKeyPress, {
|
|
313
322
|
capture: true,
|
|
314
323
|
});
|
|
324
|
+
document.addEventListener('mousedown', this.handleMouseClick);
|
|
315
325
|
}
|
|
316
326
|
else {
|
|
317
327
|
this.host.removeEventListener('keyup', this.handleKeyPress, {
|
|
@@ -320,11 +330,12 @@ export class LimeBBTextEditor {
|
|
|
320
330
|
this.host.removeEventListener('keydown', this.handleKeyPress, {
|
|
321
331
|
capture: true,
|
|
322
332
|
});
|
|
333
|
+
document.removeEventListener('mousedown', this.handleMouseClick);
|
|
323
334
|
}
|
|
324
335
|
}
|
|
325
336
|
render() {
|
|
326
337
|
return [
|
|
327
|
-
h("limel-text-editor", { key: '
|
|
338
|
+
h("limel-text-editor", { key: '68e52c47841ac14e5204c406ee3b0afc1daa3904', ref: (el) => (this.textEditor = el), tabindex: this.disabled ? -1 : 0, value: this.value, contentType: this.contentType, customElements: this.customElements, "aria-disabled": this.disabled, language: this.language, triggers: this.registeredTriggers, onTriggerStart: this.handleTriggerStart, onTriggerStop: this.handleTriggerStop, onTriggerChange: this.handleTriggerChange, 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 }),
|
|
328
339
|
this.renderPicker(),
|
|
329
340
|
];
|
|
330
341
|
}
|
|
@@ -332,7 +343,8 @@ export class LimeBBTextEditor {
|
|
|
332
343
|
if (!this.isPickerOpen) {
|
|
333
344
|
return;
|
|
334
345
|
}
|
|
335
|
-
return (h("limel-portal", { containerId: this.portalId, visible: this.isPickerOpen, openDirection: "top", inheritParentWidth: true, anchor: this.textEditor }, h("limebb-text-editor-picker", {
|
|
346
|
+
return (h("limel-portal", { containerId: this.portalId, visible: this.isPickerOpen, openDirection: "top", inheritParentWidth: true, anchor: this.textEditor }, h("limebb-text-editor-picker", { ref: (el) => (this.textEditorPickerElement =
|
|
347
|
+
el), items: getUpdatedItems(this.items, this.highlightedItemIndex), onItemSelected: this.handleItemSelection, emptyMessage: this.pickerMessage, isSearching: this.isSearching })));
|
|
336
348
|
}
|
|
337
349
|
async search() {
|
|
338
350
|
if (!this.limeObjectService) {
|
|
@@ -1301,6 +1301,15 @@ const LimeBBTextEditor = /*@__PURE__*/ proxyCustomElement(class LimeBBTextEditor
|
|
|
1301
1301
|
}),
|
|
1302
1302
|
},
|
|
1303
1303
|
};
|
|
1304
|
+
this.handleMouseClick = (event) => {
|
|
1305
|
+
if (!this.textEditorPickerElement) {
|
|
1306
|
+
return;
|
|
1307
|
+
}
|
|
1308
|
+
const clickedOnTextEditorPicker = event.target === this.textEditorPickerElement;
|
|
1309
|
+
if (!clickedOnTextEditorPicker) {
|
|
1310
|
+
this.resetTriggerAndPicker();
|
|
1311
|
+
}
|
|
1312
|
+
};
|
|
1304
1313
|
this.handleKeyPress = (event) => {
|
|
1305
1314
|
if (!this.isPickerOpen || !this.activeTrigger) {
|
|
1306
1315
|
return;
|
|
@@ -1472,6 +1481,7 @@ const LimeBBTextEditor = /*@__PURE__*/ proxyCustomElement(class LimeBBTextEditor
|
|
|
1472
1481
|
this.host.addEventListener('keydown', this.handleKeyPress, {
|
|
1473
1482
|
capture: true,
|
|
1474
1483
|
});
|
|
1484
|
+
document.addEventListener('mousedown', this.handleMouseClick);
|
|
1475
1485
|
}
|
|
1476
1486
|
else {
|
|
1477
1487
|
this.host.removeEventListener('keyup', this.handleKeyPress, {
|
|
@@ -1480,11 +1490,12 @@ const LimeBBTextEditor = /*@__PURE__*/ proxyCustomElement(class LimeBBTextEditor
|
|
|
1480
1490
|
this.host.removeEventListener('keydown', this.handleKeyPress, {
|
|
1481
1491
|
capture: true,
|
|
1482
1492
|
});
|
|
1493
|
+
document.removeEventListener('mousedown', this.handleMouseClick);
|
|
1483
1494
|
}
|
|
1484
1495
|
}
|
|
1485
1496
|
render() {
|
|
1486
1497
|
return [
|
|
1487
|
-
h("limel-text-editor", { key: '
|
|
1498
|
+
h("limel-text-editor", { key: '68e52c47841ac14e5204c406ee3b0afc1daa3904', ref: (el) => (this.textEditor = el), tabindex: this.disabled ? -1 : 0, value: this.value, contentType: this.contentType, customElements: this.customElements, "aria-disabled": this.disabled, language: this.language, triggers: this.registeredTriggers, onTriggerStart: this.handleTriggerStart, onTriggerStop: this.handleTriggerStop, onTriggerChange: this.handleTriggerChange, 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 }),
|
|
1488
1499
|
this.renderPicker(),
|
|
1489
1500
|
];
|
|
1490
1501
|
}
|
|
@@ -1492,7 +1503,8 @@ const LimeBBTextEditor = /*@__PURE__*/ proxyCustomElement(class LimeBBTextEditor
|
|
|
1492
1503
|
if (!this.isPickerOpen) {
|
|
1493
1504
|
return;
|
|
1494
1505
|
}
|
|
1495
|
-
return (h("limel-portal", { containerId: this.portalId, visible: this.isPickerOpen, openDirection: "top", inheritParentWidth: true, anchor: this.textEditor }, h("limebb-text-editor-picker", {
|
|
1506
|
+
return (h("limel-portal", { containerId: this.portalId, visible: this.isPickerOpen, openDirection: "top", inheritParentWidth: true, anchor: this.textEditor }, h("limebb-text-editor-picker", { ref: (el) => (this.textEditorPickerElement =
|
|
1507
|
+
el), items: getUpdatedItems(this.items, this.highlightedItemIndex), onItemSelected: this.handleItemSelection, emptyMessage: this.pickerMessage, isSearching: this.isSearching })));
|
|
1496
1508
|
}
|
|
1497
1509
|
async search() {
|
|
1498
1510
|
if (!this.limeObjectService) {
|
|
@@ -1298,6 +1298,15 @@ const LimeBBTextEditor = class {
|
|
|
1298
1298
|
}),
|
|
1299
1299
|
},
|
|
1300
1300
|
};
|
|
1301
|
+
this.handleMouseClick = (event) => {
|
|
1302
|
+
if (!this.textEditorPickerElement) {
|
|
1303
|
+
return;
|
|
1304
|
+
}
|
|
1305
|
+
const clickedOnTextEditorPicker = event.target === this.textEditorPickerElement;
|
|
1306
|
+
if (!clickedOnTextEditorPicker) {
|
|
1307
|
+
this.resetTriggerAndPicker();
|
|
1308
|
+
}
|
|
1309
|
+
};
|
|
1301
1310
|
this.handleKeyPress = (event) => {
|
|
1302
1311
|
if (!this.isPickerOpen || !this.activeTrigger) {
|
|
1303
1312
|
return;
|
|
@@ -1469,6 +1478,7 @@ const LimeBBTextEditor = class {
|
|
|
1469
1478
|
this.host.addEventListener('keydown', this.handleKeyPress, {
|
|
1470
1479
|
capture: true,
|
|
1471
1480
|
});
|
|
1481
|
+
document.addEventListener('mousedown', this.handleMouseClick);
|
|
1472
1482
|
}
|
|
1473
1483
|
else {
|
|
1474
1484
|
this.host.removeEventListener('keyup', this.handleKeyPress, {
|
|
@@ -1477,11 +1487,12 @@ const LimeBBTextEditor = class {
|
|
|
1477
1487
|
this.host.removeEventListener('keydown', this.handleKeyPress, {
|
|
1478
1488
|
capture: true,
|
|
1479
1489
|
});
|
|
1490
|
+
document.removeEventListener('mousedown', this.handleMouseClick);
|
|
1480
1491
|
}
|
|
1481
1492
|
}
|
|
1482
1493
|
render() {
|
|
1483
1494
|
return [
|
|
1484
|
-
h("limel-text-editor", { key: '
|
|
1495
|
+
h("limel-text-editor", { key: '68e52c47841ac14e5204c406ee3b0afc1daa3904', ref: (el) => (this.textEditor = el), tabindex: this.disabled ? -1 : 0, value: this.value, contentType: this.contentType, customElements: this.customElements, "aria-disabled": this.disabled, language: this.language, triggers: this.registeredTriggers, onTriggerStart: this.handleTriggerStart, onTriggerStop: this.handleTriggerStop, onTriggerChange: this.handleTriggerChange, 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 }),
|
|
1485
1496
|
this.renderPicker(),
|
|
1486
1497
|
];
|
|
1487
1498
|
}
|
|
@@ -1489,7 +1500,8 @@ const LimeBBTextEditor = class {
|
|
|
1489
1500
|
if (!this.isPickerOpen) {
|
|
1490
1501
|
return;
|
|
1491
1502
|
}
|
|
1492
|
-
return (h("limel-portal", { containerId: this.portalId, visible: this.isPickerOpen, openDirection: "top", inheritParentWidth: true, anchor: this.textEditor }, h("limebb-text-editor-picker", {
|
|
1503
|
+
return (h("limel-portal", { containerId: this.portalId, visible: this.isPickerOpen, openDirection: "top", inheritParentWidth: true, anchor: this.textEditor }, h("limebb-text-editor-picker", { ref: (el) => (this.textEditorPickerElement =
|
|
1504
|
+
el), items: getUpdatedItems(this.items, this.highlightedItemIndex), onItemSelected: this.handleItemSelection, emptyMessage: this.pickerMessage, isSearching: this.isSearching })));
|
|
1493
1505
|
}
|
|
1494
1506
|
async search() {
|
|
1495
1507
|
if (!this.limeObjectService) {
|
|
@@ -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-e3984a45",[[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-
|
|
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-e3984a45",[[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-04d67f14",[[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"],items:[32],highlightedItemIndex:[32],customElements:[32],registeredTriggers:[32],editorPickerQuery:[32],searchableLimetypes:[32],isPickerOpen:[32],isSearching:[32]},null,{isPickerOpen:["watchOpen"],editorPickerQuery:["watchQuery"]}]]],["p-ec740dee",[[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-d0bfc6a2",[[1,"limebb-dashboard-widget",{heading:[513],subheading:[513],supportingText:[513,"supporting-text"],icon:[513]}]]],["p-8f1d164d",[[1,"limebb-icon-picker",{value:[1],required:[4],readonly:[4],invalid:[4],disabled:[4],label:[1],helperText:[1,"helper-text"]}]]],["p-54292cee",[[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-a0858066",[[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-3755af2d",[[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-7e208183",[[1,"limebb-mention-group-counter",{count:[2],limetype:[16],helperLabel:[1,"helper-label"]}]]],["p-ede3e0c4",[[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-448679ad",[[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-edda236e",[[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-9536a00f",[[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-62616ef9",[[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-517a051a",[[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-ef7b9ac8",[[1,"limebb-notification-item",{platform:[16],context:[16],item:[16]}]]],["p-a6f3200f",[[1,"limebb-kanban-item",{platform:[16],context:[16],item:[16]}]]],["p-1a07c942",[[1,"limebb-empty-state",{heading:[513],value:[513],icon:[16]}]]]],e))));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as t,c as e,h as i,g as r}from"./p-b11e09b4.js";import{A as n,P as s}from"./p-a26d352f.js";import{a as o}from"./p-54d4113a.js";import{A as a,a as c,b as u,E as h,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 j,U as y,S as g,g as w}from"./p-bcc23575.js";import{i as O,e as k}from"./p-c40a3f4b.js";import{d as x,r as A,S,a as T,i as C}from"./p-b31772c8.js";import{d as M,i as E,o as _,g as I,h as F,n as N,a as P}from"./p-5322fd19.js";import{i as $}from"./p-6fd28e32.js";import"./p-22de5a0e.js";var D=/\s/,R=/^\s+/;var G=NaN,L=/^[-+]0x[0-9a-f]+$/i,U=/^0b[01]+$/i,Q=/^0o[0-7]+$/i,W=parseInt;function q(t){if("number"==typeof t)return t;if(O(t))return G;if(x(t)){var e="function"==typeof t.valueOf?t.valueOf():t;t=x(e)?e+"":e}if("string"!=typeof t)return 0===t?t:+t;var i;t=(i=t)?i.slice(0,function(t){for(var e=t.length;e--&&D.test(t.charAt(e)););return e}(i)+1).replace(R,""):i;var r=U.test(t);return r||Q.test(t)?W(t.slice(2),r?2:8):L.test(t)?G:+t}var B=Object.create;const z=function(){function t(){}return function(e){if(!x(e))return{};if(B)return B(e);t.prototype=e;var i=new t;return t.prototype=void 0,i}}();function H(t,e,i){"__proto__"==e&&d?d(t,e,{configurable:!0,enumerable:!0,value:i,writable:!0}):t[e]=i}var K=Object.prototype.hasOwnProperty;function V(t,e,i){var r=t[e];K.call(t,e)&&k(r,i)&&(void 0!==i||e in t)||H(t,e,i)}function J(t,e,i,r){var n=!i;i||(i={});for(var s=-1,o=e.length;++s<o;){var a=e[s],c=r?r(i[a],t[a],a,i,t):void 0;void 0===c&&(c=t[a]),n?H(i,a,c):V(i,a,c)}return i}var X=Object.prototype.hasOwnProperty;function Y(t){return E(t)?l(t,!0):function(t){if(!x(t))return function(t){var e=[];if(null!=t)for(var i in Object(t))e.push(i);return e}(t);var e=M(t),i=[];for(var r in t)("constructor"!=r||!e&&X.call(t,r))&&i.push(r);return i}(t)}const Z=_(Object.getPrototypeOf,Object);var tt="object"==typeof exports&&exports&&!exports.nodeType&&exports,et=tt&&"object"==typeof module&&module&&!module.nodeType&&module,it=et&&et.exports===tt?A.Buffer:void 0,rt=it?it.allocUnsafe:void 0;const nt=Object.getOwnPropertySymbols?function(t){for(var e=[];t;)m(e,b(t)),t=Z(t);return e}:p;function st(t){return j(t,Y,nt)}var ot=Object.prototype.hasOwnProperty;function at(t){var e=new t.constructor(t.byteLength);return new y(e).set(new y(t)),e}var ct=/\w*$/,ut=S?S.prototype:void 0,ht=ut?ut.valueOf:void 0,ft="[object Boolean]",dt="[object Date]",lt="[object Map]",vt="[object Number]",bt="[object RegExp]",pt="[object Set]",mt="[object String]",jt="[object Symbol]",yt="[object ArrayBuffer]",gt="[object DataView]",wt="[object Float32Array]",Ot="[object Float64Array]",kt="[object Int8Array]",xt="[object Int16Array]",At="[object Int32Array]",St="[object Uint8Array]",Tt="[object Uint8ClampedArray]",Ct="[object Uint16Array]",Mt="[object Uint32Array]";var Et=N&&N.isMap;const _t=Et?F(Et):function(t){return T(t)&&"[object Map]"==I(t)};var It=N&&N.isSet;const Ft=It?F(It):function(t){return T(t)&&"[object Set]"==I(t)};var Nt=1,Pt=2,$t=4,Dt="[object Arguments]",Rt="[object Function]",Gt="[object GeneratorFunction]",Lt="[object Object]",Ut={};function Qt(t,e,i,r,n,s){var o,a=e&Nt,c=e&Pt,u=e&$t;if(i&&(o=n?i(t,r,n,s):i(t)),void 0!==o)return o;if(!x(t))return t;var h=C(t);if(h){if(o=function(t){var e=t.length,i=new t.constructor(e);return e&&"string"==typeof t[0]&&ot.call(t,"index")&&(i.index=t.index,i.input=t.input),i}(t),!a)return function(t,e){var i=-1,r=t.length;for(e||(e=Array(r));++i<r;)e[i]=t[i];return e}(t,o)}else{var f=I(t),d=f==Rt||f==Gt;if(P(t))return function(t,e){if(e)return t.slice();var i=t.length,r=rt?rt(i):new t.constructor(i);return t.copy(r),r}(t,a);if(f==Lt||f==Dt||d&&!n){if(o=c||d?{}:function(t){return"function"!=typeof t.constructor||M(t)?{}:z(Z(t))}(t),!a)return c?function(t,e){return J(t,nt(t),e)}(t,function(t,e){return t&&J(e,Y(e),t)}(o,t)):function(t,e){return J(t,b(t),e)}(t,function(t,e){return t&&J(e,v(e),t)}(o,t))}else{if(!Ut[f])return n?t:{};o=function(t,e,i){var r,n,s=t.constructor;switch(e){case yt:return at(t);case ft:case dt:return new s(+t);case gt:return function(t,e){var i=e?at(t.buffer):t.buffer;return new t.constructor(i,t.byteOffset,t.byteLength)}(t,i);case wt:case Ot:case kt:case xt:case At:case St:case Tt:case Ct:case Mt:return function(t,e){var i=e?at(t.buffer):t.buffer;return new t.constructor(i,t.byteOffset,t.length)}(t,i);case lt:return new s;case vt:case mt:return new s(t);case bt:return(n=new(r=t).constructor(r.source,ct.exec(r))).lastIndex=r.lastIndex,n;case pt:return new s;case jt:return ht?Object(ht.call(t)):{}}}(t,f,a)}}s||(s=new g);var l=s.get(t);if(l)return l;s.set(t,o),Ft(t)?t.forEach((function(r){o.add(Qt(r,e,i,r,t,s))})):_t(t)&&t.forEach((function(r,n){o.set(n,Qt(r,e,i,n,t,s))}));var p=h?void 0:(u?c?st:w:c?Y:v)(t);return function(t,e){for(var i=-1,r=null==t?0:t.length;++i<r&&!1!==e(t[i],i););}(p||t,(function(r,n){p&&(r=t[n=r]),V(o,n,Qt(r,e,i,n,t,s))})),o}Ut[Dt]=Ut["[object Array]"]=Ut["[object ArrayBuffer]"]=Ut["[object DataView]"]=Ut["[object Boolean]"]=Ut["[object Date]"]=Ut["[object Float32Array]"]=Ut["[object Float64Array]"]=Ut["[object Int8Array]"]=Ut["[object Int16Array]"]=Ut["[object Int32Array]"]=Ut["[object Map]"]=Ut["[object Number]"]=Ut[Lt]=Ut["[object RegExp]"]=Ut["[object Set]"]=Ut["[object String]"]=Ut["[object Symbol]"]=Ut["[object Uint8Array]"]=Ut["[object Uint8ClampedArray]"]=Ut["[object Uint16Array]"]=Ut["[object Uint32Array]"]=!0,Ut["[object Error]"]=Ut[Rt]=Ut["[object WeakMap]"]=!1;const Wt=function(){return A.Date.now()};var qt=Math.max,Bt=Math.min;function zt(t,e){return t.label===e}function Ht(t,e){return Object.values(t.properties).find((t=>t&&t.relation&&zt(t.relation.getLimetype(),e)))}function Kt(t,e){const i=Ht(t,e);return!!i&&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)}(i)}const Vt=class{watchOpen(){this.setupHandlers()}watchQuery(){this.setPickerMessage()}constructor(i){var r;t(this,i),this.change=e(this,"change",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.items=[],this.highlightedItemIndex=0,this.customElements=[],this.registeredTriggers=[],this.isPickerOpen=!1,this.isSearching=!1,this.activeTrigger=void 0,this.groupCounts={},this.triggerMap={"@":{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.handleMouseClick=t=>{this.textEditorPickerElement&&(t.target===this.textEditorPickerElement||this.resetTriggerAndPicker())},this.handleKeyPress=t=>{if(!this.isPickerOpen||!this.activeTrigger)return;if(![c,u,a,h,f].includes(t.key))return;if(t.stopPropagation(),t.preventDefault(),"keyup"===t.type)return;const e={[c]:this.handleEscapeKey,[h]:this.handleEnterOrTabKey,[f]:this.handleEnterOrTabKey,[a]:this.handleArrowKeyPress,[u]:this.handleArrowKeyPress}[t.key];e&&e(t)},this.handleArrowKeyPress=t=>{var e;this.highlightedItemIndex=(this.highlightedItemIndex+(t.key===a?1:-1)+(e=this.items.length))%e},this.handleEscapeKey=()=>{var t;null===(t=this.triggerFunction)||void 0===t||t.stopTrigger(),this.resetTriggerAndPicker()},this.handleEnterOrTabKey=t=>{this.handleItemSelection(t)},this.handleTriggerStart=t=>{t.stopPropagation(),this.isPickerOpen=!0,this.activeTrigger=t.detail.trigger,this.triggerFunction=t.detail.textEditor},this.handleTriggerStop=t=>{t.stopPropagation(),this.resetTriggerAndPicker()},this.handleTriggerChange=t=>{t.stopImmediatePropagation(),this.editorPickerQuery=t.detail.value,this.isSearching=!0,this.search()},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 e;let i;if(t instanceof CustomEvent)i=t.detail;else{if(!(t instanceof KeyboardEvent))return;i=this.items[this.highlightedItemIndex]}this.insertEditorNode(i),this.resetTriggerAndPicker(),null===(e=this.textEditor)||void 0===e||e.focus()},this.insertEditorNode=t=>{var e,i;if(void 0===this.activeTrigger)return void console.warn("No triggerMap found");const r=this.triggerMap[this.activeTrigger];try{null===(e=this.triggerFunction)||void 0===e||e.insert({node:{tagName:r.customElement.tagName,attributes:r.mapAttributes(t)},children:[null===(i=t.value)||void 0===i?void 0:i.descriptive]})}catch(t){console.error("Can't insert node to the text editor",t)}},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.search=function(t,e,i){var r,n,s,o,a,c,u=0,h=!1,f=!1,d=!0;if("function"!=typeof t)throw new TypeError("Expected a function");function l(e){var i=r,s=n;return r=n=void 0,u=e,o=t.apply(s,i)}function v(t){var i=t-c;return void 0===c||i>=e||i<0||f&&t-u>=s}function b(){var t=Wt();if(v(t))return p(t);a=setTimeout(b,function(t){var i=e-(t-c);return f?Bt(i,s-(t-u)):i}(t))}function p(t){return a=void 0,d&&r?l(t):(r=n=void 0,o)}function m(){var t=Wt(),i=v(t);if(r=arguments,n=this,c=t,i){if(void 0===a)return function(t){return u=t,a=setTimeout(b,e),h?l(t):o}(c);if(f)return clearTimeout(a),a=setTimeout(b,e),l(c)}return void 0===a&&(a=setTimeout(b,e)),o}return e=q(e)||0,x(i)&&(h=!!i.leading,s=(f="maxWait"in i)?qt(q(i.maxWait)||0,e):s,d="trailing"in i?!!i.trailing:d),m.cancel=function(){void 0!==a&&clearTimeout(a),u=0,r=c=n=a=void 0},m.flush=function(){return void 0===a?o:p(Wt())},m}(this.search,300)}connectedCallback(){var t,e,i,r;if(this.draftIdentifier){const n=null!==(e=null===(t=this.context)||void 0===t?void 0:t.id)&&void 0!==e?e:"no-limeobject",s=null!==(r=null===(i=this.context)||void 0===i?void 0:i.limetype)&&void 0!==r?r:"no-limetype";this.textEditorInnerId=["text-editor-draft",s,n,this.draftIdentifier].join("-")}this.textEditorInnerId&&(document.addEventListener("visibilitychange",this.handleVisibilityChange),window.addEventListener("beforeunload",this.handleBeforeUnload))}componentWillLoad(){this.setCustomElementsAndTriggers(),this.loadGroupCounts(),this.loadDraft()}disconnectedCallback(){document.removeEventListener("visibilitychange",this.handleVisibilityChange),window.removeEventListener("beforeunload",this.handleBeforeUnload),this.saveDraft(),this.host&&(this.host.removeEventListener("keyup",this.handleKeyPress,{capture:!0}),this.host.removeEventListener("keydown",this.handleKeyPress,{capture:!0}))}setCustomElementsAndTriggers(){this.customElements=Object.values(this.triggerMap).map((t=>t.customElement)),this.allowMentioning&&(this.registeredTriggers=Object.keys(this.triggerMap))}setPickerMessage(){this.pickerMessage=!0===this.isPickerOpen&&this.editorPickerQuery.length>0?"No results for your search...":"Start typing a name..."}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))}render(){return[i("limel-text-editor",{key:"68e52c47841ac14e5204c406ee3b0afc1daa3904",ref:t=>this.textEditor=t,tabindex:this.disabled?-1:0,value:this.value,contentType:this.contentType,customElements:this.customElements,"aria-disabled":this.disabled,language:this.language,triggers:this.registeredTriggers,onTriggerStart:this.handleTriggerStart,onTriggerStop:this.handleTriggerStop,onTriggerChange:this.handleTriggerChange,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 i("limel-portal",{containerId:this.portalId,visible:this.isPickerOpen,openDirection:"top",inheritParentWidth:!0,anchor:this.textEditor},i("limebb-text-editor-picker",{ref:t=>this.textEditorPickerElement=t,items:(t=this.items,e=this.highlightedItemIndex,t.map(((t,i)=>{const r=Qt(t,5);return Object.assign(Object.assign({},r),{selected:i===e})}))),onItemSelected:this.handleItemSelection,emptyMessage:this.pickerMessage,isSearching:this.isSearching}));var t,e}async search(){if(!this.limeObjectService)return void(this.isSearching=!1);if(!this.editorPickerQuery)return this.items=[],void(this.isSearching=!1);const t=this.editorPickerQuery;try{const{objects:e}=await this.limeObjectService.search(t,this.searchableLimetypes,10);if(t!==this.editorPickerQuery)return;if(this.isSearching=!1,!e.length)return void(this.items=[]);if(!this.activeTrigger)return;this.items=this.createSearchListItems(e)}catch(t){console.error("Failed search for user",t)}}createSearchListItems(t=[]){return t.map((t=>this.createSearchListItem(t))).filter($)}createSearchListItem(t){const e=this.viewFactoryRegistry.getFactory("search"),i=this.limeObjectService.getObject(t._limetype,t._id);if(!i)return null;const r=e(i,this.context),n=this.getGroupCountComponent(i);return Object.assign(Object.assign({},r),n?{primaryComponent:n}:{})}getGroupCountComponent(t){var e;const i=t.getLimetype(),r=null===(e=this.groupCounts[i.name])||void 0===e?void 0:e[t.id],n=Ht(i,"user");if(void 0!==r&&n)return{name:"limebb-mention-group-counter",props:{count:r,limetype:n.relation.getLimetype(),helperLabel:this.translator.get("webclient.notification-center.members-will-be-notified")}}}async loadGroupCounts(){if(!this.allowMentioning)return;const t=this.searchableLimetypes.filter((t=>!zt(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 e;const i=Ht(t,"user"),r=t.name;try{const t=await this.query.execute({limetype:r,responseFormat:{object:{_id:null,[i.name]:{count:{aggregate:{op:n.Count}}}}}});if(!(null===(e=t.objects)||void 0===e?void 0:e.length))return{[r]:{}};const s=this.createGroupCount(t.objects,i.name);return{[r]:s}}catch(e){return console.error(`Error fetching group count for limetype: ${t.name}`,e),{[r]:{}}}}createGroupCount(t,e){const i={};return t.forEach((t=>{const{_id:r,[e]:n}=t;i[r]=n.count})),i}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,e,i;this.textEditorInnerId&&((null===(t=this.value)||void 0===t?void 0:t.trim())?null===(e=this.userDataService)||void 0===e||e.set(this.textEditorInnerId,this.value):null===(i=this.userDataService)||void 0===i||i.set(this.textEditorInnerId,void 0))}get limeObjectService(){return this.platform.get(s.LimeObjectRepository)}get query(){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 userDataService(){return this.platform.get(s.UserDataRepository)}get host(){return r(this)}static get watchers(){return{isPickerOpen:["watchOpen"],editorPickerQuery:["watchQuery"]}}};!function(t,e,i,r){var n,s=arguments.length,o=s<3?e:null===r?r=Object.getOwnPropertyDescriptor(e,i):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(t,e,i,r);else for(var a=t.length-1;a>=0;a--)(n=t[a])&&(o=(s<3?n(o):s>3?n(e,i,o):n(e,i))||o);s>3&&o&&Object.defineProperty(e,i,o)}([o({map:[function(t){return Object.values(t).filter((t=>zt(t,"user")||Kt(t,"user")))}]})],Vt.prototype,"searchableLimetypes",void 0);export{Vt as limebb_text_editor}
|
|
@@ -183,6 +183,7 @@ export declare class LimeBBTextEditor implements FormComponent<string> {
|
|
|
183
183
|
private pickerMessage;
|
|
184
184
|
private readonly triggerMap;
|
|
185
185
|
private textEditor;
|
|
186
|
+
private textEditorPickerElement;
|
|
186
187
|
private textEditorInnerId;
|
|
187
188
|
protected watchOpen(): void;
|
|
188
189
|
protected watchQuery(): void;
|
|
@@ -193,6 +194,7 @@ export declare class LimeBBTextEditor implements FormComponent<string> {
|
|
|
193
194
|
private setCustomElementsAndTriggers;
|
|
194
195
|
private setPickerMessage;
|
|
195
196
|
private setupHandlers;
|
|
197
|
+
private readonly handleMouseClick;
|
|
196
198
|
private readonly handleKeyPress;
|
|
197
199
|
private readonly handleArrowKeyPress;
|
|
198
200
|
private readonly handleEscapeKey;
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as t,c as e,h as i,g as r}from"./p-b11e09b4.js";import{A as n,P as s}from"./p-a26d352f.js";import{a as o}from"./p-54d4113a.js";import{A as a,a as c,b as u,E as h,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 j,U as y,S as g,g as w}from"./p-bcc23575.js";import{i as O,e as k}from"./p-c40a3f4b.js";import{d as x,r as A,S,a as T,i as C}from"./p-b31772c8.js";import{d as M,i as E,o as _,g as I,h as F,n as N,a as P}from"./p-5322fd19.js";import{i as $}from"./p-6fd28e32.js";import"./p-22de5a0e.js";var D=/\s/,R=/^\s+/;var G=NaN,L=/^[-+]0x[0-9a-f]+$/i,U=/^0b[01]+$/i,Q=/^0o[0-7]+$/i,W=parseInt;function q(t){if("number"==typeof t)return t;if(O(t))return G;if(x(t)){var e="function"==typeof t.valueOf?t.valueOf():t;t=x(e)?e+"":e}if("string"!=typeof t)return 0===t?t:+t;var i;t=(i=t)?i.slice(0,function(t){for(var e=t.length;e--&&D.test(t.charAt(e)););return e}(i)+1).replace(R,""):i;var r=U.test(t);return r||Q.test(t)?W(t.slice(2),r?2:8):L.test(t)?G:+t}var B=Object.create;const z=function(){function t(){}return function(e){if(!x(e))return{};if(B)return B(e);t.prototype=e;var i=new t;return t.prototype=void 0,i}}();function H(t,e,i){"__proto__"==e&&d?d(t,e,{configurable:!0,enumerable:!0,value:i,writable:!0}):t[e]=i}var K=Object.prototype.hasOwnProperty;function V(t,e,i){var r=t[e];K.call(t,e)&&k(r,i)&&(void 0!==i||e in t)||H(t,e,i)}function J(t,e,i,r){var n=!i;i||(i={});for(var s=-1,o=e.length;++s<o;){var a=e[s],c=r?r(i[a],t[a],a,i,t):void 0;void 0===c&&(c=t[a]),n?H(i,a,c):V(i,a,c)}return i}var X=Object.prototype.hasOwnProperty;function Y(t){return E(t)?l(t,!0):function(t){if(!x(t))return function(t){var e=[];if(null!=t)for(var i in Object(t))e.push(i);return e}(t);var e=M(t),i=[];for(var r in t)("constructor"!=r||!e&&X.call(t,r))&&i.push(r);return i}(t)}const Z=_(Object.getPrototypeOf,Object);var tt="object"==typeof exports&&exports&&!exports.nodeType&&exports,et=tt&&"object"==typeof module&&module&&!module.nodeType&&module,it=et&&et.exports===tt?A.Buffer:void 0,rt=it?it.allocUnsafe:void 0;const nt=Object.getOwnPropertySymbols?function(t){for(var e=[];t;)m(e,b(t)),t=Z(t);return e}:p;function st(t){return j(t,Y,nt)}var ot=Object.prototype.hasOwnProperty;function at(t){var e=new t.constructor(t.byteLength);return new y(e).set(new y(t)),e}var ct=/\w*$/,ut=S?S.prototype:void 0,ht=ut?ut.valueOf:void 0,ft="[object Boolean]",dt="[object Date]",lt="[object Map]",vt="[object Number]",bt="[object RegExp]",pt="[object Set]",mt="[object String]",jt="[object Symbol]",yt="[object ArrayBuffer]",gt="[object DataView]",wt="[object Float32Array]",Ot="[object Float64Array]",kt="[object Int8Array]",xt="[object Int16Array]",At="[object Int32Array]",St="[object Uint8Array]",Tt="[object Uint8ClampedArray]",Ct="[object Uint16Array]",Mt="[object Uint32Array]";var Et=N&&N.isMap;const _t=Et?F(Et):function(t){return T(t)&&"[object Map]"==I(t)};var It=N&&N.isSet;const Ft=It?F(It):function(t){return T(t)&&"[object Set]"==I(t)};var Nt=1,Pt=2,$t=4,Dt="[object Arguments]",Rt="[object Function]",Gt="[object GeneratorFunction]",Lt="[object Object]",Ut={};function Qt(t,e,i,r,n,s){var o,a=e&Nt,c=e&Pt,u=e&$t;if(i&&(o=n?i(t,r,n,s):i(t)),void 0!==o)return o;if(!x(t))return t;var h=C(t);if(h){if(o=function(t){var e=t.length,i=new t.constructor(e);return e&&"string"==typeof t[0]&&ot.call(t,"index")&&(i.index=t.index,i.input=t.input),i}(t),!a)return function(t,e){var i=-1,r=t.length;for(e||(e=Array(r));++i<r;)e[i]=t[i];return e}(t,o)}else{var f=I(t),d=f==Rt||f==Gt;if(P(t))return function(t,e){if(e)return t.slice();var i=t.length,r=rt?rt(i):new t.constructor(i);return t.copy(r),r}(t,a);if(f==Lt||f==Dt||d&&!n){if(o=c||d?{}:function(t){return"function"!=typeof t.constructor||M(t)?{}:z(Z(t))}(t),!a)return c?function(t,e){return J(t,nt(t),e)}(t,function(t,e){return t&&J(e,Y(e),t)}(o,t)):function(t,e){return J(t,b(t),e)}(t,function(t,e){return t&&J(e,v(e),t)}(o,t))}else{if(!Ut[f])return n?t:{};o=function(t,e,i){var r,n,s=t.constructor;switch(e){case yt:return at(t);case ft:case dt:return new s(+t);case gt:return function(t,e){var i=e?at(t.buffer):t.buffer;return new t.constructor(i,t.byteOffset,t.byteLength)}(t,i);case wt:case Ot:case kt:case xt:case At:case St:case Tt:case Ct:case Mt:return function(t,e){var i=e?at(t.buffer):t.buffer;return new t.constructor(i,t.byteOffset,t.length)}(t,i);case lt:return new s;case vt:case mt:return new s(t);case bt:return(n=new(r=t).constructor(r.source,ct.exec(r))).lastIndex=r.lastIndex,n;case pt:return new s;case jt:return ht?Object(ht.call(t)):{}}}(t,f,a)}}s||(s=new g);var l=s.get(t);if(l)return l;s.set(t,o),Ft(t)?t.forEach((function(r){o.add(Qt(r,e,i,r,t,s))})):_t(t)&&t.forEach((function(r,n){o.set(n,Qt(r,e,i,n,t,s))}));var p=h?void 0:(u?c?st:w:c?Y:v)(t);return function(t,e){for(var i=-1,r=null==t?0:t.length;++i<r&&!1!==e(t[i],i););}(p||t,(function(r,n){p&&(r=t[n=r]),V(o,n,Qt(r,e,i,n,t,s))})),o}Ut[Dt]=Ut["[object Array]"]=Ut["[object ArrayBuffer]"]=Ut["[object DataView]"]=Ut["[object Boolean]"]=Ut["[object Date]"]=Ut["[object Float32Array]"]=Ut["[object Float64Array]"]=Ut["[object Int8Array]"]=Ut["[object Int16Array]"]=Ut["[object Int32Array]"]=Ut["[object Map]"]=Ut["[object Number]"]=Ut[Lt]=Ut["[object RegExp]"]=Ut["[object Set]"]=Ut["[object String]"]=Ut["[object Symbol]"]=Ut["[object Uint8Array]"]=Ut["[object Uint8ClampedArray]"]=Ut["[object Uint16Array]"]=Ut["[object Uint32Array]"]=!0,Ut["[object Error]"]=Ut[Rt]=Ut["[object WeakMap]"]=!1;const Wt=function(){return A.Date.now()};var qt=Math.max,Bt=Math.min;function zt(t,e){return t.label===e}function Ht(t,e){return Object.values(t.properties).find((t=>t&&t.relation&&zt(t.relation.getLimetype(),e)))}function Kt(t,e){const i=Ht(t,e);return!!i&&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)}(i)}const Vt=class{watchOpen(){this.setupHandlers()}watchQuery(){this.setPickerMessage()}constructor(i){var r;t(this,i),this.change=e(this,"change",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.items=[],this.highlightedItemIndex=0,this.customElements=[],this.registeredTriggers=[],this.isPickerOpen=!1,this.isSearching=!1,this.activeTrigger=void 0,this.groupCounts={},this.triggerMap={"@":{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.handleKeyPress=t=>{if(!this.isPickerOpen||!this.activeTrigger)return;if(![c,u,a,h,f].includes(t.key))return;if(t.stopPropagation(),t.preventDefault(),"keyup"===t.type)return;const e={[c]:this.handleEscapeKey,[h]:this.handleEnterOrTabKey,[f]:this.handleEnterOrTabKey,[a]:this.handleArrowKeyPress,[u]:this.handleArrowKeyPress}[t.key];e&&e(t)},this.handleArrowKeyPress=t=>{var e;this.highlightedItemIndex=(this.highlightedItemIndex+(t.key===a?1:-1)+(e=this.items.length))%e},this.handleEscapeKey=()=>{var t;null===(t=this.triggerFunction)||void 0===t||t.stopTrigger(),this.resetTriggerAndPicker()},this.handleEnterOrTabKey=t=>{this.handleItemSelection(t)},this.handleTriggerStart=t=>{t.stopPropagation(),this.isPickerOpen=!0,this.activeTrigger=t.detail.trigger,this.triggerFunction=t.detail.textEditor},this.handleTriggerStop=t=>{t.stopPropagation(),this.resetTriggerAndPicker()},this.handleTriggerChange=t=>{t.stopImmediatePropagation(),this.editorPickerQuery=t.detail.value,this.isSearching=!0,this.search()},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 e;let i;if(t instanceof CustomEvent)i=t.detail;else{if(!(t instanceof KeyboardEvent))return;i=this.items[this.highlightedItemIndex]}this.insertEditorNode(i),this.resetTriggerAndPicker(),null===(e=this.textEditor)||void 0===e||e.focus()},this.insertEditorNode=t=>{var e,i;if(void 0===this.activeTrigger)return void console.warn("No triggerMap found");const r=this.triggerMap[this.activeTrigger];try{null===(e=this.triggerFunction)||void 0===e||e.insert({node:{tagName:r.customElement.tagName,attributes:r.mapAttributes(t)},children:[null===(i=t.value)||void 0===i?void 0:i.descriptive]})}catch(t){console.error("Can't insert node to the text editor",t)}},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.search=function(t,e,i){var r,n,s,o,a,c,u=0,h=!1,f=!1,d=!0;if("function"!=typeof t)throw new TypeError("Expected a function");function l(e){var i=r,s=n;return r=n=void 0,u=e,o=t.apply(s,i)}function v(t){var i=t-c;return void 0===c||i>=e||i<0||f&&t-u>=s}function b(){var t=Wt();if(v(t))return p(t);a=setTimeout(b,function(t){var i=e-(t-c);return f?Bt(i,s-(t-u)):i}(t))}function p(t){return a=void 0,d&&r?l(t):(r=n=void 0,o)}function m(){var t=Wt(),i=v(t);if(r=arguments,n=this,c=t,i){if(void 0===a)return function(t){return u=t,a=setTimeout(b,e),h?l(t):o}(c);if(f)return clearTimeout(a),a=setTimeout(b,e),l(c)}return void 0===a&&(a=setTimeout(b,e)),o}return e=q(e)||0,x(i)&&(h=!!i.leading,s=(f="maxWait"in i)?qt(q(i.maxWait)||0,e):s,d="trailing"in i?!!i.trailing:d),m.cancel=function(){void 0!==a&&clearTimeout(a),u=0,r=c=n=a=void 0},m.flush=function(){return void 0===a?o:p(Wt())},m}(this.search,300)}connectedCallback(){var t,e,i,r;if(this.draftIdentifier){const n=null!==(e=null===(t=this.context)||void 0===t?void 0:t.id)&&void 0!==e?e:"no-limeobject",s=null!==(r=null===(i=this.context)||void 0===i?void 0:i.limetype)&&void 0!==r?r:"no-limetype";this.textEditorInnerId=["text-editor-draft",s,n,this.draftIdentifier].join("-")}this.textEditorInnerId&&(document.addEventListener("visibilitychange",this.handleVisibilityChange),window.addEventListener("beforeunload",this.handleBeforeUnload))}componentWillLoad(){this.setCustomElementsAndTriggers(),this.loadGroupCounts(),this.loadDraft()}disconnectedCallback(){document.removeEventListener("visibilitychange",this.handleVisibilityChange),window.removeEventListener("beforeunload",this.handleBeforeUnload),this.saveDraft(),this.host&&(this.host.removeEventListener("keyup",this.handleKeyPress,{capture:!0}),this.host.removeEventListener("keydown",this.handleKeyPress,{capture:!0}))}setCustomElementsAndTriggers(){this.customElements=Object.values(this.triggerMap).map((t=>t.customElement)),this.allowMentioning&&(this.registeredTriggers=Object.keys(this.triggerMap))}setPickerMessage(){this.pickerMessage=!0===this.isPickerOpen&&this.editorPickerQuery.length>0?"No results for your search...":"Start typing a name..."}setupHandlers(){this.isPickerOpen?(this.host.addEventListener("keyup",this.handleKeyPress,{capture:!0}),this.host.addEventListener("keydown",this.handleKeyPress,{capture:!0})):(this.host.removeEventListener("keyup",this.handleKeyPress,{capture:!0}),this.host.removeEventListener("keydown",this.handleKeyPress,{capture:!0}))}render(){return[i("limel-text-editor",{key:"b5cd5406139cd8c05b32888a111e05ce4a525dd7",ref:t=>this.textEditor=t,tabindex:this.disabled?-1:0,value:this.value,contentType:this.contentType,customElements:this.customElements,"aria-disabled":this.disabled,language:this.language,triggers:this.registeredTriggers,onTriggerStart:this.handleTriggerStart,onTriggerStop:this.handleTriggerStop,onTriggerChange:this.handleTriggerChange,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 i("limel-portal",{containerId:this.portalId,visible:this.isPickerOpen,openDirection:"top",inheritParentWidth:!0,anchor:this.textEditor},i("limebb-text-editor-picker",{items:(t=this.items,e=this.highlightedItemIndex,t.map(((t,i)=>{const r=Qt(t,5);return Object.assign(Object.assign({},r),{selected:i===e})}))),onItemSelected:this.handleItemSelection,emptyMessage:this.pickerMessage,isSearching:this.isSearching}));var t,e}async search(){if(!this.limeObjectService)return void(this.isSearching=!1);if(!this.editorPickerQuery)return this.items=[],void(this.isSearching=!1);const t=this.editorPickerQuery;try{const{objects:e}=await this.limeObjectService.search(t,this.searchableLimetypes,10);if(t!==this.editorPickerQuery)return;if(this.isSearching=!1,!e.length)return void(this.items=[]);if(!this.activeTrigger)return;this.items=this.createSearchListItems(e)}catch(t){console.error("Failed search for user",t)}}createSearchListItems(t=[]){return t.map((t=>this.createSearchListItem(t))).filter($)}createSearchListItem(t){const e=this.viewFactoryRegistry.getFactory("search"),i=this.limeObjectService.getObject(t._limetype,t._id);if(!i)return null;const r=e(i,this.context),n=this.getGroupCountComponent(i);return Object.assign(Object.assign({},r),n?{primaryComponent:n}:{})}getGroupCountComponent(t){var e;const i=t.getLimetype(),r=null===(e=this.groupCounts[i.name])||void 0===e?void 0:e[t.id],n=Ht(i,"user");if(void 0!==r&&n)return{name:"limebb-mention-group-counter",props:{count:r,limetype:n.relation.getLimetype(),helperLabel:this.translator.get("webclient.notification-center.members-will-be-notified")}}}async loadGroupCounts(){if(!this.allowMentioning)return;const t=this.searchableLimetypes.filter((t=>!zt(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 e;const i=Ht(t,"user"),r=t.name;try{const t=await this.query.execute({limetype:r,responseFormat:{object:{_id:null,[i.name]:{count:{aggregate:{op:n.Count}}}}}});if(!(null===(e=t.objects)||void 0===e?void 0:e.length))return{[r]:{}};const s=this.createGroupCount(t.objects,i.name);return{[r]:s}}catch(e){return console.error(`Error fetching group count for limetype: ${t.name}`,e),{[r]:{}}}}createGroupCount(t,e){const i={};return t.forEach((t=>{const{_id:r,[e]:n}=t;i[r]=n.count})),i}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,e,i;this.textEditorInnerId&&((null===(t=this.value)||void 0===t?void 0:t.trim())?null===(e=this.userDataService)||void 0===e||e.set(this.textEditorInnerId,this.value):null===(i=this.userDataService)||void 0===i||i.set(this.textEditorInnerId,void 0))}get limeObjectService(){return this.platform.get(s.LimeObjectRepository)}get query(){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 userDataService(){return this.platform.get(s.UserDataRepository)}get host(){return r(this)}static get watchers(){return{isPickerOpen:["watchOpen"],editorPickerQuery:["watchQuery"]}}};!function(t,e,i,r){var n,s=arguments.length,o=s<3?e:null===r?r=Object.getOwnPropertyDescriptor(e,i):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(t,e,i,r);else for(var a=t.length-1;a>=0;a--)(n=t[a])&&(o=(s<3?n(o):s>3?n(e,i,o):n(e,i))||o);s>3&&o&&Object.defineProperty(e,i,o)}([o({map:[function(t){return Object.values(t).filter((t=>zt(t,"user")||Kt(t,"user")))}]})],Vt.prototype,"searchableLimetypes",void 0);export{Vt as limebb_text_editor}
|