composeai 0.1.4 → 0.1.5

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/index.d.cts CHANGED
@@ -291,6 +291,15 @@ interface MentionConfig {
291
291
  trigger?: string;
292
292
  /** Limit suggestion count. Defaults to 8. */
293
293
  maxItems?: number;
294
+ /**
295
+ * When true, serialize mentions to markdown as a link that carries the
296
+ * stable id — `[<trigger><label>](mention:<id>)`, e.g. `[@orca](mention:u_42)`
297
+ * — so the receiving end can resolve mentions by id and render them as
298
+ * clickable chips. Default (false/omitted) keeps the plain `<trigger><label>`
299
+ * form. Only affects the `markdown` field of the submit payload; the
300
+ * structured `mentions: MentionRef[]` array is unchanged either way.
301
+ */
302
+ linkedMention?: boolean;
294
303
  }
295
304
  interface SlashConfig {
296
305
  items: SlashCommand[] | ((query: string) => SlashCommand[] | Promise<SlashCommand[]>);
package/dist/index.d.ts CHANGED
@@ -291,6 +291,15 @@ interface MentionConfig {
291
291
  trigger?: string;
292
292
  /** Limit suggestion count. Defaults to 8. */
293
293
  maxItems?: number;
294
+ /**
295
+ * When true, serialize mentions to markdown as a link that carries the
296
+ * stable id — `[<trigger><label>](mention:<id>)`, e.g. `[@orca](mention:u_42)`
297
+ * — so the receiving end can resolve mentions by id and render them as
298
+ * clickable chips. Default (false/omitted) keeps the plain `<trigger><label>`
299
+ * form. Only affects the `markdown` field of the submit payload; the
300
+ * structured `mentions: MentionRef[]` array is unchanged either way.
301
+ */
302
+ linkedMention?: boolean;
294
303
  }
295
304
  interface SlashConfig {
296
305
  items: SlashCommand[] | ((query: string) => SlashCommand[] | Promise<SlashCommand[]>);
package/dist/index.js CHANGED
@@ -1397,7 +1397,8 @@ function wrapByFormat(text, format) {
1397
1397
  if (format & FORMAT_BIT.strike) out = `~~${out}~~`;
1398
1398
  return out;
1399
1399
  }
1400
- function toMarkdown(editor) {
1400
+ function toMarkdown(editor, opts) {
1401
+ const linkedMention = opts?.linkedMention === true;
1401
1402
  return editor.getEditorState().read(() => {
1402
1403
  const root = $getRoot();
1403
1404
  let usingLive = true;
@@ -1422,7 +1423,13 @@ function toMarkdown(editor) {
1422
1423
  let out = "";
1423
1424
  for (const child of paragraph.getChildren()) {
1424
1425
  if ($isMentionNode(child)) {
1425
- out += `${child.getMentionPrefix()}${child.getMentionLabel()}`;
1426
+ const prefix = child.getMentionPrefix();
1427
+ const label = child.getMentionLabel();
1428
+ if (linkedMention) {
1429
+ out += `[${prefix}${label}](mention:${child.getMentionId()})`;
1430
+ } else {
1431
+ out += `${prefix}${label}`;
1432
+ }
1426
1433
  continue;
1427
1434
  }
1428
1435
  if ($isLineBreakNode(child)) {
@@ -4497,9 +4504,10 @@ function ComposerInner({
4497
4504
  if (isStreaming) return;
4498
4505
  if (uploadsBlocking) return;
4499
4506
  let payload = null;
4507
+ const linkedMention = typeof features.mentions === "object" && !!features.mentions.linkedMention;
4500
4508
  editor.getEditorState().read(() => {
4501
4509
  const { text, mentions } = collectPlainAndMentions(editor);
4502
- const markdown = toMarkdown(editor);
4510
+ const markdown = toMarkdown(editor, { linkedMention });
4503
4511
  const trimmed = text.trim();
4504
4512
  if (!trimmed) {
4505
4513
  if (attachments.length === 0) return;