@adatechnology/content-ui 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +26 -0
- package/dist/index.d.ts +197 -35
- package/dist/index.js +854 -237
- package/dist/index.js.map +1 -1
- package/dist/styles.css +119 -1
- package/dist/styles.css.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -91,7 +91,39 @@ var en_default = {
|
|
|
91
91
|
shareOn: "Share on {network}",
|
|
92
92
|
notFound: "Post not found.",
|
|
93
93
|
postsEmpty: "No posts published yet.",
|
|
94
|
-
clearFilters: "Clear filters"
|
|
94
|
+
clearFilters: "Clear filters",
|
|
95
|
+
bodyHintToolbar: "Select text and use the buttons above. Shortcuts: Ctrl+B bold, Ctrl+I italic, Ctrl+K link.",
|
|
96
|
+
toolbarLabel: "Text formatting",
|
|
97
|
+
formatBold: "Bold",
|
|
98
|
+
formatItalic: "Italic",
|
|
99
|
+
formatHeading2: "Heading",
|
|
100
|
+
formatHeading3: "Subheading",
|
|
101
|
+
formatBulletList: "Bulleted list",
|
|
102
|
+
formatNumberedList: "Numbered list",
|
|
103
|
+
formatQuote: "Quote",
|
|
104
|
+
formatLink: "Link",
|
|
105
|
+
formatImage: "Image",
|
|
106
|
+
formatEmoji: "Emoji",
|
|
107
|
+
formatSampleText: "text",
|
|
108
|
+
linkDialogTitle: "Insert link",
|
|
109
|
+
linkUrl: "Link address (URL)",
|
|
110
|
+
linkText: "Link text",
|
|
111
|
+
imageDialogTitle: "Insert image",
|
|
112
|
+
imageUploadFromDevice: "Upload from device",
|
|
113
|
+
dialogInsert: "Insert",
|
|
114
|
+
dialogCancel: "Cancel",
|
|
115
|
+
fileNoneChosen: "No file chosen",
|
|
116
|
+
emojiTitle: "Choose emoji",
|
|
117
|
+
emojiSearch: "Search emoji",
|
|
118
|
+
emojiCategories: "Emoji categories",
|
|
119
|
+
emojiEmpty: "No emoji found.",
|
|
120
|
+
emojiSmileys: "Faces",
|
|
121
|
+
emojiGestures: "Gestures",
|
|
122
|
+
emojiFood: "Food",
|
|
123
|
+
emojiNature: "Nature",
|
|
124
|
+
emojiTravel: "Places",
|
|
125
|
+
emojiObjects: "Objects",
|
|
126
|
+
emojiSymbols: "Symbols"
|
|
95
127
|
};
|
|
96
128
|
|
|
97
129
|
// src/locales/pt-BR.json
|
|
@@ -184,7 +216,39 @@ var pt_BR_default = {
|
|
|
184
216
|
shareOn: "Compartilhar no {network}",
|
|
185
217
|
notFound: "Post n\xE3o encontrado.",
|
|
186
218
|
postsEmpty: "Nenhum post publicado ainda.",
|
|
187
|
-
clearFilters: "Limpar filtros"
|
|
219
|
+
clearFilters: "Limpar filtros",
|
|
220
|
+
bodyHintToolbar: "Selecione o texto e use os bot\xF5es acima. Atalhos: Ctrl+B negrito, Ctrl+I it\xE1lico, Ctrl+K link.",
|
|
221
|
+
toolbarLabel: "Formata\xE7\xE3o do texto",
|
|
222
|
+
formatBold: "Negrito",
|
|
223
|
+
formatItalic: "It\xE1lico",
|
|
224
|
+
formatHeading2: "T\xEDtulo",
|
|
225
|
+
formatHeading3: "Subt\xEDtulo",
|
|
226
|
+
formatBulletList: "Lista com marcadores",
|
|
227
|
+
formatNumberedList: "Lista numerada",
|
|
228
|
+
formatQuote: "Cita\xE7\xE3o",
|
|
229
|
+
formatLink: "Link",
|
|
230
|
+
formatImage: "Imagem",
|
|
231
|
+
formatEmoji: "Emoji",
|
|
232
|
+
formatSampleText: "texto",
|
|
233
|
+
linkDialogTitle: "Inserir link",
|
|
234
|
+
linkUrl: "Endere\xE7o do link (URL)",
|
|
235
|
+
linkText: "Texto do link",
|
|
236
|
+
imageDialogTitle: "Inserir imagem",
|
|
237
|
+
imageUploadFromDevice: "Enviar do aparelho",
|
|
238
|
+
dialogInsert: "Inserir",
|
|
239
|
+
dialogCancel: "Cancelar",
|
|
240
|
+
fileNoneChosen: "Nenhum arquivo escolhido",
|
|
241
|
+
emojiTitle: "Escolher emoji",
|
|
242
|
+
emojiSearch: "Buscar emoji",
|
|
243
|
+
emojiCategories: "Categorias de emoji",
|
|
244
|
+
emojiEmpty: "Nenhum emoji encontrado.",
|
|
245
|
+
emojiSmileys: "Rostos",
|
|
246
|
+
emojiGestures: "Gestos",
|
|
247
|
+
emojiFood: "Comida",
|
|
248
|
+
emojiNature: "Natureza",
|
|
249
|
+
emojiTravel: "Lugares",
|
|
250
|
+
emojiObjects: "Objetos",
|
|
251
|
+
emojiSymbols: "S\xEDmbolos"
|
|
188
252
|
};
|
|
189
253
|
|
|
190
254
|
// src/locales/index.ts
|
|
@@ -250,11 +314,11 @@ function useRenderLink() {
|
|
|
250
314
|
}
|
|
251
315
|
|
|
252
316
|
// src/components/ContentWorkspace.tsx
|
|
253
|
-
import { useState as
|
|
317
|
+
import { useState as useState11 } from "react";
|
|
254
318
|
|
|
255
319
|
// src/components/PostEditor.tsx
|
|
256
|
-
import { Archive as Archive2, ArrowLeft, CalendarClock as CalendarClock2, EyeOff,
|
|
257
|
-
import { useId as
|
|
320
|
+
import { Archive as Archive2, ArrowLeft, CalendarClock as CalendarClock2, EyeOff, Save, Send, Trash2 } from "lucide-react";
|
|
321
|
+
import { useId as useId5, useState as useState9 } from "react";
|
|
258
322
|
|
|
259
323
|
// src/hooks/usePostEditor.ts
|
|
260
324
|
import { useCallback as useCallback2, useEffect as useEffect2, useMemo as useMemo2, useState as useState2 } from "react";
|
|
@@ -484,20 +548,25 @@ function usePostEditor(params) {
|
|
|
484
548
|
setIsBusy(false);
|
|
485
549
|
}
|
|
486
550
|
}
|
|
487
|
-
async function
|
|
488
|
-
if (!api.uploadCoverImage) return;
|
|
489
|
-
if (!COVER_MIME_TYPES.includes(file.type)) return
|
|
490
|
-
if (file.size > COVER_MAX_BYTES) return
|
|
551
|
+
async function uploadImage(file) {
|
|
552
|
+
if (!api.uploadCoverImage) return { error: "coverUploadError" };
|
|
553
|
+
if (!COVER_MIME_TYPES.includes(file.type)) return { error: "coverInvalidType" };
|
|
554
|
+
if (file.size > COVER_MAX_BYTES) return { error: "coverTooLarge" };
|
|
491
555
|
setIsUploading(true);
|
|
492
556
|
try {
|
|
493
557
|
const { url } = await api.uploadCoverImage(file);
|
|
494
|
-
|
|
558
|
+
return { url };
|
|
495
559
|
} catch {
|
|
496
|
-
|
|
560
|
+
return { error: "coverUploadError" };
|
|
497
561
|
} finally {
|
|
498
562
|
setIsUploading(false);
|
|
499
563
|
}
|
|
500
564
|
}
|
|
565
|
+
async function uploadCover(file) {
|
|
566
|
+
const result = await uploadImage(file);
|
|
567
|
+
if ("error" in result) return setFeedback(result.error);
|
|
568
|
+
update("coverImageUrl", result.url);
|
|
569
|
+
}
|
|
501
570
|
return {
|
|
502
571
|
post,
|
|
503
572
|
draft,
|
|
@@ -517,7 +586,8 @@ function usePostEditor(params) {
|
|
|
517
586
|
schedule,
|
|
518
587
|
unpublish,
|
|
519
588
|
archive,
|
|
520
|
-
uploadCover
|
|
589
|
+
uploadCover,
|
|
590
|
+
uploadImage
|
|
521
591
|
};
|
|
522
592
|
}
|
|
523
593
|
|
|
@@ -537,6 +607,38 @@ function useUnsavedChangesGuard(isDirty, message) {
|
|
|
537
607
|
return { confirmLeave };
|
|
538
608
|
}
|
|
539
609
|
|
|
610
|
+
// src/components/FilePicker.tsx
|
|
611
|
+
import { ImageUp } from "lucide-react";
|
|
612
|
+
import { useRef as useRef2, useState as useState3 } from "react";
|
|
613
|
+
import { jsx as jsx2, jsxs } from "react/jsx-runtime";
|
|
614
|
+
function FilePicker({ buttonLabel, emptyLabel, accept, isBusy = false, onPick }) {
|
|
615
|
+
const inputRef = useRef2(null);
|
|
616
|
+
const [fileName, setFileName] = useState3("");
|
|
617
|
+
return /* @__PURE__ */ jsxs("div", { className: "adc-file-picker", children: [
|
|
618
|
+
/* @__PURE__ */ jsxs("button", { type: "button", className: "adc-button", disabled: isBusy, onClick: () => inputRef.current?.click(), children: [
|
|
619
|
+
/* @__PURE__ */ jsx2(ImageUp, { "aria-hidden": "true", className: "adc-icon" }),
|
|
620
|
+
buttonLabel
|
|
621
|
+
] }),
|
|
622
|
+
/* @__PURE__ */ jsx2("span", { className: "adc-file-name", "aria-live": "polite", children: fileName || emptyLabel }),
|
|
623
|
+
/* @__PURE__ */ jsx2(
|
|
624
|
+
"input",
|
|
625
|
+
{
|
|
626
|
+
ref: inputRef,
|
|
627
|
+
hidden: true,
|
|
628
|
+
type: "file",
|
|
629
|
+
accept,
|
|
630
|
+
onChange: (event) => {
|
|
631
|
+
const file = event.target.files?.[0];
|
|
632
|
+
event.target.value = "";
|
|
633
|
+
if (!file) return;
|
|
634
|
+
setFileName(file.name);
|
|
635
|
+
onPick(file);
|
|
636
|
+
}
|
|
637
|
+
}
|
|
638
|
+
)
|
|
639
|
+
] });
|
|
640
|
+
}
|
|
641
|
+
|
|
540
642
|
// src/components/MarkdownContent.tsx
|
|
541
643
|
import {
|
|
542
644
|
createHeadingIdGenerator,
|
|
@@ -547,26 +649,26 @@ import {
|
|
|
547
649
|
resolveHeadingLevel
|
|
548
650
|
} from "@adatechnology/content-contracts";
|
|
549
651
|
import { useMemo as useMemo3 } from "react";
|
|
550
|
-
import { jsx as
|
|
652
|
+
import { jsx as jsx3 } from "react/jsx-runtime";
|
|
551
653
|
function renderInline(nodes) {
|
|
552
654
|
return nodes.map((node, index) => {
|
|
553
655
|
switch (node.type) {
|
|
554
656
|
case "text":
|
|
555
657
|
return node.value;
|
|
556
658
|
case "strong":
|
|
557
|
-
return /* @__PURE__ */
|
|
659
|
+
return /* @__PURE__ */ jsx3("strong", { children: renderInline(node.children) }, index);
|
|
558
660
|
case "emphasis":
|
|
559
|
-
return /* @__PURE__ */
|
|
661
|
+
return /* @__PURE__ */ jsx3("em", { children: renderInline(node.children) }, index);
|
|
560
662
|
case "strikethrough":
|
|
561
|
-
return /* @__PURE__ */
|
|
663
|
+
return /* @__PURE__ */ jsx3("del", { children: renderInline(node.children) }, index);
|
|
562
664
|
case "inlineCode":
|
|
563
|
-
return /* @__PURE__ */
|
|
665
|
+
return /* @__PURE__ */ jsx3("code", { children: node.value }, index);
|
|
564
666
|
case "break":
|
|
565
|
-
return /* @__PURE__ */
|
|
667
|
+
return /* @__PURE__ */ jsx3("br", {}, index);
|
|
566
668
|
case "image":
|
|
567
|
-
return /* @__PURE__ */
|
|
669
|
+
return /* @__PURE__ */ jsx3("img", { src: node.src, alt: node.alt, title: node.title, loading: "lazy", decoding: "async" }, index);
|
|
568
670
|
case "link":
|
|
569
|
-
return /* @__PURE__ */
|
|
671
|
+
return /* @__PURE__ */ jsx3(
|
|
570
672
|
"a",
|
|
571
673
|
{
|
|
572
674
|
href: node.href,
|
|
@@ -584,32 +686,521 @@ function renderBlock(block, key, context, tight = false) {
|
|
|
584
686
|
switch (block.type) {
|
|
585
687
|
case "heading": {
|
|
586
688
|
const Tag = `h${resolveHeadingLevel(block.level, context.offset)}`;
|
|
587
|
-
return /* @__PURE__ */
|
|
689
|
+
return /* @__PURE__ */ jsx3(Tag, { id: context.nextHeadingId(inlineToPlainText(block.children)), children: renderInline(block.children) }, key);
|
|
588
690
|
}
|
|
589
691
|
case "paragraph":
|
|
590
|
-
return tight ? /* @__PURE__ */
|
|
692
|
+
return tight ? /* @__PURE__ */ jsx3("span", { children: renderInline(block.children) }, key) : /* @__PURE__ */ jsx3("p", { children: renderInline(block.children) }, key);
|
|
591
693
|
case "blockquote":
|
|
592
|
-
return /* @__PURE__ */
|
|
694
|
+
return /* @__PURE__ */ jsx3("blockquote", { children: block.children.map((child, index) => renderBlock(child, index, context)) }, key);
|
|
593
695
|
case "codeBlock":
|
|
594
|
-
return /* @__PURE__ */
|
|
696
|
+
return /* @__PURE__ */ jsx3("pre", { children: /* @__PURE__ */ jsx3("code", { className: block.language ? `language-${block.language}` : void 0, children: block.value }) }, key);
|
|
595
697
|
case "thematicBreak":
|
|
596
|
-
return /* @__PURE__ */
|
|
698
|
+
return /* @__PURE__ */ jsx3("hr", {}, key);
|
|
597
699
|
case "list": {
|
|
598
|
-
const items = block.items.map((item, index) => /* @__PURE__ */
|
|
599
|
-
return block.ordered ? /* @__PURE__ */
|
|
700
|
+
const items = block.items.map((item, index) => /* @__PURE__ */ jsx3("li", { children: item.map((child, childIndex) => renderBlock(child, childIndex, context, block.tight)) }, index));
|
|
701
|
+
return block.ordered ? /* @__PURE__ */ jsx3("ol", { start: block.start, children: items }, key) : /* @__PURE__ */ jsx3("ul", { children: items }, key);
|
|
600
702
|
}
|
|
601
703
|
}
|
|
602
704
|
}
|
|
603
705
|
function MarkdownContent({ markdown, headingLevelOffset = 0, className }) {
|
|
604
706
|
const document = useMemo3(() => parseMarkdown(markdown), [markdown]);
|
|
605
707
|
const context = { offset: headingLevelOffset, nextHeadingId: createHeadingIdGenerator() };
|
|
606
|
-
return /* @__PURE__ */
|
|
708
|
+
return /* @__PURE__ */ jsx3("div", { className: ["adc-prose", className].filter(Boolean).join(" "), children: document.children.map((block, index) => renderBlock(block, index, context)) });
|
|
709
|
+
}
|
|
710
|
+
|
|
711
|
+
// src/components/MarkdownEditor.tsx
|
|
712
|
+
import {
|
|
713
|
+
Bold,
|
|
714
|
+
Heading2,
|
|
715
|
+
Heading3,
|
|
716
|
+
Image as ImageIcon,
|
|
717
|
+
Italic,
|
|
718
|
+
Link as LinkIcon,
|
|
719
|
+
List,
|
|
720
|
+
ListOrdered,
|
|
721
|
+
Quote,
|
|
722
|
+
Smile
|
|
723
|
+
} from "lucide-react";
|
|
724
|
+
import { useLayoutEffect, useRef as useRef3, useState as useState7 } from "react";
|
|
725
|
+
|
|
726
|
+
// src/lib/markdownFormat.ts
|
|
727
|
+
var LINE_PREFIX_PATTERN = {
|
|
728
|
+
heading2: /^## /,
|
|
729
|
+
heading3: /^### /,
|
|
730
|
+
bulletList: /^[-*+] /,
|
|
731
|
+
numberedList: /^\d+\. /,
|
|
732
|
+
quote: /^> /
|
|
733
|
+
};
|
|
734
|
+
var ANY_BLOCK_PREFIX = /^(#{1,6} |[-*+] |\d+\. |> )/;
|
|
735
|
+
function replaceRange(source, from, to, text, select) {
|
|
736
|
+
return {
|
|
737
|
+
value: source.value.slice(0, from) + text + source.value.slice(to),
|
|
738
|
+
start: from + select[0],
|
|
739
|
+
end: from + select[1]
|
|
740
|
+
};
|
|
741
|
+
}
|
|
742
|
+
function insertText(source, text) {
|
|
743
|
+
return replaceRange(source, source.start, source.end, text, [text.length, text.length]);
|
|
744
|
+
}
|
|
745
|
+
function toggleWrap(source, marker, placeholder) {
|
|
746
|
+
const { value, start, end } = source;
|
|
747
|
+
const selected = value.slice(start, end);
|
|
748
|
+
const isWrappedOutside = value.slice(start - marker.length, start) === marker && value.slice(end, end + marker.length) === marker;
|
|
749
|
+
if (isWrappedOutside && start >= marker.length) {
|
|
750
|
+
return replaceRange(source, start - marker.length, end + marker.length, selected, [0, selected.length]);
|
|
751
|
+
}
|
|
752
|
+
const isWrappedInside = selected.length > marker.length * 2 && selected.startsWith(marker) && selected.endsWith(marker);
|
|
753
|
+
if (isWrappedInside) {
|
|
754
|
+
const inner = selected.slice(marker.length, selected.length - marker.length);
|
|
755
|
+
return replaceRange(source, start, end, inner, [0, inner.length]);
|
|
756
|
+
}
|
|
757
|
+
const content = selected || placeholder;
|
|
758
|
+
return replaceRange(source, start, end, `${marker}${content}${marker}`, [
|
|
759
|
+
marker.length,
|
|
760
|
+
marker.length + content.length
|
|
761
|
+
]);
|
|
762
|
+
}
|
|
763
|
+
function lineBounds(value, start, end) {
|
|
764
|
+
const from = value.lastIndexOf("\n", start - 1) + 1;
|
|
765
|
+
const nextBreak = value.indexOf("\n", end > start && value[end - 1] === "\n" ? end - 1 : end);
|
|
766
|
+
return { from, to: nextBreak === -1 ? value.length : nextBreak };
|
|
767
|
+
}
|
|
768
|
+
function toggleLinePrefix(source, kind, placeholder) {
|
|
769
|
+
const { from, to } = lineBounds(source.value, source.start, source.end);
|
|
770
|
+
const block = source.value.slice(from, to);
|
|
771
|
+
const lines = block.split("\n");
|
|
772
|
+
const pattern = LINE_PREFIX_PATTERN[kind];
|
|
773
|
+
const isAlreadyApplied = lines.every((line) => pattern.test(line));
|
|
774
|
+
const next = lines.map((line, index) => {
|
|
775
|
+
const bare = line.replace(ANY_BLOCK_PREFIX, "");
|
|
776
|
+
if (isAlreadyApplied) return bare;
|
|
777
|
+
const text = bare || (lines.length === 1 ? placeholder : "");
|
|
778
|
+
if (kind === "heading2") return `## ${text}`;
|
|
779
|
+
if (kind === "heading3") return `### ${text}`;
|
|
780
|
+
if (kind === "bulletList") return `- ${text}`;
|
|
781
|
+
if (kind === "numberedList") return `${index + 1}. ${text}`;
|
|
782
|
+
return `> ${text}`;
|
|
783
|
+
});
|
|
784
|
+
const result = next.join("\n");
|
|
785
|
+
return replaceRange(source, from, to, result, [0, result.length]);
|
|
786
|
+
}
|
|
787
|
+
function insertLink(source, params) {
|
|
788
|
+
const label = params.text?.trim() || source.value.slice(source.start, source.end) || params.url;
|
|
789
|
+
const markdown = `[${label}](${params.url})`;
|
|
790
|
+
return replaceRange(source, source.start, source.end, markdown, [markdown.length, markdown.length]);
|
|
791
|
+
}
|
|
792
|
+
function insertImage(source, params) {
|
|
793
|
+
const markdown = `![${params.alt.replace(/[\][]/g, "")}](${params.url})`;
|
|
794
|
+
return replaceRange(source, source.start, source.end, markdown, [markdown.length, markdown.length]);
|
|
795
|
+
}
|
|
796
|
+
function isAbsoluteUrl(value) {
|
|
797
|
+
try {
|
|
798
|
+
const { protocol } = new URL(value.trim());
|
|
799
|
+
return protocol === "http:" || protocol === "https:";
|
|
800
|
+
} catch {
|
|
801
|
+
return false;
|
|
802
|
+
}
|
|
803
|
+
}
|
|
804
|
+
|
|
805
|
+
// src/components/EmojiPicker.tsx
|
|
806
|
+
import { useId, useState as useState4 } from "react";
|
|
807
|
+
|
|
808
|
+
// src/lib/emoji.ts
|
|
809
|
+
var EMOJI_CATEGORIES = [
|
|
810
|
+
"smileys",
|
|
811
|
+
"gestures",
|
|
812
|
+
"food",
|
|
813
|
+
"nature",
|
|
814
|
+
"travel",
|
|
815
|
+
"objects",
|
|
816
|
+
"symbols"
|
|
817
|
+
];
|
|
818
|
+
function entries(raw) {
|
|
819
|
+
return raw.split("|").map((item) => {
|
|
820
|
+
const [char = "", keywords = ""] = item.split(":");
|
|
821
|
+
return { char, keywords };
|
|
822
|
+
});
|
|
823
|
+
}
|
|
824
|
+
var EMOJI_BY_CATEGORY = {
|
|
825
|
+
smileys: entries(
|
|
826
|
+
"\u{1F600}:sorriso smile happy feliz|\u{1F601}:alegre grin|\u{1F602}:rindo lol laugh|\u{1F60A}:feliz blush|\u{1F60D}:amei love apaixonado|\u{1F60E}:legal cool|\u{1F609}:piscada wink|\u{1F970}:carinho|\u{1F618}:beijo kiss|\u{1F914}:pensando think|\u{1F605}:aliviado|\u{1F622}:triste sad cry|\u{1F62D}:chorando|\u{1F621}:bravo angry|\u{1F634}:sono sleep|\u{1F929}:uau wow estrela|\u{1F642}:simples|\u{1F643}:invertido|\u{1F607}:anjo|\u{1F973}:festa party|\u{1F60B}:gostoso yum|\u{1F917}:abraco hug|\u{1F62E}:surpreso|\u{1F62C}:sem graca"
|
|
827
|
+
),
|
|
828
|
+
gestures: entries(
|
|
829
|
+
"\u{1F44D}:joia like ok|\u{1F44E}:nao dislike|\u{1F44F}:palmas clap|\u{1F64C}:comemorar hooray|\u{1F64F}:obrigado por favor thanks pray|\u{1F4AA}:forca strong|\u{1F44B}:oi tchau wave|\u{1F91D}:acordo handshake|\u270C\uFE0F:paz peace|\u{1F44C}:perfeito|\u{1F449}:direita point|\u{1F447}:baixo|\u261D\uFE0F:cima|\u270D\uFE0F:escrever write|\u{1F91E}:torcendo"
|
|
830
|
+
),
|
|
831
|
+
food: entries(
|
|
832
|
+
"\u{1F355}:pizza|\u{1F354}:hamburguer burger|\u{1F35F}:batata fritas|\u{1F32D}:cachorro quente|\u{1F363}:sushi|\u{1F35D}:massa pasta|\u{1F957}:salada salad|\u{1F370}:bolo cake|\u{1F36B}:chocolate|\u{1F377}:vinho wine|\u{1F37A}:cerveja beer|\u{1F379}:drink coquetel|\u2615:cafe coffee|\u{1F942}:brinde cheers|\u{1F34E}:maca apple|\u{1F353}:morango|\u{1F349}:melancia|\u{1F950}:croissant|\u{1F969}:carne steak|\u{1F366}:sorvete ice cream"
|
|
833
|
+
),
|
|
834
|
+
nature: entries(
|
|
835
|
+
"\u{1F31E}:sol sun|\u{1F319}:lua moon|\u2B50:estrela star|\u{1F308}:arco-iris rainbow|\u{1F525}:fogo fire|\u{1F4A7}:agua water|\u{1F338}:flor flower|\u{1F339}:rosa|\u{1F333}:arvore tree|\u{1F334}:palmeira palm|\u{1F340}:trevo|\u{1F436}:cachorro dog|\u{1F431}:gato cat|\u{1F41F}:peixe fish|\u{1F98B}:borboleta"
|
|
836
|
+
),
|
|
837
|
+
travel: entries(
|
|
838
|
+
"\u{1F697}:carro car|\u{1F68C}:onibus|\u2708\uFE0F:aviao plane|\u{1F6B2}:bicicleta|\u{1F3E0}:casa home|\u{1F3D6}\uFE0F:praia beach|\u{1F3DD}\uFE0F:ilha|\u{1F3E8}:hotel|\u{1F4CD}:local pin|\u{1F5FA}\uFE0F:mapa map|\u26F1\uFE0F:guarda-sol|\u{1F3A1}:roda gigante|\u{1F306}:cidade|\u{1F6CD}\uFE0F:compras shopping"
|
|
839
|
+
),
|
|
840
|
+
objects: entries(
|
|
841
|
+
"\u{1F389}:festa celebracao party|\u{1F381}:presente gift|\u{1F382}:aniversario birthday|\u{1F3B6}:musica music|\u{1F4E3}:aviso megaphone|\u{1F4E2}:anuncio|\u{1F4C5}:calendario calendar data|\u23F0:horario clock|\u{1F4DE}:telefone phone|\u{1F4F1}:celular mobile|\u{1F4BB}:computador|\u{1F4F7}:foto camera|\u{1F39F}\uFE0F:ingresso ticket|\u{1F3C6}:trofeu trophy|\u{1F4A1}:ideia idea|\u{1F514}:sino bell|\u{1F4CC}:fixado|\u{1F511}:chave key"
|
|
842
|
+
),
|
|
843
|
+
symbols: entries(
|
|
844
|
+
"\u2764\uFE0F:coracao heart amor|\u{1F49B}:amarelo|\u{1F499}:azul|\u{1F49A}:verde|\u2728:brilho sparkles novo|\u2705:ok check|\u274C:erro x|\u26A0\uFE0F:atencao warning|\u2757:importante|\u2753:pergunta|\u27A1\uFE0F:seta arrow|\u2B06\uFE0F:cima|\u{1F4AF}:cem 100|\u{1F195}:novo new|\u{1F51D}:topo|\u{1F4AC}:conversa chat|\u{1F4B0}:dinheiro money|\u{1F193}:gratis free|\u267B\uFE0F:reciclar"
|
|
845
|
+
)
|
|
846
|
+
};
|
|
847
|
+
function searchEmoji(query) {
|
|
848
|
+
const needle = query.trim().toLowerCase();
|
|
849
|
+
if (!needle) return [];
|
|
850
|
+
return EMOJI_CATEGORIES.flatMap((category) => EMOJI_BY_CATEGORY[category]).filter(
|
|
851
|
+
(entry) => entry.keywords.toLowerCase().includes(needle)
|
|
852
|
+
);
|
|
853
|
+
}
|
|
854
|
+
|
|
855
|
+
// src/components/EmojiPicker.tsx
|
|
856
|
+
import { jsx as jsx4, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
857
|
+
var CATEGORY_MESSAGE = {
|
|
858
|
+
smileys: "emojiSmileys",
|
|
859
|
+
gestures: "emojiGestures",
|
|
860
|
+
food: "emojiFood",
|
|
861
|
+
nature: "emojiNature",
|
|
862
|
+
travel: "emojiTravel",
|
|
863
|
+
objects: "emojiObjects",
|
|
864
|
+
symbols: "emojiSymbols"
|
|
865
|
+
};
|
|
866
|
+
function EmojiPicker({ onPick, onClose }) {
|
|
867
|
+
const { messages } = useContentText();
|
|
868
|
+
const [category, setCategory] = useState4("smileys");
|
|
869
|
+
const [query, setQuery] = useState4("");
|
|
870
|
+
const searchId = useId();
|
|
871
|
+
const isSearching = query.trim().length > 0;
|
|
872
|
+
const visible = isSearching ? searchEmoji(query) : EMOJI_BY_CATEGORY[category];
|
|
873
|
+
return /* @__PURE__ */ jsxs2(
|
|
874
|
+
"div",
|
|
875
|
+
{
|
|
876
|
+
className: "adc-popover adc-emoji",
|
|
877
|
+
role: "dialog",
|
|
878
|
+
"aria-label": messages.emojiTitle,
|
|
879
|
+
onKeyDown: (event) => {
|
|
880
|
+
if (event.key !== "Escape") return;
|
|
881
|
+
event.stopPropagation();
|
|
882
|
+
onClose();
|
|
883
|
+
},
|
|
884
|
+
children: [
|
|
885
|
+
/* @__PURE__ */ jsx4("label", { htmlFor: searchId, className: "adc-visually-hidden", children: messages.emojiSearch }),
|
|
886
|
+
/* @__PURE__ */ jsx4(
|
|
887
|
+
"input",
|
|
888
|
+
{
|
|
889
|
+
id: searchId,
|
|
890
|
+
type: "text",
|
|
891
|
+
role: "searchbox",
|
|
892
|
+
autoFocus: true,
|
|
893
|
+
placeholder: messages.emojiSearch,
|
|
894
|
+
value: query,
|
|
895
|
+
onChange: (event) => setQuery(event.target.value),
|
|
896
|
+
onKeyDown: (event) => {
|
|
897
|
+
if (event.key === "Enter") event.preventDefault();
|
|
898
|
+
}
|
|
899
|
+
}
|
|
900
|
+
),
|
|
901
|
+
!isSearching && /* @__PURE__ */ jsx4("div", { className: "adc-emoji-categories", role: "group", "aria-label": messages.emojiCategories, children: EMOJI_CATEGORIES.map((value) => /* @__PURE__ */ jsx4(
|
|
902
|
+
"button",
|
|
903
|
+
{
|
|
904
|
+
type: "button",
|
|
905
|
+
className: "adc-tab",
|
|
906
|
+
"aria-pressed": category === value,
|
|
907
|
+
onClick: () => setCategory(value),
|
|
908
|
+
children: messages[CATEGORY_MESSAGE[value]]
|
|
909
|
+
},
|
|
910
|
+
value
|
|
911
|
+
)) }),
|
|
912
|
+
visible.length === 0 ? /* @__PURE__ */ jsx4("p", { className: "adc-muted", role: "status", children: messages.emojiEmpty }) : /* @__PURE__ */ jsx4("div", { className: "adc-emoji-grid", children: visible.map((entry) => /* @__PURE__ */ jsx4(
|
|
913
|
+
"button",
|
|
914
|
+
{
|
|
915
|
+
type: "button",
|
|
916
|
+
className: "adc-emoji-button",
|
|
917
|
+
"aria-label": entry.keywords.split(" ")[0] ?? entry.char,
|
|
918
|
+
onClick: () => onPick(entry.char),
|
|
919
|
+
children: entry.char
|
|
920
|
+
},
|
|
921
|
+
entry.char
|
|
922
|
+
)) })
|
|
923
|
+
]
|
|
924
|
+
}
|
|
925
|
+
);
|
|
926
|
+
}
|
|
927
|
+
|
|
928
|
+
// src/components/InsertDialog.tsx
|
|
929
|
+
import { useId as useId2, useState as useState5 } from "react";
|
|
930
|
+
import { jsx as jsx5, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
931
|
+
function InsertDialog(props) {
|
|
932
|
+
const { messages } = useContentText();
|
|
933
|
+
const [url, setUrl] = useState5("");
|
|
934
|
+
const [text, setText] = useState5(props.initialText);
|
|
935
|
+
const [errorMessage, setErrorMessage] = useState5("");
|
|
936
|
+
const urlId = useId2();
|
|
937
|
+
const textId = useId2();
|
|
938
|
+
const isImage = props.kind === "image";
|
|
939
|
+
function submit() {
|
|
940
|
+
if (!isAbsoluteUrl(url)) return setErrorMessage(messages.errorUrl);
|
|
941
|
+
if (props.kind === "image") props.onSubmit({ url: url.trim(), alt: text });
|
|
942
|
+
else props.onSubmit({ url: url.trim(), text });
|
|
943
|
+
}
|
|
944
|
+
async function handlePick(file) {
|
|
945
|
+
if (props.kind !== "image" || !props.onUpload) return;
|
|
946
|
+
setErrorMessage("");
|
|
947
|
+
const result = await props.onUpload(file);
|
|
948
|
+
if ("error" in result) return setErrorMessage(messages[result.error]);
|
|
949
|
+
setUrl(result.url);
|
|
950
|
+
}
|
|
951
|
+
function handleKeyDown(event) {
|
|
952
|
+
if (event.key === "Escape") {
|
|
953
|
+
event.stopPropagation();
|
|
954
|
+
props.onClose();
|
|
955
|
+
}
|
|
956
|
+
if (event.key === "Enter" && event.target instanceof HTMLInputElement) {
|
|
957
|
+
event.preventDefault();
|
|
958
|
+
submit();
|
|
959
|
+
}
|
|
960
|
+
}
|
|
961
|
+
return /* @__PURE__ */ jsxs3(
|
|
962
|
+
"div",
|
|
963
|
+
{
|
|
964
|
+
className: "adc-popover adc-insert",
|
|
965
|
+
role: "dialog",
|
|
966
|
+
"aria-label": isImage ? messages.imageDialogTitle : messages.linkDialogTitle,
|
|
967
|
+
onKeyDown: handleKeyDown,
|
|
968
|
+
children: [
|
|
969
|
+
isImage && props.onUpload && /* @__PURE__ */ jsx5(
|
|
970
|
+
FilePicker,
|
|
971
|
+
{
|
|
972
|
+
buttonLabel: props.isUploading ? messages.coverUploading : messages.imageUploadFromDevice,
|
|
973
|
+
emptyLabel: messages.fileNoneChosen,
|
|
974
|
+
accept: "image/*",
|
|
975
|
+
isBusy: props.isUploading,
|
|
976
|
+
onPick: (file) => void handlePick(file)
|
|
977
|
+
}
|
|
978
|
+
),
|
|
979
|
+
/* @__PURE__ */ jsxs3("div", { className: "adc-field", children: [
|
|
980
|
+
/* @__PURE__ */ jsx5("label", { htmlFor: urlId, children: isImage ? messages.fieldCoverUrl : messages.linkUrl }),
|
|
981
|
+
/* @__PURE__ */ jsx5(
|
|
982
|
+
"input",
|
|
983
|
+
{
|
|
984
|
+
id: urlId,
|
|
985
|
+
type: "url",
|
|
986
|
+
autoFocus: true,
|
|
987
|
+
placeholder: "https://",
|
|
988
|
+
value: url,
|
|
989
|
+
onChange: (event) => setUrl(event.target.value)
|
|
990
|
+
}
|
|
991
|
+
)
|
|
992
|
+
] }),
|
|
993
|
+
/* @__PURE__ */ jsxs3("div", { className: "adc-field", children: [
|
|
994
|
+
/* @__PURE__ */ jsx5("label", { htmlFor: textId, children: isImage ? messages.fieldCoverAlt : messages.linkText }),
|
|
995
|
+
/* @__PURE__ */ jsx5("input", { id: textId, type: "text", value: text, onChange: (event) => setText(event.target.value) })
|
|
996
|
+
] }),
|
|
997
|
+
/* @__PURE__ */ jsx5("p", { className: "adc-error", role: "alert", hidden: !errorMessage, children: errorMessage }),
|
|
998
|
+
/* @__PURE__ */ jsxs3("div", { className: "adc-insert-actions", children: [
|
|
999
|
+
/* @__PURE__ */ jsx5("button", { type: "button", className: "adc-button adc-button--ghost", onClick: props.onClose, children: messages.dialogCancel }),
|
|
1000
|
+
/* @__PURE__ */ jsx5(
|
|
1001
|
+
"button",
|
|
1002
|
+
{
|
|
1003
|
+
type: "button",
|
|
1004
|
+
className: "adc-button adc-button--primary",
|
|
1005
|
+
disabled: isImage && props.isUploading,
|
|
1006
|
+
onClick: submit,
|
|
1007
|
+
children: messages.dialogInsert
|
|
1008
|
+
}
|
|
1009
|
+
)
|
|
1010
|
+
] })
|
|
1011
|
+
]
|
|
1012
|
+
}
|
|
1013
|
+
);
|
|
1014
|
+
}
|
|
1015
|
+
|
|
1016
|
+
// src/components/Tooltip.tsx
|
|
1017
|
+
import { useId as useId3, useState as useState6 } from "react";
|
|
1018
|
+
import { jsx as jsx6, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
1019
|
+
function Tooltip({ text, children }) {
|
|
1020
|
+
const id = useId3();
|
|
1021
|
+
const [isHovered, setIsHovered] = useState6(false);
|
|
1022
|
+
const [isFocused, setIsFocused] = useState6(false);
|
|
1023
|
+
return /* @__PURE__ */ jsxs4(
|
|
1024
|
+
"span",
|
|
1025
|
+
{
|
|
1026
|
+
className: "adc-tip",
|
|
1027
|
+
onMouseEnter: () => setIsHovered(true),
|
|
1028
|
+
onMouseLeave: () => setIsHovered(false),
|
|
1029
|
+
onFocus: () => setIsFocused(true),
|
|
1030
|
+
onBlur: () => setIsFocused(false),
|
|
1031
|
+
onKeyDown: (event) => {
|
|
1032
|
+
if (event.key !== "Escape" || !(isHovered || isFocused)) return;
|
|
1033
|
+
setIsHovered(false);
|
|
1034
|
+
setIsFocused(false);
|
|
1035
|
+
},
|
|
1036
|
+
children: [
|
|
1037
|
+
/* @__PURE__ */ jsx6("span", { "aria-describedby": id, className: "adc-tip-target", children }),
|
|
1038
|
+
/* @__PURE__ */ jsx6("span", { id, role: "tooltip", className: "adc-tooltip", "data-visible": isHovered || isFocused, children: text })
|
|
1039
|
+
]
|
|
1040
|
+
}
|
|
1041
|
+
);
|
|
1042
|
+
}
|
|
1043
|
+
|
|
1044
|
+
// src/components/MarkdownEditor.tsx
|
|
1045
|
+
import { jsx as jsx7, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
1046
|
+
var SIMPLE_ACTIONS = [
|
|
1047
|
+
{ id: "bold", icon: Bold, label: "formatBold", shortcut: "B" },
|
|
1048
|
+
{ id: "italic", icon: Italic, label: "formatItalic", shortcut: "I" },
|
|
1049
|
+
{ id: "heading2", icon: Heading2, label: "formatHeading2" },
|
|
1050
|
+
{ id: "heading3", icon: Heading3, label: "formatHeading3" },
|
|
1051
|
+
{ id: "bulletList", icon: List, label: "formatBulletList" },
|
|
1052
|
+
{ id: "numberedList", icon: ListOrdered, label: "formatNumberedList" },
|
|
1053
|
+
{ id: "quote", icon: Quote, label: "formatQuote" }
|
|
1054
|
+
];
|
|
1055
|
+
function ToolButton({ icon: Icon, text, isExpanded, onClick }) {
|
|
1056
|
+
return /* @__PURE__ */ jsx7(Tooltip, { text, children: /* @__PURE__ */ jsx7(
|
|
1057
|
+
"button",
|
|
1058
|
+
{
|
|
1059
|
+
type: "button",
|
|
1060
|
+
className: "adc-tool",
|
|
1061
|
+
"aria-label": text,
|
|
1062
|
+
...isExpanded === void 0 ? {} : { "aria-expanded": isExpanded },
|
|
1063
|
+
onClick,
|
|
1064
|
+
children: /* @__PURE__ */ jsx7(Icon, { "aria-hidden": "true", className: "adc-icon" })
|
|
1065
|
+
}
|
|
1066
|
+
) });
|
|
1067
|
+
}
|
|
1068
|
+
function MarkdownEditor({
|
|
1069
|
+
value,
|
|
1070
|
+
onChange,
|
|
1071
|
+
labelledBy,
|
|
1072
|
+
describedBy,
|
|
1073
|
+
showToolbar = true,
|
|
1074
|
+
onUploadImage,
|
|
1075
|
+
isUploading = false
|
|
1076
|
+
}) {
|
|
1077
|
+
const { messages } = useContentText();
|
|
1078
|
+
const textareaRef = useRef3(null);
|
|
1079
|
+
const pendingSelection = useRef3(void 0);
|
|
1080
|
+
const savedSelection = useRef3({ value, start: value.length, end: value.length });
|
|
1081
|
+
const [panel, setPanel] = useState7();
|
|
1082
|
+
useLayoutEffect(() => {
|
|
1083
|
+
const pending = pendingSelection.current;
|
|
1084
|
+
const textarea = textareaRef.current;
|
|
1085
|
+
if (!pending || !textarea) return;
|
|
1086
|
+
pendingSelection.current = void 0;
|
|
1087
|
+
textarea.focus();
|
|
1088
|
+
textarea.setSelectionRange(pending.start, pending.end);
|
|
1089
|
+
}, [value]);
|
|
1090
|
+
function readSelection() {
|
|
1091
|
+
const textarea = textareaRef.current;
|
|
1092
|
+
return { value, start: textarea?.selectionStart ?? value.length, end: textarea?.selectionEnd ?? value.length };
|
|
1093
|
+
}
|
|
1094
|
+
function apply(next) {
|
|
1095
|
+
pendingSelection.current = { start: next.start, end: next.end };
|
|
1096
|
+
onChange(next.value);
|
|
1097
|
+
setPanel(void 0);
|
|
1098
|
+
}
|
|
1099
|
+
function run(id) {
|
|
1100
|
+
const selection = readSelection();
|
|
1101
|
+
const sample = messages.formatSampleText;
|
|
1102
|
+
if (id === "bold") return apply(toggleWrap(selection, "**", sample));
|
|
1103
|
+
if (id === "italic") return apply(toggleWrap(selection, "*", sample));
|
|
1104
|
+
apply(toggleLinePrefix(selection, id, sample));
|
|
1105
|
+
}
|
|
1106
|
+
function openPanel(next) {
|
|
1107
|
+
if (panel === next) return setPanel(void 0);
|
|
1108
|
+
savedSelection.current = readSelection();
|
|
1109
|
+
setPanel(next);
|
|
1110
|
+
}
|
|
1111
|
+
function closePanel() {
|
|
1112
|
+
setPanel(void 0);
|
|
1113
|
+
textareaRef.current?.focus();
|
|
1114
|
+
}
|
|
1115
|
+
function handleKeyDown(event) {
|
|
1116
|
+
if (!showToolbar || !(event.ctrlKey || event.metaKey) || event.altKey) return;
|
|
1117
|
+
const key = event.key.toLowerCase();
|
|
1118
|
+
if (key !== "b" && key !== "i" && key !== "k") return;
|
|
1119
|
+
event.preventDefault();
|
|
1120
|
+
if (key === "k") return openPanel("link");
|
|
1121
|
+
run(key === "b" ? "bold" : "italic");
|
|
1122
|
+
}
|
|
1123
|
+
const saved = savedSelection.current;
|
|
1124
|
+
const selectedText = saved.value.slice(saved.start, saved.end);
|
|
1125
|
+
return /* @__PURE__ */ jsxs5("div", { className: "adc-md-editor", children: [
|
|
1126
|
+
showToolbar && /* @__PURE__ */ jsxs5("div", { className: "adc-md-toolbar", role: "toolbar", "aria-label": messages.toolbarLabel, children: [
|
|
1127
|
+
SIMPLE_ACTIONS.map(({ id, icon, label, shortcut }) => /* @__PURE__ */ jsx7(
|
|
1128
|
+
ToolButton,
|
|
1129
|
+
{
|
|
1130
|
+
icon,
|
|
1131
|
+
text: shortcut ? `${messages[label]} (Ctrl+${shortcut})` : messages[label],
|
|
1132
|
+
onClick: () => run(id)
|
|
1133
|
+
},
|
|
1134
|
+
id
|
|
1135
|
+
)),
|
|
1136
|
+
/* @__PURE__ */ jsx7(
|
|
1137
|
+
ToolButton,
|
|
1138
|
+
{
|
|
1139
|
+
icon: LinkIcon,
|
|
1140
|
+
text: `${messages.formatLink} (Ctrl+K)`,
|
|
1141
|
+
isExpanded: panel === "link",
|
|
1142
|
+
onClick: () => openPanel("link")
|
|
1143
|
+
}
|
|
1144
|
+
),
|
|
1145
|
+
/* @__PURE__ */ jsx7(
|
|
1146
|
+
ToolButton,
|
|
1147
|
+
{
|
|
1148
|
+
icon: ImageIcon,
|
|
1149
|
+
text: messages.formatImage,
|
|
1150
|
+
isExpanded: panel === "image",
|
|
1151
|
+
onClick: () => openPanel("image")
|
|
1152
|
+
}
|
|
1153
|
+
),
|
|
1154
|
+
/* @__PURE__ */ jsx7(
|
|
1155
|
+
ToolButton,
|
|
1156
|
+
{
|
|
1157
|
+
icon: Smile,
|
|
1158
|
+
text: messages.formatEmoji,
|
|
1159
|
+
isExpanded: panel === "emoji",
|
|
1160
|
+
onClick: () => openPanel("emoji")
|
|
1161
|
+
}
|
|
1162
|
+
)
|
|
1163
|
+
] }),
|
|
1164
|
+
panel === "link" && /* @__PURE__ */ jsx7(
|
|
1165
|
+
InsertDialog,
|
|
1166
|
+
{
|
|
1167
|
+
kind: "link",
|
|
1168
|
+
initialText: selectedText,
|
|
1169
|
+
onClose: closePanel,
|
|
1170
|
+
onSubmit: (values) => apply(insertLink(saved, values))
|
|
1171
|
+
}
|
|
1172
|
+
),
|
|
1173
|
+
panel === "image" && /* @__PURE__ */ jsx7(
|
|
1174
|
+
InsertDialog,
|
|
1175
|
+
{
|
|
1176
|
+
kind: "image",
|
|
1177
|
+
initialText: "",
|
|
1178
|
+
isUploading,
|
|
1179
|
+
...onUploadImage ? { onUpload: onUploadImage } : {},
|
|
1180
|
+
onClose: closePanel,
|
|
1181
|
+
onSubmit: (values) => apply(insertImage(saved, values))
|
|
1182
|
+
}
|
|
1183
|
+
),
|
|
1184
|
+
panel === "emoji" && /* @__PURE__ */ jsx7(EmojiPicker, { onClose: closePanel, onPick: (emoji) => apply(insertText(saved, emoji)) }),
|
|
1185
|
+
/* @__PURE__ */ jsx7(
|
|
1186
|
+
"textarea",
|
|
1187
|
+
{
|
|
1188
|
+
ref: textareaRef,
|
|
1189
|
+
"aria-labelledby": labelledBy,
|
|
1190
|
+
...describedBy ? { "aria-describedby": describedBy } : {},
|
|
1191
|
+
className: "adc-markdown-input",
|
|
1192
|
+
value,
|
|
1193
|
+
onChange: (event) => onChange(event.target.value),
|
|
1194
|
+
onKeyDown: handleKeyDown
|
|
1195
|
+
}
|
|
1196
|
+
)
|
|
1197
|
+
] });
|
|
607
1198
|
}
|
|
608
1199
|
|
|
609
1200
|
// src/components/StatusChip.tsx
|
|
610
1201
|
import { POST_STATUS } from "@adatechnology/content-contracts";
|
|
611
1202
|
import { Archive, CalendarClock, CircleCheck, PencilLine } from "lucide-react";
|
|
612
|
-
import { jsx as
|
|
1203
|
+
import { jsx as jsx8, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
613
1204
|
var STATUS_VIEW = {
|
|
614
1205
|
[POST_STATUS.DRAFT]: { icon: PencilLine, label: "statusDraft" },
|
|
615
1206
|
[POST_STATUS.SCHEDULED]: { icon: CalendarClock, label: "statusScheduled" },
|
|
@@ -619,8 +1210,8 @@ var STATUS_VIEW = {
|
|
|
619
1210
|
function StatusChip({ status }) {
|
|
620
1211
|
const { messages } = useContentText();
|
|
621
1212
|
const { icon: Icon, label } = STATUS_VIEW[status];
|
|
622
|
-
return /* @__PURE__ */
|
|
623
|
-
/* @__PURE__ */
|
|
1213
|
+
return /* @__PURE__ */ jsxs6("span", { className: `adc-chip adc-chip--${status}`, children: [
|
|
1214
|
+
/* @__PURE__ */ jsx8(Icon, { "aria-hidden": "true", className: "adc-icon" }),
|
|
624
1215
|
messages[label]
|
|
625
1216
|
] });
|
|
626
1217
|
}
|
|
@@ -628,13 +1219,13 @@ function StatusChip({ status }) {
|
|
|
628
1219
|
// src/components/TagsInput.tsx
|
|
629
1220
|
import { normalizeTags, TAGS_MAX_COUNT } from "@adatechnology/content-contracts";
|
|
630
1221
|
import { X } from "lucide-react";
|
|
631
|
-
import { useId, useState as
|
|
632
|
-
import { jsx as
|
|
1222
|
+
import { useId as useId4, useState as useState8 } from "react";
|
|
1223
|
+
import { jsx as jsx9, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
633
1224
|
function TagsInput({ value, onChange, suggestions = [], label }) {
|
|
634
1225
|
const { messages, format } = useContentText();
|
|
635
|
-
const [text, setText] =
|
|
636
|
-
const inputId =
|
|
637
|
-
const listId =
|
|
1226
|
+
const [text, setText] = useState8("");
|
|
1227
|
+
const inputId = useId4();
|
|
1228
|
+
const listId = useId4();
|
|
638
1229
|
function commit(raw) {
|
|
639
1230
|
const added = splitTagInput(raw);
|
|
640
1231
|
if (added.length > 0) onChange(normalizeTags([...value, ...added]));
|
|
@@ -648,23 +1239,23 @@ function TagsInput({ value, onChange, suggestions = [], label }) {
|
|
|
648
1239
|
onChange(value.slice(0, -1));
|
|
649
1240
|
}
|
|
650
1241
|
}
|
|
651
|
-
return /* @__PURE__ */
|
|
652
|
-
/* @__PURE__ */
|
|
653
|
-
/* @__PURE__ */
|
|
654
|
-
value.map((tag) => /* @__PURE__ */
|
|
1242
|
+
return /* @__PURE__ */ jsxs7("div", { className: "adc-field", children: [
|
|
1243
|
+
/* @__PURE__ */ jsx9("label", { htmlFor: inputId, children: label }),
|
|
1244
|
+
/* @__PURE__ */ jsxs7("div", { className: "adc-tags-input", children: [
|
|
1245
|
+
value.map((tag) => /* @__PURE__ */ jsxs7("span", { className: "adc-tag", children: [
|
|
655
1246
|
tag,
|
|
656
|
-
/* @__PURE__ */
|
|
1247
|
+
/* @__PURE__ */ jsx9(
|
|
657
1248
|
"button",
|
|
658
1249
|
{
|
|
659
1250
|
type: "button",
|
|
660
1251
|
className: "adc-tag-remove",
|
|
661
1252
|
"aria-label": format("tagRemove", { tag }),
|
|
662
1253
|
onClick: () => onChange(value.filter((current) => current !== tag)),
|
|
663
|
-
children: /* @__PURE__ */
|
|
1254
|
+
children: /* @__PURE__ */ jsx9(X, { "aria-hidden": "true", className: "adc-icon" })
|
|
664
1255
|
}
|
|
665
1256
|
)
|
|
666
1257
|
] }, tag)),
|
|
667
|
-
/* @__PURE__ */
|
|
1258
|
+
/* @__PURE__ */ jsx9(
|
|
668
1259
|
"input",
|
|
669
1260
|
{
|
|
670
1261
|
id: inputId,
|
|
@@ -678,15 +1269,15 @@ function TagsInput({ value, onChange, suggestions = [], label }) {
|
|
|
678
1269
|
}
|
|
679
1270
|
)
|
|
680
1271
|
] }),
|
|
681
|
-
/* @__PURE__ */
|
|
682
|
-
suggestions.length > 0 && /* @__PURE__ */
|
|
1272
|
+
/* @__PURE__ */ jsx9("small", { id: `${inputId}-hint`, className: "adc-hint", children: messages.tagsHint }),
|
|
1273
|
+
suggestions.length > 0 && /* @__PURE__ */ jsx9("datalist", { id: listId, children: suggestions.filter((tag) => !value.includes(tag)).map((tag) => /* @__PURE__ */ jsx9("option", { value: tag }, tag)) })
|
|
683
1274
|
] });
|
|
684
1275
|
}
|
|
685
1276
|
|
|
686
1277
|
// src/components/PostEditor.tsx
|
|
687
|
-
import { jsx as
|
|
1278
|
+
import { jsx as jsx10, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
688
1279
|
function TextField({ label, value, onChange, error, hint, type = "text", multiline, maxLength }) {
|
|
689
|
-
const id =
|
|
1280
|
+
const id = useId5();
|
|
690
1281
|
const describedBy = [hint ? `${id}-hint` : "", error ? `${id}-error` : ""].filter(Boolean).join(" ") || void 0;
|
|
691
1282
|
const common = {
|
|
692
1283
|
id,
|
|
@@ -695,20 +1286,28 @@ function TextField({ label, value, onChange, error, hint, type = "text", multili
|
|
|
695
1286
|
"aria-invalid": error ? true : void 0,
|
|
696
1287
|
"aria-describedby": describedBy
|
|
697
1288
|
};
|
|
698
|
-
return /* @__PURE__ */
|
|
699
|
-
/* @__PURE__ */
|
|
700
|
-
multiline ? /* @__PURE__ */
|
|
701
|
-
hint && /* @__PURE__ */
|
|
702
|
-
error && /* @__PURE__ */
|
|
1289
|
+
return /* @__PURE__ */ jsxs8("div", { className: "adc-field", children: [
|
|
1290
|
+
/* @__PURE__ */ jsx10("label", { htmlFor: id, children: label }),
|
|
1291
|
+
multiline ? /* @__PURE__ */ jsx10("textarea", { ...common, rows: 3, onChange: (event) => onChange(event.target.value) }) : /* @__PURE__ */ jsx10("input", { ...common, type, onChange: (event) => onChange(event.target.value) }),
|
|
1292
|
+
hint && /* @__PURE__ */ jsx10("small", { id: `${id}-hint`, className: "adc-hint", children: hint }),
|
|
1293
|
+
error && /* @__PURE__ */ jsx10("small", { id: `${id}-error`, className: "adc-error", children: error })
|
|
703
1294
|
] });
|
|
704
1295
|
}
|
|
705
1296
|
function Section({ title, children }) {
|
|
706
|
-
return /* @__PURE__ */
|
|
707
|
-
/* @__PURE__ */
|
|
1297
|
+
return /* @__PURE__ */ jsxs8("fieldset", { className: "adc-section", children: [
|
|
1298
|
+
/* @__PURE__ */ jsx10("legend", { children: title }),
|
|
708
1299
|
children
|
|
709
1300
|
] });
|
|
710
1301
|
}
|
|
711
|
-
function PostEditor({
|
|
1302
|
+
function PostEditor({
|
|
1303
|
+
postId,
|
|
1304
|
+
defaults,
|
|
1305
|
+
onSaved,
|
|
1306
|
+
onArchived,
|
|
1307
|
+
onClose,
|
|
1308
|
+
showFormattingToolbar = true,
|
|
1309
|
+
renderDateTimeInput
|
|
1310
|
+
}) {
|
|
712
1311
|
const { messages, locale, format } = useContentText();
|
|
713
1312
|
const editor = usePostEditor({
|
|
714
1313
|
...postId ? { postId } : {},
|
|
@@ -717,16 +1316,16 @@ function PostEditor({ postId, defaults, onSaved, onArchived, onClose }) {
|
|
|
717
1316
|
...onArchived ? { onArchived } : {}
|
|
718
1317
|
});
|
|
719
1318
|
const { confirmLeave } = useUnsavedChangesGuard(editor.isDirty, messages.unsavedConfirm);
|
|
720
|
-
const [tab, setTab] =
|
|
721
|
-
const bodyId =
|
|
722
|
-
const scheduleId =
|
|
1319
|
+
const [tab, setTab] = useState9("write");
|
|
1320
|
+
const bodyId = useId5();
|
|
1321
|
+
const scheduleId = useId5();
|
|
723
1322
|
const { draft, update, errors, post } = editor;
|
|
724
1323
|
if (editor.isLoading) {
|
|
725
|
-
return /* @__PURE__ */
|
|
1324
|
+
return /* @__PURE__ */ jsx10("p", { className: "adc-root adc-state", role: "status", children: messages.loading });
|
|
726
1325
|
}
|
|
727
1326
|
const status = post?.status;
|
|
728
1327
|
const isLive = status === "published" || status === "scheduled";
|
|
729
|
-
return /* @__PURE__ */
|
|
1328
|
+
return /* @__PURE__ */ jsxs8(
|
|
730
1329
|
"form",
|
|
731
1330
|
{
|
|
732
1331
|
className: "adc-root adc-editor",
|
|
@@ -735,18 +1334,18 @@ function PostEditor({ postId, defaults, onSaved, onArchived, onClose }) {
|
|
|
735
1334
|
void editor.save();
|
|
736
1335
|
},
|
|
737
1336
|
children: [
|
|
738
|
-
/* @__PURE__ */
|
|
739
|
-
onClose && /* @__PURE__ */
|
|
740
|
-
/* @__PURE__ */
|
|
1337
|
+
/* @__PURE__ */ jsxs8("header", { className: "adc-toolbar", children: [
|
|
1338
|
+
onClose && /* @__PURE__ */ jsxs8("button", { type: "button", className: "adc-button adc-button--ghost", onClick: () => confirmLeave() && onClose(), children: [
|
|
1339
|
+
/* @__PURE__ */ jsx10(ArrowLeft, { "aria-hidden": "true", className: "adc-icon" }),
|
|
741
1340
|
messages.close
|
|
742
1341
|
] }),
|
|
743
|
-
/* @__PURE__ */
|
|
744
|
-
status && /* @__PURE__ */
|
|
745
|
-
editor.isDirty && /* @__PURE__ */
|
|
1342
|
+
/* @__PURE__ */ jsx10("h2", { className: "adc-title", children: post ? messages.editorEditTitle : messages.editorNewTitle }),
|
|
1343
|
+
status && /* @__PURE__ */ jsx10(StatusChip, { status }),
|
|
1344
|
+
editor.isDirty && /* @__PURE__ */ jsx10("span", { className: "adc-badge", children: messages.unsavedBadge })
|
|
746
1345
|
] }),
|
|
747
|
-
/* @__PURE__ */
|
|
748
|
-
/* @__PURE__ */
|
|
749
|
-
/* @__PURE__ */
|
|
1346
|
+
/* @__PURE__ */ jsxs8("div", { className: "adc-editor-grid", children: [
|
|
1347
|
+
/* @__PURE__ */ jsxs8("div", { className: "adc-editor-main", children: [
|
|
1348
|
+
/* @__PURE__ */ jsx10(
|
|
750
1349
|
TextField,
|
|
751
1350
|
{
|
|
752
1351
|
label: messages.fieldTitle,
|
|
@@ -756,7 +1355,7 @@ function PostEditor({ postId, defaults, onSaved, onArchived, onClose }) {
|
|
|
756
1355
|
error: errors.title ? messages.errorTitle : void 0
|
|
757
1356
|
}
|
|
758
1357
|
),
|
|
759
|
-
/* @__PURE__ */
|
|
1358
|
+
/* @__PURE__ */ jsx10(
|
|
760
1359
|
TextField,
|
|
761
1360
|
{
|
|
762
1361
|
label: messages.fieldSlug,
|
|
@@ -767,7 +1366,7 @@ function PostEditor({ postId, defaults, onSaved, onArchived, onClose }) {
|
|
|
767
1366
|
error: errors.slug ? messages.errorSlug : void 0
|
|
768
1367
|
}
|
|
769
1368
|
),
|
|
770
|
-
/* @__PURE__ */
|
|
1369
|
+
/* @__PURE__ */ jsx10(
|
|
771
1370
|
TextField,
|
|
772
1371
|
{
|
|
773
1372
|
label: messages.fieldExcerpt,
|
|
@@ -777,10 +1376,10 @@ function PostEditor({ postId, defaults, onSaved, onArchived, onClose }) {
|
|
|
777
1376
|
onChange: (value) => update("excerpt", value)
|
|
778
1377
|
}
|
|
779
1378
|
),
|
|
780
|
-
/* @__PURE__ */
|
|
781
|
-
/* @__PURE__ */
|
|
782
|
-
/* @__PURE__ */
|
|
783
|
-
["write", "preview"].map((value) => /* @__PURE__ */
|
|
1379
|
+
/* @__PURE__ */ jsxs8("div", { className: "adc-field", children: [
|
|
1380
|
+
/* @__PURE__ */ jsxs8("div", { className: "adc-tabs", role: "tablist", "aria-label": messages.fieldBody, children: [
|
|
1381
|
+
/* @__PURE__ */ jsx10("span", { className: "adc-label", id: `${bodyId}-label`, children: messages.fieldBody }),
|
|
1382
|
+
["write", "preview"].map((value) => /* @__PURE__ */ jsx10(
|
|
784
1383
|
"button",
|
|
785
1384
|
{
|
|
786
1385
|
type: "button",
|
|
@@ -794,34 +1393,36 @@ function PostEditor({ postId, defaults, onSaved, onArchived, onClose }) {
|
|
|
794
1393
|
value
|
|
795
1394
|
))
|
|
796
1395
|
] }),
|
|
797
|
-
/* @__PURE__ */
|
|
798
|
-
/* @__PURE__ */
|
|
799
|
-
/* @__PURE__ */
|
|
800
|
-
|
|
1396
|
+
/* @__PURE__ */ jsxs8("div", { className: `adc-body-panes adc-body-panes--${tab}`, children: [
|
|
1397
|
+
/* @__PURE__ */ jsxs8("div", { id: `${bodyId}-write`, role: "tabpanel", className: "adc-pane adc-pane--write", children: [
|
|
1398
|
+
/* @__PURE__ */ jsx10(
|
|
1399
|
+
MarkdownEditor,
|
|
801
1400
|
{
|
|
802
|
-
"aria-labelledby": `${bodyId}-label`,
|
|
803
|
-
"aria-describedby": `${bodyId}-hint`,
|
|
804
|
-
className: "adc-markdown-input",
|
|
805
1401
|
value: draft.body,
|
|
806
|
-
onChange: (
|
|
1402
|
+
onChange: (value) => update("body", value),
|
|
1403
|
+
labelledBy: `${bodyId}-label`,
|
|
1404
|
+
describedBy: `${bodyId}-hint`,
|
|
1405
|
+
showToolbar: showFormattingToolbar,
|
|
1406
|
+
isUploading: editor.isUploading,
|
|
1407
|
+
...editor.canUploadCover ? { onUploadImage: editor.uploadImage } : {}
|
|
807
1408
|
}
|
|
808
1409
|
),
|
|
809
|
-
/* @__PURE__ */
|
|
1410
|
+
/* @__PURE__ */ jsx10("small", { id: `${bodyId}-hint`, className: "adc-hint", children: showFormattingToolbar ? messages.bodyHintToolbar : messages.bodyHint })
|
|
810
1411
|
] }),
|
|
811
|
-
/* @__PURE__ */
|
|
1412
|
+
/* @__PURE__ */ jsx10("div", { id: `${bodyId}-preview`, role: "tabpanel", className: "adc-pane adc-pane--preview", "aria-live": "polite", children: draft.body.trim() ? /* @__PURE__ */ jsx10(MarkdownContent, { markdown: draft.body, headingLevelOffset: 1 }) : /* @__PURE__ */ jsx10("p", { className: "adc-muted", children: messages.previewEmpty }) })
|
|
812
1413
|
] })
|
|
813
1414
|
] })
|
|
814
1415
|
] }),
|
|
815
|
-
/* @__PURE__ */
|
|
816
|
-
/* @__PURE__ */
|
|
817
|
-
post?.publishedAt && /* @__PURE__ */
|
|
1416
|
+
/* @__PURE__ */ jsxs8("aside", { className: "adc-editor-side", children: [
|
|
1417
|
+
/* @__PURE__ */ jsxs8(Section, { title: messages.publishSection, children: [
|
|
1418
|
+
post?.publishedAt && /* @__PURE__ */ jsx10("p", { className: "adc-muted", children: format(status === "scheduled" ? "scheduledFor" : "publishedOn", {
|
|
818
1419
|
date: formatPostDate(post.publishedAt, locale, true)
|
|
819
1420
|
}) }),
|
|
820
|
-
/* @__PURE__ */
|
|
821
|
-
/* @__PURE__ */
|
|
1421
|
+
/* @__PURE__ */ jsxs8("button", { type: "submit", className: "adc-button", disabled: editor.isBusy, children: [
|
|
1422
|
+
/* @__PURE__ */ jsx10(Save, { "aria-hidden": "true", className: "adc-icon" }),
|
|
822
1423
|
editor.isBusy ? messages.saving : isLive ? messages.saveChanges : messages.save
|
|
823
1424
|
] }),
|
|
824
|
-
status !== "published" && /* @__PURE__ */
|
|
1425
|
+
status !== "published" && /* @__PURE__ */ jsxs8(
|
|
825
1426
|
"button",
|
|
826
1427
|
{
|
|
827
1428
|
type: "button",
|
|
@@ -829,14 +1430,19 @@ function PostEditor({ postId, defaults, onSaved, onArchived, onClose }) {
|
|
|
829
1430
|
disabled: editor.isBusy,
|
|
830
1431
|
onClick: () => void editor.publishNow(),
|
|
831
1432
|
children: [
|
|
832
|
-
/* @__PURE__ */
|
|
1433
|
+
/* @__PURE__ */ jsx10(Send, { "aria-hidden": "true", className: "adc-icon" }),
|
|
833
1434
|
messages.publishNow
|
|
834
1435
|
]
|
|
835
1436
|
}
|
|
836
1437
|
),
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
1438
|
+
renderDateTimeInput ? renderDateTimeInput({
|
|
1439
|
+
id: scheduleId,
|
|
1440
|
+
label: messages.scheduleAt,
|
|
1441
|
+
value: editor.scheduleAt,
|
|
1442
|
+
onChange: editor.setScheduleAt
|
|
1443
|
+
}) : /* @__PURE__ */ jsxs8("div", { className: "adc-field", children: [
|
|
1444
|
+
/* @__PURE__ */ jsx10("label", { htmlFor: scheduleId, children: messages.scheduleAt }),
|
|
1445
|
+
/* @__PURE__ */ jsx10(
|
|
840
1446
|
"input",
|
|
841
1447
|
{
|
|
842
1448
|
id: scheduleId,
|
|
@@ -846,7 +1452,7 @@ function PostEditor({ postId, defaults, onSaved, onArchived, onClose }) {
|
|
|
846
1452
|
}
|
|
847
1453
|
)
|
|
848
1454
|
] }),
|
|
849
|
-
/* @__PURE__ */
|
|
1455
|
+
/* @__PURE__ */ jsxs8(
|
|
850
1456
|
"button",
|
|
851
1457
|
{
|
|
852
1458
|
type: "button",
|
|
@@ -854,12 +1460,12 @@ function PostEditor({ postId, defaults, onSaved, onArchived, onClose }) {
|
|
|
854
1460
|
disabled: editor.isBusy || !editor.scheduleAt,
|
|
855
1461
|
onClick: () => void editor.schedule(),
|
|
856
1462
|
children: [
|
|
857
|
-
/* @__PURE__ */
|
|
1463
|
+
/* @__PURE__ */ jsx10(CalendarClock2, { "aria-hidden": "true", className: "adc-icon" }),
|
|
858
1464
|
messages.schedule
|
|
859
1465
|
]
|
|
860
1466
|
}
|
|
861
1467
|
),
|
|
862
|
-
isLive && /* @__PURE__ */
|
|
1468
|
+
isLive && /* @__PURE__ */ jsxs8(
|
|
863
1469
|
"button",
|
|
864
1470
|
{
|
|
865
1471
|
type: "button",
|
|
@@ -867,12 +1473,12 @@ function PostEditor({ postId, defaults, onSaved, onArchived, onClose }) {
|
|
|
867
1473
|
disabled: editor.isBusy,
|
|
868
1474
|
onClick: () => void editor.unpublish(),
|
|
869
1475
|
children: [
|
|
870
|
-
/* @__PURE__ */
|
|
1476
|
+
/* @__PURE__ */ jsx10(EyeOff, { "aria-hidden": "true", className: "adc-icon" }),
|
|
871
1477
|
messages.unpublish
|
|
872
1478
|
]
|
|
873
1479
|
}
|
|
874
1480
|
),
|
|
875
|
-
post && status !== "archived" && /* @__PURE__ */
|
|
1481
|
+
post && status !== "archived" && /* @__PURE__ */ jsxs8(
|
|
876
1482
|
"button",
|
|
877
1483
|
{
|
|
878
1484
|
type: "button",
|
|
@@ -880,12 +1486,12 @@ function PostEditor({ postId, defaults, onSaved, onArchived, onClose }) {
|
|
|
880
1486
|
disabled: editor.isBusy,
|
|
881
1487
|
onClick: () => window.confirm(messages.archiveConfirm) && void editor.archive(),
|
|
882
1488
|
children: [
|
|
883
|
-
/* @__PURE__ */
|
|
1489
|
+
/* @__PURE__ */ jsx10(Archive2, { "aria-hidden": "true", className: "adc-icon" }),
|
|
884
1490
|
messages.archive
|
|
885
1491
|
]
|
|
886
1492
|
}
|
|
887
1493
|
),
|
|
888
|
-
editor.feedback && /* @__PURE__ */
|
|
1494
|
+
editor.feedback && /* @__PURE__ */ jsx10(
|
|
889
1495
|
"p",
|
|
890
1496
|
{
|
|
891
1497
|
className: editor.feedback === "saved" ? "adc-success" : "adc-error",
|
|
@@ -894,27 +1500,19 @@ function PostEditor({ postId, defaults, onSaved, onArchived, onClose }) {
|
|
|
894
1500
|
}
|
|
895
1501
|
)
|
|
896
1502
|
] }),
|
|
897
|
-
/* @__PURE__ */
|
|
898
|
-
draft.coverImageUrl && /* @__PURE__ */
|
|
899
|
-
editor.canUploadCover && /* @__PURE__ */
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
const file = event.target.files?.[0];
|
|
911
|
-
event.target.value = "";
|
|
912
|
-
if (file) void editor.uploadCover(file);
|
|
913
|
-
}
|
|
914
|
-
}
|
|
915
|
-
)
|
|
916
|
-
] }),
|
|
917
|
-
/* @__PURE__ */ jsx5(
|
|
1503
|
+
/* @__PURE__ */ jsxs8(Section, { title: messages.fieldCover, children: [
|
|
1504
|
+
draft.coverImageUrl && /* @__PURE__ */ jsx10("img", { className: "adc-cover-preview", src: draft.coverImageUrl, alt: draft.coverImageAlt }),
|
|
1505
|
+
editor.canUploadCover && /* @__PURE__ */ jsx10(
|
|
1506
|
+
FilePicker,
|
|
1507
|
+
{
|
|
1508
|
+
buttonLabel: editor.isUploading ? messages.coverUploading : messages.coverUpload,
|
|
1509
|
+
emptyLabel: messages.fileNoneChosen,
|
|
1510
|
+
accept: "image/jpeg,image/png,image/webp",
|
|
1511
|
+
isBusy: editor.isUploading,
|
|
1512
|
+
onPick: (file) => void editor.uploadCover(file)
|
|
1513
|
+
}
|
|
1514
|
+
),
|
|
1515
|
+
/* @__PURE__ */ jsx10(
|
|
918
1516
|
TextField,
|
|
919
1517
|
{
|
|
920
1518
|
label: messages.fieldCoverUrl,
|
|
@@ -924,7 +1522,7 @@ function PostEditor({ postId, defaults, onSaved, onArchived, onClose }) {
|
|
|
924
1522
|
error: errors.coverImageUrl ? messages.errorUrl : void 0
|
|
925
1523
|
}
|
|
926
1524
|
),
|
|
927
|
-
/* @__PURE__ */
|
|
1525
|
+
/* @__PURE__ */ jsx10(
|
|
928
1526
|
TextField,
|
|
929
1527
|
{
|
|
930
1528
|
label: messages.fieldCoverAlt,
|
|
@@ -933,21 +1531,21 @@ function PostEditor({ postId, defaults, onSaved, onArchived, onClose }) {
|
|
|
933
1531
|
onChange: (value) => update("coverImageAlt", value)
|
|
934
1532
|
}
|
|
935
1533
|
),
|
|
936
|
-
draft.coverImageUrl && /* @__PURE__ */
|
|
1534
|
+
draft.coverImageUrl && /* @__PURE__ */ jsxs8(
|
|
937
1535
|
"button",
|
|
938
1536
|
{
|
|
939
1537
|
type: "button",
|
|
940
1538
|
className: "adc-button adc-button--ghost",
|
|
941
1539
|
onClick: () => update("coverImageUrl", ""),
|
|
942
1540
|
children: [
|
|
943
|
-
/* @__PURE__ */
|
|
1541
|
+
/* @__PURE__ */ jsx10(Trash2, { "aria-hidden": "true", className: "adc-icon" }),
|
|
944
1542
|
messages.coverRemove
|
|
945
1543
|
]
|
|
946
1544
|
}
|
|
947
1545
|
)
|
|
948
1546
|
] }),
|
|
949
|
-
/* @__PURE__ */
|
|
950
|
-
/* @__PURE__ */
|
|
1547
|
+
/* @__PURE__ */ jsxs8(Section, { title: messages.fieldTags, children: [
|
|
1548
|
+
/* @__PURE__ */ jsx10(
|
|
951
1549
|
TagsInput,
|
|
952
1550
|
{
|
|
953
1551
|
label: messages.fieldTags,
|
|
@@ -956,7 +1554,7 @@ function PostEditor({ postId, defaults, onSaved, onArchived, onClose }) {
|
|
|
956
1554
|
onChange: (tags) => update("tags", tags)
|
|
957
1555
|
}
|
|
958
1556
|
),
|
|
959
|
-
/* @__PURE__ */
|
|
1557
|
+
/* @__PURE__ */ jsx10(
|
|
960
1558
|
TextField,
|
|
961
1559
|
{
|
|
962
1560
|
label: messages.fieldAuthor,
|
|
@@ -966,8 +1564,8 @@ function PostEditor({ postId, defaults, onSaved, onArchived, onClose }) {
|
|
|
966
1564
|
}
|
|
967
1565
|
)
|
|
968
1566
|
] }),
|
|
969
|
-
/* @__PURE__ */
|
|
970
|
-
/* @__PURE__ */
|
|
1567
|
+
/* @__PURE__ */ jsxs8(Section, { title: messages.seoSection, children: [
|
|
1568
|
+
/* @__PURE__ */ jsx10(
|
|
971
1569
|
TextField,
|
|
972
1570
|
{
|
|
973
1571
|
label: messages.fieldSeoTitle,
|
|
@@ -976,7 +1574,7 @@ function PostEditor({ postId, defaults, onSaved, onArchived, onClose }) {
|
|
|
976
1574
|
onChange: (value) => update("seoTitle", value)
|
|
977
1575
|
}
|
|
978
1576
|
),
|
|
979
|
-
/* @__PURE__ */
|
|
1577
|
+
/* @__PURE__ */ jsx10(
|
|
980
1578
|
TextField,
|
|
981
1579
|
{
|
|
982
1580
|
label: messages.fieldSeoDescription,
|
|
@@ -986,7 +1584,7 @@ function PostEditor({ postId, defaults, onSaved, onArchived, onClose }) {
|
|
|
986
1584
|
onChange: (value) => update("seoDescription", value)
|
|
987
1585
|
}
|
|
988
1586
|
),
|
|
989
|
-
/* @__PURE__ */
|
|
1587
|
+
/* @__PURE__ */ jsx10(
|
|
990
1588
|
TextField,
|
|
991
1589
|
{
|
|
992
1590
|
label: messages.fieldCanonical,
|
|
@@ -1007,14 +1605,14 @@ function PostEditor({ postId, defaults, onSaved, onArchived, onClose }) {
|
|
|
1007
1605
|
// src/components/PostList.tsx
|
|
1008
1606
|
import { POST_STATUSES } from "@adatechnology/content-contracts";
|
|
1009
1607
|
import { Plus, RotateCcw, Search } from "lucide-react";
|
|
1010
|
-
import { useId as
|
|
1608
|
+
import { useId as useId6 } from "react";
|
|
1011
1609
|
|
|
1012
1610
|
// src/hooks/usePostList.ts
|
|
1013
|
-
import { useState as
|
|
1611
|
+
import { useState as useState10 } from "react";
|
|
1014
1612
|
function usePostList(params) {
|
|
1015
1613
|
const api = useContentAdminApi();
|
|
1016
|
-
const [filters, setFilters] =
|
|
1017
|
-
const [page, setPage] =
|
|
1614
|
+
const [filters, setFilters] = useState10({});
|
|
1615
|
+
const [page, setPage] = useState10(1);
|
|
1018
1616
|
const key = JSON.stringify({ filters, page, pageSize: params.pageSize, reload: params.reloadKey ?? 0 });
|
|
1019
1617
|
const posts = useAsyncResource(() => api.listPosts({ ...filters, page, pageSize: params.pageSize }), key);
|
|
1020
1618
|
const tags = useAsyncResource(
|
|
@@ -1059,7 +1657,7 @@ function buildPageItems(params) {
|
|
|
1059
1657
|
}
|
|
1060
1658
|
|
|
1061
1659
|
// src/components/Pagination.tsx
|
|
1062
|
-
import { jsx as
|
|
1660
|
+
import { jsx as jsx11, jsxs as jsxs9 } from "react/jsx-runtime";
|
|
1063
1661
|
function Pagination({ page, totalPages, getPageHref, onPageChange }) {
|
|
1064
1662
|
const { messages, format } = useContentText();
|
|
1065
1663
|
const renderLink = useRenderLink();
|
|
@@ -1068,7 +1666,7 @@ function Pagination({ page, totalPages, getPageHref, onPageChange }) {
|
|
|
1068
1666
|
const className = `adc-page${isCurrent ? " adc-page--current" : ""}`;
|
|
1069
1667
|
if (getPageHref && !isCurrent)
|
|
1070
1668
|
return renderLink({ href: getPageHref(target), className, "aria-label": label, children: content });
|
|
1071
|
-
return /* @__PURE__ */
|
|
1669
|
+
return /* @__PURE__ */ jsx11(
|
|
1072
1670
|
"button",
|
|
1073
1671
|
{
|
|
1074
1672
|
type: "button",
|
|
@@ -1081,17 +1679,17 @@ function Pagination({ page, totalPages, getPageHref, onPageChange }) {
|
|
|
1081
1679
|
}
|
|
1082
1680
|
);
|
|
1083
1681
|
}
|
|
1084
|
-
return /* @__PURE__ */
|
|
1085
|
-
page > 1 && renderTarget(page - 1, messages.paginationPrevious, /* @__PURE__ */
|
|
1682
|
+
return /* @__PURE__ */ jsxs9("nav", { className: "adc-pagination", "aria-label": messages.paginationLabel, children: [
|
|
1683
|
+
page > 1 && renderTarget(page - 1, messages.paginationPrevious, /* @__PURE__ */ jsx11(ChevronLeft, { "aria-hidden": "true", className: "adc-icon" })),
|
|
1086
1684
|
buildPageItems({ current: page, total: totalPages }).map(
|
|
1087
|
-
(item) => item.kind === "gap" ? /* @__PURE__ */
|
|
1685
|
+
(item) => item.kind === "gap" ? /* @__PURE__ */ jsx11("span", { className: "adc-page-gap", "aria-hidden": "true", children: "\u2026" }, item.key) : /* @__PURE__ */ jsx11("span", { children: renderTarget(item.page, format("pageLabel", { page: item.page }), item.page, item.page === page) }, item.page)
|
|
1088
1686
|
),
|
|
1089
|
-
page < totalPages && renderTarget(page + 1, messages.paginationNext, /* @__PURE__ */
|
|
1687
|
+
page < totalPages && renderTarget(page + 1, messages.paginationNext, /* @__PURE__ */ jsx11(ChevronRight, { "aria-hidden": "true", className: "adc-icon" }))
|
|
1090
1688
|
] });
|
|
1091
1689
|
}
|
|
1092
1690
|
|
|
1093
1691
|
// src/components/PostList.tsx
|
|
1094
|
-
import { jsx as
|
|
1692
|
+
import { jsx as jsx12, jsxs as jsxs10 } from "react/jsx-runtime";
|
|
1095
1693
|
var STATUS_LABEL = {
|
|
1096
1694
|
draft: "statusDraft",
|
|
1097
1695
|
scheduled: "statusScheduled",
|
|
@@ -1104,23 +1702,23 @@ function PostList({ onSelect, onCreate, pageSize = 20, reloadKey }) {
|
|
|
1104
1702
|
pageSize,
|
|
1105
1703
|
...reloadKey !== void 0 ? { reloadKey } : {}
|
|
1106
1704
|
});
|
|
1107
|
-
const searchId =
|
|
1108
|
-
const statusId =
|
|
1109
|
-
const tagId =
|
|
1110
|
-
return /* @__PURE__ */
|
|
1111
|
-
/* @__PURE__ */
|
|
1112
|
-
/* @__PURE__ */
|
|
1113
|
-
onCreate && /* @__PURE__ */
|
|
1114
|
-
/* @__PURE__ */
|
|
1705
|
+
const searchId = useId6();
|
|
1706
|
+
const statusId = useId6();
|
|
1707
|
+
const tagId = useId6();
|
|
1708
|
+
return /* @__PURE__ */ jsxs10("section", { className: "adc-root adc-post-list", children: [
|
|
1709
|
+
/* @__PURE__ */ jsxs10("header", { className: "adc-toolbar", children: [
|
|
1710
|
+
/* @__PURE__ */ jsx12("h2", { className: "adc-title", children: messages.listTitle }),
|
|
1711
|
+
onCreate && /* @__PURE__ */ jsxs10("button", { type: "button", className: "adc-button adc-button--primary", onClick: onCreate, children: [
|
|
1712
|
+
/* @__PURE__ */ jsx12(Plus, { "aria-hidden": "true", className: "adc-icon" }),
|
|
1115
1713
|
messages.newPost
|
|
1116
1714
|
] })
|
|
1117
1715
|
] }),
|
|
1118
|
-
/* @__PURE__ */
|
|
1119
|
-
/* @__PURE__ */
|
|
1120
|
-
/* @__PURE__ */
|
|
1121
|
-
/* @__PURE__ */
|
|
1122
|
-
/* @__PURE__ */
|
|
1123
|
-
/* @__PURE__ */
|
|
1716
|
+
/* @__PURE__ */ jsxs10("div", { className: "adc-filters", children: [
|
|
1717
|
+
/* @__PURE__ */ jsxs10("div", { className: "adc-field adc-field--search", children: [
|
|
1718
|
+
/* @__PURE__ */ jsx12("label", { htmlFor: searchId, children: messages.searchLabel }),
|
|
1719
|
+
/* @__PURE__ */ jsxs10("div", { className: "adc-input-icon", children: [
|
|
1720
|
+
/* @__PURE__ */ jsx12(Search, { "aria-hidden": "true", className: "adc-icon" }),
|
|
1721
|
+
/* @__PURE__ */ jsx12(
|
|
1124
1722
|
"input",
|
|
1125
1723
|
{
|
|
1126
1724
|
id: searchId,
|
|
@@ -1132,24 +1730,24 @@ function PostList({ onSelect, onCreate, pageSize = 20, reloadKey }) {
|
|
|
1132
1730
|
)
|
|
1133
1731
|
] })
|
|
1134
1732
|
] }),
|
|
1135
|
-
/* @__PURE__ */
|
|
1136
|
-
/* @__PURE__ */
|
|
1137
|
-
/* @__PURE__ */
|
|
1733
|
+
/* @__PURE__ */ jsxs10("div", { className: "adc-field", children: [
|
|
1734
|
+
/* @__PURE__ */ jsx12("label", { htmlFor: statusId, children: messages.filterStatus }),
|
|
1735
|
+
/* @__PURE__ */ jsxs10(
|
|
1138
1736
|
"select",
|
|
1139
1737
|
{
|
|
1140
1738
|
id: statusId,
|
|
1141
1739
|
value: filters.status ?? "",
|
|
1142
1740
|
onChange: (event) => updateFilters({ ...filters, status: event.target.value || void 0 }),
|
|
1143
1741
|
children: [
|
|
1144
|
-
/* @__PURE__ */
|
|
1145
|
-
POST_STATUSES.map((status) => /* @__PURE__ */
|
|
1742
|
+
/* @__PURE__ */ jsx12("option", { value: "", children: messages.filterAll }),
|
|
1743
|
+
POST_STATUSES.map((status) => /* @__PURE__ */ jsx12("option", { value: status, children: messages[STATUS_LABEL[status]] }, status))
|
|
1146
1744
|
]
|
|
1147
1745
|
}
|
|
1148
1746
|
)
|
|
1149
1747
|
] }),
|
|
1150
|
-
/* @__PURE__ */
|
|
1151
|
-
/* @__PURE__ */
|
|
1152
|
-
/* @__PURE__ */
|
|
1748
|
+
/* @__PURE__ */ jsxs10("div", { className: "adc-field", children: [
|
|
1749
|
+
/* @__PURE__ */ jsx12("label", { htmlFor: tagId, children: messages.filterTag }),
|
|
1750
|
+
/* @__PURE__ */ jsx12(
|
|
1153
1751
|
"input",
|
|
1154
1752
|
{
|
|
1155
1753
|
id: tagId,
|
|
@@ -1158,56 +1756,64 @@ function PostList({ onSelect, onCreate, pageSize = 20, reloadKey }) {
|
|
|
1158
1756
|
onChange: (event) => updateFilters({ ...filters, tag: event.target.value || void 0 })
|
|
1159
1757
|
}
|
|
1160
1758
|
),
|
|
1161
|
-
tags && /* @__PURE__ */
|
|
1759
|
+
tags && /* @__PURE__ */ jsx12("datalist", { id: `${tagId}-list`, children: tags.map((entry) => /* @__PURE__ */ jsx12("option", { value: entry.tag }, entry.tag)) })
|
|
1162
1760
|
] }),
|
|
1163
|
-
hasFilters && /* @__PURE__ */
|
|
1164
|
-
/* @__PURE__ */
|
|
1761
|
+
hasFilters && /* @__PURE__ */ jsxs10("button", { type: "button", className: "adc-button adc-button--ghost", onClick: () => updateFilters({}), children: [
|
|
1762
|
+
/* @__PURE__ */ jsx12(RotateCcw, { "aria-hidden": "true", className: "adc-icon" }),
|
|
1165
1763
|
messages.clearFilters
|
|
1166
1764
|
] })
|
|
1167
1765
|
] }),
|
|
1168
|
-
posts.error !== void 0 && !posts.isLoading ? /* @__PURE__ */
|
|
1766
|
+
posts.error !== void 0 && !posts.isLoading ? /* @__PURE__ */ jsxs10("div", { className: "adc-state adc-state--error", role: "alert", children: [
|
|
1169
1767
|
messages.loadError,
|
|
1170
|
-
/* @__PURE__ */
|
|
1171
|
-
] }) : posts.isLoading && !posts.data ? /* @__PURE__ */
|
|
1172
|
-
/* @__PURE__ */
|
|
1173
|
-
/* @__PURE__ */
|
|
1174
|
-
/* @__PURE__ */
|
|
1175
|
-
/* @__PURE__ */
|
|
1176
|
-
/* @__PURE__ */
|
|
1768
|
+
/* @__PURE__ */ jsx12("button", { type: "button", className: "adc-button", onClick: posts.reload, children: messages.retry })
|
|
1769
|
+
] }) : posts.isLoading && !posts.data ? /* @__PURE__ */ jsx12("p", { className: "adc-state", role: "status", children: messages.loading }) : (posts.data?.data.length ?? 0) === 0 ? /* @__PURE__ */ jsx12("p", { className: "adc-state", children: messages.empty }) : /* @__PURE__ */ jsx12("div", { className: "adc-table-wrap", "aria-busy": posts.isLoading, children: /* @__PURE__ */ jsxs10("table", { className: "adc-table", children: [
|
|
1770
|
+
/* @__PURE__ */ jsx12("thead", { children: /* @__PURE__ */ jsxs10("tr", { children: [
|
|
1771
|
+
/* @__PURE__ */ jsx12("th", { scope: "col", children: messages.columnTitle }),
|
|
1772
|
+
/* @__PURE__ */ jsx12("th", { scope: "col", children: messages.columnStatus }),
|
|
1773
|
+
/* @__PURE__ */ jsx12("th", { scope: "col", children: messages.columnPublished }),
|
|
1774
|
+
/* @__PURE__ */ jsx12("th", { scope: "col", children: messages.columnUpdated })
|
|
1177
1775
|
] }) }),
|
|
1178
|
-
/* @__PURE__ */
|
|
1179
|
-
/* @__PURE__ */
|
|
1180
|
-
/* @__PURE__ */
|
|
1181
|
-
/* @__PURE__ */
|
|
1776
|
+
/* @__PURE__ */ jsx12("tbody", { children: posts.data?.data.map((post) => /* @__PURE__ */ jsxs10("tr", { children: [
|
|
1777
|
+
/* @__PURE__ */ jsxs10("td", { children: [
|
|
1778
|
+
/* @__PURE__ */ jsx12("button", { type: "button", className: "adc-row-link", onClick: () => onSelect(post), children: post.title }),
|
|
1779
|
+
/* @__PURE__ */ jsxs10("span", { className: "adc-muted adc-slug", children: [
|
|
1182
1780
|
"/",
|
|
1183
1781
|
post.slug
|
|
1184
1782
|
] })
|
|
1185
1783
|
] }),
|
|
1186
|
-
/* @__PURE__ */
|
|
1187
|
-
/* @__PURE__ */
|
|
1188
|
-
/* @__PURE__ */
|
|
1784
|
+
/* @__PURE__ */ jsx12("td", { children: /* @__PURE__ */ jsx12(StatusChip, { status: post.status }) }),
|
|
1785
|
+
/* @__PURE__ */ jsx12("td", { children: formatPostDate(post.publishedAt, locale, true) }),
|
|
1786
|
+
/* @__PURE__ */ jsx12("td", { children: formatPostDate(post.updatedAt, locale, true) })
|
|
1189
1787
|
] }, post.id)) })
|
|
1190
1788
|
] }) }),
|
|
1191
|
-
posts.data && /* @__PURE__ */
|
|
1789
|
+
posts.data && /* @__PURE__ */ jsx12(Pagination, { page, totalPages: posts.data.pagination.totalPages, onPageChange: setPage })
|
|
1192
1790
|
] });
|
|
1193
1791
|
}
|
|
1194
1792
|
|
|
1195
1793
|
// src/components/ContentWorkspace.tsx
|
|
1196
|
-
import { jsx as
|
|
1197
|
-
function ContentWorkspace({
|
|
1198
|
-
|
|
1199
|
-
|
|
1794
|
+
import { jsx as jsx13 } from "react/jsx-runtime";
|
|
1795
|
+
function ContentWorkspace({
|
|
1796
|
+
pageSize,
|
|
1797
|
+
newPostDefaults,
|
|
1798
|
+
onPostSaved,
|
|
1799
|
+
showFormattingToolbar,
|
|
1800
|
+
renderDateTimeInput
|
|
1801
|
+
}) {
|
|
1802
|
+
const [view, setView] = useState11({ kind: "list" });
|
|
1803
|
+
const [reloadKey, setReloadKey] = useState11(0);
|
|
1200
1804
|
function handleSaved(post) {
|
|
1201
1805
|
setReloadKey((value) => value + 1);
|
|
1202
1806
|
setView({ kind: "editor", postId: post.id });
|
|
1203
1807
|
onPostSaved?.(post);
|
|
1204
1808
|
}
|
|
1205
1809
|
if (view.kind === "editor") {
|
|
1206
|
-
return /* @__PURE__ */
|
|
1810
|
+
return /* @__PURE__ */ jsx13(
|
|
1207
1811
|
PostEditor,
|
|
1208
1812
|
{
|
|
1209
1813
|
...view.postId ? { postId: view.postId } : {},
|
|
1210
1814
|
...newPostDefaults ? { defaults: newPostDefaults } : {},
|
|
1815
|
+
...showFormattingToolbar === void 0 ? {} : { showFormattingToolbar },
|
|
1816
|
+
...renderDateTimeInput ? { renderDateTimeInput } : {},
|
|
1211
1817
|
onSaved: handleSaved,
|
|
1212
1818
|
onArchived: () => {
|
|
1213
1819
|
setReloadKey((value) => value + 1);
|
|
@@ -1218,7 +1824,7 @@ function ContentWorkspace({ pageSize, newPostDefaults, onPostSaved }) {
|
|
|
1218
1824
|
view.postId ?? "new"
|
|
1219
1825
|
);
|
|
1220
1826
|
}
|
|
1221
|
-
return /* @__PURE__ */
|
|
1827
|
+
return /* @__PURE__ */ jsx13(
|
|
1222
1828
|
PostList,
|
|
1223
1829
|
{
|
|
1224
1830
|
reloadKey,
|
|
@@ -1230,13 +1836,13 @@ function ContentWorkspace({ pageSize, newPostDefaults, onPostSaved }) {
|
|
|
1230
1836
|
}
|
|
1231
1837
|
|
|
1232
1838
|
// src/components/PostCard.tsx
|
|
1233
|
-
import { jsx as
|
|
1839
|
+
import { jsx as jsx14, jsxs as jsxs11 } from "react/jsx-runtime";
|
|
1234
1840
|
function PostCard({ post, href, headingLevel = 2 }) {
|
|
1235
1841
|
const { messages, locale, format } = useContentText();
|
|
1236
1842
|
const renderLink = useRenderLink();
|
|
1237
1843
|
const Heading = `h${headingLevel}`;
|
|
1238
|
-
return /* @__PURE__ */
|
|
1239
|
-
post.coverImageUrl && /* @__PURE__ */
|
|
1844
|
+
return /* @__PURE__ */ jsxs11("article", { className: "adc-card", children: [
|
|
1845
|
+
post.coverImageUrl && /* @__PURE__ */ jsx14(
|
|
1240
1846
|
"img",
|
|
1241
1847
|
{
|
|
1242
1848
|
className: "adc-card-cover",
|
|
@@ -1246,22 +1852,22 @@ function PostCard({ post, href, headingLevel = 2 }) {
|
|
|
1246
1852
|
decoding: "async"
|
|
1247
1853
|
}
|
|
1248
1854
|
),
|
|
1249
|
-
/* @__PURE__ */
|
|
1250
|
-
/* @__PURE__ */
|
|
1251
|
-
/* @__PURE__ */
|
|
1252
|
-
/* @__PURE__ */
|
|
1253
|
-
/* @__PURE__ */
|
|
1855
|
+
/* @__PURE__ */ jsxs11("div", { className: "adc-card-body", children: [
|
|
1856
|
+
/* @__PURE__ */ jsx14(Heading, { className: "adc-card-title", children: renderLink({ href, className: "adc-card-link", children: post.title }) }),
|
|
1857
|
+
/* @__PURE__ */ jsxs11("p", { className: "adc-meta", children: [
|
|
1858
|
+
/* @__PURE__ */ jsx14("time", { dateTime: post.publishedAt, children: formatPostDate(post.publishedAt, locale) }),
|
|
1859
|
+
/* @__PURE__ */ jsx14("span", { "aria-hidden": "true", children: " \xB7 " }),
|
|
1254
1860
|
format("readingTime", { minutes: post.readingTimeMinutes })
|
|
1255
1861
|
] }),
|
|
1256
|
-
post.excerpt && /* @__PURE__ */
|
|
1257
|
-
post.tags.length > 0 && /* @__PURE__ */
|
|
1258
|
-
/* @__PURE__ */
|
|
1862
|
+
post.excerpt && /* @__PURE__ */ jsx14("p", { className: "adc-card-excerpt", children: post.excerpt }),
|
|
1863
|
+
post.tags.length > 0 && /* @__PURE__ */ jsx14("ul", { className: "adc-tag-list", children: post.tags.map((tag) => /* @__PURE__ */ jsx14("li", { className: "adc-tag", children: tag }, tag)) }),
|
|
1864
|
+
/* @__PURE__ */ jsx14("span", { className: "adc-card-more", "aria-hidden": "true", children: messages.readMore })
|
|
1259
1865
|
] })
|
|
1260
1866
|
] });
|
|
1261
1867
|
}
|
|
1262
1868
|
|
|
1263
1869
|
// src/components/PostListPage.tsx
|
|
1264
|
-
import { jsx as
|
|
1870
|
+
import { jsx as jsx15, jsxs as jsxs12 } from "react/jsx-runtime";
|
|
1265
1871
|
function PostListPage({ page = 1, tag, pageSize = 10, getPostHref, getListHref, title }) {
|
|
1266
1872
|
const api = useContentPublicApi();
|
|
1267
1873
|
const { messages } = useContentText();
|
|
@@ -1275,9 +1881,9 @@ function PostListPage({ page = 1, tag, pageSize = 10, getPostHref, getListHref,
|
|
|
1275
1881
|
"public-tags"
|
|
1276
1882
|
);
|
|
1277
1883
|
const withTag = (target) => getListHref({ page: target, ...tag ? { tag } : {} });
|
|
1278
|
-
return /* @__PURE__ */
|
|
1279
|
-
title && /* @__PURE__ */
|
|
1280
|
-
(tags.data?.length ?? 0) > 0 && /* @__PURE__ */
|
|
1884
|
+
return /* @__PURE__ */ jsxs12("section", { className: "adc-root adc-public-list", children: [
|
|
1885
|
+
title && /* @__PURE__ */ jsx15("h1", { className: "adc-page-title", children: title }),
|
|
1886
|
+
(tags.data?.length ?? 0) > 0 && /* @__PURE__ */ jsxs12("nav", { className: "adc-tag-filter", "aria-label": messages.tagsLabel, children: [
|
|
1281
1887
|
renderLink({
|
|
1282
1888
|
href: getListHref({ page: 1 }),
|
|
1283
1889
|
className: `adc-tag-chip${tag ? "" : " adc-tag-chip--active"}`,
|
|
@@ -1293,11 +1899,11 @@ function PostListPage({ page = 1, tag, pageSize = 10, getPostHref, getListHref,
|
|
|
1293
1899
|
})
|
|
1294
1900
|
)
|
|
1295
1901
|
] }),
|
|
1296
|
-
posts.isLoading && !posts.data ? /* @__PURE__ */
|
|
1902
|
+
posts.isLoading && !posts.data ? /* @__PURE__ */ jsx15("p", { className: "adc-state", role: "status", children: messages.loading }) : posts.error !== void 0 ? /* @__PURE__ */ jsxs12("div", { className: "adc-state adc-state--error", role: "alert", children: [
|
|
1297
1903
|
messages.loadError,
|
|
1298
|
-
/* @__PURE__ */
|
|
1299
|
-
] }) : (posts.data?.data.length ?? 0) === 0 ? /* @__PURE__ */
|
|
1300
|
-
posts.data && /* @__PURE__ */
|
|
1904
|
+
/* @__PURE__ */ jsx15("button", { type: "button", className: "adc-button", onClick: posts.reload, children: messages.retry })
|
|
1905
|
+
] }) : (posts.data?.data.length ?? 0) === 0 ? /* @__PURE__ */ jsx15("p", { className: "adc-state", children: messages.postsEmpty }) : /* @__PURE__ */ jsx15("div", { className: "adc-card-grid", children: posts.data?.data.map((post) => /* @__PURE__ */ jsx15(PostCard, { post, href: getPostHref(post.slug) }, post.id)) }),
|
|
1906
|
+
posts.data && /* @__PURE__ */ jsx15(Pagination, { page, totalPages: posts.data.pagination.totalPages, getPageHref: withTag })
|
|
1301
1907
|
] });
|
|
1302
1908
|
}
|
|
1303
1909
|
|
|
@@ -1306,7 +1912,7 @@ import { useEffect as useEffect5 } from "react";
|
|
|
1306
1912
|
|
|
1307
1913
|
// src/components/ShareButtons.tsx
|
|
1308
1914
|
import { Check, Link2, Share2 } from "lucide-react";
|
|
1309
|
-
import { useEffect as useEffect4, useState as
|
|
1915
|
+
import { useEffect as useEffect4, useState as useState12 } from "react";
|
|
1310
1916
|
|
|
1311
1917
|
// src/lib/share.ts
|
|
1312
1918
|
var SHARE_NETWORK = {
|
|
@@ -1331,7 +1937,7 @@ function buildShareLinks(params) {
|
|
|
1331
1937
|
}
|
|
1332
1938
|
|
|
1333
1939
|
// src/components/ShareButtons.tsx
|
|
1334
|
-
import { jsx as
|
|
1940
|
+
import { jsx as jsx16, jsxs as jsxs13 } from "react/jsx-runtime";
|
|
1335
1941
|
var NETWORK_LABEL = {
|
|
1336
1942
|
[SHARE_NETWORK.WHATSAPP]: "shareWhatsApp",
|
|
1337
1943
|
[SHARE_NETWORK.FACEBOOK]: "shareFacebook",
|
|
@@ -1341,9 +1947,9 @@ var NETWORK_LABEL = {
|
|
|
1341
1947
|
var COPIED_FEEDBACK_MS = 2e3;
|
|
1342
1948
|
function ShareButtons({ url, title, networks }) {
|
|
1343
1949
|
const { messages, format } = useContentText();
|
|
1344
|
-
const [isCopied, setIsCopied] =
|
|
1950
|
+
const [isCopied, setIsCopied] = useState12(false);
|
|
1345
1951
|
const links = buildShareLinks({ url, title }).filter((link) => !networks || networks.includes(link.network));
|
|
1346
|
-
const [capabilities, setCapabilities] =
|
|
1952
|
+
const [capabilities, setCapabilities] = useState12({ canShareNatively: false, canCopy: false });
|
|
1347
1953
|
useEffect4(() => {
|
|
1348
1954
|
setCapabilities({
|
|
1349
1955
|
canShareNatively: typeof navigator.share === "function",
|
|
@@ -1356,21 +1962,21 @@ function ShareButtons({ url, title, networks }) {
|
|
|
1356
1962
|
setIsCopied(true);
|
|
1357
1963
|
window.setTimeout(() => setIsCopied(false), COPIED_FEEDBACK_MS);
|
|
1358
1964
|
}
|
|
1359
|
-
return /* @__PURE__ */
|
|
1360
|
-
/* @__PURE__ */
|
|
1361
|
-
canShareNatively && /* @__PURE__ */
|
|
1965
|
+
return /* @__PURE__ */ jsxs13("div", { className: "adc-share", role: "group", "aria-label": messages.shareLabel, children: [
|
|
1966
|
+
/* @__PURE__ */ jsx16("span", { className: "adc-label", children: messages.shareLabel }),
|
|
1967
|
+
canShareNatively && /* @__PURE__ */ jsxs13(
|
|
1362
1968
|
"button",
|
|
1363
1969
|
{
|
|
1364
1970
|
type: "button",
|
|
1365
1971
|
className: "adc-button",
|
|
1366
1972
|
onClick: () => void navigator.share({ url, title }).catch(() => void 0),
|
|
1367
1973
|
children: [
|
|
1368
|
-
/* @__PURE__ */
|
|
1974
|
+
/* @__PURE__ */ jsx16(Share2, { "aria-hidden": "true", className: "adc-icon" }),
|
|
1369
1975
|
messages.shareNative
|
|
1370
1976
|
]
|
|
1371
1977
|
}
|
|
1372
1978
|
),
|
|
1373
|
-
links.map((link) => /* @__PURE__ */
|
|
1979
|
+
links.map((link) => /* @__PURE__ */ jsx16(
|
|
1374
1980
|
"a",
|
|
1375
1981
|
{
|
|
1376
1982
|
className: `adc-button adc-share-link adc-share-link--${link.network}`,
|
|
@@ -1382,15 +1988,15 @@ function ShareButtons({ url, title, networks }) {
|
|
|
1382
1988
|
},
|
|
1383
1989
|
link.network
|
|
1384
1990
|
)),
|
|
1385
|
-
canCopy && /* @__PURE__ */
|
|
1386
|
-
isCopied ? /* @__PURE__ */
|
|
1387
|
-
/* @__PURE__ */
|
|
1991
|
+
canCopy && /* @__PURE__ */ jsxs13("button", { type: "button", className: "adc-button", onClick: () => void handleCopy().catch(() => void 0), children: [
|
|
1992
|
+
isCopied ? /* @__PURE__ */ jsx16(Check, { "aria-hidden": "true", className: "adc-icon" }) : /* @__PURE__ */ jsx16(Link2, { "aria-hidden": "true", className: "adc-icon" }),
|
|
1993
|
+
/* @__PURE__ */ jsx16("span", { "aria-live": "polite", children: isCopied ? messages.linkCopied : messages.copyLink })
|
|
1388
1994
|
] })
|
|
1389
1995
|
] });
|
|
1390
1996
|
}
|
|
1391
1997
|
|
|
1392
1998
|
// src/components/PostPage.tsx
|
|
1393
|
-
import { Fragment, jsx as
|
|
1999
|
+
import { Fragment, jsx as jsx17, jsxs as jsxs14 } from "react/jsx-runtime";
|
|
1394
2000
|
function PostPage({ slug, shareUrl, shareNetworks, getTagHref, onLoaded, renderNotFound }) {
|
|
1395
2001
|
const api = useContentPublicApi();
|
|
1396
2002
|
const { messages, locale, format } = useContentText();
|
|
@@ -1401,29 +2007,29 @@ function PostPage({ slug, shareUrl, shareNetworks, getTagHref, onLoaded, renderN
|
|
|
1401
2007
|
if (post) onLoaded?.(post);
|
|
1402
2008
|
}, [post, onLoaded]);
|
|
1403
2009
|
if (resource.isLoading && !post) {
|
|
1404
|
-
return /* @__PURE__ */
|
|
2010
|
+
return /* @__PURE__ */ jsx17("p", { className: "adc-root adc-state", role: "status", children: messages.loading });
|
|
1405
2011
|
}
|
|
1406
2012
|
if (!post) {
|
|
1407
|
-
return /* @__PURE__ */
|
|
2013
|
+
return /* @__PURE__ */ jsx17(Fragment, { children: renderNotFound ? renderNotFound() : /* @__PURE__ */ jsx17("p", { className: "adc-root adc-state", children: messages.notFound }) });
|
|
1408
2014
|
}
|
|
1409
2015
|
const url = shareUrl ?? (typeof window !== "undefined" ? window.location.href : "");
|
|
1410
|
-
return /* @__PURE__ */
|
|
1411
|
-
/* @__PURE__ */
|
|
1412
|
-
/* @__PURE__ */
|
|
1413
|
-
/* @__PURE__ */
|
|
1414
|
-
/* @__PURE__ */
|
|
1415
|
-
/* @__PURE__ */
|
|
2016
|
+
return /* @__PURE__ */ jsxs14("article", { className: "adc-root adc-post", children: [
|
|
2017
|
+
/* @__PURE__ */ jsxs14("header", { className: "adc-post-header", children: [
|
|
2018
|
+
/* @__PURE__ */ jsx17("h1", { className: "adc-page-title", children: post.title }),
|
|
2019
|
+
/* @__PURE__ */ jsxs14("p", { className: "adc-meta", children: [
|
|
2020
|
+
/* @__PURE__ */ jsx17("time", { dateTime: post.publishedAt, children: formatPostDate(post.publishedAt, locale) }),
|
|
2021
|
+
/* @__PURE__ */ jsx17("span", { "aria-hidden": "true", children: " \xB7 " }),
|
|
1416
2022
|
format("readingTime", { minutes: post.readingTimeMinutes }),
|
|
1417
|
-
post.authorName && /* @__PURE__ */
|
|
1418
|
-
/* @__PURE__ */
|
|
2023
|
+
post.authorName && /* @__PURE__ */ jsxs14(Fragment, { children: [
|
|
2024
|
+
/* @__PURE__ */ jsx17("span", { "aria-hidden": "true", children: " \xB7 " }),
|
|
1419
2025
|
format("byAuthor", { author: post.authorName })
|
|
1420
2026
|
] })
|
|
1421
2027
|
] }),
|
|
1422
|
-
post.tags.length > 0 && /* @__PURE__ */
|
|
2028
|
+
post.tags.length > 0 && /* @__PURE__ */ jsx17("ul", { className: "adc-tag-list", children: post.tags.map((tag) => /* @__PURE__ */ jsx17("li", { className: "adc-tag", children: getTagHref ? renderLink({ href: getTagHref(tag), children: tag }) : tag }, tag)) })
|
|
1423
2029
|
] }),
|
|
1424
|
-
post.coverImageUrl && /* @__PURE__ */
|
|
1425
|
-
/* @__PURE__ */
|
|
1426
|
-
url && shareNetworks?.length !== 0 && /* @__PURE__ */
|
|
2030
|
+
post.coverImageUrl && /* @__PURE__ */ jsx17("img", { className: "adc-post-cover", src: post.coverImageUrl, alt: post.coverImageAlt ?? "", decoding: "async" }),
|
|
2031
|
+
/* @__PURE__ */ jsx17(MarkdownContent, { markdown: post.body, headingLevelOffset: 1 }),
|
|
2032
|
+
url && shareNetworks?.length !== 0 && /* @__PURE__ */ jsx17(ShareButtons, { url, title: post.title, ...shareNetworks ? { networks: shareNetworks } : {} })
|
|
1427
2033
|
] });
|
|
1428
2034
|
}
|
|
1429
2035
|
|
|
@@ -1458,8 +2064,13 @@ export {
|
|
|
1458
2064
|
ContentWorkspace,
|
|
1459
2065
|
DEFAULT_CONTENT_LOCALE,
|
|
1460
2066
|
DRAFT_ERROR,
|
|
2067
|
+
EMOJI_BY_CATEGORY,
|
|
2068
|
+
EMOJI_CATEGORIES,
|
|
1461
2069
|
EMPTY_POST_DRAFT,
|
|
2070
|
+
EmojiPicker,
|
|
2071
|
+
FilePicker,
|
|
1462
2072
|
MarkdownContent,
|
|
2073
|
+
MarkdownEditor,
|
|
1463
2074
|
Pagination,
|
|
1464
2075
|
PostCard,
|
|
1465
2076
|
PostEditor,
|
|
@@ -1479,11 +2090,17 @@ export {
|
|
|
1479
2090
|
draftToInput,
|
|
1480
2091
|
formatPostDate,
|
|
1481
2092
|
fromDateTimeLocalValue,
|
|
2093
|
+
insertImage,
|
|
2094
|
+
insertLink,
|
|
2095
|
+
insertText,
|
|
1482
2096
|
interpolate,
|
|
1483
2097
|
isDraftDirty,
|
|
1484
2098
|
resolveContentMessages,
|
|
2099
|
+
searchEmoji,
|
|
1485
2100
|
splitTagInput,
|
|
1486
2101
|
toDateTimeLocalValue,
|
|
2102
|
+
toggleLinePrefix,
|
|
2103
|
+
toggleWrap,
|
|
1487
2104
|
useAsyncResource,
|
|
1488
2105
|
useContentAdminApi,
|
|
1489
2106
|
useContentPublicApi,
|