@adatechnology/content-ui 0.3.0 → 0.5.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/dist/index.d.ts +105 -21
- package/dist/index.js +1169 -423
- package/dist/index.js.map +1 -1
- package/dist/styles.css +233 -0
- package/dist/styles.css.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -163,6 +163,29 @@ var en_default = {
|
|
|
163
163
|
imageUploadFromDevice: "Upload from device",
|
|
164
164
|
dialogInsert: "Insert",
|
|
165
165
|
fileNoneChosen: "No file chosen",
|
|
166
|
+
photoDialogTitle: "Insert photos",
|
|
167
|
+
photoPickButton: "Choose photos",
|
|
168
|
+
photoDropHint: "Drag photos here, paste with Ctrl+V or choose from your device.",
|
|
169
|
+
photoCount: "{count} of {max} photos",
|
|
170
|
+
photoItemLabel: "Photo {position}",
|
|
171
|
+
photoAltLabel: "Photo description",
|
|
172
|
+
photoAltWarning: "Without a description, screen reader users will not know what the photo shows.",
|
|
173
|
+
photoCaptionLabel: "Caption (optional)",
|
|
174
|
+
photoRemove: "Remove photo",
|
|
175
|
+
photoMoveUp: "Move up",
|
|
176
|
+
photoMoveDown: "Move down",
|
|
177
|
+
photoStatusWaiting: "Waiting",
|
|
178
|
+
photoStatusReducing: "Resizing",
|
|
179
|
+
photoStatusUploading: "Uploading",
|
|
180
|
+
photoStatusDone: "Ready",
|
|
181
|
+
photoStatusError: "Failed",
|
|
182
|
+
photoRetry: "Try again",
|
|
183
|
+
photoSending: "Uploading photos\u2026",
|
|
184
|
+
photoNotImage: "{name} is not an image.",
|
|
185
|
+
photoLimitReached: "The limit is {max} photos at a time; {count} were left out.",
|
|
186
|
+
photoErrorDecode: "This photo could not be read. Try JPG, PNG or WebP.",
|
|
187
|
+
photoErrorEncode: "This browser cannot prepare the photo for upload.",
|
|
188
|
+
photoErrorTooLarge: "The photo is still too large after resizing.",
|
|
166
189
|
emojiTitle: "Choose emoji",
|
|
167
190
|
emojiSearch: "Search emoji",
|
|
168
191
|
emojiCategories: "Emoji categories",
|
|
@@ -173,7 +196,13 @@ var en_default = {
|
|
|
173
196
|
emojiNature: "Nature",
|
|
174
197
|
emojiTravel: "Places",
|
|
175
198
|
emojiObjects: "Objects",
|
|
176
|
-
emojiSymbols: "Symbols"
|
|
199
|
+
emojiSymbols: "Symbols",
|
|
200
|
+
imageOpen: "Enlarge photo {n} of {total}",
|
|
201
|
+
imageViewer: "Photo viewer",
|
|
202
|
+
imagePosition: "Photo {n} of {total}",
|
|
203
|
+
imageCounter: "{n} / {total}",
|
|
204
|
+
imagePrevious: "Previous photo",
|
|
205
|
+
imageNext: "Next photo"
|
|
177
206
|
};
|
|
178
207
|
|
|
179
208
|
// src/locales/pt-BR.json
|
|
@@ -338,6 +367,29 @@ var pt_BR_default = {
|
|
|
338
367
|
imageUploadFromDevice: "Enviar do aparelho",
|
|
339
368
|
dialogInsert: "Inserir",
|
|
340
369
|
fileNoneChosen: "Nenhum arquivo escolhido",
|
|
370
|
+
photoDialogTitle: "Inserir fotos",
|
|
371
|
+
photoPickButton: "Escolher fotos",
|
|
372
|
+
photoDropHint: "Arraste as fotos para c\xE1, cole com Ctrl+V ou escolha do aparelho.",
|
|
373
|
+
photoCount: "{count} de {max} fotos",
|
|
374
|
+
photoItemLabel: "Foto {position}",
|
|
375
|
+
photoAltLabel: "Descri\xE7\xE3o da foto",
|
|
376
|
+
photoAltWarning: "Sem descri\xE7\xE3o, quem usa leitor de tela n\xE3o saber\xE1 o que a foto mostra.",
|
|
377
|
+
photoCaptionLabel: "Legenda (opcional)",
|
|
378
|
+
photoRemove: "Remover foto",
|
|
379
|
+
photoMoveUp: "Mover para cima",
|
|
380
|
+
photoMoveDown: "Mover para baixo",
|
|
381
|
+
photoStatusWaiting: "Aguardando",
|
|
382
|
+
photoStatusReducing: "Reduzindo",
|
|
383
|
+
photoStatusUploading: "Enviando",
|
|
384
|
+
photoStatusDone: "Pronta",
|
|
385
|
+
photoStatusError: "Falhou",
|
|
386
|
+
photoRetry: "Tentar de novo",
|
|
387
|
+
photoSending: "Enviando fotos\u2026",
|
|
388
|
+
photoNotImage: "{name} n\xE3o \xE9 uma imagem.",
|
|
389
|
+
photoLimitReached: "O m\xE1ximo \xE9 {max} fotos por vez; {count} ficaram de fora.",
|
|
390
|
+
photoErrorDecode: "N\xE3o foi poss\xEDvel ler esta foto. Tente JPG, PNG ou WebP.",
|
|
391
|
+
photoErrorEncode: "Este navegador n\xE3o consegue preparar a foto para envio.",
|
|
392
|
+
photoErrorTooLarge: "A foto continua grande demais mesmo depois de reduzida.",
|
|
341
393
|
emojiTitle: "Escolher emoji",
|
|
342
394
|
emojiSearch: "Buscar emoji",
|
|
343
395
|
emojiCategories: "Categorias de emoji",
|
|
@@ -348,7 +400,13 @@ var pt_BR_default = {
|
|
|
348
400
|
emojiNature: "Natureza",
|
|
349
401
|
emojiTravel: "Lugares",
|
|
350
402
|
emojiObjects: "Objetos",
|
|
351
|
-
emojiSymbols: "S\xEDmbolos"
|
|
403
|
+
emojiSymbols: "S\xEDmbolos",
|
|
404
|
+
imageOpen: "Ampliar foto {n} de {total}",
|
|
405
|
+
imageViewer: "Visualizador de fotos",
|
|
406
|
+
imagePosition: "Foto {n} de {total}",
|
|
407
|
+
imageCounter: "{n} / {total}",
|
|
408
|
+
imagePrevious: "Foto anterior",
|
|
409
|
+
imageNext: "Pr\xF3xima foto"
|
|
352
410
|
};
|
|
353
411
|
|
|
354
412
|
// src/locales/index.ts
|
|
@@ -409,16 +467,25 @@ function useContentText() {
|
|
|
409
467
|
[messages, locale]
|
|
410
468
|
);
|
|
411
469
|
}
|
|
470
|
+
function useOptionalContentText() {
|
|
471
|
+
const value = useContext(ContentContext);
|
|
472
|
+
const locale = value?.locale ?? DEFAULT_CONTENT_LOCALE;
|
|
473
|
+
const messages = value?.messages ?? resolveContentMessages(locale);
|
|
474
|
+
return useMemo(
|
|
475
|
+
() => ({ messages, locale, format: (key, values) => interpolate(messages[key], values) }),
|
|
476
|
+
[messages, locale]
|
|
477
|
+
);
|
|
478
|
+
}
|
|
412
479
|
function useRenderLink() {
|
|
413
480
|
return useContentContext().renderLink;
|
|
414
481
|
}
|
|
415
482
|
|
|
416
483
|
// src/components/ContentWorkspace.tsx
|
|
417
|
-
import { useState as
|
|
484
|
+
import { useState as useState19 } from "react";
|
|
418
485
|
|
|
419
486
|
// src/components/PostEditor.tsx
|
|
420
487
|
import { Archive as Archive2, ArrowLeft, CalendarClock as CalendarClock2, EyeOff, Save, Send, Trash2 } from "lucide-react";
|
|
421
|
-
import { useId as
|
|
488
|
+
import { useId as useId6, useState as useState13 } from "react";
|
|
422
489
|
|
|
423
490
|
// src/hooks/usePostEditor.ts
|
|
424
491
|
import { useCallback as useCallback2, useEffect as useEffect2, useMemo as useMemo2, useState as useState2 } from "react";
|
|
@@ -649,12 +716,13 @@ function usePostEditor(params) {
|
|
|
649
716
|
}
|
|
650
717
|
}
|
|
651
718
|
async function uploadImage(file) {
|
|
652
|
-
|
|
719
|
+
const upload = api.uploadImage?.bind(api) ?? api.uploadCoverImage?.bind(api);
|
|
720
|
+
if (!upload) return { error: "coverUploadError" };
|
|
653
721
|
if (!COVER_MIME_TYPES.includes(file.type)) return { error: "coverInvalidType" };
|
|
654
722
|
if (file.size > COVER_MAX_BYTES) return { error: "coverTooLarge" };
|
|
655
723
|
setIsUploading(true);
|
|
656
724
|
try {
|
|
657
|
-
const { url } = await
|
|
725
|
+
const { url } = await upload(file);
|
|
658
726
|
return { url };
|
|
659
727
|
} catch {
|
|
660
728
|
return { error: "coverUploadError" };
|
|
@@ -679,7 +747,7 @@ function usePostEditor(params) {
|
|
|
679
747
|
feedback,
|
|
680
748
|
scheduleAt,
|
|
681
749
|
setScheduleAt,
|
|
682
|
-
canUploadCover: Boolean(api.uploadCoverImage),
|
|
750
|
+
canUploadCover: Boolean(api.uploadImage ?? api.uploadCoverImage),
|
|
683
751
|
tagSuggestions: (tags.data ?? []).map((entry) => entry.tag),
|
|
684
752
|
save,
|
|
685
753
|
publishNow,
|
|
@@ -711,15 +779,15 @@ function useUnsavedChangesGuard(isDirty, message) {
|
|
|
711
779
|
import { ImageUp } from "lucide-react";
|
|
712
780
|
import { useRef as useRef2, useState as useState3 } from "react";
|
|
713
781
|
import { jsx as jsx2, jsxs } from "react/jsx-runtime";
|
|
714
|
-
function FilePicker({
|
|
782
|
+
function FilePicker({ labels, accept, isBusy = false, isMultiple = false, onPick }) {
|
|
715
783
|
const inputRef = useRef2(null);
|
|
716
784
|
const [fileName, setFileName] = useState3("");
|
|
717
785
|
return /* @__PURE__ */ jsxs("div", { className: "adc-file-picker", children: [
|
|
718
786
|
/* @__PURE__ */ jsxs("button", { type: "button", className: "adc-button", disabled: isBusy, onClick: () => inputRef.current?.click(), children: [
|
|
719
787
|
/* @__PURE__ */ jsx2(ImageUp, { "aria-hidden": "true", className: "adc-icon" }),
|
|
720
|
-
|
|
788
|
+
labels.button
|
|
721
789
|
] }),
|
|
722
|
-
/* @__PURE__ */ jsx2("span", { className: "adc-file-name", "aria-live": "polite", children: fileName ||
|
|
790
|
+
/* @__PURE__ */ jsx2("span", { className: "adc-file-name", "aria-live": "polite", children: fileName || labels.empty }),
|
|
723
791
|
/* @__PURE__ */ jsx2(
|
|
724
792
|
"input",
|
|
725
793
|
{
|
|
@@ -727,12 +795,14 @@ function FilePicker({ buttonLabel, emptyLabel, accept, isBusy = false, onPick })
|
|
|
727
795
|
hidden: true,
|
|
728
796
|
type: "file",
|
|
729
797
|
accept,
|
|
798
|
+
multiple: isMultiple,
|
|
730
799
|
onChange: (event) => {
|
|
731
|
-
const
|
|
800
|
+
const files = Array.from(event.target.files ?? []);
|
|
732
801
|
event.target.value = "";
|
|
802
|
+
const [file] = files;
|
|
733
803
|
if (!file) return;
|
|
734
|
-
setFileName(file.name);
|
|
735
|
-
onPick(
|
|
804
|
+
if (!isMultiple) setFileName(file.name);
|
|
805
|
+
onPick(files);
|
|
736
806
|
}
|
|
737
807
|
}
|
|
738
808
|
)
|
|
@@ -748,27 +818,221 @@ import {
|
|
|
748
818
|
parseMarkdown,
|
|
749
819
|
resolveHeadingLevel
|
|
750
820
|
} from "@adatechnology/content-contracts";
|
|
751
|
-
import { useMemo as useMemo3 } from "react";
|
|
752
|
-
|
|
821
|
+
import { useMemo as useMemo3, useState as useState6 } from "react";
|
|
822
|
+
|
|
823
|
+
// src/lib/imageGallery.ts
|
|
824
|
+
var SWIPE_THRESHOLD_PX = 50;
|
|
825
|
+
function collectFromBlock(block) {
|
|
826
|
+
switch (block.type) {
|
|
827
|
+
case "figure":
|
|
828
|
+
return [{ ...block.image, caption: block.caption }];
|
|
829
|
+
case "gallery":
|
|
830
|
+
return [...block.images];
|
|
831
|
+
case "blockquote":
|
|
832
|
+
return block.children.flatMap(collectFromBlock);
|
|
833
|
+
case "list":
|
|
834
|
+
return block.items.flatMap((item) => item.flatMap(collectFromBlock));
|
|
835
|
+
default:
|
|
836
|
+
return [];
|
|
837
|
+
}
|
|
838
|
+
}
|
|
839
|
+
function collectViewerImages(document2) {
|
|
840
|
+
return document2.children.flatMap(collectFromBlock);
|
|
841
|
+
}
|
|
842
|
+
function stepImageIndex(current, delta, total) {
|
|
843
|
+
if (total <= 0) return 0;
|
|
844
|
+
return ((current + delta) % total + total) % total;
|
|
845
|
+
}
|
|
846
|
+
function resolveSwipeDirection(deltaX, deltaY) {
|
|
847
|
+
if (Math.abs(deltaX) <= SWIPE_THRESHOLD_PX || Math.abs(deltaX) <= Math.abs(deltaY)) return 0;
|
|
848
|
+
return deltaX < 0 ? 1 : -1;
|
|
849
|
+
}
|
|
850
|
+
|
|
851
|
+
// src/components/ImageLightbox.tsx
|
|
852
|
+
import { ChevronLeft, ChevronRight, X } from "lucide-react";
|
|
853
|
+
import { useEffect as useEffect4, useRef as useRef3, useState as useState5 } from "react";
|
|
854
|
+
|
|
855
|
+
// src/components/Tooltip.tsx
|
|
856
|
+
import { useId, useState as useState4 } from "react";
|
|
857
|
+
import { jsx as jsx3, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
858
|
+
function Tooltip({ text, children }) {
|
|
859
|
+
const id = useId();
|
|
860
|
+
const [isHovered, setIsHovered] = useState4(false);
|
|
861
|
+
const [isFocused, setIsFocused] = useState4(false);
|
|
862
|
+
return /* @__PURE__ */ jsxs2(
|
|
863
|
+
"span",
|
|
864
|
+
{
|
|
865
|
+
className: "adc-tip",
|
|
866
|
+
onMouseEnter: () => setIsHovered(true),
|
|
867
|
+
onMouseLeave: () => setIsHovered(false),
|
|
868
|
+
onFocus: () => setIsFocused(true),
|
|
869
|
+
onBlur: () => setIsFocused(false),
|
|
870
|
+
onKeyDown: (event) => {
|
|
871
|
+
if (event.key !== "Escape" || !(isHovered || isFocused)) return;
|
|
872
|
+
setIsHovered(false);
|
|
873
|
+
setIsFocused(false);
|
|
874
|
+
},
|
|
875
|
+
children: [
|
|
876
|
+
/* @__PURE__ */ jsx3("span", { "aria-describedby": id, className: "adc-tip-target", children }),
|
|
877
|
+
/* @__PURE__ */ jsx3("span", { id, role: "tooltip", className: "adc-tooltip", "data-visible": isHovered || isFocused, children: text })
|
|
878
|
+
]
|
|
879
|
+
}
|
|
880
|
+
);
|
|
881
|
+
}
|
|
882
|
+
|
|
883
|
+
// src/components/ImageLightbox.tsx
|
|
884
|
+
import { jsx as jsx4, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
885
|
+
var SCROLL_LOCK_CLASS = "adc-scroll-locked";
|
|
886
|
+
var FOCUSABLE_SELECTOR = "button:not([disabled])";
|
|
887
|
+
function useLightboxLifecycle(dialogRef) {
|
|
888
|
+
useEffect4(() => {
|
|
889
|
+
const trigger = document.activeElement instanceof HTMLElement ? document.activeElement : null;
|
|
890
|
+
document.body.classList.add(SCROLL_LOCK_CLASS);
|
|
891
|
+
dialogRef.current?.querySelector("[data-autofocus]")?.focus();
|
|
892
|
+
return () => {
|
|
893
|
+
document.body.classList.remove(SCROLL_LOCK_CLASS);
|
|
894
|
+
trigger?.focus();
|
|
895
|
+
};
|
|
896
|
+
}, [dialogRef]);
|
|
897
|
+
}
|
|
898
|
+
function ImageLightbox({ images, initialIndex, onClose }) {
|
|
899
|
+
const { messages, format } = useOptionalContentText();
|
|
900
|
+
const dialogRef = useRef3(null);
|
|
901
|
+
const touchStart = useRef3(null);
|
|
902
|
+
const [index, setIndex] = useState5(initialIndex);
|
|
903
|
+
const total = images.length;
|
|
904
|
+
const image = images[index];
|
|
905
|
+
const position = { n: index + 1, total };
|
|
906
|
+
useLightboxLifecycle(dialogRef);
|
|
907
|
+
function go(delta) {
|
|
908
|
+
if (total > 1) setIndex((current) => stepImageIndex(current, delta, total));
|
|
909
|
+
}
|
|
910
|
+
function trapFocus(event) {
|
|
911
|
+
const focusable = Array.from(dialogRef.current?.querySelectorAll(FOCUSABLE_SELECTOR) ?? []);
|
|
912
|
+
const first = focusable[0];
|
|
913
|
+
const last = focusable[focusable.length - 1];
|
|
914
|
+
if (!first || !last) return;
|
|
915
|
+
if (event.shiftKey && document.activeElement === first) {
|
|
916
|
+
event.preventDefault();
|
|
917
|
+
last.focus();
|
|
918
|
+
} else if (!event.shiftKey && document.activeElement === last) {
|
|
919
|
+
event.preventDefault();
|
|
920
|
+
first.focus();
|
|
921
|
+
}
|
|
922
|
+
}
|
|
923
|
+
function handleKeyDown(event) {
|
|
924
|
+
if (event.key === "Escape") onClose();
|
|
925
|
+
else if (event.key === "ArrowLeft") go(-1);
|
|
926
|
+
else if (event.key === "ArrowRight") go(1);
|
|
927
|
+
else if (event.key === "Tab") trapFocus(event);
|
|
928
|
+
}
|
|
929
|
+
function handleTouchStart(event) {
|
|
930
|
+
const touch = event.touches[0];
|
|
931
|
+
touchStart.current = touch ? { x: touch.clientX, y: touch.clientY } : null;
|
|
932
|
+
}
|
|
933
|
+
function handleTouchEnd(event) {
|
|
934
|
+
const start = touchStart.current;
|
|
935
|
+
const touch = event.changedTouches[0];
|
|
936
|
+
touchStart.current = null;
|
|
937
|
+
if (start && touch) go(resolveSwipeDirection(touch.clientX - start.x, touch.clientY - start.y));
|
|
938
|
+
}
|
|
939
|
+
if (!image) return null;
|
|
940
|
+
return /* @__PURE__ */ jsxs3(
|
|
941
|
+
"div",
|
|
942
|
+
{
|
|
943
|
+
ref: dialogRef,
|
|
944
|
+
className: "adc-root adc-lightbox",
|
|
945
|
+
role: "dialog",
|
|
946
|
+
"aria-modal": "true",
|
|
947
|
+
"aria-label": messages.imageViewer,
|
|
948
|
+
onKeyDown: handleKeyDown,
|
|
949
|
+
onClick: (event) => {
|
|
950
|
+
if (event.target === event.currentTarget) onClose();
|
|
951
|
+
},
|
|
952
|
+
children: [
|
|
953
|
+
/* @__PURE__ */ jsxs3("div", { className: "adc-lightbox__bar", children: [
|
|
954
|
+
/* @__PURE__ */ jsx4("span", { className: "adc-lightbox__counter", "aria-label": format("imagePosition", position), children: format("imageCounter", position) }),
|
|
955
|
+
/* @__PURE__ */ jsx4(Tooltip, { text: messages.close, children: /* @__PURE__ */ jsx4(
|
|
956
|
+
"button",
|
|
957
|
+
{
|
|
958
|
+
type: "button",
|
|
959
|
+
"data-autofocus": true,
|
|
960
|
+
className: "adc-lightbox__button",
|
|
961
|
+
"aria-label": messages.close,
|
|
962
|
+
onClick: onClose,
|
|
963
|
+
children: /* @__PURE__ */ jsx4(X, { "aria-hidden": "true", className: "adc-icon" })
|
|
964
|
+
}
|
|
965
|
+
) })
|
|
966
|
+
] }),
|
|
967
|
+
/* @__PURE__ */ jsxs3("div", { className: "adc-lightbox__stage", onTouchStart: handleTouchStart, onTouchEnd: handleTouchEnd, children: [
|
|
968
|
+
total > 1 && /* @__PURE__ */ jsx4(Tooltip, { text: messages.imagePrevious, children: /* @__PURE__ */ jsx4(
|
|
969
|
+
"button",
|
|
970
|
+
{
|
|
971
|
+
type: "button",
|
|
972
|
+
className: "adc-lightbox__button",
|
|
973
|
+
"aria-label": messages.imagePrevious,
|
|
974
|
+
onClick: () => go(-1),
|
|
975
|
+
children: /* @__PURE__ */ jsx4(ChevronLeft, { "aria-hidden": "true", className: "adc-icon" })
|
|
976
|
+
}
|
|
977
|
+
) }),
|
|
978
|
+
/* @__PURE__ */ jsxs3("figure", { className: "adc-lightbox__figure", children: [
|
|
979
|
+
/* @__PURE__ */ jsx4("img", { src: image.src, alt: image.alt }),
|
|
980
|
+
image.caption ? /* @__PURE__ */ jsx4("figcaption", { children: image.caption }) : null
|
|
981
|
+
] }),
|
|
982
|
+
total > 1 && /* @__PURE__ */ jsx4(Tooltip, { text: messages.imageNext, children: /* @__PURE__ */ jsx4(
|
|
983
|
+
"button",
|
|
984
|
+
{
|
|
985
|
+
type: "button",
|
|
986
|
+
className: "adc-lightbox__button",
|
|
987
|
+
"aria-label": messages.imageNext,
|
|
988
|
+
onClick: () => go(1),
|
|
989
|
+
children: /* @__PURE__ */ jsx4(ChevronRight, { "aria-hidden": "true", className: "adc-icon" })
|
|
990
|
+
}
|
|
991
|
+
) })
|
|
992
|
+
] })
|
|
993
|
+
]
|
|
994
|
+
}
|
|
995
|
+
);
|
|
996
|
+
}
|
|
997
|
+
|
|
998
|
+
// src/components/ZoomableImage.tsx
|
|
999
|
+
import { jsx as jsx5 } from "react/jsx-runtime";
|
|
1000
|
+
function ZoomableImage({ image, index, total, onOpen }) {
|
|
1001
|
+
const { format } = useOptionalContentText();
|
|
1002
|
+
const openLabel = format("imageOpen", { n: index + 1, total });
|
|
1003
|
+
return /* @__PURE__ */ jsx5(
|
|
1004
|
+
"button",
|
|
1005
|
+
{
|
|
1006
|
+
type: "button",
|
|
1007
|
+
className: "adc-figure__button",
|
|
1008
|
+
"aria-label": image.alt ? `${openLabel}: ${image.alt}` : openLabel,
|
|
1009
|
+
onClick: () => onOpen(index),
|
|
1010
|
+
children: /* @__PURE__ */ jsx5("img", { src: image.src, alt: image.alt, loading: "lazy", decoding: "async" })
|
|
1011
|
+
}
|
|
1012
|
+
);
|
|
1013
|
+
}
|
|
1014
|
+
|
|
1015
|
+
// src/components/MarkdownContent.tsx
|
|
1016
|
+
import { jsx as jsx6, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
753
1017
|
function renderInline(nodes) {
|
|
754
1018
|
return nodes.map((node, index) => {
|
|
755
1019
|
switch (node.type) {
|
|
756
1020
|
case "text":
|
|
757
1021
|
return node.value;
|
|
758
1022
|
case "strong":
|
|
759
|
-
return /* @__PURE__ */
|
|
1023
|
+
return /* @__PURE__ */ jsx6("strong", { children: renderInline(node.children) }, index);
|
|
760
1024
|
case "emphasis":
|
|
761
|
-
return /* @__PURE__ */
|
|
1025
|
+
return /* @__PURE__ */ jsx6("em", { children: renderInline(node.children) }, index);
|
|
762
1026
|
case "strikethrough":
|
|
763
|
-
return /* @__PURE__ */
|
|
1027
|
+
return /* @__PURE__ */ jsx6("del", { children: renderInline(node.children) }, index);
|
|
764
1028
|
case "inlineCode":
|
|
765
|
-
return /* @__PURE__ */
|
|
1029
|
+
return /* @__PURE__ */ jsx6("code", { children: node.value }, index);
|
|
766
1030
|
case "break":
|
|
767
|
-
return /* @__PURE__ */
|
|
1031
|
+
return /* @__PURE__ */ jsx6("br", {}, index);
|
|
768
1032
|
case "image":
|
|
769
|
-
return /* @__PURE__ */
|
|
1033
|
+
return /* @__PURE__ */ jsx6("img", { src: node.src, alt: node.alt, title: node.title, loading: "lazy", decoding: "async" }, index);
|
|
770
1034
|
case "link":
|
|
771
|
-
return /* @__PURE__ */
|
|
1035
|
+
return /* @__PURE__ */ jsx6(
|
|
772
1036
|
"a",
|
|
773
1037
|
{
|
|
774
1038
|
href: node.href,
|
|
@@ -786,26 +1050,64 @@ function renderBlock(block, key, context, tight = false) {
|
|
|
786
1050
|
switch (block.type) {
|
|
787
1051
|
case "heading": {
|
|
788
1052
|
const Tag = `h${resolveHeadingLevel(block.level, context.offset)}`;
|
|
789
|
-
return /* @__PURE__ */
|
|
1053
|
+
return /* @__PURE__ */ jsx6(Tag, { id: context.nextHeadingId(inlineToPlainText(block.children)), children: renderInline(block.children) }, key);
|
|
790
1054
|
}
|
|
791
1055
|
case "paragraph":
|
|
792
|
-
return tight ? /* @__PURE__ */
|
|
1056
|
+
return tight ? /* @__PURE__ */ jsx6("span", { children: renderInline(block.children) }, key) : /* @__PURE__ */ jsx6("p", { children: renderInline(block.children) }, key);
|
|
793
1057
|
case "blockquote":
|
|
794
|
-
return /* @__PURE__ */
|
|
1058
|
+
return /* @__PURE__ */ jsx6("blockquote", { children: block.children.map((child, index) => renderBlock(child, index, context)) }, key);
|
|
795
1059
|
case "codeBlock":
|
|
796
|
-
return /* @__PURE__ */
|
|
1060
|
+
return /* @__PURE__ */ jsx6("pre", { children: /* @__PURE__ */ jsx6("code", { className: block.language ? `language-${block.language}` : void 0, children: block.value }) }, key);
|
|
797
1061
|
case "thematicBreak":
|
|
798
|
-
return /* @__PURE__ */
|
|
1062
|
+
return /* @__PURE__ */ jsx6("hr", {}, key);
|
|
1063
|
+
case "figure":
|
|
1064
|
+
return /* @__PURE__ */ jsxs4("figure", { className: "adc-figure", children: [
|
|
1065
|
+
/* @__PURE__ */ jsx6(
|
|
1066
|
+
ZoomableImage,
|
|
1067
|
+
{
|
|
1068
|
+
image: block.image,
|
|
1069
|
+
index: context.nextImageIndex(),
|
|
1070
|
+
total: context.imageCount,
|
|
1071
|
+
onOpen: context.onOpenImage
|
|
1072
|
+
}
|
|
1073
|
+
),
|
|
1074
|
+
/* @__PURE__ */ jsx6("figcaption", { children: block.caption })
|
|
1075
|
+
] }, key);
|
|
1076
|
+
case "gallery":
|
|
1077
|
+
return /* @__PURE__ */ jsx6("div", { className: "adc-gallery", "data-count": block.images.length, children: block.images.map((image, index) => /* @__PURE__ */ jsxs4("figure", { className: "adc-figure", children: [
|
|
1078
|
+
/* @__PURE__ */ jsx6(
|
|
1079
|
+
ZoomableImage,
|
|
1080
|
+
{
|
|
1081
|
+
image,
|
|
1082
|
+
index: context.nextImageIndex(),
|
|
1083
|
+
total: context.imageCount,
|
|
1084
|
+
onOpen: context.onOpenImage
|
|
1085
|
+
}
|
|
1086
|
+
),
|
|
1087
|
+
image.caption ? /* @__PURE__ */ jsx6("figcaption", { children: image.caption }) : null
|
|
1088
|
+
] }, index)) }, key);
|
|
799
1089
|
case "list": {
|
|
800
|
-
const items = block.items.map((item, index) => /* @__PURE__ */
|
|
801
|
-
return block.ordered ? /* @__PURE__ */
|
|
1090
|
+
const items = block.items.map((item, index) => /* @__PURE__ */ jsx6("li", { children: item.map((child, childIndex) => renderBlock(child, childIndex, context, block.tight)) }, index));
|
|
1091
|
+
return block.ordered ? /* @__PURE__ */ jsx6("ol", { start: block.start, children: items }, key) : /* @__PURE__ */ jsx6("ul", { children: items }, key);
|
|
802
1092
|
}
|
|
803
1093
|
}
|
|
804
1094
|
}
|
|
805
1095
|
function MarkdownContent({ markdown, headingLevelOffset = 0, className }) {
|
|
806
1096
|
const document2 = useMemo3(() => parseMarkdown(markdown), [markdown]);
|
|
807
|
-
const
|
|
808
|
-
|
|
1097
|
+
const images = useMemo3(() => collectViewerImages(document2), [document2]);
|
|
1098
|
+
const [openIndex, setOpenIndex] = useState6(null);
|
|
1099
|
+
let imageCursor = 0;
|
|
1100
|
+
const context = {
|
|
1101
|
+
offset: headingLevelOffset,
|
|
1102
|
+
nextHeadingId: createHeadingIdGenerator(),
|
|
1103
|
+
nextImageIndex: () => imageCursor++,
|
|
1104
|
+
imageCount: images.length,
|
|
1105
|
+
onOpenImage: setOpenIndex
|
|
1106
|
+
};
|
|
1107
|
+
return /* @__PURE__ */ jsxs4("div", { className: ["adc-prose", className].filter(Boolean).join(" "), children: [
|
|
1108
|
+
document2.children.map((block, index) => renderBlock(block, index, context)),
|
|
1109
|
+
openIndex !== null && /* @__PURE__ */ jsx6(ImageLightbox, { images, initialIndex: openIndex, onClose: () => setOpenIndex(null) })
|
|
1110
|
+
] });
|
|
809
1111
|
}
|
|
810
1112
|
|
|
811
1113
|
// src/components/MarkdownEditor.tsx
|
|
@@ -821,7 +1123,7 @@ import {
|
|
|
821
1123
|
Quote,
|
|
822
1124
|
Smile
|
|
823
1125
|
} from "lucide-react";
|
|
824
|
-
import { useLayoutEffect, useRef as
|
|
1126
|
+
import { useLayoutEffect, useRef as useRef6, useState as useState11 } from "react";
|
|
825
1127
|
|
|
826
1128
|
// src/lib/markdownFormat.ts
|
|
827
1129
|
var LINE_PREFIX_PATTERN = {
|
|
@@ -902,8 +1204,46 @@ function isAbsoluteUrl(value) {
|
|
|
902
1204
|
}
|
|
903
1205
|
}
|
|
904
1206
|
|
|
1207
|
+
// src/lib/photoMarkdown.ts
|
|
1208
|
+
function collapseWhitespace(value) {
|
|
1209
|
+
return value.replace(/\s+/g, " ").trim();
|
|
1210
|
+
}
|
|
1211
|
+
function escapeImageAlt(alt) {
|
|
1212
|
+
return collapseWhitespace(alt).replace(/[\\[\]]/g, "");
|
|
1213
|
+
}
|
|
1214
|
+
function formatImageTitle(caption) {
|
|
1215
|
+
const text = collapseWhitespace(caption);
|
|
1216
|
+
if (!text) return "";
|
|
1217
|
+
if (!text.includes('"')) return ` "${text}"`;
|
|
1218
|
+
if (!text.includes("'")) return ` '${text}'`;
|
|
1219
|
+
return ` "${text.replace(/"/g, "\u201D")}"`;
|
|
1220
|
+
}
|
|
1221
|
+
var URL_ESCAPES = { "(": "%28", ")": "%29", " ": "%20" };
|
|
1222
|
+
function escapeImageUrl(url) {
|
|
1223
|
+
return url.replace(/[()\s]/g, (character) => URL_ESCAPES[character] ?? "%20");
|
|
1224
|
+
}
|
|
1225
|
+
function buildImageMarkdown(item) {
|
|
1226
|
+
return `}${formatImageTitle(item.caption)})`;
|
|
1227
|
+
}
|
|
1228
|
+
function buildPhotosMarkdown(items) {
|
|
1229
|
+
return items.map(buildImageMarkdown).join("\n");
|
|
1230
|
+
}
|
|
1231
|
+
function countTrailingNewlines(text) {
|
|
1232
|
+
return text.length - text.replace(/\n+$/, "").length;
|
|
1233
|
+
}
|
|
1234
|
+
function countLeadingNewlines(text) {
|
|
1235
|
+
return text.length - text.replace(/^\n+/, "").length;
|
|
1236
|
+
}
|
|
1237
|
+
function insertPhotosBlock(source, items) {
|
|
1238
|
+
const before = source.value.slice(0, source.start);
|
|
1239
|
+
const after = source.value.slice(source.end);
|
|
1240
|
+
const prefix = before ? "\n".repeat(Math.max(0, 2 - countTrailingNewlines(before))) : "";
|
|
1241
|
+
const suffix = after ? "\n".repeat(Math.max(0, 2 - countLeadingNewlines(after))) : "";
|
|
1242
|
+
return insertText(source, `${prefix}${buildPhotosMarkdown(items)}${suffix}`);
|
|
1243
|
+
}
|
|
1244
|
+
|
|
905
1245
|
// src/components/EmojiPicker.tsx
|
|
906
|
-
import { useId, useState as
|
|
1246
|
+
import { useId as useId2, useState as useState7 } from "react";
|
|
907
1247
|
|
|
908
1248
|
// src/lib/emoji.ts
|
|
909
1249
|
var EMOJI_CATEGORIES = [
|
|
@@ -953,7 +1293,7 @@ function searchEmoji(query) {
|
|
|
953
1293
|
}
|
|
954
1294
|
|
|
955
1295
|
// src/components/EmojiPicker.tsx
|
|
956
|
-
import { jsx as
|
|
1296
|
+
import { jsx as jsx7, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
957
1297
|
var CATEGORY_MESSAGE = {
|
|
958
1298
|
smileys: "emojiSmileys",
|
|
959
1299
|
gestures: "emojiGestures",
|
|
@@ -965,12 +1305,12 @@ var CATEGORY_MESSAGE = {
|
|
|
965
1305
|
};
|
|
966
1306
|
function EmojiPicker({ onPick, onClose }) {
|
|
967
1307
|
const { messages } = useContentText();
|
|
968
|
-
const [category, setCategory] =
|
|
969
|
-
const [query, setQuery] =
|
|
970
|
-
const searchId =
|
|
1308
|
+
const [category, setCategory] = useState7("smileys");
|
|
1309
|
+
const [query, setQuery] = useState7("");
|
|
1310
|
+
const searchId = useId2();
|
|
971
1311
|
const isSearching = query.trim().length > 0;
|
|
972
1312
|
const visible = isSearching ? searchEmoji(query) : EMOJI_BY_CATEGORY[category];
|
|
973
|
-
return /* @__PURE__ */
|
|
1313
|
+
return /* @__PURE__ */ jsxs5(
|
|
974
1314
|
"div",
|
|
975
1315
|
{
|
|
976
1316
|
className: "adc-popover adc-emoji",
|
|
@@ -982,8 +1322,8 @@ function EmojiPicker({ onPick, onClose }) {
|
|
|
982
1322
|
onClose();
|
|
983
1323
|
},
|
|
984
1324
|
children: [
|
|
985
|
-
/* @__PURE__ */
|
|
986
|
-
/* @__PURE__ */
|
|
1325
|
+
/* @__PURE__ */ jsx7("label", { htmlFor: searchId, className: "adc-visually-hidden", children: messages.emojiSearch }),
|
|
1326
|
+
/* @__PURE__ */ jsx7(
|
|
987
1327
|
"input",
|
|
988
1328
|
{
|
|
989
1329
|
id: searchId,
|
|
@@ -998,7 +1338,7 @@ function EmojiPicker({ onPick, onClose }) {
|
|
|
998
1338
|
}
|
|
999
1339
|
}
|
|
1000
1340
|
),
|
|
1001
|
-
!isSearching && /* @__PURE__ */
|
|
1341
|
+
!isSearching && /* @__PURE__ */ jsx7("div", { className: "adc-emoji-categories", role: "group", "aria-label": messages.emojiCategories, children: EMOJI_CATEGORIES.map((value) => /* @__PURE__ */ jsx7(
|
|
1002
1342
|
"button",
|
|
1003
1343
|
{
|
|
1004
1344
|
type: "button",
|
|
@@ -1009,7 +1349,7 @@ function EmojiPicker({ onPick, onClose }) {
|
|
|
1009
1349
|
},
|
|
1010
1350
|
value
|
|
1011
1351
|
)) }),
|
|
1012
|
-
visible.length === 0 ? /* @__PURE__ */
|
|
1352
|
+
visible.length === 0 ? /* @__PURE__ */ jsx7("p", { className: "adc-muted", role: "status", children: messages.emojiEmpty }) : /* @__PURE__ */ jsx7("div", { className: "adc-emoji-grid", children: visible.map((entry) => /* @__PURE__ */ jsx7(
|
|
1013
1353
|
"button",
|
|
1014
1354
|
{
|
|
1015
1355
|
type: "button",
|
|
@@ -1026,15 +1366,15 @@ function EmojiPicker({ onPick, onClose }) {
|
|
|
1026
1366
|
}
|
|
1027
1367
|
|
|
1028
1368
|
// src/components/InsertDialog.tsx
|
|
1029
|
-
import { useId as
|
|
1030
|
-
import { jsx as
|
|
1369
|
+
import { useId as useId3, useState as useState8 } from "react";
|
|
1370
|
+
import { jsx as jsx8, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
1031
1371
|
function InsertDialog(props) {
|
|
1032
1372
|
const { messages } = useContentText();
|
|
1033
|
-
const [url, setUrl] =
|
|
1034
|
-
const [text, setText] =
|
|
1035
|
-
const [errorMessage, setErrorMessage] =
|
|
1036
|
-
const urlId =
|
|
1037
|
-
const textId =
|
|
1373
|
+
const [url, setUrl] = useState8("");
|
|
1374
|
+
const [text, setText] = useState8(props.initialText);
|
|
1375
|
+
const [errorMessage, setErrorMessage] = useState8("");
|
|
1376
|
+
const urlId = useId3();
|
|
1377
|
+
const textId = useId3();
|
|
1038
1378
|
const isImage = props.kind === "image";
|
|
1039
1379
|
function submit() {
|
|
1040
1380
|
if (!isAbsoluteUrl(url)) return setErrorMessage(messages.errorUrl);
|
|
@@ -1058,7 +1398,7 @@ function InsertDialog(props) {
|
|
|
1058
1398
|
submit();
|
|
1059
1399
|
}
|
|
1060
1400
|
}
|
|
1061
|
-
return /* @__PURE__ */
|
|
1401
|
+
return /* @__PURE__ */ jsxs6(
|
|
1062
1402
|
"div",
|
|
1063
1403
|
{
|
|
1064
1404
|
className: "adc-popover adc-insert",
|
|
@@ -1066,19 +1406,24 @@ function InsertDialog(props) {
|
|
|
1066
1406
|
"aria-label": isImage ? messages.imageDialogTitle : messages.linkDialogTitle,
|
|
1067
1407
|
onKeyDown: handleKeyDown,
|
|
1068
1408
|
children: [
|
|
1069
|
-
isImage && props.onUpload && /* @__PURE__ */
|
|
1409
|
+
isImage && props.onUpload && /* @__PURE__ */ jsx8(
|
|
1070
1410
|
FilePicker,
|
|
1071
1411
|
{
|
|
1072
|
-
|
|
1073
|
-
|
|
1412
|
+
labels: {
|
|
1413
|
+
button: props.isUploading ? messages.coverUploading : messages.imageUploadFromDevice,
|
|
1414
|
+
empty: messages.fileNoneChosen
|
|
1415
|
+
},
|
|
1074
1416
|
accept: "image/*",
|
|
1075
1417
|
isBusy: props.isUploading,
|
|
1076
|
-
onPick: (
|
|
1418
|
+
onPick: (files) => {
|
|
1419
|
+
const [file] = files;
|
|
1420
|
+
if (file) void handlePick(file);
|
|
1421
|
+
}
|
|
1077
1422
|
}
|
|
1078
1423
|
),
|
|
1079
|
-
/* @__PURE__ */
|
|
1080
|
-
/* @__PURE__ */
|
|
1081
|
-
/* @__PURE__ */
|
|
1424
|
+
/* @__PURE__ */ jsxs6("div", { className: "adc-field", children: [
|
|
1425
|
+
/* @__PURE__ */ jsx8("label", { htmlFor: urlId, children: isImage ? messages.fieldCoverUrl : messages.linkUrl }),
|
|
1426
|
+
/* @__PURE__ */ jsx8(
|
|
1082
1427
|
"input",
|
|
1083
1428
|
{
|
|
1084
1429
|
id: urlId,
|
|
@@ -1090,14 +1435,14 @@ function InsertDialog(props) {
|
|
|
1090
1435
|
}
|
|
1091
1436
|
)
|
|
1092
1437
|
] }),
|
|
1093
|
-
/* @__PURE__ */
|
|
1094
|
-
/* @__PURE__ */
|
|
1095
|
-
/* @__PURE__ */
|
|
1438
|
+
/* @__PURE__ */ jsxs6("div", { className: "adc-field", children: [
|
|
1439
|
+
/* @__PURE__ */ jsx8("label", { htmlFor: textId, children: isImage ? messages.fieldCoverAlt : messages.linkText }),
|
|
1440
|
+
/* @__PURE__ */ jsx8("input", { id: textId, type: "text", value: text, onChange: (event) => setText(event.target.value) })
|
|
1096
1441
|
] }),
|
|
1097
|
-
/* @__PURE__ */
|
|
1098
|
-
/* @__PURE__ */
|
|
1099
|
-
/* @__PURE__ */
|
|
1100
|
-
/* @__PURE__ */
|
|
1442
|
+
/* @__PURE__ */ jsx8("p", { className: "adc-error", role: "alert", hidden: !errorMessage, children: errorMessage }),
|
|
1443
|
+
/* @__PURE__ */ jsxs6("div", { className: "adc-insert-actions", children: [
|
|
1444
|
+
/* @__PURE__ */ jsx8("button", { type: "button", className: "adc-button adc-button--ghost", onClick: props.onClose, children: messages.dialogCancel }),
|
|
1445
|
+
/* @__PURE__ */ jsx8(
|
|
1101
1446
|
"button",
|
|
1102
1447
|
{
|
|
1103
1448
|
type: "button",
|
|
@@ -1113,36 +1458,404 @@ function InsertDialog(props) {
|
|
|
1113
1458
|
);
|
|
1114
1459
|
}
|
|
1115
1460
|
|
|
1116
|
-
// src/components/
|
|
1117
|
-
import {
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1461
|
+
// src/components/PhotoInsertDialog.tsx
|
|
1462
|
+
import { useEffect as useEffect6, useRef as useRef5, useState as useState10 } from "react";
|
|
1463
|
+
|
|
1464
|
+
// src/hooks/usePhotoBatch.ts
|
|
1465
|
+
import { useEffect as useEffect5, useRef as useRef4, useState as useState9 } from "react";
|
|
1466
|
+
|
|
1467
|
+
// src/lib/reduceImage.ts
|
|
1468
|
+
var REDUCED_MAX_BYTES = 1024 * 1024;
|
|
1469
|
+
var REDUCTION_ATTEMPTS = [
|
|
1470
|
+
{ maxSide: 1600, quality: 0.82 },
|
|
1471
|
+
{ maxSide: 1600, quality: 0.7 },
|
|
1472
|
+
{ maxSide: 1600, quality: 0.6 },
|
|
1473
|
+
{ maxSide: 1280, quality: 0.6 }
|
|
1474
|
+
];
|
|
1475
|
+
var ReduceImageError = class extends Error {
|
|
1476
|
+
constructor(code) {
|
|
1477
|
+
super(code);
|
|
1478
|
+
this.code = code;
|
|
1479
|
+
this.name = "ReduceImageError";
|
|
1480
|
+
}
|
|
1481
|
+
code;
|
|
1482
|
+
};
|
|
1483
|
+
function computeTargetSize(width, height, maxSide) {
|
|
1484
|
+
const longestSide = Math.max(width, height);
|
|
1485
|
+
if (longestSide <= maxSide) return { width, height };
|
|
1486
|
+
const scale = maxSide / longestSide;
|
|
1487
|
+
return { width: Math.max(1, Math.round(width * scale)), height: Math.max(1, Math.round(height * scale)) };
|
|
1488
|
+
}
|
|
1489
|
+
var OUTPUT_MIME_TYPES = ["image/webp", "image/jpeg"];
|
|
1490
|
+
function extensionForMime(mime) {
|
|
1491
|
+
return mime === "image/webp" ? "webp" : "jpg";
|
|
1492
|
+
}
|
|
1493
|
+
function buildReducedFileName(identifier, mime = "image/webp") {
|
|
1494
|
+
return `${identifier}.${extensionForMime(mime)}`;
|
|
1495
|
+
}
|
|
1496
|
+
function didEncodeAs(blob, requested) {
|
|
1497
|
+
return blob.type === requested;
|
|
1498
|
+
}
|
|
1499
|
+
async function reduceInMime(encode, mime, maxBytes) {
|
|
1500
|
+
for (const attempt of REDUCTION_ATTEMPTS) {
|
|
1501
|
+
const blob = await encode(attempt, mime);
|
|
1502
|
+
if (!didEncodeAs(blob, mime)) return "unsupported";
|
|
1503
|
+
if (blob.size <= maxBytes) return blob;
|
|
1504
|
+
}
|
|
1505
|
+
return "tooLarge";
|
|
1506
|
+
}
|
|
1507
|
+
async function reduceWithLadder(encode, maxBytes = REDUCED_MAX_BYTES) {
|
|
1508
|
+
let failure = "unsupported";
|
|
1509
|
+
for (const mime of OUTPUT_MIME_TYPES) {
|
|
1510
|
+
const outcome = await reduceInMime(encode, mime, maxBytes);
|
|
1511
|
+
if (typeof outcome !== "string") return { blob: outcome, mime };
|
|
1512
|
+
if (outcome === "tooLarge") failure = "tooLarge";
|
|
1513
|
+
}
|
|
1514
|
+
throw new ReduceImageError(failure);
|
|
1515
|
+
}
|
|
1516
|
+
function encodeBitmap(bitmap, attempt, mime) {
|
|
1517
|
+
const { width, height } = computeTargetSize(bitmap.width, bitmap.height, attempt.maxSide);
|
|
1518
|
+
return drawAndEncode(bitmap, { width, height, quality: attempt.quality, mime });
|
|
1519
|
+
}
|
|
1520
|
+
async function drawAndEncode(bitmap, target) {
|
|
1521
|
+
const { width, height, quality, mime } = target;
|
|
1522
|
+
if (typeof OffscreenCanvas !== "undefined") {
|
|
1523
|
+
const canvas2 = new OffscreenCanvas(width, height);
|
|
1524
|
+
canvas2.getContext("2d")?.drawImage(bitmap, 0, 0, width, height);
|
|
1525
|
+
return canvas2.convertToBlob({ type: mime, quality });
|
|
1526
|
+
}
|
|
1527
|
+
const canvas = document.createElement("canvas");
|
|
1528
|
+
canvas.width = width;
|
|
1529
|
+
canvas.height = height;
|
|
1530
|
+
canvas.getContext("2d")?.drawImage(bitmap, 0, 0, width, height);
|
|
1531
|
+
return new Promise((resolve, reject) => {
|
|
1532
|
+
canvas.toBlob((blob) => blob ? resolve(blob) : reject(new ReduceImageError("unsupported")), mime, quality);
|
|
1533
|
+
});
|
|
1534
|
+
}
|
|
1535
|
+
async function decode(file) {
|
|
1536
|
+
try {
|
|
1537
|
+
return await createImageBitmap(file, { imageOrientation: "from-image" });
|
|
1538
|
+
} catch {
|
|
1539
|
+
throw new ReduceImageError("decode");
|
|
1540
|
+
}
|
|
1541
|
+
}
|
|
1542
|
+
async function reduceImage(file) {
|
|
1543
|
+
const bitmap = await decode(file);
|
|
1544
|
+
try {
|
|
1545
|
+
const { blob, mime } = await reduceWithLadder((attempt, outputMime) => encodeBitmap(bitmap, attempt, outputMime));
|
|
1546
|
+
return new File([blob], buildReducedFileName(crypto.randomUUID(), mime), { type: mime });
|
|
1547
|
+
} finally {
|
|
1548
|
+
bitmap.close();
|
|
1549
|
+
}
|
|
1550
|
+
}
|
|
1551
|
+
|
|
1552
|
+
// src/lib/runWithConcurrency.ts
|
|
1553
|
+
async function runWithConcurrency(items, limit, worker) {
|
|
1554
|
+
const results = new Array(items.length);
|
|
1555
|
+
let nextIndex = 0;
|
|
1556
|
+
async function drain() {
|
|
1557
|
+
while (nextIndex < items.length) {
|
|
1558
|
+
const index = nextIndex;
|
|
1559
|
+
nextIndex += 1;
|
|
1560
|
+
results[index] = await worker(items[index]);
|
|
1561
|
+
}
|
|
1562
|
+
}
|
|
1563
|
+
await Promise.all(Array.from({ length: Math.min(limit, items.length) }, drain));
|
|
1564
|
+
return results;
|
|
1565
|
+
}
|
|
1566
|
+
|
|
1567
|
+
// src/hooks/usePhotoBatch.ts
|
|
1568
|
+
var UPLOAD_CONCURRENCY = 2;
|
|
1569
|
+
var REDUCE_ERROR_KEYS = {
|
|
1570
|
+
decode: "photoErrorDecode",
|
|
1571
|
+
unsupported: "photoErrorEncode",
|
|
1572
|
+
tooLarge: "photoErrorTooLarge"
|
|
1573
|
+
};
|
|
1574
|
+
function createItem(file) {
|
|
1575
|
+
return {
|
|
1576
|
+
id: crypto.randomUUID(),
|
|
1577
|
+
file,
|
|
1578
|
+
previewUrl: URL.createObjectURL(file),
|
|
1579
|
+
alt: "",
|
|
1580
|
+
caption: "",
|
|
1581
|
+
status: "waiting",
|
|
1582
|
+
url: "",
|
|
1583
|
+
errorKey: void 0
|
|
1584
|
+
};
|
|
1585
|
+
}
|
|
1586
|
+
function usePhotoBatch({ maxImages, onUpload, onAllDone }) {
|
|
1587
|
+
const [items, setItems] = useState9([]);
|
|
1588
|
+
const [isRunning, setIsRunning] = useState9(false);
|
|
1589
|
+
const itemsRef = useRef4([]);
|
|
1590
|
+
useEffect5(() => () => itemsRef.current.forEach((item) => URL.revokeObjectURL(item.previewUrl)), []);
|
|
1591
|
+
function commit(next) {
|
|
1592
|
+
itemsRef.current = next;
|
|
1593
|
+
setItems(next);
|
|
1594
|
+
}
|
|
1595
|
+
function patch(id, changes) {
|
|
1596
|
+
commit(itemsRef.current.map((item) => item.id === id ? { ...item, ...changes } : item));
|
|
1597
|
+
}
|
|
1598
|
+
function addFiles(files) {
|
|
1599
|
+
const room = Math.max(0, maxImages - itemsRef.current.length);
|
|
1600
|
+
commit([...itemsRef.current, ...files.slice(0, room).map(createItem)]);
|
|
1601
|
+
return files.length - Math.min(files.length, room);
|
|
1602
|
+
}
|
|
1603
|
+
function remove(id) {
|
|
1604
|
+
const removed = itemsRef.current.find((item) => item.id === id);
|
|
1605
|
+
if (removed) URL.revokeObjectURL(removed.previewUrl);
|
|
1606
|
+
commit(itemsRef.current.filter((item) => item.id !== id));
|
|
1607
|
+
}
|
|
1608
|
+
function move(id, offset) {
|
|
1609
|
+
const list = [...itemsRef.current];
|
|
1610
|
+
const from = list.findIndex((item) => item.id === id);
|
|
1611
|
+
const to = from + offset;
|
|
1612
|
+
if (from < 0 || to < 0 || to >= list.length) return;
|
|
1613
|
+
list.splice(to, 0, ...list.splice(from, 1));
|
|
1614
|
+
commit(list);
|
|
1615
|
+
}
|
|
1616
|
+
async function processItem(item) {
|
|
1617
|
+
try {
|
|
1618
|
+
patch(item.id, { status: "reducing", errorKey: void 0 });
|
|
1619
|
+
const reduced = await reduceImage(item.file);
|
|
1620
|
+
patch(item.id, { status: "uploading" });
|
|
1621
|
+
const result = await onUpload(reduced);
|
|
1622
|
+
if ("error" in result) return patch(item.id, { status: "error", errorKey: result.error });
|
|
1623
|
+
patch(item.id, { status: "done", url: result.url });
|
|
1624
|
+
} catch (error) {
|
|
1625
|
+
const errorKey = error instanceof ReduceImageError ? REDUCE_ERROR_KEYS[error.code] : "coverUploadError";
|
|
1626
|
+
patch(item.id, { status: "error", errorKey });
|
|
1627
|
+
}
|
|
1628
|
+
}
|
|
1629
|
+
async function start(ids) {
|
|
1630
|
+
const pending = itemsRef.current.filter((item) => item.status !== "done" && (!ids || ids.includes(item.id)));
|
|
1631
|
+
setIsRunning(true);
|
|
1632
|
+
await runWithConcurrency(pending, UPLOAD_CONCURRENCY, processItem);
|
|
1633
|
+
setIsRunning(false);
|
|
1634
|
+
const current = itemsRef.current;
|
|
1635
|
+
if (current.length > 0 && current.every((item) => item.status === "done")) onAllDone(current);
|
|
1636
|
+
}
|
|
1637
|
+
return { items, isRunning, addFiles, remove, move, patch, start };
|
|
1638
|
+
}
|
|
1639
|
+
|
|
1640
|
+
// src/components/PhotoRow.tsx
|
|
1641
|
+
import { ArrowDown, ArrowUp, RotateCw, X as X2 } from "lucide-react";
|
|
1642
|
+
import { useId as useId4 } from "react";
|
|
1643
|
+
import { jsx as jsx9, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
1644
|
+
var STATUS_KEYS = {
|
|
1645
|
+
waiting: "photoStatusWaiting",
|
|
1646
|
+
reducing: "photoStatusReducing",
|
|
1647
|
+
uploading: "photoStatusUploading",
|
|
1648
|
+
done: "photoStatusDone",
|
|
1649
|
+
error: "photoStatusError"
|
|
1650
|
+
};
|
|
1651
|
+
function PhotoRow({ item, placement, isLocked, actions }) {
|
|
1652
|
+
const { messages } = useContentText();
|
|
1653
|
+
const altId = useId4();
|
|
1654
|
+
const captionId = useId4();
|
|
1655
|
+
const { position, total } = placement;
|
|
1656
|
+
const label = interpolate(messages.photoItemLabel, { position });
|
|
1657
|
+
const hasMissingAlt = item.alt.trim() === "";
|
|
1658
|
+
return /* @__PURE__ */ jsxs7("li", { className: "adc-photo-row", "aria-label": label, children: [
|
|
1659
|
+
/* @__PURE__ */ jsx9("img", { className: "adc-photo-thumb", src: item.previewUrl, alt: "" }),
|
|
1660
|
+
/* @__PURE__ */ jsxs7("div", { className: "adc-photo-fields", children: [
|
|
1661
|
+
/* @__PURE__ */ jsxs7("div", { className: "adc-field", children: [
|
|
1662
|
+
/* @__PURE__ */ jsx9("label", { htmlFor: altId, children: messages.photoAltLabel }),
|
|
1663
|
+
/* @__PURE__ */ jsx9(
|
|
1664
|
+
"input",
|
|
1665
|
+
{
|
|
1666
|
+
id: altId,
|
|
1667
|
+
type: "text",
|
|
1668
|
+
value: item.alt,
|
|
1669
|
+
disabled: isLocked,
|
|
1670
|
+
onChange: (event) => actions.onChange(item.id, { alt: event.target.value })
|
|
1671
|
+
}
|
|
1672
|
+
),
|
|
1673
|
+
hasMissingAlt && /* @__PURE__ */ jsx9("span", { className: "adc-hint", children: messages.photoAltWarning })
|
|
1674
|
+
] }),
|
|
1675
|
+
/* @__PURE__ */ jsxs7("div", { className: "adc-field", children: [
|
|
1676
|
+
/* @__PURE__ */ jsx9("label", { htmlFor: captionId, children: messages.photoCaptionLabel }),
|
|
1677
|
+
/* @__PURE__ */ jsx9(
|
|
1678
|
+
"input",
|
|
1679
|
+
{
|
|
1680
|
+
id: captionId,
|
|
1681
|
+
type: "text",
|
|
1682
|
+
value: item.caption,
|
|
1683
|
+
disabled: isLocked,
|
|
1684
|
+
onChange: (event) => actions.onChange(item.id, { caption: event.target.value })
|
|
1685
|
+
}
|
|
1686
|
+
)
|
|
1687
|
+
] }),
|
|
1688
|
+
/* @__PURE__ */ jsxs7("p", { className: `adc-photo-status adc-photo-status--${item.status}`, role: "status", children: [
|
|
1689
|
+
messages[STATUS_KEYS[item.status]],
|
|
1690
|
+
item.errorKey ? `: ${messages[item.errorKey]}` : ""
|
|
1691
|
+
] })
|
|
1692
|
+
] }),
|
|
1693
|
+
/* @__PURE__ */ jsxs7("div", { className: "adc-photo-actions", children: [
|
|
1694
|
+
/* @__PURE__ */ jsx9(
|
|
1695
|
+
"button",
|
|
1696
|
+
{
|
|
1697
|
+
type: "button",
|
|
1698
|
+
className: "adc-button adc-button--icon adc-button--compact",
|
|
1699
|
+
"aria-label": `${messages.photoMoveUp} (${label})`,
|
|
1700
|
+
disabled: isLocked || position === 1,
|
|
1701
|
+
onClick: () => actions.onMove(item.id, -1),
|
|
1702
|
+
children: /* @__PURE__ */ jsx9(ArrowUp, { "aria-hidden": "true", className: "adc-icon" })
|
|
1703
|
+
}
|
|
1704
|
+
),
|
|
1705
|
+
/* @__PURE__ */ jsx9(
|
|
1706
|
+
"button",
|
|
1707
|
+
{
|
|
1708
|
+
type: "button",
|
|
1709
|
+
className: "adc-button adc-button--icon adc-button--compact",
|
|
1710
|
+
"aria-label": `${messages.photoMoveDown} (${label})`,
|
|
1711
|
+
disabled: isLocked || position === total,
|
|
1712
|
+
onClick: () => actions.onMove(item.id, 1),
|
|
1713
|
+
children: /* @__PURE__ */ jsx9(ArrowDown, { "aria-hidden": "true", className: "adc-icon" })
|
|
1714
|
+
}
|
|
1715
|
+
),
|
|
1716
|
+
/* @__PURE__ */ jsx9(
|
|
1717
|
+
"button",
|
|
1718
|
+
{
|
|
1719
|
+
type: "button",
|
|
1720
|
+
className: "adc-button adc-button--icon adc-button--compact adc-button--danger",
|
|
1721
|
+
"aria-label": `${messages.photoRemove} (${label})`,
|
|
1722
|
+
disabled: isLocked,
|
|
1723
|
+
onClick: () => actions.onRemove(item.id),
|
|
1724
|
+
children: /* @__PURE__ */ jsx9(X2, { "aria-hidden": "true", className: "adc-icon" })
|
|
1725
|
+
}
|
|
1726
|
+
),
|
|
1727
|
+
item.status === "error" && /* @__PURE__ */ jsxs7(
|
|
1728
|
+
"button",
|
|
1729
|
+
{
|
|
1730
|
+
type: "button",
|
|
1731
|
+
className: "adc-button adc-button--compact",
|
|
1732
|
+
disabled: isLocked,
|
|
1733
|
+
onClick: () => actions.onRetry(item.id),
|
|
1734
|
+
children: [
|
|
1735
|
+
/* @__PURE__ */ jsx9(RotateCw, { "aria-hidden": "true", className: "adc-icon" }),
|
|
1736
|
+
messages.photoRetry
|
|
1737
|
+
]
|
|
1738
|
+
}
|
|
1739
|
+
)
|
|
1740
|
+
] })
|
|
1741
|
+
] });
|
|
1742
|
+
}
|
|
1743
|
+
|
|
1744
|
+
// src/components/PhotoInsertDialog.tsx
|
|
1745
|
+
import { jsx as jsx10, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
1746
|
+
var DEFAULT_MAX_PHOTOS = 12;
|
|
1747
|
+
function pickImages(files) {
|
|
1748
|
+
const images = [];
|
|
1749
|
+
const rejected = [];
|
|
1750
|
+
for (const file of files) (file.type.startsWith("image/") ? images : rejected).push(file);
|
|
1751
|
+
return { images, rejected };
|
|
1752
|
+
}
|
|
1753
|
+
function toMarkdownItems(items) {
|
|
1754
|
+
return items.map(({ url, alt, caption }) => ({ url, alt, caption }));
|
|
1755
|
+
}
|
|
1756
|
+
function PhotoInsertDialog({
|
|
1757
|
+
maxImages = DEFAULT_MAX_PHOTOS,
|
|
1758
|
+
onUpload,
|
|
1759
|
+
onInsert,
|
|
1760
|
+
onClose
|
|
1761
|
+
}) {
|
|
1762
|
+
const { messages } = useContentText();
|
|
1763
|
+
const [notice, setNotice] = useState10("");
|
|
1764
|
+
const [isDragging, setIsDragging] = useState10(false);
|
|
1765
|
+
const rootRef = useRef5(null);
|
|
1766
|
+
const batch = usePhotoBatch({ maxImages, onUpload, onAllDone: (done) => onInsert(toMarkdownItems(done)) });
|
|
1767
|
+
const { items, isRunning } = batch;
|
|
1768
|
+
useEffect6(() => rootRef.current?.focus(), []);
|
|
1769
|
+
function receive(files) {
|
|
1770
|
+
const { images, rejected } = pickImages(files);
|
|
1771
|
+
const overflow = batch.addFiles(images);
|
|
1772
|
+
const lines = rejected.map((file) => interpolate(messages.photoNotImage, { name: file.name }));
|
|
1773
|
+
if (overflow > 0) lines.push(interpolate(messages.photoLimitReached, { max: maxImages, count: overflow }));
|
|
1774
|
+
setNotice(lines.join(" "));
|
|
1775
|
+
}
|
|
1776
|
+
function handleDrop(event) {
|
|
1777
|
+
event.preventDefault();
|
|
1778
|
+
setIsDragging(false);
|
|
1779
|
+
if (!isRunning) receive(Array.from(event.dataTransfer.files));
|
|
1780
|
+
}
|
|
1781
|
+
function handlePaste(event) {
|
|
1782
|
+
const files = Array.from(event.clipboardData.files).filter((file) => file.type.startsWith("image/"));
|
|
1783
|
+
if (files.length === 0 || isRunning) return;
|
|
1784
|
+
event.preventDefault();
|
|
1785
|
+
receive(files);
|
|
1786
|
+
}
|
|
1787
|
+
function handleKeyDown(event) {
|
|
1788
|
+
if (event.key === "Escape" && !isRunning) {
|
|
1789
|
+
event.stopPropagation();
|
|
1790
|
+
onClose();
|
|
1791
|
+
}
|
|
1792
|
+
if (event.key === "Enter" && event.target instanceof HTMLInputElement) event.preventDefault();
|
|
1793
|
+
}
|
|
1794
|
+
const actions = {
|
|
1795
|
+
onChange: batch.patch,
|
|
1796
|
+
onRemove: batch.remove,
|
|
1797
|
+
onMove: batch.move,
|
|
1798
|
+
onRetry: (id) => void batch.start([id])
|
|
1799
|
+
};
|
|
1800
|
+
return /* @__PURE__ */ jsxs8(
|
|
1801
|
+
"div",
|
|
1125
1802
|
{
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
onKeyDown:
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1803
|
+
ref: rootRef,
|
|
1804
|
+
tabIndex: -1,
|
|
1805
|
+
className: `adc-popover adc-photo-dialog${isDragging ? " adc-photo-dialog--dragging" : ""}`,
|
|
1806
|
+
role: "dialog",
|
|
1807
|
+
"aria-label": messages.photoDialogTitle,
|
|
1808
|
+
onKeyDown: handleKeyDown,
|
|
1809
|
+
onPaste: handlePaste,
|
|
1810
|
+
onDragOver: (event) => {
|
|
1811
|
+
event.preventDefault();
|
|
1812
|
+
setIsDragging(true);
|
|
1135
1813
|
},
|
|
1814
|
+
onDragLeave: () => setIsDragging(false),
|
|
1815
|
+
onDrop: handleDrop,
|
|
1136
1816
|
children: [
|
|
1137
|
-
/* @__PURE__ */
|
|
1138
|
-
|
|
1817
|
+
/* @__PURE__ */ jsx10(
|
|
1818
|
+
FilePicker,
|
|
1819
|
+
{
|
|
1820
|
+
labels: { button: messages.photoPickButton, empty: messages.photoDropHint },
|
|
1821
|
+
accept: "image/*",
|
|
1822
|
+
isBusy: isRunning,
|
|
1823
|
+
isMultiple: true,
|
|
1824
|
+
onPick: receive
|
|
1825
|
+
}
|
|
1826
|
+
),
|
|
1827
|
+
/* @__PURE__ */ jsx10("p", { className: "adc-hint", children: interpolate(messages.photoCount, { count: items.length, max: maxImages }) }),
|
|
1828
|
+
/* @__PURE__ */ jsx10("p", { className: "adc-error", role: "alert", hidden: !notice, children: notice }),
|
|
1829
|
+
/* @__PURE__ */ jsx10("ol", { className: "adc-photo-list", children: items.map((item, index) => /* @__PURE__ */ jsx10(
|
|
1830
|
+
PhotoRow,
|
|
1831
|
+
{
|
|
1832
|
+
item,
|
|
1833
|
+
placement: { position: index + 1, total: items.length },
|
|
1834
|
+
isLocked: isRunning,
|
|
1835
|
+
actions
|
|
1836
|
+
},
|
|
1837
|
+
item.id
|
|
1838
|
+
)) }),
|
|
1839
|
+
/* @__PURE__ */ jsxs8("div", { className: "adc-insert-actions", children: [
|
|
1840
|
+
/* @__PURE__ */ jsx10("button", { type: "button", className: "adc-button adc-button--ghost", disabled: isRunning, onClick: onClose, children: messages.dialogCancel }),
|
|
1841
|
+
/* @__PURE__ */ jsx10(
|
|
1842
|
+
"button",
|
|
1843
|
+
{
|
|
1844
|
+
type: "button",
|
|
1845
|
+
className: "adc-button adc-button--primary",
|
|
1846
|
+
disabled: isRunning || items.length === 0,
|
|
1847
|
+
onClick: () => void batch.start(),
|
|
1848
|
+
children: isRunning ? messages.photoSending : messages.dialogInsert
|
|
1849
|
+
}
|
|
1850
|
+
)
|
|
1851
|
+
] })
|
|
1139
1852
|
]
|
|
1140
1853
|
}
|
|
1141
1854
|
);
|
|
1142
1855
|
}
|
|
1143
1856
|
|
|
1144
1857
|
// src/components/MarkdownEditor.tsx
|
|
1145
|
-
import { jsx as
|
|
1858
|
+
import { jsx as jsx11, jsxs as jsxs9 } from "react/jsx-runtime";
|
|
1146
1859
|
var SIMPLE_ACTIONS = [
|
|
1147
1860
|
{ id: "bold", icon: Bold, label: "formatBold", shortcut: "B" },
|
|
1148
1861
|
{ id: "italic", icon: Italic, label: "formatItalic", shortcut: "I" },
|
|
@@ -1153,7 +1866,7 @@ var SIMPLE_ACTIONS = [
|
|
|
1153
1866
|
{ id: "quote", icon: Quote, label: "formatQuote" }
|
|
1154
1867
|
];
|
|
1155
1868
|
function ToolButton({ icon: Icon, text, isExpanded, onClick }) {
|
|
1156
|
-
return /* @__PURE__ */
|
|
1869
|
+
return /* @__PURE__ */ jsx11(Tooltip, { text, children: /* @__PURE__ */ jsx11(
|
|
1157
1870
|
"button",
|
|
1158
1871
|
{
|
|
1159
1872
|
type: "button",
|
|
@@ -1161,7 +1874,7 @@ function ToolButton({ icon: Icon, text, isExpanded, onClick }) {
|
|
|
1161
1874
|
"aria-label": text,
|
|
1162
1875
|
...isExpanded === void 0 ? {} : { "aria-expanded": isExpanded },
|
|
1163
1876
|
onClick,
|
|
1164
|
-
children: /* @__PURE__ */
|
|
1877
|
+
children: /* @__PURE__ */ jsx11(Icon, { "aria-hidden": "true", className: "adc-icon" })
|
|
1165
1878
|
}
|
|
1166
1879
|
) });
|
|
1167
1880
|
}
|
|
@@ -1175,10 +1888,10 @@ function MarkdownEditor({
|
|
|
1175
1888
|
isUploading = false
|
|
1176
1889
|
}) {
|
|
1177
1890
|
const { messages } = useContentText();
|
|
1178
|
-
const textareaRef =
|
|
1179
|
-
const pendingSelection =
|
|
1180
|
-
const savedSelection =
|
|
1181
|
-
const [panel, setPanel] =
|
|
1891
|
+
const textareaRef = useRef6(null);
|
|
1892
|
+
const pendingSelection = useRef6(void 0);
|
|
1893
|
+
const savedSelection = useRef6({ value, start: value.length, end: value.length });
|
|
1894
|
+
const [panel, setPanel] = useState11();
|
|
1182
1895
|
useLayoutEffect(() => {
|
|
1183
1896
|
const pending = pendingSelection.current;
|
|
1184
1897
|
const textarea = textareaRef.current;
|
|
@@ -1222,9 +1935,9 @@ function MarkdownEditor({
|
|
|
1222
1935
|
}
|
|
1223
1936
|
const saved = savedSelection.current;
|
|
1224
1937
|
const selectedText = saved.value.slice(saved.start, saved.end);
|
|
1225
|
-
return /* @__PURE__ */
|
|
1226
|
-
showToolbar && /* @__PURE__ */
|
|
1227
|
-
SIMPLE_ACTIONS.map(({ id, icon, label, shortcut }) => /* @__PURE__ */
|
|
1938
|
+
return /* @__PURE__ */ jsxs9("div", { className: "adc-md-editor", children: [
|
|
1939
|
+
showToolbar && /* @__PURE__ */ jsxs9("div", { className: "adc-md-toolbar", role: "toolbar", "aria-label": messages.toolbarLabel, children: [
|
|
1940
|
+
SIMPLE_ACTIONS.map(({ id, icon, label, shortcut }) => /* @__PURE__ */ jsx11(
|
|
1228
1941
|
ToolButton,
|
|
1229
1942
|
{
|
|
1230
1943
|
icon,
|
|
@@ -1233,7 +1946,7 @@ function MarkdownEditor({
|
|
|
1233
1946
|
},
|
|
1234
1947
|
id
|
|
1235
1948
|
)),
|
|
1236
|
-
/* @__PURE__ */
|
|
1949
|
+
/* @__PURE__ */ jsx11(
|
|
1237
1950
|
ToolButton,
|
|
1238
1951
|
{
|
|
1239
1952
|
icon: LinkIcon,
|
|
@@ -1242,7 +1955,7 @@ function MarkdownEditor({
|
|
|
1242
1955
|
onClick: () => openPanel("link")
|
|
1243
1956
|
}
|
|
1244
1957
|
),
|
|
1245
|
-
/* @__PURE__ */
|
|
1958
|
+
/* @__PURE__ */ jsx11(
|
|
1246
1959
|
ToolButton,
|
|
1247
1960
|
{
|
|
1248
1961
|
icon: ImageIcon,
|
|
@@ -1251,7 +1964,7 @@ function MarkdownEditor({
|
|
|
1251
1964
|
onClick: () => openPanel("image")
|
|
1252
1965
|
}
|
|
1253
1966
|
),
|
|
1254
|
-
/* @__PURE__ */
|
|
1967
|
+
/* @__PURE__ */ jsx11(
|
|
1255
1968
|
ToolButton,
|
|
1256
1969
|
{
|
|
1257
1970
|
icon: Smile,
|
|
@@ -1261,7 +1974,7 @@ function MarkdownEditor({
|
|
|
1261
1974
|
}
|
|
1262
1975
|
)
|
|
1263
1976
|
] }),
|
|
1264
|
-
panel === "link" && /* @__PURE__ */
|
|
1977
|
+
panel === "link" && /* @__PURE__ */ jsx11(
|
|
1265
1978
|
InsertDialog,
|
|
1266
1979
|
{
|
|
1267
1980
|
kind: "link",
|
|
@@ -1270,19 +1983,26 @@ function MarkdownEditor({
|
|
|
1270
1983
|
onSubmit: (values) => apply(insertLink(saved, values))
|
|
1271
1984
|
}
|
|
1272
1985
|
),
|
|
1273
|
-
panel === "image" && /* @__PURE__ */
|
|
1986
|
+
panel === "image" && onUploadImage && /* @__PURE__ */ jsx11(
|
|
1987
|
+
PhotoInsertDialog,
|
|
1988
|
+
{
|
|
1989
|
+
onUpload: onUploadImage,
|
|
1990
|
+
onClose: closePanel,
|
|
1991
|
+
onInsert: (photos) => apply(insertPhotosBlock(saved, photos))
|
|
1992
|
+
}
|
|
1993
|
+
),
|
|
1994
|
+
panel === "image" && !onUploadImage && /* @__PURE__ */ jsx11(
|
|
1274
1995
|
InsertDialog,
|
|
1275
1996
|
{
|
|
1276
1997
|
kind: "image",
|
|
1277
1998
|
initialText: "",
|
|
1278
1999
|
isUploading,
|
|
1279
|
-
...onUploadImage ? { onUpload: onUploadImage } : {},
|
|
1280
2000
|
onClose: closePanel,
|
|
1281
2001
|
onSubmit: (values) => apply(insertImage(saved, values))
|
|
1282
2002
|
}
|
|
1283
2003
|
),
|
|
1284
|
-
panel === "emoji" && /* @__PURE__ */
|
|
1285
|
-
/* @__PURE__ */
|
|
2004
|
+
panel === "emoji" && /* @__PURE__ */ jsx11(EmojiPicker, { onClose: closePanel, onPick: (emoji) => apply(insertText(saved, emoji)) }),
|
|
2005
|
+
/* @__PURE__ */ jsx11(
|
|
1286
2006
|
"textarea",
|
|
1287
2007
|
{
|
|
1288
2008
|
ref: textareaRef,
|
|
@@ -1300,7 +2020,7 @@ function MarkdownEditor({
|
|
|
1300
2020
|
// src/components/StatusChip.tsx
|
|
1301
2021
|
import { POST_STATUS } from "@adatechnology/content-contracts";
|
|
1302
2022
|
import { Archive, CalendarClock, CircleCheck, Copy, PencilLine } from "lucide-react";
|
|
1303
|
-
import { jsx as
|
|
2023
|
+
import { jsx as jsx12, jsxs as jsxs10 } from "react/jsx-runtime";
|
|
1304
2024
|
var STATUS_VIEW = {
|
|
1305
2025
|
[POST_STATUS.DRAFT]: { icon: PencilLine, label: "statusDraft" },
|
|
1306
2026
|
[POST_STATUS.SCHEDULED]: { icon: CalendarClock, label: "statusScheduled" },
|
|
@@ -1310,22 +2030,22 @@ var STATUS_VIEW = {
|
|
|
1310
2030
|
function StatusChip({ status, isTemplate = false }) {
|
|
1311
2031
|
const { messages } = useContentText();
|
|
1312
2032
|
const { icon: Icon, label } = isTemplate ? { icon: Copy, label: "statusTemplate" } : STATUS_VIEW[status];
|
|
1313
|
-
return /* @__PURE__ */
|
|
1314
|
-
/* @__PURE__ */
|
|
2033
|
+
return /* @__PURE__ */ jsxs10("span", { className: `adc-badge adc-chip--${isTemplate ? "template" : status}`, children: [
|
|
2034
|
+
/* @__PURE__ */ jsx12(Icon, { "aria-hidden": "true", className: "adc-icon" }),
|
|
1315
2035
|
messages[label]
|
|
1316
2036
|
] });
|
|
1317
2037
|
}
|
|
1318
2038
|
|
|
1319
2039
|
// src/components/TagsInput.tsx
|
|
1320
2040
|
import { normalizeTags, TAGS_MAX_COUNT } from "@adatechnology/content-contracts";
|
|
1321
|
-
import { X } from "lucide-react";
|
|
1322
|
-
import { useId as
|
|
1323
|
-
import { jsx as
|
|
2041
|
+
import { X as X3 } from "lucide-react";
|
|
2042
|
+
import { useId as useId5, useState as useState12 } from "react";
|
|
2043
|
+
import { jsx as jsx13, jsxs as jsxs11 } from "react/jsx-runtime";
|
|
1324
2044
|
function TagsInput({ value, onChange, suggestions = [], label }) {
|
|
1325
2045
|
const { messages, format } = useContentText();
|
|
1326
|
-
const [text, setText] =
|
|
1327
|
-
const inputId =
|
|
1328
|
-
const listId =
|
|
2046
|
+
const [text, setText] = useState12("");
|
|
2047
|
+
const inputId = useId5();
|
|
2048
|
+
const listId = useId5();
|
|
1329
2049
|
function commit(raw) {
|
|
1330
2050
|
const added = splitTagInput(raw);
|
|
1331
2051
|
if (added.length > 0) onChange(normalizeTags([...value, ...added]));
|
|
@@ -1339,23 +2059,23 @@ function TagsInput({ value, onChange, suggestions = [], label }) {
|
|
|
1339
2059
|
onChange(value.slice(0, -1));
|
|
1340
2060
|
}
|
|
1341
2061
|
}
|
|
1342
|
-
return /* @__PURE__ */
|
|
1343
|
-
/* @__PURE__ */
|
|
1344
|
-
/* @__PURE__ */
|
|
1345
|
-
value.map((tag) => /* @__PURE__ */
|
|
2062
|
+
return /* @__PURE__ */ jsxs11("div", { className: "adc-field", children: [
|
|
2063
|
+
/* @__PURE__ */ jsx13("label", { htmlFor: inputId, children: label }),
|
|
2064
|
+
/* @__PURE__ */ jsxs11("div", { className: "adc-tags-input", children: [
|
|
2065
|
+
value.map((tag) => /* @__PURE__ */ jsxs11("span", { className: "adc-tag", children: [
|
|
1346
2066
|
tag,
|
|
1347
|
-
/* @__PURE__ */
|
|
2067
|
+
/* @__PURE__ */ jsx13(
|
|
1348
2068
|
"button",
|
|
1349
2069
|
{
|
|
1350
2070
|
type: "button",
|
|
1351
2071
|
className: "adc-tag-remove",
|
|
1352
2072
|
"aria-label": format("tagRemove", { tag }),
|
|
1353
2073
|
onClick: () => onChange(value.filter((current) => current !== tag)),
|
|
1354
|
-
children: /* @__PURE__ */
|
|
2074
|
+
children: /* @__PURE__ */ jsx13(X3, { "aria-hidden": "true", className: "adc-icon" })
|
|
1355
2075
|
}
|
|
1356
2076
|
)
|
|
1357
2077
|
] }, tag)),
|
|
1358
|
-
/* @__PURE__ */
|
|
2078
|
+
/* @__PURE__ */ jsx13(
|
|
1359
2079
|
"input",
|
|
1360
2080
|
{
|
|
1361
2081
|
id: inputId,
|
|
@@ -1369,15 +2089,15 @@ function TagsInput({ value, onChange, suggestions = [], label }) {
|
|
|
1369
2089
|
}
|
|
1370
2090
|
)
|
|
1371
2091
|
] }),
|
|
1372
|
-
/* @__PURE__ */
|
|
1373
|
-
suggestions.length > 0 && /* @__PURE__ */
|
|
2092
|
+
/* @__PURE__ */ jsx13("small", { id: `${inputId}-hint`, className: "adc-hint", children: messages.tagsHint }),
|
|
2093
|
+
suggestions.length > 0 && /* @__PURE__ */ jsx13("datalist", { id: listId, children: suggestions.filter((tag) => !value.includes(tag)).map((tag) => /* @__PURE__ */ jsx13("option", { value: tag }, tag)) })
|
|
1374
2094
|
] });
|
|
1375
2095
|
}
|
|
1376
2096
|
|
|
1377
2097
|
// src/components/PostEditor.tsx
|
|
1378
|
-
import { jsx as
|
|
2098
|
+
import { jsx as jsx14, jsxs as jsxs12 } from "react/jsx-runtime";
|
|
1379
2099
|
function TextField({ label, value, onChange, error, hint, type = "text", multiline, maxLength }) {
|
|
1380
|
-
const id =
|
|
2100
|
+
const id = useId6();
|
|
1381
2101
|
const describedBy = [hint ? `${id}-hint` : "", error ? `${id}-error` : ""].filter(Boolean).join(" ") || void 0;
|
|
1382
2102
|
const common = {
|
|
1383
2103
|
id,
|
|
@@ -1386,16 +2106,16 @@ function TextField({ label, value, onChange, error, hint, type = "text", multili
|
|
|
1386
2106
|
"aria-invalid": error ? true : void 0,
|
|
1387
2107
|
"aria-describedby": describedBy
|
|
1388
2108
|
};
|
|
1389
|
-
return /* @__PURE__ */
|
|
1390
|
-
/* @__PURE__ */
|
|
1391
|
-
multiline ? /* @__PURE__ */
|
|
1392
|
-
hint && /* @__PURE__ */
|
|
1393
|
-
error && /* @__PURE__ */
|
|
2109
|
+
return /* @__PURE__ */ jsxs12("div", { className: "adc-field", children: [
|
|
2110
|
+
/* @__PURE__ */ jsx14("label", { htmlFor: id, children: label }),
|
|
2111
|
+
multiline ? /* @__PURE__ */ jsx14("textarea", { ...common, rows: 3, onChange: (event) => onChange(event.target.value) }) : /* @__PURE__ */ jsx14("input", { ...common, type, onChange: (event) => onChange(event.target.value) }),
|
|
2112
|
+
hint && /* @__PURE__ */ jsx14("small", { id: `${id}-hint`, className: "adc-hint", children: hint }),
|
|
2113
|
+
error && /* @__PURE__ */ jsx14("small", { id: `${id}-error`, className: "adc-error", children: error })
|
|
1394
2114
|
] });
|
|
1395
2115
|
}
|
|
1396
2116
|
function Section({ title, children }) {
|
|
1397
|
-
return /* @__PURE__ */
|
|
1398
|
-
/* @__PURE__ */
|
|
2117
|
+
return /* @__PURE__ */ jsxs12("fieldset", { className: "adc-section", children: [
|
|
2118
|
+
/* @__PURE__ */ jsx14("legend", { children: title }),
|
|
1399
2119
|
children
|
|
1400
2120
|
] });
|
|
1401
2121
|
}
|
|
@@ -1416,16 +2136,16 @@ function PostEditor({
|
|
|
1416
2136
|
...onArchived ? { onArchived } : {}
|
|
1417
2137
|
});
|
|
1418
2138
|
const { confirmLeave } = useUnsavedChangesGuard(editor.isDirty, messages.unsavedConfirm);
|
|
1419
|
-
const [tab, setTab] =
|
|
1420
|
-
const bodyId =
|
|
1421
|
-
const scheduleId =
|
|
2139
|
+
const [tab, setTab] = useState13("write");
|
|
2140
|
+
const bodyId = useId6();
|
|
2141
|
+
const scheduleId = useId6();
|
|
1422
2142
|
const { draft, update, errors, post } = editor;
|
|
1423
2143
|
if (editor.isLoading) {
|
|
1424
|
-
return /* @__PURE__ */
|
|
2144
|
+
return /* @__PURE__ */ jsx14("p", { className: "adc-root adc-state", role: "status", children: messages.loading });
|
|
1425
2145
|
}
|
|
1426
2146
|
const status = post?.status;
|
|
1427
2147
|
const isLive = status === "published" || status === "scheduled";
|
|
1428
|
-
return /* @__PURE__ */
|
|
2148
|
+
return /* @__PURE__ */ jsxs12(
|
|
1429
2149
|
"form",
|
|
1430
2150
|
{
|
|
1431
2151
|
className: "adc-root adc-editor",
|
|
@@ -1434,18 +2154,18 @@ function PostEditor({
|
|
|
1434
2154
|
void editor.save();
|
|
1435
2155
|
},
|
|
1436
2156
|
children: [
|
|
1437
|
-
/* @__PURE__ */
|
|
1438
|
-
onClose && /* @__PURE__ */
|
|
1439
|
-
/* @__PURE__ */
|
|
2157
|
+
/* @__PURE__ */ jsxs12("header", { className: "adc-toolbar", children: [
|
|
2158
|
+
onClose && /* @__PURE__ */ jsxs12("button", { type: "button", className: "adc-button adc-button--ghost", onClick: () => confirmLeave() && onClose(), children: [
|
|
2159
|
+
/* @__PURE__ */ jsx14(ArrowLeft, { "aria-hidden": "true", className: "adc-icon" }),
|
|
1440
2160
|
messages.close
|
|
1441
2161
|
] }),
|
|
1442
|
-
/* @__PURE__ */
|
|
1443
|
-
status && /* @__PURE__ */
|
|
1444
|
-
editor.isDirty && /* @__PURE__ */
|
|
2162
|
+
/* @__PURE__ */ jsx14("h2", { className: "adc-title", children: post ? messages.editorEditTitle : messages.editorNewTitle }),
|
|
2163
|
+
status && /* @__PURE__ */ jsx14(StatusChip, { status }),
|
|
2164
|
+
editor.isDirty && /* @__PURE__ */ jsx14("span", { className: "adc-badge", children: messages.unsavedBadge })
|
|
1445
2165
|
] }),
|
|
1446
|
-
/* @__PURE__ */
|
|
1447
|
-
/* @__PURE__ */
|
|
1448
|
-
/* @__PURE__ */
|
|
2166
|
+
/* @__PURE__ */ jsxs12("div", { className: "adc-editor-grid", children: [
|
|
2167
|
+
/* @__PURE__ */ jsxs12("div", { className: "adc-editor-main", children: [
|
|
2168
|
+
/* @__PURE__ */ jsx14(
|
|
1449
2169
|
TextField,
|
|
1450
2170
|
{
|
|
1451
2171
|
label: messages.fieldTitle,
|
|
@@ -1455,7 +2175,7 @@ function PostEditor({
|
|
|
1455
2175
|
error: errors.title ? messages.errorTitle : void 0
|
|
1456
2176
|
}
|
|
1457
2177
|
),
|
|
1458
|
-
/* @__PURE__ */
|
|
2178
|
+
/* @__PURE__ */ jsx14(
|
|
1459
2179
|
TextField,
|
|
1460
2180
|
{
|
|
1461
2181
|
label: messages.fieldSlug,
|
|
@@ -1466,7 +2186,7 @@ function PostEditor({
|
|
|
1466
2186
|
error: errors.slug ? messages.errorSlug : void 0
|
|
1467
2187
|
}
|
|
1468
2188
|
),
|
|
1469
|
-
/* @__PURE__ */
|
|
2189
|
+
/* @__PURE__ */ jsx14(
|
|
1470
2190
|
TextField,
|
|
1471
2191
|
{
|
|
1472
2192
|
label: messages.fieldExcerpt,
|
|
@@ -1476,10 +2196,10 @@ function PostEditor({
|
|
|
1476
2196
|
onChange: (value) => update("excerpt", value)
|
|
1477
2197
|
}
|
|
1478
2198
|
),
|
|
1479
|
-
/* @__PURE__ */
|
|
1480
|
-
/* @__PURE__ */
|
|
1481
|
-
/* @__PURE__ */
|
|
1482
|
-
["write", "preview"].map((value) => /* @__PURE__ */
|
|
2199
|
+
/* @__PURE__ */ jsxs12("div", { className: "adc-field", children: [
|
|
2200
|
+
/* @__PURE__ */ jsxs12("div", { className: "adc-tabs", role: "tablist", "aria-label": messages.fieldBody, children: [
|
|
2201
|
+
/* @__PURE__ */ jsx14("span", { className: "adc-label", id: `${bodyId}-label`, children: messages.fieldBody }),
|
|
2202
|
+
["write", "preview"].map((value) => /* @__PURE__ */ jsx14(
|
|
1483
2203
|
"button",
|
|
1484
2204
|
{
|
|
1485
2205
|
type: "button",
|
|
@@ -1493,9 +2213,9 @@ function PostEditor({
|
|
|
1493
2213
|
value
|
|
1494
2214
|
))
|
|
1495
2215
|
] }),
|
|
1496
|
-
/* @__PURE__ */
|
|
1497
|
-
/* @__PURE__ */
|
|
1498
|
-
/* @__PURE__ */
|
|
2216
|
+
/* @__PURE__ */ jsxs12("div", { className: `adc-body-panes adc-body-panes--${tab}`, children: [
|
|
2217
|
+
/* @__PURE__ */ jsxs12("div", { id: `${bodyId}-write`, role: "tabpanel", className: "adc-pane adc-pane--write", children: [
|
|
2218
|
+
/* @__PURE__ */ jsx14(
|
|
1499
2219
|
MarkdownEditor,
|
|
1500
2220
|
{
|
|
1501
2221
|
value: draft.body,
|
|
@@ -1507,22 +2227,22 @@ function PostEditor({
|
|
|
1507
2227
|
...editor.canUploadCover ? { onUploadImage: editor.uploadImage } : {}
|
|
1508
2228
|
}
|
|
1509
2229
|
),
|
|
1510
|
-
/* @__PURE__ */
|
|
2230
|
+
/* @__PURE__ */ jsx14("small", { id: `${bodyId}-hint`, className: "adc-hint", children: showFormattingToolbar ? messages.bodyHintToolbar : messages.bodyHint })
|
|
1511
2231
|
] }),
|
|
1512
|
-
/* @__PURE__ */
|
|
2232
|
+
/* @__PURE__ */ jsx14("div", { id: `${bodyId}-preview`, role: "tabpanel", className: "adc-pane adc-pane--preview", "aria-live": "polite", children: draft.body.trim() ? /* @__PURE__ */ jsx14(MarkdownContent, { markdown: draft.body, headingLevelOffset: 1 }) : /* @__PURE__ */ jsx14("p", { className: "adc-muted", children: messages.previewEmpty }) })
|
|
1513
2233
|
] })
|
|
1514
2234
|
] })
|
|
1515
2235
|
] }),
|
|
1516
|
-
/* @__PURE__ */
|
|
1517
|
-
/* @__PURE__ */
|
|
1518
|
-
post?.publishedAt && /* @__PURE__ */
|
|
2236
|
+
/* @__PURE__ */ jsxs12("aside", { className: "adc-editor-side", children: [
|
|
2237
|
+
/* @__PURE__ */ jsxs12(Section, { title: messages.publishSection, children: [
|
|
2238
|
+
post?.publishedAt && /* @__PURE__ */ jsx14("p", { className: "adc-muted", children: format(status === "scheduled" ? "scheduledFor" : "publishedOn", {
|
|
1519
2239
|
date: formatPostDate(post.publishedAt, locale, true)
|
|
1520
2240
|
}) }),
|
|
1521
|
-
/* @__PURE__ */
|
|
1522
|
-
/* @__PURE__ */
|
|
2241
|
+
/* @__PURE__ */ jsxs12("button", { type: "submit", className: "adc-button", disabled: editor.isBusy, children: [
|
|
2242
|
+
/* @__PURE__ */ jsx14(Save, { "aria-hidden": "true", className: "adc-icon" }),
|
|
1523
2243
|
editor.isBusy ? messages.saving : isLive ? messages.saveChanges : messages.save
|
|
1524
2244
|
] }),
|
|
1525
|
-
status !== "published" && /* @__PURE__ */
|
|
2245
|
+
status !== "published" && /* @__PURE__ */ jsxs12(
|
|
1526
2246
|
"button",
|
|
1527
2247
|
{
|
|
1528
2248
|
type: "button",
|
|
@@ -1530,7 +2250,7 @@ function PostEditor({
|
|
|
1530
2250
|
disabled: editor.isBusy,
|
|
1531
2251
|
onClick: () => void editor.publishNow(),
|
|
1532
2252
|
children: [
|
|
1533
|
-
/* @__PURE__ */
|
|
2253
|
+
/* @__PURE__ */ jsx14(Send, { "aria-hidden": "true", className: "adc-icon" }),
|
|
1534
2254
|
messages.publishNow
|
|
1535
2255
|
]
|
|
1536
2256
|
}
|
|
@@ -1540,9 +2260,9 @@ function PostEditor({
|
|
|
1540
2260
|
label: messages.scheduleAt,
|
|
1541
2261
|
value: editor.scheduleAt,
|
|
1542
2262
|
onChange: editor.setScheduleAt
|
|
1543
|
-
}) : /* @__PURE__ */
|
|
1544
|
-
/* @__PURE__ */
|
|
1545
|
-
/* @__PURE__ */
|
|
2263
|
+
}) : /* @__PURE__ */ jsxs12("div", { className: "adc-field", children: [
|
|
2264
|
+
/* @__PURE__ */ jsx14("label", { htmlFor: scheduleId, children: messages.scheduleAt }),
|
|
2265
|
+
/* @__PURE__ */ jsx14(
|
|
1546
2266
|
"input",
|
|
1547
2267
|
{
|
|
1548
2268
|
id: scheduleId,
|
|
@@ -1552,7 +2272,7 @@ function PostEditor({
|
|
|
1552
2272
|
}
|
|
1553
2273
|
)
|
|
1554
2274
|
] }),
|
|
1555
|
-
/* @__PURE__ */
|
|
2275
|
+
/* @__PURE__ */ jsxs12(
|
|
1556
2276
|
"button",
|
|
1557
2277
|
{
|
|
1558
2278
|
type: "button",
|
|
@@ -1560,12 +2280,12 @@ function PostEditor({
|
|
|
1560
2280
|
disabled: editor.isBusy || !editor.scheduleAt,
|
|
1561
2281
|
onClick: () => void editor.schedule(),
|
|
1562
2282
|
children: [
|
|
1563
|
-
/* @__PURE__ */
|
|
2283
|
+
/* @__PURE__ */ jsx14(CalendarClock2, { "aria-hidden": "true", className: "adc-icon" }),
|
|
1564
2284
|
messages.schedule
|
|
1565
2285
|
]
|
|
1566
2286
|
}
|
|
1567
2287
|
),
|
|
1568
|
-
isLive && /* @__PURE__ */
|
|
2288
|
+
isLive && /* @__PURE__ */ jsxs12(
|
|
1569
2289
|
"button",
|
|
1570
2290
|
{
|
|
1571
2291
|
type: "button",
|
|
@@ -1573,12 +2293,12 @@ function PostEditor({
|
|
|
1573
2293
|
disabled: editor.isBusy,
|
|
1574
2294
|
onClick: () => void editor.unpublish(),
|
|
1575
2295
|
children: [
|
|
1576
|
-
/* @__PURE__ */
|
|
2296
|
+
/* @__PURE__ */ jsx14(EyeOff, { "aria-hidden": "true", className: "adc-icon" }),
|
|
1577
2297
|
messages.unpublish
|
|
1578
2298
|
]
|
|
1579
2299
|
}
|
|
1580
2300
|
),
|
|
1581
|
-
post && status !== "archived" && /* @__PURE__ */
|
|
2301
|
+
post && status !== "archived" && /* @__PURE__ */ jsxs12(
|
|
1582
2302
|
"button",
|
|
1583
2303
|
{
|
|
1584
2304
|
type: "button",
|
|
@@ -1586,12 +2306,12 @@ function PostEditor({
|
|
|
1586
2306
|
disabled: editor.isBusy,
|
|
1587
2307
|
onClick: () => window.confirm(messages.archiveConfirm) && void editor.archive(),
|
|
1588
2308
|
children: [
|
|
1589
|
-
/* @__PURE__ */
|
|
2309
|
+
/* @__PURE__ */ jsx14(Archive2, { "aria-hidden": "true", className: "adc-icon" }),
|
|
1590
2310
|
messages.archive
|
|
1591
2311
|
]
|
|
1592
2312
|
}
|
|
1593
2313
|
),
|
|
1594
|
-
editor.feedback && /* @__PURE__ */
|
|
2314
|
+
editor.feedback && /* @__PURE__ */ jsx14(
|
|
1595
2315
|
"p",
|
|
1596
2316
|
{
|
|
1597
2317
|
className: editor.feedback === "saved" ? "adc-success" : "adc-error",
|
|
@@ -1600,19 +2320,24 @@ function PostEditor({
|
|
|
1600
2320
|
}
|
|
1601
2321
|
)
|
|
1602
2322
|
] }),
|
|
1603
|
-
/* @__PURE__ */
|
|
1604
|
-
draft.coverImageUrl && /* @__PURE__ */
|
|
1605
|
-
editor.canUploadCover && /* @__PURE__ */
|
|
2323
|
+
/* @__PURE__ */ jsxs12(Section, { title: messages.fieldCover, children: [
|
|
2324
|
+
draft.coverImageUrl && /* @__PURE__ */ jsx14("img", { className: "adc-cover-preview", src: draft.coverImageUrl, alt: draft.coverImageAlt }),
|
|
2325
|
+
editor.canUploadCover && /* @__PURE__ */ jsx14(
|
|
1606
2326
|
FilePicker,
|
|
1607
2327
|
{
|
|
1608
|
-
|
|
1609
|
-
|
|
2328
|
+
labels: {
|
|
2329
|
+
button: editor.isUploading ? messages.coverUploading : messages.coverUpload,
|
|
2330
|
+
empty: messages.fileNoneChosen
|
|
2331
|
+
},
|
|
1610
2332
|
accept: "image/jpeg,image/png,image/webp",
|
|
1611
2333
|
isBusy: editor.isUploading,
|
|
1612
|
-
onPick: (
|
|
2334
|
+
onPick: (files) => {
|
|
2335
|
+
const [file] = files;
|
|
2336
|
+
if (file) void editor.uploadCover(file);
|
|
2337
|
+
}
|
|
1613
2338
|
}
|
|
1614
2339
|
),
|
|
1615
|
-
/* @__PURE__ */
|
|
2340
|
+
/* @__PURE__ */ jsx14(
|
|
1616
2341
|
TextField,
|
|
1617
2342
|
{
|
|
1618
2343
|
label: messages.fieldCoverUrl,
|
|
@@ -1622,7 +2347,7 @@ function PostEditor({
|
|
|
1622
2347
|
error: errors.coverImageUrl ? messages.errorUrl : void 0
|
|
1623
2348
|
}
|
|
1624
2349
|
),
|
|
1625
|
-
/* @__PURE__ */
|
|
2350
|
+
/* @__PURE__ */ jsx14(
|
|
1626
2351
|
TextField,
|
|
1627
2352
|
{
|
|
1628
2353
|
label: messages.fieldCoverAlt,
|
|
@@ -1631,21 +2356,21 @@ function PostEditor({
|
|
|
1631
2356
|
onChange: (value) => update("coverImageAlt", value)
|
|
1632
2357
|
}
|
|
1633
2358
|
),
|
|
1634
|
-
draft.coverImageUrl && /* @__PURE__ */
|
|
2359
|
+
draft.coverImageUrl && /* @__PURE__ */ jsxs12(
|
|
1635
2360
|
"button",
|
|
1636
2361
|
{
|
|
1637
2362
|
type: "button",
|
|
1638
2363
|
className: "adc-button adc-button--ghost",
|
|
1639
2364
|
onClick: () => update("coverImageUrl", ""),
|
|
1640
2365
|
children: [
|
|
1641
|
-
/* @__PURE__ */
|
|
2366
|
+
/* @__PURE__ */ jsx14(Trash2, { "aria-hidden": "true", className: "adc-icon" }),
|
|
1642
2367
|
messages.coverRemove
|
|
1643
2368
|
]
|
|
1644
2369
|
}
|
|
1645
2370
|
)
|
|
1646
2371
|
] }),
|
|
1647
|
-
/* @__PURE__ */
|
|
1648
|
-
/* @__PURE__ */
|
|
2372
|
+
/* @__PURE__ */ jsxs12(Section, { title: messages.fieldTags, children: [
|
|
2373
|
+
/* @__PURE__ */ jsx14(
|
|
1649
2374
|
TagsInput,
|
|
1650
2375
|
{
|
|
1651
2376
|
label: messages.fieldTags,
|
|
@@ -1654,7 +2379,7 @@ function PostEditor({
|
|
|
1654
2379
|
onChange: (tags) => update("tags", tags)
|
|
1655
2380
|
}
|
|
1656
2381
|
),
|
|
1657
|
-
/* @__PURE__ */
|
|
2382
|
+
/* @__PURE__ */ jsx14(
|
|
1658
2383
|
TextField,
|
|
1659
2384
|
{
|
|
1660
2385
|
label: messages.fieldAuthor,
|
|
@@ -1664,8 +2389,8 @@ function PostEditor({
|
|
|
1664
2389
|
}
|
|
1665
2390
|
)
|
|
1666
2391
|
] }),
|
|
1667
|
-
/* @__PURE__ */
|
|
1668
|
-
/* @__PURE__ */
|
|
2392
|
+
/* @__PURE__ */ jsxs12(Section, { title: messages.seoSection, children: [
|
|
2393
|
+
/* @__PURE__ */ jsx14(
|
|
1669
2394
|
TextField,
|
|
1670
2395
|
{
|
|
1671
2396
|
label: messages.fieldSeoTitle,
|
|
@@ -1674,7 +2399,7 @@ function PostEditor({
|
|
|
1674
2399
|
onChange: (value) => update("seoTitle", value)
|
|
1675
2400
|
}
|
|
1676
2401
|
),
|
|
1677
|
-
/* @__PURE__ */
|
|
2402
|
+
/* @__PURE__ */ jsx14(
|
|
1678
2403
|
TextField,
|
|
1679
2404
|
{
|
|
1680
2405
|
label: messages.fieldSeoDescription,
|
|
@@ -1684,7 +2409,7 @@ function PostEditor({
|
|
|
1684
2409
|
onChange: (value) => update("seoDescription", value)
|
|
1685
2410
|
}
|
|
1686
2411
|
),
|
|
1687
|
-
/* @__PURE__ */
|
|
2412
|
+
/* @__PURE__ */ jsx14(
|
|
1688
2413
|
TextField,
|
|
1689
2414
|
{
|
|
1690
2415
|
label: messages.fieldCanonical,
|
|
@@ -1704,10 +2429,10 @@ function PostEditor({
|
|
|
1704
2429
|
|
|
1705
2430
|
// src/components/PostList.tsx
|
|
1706
2431
|
import { CopyPlus as CopyPlus2, FilePlus2 as FilePlus22, RefreshCw as RefreshCw2 } from "lucide-react";
|
|
1707
|
-
import { useState as
|
|
2432
|
+
import { useState as useState18 } from "react";
|
|
1708
2433
|
|
|
1709
2434
|
// src/hooks/usePostList.ts
|
|
1710
|
-
import { useEffect as
|
|
2435
|
+
import { useEffect as useEffect7, useState as useState14 } from "react";
|
|
1711
2436
|
|
|
1712
2437
|
// src/lib/listUrlState.ts
|
|
1713
2438
|
import { POST_SORT_FIELDS } from "@adatechnology/content-contracts";
|
|
@@ -1767,13 +2492,13 @@ function usePostList(params) {
|
|
|
1767
2492
|
const api = useContentAdminApi();
|
|
1768
2493
|
const syncUrl = params.syncUrl ?? false;
|
|
1769
2494
|
const hasTabs = Boolean(api.countPosts);
|
|
1770
|
-
const [state, setState] =
|
|
1771
|
-
const [localReload, setLocalReload] =
|
|
1772
|
-
const [selectedIds, setSelectedIds] =
|
|
2495
|
+
const [state, setState] = useState14(() => initialState(syncUrl));
|
|
2496
|
+
const [localReload, setLocalReload] = useState14(0);
|
|
2497
|
+
const [selectedIds, setSelectedIds] = useState14(/* @__PURE__ */ new Set());
|
|
1773
2498
|
const reload = (params.reloadKey ?? 0) + localReload;
|
|
1774
2499
|
const tab = hasTabs ? state.tab ?? POST_LIST_TAB.PUBLISHED : void 0;
|
|
1775
2500
|
const pageSize = state.pageSize ?? params.pageSize;
|
|
1776
|
-
|
|
2501
|
+
useEffect7(() => {
|
|
1777
2502
|
if (!syncUrl || typeof window === "undefined") return;
|
|
1778
2503
|
const query = serializeListUrlState({ ...state, ...tab ? { tab } : {} });
|
|
1779
2504
|
const url = `${window.location.pathname}${query ? `?${query}` : ""}${window.location.hash}`;
|
|
@@ -1801,7 +2526,7 @@ function usePostList(params) {
|
|
|
1801
2526
|
() => api.listTags ? api.listTags() : Promise.resolve([]),
|
|
1802
2527
|
`tags-${reload}`
|
|
1803
2528
|
);
|
|
1804
|
-
|
|
2529
|
+
useEffect7(() => setSelectedIds(/* @__PURE__ */ new Set()), [key]);
|
|
1805
2530
|
const change = (patch) => setState((current) => ({ ...current, page: 1, ...patch }));
|
|
1806
2531
|
function toggleSort(field) {
|
|
1807
2532
|
change({ sort: field, order: state.sort === field && state.order === "asc" ? "desc" : "asc" });
|
|
@@ -1839,13 +2564,13 @@ function usePostList(params) {
|
|
|
1839
2564
|
}
|
|
1840
2565
|
|
|
1841
2566
|
// src/components/BatchBar.tsx
|
|
1842
|
-
import { Archive as Archive3, CircleCheck as CircleCheck2, EyeOff as EyeOff2, X as
|
|
1843
|
-
import { useState as
|
|
2567
|
+
import { Archive as Archive3, CircleCheck as CircleCheck2, EyeOff as EyeOff2, X as X5 } from "lucide-react";
|
|
2568
|
+
import { useState as useState15 } from "react";
|
|
1844
2569
|
|
|
1845
2570
|
// src/components/ActionDialog.tsx
|
|
1846
|
-
import { X as
|
|
1847
|
-
import { useEffect as
|
|
1848
|
-
import { jsx as
|
|
2571
|
+
import { X as X4 } from "lucide-react";
|
|
2572
|
+
import { useEffect as useEffect8, useId as useId7, useRef as useRef7 } from "react";
|
|
2573
|
+
import { jsx as jsx15, jsxs as jsxs13 } from "react/jsx-runtime";
|
|
1849
2574
|
function ActionDialog({
|
|
1850
2575
|
title,
|
|
1851
2576
|
confirmLabel,
|
|
@@ -1857,9 +2582,9 @@ function ActionDialog({
|
|
|
1857
2582
|
children
|
|
1858
2583
|
}) {
|
|
1859
2584
|
const { messages } = useContentText();
|
|
1860
|
-
const titleId =
|
|
1861
|
-
const formRef =
|
|
1862
|
-
|
|
2585
|
+
const titleId = useId7();
|
|
2586
|
+
const formRef = useRef7(null);
|
|
2587
|
+
useEffect8(() => {
|
|
1863
2588
|
formRef.current?.querySelector("input, button[aria-haspopup], select, textarea")?.focus();
|
|
1864
2589
|
const handleKeyDown = (event) => {
|
|
1865
2590
|
if (event.key === "Escape") onClose();
|
|
@@ -1871,7 +2596,7 @@ function ActionDialog({
|
|
|
1871
2596
|
event.preventDefault();
|
|
1872
2597
|
if (!isBusy) onConfirm();
|
|
1873
2598
|
}
|
|
1874
|
-
return /* @__PURE__ */
|
|
2599
|
+
return /* @__PURE__ */ jsx15("div", { className: "adc-root adc-dialog-backdrop", children: /* @__PURE__ */ jsxs13(
|
|
1875
2600
|
"form",
|
|
1876
2601
|
{
|
|
1877
2602
|
ref: formRef,
|
|
@@ -1881,24 +2606,24 @@ function ActionDialog({
|
|
|
1881
2606
|
"aria-labelledby": titleId,
|
|
1882
2607
|
onSubmit: handleSubmit,
|
|
1883
2608
|
children: [
|
|
1884
|
-
/* @__PURE__ */
|
|
1885
|
-
/* @__PURE__ */
|
|
1886
|
-
/* @__PURE__ */
|
|
2609
|
+
/* @__PURE__ */ jsxs13("header", { className: "adc-dialog__header", children: [
|
|
2610
|
+
/* @__PURE__ */ jsx15("h3", { id: titleId, className: "adc-dialog__title", children: title }),
|
|
2611
|
+
/* @__PURE__ */ jsx15(
|
|
1887
2612
|
"button",
|
|
1888
2613
|
{
|
|
1889
2614
|
type: "button",
|
|
1890
2615
|
className: "adc-button adc-button--ghost adc-button--icon",
|
|
1891
2616
|
"aria-label": messages.close,
|
|
1892
2617
|
onClick: onClose,
|
|
1893
|
-
children: /* @__PURE__ */
|
|
2618
|
+
children: /* @__PURE__ */ jsx15(X4, { "aria-hidden": "true", className: "adc-icon" })
|
|
1894
2619
|
}
|
|
1895
2620
|
)
|
|
1896
2621
|
] }),
|
|
1897
|
-
/* @__PURE__ */
|
|
1898
|
-
error && /* @__PURE__ */
|
|
1899
|
-
/* @__PURE__ */
|
|
1900
|
-
/* @__PURE__ */
|
|
1901
|
-
/* @__PURE__ */
|
|
2622
|
+
/* @__PURE__ */ jsx15("div", { className: "adc-dialog__body", children }),
|
|
2623
|
+
error && /* @__PURE__ */ jsx15("p", { className: "adc-error", role: "alert", children: error }),
|
|
2624
|
+
/* @__PURE__ */ jsxs13("footer", { className: "adc-dialog__footer", children: [
|
|
2625
|
+
/* @__PURE__ */ jsx15("button", { type: "button", className: "adc-button", onClick: onClose, children: messages.dialogCancel }),
|
|
2626
|
+
/* @__PURE__ */ jsxs13("button", { type: "submit", className: "adc-button adc-button--primary", disabled: isBusy, children: [
|
|
1902
2627
|
confirmIcon,
|
|
1903
2628
|
confirmLabel
|
|
1904
2629
|
] })
|
|
@@ -1909,13 +2634,13 @@ function ActionDialog({
|
|
|
1909
2634
|
}
|
|
1910
2635
|
|
|
1911
2636
|
// src/components/BatchBar.tsx
|
|
1912
|
-
import { jsx as
|
|
2637
|
+
import { jsx as jsx16, jsxs as jsxs14 } from "react/jsx-runtime";
|
|
1913
2638
|
function BatchBar({ ids, tab, onClearSelection, onDone }) {
|
|
1914
2639
|
const api = useContentAdminApi();
|
|
1915
2640
|
const { messages, format } = useContentText();
|
|
1916
|
-
const [isConfirming, setIsConfirming] =
|
|
1917
|
-
const [isBusy, setIsBusy] =
|
|
1918
|
-
const [result, setResult] =
|
|
2641
|
+
const [isConfirming, setIsConfirming] = useState15(false);
|
|
2642
|
+
const [isBusy, setIsBusy] = useState15(false);
|
|
2643
|
+
const [result, setResult] = useState15();
|
|
1919
2644
|
async function run(action) {
|
|
1920
2645
|
setIsBusy(true);
|
|
1921
2646
|
const calls = ids.map(
|
|
@@ -1930,9 +2655,9 @@ function BatchBar({ ids, tab, onClearSelection, onDone }) {
|
|
|
1930
2655
|
}
|
|
1931
2656
|
const canPublish = tab === "draft";
|
|
1932
2657
|
const canUnpublish = tab === "published" || tab === "scheduled";
|
|
1933
|
-
return /* @__PURE__ */
|
|
1934
|
-
/* @__PURE__ */
|
|
1935
|
-
canPublish && /* @__PURE__ */
|
|
2658
|
+
return /* @__PURE__ */ jsxs14("div", { className: "adc-batch-bar", role: "region", "aria-label": messages.batchLabel, children: [
|
|
2659
|
+
/* @__PURE__ */ jsx16("strong", { children: format("selectedCount", { count: ids.length }) }),
|
|
2660
|
+
canPublish && /* @__PURE__ */ jsxs14(
|
|
1936
2661
|
"button",
|
|
1937
2662
|
{
|
|
1938
2663
|
type: "button",
|
|
@@ -1940,12 +2665,12 @@ function BatchBar({ ids, tab, onClearSelection, onDone }) {
|
|
|
1940
2665
|
disabled: isBusy,
|
|
1941
2666
|
onClick: () => void run("publish"),
|
|
1942
2667
|
children: [
|
|
1943
|
-
/* @__PURE__ */
|
|
2668
|
+
/* @__PURE__ */ jsx16(CircleCheck2, { "aria-hidden": "true", className: "adc-icon" }),
|
|
1944
2669
|
messages.batchPublish
|
|
1945
2670
|
]
|
|
1946
2671
|
}
|
|
1947
2672
|
),
|
|
1948
|
-
canUnpublish && /* @__PURE__ */
|
|
2673
|
+
canUnpublish && /* @__PURE__ */ jsxs14(
|
|
1949
2674
|
"button",
|
|
1950
2675
|
{
|
|
1951
2676
|
type: "button",
|
|
@@ -1953,12 +2678,12 @@ function BatchBar({ ids, tab, onClearSelection, onDone }) {
|
|
|
1953
2678
|
disabled: isBusy,
|
|
1954
2679
|
onClick: () => void run("unpublish"),
|
|
1955
2680
|
children: [
|
|
1956
|
-
/* @__PURE__ */
|
|
2681
|
+
/* @__PURE__ */ jsx16(EyeOff2, { "aria-hidden": "true", className: "adc-icon" }),
|
|
1957
2682
|
messages.batchUnpublish
|
|
1958
2683
|
]
|
|
1959
2684
|
}
|
|
1960
2685
|
),
|
|
1961
|
-
/* @__PURE__ */
|
|
2686
|
+
/* @__PURE__ */ jsxs14(
|
|
1962
2687
|
"button",
|
|
1963
2688
|
{
|
|
1964
2689
|
type: "button",
|
|
@@ -1966,26 +2691,26 @@ function BatchBar({ ids, tab, onClearSelection, onDone }) {
|
|
|
1966
2691
|
disabled: isBusy,
|
|
1967
2692
|
onClick: () => setIsConfirming(true),
|
|
1968
2693
|
children: [
|
|
1969
|
-
/* @__PURE__ */
|
|
2694
|
+
/* @__PURE__ */ jsx16(Archive3, { "aria-hidden": "true", className: "adc-icon" }),
|
|
1970
2695
|
messages.batchArchive
|
|
1971
2696
|
]
|
|
1972
2697
|
}
|
|
1973
2698
|
),
|
|
1974
|
-
/* @__PURE__ */
|
|
1975
|
-
/* @__PURE__ */
|
|
2699
|
+
/* @__PURE__ */ jsxs14("button", { type: "button", className: "adc-button adc-button--compact adc-button--ghost", onClick: onClearSelection, children: [
|
|
2700
|
+
/* @__PURE__ */ jsx16(X5, { "aria-hidden": "true", className: "adc-icon" }),
|
|
1976
2701
|
messages.clearSelection
|
|
1977
2702
|
] }),
|
|
1978
|
-
result && /* @__PURE__ */
|
|
1979
|
-
isConfirming && /* @__PURE__ */
|
|
2703
|
+
result && /* @__PURE__ */ jsx16("span", { className: "adc-error", role: "alert", children: result }),
|
|
2704
|
+
isConfirming && /* @__PURE__ */ jsx16(
|
|
1980
2705
|
ActionDialog,
|
|
1981
2706
|
{
|
|
1982
2707
|
title: messages.batchArchive,
|
|
1983
2708
|
confirmLabel: messages.batchArchive,
|
|
1984
|
-
confirmIcon: /* @__PURE__ */
|
|
2709
|
+
confirmIcon: /* @__PURE__ */ jsx16(Archive3, { "aria-hidden": "true", className: "adc-icon" }),
|
|
1985
2710
|
isBusy,
|
|
1986
2711
|
onClose: () => setIsConfirming(false),
|
|
1987
2712
|
onConfirm: () => void run("archive"),
|
|
1988
|
-
children: /* @__PURE__ */
|
|
2713
|
+
children: /* @__PURE__ */ jsx16("p", { children: format("batchArchiveConfirm", { count: ids.length }) })
|
|
1989
2714
|
}
|
|
1990
2715
|
)
|
|
1991
2716
|
] });
|
|
@@ -1993,15 +2718,15 @@ function BatchBar({ ids, tab, onClearSelection, onDone }) {
|
|
|
1993
2718
|
|
|
1994
2719
|
// src/components/PostActionDialogs.tsx
|
|
1995
2720
|
import { CopyPlus, FilePlus2, RefreshCw } from "lucide-react";
|
|
1996
|
-
import { useId as
|
|
2721
|
+
import { useId as useId8, useState as useState16 } from "react";
|
|
1997
2722
|
|
|
1998
2723
|
// src/components/DateTimeField.tsx
|
|
1999
|
-
import { jsx as
|
|
2724
|
+
import { jsx as jsx17, jsxs as jsxs15 } from "react/jsx-runtime";
|
|
2000
2725
|
function DateTimeField({ renderDateTimeInput, ...props }) {
|
|
2001
2726
|
if (renderDateTimeInput) return renderDateTimeInput(props);
|
|
2002
|
-
return /* @__PURE__ */
|
|
2003
|
-
/* @__PURE__ */
|
|
2004
|
-
/* @__PURE__ */
|
|
2727
|
+
return /* @__PURE__ */ jsxs15("div", { className: "adc-field", children: [
|
|
2728
|
+
/* @__PURE__ */ jsx17("label", { htmlFor: props.id, children: props.label }),
|
|
2729
|
+
/* @__PURE__ */ jsx17(
|
|
2005
2730
|
"input",
|
|
2006
2731
|
{
|
|
2007
2732
|
id: props.id,
|
|
@@ -2014,11 +2739,11 @@ function DateTimeField({ renderDateTimeInput, ...props }) {
|
|
|
2014
2739
|
}
|
|
2015
2740
|
|
|
2016
2741
|
// src/components/PostActionDialogs.tsx
|
|
2017
|
-
import { jsx as
|
|
2742
|
+
import { jsx as jsx18, jsxs as jsxs16 } from "react/jsx-runtime";
|
|
2018
2743
|
function useAction(run, onDone) {
|
|
2019
2744
|
const { messages } = useContentText();
|
|
2020
|
-
const [isBusy, setIsBusy] =
|
|
2021
|
-
const [error, setError] =
|
|
2745
|
+
const [isBusy, setIsBusy] = useState16(false);
|
|
2746
|
+
const [error, setError] = useState16();
|
|
2022
2747
|
async function submit() {
|
|
2023
2748
|
setIsBusy(true);
|
|
2024
2749
|
setError(void 0);
|
|
@@ -2032,10 +2757,10 @@ function useAction(run, onDone) {
|
|
|
2032
2757
|
return { isBusy, error, submit: () => void submit() };
|
|
2033
2758
|
}
|
|
2034
2759
|
function TitleDialog({ post, heading, fieldLabel, confirmLabel, icon, run, onClose, onDone }) {
|
|
2035
|
-
const [title, setTitle] =
|
|
2036
|
-
const id =
|
|
2760
|
+
const [title, setTitle] = useState16(post.title);
|
|
2761
|
+
const id = useId8();
|
|
2037
2762
|
const action = useAction(() => run(title.trim() || void 0), onDone);
|
|
2038
|
-
return /* @__PURE__ */
|
|
2763
|
+
return /* @__PURE__ */ jsx18(
|
|
2039
2764
|
ActionDialog,
|
|
2040
2765
|
{
|
|
2041
2766
|
title: heading,
|
|
@@ -2045,9 +2770,9 @@ function TitleDialog({ post, heading, fieldLabel, confirmLabel, icon, run, onClo
|
|
|
2045
2770
|
onConfirm: action.submit,
|
|
2046
2771
|
isBusy: action.isBusy,
|
|
2047
2772
|
error: action.error,
|
|
2048
|
-
children: /* @__PURE__ */
|
|
2049
|
-
/* @__PURE__ */
|
|
2050
|
-
/* @__PURE__ */
|
|
2773
|
+
children: /* @__PURE__ */ jsxs16("div", { className: "adc-field", children: [
|
|
2774
|
+
/* @__PURE__ */ jsx18("label", { htmlFor: id, children: fieldLabel }),
|
|
2775
|
+
/* @__PURE__ */ jsx18("input", { id, value: title, maxLength: 200, onChange: (event) => setTitle(event.target.value) })
|
|
2051
2776
|
] })
|
|
2052
2777
|
}
|
|
2053
2778
|
);
|
|
@@ -2055,14 +2780,14 @@ function TitleDialog({ post, heading, fieldLabel, confirmLabel, icon, run, onClo
|
|
|
2055
2780
|
function SaveAsTemplateDialog(props) {
|
|
2056
2781
|
const api = useContentAdminApi();
|
|
2057
2782
|
const { messages } = useContentText();
|
|
2058
|
-
return /* @__PURE__ */
|
|
2783
|
+
return /* @__PURE__ */ jsx18(
|
|
2059
2784
|
TitleDialog,
|
|
2060
2785
|
{
|
|
2061
2786
|
...props,
|
|
2062
2787
|
heading: messages.saveAsTemplate,
|
|
2063
2788
|
fieldLabel: messages.templateNameLabel,
|
|
2064
2789
|
confirmLabel: messages.saveAsTemplate,
|
|
2065
|
-
icon: /* @__PURE__ */
|
|
2790
|
+
icon: /* @__PURE__ */ jsx18(CopyPlus, { "aria-hidden": "true", className: "adc-icon" }),
|
|
2066
2791
|
run: (title) => api.saveAsTemplate ? api.saveAsTemplate(props.post.id, title ? { title } : {}) : Promise.reject(new Error(messages.actionError))
|
|
2067
2792
|
}
|
|
2068
2793
|
);
|
|
@@ -2070,14 +2795,14 @@ function SaveAsTemplateDialog(props) {
|
|
|
2070
2795
|
function FromTemplateDialog(props) {
|
|
2071
2796
|
const api = useContentAdminApi();
|
|
2072
2797
|
const { messages } = useContentText();
|
|
2073
|
-
return /* @__PURE__ */
|
|
2798
|
+
return /* @__PURE__ */ jsx18(
|
|
2074
2799
|
TitleDialog,
|
|
2075
2800
|
{
|
|
2076
2801
|
...props,
|
|
2077
2802
|
heading: messages.newFromTemplate,
|
|
2078
2803
|
fieldLabel: messages.newPostTitleLabel,
|
|
2079
2804
|
confirmLabel: messages.createDraft,
|
|
2080
|
-
icon: /* @__PURE__ */
|
|
2805
|
+
icon: /* @__PURE__ */ jsx18(FilePlus2, { "aria-hidden": "true", className: "adc-icon" }),
|
|
2081
2806
|
run: (title) => api.createFromTemplate ? api.createFromTemplate(props.post.id, title ? { title } : {}) : Promise.reject(new Error(messages.actionError))
|
|
2082
2807
|
}
|
|
2083
2808
|
);
|
|
@@ -2090,26 +2815,26 @@ function RepublishDialog({
|
|
|
2090
2815
|
}) {
|
|
2091
2816
|
const api = useContentAdminApi();
|
|
2092
2817
|
const { messages } = useContentText();
|
|
2093
|
-
const [value, setValue] =
|
|
2094
|
-
const id =
|
|
2818
|
+
const [value, setValue] = useState16(() => toDateTimeLocalValue((/* @__PURE__ */ new Date()).toISOString()));
|
|
2819
|
+
const id = useId8();
|
|
2095
2820
|
const action = useAction(() => {
|
|
2096
2821
|
if (!api.republishPost) return Promise.reject(new Error(messages.actionError));
|
|
2097
2822
|
const publishedAt = fromDateTimeLocalValue(value);
|
|
2098
2823
|
return api.republishPost(post.id, publishedAt ? { publishedAt } : {});
|
|
2099
2824
|
}, onDone);
|
|
2100
|
-
return /* @__PURE__ */
|
|
2825
|
+
return /* @__PURE__ */ jsxs16(
|
|
2101
2826
|
ActionDialog,
|
|
2102
2827
|
{
|
|
2103
2828
|
title: messages.republish,
|
|
2104
2829
|
confirmLabel: messages.republish,
|
|
2105
|
-
confirmIcon: /* @__PURE__ */
|
|
2830
|
+
confirmIcon: /* @__PURE__ */ jsx18(RefreshCw, { "aria-hidden": "true", className: "adc-icon" }),
|
|
2106
2831
|
onClose,
|
|
2107
2832
|
onConfirm: action.submit,
|
|
2108
2833
|
isBusy: action.isBusy,
|
|
2109
2834
|
error: action.error,
|
|
2110
2835
|
children: [
|
|
2111
|
-
/* @__PURE__ */
|
|
2112
|
-
/* @__PURE__ */
|
|
2836
|
+
/* @__PURE__ */ jsx18("p", { className: "adc-muted", children: post.title }),
|
|
2837
|
+
/* @__PURE__ */ jsx18(
|
|
2113
2838
|
DateTimeField,
|
|
2114
2839
|
{
|
|
2115
2840
|
id,
|
|
@@ -2119,17 +2844,17 @@ function RepublishDialog({
|
|
|
2119
2844
|
renderDateTimeInput
|
|
2120
2845
|
}
|
|
2121
2846
|
),
|
|
2122
|
-
/* @__PURE__ */
|
|
2847
|
+
/* @__PURE__ */ jsx18("p", { className: "adc-hint", children: messages.republishHint })
|
|
2123
2848
|
]
|
|
2124
2849
|
}
|
|
2125
2850
|
);
|
|
2126
2851
|
}
|
|
2127
2852
|
|
|
2128
2853
|
// src/components/PostListFooter.tsx
|
|
2129
|
-
import { useId as
|
|
2854
|
+
import { useId as useId9 } from "react";
|
|
2130
2855
|
|
|
2131
2856
|
// src/components/Pagination.tsx
|
|
2132
|
-
import { ChevronLeft, ChevronRight } from "lucide-react";
|
|
2857
|
+
import { ChevronLeft as ChevronLeft2, ChevronRight as ChevronRight2 } from "lucide-react";
|
|
2133
2858
|
|
|
2134
2859
|
// src/lib/pagination.ts
|
|
2135
2860
|
function buildPageItems(params) {
|
|
@@ -2151,7 +2876,7 @@ function buildPageItems(params) {
|
|
|
2151
2876
|
}
|
|
2152
2877
|
|
|
2153
2878
|
// src/components/Pagination.tsx
|
|
2154
|
-
import { jsx as
|
|
2879
|
+
import { jsx as jsx19, jsxs as jsxs17 } from "react/jsx-runtime";
|
|
2155
2880
|
function Pagination({ page, totalPages, getPageHref, onPageChange }) {
|
|
2156
2881
|
const { messages, format } = useContentText();
|
|
2157
2882
|
const renderLink = useRenderLink();
|
|
@@ -2160,7 +2885,7 @@ function Pagination({ page, totalPages, getPageHref, onPageChange }) {
|
|
|
2160
2885
|
const className = `adc-page${isCurrent ? " adc-page--current" : ""}`;
|
|
2161
2886
|
if (getPageHref && !isCurrent)
|
|
2162
2887
|
return renderLink({ href: getPageHref(target), className, "aria-label": label, children: content });
|
|
2163
|
-
return /* @__PURE__ */
|
|
2888
|
+
return /* @__PURE__ */ jsx19(
|
|
2164
2889
|
"button",
|
|
2165
2890
|
{
|
|
2166
2891
|
type: "button",
|
|
@@ -2173,37 +2898,37 @@ function Pagination({ page, totalPages, getPageHref, onPageChange }) {
|
|
|
2173
2898
|
}
|
|
2174
2899
|
);
|
|
2175
2900
|
}
|
|
2176
|
-
return /* @__PURE__ */
|
|
2177
|
-
page > 1 && renderTarget(page - 1, messages.paginationPrevious, /* @__PURE__ */
|
|
2901
|
+
return /* @__PURE__ */ jsxs17("nav", { className: "adc-pagination", "aria-label": messages.paginationLabel, children: [
|
|
2902
|
+
page > 1 && renderTarget(page - 1, messages.paginationPrevious, /* @__PURE__ */ jsx19(ChevronLeft2, { "aria-hidden": "true", className: "adc-icon" })),
|
|
2178
2903
|
buildPageItems({ current: page, total: totalPages }).map(
|
|
2179
|
-
(item) => item.kind === "gap" ? /* @__PURE__ */
|
|
2904
|
+
(item) => item.kind === "gap" ? /* @__PURE__ */ jsx19("span", { className: "adc-page-gap", "aria-hidden": "true", children: "\u2026" }, item.key) : /* @__PURE__ */ jsx19("span", { children: renderTarget(item.page, format("pageLabel", { page: item.page }), item.page, item.page === page) }, item.page)
|
|
2180
2905
|
),
|
|
2181
|
-
page < totalPages && renderTarget(page + 1, messages.paginationNext, /* @__PURE__ */
|
|
2906
|
+
page < totalPages && renderTarget(page + 1, messages.paginationNext, /* @__PURE__ */ jsx19(ChevronRight2, { "aria-hidden": "true", className: "adc-icon" }))
|
|
2182
2907
|
] });
|
|
2183
2908
|
}
|
|
2184
2909
|
|
|
2185
2910
|
// src/components/SelectField.tsx
|
|
2186
|
-
import { jsx as
|
|
2911
|
+
import { jsx as jsx20, jsxs as jsxs18 } from "react/jsx-runtime";
|
|
2187
2912
|
function SelectField({ renderSelect, ...props }) {
|
|
2188
2913
|
if (renderSelect) return renderSelect(props);
|
|
2189
|
-
return /* @__PURE__ */
|
|
2190
|
-
/* @__PURE__ */
|
|
2191
|
-
/* @__PURE__ */
|
|
2914
|
+
return /* @__PURE__ */ jsxs18("div", { className: "adc-field", children: [
|
|
2915
|
+
/* @__PURE__ */ jsx20("label", { htmlFor: props.id, children: props.label }),
|
|
2916
|
+
/* @__PURE__ */ jsx20("select", { id: props.id, value: props.value, onChange: (event) => props.onChange(event.target.value), children: props.options.map((option) => /* @__PURE__ */ jsx20("option", { value: option.id, children: option.label }, option.id)) })
|
|
2192
2917
|
] });
|
|
2193
2918
|
}
|
|
2194
2919
|
|
|
2195
2920
|
// src/components/PostListFooter.tsx
|
|
2196
|
-
import { jsx as
|
|
2921
|
+
import { jsx as jsx21, jsxs as jsxs19 } from "react/jsx-runtime";
|
|
2197
2922
|
function PostListFooter({ data, pageSize, onPage, onPageSize, renderSelect }) {
|
|
2198
2923
|
const { messages, format } = useContentText();
|
|
2199
|
-
const id =
|
|
2924
|
+
const id = useId9();
|
|
2200
2925
|
const { page, total } = data.pagination;
|
|
2201
2926
|
const from = total === 0 ? 0 : (page - 1) * pageSize + 1;
|
|
2202
2927
|
const to = Math.min(page * pageSize, total);
|
|
2203
|
-
return /* @__PURE__ */
|
|
2204
|
-
/* @__PURE__ */
|
|
2205
|
-
/* @__PURE__ */
|
|
2206
|
-
/* @__PURE__ */
|
|
2928
|
+
return /* @__PURE__ */ jsxs19("div", { className: "adc-list-footer", children: [
|
|
2929
|
+
/* @__PURE__ */ jsx21("span", { className: "adc-muted", "aria-live": "polite", children: format("rangeLabel", { from, to, total }) }),
|
|
2930
|
+
/* @__PURE__ */ jsx21(Pagination, { page, totalPages: data.pagination.totalPages, onPageChange: onPage }),
|
|
2931
|
+
/* @__PURE__ */ jsx21(
|
|
2207
2932
|
SelectField,
|
|
2208
2933
|
{
|
|
2209
2934
|
id,
|
|
@@ -2219,7 +2944,7 @@ function PostListFooter({ data, pageSize, onPage, onPageSize, renderSelect }) {
|
|
|
2219
2944
|
|
|
2220
2945
|
// src/components/PostListTabs.tsx
|
|
2221
2946
|
import { CalendarClock as CalendarClock3, CircleCheck as CircleCheck3, Copy as Copy2, PencilLine as PencilLine2 } from "lucide-react";
|
|
2222
|
-
import { jsx as
|
|
2947
|
+
import { jsx as jsx22, jsxs as jsxs20 } from "react/jsx-runtime";
|
|
2223
2948
|
var TABS2 = [
|
|
2224
2949
|
{ id: POST_LIST_TAB.PUBLISHED, icon: CircleCheck3, label: "tabPublished", count: "published" },
|
|
2225
2950
|
{ id: POST_LIST_TAB.SCHEDULED, icon: CalendarClock3, label: "tabScheduled", count: "scheduled" },
|
|
@@ -2228,7 +2953,7 @@ var TABS2 = [
|
|
|
2228
2953
|
];
|
|
2229
2954
|
function PostListTabs({ active, counts, onChange }) {
|
|
2230
2955
|
const { messages } = useContentText();
|
|
2231
|
-
return /* @__PURE__ */
|
|
2956
|
+
return /* @__PURE__ */ jsx22("div", { className: "adc-status-tabs", role: "tablist", "aria-label": messages.tabsLabel, children: TABS2.map(({ id, icon: Icon, label, count }) => /* @__PURE__ */ jsxs20(
|
|
2232
2957
|
"button",
|
|
2233
2958
|
{
|
|
2234
2959
|
type: "button",
|
|
@@ -2237,9 +2962,9 @@ function PostListTabs({ active, counts, onChange }) {
|
|
|
2237
2962
|
className: `adc-status-tab adc-status-tab--${id}`,
|
|
2238
2963
|
onClick: () => onChange(id),
|
|
2239
2964
|
children: [
|
|
2240
|
-
/* @__PURE__ */
|
|
2241
|
-
/* @__PURE__ */
|
|
2242
|
-
/* @__PURE__ */
|
|
2965
|
+
/* @__PURE__ */ jsx22(Icon, { "aria-hidden": "true", className: "adc-icon" }),
|
|
2966
|
+
/* @__PURE__ */ jsx22("span", { children: messages[label] }),
|
|
2967
|
+
/* @__PURE__ */ jsx22("span", { className: "adc-status-tab__count", children: counts ? counts[count] : "\u2013" })
|
|
2243
2968
|
]
|
|
2244
2969
|
},
|
|
2245
2970
|
id
|
|
@@ -2249,18 +2974,18 @@ function PostListTabs({ active, counts, onChange }) {
|
|
|
2249
2974
|
// src/components/PostListToolbar.tsx
|
|
2250
2975
|
import { formatTagLabel } from "@adatechnology/content-contracts";
|
|
2251
2976
|
import { Plus, RotateCcw, Search } from "lucide-react";
|
|
2252
|
-
import { useId as
|
|
2253
|
-
import { jsx as
|
|
2977
|
+
import { useId as useId10 } from "react";
|
|
2978
|
+
import { jsx as jsx23, jsxs as jsxs21 } from "react/jsx-runtime";
|
|
2254
2979
|
function PostListToolbar(props) {
|
|
2255
2980
|
const { messages } = useContentText();
|
|
2256
|
-
const searchId =
|
|
2257
|
-
return /* @__PURE__ */
|
|
2258
|
-
/* @__PURE__ */
|
|
2259
|
-
/* @__PURE__ */
|
|
2260
|
-
/* @__PURE__ */
|
|
2261
|
-
/* @__PURE__ */
|
|
2262
|
-
/* @__PURE__ */
|
|
2263
|
-
/* @__PURE__ */
|
|
2981
|
+
const searchId = useId10();
|
|
2982
|
+
return /* @__PURE__ */ jsxs21("div", { className: "adc-list-toolbar", children: [
|
|
2983
|
+
/* @__PURE__ */ jsxs21("div", { className: "adc-list-toolbar__filters", children: [
|
|
2984
|
+
/* @__PURE__ */ jsxs21("div", { className: "adc-field adc-field--search", children: [
|
|
2985
|
+
/* @__PURE__ */ jsx23("label", { htmlFor: searchId, className: "adc-visually-hidden", children: messages.searchLabel }),
|
|
2986
|
+
/* @__PURE__ */ jsxs21("div", { className: "adc-input-icon", children: [
|
|
2987
|
+
/* @__PURE__ */ jsx23(Search, { "aria-hidden": "true", className: "adc-icon" }),
|
|
2988
|
+
/* @__PURE__ */ jsx23(
|
|
2264
2989
|
"input",
|
|
2265
2990
|
{
|
|
2266
2991
|
id: searchId,
|
|
@@ -2274,7 +2999,7 @@ function PostListToolbar(props) {
|
|
|
2274
2999
|
)
|
|
2275
3000
|
] })
|
|
2276
3001
|
] }),
|
|
2277
|
-
props.tags && props.tags.length > 0 && /* @__PURE__ */
|
|
3002
|
+
props.tags && props.tags.length > 0 && /* @__PURE__ */ jsx23("div", { className: "adc-tag-toggles", role: "group", "aria-label": messages.filterTag, children: props.tags.slice(0, 12).map((entry) => /* @__PURE__ */ jsxs21(
|
|
2278
3003
|
"button",
|
|
2279
3004
|
{
|
|
2280
3005
|
type: "button",
|
|
@@ -2283,32 +3008,32 @@ function PostListToolbar(props) {
|
|
|
2283
3008
|
onClick: () => props.onToggleTag(entry.tag),
|
|
2284
3009
|
children: [
|
|
2285
3010
|
formatTagLabel(entry.tag),
|
|
2286
|
-
/* @__PURE__ */
|
|
3011
|
+
/* @__PURE__ */ jsx23("span", { className: "adc-tag-toggle__count", children: entry.count })
|
|
2287
3012
|
]
|
|
2288
3013
|
},
|
|
2289
3014
|
entry.tag
|
|
2290
3015
|
)) }),
|
|
2291
|
-
props.hasFilters && /* @__PURE__ */
|
|
2292
|
-
/* @__PURE__ */
|
|
3016
|
+
props.hasFilters && /* @__PURE__ */ jsxs21("button", { type: "button", className: "adc-button adc-button--ghost", onClick: props.onClear, children: [
|
|
3017
|
+
/* @__PURE__ */ jsx23(RotateCcw, { "aria-hidden": "true", className: "adc-icon" }),
|
|
2293
3018
|
messages.clearFilters
|
|
2294
3019
|
] })
|
|
2295
3020
|
] }),
|
|
2296
|
-
props.onCreate && /* @__PURE__ */
|
|
2297
|
-
/* @__PURE__ */
|
|
3021
|
+
props.onCreate && /* @__PURE__ */ jsxs21("button", { type: "button", className: "adc-button adc-button--primary", onClick: props.onCreate, children: [
|
|
3022
|
+
/* @__PURE__ */ jsx23(Plus, { "aria-hidden": "true", className: "adc-icon" }),
|
|
2298
3023
|
messages.newPost
|
|
2299
3024
|
] })
|
|
2300
3025
|
] });
|
|
2301
3026
|
}
|
|
2302
3027
|
|
|
2303
3028
|
// src/components/PostTable.tsx
|
|
2304
|
-
import { ArrowDown, ArrowUp, ChevronsUpDown } from "lucide-react";
|
|
3029
|
+
import { ArrowDown as ArrowDown2, ArrowUp as ArrowUp2, ChevronsUpDown } from "lucide-react";
|
|
2305
3030
|
|
|
2306
3031
|
// src/components/CheckBox.tsx
|
|
2307
3032
|
import { Check, Minus } from "lucide-react";
|
|
2308
|
-
import { jsx as
|
|
3033
|
+
import { jsx as jsx24 } from "react/jsx-runtime";
|
|
2309
3034
|
function CheckBox({ checked, isMixed = false, label, onChange }) {
|
|
2310
3035
|
const Icon = isMixed ? Minus : Check;
|
|
2311
|
-
return /* @__PURE__ */
|
|
3036
|
+
return /* @__PURE__ */ jsx24(
|
|
2312
3037
|
"button",
|
|
2313
3038
|
{
|
|
2314
3039
|
type: "button",
|
|
@@ -2317,13 +3042,13 @@ function CheckBox({ checked, isMixed = false, label, onChange }) {
|
|
|
2317
3042
|
"aria-label": label,
|
|
2318
3043
|
className: `adc-checkbox${checked || isMixed ? " is-on" : ""}`,
|
|
2319
3044
|
onClick: onChange,
|
|
2320
|
-
children: (checked || isMixed) && /* @__PURE__ */
|
|
3045
|
+
children: (checked || isMixed) && /* @__PURE__ */ jsx24(Icon, { "aria-hidden": "true", className: "adc-icon" })
|
|
2321
3046
|
}
|
|
2322
3047
|
);
|
|
2323
3048
|
}
|
|
2324
3049
|
|
|
2325
3050
|
// src/components/PostTable.tsx
|
|
2326
|
-
import { jsx as
|
|
3051
|
+
import { jsx as jsx25, jsxs as jsxs22 } from "react/jsx-runtime";
|
|
2327
3052
|
var SORTABLE_COLUMNS = [
|
|
2328
3053
|
{ field: "title", label: "columnTitle" },
|
|
2329
3054
|
{ field: "status", label: "columnStatus" },
|
|
@@ -2334,9 +3059,9 @@ function PostTable(props) {
|
|
|
2334
3059
|
const { messages, locale } = useContentText();
|
|
2335
3060
|
const selectedCount = props.rows.filter((row) => props.selectedIds.has(row.id)).length;
|
|
2336
3061
|
const isAll = selectedCount > 0 && selectedCount === props.rows.length;
|
|
2337
|
-
return /* @__PURE__ */
|
|
2338
|
-
/* @__PURE__ */
|
|
2339
|
-
/* @__PURE__ */
|
|
3062
|
+
return /* @__PURE__ */ jsx25("div", { className: "adc-table-wrap", "aria-busy": props.isBusy, children: /* @__PURE__ */ jsxs22("table", { className: "adc-table", children: [
|
|
3063
|
+
/* @__PURE__ */ jsx25("thead", { children: /* @__PURE__ */ jsxs22("tr", { children: [
|
|
3064
|
+
/* @__PURE__ */ jsx25("th", { scope: "col", className: "adc-table__check", children: /* @__PURE__ */ jsx25(
|
|
2340
3065
|
CheckBox,
|
|
2341
3066
|
{
|
|
2342
3067
|
checked: isAll,
|
|
@@ -2347,24 +3072,24 @@ function PostTable(props) {
|
|
|
2347
3072
|
) }),
|
|
2348
3073
|
SORTABLE_COLUMNS.map(({ field, label }) => {
|
|
2349
3074
|
const isActive = props.sort === field;
|
|
2350
|
-
const Icon = !isActive ? ChevronsUpDown : props.order === "asc" ?
|
|
2351
|
-
return /* @__PURE__ */
|
|
3075
|
+
const Icon = !isActive ? ChevronsUpDown : props.order === "asc" ? ArrowUp2 : ArrowDown2;
|
|
3076
|
+
return /* @__PURE__ */ jsx25(
|
|
2352
3077
|
"th",
|
|
2353
3078
|
{
|
|
2354
3079
|
scope: "col",
|
|
2355
3080
|
"aria-sort": !isActive ? "none" : props.order === "asc" ? "ascending" : "descending",
|
|
2356
|
-
children: /* @__PURE__ */
|
|
3081
|
+
children: /* @__PURE__ */ jsxs22("button", { type: "button", className: "adc-sort", onClick: () => props.onSort(field), children: [
|
|
2357
3082
|
messages[label],
|
|
2358
|
-
/* @__PURE__ */
|
|
3083
|
+
/* @__PURE__ */ jsx25(Icon, { "aria-hidden": "true", className: "adc-icon" })
|
|
2359
3084
|
] })
|
|
2360
3085
|
},
|
|
2361
3086
|
field
|
|
2362
3087
|
);
|
|
2363
3088
|
}),
|
|
2364
|
-
props.hasActions && /* @__PURE__ */
|
|
3089
|
+
props.hasActions && /* @__PURE__ */ jsx25("th", { scope: "col", children: messages.columnActions })
|
|
2365
3090
|
] }) }),
|
|
2366
|
-
/* @__PURE__ */
|
|
2367
|
-
/* @__PURE__ */
|
|
3091
|
+
/* @__PURE__ */ jsx25("tbody", { children: props.rows.map((post) => /* @__PURE__ */ jsxs22("tr", { className: props.selectedIds.has(post.id) ? "is-selected" : void 0, children: [
|
|
3092
|
+
/* @__PURE__ */ jsx25("td", { className: "adc-table__check", children: /* @__PURE__ */ jsx25(
|
|
2368
3093
|
CheckBox,
|
|
2369
3094
|
{
|
|
2370
3095
|
checked: props.selectedIds.has(post.id),
|
|
@@ -2372,17 +3097,17 @@ function PostTable(props) {
|
|
|
2372
3097
|
onChange: () => props.onToggleSelected(post.id)
|
|
2373
3098
|
}
|
|
2374
3099
|
) }),
|
|
2375
|
-
/* @__PURE__ */
|
|
2376
|
-
/* @__PURE__ */
|
|
2377
|
-
/* @__PURE__ */
|
|
3100
|
+
/* @__PURE__ */ jsxs22("td", { children: [
|
|
3101
|
+
/* @__PURE__ */ jsx25("button", { type: "button", className: "adc-row-link", onClick: () => props.onSelect(post), children: post.title }),
|
|
3102
|
+
/* @__PURE__ */ jsxs22("span", { className: "adc-muted adc-slug", children: [
|
|
2378
3103
|
"/",
|
|
2379
3104
|
post.slug
|
|
2380
3105
|
] })
|
|
2381
3106
|
] }),
|
|
2382
|
-
/* @__PURE__ */
|
|
2383
|
-
/* @__PURE__ */
|
|
2384
|
-
/* @__PURE__ */
|
|
2385
|
-
props.hasActions && /* @__PURE__ */
|
|
3107
|
+
/* @__PURE__ */ jsx25("td", { children: /* @__PURE__ */ jsx25(StatusChip, { status: post.status, isTemplate: post.isTemplate }) }),
|
|
3108
|
+
/* @__PURE__ */ jsx25("td", { children: formatPostDate(post.publishedAt, locale, true) }),
|
|
3109
|
+
/* @__PURE__ */ jsx25("td", { children: formatPostDate(post.updatedAt, locale, true) }),
|
|
3110
|
+
props.hasActions && /* @__PURE__ */ jsx25("td", { className: "adc-row-actions", children: props.renderActions(post) })
|
|
2386
3111
|
] }, post.id)) })
|
|
2387
3112
|
] }) });
|
|
2388
3113
|
}
|
|
@@ -2392,8 +3117,8 @@ import {
|
|
|
2392
3117
|
RECURRENCE_FREQUENCY
|
|
2393
3118
|
} from "@adatechnology/content-contracts";
|
|
2394
3119
|
import { CirclePause, CirclePlay, Plus as Plus2, Repeat, Trash2 as Trash22 } from "lucide-react";
|
|
2395
|
-
import { useId as
|
|
2396
|
-
import { jsx as
|
|
3120
|
+
import { useId as useId11, useState as useState17 } from "react";
|
|
3121
|
+
import { jsx as jsx26, jsxs as jsxs23 } from "react/jsx-runtime";
|
|
2397
3122
|
function defaultStart() {
|
|
2398
3123
|
const next = new Date(Date.now() + 24 * 60 * 60 * 1e3);
|
|
2399
3124
|
next.setMinutes(0, 0, 0);
|
|
@@ -2408,12 +3133,12 @@ function CreateRecurrenceDialog({
|
|
|
2408
3133
|
}) {
|
|
2409
3134
|
const api = useContentAdminApi();
|
|
2410
3135
|
const { messages } = useContentText();
|
|
2411
|
-
const [templateId, setTemplateId] =
|
|
2412
|
-
const [frequency, setFrequency] =
|
|
2413
|
-
const [startsAt, setStartsAt] =
|
|
2414
|
-
const [isBusy, setIsBusy] =
|
|
2415
|
-
const [error, setError] =
|
|
2416
|
-
const ids = { template:
|
|
3136
|
+
const [templateId, setTemplateId] = useState17(templates[0]?.id ?? "");
|
|
3137
|
+
const [frequency, setFrequency] = useState17(RECURRENCE_FREQUENCY.WEEKLY);
|
|
3138
|
+
const [startsAt, setStartsAt] = useState17(defaultStart);
|
|
3139
|
+
const [isBusy, setIsBusy] = useState17(false);
|
|
3140
|
+
const [error, setError] = useState17();
|
|
3141
|
+
const ids = { template: useId11(), frequency: useId11(), start: useId11() };
|
|
2417
3142
|
async function submit() {
|
|
2418
3143
|
const iso = fromDateTimeLocalValue(startsAt);
|
|
2419
3144
|
if (!api.createRecurrence || !iso || !templateId) return;
|
|
@@ -2426,18 +3151,18 @@ function CreateRecurrenceDialog({
|
|
|
2426
3151
|
setIsBusy(false);
|
|
2427
3152
|
}
|
|
2428
3153
|
}
|
|
2429
|
-
return /* @__PURE__ */
|
|
3154
|
+
return /* @__PURE__ */ jsxs23(
|
|
2430
3155
|
ActionDialog,
|
|
2431
3156
|
{
|
|
2432
3157
|
title: messages.recurrenceNew,
|
|
2433
3158
|
confirmLabel: messages.recurrenceCreate,
|
|
2434
|
-
confirmIcon: /* @__PURE__ */
|
|
3159
|
+
confirmIcon: /* @__PURE__ */ jsx26(Repeat, { "aria-hidden": "true", className: "adc-icon" }),
|
|
2435
3160
|
isBusy,
|
|
2436
3161
|
error,
|
|
2437
3162
|
onClose,
|
|
2438
3163
|
onConfirm: () => void submit(),
|
|
2439
3164
|
children: [
|
|
2440
|
-
/* @__PURE__ */
|
|
3165
|
+
/* @__PURE__ */ jsx26(
|
|
2441
3166
|
SelectField,
|
|
2442
3167
|
{
|
|
2443
3168
|
id: ids.template,
|
|
@@ -2448,7 +3173,7 @@ function CreateRecurrenceDialog({
|
|
|
2448
3173
|
renderSelect
|
|
2449
3174
|
}
|
|
2450
3175
|
),
|
|
2451
|
-
/* @__PURE__ */
|
|
3176
|
+
/* @__PURE__ */ jsx26(
|
|
2452
3177
|
SelectField,
|
|
2453
3178
|
{
|
|
2454
3179
|
id: ids.frequency,
|
|
@@ -2462,7 +3187,7 @@ function CreateRecurrenceDialog({
|
|
|
2462
3187
|
renderSelect
|
|
2463
3188
|
}
|
|
2464
3189
|
),
|
|
2465
|
-
/* @__PURE__ */
|
|
3190
|
+
/* @__PURE__ */ jsx26(
|
|
2466
3191
|
DateTimeField,
|
|
2467
3192
|
{
|
|
2468
3193
|
id: ids.start,
|
|
@@ -2472,7 +3197,7 @@ function CreateRecurrenceDialog({
|
|
|
2472
3197
|
renderDateTimeInput
|
|
2473
3198
|
}
|
|
2474
3199
|
),
|
|
2475
|
-
/* @__PURE__ */
|
|
3200
|
+
/* @__PURE__ */ jsx26("p", { className: "adc-hint", children: messages.recurrenceHint })
|
|
2476
3201
|
]
|
|
2477
3202
|
}
|
|
2478
3203
|
);
|
|
@@ -2491,36 +3216,36 @@ function RuleRow({ rule, onChanged }) {
|
|
|
2491
3216
|
await api.removeRecurrence?.(rule.id);
|
|
2492
3217
|
onChanged();
|
|
2493
3218
|
}
|
|
2494
|
-
return /* @__PURE__ */
|
|
2495
|
-
/* @__PURE__ */
|
|
2496
|
-
/* @__PURE__ */
|
|
2497
|
-
/* @__PURE__ */
|
|
3219
|
+
return /* @__PURE__ */ jsxs23("li", { className: "adc-rule", children: [
|
|
3220
|
+
/* @__PURE__ */ jsxs23("div", { className: "adc-rule__main", children: [
|
|
3221
|
+
/* @__PURE__ */ jsx26("strong", { children: rule.templateTitle }),
|
|
3222
|
+
/* @__PURE__ */ jsxs23("span", { className: "adc-muted", children: [
|
|
2498
3223
|
rule.frequency === RECURRENCE_FREQUENCY.WEEKLY ? messages.frequencyWeekly : messages.frequencyMonthly,
|
|
2499
3224
|
rule.isActive && ` \xB7 ${format("recurrenceNext", { date: formatPostDate(rule.nextRunAt, locale, true) })}`
|
|
2500
3225
|
] })
|
|
2501
3226
|
] }),
|
|
2502
|
-
/* @__PURE__ */
|
|
2503
|
-
/* @__PURE__ */
|
|
3227
|
+
/* @__PURE__ */ jsxs23("span", { className: `adc-chip adc-badge adc-chip--${rule.isActive ? "published" : "draft"}`, children: [
|
|
3228
|
+
/* @__PURE__ */ jsx26(StateIcon, { "aria-hidden": "true", className: "adc-icon" }),
|
|
2504
3229
|
rule.isActive ? messages.recurrenceActive : messages.recurrencePaused
|
|
2505
3230
|
] }),
|
|
2506
|
-
/* @__PURE__ */
|
|
3231
|
+
/* @__PURE__ */ jsx26(Tooltip, { text: toggleLabel, children: /* @__PURE__ */ jsx26(
|
|
2507
3232
|
"button",
|
|
2508
3233
|
{
|
|
2509
3234
|
type: "button",
|
|
2510
3235
|
className: "adc-button adc-button--ghost adc-button--icon",
|
|
2511
3236
|
"aria-label": toggleLabel,
|
|
2512
3237
|
onClick: () => void toggle(),
|
|
2513
|
-
children: /* @__PURE__ */
|
|
3238
|
+
children: /* @__PURE__ */ jsx26(ToggleIcon, { "aria-hidden": "true", className: "adc-icon" })
|
|
2514
3239
|
}
|
|
2515
3240
|
) }),
|
|
2516
|
-
/* @__PURE__ */
|
|
3241
|
+
/* @__PURE__ */ jsx26(Tooltip, { text: messages.recurrenceRemoveTip, children: /* @__PURE__ */ jsx26(
|
|
2517
3242
|
"button",
|
|
2518
3243
|
{
|
|
2519
3244
|
type: "button",
|
|
2520
3245
|
className: "adc-button adc-button--ghost adc-button--icon adc-button--danger",
|
|
2521
3246
|
"aria-label": messages.recurrenceRemove,
|
|
2522
3247
|
onClick: () => void remove(),
|
|
2523
|
-
children: /* @__PURE__ */
|
|
3248
|
+
children: /* @__PURE__ */ jsx26(Trash22, { "aria-hidden": "true", className: "adc-icon" })
|
|
2524
3249
|
}
|
|
2525
3250
|
) })
|
|
2526
3251
|
] });
|
|
@@ -2528,20 +3253,20 @@ function RuleRow({ rule, onChanged }) {
|
|
|
2528
3253
|
function RecurrencePanel(props) {
|
|
2529
3254
|
const api = useContentAdminApi();
|
|
2530
3255
|
const { messages } = useContentText();
|
|
2531
|
-
const [isCreating, setIsCreating] =
|
|
3256
|
+
const [isCreating, setIsCreating] = useState17(false);
|
|
2532
3257
|
const rules = useAsyncResource(
|
|
2533
3258
|
() => api.listRecurrences ? api.listRecurrences() : Promise.resolve([]),
|
|
2534
3259
|
"recurrences"
|
|
2535
3260
|
);
|
|
2536
3261
|
if (!api.listRecurrences) return null;
|
|
2537
|
-
return /* @__PURE__ */
|
|
2538
|
-
/* @__PURE__ */
|
|
2539
|
-
/* @__PURE__ */
|
|
2540
|
-
/* @__PURE__ */
|
|
3262
|
+
return /* @__PURE__ */ jsxs23("section", { className: "adc-recurrence", "aria-labelledby": "adc-recurrence-title", children: [
|
|
3263
|
+
/* @__PURE__ */ jsxs23("header", { className: "adc-toolbar", children: [
|
|
3264
|
+
/* @__PURE__ */ jsxs23("h3", { id: "adc-recurrence-title", className: "adc-subtitle", children: [
|
|
3265
|
+
/* @__PURE__ */ jsx26(Repeat, { "aria-hidden": "true", className: "adc-icon" }),
|
|
2541
3266
|
" ",
|
|
2542
3267
|
messages.recurrenceTitle
|
|
2543
3268
|
] }),
|
|
2544
|
-
/* @__PURE__ */
|
|
3269
|
+
/* @__PURE__ */ jsxs23(
|
|
2545
3270
|
"button",
|
|
2546
3271
|
{
|
|
2547
3272
|
type: "button",
|
|
@@ -2549,14 +3274,14 @@ function RecurrencePanel(props) {
|
|
|
2549
3274
|
disabled: props.templates.length === 0,
|
|
2550
3275
|
onClick: () => setIsCreating(true),
|
|
2551
3276
|
children: [
|
|
2552
|
-
/* @__PURE__ */
|
|
3277
|
+
/* @__PURE__ */ jsx26(Plus2, { "aria-hidden": "true", className: "adc-icon" }),
|
|
2553
3278
|
messages.recurrenceNew
|
|
2554
3279
|
]
|
|
2555
3280
|
}
|
|
2556
3281
|
)
|
|
2557
3282
|
] }),
|
|
2558
|
-
(rules.data?.length ?? 0) === 0 ? /* @__PURE__ */
|
|
2559
|
-
isCreating && /* @__PURE__ */
|
|
3283
|
+
(rules.data?.length ?? 0) === 0 ? /* @__PURE__ */ jsx26("p", { className: "adc-state", children: props.templates.length === 0 ? messages.recurrenceNeedsTemplate : messages.recurrenceEmpty }) : /* @__PURE__ */ jsx26("ul", { className: "adc-rule-list", children: rules.data?.map((rule) => /* @__PURE__ */ jsx26(RuleRow, { rule, onChanged: rules.reload }, rule.id)) }),
|
|
3284
|
+
isCreating && /* @__PURE__ */ jsx26(
|
|
2560
3285
|
CreateRecurrenceDialog,
|
|
2561
3286
|
{
|
|
2562
3287
|
...props,
|
|
@@ -2571,7 +3296,16 @@ function RecurrencePanel(props) {
|
|
|
2571
3296
|
}
|
|
2572
3297
|
|
|
2573
3298
|
// src/components/PostList.tsx
|
|
2574
|
-
import { jsx as
|
|
3299
|
+
import { jsx as jsx27, jsxs as jsxs24 } from "react/jsx-runtime";
|
|
3300
|
+
function buildExportFilters(state, tab) {
|
|
3301
|
+
return {
|
|
3302
|
+
...tab ? { tab } : {},
|
|
3303
|
+
...state.search ? { search: state.search } : {},
|
|
3304
|
+
...state.tags.length > 0 ? { tag: state.tags.join(",") } : {},
|
|
3305
|
+
sort: state.sort,
|
|
3306
|
+
order: state.order
|
|
3307
|
+
};
|
|
3308
|
+
}
|
|
2575
3309
|
function PostList({
|
|
2576
3310
|
onSelect,
|
|
2577
3311
|
onCreate,
|
|
@@ -2579,11 +3313,12 @@ function PostList({
|
|
|
2579
3313
|
reloadKey,
|
|
2580
3314
|
syncUrl,
|
|
2581
3315
|
renderDateTimeInput,
|
|
2582
|
-
renderSelect
|
|
3316
|
+
renderSelect,
|
|
3317
|
+
renderExport
|
|
2583
3318
|
}) {
|
|
2584
3319
|
const { messages } = useContentText();
|
|
2585
3320
|
const api = useContentAdminApi();
|
|
2586
|
-
const [dialog, setDialog] =
|
|
3321
|
+
const [dialog, setDialog] = useState18();
|
|
2587
3322
|
const list = usePostList({
|
|
2588
3323
|
pageSize,
|
|
2589
3324
|
...reloadKey !== void 0 ? { reloadKey } : {},
|
|
@@ -2624,9 +3359,18 @@ function PostList({
|
|
|
2624
3359
|
function toggleAll() {
|
|
2625
3360
|
list.setSelectedIds(list.selectedIds.size === rows.length ? /* @__PURE__ */ new Set() : new Set(rows.map((row) => row.id)));
|
|
2626
3361
|
}
|
|
2627
|
-
return /* @__PURE__ */
|
|
2628
|
-
/* @__PURE__ */
|
|
2629
|
-
|
|
3362
|
+
return /* @__PURE__ */ jsxs24("section", { className: "adc-root adc-post-list", children: [
|
|
3363
|
+
/* @__PURE__ */ jsxs24("header", { className: "adc-toolbar", children: [
|
|
3364
|
+
/* @__PURE__ */ jsx27("h2", { className: "adc-title", children: messages.listTitle }),
|
|
3365
|
+
renderExport && posts.data ? renderExport({
|
|
3366
|
+
total: posts.data.pagination.total,
|
|
3367
|
+
page: state.page,
|
|
3368
|
+
pageSize: list.pageSize,
|
|
3369
|
+
pageCount: posts.data.data.length,
|
|
3370
|
+
filters: buildExportFilters(list.state, tab)
|
|
3371
|
+
}) : null
|
|
3372
|
+
] }),
|
|
3373
|
+
/* @__PURE__ */ jsx27(
|
|
2630
3374
|
PostListToolbar,
|
|
2631
3375
|
{
|
|
2632
3376
|
search: state.search,
|
|
@@ -2639,8 +3383,8 @@ function PostList({
|
|
|
2639
3383
|
onCreate
|
|
2640
3384
|
}
|
|
2641
3385
|
),
|
|
2642
|
-
tab && /* @__PURE__ */
|
|
2643
|
-
list.selectedIds.size > 0 && /* @__PURE__ */
|
|
3386
|
+
tab && /* @__PURE__ */ jsx27(PostListTabs, { active: tab, counts: list.counts, onChange: list.setTab }),
|
|
3387
|
+
list.selectedIds.size > 0 && /* @__PURE__ */ jsx27(
|
|
2644
3388
|
BatchBar,
|
|
2645
3389
|
{
|
|
2646
3390
|
ids: [...list.selectedIds],
|
|
@@ -2649,10 +3393,10 @@ function PostList({
|
|
|
2649
3393
|
onDone: list.refresh
|
|
2650
3394
|
}
|
|
2651
3395
|
),
|
|
2652
|
-
posts.error !== void 0 && !posts.isLoading ? /* @__PURE__ */
|
|
3396
|
+
posts.error !== void 0 && !posts.isLoading ? /* @__PURE__ */ jsxs24("div", { className: "adc-state adc-state--error", role: "alert", children: [
|
|
2653
3397
|
messages.loadError,
|
|
2654
|
-
/* @__PURE__ */
|
|
2655
|
-
] }) : posts.isLoading && !posts.data ? /* @__PURE__ */
|
|
3398
|
+
/* @__PURE__ */ jsx27("button", { type: "button", className: "adc-button", onClick: posts.reload, children: messages.retry })
|
|
3399
|
+
] }) : posts.isLoading && !posts.data ? /* @__PURE__ */ jsx27("p", { className: "adc-state", role: "status", children: messages.loading }) : rows.length === 0 ? /* @__PURE__ */ jsx27("p", { className: "adc-state", children: tab === POST_LIST_TAB.TEMPLATES ? messages.emptyTemplates : messages.empty }) : /* @__PURE__ */ jsx27(
|
|
2656
3400
|
PostTable,
|
|
2657
3401
|
{
|
|
2658
3402
|
rows,
|
|
@@ -2665,21 +3409,21 @@ function PostList({
|
|
|
2665
3409
|
onSelect,
|
|
2666
3410
|
hasActions: Boolean(tab),
|
|
2667
3411
|
isBusy: posts.isLoading,
|
|
2668
|
-
renderActions: (post) => actionsFor(post).map(({ action, icon: Icon, label, tip }) => /* @__PURE__ */
|
|
3412
|
+
renderActions: (post) => actionsFor(post).map(({ action, icon: Icon, label, tip }) => /* @__PURE__ */ jsx27(Tooltip, { text: tip, children: /* @__PURE__ */ jsxs24(
|
|
2669
3413
|
"button",
|
|
2670
3414
|
{
|
|
2671
3415
|
type: "button",
|
|
2672
3416
|
className: "adc-button adc-button--compact",
|
|
2673
3417
|
onClick: () => setDialog({ action, post }),
|
|
2674
3418
|
children: [
|
|
2675
|
-
/* @__PURE__ */
|
|
3419
|
+
/* @__PURE__ */ jsx27(Icon, { "aria-hidden": "true", className: "adc-icon" }),
|
|
2676
3420
|
label
|
|
2677
3421
|
]
|
|
2678
3422
|
}
|
|
2679
3423
|
) }, action))
|
|
2680
3424
|
}
|
|
2681
3425
|
),
|
|
2682
|
-
posts.data && /* @__PURE__ */
|
|
3426
|
+
posts.data && /* @__PURE__ */ jsx27(
|
|
2683
3427
|
PostListFooter,
|
|
2684
3428
|
{
|
|
2685
3429
|
data: posts.data,
|
|
@@ -2689,10 +3433,10 @@ function PostList({
|
|
|
2689
3433
|
renderSelect
|
|
2690
3434
|
}
|
|
2691
3435
|
),
|
|
2692
|
-
tab === POST_LIST_TAB.TEMPLATES && /* @__PURE__ */
|
|
2693
|
-
dialog?.action === "saveAsTemplate" && /* @__PURE__ */
|
|
2694
|
-
dialog?.action === "fromTemplate" && /* @__PURE__ */
|
|
2695
|
-
dialog?.action === "republish" && /* @__PURE__ */
|
|
3436
|
+
tab === POST_LIST_TAB.TEMPLATES && /* @__PURE__ */ jsx27(RecurrencePanel, { templates: rows, renderDateTimeInput, renderSelect }),
|
|
3437
|
+
dialog?.action === "saveAsTemplate" && /* @__PURE__ */ jsx27(SaveAsTemplateDialog, { post: dialog.post, onClose: () => setDialog(void 0), onDone: handleActionDone }),
|
|
3438
|
+
dialog?.action === "fromTemplate" && /* @__PURE__ */ jsx27(FromTemplateDialog, { post: dialog.post, onClose: () => setDialog(void 0), onDone: handleActionDone }),
|
|
3439
|
+
dialog?.action === "republish" && /* @__PURE__ */ jsx27(
|
|
2696
3440
|
RepublishDialog,
|
|
2697
3441
|
{
|
|
2698
3442
|
post: dialog.post,
|
|
@@ -2705,7 +3449,7 @@ function PostList({
|
|
|
2705
3449
|
}
|
|
2706
3450
|
|
|
2707
3451
|
// src/components/ContentWorkspace.tsx
|
|
2708
|
-
import { jsx as
|
|
3452
|
+
import { jsx as jsx28 } from "react/jsx-runtime";
|
|
2709
3453
|
function ContentWorkspace({
|
|
2710
3454
|
pageSize,
|
|
2711
3455
|
newPostDefaults,
|
|
@@ -2713,17 +3457,18 @@ function ContentWorkspace({
|
|
|
2713
3457
|
renderDateTimeInput,
|
|
2714
3458
|
renderSelect,
|
|
2715
3459
|
syncUrl,
|
|
3460
|
+
renderExport,
|
|
2716
3461
|
showFormattingToolbar
|
|
2717
3462
|
}) {
|
|
2718
|
-
const [view, setView] =
|
|
2719
|
-
const [reloadKey, setReloadKey] =
|
|
3463
|
+
const [view, setView] = useState19({ kind: "list" });
|
|
3464
|
+
const [reloadKey, setReloadKey] = useState19(0);
|
|
2720
3465
|
function handleSaved(post) {
|
|
2721
3466
|
setReloadKey((value) => value + 1);
|
|
2722
3467
|
setView({ kind: "editor", postId: post.id });
|
|
2723
3468
|
onPostSaved?.(post);
|
|
2724
3469
|
}
|
|
2725
3470
|
if (view.kind === "editor") {
|
|
2726
|
-
return /* @__PURE__ */
|
|
3471
|
+
return /* @__PURE__ */ jsx28(
|
|
2727
3472
|
PostEditor,
|
|
2728
3473
|
{
|
|
2729
3474
|
...view.postId ? { postId: view.postId } : {},
|
|
@@ -2740,7 +3485,7 @@ function ContentWorkspace({
|
|
|
2740
3485
|
view.postId ?? "new"
|
|
2741
3486
|
);
|
|
2742
3487
|
}
|
|
2743
|
-
return /* @__PURE__ */
|
|
3488
|
+
return /* @__PURE__ */ jsx28(
|
|
2744
3489
|
PostList,
|
|
2745
3490
|
{
|
|
2746
3491
|
reloadKey,
|
|
@@ -2749,20 +3494,21 @@ function ContentWorkspace({
|
|
|
2749
3494
|
...syncUrl ? { syncUrl } : {},
|
|
2750
3495
|
...pageSize ? { pageSize } : {},
|
|
2751
3496
|
onSelect: (post) => setView({ kind: "editor", postId: post.id }),
|
|
2752
|
-
onCreate: () => setView({ kind: "editor" })
|
|
3497
|
+
onCreate: () => setView({ kind: "editor" }),
|
|
3498
|
+
...renderExport ? { renderExport } : {}
|
|
2753
3499
|
}
|
|
2754
3500
|
);
|
|
2755
3501
|
}
|
|
2756
3502
|
|
|
2757
3503
|
// src/components/PostCard.tsx
|
|
2758
3504
|
import { formatTagLabel as formatTagLabel2 } from "@adatechnology/content-contracts";
|
|
2759
|
-
import { jsx as
|
|
3505
|
+
import { jsx as jsx29, jsxs as jsxs25 } from "react/jsx-runtime";
|
|
2760
3506
|
function PostCard({ post, href, headingLevel = 2 }) {
|
|
2761
3507
|
const { messages, locale, format } = useContentText();
|
|
2762
3508
|
const renderLink = useRenderLink();
|
|
2763
3509
|
const Heading = `h${headingLevel}`;
|
|
2764
|
-
return /* @__PURE__ */
|
|
2765
|
-
post.coverImageUrl && /* @__PURE__ */
|
|
3510
|
+
return /* @__PURE__ */ jsxs25("article", { className: "adc-card", children: [
|
|
3511
|
+
post.coverImageUrl && /* @__PURE__ */ jsx29(
|
|
2766
3512
|
"img",
|
|
2767
3513
|
{
|
|
2768
3514
|
className: "adc-card-cover",
|
|
@@ -2772,23 +3518,23 @@ function PostCard({ post, href, headingLevel = 2 }) {
|
|
|
2772
3518
|
decoding: "async"
|
|
2773
3519
|
}
|
|
2774
3520
|
),
|
|
2775
|
-
/* @__PURE__ */
|
|
2776
|
-
/* @__PURE__ */
|
|
2777
|
-
/* @__PURE__ */
|
|
2778
|
-
/* @__PURE__ */
|
|
2779
|
-
/* @__PURE__ */
|
|
3521
|
+
/* @__PURE__ */ jsxs25("div", { className: "adc-card-body", children: [
|
|
3522
|
+
/* @__PURE__ */ jsx29(Heading, { className: "adc-card-title", children: renderLink({ href, className: "adc-card-link", children: post.title }) }),
|
|
3523
|
+
/* @__PURE__ */ jsxs25("p", { className: "adc-meta", children: [
|
|
3524
|
+
/* @__PURE__ */ jsx29("time", { dateTime: post.publishedAt, children: formatPostDate(post.publishedAt, locale) }),
|
|
3525
|
+
/* @__PURE__ */ jsx29("span", { "aria-hidden": "true", children: " \xB7 " }),
|
|
2780
3526
|
format("readingTime", { minutes: post.readingTimeMinutes })
|
|
2781
3527
|
] }),
|
|
2782
|
-
post.excerpt && /* @__PURE__ */
|
|
2783
|
-
post.tags.length > 0 && /* @__PURE__ */
|
|
2784
|
-
/* @__PURE__ */
|
|
3528
|
+
post.excerpt && /* @__PURE__ */ jsx29("p", { className: "adc-card-excerpt", children: post.excerpt }),
|
|
3529
|
+
post.tags.length > 0 && /* @__PURE__ */ jsx29("ul", { className: "adc-tag-list", children: post.tags.map((tag) => /* @__PURE__ */ jsx29("li", { className: "adc-tag", children: formatTagLabel2(tag, post.tagLabels) }, tag)) }),
|
|
3530
|
+
/* @__PURE__ */ jsx29("span", { className: "adc-card-more", "aria-hidden": "true", children: messages.readMore })
|
|
2785
3531
|
] })
|
|
2786
3532
|
] });
|
|
2787
3533
|
}
|
|
2788
3534
|
|
|
2789
3535
|
// src/components/PostListPage.tsx
|
|
2790
3536
|
import { formatTagLabel as formatTagLabel3 } from "@adatechnology/content-contracts";
|
|
2791
|
-
import { jsx as
|
|
3537
|
+
import { jsx as jsx30, jsxs as jsxs26 } from "react/jsx-runtime";
|
|
2792
3538
|
function PostListPage({ page = 1, tag, pageSize = 10, getPostHref, getListHref, title }) {
|
|
2793
3539
|
const api = useContentPublicApi();
|
|
2794
3540
|
const { messages } = useContentText();
|
|
@@ -2802,9 +3548,9 @@ function PostListPage({ page = 1, tag, pageSize = 10, getPostHref, getListHref,
|
|
|
2802
3548
|
"public-tags"
|
|
2803
3549
|
);
|
|
2804
3550
|
const withTag = (target) => getListHref({ page: target, ...tag ? { tag } : {} });
|
|
2805
|
-
return /* @__PURE__ */
|
|
2806
|
-
title && /* @__PURE__ */
|
|
2807
|
-
(tags.data?.length ?? 0) > 0 && /* @__PURE__ */
|
|
3551
|
+
return /* @__PURE__ */ jsxs26("section", { className: "adc-root adc-public-list", children: [
|
|
3552
|
+
title && /* @__PURE__ */ jsx30("h1", { className: "adc-page-title", children: title }),
|
|
3553
|
+
(tags.data?.length ?? 0) > 0 && /* @__PURE__ */ jsxs26("nav", { className: "adc-tag-filter", "aria-label": messages.tagsLabel, children: [
|
|
2808
3554
|
renderLink({
|
|
2809
3555
|
href: getListHref({ page: 1 }),
|
|
2810
3556
|
className: `adc-tag-chip${tag ? "" : " adc-tag-chip--active"}`,
|
|
@@ -2820,21 +3566,21 @@ function PostListPage({ page = 1, tag, pageSize = 10, getPostHref, getListHref,
|
|
|
2820
3566
|
})
|
|
2821
3567
|
)
|
|
2822
3568
|
] }),
|
|
2823
|
-
posts.isLoading && !posts.data ? /* @__PURE__ */
|
|
3569
|
+
posts.isLoading && !posts.data ? /* @__PURE__ */ jsx30("p", { className: "adc-state", role: "status", children: messages.loading }) : posts.error !== void 0 ? /* @__PURE__ */ jsxs26("div", { className: "adc-state adc-state--error", role: "alert", children: [
|
|
2824
3570
|
messages.loadError,
|
|
2825
|
-
/* @__PURE__ */
|
|
2826
|
-
] }) : (posts.data?.data.length ?? 0) === 0 ? /* @__PURE__ */
|
|
2827
|
-
posts.data && /* @__PURE__ */
|
|
3571
|
+
/* @__PURE__ */ jsx30("button", { type: "button", className: "adc-button", onClick: posts.reload, children: messages.retry })
|
|
3572
|
+
] }) : (posts.data?.data.length ?? 0) === 0 ? /* @__PURE__ */ jsx30("p", { className: "adc-state", children: messages.postsEmpty }) : /* @__PURE__ */ jsx30("div", { className: "adc-card-grid", children: posts.data?.data.map((post) => /* @__PURE__ */ jsx30(PostCard, { post, href: getPostHref(post.slug) }, post.id)) }),
|
|
3573
|
+
posts.data && /* @__PURE__ */ jsx30(Pagination, { page, totalPages: posts.data.pagination.totalPages, getPageHref: withTag })
|
|
2828
3574
|
] });
|
|
2829
3575
|
}
|
|
2830
3576
|
|
|
2831
3577
|
// src/components/PostPage.tsx
|
|
2832
3578
|
import { formatTagLabel as formatTagLabel4 } from "@adatechnology/content-contracts";
|
|
2833
|
-
import { useEffect as
|
|
3579
|
+
import { useEffect as useEffect10 } from "react";
|
|
2834
3580
|
|
|
2835
3581
|
// src/components/ShareButtons.tsx
|
|
2836
3582
|
import { Check as Check2, Link2, Share2 } from "lucide-react";
|
|
2837
|
-
import { useEffect as
|
|
3583
|
+
import { useEffect as useEffect9, useState as useState20 } from "react";
|
|
2838
3584
|
|
|
2839
3585
|
// src/lib/share.ts
|
|
2840
3586
|
var SHARE_NETWORK = {
|
|
@@ -2859,7 +3605,7 @@ function buildShareLinks(params) {
|
|
|
2859
3605
|
}
|
|
2860
3606
|
|
|
2861
3607
|
// src/components/ShareButtons.tsx
|
|
2862
|
-
import { jsx as
|
|
3608
|
+
import { jsx as jsx31, jsxs as jsxs27 } from "react/jsx-runtime";
|
|
2863
3609
|
var NETWORK_LABEL = {
|
|
2864
3610
|
[SHARE_NETWORK.WHATSAPP]: "shareWhatsApp",
|
|
2865
3611
|
[SHARE_NETWORK.FACEBOOK]: "shareFacebook",
|
|
@@ -2869,10 +3615,10 @@ var NETWORK_LABEL = {
|
|
|
2869
3615
|
var COPIED_FEEDBACK_MS = 2e3;
|
|
2870
3616
|
function ShareButtons({ url, title, networks }) {
|
|
2871
3617
|
const { messages, format } = useContentText();
|
|
2872
|
-
const [isCopied, setIsCopied] =
|
|
3618
|
+
const [isCopied, setIsCopied] = useState20(false);
|
|
2873
3619
|
const links = buildShareLinks({ url, title }).filter((link) => !networks || networks.includes(link.network));
|
|
2874
|
-
const [capabilities, setCapabilities] =
|
|
2875
|
-
|
|
3620
|
+
const [capabilities, setCapabilities] = useState20({ canShareNatively: false, canCopy: false });
|
|
3621
|
+
useEffect9(() => {
|
|
2876
3622
|
setCapabilities({
|
|
2877
3623
|
canShareNatively: typeof navigator.share === "function",
|
|
2878
3624
|
canCopy: Boolean(navigator.clipboard)
|
|
@@ -2884,21 +3630,21 @@ function ShareButtons({ url, title, networks }) {
|
|
|
2884
3630
|
setIsCopied(true);
|
|
2885
3631
|
window.setTimeout(() => setIsCopied(false), COPIED_FEEDBACK_MS);
|
|
2886
3632
|
}
|
|
2887
|
-
return /* @__PURE__ */
|
|
2888
|
-
/* @__PURE__ */
|
|
2889
|
-
canShareNatively && /* @__PURE__ */
|
|
3633
|
+
return /* @__PURE__ */ jsxs27("div", { className: "adc-share", role: "group", "aria-label": messages.shareLabel, children: [
|
|
3634
|
+
/* @__PURE__ */ jsx31("span", { className: "adc-label", children: messages.shareLabel }),
|
|
3635
|
+
canShareNatively && /* @__PURE__ */ jsxs27(
|
|
2890
3636
|
"button",
|
|
2891
3637
|
{
|
|
2892
3638
|
type: "button",
|
|
2893
3639
|
className: "adc-button",
|
|
2894
3640
|
onClick: () => void navigator.share({ url, title }).catch(() => void 0),
|
|
2895
3641
|
children: [
|
|
2896
|
-
/* @__PURE__ */
|
|
3642
|
+
/* @__PURE__ */ jsx31(Share2, { "aria-hidden": "true", className: "adc-icon" }),
|
|
2897
3643
|
messages.shareNative
|
|
2898
3644
|
]
|
|
2899
3645
|
}
|
|
2900
3646
|
),
|
|
2901
|
-
links.map((link) => /* @__PURE__ */
|
|
3647
|
+
links.map((link) => /* @__PURE__ */ jsx31(
|
|
2902
3648
|
"a",
|
|
2903
3649
|
{
|
|
2904
3650
|
className: `adc-button adc-share-link adc-share-link--${link.network}`,
|
|
@@ -2910,48 +3656,48 @@ function ShareButtons({ url, title, networks }) {
|
|
|
2910
3656
|
},
|
|
2911
3657
|
link.network
|
|
2912
3658
|
)),
|
|
2913
|
-
canCopy && /* @__PURE__ */
|
|
2914
|
-
isCopied ? /* @__PURE__ */
|
|
2915
|
-
/* @__PURE__ */
|
|
3659
|
+
canCopy && /* @__PURE__ */ jsxs27("button", { type: "button", className: "adc-button", onClick: () => void handleCopy().catch(() => void 0), children: [
|
|
3660
|
+
isCopied ? /* @__PURE__ */ jsx31(Check2, { "aria-hidden": "true", className: "adc-icon" }) : /* @__PURE__ */ jsx31(Link2, { "aria-hidden": "true", className: "adc-icon" }),
|
|
3661
|
+
/* @__PURE__ */ jsx31("span", { "aria-live": "polite", children: isCopied ? messages.linkCopied : messages.copyLink })
|
|
2916
3662
|
] })
|
|
2917
3663
|
] });
|
|
2918
3664
|
}
|
|
2919
3665
|
|
|
2920
3666
|
// src/components/PostPage.tsx
|
|
2921
|
-
import { Fragment, jsx as
|
|
3667
|
+
import { Fragment, jsx as jsx32, jsxs as jsxs28 } from "react/jsx-runtime";
|
|
2922
3668
|
function PostPage({ slug, shareUrl, shareNetworks, getTagHref, onLoaded, renderNotFound }) {
|
|
2923
3669
|
const api = useContentPublicApi();
|
|
2924
3670
|
const { messages, locale, format } = useContentText();
|
|
2925
3671
|
const renderLink = useRenderLink();
|
|
2926
3672
|
const resource = useAsyncResource(() => api.getPublishedPost(slug), slug);
|
|
2927
3673
|
const post = resource.data;
|
|
2928
|
-
|
|
3674
|
+
useEffect10(() => {
|
|
2929
3675
|
if (post) onLoaded?.(post);
|
|
2930
3676
|
}, [post, onLoaded]);
|
|
2931
3677
|
if (resource.isLoading && !post) {
|
|
2932
|
-
return /* @__PURE__ */
|
|
3678
|
+
return /* @__PURE__ */ jsx32("p", { className: "adc-root adc-state", role: "status", children: messages.loading });
|
|
2933
3679
|
}
|
|
2934
3680
|
if (!post) {
|
|
2935
|
-
return /* @__PURE__ */
|
|
3681
|
+
return /* @__PURE__ */ jsx32(Fragment, { children: renderNotFound ? renderNotFound() : /* @__PURE__ */ jsx32("p", { className: "adc-root adc-state", children: messages.notFound }) });
|
|
2936
3682
|
}
|
|
2937
3683
|
const url = shareUrl ?? (typeof window !== "undefined" ? window.location.href : "");
|
|
2938
|
-
return /* @__PURE__ */
|
|
2939
|
-
/* @__PURE__ */
|
|
2940
|
-
/* @__PURE__ */
|
|
2941
|
-
/* @__PURE__ */
|
|
2942
|
-
/* @__PURE__ */
|
|
2943
|
-
/* @__PURE__ */
|
|
3684
|
+
return /* @__PURE__ */ jsxs28("article", { className: "adc-root adc-post", children: [
|
|
3685
|
+
/* @__PURE__ */ jsxs28("header", { className: "adc-post-header", children: [
|
|
3686
|
+
/* @__PURE__ */ jsx32("h1", { className: "adc-page-title", children: post.title }),
|
|
3687
|
+
/* @__PURE__ */ jsxs28("p", { className: "adc-meta", children: [
|
|
3688
|
+
/* @__PURE__ */ jsx32("time", { dateTime: post.publishedAt, children: formatPostDate(post.publishedAt, locale) }),
|
|
3689
|
+
/* @__PURE__ */ jsx32("span", { "aria-hidden": "true", children: " \xB7 " }),
|
|
2944
3690
|
format("readingTime", { minutes: post.readingTimeMinutes }),
|
|
2945
|
-
post.authorName && /* @__PURE__ */
|
|
2946
|
-
/* @__PURE__ */
|
|
3691
|
+
post.authorName && /* @__PURE__ */ jsxs28(Fragment, { children: [
|
|
3692
|
+
/* @__PURE__ */ jsx32("span", { "aria-hidden": "true", children: " \xB7 " }),
|
|
2947
3693
|
format("byAuthor", { author: post.authorName })
|
|
2948
3694
|
] })
|
|
2949
3695
|
] }),
|
|
2950
|
-
post.tags.length > 0 && /* @__PURE__ */
|
|
3696
|
+
post.tags.length > 0 && /* @__PURE__ */ jsx32("ul", { className: "adc-tag-list", children: post.tags.map((tag) => /* @__PURE__ */ jsx32("li", { className: "adc-tag", children: getTagHref ? renderLink({ href: getTagHref(tag), children: formatTagLabel4(tag, post.tagLabels) }) : formatTagLabel4(tag, post.tagLabels) }, tag)) })
|
|
2951
3697
|
] }),
|
|
2952
|
-
post.coverImageUrl && /* @__PURE__ */
|
|
2953
|
-
/* @__PURE__ */
|
|
2954
|
-
url && shareNetworks?.length !== 0 && /* @__PURE__ */
|
|
3698
|
+
post.coverImageUrl && /* @__PURE__ */ jsx32("img", { className: "adc-post-cover", src: post.coverImageUrl, alt: post.coverImageAlt ?? "", decoding: "async" }),
|
|
3699
|
+
/* @__PURE__ */ jsx32(MarkdownContent, { markdown: post.body, headingLevelOffset: 1 }),
|
|
3700
|
+
url && shareNetworks?.length !== 0 && /* @__PURE__ */ jsx32(ShareButtons, { url, title: post.title, ...shareNetworks ? { networks: shareNetworks } : {} })
|
|
2955
3701
|
] });
|
|
2956
3702
|
}
|
|
2957
3703
|
|