chatccc 0.2.288 → 0.2.290
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/src/format-message.js +25 -1
- package/package.json +1 -1
|
@@ -111,6 +111,16 @@ function getPostParagraphs(content) {
|
|
|
111
111
|
}
|
|
112
112
|
function formatPostTextElement(el) {
|
|
113
113
|
const t = typeof el.text === "string" ? el.text : "";
|
|
114
|
+
// 超链接元素:必须保留 URL,否则 AI 拿不到链接(飞书 post 里链接是独立元素,
|
|
115
|
+
// 不与相邻 text 合并)。文本与 URL 相同时只输出 URL,避免 "url (url)" 冗余。
|
|
116
|
+
if (el.tag === "a") {
|
|
117
|
+
const href = typeof el.href === "string" ? el.href.trim() : "";
|
|
118
|
+
if (!href)
|
|
119
|
+
return t;
|
|
120
|
+
if (!t || t === href)
|
|
121
|
+
return href;
|
|
122
|
+
return `[${t}](${href})`;
|
|
123
|
+
}
|
|
114
124
|
if (el.tag === "code_block") {
|
|
115
125
|
const lang = typeof el.language === "string" ? el.language : "";
|
|
116
126
|
return "```" + lang + "\n" + t + "\n```";
|
|
@@ -118,7 +128,21 @@ function formatPostTextElement(el) {
|
|
|
118
128
|
if (el.tag === "p" || el.tag === "text") {
|
|
119
129
|
return t;
|
|
120
130
|
}
|
|
121
|
-
|
|
131
|
+
// 图片元素由 getPostImageKey 单独处理(可能带 image_key/file_key),此处不重复输出。
|
|
132
|
+
if (el.tag === "img" || getPostImageKey(el))
|
|
133
|
+
return "";
|
|
134
|
+
// 兜底:飞书可能新增富文本元素类型,而历史上曾因入口重写而整类元素被静默丢弃
|
|
135
|
+
// (见 tag="a" 丢失链接)。未知 tag 不再静默丢弃,尽量透传可读内容并留 warn 日志,
|
|
136
|
+
// 便于发现新增类型后补齐专门处理。
|
|
137
|
+
const tag = typeof el.tag === "string" ? el.tag : "(no tag)";
|
|
138
|
+
const href = typeof el.href === "string" ? el.href.trim() : "";
|
|
139
|
+
const userName = typeof el.user_name === "string" ? el.user_name.trim() : "";
|
|
140
|
+
const fallback = t && href && t !== href
|
|
141
|
+
? `[${t}](${href})`
|
|
142
|
+
: t || href || (userName ? `@${userName}` : "");
|
|
143
|
+
console.warn(`[${ts()}] [POST] 未知富文本元素 tag=${tag},` +
|
|
144
|
+
(fallback ? `已降级透传:${fallback}` : "无可透传内容,已丢弃(请补充分支)"));
|
|
145
|
+
return fallback;
|
|
122
146
|
}
|
|
123
147
|
function getPostImageKey(el) {
|
|
124
148
|
const imageKey = el.image_key;
|