@frontlit/text-editor 0.1.0-alpha.2 → 0.1.0-alpha.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/docs.d.ts +1 -1
- package/dist/docs.js +621 -35
- package/dist/docs.js.map +1 -1
- package/dist/index.js +683 -18
- package/dist/index.js.map +1 -1
- package/dist/prose.css +305 -0
- package/dist/renderer/index.js +218 -14
- package/dist/renderer/index.js.map +1 -1
- package/dist/renderer/islands/docs-tabs.js +57 -0
- package/dist/renderer/islands/docs-tabs.js.map +1 -0
- package/dist/styles.css +299 -0
- package/package.json +7 -2
package/dist/prose.css
CHANGED
|
@@ -399,3 +399,308 @@
|
|
|
399
399
|
border-radius: 0.5rem;
|
|
400
400
|
margin: 1rem auto;
|
|
401
401
|
}
|
|
402
|
+
|
|
403
|
+
/* Rich docs blocks. Colours come from the site theme tokens; callout accents
|
|
404
|
+
mix a fixed hue into them so they read in light and dark themes. */
|
|
405
|
+
.tiptap-renderer .te-code-block__title {
|
|
406
|
+
border: 1px solid var(--border, hsl(214.3 31.8% 91.4%));
|
|
407
|
+
border-bottom: none;
|
|
408
|
+
border-radius: 0.5rem 0.5rem 0 0;
|
|
409
|
+
color: var(--muted-foreground, hsl(215.4 16.3% 46.9%));
|
|
410
|
+
font-family:
|
|
411
|
+
ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono",
|
|
412
|
+
monospace;
|
|
413
|
+
font-size: 0.8125rem;
|
|
414
|
+
padding: 0.5rem 1rem;
|
|
415
|
+
padding-right: 2.75rem;
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
.tiptap-renderer .te-code-block__title + pre {
|
|
419
|
+
border-top-left-radius: 0;
|
|
420
|
+
border-top-right-radius: 0;
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
.tiptap-renderer .te-callout {
|
|
424
|
+
--te-callout-accent: var(--primary, hsl(222.2 47.4% 11.2%));
|
|
425
|
+
display: flex;
|
|
426
|
+
gap: 0.75rem;
|
|
427
|
+
margin: 1rem 0;
|
|
428
|
+
padding: 0.75rem 1rem;
|
|
429
|
+
border: 1px solid color-mix(in srgb, var(--te-callout-accent) 35%, transparent);
|
|
430
|
+
border-radius: 0.5rem;
|
|
431
|
+
background: color-mix(in srgb, var(--te-callout-accent) 7%, transparent);
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
.tiptap-renderer .te-callout[data-type="tip"] {
|
|
435
|
+
--te-callout-accent: hsl(142 71% 36%);
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
.tiptap-renderer .te-callout[data-type="warning"] {
|
|
439
|
+
--te-callout-accent: hsl(38 92% 45%);
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
.tiptap-renderer .te-callout[data-type="danger"] {
|
|
443
|
+
--te-callout-accent: hsl(0 72% 51%);
|
|
444
|
+
}
|
|
445
|
+
|
|
446
|
+
.tiptap-renderer .te-callout[data-type="note"] {
|
|
447
|
+
--te-callout-accent: var(--muted-foreground, hsl(215.4 16.3% 46.9%));
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
.tiptap-renderer .te-callout__icon {
|
|
451
|
+
flex-shrink: 0;
|
|
452
|
+
width: 1.125rem;
|
|
453
|
+
height: 1.125rem;
|
|
454
|
+
margin-top: 0.2rem;
|
|
455
|
+
color: var(--te-callout-accent);
|
|
456
|
+
}
|
|
457
|
+
|
|
458
|
+
.tiptap-renderer .te-callout__body {
|
|
459
|
+
min-width: 0;
|
|
460
|
+
flex: 1;
|
|
461
|
+
}
|
|
462
|
+
|
|
463
|
+
.tiptap-renderer .te-callout__body > :first-child {
|
|
464
|
+
margin-top: 0;
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
.tiptap-renderer .te-callout__body > :last-child {
|
|
468
|
+
margin-bottom: 0;
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
.tiptap-renderer .te-callout__title {
|
|
472
|
+
font-weight: 600;
|
|
473
|
+
}
|
|
474
|
+
|
|
475
|
+
.tiptap-renderer .te-tabs {
|
|
476
|
+
margin: 1rem 0;
|
|
477
|
+
}
|
|
478
|
+
|
|
479
|
+
.tiptap-renderer .te-tabs__list {
|
|
480
|
+
display: flex;
|
|
481
|
+
gap: 0.25rem;
|
|
482
|
+
overflow-x: auto;
|
|
483
|
+
border-bottom: 1px solid var(--border, hsl(214.3 31.8% 91.4%));
|
|
484
|
+
}
|
|
485
|
+
|
|
486
|
+
.tiptap-renderer .te-tabs__tab {
|
|
487
|
+
appearance: none;
|
|
488
|
+
background: none;
|
|
489
|
+
border: none;
|
|
490
|
+
border-bottom: 2px solid transparent;
|
|
491
|
+
margin-bottom: -1px;
|
|
492
|
+
padding: 0.5rem 0.75rem;
|
|
493
|
+
color: var(--muted-foreground, hsl(215.4 16.3% 46.9%));
|
|
494
|
+
font: inherit;
|
|
495
|
+
font-size: 0.875rem;
|
|
496
|
+
font-weight: 500;
|
|
497
|
+
white-space: nowrap;
|
|
498
|
+
cursor: pointer;
|
|
499
|
+
}
|
|
500
|
+
|
|
501
|
+
.tiptap-renderer .te-tabs__tab[aria-selected="true"] {
|
|
502
|
+
border-bottom-color: var(--primary, hsl(222.2 47.4% 11.2%));
|
|
503
|
+
color: var(--foreground, hsl(222.2 84% 4.9%));
|
|
504
|
+
}
|
|
505
|
+
|
|
506
|
+
.tiptap-renderer .te-tabs__panel > :first-child {
|
|
507
|
+
margin-top: 0.75rem;
|
|
508
|
+
}
|
|
509
|
+
|
|
510
|
+
.tiptap-renderer .te-code-group .te-code-block__title {
|
|
511
|
+
display: none;
|
|
512
|
+
}
|
|
513
|
+
|
|
514
|
+
.tiptap-renderer .te-steps {
|
|
515
|
+
counter-reset: te-step;
|
|
516
|
+
margin: 1rem 0;
|
|
517
|
+
padding-left: 0;
|
|
518
|
+
}
|
|
519
|
+
|
|
520
|
+
.tiptap-renderer .te-steps > .te-step {
|
|
521
|
+
counter-increment: te-step;
|
|
522
|
+
list-style: none;
|
|
523
|
+
position: relative;
|
|
524
|
+
padding-left: 2.75rem;
|
|
525
|
+
padding-bottom: 0.5rem;
|
|
526
|
+
}
|
|
527
|
+
|
|
528
|
+
.tiptap-renderer .te-steps > .te-step::before {
|
|
529
|
+
content: counter(te-step);
|
|
530
|
+
position: absolute;
|
|
531
|
+
left: 0;
|
|
532
|
+
top: 0;
|
|
533
|
+
display: flex;
|
|
534
|
+
align-items: center;
|
|
535
|
+
justify-content: center;
|
|
536
|
+
width: 1.75rem;
|
|
537
|
+
height: 1.75rem;
|
|
538
|
+
border: 1px solid var(--border, hsl(214.3 31.8% 91.4%));
|
|
539
|
+
border-radius: 9999px;
|
|
540
|
+
background: var(--muted, hsl(210 40% 96.1%));
|
|
541
|
+
font-size: 0.875rem;
|
|
542
|
+
font-weight: 600;
|
|
543
|
+
}
|
|
544
|
+
|
|
545
|
+
.tiptap-renderer .te-steps > .te-step::after {
|
|
546
|
+
content: "";
|
|
547
|
+
position: absolute;
|
|
548
|
+
left: 0.875rem;
|
|
549
|
+
top: 2.25rem;
|
|
550
|
+
bottom: 0.25rem;
|
|
551
|
+
border-left: 1px solid var(--border, hsl(214.3 31.8% 91.4%));
|
|
552
|
+
}
|
|
553
|
+
|
|
554
|
+
.tiptap-renderer .te-steps > .te-step > :first-child {
|
|
555
|
+
margin-top: 0;
|
|
556
|
+
}
|
|
557
|
+
|
|
558
|
+
.tiptap-renderer .te-cards {
|
|
559
|
+
display: grid;
|
|
560
|
+
grid-template-columns: repeat(auto-fill, minmax(14rem, 1fr));
|
|
561
|
+
gap: 0.75rem;
|
|
562
|
+
margin: 1rem 0;
|
|
563
|
+
}
|
|
564
|
+
|
|
565
|
+
.tiptap-renderer .te-card {
|
|
566
|
+
display: flex;
|
|
567
|
+
flex-direction: column;
|
|
568
|
+
gap: 0.25rem;
|
|
569
|
+
padding: 1rem;
|
|
570
|
+
border: 1px solid var(--border, hsl(214.3 31.8% 91.4%));
|
|
571
|
+
border-radius: 0.5rem;
|
|
572
|
+
background: var(--card, transparent);
|
|
573
|
+
color: inherit;
|
|
574
|
+
text-decoration: none;
|
|
575
|
+
}
|
|
576
|
+
|
|
577
|
+
.tiptap-renderer a.te-card:hover {
|
|
578
|
+
background: var(--muted, hsl(210 40% 96.1%));
|
|
579
|
+
}
|
|
580
|
+
|
|
581
|
+
.tiptap-renderer .te-card__icon {
|
|
582
|
+
width: 1.25rem;
|
|
583
|
+
height: 1.25rem;
|
|
584
|
+
margin-bottom: 0.25rem;
|
|
585
|
+
color: var(--muted-foreground, hsl(215.4 16.3% 46.9%));
|
|
586
|
+
}
|
|
587
|
+
|
|
588
|
+
.tiptap-renderer .te-card__title {
|
|
589
|
+
font-weight: 600;
|
|
590
|
+
}
|
|
591
|
+
|
|
592
|
+
.tiptap-renderer .te-card__body {
|
|
593
|
+
color: var(--muted-foreground, hsl(215.4 16.3% 46.9%));
|
|
594
|
+
font-size: 0.875rem;
|
|
595
|
+
}
|
|
596
|
+
|
|
597
|
+
.tiptap-renderer .te-card__body > * {
|
|
598
|
+
margin: 0;
|
|
599
|
+
}
|
|
600
|
+
|
|
601
|
+
.tiptap-renderer .te-accordions {
|
|
602
|
+
margin: 1rem 0;
|
|
603
|
+
border: 1px solid var(--border, hsl(214.3 31.8% 91.4%));
|
|
604
|
+
border-radius: 0.5rem;
|
|
605
|
+
}
|
|
606
|
+
|
|
607
|
+
.tiptap-renderer .te-accordion + .te-accordion {
|
|
608
|
+
border-top: 1px solid var(--border, hsl(214.3 31.8% 91.4%));
|
|
609
|
+
}
|
|
610
|
+
|
|
611
|
+
.tiptap-renderer .te-accordion__title {
|
|
612
|
+
padding: 0.75rem 1rem;
|
|
613
|
+
font-weight: 600;
|
|
614
|
+
cursor: pointer;
|
|
615
|
+
}
|
|
616
|
+
|
|
617
|
+
.tiptap-renderer .te-accordion__body {
|
|
618
|
+
padding: 0 1rem;
|
|
619
|
+
}
|
|
620
|
+
|
|
621
|
+
.tiptap-renderer .te-type-table {
|
|
622
|
+
overflow-x: auto;
|
|
623
|
+
}
|
|
624
|
+
|
|
625
|
+
.tiptap-renderer .te-type-table table {
|
|
626
|
+
table-layout: auto;
|
|
627
|
+
}
|
|
628
|
+
|
|
629
|
+
.tiptap-renderer .te-type-table__required {
|
|
630
|
+
color: var(--muted-foreground, hsl(215.4 16.3% 46.9%));
|
|
631
|
+
font-size: 0.75rem;
|
|
632
|
+
}
|
|
633
|
+
|
|
634
|
+
/* Rich docs blocks in the editor: a labelled frame per block with its props. */
|
|
635
|
+
.tiptap-editor .ProseMirror .te-block {
|
|
636
|
+
margin: 0.75rem 0;
|
|
637
|
+
border: 1px solid var(--border);
|
|
638
|
+
border-radius: 0.5rem;
|
|
639
|
+
}
|
|
640
|
+
|
|
641
|
+
.tiptap-editor .ProseMirror .te-block__bar {
|
|
642
|
+
display: flex;
|
|
643
|
+
flex-wrap: wrap;
|
|
644
|
+
align-items: center;
|
|
645
|
+
gap: 0.375rem;
|
|
646
|
+
padding: 0.25rem 0.5rem;
|
|
647
|
+
border-bottom: 1px solid var(--border);
|
|
648
|
+
background: var(--muted);
|
|
649
|
+
border-radius: 0.5rem 0.5rem 0 0;
|
|
650
|
+
font-size: 0.75rem;
|
|
651
|
+
}
|
|
652
|
+
|
|
653
|
+
.tiptap-editor .ProseMirror .te-block__label {
|
|
654
|
+
font-weight: 600;
|
|
655
|
+
color: var(--muted-foreground);
|
|
656
|
+
text-transform: uppercase;
|
|
657
|
+
letter-spacing: 0.04em;
|
|
658
|
+
}
|
|
659
|
+
|
|
660
|
+
.tiptap-editor .ProseMirror .te-block__content {
|
|
661
|
+
padding: 0.25rem 0.75rem;
|
|
662
|
+
}
|
|
663
|
+
|
|
664
|
+
.tiptap-editor .ProseMirror .te-block-item {
|
|
665
|
+
margin: 0.5rem 0;
|
|
666
|
+
border: 1px dashed var(--border);
|
|
667
|
+
border-radius: 0.375rem;
|
|
668
|
+
}
|
|
669
|
+
|
|
670
|
+
.tiptap-editor .ProseMirror .te-block-item > .te-block__bar {
|
|
671
|
+
background: transparent;
|
|
672
|
+
}
|
|
673
|
+
|
|
674
|
+
.tiptap-editor .ProseMirror .te-block[data-block="steps"] > .te-block__content {
|
|
675
|
+
counter-reset: te-step;
|
|
676
|
+
}
|
|
677
|
+
|
|
678
|
+
.tiptap-editor .ProseMirror .te-block-item[data-block="step"]::before {
|
|
679
|
+
counter-increment: te-step;
|
|
680
|
+
content: "Step " counter(te-step);
|
|
681
|
+
display: block;
|
|
682
|
+
padding: 0.25rem 0.75rem 0;
|
|
683
|
+
font-size: 0.75rem;
|
|
684
|
+
font-weight: 600;
|
|
685
|
+
color: var(--muted-foreground);
|
|
686
|
+
}
|
|
687
|
+
|
|
688
|
+
.tiptap-editor .ProseMirror .te-block-code {
|
|
689
|
+
margin: 0.75rem 0;
|
|
690
|
+
}
|
|
691
|
+
|
|
692
|
+
.tiptap-editor .ProseMirror .te-block-code pre {
|
|
693
|
+
margin-top: 0;
|
|
694
|
+
border-top-left-radius: 0;
|
|
695
|
+
border-top-right-radius: 0;
|
|
696
|
+
}
|
|
697
|
+
|
|
698
|
+
.tiptap-editor .ProseMirror .te-block-table {
|
|
699
|
+
table-layout: auto;
|
|
700
|
+
margin: 0.5rem 0;
|
|
701
|
+
}
|
|
702
|
+
|
|
703
|
+
.tiptap-editor .ProseMirror .te-block-table th,
|
|
704
|
+
.tiptap-editor .ProseMirror .te-block-table td {
|
|
705
|
+
padding: 0.25rem;
|
|
706
|
+
}
|
package/dist/renderer/index.js
CHANGED
|
@@ -82,6 +82,95 @@ var CodeMirrorNode = Node.create({
|
|
|
82
82
|
}
|
|
83
83
|
});
|
|
84
84
|
|
|
85
|
+
// src/docs/blocks.ts
|
|
86
|
+
import { Extension, Node as Node2 } from "@tiptap/core";
|
|
87
|
+
import Code from "@tiptap/extension-code";
|
|
88
|
+
function attr(name, fallback = null) {
|
|
89
|
+
return {
|
|
90
|
+
[name]: {
|
|
91
|
+
default: fallback,
|
|
92
|
+
parseHTML: (element) => {
|
|
93
|
+
const value = element.getAttribute(`data-${name}`);
|
|
94
|
+
if (value === null) return fallback;
|
|
95
|
+
try {
|
|
96
|
+
return JSON.parse(value);
|
|
97
|
+
} catch {
|
|
98
|
+
return fallback;
|
|
99
|
+
}
|
|
100
|
+
},
|
|
101
|
+
renderHTML: (attributes) => attributes[name] === null || attributes[name] === void 0 ? {} : { [`data-${name}`]: JSON.stringify(attributes[name]) }
|
|
102
|
+
}
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
function block(name, spec) {
|
|
106
|
+
const tag = `div[data-docs-block="${name}"]`;
|
|
107
|
+
return Node2.create({
|
|
108
|
+
name,
|
|
109
|
+
group: spec.group,
|
|
110
|
+
content: spec.content,
|
|
111
|
+
atom: spec.atom,
|
|
112
|
+
defining: true,
|
|
113
|
+
isolating: true,
|
|
114
|
+
addAttributes() {
|
|
115
|
+
return Object.assign(
|
|
116
|
+
{},
|
|
117
|
+
...Object.entries(spec.attrs ?? {}).map(([key, value]) => attr(key, value))
|
|
118
|
+
);
|
|
119
|
+
},
|
|
120
|
+
parseHTML() {
|
|
121
|
+
return [{ tag }];
|
|
122
|
+
},
|
|
123
|
+
renderHTML({ HTMLAttributes }) {
|
|
124
|
+
return spec.atom ? ["div", { ...HTMLAttributes, "data-docs-block": name }] : ["div", { ...HTMLAttributes, "data-docs-block": name }, 0];
|
|
125
|
+
}
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
var DocsCode = Code.extend({ excludes: "" });
|
|
129
|
+
function createDocsBlockExtensions() {
|
|
130
|
+
return [
|
|
131
|
+
DocsCode,
|
|
132
|
+
block("callout", {
|
|
133
|
+
group: "block",
|
|
134
|
+
content: "block+",
|
|
135
|
+
attrs: { type: null, title: null }
|
|
136
|
+
}),
|
|
137
|
+
block("tabs", { group: "block", content: "tab+" }),
|
|
138
|
+
block("tab", { content: "block+", attrs: { label: "" } }),
|
|
139
|
+
block("steps", { group: "block", content: "step+" }),
|
|
140
|
+
block("step", { content: "block+" }),
|
|
141
|
+
block("cards", { group: "block", content: "card+" }),
|
|
142
|
+
block("card", {
|
|
143
|
+
content: "block*",
|
|
144
|
+
attrs: { title: "", href: null, icon: null }
|
|
145
|
+
}),
|
|
146
|
+
block("accordions", {
|
|
147
|
+
group: "block",
|
|
148
|
+
content: "accordion+",
|
|
149
|
+
attrs: { type: null }
|
|
150
|
+
}),
|
|
151
|
+
block("accordion", { content: "block+", attrs: { title: "" } }),
|
|
152
|
+
block("codeGroup", { group: "block", content: "codeBlock+" }),
|
|
153
|
+
block("typeTable", { group: "block", atom: true, attrs: { rows: [] } })
|
|
154
|
+
];
|
|
155
|
+
}
|
|
156
|
+
var CodeBlockTitle = Extension.create({
|
|
157
|
+
name: "codeBlockTitle",
|
|
158
|
+
addGlobalAttributes() {
|
|
159
|
+
return [
|
|
160
|
+
{
|
|
161
|
+
types: ["codeBlock"],
|
|
162
|
+
attributes: {
|
|
163
|
+
title: {
|
|
164
|
+
default: null,
|
|
165
|
+
parseHTML: (element) => element.getAttribute("data-title"),
|
|
166
|
+
renderHTML: (attributes) => attributes.title ? { "data-title": attributes.title } : {}
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
];
|
|
171
|
+
}
|
|
172
|
+
});
|
|
173
|
+
|
|
85
174
|
// src/extensions.ts
|
|
86
175
|
lowlight.registerLanguage("javascript", javascript);
|
|
87
176
|
lowlight.registerLanguage("typescript", typescript);
|
|
@@ -92,6 +181,7 @@ var createExtensions = ({
|
|
|
92
181
|
placeholder
|
|
93
182
|
} = {}) => [
|
|
94
183
|
StarterKit.configure({
|
|
184
|
+
code: false,
|
|
95
185
|
codeBlock: false,
|
|
96
186
|
// Configured/replaced explicitly below (custom options or a
|
|
97
187
|
// `.extend()`) — disabled here to avoid tiptap's duplicate-extension
|
|
@@ -151,7 +241,9 @@ var createExtensions = ({
|
|
|
151
241
|
}
|
|
152
242
|
}),
|
|
153
243
|
Highlight,
|
|
154
|
-
CodeMirrorNode
|
|
244
|
+
CodeMirrorNode,
|
|
245
|
+
CodeBlockTitle,
|
|
246
|
+
...createDocsBlockExtensions()
|
|
155
247
|
];
|
|
156
248
|
|
|
157
249
|
// src/lib/cn.ts
|
|
@@ -179,10 +271,12 @@ function textFromChildren(node) {
|
|
|
179
271
|
function RenderedCodeBlock({
|
|
180
272
|
node,
|
|
181
273
|
children,
|
|
182
|
-
language
|
|
274
|
+
language,
|
|
275
|
+
title
|
|
183
276
|
}) {
|
|
184
277
|
const source = extractTextFromNode(node) || textFromChildren(children);
|
|
185
278
|
return /* @__PURE__ */ jsxs("div", { className: "te-code-block", children: [
|
|
279
|
+
title && /* @__PURE__ */ jsx("div", { className: "te-code-block__title", children: title }),
|
|
186
280
|
/* @__PURE__ */ jsx("pre", { children: /* @__PURE__ */ jsx("code", { className: language ? `language-${language}` : void 0, children }) }),
|
|
187
281
|
/* @__PURE__ */ jsx(CopyCodeButton, { source })
|
|
188
282
|
] });
|
|
@@ -219,8 +313,109 @@ function extractDocsHeadings(json2) {
|
|
|
219
313
|
return headings;
|
|
220
314
|
}
|
|
221
315
|
|
|
316
|
+
// src/components/docs-blocks.tsx
|
|
317
|
+
import { CircleAlert, Info, Lightbulb, OctagonAlert, StickyNote } from "lucide-react";
|
|
318
|
+
import { DynamicIcon } from "lucide-react/dynamic";
|
|
319
|
+
import { DocsTabs } from "./islands/docs-tabs.js";
|
|
320
|
+
import { Fragment, jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
321
|
+
var childAttrs = (node) => {
|
|
322
|
+
const attrs = [];
|
|
323
|
+
node.forEach((child) => {
|
|
324
|
+
attrs.push(child.attrs);
|
|
325
|
+
});
|
|
326
|
+
return attrs;
|
|
327
|
+
};
|
|
328
|
+
var CALLOUT_ICONS = {
|
|
329
|
+
note: StickyNote,
|
|
330
|
+
tip: Lightbulb,
|
|
331
|
+
info: Info,
|
|
332
|
+
warning: CircleAlert,
|
|
333
|
+
danger: OctagonAlert
|
|
334
|
+
};
|
|
335
|
+
function Callout({ node, children }) {
|
|
336
|
+
const type = node.attrs.type ?? "info";
|
|
337
|
+
const Icon = CALLOUT_ICONS[type] ?? Info;
|
|
338
|
+
return /* @__PURE__ */ jsxs2("div", { className: "te-callout", "data-type": type, role: "note", children: [
|
|
339
|
+
/* @__PURE__ */ jsx2(Icon, { className: "te-callout__icon", "aria-hidden": true }),
|
|
340
|
+
/* @__PURE__ */ jsxs2("div", { className: "te-callout__body", children: [
|
|
341
|
+
node.attrs.title && /* @__PURE__ */ jsx2("p", { className: "te-callout__title", children: node.attrs.title }),
|
|
342
|
+
children
|
|
343
|
+
] })
|
|
344
|
+
] });
|
|
345
|
+
}
|
|
346
|
+
function Tabs({ node, children }) {
|
|
347
|
+
return /* @__PURE__ */ jsx2(DocsTabs, { className: "te-tabs", labels: childAttrs(node).map((attrs) => attrs.label), children });
|
|
348
|
+
}
|
|
349
|
+
function CodeGroup({ node, children }) {
|
|
350
|
+
const labels = childAttrs(node).map(
|
|
351
|
+
(attrs, index) => attrs.title ?? attrs.language ?? `Code ${index + 1}`
|
|
352
|
+
);
|
|
353
|
+
return /* @__PURE__ */ jsx2(DocsTabs, { className: "te-tabs te-code-group", labels, children });
|
|
354
|
+
}
|
|
355
|
+
function Steps({ children }) {
|
|
356
|
+
return /* @__PURE__ */ jsx2("ol", { className: "te-steps", children });
|
|
357
|
+
}
|
|
358
|
+
function Step({ children }) {
|
|
359
|
+
return /* @__PURE__ */ jsx2("li", { className: "te-step", children });
|
|
360
|
+
}
|
|
361
|
+
function Cards({ children }) {
|
|
362
|
+
return /* @__PURE__ */ jsx2("div", { className: "te-cards", children });
|
|
363
|
+
}
|
|
364
|
+
var iconName = (name) => name.replace(/([a-z0-9])([A-Z])/g, "$1-$2").replace(/([A-Za-z])([0-9])/g, "$1-$2").toLowerCase();
|
|
365
|
+
function Card({ node, children }) {
|
|
366
|
+
const { title, href, icon } = node.attrs;
|
|
367
|
+
const body = /* @__PURE__ */ jsxs2(Fragment, { children: [
|
|
368
|
+
icon && /* @__PURE__ */ jsx2(DynamicIcon, { name: iconName(icon), className: "te-card__icon", "aria-hidden": true }),
|
|
369
|
+
/* @__PURE__ */ jsx2("span", { className: "te-card__title", children: title }),
|
|
370
|
+
node.childCount > 0 && /* @__PURE__ */ jsx2("div", { className: "te-card__body", children })
|
|
371
|
+
] });
|
|
372
|
+
return href ? /* @__PURE__ */ jsx2("a", { className: "te-card", href, children: body }) : /* @__PURE__ */ jsx2("div", { className: "te-card", children: body });
|
|
373
|
+
}
|
|
374
|
+
function Accordions({ children }) {
|
|
375
|
+
return /* @__PURE__ */ jsx2("div", { className: "te-accordions", children });
|
|
376
|
+
}
|
|
377
|
+
function Accordion({ node, children }) {
|
|
378
|
+
return /* @__PURE__ */ jsxs2("details", { className: "te-accordion", children: [
|
|
379
|
+
/* @__PURE__ */ jsx2("summary", { className: "te-accordion__title", children: node.attrs.title }),
|
|
380
|
+
/* @__PURE__ */ jsx2("div", { className: "te-accordion__body", children })
|
|
381
|
+
] });
|
|
382
|
+
}
|
|
383
|
+
function TypeTable({ node }) {
|
|
384
|
+
const rows = node.attrs.rows ?? [];
|
|
385
|
+
return /* @__PURE__ */ jsx2("div", { className: "te-type-table", children: /* @__PURE__ */ jsxs2("table", { children: [
|
|
386
|
+
/* @__PURE__ */ jsx2("thead", { children: /* @__PURE__ */ jsxs2("tr", { children: [
|
|
387
|
+
/* @__PURE__ */ jsx2("th", { children: "Prop" }),
|
|
388
|
+
/* @__PURE__ */ jsx2("th", { children: "Type" }),
|
|
389
|
+
/* @__PURE__ */ jsx2("th", { children: "Default" }),
|
|
390
|
+
/* @__PURE__ */ jsx2("th", { children: "Description" })
|
|
391
|
+
] }) }),
|
|
392
|
+
/* @__PURE__ */ jsx2("tbody", { children: rows.map((row) => /* @__PURE__ */ jsxs2("tr", { children: [
|
|
393
|
+
/* @__PURE__ */ jsxs2("td", { children: [
|
|
394
|
+
/* @__PURE__ */ jsx2("code", { children: row.name }),
|
|
395
|
+
row.required && /* @__PURE__ */ jsx2("span", { className: "te-type-table__required", children: " (required)" })
|
|
396
|
+
] }),
|
|
397
|
+
/* @__PURE__ */ jsx2("td", { children: /* @__PURE__ */ jsx2("code", { children: row.type }) }),
|
|
398
|
+
/* @__PURE__ */ jsx2("td", { children: row.default === null ? "\u2014" : /* @__PURE__ */ jsx2("code", { children: row.default }) }),
|
|
399
|
+
/* @__PURE__ */ jsx2("td", { children: row.description ?? "" })
|
|
400
|
+
] }, row.name)) })
|
|
401
|
+
] }) });
|
|
402
|
+
}
|
|
403
|
+
var docsBlockMapping = {
|
|
404
|
+
callout: Callout,
|
|
405
|
+
tabs: Tabs,
|
|
406
|
+
tab: ({ children }) => /* @__PURE__ */ jsx2(Fragment, { children }),
|
|
407
|
+
codeGroup: CodeGroup,
|
|
408
|
+
steps: Steps,
|
|
409
|
+
step: Step,
|
|
410
|
+
cards: Cards,
|
|
411
|
+
card: Card,
|
|
412
|
+
accordions: Accordions,
|
|
413
|
+
accordion: Accordion,
|
|
414
|
+
typeTable: TypeTable
|
|
415
|
+
};
|
|
416
|
+
|
|
222
417
|
// src/text-renderer.tsx
|
|
223
|
-
import { jsx as
|
|
418
|
+
import { jsx as jsx3 } from "react/jsx-runtime";
|
|
224
419
|
var typographyClasses = (typography) => [
|
|
225
420
|
typography?.fontFamily,
|
|
226
421
|
typography?.fontSize,
|
|
@@ -278,30 +473,30 @@ function TextRenderer({
|
|
|
278
473
|
"text-base",
|
|
279
474
|
...typographyClasses(theme?.typography?.text1)
|
|
280
475
|
);
|
|
281
|
-
return /* @__PURE__ */
|
|
476
|
+
return /* @__PURE__ */ jsx3("p", { className: classes, children });
|
|
282
477
|
},
|
|
283
|
-
hardBreak: () => /* @__PURE__ */
|
|
478
|
+
hardBreak: () => /* @__PURE__ */ jsx3("br", {}),
|
|
284
479
|
heading: ({ node, children }) => {
|
|
285
480
|
const level = node?.attrs?.level ?? 1;
|
|
286
481
|
const textContent = extractTextFromNode(node);
|
|
287
482
|
const id = profile === "documentation" ? headingIds.get(node) : createId(textContent);
|
|
288
483
|
if (!theme) {
|
|
289
484
|
const Tag2 = `h${level}`;
|
|
290
|
-
return /* @__PURE__ */
|
|
485
|
+
return /* @__PURE__ */ jsx3(Tag2, { id, children });
|
|
291
486
|
}
|
|
292
487
|
if (level === 1) {
|
|
293
488
|
const classes2 = cn(
|
|
294
489
|
"scroll-m-20 text-4xl font-bold tracking-tight",
|
|
295
490
|
...typographyClasses(theme?.typography?.header1)
|
|
296
491
|
);
|
|
297
|
-
return /* @__PURE__ */
|
|
492
|
+
return /* @__PURE__ */ jsx3("h1", { id, className: classes2, children });
|
|
298
493
|
}
|
|
299
494
|
if (level === 2) {
|
|
300
495
|
const classes2 = cn(
|
|
301
496
|
"scroll-m-20 text-3xl font-bold tracking-tight",
|
|
302
497
|
...typographyClasses(theme?.typography?.header2)
|
|
303
498
|
);
|
|
304
|
-
return /* @__PURE__ */
|
|
499
|
+
return /* @__PURE__ */ jsx3("h2", { id, className: classes2, children });
|
|
305
500
|
}
|
|
306
501
|
const classes = cn(
|
|
307
502
|
"scroll-m-20 text-2xl font-semibold tracking-normal",
|
|
@@ -310,10 +505,19 @@ function TextRenderer({
|
|
|
310
505
|
)
|
|
311
506
|
);
|
|
312
507
|
const Tag = profile === "documentation" ? `h${level}` : "h3";
|
|
313
|
-
return /* @__PURE__ */
|
|
508
|
+
return /* @__PURE__ */ jsx3(Tag, { id, className: classes, children });
|
|
314
509
|
},
|
|
315
|
-
|
|
316
|
-
|
|
510
|
+
...docsBlockMapping,
|
|
511
|
+
codeBlock: ({ node, children }) => /* @__PURE__ */ jsx3(
|
|
512
|
+
RenderedCodeBlock,
|
|
513
|
+
{
|
|
514
|
+
node,
|
|
515
|
+
language: node?.attrs?.language,
|
|
516
|
+
title: node?.attrs?.title,
|
|
517
|
+
children
|
|
518
|
+
}
|
|
519
|
+
),
|
|
520
|
+
codeMirror: ({ node, children }) => /* @__PURE__ */ jsx3(RenderedCodeBlock, { node, children })
|
|
317
521
|
},
|
|
318
522
|
markMapping: {
|
|
319
523
|
link: ({ mark, children }) => {
|
|
@@ -329,7 +533,7 @@ function TextRenderer({
|
|
|
329
533
|
linkStyle?.border?.style,
|
|
330
534
|
linkStyle?.custom
|
|
331
535
|
);
|
|
332
|
-
return /* @__PURE__ */
|
|
536
|
+
return /* @__PURE__ */ jsx3(
|
|
333
537
|
"a",
|
|
334
538
|
{
|
|
335
539
|
href,
|
|
@@ -343,12 +547,12 @@ function TextRenderer({
|
|
|
343
547
|
}
|
|
344
548
|
);
|
|
345
549
|
},
|
|
346
|
-
highlight: ({ children }) => /* @__PURE__ */
|
|
550
|
+
highlight: ({ children }) => /* @__PURE__ */ jsx3("mark", { className: "bg-accent text-accent-foreground", children })
|
|
347
551
|
}
|
|
348
552
|
}
|
|
349
553
|
});
|
|
350
554
|
const combinedClassName = ["tiptap-renderer", className].filter(Boolean).join(" ");
|
|
351
|
-
return /* @__PURE__ */
|
|
555
|
+
return /* @__PURE__ */ jsx3("div", { className: "text-editor flex flex-col gap-4", children: /* @__PURE__ */ jsx3("div", { className: combinedClassName, children: rendered }) });
|
|
352
556
|
}
|
|
353
557
|
export {
|
|
354
558
|
TextRenderer
|