@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.
Files changed (36) hide show
  1. package/dist/apps-home/app-menu.d.ts +55 -0
  2. package/dist/apps-home/app-menu.js +126 -0
  3. package/dist/apps-home/app-status.d.ts +34 -0
  4. package/dist/apps-home/app-status.js +85 -0
  5. package/dist/apps-home/app-tile.d.ts +33 -0
  6. package/dist/apps-home/app-tile.js +106 -0
  7. package/dist/apps-home/apps-home.d.ts +29 -0
  8. package/dist/apps-home/apps-home.js +311 -0
  9. package/dist/apps-home/get-apps-sheet.d.ts +52 -0
  10. package/dist/apps-home/get-apps-sheet.js +130 -0
  11. package/dist/apps-home/pinned-apps.d.ts +73 -0
  12. package/dist/apps-home/pinned-apps.js +213 -0
  13. package/dist/apps-home/remove-app-dialog.d.ts +20 -0
  14. package/dist/apps-home/remove-app-dialog.js +62 -0
  15. package/dist/command-palette/command-palette-ui.js +2 -33
  16. package/dist/components/markdown-editor/editor.d.ts +22 -8
  17. package/dist/components/markdown-editor/editor.js +5 -4
  18. package/dist/components/markdown-editor/mention-preview-card.d.ts +13 -0
  19. package/dist/components/markdown-editor/mention-preview-card.js +30 -0
  20. package/dist/components/markdown-editor/mentions-plugin.d.ts +36 -2
  21. package/dist/components/markdown-editor/mentions-plugin.js +129 -34
  22. package/dist/components/markdown-editor/selection-effects-plugin.d.ts +18 -0
  23. package/dist/components/markdown-editor/selection-effects-plugin.js +49 -0
  24. package/dist/mentions/mention-chip.d.ts +3 -2
  25. package/dist/mentions/mention-chip.js +5 -4
  26. package/dist/root-layout/root-layout-host.js +0 -1
  27. package/dist/screens/search/global-search.js +2 -33
  28. package/dist/tabs-layout/tabs-layout.js +2 -127
  29. package/dist/tabs-layout/tabs-state.d.ts +7 -10
  30. package/dist/tabs-layout/tabs-state.js +8 -63
  31. package/dist/theme.css +948 -6
  32. package/dist/ui-router/app-catalog.d.ts +55 -0
  33. package/dist/ui-router/app-catalog.js +74 -0
  34. package/dist/ui-router/routes-loader.js +46 -27
  35. package/dist/ui-router/runnable-version.js +2 -1
  36. package/package.json +3 -3
