greenline-works-mcp-server 0.3.2 → 0.3.4
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/README.md +26 -10
- package/package.json +1 -1
- package/src/constants.js +1 -1
- package/src/markdown.js +134 -0
- package/src/tools/cards.js +1 -1
- package/src/tools/checklists.js +13 -4
- package/src/tools/comments.js +1 -1
- package/src/tools/tasks.js +1 -1
- package/src/markdown-delta.js +0 -94
package/README.md
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
# GreenLine MCP Server
|
|
2
2
|
|
|
3
|
-
[Model Context Protocol](https://modelcontextprotocol.io/) server that lets AI assistants (Claude Desktop, Claude Code, Cursor, VS Code, Windsurf, and any
|
|
3
|
+
[Model Context Protocol](https://modelcontextprotocol.io/) server that lets AI assistants (Claude Desktop, Claude Code, Cursor, VS Code, Windsurf, and any MCP client) drive your [GreenLine](https://greenline.legal) workspace via the public API.
|
|
4
4
|
|
|
5
5
|
27 tools across boards, cards, comments, checklists, tasks, and labels. No delete operations.
|
|
6
6
|
|
|
7
|
+
**Two ways to connect.** The **hosted server** at `https://mcp.greenline.works/mcp` is the recommended option for every client, Claude Desktop included — paste the URL, sign in with your GreenLine account, done. Nothing to install, no API key to manage, and you always get the current tool set. The **local install** (this npm package) runs the same server on your own machine over stdio — for stdio-only clients, unattended setups like CI where a browser sign-in isn't possible, restricted networks, or developing against a fork.
|
|
8
|
+
|
|
7
9
|
## What you can do
|
|
8
10
|
|
|
9
11
|
- Read your boards, columns, labels, members, and custom fields.
|
|
@@ -14,9 +16,23 @@
|
|
|
14
16
|
- Create, update, and list checklists — including bulk task creation in a single call.
|
|
15
17
|
- Create, update, and move tasks.
|
|
16
18
|
|
|
17
|
-
## Quick start (
|
|
19
|
+
## Quick start (hosted — recommended)
|
|
20
|
+
|
|
21
|
+
**Claude Desktop:** open **Settings → Connectors → Add custom connector**, paste `https://mcp.greenline.works/mcp`, and click **Connect**. A browser window opens to sign in to GreenLine and approve access — the tools then appear in the tool picker. No config file, no API key.
|
|
22
|
+
|
|
23
|
+
**Claude Code:**
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
claude mcp add --transport http greenline https://mcp.greenline.works/mcp
|
|
27
|
+
```
|
|
18
28
|
|
|
19
|
-
|
|
29
|
+
Sign in when prompted. Where a browser sign-in isn't possible, the hosted server also accepts an API key as a header: `Authorization: Bearer accessId:apiKey`.
|
|
30
|
+
|
|
31
|
+
## Local install (Claude Desktop)
|
|
32
|
+
|
|
33
|
+
Prefer the hosted quick start above. Use a local install when your client is stdio-only, your setup is unattended (an API key in an env var beats a browser sign-in there), your network blocks `mcp.greenline.works`, or you're developing against a fork.
|
|
34
|
+
|
|
35
|
+
1. **Get an API key.** In GreenLine: **Settings → Integrations → API Keys**. Copy the whole thing — it looks like `accessId:apiKey`.
|
|
20
36
|
|
|
21
37
|
2. **Edit your config.**
|
|
22
38
|
|
|
@@ -41,7 +57,7 @@
|
|
|
41
57
|
|
|
42
58
|
4. **Try it.** Ask Claude: *"Is my GreenLine connection working?"* — Claude calls `greenline_get_me` and replies with your org name.
|
|
43
59
|
|
|
44
|
-
##
|
|
60
|
+
## Local install (Claude Code)
|
|
45
61
|
|
|
46
62
|
```bash
|
|
47
63
|
claude mcp add greenline \
|
|
@@ -51,9 +67,11 @@ claude mcp add greenline \
|
|
|
51
67
|
|
|
52
68
|
## Configuration
|
|
53
69
|
|
|
70
|
+
Environment variables for the local server:
|
|
71
|
+
|
|
54
72
|
| Variable | Required | Default | Description |
|
|
55
73
|
| --- | --- | --- | --- |
|
|
56
|
-
| `GREENLINE_API_KEY` | yes | — | Composite credential `accessId:apiKey`. Generate in **
|
|
74
|
+
| `GREENLINE_API_KEY` | yes | — | Composite credential `accessId:apiKey`. Generate in **Settings → Integrations → API Keys**. |
|
|
57
75
|
| `GREENLINE_BASE_URL` | no | `https://integrations.greenline.works/v1` | Override only when pointing at a non-production environment. |
|
|
58
76
|
|
|
59
77
|
The server validates the key on startup. A missing or malformed value (no `:` separator) exits immediately with a message pointing at the org settings page.
|
|
@@ -97,7 +115,7 @@ Plain JavaScript — no compile step.
|
|
|
97
115
|
|
|
98
116
|
## Troubleshooting
|
|
99
117
|
|
|
100
|
-
**`401` on every tool call.** API key
|
|
118
|
+
**`401` on every tool call.** If you connected with an API key, it's wrong or expired — regenerate it. If you signed in to the hosted server, disconnect it in your client and connect again for a fresh token.
|
|
101
119
|
|
|
102
120
|
**Tools don't appear in the client.** Confirm the path is correct and the client was restarted after editing config. For `npx` installs, run `npx -y greenline-works-mcp-server` once manually to make sure it downloads cleanly.
|
|
103
121
|
|
|
@@ -107,11 +125,9 @@ Plain JavaScript — no compile step.
|
|
|
107
125
|
|
|
108
126
|
## Security
|
|
109
127
|
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
## What's next
|
|
128
|
+
The local server runs on your machine. It does not transmit data to any third-party AI service — every API call goes directly to `https://integrations.greenline.works`. Your API key never leaves your machine except as an `Authorization: Basic` header on those direct calls.
|
|
113
129
|
|
|
114
|
-
The server is
|
|
130
|
+
The hosted server is operated by GreenLine and talks to that same public API. Signing in uses OAuth and makes a **user-level** connection: your client holds an access token tied to your account, the tools reach what your account can reach, and changes are attributed to your name. An API key is an **org-level** credential — it acts as the organization's integration identity and by default reaches every board in the org (keys can be scoped to chosen boards when generated).
|
|
115
131
|
|
|
116
132
|
## License
|
|
117
133
|
|
package/package.json
CHANGED
package/src/constants.js
CHANGED
package/src/markdown.js
ADDED
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
// Converts the markdown LLM clients naturally produce into the HTML the API accepts.
|
|
2
|
+
//
|
|
3
|
+
// The public API takes rich text as an HTML string — POST /comments, POST /tasks and the
|
|
4
|
+
// checklist tasks[] all validate `required|string` on it — so markdown must become HTML here
|
|
5
|
+
// rather than a delta. The server converts that HTML to its stored delta (utils/quill.js),
|
|
6
|
+
// which preserves inline <code> and multi-line <pre> as of 8.8.0.
|
|
7
|
+
//
|
|
8
|
+
// Input that already contains HTML is returned untouched, so a client following the documented
|
|
9
|
+
// format is never double-converted.
|
|
10
|
+
|
|
11
|
+
const SUPPORTED_TAG = /<(?:p|br|strong|em|u|s|a|ul|ol|li|h[1-3]|blockquote|pre|code)\b[^>]*>/i;
|
|
12
|
+
const containsHtml = text => SUPPORTED_TAG.test(text);
|
|
13
|
+
|
|
14
|
+
const escapeHtml = text => text.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>');
|
|
15
|
+
|
|
16
|
+
const renderMarkers = text =>
|
|
17
|
+
text
|
|
18
|
+
.replace(/\*\*([^*]+)\*\*/g, '<strong>$1</strong>')
|
|
19
|
+
.replace(/__([^_]+)__/g, '<strong>$1</strong>')
|
|
20
|
+
.replace(/(^|[^*])\*([^*\s][^*]*)\*/g, '$1<em>$2</em>')
|
|
21
|
+
.replace(/(^|[^_])_([^_\s][^_]*)_/g, '$1<em>$2</em>')
|
|
22
|
+
.replace(/~~([^~]+)~~/g, '<s>$1</s>')
|
|
23
|
+
.replace(/\[([^\]]+)\]\((https?:\/\/[^)\s]+)\)/g, '<a href="$2">$1</a>');
|
|
24
|
+
|
|
25
|
+
// Code spans are split out before the other markers so they cannot mangle their contents —
|
|
26
|
+
// `run_a_test` is a name, not italics.
|
|
27
|
+
const renderInline = text =>
|
|
28
|
+
escapeHtml(text)
|
|
29
|
+
.split(/(`[^`]+`)/)
|
|
30
|
+
.map(part =>
|
|
31
|
+
part.length > 2 && part.startsWith('`') && part.endsWith('`')
|
|
32
|
+
? `<code>${part.slice(1, -1)}</code>`
|
|
33
|
+
: renderMarkers(part)
|
|
34
|
+
)
|
|
35
|
+
.join('');
|
|
36
|
+
|
|
37
|
+
const UNORDERED = /^(\s*)[-*+]\s+(.*)$/;
|
|
38
|
+
const ORDERED = /^(\s*)\d+[.)]\s+(.*)$/;
|
|
39
|
+
const HEADING = /^(#{1,3})\s+(.*)$/;
|
|
40
|
+
const QUOTE = /^>\s?(.*)$/;
|
|
41
|
+
const FENCE = /^\s*```/;
|
|
42
|
+
|
|
43
|
+
const markdownToHtml = value => {
|
|
44
|
+
if (typeof value !== 'string' || !value.trim()) return value;
|
|
45
|
+
if (containsHtml(value)) return value;
|
|
46
|
+
|
|
47
|
+
const lines = value.replace(/\r\n/g, '\n').split('\n');
|
|
48
|
+
const out = [];
|
|
49
|
+
let list = null;
|
|
50
|
+
let paragraph = [];
|
|
51
|
+
let fenced = false;
|
|
52
|
+
let fence = [];
|
|
53
|
+
|
|
54
|
+
const closeList = () => {
|
|
55
|
+
if (list) {
|
|
56
|
+
out.push(`</${list}>`);
|
|
57
|
+
list = null;
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
const closeParagraph = () => {
|
|
61
|
+
if (paragraph.length) {
|
|
62
|
+
out.push(`<p>${renderInline(paragraph.join(' '))}</p>`);
|
|
63
|
+
paragraph = [];
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
const closeFence = () => {
|
|
67
|
+
out.push(`<pre>${fence.map(escapeHtml).join('\n')}</pre>`);
|
|
68
|
+
fence = [];
|
|
69
|
+
};
|
|
70
|
+
const openList = kind => {
|
|
71
|
+
if (list !== kind) {
|
|
72
|
+
closeList();
|
|
73
|
+
out.push(`<${kind}>`);
|
|
74
|
+
list = kind;
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
for (const line of lines) {
|
|
79
|
+
if (FENCE.test(line)) {
|
|
80
|
+
closeParagraph();
|
|
81
|
+
closeList();
|
|
82
|
+
if (fenced) closeFence();
|
|
83
|
+
fenced = !fenced;
|
|
84
|
+
continue;
|
|
85
|
+
}
|
|
86
|
+
if (fenced) {
|
|
87
|
+
fence.push(line);
|
|
88
|
+
continue;
|
|
89
|
+
}
|
|
90
|
+
if (!line.trim()) {
|
|
91
|
+
closeParagraph();
|
|
92
|
+
closeList();
|
|
93
|
+
continue;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
const heading = line.match(HEADING);
|
|
97
|
+
if (heading) {
|
|
98
|
+
closeParagraph();
|
|
99
|
+
closeList();
|
|
100
|
+
out.push(`<h${heading[1].length}>${renderInline(heading[2])}</h${heading[1].length}>`);
|
|
101
|
+
continue;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
const quote = line.match(QUOTE);
|
|
105
|
+
if (quote) {
|
|
106
|
+
closeParagraph();
|
|
107
|
+
closeList();
|
|
108
|
+
out.push(`<blockquote>${renderInline(quote[1])}</blockquote>`);
|
|
109
|
+
continue;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
const unordered = line.match(UNORDERED);
|
|
113
|
+
const ordered = unordered ? null : line.match(ORDERED);
|
|
114
|
+
if (unordered || ordered) {
|
|
115
|
+
closeParagraph();
|
|
116
|
+
openList(unordered ? 'ul' : 'ol');
|
|
117
|
+
out.push(`<li>${renderInline((unordered || ordered)[2])}</li>`);
|
|
118
|
+
continue;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
paragraph.push(line.trim());
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
closeParagraph();
|
|
125
|
+
closeList();
|
|
126
|
+
// An unterminated fence still carries its lines.
|
|
127
|
+
if (fenced && fence.length) closeFence();
|
|
128
|
+
return out.join('');
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
// Every rich-text field on the API is an HTML string; markdown is converted, HTML passes through.
|
|
132
|
+
const richTextBody = (field, value) => ({ [field]: markdownToHtml(value) });
|
|
133
|
+
|
|
134
|
+
module.exports = { markdownToHtml, richTextBody, containsHtml };
|
package/src/tools/cards.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
const { z } = require('zod');
|
|
2
2
|
const { makeApiRequest, safeRun } = require('../client');
|
|
3
3
|
const { responseFormatField, ResponseFormat, toJsonString, truncateIfNeeded, RICH_TEXT_HELP } = require('../format');
|
|
4
|
-
const { richTextBody } = require('../markdown
|
|
4
|
+
const { richTextBody } = require('../markdown');
|
|
5
5
|
const { objectIdField, boardPublicIdField, pageField, countField, isoDateField } = require('../schemas');
|
|
6
6
|
|
|
7
7
|
const READ = { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: true };
|
package/src/tools/checklists.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
const { z } = require('zod');
|
|
2
2
|
const { makeApiRequest, safeRun } = require('../client');
|
|
3
|
-
const { responseFormatField, ResponseFormat, toJsonString, truncateIfNeeded } = require('../format');
|
|
3
|
+
const { responseFormatField, ResponseFormat, toJsonString, truncateIfNeeded, RICH_TEXT_HELP } = require('../format');
|
|
4
|
+
const { markdownToHtml } = require('../markdown');
|
|
4
5
|
const { objectIdField } = require('../schemas');
|
|
5
6
|
|
|
6
7
|
const READ = { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: true };
|
|
@@ -19,7 +20,7 @@ const registerChecklistsTools = server => {
|
|
|
19
20
|
' - card (string, required): card ObjectId.',
|
|
20
21
|
' - title (string, optional): checklist title.',
|
|
21
22
|
' - checklistTemplate (string, optional): checklist template ObjectId.',
|
|
22
|
-
|
|
23
|
+
` - tasks (array, optional): list of { description: string }. ${RICH_TEXT_HELP} Task position is taken from array index — any \`position\` field on a task is ignored.`,
|
|
23
24
|
'',
|
|
24
25
|
'Examples:',
|
|
25
26
|
' - "Add a checklist to card 670... with tasks: write tests, update docs"',
|
|
@@ -32,7 +33,11 @@ const registerChecklistsTools = server => {
|
|
|
32
33
|
tasks: z
|
|
33
34
|
.array(
|
|
34
35
|
z.object({
|
|
35
|
-
description: z
|
|
36
|
+
description: z
|
|
37
|
+
.string()
|
|
38
|
+
.min(1)
|
|
39
|
+
.max(2000)
|
|
40
|
+
.describe(RICH_TEXT_HELP),
|
|
36
41
|
})
|
|
37
42
|
)
|
|
38
43
|
.optional(),
|
|
@@ -44,7 +49,11 @@ const registerChecklistsTools = server => {
|
|
|
44
49
|
const body = { card };
|
|
45
50
|
if (title !== undefined) body.title = title;
|
|
46
51
|
if (checklistTemplate !== undefined) body.checklistTemplate = checklistTemplate;
|
|
47
|
-
|
|
52
|
+
// tasks[].description is a plain string field on the API, so convert markdown
|
|
53
|
+
// here the same way every other rich-text field is converted.
|
|
54
|
+
if (tasks !== undefined) {
|
|
55
|
+
body.tasks = tasks.map(task => ({ ...task, description: markdownToHtml(task.description) }));
|
|
56
|
+
}
|
|
48
57
|
|
|
49
58
|
const data = await makeApiRequest('/checklists', { method: 'POST', body });
|
|
50
59
|
const taskCount = Array.isArray(data.tasks) ? data.tasks.length : 0;
|
package/src/tools/comments.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
const { z } = require('zod');
|
|
2
2
|
const { makeApiRequest, safeRun } = require('../client');
|
|
3
3
|
const { responseFormatField, ResponseFormat, toJsonString, truncateIfNeeded, RICH_TEXT_HELP } = require('../format');
|
|
4
|
-
const { richTextBody } = require('../markdown
|
|
4
|
+
const { richTextBody } = require('../markdown');
|
|
5
5
|
const { objectIdField } = require('../schemas');
|
|
6
6
|
|
|
7
7
|
const READ = { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: true };
|
package/src/tools/tasks.js
CHANGED
|
@@ -2,7 +2,7 @@ const { z } = require('zod');
|
|
|
2
2
|
const { makeApiRequest, safeRun } = require('../client');
|
|
3
3
|
const { isoDateField, objectIdField } = require('../schemas');
|
|
4
4
|
const { RICH_TEXT_HELP } = require('../format');
|
|
5
|
-
const { richTextBody } = require('../markdown
|
|
5
|
+
const { richTextBody } = require('../markdown');
|
|
6
6
|
|
|
7
7
|
const WRITE = { readOnlyHint: false, destructiveHint: false, idempotentHint: false, openWorldHint: true };
|
|
8
8
|
const IDEMPOTENT_WRITE = { readOnlyHint: false, destructiveHint: false, idempotentHint: true, openWorldHint: true };
|
package/src/markdown-delta.js
DELETED
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
// Converts the markdown LLM clients naturally produce into a Quill Delta, so the API receives the
|
|
2
|
-
// stored format directly. Inline: `code`, **bold**, __bold__, *em*, _em_, ~~strike~~, [text](url).
|
|
3
|
-
// Blocks: #-### headings, -/*/+ and 1. lists (2-space nesting -> indent), > quotes, ``` fences ->
|
|
4
|
-
// code-block lines, blank-line paragraph breaks. Input that already contains HTML is passed through
|
|
5
|
-
// in the plain field for the server to convert (richTextBody).
|
|
6
|
-
|
|
7
|
-
const SUPPORTED_TAG = /<(?:p|br|strong|em|u|s|a|ul|ol|li|h[1-3]|blockquote|pre|code)\b[^>]*>/i;
|
|
8
|
-
const containsHtml = text => SUPPORTED_TAG.test(text);
|
|
9
|
-
|
|
10
|
-
const INLINE_TOKEN =
|
|
11
|
-
/(`[^`]+`)|(\*\*[^*]+?\*\*)|(__[^_]+?__)|(~~[^~]+?~~)|(\[([^\]]+)\]\((https?:\/\/[^)\s]+)\))|((?<![\w*])\*[^*\s][^*]*?\*(?![\w*]))|((?<![\w_])_[^_\s][^_]*?_(?![\w_]))/;
|
|
12
|
-
|
|
13
|
-
const runsFromText = text => {
|
|
14
|
-
const runs = [];
|
|
15
|
-
let rest = text;
|
|
16
|
-
while (rest) {
|
|
17
|
-
const match = rest.match(INLINE_TOKEN);
|
|
18
|
-
if (!match) {
|
|
19
|
-
runs.push({ insert: rest });
|
|
20
|
-
break;
|
|
21
|
-
}
|
|
22
|
-
if (match.index > 0) runs.push({ insert: rest.slice(0, match.index) });
|
|
23
|
-
const token = match[0];
|
|
24
|
-
if (match[1]) runs.push({ insert: token.slice(1, -1), attributes: { code: true } });
|
|
25
|
-
else if (match[2] || match[3]) runs.push({ insert: token.slice(2, -2), attributes: { bold: true } });
|
|
26
|
-
else if (match[4]) runs.push({ insert: token.slice(2, -2), attributes: { strike: true } });
|
|
27
|
-
else if (match[5]) runs.push({ insert: match[6], attributes: { link: match[7] } });
|
|
28
|
-
else runs.push({ insert: token.slice(1, -1), attributes: { italic: true } });
|
|
29
|
-
rest = rest.slice(match.index + token.length);
|
|
30
|
-
}
|
|
31
|
-
return runs;
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
const markdownToDelta = markdown => {
|
|
35
|
-
const ops = [];
|
|
36
|
-
const lines = String(markdown).replace(/\r\n/g, '\n').split('\n');
|
|
37
|
-
let paragraph = [];
|
|
38
|
-
let fenced = false;
|
|
39
|
-
|
|
40
|
-
const flushParagraph = () => {
|
|
41
|
-
if (!paragraph.length) return;
|
|
42
|
-
ops.push(...runsFromText(paragraph.join(' ')), { insert: '\n' });
|
|
43
|
-
paragraph = [];
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
for (const line of lines) {
|
|
47
|
-
if (/^\s*```/.test(line)) {
|
|
48
|
-
flushParagraph();
|
|
49
|
-
fenced = !fenced;
|
|
50
|
-
continue;
|
|
51
|
-
}
|
|
52
|
-
if (fenced) {
|
|
53
|
-
if (line) ops.push({ insert: line });
|
|
54
|
-
ops.push({ insert: '\n', attributes: { 'code-block': true } });
|
|
55
|
-
continue;
|
|
56
|
-
}
|
|
57
|
-
if (!line.trim()) {
|
|
58
|
-
flushParagraph();
|
|
59
|
-
continue;
|
|
60
|
-
}
|
|
61
|
-
const heading = line.match(/^(#{1,3})\s+(.*)$/);
|
|
62
|
-
if (heading) {
|
|
63
|
-
flushParagraph();
|
|
64
|
-
ops.push(...runsFromText(heading[2]), { insert: '\n', attributes: { header: heading[1].length } });
|
|
65
|
-
continue;
|
|
66
|
-
}
|
|
67
|
-
const quote = line.match(/^>\s?(.*)$/);
|
|
68
|
-
if (quote) {
|
|
69
|
-
flushParagraph();
|
|
70
|
-
ops.push(...runsFromText(quote[1]), { insert: '\n', attributes: { blockquote: true } });
|
|
71
|
-
continue;
|
|
72
|
-
}
|
|
73
|
-
const unordered = line.match(/^(\s*)[-*+]\s+(.*)$/);
|
|
74
|
-
const ordered = unordered ? null : line.match(/^(\s*)\d+[.)]\s+(.*)$/);
|
|
75
|
-
if (unordered || ordered) {
|
|
76
|
-
flushParagraph();
|
|
77
|
-
const [, lead, text] = unordered || ordered;
|
|
78
|
-
const attributes = { list: unordered ? 'bullet' : 'ordered' };
|
|
79
|
-
const indent = Math.min(Math.floor(lead.length / 2), 8);
|
|
80
|
-
if (indent) attributes.indent = indent;
|
|
81
|
-
ops.push(...runsFromText(text), { insert: '\n', attributes });
|
|
82
|
-
continue;
|
|
83
|
-
}
|
|
84
|
-
paragraph.push(line.trim());
|
|
85
|
-
}
|
|
86
|
-
flushParagraph();
|
|
87
|
-
return ops.length ? { ops } : { ops: [{ insert: '\n' }] };
|
|
88
|
-
};
|
|
89
|
-
|
|
90
|
-
// HTML goes through unchanged for the server to convert; anything else is markdown.
|
|
91
|
-
const richTextBody = (field, value) =>
|
|
92
|
-
containsHtml(value) ? { [field]: value } : { [`${field}Delta`]: markdownToDelta(value) };
|
|
93
|
-
|
|
94
|
-
module.exports = { markdownToDelta, richTextBody, containsHtml };
|