@portabletext/markdown 1.4.4 → 1.4.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.ts +92 -113
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1205 -1398
- package/dist/index.js.map +1 -1
- package/package.json +10 -5
package/dist/index.js
CHANGED
|
@@ -1,1460 +1,1267 @@
|
|
|
1
|
-
import { compileSchema, defineSchema,
|
|
2
|
-
import {
|
|
1
|
+
import { compileSchema, defineSchema, isSpan, isTextBlock } from "@portabletext/schema";
|
|
2
|
+
import { buildMarksTree, isPortableTextBlock, isPortableTextListItemBlock, isPortableTextToolkitSpan, isPortableTextToolkitTextNode, spanToPlainText } from "@portabletext/toolkit";
|
|
3
3
|
import { alert } from "@mdit/plugin-alert";
|
|
4
4
|
import markdownit from "markdown-it";
|
|
5
5
|
function defaultKeyGenerator() {
|
|
6
|
-
|
|
6
|
+
return randomKey(12);
|
|
7
7
|
}
|
|
8
|
-
const getByteHexTable =
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
return table;
|
|
17
|
-
};
|
|
8
|
+
const getByteHexTable = (() => {
|
|
9
|
+
let table;
|
|
10
|
+
return () => {
|
|
11
|
+
if (table) return table;
|
|
12
|
+
table = [];
|
|
13
|
+
for (let i = 0; i < 256; ++i) table[i] = (i + 256).toString(16).slice(1);
|
|
14
|
+
return table;
|
|
15
|
+
};
|
|
18
16
|
})();
|
|
19
17
|
function whatwgRNG(length = 16) {
|
|
20
|
-
|
|
21
|
-
|
|
18
|
+
let rnds8 = new Uint8Array(length);
|
|
19
|
+
return crypto.getRandomValues(rnds8), rnds8;
|
|
22
20
|
}
|
|
23
21
|
function randomKey(length) {
|
|
24
|
-
|
|
25
|
-
|
|
22
|
+
let table = getByteHexTable();
|
|
23
|
+
return whatwgRNG(length).reduce((str, n) => str + table[n], "").slice(0, length);
|
|
26
24
|
}
|
|
27
25
|
const schema = compileSchema(defineSchema({}));
|
|
26
|
+
/**
|
|
27
|
+
* Builds a map of list item `_key`s to their index.
|
|
28
|
+
*
|
|
29
|
+
* Mutates the blocks in place by adding a `_key` if necessary.
|
|
30
|
+
*/
|
|
28
31
|
function buildListIndexMap(blocks) {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
};
|
|
74
|
-
}
|
|
75
|
-
return listIndexMap;
|
|
32
|
+
let levelIndexMaps = /* @__PURE__ */ new Map(), listIndexMap = /* @__PURE__ */ new Map(), previousListItem;
|
|
33
|
+
for (let blockIndex = 0; blockIndex < blocks.length; blockIndex++) {
|
|
34
|
+
let block = blocks.at(blockIndex);
|
|
35
|
+
if (block === void 0) continue;
|
|
36
|
+
if (block._key ||= defaultKeyGenerator(), !isTextBlock({ schema }, block)) {
|
|
37
|
+
levelIndexMaps.clear(), previousListItem = void 0;
|
|
38
|
+
continue;
|
|
39
|
+
}
|
|
40
|
+
if (block.listItem === void 0 || block.level === void 0) {
|
|
41
|
+
levelIndexMaps.clear(), previousListItem = void 0;
|
|
42
|
+
continue;
|
|
43
|
+
}
|
|
44
|
+
if (!previousListItem) {
|
|
45
|
+
let levelIndexMap = levelIndexMaps.get(block.listItem) ?? /* @__PURE__ */ new Map();
|
|
46
|
+
levelIndexMap.set(block.level, 1), levelIndexMaps.set(block.listItem, levelIndexMap), listIndexMap.set(block._key, 1), previousListItem = {
|
|
47
|
+
listItem: block.listItem,
|
|
48
|
+
level: block.level
|
|
49
|
+
};
|
|
50
|
+
continue;
|
|
51
|
+
}
|
|
52
|
+
if (previousListItem.listItem === block.listItem && previousListItem.level < block.level) {
|
|
53
|
+
let levelIndexMap = levelIndexMaps.get(block.listItem) ?? /* @__PURE__ */ new Map();
|
|
54
|
+
levelIndexMap.set(block.level, 1), levelIndexMaps.set(block.listItem, levelIndexMap), listIndexMap.set(block._key, 1), previousListItem = {
|
|
55
|
+
listItem: block.listItem,
|
|
56
|
+
level: block.level
|
|
57
|
+
};
|
|
58
|
+
continue;
|
|
59
|
+
}
|
|
60
|
+
levelIndexMaps.forEach((levelIndexMap, listItem) => {
|
|
61
|
+
if (listItem === block.listItem) return;
|
|
62
|
+
let levelsToDelete = [];
|
|
63
|
+
levelIndexMap.forEach((_, level) => {
|
|
64
|
+
level >= block.level && levelsToDelete.push(level);
|
|
65
|
+
}), levelsToDelete.forEach((level) => {
|
|
66
|
+
levelIndexMap.delete(level);
|
|
67
|
+
});
|
|
68
|
+
});
|
|
69
|
+
let levelIndexMap = levelIndexMaps.get(block.listItem) ?? /* @__PURE__ */ new Map(), levelCounter = levelIndexMap.get(block.level) ?? 0;
|
|
70
|
+
levelIndexMap.set(block.level, levelCounter + 1), levelIndexMaps.set(block.listItem, levelIndexMap), listIndexMap.set(block._key, levelCounter + 1), previousListItem = {
|
|
71
|
+
listItem: block.listItem,
|
|
72
|
+
level: block.level
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
return listIndexMap;
|
|
76
76
|
}
|
|
77
77
|
const createRenderNode = (renderers, listIndexMap) => {
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
78
|
+
function renderNode(options) {
|
|
79
|
+
let { node, index, isInline } = options;
|
|
80
|
+
return isPortableTextListItemBlock(node) ? renderListItem(node, index) : isPortableTextToolkitSpan(node) ? renderSpan(node) : isPortableTextBlock(node) ? renderBlock(node, index, isInline) : isPortableTextToolkitTextNode(node) ? renderText(node) : renderCustomBlock(node, index, isInline);
|
|
81
|
+
}
|
|
82
|
+
function renderListItem(node, index) {
|
|
83
|
+
let renderer = renderers.listItem, itemHandler = (typeof renderer == "function" ? renderer : renderer[node.listItem]) || renderers.unknownListItem, children = buildMarksTree(node).map((child, i) => renderNode({
|
|
84
|
+
node: child,
|
|
85
|
+
isInline: !0,
|
|
86
|
+
index: i,
|
|
87
|
+
renderNode
|
|
88
|
+
})).join("");
|
|
89
|
+
if (node.style && node.style !== "normal") {
|
|
90
|
+
let { listItem: _listItem, ...blockNode } = node;
|
|
91
|
+
children = renderNode({
|
|
92
|
+
node: blockNode,
|
|
93
|
+
index,
|
|
94
|
+
isInline: !1,
|
|
95
|
+
renderNode
|
|
96
|
+
}), children = children.replace(/\n+$/, "");
|
|
97
|
+
}
|
|
98
|
+
return itemHandler({
|
|
99
|
+
value: node,
|
|
100
|
+
index,
|
|
101
|
+
listIndex: node._key ? listIndexMap.get(node._key) : void 0,
|
|
102
|
+
isInline: !1,
|
|
103
|
+
renderNode,
|
|
104
|
+
children
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
function renderSpan(node) {
|
|
108
|
+
let { markDef, markType, markKey } = node, span = renderers.marks[markType] || renderers.unknownMark, children = node.children.map((child, childIndex) => renderNode({
|
|
109
|
+
node: child,
|
|
110
|
+
index: childIndex,
|
|
111
|
+
isInline: !0,
|
|
112
|
+
renderNode
|
|
113
|
+
}));
|
|
114
|
+
return span({
|
|
115
|
+
text: spanToPlainText(node),
|
|
116
|
+
value: markDef,
|
|
117
|
+
markType,
|
|
118
|
+
markKey,
|
|
119
|
+
renderNode,
|
|
120
|
+
children: children.join("")
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
function renderBlock(node, index, isInline) {
|
|
124
|
+
let { _key, ...props } = serializeBlock({
|
|
125
|
+
node,
|
|
126
|
+
index,
|
|
127
|
+
isInline,
|
|
128
|
+
renderNode
|
|
129
|
+
}), style = props.node.style || "normal";
|
|
130
|
+
return ((typeof renderers.block == "function" ? renderers.block : renderers.block[style]) || renderers.unknownBlockStyle)({
|
|
131
|
+
...props,
|
|
132
|
+
value: props.node,
|
|
133
|
+
renderNode
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
function renderText(node) {
|
|
137
|
+
return node.text === "\n" ? renderers.hardBreak() : node.text;
|
|
138
|
+
}
|
|
139
|
+
function renderCustomBlock(value, index, isInline) {
|
|
140
|
+
return (renderers.types[value._type] ?? renderers.unknownType)({
|
|
141
|
+
value,
|
|
142
|
+
isInline,
|
|
143
|
+
index,
|
|
144
|
+
renderNode
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
return renderNode;
|
|
132
148
|
};
|
|
133
149
|
function serializeBlock(options) {
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
150
|
+
let { node, index, isInline, renderNode } = options, renderedChildren = buildMarksTree(node).map((child, i) => renderNode({
|
|
151
|
+
node: child,
|
|
152
|
+
isInline: !0,
|
|
153
|
+
index: i,
|
|
154
|
+
renderNode
|
|
155
|
+
}));
|
|
156
|
+
return {
|
|
157
|
+
_key: node._key || defaultKeyGenerator(),
|
|
158
|
+
children: renderedChildren.join(""),
|
|
159
|
+
index,
|
|
160
|
+
isInline,
|
|
161
|
+
node
|
|
162
|
+
};
|
|
144
163
|
}
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
}) => isPortableTextListItemBlock(current) && isPortableTextListItemBlock(next) ?
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
children,
|
|
156
|
-
value,
|
|
157
|
-
listIndex
|
|
158
|
-
}) => {
|
|
159
|
-
const listStyle = value.listItem || "bullet", level = value.level || 1, indent = " ".repeat(level - 1);
|
|
160
|
-
if (listStyle === "number")
|
|
161
|
-
return `${indent}${listIndex ?? 1}. ${children}`;
|
|
162
|
-
if (listStyle === "task") {
|
|
163
|
-
const marker = "checked" in value && typeof value.checked == "boolean" && value.checked ? "[x]" : "[ ]";
|
|
164
|
-
return `${indent}- ${marker} ${children}`;
|
|
165
|
-
}
|
|
166
|
-
return `${indent}- ${children}`;
|
|
167
|
-
}, DefaultUnknownListItemRenderer = ({
|
|
168
|
-
children
|
|
169
|
-
}) => `- ${children}
|
|
170
|
-
`;
|
|
164
|
+
/**
|
|
165
|
+
* @public
|
|
166
|
+
*/
|
|
167
|
+
const DefaultBlockSpacingRenderer = ({ current, next }) => isPortableTextListItemBlock(current) && isPortableTextListItemBlock(next) ? "\n" : isPortableTextBlock(current) && isPortableTextBlock(next) && current.style === "blockquote" && next.style === "blockquote" ? "\n>\n" : "\n\n", DefaultHardBreakRenderer = () => " \n", DefaultListItemRenderer = ({ children, value, listIndex }) => {
|
|
168
|
+
let listStyle = value.listItem || "bullet", level = value.level || 1, indent = " ".repeat(level - 1);
|
|
169
|
+
return listStyle === "number" ? `${indent}${listIndex ?? 1}. ${children}` : listStyle === "task" ? `${indent}- ${"checked" in value && typeof value.checked == "boolean" && value.checked ? "[x]" : "[ ]"} ${children}` : `${indent}- ${children}`;
|
|
170
|
+
}, DefaultUnknownListItemRenderer = ({ children }) => `- ${children}\n`;
|
|
171
|
+
/**
|
|
172
|
+
* Escapes special characters in image alt texts and link texts.
|
|
173
|
+
*/
|
|
171
174
|
function escapeImageAndLinkText(text) {
|
|
172
|
-
|
|
175
|
+
return text.replace(/([[\]\\])/g, "\\$1");
|
|
173
176
|
}
|
|
177
|
+
/**
|
|
178
|
+
* Unescapes special characters in image alt texts and link texts.
|
|
179
|
+
*/
|
|
174
180
|
function unescapeImageAndLinkText(text) {
|
|
175
|
-
|
|
181
|
+
return text.replace(/\\([!"#$%&'()*+,\-./:;<=>?@[\\\]^_`{|}~])/g, "$1");
|
|
176
182
|
}
|
|
183
|
+
/**
|
|
184
|
+
* Escapes special characters in image/link titles (the part inside quotes).
|
|
185
|
+
*/
|
|
177
186
|
function escapeImageAndLinkTitle(text) {
|
|
178
|
-
|
|
187
|
+
return text.replace(/([\\"])/g, "\\$1");
|
|
179
188
|
}
|
|
189
|
+
/**
|
|
190
|
+
* Escapes characters that have special meaning at the row level of a GFM
|
|
191
|
+
* table cell.
|
|
192
|
+
*
|
|
193
|
+
* A literal `|` ends the cell, so unescaped pipes are replaced with `\|`.
|
|
194
|
+
* Newlines end the row, so they are replaced with `<br>` to keep the
|
|
195
|
+
* visible line break inside the cell. Already-escaped pipes (`\|`) are
|
|
196
|
+
* left intact so that escapes introduced by mark renderers survive the
|
|
197
|
+
* pass.
|
|
198
|
+
*
|
|
199
|
+
* Backslashes are intentionally not escaped here so that other escapes
|
|
200
|
+
* already in the rendered cell (such as `\[` and `\]` in link text) are
|
|
201
|
+
* not double-escaped.
|
|
202
|
+
*/
|
|
180
203
|
function escapeTableCell(text) {
|
|
181
|
-
|
|
204
|
+
return text.replace(RegExp("(?<!\\\\)\\|", "g"), "\\|").replace(/\n/g, "<br>");
|
|
182
205
|
}
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
}
|
|
197
|
-
return `[${escapeImageAndLinkText(children)}](${href}${title ? ` "${escapeImageAndLinkTitle(title)}"` : ""})`;
|
|
198
|
-
}
|
|
199
|
-
return children;
|
|
206
|
+
/**
|
|
207
|
+
* @public
|
|
208
|
+
*/
|
|
209
|
+
const DefaultEmRenderer = ({ children }) => `_${children}_`, DefaultStrongRenderer = ({ children }) => `**${children}**`, DefaultCodeRenderer = ({ children }) => `\`${children}\``, DefaultUnderlineRenderer = ({ children }) => `<u>${children}</u>`, DefaultStrikeThroughRenderer = ({ children }) => `~~${children}~~`, DefaultLinkRenderer = ({ children, value }) => {
|
|
210
|
+
let href = value?.href || "", title = value?.title || "";
|
|
211
|
+
if (uriLooksSafe(href)) {
|
|
212
|
+
if (/["'][^"']*[<>]|[<>][^<>]*["']/.test(href)) {
|
|
213
|
+
let encodedHref = href.replace(/["<>() ]/g, (char) => `%${char.charCodeAt(0).toString(16).toUpperCase()}`);
|
|
214
|
+
return `[${escapeImageAndLinkText(children)}](${encodedHref})`;
|
|
215
|
+
}
|
|
216
|
+
return `[${escapeImageAndLinkText(children)}](${href}${title ? ` "${escapeImageAndLinkTitle(title)}"` : ""})`;
|
|
217
|
+
}
|
|
218
|
+
return children;
|
|
200
219
|
};
|
|
201
220
|
function uriLooksSafe(uri) {
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
221
|
+
let url = (uri || "").trim(), first = url.charAt(0);
|
|
222
|
+
if (first === "#" || first === "/") return !0;
|
|
223
|
+
let colonIndex = url.indexOf(":");
|
|
224
|
+
if (colonIndex === -1) return !0;
|
|
225
|
+
let allowedProtocols = [
|
|
226
|
+
"http",
|
|
227
|
+
"https",
|
|
228
|
+
"mailto",
|
|
229
|
+
"tel"
|
|
230
|
+
], proto = url.slice(0, colonIndex).toLowerCase();
|
|
231
|
+
if (allowedProtocols.indexOf(proto) !== -1) return !0;
|
|
232
|
+
let queryIndex = url.indexOf("?");
|
|
233
|
+
if (queryIndex !== -1 && colonIndex > queryIndex) return !0;
|
|
234
|
+
let hashIndex = url.indexOf("#");
|
|
235
|
+
return hashIndex !== -1 && colonIndex > hashIndex;
|
|
216
236
|
}
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
}) => children ? children.split(`
|
|
224
|
-
`).map((line) => `> ${line}`).join(`
|
|
225
|
-
`) : ">", DefaultH1Renderer = ({ children }) => `# ${children}`, DefaultH2Renderer = ({ children }) => `## ${children}`, DefaultH3Renderer = ({ children }) => `### ${children}`, DefaultH4Renderer = ({ children }) => `#### ${children}`, DefaultH5Renderer = ({ children }) => `##### ${children}`, DefaultH6Renderer = ({ children }) => `###### ${children}`, DefaultUnknownStyleRenderer = ({
|
|
226
|
-
children
|
|
227
|
-
}) => children ?? "", DefaultCodeBlockRenderer = ({ value }) => `\`\`\`${value.language ?? ""}
|
|
228
|
-
${value.code}
|
|
229
|
-
\`\`\``, DefaultHorizontalRuleRenderer = () => "---", DefaultHtmlRenderer = ({ value }) => value.html, DefaultImageRenderer = ({ value }) => {
|
|
230
|
-
const alt = escapeImageAndLinkText(value.alt ?? ""), title = value.title ? ` "${escapeImageAndLinkTitle(value.title)}"` : "";
|
|
231
|
-
return ``;
|
|
237
|
+
/**
|
|
238
|
+
* @public
|
|
239
|
+
*/
|
|
240
|
+
const DefaultUnknownMarkRenderer = ({ children }) => children, DefaultNormalRenderer = ({ children }) => !children || children.trim() === "" ? "" : children, DefaultBlockquoteRenderer = ({ children }) => children ? children.split("\n").map((line) => `> ${line}`).join("\n") : ">", DefaultH1Renderer = ({ children }) => `# ${children}`, DefaultH2Renderer = ({ children }) => `## ${children}`, DefaultH3Renderer = ({ children }) => `### ${children}`, DefaultH4Renderer = ({ children }) => `#### ${children}`, DefaultH5Renderer = ({ children }) => `##### ${children}`, DefaultH6Renderer = ({ children }) => `###### ${children}`, DefaultUnknownStyleRenderer = ({ children }) => children ?? "", DefaultCodeBlockRenderer = ({ value }) => `\`\`\`${value.language ?? ""}\n${value.code}\n\`\`\``, DefaultHorizontalRuleRenderer = () => "---", DefaultHtmlRenderer = ({ value }) => value.html, DefaultImageRenderer = ({ value }) => {
|
|
241
|
+
let alt = escapeImageAndLinkText(value.alt ?? ""), title = value.title ? ` "${escapeImageAndLinkTitle(value.title)}"` : "";
|
|
242
|
+
return ``;
|
|
232
243
|
}, DefaultTableRenderer = ({ value, renderNode }) => {
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
} else {
|
|
260
|
-
lines.push(renderRow(headerRow.cells)), lines.push(delimiter);
|
|
261
|
-
for (let i = 1; i < rows.length; i++) {
|
|
262
|
-
const row = rows.at(i);
|
|
263
|
-
row && lines.push(renderRow(row.cells));
|
|
264
|
-
}
|
|
265
|
-
}
|
|
266
|
-
return lines.join(`
|
|
267
|
-
`);
|
|
244
|
+
let rows = value.rows, alignment = value.alignment, headerRow = rows.at(0);
|
|
245
|
+
if (!headerRow) return "";
|
|
246
|
+
let getCellText = (cellBlocks) => cellBlocks.map((block, index) => renderNode({
|
|
247
|
+
node: block,
|
|
248
|
+
index,
|
|
249
|
+
isInline: !1,
|
|
250
|
+
renderNode
|
|
251
|
+
})).join(" ").trim(), lines = [], columnCount = rows.reduce((max, row) => Math.max(max, row.cells.length), 0), renderCells = (texts) => {
|
|
252
|
+
let padded = [...texts];
|
|
253
|
+
for (; padded.length < columnCount;) padded.push("");
|
|
254
|
+
return `| ${padded.join(" | ")} |`;
|
|
255
|
+
}, renderRow = (cells) => renderCells(cells.map((cell) => escapeTableCell(getCellText(cell.value)))), delimiter = `|${Array.from({ length: columnCount }, (_, index) => {
|
|
256
|
+
let align = alignment?.at(index);
|
|
257
|
+
return align === "left" ? " :--- " : align === "center" ? " :---: " : align === "right" ? " ---: " : " --- ";
|
|
258
|
+
}).join("|")}|`;
|
|
259
|
+
if (value.headerRows === 0) {
|
|
260
|
+
lines.push(renderCells([])), lines.push(delimiter);
|
|
261
|
+
for (let row of rows) lines.push(renderRow(row.cells));
|
|
262
|
+
} else {
|
|
263
|
+
lines.push(renderRow(headerRow.cells)), lines.push(delimiter);
|
|
264
|
+
for (let i = 1; i < rows.length; i++) {
|
|
265
|
+
let row = rows.at(i);
|
|
266
|
+
row && lines.push(renderRow(row.cells));
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
return lines.join("\n");
|
|
268
270
|
}, DefaultCalloutRenderer = ({ value, renderNode }) => {
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
},
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
).
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
text: renderNode({
|
|
305
|
-
node: block,
|
|
306
|
-
index: blockIndex,
|
|
307
|
-
isInline: !1,
|
|
308
|
-
renderNode
|
|
309
|
-
})
|
|
310
|
-
})), [first, ...rest] = renderedBlocks, head = `${marker}${first?.text ?? ""}`.trimEnd();
|
|
311
|
-
if (rest.length === 0)
|
|
312
|
-
return head;
|
|
313
|
-
const tail = rest.map((rendered) => {
|
|
314
|
-
const indented = rendered.text.split(`
|
|
315
|
-
`).map((line) => line === "" ? "" : `${indent}${line}`).join(`
|
|
316
|
-
`);
|
|
317
|
-
return rendered.isNestedList ? `
|
|
318
|
-
${indented}` : `
|
|
319
|
-
|
|
320
|
-
${indented}`;
|
|
321
|
-
}).join("");
|
|
322
|
-
return `${head}${tail}`;
|
|
323
|
-
}).join(itemSeparator);
|
|
271
|
+
let prefixed = value.content.map((block, index) => renderNode({
|
|
272
|
+
node: {
|
|
273
|
+
...block,
|
|
274
|
+
style: "normal"
|
|
275
|
+
},
|
|
276
|
+
index,
|
|
277
|
+
isInline: !1,
|
|
278
|
+
renderNode
|
|
279
|
+
})).join("\n\n").split("\n").map((line) => line === "" ? ">" : `> ${line}`).join("\n");
|
|
280
|
+
return `> [!${value.tone.toUpperCase()}]\n${prefixed}`;
|
|
281
|
+
}, DefaultBlockquoteObjectRenderer = ({ value, renderNode }) => value.content.map((block, index) => renderNode({
|
|
282
|
+
node: {
|
|
283
|
+
...block,
|
|
284
|
+
style: "normal"
|
|
285
|
+
},
|
|
286
|
+
index,
|
|
287
|
+
isInline: !1,
|
|
288
|
+
renderNode
|
|
289
|
+
})).join("\n\n").split("\n").map((line) => line === "" ? ">" : `> ${line}`).join("\n"), DefaultListRenderer = ({ value, renderNode }) => {
|
|
290
|
+
let itemSeparator = value.items.some((item) => item.content.filter((block) => block._type !== "list").length > 1) ? "\n\n" : "\n";
|
|
291
|
+
return value.items.map((item, itemIndex) => {
|
|
292
|
+
let marker = getListMarker(value.kind, itemIndex, item.checked), indentWidth = value.kind === "task" ? 2 : marker.length, indent = " ".repeat(indentWidth), [first, ...rest] = item.content.map((block, blockIndex) => ({
|
|
293
|
+
isNestedList: block._type === "list",
|
|
294
|
+
text: renderNode({
|
|
295
|
+
node: block,
|
|
296
|
+
index: blockIndex,
|
|
297
|
+
isInline: !1,
|
|
298
|
+
renderNode
|
|
299
|
+
})
|
|
300
|
+
})), head = `${marker}${first?.text ?? ""}`.trimEnd();
|
|
301
|
+
return rest.length === 0 ? head : `${head}${rest.map((rendered) => {
|
|
302
|
+
let indented = rendered.text.split("\n").map((line) => line === "" ? "" : `${indent}${line}`).join("\n");
|
|
303
|
+
return rendered.isNestedList ? `\n${indented}` : `\n\n${indented}`;
|
|
304
|
+
}).join("")}`;
|
|
305
|
+
}).join(itemSeparator);
|
|
324
306
|
};
|
|
325
307
|
function getListMarker(kind, itemIndex, checked) {
|
|
326
|
-
|
|
308
|
+
return kind === "number" ? `${itemIndex + 1}. ` : kind === "task" ? checked ? "- [x] " : "- [ ] " : "- ";
|
|
327
309
|
}
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
}) => {
|
|
332
|
-
|
|
333
|
-
${
|
|
334
|
-
\`\`\``;
|
|
335
|
-
return isInline ? `
|
|
336
|
-
${json}
|
|
337
|
-
` : json;
|
|
310
|
+
/**
|
|
311
|
+
* @public
|
|
312
|
+
*/
|
|
313
|
+
const DefaultUnknownTypeRenderer = ({ value, isInline }) => {
|
|
314
|
+
let json = `\`\`\`json\n${JSON.stringify(value, null, 2)}\n\`\`\``;
|
|
315
|
+
return isInline ? `\n${json}\n` : json;
|
|
338
316
|
}, defaultRenderers = {
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
317
|
+
types: {},
|
|
318
|
+
block: {
|
|
319
|
+
normal: DefaultNormalRenderer,
|
|
320
|
+
blockquote: DefaultBlockquoteRenderer,
|
|
321
|
+
h1: DefaultH1Renderer,
|
|
322
|
+
h2: DefaultH2Renderer,
|
|
323
|
+
h3: DefaultH3Renderer,
|
|
324
|
+
h4: DefaultH4Renderer,
|
|
325
|
+
h5: DefaultH5Renderer,
|
|
326
|
+
h6: DefaultH6Renderer
|
|
327
|
+
},
|
|
328
|
+
marks: {
|
|
329
|
+
em: DefaultEmRenderer,
|
|
330
|
+
strong: DefaultStrongRenderer,
|
|
331
|
+
code: DefaultCodeRenderer,
|
|
332
|
+
underline: DefaultUnderlineRenderer,
|
|
333
|
+
"strike-through": DefaultStrikeThroughRenderer,
|
|
334
|
+
link: DefaultLinkRenderer
|
|
335
|
+
},
|
|
336
|
+
listItem: DefaultListItemRenderer,
|
|
337
|
+
hardBreak: DefaultHardBreakRenderer,
|
|
338
|
+
unknownType: DefaultUnknownTypeRenderer,
|
|
339
|
+
unknownMark: DefaultUnknownMarkRenderer,
|
|
340
|
+
unknownListItem: DefaultUnknownListItemRenderer,
|
|
341
|
+
unknownBlockStyle: DefaultUnknownStyleRenderer
|
|
364
342
|
};
|
|
343
|
+
/**
|
|
344
|
+
* @public
|
|
345
|
+
*/
|
|
365
346
|
function portableTextToMarkdown(blocks, options = {}) {
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
next: nextNode
|
|
401
|
-
}) ?? `
|
|
402
|
-
|
|
403
|
-
`;
|
|
404
|
-
return `${renderedNode}${blockSpacing}`;
|
|
405
|
-
}).join("");
|
|
347
|
+
let renderers = {
|
|
348
|
+
block: {
|
|
349
|
+
...defaultRenderers.block,
|
|
350
|
+
...options.block
|
|
351
|
+
},
|
|
352
|
+
listItem: options.listItem ?? defaultRenderers.listItem,
|
|
353
|
+
marks: {
|
|
354
|
+
...defaultRenderers.marks,
|
|
355
|
+
...options.marks
|
|
356
|
+
},
|
|
357
|
+
types: {
|
|
358
|
+
...defaultRenderers.types,
|
|
359
|
+
...options.types
|
|
360
|
+
},
|
|
361
|
+
hardBreak: options.hardBreak ?? defaultRenderers.hardBreak,
|
|
362
|
+
unknownType: options.unknownType ?? defaultRenderers.unknownType,
|
|
363
|
+
unknownBlockStyle: options.unknownBlockStyle ?? defaultRenderers.unknownBlockStyle,
|
|
364
|
+
unknownListItem: options.unknownListItem ?? defaultRenderers.unknownListItem,
|
|
365
|
+
unknownMark: options.unknownMark ?? defaultRenderers.unknownMark
|
|
366
|
+
}, renderBlockSpacing = options.blockSpacing ?? DefaultBlockSpacingRenderer, listIndexMap = buildListIndexMap(blocks), renderNode = createRenderNode(renderers, listIndexMap);
|
|
367
|
+
return blocks.map((node, index) => {
|
|
368
|
+
let renderedNode = renderNode({
|
|
369
|
+
node,
|
|
370
|
+
index,
|
|
371
|
+
isInline: !1,
|
|
372
|
+
renderNode
|
|
373
|
+
});
|
|
374
|
+
if (index === blocks.length - 1) return renderedNode;
|
|
375
|
+
let nextNode = blocks.at(index + 1);
|
|
376
|
+
return nextNode ? `${renderedNode}${renderBlockSpacing({
|
|
377
|
+
current: node,
|
|
378
|
+
next: nextNode
|
|
379
|
+
}) ?? "\n\n"}` : renderedNode;
|
|
380
|
+
}).join("");
|
|
406
381
|
}
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
},
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
}, h6StyleDefinition = {
|
|
420
|
-
name: "h6"
|
|
421
|
-
}, blockquoteStyleDefinition = {
|
|
422
|
-
name: "blockquote"
|
|
423
|
-
}, defaultOrderedListItemDefinition = {
|
|
424
|
-
name: "number"
|
|
425
|
-
}, defaultUnorderedListItemDefinition = {
|
|
426
|
-
name: "bullet"
|
|
427
|
-
}, defaultTaskListItemDefinition = {
|
|
428
|
-
name: "task"
|
|
429
|
-
}, defaultStrongDecoratorDefinition = {
|
|
430
|
-
name: "strong"
|
|
431
|
-
}, defaultEmDecoratorDefinition = {
|
|
432
|
-
name: "em"
|
|
433
|
-
}, defaultCodeDecoratorDefinition = {
|
|
434
|
-
name: "code"
|
|
435
|
-
}, defaultStrikeThroughDecoratorDefinition = {
|
|
436
|
-
name: "strike-through"
|
|
437
|
-
}, defaultLinkObjectDefinition = {
|
|
438
|
-
name: "link",
|
|
439
|
-
fields: [
|
|
440
|
-
{ name: "href", type: "string" },
|
|
441
|
-
{ name: "title", type: "string" }
|
|
442
|
-
]
|
|
382
|
+
/********************
|
|
383
|
+
* Default style definitions
|
|
384
|
+
********************/
|
|
385
|
+
const normalStyleDefinition = { name: "normal" }, h1StyleDefinition = { name: "h1" }, h2StyleDefinition = { name: "h2" }, h3StyleDefinition = { name: "h3" }, h4StyleDefinition = { name: "h4" }, h5StyleDefinition = { name: "h5" }, h6StyleDefinition = { name: "h6" }, blockquoteStyleDefinition = { name: "blockquote" }, defaultOrderedListItemDefinition = { name: "number" }, defaultUnorderedListItemDefinition = { name: "bullet" }, defaultTaskListItemDefinition = { name: "task" }, defaultStrongDecoratorDefinition = { name: "strong" }, defaultEmDecoratorDefinition = { name: "em" }, defaultCodeDecoratorDefinition = { name: "code" }, defaultStrikeThroughDecoratorDefinition = { name: "strike-through" }, defaultLinkObjectDefinition = {
|
|
386
|
+
name: "link",
|
|
387
|
+
fields: [{
|
|
388
|
+
name: "href",
|
|
389
|
+
type: "string"
|
|
390
|
+
}, {
|
|
391
|
+
name: "title",
|
|
392
|
+
type: "string"
|
|
393
|
+
}]
|
|
443
394
|
}, defaultCodeObjectDefinition = {
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
395
|
+
name: "code",
|
|
396
|
+
fields: [{
|
|
397
|
+
name: "language",
|
|
398
|
+
type: "string"
|
|
399
|
+
}, {
|
|
400
|
+
name: "code",
|
|
401
|
+
type: "string"
|
|
402
|
+
}]
|
|
449
403
|
}, defaultImageObjectDefinition = {
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
404
|
+
name: "image",
|
|
405
|
+
fields: [
|
|
406
|
+
{
|
|
407
|
+
name: "src",
|
|
408
|
+
type: "string"
|
|
409
|
+
},
|
|
410
|
+
{
|
|
411
|
+
name: "alt",
|
|
412
|
+
type: "string"
|
|
413
|
+
},
|
|
414
|
+
{
|
|
415
|
+
name: "title",
|
|
416
|
+
type: "string"
|
|
417
|
+
}
|
|
418
|
+
]
|
|
419
|
+
}, defaultHorizontalRuleObjectDefinition = { name: "horizontal-rule" }, defaultHtmlObjectDefinition = {
|
|
420
|
+
name: "html",
|
|
421
|
+
fields: [{
|
|
422
|
+
name: "html",
|
|
423
|
+
type: "string"
|
|
424
|
+
}]
|
|
461
425
|
}, defaultTableObjectDefinition = {
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
426
|
+
name: "table",
|
|
427
|
+
fields: [
|
|
428
|
+
{
|
|
429
|
+
name: "headerRows",
|
|
430
|
+
type: "number"
|
|
431
|
+
},
|
|
432
|
+
{
|
|
433
|
+
name: "alignment",
|
|
434
|
+
type: "array"
|
|
435
|
+
},
|
|
436
|
+
{
|
|
437
|
+
name: "rows",
|
|
438
|
+
type: "array"
|
|
439
|
+
}
|
|
440
|
+
]
|
|
468
441
|
}, defaultCalloutObjectDefinition = {
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
442
|
+
name: "callout",
|
|
443
|
+
fields: [{
|
|
444
|
+
name: "tone",
|
|
445
|
+
type: "string"
|
|
446
|
+
}, {
|
|
447
|
+
name: "content",
|
|
448
|
+
type: "array"
|
|
449
|
+
}]
|
|
450
|
+
}, defaultSchema = compileSchema(defineSchema({
|
|
451
|
+
block: { fields: [{
|
|
452
|
+
name: "checked",
|
|
453
|
+
type: "boolean"
|
|
454
|
+
}] },
|
|
455
|
+
styles: [
|
|
456
|
+
normalStyleDefinition,
|
|
457
|
+
h1StyleDefinition,
|
|
458
|
+
h2StyleDefinition,
|
|
459
|
+
h3StyleDefinition,
|
|
460
|
+
h4StyleDefinition,
|
|
461
|
+
h5StyleDefinition,
|
|
462
|
+
h6StyleDefinition,
|
|
463
|
+
blockquoteStyleDefinition
|
|
464
|
+
],
|
|
465
|
+
lists: [
|
|
466
|
+
defaultOrderedListItemDefinition,
|
|
467
|
+
defaultUnorderedListItemDefinition,
|
|
468
|
+
defaultTaskListItemDefinition
|
|
469
|
+
],
|
|
470
|
+
decorators: [
|
|
471
|
+
defaultStrongDecoratorDefinition,
|
|
472
|
+
defaultEmDecoratorDefinition,
|
|
473
|
+
defaultCodeDecoratorDefinition,
|
|
474
|
+
defaultStrikeThroughDecoratorDefinition
|
|
475
|
+
],
|
|
476
|
+
annotations: [defaultLinkObjectDefinition],
|
|
477
|
+
blockObjects: [
|
|
478
|
+
defaultCalloutObjectDefinition,
|
|
479
|
+
defaultCodeObjectDefinition,
|
|
480
|
+
defaultHorizontalRuleObjectDefinition,
|
|
481
|
+
defaultHtmlObjectDefinition,
|
|
482
|
+
defaultImageObjectDefinition,
|
|
483
|
+
defaultTableObjectDefinition
|
|
484
|
+
],
|
|
485
|
+
inlineObjects: [defaultImageObjectDefinition]
|
|
486
|
+
}));
|
|
512
487
|
function buildStyleMatcher(definition) {
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
if (schemaDefinition)
|
|
518
|
-
return schemaDefinition.name;
|
|
519
|
-
};
|
|
488
|
+
return ({ context }) => {
|
|
489
|
+
let schemaDefinition = context.schema.styles.find((item) => item.name === definition.name);
|
|
490
|
+
if (schemaDefinition) return schemaDefinition.name;
|
|
491
|
+
};
|
|
520
492
|
}
|
|
521
493
|
function buildListItemMatcher(definition) {
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
if (schemaDefinition)
|
|
527
|
-
return schemaDefinition.name;
|
|
528
|
-
};
|
|
494
|
+
return ({ context }) => {
|
|
495
|
+
let schemaDefinition = context.schema.lists.find((item) => item.name === definition.name);
|
|
496
|
+
if (schemaDefinition) return schemaDefinition.name;
|
|
497
|
+
};
|
|
529
498
|
}
|
|
530
499
|
function buildDecoratorMatcher(definition) {
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
if (schemaDefinition)
|
|
536
|
-
return schemaDefinition.name;
|
|
537
|
-
};
|
|
500
|
+
return ({ context }) => {
|
|
501
|
+
let schemaDefinition = context.schema.decorators.find((item) => item.name === definition.name);
|
|
502
|
+
if (schemaDefinition) return schemaDefinition.name;
|
|
503
|
+
};
|
|
538
504
|
}
|
|
539
505
|
function buildAnnotationMatcher(definition) {
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
...filteredValue
|
|
554
|
-
};
|
|
555
|
-
};
|
|
506
|
+
return ({ context, value }) => {
|
|
507
|
+
let schemaDefinition = context.schema.annotations.find((item) => item.name === definition.name);
|
|
508
|
+
if (!schemaDefinition) return;
|
|
509
|
+
let filteredValue = schemaDefinition.fields.reduce((filteredValue, field) => {
|
|
510
|
+
let fieldValue = value[field.name];
|
|
511
|
+
return fieldValue !== void 0 && (filteredValue[field.name] = fieldValue), filteredValue;
|
|
512
|
+
}, {});
|
|
513
|
+
return {
|
|
514
|
+
_key: context.keyGenerator(),
|
|
515
|
+
_type: schemaDefinition.name,
|
|
516
|
+
...filteredValue
|
|
517
|
+
};
|
|
518
|
+
};
|
|
556
519
|
}
|
|
557
520
|
function buildObjectMatcher(definition) {
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
...filteredValue
|
|
572
|
-
};
|
|
573
|
-
};
|
|
521
|
+
return ({ context, value, isInline }) => {
|
|
522
|
+
let schemaDefinition = (isInline ? context.schema.inlineObjects : context.schema.blockObjects).find((item) => item.name === definition.name);
|
|
523
|
+
if (!schemaDefinition) return;
|
|
524
|
+
let filteredValue = schemaDefinition.fields.reduce((filteredValue, field) => {
|
|
525
|
+
let fieldValue = value[field.name];
|
|
526
|
+
return fieldValue !== void 0 && (filteredValue[field.name] = fieldValue), filteredValue;
|
|
527
|
+
}, {});
|
|
528
|
+
return {
|
|
529
|
+
_key: context.keyGenerator(),
|
|
530
|
+
_type: schemaDefinition.name,
|
|
531
|
+
...filteredValue
|
|
532
|
+
};
|
|
533
|
+
};
|
|
574
534
|
}
|
|
575
535
|
const codeBlockMatcher = ({ context, value, isInline }) => {
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
536
|
+
let codeObject = buildObjectMatcher(defaultCodeObjectDefinition)({
|
|
537
|
+
context,
|
|
538
|
+
value,
|
|
539
|
+
isInline
|
|
540
|
+
});
|
|
541
|
+
if (codeObject && "code" in codeObject) return codeObject;
|
|
579
542
|
}, imageBlockMatcher = ({ context, value, isInline }) => {
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
543
|
+
let imageObject = buildObjectMatcher(defaultImageObjectDefinition)({
|
|
544
|
+
context,
|
|
545
|
+
value,
|
|
546
|
+
isInline
|
|
547
|
+
});
|
|
548
|
+
if (imageObject && "src" in imageObject) return imageObject;
|
|
583
549
|
}, defaultOptions = {
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
550
|
+
schema: defaultSchema,
|
|
551
|
+
keyGenerator: defaultKeyGenerator,
|
|
552
|
+
html: { inline: "skip" },
|
|
553
|
+
block: {
|
|
554
|
+
normal: buildStyleMatcher(normalStyleDefinition),
|
|
555
|
+
blockquote: buildStyleMatcher(blockquoteStyleDefinition),
|
|
556
|
+
h1: buildStyleMatcher(h1StyleDefinition),
|
|
557
|
+
h2: buildStyleMatcher(h2StyleDefinition),
|
|
558
|
+
h3: buildStyleMatcher(h3StyleDefinition),
|
|
559
|
+
h4: buildStyleMatcher(h4StyleDefinition),
|
|
560
|
+
h5: buildStyleMatcher(h5StyleDefinition),
|
|
561
|
+
h6: buildStyleMatcher(h6StyleDefinition)
|
|
562
|
+
},
|
|
563
|
+
listItem: {
|
|
564
|
+
number: buildListItemMatcher(defaultOrderedListItemDefinition),
|
|
565
|
+
bullet: buildListItemMatcher(defaultUnorderedListItemDefinition),
|
|
566
|
+
task: buildListItemMatcher(defaultTaskListItemDefinition)
|
|
567
|
+
},
|
|
568
|
+
marks: {
|
|
569
|
+
strong: buildDecoratorMatcher(defaultStrongDecoratorDefinition),
|
|
570
|
+
em: buildDecoratorMatcher(defaultEmDecoratorDefinition),
|
|
571
|
+
code: buildDecoratorMatcher(defaultCodeDecoratorDefinition),
|
|
572
|
+
strikeThrough: buildDecoratorMatcher(defaultStrikeThroughDecoratorDefinition),
|
|
573
|
+
link: buildAnnotationMatcher(defaultLinkObjectDefinition)
|
|
574
|
+
},
|
|
575
|
+
types: {
|
|
576
|
+
code: codeBlockMatcher,
|
|
577
|
+
horizontalRule: buildObjectMatcher(defaultHorizontalRuleObjectDefinition),
|
|
578
|
+
html: buildObjectMatcher(defaultHtmlObjectDefinition),
|
|
579
|
+
image: imageBlockMatcher,
|
|
580
|
+
callout: buildObjectMatcher(defaultCalloutObjectDefinition)
|
|
581
|
+
}
|
|
615
582
|
};
|
|
583
|
+
/**
|
|
584
|
+
* Reads GFM column alignment from a markdown-it cell token's `style`
|
|
585
|
+
* attribute. Tolerates other CSS declarations sharing the value.
|
|
586
|
+
*/
|
|
616
587
|
function extractAlignmentFromStyleAttr(styleAttr) {
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
return match ? match[1] : null;
|
|
588
|
+
if (!styleAttr) return null;
|
|
589
|
+
let match = styleAttr.match(/text-align\s*:\s*(left|center|right)/);
|
|
590
|
+
return match ? match[1] : null;
|
|
621
591
|
}
|
|
592
|
+
/**
|
|
593
|
+
* A table row is empty when every cell holds only blank spans, no non-empty
|
|
594
|
+
* text, no inline objects, no non-text blocks. Used to detect a headerless
|
|
595
|
+
* GFM table: `portableTextToMarkdown` emits an empty header row for
|
|
596
|
+
* `headerRows: 0`, and an empty header must round-trip back to
|
|
597
|
+
* `headerRows: 0` rather than a phantom header row.
|
|
598
|
+
*/
|
|
622
599
|
function isEmptyTableRow(cells, context) {
|
|
623
|
-
|
|
624
|
-
(cell) => cell.value.every(
|
|
625
|
-
(block) => isTextBlock(context, block) && block.children.every(
|
|
626
|
-
(child) => isSpan(context, child) && (child.text ?? "").trim() === ""
|
|
627
|
-
)
|
|
628
|
-
)
|
|
629
|
-
);
|
|
600
|
+
return cells.every((cell) => cell.value.every((block) => isTextBlock(context, block) && block.children.every((child) => isSpan(context, child) && (child.text ?? "").trim() === "")));
|
|
630
601
|
}
|
|
602
|
+
/**
|
|
603
|
+
* Flattens a table structure by lifting all blocks from all cells.
|
|
604
|
+
*/
|
|
631
605
|
function flattenTable(table, portableText) {
|
|
632
|
-
|
|
633
|
-
for (const cell of row.cells)
|
|
634
|
-
for (const block of cell.value)
|
|
635
|
-
portableText.push(block);
|
|
606
|
+
for (let row of table.rows) for (let cell of row.cells) for (let block of cell.value) portableText.push(block);
|
|
636
607
|
}
|
|
608
|
+
/**
|
|
609
|
+
* Converts a markdown string to an array of Portable Text blocks.
|
|
610
|
+
*
|
|
611
|
+
* @public
|
|
612
|
+
*/
|
|
637
613
|
function markdownToPortableText(markdown, options) {
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
index !== -1 && markDefRefs.splice(index, 1);
|
|
1289
|
-
break;
|
|
1290
|
-
}
|
|
1291
|
-
case "s_open": {
|
|
1292
|
-
const decorator = consolidatedOptions.marks.strikeThrough({
|
|
1293
|
-
context: { schema: consolidatedOptions.schema }
|
|
1294
|
-
});
|
|
1295
|
-
if (!decorator)
|
|
1296
|
-
break;
|
|
1297
|
-
markDefRefs.push(decorator);
|
|
1298
|
-
break;
|
|
1299
|
-
}
|
|
1300
|
-
case "s_close": {
|
|
1301
|
-
const decorator = consolidatedOptions.marks.strikeThrough({
|
|
1302
|
-
context: { schema: consolidatedOptions.schema }
|
|
1303
|
-
});
|
|
1304
|
-
if (!decorator)
|
|
1305
|
-
break;
|
|
1306
|
-
const index = markDefRefs.lastIndexOf(decorator);
|
|
1307
|
-
index !== -1 && markDefRefs.splice(index, 1);
|
|
1308
|
-
break;
|
|
1309
|
-
}
|
|
1310
|
-
case "link_open": {
|
|
1311
|
-
const href = childToken.attrs?.find(([name]) => name === "href")?.at(1);
|
|
1312
|
-
if (!href)
|
|
1313
|
-
break;
|
|
1314
|
-
const title = childToken.attrs?.find(([name]) => name === "title")?.at(1), linkObject = consolidatedOptions.marks.link({
|
|
1315
|
-
context: {
|
|
1316
|
-
schema: consolidatedOptions.schema,
|
|
1317
|
-
keyGenerator: consolidatedOptions.keyGenerator
|
|
1318
|
-
},
|
|
1319
|
-
value: { href, title }
|
|
1320
|
-
});
|
|
1321
|
-
if (!linkObject)
|
|
1322
|
-
break;
|
|
1323
|
-
currentMarkDefs.push(linkObject), markDefRefs.push(linkObject._key);
|
|
1324
|
-
break;
|
|
1325
|
-
}
|
|
1326
|
-
case "link_close": {
|
|
1327
|
-
const markDefKeys = new Set(currentMarkDefs.map((d) => d._key));
|
|
1328
|
-
let lastLinkIndex;
|
|
1329
|
-
for (const markDefRef of markDefRefs.reverse())
|
|
1330
|
-
if (markDefKeys.has(markDefRef)) {
|
|
1331
|
-
lastLinkIndex = markDefRefs.indexOf(markDefRef);
|
|
1332
|
-
break;
|
|
1333
|
-
}
|
|
1334
|
-
if (lastLinkIndex !== void 0) {
|
|
1335
|
-
const realIndex = markDefRefs.length - 1 - lastLinkIndex;
|
|
1336
|
-
markDefRefs.splice(realIndex, 1);
|
|
1337
|
-
}
|
|
1338
|
-
break;
|
|
1339
|
-
}
|
|
1340
|
-
case "image": {
|
|
1341
|
-
const src = childToken.attrs?.find(([name]) => name === "src")?.at(1) || "", alt = unescapeImageAndLinkText(childToken.content || ""), inlineImageObject = consolidatedOptions.types.image({
|
|
1342
|
-
context: {
|
|
1343
|
-
schema: consolidatedOptions.schema,
|
|
1344
|
-
keyGenerator: consolidatedOptions.keyGenerator
|
|
1345
|
-
},
|
|
1346
|
-
value: { src, alt, title: void 0 },
|
|
1347
|
-
isInline: !0
|
|
1348
|
-
});
|
|
1349
|
-
if (inlineImageObject) {
|
|
1350
|
-
if (!currentBlock) {
|
|
1351
|
-
const style2 = consolidatedOptions.block.normal({
|
|
1352
|
-
context: { schema: consolidatedOptions.schema }
|
|
1353
|
-
});
|
|
1354
|
-
style2 ? startBlock(style2) : (console.warn('No default style found, using "normal"'), startBlock("normal"));
|
|
1355
|
-
}
|
|
1356
|
-
if (!currentBlock)
|
|
1357
|
-
throw new Error("Expected current block after startBlock");
|
|
1358
|
-
currentBlock.children.push(
|
|
1359
|
-
inlineImageObject
|
|
1360
|
-
);
|
|
1361
|
-
break;
|
|
1362
|
-
}
|
|
1363
|
-
const blockImageObject = consolidatedOptions.types.image({
|
|
1364
|
-
context: {
|
|
1365
|
-
schema: consolidatedOptions.schema,
|
|
1366
|
-
keyGenerator: consolidatedOptions.keyGenerator
|
|
1367
|
-
},
|
|
1368
|
-
value: { src, alt, title: void 0 },
|
|
1369
|
-
isInline: !1
|
|
1370
|
-
});
|
|
1371
|
-
if (!blockImageObject) {
|
|
1372
|
-
addSpan(``);
|
|
1373
|
-
break;
|
|
1374
|
-
}
|
|
1375
|
-
if (inTableCell) {
|
|
1376
|
-
currentBlock && "children" in currentBlock && currentBlock.children.push(
|
|
1377
|
-
blockImageObject
|
|
1378
|
-
);
|
|
1379
|
-
break;
|
|
1380
|
-
}
|
|
1381
|
-
flushBlock(), pushBlock(blockImageObject);
|
|
1382
|
-
const style = consolidatedOptions.block.normal({
|
|
1383
|
-
context: { schema: consolidatedOptions.schema }
|
|
1384
|
-
});
|
|
1385
|
-
style && startBlock(style);
|
|
1386
|
-
break;
|
|
1387
|
-
}
|
|
1388
|
-
case "html_inline": {
|
|
1389
|
-
consolidatedOptions.html.inline === "text" && addSpan(childToken.content);
|
|
1390
|
-
break;
|
|
1391
|
-
}
|
|
1392
|
-
}
|
|
1393
|
-
break;
|
|
1394
|
-
}
|
|
1395
|
-
// Callouts (GFM alerts)
|
|
1396
|
-
case "alert_open": {
|
|
1397
|
-
flushBlock(), calloutStartTarget = blockTarget(), calloutStartIndex = calloutStartTarget.length, calloutType = token.markup, currentBlockquoteStyle = consolidatedOptions.block.blockquote({
|
|
1398
|
-
context: { schema: consolidatedOptions.schema }
|
|
1399
|
-
}) ?? consolidatedOptions.block.normal({
|
|
1400
|
-
context: { schema: consolidatedOptions.schema }
|
|
1401
|
-
}) ?? "normal";
|
|
1402
|
-
break;
|
|
1403
|
-
}
|
|
1404
|
-
case "alert_title":
|
|
1405
|
-
break;
|
|
1406
|
-
case "alert_close": {
|
|
1407
|
-
if (flushBlock(), calloutStartIndex !== null && calloutType !== null && calloutStartTarget !== null) {
|
|
1408
|
-
const contentBlocks = calloutStartTarget.splice(
|
|
1409
|
-
calloutStartIndex
|
|
1410
|
-
), calloutObject = consolidatedOptions.types.callout?.({
|
|
1411
|
-
context: {
|
|
1412
|
-
schema: consolidatedOptions.schema,
|
|
1413
|
-
keyGenerator: consolidatedOptions.keyGenerator
|
|
1414
|
-
},
|
|
1415
|
-
value: { tone: calloutType, content: contentBlocks },
|
|
1416
|
-
isInline: !1
|
|
1417
|
-
});
|
|
1418
|
-
if (calloutObject)
|
|
1419
|
-
pushBlock(calloutObject);
|
|
1420
|
-
else
|
|
1421
|
-
for (const block of contentBlocks)
|
|
1422
|
-
pushBlock(block);
|
|
1423
|
-
}
|
|
1424
|
-
calloutStartIndex = null, calloutStartTarget = null, calloutType = null, currentBlockquoteStyle = null;
|
|
1425
|
-
break;
|
|
1426
|
-
}
|
|
1427
|
-
}
|
|
1428
|
-
}
|
|
1429
|
-
return flushBlock(), portableText;
|
|
614
|
+
let consolidatedOptions = {
|
|
615
|
+
schema: options?.schema ?? defaultSchema,
|
|
616
|
+
keyGenerator: options?.keyGenerator ?? defaultKeyGenerator,
|
|
617
|
+
html: { inline: options?.html?.inline ?? "skip" },
|
|
618
|
+
marks: {
|
|
619
|
+
...defaultOptions.marks,
|
|
620
|
+
...options?.marks
|
|
621
|
+
},
|
|
622
|
+
block: {
|
|
623
|
+
...defaultOptions.block,
|
|
624
|
+
...options?.block
|
|
625
|
+
},
|
|
626
|
+
listItem: {
|
|
627
|
+
...defaultOptions.listItem,
|
|
628
|
+
...options?.listItem
|
|
629
|
+
},
|
|
630
|
+
types: {
|
|
631
|
+
...defaultOptions.types,
|
|
632
|
+
...options?.types
|
|
633
|
+
}
|
|
634
|
+
}, tokens = markdownit({
|
|
635
|
+
html: !0,
|
|
636
|
+
linkify: !0,
|
|
637
|
+
typographer: !1
|
|
638
|
+
}).enable(["strikethrough", "table"]).use(alert).parse(markdown, {}), taskCheckedByListItemIndex = /* @__PURE__ */ new Map();
|
|
639
|
+
for (let i = 0; i < tokens.length; i++) {
|
|
640
|
+
if (tokens[i]?.type !== "list_item_open") continue;
|
|
641
|
+
let inlineIndex = -1;
|
|
642
|
+
for (let j = i + 1; j < tokens.length; j++) {
|
|
643
|
+
let candidate = tokens[j];
|
|
644
|
+
if (candidate) {
|
|
645
|
+
if (candidate.type === "list_item_close") break;
|
|
646
|
+
if (candidate.type === "inline") {
|
|
647
|
+
inlineIndex = j;
|
|
648
|
+
break;
|
|
649
|
+
}
|
|
650
|
+
}
|
|
651
|
+
}
|
|
652
|
+
if (inlineIndex === -1) continue;
|
|
653
|
+
let inlineToken = tokens[inlineIndex];
|
|
654
|
+
if (!inlineToken) continue;
|
|
655
|
+
let match = inlineToken.content.match(/^\[([ xX])\] /);
|
|
656
|
+
if (!match) continue;
|
|
657
|
+
let checked = match[1] !== " ";
|
|
658
|
+
taskCheckedByListItemIndex.set(i, checked), inlineToken.content = inlineToken.content.slice(match[0].length);
|
|
659
|
+
let firstChild = inlineToken.children?.[0];
|
|
660
|
+
firstChild && typeof firstChild.content == "string" && (firstChild.content = firstChild.content.slice(match[0].length));
|
|
661
|
+
}
|
|
662
|
+
let portableText = [], currentBlock = null, currentListStack = [], markDefRefs = [], currentMarkDefs = [], currentBlockquoteStyle = null, inListItem = !1, calloutStartIndex = null, calloutStartTarget = null, calloutType = null, blockquoteStack = [], currentTable = null, currentTableRow = null, inTableHead = !1, listContainerStack = [], blockTarget = () => {
|
|
663
|
+
for (let i = listContainerStack.length - 1; i >= 0; i--) {
|
|
664
|
+
let frame = listContainerStack[i];
|
|
665
|
+
if (frame && frame.currentItem) return frame.currentItem.content;
|
|
666
|
+
}
|
|
667
|
+
return portableText;
|
|
668
|
+
}, pushBlock = (block) => {
|
|
669
|
+
blockTarget().push(block);
|
|
670
|
+
}, startBlock = (style) => {
|
|
671
|
+
flushBlock(), currentBlock = {
|
|
672
|
+
_type: "block",
|
|
673
|
+
style,
|
|
674
|
+
children: [],
|
|
675
|
+
_key: consolidatedOptions.keyGenerator(),
|
|
676
|
+
markDefs: []
|
|
677
|
+
}, currentMarkDefs = [];
|
|
678
|
+
}, flushBlock = () => {
|
|
679
|
+
currentBlock && (currentBlock.children.length === 0 && currentBlock.children.push({
|
|
680
|
+
_type: consolidatedOptions.schema.span.name,
|
|
681
|
+
_key: consolidatedOptions.keyGenerator(),
|
|
682
|
+
text: "",
|
|
683
|
+
marks: []
|
|
684
|
+
}), currentBlock.markDefs = currentMarkDefs, pushBlock(currentBlock), currentBlock = null, currentMarkDefs = []);
|
|
685
|
+
}, addSpan = (text) => {
|
|
686
|
+
if (text.length === 0) return;
|
|
687
|
+
if (!currentBlock) {
|
|
688
|
+
let style = currentBlockquoteStyle ?? consolidatedOptions.block.normal({ context: { schema: consolidatedOptions.schema } });
|
|
689
|
+
style ? startBlock(style) : (console.warn("No default style found, using \"normal\""), startBlock("normal"));
|
|
690
|
+
}
|
|
691
|
+
if (!currentBlock) throw Error("Expected current block");
|
|
692
|
+
let lastChild = currentBlock.children.at(-1);
|
|
693
|
+
isSpan({ schema: consolidatedOptions.schema }, lastChild) && lastChild.marks?.every((mark) => markDefRefs.includes(mark)) && markDefRefs.every((mark) => lastChild.marks?.includes(mark)) ? lastChild.text += text : currentBlock.children.push({
|
|
694
|
+
_type: consolidatedOptions.schema.span.name,
|
|
695
|
+
_key: consolidatedOptions.keyGenerator(),
|
|
696
|
+
text,
|
|
697
|
+
marks: [...markDefRefs]
|
|
698
|
+
});
|
|
699
|
+
}, listLevel = () => currentListStack.length, ensureListBlock = (listItem, checked) => {
|
|
700
|
+
if (!currentBlock) {
|
|
701
|
+
let style = currentBlockquoteStyle ?? consolidatedOptions.block.normal({ context: { schema: consolidatedOptions.schema } });
|
|
702
|
+
style ? startBlock(style) : (console.warn("No default style found, using \"normal\""), startBlock("normal"));
|
|
703
|
+
}
|
|
704
|
+
if (!currentBlock) throw Error("Expected current block");
|
|
705
|
+
(currentBlock.listItem !== listItem || currentBlock.level !== listLevel()) && (currentBlock.listItem = listItem, currentBlock.level = listLevel()), checked !== void 0 && (currentBlock.checked = checked);
|
|
706
|
+
};
|
|
707
|
+
for (let tokenIndex = 0; tokenIndex < tokens.length; tokenIndex++) {
|
|
708
|
+
let token = tokens[tokenIndex];
|
|
709
|
+
if (token) switch (token.type) {
|
|
710
|
+
case "paragraph_open": {
|
|
711
|
+
if (inListItem) {
|
|
712
|
+
if (listContainerStack.at(-1)) {
|
|
713
|
+
currentBlock || startBlock(currentBlockquoteStyle ?? consolidatedOptions.block.normal({ context: { schema: consolidatedOptions.schema } }) ?? "normal");
|
|
714
|
+
break;
|
|
715
|
+
}
|
|
716
|
+
if (!currentBlock) {
|
|
717
|
+
let listType = currentListStack.at(-1);
|
|
718
|
+
listType && ensureListBlock(listType);
|
|
719
|
+
}
|
|
720
|
+
break;
|
|
721
|
+
}
|
|
722
|
+
let style = currentBlockquoteStyle ?? consolidatedOptions.block.normal({ context: { schema: consolidatedOptions.schema } });
|
|
723
|
+
if (!style) {
|
|
724
|
+
console.warn("No default style found, using \"normal\""), startBlock("normal");
|
|
725
|
+
break;
|
|
726
|
+
}
|
|
727
|
+
startBlock(style);
|
|
728
|
+
break;
|
|
729
|
+
}
|
|
730
|
+
case "paragraph_close":
|
|
731
|
+
if (inListItem) {
|
|
732
|
+
listContainerStack.at(-1) && flushBlock();
|
|
733
|
+
break;
|
|
734
|
+
}
|
|
735
|
+
flushBlock();
|
|
736
|
+
break;
|
|
737
|
+
case "heading_open": {
|
|
738
|
+
let level = Number(token?.tag?.slice(1)), headingMatcher = {
|
|
739
|
+
1: consolidatedOptions.block.h1,
|
|
740
|
+
2: consolidatedOptions.block.h2,
|
|
741
|
+
3: consolidatedOptions.block.h3,
|
|
742
|
+
4: consolidatedOptions.block.h4,
|
|
743
|
+
5: consolidatedOptions.block.h5,
|
|
744
|
+
6: consolidatedOptions.block.h6
|
|
745
|
+
}[level], style = headingMatcher?.({ context: { schema: consolidatedOptions.schema } }) ?? consolidatedOptions.block.normal({ context: { schema: consolidatedOptions.schema } });
|
|
746
|
+
if (!style) {
|
|
747
|
+
console.warn("No heading style found, using \"normal\""), startBlock("normal");
|
|
748
|
+
break;
|
|
749
|
+
}
|
|
750
|
+
startBlock(style);
|
|
751
|
+
break;
|
|
752
|
+
}
|
|
753
|
+
case "heading_close":
|
|
754
|
+
flushBlock();
|
|
755
|
+
break;
|
|
756
|
+
case "blockquote_open":
|
|
757
|
+
if (flushBlock(), consolidatedOptions.types.blockquote) {
|
|
758
|
+
let startTarget = blockTarget();
|
|
759
|
+
blockquoteStack.push({
|
|
760
|
+
startTarget,
|
|
761
|
+
startIndex: startTarget.length
|
|
762
|
+
});
|
|
763
|
+
break;
|
|
764
|
+
}
|
|
765
|
+
currentBlockquoteStyle = consolidatedOptions.block.blockquote({ context: { schema: consolidatedOptions.schema } }) ?? consolidatedOptions.block.normal({ context: { schema: consolidatedOptions.schema } }) ?? "normal";
|
|
766
|
+
break;
|
|
767
|
+
case "blockquote_close":
|
|
768
|
+
if (flushBlock(), consolidatedOptions.types.blockquote && blockquoteStack.length > 0) {
|
|
769
|
+
let frame = blockquoteStack.pop();
|
|
770
|
+
if (frame) {
|
|
771
|
+
let contentBlocks = frame.startTarget.splice(frame.startIndex), blockquoteObject = consolidatedOptions.types.blockquote({
|
|
772
|
+
context: {
|
|
773
|
+
schema: consolidatedOptions.schema,
|
|
774
|
+
keyGenerator: consolidatedOptions.keyGenerator
|
|
775
|
+
},
|
|
776
|
+
value: { content: contentBlocks },
|
|
777
|
+
isInline: !1
|
|
778
|
+
});
|
|
779
|
+
if (blockquoteObject) pushBlock(blockquoteObject);
|
|
780
|
+
else {
|
|
781
|
+
let blockquoteStyle = consolidatedOptions.block.blockquote({ context: { schema: consolidatedOptions.schema } }) ?? consolidatedOptions.block.normal({ context: { schema: consolidatedOptions.schema } }) ?? "blockquote";
|
|
782
|
+
for (let block of contentBlocks) block._type === "block" ? pushBlock({
|
|
783
|
+
...block,
|
|
784
|
+
style: blockquoteStyle
|
|
785
|
+
}) : pushBlock(block);
|
|
786
|
+
}
|
|
787
|
+
}
|
|
788
|
+
break;
|
|
789
|
+
}
|
|
790
|
+
currentBlockquoteStyle = null;
|
|
791
|
+
break;
|
|
792
|
+
case "bullet_list_open": {
|
|
793
|
+
if (flushBlock(), consolidatedOptions.types.list) {
|
|
794
|
+
listContainerStack.push({
|
|
795
|
+
kind: "bullet",
|
|
796
|
+
items: [],
|
|
797
|
+
currentItem: null
|
|
798
|
+
}), currentListStack.push(null);
|
|
799
|
+
break;
|
|
800
|
+
}
|
|
801
|
+
let listItem = consolidatedOptions.listItem.bullet({ context: { schema: consolidatedOptions.schema } });
|
|
802
|
+
if (listContainerStack.push(null), !listItem) {
|
|
803
|
+
currentListStack.push(null);
|
|
804
|
+
break;
|
|
805
|
+
}
|
|
806
|
+
currentListStack.push(listItem);
|
|
807
|
+
break;
|
|
808
|
+
}
|
|
809
|
+
case "ordered_list_open": {
|
|
810
|
+
if (flushBlock(), consolidatedOptions.types.list) {
|
|
811
|
+
listContainerStack.push({
|
|
812
|
+
kind: "number",
|
|
813
|
+
items: [],
|
|
814
|
+
currentItem: null
|
|
815
|
+
}), currentListStack.push(null);
|
|
816
|
+
break;
|
|
817
|
+
}
|
|
818
|
+
let listItem = consolidatedOptions.listItem.number({ context: { schema: consolidatedOptions.schema } });
|
|
819
|
+
if (listContainerStack.push(null), !listItem) {
|
|
820
|
+
currentListStack.push(null);
|
|
821
|
+
break;
|
|
822
|
+
}
|
|
823
|
+
currentListStack.push(listItem);
|
|
824
|
+
break;
|
|
825
|
+
}
|
|
826
|
+
case "bullet_list_close":
|
|
827
|
+
case "ordered_list_close": {
|
|
828
|
+
let frame = listContainerStack.pop();
|
|
829
|
+
if (currentListStack.pop(), frame && consolidatedOptions.types.list) {
|
|
830
|
+
let kind = frame.items.some((item) => "checked" in item) ? "task" : frame.kind, listObject = consolidatedOptions.types.list({
|
|
831
|
+
context: {
|
|
832
|
+
schema: consolidatedOptions.schema,
|
|
833
|
+
keyGenerator: consolidatedOptions.keyGenerator
|
|
834
|
+
},
|
|
835
|
+
value: {
|
|
836
|
+
kind,
|
|
837
|
+
items: frame.items
|
|
838
|
+
},
|
|
839
|
+
isInline: !1
|
|
840
|
+
});
|
|
841
|
+
if (listObject) pushBlock(listObject);
|
|
842
|
+
else {
|
|
843
|
+
let flatListItem = (kind === "task" ? consolidatedOptions.listItem.task?.({ context: { schema: consolidatedOptions.schema } }) : kind === "number" ? consolidatedOptions.listItem.number({ context: { schema: consolidatedOptions.schema } }) : consolidatedOptions.listItem.bullet({ context: { schema: consolidatedOptions.schema } })) ?? null, level = listContainerStack.length + 1;
|
|
844
|
+
for (let item of frame.items) for (let block of item.content) block._type === "block" && flatListItem !== null && !("listItem" in block) ? pushBlock({
|
|
845
|
+
...block,
|
|
846
|
+
listItem: flatListItem,
|
|
847
|
+
level,
|
|
848
|
+
...item.checked === void 0 ? {} : { checked: item.checked }
|
|
849
|
+
}) : pushBlock(block);
|
|
850
|
+
}
|
|
851
|
+
}
|
|
852
|
+
break;
|
|
853
|
+
}
|
|
854
|
+
case "list_item_open": {
|
|
855
|
+
let frame = listContainerStack.at(-1);
|
|
856
|
+
if (currentBlock && flushBlock(), frame) {
|
|
857
|
+
let taskChecked = taskCheckedByListItemIndex.get(tokenIndex);
|
|
858
|
+
frame.currentItem = {
|
|
859
|
+
_type: "list-item",
|
|
860
|
+
_key: consolidatedOptions.keyGenerator(),
|
|
861
|
+
...taskChecked === void 0 ? {} : { checked: taskChecked },
|
|
862
|
+
content: []
|
|
863
|
+
}, inListItem = !0;
|
|
864
|
+
break;
|
|
865
|
+
}
|
|
866
|
+
let baseListType = currentListStack.at(-1);
|
|
867
|
+
if (baseListType === void 0) throw Error("Expected an open list");
|
|
868
|
+
let taskChecked = taskCheckedByListItemIndex.get(tokenIndex), listType = baseListType, checked;
|
|
869
|
+
if (taskChecked !== void 0) {
|
|
870
|
+
let taskListType = consolidatedOptions.listItem.task?.({ context: { schema: consolidatedOptions.schema } });
|
|
871
|
+
taskListType && (listType = taskListType, checked = taskChecked);
|
|
872
|
+
}
|
|
873
|
+
if (listType === null) {
|
|
874
|
+
let style = currentBlockquoteStyle ?? consolidatedOptions.block.normal({ context: { schema: consolidatedOptions.schema } });
|
|
875
|
+
style ? startBlock(style) : (console.warn("No default style found, using \"normal\""), startBlock("normal")), inListItem = !0;
|
|
876
|
+
break;
|
|
877
|
+
}
|
|
878
|
+
ensureListBlock(listType, checked), inListItem = !0;
|
|
879
|
+
break;
|
|
880
|
+
}
|
|
881
|
+
case "list_item_close": {
|
|
882
|
+
let frame = listContainerStack.at(-1);
|
|
883
|
+
if (frame && frame.currentItem) {
|
|
884
|
+
flushBlock(), frame.items.push(frame.currentItem), frame.currentItem = null, inListItem = !1;
|
|
885
|
+
break;
|
|
886
|
+
}
|
|
887
|
+
inListItem = !1, flushBlock();
|
|
888
|
+
break;
|
|
889
|
+
}
|
|
890
|
+
case "fence": {
|
|
891
|
+
flushBlock();
|
|
892
|
+
let language = token.info.trim() || void 0, code = token.content.replace(/\n$/, ""), codeObject = consolidatedOptions.types.code({
|
|
893
|
+
context: {
|
|
894
|
+
schema: consolidatedOptions.schema,
|
|
895
|
+
keyGenerator: consolidatedOptions.keyGenerator
|
|
896
|
+
},
|
|
897
|
+
value: {
|
|
898
|
+
language,
|
|
899
|
+
code
|
|
900
|
+
},
|
|
901
|
+
isInline: !1
|
|
902
|
+
});
|
|
903
|
+
if (!codeObject) {
|
|
904
|
+
let style = consolidatedOptions.block.normal({ context: { schema: consolidatedOptions.schema } });
|
|
905
|
+
style ? startBlock(style) : (console.warn("No default style found, using \"normal\""), startBlock("normal")), addSpan(code), flushBlock();
|
|
906
|
+
break;
|
|
907
|
+
}
|
|
908
|
+
pushBlock(codeObject);
|
|
909
|
+
break;
|
|
910
|
+
}
|
|
911
|
+
case "hr": {
|
|
912
|
+
flushBlock();
|
|
913
|
+
let hrObject = consolidatedOptions.types.horizontalRule({
|
|
914
|
+
context: {
|
|
915
|
+
schema: consolidatedOptions.schema,
|
|
916
|
+
keyGenerator: consolidatedOptions.keyGenerator
|
|
917
|
+
},
|
|
918
|
+
value: {},
|
|
919
|
+
isInline: !1
|
|
920
|
+
});
|
|
921
|
+
if (!hrObject) {
|
|
922
|
+
let style = consolidatedOptions.block.normal({ context: { schema: consolidatedOptions.schema } });
|
|
923
|
+
style ? startBlock(style) : (console.warn("No default style found, using \"normal\""), startBlock("normal")), addSpan("---"), flushBlock();
|
|
924
|
+
break;
|
|
925
|
+
}
|
|
926
|
+
pushBlock(hrObject);
|
|
927
|
+
break;
|
|
928
|
+
}
|
|
929
|
+
case "html_block": {
|
|
930
|
+
flushBlock();
|
|
931
|
+
let htmlContent = token.content.trim();
|
|
932
|
+
if (!htmlContent) break;
|
|
933
|
+
let htmlObject = consolidatedOptions.types.html({
|
|
934
|
+
context: {
|
|
935
|
+
schema: consolidatedOptions.schema,
|
|
936
|
+
keyGenerator: consolidatedOptions.keyGenerator
|
|
937
|
+
},
|
|
938
|
+
value: { html: htmlContent },
|
|
939
|
+
isInline: !1
|
|
940
|
+
});
|
|
941
|
+
if (!htmlObject) {
|
|
942
|
+
let style = consolidatedOptions.block.normal({ context: { schema: consolidatedOptions.schema } });
|
|
943
|
+
style ? startBlock(style) : (console.warn("No default style found, using \"normal\""), startBlock("normal")), addSpan(htmlContent), flushBlock();
|
|
944
|
+
break;
|
|
945
|
+
}
|
|
946
|
+
pushBlock(htmlObject);
|
|
947
|
+
break;
|
|
948
|
+
}
|
|
949
|
+
case "code_block": {
|
|
950
|
+
flushBlock();
|
|
951
|
+
let code = token.content.replace(/\n$/, ""), codeObject = consolidatedOptions.types.code({
|
|
952
|
+
context: {
|
|
953
|
+
schema: consolidatedOptions.schema,
|
|
954
|
+
keyGenerator: consolidatedOptions.keyGenerator
|
|
955
|
+
},
|
|
956
|
+
value: {
|
|
957
|
+
language: void 0,
|
|
958
|
+
code
|
|
959
|
+
},
|
|
960
|
+
isInline: !1
|
|
961
|
+
});
|
|
962
|
+
if (codeObject) pushBlock(codeObject);
|
|
963
|
+
else {
|
|
964
|
+
let style = consolidatedOptions.block.normal({ context: { schema: consolidatedOptions.schema } });
|
|
965
|
+
style ? startBlock(style) : (console.warn("No default style found, using \"normal\""), startBlock("normal")), addSpan(code), flushBlock();
|
|
966
|
+
}
|
|
967
|
+
break;
|
|
968
|
+
}
|
|
969
|
+
case "table_open":
|
|
970
|
+
flushBlock(), currentTable = {
|
|
971
|
+
rows: [],
|
|
972
|
+
headerRows: 0,
|
|
973
|
+
emptyHeaderDropped: !1,
|
|
974
|
+
alignment: []
|
|
975
|
+
};
|
|
976
|
+
break;
|
|
977
|
+
case "table_close":
|
|
978
|
+
if (!currentTable) break;
|
|
979
|
+
if (consolidatedOptions.types.table) {
|
|
980
|
+
let hasAlignment = currentTable.alignment.some((a) => a !== null), tableObject = consolidatedOptions.types.table({
|
|
981
|
+
context: {
|
|
982
|
+
schema: consolidatedOptions.schema,
|
|
983
|
+
keyGenerator: consolidatedOptions.keyGenerator
|
|
984
|
+
},
|
|
985
|
+
value: {
|
|
986
|
+
rows: currentTable.rows,
|
|
987
|
+
headerRows: currentTable.headerRows > 0 ? currentTable.headerRows : currentTable.emptyHeaderDropped ? 0 : void 0,
|
|
988
|
+
alignment: hasAlignment ? currentTable.alignment : void 0
|
|
989
|
+
},
|
|
990
|
+
isInline: !1
|
|
991
|
+
});
|
|
992
|
+
tableObject ? pushBlock(tableObject) : flattenTable(currentTable, blockTarget());
|
|
993
|
+
} else flattenTable(currentTable, blockTarget());
|
|
994
|
+
currentTable = null;
|
|
995
|
+
break;
|
|
996
|
+
case "thead_open":
|
|
997
|
+
inTableHead = !0;
|
|
998
|
+
break;
|
|
999
|
+
case "thead_close":
|
|
1000
|
+
inTableHead = !1;
|
|
1001
|
+
break;
|
|
1002
|
+
case "tbody_open":
|
|
1003
|
+
case "tbody_close": break;
|
|
1004
|
+
case "tr_open":
|
|
1005
|
+
currentTableRow = [];
|
|
1006
|
+
break;
|
|
1007
|
+
case "tr_close":
|
|
1008
|
+
currentTable && currentTableRow && (inTableHead && isEmptyTableRow(currentTableRow, { schema: consolidatedOptions.schema }) ? currentTable.emptyHeaderDropped = !0 : (currentTable.rows.push({
|
|
1009
|
+
_key: consolidatedOptions.keyGenerator(),
|
|
1010
|
+
_type: "row",
|
|
1011
|
+
cells: currentTableRow
|
|
1012
|
+
}), inTableHead && currentTable.headerRows++)), currentTableRow = null;
|
|
1013
|
+
break;
|
|
1014
|
+
case "th_open":
|
|
1015
|
+
case "td_open": {
|
|
1016
|
+
currentTable && inTableHead && token.type === "th_open" && currentTable.alignment.push(extractAlignmentFromStyleAttr(token.attrGet("style")));
|
|
1017
|
+
let style = consolidatedOptions.block.normal({ context: { schema: consolidatedOptions.schema } });
|
|
1018
|
+
style ? startBlock(style) : (console.warn("No default style found, using \"normal\""), startBlock("normal"));
|
|
1019
|
+
break;
|
|
1020
|
+
}
|
|
1021
|
+
case "th_close":
|
|
1022
|
+
case "td_close": {
|
|
1023
|
+
flushBlock();
|
|
1024
|
+
let cellBlocks = [], target = blockTarget();
|
|
1025
|
+
if (target.length > 0) {
|
|
1026
|
+
let lastBlock = target.at(-1);
|
|
1027
|
+
lastBlock && lastBlock._type === "block" && cellBlocks.push(target.pop());
|
|
1028
|
+
}
|
|
1029
|
+
cellBlocks.length === 0 && cellBlocks.push({
|
|
1030
|
+
_type: "block",
|
|
1031
|
+
style: consolidatedOptions.block.normal({ context: { schema: consolidatedOptions.schema } }) || "normal",
|
|
1032
|
+
children: [{
|
|
1033
|
+
_type: consolidatedOptions.schema.span.name,
|
|
1034
|
+
_key: consolidatedOptions.keyGenerator(),
|
|
1035
|
+
text: "",
|
|
1036
|
+
marks: []
|
|
1037
|
+
}],
|
|
1038
|
+
_key: consolidatedOptions.keyGenerator(),
|
|
1039
|
+
markDefs: []
|
|
1040
|
+
});
|
|
1041
|
+
let firstBlock = cellBlocks[0];
|
|
1042
|
+
if (cellBlocks.length === 1 && firstBlock && firstBlock._type === "block" && "children" in firstBlock && Array.isArray(firstBlock.children) && firstBlock.children.length === 1) {
|
|
1043
|
+
let onlyChild = firstBlock.children[0];
|
|
1044
|
+
typeof onlyChild == "object" && onlyChild && "_type" in onlyChild && onlyChild._type !== consolidatedOptions.schema.span.name && onlyChild._type === "image" && (cellBlocks[0] = onlyChild);
|
|
1045
|
+
}
|
|
1046
|
+
currentTableRow !== null && currentTableRow.push({
|
|
1047
|
+
_type: "cell",
|
|
1048
|
+
_key: consolidatedOptions.keyGenerator(),
|
|
1049
|
+
value: cellBlocks
|
|
1050
|
+
});
|
|
1051
|
+
break;
|
|
1052
|
+
}
|
|
1053
|
+
case "inline": {
|
|
1054
|
+
let inTableCell = currentTableRow !== null;
|
|
1055
|
+
if (token.children?.length === 1 && token.children[0]?.type === "image") {
|
|
1056
|
+
let imageToken = token.children[0];
|
|
1057
|
+
if (!imageToken) break;
|
|
1058
|
+
let src = imageToken.attrs?.find(([name]) => name === "src")?.at(1) || "", alt = unescapeImageAndLinkText(imageToken.content || ""), title = imageToken.attrs?.find(([name]) => name === "title")?.at(1) || void 0, blockImageObject = consolidatedOptions.types.image({
|
|
1059
|
+
context: {
|
|
1060
|
+
schema: consolidatedOptions.schema,
|
|
1061
|
+
keyGenerator: consolidatedOptions.keyGenerator
|
|
1062
|
+
},
|
|
1063
|
+
value: {
|
|
1064
|
+
src,
|
|
1065
|
+
alt,
|
|
1066
|
+
title
|
|
1067
|
+
},
|
|
1068
|
+
isInline: !1
|
|
1069
|
+
});
|
|
1070
|
+
if (blockImageObject) {
|
|
1071
|
+
inTableCell ? currentBlock && "children" in currentBlock && currentBlock.children.push(blockImageObject) : (currentBlock && "children" in currentBlock && currentBlock.children.length > 0 ? flushBlock() : (currentBlock = null, currentMarkDefs = []), pushBlock(blockImageObject));
|
|
1072
|
+
break;
|
|
1073
|
+
}
|
|
1074
|
+
let inlineImageObject = consolidatedOptions.types.image({
|
|
1075
|
+
context: {
|
|
1076
|
+
schema: consolidatedOptions.schema,
|
|
1077
|
+
keyGenerator: consolidatedOptions.keyGenerator
|
|
1078
|
+
},
|
|
1079
|
+
value: {
|
|
1080
|
+
src,
|
|
1081
|
+
alt,
|
|
1082
|
+
title
|
|
1083
|
+
},
|
|
1084
|
+
isInline: !0
|
|
1085
|
+
});
|
|
1086
|
+
if (inlineImageObject) {
|
|
1087
|
+
if (!currentBlock) if (inListItem) if (listContainerStack.at(-1)) startBlock(consolidatedOptions.block.normal({ context: { schema: consolidatedOptions.schema } }) ?? "normal");
|
|
1088
|
+
else {
|
|
1089
|
+
let listType = currentListStack.at(-1);
|
|
1090
|
+
listType && ensureListBlock(listType);
|
|
1091
|
+
}
|
|
1092
|
+
else {
|
|
1093
|
+
let style = consolidatedOptions.block.normal({ context: { schema: consolidatedOptions.schema } });
|
|
1094
|
+
style && startBlock(style);
|
|
1095
|
+
}
|
|
1096
|
+
currentBlock && "children" in currentBlock && currentBlock.children.push(inlineImageObject);
|
|
1097
|
+
break;
|
|
1098
|
+
}
|
|
1099
|
+
addSpan(``);
|
|
1100
|
+
break;
|
|
1101
|
+
}
|
|
1102
|
+
for (let childToken of token.children ?? []) switch (childToken.type) {
|
|
1103
|
+
case "text":
|
|
1104
|
+
addSpan(childToken.content);
|
|
1105
|
+
break;
|
|
1106
|
+
case "softbreak":
|
|
1107
|
+
case "hardbreak":
|
|
1108
|
+
addSpan("\n");
|
|
1109
|
+
break;
|
|
1110
|
+
case "code_inline": {
|
|
1111
|
+
let decorator = consolidatedOptions.marks.code({ context: { schema: consolidatedOptions.schema } });
|
|
1112
|
+
if (!decorator) {
|
|
1113
|
+
addSpan(childToken.content);
|
|
1114
|
+
break;
|
|
1115
|
+
}
|
|
1116
|
+
markDefRefs.push(decorator), addSpan(childToken.content);
|
|
1117
|
+
let index = markDefRefs.lastIndexOf(decorator);
|
|
1118
|
+
index !== -1 && markDefRefs.splice(index, 1);
|
|
1119
|
+
break;
|
|
1120
|
+
}
|
|
1121
|
+
case "strong_open": {
|
|
1122
|
+
let decorator = consolidatedOptions.marks.strong({ context: { schema: consolidatedOptions.schema } });
|
|
1123
|
+
if (!decorator) break;
|
|
1124
|
+
markDefRefs.push(decorator);
|
|
1125
|
+
break;
|
|
1126
|
+
}
|
|
1127
|
+
case "strong_close": {
|
|
1128
|
+
let decorator = consolidatedOptions.marks.strong({ context: { schema: consolidatedOptions.schema } });
|
|
1129
|
+
if (!decorator) break;
|
|
1130
|
+
let index = markDefRefs.lastIndexOf(decorator);
|
|
1131
|
+
index !== -1 && markDefRefs.splice(index, 1);
|
|
1132
|
+
break;
|
|
1133
|
+
}
|
|
1134
|
+
case "em_open": {
|
|
1135
|
+
let decorator = consolidatedOptions.marks.em({ context: { schema: consolidatedOptions.schema } });
|
|
1136
|
+
if (!decorator) break;
|
|
1137
|
+
markDefRefs.push(decorator);
|
|
1138
|
+
break;
|
|
1139
|
+
}
|
|
1140
|
+
case "em_close": {
|
|
1141
|
+
let decorator = consolidatedOptions.marks.em({ context: { schema: consolidatedOptions.schema } });
|
|
1142
|
+
if (!decorator) break;
|
|
1143
|
+
let index = markDefRefs.lastIndexOf(decorator);
|
|
1144
|
+
index !== -1 && markDefRefs.splice(index, 1);
|
|
1145
|
+
break;
|
|
1146
|
+
}
|
|
1147
|
+
case "s_open": {
|
|
1148
|
+
let decorator = consolidatedOptions.marks.strikeThrough({ context: { schema: consolidatedOptions.schema } });
|
|
1149
|
+
if (!decorator) break;
|
|
1150
|
+
markDefRefs.push(decorator);
|
|
1151
|
+
break;
|
|
1152
|
+
}
|
|
1153
|
+
case "s_close": {
|
|
1154
|
+
let decorator = consolidatedOptions.marks.strikeThrough({ context: { schema: consolidatedOptions.schema } });
|
|
1155
|
+
if (!decorator) break;
|
|
1156
|
+
let index = markDefRefs.lastIndexOf(decorator);
|
|
1157
|
+
index !== -1 && markDefRefs.splice(index, 1);
|
|
1158
|
+
break;
|
|
1159
|
+
}
|
|
1160
|
+
case "link_open": {
|
|
1161
|
+
let href = childToken.attrs?.find(([name]) => name === "href")?.at(1);
|
|
1162
|
+
if (!href) break;
|
|
1163
|
+
let title = childToken.attrs?.find(([name]) => name === "title")?.at(1), linkObject = consolidatedOptions.marks.link({
|
|
1164
|
+
context: {
|
|
1165
|
+
schema: consolidatedOptions.schema,
|
|
1166
|
+
keyGenerator: consolidatedOptions.keyGenerator
|
|
1167
|
+
},
|
|
1168
|
+
value: {
|
|
1169
|
+
href,
|
|
1170
|
+
title
|
|
1171
|
+
}
|
|
1172
|
+
});
|
|
1173
|
+
if (!linkObject) break;
|
|
1174
|
+
currentMarkDefs.push(linkObject), markDefRefs.push(linkObject._key);
|
|
1175
|
+
break;
|
|
1176
|
+
}
|
|
1177
|
+
case "link_close": {
|
|
1178
|
+
let markDefKeys = new Set(currentMarkDefs.map((d) => d._key)), lastLinkIndex;
|
|
1179
|
+
for (let markDefRef of markDefRefs.reverse()) if (markDefKeys.has(markDefRef)) {
|
|
1180
|
+
lastLinkIndex = markDefRefs.indexOf(markDefRef);
|
|
1181
|
+
break;
|
|
1182
|
+
}
|
|
1183
|
+
if (lastLinkIndex !== void 0) {
|
|
1184
|
+
let realIndex = markDefRefs.length - 1 - lastLinkIndex;
|
|
1185
|
+
markDefRefs.splice(realIndex, 1);
|
|
1186
|
+
}
|
|
1187
|
+
break;
|
|
1188
|
+
}
|
|
1189
|
+
case "image": {
|
|
1190
|
+
let src = childToken.attrs?.find(([name]) => name === "src")?.at(1) || "", alt = unescapeImageAndLinkText(childToken.content || ""), inlineImageObject = consolidatedOptions.types.image({
|
|
1191
|
+
context: {
|
|
1192
|
+
schema: consolidatedOptions.schema,
|
|
1193
|
+
keyGenerator: consolidatedOptions.keyGenerator
|
|
1194
|
+
},
|
|
1195
|
+
value: {
|
|
1196
|
+
src,
|
|
1197
|
+
alt,
|
|
1198
|
+
title: void 0
|
|
1199
|
+
},
|
|
1200
|
+
isInline: !0
|
|
1201
|
+
});
|
|
1202
|
+
if (inlineImageObject) {
|
|
1203
|
+
if (!currentBlock) {
|
|
1204
|
+
let style = consolidatedOptions.block.normal({ context: { schema: consolidatedOptions.schema } });
|
|
1205
|
+
style ? startBlock(style) : (console.warn("No default style found, using \"normal\""), startBlock("normal"));
|
|
1206
|
+
}
|
|
1207
|
+
if (!currentBlock) throw Error("Expected current block after startBlock");
|
|
1208
|
+
currentBlock.children.push(inlineImageObject);
|
|
1209
|
+
break;
|
|
1210
|
+
}
|
|
1211
|
+
let blockImageObject = consolidatedOptions.types.image({
|
|
1212
|
+
context: {
|
|
1213
|
+
schema: consolidatedOptions.schema,
|
|
1214
|
+
keyGenerator: consolidatedOptions.keyGenerator
|
|
1215
|
+
},
|
|
1216
|
+
value: {
|
|
1217
|
+
src,
|
|
1218
|
+
alt,
|
|
1219
|
+
title: void 0
|
|
1220
|
+
},
|
|
1221
|
+
isInline: !1
|
|
1222
|
+
});
|
|
1223
|
+
if (!blockImageObject) {
|
|
1224
|
+
addSpan(``);
|
|
1225
|
+
break;
|
|
1226
|
+
}
|
|
1227
|
+
if (inTableCell) {
|
|
1228
|
+
currentBlock && "children" in currentBlock && currentBlock.children.push(blockImageObject);
|
|
1229
|
+
break;
|
|
1230
|
+
}
|
|
1231
|
+
flushBlock(), pushBlock(blockImageObject);
|
|
1232
|
+
let style = consolidatedOptions.block.normal({ context: { schema: consolidatedOptions.schema } });
|
|
1233
|
+
style && startBlock(style);
|
|
1234
|
+
break;
|
|
1235
|
+
}
|
|
1236
|
+
case "html_inline": consolidatedOptions.html.inline === "text" && addSpan(childToken.content);
|
|
1237
|
+
}
|
|
1238
|
+
break;
|
|
1239
|
+
}
|
|
1240
|
+
case "alert_open":
|
|
1241
|
+
flushBlock(), calloutStartTarget = blockTarget(), calloutStartIndex = calloutStartTarget.length, calloutType = token.markup, currentBlockquoteStyle = consolidatedOptions.block.blockquote({ context: { schema: consolidatedOptions.schema } }) ?? consolidatedOptions.block.normal({ context: { schema: consolidatedOptions.schema } }) ?? "normal";
|
|
1242
|
+
break;
|
|
1243
|
+
case "alert_title": break;
|
|
1244
|
+
case "alert_close":
|
|
1245
|
+
if (flushBlock(), calloutStartIndex !== null && calloutType !== null && calloutStartTarget !== null) {
|
|
1246
|
+
let contentBlocks = calloutStartTarget.splice(calloutStartIndex), calloutObject = consolidatedOptions.types.callout?.({
|
|
1247
|
+
context: {
|
|
1248
|
+
schema: consolidatedOptions.schema,
|
|
1249
|
+
keyGenerator: consolidatedOptions.keyGenerator
|
|
1250
|
+
},
|
|
1251
|
+
value: {
|
|
1252
|
+
tone: calloutType,
|
|
1253
|
+
content: contentBlocks
|
|
1254
|
+
},
|
|
1255
|
+
isInline: !1
|
|
1256
|
+
});
|
|
1257
|
+
if (calloutObject) pushBlock(calloutObject);
|
|
1258
|
+
else for (let block of contentBlocks) pushBlock(block);
|
|
1259
|
+
}
|
|
1260
|
+
calloutStartIndex = null, calloutStartTarget = null, calloutType = null, currentBlockquoteStyle = null;
|
|
1261
|
+
}
|
|
1262
|
+
}
|
|
1263
|
+
return flushBlock(), portableText;
|
|
1430
1264
|
}
|
|
1431
|
-
export {
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
DefaultBlockquoteRenderer,
|
|
1435
|
-
DefaultCalloutRenderer,
|
|
1436
|
-
DefaultCodeBlockRenderer,
|
|
1437
|
-
DefaultCodeRenderer,
|
|
1438
|
-
DefaultEmRenderer,
|
|
1439
|
-
DefaultH1Renderer,
|
|
1440
|
-
DefaultH2Renderer,
|
|
1441
|
-
DefaultH3Renderer,
|
|
1442
|
-
DefaultH4Renderer,
|
|
1443
|
-
DefaultH5Renderer,
|
|
1444
|
-
DefaultH6Renderer,
|
|
1445
|
-
DefaultHardBreakRenderer,
|
|
1446
|
-
DefaultHorizontalRuleRenderer,
|
|
1447
|
-
DefaultHtmlRenderer,
|
|
1448
|
-
DefaultImageRenderer,
|
|
1449
|
-
DefaultLinkRenderer,
|
|
1450
|
-
DefaultListItemRenderer,
|
|
1451
|
-
DefaultListRenderer,
|
|
1452
|
-
DefaultNormalRenderer,
|
|
1453
|
-
DefaultStrikeThroughRenderer,
|
|
1454
|
-
DefaultStrongRenderer,
|
|
1455
|
-
DefaultTableRenderer,
|
|
1456
|
-
DefaultUnderlineRenderer,
|
|
1457
|
-
markdownToPortableText,
|
|
1458
|
-
portableTextToMarkdown
|
|
1459
|
-
};
|
|
1460
|
-
//# sourceMappingURL=index.js.map
|
|
1265
|
+
export { DefaultBlockSpacingRenderer, DefaultBlockquoteObjectRenderer, DefaultBlockquoteRenderer, DefaultCalloutRenderer, DefaultCodeBlockRenderer, DefaultCodeRenderer, DefaultEmRenderer, DefaultH1Renderer, DefaultH2Renderer, DefaultH3Renderer, DefaultH4Renderer, DefaultH5Renderer, DefaultH6Renderer, DefaultHardBreakRenderer, DefaultHorizontalRuleRenderer, DefaultHtmlRenderer, DefaultImageRenderer, DefaultLinkRenderer, DefaultListItemRenderer, DefaultListRenderer, DefaultNormalRenderer, DefaultStrikeThroughRenderer, DefaultStrongRenderer, DefaultTableRenderer, DefaultUnderlineRenderer, markdownToPortableText, portableTextToMarkdown };
|
|
1266
|
+
|
|
1267
|
+
//# sourceMappingURL=index.js.map
|