@peers-app/peers-ui 0.33.7 → 0.33.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/apps-home/app-menu.d.ts +55 -0
- package/dist/apps-home/app-menu.js +126 -0
- package/dist/apps-home/app-status.d.ts +34 -0
- package/dist/apps-home/app-status.js +85 -0
- package/dist/apps-home/app-tile.d.ts +33 -0
- package/dist/apps-home/app-tile.js +106 -0
- package/dist/apps-home/apps-home.d.ts +29 -0
- package/dist/apps-home/apps-home.js +311 -0
- package/dist/apps-home/get-apps-sheet.d.ts +52 -0
- package/dist/apps-home/get-apps-sheet.js +130 -0
- package/dist/apps-home/pinned-apps.d.ts +73 -0
- package/dist/apps-home/pinned-apps.js +213 -0
- package/dist/apps-home/remove-app-dialog.d.ts +20 -0
- package/dist/apps-home/remove-app-dialog.js +62 -0
- package/dist/command-palette/command-palette-ui.js +2 -33
- package/dist/components/markdown-editor/editor.d.ts +22 -8
- package/dist/components/markdown-editor/editor.js +5 -4
- package/dist/components/markdown-editor/mention-preview-card.d.ts +13 -0
- package/dist/components/markdown-editor/mention-preview-card.js +30 -0
- package/dist/components/markdown-editor/mentions-plugin.d.ts +36 -2
- package/dist/components/markdown-editor/mentions-plugin.js +129 -34
- package/dist/components/markdown-editor/selection-effects-plugin.d.ts +18 -0
- package/dist/components/markdown-editor/selection-effects-plugin.js +49 -0
- package/dist/mentions/mention-chip.d.ts +3 -2
- package/dist/mentions/mention-chip.js +5 -4
- package/dist/root-layout/root-layout-host.js +0 -1
- package/dist/screens/search/global-search.js +2 -33
- package/dist/tabs-layout/tabs-layout.js +2 -127
- package/dist/tabs-layout/tabs-state.d.ts +7 -10
- package/dist/tabs-layout/tabs-state.js +8 -63
- package/dist/theme.css +948 -6
- package/dist/ui-router/app-catalog.d.ts +55 -0
- package/dist/ui-router/app-catalog.js +74 -0
- package/dist/ui-router/routes-loader.js +46 -27
- package/dist/ui-router/runnable-version.js +2 -1
- package/package.json +3 -3
|
@@ -33,6 +33,8 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
33
33
|
};
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.parseQuery = parseQuery;
|
|
37
|
+
exports.pickerOptions = pickerOptions;
|
|
36
38
|
exports.sharedKinds = sharedKinds;
|
|
37
39
|
exports.MentionsPlugin = MentionsPlugin;
|
|
38
40
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
@@ -44,6 +46,7 @@ const react_1 = require("react");
|
|
|
44
46
|
const ReactDOM = __importStar(require("react-dom"));
|
|
45
47
|
const mentions_client_1 = require("../../mentions/mentions-client");
|
|
46
48
|
const mention_node_1 = require("./mention-node");
|
|
49
|
+
const mention_preview_card_1 = require("./mention-preview-card");
|
|
47
50
|
const PUNCTUATION = "\\.,\\+\\*\\?\\$\\@\\|#{}\\(\\)\\^\\-\\[\\]\\\\/!%'\"~=<>_:;";
|
|
48
51
|
const NAME = `\\b[A-Z][^\\s${PUNCTUATION}]`;
|
|
49
52
|
const DocumentMentionsRegex = {
|
|
@@ -51,8 +54,9 @@ const DocumentMentionsRegex = {
|
|
|
51
54
|
PUNCTUATION,
|
|
52
55
|
};
|
|
53
56
|
const PUNC = DocumentMentionsRegex.PUNCTUATION;
|
|
54
|
-
// `@`
|
|
55
|
-
|
|
57
|
+
// `@` or `<` starts the picker (Mark, 2026-11-14: `<` as well as `@`); `@kind:` narrows the search
|
|
58
|
+
// to one kind.
|
|
59
|
+
const TRIGGERS = "@<";
|
|
56
60
|
// Chars we expect to see in a mention (non-space, non-punctuation).
|
|
57
61
|
const VALID_CHARS = `[^${TRIGGERS}${PUNC}\\s]`;
|
|
58
62
|
// Non-standard series of chars. Each series must be preceded and followed by
|
|
@@ -93,9 +97,13 @@ const AtSignMentionsRegexAliasRegex = new RegExp("(^|\\s|\\()(" +
|
|
|
93
97
|
const SUGGESTION_LIST_LENGTH_LIMIT = 10;
|
|
94
98
|
/** How long typing pauses before a search. */
|
|
95
99
|
const SEARCH_DEBOUNCE_MS = 120;
|
|
96
|
-
/**
|
|
100
|
+
/**
|
|
101
|
+
* What the user typed after `@` or `<`: words, and a kind when it starts with `kind:`.
|
|
102
|
+
*
|
|
103
|
+
* @param query - The text from the trigger on, such as `@task:garden`.
|
|
104
|
+
*/
|
|
97
105
|
function parseQuery(query) {
|
|
98
|
-
const typed = query.replace(
|
|
106
|
+
const typed = query.replace(/^[@<]/, "");
|
|
99
107
|
const colon = typed.indexOf(":");
|
|
100
108
|
const kind = colon > 0 ? typed.slice(0, colon).toLowerCase() : "";
|
|
101
109
|
if ((0, peers_sdk_1.isMentionKind)(kind))
|
|
@@ -107,12 +115,10 @@ function parseQuery(query) {
|
|
|
107
115
|
* so a slow answer never overwrites a newer one.
|
|
108
116
|
*/
|
|
109
117
|
function useMentionSearch(query, groupId) {
|
|
110
|
-
const [found, setFound] = (0, react_1.useState)({
|
|
111
|
-
results: [],
|
|
112
|
-
});
|
|
118
|
+
const [found, setFound] = (0, react_1.useState)({ query: null, results: [] });
|
|
113
119
|
(0, react_1.useEffect)(() => {
|
|
114
120
|
if (!query) {
|
|
115
|
-
setFound({ results: [] });
|
|
121
|
+
setFound({ query, results: [] });
|
|
116
122
|
return;
|
|
117
123
|
}
|
|
118
124
|
let live = true;
|
|
@@ -125,11 +131,12 @@ function useMentionSearch(query, groupId) {
|
|
|
125
131
|
limit: SUGGESTION_LIST_LENGTH_LIMIT,
|
|
126
132
|
});
|
|
127
133
|
if (live)
|
|
128
|
-
setFound({ results, docGroup });
|
|
134
|
+
setFound({ query, results, docGroup });
|
|
129
135
|
})().catch((error) => {
|
|
130
136
|
console.warn("[mentions] search failed", error);
|
|
137
|
+
// A failed search isn't an answer that nothing has this id.
|
|
131
138
|
if (live)
|
|
132
|
-
setFound({ results: [] });
|
|
139
|
+
setFound({ query: null, results: [] });
|
|
133
140
|
});
|
|
134
141
|
}, SEARCH_DEBOUNCE_MS);
|
|
135
142
|
return () => {
|
|
@@ -139,6 +146,47 @@ function useMentionSearch(query, groupId) {
|
|
|
139
146
|
}, [query, groupId]);
|
|
140
147
|
return found;
|
|
141
148
|
}
|
|
149
|
+
/**
|
|
150
|
+
* The result offered for a pasted id that matches nothing: a link to whatever has that id, or to
|
|
151
|
+
* the kind the user typed before it (`<task:<id>`).
|
|
152
|
+
*/
|
|
153
|
+
function unknownIdResult(id, kind = peers_sdk_1.ANY_MENTION_KIND) {
|
|
154
|
+
return {
|
|
155
|
+
kind,
|
|
156
|
+
id,
|
|
157
|
+
kindLabel: "Not found",
|
|
158
|
+
title: id,
|
|
159
|
+
iconClassName: "bi bi-question-circle",
|
|
160
|
+
route: "",
|
|
161
|
+
places: 0,
|
|
162
|
+
};
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* What the picker offers for a query, and whether one result should be taken without asking.
|
|
166
|
+
*
|
|
167
|
+
* - Words: the results, as they are.
|
|
168
|
+
* - A pasted id (`@<id>` or `<<id>`), once its search has answered: the one record with that id,
|
|
169
|
+
* taken at once; nothing found, a link to whatever has the id, taken at once; several records
|
|
170
|
+
* (the same id in two kinds), offered to pick from. Before the answer, nothing.
|
|
171
|
+
*
|
|
172
|
+
* @param query - The text from the trigger on, or null when the picker is closed.
|
|
173
|
+
* @param found - The latest search answer.
|
|
174
|
+
* @param declined - A query the user undid an automatic pick for: offered, not taken again.
|
|
175
|
+
*/
|
|
176
|
+
function pickerOptions(query, found, declined) {
|
|
177
|
+
if (!query)
|
|
178
|
+
return { results: [] };
|
|
179
|
+
const { text, kinds } = parseQuery(query);
|
|
180
|
+
if (!(0, peers_sdk_1.looksLikeRecordId)(text))
|
|
181
|
+
return { results: found.results };
|
|
182
|
+
if (found.query !== query)
|
|
183
|
+
return { results: [] };
|
|
184
|
+
const exact = found.results.filter((r) => r.id === text);
|
|
185
|
+
const results = exact.length ? exact : [unknownIdResult(text, kinds?.[0])];
|
|
186
|
+
if (results.length > 1 || declined === query)
|
|
187
|
+
return { results };
|
|
188
|
+
return { results, autoPick: results[0] };
|
|
189
|
+
}
|
|
142
190
|
function checkForAtSignMentions(text, minMatchLength) {
|
|
143
191
|
let match = AtSignMentionsRegex.exec(text);
|
|
144
192
|
if (match === null) {
|
|
@@ -186,8 +234,8 @@ function sharedKinds(results) {
|
|
|
186
234
|
return new Set([...packages].filter(([, ids]) => ids.size > 1).map(([kind]) => kind));
|
|
187
235
|
}
|
|
188
236
|
/**
|
|
189
|
-
*
|
|
190
|
-
* group when not the document's
|
|
237
|
+
* A row's second line: what it is (with its package when another package shares its kind), its
|
|
238
|
+
* status, and its group when not the document's.
|
|
191
239
|
*/
|
|
192
240
|
function details(option, docGroup) {
|
|
193
241
|
const { result } = option;
|
|
@@ -196,7 +244,6 @@ function details(option, docGroup) {
|
|
|
196
244
|
option.showPackage ? result.packageName : undefined,
|
|
197
245
|
result.status,
|
|
198
246
|
result.groupId && result.groupId !== docGroup ? result.groupName : undefined,
|
|
199
|
-
result.places > 1 ? `${result.places} places` : undefined,
|
|
200
247
|
]
|
|
201
248
|
.filter(Boolean)
|
|
202
249
|
.join(" · ");
|
|
@@ -205,17 +252,47 @@ function MentionsTypeaheadMenuItem({ index, isSelected, onClick, onMouseEnter, o
|
|
|
205
252
|
const { result } = option;
|
|
206
253
|
const otherGroup = !!result.groupId && result.groupId !== docGroup;
|
|
207
254
|
const detail = details(option, docGroup);
|
|
208
|
-
return ((0, jsx_runtime_1.jsxs)("li", { tabIndex: -1, className: `item${isSelected ? " selected" : ""}${otherGroup ? " other-group" : ""}`, ref: option.setRefElement, "aria-selected": isSelected, id: `typeahead-item-${index}`, onMouseEnter: onMouseEnter, onClick: onClick, "data-kind": result.kind, "data-id": result.id, children: [
|
|
255
|
+
return ((0, jsx_runtime_1.jsxs)("li", { tabIndex: -1, className: `peers-mention-menu-item${isSelected ? " is-selected" : ""}${otherGroup ? " is-other-group" : ""}`, ref: option.setRefElement, "aria-selected": isSelected, id: `typeahead-item-${index}`, onMouseEnter: onMouseEnter, onClick: onClick, "data-kind": result.kind, "data-id": result.id, children: [(0, jsx_runtime_1.jsx)("span", { className: "peers-mention-menu-icon", "aria-hidden": true, children: result.kind === "user" ? ("@") : ((0, jsx_runtime_1.jsx)("i", { className: result.iconClassName ?? "bi bi-link-45deg" })) }), (0, jsx_runtime_1.jsxs)("span", { className: "peers-mention-menu-text", children: [(0, jsx_runtime_1.jsx)("span", { className: `peers-mention-menu-title${result.done ? " peers-mention-done" : ""}`, children: result.title || result.kindLabel }), detail && (0, jsx_runtime_1.jsx)("span", { className: "peers-mention-menu-detail", children: detail })] })] }, option.key));
|
|
256
|
+
}
|
|
257
|
+
/** Takes a result as soon as it's shown: a pasted id that found one record, or none. */
|
|
258
|
+
function AutoPick({ pick }) {
|
|
259
|
+
(0, react_1.useEffect)(() => pick(), []);
|
|
260
|
+
return null;
|
|
209
261
|
}
|
|
262
|
+
/** Whether the menu should open above the caret: the caret is in the lower half of the window. */
|
|
263
|
+
function opensAbove(anchor) {
|
|
264
|
+
return anchor.getBoundingClientRect().top > window.innerHeight / 2;
|
|
265
|
+
}
|
|
266
|
+
/** The menu's width and the card's, and the gap between them (`theme.css`). */
|
|
267
|
+
const MENU_WIDTH = 300;
|
|
268
|
+
const PREVIEW_GAP = 8;
|
|
210
269
|
/**
|
|
211
|
-
*
|
|
212
|
-
*
|
|
270
|
+
* Where the preview goes: right of the menu, else left of it, else under it (a window too narrow
|
|
271
|
+
* for either, such as a tablet held upright).
|
|
272
|
+
*/
|
|
273
|
+
function previewSide(anchor) {
|
|
274
|
+
const { left } = anchor.getBoundingClientRect();
|
|
275
|
+
if (left + MENU_WIDTH + PREVIEW_GAP + MENU_WIDTH <= window.innerWidth)
|
|
276
|
+
return "";
|
|
277
|
+
if (left - PREVIEW_GAP - MENU_WIDTH >= 0)
|
|
278
|
+
return "is-preview-left";
|
|
279
|
+
return "is-preview-below";
|
|
280
|
+
}
|
|
281
|
+
/**
|
|
282
|
+
* The mention picker, opened by `@` or `<`: people first, then records from every group the user
|
|
283
|
+
* is in, through System Mentions, with a preview of the highlighted one. Picking one inserts a
|
|
284
|
+
* mention chip labeled with the record's title. A pasted id becomes a chip at once: the record's,
|
|
285
|
+
* or a dotted `?` chip for an id that matches nothing.
|
|
213
286
|
*/
|
|
214
287
|
function MentionsPlugin(props) {
|
|
215
288
|
const [editor] = (0, LexicalComposerContext_1.useLexicalComposerContext)();
|
|
216
289
|
const [queryString, setQueryString] = (0, react_1.useState)(null);
|
|
217
|
-
const
|
|
290
|
+
const found = useMentionSearch(queryString, props.groupId);
|
|
291
|
+
const { docGroup } = found;
|
|
218
292
|
const [_mentionsOpen] = (0, react_1.useState)(() => (0, peers_sdk_1.observable)(false));
|
|
293
|
+
// The last query taken automatically. An undo brings it back; then it's offered, not retaken.
|
|
294
|
+
const autoPicked = (0, react_1.useRef)(null);
|
|
295
|
+
const { results, autoPick } = (0, react_1.useMemo)(() => pickerOptions(queryString, found, autoPicked.current), [queryString, found]);
|
|
219
296
|
if (props.mentionsOpen) {
|
|
220
297
|
const finalMentionsOpen = _mentionsOpen() && results.length > 0;
|
|
221
298
|
if (props.mentionsOpen() !== finalMentionsOpen) {
|
|
@@ -232,11 +309,14 @@ function MentionsPlugin(props) {
|
|
|
232
309
|
}, [results]);
|
|
233
310
|
const onSelectOption = (0, react_1.useCallback)((selectedOption, nodeToReplace, closeMenu) => {
|
|
234
311
|
editor.update(() => {
|
|
312
|
+
// The typed query is gone (an undo, or a pick already made): nothing to put a chip in.
|
|
313
|
+
if (!nodeToReplace) {
|
|
314
|
+
closeMenu();
|
|
315
|
+
return;
|
|
316
|
+
}
|
|
235
317
|
const { kind, id, title, kindLabel } = selectedOption.result;
|
|
236
318
|
const mentionNode = (0, mention_node_1.$createMentionNode)({ kind, id, label: title || kindLabel });
|
|
237
|
-
|
|
238
|
-
nodeToReplace.replace(mentionNode);
|
|
239
|
-
}
|
|
319
|
+
nodeToReplace.replace(mentionNode);
|
|
240
320
|
mentionNode.selectNext(); // Move cursor to the position after the mention
|
|
241
321
|
const selection = (0, lexical_1.$getSelection)();
|
|
242
322
|
if (selection !== null) {
|
|
@@ -252,22 +332,37 @@ function MentionsPlugin(props) {
|
|
|
252
332
|
}
|
|
253
333
|
return getPossibleQueryMatch(text);
|
|
254
334
|
}, [checkForSlashTriggerMatch, editor]);
|
|
255
|
-
return ((0, jsx_runtime_1.jsx)(LexicalTypeaheadMenuPlugin_1.LexicalTypeaheadMenuPlugin, { onQueryChange:
|
|
256
|
-
|
|
335
|
+
return ((0, jsx_runtime_1.jsx)(LexicalTypeaheadMenuPlugin_1.LexicalTypeaheadMenuPlugin, { onQueryChange: (query) => {
|
|
336
|
+
// Closing the menu (null) keeps it, so an undo right after doesn't pick it again.
|
|
337
|
+
if (query !== null && query !== autoPicked.current)
|
|
338
|
+
autoPicked.current = null;
|
|
339
|
+
setQueryString(query);
|
|
340
|
+
}, onSelectOption: onSelectOption, triggerFn: checkForMentionMatch, options: options, onOpen: () => _mentionsOpen(true), onClose: () => _mentionsOpen(false), menuRenderFn: (anchorElementRef, { selectedIndex, selectOptionAndCleanUp, setHighlightedIndex }) => {
|
|
341
|
+
const anchor = anchorElementRef.current;
|
|
342
|
+
if (!(anchor && options.length)) {
|
|
257
343
|
return null;
|
|
258
344
|
}
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
345
|
+
if (autoPick) {
|
|
346
|
+
const option = options[0];
|
|
347
|
+
return ((0, jsx_runtime_1.jsx)(AutoPick, { pick: () => {
|
|
348
|
+
// Once per query: React may run the effect twice, and an undo brings it back.
|
|
349
|
+
if (autoPicked.current === queryString)
|
|
350
|
+
return;
|
|
351
|
+
autoPicked.current = queryString;
|
|
352
|
+
selectOptionAndCleanUp(option);
|
|
353
|
+
} }, `${queryString}:${option.key}`));
|
|
265
354
|
}
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
355
|
+
const highlighted = selectedIndex === null ? undefined : options[selectedIndex];
|
|
356
|
+
const classes = [
|
|
357
|
+
"peers-mention-menu",
|
|
358
|
+
opensAbove(anchor) ? "is-above" : "",
|
|
359
|
+
previewSide(anchor),
|
|
360
|
+
];
|
|
361
|
+
return ReactDOM.createPortal((0, jsx_runtime_1.jsxs)("div", { className: classes.filter(Boolean).join(" "), children: [(0, jsx_runtime_1.jsx)("ul", { className: "peers-mention-menu-list", children: options.map((option, i) => ((0, jsx_runtime_1.jsx)(MentionsTypeaheadMenuItem, { index: i, isSelected: selectedIndex === i, onClick: () => {
|
|
362
|
+
setHighlightedIndex(i);
|
|
363
|
+
selectOptionAndCleanUp(option);
|
|
364
|
+
}, onMouseEnter: () => {
|
|
365
|
+
setHighlightedIndex(i);
|
|
366
|
+
}, option: option, docGroup: docGroup }, option.key))) }), highlighted ? ((0, jsx_runtime_1.jsx)(mention_preview_card_1.MentionPreviewCard, { result: highlighted.result, showPackage: highlighted.showPackage })) : null] }), anchor);
|
|
272
367
|
} }));
|
|
273
368
|
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { IMentionLink } from "@peers-app/peers-sdk";
|
|
2
|
+
import type { IEditorEffects } from "./editor";
|
|
3
|
+
/** The selected text as plain text, or empty when nothing is selected. Inside an editor read. */
|
|
4
|
+
export declare function $selectedText(): string;
|
|
5
|
+
/**
|
|
6
|
+
* Replace the selected text with a mention chip. Inside an editor update.
|
|
7
|
+
*
|
|
8
|
+
* @param link - The record and the chip's label.
|
|
9
|
+
* @returns false, changing nothing, when nothing is selected.
|
|
10
|
+
*/
|
|
11
|
+
export declare function $replaceSelectionWithMention(link: IMentionLink): boolean;
|
|
12
|
+
/**
|
|
13
|
+
* Fills in the selection hooks of {@link IEditorEffects}, so a screen can turn selected text into
|
|
14
|
+
* a link to something it makes from it (Notes' Make note and Make task).
|
|
15
|
+
*/
|
|
16
|
+
export declare function SelectionEffectsPlugin({ effects }: {
|
|
17
|
+
effects: IEditorEffects;
|
|
18
|
+
}): null;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.$selectedText = $selectedText;
|
|
4
|
+
exports.$replaceSelectionWithMention = $replaceSelectionWithMention;
|
|
5
|
+
exports.SelectionEffectsPlugin = SelectionEffectsPlugin;
|
|
6
|
+
const LexicalComposerContext_1 = require("@lexical/react/LexicalComposerContext");
|
|
7
|
+
const lexical_1 = require("lexical");
|
|
8
|
+
const react_1 = require("react");
|
|
9
|
+
const mention_node_1 = require("./mention-node");
|
|
10
|
+
/** The selected text as plain text, or empty when nothing is selected. Inside an editor read. */
|
|
11
|
+
function $selectedText() {
|
|
12
|
+
const selection = (0, lexical_1.$getSelection)();
|
|
13
|
+
return (0, lexical_1.$isRangeSelection)(selection) && !selection.isCollapsed() ? selection.getTextContent() : "";
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Replace the selected text with a mention chip. Inside an editor update.
|
|
17
|
+
*
|
|
18
|
+
* @param link - The record and the chip's label.
|
|
19
|
+
* @returns false, changing nothing, when nothing is selected.
|
|
20
|
+
*/
|
|
21
|
+
function $replaceSelectionWithMention(link) {
|
|
22
|
+
const selection = (0, lexical_1.$getSelection)();
|
|
23
|
+
if (!(0, lexical_1.$isRangeSelection)(selection) || selection.isCollapsed())
|
|
24
|
+
return false;
|
|
25
|
+
selection.insertNodes([(0, mention_node_1.$createMentionNode)(link)]);
|
|
26
|
+
return true;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Fills in the selection hooks of {@link IEditorEffects}, so a screen can turn selected text into
|
|
30
|
+
* a link to something it makes from it (Notes' Make note and Make task).
|
|
31
|
+
*/
|
|
32
|
+
function SelectionEffectsPlugin({ effects }) {
|
|
33
|
+
const [editor] = (0, LexicalComposerContext_1.useLexicalComposerContext)();
|
|
34
|
+
(0, react_1.useEffect)(() => {
|
|
35
|
+
effects.getSelectedText = () => editor.getEditorState().read($selectedText);
|
|
36
|
+
effects.replaceSelectionWithMention = (link) => {
|
|
37
|
+
let replaced = false;
|
|
38
|
+
editor.update(() => {
|
|
39
|
+
replaced = $replaceSelectionWithMention(link);
|
|
40
|
+
}, { discrete: true });
|
|
41
|
+
return replaced;
|
|
42
|
+
};
|
|
43
|
+
return () => {
|
|
44
|
+
effects.getSelectedText = undefined;
|
|
45
|
+
effects.replaceSelectionWithMention = undefined;
|
|
46
|
+
};
|
|
47
|
+
}, [editor, effects]);
|
|
48
|
+
return null;
|
|
49
|
+
}
|
|
@@ -26,7 +26,8 @@ export declare function useMentionPlace(link: {
|
|
|
26
26
|
}, groupId?: string): MentionState;
|
|
27
27
|
/**
|
|
28
28
|
* A mention as it reads in text: the record's icon and live title, struck through when it's
|
|
29
|
-
* done. Clicking opens it (or asks which, when it's in more than one place). A mention
|
|
30
|
-
* can
|
|
29
|
+
* done. Clicking opens it (or asks which, when it's in more than one place). A mention that
|
|
30
|
+
* resolves nowhere the user can read (deleted, in a group they're not in, or an id nothing has)
|
|
31
|
+
* is a dotted chip with a `?` and the label it was written with; it opens nothing.
|
|
31
32
|
*/
|
|
32
33
|
export declare function MentionChip(props: IMentionLink): import("react/jsx-runtime").JSX.Element;
|
|
@@ -44,15 +44,16 @@ function useMentionPlace(link, groupId) {
|
|
|
44
44
|
}
|
|
45
45
|
/**
|
|
46
46
|
* A mention as it reads in text: the record's icon and live title, struck through when it's
|
|
47
|
-
* done. Clicking opens it (or asks which, when it's in more than one place). A mention
|
|
48
|
-
* can
|
|
47
|
+
* done. Clicking opens it (or asks which, when it's in more than one place). A mention that
|
|
48
|
+
* resolves nowhere the user can read (deleted, in a group they're not in, or an id nothing has)
|
|
49
|
+
* is a dotted chip with a `?` and the label it was written with; it opens nothing.
|
|
49
50
|
*/
|
|
50
51
|
function MentionChip(props) {
|
|
51
52
|
const { kind, id, label } = props;
|
|
52
53
|
const groupId = (0, react_1.useContext)(exports.MentionGroupContext);
|
|
53
54
|
const state = useMentionPlace({ kind, id }, groupId);
|
|
54
55
|
if (state.status === "missing") {
|
|
55
|
-
return ((0, jsx_runtime_1.
|
|
56
|
+
return ((0, jsx_runtime_1.jsxs)("span", { className: "peers-mention peers-mention-missing", "data-kind": kind, "data-id": id, title: "Not found: it was deleted, it's in a group you're not in, or nothing has this id", children: [(0, jsx_runtime_1.jsx)("i", { className: "bi bi-question-lg peers-mention-icon", "aria-hidden": true }), label || id] }));
|
|
56
57
|
}
|
|
57
58
|
const place = state.status === "found" ? state.place : undefined;
|
|
58
59
|
const title = place?.title || label;
|
|
@@ -71,5 +72,5 @@ function MentionChip(props) {
|
|
|
71
72
|
e.preventDefault();
|
|
72
73
|
open();
|
|
73
74
|
}
|
|
74
|
-
}, children: [kind === "user" ? ("@") : ((0, jsx_runtime_1.jsx)("i", { className: `${place?.iconClassName ?? "bi bi-link-45deg"} peers-mention-icon` })), title] }));
|
|
75
|
+
}, children: [(place?.kind ?? kind) === "user" ? ("@") : ((0, jsx_runtime_1.jsx)("i", { className: `${place?.iconClassName ?? "bi bi-link-45deg"} peers-mention-icon` })), title] }));
|
|
75
76
|
}
|
|
@@ -92,7 +92,6 @@ function RootLayoutBootstrap(props) {
|
|
|
92
92
|
await Promise.all([
|
|
93
93
|
tabs_state_1.activeTabs.loadingPromise,
|
|
94
94
|
tabs_state_1.activeTabId.loadingPromise,
|
|
95
|
-
tabs_state_1.recentlyUsedApps.loadingPromise,
|
|
96
95
|
peers_sdk_1.hasShownWelcomeModal.loadingPromise,
|
|
97
96
|
]);
|
|
98
97
|
(0, globals_1.initializeHashNavigation)();
|
|
@@ -5,8 +5,8 @@ const jsx_runtime_1 = require("react/jsx-runtime");
|
|
|
5
5
|
const react_1 = require("react");
|
|
6
6
|
const hooks_1 = require("../../hooks");
|
|
7
7
|
const mention_configs_1 = require("../../mention-configs");
|
|
8
|
-
const system_apps_1 = require("../../system-apps");
|
|
9
8
|
const tabs_state_1 = require("../../tabs-layout/tabs-state");
|
|
9
|
+
const app_catalog_1 = require("../../ui-router/app-catalog");
|
|
10
10
|
const routes_loader_1 = require("../../ui-router/routes-loader");
|
|
11
11
|
const color_mode_dropdown_1 = require("../settings/color-mode-dropdown");
|
|
12
12
|
const searchConfigs = [
|
|
@@ -31,38 +31,7 @@ function GlobalSearch() {
|
|
|
31
31
|
}
|
|
32
32
|
}, []);
|
|
33
33
|
// Get all apps (system and user)
|
|
34
|
-
const getAllApps = (0, react_1.useCallback)(() =>
|
|
35
|
-
const allPackages_ = [...packages, system_apps_1.systemPackage];
|
|
36
|
-
return allPackages_
|
|
37
|
-
.filter((p) => !p.disabled && p.appNavs && p.appNavs.length > 0)
|
|
38
|
-
.flatMap((pkg) => {
|
|
39
|
-
const navs = pkg.appNavs;
|
|
40
|
-
if (!navs?.length)
|
|
41
|
-
return [];
|
|
42
|
-
return navs.map((navItem) => {
|
|
43
|
-
// Construct path - use direct path for system apps, package-nav for others
|
|
44
|
-
let path;
|
|
45
|
-
if (pkg.packageId === "system-apps") {
|
|
46
|
-
path = navItem.navigationPath ?? navItem.name.replace(/\s/g, "-").toLowerCase();
|
|
47
|
-
}
|
|
48
|
-
else {
|
|
49
|
-
path = `package-nav/${pkg.packageId}/${(navItem.navigationPath ?? navItem.name).replace(/[^a-zA-Z0-9]/g, "-").toLowerCase()}`;
|
|
50
|
-
while (path.includes("//")) {
|
|
51
|
-
path = path.replace("//", "/");
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
return {
|
|
55
|
-
packageId: pkg.packageId,
|
|
56
|
-
packageName: pkg.name,
|
|
57
|
-
navItem,
|
|
58
|
-
path,
|
|
59
|
-
name: navItem.name,
|
|
60
|
-
displayName: navItem.displayName || navItem.name,
|
|
61
|
-
iconClassName: navItem.iconClassName || "bi-box-seam",
|
|
62
|
-
};
|
|
63
|
-
});
|
|
64
|
-
});
|
|
65
|
-
}, [packages]);
|
|
34
|
+
const getAllApps = (0, react_1.useCallback)(() => (0, app_catalog_1.buildAppCatalog)(packages), [packages]);
|
|
66
35
|
// Debounced search effect
|
|
67
36
|
(0, react_1.useEffect)(() => {
|
|
68
37
|
if (!searchQuery.trim()) {
|
|
@@ -39,20 +39,18 @@ exports.TabContent = TabContent;
|
|
|
39
39
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
40
40
|
const peers_sdk_1 = require("@peers-app/peers-sdk");
|
|
41
41
|
const react_1 = __importStar(require("react"));
|
|
42
|
+
const apps_home_1 = require("../apps-home/apps-home");
|
|
42
43
|
const command_palette_1 = require("../command-palette/command-palette");
|
|
43
44
|
const group_switcher_1 = require("../components/group-switcher");
|
|
44
45
|
const menu_surface_1 = require("../components/menu-surface");
|
|
45
46
|
const router_1 = require("../components/router");
|
|
46
47
|
const globals_1 = require("../globals");
|
|
47
48
|
const hooks_1 = require("../hooks");
|
|
48
|
-
const local_network_offer_1 = require("../local-network/local-network-offer");
|
|
49
49
|
const notifications_client_1 = require("../notifications/notifications-client");
|
|
50
50
|
const notifications_panel_1 = require("../notifications/notifications-panel");
|
|
51
51
|
const app_shell_height_1 = require("../root-layout/app-shell-height");
|
|
52
52
|
const identity_routes_1 = require("../screens/identity/identity-routes");
|
|
53
53
|
const color_mode_dropdown_1 = require("../screens/settings/color-mode-dropdown");
|
|
54
|
-
const system_apps_1 = require("../system-apps");
|
|
55
|
-
const routes_loader_1 = require("../ui-router/routes-loader");
|
|
56
54
|
const ui_loader_1 = require("../ui-router/ui-loader");
|
|
57
55
|
const network_status_indicator_1 = require("./network-status-indicator");
|
|
58
56
|
const tabs_state_1 = require("./tabs-state");
|
|
@@ -313,7 +311,7 @@ function TabContent({ tab, isMobile, isActive }) {
|
|
|
313
311
|
// Create individual tab content components that don't re-render
|
|
314
312
|
const TabContentRenderer = react_1.default.memo(({ tab, isMobile }) => {
|
|
315
313
|
if (tab.packageId === "launcher") {
|
|
316
|
-
return (0, jsx_runtime_1.jsx)(
|
|
314
|
+
return (0, jsx_runtime_1.jsx)(apps_home_1.AppsHome, { isMobile: isMobile });
|
|
317
315
|
}
|
|
318
316
|
// System apps use the main Router (which reads from mainContentPath)
|
|
319
317
|
// Package apps use UIRouter with explicit path
|
|
@@ -326,126 +324,3 @@ const TabContentRenderer = react_1.default.memo(({ tab, isMobile }) => {
|
|
|
326
324
|
prevProps.tab.path === nextProps.tab.path &&
|
|
327
325
|
prevProps.isMobile === nextProps.isMobile);
|
|
328
326
|
});
|
|
329
|
-
function AppLauncherTab({ isMobile }) {
|
|
330
|
-
const [packages] = (0, hooks_1.useObservable)(routes_loader_1.allPackages);
|
|
331
|
-
const [recentApps] = (0, hooks_1.useObservable)(tabs_state_1.recentlyUsedApps);
|
|
332
|
-
const [searchTerm, setSearchTerm] = react_1.default.useState("");
|
|
333
|
-
// Combine regular packages with system apps package
|
|
334
|
-
const allPackages_ = [...packages, system_apps_1.systemPackage];
|
|
335
|
-
// Create app items from nav items in packages
|
|
336
|
-
const allApps = allPackages_
|
|
337
|
-
.filter((p) => !p.disabled && p.appNavs && p.appNavs.length > 0)
|
|
338
|
-
.flatMap((pkg) => {
|
|
339
|
-
const navs = pkg.appNavs;
|
|
340
|
-
if (!navs)
|
|
341
|
-
return [];
|
|
342
|
-
return navs.map((navItem) => {
|
|
343
|
-
// Construct path - use direct path for system apps, package-nav for others
|
|
344
|
-
let path;
|
|
345
|
-
if (pkg.packageId === "system-apps") {
|
|
346
|
-
// System apps use direct routing (like the original left bar)
|
|
347
|
-
path = navItem.navigationPath ?? navItem.name.replace(/\s/g, "-").toLowerCase();
|
|
348
|
-
}
|
|
349
|
-
else {
|
|
350
|
-
// Regular packages use package-nav format
|
|
351
|
-
path = `package-nav/${pkg.packageId}/${(navItem.navigationPath ?? navItem.name).replace(/[^a-zA-Z0-9]/g, "-").toLowerCase()}`;
|
|
352
|
-
while (path.includes("//")) {
|
|
353
|
-
path = path.replace("//", "/");
|
|
354
|
-
}
|
|
355
|
-
}
|
|
356
|
-
return {
|
|
357
|
-
packageId: pkg.packageId,
|
|
358
|
-
packageName: pkg.name,
|
|
359
|
-
navItem,
|
|
360
|
-
path,
|
|
361
|
-
name: navItem.name,
|
|
362
|
-
displayName: navItem.displayName || navItem.name,
|
|
363
|
-
iconClassName: navItem.iconClassName || "bi-box-seam",
|
|
364
|
-
};
|
|
365
|
-
});
|
|
366
|
-
});
|
|
367
|
-
// Filter apps based on search term
|
|
368
|
-
const filteredApps = searchTerm.trim()
|
|
369
|
-
? allApps.filter((app) => app.name.toLowerCase().includes(searchTerm.toLowerCase()) ||
|
|
370
|
-
app.displayName.toLowerCase().includes(searchTerm.toLowerCase()))
|
|
371
|
-
: allApps;
|
|
372
|
-
// Categorize filtered apps by package ID
|
|
373
|
-
const systemApps = filteredApps.filter((app) => app.packageId === "system-apps");
|
|
374
|
-
const userApps = filteredApps.filter((app) => app.packageId !== "system-apps");
|
|
375
|
-
// Get recently used apps by matching paths (only show if they match search)
|
|
376
|
-
const recentAppItems = recentApps
|
|
377
|
-
.map((path) => filteredApps.find((app) => app.path === path))
|
|
378
|
-
.filter(Boolean);
|
|
379
|
-
const openApp = (appItem) => {
|
|
380
|
-
// Check if this is the mobile-settings app and we're in React Native
|
|
381
|
-
const w = window;
|
|
382
|
-
if (appItem.path === "mobile-settings" && typeof w.__NATIVE_THEME !== "undefined") {
|
|
383
|
-
if (w.ReactNativeWebView) {
|
|
384
|
-
w.ReactNativeWebView.postMessage(JSON.stringify({
|
|
385
|
-
type: "navigate",
|
|
386
|
-
path: "mobile-settings",
|
|
387
|
-
}));
|
|
388
|
-
}
|
|
389
|
-
else {
|
|
390
|
-
window.location.href = "peers://mobile-settings";
|
|
391
|
-
}
|
|
392
|
-
return;
|
|
393
|
-
}
|
|
394
|
-
(0, tabs_state_1.goToTabPath)(appItem.path);
|
|
395
|
-
};
|
|
396
|
-
return ((0, jsx_runtime_1.jsxs)("div", { className: `container-fluid ${isMobile ? "p-2" : "p-4"}`, style: { maxHeight: "100%", overflowY: "auto" }, children: [(0, jsx_runtime_1.jsx)(local_network_offer_1.LocalNetworkHomeCards, {}), (0, jsx_runtime_1.jsx)("div", { className: isMobile ? "mb-3" : "mb-4", children: (0, jsx_runtime_1.jsxs)("div", { className: "position-relative", children: [(0, jsx_runtime_1.jsx)("i", { className: "bi-search position-absolute", style: {
|
|
397
|
-
left: "12px",
|
|
398
|
-
top: "50%",
|
|
399
|
-
transform: "translateY(-50%)",
|
|
400
|
-
color: "#6c757d",
|
|
401
|
-
zIndex: 1,
|
|
402
|
-
} }), (0, jsx_runtime_1.jsx)("input", { type: "text", className: "form-control", placeholder: "Search apps...", value: searchTerm, onChange: (e) => setSearchTerm(e.target.value), style: {
|
|
403
|
-
paddingLeft: "40px",
|
|
404
|
-
fontSize: isMobile ? "14px" : "15px",
|
|
405
|
-
} }), searchTerm && ((0, jsx_runtime_1.jsx)("button", { type: "button", className: "btn btn-sm position-absolute", style: {
|
|
406
|
-
right: "8px",
|
|
407
|
-
top: "50%",
|
|
408
|
-
transform: "translateY(-50%)",
|
|
409
|
-
border: "none",
|
|
410
|
-
background: "none",
|
|
411
|
-
color: "#6c757d",
|
|
412
|
-
}, onClick: () => setSearchTerm(""), children: (0, jsx_runtime_1.jsx)("i", { className: "bi-x" }) }))] }) }), recentAppItems.length > 0 && ((0, jsx_runtime_1.jsx)(AppSection, { title: "Recently Used", iconClassName: "bi-clock", apps: recentAppItems, onOpenApp: openApp, isMobile: isMobile })), userApps.length > 0 && ((0, jsx_runtime_1.jsx)(AppSection, { title: "User Apps", iconClassName: "bi-person", apps: userApps, onOpenApp: openApp, isMobile: isMobile })), systemApps.length > 0 && ((0, jsx_runtime_1.jsx)(AppSection, { title: "System Apps", iconClassName: "bi-gear", apps: systemApps, onOpenApp: openApp, isMobile: isMobile }))] }));
|
|
413
|
-
}
|
|
414
|
-
function AppSection({ title, iconClassName, apps, onOpenApp, isMobile }) {
|
|
415
|
-
return ((0, jsx_runtime_1.jsxs)("div", { className: "mb-5", children: [(0, jsx_runtime_1.jsxs)("h4", { className: `${isMobile ? "mb-3 h5" : "mb-3"}`, children: [(0, jsx_runtime_1.jsx)("i", { className: `${iconClassName} me-2` }), title] }), (0, jsx_runtime_1.jsx)("div", { className: `d-flex flex-wrap ${isMobile ? "gap-3" : "gap-4"}`, style: { gap: isMobile ? "16px" : "20px" }, children: apps.map((app) => ((0, jsx_runtime_1.jsx)(AppCard, { appItem: app, onOpenApp: onOpenApp, isMobile: isMobile }, `${app.packageId}-${app.path}`))) })] }));
|
|
416
|
-
}
|
|
417
|
-
function AppCard({ appItem, onOpenApp, isMobile }) {
|
|
418
|
-
const [_colorMode] = (0, hooks_1.useObservable)(color_mode_dropdown_1.colorMode);
|
|
419
|
-
const isDark = _colorMode === "dark";
|
|
420
|
-
return ((0, jsx_runtime_1.jsxs)("button", { type: "button", className: "d-flex flex-column align-items-center text-center", style: {
|
|
421
|
-
cursor: "pointer",
|
|
422
|
-
width: isMobile ? "80px" : "90px",
|
|
423
|
-
transition: "all 0.15s ease",
|
|
424
|
-
background: "none",
|
|
425
|
-
border: "none",
|
|
426
|
-
padding: 0,
|
|
427
|
-
}, title: appItem.name, onMouseEnter: (e) => {
|
|
428
|
-
e.currentTarget.style.transform = "scale(1.05)";
|
|
429
|
-
}, onMouseLeave: (e) => {
|
|
430
|
-
e.currentTarget.style.transform = "scale(1)";
|
|
431
|
-
}, onClick: () => onOpenApp(appItem), children: [(0, jsx_runtime_1.jsx)("div", { className: "d-flex align-items-center justify-content-center mb-2", style: {
|
|
432
|
-
width: isMobile ? "64px" : "72px",
|
|
433
|
-
height: isMobile ? "64px" : "72px",
|
|
434
|
-
backgroundColor: isDark ? "#343a40" : "var(--peers-surface-bg)",
|
|
435
|
-
borderRadius: "12px",
|
|
436
|
-
border: `1px solid ${isDark ? "#495057" : "var(--peers-surface-border)"}`,
|
|
437
|
-
boxShadow: isDark ? "0 2px 4px rgba(0,0,0,0.3)" : "0 2px 4px rgba(0,0,0,0.08)",
|
|
438
|
-
transition: "all 0.15s ease",
|
|
439
|
-
}, children: (0, jsx_runtime_1.jsx)("i", { className: appItem.iconClassName, style: {
|
|
440
|
-
fontSize: isMobile ? "28px" : "32px",
|
|
441
|
-
color: isDark ? "#0d6efd" : "#0d6efd",
|
|
442
|
-
} }) }), (0, jsx_runtime_1.jsx)("span", { className: isDark ? "text-light" : "text-body", style: {
|
|
443
|
-
fontSize: isMobile ? "11px" : "12px",
|
|
444
|
-
fontWeight: "500",
|
|
445
|
-
lineHeight: "1.2",
|
|
446
|
-
maxWidth: "100%",
|
|
447
|
-
overflow: "hidden",
|
|
448
|
-
textOverflow: "ellipsis",
|
|
449
|
-
whiteSpace: "nowrap",
|
|
450
|
-
}, children: appItem.displayName })] }));
|
|
451
|
-
}
|
|
@@ -18,10 +18,6 @@ export declare const activeTabs: Observable<TabState[]> & {
|
|
|
18
18
|
export declare const activeTabId: Observable<string> & {
|
|
19
19
|
loadingPromise: Promise<void>;
|
|
20
20
|
};
|
|
21
|
-
/** App roots recently opened from the launcher, newest first. */
|
|
22
|
-
export declare const recentlyUsedApps: Observable<string[]> & {
|
|
23
|
-
loadingPromise: Promise<void>;
|
|
24
|
-
};
|
|
25
21
|
/** Tab ids whose bodies have been mounted at least once. */
|
|
26
22
|
export declare const initializedTabs: Set<string>;
|
|
27
23
|
/** Options for {@link navigateTo}. */
|
|
@@ -59,6 +55,13 @@ export declare function goToTabPath(path: string): void;
|
|
|
59
55
|
* @param _setNewMainPath - Direct path setter. Navigation updates the path itself.
|
|
60
56
|
*/
|
|
61
57
|
export declare const handleMainPathChanged: (_oldPath: string, newPath: string, _setNewMainPath: (path: string) => void) => void;
|
|
58
|
+
/**
|
|
59
|
+
* Whether a route belonged to a built-in app Peers no longer has (Threads, Assistants,
|
|
60
|
+
* Workflows).
|
|
61
|
+
*
|
|
62
|
+
* @param path - A route, with or without a query string.
|
|
63
|
+
*/
|
|
64
|
+
export declare function isRemovedAppRoute(path: string): boolean;
|
|
62
65
|
/**
|
|
63
66
|
* Rewrite stored tabs onto canonical routes.
|
|
64
67
|
*
|
|
@@ -73,12 +76,6 @@ export declare function restoreNavigationState(tabs: TabState[], activeId: strin
|
|
|
73
76
|
tabs: TabState[];
|
|
74
77
|
activeId: string;
|
|
75
78
|
};
|
|
76
|
-
/**
|
|
77
|
-
* Map a stored recent-app path onto the current app root.
|
|
78
|
-
*
|
|
79
|
-
* @param path - Persisted recent path, possibly a legacy alias.
|
|
80
|
-
*/
|
|
81
|
-
export declare function migrateRecentPath(path: string): string;
|
|
82
79
|
type AppInfo = {
|
|
83
80
|
navItem: IAppNav;
|
|
84
81
|
package: IPackageWithNavs;
|