@opencxh/ui-kit 3.180.0 → 3.182.1

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.
@@ -1,3 +1,4 @@
1
+ import { MentionRef } from './richTextMentions';
1
2
  export interface RichTextProps {
2
3
  /** Markdown or HTML; which of the two is auto-detected. */
3
4
  text: string | null | undefined;
@@ -6,6 +7,14 @@ export interface RichTextProps {
6
7
  /** Force a branch instead of detecting — only when the heuristic gets in
7
8
  * the way (e.g. plain text that happens to look like a tag). */
8
9
  as?: "markdown" | "html";
10
+ /**
11
+ * People whose `@Name` should render as a chip when the text is plain.
12
+ *
13
+ * Only the markdown branch needs it: text stored by the composer already carries its chips
14
+ * as markup. Pass the names behind a comment's `payload.mentions` and an older comment, or
15
+ * one an agent wrote, highlights the same way a fresh one does.
16
+ */
17
+ mentions?: MentionRef[];
9
18
  }
10
19
  /** Safely rendered markdown-or-HTML text. */
11
- export declare function RichText({ text, className, as }: RichTextProps): import("react").JSX.Element;
20
+ export declare function RichText({ text, className, as, mentions }: RichTextProps): import("react").JSX.Element;
@@ -0,0 +1,40 @@
1
+ /**
2
+ * Turn `@Name` in plain comment text into a mention chip, at render time.
3
+ *
4
+ * The composer already stores chips as markup, so a *new* comment needs none of this. This is
5
+ * for every other way a comment reaches the feed: one written before the markup existed, and
6
+ * one an agent wrote as markdown. Those arrive as text, and the name in them is only a name.
7
+ *
8
+ * Runs as a rehype pass rather than a string replace on the source, because injecting a tag
9
+ * into the text would flip `RichText` to its HTML branch and leave an agent's markdown
10
+ * rendering as literal asterisks.
11
+ */
12
+ /** Who may be chipped. The id rides along so a chip can later become a link to a person. */
13
+ export interface MentionRef {
14
+ id: string;
15
+ name: string;
16
+ }
17
+ interface TextNode {
18
+ type: "text";
19
+ value: string;
20
+ children?: undefined;
21
+ }
22
+ interface ElementNode {
23
+ type: "element";
24
+ tagName: string;
25
+ properties?: Record<string, unknown>;
26
+ children?: Node[];
27
+ }
28
+ interface OtherNode {
29
+ type: string;
30
+ children?: Node[];
31
+ }
32
+ type Node = TextNode | ElementNode | OtherNode;
33
+ /**
34
+ * A rehype plugin that chips every `@Name` it is told about.
35
+ *
36
+ * Longest name first: with both "Jan" and "Jan de Vries" on the list, matching the short one
37
+ * would chip half of the long one and leave " de Vries" hanging outside it.
38
+ */
39
+ export declare function rehypeMentions(mentions: MentionRef[]): () => (tree: Node) => void;
40
+ export {};
@@ -22,6 +22,7 @@ export { Page, type PageProps } from './content/Page';
22
22
  export { PageHeader, type PageHeaderAction, type PageHeaderProps, } from './content/PageHeader';
23
23
  export { PageToolbar, PageToolbarActions, type PageToolbarActionsProps, type PageToolbarProps, } from './content/PageToolbar';
24
24
  export { RichText, type RichTextProps } from './content/RichText';
25
+ export type { MentionRef } from './content/richTextMentions';
25
26
  export { SectionCaption, type SectionCaptionProps } from './content/SectionCaption';
26
27
  export { SectionDivider, type SectionDividerProps } from './content/SectionDivider';
27
28
  export { type SettingsFrameApi, SettingsFrameProvider, SettingsPage, type SettingsPageProps, type SettingsTrailEntry, useSettingsFrame, useSettingsFrameHost, } from './content/SettingsPage';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opencxh/ui-kit",
3
- "version": "3.180.0",
3
+ "version": "3.182.1",
4
4
  "description": "Theme-aware UI component library for OpenCXH platform",
5
5
  "type": "module",
6
6
  "exports": {