@liveblocks/react-ui 3.1.4 → 3.2.1

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.
Files changed (63) hide show
  1. package/dist/_private/index.d.cts +279 -38
  2. package/dist/_private/index.d.ts +279 -38
  3. package/dist/components/AiChat.cjs +213 -63
  4. package/dist/components/AiChat.cjs.map +1 -1
  5. package/dist/components/AiChat.js +215 -65
  6. package/dist/components/AiChat.js.map +1 -1
  7. package/dist/components/Composer.cjs +2 -0
  8. package/dist/components/Composer.cjs.map +1 -1
  9. package/dist/components/Composer.js +2 -0
  10. package/dist/components/Composer.js.map +1 -1
  11. package/dist/components/Thread.cjs +2 -0
  12. package/dist/components/Thread.cjs.map +1 -1
  13. package/dist/components/Thread.js +2 -0
  14. package/dist/components/Thread.js.map +1 -1
  15. package/dist/components/internal/AiChatAssistantMessage.cjs +21 -15
  16. package/dist/components/internal/AiChatAssistantMessage.cjs.map +1 -1
  17. package/dist/components/internal/AiChatAssistantMessage.js +20 -14
  18. package/dist/components/internal/AiChatAssistantMessage.js.map +1 -1
  19. package/dist/components/internal/AiChatUserMessage.cjs +2 -1
  20. package/dist/components/internal/AiChatUserMessage.cjs.map +1 -1
  21. package/dist/components/internal/AiChatUserMessage.js +2 -1
  22. package/dist/components/internal/AiChatUserMessage.js.map +1 -1
  23. package/dist/components/internal/Prose.cjs +15 -7
  24. package/dist/components/internal/Prose.cjs.map +1 -1
  25. package/dist/components/internal/Prose.js +16 -8
  26. package/dist/components/internal/Prose.js.map +1 -1
  27. package/dist/index.d.cts +284 -5
  28. package/dist/index.d.ts +284 -5
  29. package/dist/primitives/Composer/index.cjs +5 -2
  30. package/dist/primitives/Composer/index.cjs.map +1 -1
  31. package/dist/primitives/Composer/index.js +5 -2
  32. package/dist/primitives/Composer/index.js.map +1 -1
  33. package/dist/primitives/Composer/utils.cjs +1 -2
  34. package/dist/primitives/Composer/utils.cjs.map +1 -1
  35. package/dist/primitives/Composer/utils.js +1 -2
  36. package/dist/primitives/Composer/utils.js.map +1 -1
  37. package/dist/primitives/Markdown.cjs +268 -336
  38. package/dist/primitives/Markdown.cjs.map +1 -1
  39. package/dist/primitives/Markdown.js +270 -338
  40. package/dist/primitives/Markdown.js.map +1 -1
  41. package/dist/primitives/index.d.cts +4 -0
  42. package/dist/primitives/index.d.ts +4 -0
  43. package/dist/utils/use-observable.cjs +2 -2
  44. package/dist/utils/use-observable.cjs.map +1 -1
  45. package/dist/utils/use-observable.js +1 -1
  46. package/dist/utils/use-observable.js.map +1 -1
  47. package/dist/utils/use-visible.cjs +8 -6
  48. package/dist/utils/use-visible.cjs.map +1 -1
  49. package/dist/utils/use-visible.js +7 -5
  50. package/dist/utils/use-visible.js.map +1 -1
  51. package/dist/version.cjs +1 -1
  52. package/dist/version.js +1 -1
  53. package/package.json +4 -4
  54. package/src/styles/constants.css +2 -2
  55. package/src/styles/index.css +15 -2
  56. package/styles/dark/attributes.css +1 -1
  57. package/styles/dark/media-query.css +1 -1
  58. package/styles.css +1 -1
  59. package/styles.css.map +1 -1
  60. package/dist/utils/use-latest.cjs +0 -14
  61. package/dist/utils/use-latest.cjs.map +0 -1
  62. package/dist/utils/use-latest.js +0 -12
  63. package/dist/utils/use-latest.js.map +0 -1
