@limetech/lime-crm-building-blocks 1.52.0 → 1.54.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 +14 -0
- package/dist/cjs/lime-crm-building-blocks.cjs.js +1 -1
- package/dist/cjs/limebb-text-editor.cjs.entry.js +93 -87
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/collection/components/text-editor/mentions.js +27 -0
- package/dist/collection/components/text-editor/text-editor.js +91 -34
- package/dist/components/limebb-text-editor.js +96 -89
- package/dist/esm/lime-crm-building-blocks.js +1 -1
- package/dist/esm/limebb-text-editor.entry.js +93 -87
- package/dist/esm/loader.js +1 -1
- package/dist/lime-crm-building-blocks/lime-crm-building-blocks.esm.js +1 -1
- package/dist/lime-crm-building-blocks/p-6ed04e48.entry.js +1 -0
- package/dist/types/components/text-editor/mentions.d.ts +8 -0
- package/dist/types/components/text-editor/text-editor.d.ts +20 -5
- package/dist/types/components/text-editor/utils/searcher-utils.d.ts +1 -1
- package/dist/types/components.d.ts +13 -5
- package/package.json +1 -1
- package/dist/lime-crm-building-blocks/p-3327dbec.entry.js +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
## [1.54.0](https://github.com/Lundalogik/lime-crm-building-blocks/compare/v1.53.0...v1.54.0) (2024-11-26)
|
|
2
|
+
|
|
3
|
+
### Features
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
* **text-editor:** be able to mention a group ([e9b403a](https://github.com/Lundalogik/lime-crm-building-blocks/commit/e9b403aaa1d11ba78f9e8e34f8a2711c8f0bc3a3))
|
|
7
|
+
|
|
8
|
+
## [1.53.0](https://github.com/Lundalogik/lime-crm-building-blocks/compare/v1.52.0...v1.53.0) (2024-11-25)
|
|
9
|
+
|
|
10
|
+
### Features
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
* **text-editor:** pass missing props ([419f32c](https://github.com/Lundalogik/lime-crm-building-blocks/commit/419f32cb7922d7f8d0375124a81f99a59a925892))
|
|
14
|
+
|
|
1
15
|
## [1.52.0](https://github.com/Lundalogik/lime-crm-building-blocks/compare/v1.51.0...v1.52.0) (2024-11-22)
|
|
2
16
|
|
|
3
17
|
### Features
|
|
@@ -15,5 +15,5 @@ const patchBrowser = () => {
|
|
|
15
15
|
};
|
|
16
16
|
|
|
17
17
|
patchBrowser().then(options => {
|
|
18
|
-
return index.bootstrapLazy([["limebb-feed.cjs",[[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"],"lastVisitedTimestamp":[1,"last-visited-timestamp"]}]]],["limebb-kanban.cjs",[[1,"limebb-kanban",{"platform":[16],"context":[16],"items":[16],"paginationSize":[2,"pagination-size"],"groupBy":[513,"group-by"],"groups":[16]}]]],["limebb-date-range.cjs",[[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]}]]],["limebb-info-tile-currency-format.cjs",[[1,"limebb-info-tile-currency-format",{"platform":[16],"context":[16],"value":[16]}]]],["limebb-notification-list.cjs",[[1,"limebb-notification-list",{"platform":[16],"context":[16],"items":[16],"loading":[4],"lastVisitedTimestamp":[1,"last-visited-timestamp"]}]]],["limebb-text-editor.cjs",[[1,"limebb-text-editor",{"platform":[16],"context":[16],"contentType":[1,"content-type"],"language":[513],"disabled":[516],"readonly":[516],"helperText":[513,"helper-text"],"placeholder":[513],"label":[513],"invalid":[516],"
|
|
18
|
+
return index.bootstrapLazy([["limebb-feed.cjs",[[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"],"lastVisitedTimestamp":[1,"last-visited-timestamp"]}]]],["limebb-kanban.cjs",[[1,"limebb-kanban",{"platform":[16],"context":[16],"items":[16],"paginationSize":[2,"pagination-size"],"groupBy":[513,"group-by"],"groups":[16]}]]],["limebb-date-range.cjs",[[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]}]]],["limebb-info-tile-currency-format.cjs",[[1,"limebb-info-tile-currency-format",{"platform":[16],"context":[16],"value":[16]}]]],["limebb-notification-list.cjs",[[1,"limebb-notification-list",{"platform":[16],"context":[16],"items":[16],"loading":[4],"lastVisitedTimestamp":[1,"last-visited-timestamp"]}]]],["limebb-text-editor.cjs",[[1,"limebb-text-editor",{"platform":[16],"context":[16],"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],"items":[32],"customElements":[32],"registeredTriggers":[32],"editorPickerQuery":[32],"searchableLimetypes":[32],"isPickerOpen":[32]}]]],["limebb-browser.cjs",[[17,"limebb-browser",{"platform":[16],"context":[16],"items":[16],"layout":[1],"filter":[32]}]]],["limebb-component-config.cjs",[[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]}]]],["limebb-component-picker.cjs",[[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"]}]]],["limebb-dashboard-widget.cjs",[[1,"limebb-dashboard-widget",{"heading":[513],"subheading":[513],"supportingText":[513,"supporting-text"],"icon":[513]}]]],["limebb-icon-picker.cjs",[[1,"limebb-icon-picker",{"value":[1],"required":[4],"readonly":[4],"invalid":[4],"disabled":[4],"label":[1],"helperText":[1,"helper-text"]}]]],["limebb-info-tile.cjs",[[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]}]]],["limebb-info-tile-date-format.cjs",[[1,"limebb-info-tile-date-format",{"value":[16]}]]],["limebb-info-tile-decimal-format.cjs",[[1,"limebb-info-tile-decimal-format",{"value":[16]}]]],["limebb-info-tile-format.cjs",[[1,"limebb-info-tile-format",{"platform":[16],"context":[16],"type":[1],"value":[16]}]]],["limebb-info-tile-relative-date-format.cjs",[[1,"limebb-info-tile-relative-date-format",{"value":[16]}]]],["limebb-info-tile-unit-format.cjs",[[1,"limebb-info-tile-unit-format",{"value":[16]}]]],["limebb-limeobject-file-viewer.cjs",[[1,"limebb-limeobject-file-viewer",{"platform":[16],"context":[16],"property":[1],"fileTypes":[16],"limeobject":[32],"limetype":[32]}]]],["limebb-locale-picker.cjs",[[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]}]]],["limebb-mention.cjs",[[1,"limebb-mention",{"limetype":[1],"objectid":[2],"limeobject":[32]}]]],["limebb-navigation-button.cjs",[[17,"limebb-navigation-button",{"href":[513],"tooltipLabel":[513,"tooltip-label"],"tooltipHelperLabel":[513,"tooltip-helper-label"],"type":[513]}]]],["limebb-kanban-column.cjs",[[1,"limebb-kanban-column",{"platform":[16],"context":[16],"columnHeading":[1,"column-heading"],"items":[16],"loading":[4],"paginationSize":[2,"pagination-size"],"displayedItemCount":[32]}]]],["limebb-currency-picker.cjs",[[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]}]]],["limebb-date-picker.cjs",[[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]}]]],["limebb-notification-item.cjs",[[1,"limebb-notification-item",{"platform":[16],"context":[16],"item":[16]}]]],["limebb-text-editor-picker.cjs",[[1,"limebb-text-editor-picker",{"items":[16],"open":[516],"emptyMessage":[1,"empty-message"]}]]],["limebb-empty-state_2.cjs",[[1,"limebb-empty-state",{"heading":[513],"value":[513],"icon":[16]}],[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]}]]],["limebb-kanban-item.cjs",[[1,"limebb-kanban-item",{"platform":[16],"context":[16],"item":[16]}]]]], options);
|
|
19
19
|
});
|
|
@@ -10,77 +10,26 @@ const nonNull = require('./non-null-45e885d5.js');
|
|
|
10
10
|
require('./factory-310afac1.js');
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
|
-
* Creates a function to find a limetype by its label in a collection of limetypes.
|
|
14
|
-
*
|
|
15
|
-
* The returned function searches through a collection of limetypes and returns
|
|
16
|
-
* the first one that matches the given label. This function is typically used
|
|
17
|
-
* to generate a callback for decorators or other higher-order logic.
|
|
18
|
-
*
|
|
19
|
-
* @param label - The label of the limetype to find.
|
|
20
|
-
* @returns A function that takes a collection of limetypes and returns the first
|
|
21
|
-
* limetype that matches the label, or `undefined` if no match is found.
|
|
22
|
-
*
|
|
23
|
-
* @example
|
|
24
|
-
* ```typescript
|
|
25
|
-
* import { findLimetypeByLabel } from '@limetech/lime-web-components';
|
|
26
|
-
*
|
|
27
|
-
* const limetypes = {
|
|
28
|
-
* company: { label: 'company', properties: {} },
|
|
29
|
-
* person: { label: 'person', properties: {} },
|
|
30
|
-
* };
|
|
31
|
-
*
|
|
32
|
-
* const findPersonLimetype = findLimetypeByLabel('person');
|
|
33
|
-
* const personLimetype = findPersonLimetype(limetypes);
|
|
34
|
-
* console.log(personLimetype); // { label: 'person', properties: {} }
|
|
35
|
-
* ```
|
|
36
|
-
*
|
|
37
|
-
* @example
|
|
38
|
-
* ```typescript
|
|
39
|
-
* // Using `findLimetypeByLabel` as a callback for a decorator
|
|
40
|
-
* import { findLimetypeByLabel, SelectLimeTypes } from '@limetech/lime-web-components';
|
|
41
|
-
*
|
|
42
|
-
* @SelectLimeTypes({
|
|
43
|
-
* map: [findLimetypeByLabel('person')],
|
|
44
|
-
* })
|
|
45
|
-
* private personLimetype: LimeType;
|
|
46
|
-
* ```
|
|
47
|
-
*
|
|
48
13
|
* @public
|
|
49
14
|
* @group Lime types
|
|
50
15
|
*/
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
16
|
+
function isRelation(property) {
|
|
17
|
+
const propTypes = [
|
|
18
|
+
'belongsto',
|
|
19
|
+
'hasone',
|
|
20
|
+
'hasmany',
|
|
21
|
+
'hasandbelongstomany',
|
|
22
|
+
];
|
|
23
|
+
return property && propTypes.includes(property.type);
|
|
24
|
+
}
|
|
55
25
|
/**
|
|
56
|
-
* Creates a function to check if a given object has a specific label.
|
|
57
|
-
*
|
|
58
|
-
* The returned function takes an object (a `LimeType` or `LimeProperty`) and
|
|
59
|
-
* checks whether it contains the specified label. This function is typically
|
|
60
|
-
* used as a callback for array methods like `.find` or `.filter`.
|
|
61
|
-
*
|
|
62
|
-
* @param label - The label to check for.
|
|
63
|
-
* @returns A function that takes an optional object and returns `true` if the label matches, or `false` otherwise.
|
|
64
|
-
*
|
|
65
|
-
* @example
|
|
66
|
-
* ```typescript
|
|
67
|
-
* import { hasLabel } from '@limetech/lime-web-components';
|
|
68
|
-
*
|
|
69
|
-
* const properties = [
|
|
70
|
-
* { label: 'name', type: 'string' },
|
|
71
|
-
* { label: 'email', type: 'string' },
|
|
72
|
-
* ];
|
|
73
|
-
*
|
|
74
|
-
* const emailProperty = properties.find(hasLabel('email'));
|
|
75
|
-
* console.log(emailProperty); // { label: 'email', type: 'string' }
|
|
76
|
-
* ```
|
|
77
|
-
*
|
|
78
26
|
* @public
|
|
79
27
|
* @group Lime types
|
|
80
28
|
*/
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
29
|
+
function isSingleRelation(property) {
|
|
30
|
+
const propTypes = ['belongsto', 'hasone'];
|
|
31
|
+
return property && propTypes.includes(property.type);
|
|
32
|
+
}
|
|
84
33
|
|
|
85
34
|
const createRandomString = () => {
|
|
86
35
|
var _a;
|
|
@@ -100,6 +49,33 @@ function legacyCreateRandomString() {
|
|
|
100
49
|
Math.random().toString(USE_HEX).substring(SKIP_LEADING_ZERODOT));
|
|
101
50
|
}
|
|
102
51
|
|
|
52
|
+
/**
|
|
53
|
+
* Get the limetypes that should be available for mentions
|
|
54
|
+
*
|
|
55
|
+
* @param {Record<string, LimeType>} limetypes all limetypes
|
|
56
|
+
* @returns {LimeType[]} mention limetypes
|
|
57
|
+
*/
|
|
58
|
+
function getMentionLimetypes(limetypes) {
|
|
59
|
+
return Object.values(limetypes).filter((limetype) => {
|
|
60
|
+
return limetype.label === 'user' || isGroupMention(limetype);
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
function isGroupMention(limetype) {
|
|
64
|
+
const coworkerProperty = getRelationProperty(limetype, 'user');
|
|
65
|
+
return (!!coworkerProperty &&
|
|
66
|
+
isManyRelation(coworkerProperty) &&
|
|
67
|
+
!hasLabel(limetype, 'user'));
|
|
68
|
+
}
|
|
69
|
+
function hasLabel(object, label) {
|
|
70
|
+
return object.label === label;
|
|
71
|
+
}
|
|
72
|
+
function isManyRelation(property) {
|
|
73
|
+
return isRelation(property) && !isSingleRelation(property);
|
|
74
|
+
}
|
|
75
|
+
function getRelationProperty(limetype, label) {
|
|
76
|
+
return Object.values(limetype.properties).find((property) => { var _a, _b; return ((_b = (_a = property === null || property === void 0 ? void 0 : property.relation) === null || _a === void 0 ? void 0 : _a.getLimetype()) === null || _b === void 0 ? void 0 : _b.label) === label; });
|
|
77
|
+
}
|
|
78
|
+
|
|
103
79
|
var __decorate = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
|
|
104
80
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
105
81
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
@@ -147,6 +123,26 @@ const LimeBBTextEditor = class {
|
|
|
147
123
|
* invalid.
|
|
148
124
|
*/
|
|
149
125
|
this.invalid = false;
|
|
126
|
+
/**
|
|
127
|
+
* Set to `true` to indicate that the field is required.
|
|
128
|
+
*
|
|
129
|
+
* :::important
|
|
130
|
+
* An empty but required field is not automatically considered invalid.
|
|
131
|
+
* You must make sure to check the validity of the field on your own,
|
|
132
|
+
* and properly handle the `invalid` state.
|
|
133
|
+
* :::
|
|
134
|
+
*/
|
|
135
|
+
this.required = false;
|
|
136
|
+
/**
|
|
137
|
+
* Specifies the visual appearance of the editor.
|
|
138
|
+
*
|
|
139
|
+
* - `standard`: The default editor appearance with a full toolbar and
|
|
140
|
+
* standard layout.
|
|
141
|
+
* - `minimal`: A compact editor appearance, ideal for limited space
|
|
142
|
+
* scenarios such as mobile devices. In this mode, the toolbar is hidden
|
|
143
|
+
* until the editor is focused.
|
|
144
|
+
*/
|
|
145
|
+
this.ui = 'standard';
|
|
150
146
|
/**
|
|
151
147
|
* Set to `true` to allow the user to vertically resize the editor.
|
|
152
148
|
* Set to `false` to disable the resize functionality.
|
|
@@ -218,21 +214,6 @@ const LimeBBTextEditor = class {
|
|
|
218
214
|
this.editorPickerQuery = event.detail.value;
|
|
219
215
|
this.search();
|
|
220
216
|
};
|
|
221
|
-
this.loadObjects = (limetype, objects) => {
|
|
222
|
-
return objects
|
|
223
|
-
.map((object) => {
|
|
224
|
-
const limeobject = this.limeObjectService.getObject(limetype.name, object._id);
|
|
225
|
-
if (!limeobject) {
|
|
226
|
-
return;
|
|
227
|
-
}
|
|
228
|
-
return {
|
|
229
|
-
text: limeobject.descriptive,
|
|
230
|
-
secondaryText: limetype.name,
|
|
231
|
-
value: object._id,
|
|
232
|
-
};
|
|
233
|
-
})
|
|
234
|
-
.filter(nonNull.isNonNull);
|
|
235
|
-
};
|
|
236
217
|
this.handleItemSelected = (event) => {
|
|
237
218
|
this.insertEditorNode(event.detail);
|
|
238
219
|
this.activeTrigger = undefined;
|
|
@@ -299,7 +280,7 @@ const LimeBBTextEditor = class {
|
|
|
299
280
|
}
|
|
300
281
|
render() {
|
|
301
282
|
return [
|
|
302
|
-
index.h("limel-text-editor", { ref: (el) => (this.textEditor = el), tabindex: this.disabled ? -1 : 0, value: this.value, contentType: this.contentType,
|
|
283
|
+
index.h("limel-text-editor", { 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 }),
|
|
303
284
|
this.renderPicker(),
|
|
304
285
|
];
|
|
305
286
|
}
|
|
@@ -314,14 +295,16 @@ const LimeBBTextEditor = class {
|
|
|
314
295
|
return;
|
|
315
296
|
}
|
|
316
297
|
const query = this.editorPickerQuery;
|
|
317
|
-
const limetype = this.coworkerLimetype;
|
|
318
298
|
const limit = SEARCH_LIMIT;
|
|
319
299
|
try {
|
|
320
|
-
const response = await this.limeObjectService.search(query,
|
|
300
|
+
const response = await this.limeObjectService.search(query, this.searchableLimetypes, limit);
|
|
321
301
|
if (query !== this.editorPickerQuery) {
|
|
322
302
|
return;
|
|
323
303
|
}
|
|
324
|
-
const ids = response.objects.map((
|
|
304
|
+
const ids = response.objects.map((obj) => obj._id);
|
|
305
|
+
if (!ids.length) {
|
|
306
|
+
return;
|
|
307
|
+
}
|
|
325
308
|
const options = {
|
|
326
309
|
filter: {
|
|
327
310
|
key: '_id',
|
|
@@ -329,13 +312,36 @@ const LimeBBTextEditor = class {
|
|
|
329
312
|
exp: ids,
|
|
330
313
|
},
|
|
331
314
|
};
|
|
332
|
-
|
|
333
|
-
this.items = this.loadObjects(limetype, objects);
|
|
315
|
+
this.items = await this.getListItems(this.searchableLimetypes, options);
|
|
334
316
|
}
|
|
335
317
|
catch (e) {
|
|
336
318
|
console.error('Failed search for user', e);
|
|
337
319
|
}
|
|
338
320
|
}
|
|
321
|
+
async getListItems(limetypes, options) {
|
|
322
|
+
const items = await Promise.all(limetypes.map((limetype) => this.getLimetypeItems(limetype, options)));
|
|
323
|
+
return items.flat();
|
|
324
|
+
}
|
|
325
|
+
async getLimetypeItems(limetype, options) {
|
|
326
|
+
const { objects } = await this.limeObjectService.loadObjects(limetype.name, options);
|
|
327
|
+
return this.createListItems(limetype, objects);
|
|
328
|
+
}
|
|
329
|
+
createListItems(limetype, objects) {
|
|
330
|
+
return objects
|
|
331
|
+
.map((object) => this.createListItem(limetype, object))
|
|
332
|
+
.filter(nonNull.isNonNull);
|
|
333
|
+
}
|
|
334
|
+
createListItem(limetype, object) {
|
|
335
|
+
const limeobject = this.limeObjectService.getObject(limetype.name, object._id);
|
|
336
|
+
if (!limeobject) {
|
|
337
|
+
return null;
|
|
338
|
+
}
|
|
339
|
+
return {
|
|
340
|
+
text: limeobject.descriptive,
|
|
341
|
+
secondaryText: limetype.name,
|
|
342
|
+
value: object._id,
|
|
343
|
+
};
|
|
344
|
+
}
|
|
339
345
|
get limeObjectService() {
|
|
340
346
|
return this.platform.get(types.PlatformServiceName.LimeObjectRepository);
|
|
341
347
|
}
|
|
@@ -347,8 +353,8 @@ const LimeBBTextEditor = class {
|
|
|
347
353
|
};
|
|
348
354
|
__decorate([
|
|
349
355
|
decorator.SelectLimeTypes({
|
|
350
|
-
map: [
|
|
356
|
+
map: [getMentionLimetypes],
|
|
351
357
|
})
|
|
352
|
-
], LimeBBTextEditor.prototype, "
|
|
358
|
+
], LimeBBTextEditor.prototype, "searchableLimetypes", void 0);
|
|
353
359
|
|
|
354
360
|
exports.limebb_text_editor = LimeBBTextEditor;
|
package/dist/cjs/loader.cjs.js
CHANGED
|
@@ -14,7 +14,7 @@ const patchEsm = () => {
|
|
|
14
14
|
const defineCustomElements = (win, options) => {
|
|
15
15
|
if (typeof window === 'undefined') return Promise.resolve();
|
|
16
16
|
return patchEsm().then(() => {
|
|
17
|
-
return index.bootstrapLazy([["limebb-feed.cjs",[[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"],"lastVisitedTimestamp":[1,"last-visited-timestamp"]}]]],["limebb-kanban.cjs",[[1,"limebb-kanban",{"platform":[16],"context":[16],"items":[16],"paginationSize":[2,"pagination-size"],"groupBy":[513,"group-by"],"groups":[16]}]]],["limebb-date-range.cjs",[[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]}]]],["limebb-info-tile-currency-format.cjs",[[1,"limebb-info-tile-currency-format",{"platform":[16],"context":[16],"value":[16]}]]],["limebb-notification-list.cjs",[[1,"limebb-notification-list",{"platform":[16],"context":[16],"items":[16],"loading":[4],"lastVisitedTimestamp":[1,"last-visited-timestamp"]}]]],["limebb-text-editor.cjs",[[1,"limebb-text-editor",{"platform":[16],"context":[16],"contentType":[1,"content-type"],"language":[513],"disabled":[516],"readonly":[516],"helperText":[513,"helper-text"],"placeholder":[513],"label":[513],"invalid":[516],"
|
|
17
|
+
return index.bootstrapLazy([["limebb-feed.cjs",[[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"],"lastVisitedTimestamp":[1,"last-visited-timestamp"]}]]],["limebb-kanban.cjs",[[1,"limebb-kanban",{"platform":[16],"context":[16],"items":[16],"paginationSize":[2,"pagination-size"],"groupBy":[513,"group-by"],"groups":[16]}]]],["limebb-date-range.cjs",[[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]}]]],["limebb-info-tile-currency-format.cjs",[[1,"limebb-info-tile-currency-format",{"platform":[16],"context":[16],"value":[16]}]]],["limebb-notification-list.cjs",[[1,"limebb-notification-list",{"platform":[16],"context":[16],"items":[16],"loading":[4],"lastVisitedTimestamp":[1,"last-visited-timestamp"]}]]],["limebb-text-editor.cjs",[[1,"limebb-text-editor",{"platform":[16],"context":[16],"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],"items":[32],"customElements":[32],"registeredTriggers":[32],"editorPickerQuery":[32],"searchableLimetypes":[32],"isPickerOpen":[32]}]]],["limebb-browser.cjs",[[17,"limebb-browser",{"platform":[16],"context":[16],"items":[16],"layout":[1],"filter":[32]}]]],["limebb-component-config.cjs",[[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]}]]],["limebb-component-picker.cjs",[[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"]}]]],["limebb-dashboard-widget.cjs",[[1,"limebb-dashboard-widget",{"heading":[513],"subheading":[513],"supportingText":[513,"supporting-text"],"icon":[513]}]]],["limebb-icon-picker.cjs",[[1,"limebb-icon-picker",{"value":[1],"required":[4],"readonly":[4],"invalid":[4],"disabled":[4],"label":[1],"helperText":[1,"helper-text"]}]]],["limebb-info-tile.cjs",[[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]}]]],["limebb-info-tile-date-format.cjs",[[1,"limebb-info-tile-date-format",{"value":[16]}]]],["limebb-info-tile-decimal-format.cjs",[[1,"limebb-info-tile-decimal-format",{"value":[16]}]]],["limebb-info-tile-format.cjs",[[1,"limebb-info-tile-format",{"platform":[16],"context":[16],"type":[1],"value":[16]}]]],["limebb-info-tile-relative-date-format.cjs",[[1,"limebb-info-tile-relative-date-format",{"value":[16]}]]],["limebb-info-tile-unit-format.cjs",[[1,"limebb-info-tile-unit-format",{"value":[16]}]]],["limebb-limeobject-file-viewer.cjs",[[1,"limebb-limeobject-file-viewer",{"platform":[16],"context":[16],"property":[1],"fileTypes":[16],"limeobject":[32],"limetype":[32]}]]],["limebb-locale-picker.cjs",[[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]}]]],["limebb-mention.cjs",[[1,"limebb-mention",{"limetype":[1],"objectid":[2],"limeobject":[32]}]]],["limebb-navigation-button.cjs",[[17,"limebb-navigation-button",{"href":[513],"tooltipLabel":[513,"tooltip-label"],"tooltipHelperLabel":[513,"tooltip-helper-label"],"type":[513]}]]],["limebb-kanban-column.cjs",[[1,"limebb-kanban-column",{"platform":[16],"context":[16],"columnHeading":[1,"column-heading"],"items":[16],"loading":[4],"paginationSize":[2,"pagination-size"],"displayedItemCount":[32]}]]],["limebb-currency-picker.cjs",[[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]}]]],["limebb-date-picker.cjs",[[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]}]]],["limebb-notification-item.cjs",[[1,"limebb-notification-item",{"platform":[16],"context":[16],"item":[16]}]]],["limebb-text-editor-picker.cjs",[[1,"limebb-text-editor-picker",{"items":[16],"open":[516],"emptyMessage":[1,"empty-message"]}]]],["limebb-empty-state_2.cjs",[[1,"limebb-empty-state",{"heading":[513],"value":[513],"icon":[16]}],[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]}]]],["limebb-kanban-item.cjs",[[1,"limebb-kanban-item",{"platform":[16],"context":[16],"item":[16]}]]]], options);
|
|
18
18
|
});
|
|
19
19
|
};
|
|
20
20
|
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { isRelation, isSingleRelation, } from '@limetech/lime-web-components';
|
|
2
|
+
/**
|
|
3
|
+
* Get the limetypes that should be available for mentions
|
|
4
|
+
*
|
|
5
|
+
* @param {Record<string, LimeType>} limetypes all limetypes
|
|
6
|
+
* @returns {LimeType[]} mention limetypes
|
|
7
|
+
*/
|
|
8
|
+
export function getMentionLimetypes(limetypes) {
|
|
9
|
+
return Object.values(limetypes).filter((limetype) => {
|
|
10
|
+
return limetype.label === 'user' || isGroupMention(limetype);
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
function isGroupMention(limetype) {
|
|
14
|
+
const coworkerProperty = getRelationProperty(limetype, 'user');
|
|
15
|
+
return (!!coworkerProperty &&
|
|
16
|
+
isManyRelation(coworkerProperty) &&
|
|
17
|
+
!hasLabel(limetype, 'user'));
|
|
18
|
+
}
|
|
19
|
+
function hasLabel(object, label) {
|
|
20
|
+
return object.label === label;
|
|
21
|
+
}
|
|
22
|
+
function isManyRelation(property) {
|
|
23
|
+
return isRelation(property) && !isSingleRelation(property);
|
|
24
|
+
}
|
|
25
|
+
function getRelationProperty(limetype, label) {
|
|
26
|
+
return Object.values(limetype.properties).find((property) => { var _a, _b; return ((_b = (_a = property === null || property === void 0 ? void 0 : property.relation) === null || _a === void 0 ? void 0 : _a.getLimetype()) === null || _b === void 0 ? void 0 : _b.label) === label; });
|
|
27
|
+
}
|
|
@@ -8,11 +8,12 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
8
8
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
9
9
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
10
10
|
};
|
|
11
|
-
import {
|
|
11
|
+
import { Operator, PlatformServiceName, SelectLimeTypes, } from '@limetech/lime-web-components';
|
|
12
12
|
import { h, } from '@stencil/core';
|
|
13
13
|
import { BACKSPACE, ENTER, ESCAPE, TAB } from '../../util/keycodes';
|
|
14
14
|
import { createRandomString } from '../../util/random-string';
|
|
15
15
|
import { isNonNull } from '@building-blocks/util/non-null';
|
|
16
|
+
import { getMentionLimetypes } from './mentions';
|
|
16
17
|
const SEARCH_LIMIT = 20;
|
|
17
18
|
/**
|
|
18
19
|
* This component is a wrapper on the `limel-text-editor`. It adds support for platform
|
|
@@ -34,6 +35,8 @@ const SEARCH_LIMIT = 20;
|
|
|
34
35
|
*
|
|
35
36
|
* @exampleComponent limebb-example-text-editor-basic
|
|
36
37
|
* @exampleComponent limebb-example-text-editor-as-form-component
|
|
38
|
+
* @exampleComponent limebb-example-text-editor-composite
|
|
39
|
+
* @exampleComponent limebb-example-text-editor-allow-resize
|
|
37
40
|
* @beta
|
|
38
41
|
*/
|
|
39
42
|
export class LimeBBTextEditor {
|
|
@@ -70,6 +73,26 @@ export class LimeBBTextEditor {
|
|
|
70
73
|
* invalid.
|
|
71
74
|
*/
|
|
72
75
|
this.invalid = false;
|
|
76
|
+
/**
|
|
77
|
+
* Set to `true` to indicate that the field is required.
|
|
78
|
+
*
|
|
79
|
+
* :::important
|
|
80
|
+
* An empty but required field is not automatically considered invalid.
|
|
81
|
+
* You must make sure to check the validity of the field on your own,
|
|
82
|
+
* and properly handle the `invalid` state.
|
|
83
|
+
* :::
|
|
84
|
+
*/
|
|
85
|
+
this.required = false;
|
|
86
|
+
/**
|
|
87
|
+
* Specifies the visual appearance of the editor.
|
|
88
|
+
*
|
|
89
|
+
* - `standard`: The default editor appearance with a full toolbar and
|
|
90
|
+
* standard layout.
|
|
91
|
+
* - `minimal`: A compact editor appearance, ideal for limited space
|
|
92
|
+
* scenarios such as mobile devices. In this mode, the toolbar is hidden
|
|
93
|
+
* until the editor is focused.
|
|
94
|
+
*/
|
|
95
|
+
this.ui = 'standard';
|
|
73
96
|
/**
|
|
74
97
|
* Set to `true` to allow the user to vertically resize the editor.
|
|
75
98
|
* Set to `false` to disable the resize functionality.
|
|
@@ -141,21 +164,6 @@ export class LimeBBTextEditor {
|
|
|
141
164
|
this.editorPickerQuery = event.detail.value;
|
|
142
165
|
this.search();
|
|
143
166
|
};
|
|
144
|
-
this.loadObjects = (limetype, objects) => {
|
|
145
|
-
return objects
|
|
146
|
-
.map((object) => {
|
|
147
|
-
const limeobject = this.limeObjectService.getObject(limetype.name, object._id);
|
|
148
|
-
if (!limeobject) {
|
|
149
|
-
return;
|
|
150
|
-
}
|
|
151
|
-
return {
|
|
152
|
-
text: limeobject.descriptive,
|
|
153
|
-
secondaryText: limetype.name,
|
|
154
|
-
value: object._id,
|
|
155
|
-
};
|
|
156
|
-
})
|
|
157
|
-
.filter(isNonNull);
|
|
158
|
-
};
|
|
159
167
|
this.handleItemSelected = (event) => {
|
|
160
168
|
this.insertEditorNode(event.detail);
|
|
161
169
|
this.activeTrigger = undefined;
|
|
@@ -222,7 +230,7 @@ export class LimeBBTextEditor {
|
|
|
222
230
|
}
|
|
223
231
|
render() {
|
|
224
232
|
return [
|
|
225
|
-
h("limel-text-editor", { ref: (el) => (this.textEditor = el), tabindex: this.disabled ? -1 : 0, value: this.value, contentType: this.contentType,
|
|
233
|
+
h("limel-text-editor", { 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 }),
|
|
226
234
|
this.renderPicker(),
|
|
227
235
|
];
|
|
228
236
|
}
|
|
@@ -237,14 +245,16 @@ export class LimeBBTextEditor {
|
|
|
237
245
|
return;
|
|
238
246
|
}
|
|
239
247
|
const query = this.editorPickerQuery;
|
|
240
|
-
const limetype = this.coworkerLimetype;
|
|
241
248
|
const limit = SEARCH_LIMIT;
|
|
242
249
|
try {
|
|
243
|
-
const response = await this.limeObjectService.search(query,
|
|
250
|
+
const response = await this.limeObjectService.search(query, this.searchableLimetypes, limit);
|
|
244
251
|
if (query !== this.editorPickerQuery) {
|
|
245
252
|
return;
|
|
246
253
|
}
|
|
247
|
-
const ids = response.objects.map((
|
|
254
|
+
const ids = response.objects.map((obj) => obj._id);
|
|
255
|
+
if (!ids.length) {
|
|
256
|
+
return;
|
|
257
|
+
}
|
|
248
258
|
const options = {
|
|
249
259
|
filter: {
|
|
250
260
|
key: '_id',
|
|
@@ -252,13 +262,36 @@ export class LimeBBTextEditor {
|
|
|
252
262
|
exp: ids,
|
|
253
263
|
},
|
|
254
264
|
};
|
|
255
|
-
|
|
256
|
-
this.items = this.loadObjects(limetype, objects);
|
|
265
|
+
this.items = await this.getListItems(this.searchableLimetypes, options);
|
|
257
266
|
}
|
|
258
267
|
catch (e) {
|
|
259
268
|
console.error('Failed search for user', e);
|
|
260
269
|
}
|
|
261
270
|
}
|
|
271
|
+
async getListItems(limetypes, options) {
|
|
272
|
+
const items = await Promise.all(limetypes.map((limetype) => this.getLimetypeItems(limetype, options)));
|
|
273
|
+
return items.flat();
|
|
274
|
+
}
|
|
275
|
+
async getLimetypeItems(limetype, options) {
|
|
276
|
+
const { objects } = await this.limeObjectService.loadObjects(limetype.name, options);
|
|
277
|
+
return this.createListItems(limetype, objects);
|
|
278
|
+
}
|
|
279
|
+
createListItems(limetype, objects) {
|
|
280
|
+
return objects
|
|
281
|
+
.map((object) => this.createListItem(limetype, object))
|
|
282
|
+
.filter(isNonNull);
|
|
283
|
+
}
|
|
284
|
+
createListItem(limetype, object) {
|
|
285
|
+
const limeobject = this.limeObjectService.getObject(limetype.name, object._id);
|
|
286
|
+
if (!limeobject) {
|
|
287
|
+
return null;
|
|
288
|
+
}
|
|
289
|
+
return {
|
|
290
|
+
text: limeobject.descriptive,
|
|
291
|
+
secondaryText: limetype.name,
|
|
292
|
+
value: object._id,
|
|
293
|
+
};
|
|
294
|
+
}
|
|
262
295
|
get limeObjectService() {
|
|
263
296
|
return this.platform.get(PlatformServiceName.LimeObjectRepository);
|
|
264
297
|
}
|
|
@@ -458,6 +491,24 @@ export class LimeBBTextEditor {
|
|
|
458
491
|
"reflect": true,
|
|
459
492
|
"defaultValue": "false"
|
|
460
493
|
},
|
|
494
|
+
"required": {
|
|
495
|
+
"type": "boolean",
|
|
496
|
+
"mutable": false,
|
|
497
|
+
"complexType": {
|
|
498
|
+
"original": "boolean",
|
|
499
|
+
"resolved": "boolean | undefined",
|
|
500
|
+
"references": {}
|
|
501
|
+
},
|
|
502
|
+
"required": false,
|
|
503
|
+
"optional": true,
|
|
504
|
+
"docs": {
|
|
505
|
+
"tags": [],
|
|
506
|
+
"text": "Set to `true` to indicate that the field is required.\n\n:::important\nAn empty but required field is not automatically considered invalid.\nYou must make sure to check the validity of the field on your own,\nand properly handle the `invalid` state.\n:::"
|
|
507
|
+
},
|
|
508
|
+
"attribute": "required",
|
|
509
|
+
"reflect": true,
|
|
510
|
+
"defaultValue": "false"
|
|
511
|
+
},
|
|
461
512
|
"selectedContext": {
|
|
462
513
|
"type": "unknown",
|
|
463
514
|
"mutable": false,
|
|
@@ -478,22 +529,28 @@ export class LimeBBTextEditor {
|
|
|
478
529
|
"text": "Context of the selected object in the list"
|
|
479
530
|
}
|
|
480
531
|
},
|
|
481
|
-
"
|
|
482
|
-
"type": "
|
|
532
|
+
"ui": {
|
|
533
|
+
"type": "string",
|
|
483
534
|
"mutable": false,
|
|
484
535
|
"complexType": {
|
|
485
|
-
"original": "
|
|
486
|
-
"resolved": "
|
|
487
|
-
"references": {
|
|
536
|
+
"original": "EditorUiType",
|
|
537
|
+
"resolved": "\"minimal\" | \"standard\" | undefined",
|
|
538
|
+
"references": {
|
|
539
|
+
"EditorUiType": {
|
|
540
|
+
"location": "import",
|
|
541
|
+
"path": "@limetech/lime-elements"
|
|
542
|
+
}
|
|
543
|
+
}
|
|
488
544
|
},
|
|
489
545
|
"required": false,
|
|
490
|
-
"optional":
|
|
546
|
+
"optional": true,
|
|
491
547
|
"docs": {
|
|
492
548
|
"tags": [],
|
|
493
|
-
"text": "
|
|
549
|
+
"text": "Specifies the visual appearance of the editor.\n\n- `standard`: The default editor appearance with a full toolbar and\nstandard layout.\n- `minimal`: A compact editor appearance, ideal for limited space\nscenarios such as mobile devices. In this mode, the toolbar is hidden\nuntil the editor is focused."
|
|
494
550
|
},
|
|
495
|
-
"attribute": "ui
|
|
496
|
-
"reflect":
|
|
551
|
+
"attribute": "ui",
|
|
552
|
+
"reflect": true,
|
|
553
|
+
"defaultValue": "'standard'"
|
|
497
554
|
},
|
|
498
555
|
"allowResize": {
|
|
499
556
|
"type": "boolean",
|
|
@@ -539,7 +596,7 @@ export class LimeBBTextEditor {
|
|
|
539
596
|
"customElements": {},
|
|
540
597
|
"registeredTriggers": {},
|
|
541
598
|
"editorPickerQuery": {},
|
|
542
|
-
"
|
|
599
|
+
"searchableLimetypes": {},
|
|
543
600
|
"isPickerOpen": {}
|
|
544
601
|
};
|
|
545
602
|
}
|
|
@@ -574,6 +631,6 @@ export class LimeBBTextEditor {
|
|
|
574
631
|
}
|
|
575
632
|
__decorate([
|
|
576
633
|
SelectLimeTypes({
|
|
577
|
-
map: [
|
|
634
|
+
map: [getMentionLimetypes],
|
|
578
635
|
})
|
|
579
|
-
], LimeBBTextEditor.prototype, "
|
|
636
|
+
], LimeBBTextEditor.prototype, "searchableLimetypes", void 0);
|