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.cjs +11 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +9 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.js +11 -3
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1399,7 +1399,8 @@ function wrapByFormat(text, format) {
|
|
|
1399
1399
|
if (format & FORMAT_BIT.strike) out = `~~${out}~~`;
|
|
1400
1400
|
return out;
|
|
1401
1401
|
}
|
|
1402
|
-
function toMarkdown(editor) {
|
|
1402
|
+
function toMarkdown(editor, opts) {
|
|
1403
|
+
const linkedMention = opts?.linkedMention === true;
|
|
1403
1404
|
return editor.getEditorState().read(() => {
|
|
1404
1405
|
const root = lexical.$getRoot();
|
|
1405
1406
|
let usingLive = true;
|
|
@@ -1424,7 +1425,13 @@ function toMarkdown(editor) {
|
|
|
1424
1425
|
let out = "";
|
|
1425
1426
|
for (const child of paragraph.getChildren()) {
|
|
1426
1427
|
if ($isMentionNode(child)) {
|
|
1427
|
-
|
|
1428
|
+
const prefix = child.getMentionPrefix();
|
|
1429
|
+
const label = child.getMentionLabel();
|
|
1430
|
+
if (linkedMention) {
|
|
1431
|
+
out += `[${prefix}${label}](mention:${child.getMentionId()})`;
|
|
1432
|
+
} else {
|
|
1433
|
+
out += `${prefix}${label}`;
|
|
1434
|
+
}
|
|
1428
1435
|
continue;
|
|
1429
1436
|
}
|
|
1430
1437
|
if (lexical.$isLineBreakNode(child)) {
|
|
@@ -4499,9 +4506,10 @@ function ComposerInner({
|
|
|
4499
4506
|
if (isStreaming) return;
|
|
4500
4507
|
if (uploadsBlocking) return;
|
|
4501
4508
|
let payload = null;
|
|
4509
|
+
const linkedMention = typeof features.mentions === "object" && !!features.mentions.linkedMention;
|
|
4502
4510
|
editor.getEditorState().read(() => {
|
|
4503
4511
|
const { text, mentions } = collectPlainAndMentions(editor);
|
|
4504
|
-
const markdown = toMarkdown(editor);
|
|
4512
|
+
const markdown = toMarkdown(editor, { linkedMention });
|
|
4505
4513
|
const trimmed = text.trim();
|
|
4506
4514
|
if (!trimmed) {
|
|
4507
4515
|
if (attachments.length === 0) return;
|