@chykalophia/clickup-mcp-server 3.2.0
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/LICENSE +21 -0
- package/README.md +467 -0
- package/bin/clickup-mcp-server-ai.js +9 -0
- package/bin/clickup-mcp-server-basic.js +9 -0
- package/bin/clickup-mcp-server-efficiency.js +9 -0
- package/bin/clickup-mcp-server-enhanced.js +9 -0
- package/build/app.d.ts +1 -0
- package/build/app.js +2 -0
- package/build/app.js.map +1 -0
- package/build/clickup-client/attachments-enhanced.d.ts +128 -0
- package/build/clickup-client/attachments-enhanced.js +212 -0
- package/build/clickup-client/attachments-enhanced.js.map +1 -0
- package/build/clickup-client/auth.d.ts +254 -0
- package/build/clickup-client/auth.js +105 -0
- package/build/clickup-client/auth.js.map +1 -0
- package/build/clickup-client/chat-enhanced.d.ts +141 -0
- package/build/clickup-client/chat-enhanced.js +196 -0
- package/build/clickup-client/chat-enhanced.js.map +1 -0
- package/build/clickup-client/checklists.d.ts +87 -0
- package/build/clickup-client/checklists.js +63 -0
- package/build/clickup-client/checklists.js.map +1 -0
- package/build/clickup-client/comments-enhanced.d.ts +176 -0
- package/build/clickup-client/comments-enhanced.js +230 -0
- package/build/clickup-client/comments-enhanced.js.map +1 -0
- package/build/clickup-client/comments.d.ts +173 -0
- package/build/clickup-client/comments.js +312 -0
- package/build/clickup-client/comments.js.map +1 -0
- package/build/clickup-client/custom-fields-enhanced.d.ts +286 -0
- package/build/clickup-client/custom-fields-enhanced.js +416 -0
- package/build/clickup-client/custom-fields-enhanced.js.map +1 -0
- package/build/clickup-client/dependencies-enhanced.d.ts +144 -0
- package/build/clickup-client/dependencies-enhanced.js +142 -0
- package/build/clickup-client/dependencies-enhanced.js.map +1 -0
- package/build/clickup-client/docs-enhanced.d.ts +176 -0
- package/build/clickup-client/docs-enhanced.js +374 -0
- package/build/clickup-client/docs-enhanced.js.map +1 -0
- package/build/clickup-client/docs.d.ts +84 -0
- package/build/clickup-client/docs.js +156 -0
- package/build/clickup-client/docs.js.map +1 -0
- package/build/clickup-client/folders.d.ts +62 -0
- package/build/clickup-client/folders.js +53 -0
- package/build/clickup-client/folders.js.map +1 -0
- package/build/clickup-client/goals-enhanced.d.ts +163 -0
- package/build/clickup-client/goals-enhanced.js +309 -0
- package/build/clickup-client/goals-enhanced.js.map +1 -0
- package/build/clickup-client/index.d.ts +16 -0
- package/build/clickup-client/index.js +61 -0
- package/build/clickup-client/index.js.map +1 -0
- package/build/clickup-client/lists.d.ts +105 -0
- package/build/clickup-client/lists.js +108 -0
- package/build/clickup-client/lists.js.map +1 -0
- package/build/clickup-client/secure-client.d.ts +88 -0
- package/build/clickup-client/secure-client.js +275 -0
- package/build/clickup-client/secure-client.js.map +1 -0
- package/build/clickup-client/spaces.d.ts +58 -0
- package/build/clickup-client/spaces.js +28 -0
- package/build/clickup-client/spaces.js.map +1 -0
- package/build/clickup-client/tasks.d.ts +161 -0
- package/build/clickup-client/tasks.js +99 -0
- package/build/clickup-client/tasks.js.map +1 -0
- package/build/clickup-client/time-tracking-enhanced.d.ts +153 -0
- package/build/clickup-client/time-tracking-enhanced.js +292 -0
- package/build/clickup-client/time-tracking-enhanced.js.map +1 -0
- package/build/clickup-client/views-enhanced.d.ts +149 -0
- package/build/clickup-client/views-enhanced.js +210 -0
- package/build/clickup-client/views-enhanced.js.map +1 -0
- package/build/clickup-client/webhooks-enhanced.d.ts +119 -0
- package/build/clickup-client/webhooks-enhanced.js +169 -0
- package/build/clickup-client/webhooks-enhanced.js.map +1 -0
- package/build/controllers/lists.controller.d.ts +1 -0
- package/build/controllers/lists.controller.js +2 -0
- package/build/controllers/lists.controller.js.map +1 -0
- package/build/index-efficiency-simple.d.ts +2 -0
- package/build/index-efficiency-simple.js +379 -0
- package/build/index-efficiency-simple.js.map +1 -0
- package/build/index-enhanced-efficiency.d.ts +2 -0
- package/build/index-enhanced-efficiency.js +275 -0
- package/build/index-enhanced-efficiency.js.map +1 -0
- package/build/index-enhanced.d.ts +2 -0
- package/build/index-enhanced.js +74 -0
- package/build/index-enhanced.js.map +1 -0
- package/build/index.d.ts +2 -0
- package/build/index.js +77 -0
- package/build/index.js.map +1 -0
- package/build/resources/checklist-resources.d.ts +2 -0
- package/build/resources/checklist-resources.js +102 -0
- package/build/resources/checklist-resources.js.map +1 -0
- package/build/resources/comment-resources.d.ts +2 -0
- package/build/resources/comment-resources.js +152 -0
- package/build/resources/comment-resources.js.map +1 -0
- package/build/resources/doc-resources.d.ts +2 -0
- package/build/resources/doc-resources.js +77 -0
- package/build/resources/doc-resources.js.map +1 -0
- package/build/resources/folder-resources.d.ts +2 -0
- package/build/resources/folder-resources.js +160 -0
- package/build/resources/folder-resources.js.map +1 -0
- package/build/resources/list-resources.d.ts +2 -0
- package/build/resources/list-resources.js +104 -0
- package/build/resources/list-resources.js.map +1 -0
- package/build/resources/space-resources.d.ts +2 -0
- package/build/resources/space-resources.js +104 -0
- package/build/resources/space-resources.js.map +1 -0
- package/build/resources/task-resources.d.ts +2 -0
- package/build/resources/task-resources.js +57 -0
- package/build/resources/task-resources.js.map +1 -0
- package/build/routes/lists.routes.d.ts +1 -0
- package/build/routes/lists.routes.js +2 -0
- package/build/routes/lists.routes.js.map +1 -0
- package/build/schemas/attachments-schemas.d.ts +201 -0
- package/build/schemas/attachments-schemas.js +250 -0
- package/build/schemas/attachments-schemas.js.map +1 -0
- package/build/schemas/chat-schemas.d.ts +478 -0
- package/build/schemas/chat-schemas.js +173 -0
- package/build/schemas/chat-schemas.js.map +1 -0
- package/build/schemas/custom-field-schemas.d.ts +1617 -0
- package/build/schemas/custom-field-schemas.js +384 -0
- package/build/schemas/custom-field-schemas.js.map +1 -0
- package/build/schemas/dependencies-schemas.d.ts +274 -0
- package/build/schemas/dependencies-schemas.js +176 -0
- package/build/schemas/dependencies-schemas.js.map +1 -0
- package/build/schemas/document-schemas.d.ts +433 -0
- package/build/schemas/document-schemas.js +168 -0
- package/build/schemas/document-schemas.js.map +1 -0
- package/build/schemas/goals-schemas.d.ts +961 -0
- package/build/schemas/goals-schemas.js +293 -0
- package/build/schemas/goals-schemas.js.map +1 -0
- package/build/schemas/time-tracking-schemas.d.ts +741 -0
- package/build/schemas/time-tracking-schemas.js +234 -0
- package/build/schemas/time-tracking-schemas.js.map +1 -0
- package/build/schemas/views-schemas.d.ts +1168 -0
- package/build/schemas/views-schemas.js +221 -0
- package/build/schemas/views-schemas.js.map +1 -0
- package/build/schemas/webhook-schemas.d.ts +1127 -0
- package/build/schemas/webhook-schemas.js +137 -0
- package/build/schemas/webhook-schemas.js.map +1 -0
- package/build/services/lists.service.d.ts +1 -0
- package/build/services/lists.service.js +2 -0
- package/build/services/lists.service.js.map +1 -0
- package/build/tools/attachments-tools-setup.d.ts +2 -0
- package/build/tools/attachments-tools-setup.js +387 -0
- package/build/tools/attachments-tools-setup.js.map +1 -0
- package/build/tools/chat-tools-enhanced.d.ts +5 -0
- package/build/tools/chat-tools-enhanced.js +396 -0
- package/build/tools/chat-tools-enhanced.js.map +1 -0
- package/build/tools/chat-tools.d.ts +2 -0
- package/build/tools/chat-tools.js +614 -0
- package/build/tools/chat-tools.js.map +1 -0
- package/build/tools/checklist-tools.d.ts +2 -0
- package/build/tools/checklist-tools.js +139 -0
- package/build/tools/checklist-tools.js.map +1 -0
- package/build/tools/comment-tools.d.ts +2 -0
- package/build/tools/comment-tools.js +295 -0
- package/build/tools/comment-tools.js.map +1 -0
- package/build/tools/custom-field-tools.d.ts +2 -0
- package/build/tools/custom-field-tools.js +578 -0
- package/build/tools/custom-field-tools.js.map +1 -0
- package/build/tools/dependencies-tools-setup.d.ts +2 -0
- package/build/tools/dependencies-tools-setup.js +319 -0
- package/build/tools/dependencies-tools-setup.js.map +1 -0
- package/build/tools/doc-tools-enhanced.d.ts +2 -0
- package/build/tools/doc-tools-enhanced.js +417 -0
- package/build/tools/doc-tools-enhanced.js.map +1 -0
- package/build/tools/doc-tools.d.ts +2 -0
- package/build/tools/doc-tools.js +109 -0
- package/build/tools/doc-tools.js.map +1 -0
- package/build/tools/goals-tools.d.ts +2 -0
- package/build/tools/goals-tools.js +422 -0
- package/build/tools/goals-tools.js.map +1 -0
- package/build/tools/helper-tools.d.ts +2 -0
- package/build/tools/helper-tools.js +363 -0
- package/build/tools/helper-tools.js.map +1 -0
- package/build/tools/space-tools.d.ts +2 -0
- package/build/tools/space-tools.js +45 -0
- package/build/tools/space-tools.js.map +1 -0
- package/build/tools/task-tools.d.ts +2 -0
- package/build/tools/task-tools.js +415 -0
- package/build/tools/task-tools.js.map +1 -0
- package/build/tools/time-tracking-tools.d.ts +2 -0
- package/build/tools/time-tracking-tools.js +329 -0
- package/build/tools/time-tracking-tools.js.map +1 -0
- package/build/tools/views-tools-setup.d.ts +2 -0
- package/build/tools/views-tools-setup.js +358 -0
- package/build/tools/views-tools-setup.js.map +1 -0
- package/build/tools/webhook-tools-setup.d.ts +2 -0
- package/build/tools/webhook-tools-setup.js +304 -0
- package/build/tools/webhook-tools-setup.js.map +1 -0
- package/build/tools/webhook-tools.d.ts +4 -0
- package/build/tools/webhook-tools.js +345 -0
- package/build/tools/webhook-tools.js.map +1 -0
- package/build/utils/clickup-comment-formatter.d.ts +124 -0
- package/build/utils/clickup-comment-formatter.js +504 -0
- package/build/utils/clickup-comment-formatter.js.map +1 -0
- package/build/utils/context-aware-suggestions.d.ts +45 -0
- package/build/utils/context-aware-suggestions.js +360 -0
- package/build/utils/context-aware-suggestions.js.map +1 -0
- package/build/utils/error-handling.d.ts +140 -0
- package/build/utils/error-handling.js +392 -0
- package/build/utils/error-handling.js.map +1 -0
- package/build/utils/markdown-styling.d.ts +40 -0
- package/build/utils/markdown-styling.js +344 -0
- package/build/utils/markdown-styling.js.map +1 -0
- package/build/utils/markdown.d.ts +54 -0
- package/build/utils/markdown.js +243 -0
- package/build/utils/markdown.js.map +1 -0
- package/build/utils/security.d.ts +79 -0
- package/build/utils/security.js +303 -0
- package/build/utils/security.js.map +1 -0
- package/build/utils/tool-efficiency.d.ts +59 -0
- package/build/utils/tool-efficiency.js +247 -0
- package/build/utils/tool-efficiency.js.map +1 -0
- package/package.json +130 -0
|
@@ -0,0 +1,344 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Simple Markdown Styling Processor
|
|
3
|
+
* Provides enhanced display formatting for markdown content with visual styling
|
|
4
|
+
*/
|
|
5
|
+
const DEFAULT_OPTIONS = {
|
|
6
|
+
useColors: true,
|
|
7
|
+
useEmojis: true,
|
|
8
|
+
indentSize: 2,
|
|
9
|
+
maxWidth: 80
|
|
10
|
+
};
|
|
11
|
+
// ANSI color codes for terminal styling
|
|
12
|
+
const COLORS = {
|
|
13
|
+
reset: '\x1b[0m',
|
|
14
|
+
bright: '\x1b[1m',
|
|
15
|
+
dim: '\x1b[2m',
|
|
16
|
+
italic: '\x1b[3m',
|
|
17
|
+
underline: '\x1b[4m',
|
|
18
|
+
// Text colors
|
|
19
|
+
black: '\x1b[30m',
|
|
20
|
+
red: '\x1b[31m',
|
|
21
|
+
green: '\x1b[32m',
|
|
22
|
+
yellow: '\x1b[33m',
|
|
23
|
+
blue: '\x1b[34m',
|
|
24
|
+
magenta: '\x1b[35m',
|
|
25
|
+
cyan: '\x1b[36m',
|
|
26
|
+
white: '\x1b[37m',
|
|
27
|
+
// Background colors
|
|
28
|
+
bgBlack: '\x1b[40m',
|
|
29
|
+
bgRed: '\x1b[41m',
|
|
30
|
+
bgGreen: '\x1b[42m',
|
|
31
|
+
bgYellow: '\x1b[43m',
|
|
32
|
+
bgBlue: '\x1b[44m',
|
|
33
|
+
bgMagenta: '\x1b[45m',
|
|
34
|
+
bgCyan: '\x1b[46m',
|
|
35
|
+
bgWhite: '\x1b[47m'
|
|
36
|
+
};
|
|
37
|
+
// Emoji mappings for enhanced visual display
|
|
38
|
+
const EMOJI_MAP = {
|
|
39
|
+
h1: '🔥',
|
|
40
|
+
h2: '⚡',
|
|
41
|
+
h3: '💫',
|
|
42
|
+
h4: '✨',
|
|
43
|
+
h5: '🌟',
|
|
44
|
+
h6: '⭐',
|
|
45
|
+
bold: '💪',
|
|
46
|
+
italic: '✨',
|
|
47
|
+
code: '💻',
|
|
48
|
+
link: '🔗',
|
|
49
|
+
image: '🖼️',
|
|
50
|
+
list: '📋',
|
|
51
|
+
quote: '💬',
|
|
52
|
+
check: '✅',
|
|
53
|
+
uncheck: '☐',
|
|
54
|
+
warning: '⚠️',
|
|
55
|
+
info: '💡',
|
|
56
|
+
success: '🎉',
|
|
57
|
+
error: '❌'
|
|
58
|
+
};
|
|
59
|
+
/**
|
|
60
|
+
* Apply color styling to text
|
|
61
|
+
*/
|
|
62
|
+
function colorize(text, color, options) {
|
|
63
|
+
if (!options.useColors)
|
|
64
|
+
return text;
|
|
65
|
+
return `${color}${text}${COLORS.reset}`;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Add emoji prefix to text
|
|
69
|
+
*/
|
|
70
|
+
function addEmoji(text, emoji, options) {
|
|
71
|
+
if (!options.useEmojis)
|
|
72
|
+
return text;
|
|
73
|
+
return `${emoji} ${text}`;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Process headers with styling
|
|
77
|
+
*/
|
|
78
|
+
function processHeaders(content, options) {
|
|
79
|
+
return content.replace(/^(#{1,6})\s+(.+)$/gm, (match, hashes, text) => {
|
|
80
|
+
const level = hashes.length;
|
|
81
|
+
const emoji = EMOJI_MAP[`h${level}`];
|
|
82
|
+
let styled = text;
|
|
83
|
+
switch (level) {
|
|
84
|
+
case 1:
|
|
85
|
+
styled = colorize(text.toUpperCase(), COLORS.bright + COLORS.red, options);
|
|
86
|
+
break;
|
|
87
|
+
case 2:
|
|
88
|
+
styled = colorize(text, COLORS.bright + COLORS.blue, options);
|
|
89
|
+
break;
|
|
90
|
+
case 3:
|
|
91
|
+
styled = colorize(text, COLORS.bright + COLORS.green, options);
|
|
92
|
+
break;
|
|
93
|
+
case 4:
|
|
94
|
+
styled = colorize(text, COLORS.bright + COLORS.yellow, options);
|
|
95
|
+
break;
|
|
96
|
+
case 5:
|
|
97
|
+
styled = colorize(text, COLORS.bright + COLORS.magenta, options);
|
|
98
|
+
break;
|
|
99
|
+
case 6:
|
|
100
|
+
styled = colorize(text, COLORS.bright + COLORS.cyan, options);
|
|
101
|
+
break;
|
|
102
|
+
}
|
|
103
|
+
const result = addEmoji(styled, emoji, options);
|
|
104
|
+
return `\n${result}\n${'='.repeat(Math.min(text.length, options.maxWidth || 80))}\n`;
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Process bold and italic text
|
|
109
|
+
*/
|
|
110
|
+
function processEmphasis(content, options) {
|
|
111
|
+
// Bold text
|
|
112
|
+
content = content.replace(/\*\*([^*]+)\*\*/g, (match, text) => {
|
|
113
|
+
const styled = colorize(text, COLORS.bright, options);
|
|
114
|
+
return options.useEmojis ? `💪 ${styled}` : styled;
|
|
115
|
+
});
|
|
116
|
+
// Italic text
|
|
117
|
+
content = content.replace(/\*([^*]+)\*/g, (match, text) => {
|
|
118
|
+
const styled = colorize(text, COLORS.italic, options);
|
|
119
|
+
return options.useEmojis ? `✨ ${styled}` : styled;
|
|
120
|
+
});
|
|
121
|
+
return content;
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Process code blocks and inline code
|
|
125
|
+
*/
|
|
126
|
+
function processCode(content, options) {
|
|
127
|
+
// Code blocks
|
|
128
|
+
content = content.replace(/```(\w+)?\n([\s\S]*?)```/g, (match, lang, code) => {
|
|
129
|
+
const langLabel = lang ? ` (${lang})` : '';
|
|
130
|
+
const header = colorize(`CODE${langLabel}`, COLORS.bgBlue + COLORS.white, options);
|
|
131
|
+
const styledCode = colorize(code.trim(), COLORS.dim + COLORS.cyan, options);
|
|
132
|
+
const border = '─'.repeat(Math.min(60, options.maxWidth || 80));
|
|
133
|
+
return `\n${addEmoji(header, EMOJI_MAP.code, options)}\n${border}\n${styledCode}\n${border}\n`;
|
|
134
|
+
});
|
|
135
|
+
// Inline code
|
|
136
|
+
content = content.replace(/`([^`]+)`/g, (match, code) => {
|
|
137
|
+
const styled = colorize(code, COLORS.bgBlack + COLORS.yellow, options);
|
|
138
|
+
return options.useEmojis ? `💻 ${styled}` : styled;
|
|
139
|
+
});
|
|
140
|
+
return content;
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Process lists
|
|
144
|
+
*/
|
|
145
|
+
function processLists(content, options) {
|
|
146
|
+
// const indent = ' '.repeat(options.indentSize || 2);
|
|
147
|
+
// Unordered lists
|
|
148
|
+
content = content.replace(/^(\s*)[-*+]\s+(.+)$/gm, (match, spaces, text) => {
|
|
149
|
+
const bullet = options.useEmojis ? '📋' : '•';
|
|
150
|
+
const styled = colorize(text, COLORS.white, options);
|
|
151
|
+
return `${spaces}${bullet} ${styled}`;
|
|
152
|
+
});
|
|
153
|
+
// Ordered lists
|
|
154
|
+
content = content.replace(/^(\s*)(\d+)\.\s+(.+)$/gm, (match, spaces, num, text) => {
|
|
155
|
+
const bullet = options.useEmojis ? `${num}️⃣` : `${num}.`;
|
|
156
|
+
const styled = colorize(text, COLORS.white, options);
|
|
157
|
+
return `${spaces}${bullet} ${styled}`;
|
|
158
|
+
});
|
|
159
|
+
// Checkboxes
|
|
160
|
+
content = content.replace(/^(\s*)- \[([x ])\]\s+(.+)$/gm, (match, spaces, check, text) => {
|
|
161
|
+
const checkbox = check === 'x' ? EMOJI_MAP.check : EMOJI_MAP.uncheck;
|
|
162
|
+
const styled = check === 'x'
|
|
163
|
+
? colorize(text, COLORS.dim + COLORS.green, options)
|
|
164
|
+
: colorize(text, COLORS.white, options);
|
|
165
|
+
return `${spaces}${checkbox} ${styled}`;
|
|
166
|
+
});
|
|
167
|
+
return content;
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* Process blockquotes
|
|
171
|
+
*/
|
|
172
|
+
function processBlockquotes(content, options) {
|
|
173
|
+
return content.replace(/^>\s+(.+)$/gm, (match, text) => {
|
|
174
|
+
const styled = colorize(text, COLORS.italic + COLORS.cyan, options);
|
|
175
|
+
const quote = addEmoji(styled, EMOJI_MAP.quote, options);
|
|
176
|
+
return `│ ${quote}`;
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* Process links and images
|
|
181
|
+
*/
|
|
182
|
+
function processLinks(content, options) {
|
|
183
|
+
// Images
|
|
184
|
+
content = content.replace(/!\[([^\]]*)\]\(([^)]+)\)/g, (match, alt, url) => {
|
|
185
|
+
const styled = colorize(`[${alt || 'Image'}]`, COLORS.bright + COLORS.magenta, options);
|
|
186
|
+
return addEmoji(`${styled} (${url})`, EMOJI_MAP.image, options);
|
|
187
|
+
});
|
|
188
|
+
// Links
|
|
189
|
+
content = content.replace(/\[([^\]]+)\]\(([^)]+)\)/g, (match, text, url) => {
|
|
190
|
+
const styled = colorize(text, COLORS.underline + COLORS.blue, options);
|
|
191
|
+
return addEmoji(`${styled} (${url})`, EMOJI_MAP.link, options);
|
|
192
|
+
});
|
|
193
|
+
return content;
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* Process horizontal rules
|
|
197
|
+
*/
|
|
198
|
+
function processHorizontalRules(content, options) {
|
|
199
|
+
return content.replace(/^---+$/gm, () => {
|
|
200
|
+
const rule = '═'.repeat(Math.min(60, options.maxWidth || 80));
|
|
201
|
+
return colorize(rule, COLORS.dim + COLORS.white, options);
|
|
202
|
+
});
|
|
203
|
+
}
|
|
204
|
+
/**
|
|
205
|
+
* Add visual separators and spacing
|
|
206
|
+
*/
|
|
207
|
+
function addVisualEnhancements(content, _options) {
|
|
208
|
+
// Add spacing around sections
|
|
209
|
+
content = content.replace(/\n(#{1,6})/g, '\n\n$1');
|
|
210
|
+
content = content.replace(/(#{1,6}[^\n]+)\n/g, '$1\n\n');
|
|
211
|
+
// Clean up excessive newlines
|
|
212
|
+
content = content.replace(/\n{3,}/g, '\n\n');
|
|
213
|
+
return content.trim();
|
|
214
|
+
}
|
|
215
|
+
/**
|
|
216
|
+
* Main function to apply simple markdown styling
|
|
217
|
+
* @param markdown The markdown content to style
|
|
218
|
+
* @param options Styling options
|
|
219
|
+
* @returns Styled markdown content with visual enhancements
|
|
220
|
+
*/
|
|
221
|
+
export function applyMarkdownStyling(markdown, options = {}) {
|
|
222
|
+
if (!markdown || typeof markdown !== 'string') {
|
|
223
|
+
return '';
|
|
224
|
+
}
|
|
225
|
+
const opts = { ...DEFAULT_OPTIONS, ...options };
|
|
226
|
+
let styled = markdown;
|
|
227
|
+
// Apply styling in order
|
|
228
|
+
styled = processHeaders(styled, opts);
|
|
229
|
+
styled = processCode(styled, opts);
|
|
230
|
+
styled = processEmphasis(styled, opts);
|
|
231
|
+
styled = processLists(styled, opts);
|
|
232
|
+
styled = processBlockquotes(styled, opts);
|
|
233
|
+
styled = processLinks(styled, opts);
|
|
234
|
+
styled = processHorizontalRules(styled, opts);
|
|
235
|
+
styled = addVisualEnhancements(styled, opts);
|
|
236
|
+
return styled;
|
|
237
|
+
}
|
|
238
|
+
/**
|
|
239
|
+
* Create a styled preview of markdown content
|
|
240
|
+
* @param markdown The markdown content
|
|
241
|
+
* @param title Optional title for the preview
|
|
242
|
+
* @param options Styling options
|
|
243
|
+
* @returns Formatted preview with title and borders
|
|
244
|
+
*/
|
|
245
|
+
export function createMarkdownPreview(markdown, title, options = {}) {
|
|
246
|
+
const opts = { ...DEFAULT_OPTIONS, ...options };
|
|
247
|
+
const styled = applyMarkdownStyling(markdown, opts);
|
|
248
|
+
if (!title) {
|
|
249
|
+
return styled;
|
|
250
|
+
}
|
|
251
|
+
const border = '═'.repeat(Math.min(title.length + 4, opts.maxWidth || 80));
|
|
252
|
+
const styledTitle = colorize(title.toUpperCase(), COLORS.bright + COLORS.white, opts);
|
|
253
|
+
const titleWithEmoji = addEmoji(styledTitle, '📄', opts);
|
|
254
|
+
return `${border}\n ${titleWithEmoji}\n${border}\n\n${styled}\n\n${border}`;
|
|
255
|
+
}
|
|
256
|
+
/**
|
|
257
|
+
* Extract and style markdown sections
|
|
258
|
+
* @param markdown The markdown content
|
|
259
|
+
* @param sectionType The type of section to extract ('headers', 'code', 'lists', etc.)
|
|
260
|
+
* @param options Styling options
|
|
261
|
+
* @returns Styled sections
|
|
262
|
+
*/
|
|
263
|
+
export function extractStyledSections(markdown, sectionType, options = {}) {
|
|
264
|
+
if (!markdown)
|
|
265
|
+
return [];
|
|
266
|
+
const opts = { ...DEFAULT_OPTIONS, ...options };
|
|
267
|
+
const sections = [];
|
|
268
|
+
switch (sectionType) {
|
|
269
|
+
case 'headers': {
|
|
270
|
+
const headerMatches = markdown.match(/^#{1,6}\s+.+$/gm);
|
|
271
|
+
if (headerMatches) {
|
|
272
|
+
sections.push(...headerMatches.map(h => processHeaders(h, opts)));
|
|
273
|
+
}
|
|
274
|
+
break;
|
|
275
|
+
}
|
|
276
|
+
case 'code': {
|
|
277
|
+
const codeMatches = markdown.match(/```[\s\S]*?```|`[^`]+`/g);
|
|
278
|
+
if (codeMatches) {
|
|
279
|
+
sections.push(...codeMatches.map(c => processCode(c, opts)));
|
|
280
|
+
}
|
|
281
|
+
break;
|
|
282
|
+
}
|
|
283
|
+
case 'lists': {
|
|
284
|
+
const listMatches = markdown.match(/^(\s*)[-*+]\s+.+$|^(\s*)\d+\.\s+.+$/gm);
|
|
285
|
+
if (listMatches) {
|
|
286
|
+
sections.push(...listMatches.map(l => processLists(l, opts)));
|
|
287
|
+
}
|
|
288
|
+
break;
|
|
289
|
+
}
|
|
290
|
+
case 'quotes': {
|
|
291
|
+
const quoteMatches = markdown.match(/^>\s+.+$/gm);
|
|
292
|
+
if (quoteMatches) {
|
|
293
|
+
sections.push(...quoteMatches.map(q => processBlockquotes(q, opts)));
|
|
294
|
+
}
|
|
295
|
+
break;
|
|
296
|
+
}
|
|
297
|
+
case 'links': {
|
|
298
|
+
const linkMatches = markdown.match(/\[([^\]]+)\]\(([^)]+)\)|!\[([^\]]*)\]\(([^)]+)\)/g);
|
|
299
|
+
if (linkMatches) {
|
|
300
|
+
sections.push(...linkMatches.map(l => processLinks(l, opts)));
|
|
301
|
+
}
|
|
302
|
+
break;
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
return sections;
|
|
306
|
+
}
|
|
307
|
+
/**
|
|
308
|
+
* Create a markdown summary with key information highlighted
|
|
309
|
+
* @param markdown The markdown content
|
|
310
|
+
* @param options Styling options
|
|
311
|
+
* @returns Styled summary
|
|
312
|
+
*/
|
|
313
|
+
export function createMarkdownSummary(markdown, options = {}) {
|
|
314
|
+
if (!markdown)
|
|
315
|
+
return '';
|
|
316
|
+
const opts = { ...DEFAULT_OPTIONS, ...options };
|
|
317
|
+
const summary = [];
|
|
318
|
+
// Extract headers
|
|
319
|
+
const headers = extractStyledSections(markdown, 'headers', opts);
|
|
320
|
+
if (headers.length > 0) {
|
|
321
|
+
summary.push(colorize('📋 SECTIONS:', COLORS.bright + COLORS.blue, opts));
|
|
322
|
+
summary.push(...headers.slice(0, 5)); // Limit to first 5 headers
|
|
323
|
+
}
|
|
324
|
+
// Extract code blocks
|
|
325
|
+
const codeBlocks = extractStyledSections(markdown, 'code', opts);
|
|
326
|
+
if (codeBlocks.length > 0) {
|
|
327
|
+
summary.push(colorize('💻 CODE BLOCKS:', COLORS.bright + COLORS.green, opts));
|
|
328
|
+
summary.push(`${codeBlocks.length} code block(s) found`);
|
|
329
|
+
}
|
|
330
|
+
// Extract lists
|
|
331
|
+
const lists = extractStyledSections(markdown, 'lists', opts);
|
|
332
|
+
if (lists.length > 0) {
|
|
333
|
+
summary.push(colorize('📝 LISTS:', COLORS.bright + COLORS.yellow, opts));
|
|
334
|
+
summary.push(`${lists.length} list item(s) found`);
|
|
335
|
+
}
|
|
336
|
+
// Extract links
|
|
337
|
+
const links = extractStyledSections(markdown, 'links', opts);
|
|
338
|
+
if (links.length > 0) {
|
|
339
|
+
summary.push(colorize('🔗 LINKS:', COLORS.bright + COLORS.cyan, opts));
|
|
340
|
+
summary.push(`${links.length} link(s) found`);
|
|
341
|
+
}
|
|
342
|
+
return summary.join('\n');
|
|
343
|
+
}
|
|
344
|
+
//# sourceMappingURL=markdown-styling.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"markdown-styling.js","sourceRoot":"","sources":["../../src/utils/markdown-styling.ts"],"names":[],"mappings":"AAAA;;;GAGG;AASH,MAAM,eAAe,GAAyB;IAC5C,SAAS,EAAE,IAAI;IACf,SAAS,EAAE,IAAI;IACf,UAAU,EAAE,CAAC;IACb,QAAQ,EAAE,EAAE;CACb,CAAC;AAEF,wCAAwC;AACxC,MAAM,MAAM,GAAG;IACb,KAAK,EAAE,SAAS;IAChB,MAAM,EAAE,SAAS;IACjB,GAAG,EAAE,SAAS;IACd,MAAM,EAAE,SAAS;IACjB,SAAS,EAAE,SAAS;IAEpB,cAAc;IACd,KAAK,EAAE,UAAU;IACjB,GAAG,EAAE,UAAU;IACf,KAAK,EAAE,UAAU;IACjB,MAAM,EAAE,UAAU;IAClB,IAAI,EAAE,UAAU;IAChB,OAAO,EAAE,UAAU;IACnB,IAAI,EAAE,UAAU;IAChB,KAAK,EAAE,UAAU;IAEjB,oBAAoB;IACpB,OAAO,EAAE,UAAU;IACnB,KAAK,EAAE,UAAU;IACjB,OAAO,EAAE,UAAU;IACnB,QAAQ,EAAE,UAAU;IACpB,MAAM,EAAE,UAAU;IAClB,SAAS,EAAE,UAAU;IACrB,MAAM,EAAE,UAAU;IAClB,OAAO,EAAE,UAAU;CACpB,CAAC;AAEF,6CAA6C;AAC7C,MAAM,SAAS,GAAG;IAChB,EAAE,EAAE,IAAI;IACR,EAAE,EAAE,GAAG;IACP,EAAE,EAAE,IAAI;IACR,EAAE,EAAE,GAAG;IACP,EAAE,EAAE,IAAI;IACR,EAAE,EAAE,GAAG;IACP,IAAI,EAAE,IAAI;IACV,MAAM,EAAE,GAAG;IACX,IAAI,EAAE,IAAI;IACV,IAAI,EAAE,IAAI;IACV,KAAK,EAAE,KAAK;IACZ,IAAI,EAAE,IAAI;IACV,KAAK,E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ED,gBAAgB;IAChB,MAAM,KAAK,GAAG,qBAAqB,CAAC,QAAQ,EAAE,OAAO,EAAE,IAAI,CAAC,CAAC;IAC7D,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACrB,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC,MAAM,GAAG,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC;QACvE,OAAO,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC,MAAM,gBAAgB,CAAC,CAAC;IAChD,CAAC;IAED,OAAO,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC5B,CAAC"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Convert markdown to HTML for ClickUp API submission
|
|
3
|
+
* @param markdown The markdown content to convert
|
|
4
|
+
* @returns HTML string suitable for ClickUp API
|
|
5
|
+
*/
|
|
6
|
+
export declare function markdownToHtml(markdown: string): string;
|
|
7
|
+
/**
|
|
8
|
+
* Convert HTML to markdown for display/editing
|
|
9
|
+
* @param html The HTML content to convert
|
|
10
|
+
* @returns Markdown string
|
|
11
|
+
*/
|
|
12
|
+
export declare function htmlToMarkdown(html: string): string;
|
|
13
|
+
/**
|
|
14
|
+
* Convert markdown to plain text by stripping formatting
|
|
15
|
+
* @param markdown The markdown content to convert
|
|
16
|
+
* @returns Plain text string
|
|
17
|
+
*/
|
|
18
|
+
export declare function markdownToPlainText(markdown: string): string;
|
|
19
|
+
/**
|
|
20
|
+
* Detect if content contains markdown formatting
|
|
21
|
+
* @param content The content to check
|
|
22
|
+
* @returns True if content appears to contain markdown
|
|
23
|
+
*/
|
|
24
|
+
export declare function isMarkdown(content: string): boolean;
|
|
25
|
+
/**
|
|
26
|
+
* Detect if content contains HTML formatting
|
|
27
|
+
* @param content The content to check
|
|
28
|
+
* @returns True if content appears to contain HTML
|
|
29
|
+
*/
|
|
30
|
+
export declare function isHtml(content: string): boolean;
|
|
31
|
+
/**
|
|
32
|
+
* Smart content formatter that detects format and converts appropriately
|
|
33
|
+
* @param content The content to format
|
|
34
|
+
* @param targetFormat The desired output format
|
|
35
|
+
* @returns Formatted content
|
|
36
|
+
*/
|
|
37
|
+
export declare function formatContent(content: string, targetFormat: 'html' | 'markdown' | 'plain'): string;
|
|
38
|
+
/**
|
|
39
|
+
* Prepare content for ClickUp API submission
|
|
40
|
+
* Converts markdown to HTML and provides both formats
|
|
41
|
+
* @param content The content to prepare (markdown or plain text)
|
|
42
|
+
* @returns Object with both HTML and plain text versions
|
|
43
|
+
*/
|
|
44
|
+
export declare function prepareContentForClickUp(content: string): {
|
|
45
|
+
description: string;
|
|
46
|
+
text_content?: string;
|
|
47
|
+
};
|
|
48
|
+
/**
|
|
49
|
+
* Process ClickUp response content for display
|
|
50
|
+
* Converts HTML to markdown for better readability
|
|
51
|
+
* @param response ClickUp API response with description/text_content
|
|
52
|
+
* @returns Processed content with markdown formatting
|
|
53
|
+
*/
|
|
54
|
+
export declare function processClickUpResponse(response: any): any;
|
|
@@ -0,0 +1,243 @@
|
|
|
1
|
+
import { marked } from 'marked';
|
|
2
|
+
import TurndownService from 'turndown';
|
|
3
|
+
/**
|
|
4
|
+
* Markdown processing utilities for ClickUp content
|
|
5
|
+
* Handles conversion between markdown, HTML, and plain text formats
|
|
6
|
+
*/
|
|
7
|
+
// Configure marked for ClickUp-compatible HTML output
|
|
8
|
+
marked.setOptions({
|
|
9
|
+
gfm: true, // GitHub Flavored Markdown
|
|
10
|
+
breaks: true // Convert line breaks to <br>
|
|
11
|
+
});
|
|
12
|
+
// Configure Turndown for ClickUp HTML to markdown conversion
|
|
13
|
+
const turndownService = new TurndownService({
|
|
14
|
+
headingStyle: 'atx', // Use # for headers
|
|
15
|
+
codeBlockStyle: 'fenced', // Use ``` for code blocks
|
|
16
|
+
fence: '```', // Use ``` for code fences
|
|
17
|
+
emDelimiter: '*', // Use * for emphasis
|
|
18
|
+
strongDelimiter: '**', // Use ** for strong
|
|
19
|
+
linkStyle: 'inlined', // Use [text](url) for links
|
|
20
|
+
linkReferenceStyle: 'full' // Use full reference links
|
|
21
|
+
});
|
|
22
|
+
// Add custom rules for ClickUp-specific elements
|
|
23
|
+
turndownService.addRule('strikethrough', {
|
|
24
|
+
filter: ['del', 's'],
|
|
25
|
+
replacement: (content) => `~~${content}~~`
|
|
26
|
+
});
|
|
27
|
+
turndownService.addRule('underline', {
|
|
28
|
+
filter: 'u',
|
|
29
|
+
replacement: (content) => `<u>${content}</u>` // Keep underline as HTML since markdown doesn't support it
|
|
30
|
+
});
|
|
31
|
+
turndownService.addRule('highlight', {
|
|
32
|
+
filter: 'mark',
|
|
33
|
+
replacement: (content) => `==${content}==` // Use highlight syntax
|
|
34
|
+
});
|
|
35
|
+
/**
|
|
36
|
+
* Convert markdown to HTML for ClickUp API submission
|
|
37
|
+
* @param markdown The markdown content to convert
|
|
38
|
+
* @returns HTML string suitable for ClickUp API
|
|
39
|
+
*/
|
|
40
|
+
export function markdownToHtml(markdown) {
|
|
41
|
+
if (!markdown || typeof markdown !== 'string') {
|
|
42
|
+
return '';
|
|
43
|
+
}
|
|
44
|
+
try {
|
|
45
|
+
const result = marked.parse(markdown);
|
|
46
|
+
return typeof result === 'string' ? result : '';
|
|
47
|
+
}
|
|
48
|
+
catch (error) {
|
|
49
|
+
console.warn('Failed to parse markdown, returning as plain text:', error);
|
|
50
|
+
return markdown;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Convert HTML to markdown for display/editing
|
|
55
|
+
* @param html The HTML content to convert
|
|
56
|
+
* @returns Markdown string
|
|
57
|
+
*/
|
|
58
|
+
export function htmlToMarkdown(html) {
|
|
59
|
+
if (!html || typeof html !== 'string') {
|
|
60
|
+
return '';
|
|
61
|
+
}
|
|
62
|
+
try {
|
|
63
|
+
return turndownService.turndown(html);
|
|
64
|
+
}
|
|
65
|
+
catch (error) {
|
|
66
|
+
console.warn('Failed to convert HTML to markdown, returning as plain text:', error);
|
|
67
|
+
// Strip HTML tags as fallback
|
|
68
|
+
return html.replace(/<[^>]*>/g, '');
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Convert markdown to plain text by stripping formatting
|
|
73
|
+
* @param markdown The markdown content to convert
|
|
74
|
+
* @returns Plain text string
|
|
75
|
+
*/
|
|
76
|
+
export function markdownToPlainText(markdown) {
|
|
77
|
+
if (!markdown || typeof markdown !== 'string') {
|
|
78
|
+
return '';
|
|
79
|
+
}
|
|
80
|
+
try {
|
|
81
|
+
// First convert to HTML, then strip tags
|
|
82
|
+
const htmlResult = marked.parse(markdown);
|
|
83
|
+
const html = typeof htmlResult === 'string' ? htmlResult : '';
|
|
84
|
+
return html.replace(/<[^>]*>/g, '').replace(/\n\s*\n/g, '\n').trim();
|
|
85
|
+
}
|
|
86
|
+
catch (error) {
|
|
87
|
+
console.warn('Failed to convert markdown to plain text:', error);
|
|
88
|
+
// Fallback: basic markdown stripping
|
|
89
|
+
return markdown
|
|
90
|
+
.replace(/#{1,6}\s+/g, '') // Remove headers
|
|
91
|
+
.replace(/\*\*(.*?)\*\*/g, '$1') // Remove bold
|
|
92
|
+
.replace(/\*(.*?)\*/g, '$1') // Remove italic
|
|
93
|
+
.replace(/`(.*?)`/g, '$1') // Remove inline code
|
|
94
|
+
.replace(/```[\s\S]*?```/g, '') // Remove code blocks
|
|
95
|
+
.replace(/\[([^\]]+)\]\([^)]+\)/g, '$1') // Convert links to text
|
|
96
|
+
.replace(/!\[([^\]]*)\]\([^)]+\)/g, '$1') // Convert images to alt text
|
|
97
|
+
.trim();
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Detect if content contains markdown formatting
|
|
102
|
+
* @param content The content to check
|
|
103
|
+
* @returns True if content appears to contain markdown
|
|
104
|
+
*/
|
|
105
|
+
export function isMarkdown(content) {
|
|
106
|
+
if (!content || typeof content !== 'string') {
|
|
107
|
+
return false;
|
|
108
|
+
}
|
|
109
|
+
// Check for common markdown patterns
|
|
110
|
+
const markdownPatterns = [
|
|
111
|
+
/#{1,6}\s+/, // Headers
|
|
112
|
+
/\*\*.*?\*\*/, // Bold
|
|
113
|
+
/\*.*?\*/, // Italic
|
|
114
|
+
/`.*?`/, // Inline code
|
|
115
|
+
/```[\s\S]*?```/, // Code blocks
|
|
116
|
+
/\[.*?\]\(.*?\)/, // Links
|
|
117
|
+
/!\[.*?\]\(.*?\)/, // Images
|
|
118
|
+
/^\s*[-*+]\s+/m, // Unordered lists
|
|
119
|
+
/^\s*\d+\.\s+/m, // Ordered lists
|
|
120
|
+
/^\s*>\s+/m, // Blockquotes
|
|
121
|
+
/~~.*?~~/, // Strikethrough
|
|
122
|
+
/==[^=]+==/ // Highlight
|
|
123
|
+
];
|
|
124
|
+
return markdownPatterns.some(pattern => pattern.test(content));
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Detect if content contains HTML formatting
|
|
128
|
+
* @param content The content to check
|
|
129
|
+
* @returns True if content appears to contain HTML
|
|
130
|
+
*/
|
|
131
|
+
export function isHtml(content) {
|
|
132
|
+
if (!content || typeof content !== 'string') {
|
|
133
|
+
return false;
|
|
134
|
+
}
|
|
135
|
+
// Check for HTML tags
|
|
136
|
+
return /<[^>]+>/g.test(content);
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Smart content formatter that detects format and converts appropriately
|
|
140
|
+
* @param content The content to format
|
|
141
|
+
* @param targetFormat The desired output format
|
|
142
|
+
* @returns Formatted content
|
|
143
|
+
*/
|
|
144
|
+
export function formatContent(content, targetFormat) {
|
|
145
|
+
if (!content || typeof content !== 'string') {
|
|
146
|
+
return '';
|
|
147
|
+
}
|
|
148
|
+
// Detect current format
|
|
149
|
+
const isCurrentlyHtml = isHtml(content);
|
|
150
|
+
const isCurrentlyMarkdown = !isCurrentlyHtml && isMarkdown(content);
|
|
151
|
+
switch (targetFormat) {
|
|
152
|
+
case 'html':
|
|
153
|
+
if (isCurrentlyHtml)
|
|
154
|
+
return content;
|
|
155
|
+
if (isCurrentlyMarkdown)
|
|
156
|
+
return markdownToHtml(content);
|
|
157
|
+
return content; // Plain text, return as-is
|
|
158
|
+
case 'markdown':
|
|
159
|
+
if (isCurrentlyMarkdown)
|
|
160
|
+
return content;
|
|
161
|
+
if (isCurrentlyHtml)
|
|
162
|
+
return htmlToMarkdown(content);
|
|
163
|
+
return content; // Plain text, return as-is
|
|
164
|
+
case 'plain':
|
|
165
|
+
if (isCurrentlyMarkdown)
|
|
166
|
+
return markdownToPlainText(content);
|
|
167
|
+
if (isCurrentlyHtml)
|
|
168
|
+
return htmlToMarkdown(content).replace(/[*_`#[\]()]/g, '');
|
|
169
|
+
return content; // Already plain text
|
|
170
|
+
default:
|
|
171
|
+
return content;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* Prepare content for ClickUp API submission
|
|
176
|
+
* Converts markdown to HTML and provides both formats
|
|
177
|
+
* @param content The content to prepare (markdown or plain text)
|
|
178
|
+
* @returns Object with both HTML and plain text versions
|
|
179
|
+
*/
|
|
180
|
+
export function prepareContentForClickUp(content) {
|
|
181
|
+
if (!content || typeof content !== 'string') {
|
|
182
|
+
return { description: '' };
|
|
183
|
+
}
|
|
184
|
+
// If content looks like markdown, convert to HTML
|
|
185
|
+
if (isMarkdown(content)) {
|
|
186
|
+
const html = markdownToHtml(content);
|
|
187
|
+
const plainText = markdownToPlainText(content);
|
|
188
|
+
return {
|
|
189
|
+
description: html,
|
|
190
|
+
text_content: plainText
|
|
191
|
+
};
|
|
192
|
+
}
|
|
193
|
+
// If content is already HTML, use as-is
|
|
194
|
+
if (isHtml(content)) {
|
|
195
|
+
const plainText = htmlToMarkdown(content);
|
|
196
|
+
return {
|
|
197
|
+
description: content,
|
|
198
|
+
text_content: markdownToPlainText(plainText)
|
|
199
|
+
};
|
|
200
|
+
}
|
|
201
|
+
// Plain text content
|
|
202
|
+
return {
|
|
203
|
+
description: content,
|
|
204
|
+
text_content: content
|
|
205
|
+
};
|
|
206
|
+
}
|
|
207
|
+
/**
|
|
208
|
+
* Process ClickUp response content for display
|
|
209
|
+
* Converts HTML to markdown for better readability
|
|
210
|
+
* @param response ClickUp API response with description/text_content
|
|
211
|
+
* @returns Processed content with markdown formatting
|
|
212
|
+
*/
|
|
213
|
+
export function processClickUpResponse(response) {
|
|
214
|
+
if (!response || typeof response !== 'object') {
|
|
215
|
+
return response;
|
|
216
|
+
}
|
|
217
|
+
const processed = { ...response };
|
|
218
|
+
// Process description field
|
|
219
|
+
if (processed.description && isHtml(processed.description)) {
|
|
220
|
+
processed.description_markdown = htmlToMarkdown(processed.description);
|
|
221
|
+
}
|
|
222
|
+
// Process comment fields
|
|
223
|
+
if (processed.comment_text && processed.comment && Array.isArray(processed.comment)) {
|
|
224
|
+
// ClickUp comments come as rich text blocks, try to convert to markdown
|
|
225
|
+
try {
|
|
226
|
+
const htmlContent = processed.comment.map((block) => {
|
|
227
|
+
if (typeof block === 'string')
|
|
228
|
+
return block;
|
|
229
|
+
if (block.text)
|
|
230
|
+
return block.text;
|
|
231
|
+
return '';
|
|
232
|
+
}).join('');
|
|
233
|
+
if (htmlContent && isHtml(htmlContent)) {
|
|
234
|
+
processed.comment_markdown = htmlToMarkdown(htmlContent);
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
catch (error) {
|
|
238
|
+
console.warn('Failed to process comment blocks:', error);
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
return processed;
|
|
242
|
+
}
|
|
243
|
+
//# sourceMappingURL=markdown.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"markdown.js","sourceRoot":"","sources":["../../src/utils/markdown.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,eAAe,MAAM,UAAU,CAAC;AAEvC;;;GAGG;AAEH,sDAAsD;AACtD,MAA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