@@ -0,0 +1,213 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.appPathOfRecent = appPathOfRecent;
4
+ exports.pinsFromRecents = pinsFromRecents;
5
+ exports.pinnedAppsReady = pinnedAppsReady;
6
+ exports.currentPins = currentPins;
7
+ exports.usePinnedApps = usePinnedApps;
8
+ exports.pinApp = pinApp;
9
+ exports.unpinApp = unpinApp;
10
+ exports.reorderPins = reorderPins;
11
+ exports.withShownReordered = withShownReordered;
12
+ exports.movePin = movePin;
13
+ const peers_sdk_1 = require("@peers-app/peers-sdk");
14
+ const lodash_1 = require("lodash");
15
+ const react_1 = require("react");
16
+ const use_observable_1 = require("../hooks/use-observable");
17
+ const identity_routes_1 = require("../screens/identity/identity-routes");
18
+ const tabs_state_1 = require("../tabs-layout/tabs-state");
19
+ /**
20
+ * The apps pinned to the top of the Apps screen, as canonical app paths in the user's order.
21
+ * One list per group, synced across the user's devices. Unset until the user first changes it.
22
+ */
23
+ const pinnedAppsVar = (0, peers_sdk_1.groupUserVar)("pinnedApps");
24
+ /**
25
+ * The launcher's recently used apps, from before pins. Nothing writes it now; it only gives the
26
+ * pins their first value, until the user changes them.
27
+ */
28
+ const legacyRecentApps = (0, peers_sdk_1.groupUserVar)("recentlyUsedApps");
29
+ /** How many recent apps become pins when a group's pins were never set. */
30
+ const SEEDED_PIN_COUNT = 4;
31
+ /**
32
+ * The app path a stored recent path belongs to: a built-in app's first segment, or a package's
33
+ * `package-nav/<packageId>/<nav>`. Legacy identity routes map onto Identity, and the routes of
34
+ * removed built-in apps name nothing.
35
+ *
36
+ * @param path - A path from the old recents list, possibly a deep link or a legacy alias.
37
+ * @returns The app's path, or `undefined` when the path names no app.
38
+ */
39
+ function appPathOfRecent(path) {
40
+ const canonical = (0, identity_routes_1.canonicalizeRoute)(path);
41
+ if ((0, identity_routes_1.isIdentityPath)(canonical))
42
+ return identity_routes_1.IDENTITY_APP_PATH;
43
+ if ((0, tabs_state_1.isRemovedAppRoute)(canonical))
44
+ return undefined;
45
+ const segments = (0, identity_routes_1.parseRoute)(canonical)
46
+ .pathname.split("/")
47
+ .filter(Boolean)
48
+ .map((segment) => segment.toLowerCase());
49
+ if (segments[0] === "package-nav") {
50
+ return segments.length >= 3 ? segments.slice(0, 3).join("/") : undefined;
51
+ }
52
+ return segments[0];
53
+ }
54
+ /**
55
+ * The pins a group starts with when they were never set: the first four distinct apps of the
56
+ * old recents list.
57
+ *
58
+ * @param recents - The old recents, newest first.
59
+ */
60
+ function pinsFromRecents(recents) {
61
+ const pins = [];
62
+ for (const recent of recents) {
63
+ const path = appPathOfRecent(recent);
64
+ if (path && !pins.includes(path))
65
+ pins.push(path);
66
+ if (pins.length === SEEDED_PIN_COUNT)
67
+ break;
68
+ }
69
+ return pins;
70
+ }
71
+ /**
72
+ * This device's pins, which the screen reads instead of the stored var. When changes come
73
+ * quickly, the stored var can briefly go back to an older list as its own writes echo back, and
74
+ * then drop the newer writes as stale; this copy keeps the newest list and writes it again.
75
+ */
76
+ const localPins = (0, peers_sdk_1.observable)(undefined);
77
+ const pinsLoaded = (0, peers_sdk_1.observable)(false);
78
+ /** Lists written here recently, newest last: the stored var going back to one is an echo. */
79
+ const recentWrites = [];
80
+ /** How long a write here can still echo back. */
81
+ const ECHO_WINDOW_MS = 30_000;
82
+ let pinsReady;
83
+ /**
84
+ * Load the stored pins and follow changes made on the user's other devices. Safe to call more
85
+ * than once.
86
+ */
87
+ function pinnedAppsReady() {
88
+ pinsReady ??= Promise.all([pinnedAppsVar.loadingPromise, legacyRecentApps.loadingPromise]).then(() => {
89
+ localPins(pinnedAppsVar());
90
+ pinsLoaded(true);
91
+ pinnedAppsVar.subscribe(onStoredPins);
92
+ });
93
+ return pinsReady;
94
+ }
95
+ function onStoredPins(stored) {
96
+ if ((0, lodash_1.isEqual)(stored, localPins()))
97
+ return;
98
+ const now = Date.now();
99
+ const echo = recentWrites.some((write) => now - write.at < ECHO_WINDOW_MS && (0, lodash_1.isEqual)(write.pins, stored));
100
+ if (!echo) {
101
+ localPins(stored); // changed on another device
102
+ return;
103
+ }
104
+ // An older write here came back: store the newest pins again, after this change settles.
105
+ setTimeout(() => {
106
+ const latest = localPins();
107
+ if (latest && !(0, lodash_1.isEqual)(pinnedAppsVar(), latest))
108
+ pinnedAppsVar(latest);
109
+ }, 0);
110
+ }
111
+ /**
112
+ * Run a change to the pins now, or once they've loaded: before then the change would start from
113
+ * an empty or seeded list and replace the stored pins.
114
+ */
115
+ function whenPinsLoaded(change) {
116
+ if (pinsLoaded())
117
+ change();
118
+ else
119
+ void pinnedAppsReady().then(change);
120
+ }
121
+ function writePins(pins) {
122
+ localPins(pins);
123
+ recentWrites.push({ pins, at: Date.now() });
124
+ if (recentWrites.length > 20)
125
+ recentWrites.shift();
126
+ pinnedAppsVar(pins);
127
+ }
128
+ /**
129
+ * The pins in effect: the stored list, or, until one is stored, the pins seeded from the old
130
+ * recents. The seed isn't written, so a device that hasn't synced yet can't replace pins set on
131
+ * another device.
132
+ */
133
+ function currentPins() {
134
+ return localPins() ?? pinsFromRecents(legacyRecentApps() ?? []);
135
+ }
136
+ /**
137
+ * The pinned app paths in order, including apps that aren't installed now (the screen hides
138
+ * those, and they come back if the app is installed again). `loaded` is false until the stored
139
+ * pins have loaded; `pins` stays empty until then so an early recents load can't show the seed.
140
+ */
141
+ function usePinnedApps() {
142
+ (0, react_1.useEffect)(() => {
143
+ void pinnedAppsReady();
144
+ }, []);
145
+ const [local] = (0, use_observable_1.useObservable)(localPins);
146
+ const [recents] = (0, use_observable_1.useObservable)(legacyRecentApps);
147
+ const [loaded] = (0, use_observable_1.useObservable)(pinsLoaded);
148
+ return { pins: loaded ? (local ?? pinsFromRecents(recents ?? [])) : [], loaded };
149
+ }
150
+ /**
151
+ * Pin an app at the end of the list. Pinning a pinned app changes nothing. Before the stored
152
+ * pins have loaded, this waits for them.
153
+ *
154
+ * @param path - The app's canonical path.
155
+ */
156
+ function pinApp(path) {
157
+ whenPinsLoaded(() => {
158
+ const pins = currentPins();
159
+ if (!pins.includes(path))
160
+ writePins([...pins, path]);
161
+ });
162
+ }
163
+ /**
164
+ * Unpin an app. Before the stored pins have loaded, this waits for them.
165
+ *
166
+ * @param path - The app's canonical path.
167
+ */
168
+ function unpinApp(path) {
169
+ whenPinsLoaded(() => {
170
+ const pins = currentPins();
171
+ if (pins.includes(path))
172
+ writePins(pins.filter((pin) => pin !== path));
173
+ });
174
+ }
175
+ /**
176
+ * Put the shown pins in a new order. Pins that aren't shown (apps not installed now) keep their
177
+ * places in the stored list. Before the stored pins have loaded, this waits for them.
178
+ *
179
+ * @param shown - The pins on screen, in their current order.
180
+ * @param reordered - The same pins in the new order.
181
+ */
182
+ function reorderPins(shown, reordered) {
183
+ whenPinsLoaded(() => writePins(withShownReordered(currentPins(), shown, reordered)));
184
+ }
185
+ /**
186
+ * Replace the shown pins' slots in `pins` with `reordered`, leaving the other pins in place.
187
+ *
188
+ * @param pins - Every pin, in stored order.
189
+ * @param shown - The pins on screen, in their current order; each one is in `pins`.
190
+ * @param reordered - `shown` in its new order.
191
+ */
192
+ function withShownReordered(pins, shown, reordered) {
193
+ const visible = new Set(shown);
194
+ let next = 0;
195
+ return pins.map((pin) => (visible.has(pin) ? (reordered[next++] ?? pin) : pin));
196
+ }
197
+ /**
198
+ * Move a shown pin one place earlier or later among the shown pins.
199
+ *
200
+ * @param shown - The pins on screen, in order.
201
+ * @param path - The pin to move.
202
+ * @param step - -1 for earlier, 1 for later.
203
+ */
204
+ function movePin(shown, path, step) {
205
+ const from = shown.indexOf(path);
206
+ const to = from + step;
207
+ if (from < 0 || to < 0 || to >= shown.length)
208
+ return;
209
+ const reordered = [...shown];
210
+ reordered.splice(from, 1);
211
+ reordered.splice(to, 0, path);
212
+ reorderPins(shown, reordered);
213
+ }
@@ -0,0 +1,20 @@
1
+ import type React from "react";
2
+ import type { IAppEntry } from "../ui-router/app-catalog";
3
+ interface IRemoveAppDialogProps {
4
+ /** The app whose package is removed. */
5
+ entry: IAppEntry;
6
+ /** The package's other apps, which go with it. */
7
+ otherApps: readonly IAppEntry[];
8
+ /** The group (or "Personal") it's removed from. */
9
+ groupName: string;
10
+ /** Remove the package. A rejection is shown in the dialog. */
11
+ onConfirm: () => Promise<void>;
12
+ /** Close without removing. */
13
+ onCancel: () => void;
14
+ }
15
+ /**
16
+ * Asks before removing an app's package from the group, since that removes it for every device
17
+ * there. A modal dialog: focus starts on Cancel and stays inside, and Escape cancels.
18
+ */
19
+ export declare function RemoveAppDialog({ entry, otherApps, groupName, onConfirm, onCancel, }: IRemoveAppDialogProps): React.ReactPortal;
20
+ export {};
@@ -0,0 +1,62 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RemoveAppDialog = RemoveAppDialog;
4
+ const jsx_runtime_1 = require("react/jsx-runtime");
5
+ const react_1 = require("react");
6
+ const react_dom_1 = require("react-dom");
7
+ /**
8
+ * Asks before removing an app's package from the group, since that removes it for every device
9
+ * there. A modal dialog: focus starts on Cancel and stays inside, and Escape cancels.
10
+ */
11
+ function RemoveAppDialog({ entry, otherApps, groupName, onConfirm, onCancel, }) {
12
+ const dialogRef = (0, react_1.useRef)(null);
13
+ const cancelRef = (0, react_1.useRef)(null);
14
+ const [removing, setRemoving] = (0, react_1.useState)(false);
15
+ const [error, setError] = (0, react_1.useState)();
16
+ const name = otherApps.length ? entry.packageName : entry.displayName;
17
+ (0, react_1.useEffect)(() => {
18
+ cancelRef.current?.focus();
19
+ }, []);
20
+ const onKeyDown = (event) => {
21
+ if (event.key === "Escape" && !removing) {
22
+ event.preventDefault();
23
+ onCancel();
24
+ return;
25
+ }
26
+ if (event.key !== "Tab")
27
+ return;
28
+ const focusable = Array.from(dialogRef.current?.querySelectorAll("button:not(:disabled)") ?? []);
29
+ if (!focusable.length)
30
+ return;
31
+ const first = focusable[0];
32
+ const last = focusable[focusable.length - 1];
33
+ if (event.shiftKey && document.activeElement === first) {
34
+ event.preventDefault();
35
+ last.focus();
36
+ }
37
+ else if (!event.shiftKey && document.activeElement === last) {
38
+ event.preventDefault();
39
+ first.focus();
40
+ }
41
+ };
42
+ const remove = async () => {
43
+ setRemoving(true);
44
+ setError(undefined);
45
+ try {
46
+ await onConfirm();
47
+ }
48
+ catch (err) {
49
+ setError(err instanceof Error ? err.message : String(err));
50
+ setRemoving(false);
51
+ }
52
+ };
53
+ return (0, react_dom_1.createPortal)(
54
+ // biome-ignore lint/a11y/noStaticElementInteractions: a pointer-only backdrop; Escape cancels
55
+ (0, jsx_runtime_1.jsx)("div", { className: "peers-apps-dialog-backdrop", onMouseDown: (event) => {
56
+ if (event.target === event.currentTarget && !removing)
57
+ onCancel();
58
+ }, children: (0, jsx_runtime_1.jsxs)("div", { ref: dialogRef, className: "peers-apps-dialog text-body", role: "dialog", "aria-modal": "true", "aria-labelledby": "peers-remove-app-title", "aria-describedby": "peers-remove-app-text", onKeyDown: onKeyDown, "data-testid": "remove-app-dialog", children: [(0, jsx_runtime_1.jsxs)("div", { className: "peers-apps-dialog-head", children: [(0, jsx_runtime_1.jsx)("span", { className: `peers-app-icon peers-app-color-${entry.color}`, "aria-hidden": "true", children: (0, jsx_runtime_1.jsx)("i", { className: entry.iconClassName }) }), (0, jsx_runtime_1.jsxs)("h3", { id: "peers-remove-app-title", children: ["Remove ", name, " from ", groupName, "?"] })] }), (0, jsx_runtime_1.jsxs)("p", { id: "peers-remove-app-text", children: [name, " is removed for every device in ", groupName, ".", otherApps.length > 0 &&
59
+ ` Its other ${otherApps.length === 1 ? "app" : "apps"}, ${otherApps
60
+ .map((app) => app.displayName)
61
+ .join(", ")}, ${otherApps.length === 1 ? "goes" : "go"} with it.`, " ", "You can install it again from Get apps."] }), error && ((0, jsx_runtime_1.jsx)("div", { className: "alert alert-danger py-2 px-3 small", role: "alert", children: error })), (0, jsx_runtime_1.jsxs)("div", { className: "peers-apps-dialog-actions", children: [(0, jsx_runtime_1.jsx)("button", { ref: cancelRef, type: "button", className: "btn peers-apps-ghost", onClick: onCancel, disabled: removing, children: "Cancel" }), (0, jsx_runtime_1.jsx)("button", { type: "button", className: "btn btn-danger", onClick: remove, disabled: removing, "data-testid": "remove-app-confirm", children: removing ? "Removing…" : "Remove" })] })] }) }), document.body);
62
+ }
@@ -6,8 +6,8 @@ const jsx_runtime_1 = require("react/jsx-runtime");
6
6
  const react_1 = require("react");