@@ -1,10 +1,37 @@
1
- import { jsx, jsxs } from 'react/jsx-runtime';
2
- import { sanitizeUrl } from '@liveblocks/core';
1
+ import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
2
+ import { assertNever, sanitizeUrl } from '@liveblocks/core';
3
3
  import { Slot } from '@radix-ui/react-slot';
4
4
  import { Lexer } from 'marked';
5
5
  import { forwardRef, useMemo, memo } from 'react';
6
6
 
7
7
  const defaultComponents = {
8
+ Paragraph: ({ children }) => {
9
+ return /* @__PURE__ */ jsx("p", {
10
+ children
11
+ });
12
+ },
13
+ Inline: ({ type, children }) => {
14
+ switch (type) {
15
+ case "strong":
16
+ return /* @__PURE__ */ jsx("strong", {
17
+ children
18
+ });
19
+ case "em":
20
+ return /* @__PURE__ */ jsx("em", {
21
+ children
22
+ });
23
+ case "code":
24
+ return /* @__PURE__ */ jsx("code", {
25
+ children
26
+ });
27
+ case "del":
28
+ return /* @__PURE__ */ jsx("del", {
29
+ children
30
+ });
31
+ default:
32
+ assertNever(type, "Unknown inline type");
33
+ }
34
+ },
8
35
  CodeBlock: ({ language, code }) => {
9
36
  return /* @__PURE__ */ jsx("pre", {
10
37
  "data-language": language ?? void 0,
@@ -39,6 +66,58 @@ const defaultComponents = {
39
66
  return /* @__PURE__ */ jsx("blockquote", {
40
67
  children
41
68
  });
69
+ },
70
+ Table: ({ headings, rows }) => {
71
+ return /* @__PURE__ */ jsxs("table", {
72
+ children: [
73
+ /* @__PURE__ */ jsx("thead", {
74
+ children: /* @__PURE__ */ jsx("tr", {
75
+ children: headings.map((heading, index) => {
76
+ return /* @__PURE__ */ jsx("th", {
77
+ align: heading.align,
78
+ children: heading.children
79
+ }, index);
80
+ })
81
+ })
82
+ }),
83
+ /* @__PURE__ */ jsx("tbody", {
84
+ children: rows.map((row, index) => {
85
+ return /* @__PURE__ */ jsx("tr", {
86
+ children: row.map((cell, index2) => {
87
+ return /* @__PURE__ */ jsx("td", {
88
+ align: cell.align,
89
+ children: cell.children
90
+ }, index2);
91
+ })
92
+ }, index);
93
+ })
94
+ })
95
+ ]
96
+ });
97
+ },
98
+ List: ({ type, items, start }) => {
99
+ const List = type === "ordered" ? "ol" : "ul";
100
+ return /* @__PURE__ */ jsx(List, {
101
+ start: start === 1 ? void 0 : start,
102
+ children: items.map((item, index) => /* @__PURE__ */ jsxs("li", {
103
+ children: [
104
+ item.checked !== void 0 && /* @__PURE__ */ jsxs(Fragment, {
105
+ children: [
106
+ /* @__PURE__ */ jsx("input", {
107
+ type: "checkbox",
108
+ disabled: true,
109
+ checked: item.checked
110
+ }),
111
+ " "
112
+ ]
113
+ }),
114
+ item.children
115
+ ]
116
+ }, index))
117
+ });
118
+ },
119
+ Separator: () => {
120
+ return /* @__PURE__ */ jsx("hr", {});
42
121
  }
43
122
  };
44
123
  const Markdown = forwardRef(
@@ -51,7 +130,7 @@ const Markdown = forwardRef(
51
130
  ...props,
52
131
  ref: forwardedRef,
53
132
  children: tokens.map((token, index) => {
54
- return /* @__PURE__ */ jsx(MemoizedMarkdownBlockToken, {
133
+ return /* @__PURE__ */ jsx(MemoizedMarkdownToken, {
55
134
  token,
56
135
  components
57
136
  }, index);
@@ -59,382 +138,190 @@ const Markdown = forwardRef(
59
138
  });
60
139
  }
61
140
  );
62
- const MemoizedMarkdownBlockToken = memo(
141
+ const MemoizedMarkdownToken = memo(
63
142
  ({
64
143
  token,
65
144
  components
66
145
  }) => {
67
- return /* @__PURE__ */ jsx(MarkdownBlockToken, {
146
+ return /* @__PURE__ */ jsx(MarkdownToken, {
68
147
  token,
69
148
  components
70
149
  });
71
150
  },
72
- (prevProps, nextProps) => {
73
- const prevToken = prevProps.token;
151
+ (previousProps, nextProps) => {
152
+ const previousToken = previousProps.token;
74
153
  const nextToken = nextProps.token;
75
- if (prevToken.raw.length !== nextToken.raw.length) {
154
+ if (previousToken.raw.length !== nextToken.raw.length) {
76
155
  return false;
77
156
  }
78
- if (prevToken.type !== nextToken.type) {
157
+ if (previousToken.type !== nextToken.type) {
79
158
  return false;
80
159
  }
81
- return prevToken.raw === nextToken.raw;
160
+ return previousToken.raw === nextToken.raw;
82
161
  }
83
162
  );
84
- function MarkdownBlockToken({
163
+ function MarkdownToken({
85
164
  token,
86
165
  components
87
166
  }) {
167
+ if (!isMarkedToken(token)) {
168
+ return null;
169
+ }
88
170
  switch (token.type) {
171
+ case "escape": {
172
+ return token.text;
173
+ }
89
174
  case "space": {
90
175
  return null;
91
176
  }
92
- case "code": {
93
- let language = void 0;
94
- if (token.lang !== void 0) {
95
- language = token.lang.match(/^\S*/)?.[0] ?? void 0;
177
+ case "text": {
178
+ if (token.tokens !== void 0) {
179
+ return /* @__PURE__ */ jsx(MarkdownTokens, {
180
+ tokens: token.tokens,
181
+ components
182
+ });
183
+ } else {
184
+ return parseHtmlEntities(token.text);
96
185
  }
97
- const CodeBlock = components?.CodeBlock ?? defaultComponents.CodeBlock;
98
- return /* @__PURE__ */ jsx(CodeBlock, {
99
- language,
100
- code: token.text
101
- });
102
186
  }
103
- case "blockquote": {
104
- const tokens = [];
105
- for (let i = 0; i < token.tokens.length; i++) {
106
- switch (token.tokens[i].type) {
107
- case "space":
108
- case "code":
109
- case "blockquote":
110
- case "html":
111
- case "heading":
112
- case "hr":
113
- case "list":
114
- case "paragraph":
115
- case "table": {
116
- tokens.push(token.tokens[i]);
117
- break;
118
- }
119
- case "text": {
120
- const texts = [token.tokens[i]];
121
- while (i + 1 < token.tokens.length && token.tokens[i + 1].type === "text") {
122
- i++;
123
- texts.push(token.tokens[i]);
124
- }
125
- tokens.push({
126
- type: "paragraph",
127
- tokens: texts,
128
- raw: texts.map((text) => text.raw).join(""),
129
- text: texts.map((text) => text.text).join("")
130
- });
131
- break;
132
- }
133
- default: {
134
- continue;
135
- }
136
- }
137
- }
138
- const Blockquote = components?.Blockquote ?? defaultComponents.Blockquote;
139
- return /* @__PURE__ */ jsx(Blockquote, {
140
- children: tokens.map((token2, index) => {
141
- return /* @__PURE__ */ jsx(MarkdownBlockToken, {
142
- token: token2,
143
- components
144
- }, index);
187
+ case "br": {
188
+ return /* @__PURE__ */ jsx("br", {});
189
+ }
190
+ case "paragraph": {
191
+ const Paragraph = components?.Paragraph ?? defaultComponents.Paragraph;
192
+ return /* @__PURE__ */ jsx(Paragraph, {
193
+ children: /* @__PURE__ */ jsx(MarkdownTokens, {
194
+ tokens: token.tokens,
195
+ components
145
196
  })
146
197
  });
147
198
  }
148
- case "html": {
149
- return token.text;
150
- }
151
199
  case "heading": {
152
200
  const Heading = components?.Heading ?? defaultComponents.Heading;
153
201
  return /* @__PURE__ */ jsx(Heading, {
154
202
  level: clampHeadingLevel(token.depth),
155
- children: token.tokens.map((token2, index) => /* @__PURE__ */ jsx(MarkdownInlineToken, {
156
- token: token2,
203
+ children: /* @__PURE__ */ jsx(MarkdownTokens, {
204
+ tokens: token.tokens,
157
205
  components
158
- }, index))
159
- });
160
- }
161
- case "hr": {
162
- return /* @__PURE__ */ jsx("hr", {});
163
- }
164
- case "list": {
165
- const ListTag = token.ordered ? "ol" : "ul";
166
- return /* @__PURE__ */ jsx(ListTag, {
167
- children: token.items.map((item, index) => {
168
- if (item.loose) {
169
- if (item.task) {
170
- const tokens = [...item.tokens];
171
- if (tokens[0]?.type === "paragraph") {
172
- const token2 = tokens[0];
173
- token2.tokens.unshift(
174
- {
175
- type: "checkbox",
176
- checked: item.checked,
177
- raw: ""
178
- },
179
- {
180
- type: "text",
181
- text: " ",
182
- raw: " ",
183
- escaped: false
184
- }
185
- );
186
- } else {
187
- tokens.unshift(
188
- {
189
- type: "checkbox",
190
- checked: item.checked,
191
- raw: ""
192
- },
193
- {
194
- type: "text",
195
- text: " ",
196
- raw: " ",
197
- escaped: false
198
- }
199
- );
200
- }
201
- const items = [];
202
- for (let i = 0; i < tokens.length; i++) {
203
- switch (tokens[i].type) {
204
- case "space":
205
- case "code":
206
- case "blockquote":
207
- case "html":
208
- case "heading":
209
- case "hr":
210
- case "list":
211
- case "paragraph":
212
- case "table": {
213
- items.push(tokens[i]);
214
- break;
215
- }
216
- case "text":
217
- case "checkbox": {
218
- const texts = [
219
- tokens[i]
220
- ];
221
- while (i + 1 < tokens.length && tokens[i + 1].type === "text") {
222
- i++;
223
- texts.push(tokens[i]);
224
- }
225
- items.push({
226
- type: "paragraph",
227
- tokens: texts,
228
- raw: texts.map((text) => text.raw).join(""),
229
- text: texts.map((text) => text.text).join("")
230
- });
231
- break;
232
- }
233
- default: {
234
- continue;
235
- }
236
- }
237
- }
238
- return /* @__PURE__ */ jsx("li", {
239
- children: items.map((token2, index2) => {
240
- return /* @__PURE__ */ jsx(MarkdownBlockToken, {
241
- token: token2,
242
- components
243
- }, index2);
244
- })
245
- }, index);
246
- } else {
247
- const tokens = [];
248
- for (let i = 0; i < item.tokens.length; i++) {
249
- switch (item.tokens[i].type) {
250
- case "space":
251
- case "code":
252
- case "blockquote":
253
- case "html":
254
- case "heading":
255
- case "hr":
256
- case "list":
257
- case "paragraph":
258
- case "table": {
259
- tokens.push(item.tokens[i]);
260
- break;
261
- }
262
- case "text": {
263
- const texts = [
264
- item.tokens[i]
265
- ];
266
- while (i + 1 < item.tokens.length && item.tokens[i + 1].type === "text") {
267
- i++;
268
- texts.push(item.tokens[i]);
269
- }
270
- tokens.push({
271
- type: "paragraph",
272
- tokens: texts,
273
- raw: texts.map((text) => text.raw).join(""),
274
- text: texts.map((text) => text.text).join("")
275
- });
276
- break;
277
- }
278
- default: {
279
- continue;
280
- }
281
- }
282
- }
283
- return /* @__PURE__ */ jsx("li", {
284
- children: tokens.map((token2, index2) => {
285
- return /* @__PURE__ */ jsx(MarkdownBlockToken, {
286
- token: token2,
287
- components
288
- }, index2);
289
- })
290
- }, index);
291
- }
292
- } else {
293
- const Items = item.tokens.map((token2, index2) => {
294
- switch (token2.type) {
295
- case "space":
296
- case "code":
297
- case "blockquote":
298
- case "html":
299
- case "heading":
300
- case "hr":
301
- case "list":
302
- case "paragraph":
303
- case "table": {
304
- return /* @__PURE__ */ jsx(MarkdownBlockToken, {
305
- token: token2,
306
- components
307
- }, index2);
308
- }
309
- case "text": {
310
- return /* @__PURE__ */ jsx(MarkdownInlineToken, {
311
- token: token2,
312
- components
313
- }, index2);
314
- }
315
- default: {
316
- return null;
317
- }
318
- }
319
- });
320
- if (item.task) {
321
- return /* @__PURE__ */ jsxs("li", {
322
- children: [
323
- /* @__PURE__ */ jsx("input", {
324
- type: "checkbox",
325
- disabled: true,
326
- checked: item.checked
327
- }),
328
- " ",
329
- Items
330
- ]
331
- }, index);
332
- } else {
333
- return /* @__PURE__ */ jsx("li", {
334
- children: Items
335
- }, index);
336
- }
337
- }
338
206
  })
339
207
  });
340
208
  }
341
- case "paragraph": {
342
- return /* @__PURE__ */ jsx("p", {
343
- children: token.tokens.map((token2, index) => /* @__PURE__ */ jsx(MarkdownInlineToken, {
344
- token: token2,
345
- components
346
- }, index))
347
- });
348
- }
349
- case "table": {
350
- return /* @__PURE__ */ jsxs("table", {
351
- children: [
352
- /* @__PURE__ */ jsx("thead", {
353
- children: /* @__PURE__ */ jsx("tr", {
354
- children: token.header.map((cell, index) => {
355
- return /* @__PURE__ */ jsx("th", {
356
- align: cell.align ?? void 0,
357
- children: cell.tokens.map((token2, index2) => /* @__PURE__ */ jsx(MarkdownInlineToken, {
358
- token: token2,
359
- components
360
- }, index2))
361
- }, index);
362
- })
363
- })
364
- }),
365
- /* @__PURE__ */ jsx("tbody", {
366
- children: token.rows.map((row, index) => {
367
- return /* @__PURE__ */ jsx("tr", {
368
- children: row.map((cell, index2) => {
369
- return /* @__PURE__ */ jsx("td", {
370
- align: cell.align ?? void 0,
371
- children: cell.tokens.map((token2, index3) => /* @__PURE__ */ jsx(MarkdownInlineToken, {
372
- token: token2,
373
- components
374
- }, index3))
375
- }, index2);
376
- })
377
- }, index);
378
- })
379
- })
380
- ]
381
- });
382
- }
383
- }
384
- }
385
- function MarkdownInlineToken({
386
- token,
387
- components
388
- }) {
389
- switch (token.type) {
390
209
  case "strong": {
391
- return /* @__PURE__ */ jsx("strong", {
392
- children: token.tokens.map((token2, index) => /* @__PURE__ */ jsx(MarkdownInlineToken, {
393
- token: token2,
210
+ const Inline = components?.Inline ?? defaultComponents.Inline;
211
+ return /* @__PURE__ */ jsx(Inline, {
212
+ type: "strong",
213
+ children: /* @__PURE__ */ jsx(MarkdownTokens, {
214
+ tokens: token.tokens,
394
215
  components
395
- }, index))
216
+ })
396
217
  });
397
218
  }
398
219
  case "em": {
399
- return /* @__PURE__ */ jsx("em", {
400
- children: token.tokens.map((token2, index) => /* @__PURE__ */ jsx(MarkdownInlineToken, {
401
- token: token2,
220
+ const Inline = components?.Inline ?? defaultComponents.Inline;
221
+ return /* @__PURE__ */ jsx(Inline, {
222
+ type: "em",
223
+ children: /* @__PURE__ */ jsx(MarkdownTokens, {
224
+ tokens: token.tokens,
402
225
  components
403
- }, index))
226
+ })
404
227
  });
405
228
  }
406
229
  case "codespan": {
407
- return /* @__PURE__ */ jsx("code", {
230
+ const Inline = components?.Inline ?? defaultComponents.Inline;
231
+ return /* @__PURE__ */ jsx(Inline, {
232
+ type: "code",
408
233
  children: parseHtmlEntities(token.text)
409
234
  });
410
235
  }
411
- case "br": {
412
- return /* @__PURE__ */ jsx("br", {});
413
- }
414
236
  case "del": {
415
- return /* @__PURE__ */ jsx("del", {
416
- children: token.tokens.map((token2, index) => /* @__PURE__ */ jsx(MarkdownInlineToken, {
417
- token: token2,
237
+ const Inline = components?.Inline ?? defaultComponents.Inline;
238
+ return /* @__PURE__ */ jsx(Inline, {
239
+ type: "del",
240
+ children: /* @__PURE__ */ jsx(MarkdownTokens, {
241
+ tokens: token.tokens,
418
242
  components
419
- }, index))
243
+ })
420
244
  });
421
245
  }
422
246
  case "link": {
423
247
  const href = sanitizeUrl(token.href);
424
248
  if (href === null) {
425
- return token.tokens.map((token2, index) => /* @__PURE__ */ jsx(MarkdownInlineToken, {
426
- token: token2,
249
+ return /* @__PURE__ */ jsx(MarkdownTokens, {
250
+ tokens: token.tokens,
427
251
  components
428
- }, index));
252
+ });
429
253
  }
430
254
  const Link = components?.Link ?? defaultComponents.Link;
431
255
  return /* @__PURE__ */ jsx(Link, {
432
256
  href,
433
257
  title: token.title ?? void 0,
434
- children: token.tokens.map((token2, index) => /* @__PURE__ */ jsx(MarkdownInlineToken, {
435
- token: token2,
258
+ children: /* @__PURE__ */ jsx(MarkdownTokens, {
259
+ tokens: token.tokens,
436
260
  components
437
- }, index))
261
+ })
262
+ });
263
+ }
264
+ case "code": {
265
+ let language = void 0;
266
+ if (token.lang !== void 0) {
267
+ language = token.lang.match(/^\S*/)?.[0] ?? void 0;
268
+ }
269
+ const CodeBlock = components?.CodeBlock ?? defaultComponents.CodeBlock;
270
+ return /* @__PURE__ */ jsx(CodeBlock, {
271
+ language,
272
+ code: token.text
273
+ });
274
+ }
275
+ case "blockquote": {
276
+ const Blockquote = components?.Blockquote ?? defaultComponents.Blockquote;
277
+ return /* @__PURE__ */ jsx(Blockquote, {
278
+ children: /* @__PURE__ */ jsx(MarkdownTokens, {
279
+ tokens: token.tokens,
280
+ components,
281
+ normalizeToBlockTokens: true
282
+ })
283
+ });
284
+ }
285
+ case "list": {
286
+ const List = components?.List ?? defaultComponents.List;
287
+ const items = token.items.map((item) => {
288
+ return {
289
+ checked: item.task ? item.checked : void 0,
290
+ children: /* @__PURE__ */ jsx(MarkdownTokens, {
291
+ tokens: item.tokens,
292
+ components,
293
+ normalizeToBlockTokens: item.loose
294
+ })
295
+ };
296
+ });
297
+ const props = token.ordered ? { type: "ordered", items, start: token.start || 1 } : { type: "unordered", items };
298
+ return /* @__PURE__ */ jsx(List, {
299
+ ...props
300
+ });
301
+ }
302
+ case "table": {
303
+ const Table = components?.Table ?? defaultComponents.Table;
304
+ const headings = token.header.map(
305
+ (cell) => ({
306
+ align: cell.align ?? void 0,
307
+ children: /* @__PURE__ */ jsx(MarkdownTokens, {
308
+ tokens: cell.tokens,
309
+ components
310
+ })
311
+ })
312
+ );
313
+ const rows = token.rows.map(
314
+ (row) => row.map((cell) => ({
315
+ align: cell.align ?? void 0,
316
+ children: /* @__PURE__ */ jsx(MarkdownTokens, {
317
+ tokens: cell.tokens,
318
+ components
319
+ })
320
+ }))
321
+ );
322
+ return /* @__PURE__ */ jsx(Table, {
323
+ headings,
324
+ rows
438
325
  });
439
326
  }
440
327
  case "image": {
@@ -449,31 +336,76 @@ function MarkdownInlineToken({
449
336
  title: token.title ?? void 0
450
337
  });
451
338
  }
452
- case "text": {
453
- if (token.tokens !== void 0) {
454
- return token.tokens.map((token2, index) => /* @__PURE__ */ jsx(MarkdownInlineToken, {
455
- token: token2,
456
- components
457
- }, index));
458
- } else {
459
- return parseHtmlEntities(token.text);
460
- }
461
- }
462
- case "escape": {
463
- return token.text;
464
- }
465
- case "checkbox": {
466
- return /* @__PURE__ */ jsx("input", {
467
- type: "checkbox",
468
- disabled: true,
469
- checked: token.checked
470
- });
339
+ case "hr": {
340
+ const Separator = components?.Separator ?? defaultComponents.Separator;
341
+ return /* @__PURE__ */ jsx(Separator, {});
471
342
  }
343
+ case "html":
472
344
  default: {
473
345
  return null;
474
346
  }
475
347
  }
476
348
  }
349
+ function MarkdownTokens({
350
+ tokens,
351
+ components,
352
+ normalizeToBlockTokens = false
353
+ }) {
354
+ const normalizedTokens = [];
355
+ if (normalizeToBlockTokens) {
356
+ for (let i = 0; i < tokens.length; i++) {
357
+ const token = tokens[i];
358
+ switch (token.type) {
359
+ case "text": {
360
+ const texts = [token];
361
+ while (i + 1 < tokens.length && tokens[i + 1].type === "text") {
362
+ i++;
363
+ texts.push(tokens[i]);
364
+ }
365
+ normalizedTokens.push({
366
+ type: "paragraph",
367
+ tokens: texts,
368
+ raw: texts.map((text) => text.raw).join(""),
369
+ text: texts.map((text) => text.text).join("")
370
+ });
371
+ break;
372
+ }
373
+ default: {
374
+ normalizedTokens.push(token);
375
+ }
376
+ }
377
+ }
378
+ }
379
+ return tokens.map((token, index) => /* @__PURE__ */ jsx(MarkdownToken, {
380
+ token,
381
+ components
382
+ }, index));
383
+ }
384
+ const markedTokenTypes = [
385
+ "blockquote",
386
+ "br",
387
+ "code",
388
+ "codespan",
389
+ "def",
390
+ "del",
391
+ "em",
392
+ "escape",
393
+ "heading",
394
+ "hr",
395
+ "html",
396
+ "image",
397
+ "link",
398
+ "list",
399
+ "list_item",
400
+ "paragraph",
401
+ "space",
402
+ "strong",
403
+ "table",
404
+ "text"
405
+ ];
406
+ function isMarkedToken(token) {
407
+ return typeof token === "object" && token !== null && "type" in token && markedTokenTypes.includes(token.type);
408
+ }
477
409
  function parseHtmlEntities(input) {
478
410
  const document = new DOMParser().parseFromString(
479
411
  `<!doctype html><body>${input}`,
@@ -485,5 +417,5 @@ function clampHeadingLevel(level) {
485
417
  return Math.max(1, Math.min(6, level));
486
418
  }
487
419
 
488
- export { Markdown, MarkdownBlockToken };
420
+ export { Markdown, MarkdownToken };
489
421
  //# sourceMappingURL=Markdown.js.map