7
7
  const hooks_1 = require("../hooks");
8
8
  const color_mode_dropdown_1 = require("../screens/settings/color-mode-dropdown");
9
- const system_apps_1 = require("../system-apps");
10
9
  const tabs_state_1 = require("../tabs-layout/tabs-state");
10
+ const app_catalog_1 = require("../ui-router/app-catalog");
11
11
  const routes_loader_1 = require("../ui-router/routes-loader");
12
12
  const command_palette_1 = require("./command-palette");
13
13
  /** Searchable overlay for launching apps and running commands. */
@@ -50,38 +50,7 @@ function CommandPaletteOverlay() {
50
50
  const searchQuery = localQuery;
51
51
  const filteredCommands = (0, command_palette_1.searchCommands)(searchQuery);
52
52
  // Get all apps (system and user)
53
- const getAllApps = () => {
54
- const allPackages_ = [...packages, system_apps_1.systemPackage];
55
- return allPackages_
56
- .filter((p) => !p.disabled && p.appNavs && p.appNavs.length > 0)
57
- .flatMap((pkg) => {
58
- const navs = pkg.appNavs;
59
- if (!navs)
60
- return [];
61
- return navs.map((navItem) => {
62
- // Construct path - use direct path for system apps, package-nav for others
63
- let path;
64
- if (pkg.packageId === "system-apps") {
65
- path = navItem.navigationPath ?? navItem.name.replace(/\s/g, "-").toLowerCase();
66
- }
67
- else {
68
- path = `package-nav/${pkg.packageId}/${(navItem.navigationPath ?? navItem.name).replace(/[^a-zA-Z0-9]/g, "-").toLowerCase()}`;
69
- while (path.includes("//")) {
70
- path = path.replace("//", "/");
71
- }
72
- }
73
- return {
74
- packageId: pkg.packageId,
75
- packageName: pkg.name,
76
- navItem,
77
- path,
78
- name: navItem.name,
79
- displayName: navItem.displayName || navItem.name,
80
- iconClassName: navItem.iconClassName || "bi-box-seam",
81
- };
82
- });
83
- });
84
- };
53
+ const getAllApps = () => (0, app_catalog_1.buildAppCatalog)(packages);
85
54
  // Search apps
86
55
  const searchApps = (query) => {
87
56
  if (!query.trim())
@@ -1,14 +1,25 @@
1
- import { type Observable } from "@peers-app/peers-sdk";
1
+ import { type IMentionLink, type Observable } from "@peers-app/peers-sdk";
2
2
  import React from "react";
3
3
  import { type IToolbarControl } from "./toolbar";
4
4
  /**
5
- * Hooks a caller fills in to work with the editor imperatively: `onKeyDown` sees keys first
6
- * (return true to handle one; skipped while the mention picker is open), and the editor sets
7
- * `focus` so the caller can focus it.
5
+ * Hooks for working with the editor imperatively. The caller sets `onKeyDown`, which sees keys
6
+ * first (return true to handle one; skipped while the mention picker is open). The editor sets
7
+ * the rest once it's mounted, so the caller can focus it and work with the selection.
8
8
  */
9
9
  export interface IEditorEffects {
10
10
  onKeyDown?: (e: React.KeyboardEvent) => boolean | undefined;
11
+ /** Focus the editor, caret at the end. Set by the editor. */
11
12
  focus?: () => void;
13
+ /**
14
+ * The selected text, as plain text; empty when nothing is selected. After the editor loses
15
+ * focus (a click on the caller's button), it's the selection it had. Set by the editor.
16
+ */
17
+ getSelectedText?: () => string;
18
+ /**
19
+ * Replace the selected text with a mention chip, such as a link to a note made from it.
20
+ * Returns false, changing nothing, when nothing is selected. Set by the editor.
21
+ */
22
+ replaceSelectionWithMention?: (link: IMentionLink) => boolean;
12
23
  }
13
24
  /** What {@link MarkdownEditor} takes. */
14
25
  export interface IMarkdownEditorProps {
@@ -24,7 +35,10 @@ export interface IMarkdownEditorProps {
24
35
  hideToolbar?: boolean;
25
36
  /** Scroll inside the editor past this height. */
26
37
  maxHeight?: string | number;
27
- /** The `@` picker; on unless false. Mentions already in the text show as chips either way. */
38
+ /**
39
+ * The mention picker (`@` or `<`); on unless false. Mentions already in the text show as chips
40
+ * either way.
41
+ */
28
42
  mentions?: boolean;
29
43
  /**
30
44
  * The group the text belongs to. Its records come first in the picker, results from other
@@ -34,8 +48,8 @@ export interface IMarkdownEditorProps {
34
48
  groupId?: string;
35
49
  }
36
50
  /**
37
- * A rich-text editor whose value is markdown: lists and checklists, links, and mentions (`@`
38
- * finds people and records in every group; a mention shows as a chip with the record's live
39
- * title). Edits are written back to `value`.
51
+ * A rich-text editor whose value is markdown: lists and checklists, links, and mentions (`@` or
52
+ * `<` finds people and records in every group, and a pasted id becomes its record's chip; a
53
+ * mention shows as a chip with the record's live title). Edits are written back to `value`.
40
54
  */
41
55
  export declare function MarkdownEditor(props: IMarkdownEditorProps): import("react/jsx-runtime").JSX.Element;
@@ -63,6 +63,7 @@ const mention_node_1 = require("./mention-node");
63
63
  const mentions_plugin_1 = require("./mentions-plugin");
64
64
  const move_line_plugin_1 = require("./move-line-plugin");
65
65
  const select_line_boundary_plugin_1 = require("./select-line-boundary-plugin");
66
+ const selection_effects_plugin_1 = require("./selection-effects-plugin");
66
67
  const theme_1 = __importDefault(require("./theme"));
67
68
  const toolbar_1 = require("./toolbar");
68
69
  const editorConfig = {
@@ -86,9 +87,9 @@ const editorConfig = {
86
87
  theme: theme_1.default,
87
88
  };
88
89
  /**
89
- * A rich-text editor whose value is markdown: lists and checklists, links, and mentions (`@`
90
- * finds people and records in every group; a mention shows as a chip with the record's live
91
- * title). Edits are written back to `value`.
90
+ * A rich-text editor whose value is markdown: lists and checklists, links, and mentions (`@` or
91
+ * `<` finds people and records in every group, and a pasted id becomes its record's chip; a
92
+ * mention shows as a chip with the record's live title). Edits are written back to `value`.
92
93
  */
93
94
  function MarkdownEditor(props) {
94
95
  const { effects } = props;
@@ -116,7 +117,7 @@ function MarkdownEditor(props) {
116
117
  }
117
118
  };
118
119
  }
119
- return ((0, jsx_runtime_1.jsx)(mention_chip_1.MentionGroupContext.Provider, { value: props.groupId, children: (0, jsx_runtime_1.jsx)(LexicalComposer_1.LexicalComposer, { initialConfig: { ...editorConfig }, children: (0, jsx_runtime_1.jsxs)("div", { className: "editor-container", children: [props.hideToolbar ? null : (0, jsx_runtime_1.jsx)(toolbar_1.ToolbarPlugin, { topRightControls: props.topRightControls }), (0, jsx_runtime_1.jsxs)("div", { className: "editor-inner", ref: editorRef, style: { maxHeight: props.maxHeight, overflowY: "auto" }, children: [(0, jsx_runtime_1.jsx)(LexicalRichTextPlugin_1.RichTextPlugin, { contentEditable: (0, jsx_runtime_1.jsx)(LexicalContentEditable_1.ContentEditable, { className: "editor-input p-2" }), placeholder: null, ErrorBoundary: LexicalErrorBoundary_1.LexicalErrorBoundary }), (0, jsx_runtime_1.jsx)(LexicalHistoryPlugin_1.HistoryPlugin, {}), props.autoFocus && (0, jsx_runtime_1.jsx)(LexicalAutoFocusPlugin_1.AutoFocusPlugin, { defaultSelection: "rootEnd" }), (0, jsx_runtime_1.jsx)(LexicalListPlugin_1.ListPlugin, {}), props.mentions !== false && ((0, jsx_runtime_1.jsx)(mentions_plugin_1.MentionsPlugin, { mentionsOpen: mentionsOpen, groupId: props.groupId })), (0, jsx_runtime_1.jsx)(autolink_plugin_1.LexicalAutoLinkPlugin, {}), (0, jsx_runtime_1.jsx)(markdown_plugin_1.MarkdownPlugin, { markdownObs: props.value }), (0, jsx_runtime_1.jsx)(LexicalMarkdownShortcutPlugin_1.MarkdownShortcutPlugin, { transformers: markdown_plugin_1.customMarkdownTransformers }), (0, jsx_runtime_1.jsx)(LexicalCheckListPlugin_1.CheckListPlugin, {}), (0, jsx_runtime_1.jsx)(LexicalTabIndentationPlugin_1.TabIndentationPlugin, {}), (0, jsx_runtime_1.jsx)(move_line_plugin_1.MoveLineWithAltArrowsPlugin, { mentionsOpen: mentionsOpen }), (0, jsx_runtime_1.jsx)(select_line_boundary_plugin_1.SelectToLineBoundaryPlugin, {}), (0, jsx_runtime_1.jsx)(OnKeyDownPlugin, { effects: props.effects, mentionsOpen: mentionsOpen })] })] }) }) }));
120
+ return ((0, jsx_runtime_1.jsx)(mention_chip_1.MentionGroupContext.Provider, { value: props.groupId, children: (0, jsx_runtime_1.jsx)(LexicalComposer_1.LexicalComposer, { initialConfig: { ...editorConfig }, children: (0, jsx_runtime_1.jsxs)("div", { className: "editor-container", children: [props.hideToolbar ? null : (0, jsx_runtime_1.jsx)(toolbar_1.ToolbarPlugin, { topRightControls: props.topRightControls }), (0, jsx_runtime_1.jsxs)("div", { className: "editor-inner", ref: editorRef, style: { maxHeight: props.maxHeight, overflowY: "auto" }, children: [(0, jsx_runtime_1.jsx)(LexicalRichTextPlugin_1.RichTextPlugin, { contentEditable: (0, jsx_runtime_1.jsx)(LexicalContentEditable_1.ContentEditable, { className: "editor-input p-2" }), placeholder: null, ErrorBoundary: LexicalErrorBoundary_1.LexicalErrorBoundary }), (0, jsx_runtime_1.jsx)(LexicalHistoryPlugin_1.HistoryPlugin, {}), props.autoFocus && (0, jsx_runtime_1.jsx)(LexicalAutoFocusPlugin_1.AutoFocusPlugin, { defaultSelection: "rootEnd" }), (0, jsx_runtime_1.jsx)(LexicalListPlugin_1.ListPlugin, {}), props.mentions !== false && ((0, jsx_runtime_1.jsx)(mentions_plugin_1.MentionsPlugin, { mentionsOpen: mentionsOpen, groupId: props.groupId })), (0, jsx_runtime_1.jsx)(autolink_plugin_1.LexicalAutoLinkPlugin, {}), (0, jsx_runtime_1.jsx)(markdown_plugin_1.MarkdownPlugin, { markdownObs: props.value }), (0, jsx_runtime_1.jsx)(LexicalMarkdownShortcutPlugin_1.MarkdownShortcutPlugin, { transformers: markdown_plugin_1.customMarkdownTransformers }), (0, jsx_runtime_1.jsx)(LexicalCheckListPlugin_1.CheckListPlugin, {}), (0, jsx_runtime_1.jsx)(LexicalTabIndentationPlugin_1.TabIndentationPlugin, {}), (0, jsx_runtime_1.jsx)(move_line_plugin_1.MoveLineWithAltArrowsPlugin, { mentionsOpen: mentionsOpen }), (0, jsx_runtime_1.jsx)(select_line_boundary_plugin_1.SelectToLineBoundaryPlugin, {}), (0, jsx_runtime_1.jsx)(OnKeyDownPlugin, { effects: props.effects, mentionsOpen: mentionsOpen }), effects ? (0, jsx_runtime_1.jsx)(selection_effects_plugin_1.SelectionEffectsPlugin, { effects: effects }) : null] })] }) }) }));
120
121
  }
121
122
  const OnKeyDownPlugin = (props) => {
122
123
  const [editor] = (0, LexicalComposerContext_1.useLexicalComposerContext)();
@@ -0,0 +1,13 @@
1
+ import type { IMentionSearchResult } from "@peers-app/peers-sdk";
2
+ /**
3
+ * The picker's card for the highlighted result, so the user can tell similar titles apart: what
4
+ * it is, its title and status, its group, and the start of its text when its source declares a
5
+ * preview field. For a pasted id nothing has, it says so.
6
+ *
7
+ * @param props.result - The highlighted result.
8
+ * @param props.showPackage - Name its package: another package's results share its kind.
9
+ */
10
+ export declare function MentionPreviewCard({ result, showPackage, }: {
11
+ result: IMentionSearchResult;
12
+ showPackage: boolean;
13
+ }): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MentionPreviewCard = MentionPreviewCard;
4
+ const jsx_runtime_1 = require("react/jsx-runtime");
5
+ /**
6
+ * The picker's card for the highlighted result, so the user can tell similar titles apart: what
7
+ * it is, its title and status, its group, and the start of its text when its source declares a
8
+ * preview field. For a pasted id nothing has, it says so.
9
+ *
10
+ * @param props.result - The highlighted result.
11
+ * @param props.showPackage - Name its package: another package's results share its kind.
12
+ */
13
+ function MentionPreviewCard({ result, showPackage, }) {
14
+ // A pasted id that matched nothing is offered with no places.
15
+ const unknown = result.places === 0;
16
+ const what = [
17
+ unknown ? "Nothing has this id" : result.kindLabel,
18
+ showPackage ? result.packageName : undefined,
19
+ ]
20
+ .filter(Boolean)
21
+ .join(" · ");
22
+ const where = [
23
+ result.status,
24
+ result.groupName,
25
+ result.places > 1 ? `${result.places} places` : "",
26
+ ]
27
+ .filter(Boolean)
28
+ .join(" · ");
29
+ return ((0, jsx_runtime_1.jsxs)("div", { className: "peers-mention-preview", "aria-live": "polite", children: [(0, jsx_runtime_1.jsxs)("div", { className: "peers-mention-preview-kind", children: [result.kind === "user" ? ((0, jsx_runtime_1.jsx)("span", { "aria-hidden": true, children: "@" })) : ((0, jsx_runtime_1.jsx)("i", { className: result.iconClassName ?? "bi bi-link-45deg", "aria-hidden": true })), (0, jsx_runtime_1.jsx)("span", { children: what })] }), (0, jsx_runtime_1.jsx)("div", { className: `peers-mention-preview-title${result.done ? " peers-mention-done" : ""}`, children: result.title || result.kindLabel }), where ? (0, jsx_runtime_1.jsx)("div", { className: "peers-mention-preview-where", children: where }) : null, result.preview ? (0, jsx_runtime_1.jsx)("p", { className: "peers-mention-preview-text", children: result.preview }) : null, unknown ? ((0, jsx_runtime_1.jsx)("p", { className: "peers-mention-preview-text", children: "It's linked by id, and shows as a dotted chip until a record with this id turns up in a group you're in." })) : null] }));
30
+ }
@@ -1,12 +1,46 @@
1
1
  import { type IMentionSearchResult, type Observable } from "@peers-app/peers-sdk";
2
+ /**
3
+ * What the user typed after `@` or `<`: words, and a kind when it starts with `kind:`.
4
+ *
5
+ * @param query - The text from the trigger on, such as `@task:garden`.
6
+ */
7
+ export declare function parseQuery(query: string): {
8
+ text: string;
9
+ kinds?: string[];
10
+ };
11
+ /** A search's answer, with the query it answers, so an older one is never taken for a newer. */
12
+ interface Found {
13
+ query: string | null;
14
+ results: IMentionSearchResult[];
15
+ docGroup?: string;
16
+ }
17
+ /**
18
+ * What the picker offers for a query, and whether one result should be taken without asking.
19
+ *
20
+ * - Words: the results, as they are.
21
+ * - A pasted id (`@<id>` or `<<id>`), once its search has answered: the one record with that id,
22
+ * taken at once; nothing found, a link to whatever has the id, taken at once; several records
23
+ * (the same id in two kinds), offered to pick from. Before the answer, nothing.
24
+ *
25
+ * @param query - The text from the trigger on, or null when the picker is closed.
26
+ * @param found - The latest search answer.
27
+ * @param declined - A query the user undid an automatic pick for: offered, not taken again.
28
+ */
29
+ export declare function pickerOptions(query: string | null, found: Found, declined?: string | null): {
30
+ results: IMentionSearchResult[];
31
+ autoPick?: IMentionSearchResult;
32
+ };
2
33
  /** The kinds that more than one package answers for among these results. */
3
34
  export declare function sharedKinds(results: IMentionSearchResult[]): Set<string>;
4
35
  /**
5
- * The `@` picker: people first, then records from every group the user is in, through System
6
- * Mentions. Picking one inserts a mention chip labeled with the record's title.
36
+ * The mention picker, opened by `@` or `<`: people first, then records from every group the user
37
+ * is in, through System Mentions, with a preview of the highlighted one. Picking one inserts a
38
+ * mention chip labeled with the record's title. A pasted id becomes a chip at once: the record's,
39
+ * or a dotted `?` chip for an id that matches nothing.
7
40
  */
8
41
  export declare function MentionsPlugin(props: {
9
42
  mentionsOpen?: Observable<boolean>;
10
43
  /** The document's group; its records come first, and results from other groups are marked. */
11
44
  groupId?: string;
12
45
  }): JSX.Element | null;
46
+ export {};