@adatechnology/content-ui 0.1.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +41 -0
- package/dist/index.d.ts +398 -47
- package/dist/index.js +1846 -302
- package/dist/index.js.map +1 -1
- package/dist/styles.css +410 -2
- package/dist/styles.css.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -65,7 +65,7 @@ var en_default = {
|
|
|
65
65
|
unpublish: "Unpublish",
|
|
66
66
|
archive: "Archive",
|
|
67
67
|
archiveConfirm: "Archive this post? It will leave the site.",
|
|
68
|
-
close: "
|
|
68
|
+
close: "Close",
|
|
69
69
|
unsavedConfirm: "You have unsaved changes. Leave anyway?",
|
|
70
70
|
unsavedBadge: "Unsaved changes",
|
|
71
71
|
saveError: "Could not save.",
|
|
@@ -91,7 +91,89 @@ var en_default = {
|
|
|
91
91
|
shareOn: "Share on {network}",
|
|
92
92
|
notFound: "Post not found.",
|
|
93
93
|
postsEmpty: "No posts published yet.",
|
|
94
|
-
clearFilters: "Clear filters"
|
|
94
|
+
clearFilters: "Clear filters",
|
|
95
|
+
statusTemplate: "Template",
|
|
96
|
+
tabsLabel: "Post status",
|
|
97
|
+
tabPublished: "Published",
|
|
98
|
+
tabScheduled: "Scheduled",
|
|
99
|
+
tabDraft: "Drafts",
|
|
100
|
+
tabTemplates: "Templates",
|
|
101
|
+
columnActions: "Actions",
|
|
102
|
+
dialogCancel: "Cancel",
|
|
103
|
+
actionError: "Could not finish. Try again.",
|
|
104
|
+
emptyTemplates: "No templates yet. On any post, use \u201CSave as template\u201D.",
|
|
105
|
+
saveAsTemplate: "Save as template",
|
|
106
|
+
saveAsTemplateTip: "Makes a reusable copy. The original post does not change.",
|
|
107
|
+
templateNameLabel: "Template name",
|
|
108
|
+
newFromTemplate: "New from template",
|
|
109
|
+
newFromTemplateTip: "Creates a draft with the template content.",
|
|
110
|
+
newPostTitleLabel: "New post title",
|
|
111
|
+
createDraft: "Create draft",
|
|
112
|
+
republish: "Republish",
|
|
113
|
+
republishTip: "Changes the date and keeps the same link: the right way for search engines.",
|
|
114
|
+
republishDateLabel: "New publish date",
|
|
115
|
+
republishHint: "The post address does not change. Use now or a past date: a future date would take the post offline.",
|
|
116
|
+
recurrenceTitle: "Automatic publishing",
|
|
117
|
+
recurrenceNew: "New recurrence",
|
|
118
|
+
recurrenceCreate: "Create recurrence",
|
|
119
|
+
recurrenceTemplate: "Template",
|
|
120
|
+
recurrenceFrequency: "Repeats",
|
|
121
|
+
recurrenceStart: "First publication",
|
|
122
|
+
frequencyWeekly: "Every week",
|
|
123
|
+
frequencyMonthly: "Every month",
|
|
124
|
+
recurrenceHint: "On each date a new post is published automatically from the template.",
|
|
125
|
+
recurrenceNext: "next {date}",
|
|
126
|
+
recurrenceActive: "Active",
|
|
127
|
+
recurrencePaused: "Paused",
|
|
128
|
+
recurrencePause: "Pause",
|
|
129
|
+
recurrenceResume: "Resume",
|
|
130
|
+
recurrenceRemove: "Delete rule",
|
|
131
|
+
recurrenceRemoveTip: "Deletes only the rule. Posts already published stay online.",
|
|
132
|
+
recurrenceEmpty: "No recurrences. Create one to publish by itself every week or month.",
|
|
133
|
+
recurrenceNeedsTemplate: "Create a template first to schedule automatic publishing.",
|
|
134
|
+
selectAll: "Select all",
|
|
135
|
+
selectRow: "Select {title}",
|
|
136
|
+
selectedCount: "Selected: {count}",
|
|
137
|
+
clearSelection: "Clear selection",
|
|
138
|
+
batchLabel: "Batch actions",
|
|
139
|
+
batchPublish: "Publish",
|
|
140
|
+
batchUnpublish: "Unpublish",
|
|
141
|
+
batchArchive: "Delete",
|
|
142
|
+
batchArchiveConfirm: "Delete {count} posts? They leave the site; the content stays archived.",
|
|
143
|
+
batchPartial: "Only {done} of {total} done. Try again for the rest.",
|
|
144
|
+
itemsPerPage: "Per page",
|
|
145
|
+
rangeLabel: "{from}\u2013{to} of {total}",
|
|
146
|
+
bodyHintToolbar: "Select text and use the buttons above. Shortcuts: Ctrl+B bold, Ctrl+I italic, Ctrl+K link.",
|
|
147
|
+
toolbarLabel: "Text formatting",
|
|
148
|
+
formatBold: "Bold",
|
|
149
|
+
formatItalic: "Italic",
|
|
150
|
+
formatHeading2: "Heading",
|
|
151
|
+
formatHeading3: "Subheading",
|
|
152
|
+
formatBulletList: "Bulleted list",
|
|
153
|
+
formatNumberedList: "Numbered list",
|
|
154
|
+
formatQuote: "Quote",
|
|
155
|
+
formatLink: "Link",
|
|
156
|
+
formatImage: "Image",
|
|
157
|
+
formatEmoji: "Emoji",
|
|
158
|
+
formatSampleText: "text",
|
|
159
|
+
linkDialogTitle: "Insert link",
|
|
160
|
+
linkUrl: "Link address (URL)",
|
|
161
|
+
linkText: "Link text",
|
|
162
|
+
imageDialogTitle: "Insert image",
|
|
163
|
+
imageUploadFromDevice: "Upload from device",
|
|
164
|
+
dialogInsert: "Insert",
|
|
165
|
+
fileNoneChosen: "No file chosen",
|
|
166
|
+
emojiTitle: "Choose emoji",
|
|
167
|
+
emojiSearch: "Search emoji",
|
|
168
|
+
emojiCategories: "Emoji categories",
|
|
169
|
+
emojiEmpty: "No emoji found.",
|
|
170
|
+
emojiSmileys: "Faces",
|
|
171
|
+
emojiGestures: "Gestures",
|
|
172
|
+
emojiFood: "Food",
|
|
173
|
+
emojiNature: "Nature",
|
|
174
|
+
emojiTravel: "Places",
|
|
175
|
+
emojiObjects: "Objects",
|
|
176
|
+
emojiSymbols: "Symbols"
|
|
95
177
|
};
|
|
96
178
|
|
|
97
179
|
// src/locales/pt-BR.json
|
|
@@ -158,7 +240,7 @@ var pt_BR_default = {
|
|
|
158
240
|
unpublish: "Despublicar",
|
|
159
241
|
archive: "Arquivar",
|
|
160
242
|
archiveConfirm: "Arquivar este post? Ele sai do site.",
|
|
161
|
-
close: "
|
|
243
|
+
close: "Fechar",
|
|
162
244
|
unsavedConfirm: "H\xE1 altera\xE7\xF5es n\xE3o salvas. Sair mesmo assim?",
|
|
163
245
|
unsavedBadge: "Altera\xE7\xF5es n\xE3o salvas",
|
|
164
246
|
saveError: "N\xE3o foi poss\xEDvel salvar.",
|
|
@@ -184,7 +266,89 @@ var pt_BR_default = {
|
|
|
184
266
|
shareOn: "Compartilhar no {network}",
|
|
185
267
|
notFound: "Post n\xE3o encontrado.",
|
|
186
268
|
postsEmpty: "Nenhum post publicado ainda.",
|
|
187
|
-
clearFilters: "Limpar filtros"
|
|
269
|
+
clearFilters: "Limpar filtros",
|
|
270
|
+
statusTemplate: "Modelo",
|
|
271
|
+
tabsLabel: "Situa\xE7\xE3o dos posts",
|
|
272
|
+
tabPublished: "Publicados",
|
|
273
|
+
tabScheduled: "Agendados",
|
|
274
|
+
tabDraft: "Rascunhos",
|
|
275
|
+
tabTemplates: "Modelos",
|
|
276
|
+
columnActions: "A\xE7\xF5es",
|
|
277
|
+
dialogCancel: "Cancelar",
|
|
278
|
+
actionError: "N\xE3o foi poss\xEDvel concluir. Tente de novo.",
|
|
279
|
+
emptyTemplates: "Nenhum modelo ainda. Em qualquer post, use \u201CSalvar como modelo\u201D.",
|
|
280
|
+
saveAsTemplate: "Salvar como modelo",
|
|
281
|
+
saveAsTemplateTip: "Cria uma c\xF3pia reutiliz\xE1vel. O post original n\xE3o muda.",
|
|
282
|
+
templateNameLabel: "Nome do modelo",
|
|
283
|
+
newFromTemplate: "Novo a partir do modelo",
|
|
284
|
+
newFromTemplateTip: "Cria um rascunho com o conte\xFAdo do modelo.",
|
|
285
|
+
newPostTitleLabel: "T\xEDtulo do novo post",
|
|
286
|
+
createDraft: "Criar rascunho",
|
|
287
|
+
republish: "Republicar",
|
|
288
|
+
republishTip: "Muda a data e mant\xE9m o mesmo link: o jeito certo para buscadores.",
|
|
289
|
+
republishDateLabel: "Nova data de publica\xE7\xE3o",
|
|
290
|
+
republishHint: "O endere\xE7o do post n\xE3o muda. Use agora ou uma data passada: data futura tiraria o post do ar.",
|
|
291
|
+
recurrenceTitle: "Publica\xE7\xE3o autom\xE1tica",
|
|
292
|
+
recurrenceNew: "Nova recorr\xEAncia",
|
|
293
|
+
recurrenceCreate: "Criar recorr\xEAncia",
|
|
294
|
+
recurrenceTemplate: "Modelo",
|
|
295
|
+
recurrenceFrequency: "Repete",
|
|
296
|
+
recurrenceStart: "Primeira publica\xE7\xE3o",
|
|
297
|
+
frequencyWeekly: "Toda semana",
|
|
298
|
+
frequencyMonthly: "Todo m\xEAs",
|
|
299
|
+
recurrenceHint: "A cada data, um post novo \xE9 publicado sozinho a partir do modelo.",
|
|
300
|
+
recurrenceNext: "pr\xF3xima {date}",
|
|
301
|
+
recurrenceActive: "Ativa",
|
|
302
|
+
recurrencePaused: "Pausada",
|
|
303
|
+
recurrencePause: "Pausar",
|
|
304
|
+
recurrenceResume: "Retomar",
|
|
305
|
+
recurrenceRemove: "Apagar regra",
|
|
306
|
+
recurrenceRemoveTip: "Apaga s\xF3 a regra. Os posts j\xE1 publicados continuam no ar.",
|
|
307
|
+
recurrenceEmpty: "Nenhuma recorr\xEAncia. Crie uma para publicar sozinho toda semana ou m\xEAs.",
|
|
308
|
+
recurrenceNeedsTemplate: "Crie um modelo primeiro para agendar publica\xE7\xF5es autom\xE1ticas.",
|
|
309
|
+
selectAll: "Selecionar todos",
|
|
310
|
+
selectRow: "Selecionar {title}",
|
|
311
|
+
selectedCount: "Selecionados: {count}",
|
|
312
|
+
clearSelection: "Limpar sele\xE7\xE3o",
|
|
313
|
+
batchLabel: "A\xE7\xF5es em lote",
|
|
314
|
+
batchPublish: "Publicar",
|
|
315
|
+
batchUnpublish: "Despublicar",
|
|
316
|
+
batchArchive: "Excluir",
|
|
317
|
+
batchArchiveConfirm: "Excluir {count} posts? Eles saem do site; o conte\xFAdo fica arquivado.",
|
|
318
|
+
batchPartial: "S\xF3 {done} de {total} conclu\xEDdos. Tente de novo nos demais.",
|
|
319
|
+
itemsPerPage: "Por p\xE1gina",
|
|
320
|
+
rangeLabel: "{from}\u2013{to} de {total}",
|
|
321
|
+
bodyHintToolbar: "Selecione o texto e use os bot\xF5es acima. Atalhos: Ctrl+B negrito, Ctrl+I it\xE1lico, Ctrl+K link.",
|
|
322
|
+
toolbarLabel: "Formata\xE7\xE3o do texto",
|
|
323
|
+
formatBold: "Negrito",
|
|
324
|
+
formatItalic: "It\xE1lico",
|
|
325
|
+
formatHeading2: "T\xEDtulo",
|
|
326
|
+
formatHeading3: "Subt\xEDtulo",
|
|
327
|
+
formatBulletList: "Lista com marcadores",
|
|
328
|
+
formatNumberedList: "Lista numerada",
|
|
329
|
+
formatQuote: "Cita\xE7\xE3o",
|
|
330
|
+
formatLink: "Link",
|
|
331
|
+
formatImage: "Imagem",
|
|
332
|
+
formatEmoji: "Emoji",
|
|
333
|
+
formatSampleText: "texto",
|
|
334
|
+
linkDialogTitle: "Inserir link",
|
|
335
|
+
linkUrl: "Endere\xE7o do link (URL)",
|
|
336
|
+
linkText: "Texto do link",
|
|
337
|
+
imageDialogTitle: "Inserir imagem",
|
|
338
|
+
imageUploadFromDevice: "Enviar do aparelho",
|
|
339
|
+
dialogInsert: "Inserir",
|
|
340
|
+
fileNoneChosen: "Nenhum arquivo escolhido",
|
|
341
|
+
emojiTitle: "Escolher emoji",
|
|
342
|
+
emojiSearch: "Buscar emoji",
|
|
343
|
+
emojiCategories: "Categorias de emoji",
|
|
344
|
+
emojiEmpty: "Nenhum emoji encontrado.",
|
|
345
|
+
emojiSmileys: "Rostos",
|
|
346
|
+
emojiGestures: "Gestos",
|
|
347
|
+
emojiFood: "Comida",
|
|
348
|
+
emojiNature: "Natureza",
|
|
349
|
+
emojiTravel: "Lugares",
|
|
350
|
+
emojiObjects: "Objetos",
|
|
351
|
+
emojiSymbols: "S\xEDmbolos"
|
|
188
352
|
};
|
|
189
353
|
|
|
190
354
|
// src/locales/index.ts
|
|
@@ -250,11 +414,11 @@ function useRenderLink() {
|
|
|
250
414
|
}
|
|
251
415
|
|
|
252
416
|
// src/components/ContentWorkspace.tsx
|
|
253
|
-
import { useState as
|
|
417
|
+
import { useState as useState15 } from "react";
|
|
254
418
|
|
|
255
419
|
// src/components/PostEditor.tsx
|
|
256
|
-
import { Archive as Archive2, ArrowLeft, CalendarClock as CalendarClock2, EyeOff,
|
|
257
|
-
import { useId as
|
|
420
|
+
import { Archive as Archive2, ArrowLeft, CalendarClock as CalendarClock2, EyeOff, Save, Send, Trash2 } from "lucide-react";
|
|
421
|
+
import { useId as useId5, useState as useState9 } from "react";
|
|
258
422
|
|
|
259
423
|
// src/hooks/usePostEditor.ts
|
|
260
424
|
import { useCallback as useCallback2, useEffect as useEffect2, useMemo as useMemo2, useState as useState2 } from "react";
|
|
@@ -484,20 +648,25 @@ function usePostEditor(params) {
|
|
|
484
648
|
setIsBusy(false);
|
|
485
649
|
}
|
|
486
650
|
}
|
|
487
|
-
async function
|
|
488
|
-
if (!api.uploadCoverImage) return;
|
|
489
|
-
if (!COVER_MIME_TYPES.includes(file.type)) return
|
|
490
|
-
if (file.size > COVER_MAX_BYTES) return
|
|
651
|
+
async function uploadImage(file) {
|
|
652
|
+
if (!api.uploadCoverImage) return { error: "coverUploadError" };
|
|
653
|
+
if (!COVER_MIME_TYPES.includes(file.type)) return { error: "coverInvalidType" };
|
|
654
|
+
if (file.size > COVER_MAX_BYTES) return { error: "coverTooLarge" };
|
|
491
655
|
setIsUploading(true);
|
|
492
656
|
try {
|
|
493
657
|
const { url } = await api.uploadCoverImage(file);
|
|
494
|
-
|
|
658
|
+
return { url };
|
|
495
659
|
} catch {
|
|
496
|
-
|
|
660
|
+
return { error: "coverUploadError" };
|
|
497
661
|
} finally {
|
|
498
662
|
setIsUploading(false);
|
|
499
663
|
}
|
|
500
664
|
}
|
|
665
|
+
async function uploadCover(file) {
|
|
666
|
+
const result = await uploadImage(file);
|
|
667
|
+
if ("error" in result) return setFeedback(result.error);
|
|
668
|
+
update("coverImageUrl", result.url);
|
|
669
|
+
}
|
|
501
670
|
return {
|
|
502
671
|
post,
|
|
503
672
|
draft,
|
|
@@ -517,7 +686,8 @@ function usePostEditor(params) {
|
|
|
517
686
|
schedule,
|
|
518
687
|
unpublish,
|
|
519
688
|
archive,
|
|
520
|
-
uploadCover
|
|
689
|
+
uploadCover,
|
|
690
|
+
uploadImage
|
|
521
691
|
};
|
|
522
692
|
}
|
|
523
693
|
|
|
@@ -537,6 +707,38 @@ function useUnsavedChangesGuard(isDirty, message) {
|
|
|
537
707
|
return { confirmLeave };
|
|
538
708
|
}
|
|
539
709
|
|
|
710
|
+
// src/components/FilePicker.tsx
|
|
711
|
+
import { ImageUp } from "lucide-react";
|
|
712
|
+
import { useRef as useRef2, useState as useState3 } from "react";
|
|
713
|
+
import { jsx as jsx2, jsxs } from "react/jsx-runtime";
|
|
714
|
+
function FilePicker({ buttonLabel, emptyLabel, accept, isBusy = false, onPick }) {
|
|
715
|
+
const inputRef = useRef2(null);
|
|
716
|
+
const [fileName, setFileName] = useState3("");
|
|
717
|
+
return /* @__PURE__ */ jsxs("div", { className: "adc-file-picker", children: [
|
|
718
|
+
/* @__PURE__ */ jsxs("button", { type: "button", className: "adc-button", disabled: isBusy, onClick: () => inputRef.current?.click(), children: [
|
|
719
|
+
/* @__PURE__ */ jsx2(ImageUp, { "aria-hidden": "true", className: "adc-icon" }),
|
|
720
|
+
buttonLabel
|
|
721
|
+
] }),
|
|
722
|
+
/* @__PURE__ */ jsx2("span", { className: "adc-file-name", "aria-live": "polite", children: fileName || emptyLabel }),
|
|
723
|
+
/* @__PURE__ */ jsx2(
|
|
724
|
+
"input",
|
|
725
|
+
{
|
|
726
|
+
ref: inputRef,
|
|
727
|
+
hidden: true,
|
|
728
|
+
type: "file",
|
|
729
|
+
accept,
|
|
730
|
+
onChange: (event) => {
|
|
731
|
+
const file = event.target.files?.[0];
|
|
732
|
+
event.target.value = "";
|
|
733
|
+
if (!file) return;
|
|
734
|
+
setFileName(file.name);
|
|
735
|
+
onPick(file);
|
|
736
|
+
}
|
|
737
|
+
}
|
|
738
|
+
)
|
|
739
|
+
] });
|
|
740
|
+
}
|
|
741
|
+
|
|
540
742
|
// src/components/MarkdownContent.tsx
|
|
541
743
|
import {
|
|
542
744
|
createHeadingIdGenerator,
|
|
@@ -547,26 +749,26 @@ import {
|
|
|
547
749
|
resolveHeadingLevel
|
|
548
750
|
} from "@adatechnology/content-contracts";
|
|
549
751
|
import { useMemo as useMemo3 } from "react";
|
|
550
|
-
import { jsx as
|
|
752
|
+
import { jsx as jsx3 } from "react/jsx-runtime";
|
|
551
753
|
function renderInline(nodes) {
|
|
552
754
|
return nodes.map((node, index) => {
|
|
553
755
|
switch (node.type) {
|
|
554
756
|
case "text":
|
|
555
757
|
return node.value;
|
|
556
758
|
case "strong":
|
|
557
|
-
return /* @__PURE__ */
|
|
759
|
+
return /* @__PURE__ */ jsx3("strong", { children: renderInline(node.children) }, index);
|
|
558
760
|
case "emphasis":
|
|
559
|
-
return /* @__PURE__ */
|
|
761
|
+
return /* @__PURE__ */ jsx3("em", { children: renderInline(node.children) }, index);
|
|
560
762
|
case "strikethrough":
|
|
561
|
-
return /* @__PURE__ */
|
|
763
|
+
return /* @__PURE__ */ jsx3("del", { children: renderInline(node.children) }, index);
|
|
562
764
|
case "inlineCode":
|
|
563
|
-
return /* @__PURE__ */
|
|
765
|
+
return /* @__PURE__ */ jsx3("code", { children: node.value }, index);
|
|
564
766
|
case "break":
|
|
565
|
-
return /* @__PURE__ */
|
|
767
|
+
return /* @__PURE__ */ jsx3("br", {}, index);
|
|
566
768
|
case "image":
|
|
567
|
-
return /* @__PURE__ */
|
|
769
|
+
return /* @__PURE__ */ jsx3("img", { src: node.src, alt: node.alt, title: node.title, loading: "lazy", decoding: "async" }, index);
|
|
568
770
|
case "link":
|
|
569
|
-
return /* @__PURE__ */
|
|
771
|
+
return /* @__PURE__ */ jsx3(
|
|
570
772
|
"a",
|
|
571
773
|
{
|
|
572
774
|
href: node.href,
|
|
@@ -584,43 +786,532 @@ function renderBlock(block, key, context, tight = false) {
|
|
|
584
786
|
switch (block.type) {
|
|
585
787
|
case "heading": {
|
|
586
788
|
const Tag = `h${resolveHeadingLevel(block.level, context.offset)}`;
|
|
587
|
-
return /* @__PURE__ */
|
|
789
|
+
return /* @__PURE__ */ jsx3(Tag, { id: context.nextHeadingId(inlineToPlainText(block.children)), children: renderInline(block.children) }, key);
|
|
588
790
|
}
|
|
589
791
|
case "paragraph":
|
|
590
|
-
return tight ? /* @__PURE__ */
|
|
792
|
+
return tight ? /* @__PURE__ */ jsx3("span", { children: renderInline(block.children) }, key) : /* @__PURE__ */ jsx3("p", { children: renderInline(block.children) }, key);
|
|
591
793
|
case "blockquote":
|
|
592
|
-
return /* @__PURE__ */
|
|
794
|
+
return /* @__PURE__ */ jsx3("blockquote", { children: block.children.map((child, index) => renderBlock(child, index, context)) }, key);
|
|
593
795
|
case "codeBlock":
|
|
594
|
-
return /* @__PURE__ */
|
|
796
|
+
return /* @__PURE__ */ jsx3("pre", { children: /* @__PURE__ */ jsx3("code", { className: block.language ? `language-${block.language}` : void 0, children: block.value }) }, key);
|
|
595
797
|
case "thematicBreak":
|
|
596
|
-
return /* @__PURE__ */
|
|
798
|
+
return /* @__PURE__ */ jsx3("hr", {}, key);
|
|
597
799
|
case "list": {
|
|
598
|
-
const items = block.items.map((item, index) => /* @__PURE__ */
|
|
599
|
-
return block.ordered ? /* @__PURE__ */
|
|
800
|
+
const items = block.items.map((item, index) => /* @__PURE__ */ jsx3("li", { children: item.map((child, childIndex) => renderBlock(child, childIndex, context, block.tight)) }, index));
|
|
801
|
+
return block.ordered ? /* @__PURE__ */ jsx3("ol", { start: block.start, children: items }, key) : /* @__PURE__ */ jsx3("ul", { children: items }, key);
|
|
600
802
|
}
|
|
601
803
|
}
|
|
602
804
|
}
|
|
603
805
|
function MarkdownContent({ markdown, headingLevelOffset = 0, className }) {
|
|
604
|
-
const
|
|
806
|
+
const document2 = useMemo3(() => parseMarkdown(markdown), [markdown]);
|
|
605
807
|
const context = { offset: headingLevelOffset, nextHeadingId: createHeadingIdGenerator() };
|
|
606
|
-
return /* @__PURE__ */
|
|
808
|
+
return /* @__PURE__ */ jsx3("div", { className: ["adc-prose", className].filter(Boolean).join(" "), children: document2.children.map((block, index) => renderBlock(block, index, context)) });
|
|
809
|
+
}
|
|
810
|
+
|
|
811
|
+
// src/components/MarkdownEditor.tsx
|
|
812
|
+
import {
|
|
813
|
+
Bold,
|
|
814
|
+
Heading2,
|
|
815
|
+
Heading3,
|
|
816
|
+
Image as ImageIcon,
|
|
817
|
+
Italic,
|
|
818
|
+
Link as LinkIcon,
|
|
819
|
+
List,
|
|
820
|
+
ListOrdered,
|
|
821
|
+
Quote,
|
|
822
|
+
Smile
|
|
823
|
+
} from "lucide-react";
|
|
824
|
+
import { useLayoutEffect, useRef as useRef3, useState as useState7 } from "react";
|
|
825
|
+
|
|
826
|
+
// src/lib/markdownFormat.ts
|
|
827
|
+
var LINE_PREFIX_PATTERN = {
|
|
828
|
+
heading2: /^## /,
|
|
829
|
+
heading3: /^### /,
|
|
830
|
+
bulletList: /^[-*+] /,
|
|
831
|
+
numberedList: /^\d+\. /,
|
|
832
|
+
quote: /^> /
|
|
833
|
+
};
|
|
834
|
+
var ANY_BLOCK_PREFIX = /^(#{1,6} |[-*+] |\d+\. |> )/;
|
|
835
|
+
function replaceRange(source, from, to, text, select) {
|
|
836
|
+
return {
|
|
837
|
+
value: source.value.slice(0, from) + text + source.value.slice(to),
|
|
838
|
+
start: from + select[0],
|
|
839
|
+
end: from + select[1]
|
|
840
|
+
};
|
|
841
|
+
}
|
|
842
|
+
function insertText(source, text) {
|
|
843
|
+
return replaceRange(source, source.start, source.end, text, [text.length, text.length]);
|
|
844
|
+
}
|
|
845
|
+
function toggleWrap(source, marker, placeholder) {
|
|
846
|
+
const { value, start, end } = source;
|
|
847
|
+
const selected = value.slice(start, end);
|
|
848
|
+
const isWrappedOutside = value.slice(start - marker.length, start) === marker && value.slice(end, end + marker.length) === marker;
|
|
849
|
+
if (isWrappedOutside && start >= marker.length) {
|
|
850
|
+
return replaceRange(source, start - marker.length, end + marker.length, selected, [0, selected.length]);
|
|
851
|
+
}
|
|
852
|
+
const isWrappedInside = selected.length > marker.length * 2 && selected.startsWith(marker) && selected.endsWith(marker);
|
|
853
|
+
if (isWrappedInside) {
|
|
854
|
+
const inner = selected.slice(marker.length, selected.length - marker.length);
|
|
855
|
+
return replaceRange(source, start, end, inner, [0, inner.length]);
|
|
856
|
+
}
|
|
857
|
+
const content = selected || placeholder;
|
|
858
|
+
return replaceRange(source, start, end, `${marker}${content}${marker}`, [
|
|
859
|
+
marker.length,
|
|
860
|
+
marker.length + content.length
|
|
861
|
+
]);
|
|
862
|
+
}
|
|
863
|
+
function lineBounds(value, start, end) {
|
|
864
|
+
const from = value.lastIndexOf("\n", start - 1) + 1;
|
|
865
|
+
const nextBreak = value.indexOf("\n", end > start && value[end - 1] === "\n" ? end - 1 : end);
|
|
866
|
+
return { from, to: nextBreak === -1 ? value.length : nextBreak };
|
|
867
|
+
}
|
|
868
|
+
function toggleLinePrefix(source, kind, placeholder) {
|
|
869
|
+
const { from, to } = lineBounds(source.value, source.start, source.end);
|
|
870
|
+
const block = source.value.slice(from, to);
|
|
871
|
+
const lines = block.split("\n");
|
|
872
|
+
const pattern = LINE_PREFIX_PATTERN[kind];
|
|
873
|
+
const isAlreadyApplied = lines.every((line) => pattern.test(line));
|
|
874
|
+
const next = lines.map((line, index) => {
|
|
875
|
+
const bare = line.replace(ANY_BLOCK_PREFIX, "");
|
|
876
|
+
if (isAlreadyApplied) return bare;
|
|
877
|
+
const text = bare || (lines.length === 1 ? placeholder : "");
|
|
878
|
+
if (kind === "heading2") return `## ${text}`;
|
|
879
|
+
if (kind === "heading3") return `### ${text}`;
|
|
880
|
+
if (kind === "bulletList") return `- ${text}`;
|
|
881
|
+
if (kind === "numberedList") return `${index + 1}. ${text}`;
|
|
882
|
+
return `> ${text}`;
|
|
883
|
+
});
|
|
884
|
+
const result = next.join("\n");
|
|
885
|
+
return replaceRange(source, from, to, result, [0, result.length]);
|
|
886
|
+
}
|
|
887
|
+
function insertLink(source, params) {
|
|
888
|
+
const label = params.text?.trim() || source.value.slice(source.start, source.end) || params.url;
|
|
889
|
+
const markdown = `[${label}](${params.url})`;
|
|
890
|
+
return replaceRange(source, source.start, source.end, markdown, [markdown.length, markdown.length]);
|
|
891
|
+
}
|
|
892
|
+
function insertImage(source, params) {
|
|
893
|
+
const markdown = `![${params.alt.replace(/[\][]/g, "")}](${params.url})`;
|
|
894
|
+
return replaceRange(source, source.start, source.end, markdown, [markdown.length, markdown.length]);
|
|
895
|
+
}
|
|
896
|
+
function isAbsoluteUrl(value) {
|
|
897
|
+
try {
|
|
898
|
+
const { protocol } = new URL(value.trim());
|
|
899
|
+
return protocol === "http:" || protocol === "https:";
|
|
900
|
+
} catch {
|
|
901
|
+
return false;
|
|
902
|
+
}
|
|
903
|
+
}
|
|
904
|
+
|
|
905
|
+
// src/components/EmojiPicker.tsx
|
|
906
|
+
import { useId, useState as useState4 } from "react";
|
|
907
|
+
|
|
908
|
+
// src/lib/emoji.ts
|
|
909
|
+
var EMOJI_CATEGORIES = [
|
|
910
|
+
"smileys",
|
|
911
|
+
"gestures",
|
|
912
|
+
"food",
|
|
913
|
+
"nature",
|
|
914
|
+
"travel",
|
|
915
|
+
"objects",
|
|
916
|
+
"symbols"
|
|
917
|
+
];
|
|
918
|
+
function entries(raw) {
|
|
919
|
+
return raw.split("|").map((item) => {
|
|
920
|
+
const [char = "", keywords = ""] = item.split(":");
|
|
921
|
+
return { char, keywords };
|
|
922
|
+
});
|
|
923
|
+
}
|
|
924
|
+
var EMOJI_BY_CATEGORY = {
|
|
925
|
+
smileys: entries(
|
|
926
|
+
"\u{1F600}:sorriso smile happy feliz|\u{1F601}:alegre grin|\u{1F602}:rindo lol laugh|\u{1F60A}:feliz blush|\u{1F60D}:amei love apaixonado|\u{1F60E}:legal cool|\u{1F609}:piscada wink|\u{1F970}:carinho|\u{1F618}:beijo kiss|\u{1F914}:pensando think|\u{1F605}:aliviado|\u{1F622}:triste sad cry|\u{1F62D}:chorando|\u{1F621}:bravo angry|\u{1F634}:sono sleep|\u{1F929}:uau wow estrela|\u{1F642}:simples|\u{1F643}:invertido|\u{1F607}:anjo|\u{1F973}:festa party|\u{1F60B}:gostoso yum|\u{1F917}:abraco hug|\u{1F62E}:surpreso|\u{1F62C}:sem graca"
|
|
927
|
+
),
|
|
928
|
+
gestures: entries(
|
|
929
|
+
"\u{1F44D}:joia like ok|\u{1F44E}:nao dislike|\u{1F44F}:palmas clap|\u{1F64C}:comemorar hooray|\u{1F64F}:obrigado por favor thanks pray|\u{1F4AA}:forca strong|\u{1F44B}:oi tchau wave|\u{1F91D}:acordo handshake|\u270C\uFE0F:paz peace|\u{1F44C}:perfeito|\u{1F449}:direita point|\u{1F447}:baixo|\u261D\uFE0F:cima|\u270D\uFE0F:escrever write|\u{1F91E}:torcendo"
|
|
930
|
+
),
|
|
931
|
+
food: entries(
|
|
932
|
+
"\u{1F355}:pizza|\u{1F354}:hamburguer burger|\u{1F35F}:batata fritas|\u{1F32D}:cachorro quente|\u{1F363}:sushi|\u{1F35D}:massa pasta|\u{1F957}:salada salad|\u{1F370}:bolo cake|\u{1F36B}:chocolate|\u{1F377}:vinho wine|\u{1F37A}:cerveja beer|\u{1F379}:drink coquetel|\u2615:cafe coffee|\u{1F942}:brinde cheers|\u{1F34E}:maca apple|\u{1F353}:morango|\u{1F349}:melancia|\u{1F950}:croissant|\u{1F969}:carne steak|\u{1F366}:sorvete ice cream"
|
|
933
|
+
),
|
|
934
|
+
nature: entries(
|
|
935
|
+
"\u{1F31E}:sol sun|\u{1F319}:lua moon|\u2B50:estrela star|\u{1F308}:arco-iris rainbow|\u{1F525}:fogo fire|\u{1F4A7}:agua water|\u{1F338}:flor flower|\u{1F339}:rosa|\u{1F333}:arvore tree|\u{1F334}:palmeira palm|\u{1F340}:trevo|\u{1F436}:cachorro dog|\u{1F431}:gato cat|\u{1F41F}:peixe fish|\u{1F98B}:borboleta"
|
|
936
|
+
),
|
|
937
|
+
travel: entries(
|
|
938
|
+
"\u{1F697}:carro car|\u{1F68C}:onibus|\u2708\uFE0F:aviao plane|\u{1F6B2}:bicicleta|\u{1F3E0}:casa home|\u{1F3D6}\uFE0F:praia beach|\u{1F3DD}\uFE0F:ilha|\u{1F3E8}:hotel|\u{1F4CD}:local pin|\u{1F5FA}\uFE0F:mapa map|\u26F1\uFE0F:guarda-sol|\u{1F3A1}:roda gigante|\u{1F306}:cidade|\u{1F6CD}\uFE0F:compras shopping"
|
|
939
|
+
),
|
|
940
|
+
objects: entries(
|
|
941
|
+
"\u{1F389}:festa celebracao party|\u{1F381}:presente gift|\u{1F382}:aniversario birthday|\u{1F3B6}:musica music|\u{1F4E3}:aviso megaphone|\u{1F4E2}:anuncio|\u{1F4C5}:calendario calendar data|\u23F0:horario clock|\u{1F4DE}:telefone phone|\u{1F4F1}:celular mobile|\u{1F4BB}:computador|\u{1F4F7}:foto camera|\u{1F39F}\uFE0F:ingresso ticket|\u{1F3C6}:trofeu trophy|\u{1F4A1}:ideia idea|\u{1F514}:sino bell|\u{1F4CC}:fixado|\u{1F511}:chave key"
|
|
942
|
+
),
|
|
943
|
+
symbols: entries(
|
|
944
|
+
"\u2764\uFE0F:coracao heart amor|\u{1F49B}:amarelo|\u{1F499}:azul|\u{1F49A}:verde|\u2728:brilho sparkles novo|\u2705:ok check|\u274C:erro x|\u26A0\uFE0F:atencao warning|\u2757:importante|\u2753:pergunta|\u27A1\uFE0F:seta arrow|\u2B06\uFE0F:cima|\u{1F4AF}:cem 100|\u{1F195}:novo new|\u{1F51D}:topo|\u{1F4AC}:conversa chat|\u{1F4B0}:dinheiro money|\u{1F193}:gratis free|\u267B\uFE0F:reciclar"
|
|
945
|
+
)
|
|
946
|
+
};
|
|
947
|
+
function searchEmoji(query) {
|
|
948
|
+
const needle = query.trim().toLowerCase();
|
|
949
|
+
if (!needle) return [];
|
|
950
|
+
return EMOJI_CATEGORIES.flatMap((category) => EMOJI_BY_CATEGORY[category]).filter(
|
|
951
|
+
(entry) => entry.keywords.toLowerCase().includes(needle)
|
|
952
|
+
);
|
|
953
|
+
}
|
|
954
|
+
|
|
955
|
+
// src/components/EmojiPicker.tsx
|
|
956
|
+
import { jsx as jsx4, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
957
|
+
var CATEGORY_MESSAGE = {
|
|
958
|
+
smileys: "emojiSmileys",
|
|
959
|
+
gestures: "emojiGestures",
|
|
960
|
+
food: "emojiFood",
|
|
961
|
+
nature: "emojiNature",
|
|
962
|
+
travel: "emojiTravel",
|
|
963
|
+
objects: "emojiObjects",
|
|
964
|
+
symbols: "emojiSymbols"
|
|
965
|
+
};
|
|
966
|
+
function EmojiPicker({ onPick, onClose }) {
|
|
967
|
+
const { messages } = useContentText();
|
|
968
|
+
const [category, setCategory] = useState4("smileys");
|
|
969
|
+
const [query, setQuery] = useState4("");
|
|
970
|
+
const searchId = useId();
|
|
971
|
+
const isSearching = query.trim().length > 0;
|
|
972
|
+
const visible = isSearching ? searchEmoji(query) : EMOJI_BY_CATEGORY[category];
|
|
973
|
+
return /* @__PURE__ */ jsxs2(
|
|
974
|
+
"div",
|
|
975
|
+
{
|
|
976
|
+
className: "adc-popover adc-emoji",
|
|
977
|
+
role: "dialog",
|
|
978
|
+
"aria-label": messages.emojiTitle,
|
|
979
|
+
onKeyDown: (event) => {
|
|
980
|
+
if (event.key !== "Escape") return;
|
|
981
|
+
event.stopPropagation();
|
|
982
|
+
onClose();
|
|
983
|
+
},
|
|
984
|
+
children: [
|
|
985
|
+
/* @__PURE__ */ jsx4("label", { htmlFor: searchId, className: "adc-visually-hidden", children: messages.emojiSearch }),
|
|
986
|
+
/* @__PURE__ */ jsx4(
|
|
987
|
+
"input",
|
|
988
|
+
{
|
|
989
|
+
id: searchId,
|
|
990
|
+
type: "text",
|
|
991
|
+
role: "searchbox",
|
|
992
|
+
autoFocus: true,
|
|
993
|
+
placeholder: messages.emojiSearch,
|
|
994
|
+
value: query,
|
|
995
|
+
onChange: (event) => setQuery(event.target.value),
|
|
996
|
+
onKeyDown: (event) => {
|
|
997
|
+
if (event.key === "Enter") event.preventDefault();
|
|
998
|
+
}
|
|
999
|
+
}
|
|
1000
|
+
),
|
|
1001
|
+
!isSearching && /* @__PURE__ */ jsx4("div", { className: "adc-emoji-categories", role: "group", "aria-label": messages.emojiCategories, children: EMOJI_CATEGORIES.map((value) => /* @__PURE__ */ jsx4(
|
|
1002
|
+
"button",
|
|
1003
|
+
{
|
|
1004
|
+
type: "button",
|
|
1005
|
+
className: "adc-tab",
|
|
1006
|
+
"aria-pressed": category === value,
|
|
1007
|
+
onClick: () => setCategory(value),
|
|
1008
|
+
children: messages[CATEGORY_MESSAGE[value]]
|
|
1009
|
+
},
|
|
1010
|
+
value
|
|
1011
|
+
)) }),
|
|
1012
|
+
visible.length === 0 ? /* @__PURE__ */ jsx4("p", { className: "adc-muted", role: "status", children: messages.emojiEmpty }) : /* @__PURE__ */ jsx4("div", { className: "adc-emoji-grid", children: visible.map((entry) => /* @__PURE__ */ jsx4(
|
|
1013
|
+
"button",
|
|
1014
|
+
{
|
|
1015
|
+
type: "button",
|
|
1016
|
+
className: "adc-emoji-button",
|
|
1017
|
+
"aria-label": entry.keywords.split(" ")[0] ?? entry.char,
|
|
1018
|
+
onClick: () => onPick(entry.char),
|
|
1019
|
+
children: entry.char
|
|
1020
|
+
},
|
|
1021
|
+
entry.char
|
|
1022
|
+
)) })
|
|
1023
|
+
]
|
|
1024
|
+
}
|
|
1025
|
+
);
|
|
1026
|
+
}
|
|
1027
|
+
|
|
1028
|
+
// src/components/InsertDialog.tsx
|
|
1029
|
+
import { useId as useId2, useState as useState5 } from "react";
|
|
1030
|
+
import { jsx as jsx5, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
1031
|
+
function InsertDialog(props) {
|
|
1032
|
+
const { messages } = useContentText();
|
|
1033
|
+
const [url, setUrl] = useState5("");
|
|
1034
|
+
const [text, setText] = useState5(props.initialText);
|
|
1035
|
+
const [errorMessage, setErrorMessage] = useState5("");
|
|
1036
|
+
const urlId = useId2();
|
|
1037
|
+
const textId = useId2();
|
|
1038
|
+
const isImage = props.kind === "image";
|
|
1039
|
+
function submit() {
|
|
1040
|
+
if (!isAbsoluteUrl(url)) return setErrorMessage(messages.errorUrl);
|
|
1041
|
+
if (props.kind === "image") props.onSubmit({ url: url.trim(), alt: text });
|
|
1042
|
+
else props.onSubmit({ url: url.trim(), text });
|
|
1043
|
+
}
|
|
1044
|
+
async function handlePick(file) {
|
|
1045
|
+
if (props.kind !== "image" || !props.onUpload) return;
|
|
1046
|
+
setErrorMessage("");
|
|
1047
|
+
const result = await props.onUpload(file);
|
|
1048
|
+
if ("error" in result) return setErrorMessage(messages[result.error]);
|
|
1049
|
+
setUrl(result.url);
|
|
1050
|
+
}
|
|
1051
|
+
function handleKeyDown(event) {
|
|
1052
|
+
if (event.key === "Escape") {
|
|
1053
|
+
event.stopPropagation();
|
|
1054
|
+
props.onClose();
|
|
1055
|
+
}
|
|
1056
|
+
if (event.key === "Enter" && event.target instanceof HTMLInputElement) {
|
|
1057
|
+
event.preventDefault();
|
|
1058
|
+
submit();
|
|
1059
|
+
}
|
|
1060
|
+
}
|
|
1061
|
+
return /* @__PURE__ */ jsxs3(
|
|
1062
|
+
"div",
|
|
1063
|
+
{
|
|
1064
|
+
className: "adc-popover adc-insert",
|
|
1065
|
+
role: "dialog",
|
|
1066
|
+
"aria-label": isImage ? messages.imageDialogTitle : messages.linkDialogTitle,
|
|
1067
|
+
onKeyDown: handleKeyDown,
|
|
1068
|
+
children: [
|
|
1069
|
+
isImage && props.onUpload && /* @__PURE__ */ jsx5(
|
|
1070
|
+
FilePicker,
|
|
1071
|
+
{
|
|
1072
|
+
buttonLabel: props.isUploading ? messages.coverUploading : messages.imageUploadFromDevice,
|
|
1073
|
+
emptyLabel: messages.fileNoneChosen,
|
|
1074
|
+
accept: "image/*",
|
|
1075
|
+
isBusy: props.isUploading,
|
|
1076
|
+
onPick: (file) => void handlePick(file)
|
|
1077
|
+
}
|
|
1078
|
+
),
|
|
1079
|
+
/* @__PURE__ */ jsxs3("div", { className: "adc-field", children: [
|
|
1080
|
+
/* @__PURE__ */ jsx5("label", { htmlFor: urlId, children: isImage ? messages.fieldCoverUrl : messages.linkUrl }),
|
|
1081
|
+
/* @__PURE__ */ jsx5(
|
|
1082
|
+
"input",
|
|
1083
|
+
{
|
|
1084
|
+
id: urlId,
|
|
1085
|
+
type: "url",
|
|
1086
|
+
autoFocus: true,
|
|
1087
|
+
placeholder: "https://",
|
|
1088
|
+
value: url,
|
|
1089
|
+
onChange: (event) => setUrl(event.target.value)
|
|
1090
|
+
}
|
|
1091
|
+
)
|
|
1092
|
+
] }),
|
|
1093
|
+
/* @__PURE__ */ jsxs3("div", { className: "adc-field", children: [
|
|
1094
|
+
/* @__PURE__ */ jsx5("label", { htmlFor: textId, children: isImage ? messages.fieldCoverAlt : messages.linkText }),
|
|
1095
|
+
/* @__PURE__ */ jsx5("input", { id: textId, type: "text", value: text, onChange: (event) => setText(event.target.value) })
|
|
1096
|
+
] }),
|
|
1097
|
+
/* @__PURE__ */ jsx5("p", { className: "adc-error", role: "alert", hidden: !errorMessage, children: errorMessage }),
|
|
1098
|
+
/* @__PURE__ */ jsxs3("div", { className: "adc-insert-actions", children: [
|
|
1099
|
+
/* @__PURE__ */ jsx5("button", { type: "button", className: "adc-button adc-button--ghost", onClick: props.onClose, children: messages.dialogCancel }),
|
|
1100
|
+
/* @__PURE__ */ jsx5(
|
|
1101
|
+
"button",
|
|
1102
|
+
{
|
|
1103
|
+
type: "button",
|
|
1104
|
+
className: "adc-button adc-button--primary",
|
|
1105
|
+
disabled: isImage && props.isUploading,
|
|
1106
|
+
onClick: submit,
|
|
1107
|
+
children: messages.dialogInsert
|
|
1108
|
+
}
|
|
1109
|
+
)
|
|
1110
|
+
] })
|
|
1111
|
+
]
|
|
1112
|
+
}
|
|
1113
|
+
);
|
|
1114
|
+
}
|
|
1115
|
+
|
|
1116
|
+
// src/components/Tooltip.tsx
|
|
1117
|
+
import { useId as useId3, useState as useState6 } from "react";
|
|
1118
|
+
import { jsx as jsx6, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
1119
|
+
function Tooltip({ text, children }) {
|
|
1120
|
+
const id = useId3();
|
|
1121
|
+
const [isHovered, setIsHovered] = useState6(false);
|
|
1122
|
+
const [isFocused, setIsFocused] = useState6(false);
|
|
1123
|
+
return /* @__PURE__ */ jsxs4(
|
|
1124
|
+
"span",
|
|
1125
|
+
{
|
|
1126
|
+
className: "adc-tip",
|
|
1127
|
+
onMouseEnter: () => setIsHovered(true),
|
|
1128
|
+
onMouseLeave: () => setIsHovered(false),
|
|
1129
|
+
onFocus: () => setIsFocused(true),
|
|
1130
|
+
onBlur: () => setIsFocused(false),
|
|
1131
|
+
onKeyDown: (event) => {
|
|
1132
|
+
if (event.key !== "Escape" || !(isHovered || isFocused)) return;
|
|
1133
|
+
setIsHovered(false);
|
|
1134
|
+
setIsFocused(false);
|
|
1135
|
+
},
|
|
1136
|
+
children: [
|
|
1137
|
+
/* @__PURE__ */ jsx6("span", { "aria-describedby": id, className: "adc-tip-target", children }),
|
|
1138
|
+
/* @__PURE__ */ jsx6("span", { id, role: "tooltip", className: "adc-tooltip", "data-visible": isHovered || isFocused, children: text })
|
|
1139
|
+
]
|
|
1140
|
+
}
|
|
1141
|
+
);
|
|
1142
|
+
}
|
|
1143
|
+
|
|
1144
|
+
// src/components/MarkdownEditor.tsx
|
|
1145
|
+
import { jsx as jsx7, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
1146
|
+
var SIMPLE_ACTIONS = [
|
|
1147
|
+
{ id: "bold", icon: Bold, label: "formatBold", shortcut: "B" },
|
|
1148
|
+
{ id: "italic", icon: Italic, label: "formatItalic", shortcut: "I" },
|
|
1149
|
+
{ id: "heading2", icon: Heading2, label: "formatHeading2" },
|
|
1150
|
+
{ id: "heading3", icon: Heading3, label: "formatHeading3" },
|
|
1151
|
+
{ id: "bulletList", icon: List, label: "formatBulletList" },
|
|
1152
|
+
{ id: "numberedList", icon: ListOrdered, label: "formatNumberedList" },
|
|
1153
|
+
{ id: "quote", icon: Quote, label: "formatQuote" }
|
|
1154
|
+
];
|
|
1155
|
+
function ToolButton({ icon: Icon, text, isExpanded, onClick }) {
|
|
1156
|
+
return /* @__PURE__ */ jsx7(Tooltip, { text, children: /* @__PURE__ */ jsx7(
|
|
1157
|
+
"button",
|
|
1158
|
+
{
|
|
1159
|
+
type: "button",
|
|
1160
|
+
className: "adc-tool",
|
|
1161
|
+
"aria-label": text,
|
|
1162
|
+
...isExpanded === void 0 ? {} : { "aria-expanded": isExpanded },
|
|
1163
|
+
onClick,
|
|
1164
|
+
children: /* @__PURE__ */ jsx7(Icon, { "aria-hidden": "true", className: "adc-icon" })
|
|
1165
|
+
}
|
|
1166
|
+
) });
|
|
1167
|
+
}
|
|
1168
|
+
function MarkdownEditor({
|
|
1169
|
+
value,
|
|
1170
|
+
onChange,
|
|
1171
|
+
labelledBy,
|
|
1172
|
+
describedBy,
|
|
1173
|
+
showToolbar = true,
|
|
1174
|
+
onUploadImage,
|
|
1175
|
+
isUploading = false
|
|
1176
|
+
}) {
|
|
1177
|
+
const { messages } = useContentText();
|
|
1178
|
+
const textareaRef = useRef3(null);
|
|
1179
|
+
const pendingSelection = useRef3(void 0);
|
|
1180
|
+
const savedSelection = useRef3({ value, start: value.length, end: value.length });
|
|
1181
|
+
const [panel, setPanel] = useState7();
|
|
1182
|
+
useLayoutEffect(() => {
|
|
1183
|
+
const pending = pendingSelection.current;
|
|
1184
|
+
const textarea = textareaRef.current;
|
|
1185
|
+
if (!pending || !textarea) return;
|
|
1186
|
+
pendingSelection.current = void 0;
|
|
1187
|
+
textarea.focus();
|
|
1188
|
+
textarea.setSelectionRange(pending.start, pending.end);
|
|
1189
|
+
}, [value]);
|
|
1190
|
+
function readSelection() {
|
|
1191
|
+
const textarea = textareaRef.current;
|
|
1192
|
+
return { value, start: textarea?.selectionStart ?? value.length, end: textarea?.selectionEnd ?? value.length };
|
|
1193
|
+
}
|
|
1194
|
+
function apply(next) {
|
|
1195
|
+
pendingSelection.current = { start: next.start, end: next.end };
|
|
1196
|
+
onChange(next.value);
|
|
1197
|
+
setPanel(void 0);
|
|
1198
|
+
}
|
|
1199
|
+
function run(id) {
|
|
1200
|
+
const selection = readSelection();
|
|
1201
|
+
const sample = messages.formatSampleText;
|
|
1202
|
+
if (id === "bold") return apply(toggleWrap(selection, "**", sample));
|
|
1203
|
+
if (id === "italic") return apply(toggleWrap(selection, "*", sample));
|
|
1204
|
+
apply(toggleLinePrefix(selection, id, sample));
|
|
1205
|
+
}
|
|
1206
|
+
function openPanel(next) {
|
|
1207
|
+
if (panel === next) return setPanel(void 0);
|
|
1208
|
+
savedSelection.current = readSelection();
|
|
1209
|
+
setPanel(next);
|
|
1210
|
+
}
|
|
1211
|
+
function closePanel() {
|
|
1212
|
+
setPanel(void 0);
|
|
1213
|
+
textareaRef.current?.focus();
|
|
1214
|
+
}
|
|
1215
|
+
function handleKeyDown(event) {
|
|
1216
|
+
if (!showToolbar || !(event.ctrlKey || event.metaKey) || event.altKey) return;
|
|
1217
|
+
const key = event.key.toLowerCase();
|
|
1218
|
+
if (key !== "b" && key !== "i" && key !== "k") return;
|
|
1219
|
+
event.preventDefault();
|
|
1220
|
+
if (key === "k") return openPanel("link");
|
|
1221
|
+
run(key === "b" ? "bold" : "italic");
|
|
1222
|
+
}
|
|
1223
|
+
const saved = savedSelection.current;
|
|
1224
|
+
const selectedText = saved.value.slice(saved.start, saved.end);
|
|
1225
|
+
return /* @__PURE__ */ jsxs5("div", { className: "adc-md-editor", children: [
|
|
1226
|
+
showToolbar && /* @__PURE__ */ jsxs5("div", { className: "adc-md-toolbar", role: "toolbar", "aria-label": messages.toolbarLabel, children: [
|
|
1227
|
+
SIMPLE_ACTIONS.map(({ id, icon, label, shortcut }) => /* @__PURE__ */ jsx7(
|
|
1228
|
+
ToolButton,
|
|
1229
|
+
{
|
|
1230
|
+
icon,
|
|
1231
|
+
text: shortcut ? `${messages[label]} (Ctrl+${shortcut})` : messages[label],
|
|
1232
|
+
onClick: () => run(id)
|
|
1233
|
+
},
|
|
1234
|
+
id
|
|
1235
|
+
)),
|
|
1236
|
+
/* @__PURE__ */ jsx7(
|
|
1237
|
+
ToolButton,
|
|
1238
|
+
{
|
|
1239
|
+
icon: LinkIcon,
|
|
1240
|
+
text: `${messages.formatLink} (Ctrl+K)`,
|
|
1241
|
+
isExpanded: panel === "link",
|
|
1242
|
+
onClick: () => openPanel("link")
|
|
1243
|
+
}
|
|
1244
|
+
),
|
|
1245
|
+
/* @__PURE__ */ jsx7(
|
|
1246
|
+
ToolButton,
|
|
1247
|
+
{
|
|
1248
|
+
icon: ImageIcon,
|
|
1249
|
+
text: messages.formatImage,
|
|
1250
|
+
isExpanded: panel === "image",
|
|
1251
|
+
onClick: () => openPanel("image")
|
|
1252
|
+
}
|
|
1253
|
+
),
|
|
1254
|
+
/* @__PURE__ */ jsx7(
|
|
1255
|
+
ToolButton,
|
|
1256
|
+
{
|
|
1257
|
+
icon: Smile,
|
|
1258
|
+
text: messages.formatEmoji,
|
|
1259
|
+
isExpanded: panel === "emoji",
|
|
1260
|
+
onClick: () => openPanel("emoji")
|
|
1261
|
+
}
|
|
1262
|
+
)
|
|
1263
|
+
] }),
|
|
1264
|
+
panel === "link" && /* @__PURE__ */ jsx7(
|
|
1265
|
+
InsertDialog,
|
|
1266
|
+
{
|
|
1267
|
+
kind: "link",
|
|
1268
|
+
initialText: selectedText,
|
|
1269
|
+
onClose: closePanel,
|
|
1270
|
+
onSubmit: (values) => apply(insertLink(saved, values))
|
|
1271
|
+
}
|
|
1272
|
+
),
|
|
1273
|
+
panel === "image" && /* @__PURE__ */ jsx7(
|
|
1274
|
+
InsertDialog,
|
|
1275
|
+
{
|
|
1276
|
+
kind: "image",
|
|
1277
|
+
initialText: "",
|
|
1278
|
+
isUploading,
|
|
1279
|
+
...onUploadImage ? { onUpload: onUploadImage } : {},
|
|
1280
|
+
onClose: closePanel,
|
|
1281
|
+
onSubmit: (values) => apply(insertImage(saved, values))
|
|
1282
|
+
}
|
|
1283
|
+
),
|
|
1284
|
+
panel === "emoji" && /* @__PURE__ */ jsx7(EmojiPicker, { onClose: closePanel, onPick: (emoji) => apply(insertText(saved, emoji)) }),
|
|
1285
|
+
/* @__PURE__ */ jsx7(
|
|
1286
|
+
"textarea",
|
|
1287
|
+
{
|
|
1288
|
+
ref: textareaRef,
|
|
1289
|
+
"aria-labelledby": labelledBy,
|
|
1290
|
+
...describedBy ? { "aria-describedby": describedBy } : {},
|
|
1291
|
+
className: "adc-markdown-input",
|
|
1292
|
+
value,
|
|
1293
|
+
onChange: (event) => onChange(event.target.value),
|
|
1294
|
+
onKeyDown: handleKeyDown
|
|
1295
|
+
}
|
|
1296
|
+
)
|
|
1297
|
+
] });
|
|
607
1298
|
}
|
|
608
1299
|
|
|
609
1300
|
// src/components/StatusChip.tsx
|
|
610
1301
|
import { POST_STATUS } from "@adatechnology/content-contracts";
|
|
611
|
-
import { Archive, CalendarClock, CircleCheck, PencilLine } from "lucide-react";
|
|
612
|
-
import { jsx as
|
|
1302
|
+
import { Archive, CalendarClock, CircleCheck, Copy, PencilLine } from "lucide-react";
|
|
1303
|
+
import { jsx as jsx8, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
613
1304
|
var STATUS_VIEW = {
|
|
614
1305
|
[POST_STATUS.DRAFT]: { icon: PencilLine, label: "statusDraft" },
|
|
615
1306
|
[POST_STATUS.SCHEDULED]: { icon: CalendarClock, label: "statusScheduled" },
|
|
616
1307
|
[POST_STATUS.PUBLISHED]: { icon: CircleCheck, label: "statusPublished" },
|
|
617
1308
|
[POST_STATUS.ARCHIVED]: { icon: Archive, label: "statusArchived" }
|
|
618
1309
|
};
|
|
619
|
-
function StatusChip({ status }) {
|
|
1310
|
+
function StatusChip({ status, isTemplate = false }) {
|
|
620
1311
|
const { messages } = useContentText();
|
|
621
|
-
const { icon: Icon, label } = STATUS_VIEW[status];
|
|
622
|
-
return /* @__PURE__ */
|
|
623
|
-
/* @__PURE__ */
|
|
1312
|
+
const { icon: Icon, label } = isTemplate ? { icon: Copy, label: "statusTemplate" } : STATUS_VIEW[status];
|
|
1313
|
+
return /* @__PURE__ */ jsxs6("span", { className: `adc-badge adc-chip--${isTemplate ? "template" : status}`, children: [
|
|
1314
|
+
/* @__PURE__ */ jsx8(Icon, { "aria-hidden": "true", className: "adc-icon" }),
|
|
624
1315
|
messages[label]
|
|
625
1316
|
] });
|
|
626
1317
|
}
|
|
@@ -628,13 +1319,13 @@ function StatusChip({ status }) {
|
|
|
628
1319
|
// src/components/TagsInput.tsx
|
|
629
1320
|
import { normalizeTags, TAGS_MAX_COUNT } from "@adatechnology/content-contracts";
|
|
630
1321
|
import { X } from "lucide-react";
|
|
631
|
-
import { useId, useState as
|
|
632
|
-
import { jsx as
|
|
1322
|
+
import { useId as useId4, useState as useState8 } from "react";
|
|
1323
|
+
import { jsx as jsx9, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
633
1324
|
function TagsInput({ value, onChange, suggestions = [], label }) {
|
|
634
1325
|
const { messages, format } = useContentText();
|
|
635
|
-
const [text, setText] =
|
|
636
|
-
const inputId =
|
|
637
|
-
const listId =
|
|
1326
|
+
const [text, setText] = useState8("");
|
|
1327
|
+
const inputId = useId4();
|
|
1328
|
+
const listId = useId4();
|
|
638
1329
|
function commit(raw) {
|
|
639
1330
|
const added = splitTagInput(raw);
|
|
640
1331
|
if (added.length > 0) onChange(normalizeTags([...value, ...added]));
|
|
@@ -648,23 +1339,23 @@ function TagsInput({ value, onChange, suggestions = [], label }) {
|
|
|
648
1339
|
onChange(value.slice(0, -1));
|
|
649
1340
|
}
|
|
650
1341
|
}
|
|
651
|
-
return /* @__PURE__ */
|
|
652
|
-
/* @__PURE__ */
|
|
653
|
-
/* @__PURE__ */
|
|
654
|
-
value.map((tag) => /* @__PURE__ */
|
|
1342
|
+
return /* @__PURE__ */ jsxs7("div", { className: "adc-field", children: [
|
|
1343
|
+
/* @__PURE__ */ jsx9("label", { htmlFor: inputId, children: label }),
|
|
1344
|
+
/* @__PURE__ */ jsxs7("div", { className: "adc-tags-input", children: [
|
|
1345
|
+
value.map((tag) => /* @__PURE__ */ jsxs7("span", { className: "adc-tag", children: [
|
|
655
1346
|
tag,
|
|
656
|
-
/* @__PURE__ */
|
|
1347
|
+
/* @__PURE__ */ jsx9(
|
|
657
1348
|
"button",
|
|
658
1349
|
{
|
|
659
1350
|
type: "button",
|
|
660
1351
|
className: "adc-tag-remove",
|
|
661
1352
|
"aria-label": format("tagRemove", { tag }),
|
|
662
1353
|
onClick: () => onChange(value.filter((current) => current !== tag)),
|
|
663
|
-
children: /* @__PURE__ */
|
|
1354
|
+
children: /* @__PURE__ */ jsx9(X, { "aria-hidden": "true", className: "adc-icon" })
|
|
664
1355
|
}
|
|
665
1356
|
)
|
|
666
1357
|
] }, tag)),
|
|
667
|
-
/* @__PURE__ */
|
|
1358
|
+
/* @__PURE__ */ jsx9(
|
|
668
1359
|
"input",
|
|
669
1360
|
{
|
|
670
1361
|
id: inputId,
|
|
@@ -678,15 +1369,15 @@ function TagsInput({ value, onChange, suggestions = [], label }) {
|
|
|
678
1369
|
}
|
|
679
1370
|
)
|
|
680
1371
|
] }),
|
|
681
|
-
/* @__PURE__ */
|
|
682
|
-
suggestions.length > 0 && /* @__PURE__ */
|
|
1372
|
+
/* @__PURE__ */ jsx9("small", { id: `${inputId}-hint`, className: "adc-hint", children: messages.tagsHint }),
|
|
1373
|
+
suggestions.length > 0 && /* @__PURE__ */ jsx9("datalist", { id: listId, children: suggestions.filter((tag) => !value.includes(tag)).map((tag) => /* @__PURE__ */ jsx9("option", { value: tag }, tag)) })
|
|
683
1374
|
] });
|
|
684
1375
|
}
|
|
685
1376
|
|
|
686
1377
|
// src/components/PostEditor.tsx
|
|
687
|
-
import { jsx as
|
|
1378
|
+
import { jsx as jsx10, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
688
1379
|
function TextField({ label, value, onChange, error, hint, type = "text", multiline, maxLength }) {
|
|
689
|
-
const id =
|
|
1380
|
+
const id = useId5();
|
|
690
1381
|
const describedBy = [hint ? `${id}-hint` : "", error ? `${id}-error` : ""].filter(Boolean).join(" ") || void 0;
|
|
691
1382
|
const common = {
|
|
692
1383
|
id,
|
|
@@ -695,20 +1386,28 @@ function TextField({ label, value, onChange, error, hint, type = "text", multili
|
|
|
695
1386
|
"aria-invalid": error ? true : void 0,
|
|
696
1387
|
"aria-describedby": describedBy
|
|
697
1388
|
};
|
|
698
|
-
return /* @__PURE__ */
|
|
699
|
-
/* @__PURE__ */
|
|
700
|
-
multiline ? /* @__PURE__ */
|
|
701
|
-
hint && /* @__PURE__ */
|
|
702
|
-
error && /* @__PURE__ */
|
|
1389
|
+
return /* @__PURE__ */ jsxs8("div", { className: "adc-field", children: [
|
|
1390
|
+
/* @__PURE__ */ jsx10("label", { htmlFor: id, children: label }),
|
|
1391
|
+
multiline ? /* @__PURE__ */ jsx10("textarea", { ...common, rows: 3, onChange: (event) => onChange(event.target.value) }) : /* @__PURE__ */ jsx10("input", { ...common, type, onChange: (event) => onChange(event.target.value) }),
|
|
1392
|
+
hint && /* @__PURE__ */ jsx10("small", { id: `${id}-hint`, className: "adc-hint", children: hint }),
|
|
1393
|
+
error && /* @__PURE__ */ jsx10("small", { id: `${id}-error`, className: "adc-error", children: error })
|
|
703
1394
|
] });
|
|
704
1395
|
}
|
|
705
1396
|
function Section({ title, children }) {
|
|
706
|
-
return /* @__PURE__ */
|
|
707
|
-
/* @__PURE__ */
|
|
1397
|
+
return /* @__PURE__ */ jsxs8("fieldset", { className: "adc-section", children: [
|
|
1398
|
+
/* @__PURE__ */ jsx10("legend", { children: title }),
|
|
708
1399
|
children
|
|
709
1400
|
] });
|
|
710
1401
|
}
|
|
711
|
-
function PostEditor({
|
|
1402
|
+
function PostEditor({
|
|
1403
|
+
postId,
|
|
1404
|
+
defaults,
|
|
1405
|
+
onSaved,
|
|
1406
|
+
onArchived,
|
|
1407
|
+
onClose,
|
|
1408
|
+
showFormattingToolbar = true,
|
|
1409
|
+
renderDateTimeInput
|
|
1410
|
+
}) {
|
|
712
1411
|
const { messages, locale, format } = useContentText();
|
|
713
1412
|
const editor = usePostEditor({
|
|
714
1413
|
...postId ? { postId } : {},
|
|
@@ -717,16 +1416,16 @@ function PostEditor({ postId, defaults, onSaved, onArchived, onClose }) {
|
|
|
717
1416
|
...onArchived ? { onArchived } : {}
|
|
718
1417
|
});
|
|
719
1418
|
const { confirmLeave } = useUnsavedChangesGuard(editor.isDirty, messages.unsavedConfirm);
|
|
720
|
-
const [tab, setTab] =
|
|
721
|
-
const bodyId =
|
|
722
|
-
const scheduleId =
|
|
1419
|
+
const [tab, setTab] = useState9("write");
|
|
1420
|
+
const bodyId = useId5();
|
|
1421
|
+
const scheduleId = useId5();
|
|
723
1422
|
const { draft, update, errors, post } = editor;
|
|
724
1423
|
if (editor.isLoading) {
|
|
725
|
-
return /* @__PURE__ */
|
|
1424
|
+
return /* @__PURE__ */ jsx10("p", { className: "adc-root adc-state", role: "status", children: messages.loading });
|
|
726
1425
|
}
|
|
727
1426
|
const status = post?.status;
|
|
728
1427
|
const isLive = status === "published" || status === "scheduled";
|
|
729
|
-
return /* @__PURE__ */
|
|
1428
|
+
return /* @__PURE__ */ jsxs8(
|
|
730
1429
|
"form",
|
|
731
1430
|
{
|
|
732
1431
|
className: "adc-root adc-editor",
|
|
@@ -735,18 +1434,18 @@ function PostEditor({ postId, defaults, onSaved, onArchived, onClose }) {
|
|
|
735
1434
|
void editor.save();
|
|
736
1435
|
},
|
|
737
1436
|
children: [
|
|
738
|
-
/* @__PURE__ */
|
|
739
|
-
onClose && /* @__PURE__ */
|
|
740
|
-
/* @__PURE__ */
|
|
1437
|
+
/* @__PURE__ */ jsxs8("header", { className: "adc-toolbar", children: [
|
|
1438
|
+
onClose && /* @__PURE__ */ jsxs8("button", { type: "button", className: "adc-button adc-button--ghost", onClick: () => confirmLeave() && onClose(), children: [
|
|
1439
|
+
/* @__PURE__ */ jsx10(ArrowLeft, { "aria-hidden": "true", className: "adc-icon" }),
|
|
741
1440
|
messages.close
|
|
742
1441
|
] }),
|
|
743
|
-
/* @__PURE__ */
|
|
744
|
-
status && /* @__PURE__ */
|
|
745
|
-
editor.isDirty && /* @__PURE__ */
|
|
1442
|
+
/* @__PURE__ */ jsx10("h2", { className: "adc-title", children: post ? messages.editorEditTitle : messages.editorNewTitle }),
|
|
1443
|
+
status && /* @__PURE__ */ jsx10(StatusChip, { status }),
|
|
1444
|
+
editor.isDirty && /* @__PURE__ */ jsx10("span", { className: "adc-badge", children: messages.unsavedBadge })
|
|
746
1445
|
] }),
|
|
747
|
-
/* @__PURE__ */
|
|
748
|
-
/* @__PURE__ */
|
|
749
|
-
/* @__PURE__ */
|
|
1446
|
+
/* @__PURE__ */ jsxs8("div", { className: "adc-editor-grid", children: [
|
|
1447
|
+
/* @__PURE__ */ jsxs8("div", { className: "adc-editor-main", children: [
|
|
1448
|
+
/* @__PURE__ */ jsx10(
|
|
750
1449
|
TextField,
|
|
751
1450
|
{
|
|
752
1451
|
label: messages.fieldTitle,
|
|
@@ -756,7 +1455,7 @@ function PostEditor({ postId, defaults, onSaved, onArchived, onClose }) {
|
|
|
756
1455
|
error: errors.title ? messages.errorTitle : void 0
|
|
757
1456
|
}
|
|
758
1457
|
),
|
|
759
|
-
/* @__PURE__ */
|
|
1458
|
+
/* @__PURE__ */ jsx10(
|
|
760
1459
|
TextField,
|
|
761
1460
|
{
|
|
762
1461
|
label: messages.fieldSlug,
|
|
@@ -767,7 +1466,7 @@ function PostEditor({ postId, defaults, onSaved, onArchived, onClose }) {
|
|
|
767
1466
|
error: errors.slug ? messages.errorSlug : void 0
|
|
768
1467
|
}
|
|
769
1468
|
),
|
|
770
|
-
/* @__PURE__ */
|
|
1469
|
+
/* @__PURE__ */ jsx10(
|
|
771
1470
|
TextField,
|
|
772
1471
|
{
|
|
773
1472
|
label: messages.fieldExcerpt,
|
|
@@ -777,10 +1476,10 @@ function PostEditor({ postId, defaults, onSaved, onArchived, onClose }) {
|
|
|
777
1476
|
onChange: (value) => update("excerpt", value)
|
|
778
1477
|
}
|
|
779
1478
|
),
|
|
780
|
-
/* @__PURE__ */
|
|
781
|
-
/* @__PURE__ */
|
|
782
|
-
/* @__PURE__ */
|
|
783
|
-
["write", "preview"].map((value) => /* @__PURE__ */
|
|
1479
|
+
/* @__PURE__ */ jsxs8("div", { className: "adc-field", children: [
|
|
1480
|
+
/* @__PURE__ */ jsxs8("div", { className: "adc-tabs", role: "tablist", "aria-label": messages.fieldBody, children: [
|
|
1481
|
+
/* @__PURE__ */ jsx10("span", { className: "adc-label", id: `${bodyId}-label`, children: messages.fieldBody }),
|
|
1482
|
+
["write", "preview"].map((value) => /* @__PURE__ */ jsx10(
|
|
784
1483
|
"button",
|
|
785
1484
|
{
|
|
786
1485
|
type: "button",
|
|
@@ -794,34 +1493,36 @@ function PostEditor({ postId, defaults, onSaved, onArchived, onClose }) {
|
|
|
794
1493
|
value
|
|
795
1494
|
))
|
|
796
1495
|
] }),
|
|
797
|
-
/* @__PURE__ */
|
|
798
|
-
/* @__PURE__ */
|
|
799
|
-
/* @__PURE__ */
|
|
800
|
-
|
|
1496
|
+
/* @__PURE__ */ jsxs8("div", { className: `adc-body-panes adc-body-panes--${tab}`, children: [
|
|
1497
|
+
/* @__PURE__ */ jsxs8("div", { id: `${bodyId}-write`, role: "tabpanel", className: "adc-pane adc-pane--write", children: [
|
|
1498
|
+
/* @__PURE__ */ jsx10(
|
|
1499
|
+
MarkdownEditor,
|
|
801
1500
|
{
|
|
802
|
-
"aria-labelledby": `${bodyId}-label`,
|
|
803
|
-
"aria-describedby": `${bodyId}-hint`,
|
|
804
|
-
className: "adc-markdown-input",
|
|
805
1501
|
value: draft.body,
|
|
806
|
-
onChange: (
|
|
1502
|
+
onChange: (value) => update("body", value),
|
|
1503
|
+
labelledBy: `${bodyId}-label`,
|
|
1504
|
+
describedBy: `${bodyId}-hint`,
|
|
1505
|
+
showToolbar: showFormattingToolbar,
|
|
1506
|
+
isUploading: editor.isUploading,
|
|
1507
|
+
...editor.canUploadCover ? { onUploadImage: editor.uploadImage } : {}
|
|
807
1508
|
}
|
|
808
1509
|
),
|
|
809
|
-
/* @__PURE__ */
|
|
1510
|
+
/* @__PURE__ */ jsx10("small", { id: `${bodyId}-hint`, className: "adc-hint", children: showFormattingToolbar ? messages.bodyHintToolbar : messages.bodyHint })
|
|
810
1511
|
] }),
|
|
811
|
-
/* @__PURE__ */
|
|
1512
|
+
/* @__PURE__ */ jsx10("div", { id: `${bodyId}-preview`, role: "tabpanel", className: "adc-pane adc-pane--preview", "aria-live": "polite", children: draft.body.trim() ? /* @__PURE__ */ jsx10(MarkdownContent, { markdown: draft.body, headingLevelOffset: 1 }) : /* @__PURE__ */ jsx10("p", { className: "adc-muted", children: messages.previewEmpty }) })
|
|
812
1513
|
] })
|
|
813
1514
|
] })
|
|
814
1515
|
] }),
|
|
815
|
-
/* @__PURE__ */
|
|
816
|
-
/* @__PURE__ */
|
|
817
|
-
post?.publishedAt && /* @__PURE__ */
|
|
1516
|
+
/* @__PURE__ */ jsxs8("aside", { className: "adc-editor-side", children: [
|
|
1517
|
+
/* @__PURE__ */ jsxs8(Section, { title: messages.publishSection, children: [
|
|
1518
|
+
post?.publishedAt && /* @__PURE__ */ jsx10("p", { className: "adc-muted", children: format(status === "scheduled" ? "scheduledFor" : "publishedOn", {
|
|
818
1519
|
date: formatPostDate(post.publishedAt, locale, true)
|
|
819
1520
|
}) }),
|
|
820
|
-
/* @__PURE__ */
|
|
821
|
-
/* @__PURE__ */
|
|
1521
|
+
/* @__PURE__ */ jsxs8("button", { type: "submit", className: "adc-button", disabled: editor.isBusy, children: [
|
|
1522
|
+
/* @__PURE__ */ jsx10(Save, { "aria-hidden": "true", className: "adc-icon" }),
|
|
822
1523
|
editor.isBusy ? messages.saving : isLive ? messages.saveChanges : messages.save
|
|
823
1524
|
] }),
|
|
824
|
-
status !== "published" && /* @__PURE__ */
|
|
1525
|
+
status !== "published" && /* @__PURE__ */ jsxs8(
|
|
825
1526
|
"button",
|
|
826
1527
|
{
|
|
827
1528
|
type: "button",
|
|
@@ -829,14 +1530,19 @@ function PostEditor({ postId, defaults, onSaved, onArchived, onClose }) {
|
|
|
829
1530
|
disabled: editor.isBusy,
|
|
830
1531
|
onClick: () => void editor.publishNow(),
|
|
831
1532
|
children: [
|
|
832
|
-
/* @__PURE__ */
|
|
1533
|
+
/* @__PURE__ */ jsx10(Send, { "aria-hidden": "true", className: "adc-icon" }),
|
|
833
1534
|
messages.publishNow
|
|
834
1535
|
]
|
|
835
1536
|
}
|
|
836
1537
|
),
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
1538
|
+
renderDateTimeInput ? renderDateTimeInput({
|
|
1539
|
+
id: scheduleId,
|
|
1540
|
+
label: messages.scheduleAt,
|
|
1541
|
+
value: editor.scheduleAt,
|
|
1542
|
+
onChange: editor.setScheduleAt
|
|
1543
|
+
}) : /* @__PURE__ */ jsxs8("div", { className: "adc-field", children: [
|
|
1544
|
+
/* @__PURE__ */ jsx10("label", { htmlFor: scheduleId, children: messages.scheduleAt }),
|
|
1545
|
+
/* @__PURE__ */ jsx10(
|
|
840
1546
|
"input",
|
|
841
1547
|
{
|
|
842
1548
|
id: scheduleId,
|
|
@@ -846,7 +1552,7 @@ function PostEditor({ postId, defaults, onSaved, onArchived, onClose }) {
|
|
|
846
1552
|
}
|
|
847
1553
|
)
|
|
848
1554
|
] }),
|
|
849
|
-
/* @__PURE__ */
|
|
1555
|
+
/* @__PURE__ */ jsxs8(
|
|
850
1556
|
"button",
|
|
851
1557
|
{
|
|
852
1558
|
type: "button",
|
|
@@ -854,12 +1560,12 @@ function PostEditor({ postId, defaults, onSaved, onArchived, onClose }) {
|
|
|
854
1560
|
disabled: editor.isBusy || !editor.scheduleAt,
|
|
855
1561
|
onClick: () => void editor.schedule(),
|
|
856
1562
|
children: [
|
|
857
|
-
/* @__PURE__ */
|
|
1563
|
+
/* @__PURE__ */ jsx10(CalendarClock2, { "aria-hidden": "true", className: "adc-icon" }),
|
|
858
1564
|
messages.schedule
|
|
859
1565
|
]
|
|
860
1566
|
}
|
|
861
1567
|
),
|
|
862
|
-
isLive && /* @__PURE__ */
|
|
1568
|
+
isLive && /* @__PURE__ */ jsxs8(
|
|
863
1569
|
"button",
|
|
864
1570
|
{
|
|
865
1571
|
type: "button",
|
|
@@ -867,12 +1573,12 @@ function PostEditor({ postId, defaults, onSaved, onArchived, onClose }) {
|
|
|
867
1573
|
disabled: editor.isBusy,
|
|
868
1574
|
onClick: () => void editor.unpublish(),
|
|
869
1575
|
children: [
|
|
870
|
-
/* @__PURE__ */
|
|
1576
|
+
/* @__PURE__ */ jsx10(EyeOff, { "aria-hidden": "true", className: "adc-icon" }),
|
|
871
1577
|
messages.unpublish
|
|
872
1578
|
]
|
|
873
1579
|
}
|
|
874
1580
|
),
|
|
875
|
-
post && status !== "archived" && /* @__PURE__ */
|
|
1581
|
+
post && status !== "archived" && /* @__PURE__ */ jsxs8(
|
|
876
1582
|
"button",
|
|
877
1583
|
{
|
|
878
1584
|
type: "button",
|
|
@@ -880,12 +1586,12 @@ function PostEditor({ postId, defaults, onSaved, onArchived, onClose }) {
|
|
|
880
1586
|
disabled: editor.isBusy,
|
|
881
1587
|
onClick: () => window.confirm(messages.archiveConfirm) && void editor.archive(),
|
|
882
1588
|
children: [
|
|
883
|
-
/* @__PURE__ */
|
|
1589
|
+
/* @__PURE__ */ jsx10(Archive2, { "aria-hidden": "true", className: "adc-icon" }),
|
|
884
1590
|
messages.archive
|
|
885
1591
|
]
|
|
886
1592
|
}
|
|
887
1593
|
),
|
|
888
|
-
editor.feedback && /* @__PURE__ */
|
|
1594
|
+
editor.feedback && /* @__PURE__ */ jsx10(
|
|
889
1595
|
"p",
|
|
890
1596
|
{
|
|
891
1597
|
className: editor.feedback === "saved" ? "adc-success" : "adc-error",
|
|
@@ -894,27 +1600,19 @@ function PostEditor({ postId, defaults, onSaved, onArchived, onClose }) {
|
|
|
894
1600
|
}
|
|
895
1601
|
)
|
|
896
1602
|
] }),
|
|
897
|
-
/* @__PURE__ */
|
|
898
|
-
draft.coverImageUrl && /* @__PURE__ */
|
|
899
|
-
editor.canUploadCover && /* @__PURE__ */
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
const file = event.target.files?.[0];
|
|
911
|
-
event.target.value = "";
|
|
912
|
-
if (file) void editor.uploadCover(file);
|
|
913
|
-
}
|
|
914
|
-
}
|
|
915
|
-
)
|
|
916
|
-
] }),
|
|
917
|
-
/* @__PURE__ */ jsx5(
|
|
1603
|
+
/* @__PURE__ */ jsxs8(Section, { title: messages.fieldCover, children: [
|
|
1604
|
+
draft.coverImageUrl && /* @__PURE__ */ jsx10("img", { className: "adc-cover-preview", src: draft.coverImageUrl, alt: draft.coverImageAlt }),
|
|
1605
|
+
editor.canUploadCover && /* @__PURE__ */ jsx10(
|
|
1606
|
+
FilePicker,
|
|
1607
|
+
{
|
|
1608
|
+
buttonLabel: editor.isUploading ? messages.coverUploading : messages.coverUpload,
|
|
1609
|
+
emptyLabel: messages.fileNoneChosen,
|
|
1610
|
+
accept: "image/jpeg,image/png,image/webp",
|
|
1611
|
+
isBusy: editor.isUploading,
|
|
1612
|
+
onPick: (file) => void editor.uploadCover(file)
|
|
1613
|
+
}
|
|
1614
|
+
),
|
|
1615
|
+
/* @__PURE__ */ jsx10(
|
|
918
1616
|
TextField,
|
|
919
1617
|
{
|
|
920
1618
|
label: messages.fieldCoverUrl,
|
|
@@ -924,7 +1622,7 @@ function PostEditor({ postId, defaults, onSaved, onArchived, onClose }) {
|
|
|
924
1622
|
error: errors.coverImageUrl ? messages.errorUrl : void 0
|
|
925
1623
|
}
|
|
926
1624
|
),
|
|
927
|
-
/* @__PURE__ */
|
|
1625
|
+
/* @__PURE__ */ jsx10(
|
|
928
1626
|
TextField,
|
|
929
1627
|
{
|
|
930
1628
|
label: messages.fieldCoverAlt,
|
|
@@ -933,21 +1631,21 @@ function PostEditor({ postId, defaults, onSaved, onArchived, onClose }) {
|
|
|
933
1631
|
onChange: (value) => update("coverImageAlt", value)
|
|
934
1632
|
}
|
|
935
1633
|
),
|
|
936
|
-
draft.coverImageUrl && /* @__PURE__ */
|
|
1634
|
+
draft.coverImageUrl && /* @__PURE__ */ jsxs8(
|
|
937
1635
|
"button",
|
|
938
1636
|
{
|
|
939
1637
|
type: "button",
|
|
940
1638
|
className: "adc-button adc-button--ghost",
|
|
941
1639
|
onClick: () => update("coverImageUrl", ""),
|
|
942
1640
|
children: [
|
|
943
|
-
/* @__PURE__ */
|
|
1641
|
+
/* @__PURE__ */ jsx10(Trash2, { "aria-hidden": "true", className: "adc-icon" }),
|
|
944
1642
|
messages.coverRemove
|
|
945
1643
|
]
|
|
946
1644
|
}
|
|
947
1645
|
)
|
|
948
1646
|
] }),
|
|
949
|
-
/* @__PURE__ */
|
|
950
|
-
/* @__PURE__ */
|
|
1647
|
+
/* @__PURE__ */ jsxs8(Section, { title: messages.fieldTags, children: [
|
|
1648
|
+
/* @__PURE__ */ jsx10(
|
|
951
1649
|
TagsInput,
|
|
952
1650
|
{
|
|
953
1651
|
label: messages.fieldTags,
|
|
@@ -956,7 +1654,7 @@ function PostEditor({ postId, defaults, onSaved, onArchived, onClose }) {
|
|
|
956
1654
|
onChange: (tags) => update("tags", tags)
|
|
957
1655
|
}
|
|
958
1656
|
),
|
|
959
|
-
/* @__PURE__ */
|
|
1657
|
+
/* @__PURE__ */ jsx10(
|
|
960
1658
|
TextField,
|
|
961
1659
|
{
|
|
962
1660
|
label: messages.fieldAuthor,
|
|
@@ -966,8 +1664,8 @@ function PostEditor({ postId, defaults, onSaved, onArchived, onClose }) {
|
|
|
966
1664
|
}
|
|
967
1665
|
)
|
|
968
1666
|
] }),
|
|
969
|
-
/* @__PURE__ */
|
|
970
|
-
/* @__PURE__ */
|
|
1667
|
+
/* @__PURE__ */ jsxs8(Section, { title: messages.seoSection, children: [
|
|
1668
|
+
/* @__PURE__ */ jsx10(
|
|
971
1669
|
TextField,
|
|
972
1670
|
{
|
|
973
1671
|
label: messages.fieldSeoTitle,
|
|
@@ -976,7 +1674,7 @@ function PostEditor({ postId, defaults, onSaved, onArchived, onClose }) {
|
|
|
976
1674
|
onChange: (value) => update("seoTitle", value)
|
|
977
1675
|
}
|
|
978
1676
|
),
|
|
979
|
-
/* @__PURE__ */
|
|
1677
|
+
/* @__PURE__ */ jsx10(
|
|
980
1678
|
TextField,
|
|
981
1679
|
{
|
|
982
1680
|
label: messages.fieldSeoDescription,
|
|
@@ -986,7 +1684,7 @@ function PostEditor({ postId, defaults, onSaved, onArchived, onClose }) {
|
|
|
986
1684
|
onChange: (value) => update("seoDescription", value)
|
|
987
1685
|
}
|
|
988
1686
|
),
|
|
989
|
-
/* @__PURE__ */
|
|
1687
|
+
/* @__PURE__ */ jsx10(
|
|
990
1688
|
TextField,
|
|
991
1689
|
{
|
|
992
1690
|
label: messages.fieldCanonical,
|
|
@@ -1005,37 +1703,431 @@ function PostEditor({ postId, defaults, onSaved, onArchived, onClose }) {
|
|
|
1005
1703
|
}
|
|
1006
1704
|
|
|
1007
1705
|
// src/components/PostList.tsx
|
|
1008
|
-
import {
|
|
1009
|
-
import {
|
|
1010
|
-
import { useId as useId3 } from "react";
|
|
1706
|
+
import { CopyPlus as CopyPlus2, FilePlus2 as FilePlus22, RefreshCw as RefreshCw2 } from "lucide-react";
|
|
1707
|
+
import { useState as useState14 } from "react";
|
|
1011
1708
|
|
|
1012
1709
|
// src/hooks/usePostList.ts
|
|
1013
|
-
import { useState as
|
|
1710
|
+
import { useEffect as useEffect4, useState as useState10 } from "react";
|
|
1711
|
+
|
|
1712
|
+
// src/lib/listUrlState.ts
|
|
1713
|
+
import { POST_SORT_FIELDS } from "@adatechnology/content-contracts";
|
|
1714
|
+
var PAGE_SIZE_OPTIONS = [10, 20, 50, 100];
|
|
1715
|
+
var DEFAULT_LIST_STATE = {
|
|
1716
|
+
search: "",
|
|
1717
|
+
tags: [],
|
|
1718
|
+
page: 1,
|
|
1719
|
+
sort: "updatedAt",
|
|
1720
|
+
order: "desc"
|
|
1721
|
+
};
|
|
1722
|
+
var TABS = ["published", "scheduled", "draft", "templates"];
|
|
1723
|
+
function positiveInteger(value) {
|
|
1724
|
+
const parsed = Number(value);
|
|
1725
|
+
return Number.isInteger(parsed) && parsed > 0 ? parsed : void 0;
|
|
1726
|
+
}
|
|
1727
|
+
function parseListUrlState(search) {
|
|
1728
|
+
const params = new URLSearchParams(search);
|
|
1729
|
+
const sort = params.get("sort");
|
|
1730
|
+
const size = positiveInteger(params.get("size"));
|
|
1731
|
+
const tab = params.get("tab");
|
|
1732
|
+
return {
|
|
1733
|
+
...DEFAULT_LIST_STATE,
|
|
1734
|
+
...tab && TABS.includes(tab) ? { tab } : {},
|
|
1735
|
+
search: params.get("q") ?? "",
|
|
1736
|
+
tags: (params.get("tags") ?? "").split(",").filter(Boolean),
|
|
1737
|
+
page: positiveInteger(params.get("page")) ?? 1,
|
|
1738
|
+
...size && PAGE_SIZE_OPTIONS.includes(size) ? { pageSize: size } : {},
|
|
1739
|
+
sort: POST_SORT_FIELDS.includes(sort ?? "") ? sort : "updatedAt",
|
|
1740
|
+
order: params.get("order") === "asc" ? "asc" : "desc"
|
|
1741
|
+
};
|
|
1742
|
+
}
|
|
1743
|
+
function serializeListUrlState(state) {
|
|
1744
|
+
const params = new URLSearchParams();
|
|
1745
|
+
if (state.tab && state.tab !== "published") params.set("tab", state.tab);
|
|
1746
|
+
if (state.search) params.set("q", state.search);
|
|
1747
|
+
if (state.tags.length > 0) params.set("tags", state.tags.join(","));
|
|
1748
|
+
if (state.page > 1) params.set("page", String(state.page));
|
|
1749
|
+
if (state.pageSize) params.set("size", String(state.pageSize));
|
|
1750
|
+
if (state.sort !== DEFAULT_LIST_STATE.sort) params.set("sort", state.sort);
|
|
1751
|
+
if (state.order !== DEFAULT_LIST_STATE.order) params.set("order", state.order);
|
|
1752
|
+
return params.toString();
|
|
1753
|
+
}
|
|
1754
|
+
|
|
1755
|
+
// src/hooks/usePostList.ts
|
|
1756
|
+
var POST_LIST_TAB = {
|
|
1757
|
+
PUBLISHED: "published",
|
|
1758
|
+
SCHEDULED: "scheduled",
|
|
1759
|
+
DRAFT: "draft",
|
|
1760
|
+
TEMPLATES: "templates"
|
|
1761
|
+
};
|
|
1762
|
+
function initialState(syncUrl) {
|
|
1763
|
+
if (!syncUrl || typeof window === "undefined") return DEFAULT_LIST_STATE;
|
|
1764
|
+
return parseListUrlState(window.location.search);
|
|
1765
|
+
}
|
|
1014
1766
|
function usePostList(params) {
|
|
1015
1767
|
const api = useContentAdminApi();
|
|
1016
|
-
const
|
|
1017
|
-
const
|
|
1018
|
-
const
|
|
1019
|
-
const
|
|
1768
|
+
const syncUrl = params.syncUrl ?? false;
|
|
1769
|
+
const hasTabs = Boolean(api.countPosts);
|
|
1770
|
+
const [state, setState] = useState10(() => initialState(syncUrl));
|
|
1771
|
+
const [localReload, setLocalReload] = useState10(0);
|
|
1772
|
+
const [selectedIds, setSelectedIds] = useState10(/* @__PURE__ */ new Set());
|
|
1773
|
+
const reload = (params.reloadKey ?? 0) + localReload;
|
|
1774
|
+
const tab = hasTabs ? state.tab ?? POST_LIST_TAB.PUBLISHED : void 0;
|
|
1775
|
+
const pageSize = state.pageSize ?? params.pageSize;
|
|
1776
|
+
useEffect4(() => {
|
|
1777
|
+
if (!syncUrl || typeof window === "undefined") return;
|
|
1778
|
+
const query = serializeListUrlState({ ...state, ...tab ? { tab } : {} });
|
|
1779
|
+
const url = `${window.location.pathname}${query ? `?${query}` : ""}${window.location.hash}`;
|
|
1780
|
+
window.history.replaceState(window.history.state, "", url);
|
|
1781
|
+
}, [state, tab, syncUrl]);
|
|
1782
|
+
const tabFilter = !tab ? {} : tab === POST_LIST_TAB.TEMPLATES ? { isTemplate: true } : { status: tab };
|
|
1783
|
+
const key = JSON.stringify({ state, tab, pageSize, reload });
|
|
1784
|
+
const posts = useAsyncResource(
|
|
1785
|
+
() => api.listPosts({
|
|
1786
|
+
...tabFilter,
|
|
1787
|
+
...state.search ? { search: state.search } : {},
|
|
1788
|
+
...state.tags.length > 0 ? { tag: state.tags.join(",") } : {},
|
|
1789
|
+
sort: state.sort,
|
|
1790
|
+
order: state.order,
|
|
1791
|
+
page: state.page,
|
|
1792
|
+
pageSize
|
|
1793
|
+
}),
|
|
1794
|
+
key
|
|
1795
|
+
);
|
|
1796
|
+
const counts = useAsyncResource(
|
|
1797
|
+
() => api.countPosts ? api.countPosts() : Promise.resolve(void 0),
|
|
1798
|
+
`counts-${reload}`
|
|
1799
|
+
);
|
|
1020
1800
|
const tags = useAsyncResource(
|
|
1021
1801
|
() => api.listTags ? api.listTags() : Promise.resolve([]),
|
|
1022
|
-
`tags-${
|
|
1802
|
+
`tags-${reload}`
|
|
1023
1803
|
);
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1804
|
+
useEffect4(() => setSelectedIds(/* @__PURE__ */ new Set()), [key]);
|
|
1805
|
+
const change = (patch) => setState((current) => ({ ...current, page: 1, ...patch }));
|
|
1806
|
+
function toggleSort(field) {
|
|
1807
|
+
change({ sort: field, order: state.sort === field && state.order === "asc" ? "desc" : "asc" });
|
|
1808
|
+
}
|
|
1809
|
+
function toggleTag(tag) {
|
|
1810
|
+
change({ tags: state.tags.includes(tag) ? state.tags.filter((entry) => entry !== tag) : [...state.tags, tag] });
|
|
1811
|
+
}
|
|
1812
|
+
function toggleSelected(id) {
|
|
1813
|
+
setSelectedIds((current) => {
|
|
1814
|
+
const next = new Set(current);
|
|
1815
|
+
if (!next.delete(id)) next.add(id);
|
|
1816
|
+
return next;
|
|
1817
|
+
});
|
|
1027
1818
|
}
|
|
1028
1819
|
return {
|
|
1029
1820
|
posts,
|
|
1821
|
+
counts: counts.data,
|
|
1030
1822
|
tags: api.listTags ? tags.data ?? [] : void 0,
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1823
|
+
state,
|
|
1824
|
+
tab,
|
|
1825
|
+
pageSize,
|
|
1826
|
+
selectedIds,
|
|
1827
|
+
setSelectedIds,
|
|
1828
|
+
toggleSelected,
|
|
1829
|
+
toggleSort,
|
|
1830
|
+
toggleTag,
|
|
1831
|
+
setTab: (next) => change({ tab: next }),
|
|
1832
|
+
setSearch: (search) => change({ search }),
|
|
1833
|
+
setPageSize: (next) => change({ pageSize: next }),
|
|
1834
|
+
setPage: (page) => setState((current) => ({ ...current, page })),
|
|
1835
|
+
clearFilters: () => change({ search: "", tags: [] }),
|
|
1836
|
+
refresh: () => setLocalReload((value) => value + 1),
|
|
1837
|
+
hasFilters: Boolean(state.search || state.tags.length > 0)
|
|
1036
1838
|
};
|
|
1037
1839
|
}
|
|
1038
1840
|
|
|
1841
|
+
// src/components/BatchBar.tsx
|
|
1842
|
+
import { Archive as Archive3, CircleCheck as CircleCheck2, EyeOff as EyeOff2, X as X3 } from "lucide-react";
|
|
1843
|
+
import { useState as useState11 } from "react";
|
|
1844
|
+
|
|
1845
|
+
// src/components/ActionDialog.tsx
|
|
1846
|
+
import { X as X2 } from "lucide-react";
|
|
1847
|
+
import { useEffect as useEffect5, useId as useId6, useRef as useRef4 } from "react";
|
|
1848
|
+
import { jsx as jsx11, jsxs as jsxs9 } from "react/jsx-runtime";
|
|
1849
|
+
function ActionDialog({
|
|
1850
|
+
title,
|
|
1851
|
+
confirmLabel,
|
|
1852
|
+
confirmIcon,
|
|
1853
|
+
isBusy = false,
|
|
1854
|
+
error,
|
|
1855
|
+
onConfirm,
|
|
1856
|
+
onClose,
|
|
1857
|
+
children
|
|
1858
|
+
}) {
|
|
1859
|
+
const { messages } = useContentText();
|
|
1860
|
+
const titleId = useId6();
|
|
1861
|
+
const formRef = useRef4(null);
|
|
1862
|
+
useEffect5(() => {
|
|
1863
|
+
formRef.current?.querySelector("input, button[aria-haspopup], select, textarea")?.focus();
|
|
1864
|
+
const handleKeyDown = (event) => {
|
|
1865
|
+
if (event.key === "Escape") onClose();
|
|
1866
|
+
};
|
|
1867
|
+
document.addEventListener("keydown", handleKeyDown);
|
|
1868
|
+
return () => document.removeEventListener("keydown", handleKeyDown);
|
|
1869
|
+
}, [onClose]);
|
|
1870
|
+
function handleSubmit(event) {
|
|
1871
|
+
event.preventDefault();
|
|
1872
|
+
if (!isBusy) onConfirm();
|
|
1873
|
+
}
|
|
1874
|
+
return /* @__PURE__ */ jsx11("div", { className: "adc-root adc-dialog-backdrop", children: /* @__PURE__ */ jsxs9(
|
|
1875
|
+
"form",
|
|
1876
|
+
{
|
|
1877
|
+
ref: formRef,
|
|
1878
|
+
className: "adc-dialog",
|
|
1879
|
+
role: "dialog",
|
|
1880
|
+
"aria-modal": "true",
|
|
1881
|
+
"aria-labelledby": titleId,
|
|
1882
|
+
onSubmit: handleSubmit,
|
|
1883
|
+
children: [
|
|
1884
|
+
/* @__PURE__ */ jsxs9("header", { className: "adc-dialog__header", children: [
|
|
1885
|
+
/* @__PURE__ */ jsx11("h3", { id: titleId, className: "adc-dialog__title", children: title }),
|
|
1886
|
+
/* @__PURE__ */ jsx11(
|
|
1887
|
+
"button",
|
|
1888
|
+
{
|
|
1889
|
+
type: "button",
|
|
1890
|
+
className: "adc-button adc-button--ghost adc-button--icon",
|
|
1891
|
+
"aria-label": messages.close,
|
|
1892
|
+
onClick: onClose,
|
|
1893
|
+
children: /* @__PURE__ */ jsx11(X2, { "aria-hidden": "true", className: "adc-icon" })
|
|
1894
|
+
}
|
|
1895
|
+
)
|
|
1896
|
+
] }),
|
|
1897
|
+
/* @__PURE__ */ jsx11("div", { className: "adc-dialog__body", children }),
|
|
1898
|
+
error && /* @__PURE__ */ jsx11("p", { className: "adc-error", role: "alert", children: error }),
|
|
1899
|
+
/* @__PURE__ */ jsxs9("footer", { className: "adc-dialog__footer", children: [
|
|
1900
|
+
/* @__PURE__ */ jsx11("button", { type: "button", className: "adc-button", onClick: onClose, children: messages.dialogCancel }),
|
|
1901
|
+
/* @__PURE__ */ jsxs9("button", { type: "submit", className: "adc-button adc-button--primary", disabled: isBusy, children: [
|
|
1902
|
+
confirmIcon,
|
|
1903
|
+
confirmLabel
|
|
1904
|
+
] })
|
|
1905
|
+
] })
|
|
1906
|
+
]
|
|
1907
|
+
}
|
|
1908
|
+
) });
|
|
1909
|
+
}
|
|
1910
|
+
|
|
1911
|
+
// src/components/BatchBar.tsx
|
|
1912
|
+
import { jsx as jsx12, jsxs as jsxs10 } from "react/jsx-runtime";
|
|
1913
|
+
function BatchBar({ ids, tab, onClearSelection, onDone }) {
|
|
1914
|
+
const api = useContentAdminApi();
|
|
1915
|
+
const { messages, format } = useContentText();
|
|
1916
|
+
const [isConfirming, setIsConfirming] = useState11(false);
|
|
1917
|
+
const [isBusy, setIsBusy] = useState11(false);
|
|
1918
|
+
const [result, setResult] = useState11();
|
|
1919
|
+
async function run(action) {
|
|
1920
|
+
setIsBusy(true);
|
|
1921
|
+
const calls = ids.map(
|
|
1922
|
+
(id) => action === "publish" ? api.publishPost(id) : action === "unpublish" ? api.unpublishPost(id) : api.archivePost(id)
|
|
1923
|
+
);
|
|
1924
|
+
const settled = await Promise.allSettled(calls);
|
|
1925
|
+
const done = settled.filter((entry) => entry.status === "fulfilled").length;
|
|
1926
|
+
setResult(done === ids.length ? void 0 : format("batchPartial", { done, total: ids.length }));
|
|
1927
|
+
setIsBusy(false);
|
|
1928
|
+
setIsConfirming(false);
|
|
1929
|
+
onDone();
|
|
1930
|
+
}
|
|
1931
|
+
const canPublish = tab === "draft";
|
|
1932
|
+
const canUnpublish = tab === "published" || tab === "scheduled";
|
|
1933
|
+
return /* @__PURE__ */ jsxs10("div", { className: "adc-batch-bar", role: "region", "aria-label": messages.batchLabel, children: [
|
|
1934
|
+
/* @__PURE__ */ jsx12("strong", { children: format("selectedCount", { count: ids.length }) }),
|
|
1935
|
+
canPublish && /* @__PURE__ */ jsxs10(
|
|
1936
|
+
"button",
|
|
1937
|
+
{
|
|
1938
|
+
type: "button",
|
|
1939
|
+
className: "adc-button adc-button--compact",
|
|
1940
|
+
disabled: isBusy,
|
|
1941
|
+
onClick: () => void run("publish"),
|
|
1942
|
+
children: [
|
|
1943
|
+
/* @__PURE__ */ jsx12(CircleCheck2, { "aria-hidden": "true", className: "adc-icon" }),
|
|
1944
|
+
messages.batchPublish
|
|
1945
|
+
]
|
|
1946
|
+
}
|
|
1947
|
+
),
|
|
1948
|
+
canUnpublish && /* @__PURE__ */ jsxs10(
|
|
1949
|
+
"button",
|
|
1950
|
+
{
|
|
1951
|
+
type: "button",
|
|
1952
|
+
className: "adc-button adc-button--compact",
|
|
1953
|
+
disabled: isBusy,
|
|
1954
|
+
onClick: () => void run("unpublish"),
|
|
1955
|
+
children: [
|
|
1956
|
+
/* @__PURE__ */ jsx12(EyeOff2, { "aria-hidden": "true", className: "adc-icon" }),
|
|
1957
|
+
messages.batchUnpublish
|
|
1958
|
+
]
|
|
1959
|
+
}
|
|
1960
|
+
),
|
|
1961
|
+
/* @__PURE__ */ jsxs10(
|
|
1962
|
+
"button",
|
|
1963
|
+
{
|
|
1964
|
+
type: "button",
|
|
1965
|
+
className: "adc-button adc-button--compact adc-button--danger",
|
|
1966
|
+
disabled: isBusy,
|
|
1967
|
+
onClick: () => setIsConfirming(true),
|
|
1968
|
+
children: [
|
|
1969
|
+
/* @__PURE__ */ jsx12(Archive3, { "aria-hidden": "true", className: "adc-icon" }),
|
|
1970
|
+
messages.batchArchive
|
|
1971
|
+
]
|
|
1972
|
+
}
|
|
1973
|
+
),
|
|
1974
|
+
/* @__PURE__ */ jsxs10("button", { type: "button", className: "adc-button adc-button--compact adc-button--ghost", onClick: onClearSelection, children: [
|
|
1975
|
+
/* @__PURE__ */ jsx12(X3, { "aria-hidden": "true", className: "adc-icon" }),
|
|
1976
|
+
messages.clearSelection
|
|
1977
|
+
] }),
|
|
1978
|
+
result && /* @__PURE__ */ jsx12("span", { className: "adc-error", role: "alert", children: result }),
|
|
1979
|
+
isConfirming && /* @__PURE__ */ jsx12(
|
|
1980
|
+
ActionDialog,
|
|
1981
|
+
{
|
|
1982
|
+
title: messages.batchArchive,
|
|
1983
|
+
confirmLabel: messages.batchArchive,
|
|
1984
|
+
confirmIcon: /* @__PURE__ */ jsx12(Archive3, { "aria-hidden": "true", className: "adc-icon" }),
|
|
1985
|
+
isBusy,
|
|
1986
|
+
onClose: () => setIsConfirming(false),
|
|
1987
|
+
onConfirm: () => void run("archive"),
|
|
1988
|
+
children: /* @__PURE__ */ jsx12("p", { children: format("batchArchiveConfirm", { count: ids.length }) })
|
|
1989
|
+
}
|
|
1990
|
+
)
|
|
1991
|
+
] });
|
|
1992
|
+
}
|
|
1993
|
+
|
|
1994
|
+
// src/components/PostActionDialogs.tsx
|
|
1995
|
+
import { CopyPlus, FilePlus2, RefreshCw } from "lucide-react";
|
|
1996
|
+
import { useId as useId7, useState as useState12 } from "react";
|
|
1997
|
+
|
|
1998
|
+
// src/components/DateTimeField.tsx
|
|
1999
|
+
import { jsx as jsx13, jsxs as jsxs11 } from "react/jsx-runtime";
|
|
2000
|
+
function DateTimeField({ renderDateTimeInput, ...props }) {
|
|
2001
|
+
if (renderDateTimeInput) return renderDateTimeInput(props);
|
|
2002
|
+
return /* @__PURE__ */ jsxs11("div", { className: "adc-field", children: [
|
|
2003
|
+
/* @__PURE__ */ jsx13("label", { htmlFor: props.id, children: props.label }),
|
|
2004
|
+
/* @__PURE__ */ jsx13(
|
|
2005
|
+
"input",
|
|
2006
|
+
{
|
|
2007
|
+
id: props.id,
|
|
2008
|
+
type: "datetime-local",
|
|
2009
|
+
value: props.value,
|
|
2010
|
+
onChange: (event) => props.onChange(event.target.value)
|
|
2011
|
+
}
|
|
2012
|
+
)
|
|
2013
|
+
] });
|
|
2014
|
+
}
|
|
2015
|
+
|
|
2016
|
+
// src/components/PostActionDialogs.tsx
|
|
2017
|
+
import { jsx as jsx14, jsxs as jsxs12 } from "react/jsx-runtime";
|
|
2018
|
+
function useAction(run, onDone) {
|
|
2019
|
+
const { messages } = useContentText();
|
|
2020
|
+
const [isBusy, setIsBusy] = useState12(false);
|
|
2021
|
+
const [error, setError] = useState12();
|
|
2022
|
+
async function submit() {
|
|
2023
|
+
setIsBusy(true);
|
|
2024
|
+
setError(void 0);
|
|
2025
|
+
try {
|
|
2026
|
+
onDone(await run());
|
|
2027
|
+
} catch (caught) {
|
|
2028
|
+
setError(caught instanceof Error && caught.message ? caught.message : messages.actionError);
|
|
2029
|
+
setIsBusy(false);
|
|
2030
|
+
}
|
|
2031
|
+
}
|
|
2032
|
+
return { isBusy, error, submit: () => void submit() };
|
|
2033
|
+
}
|
|
2034
|
+
function TitleDialog({ post, heading, fieldLabel, confirmLabel, icon, run, onClose, onDone }) {
|
|
2035
|
+
const [title, setTitle] = useState12(post.title);
|
|
2036
|
+
const id = useId7();
|
|
2037
|
+
const action = useAction(() => run(title.trim() || void 0), onDone);
|
|
2038
|
+
return /* @__PURE__ */ jsx14(
|
|
2039
|
+
ActionDialog,
|
|
2040
|
+
{
|
|
2041
|
+
title: heading,
|
|
2042
|
+
confirmLabel,
|
|
2043
|
+
confirmIcon: icon,
|
|
2044
|
+
onClose,
|
|
2045
|
+
onConfirm: action.submit,
|
|
2046
|
+
isBusy: action.isBusy,
|
|
2047
|
+
error: action.error,
|
|
2048
|
+
children: /* @__PURE__ */ jsxs12("div", { className: "adc-field", children: [
|
|
2049
|
+
/* @__PURE__ */ jsx14("label", { htmlFor: id, children: fieldLabel }),
|
|
2050
|
+
/* @__PURE__ */ jsx14("input", { id, value: title, maxLength: 200, onChange: (event) => setTitle(event.target.value) })
|
|
2051
|
+
] })
|
|
2052
|
+
}
|
|
2053
|
+
);
|
|
2054
|
+
}
|
|
2055
|
+
function SaveAsTemplateDialog(props) {
|
|
2056
|
+
const api = useContentAdminApi();
|
|
2057
|
+
const { messages } = useContentText();
|
|
2058
|
+
return /* @__PURE__ */ jsx14(
|
|
2059
|
+
TitleDialog,
|
|
2060
|
+
{
|
|
2061
|
+
...props,
|
|
2062
|
+
heading: messages.saveAsTemplate,
|
|
2063
|
+
fieldLabel: messages.templateNameLabel,
|
|
2064
|
+
confirmLabel: messages.saveAsTemplate,
|
|
2065
|
+
icon: /* @__PURE__ */ jsx14(CopyPlus, { "aria-hidden": "true", className: "adc-icon" }),
|
|
2066
|
+
run: (title) => api.saveAsTemplate ? api.saveAsTemplate(props.post.id, title ? { title } : {}) : Promise.reject(new Error(messages.actionError))
|
|
2067
|
+
}
|
|
2068
|
+
);
|
|
2069
|
+
}
|
|
2070
|
+
function FromTemplateDialog(props) {
|
|
2071
|
+
const api = useContentAdminApi();
|
|
2072
|
+
const { messages } = useContentText();
|
|
2073
|
+
return /* @__PURE__ */ jsx14(
|
|
2074
|
+
TitleDialog,
|
|
2075
|
+
{
|
|
2076
|
+
...props,
|
|
2077
|
+
heading: messages.newFromTemplate,
|
|
2078
|
+
fieldLabel: messages.newPostTitleLabel,
|
|
2079
|
+
confirmLabel: messages.createDraft,
|
|
2080
|
+
icon: /* @__PURE__ */ jsx14(FilePlus2, { "aria-hidden": "true", className: "adc-icon" }),
|
|
2081
|
+
run: (title) => api.createFromTemplate ? api.createFromTemplate(props.post.id, title ? { title } : {}) : Promise.reject(new Error(messages.actionError))
|
|
2082
|
+
}
|
|
2083
|
+
);
|
|
2084
|
+
}
|
|
2085
|
+
function RepublishDialog({
|
|
2086
|
+
post,
|
|
2087
|
+
renderDateTimeInput,
|
|
2088
|
+
onClose,
|
|
2089
|
+
onDone
|
|
2090
|
+
}) {
|
|
2091
|
+
const api = useContentAdminApi();
|
|
2092
|
+
const { messages } = useContentText();
|
|
2093
|
+
const [value, setValue] = useState12(() => toDateTimeLocalValue((/* @__PURE__ */ new Date()).toISOString()));
|
|
2094
|
+
const id = useId7();
|
|
2095
|
+
const action = useAction(() => {
|
|
2096
|
+
if (!api.republishPost) return Promise.reject(new Error(messages.actionError));
|
|
2097
|
+
const publishedAt = fromDateTimeLocalValue(value);
|
|
2098
|
+
return api.republishPost(post.id, publishedAt ? { publishedAt } : {});
|
|
2099
|
+
}, onDone);
|
|
2100
|
+
return /* @__PURE__ */ jsxs12(
|
|
2101
|
+
ActionDialog,
|
|
2102
|
+
{
|
|
2103
|
+
title: messages.republish,
|
|
2104
|
+
confirmLabel: messages.republish,
|
|
2105
|
+
confirmIcon: /* @__PURE__ */ jsx14(RefreshCw, { "aria-hidden": "true", className: "adc-icon" }),
|
|
2106
|
+
onClose,
|
|
2107
|
+
onConfirm: action.submit,
|
|
2108
|
+
isBusy: action.isBusy,
|
|
2109
|
+
error: action.error,
|
|
2110
|
+
children: [
|
|
2111
|
+
/* @__PURE__ */ jsx14("p", { className: "adc-muted", children: post.title }),
|
|
2112
|
+
/* @__PURE__ */ jsx14(
|
|
2113
|
+
DateTimeField,
|
|
2114
|
+
{
|
|
2115
|
+
id,
|
|
2116
|
+
label: messages.republishDateLabel,
|
|
2117
|
+
value,
|
|
2118
|
+
onChange: setValue,
|
|
2119
|
+
renderDateTimeInput
|
|
2120
|
+
}
|
|
2121
|
+
),
|
|
2122
|
+
/* @__PURE__ */ jsx14("p", { className: "adc-hint", children: messages.republishHint })
|
|
2123
|
+
]
|
|
2124
|
+
}
|
|
2125
|
+
);
|
|
2126
|
+
}
|
|
2127
|
+
|
|
2128
|
+
// src/components/PostListFooter.tsx
|
|
2129
|
+
import { useId as useId8 } from "react";
|
|
2130
|
+
|
|
1039
2131
|
// src/components/Pagination.tsx
|
|
1040
2132
|
import { ChevronLeft, ChevronRight } from "lucide-react";
|
|
1041
2133
|
|
|
@@ -1059,7 +2151,7 @@ function buildPageItems(params) {
|
|
|
1059
2151
|
}
|
|
1060
2152
|
|
|
1061
2153
|
// src/components/Pagination.tsx
|
|
1062
|
-
import { jsx as
|
|
2154
|
+
import { jsx as jsx15, jsxs as jsxs13 } from "react/jsx-runtime";
|
|
1063
2155
|
function Pagination({ page, totalPages, getPageHref, onPageChange }) {
|
|
1064
2156
|
const { messages, format } = useContentText();
|
|
1065
2157
|
const renderLink = useRenderLink();
|
|
@@ -1068,7 +2160,7 @@ function Pagination({ page, totalPages, getPageHref, onPageChange }) {
|
|
|
1068
2160
|
const className = `adc-page${isCurrent ? " adc-page--current" : ""}`;
|
|
1069
2161
|
if (getPageHref && !isCurrent)
|
|
1070
2162
|
return renderLink({ href: getPageHref(target), className, "aria-label": label, children: content });
|
|
1071
|
-
return /* @__PURE__ */
|
|
2163
|
+
return /* @__PURE__ */ jsx15(
|
|
1072
2164
|
"button",
|
|
1073
2165
|
{
|
|
1074
2166
|
type: "button",
|
|
@@ -1081,133 +2173,563 @@ function Pagination({ page, totalPages, getPageHref, onPageChange }) {
|
|
|
1081
2173
|
}
|
|
1082
2174
|
);
|
|
1083
2175
|
}
|
|
1084
|
-
return /* @__PURE__ */
|
|
1085
|
-
page > 1 && renderTarget(page - 1, messages.paginationPrevious, /* @__PURE__ */
|
|
2176
|
+
return /* @__PURE__ */ jsxs13("nav", { className: "adc-pagination", "aria-label": messages.paginationLabel, children: [
|
|
2177
|
+
page > 1 && renderTarget(page - 1, messages.paginationPrevious, /* @__PURE__ */ jsx15(ChevronLeft, { "aria-hidden": "true", className: "adc-icon" })),
|
|
1086
2178
|
buildPageItems({ current: page, total: totalPages }).map(
|
|
1087
|
-
(item) => item.kind === "gap" ? /* @__PURE__ */
|
|
2179
|
+
(item) => item.kind === "gap" ? /* @__PURE__ */ jsx15("span", { className: "adc-page-gap", "aria-hidden": "true", children: "\u2026" }, item.key) : /* @__PURE__ */ jsx15("span", { children: renderTarget(item.page, format("pageLabel", { page: item.page }), item.page, item.page === page) }, item.page)
|
|
1088
2180
|
),
|
|
1089
|
-
page < totalPages && renderTarget(page + 1, messages.paginationNext, /* @__PURE__ */
|
|
2181
|
+
page < totalPages && renderTarget(page + 1, messages.paginationNext, /* @__PURE__ */ jsx15(ChevronRight, { "aria-hidden": "true", className: "adc-icon" }))
|
|
1090
2182
|
] });
|
|
1091
2183
|
}
|
|
1092
2184
|
|
|
1093
|
-
// src/components/
|
|
1094
|
-
import { jsx as
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
};
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
});
|
|
1107
|
-
const
|
|
1108
|
-
const
|
|
1109
|
-
const
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
2185
|
+
// src/components/SelectField.tsx
|
|
2186
|
+
import { jsx as jsx16, jsxs as jsxs14 } from "react/jsx-runtime";
|
|
2187
|
+
function SelectField({ renderSelect, ...props }) {
|
|
2188
|
+
if (renderSelect) return renderSelect(props);
|
|
2189
|
+
return /* @__PURE__ */ jsxs14("div", { className: "adc-field", children: [
|
|
2190
|
+
/* @__PURE__ */ jsx16("label", { htmlFor: props.id, children: props.label }),
|
|
2191
|
+
/* @__PURE__ */ jsx16("select", { id: props.id, value: props.value, onChange: (event) => props.onChange(event.target.value), children: props.options.map((option) => /* @__PURE__ */ jsx16("option", { value: option.id, children: option.label }, option.id)) })
|
|
2192
|
+
] });
|
|
2193
|
+
}
|
|
2194
|
+
|
|
2195
|
+
// src/components/PostListFooter.tsx
|
|
2196
|
+
import { jsx as jsx17, jsxs as jsxs15 } from "react/jsx-runtime";
|
|
2197
|
+
function PostListFooter({ data, pageSize, onPage, onPageSize, renderSelect }) {
|
|
2198
|
+
const { messages, format } = useContentText();
|
|
2199
|
+
const id = useId8();
|
|
2200
|
+
const { page, total } = data.pagination;
|
|
2201
|
+
const from = total === 0 ? 0 : (page - 1) * pageSize + 1;
|
|
2202
|
+
const to = Math.min(page * pageSize, total);
|
|
2203
|
+
return /* @__PURE__ */ jsxs15("div", { className: "adc-list-footer", children: [
|
|
2204
|
+
/* @__PURE__ */ jsx17("span", { className: "adc-muted", "aria-live": "polite", children: format("rangeLabel", { from, to, total }) }),
|
|
2205
|
+
/* @__PURE__ */ jsx17(Pagination, { page, totalPages: data.pagination.totalPages, onPageChange: onPage }),
|
|
2206
|
+
/* @__PURE__ */ jsx17(
|
|
2207
|
+
SelectField,
|
|
2208
|
+
{
|
|
2209
|
+
id,
|
|
2210
|
+
label: messages.itemsPerPage,
|
|
2211
|
+
value: String(pageSize),
|
|
2212
|
+
options: PAGE_SIZE_OPTIONS.map((size) => ({ id: String(size), label: String(size) })),
|
|
2213
|
+
onChange: (value) => onPageSize(Number(value)),
|
|
2214
|
+
renderSelect
|
|
2215
|
+
}
|
|
2216
|
+
)
|
|
2217
|
+
] });
|
|
2218
|
+
}
|
|
2219
|
+
|
|
2220
|
+
// src/components/PostListTabs.tsx
|
|
2221
|
+
import { CalendarClock as CalendarClock3, CircleCheck as CircleCheck3, Copy as Copy2, PencilLine as PencilLine2 } from "lucide-react";
|
|
2222
|
+
import { jsx as jsx18, jsxs as jsxs16 } from "react/jsx-runtime";
|
|
2223
|
+
var TABS2 = [
|
|
2224
|
+
{ id: POST_LIST_TAB.PUBLISHED, icon: CircleCheck3, label: "tabPublished", count: "published" },
|
|
2225
|
+
{ id: POST_LIST_TAB.SCHEDULED, icon: CalendarClock3, label: "tabScheduled", count: "scheduled" },
|
|
2226
|
+
{ id: POST_LIST_TAB.DRAFT, icon: PencilLine2, label: "tabDraft", count: "draft" },
|
|
2227
|
+
{ id: POST_LIST_TAB.TEMPLATES, icon: Copy2, label: "tabTemplates", count: "templates" }
|
|
2228
|
+
];
|
|
2229
|
+
function PostListTabs({ active, counts, onChange }) {
|
|
2230
|
+
const { messages } = useContentText();
|
|
2231
|
+
return /* @__PURE__ */ jsx18("div", { className: "adc-status-tabs", role: "tablist", "aria-label": messages.tabsLabel, children: TABS2.map(({ id, icon: Icon, label, count }) => /* @__PURE__ */ jsxs16(
|
|
2232
|
+
"button",
|
|
2233
|
+
{
|
|
2234
|
+
type: "button",
|
|
2235
|
+
role: "tab",
|
|
2236
|
+
"aria-selected": id === active,
|
|
2237
|
+
className: `adc-status-tab adc-status-tab--${id}`,
|
|
2238
|
+
onClick: () => onChange(id),
|
|
2239
|
+
children: [
|
|
2240
|
+
/* @__PURE__ */ jsx18(Icon, { "aria-hidden": "true", className: "adc-icon" }),
|
|
2241
|
+
/* @__PURE__ */ jsx18("span", { children: messages[label] }),
|
|
2242
|
+
/* @__PURE__ */ jsx18("span", { className: "adc-status-tab__count", children: counts ? counts[count] : "\u2013" })
|
|
2243
|
+
]
|
|
2244
|
+
},
|
|
2245
|
+
id
|
|
2246
|
+
)) });
|
|
2247
|
+
}
|
|
2248
|
+
|
|
2249
|
+
// src/components/PostListToolbar.tsx
|
|
2250
|
+
import { formatTagLabel } from "@adatechnology/content-contracts";
|
|
2251
|
+
import { Plus, RotateCcw, Search } from "lucide-react";
|
|
2252
|
+
import { useId as useId9 } from "react";
|
|
2253
|
+
import { jsx as jsx19, jsxs as jsxs17 } from "react/jsx-runtime";
|
|
2254
|
+
function PostListToolbar(props) {
|
|
2255
|
+
const { messages } = useContentText();
|
|
2256
|
+
const searchId = useId9();
|
|
2257
|
+
return /* @__PURE__ */ jsxs17("div", { className: "adc-list-toolbar", children: [
|
|
2258
|
+
/* @__PURE__ */ jsxs17("div", { className: "adc-list-toolbar__filters", children: [
|
|
2259
|
+
/* @__PURE__ */ jsxs17("div", { className: "adc-field adc-field--search", children: [
|
|
2260
|
+
/* @__PURE__ */ jsx19("label", { htmlFor: searchId, className: "adc-visually-hidden", children: messages.searchLabel }),
|
|
2261
|
+
/* @__PURE__ */ jsxs17("div", { className: "adc-input-icon", children: [
|
|
2262
|
+
/* @__PURE__ */ jsx19(Search, { "aria-hidden": "true", className: "adc-icon" }),
|
|
2263
|
+
/* @__PURE__ */ jsx19(
|
|
1124
2264
|
"input",
|
|
1125
2265
|
{
|
|
1126
2266
|
id: searchId,
|
|
1127
|
-
type: "
|
|
2267
|
+
type: "text",
|
|
2268
|
+
inputMode: "search",
|
|
2269
|
+
autoComplete: "off",
|
|
1128
2270
|
placeholder: messages.searchPlaceholder,
|
|
1129
|
-
value:
|
|
1130
|
-
onChange: (event) =>
|
|
2271
|
+
value: props.search,
|
|
2272
|
+
onChange: (event) => props.onSearch(event.target.value)
|
|
1131
2273
|
}
|
|
1132
2274
|
)
|
|
1133
2275
|
] })
|
|
1134
2276
|
] }),
|
|
1135
|
-
/* @__PURE__ */
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
"
|
|
2277
|
+
props.tags && props.tags.length > 0 && /* @__PURE__ */ jsx19("div", { className: "adc-tag-toggles", role: "group", "aria-label": messages.filterTag, children: props.tags.slice(0, 12).map((entry) => /* @__PURE__ */ jsxs17(
|
|
2278
|
+
"button",
|
|
2279
|
+
{
|
|
2280
|
+
type: "button",
|
|
2281
|
+
className: "adc-tag-toggle",
|
|
2282
|
+
"aria-pressed": props.selectedTags.includes(entry.tag),
|
|
2283
|
+
onClick: () => props.onToggleTag(entry.tag),
|
|
2284
|
+
children: [
|
|
2285
|
+
formatTagLabel(entry.tag),
|
|
2286
|
+
/* @__PURE__ */ jsx19("span", { className: "adc-tag-toggle__count", children: entry.count })
|
|
2287
|
+
]
|
|
2288
|
+
},
|
|
2289
|
+
entry.tag
|
|
2290
|
+
)) }),
|
|
2291
|
+
props.hasFilters && /* @__PURE__ */ jsxs17("button", { type: "button", className: "adc-button adc-button--ghost", onClick: props.onClear, children: [
|
|
2292
|
+
/* @__PURE__ */ jsx19(RotateCcw, { "aria-hidden": "true", className: "adc-icon" }),
|
|
2293
|
+
messages.clearFilters
|
|
2294
|
+
] })
|
|
2295
|
+
] }),
|
|
2296
|
+
props.onCreate && /* @__PURE__ */ jsxs17("button", { type: "button", className: "adc-button adc-button--primary", onClick: props.onCreate, children: [
|
|
2297
|
+
/* @__PURE__ */ jsx19(Plus, { "aria-hidden": "true", className: "adc-icon" }),
|
|
2298
|
+
messages.newPost
|
|
2299
|
+
] })
|
|
2300
|
+
] });
|
|
2301
|
+
}
|
|
2302
|
+
|
|
2303
|
+
// src/components/PostTable.tsx
|
|
2304
|
+
import { ArrowDown, ArrowUp, ChevronsUpDown } from "lucide-react";
|
|
2305
|
+
|
|
2306
|
+
// src/components/CheckBox.tsx
|
|
2307
|
+
import { Check, Minus } from "lucide-react";
|
|
2308
|
+
import { jsx as jsx20 } from "react/jsx-runtime";
|
|
2309
|
+
function CheckBox({ checked, isMixed = false, label, onChange }) {
|
|
2310
|
+
const Icon = isMixed ? Minus : Check;
|
|
2311
|
+
return /* @__PURE__ */ jsx20(
|
|
2312
|
+
"button",
|
|
2313
|
+
{
|
|
2314
|
+
type: "button",
|
|
2315
|
+
role: "checkbox",
|
|
2316
|
+
"aria-checked": isMixed ? "mixed" : checked,
|
|
2317
|
+
"aria-label": label,
|
|
2318
|
+
className: `adc-checkbox${checked || isMixed ? " is-on" : ""}`,
|
|
2319
|
+
onClick: onChange,
|
|
2320
|
+
children: (checked || isMixed) && /* @__PURE__ */ jsx20(Icon, { "aria-hidden": "true", className: "adc-icon" })
|
|
2321
|
+
}
|
|
2322
|
+
);
|
|
2323
|
+
}
|
|
2324
|
+
|
|
2325
|
+
// src/components/PostTable.tsx
|
|
2326
|
+
import { jsx as jsx21, jsxs as jsxs18 } from "react/jsx-runtime";
|
|
2327
|
+
var SORTABLE_COLUMNS = [
|
|
2328
|
+
{ field: "title", label: "columnTitle" },
|
|
2329
|
+
{ field: "status", label: "columnStatus" },
|
|
2330
|
+
{ field: "publishedAt", label: "columnPublished" },
|
|
2331
|
+
{ field: "updatedAt", label: "columnUpdated" }
|
|
2332
|
+
];
|
|
2333
|
+
function PostTable(props) {
|
|
2334
|
+
const { messages, locale } = useContentText();
|
|
2335
|
+
const selectedCount = props.rows.filter((row) => props.selectedIds.has(row.id)).length;
|
|
2336
|
+
const isAll = selectedCount > 0 && selectedCount === props.rows.length;
|
|
2337
|
+
return /* @__PURE__ */ jsx21("div", { className: "adc-table-wrap", "aria-busy": props.isBusy, children: /* @__PURE__ */ jsxs18("table", { className: "adc-table", children: [
|
|
2338
|
+
/* @__PURE__ */ jsx21("thead", { children: /* @__PURE__ */ jsxs18("tr", { children: [
|
|
2339
|
+
/* @__PURE__ */ jsx21("th", { scope: "col", className: "adc-table__check", children: /* @__PURE__ */ jsx21(
|
|
2340
|
+
CheckBox,
|
|
2341
|
+
{
|
|
2342
|
+
checked: isAll,
|
|
2343
|
+
isMixed: selectedCount > 0 && !isAll,
|
|
2344
|
+
label: messages.selectAll,
|
|
2345
|
+
onChange: props.onToggleAll
|
|
2346
|
+
}
|
|
2347
|
+
) }),
|
|
2348
|
+
SORTABLE_COLUMNS.map(({ field, label }) => {
|
|
2349
|
+
const isActive = props.sort === field;
|
|
2350
|
+
const Icon = !isActive ? ChevronsUpDown : props.order === "asc" ? ArrowUp : ArrowDown;
|
|
2351
|
+
return /* @__PURE__ */ jsx21(
|
|
2352
|
+
"th",
|
|
1139
2353
|
{
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
/* @__PURE__ */
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
)
|
|
2354
|
+
scope: "col",
|
|
2355
|
+
"aria-sort": !isActive ? "none" : props.order === "asc" ? "ascending" : "descending",
|
|
2356
|
+
children: /* @__PURE__ */ jsxs18("button", { type: "button", className: "adc-sort", onClick: () => props.onSort(field), children: [
|
|
2357
|
+
messages[label],
|
|
2358
|
+
/* @__PURE__ */ jsx21(Icon, { "aria-hidden": "true", className: "adc-icon" })
|
|
2359
|
+
] })
|
|
2360
|
+
},
|
|
2361
|
+
field
|
|
2362
|
+
);
|
|
2363
|
+
}),
|
|
2364
|
+
props.hasActions && /* @__PURE__ */ jsx21("th", { scope: "col", children: messages.columnActions })
|
|
2365
|
+
] }) }),
|
|
2366
|
+
/* @__PURE__ */ jsx21("tbody", { children: props.rows.map((post) => /* @__PURE__ */ jsxs18("tr", { className: props.selectedIds.has(post.id) ? "is-selected" : void 0, children: [
|
|
2367
|
+
/* @__PURE__ */ jsx21("td", { className: "adc-table__check", children: /* @__PURE__ */ jsx21(
|
|
2368
|
+
CheckBox,
|
|
2369
|
+
{
|
|
2370
|
+
checked: props.selectedIds.has(post.id),
|
|
2371
|
+
label: messages.selectRow.replace("{title}", post.title),
|
|
2372
|
+
onChange: () => props.onToggleSelected(post.id)
|
|
2373
|
+
}
|
|
2374
|
+
) }),
|
|
2375
|
+
/* @__PURE__ */ jsxs18("td", { children: [
|
|
2376
|
+
/* @__PURE__ */ jsx21("button", { type: "button", className: "adc-row-link", onClick: () => props.onSelect(post), children: post.title }),
|
|
2377
|
+
/* @__PURE__ */ jsxs18("span", { className: "adc-muted adc-slug", children: [
|
|
2378
|
+
"/",
|
|
2379
|
+
post.slug
|
|
2380
|
+
] })
|
|
1149
2381
|
] }),
|
|
1150
|
-
/* @__PURE__ */
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
2382
|
+
/* @__PURE__ */ jsx21("td", { children: /* @__PURE__ */ jsx21(StatusChip, { status: post.status, isTemplate: post.isTemplate }) }),
|
|
2383
|
+
/* @__PURE__ */ jsx21("td", { children: formatPostDate(post.publishedAt, locale, true) }),
|
|
2384
|
+
/* @__PURE__ */ jsx21("td", { children: formatPostDate(post.updatedAt, locale, true) }),
|
|
2385
|
+
props.hasActions && /* @__PURE__ */ jsx21("td", { className: "adc-row-actions", children: props.renderActions(post) })
|
|
2386
|
+
] }, post.id)) })
|
|
2387
|
+
] }) });
|
|
2388
|
+
}
|
|
2389
|
+
|
|
2390
|
+
// src/components/RecurrencePanel.tsx
|
|
2391
|
+
import {
|
|
2392
|
+
RECURRENCE_FREQUENCY
|
|
2393
|
+
} from "@adatechnology/content-contracts";
|
|
2394
|
+
import { CirclePause, CirclePlay, Plus as Plus2, Repeat, Trash2 as Trash22 } from "lucide-react";
|
|
2395
|
+
import { useId as useId10, useState as useState13 } from "react";
|
|
2396
|
+
import { jsx as jsx22, jsxs as jsxs19 } from "react/jsx-runtime";
|
|
2397
|
+
function defaultStart() {
|
|
2398
|
+
const next = new Date(Date.now() + 24 * 60 * 60 * 1e3);
|
|
2399
|
+
next.setMinutes(0, 0, 0);
|
|
2400
|
+
return toDateTimeLocalValue(next.toISOString());
|
|
2401
|
+
}
|
|
2402
|
+
function CreateRecurrenceDialog({
|
|
2403
|
+
templates,
|
|
2404
|
+
renderDateTimeInput,
|
|
2405
|
+
renderSelect,
|
|
2406
|
+
onClose,
|
|
2407
|
+
onCreated
|
|
2408
|
+
}) {
|
|
2409
|
+
const api = useContentAdminApi();
|
|
2410
|
+
const { messages } = useContentText();
|
|
2411
|
+
const [templateId, setTemplateId] = useState13(templates[0]?.id ?? "");
|
|
2412
|
+
const [frequency, setFrequency] = useState13(RECURRENCE_FREQUENCY.WEEKLY);
|
|
2413
|
+
const [startsAt, setStartsAt] = useState13(defaultStart);
|
|
2414
|
+
const [isBusy, setIsBusy] = useState13(false);
|
|
2415
|
+
const [error, setError] = useState13();
|
|
2416
|
+
const ids = { template: useId10(), frequency: useId10(), start: useId10() };
|
|
2417
|
+
async function submit() {
|
|
2418
|
+
const iso = fromDateTimeLocalValue(startsAt);
|
|
2419
|
+
if (!api.createRecurrence || !iso || !templateId) return;
|
|
2420
|
+
setIsBusy(true);
|
|
2421
|
+
try {
|
|
2422
|
+
await api.createRecurrence({ templateId, frequency, startsAt: iso });
|
|
2423
|
+
onCreated();
|
|
2424
|
+
} catch (caught) {
|
|
2425
|
+
setError(caught instanceof Error && caught.message ? caught.message : messages.actionError);
|
|
2426
|
+
setIsBusy(false);
|
|
2427
|
+
}
|
|
2428
|
+
}
|
|
2429
|
+
return /* @__PURE__ */ jsxs19(
|
|
2430
|
+
ActionDialog,
|
|
2431
|
+
{
|
|
2432
|
+
title: messages.recurrenceNew,
|
|
2433
|
+
confirmLabel: messages.recurrenceCreate,
|
|
2434
|
+
confirmIcon: /* @__PURE__ */ jsx22(Repeat, { "aria-hidden": "true", className: "adc-icon" }),
|
|
2435
|
+
isBusy,
|
|
2436
|
+
error,
|
|
2437
|
+
onClose,
|
|
2438
|
+
onConfirm: () => void submit(),
|
|
2439
|
+
children: [
|
|
2440
|
+
/* @__PURE__ */ jsx22(
|
|
2441
|
+
SelectField,
|
|
1154
2442
|
{
|
|
1155
|
-
id:
|
|
1156
|
-
|
|
1157
|
-
value:
|
|
1158
|
-
|
|
2443
|
+
id: ids.template,
|
|
2444
|
+
label: messages.recurrenceTemplate,
|
|
2445
|
+
value: templateId,
|
|
2446
|
+
options: templates.map((template) => ({ id: template.id, label: template.title })),
|
|
2447
|
+
onChange: setTemplateId,
|
|
2448
|
+
renderSelect
|
|
1159
2449
|
}
|
|
1160
2450
|
),
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
2451
|
+
/* @__PURE__ */ jsx22(
|
|
2452
|
+
SelectField,
|
|
2453
|
+
{
|
|
2454
|
+
id: ids.frequency,
|
|
2455
|
+
label: messages.recurrenceFrequency,
|
|
2456
|
+
value: frequency,
|
|
2457
|
+
options: [
|
|
2458
|
+
{ id: RECURRENCE_FREQUENCY.WEEKLY, label: messages.frequencyWeekly },
|
|
2459
|
+
{ id: RECURRENCE_FREQUENCY.MONTHLY, label: messages.frequencyMonthly }
|
|
2460
|
+
],
|
|
2461
|
+
onChange: (value) => setFrequency(value),
|
|
2462
|
+
renderSelect
|
|
2463
|
+
}
|
|
2464
|
+
),
|
|
2465
|
+
/* @__PURE__ */ jsx22(
|
|
2466
|
+
DateTimeField,
|
|
2467
|
+
{
|
|
2468
|
+
id: ids.start,
|
|
2469
|
+
label: messages.recurrenceStart,
|
|
2470
|
+
value: startsAt,
|
|
2471
|
+
onChange: setStartsAt,
|
|
2472
|
+
renderDateTimeInput
|
|
2473
|
+
}
|
|
2474
|
+
),
|
|
2475
|
+
/* @__PURE__ */ jsx22("p", { className: "adc-hint", children: messages.recurrenceHint })
|
|
2476
|
+
]
|
|
2477
|
+
}
|
|
2478
|
+
);
|
|
2479
|
+
}
|
|
2480
|
+
function RuleRow({ rule, onChanged }) {
|
|
2481
|
+
const api = useContentAdminApi();
|
|
2482
|
+
const { messages, locale, format } = useContentText();
|
|
2483
|
+
const toggleLabel = rule.isActive ? messages.recurrencePause : messages.recurrenceResume;
|
|
2484
|
+
const ToggleIcon = rule.isActive ? CirclePause : CirclePlay;
|
|
2485
|
+
const StateIcon = rule.isActive ? CirclePlay : CirclePause;
|
|
2486
|
+
async function toggle() {
|
|
2487
|
+
await api.updateRecurrence?.(rule.id, { isActive: !rule.isActive });
|
|
2488
|
+
onChanged();
|
|
2489
|
+
}
|
|
2490
|
+
async function remove() {
|
|
2491
|
+
await api.removeRecurrence?.(rule.id);
|
|
2492
|
+
onChanged();
|
|
2493
|
+
}
|
|
2494
|
+
return /* @__PURE__ */ jsxs19("li", { className: "adc-rule", children: [
|
|
2495
|
+
/* @__PURE__ */ jsxs19("div", { className: "adc-rule__main", children: [
|
|
2496
|
+
/* @__PURE__ */ jsx22("strong", { children: rule.templateTitle }),
|
|
2497
|
+
/* @__PURE__ */ jsxs19("span", { className: "adc-muted", children: [
|
|
2498
|
+
rule.frequency === RECURRENCE_FREQUENCY.WEEKLY ? messages.frequencyWeekly : messages.frequencyMonthly,
|
|
2499
|
+
rule.isActive && ` \xB7 ${format("recurrenceNext", { date: formatPostDate(rule.nextRunAt, locale, true) })}`
|
|
1166
2500
|
] })
|
|
1167
2501
|
] }),
|
|
1168
|
-
|
|
2502
|
+
/* @__PURE__ */ jsxs19("span", { className: `adc-chip adc-badge adc-chip--${rule.isActive ? "published" : "draft"}`, children: [
|
|
2503
|
+
/* @__PURE__ */ jsx22(StateIcon, { "aria-hidden": "true", className: "adc-icon" }),
|
|
2504
|
+
rule.isActive ? messages.recurrenceActive : messages.recurrencePaused
|
|
2505
|
+
] }),
|
|
2506
|
+
/* @__PURE__ */ jsx22(Tooltip, { text: toggleLabel, children: /* @__PURE__ */ jsx22(
|
|
2507
|
+
"button",
|
|
2508
|
+
{
|
|
2509
|
+
type: "button",
|
|
2510
|
+
className: "adc-button adc-button--ghost adc-button--icon",
|
|
2511
|
+
"aria-label": toggleLabel,
|
|
2512
|
+
onClick: () => void toggle(),
|
|
2513
|
+
children: /* @__PURE__ */ jsx22(ToggleIcon, { "aria-hidden": "true", className: "adc-icon" })
|
|
2514
|
+
}
|
|
2515
|
+
) }),
|
|
2516
|
+
/* @__PURE__ */ jsx22(Tooltip, { text: messages.recurrenceRemoveTip, children: /* @__PURE__ */ jsx22(
|
|
2517
|
+
"button",
|
|
2518
|
+
{
|
|
2519
|
+
type: "button",
|
|
2520
|
+
className: "adc-button adc-button--ghost adc-button--icon adc-button--danger",
|
|
2521
|
+
"aria-label": messages.recurrenceRemove,
|
|
2522
|
+
onClick: () => void remove(),
|
|
2523
|
+
children: /* @__PURE__ */ jsx22(Trash22, { "aria-hidden": "true", className: "adc-icon" })
|
|
2524
|
+
}
|
|
2525
|
+
) })
|
|
2526
|
+
] });
|
|
2527
|
+
}
|
|
2528
|
+
function RecurrencePanel(props) {
|
|
2529
|
+
const api = useContentAdminApi();
|
|
2530
|
+
const { messages } = useContentText();
|
|
2531
|
+
const [isCreating, setIsCreating] = useState13(false);
|
|
2532
|
+
const rules = useAsyncResource(
|
|
2533
|
+
() => api.listRecurrences ? api.listRecurrences() : Promise.resolve([]),
|
|
2534
|
+
"recurrences"
|
|
2535
|
+
);
|
|
2536
|
+
if (!api.listRecurrences) return null;
|
|
2537
|
+
return /* @__PURE__ */ jsxs19("section", { className: "adc-recurrence", "aria-labelledby": "adc-recurrence-title", children: [
|
|
2538
|
+
/* @__PURE__ */ jsxs19("header", { className: "adc-toolbar", children: [
|
|
2539
|
+
/* @__PURE__ */ jsxs19("h3", { id: "adc-recurrence-title", className: "adc-subtitle", children: [
|
|
2540
|
+
/* @__PURE__ */ jsx22(Repeat, { "aria-hidden": "true", className: "adc-icon" }),
|
|
2541
|
+
" ",
|
|
2542
|
+
messages.recurrenceTitle
|
|
2543
|
+
] }),
|
|
2544
|
+
/* @__PURE__ */ jsxs19(
|
|
2545
|
+
"button",
|
|
2546
|
+
{
|
|
2547
|
+
type: "button",
|
|
2548
|
+
className: "adc-button",
|
|
2549
|
+
disabled: props.templates.length === 0,
|
|
2550
|
+
onClick: () => setIsCreating(true),
|
|
2551
|
+
children: [
|
|
2552
|
+
/* @__PURE__ */ jsx22(Plus2, { "aria-hidden": "true", className: "adc-icon" }),
|
|
2553
|
+
messages.recurrenceNew
|
|
2554
|
+
]
|
|
2555
|
+
}
|
|
2556
|
+
)
|
|
2557
|
+
] }),
|
|
2558
|
+
(rules.data?.length ?? 0) === 0 ? /* @__PURE__ */ jsx22("p", { className: "adc-state", children: props.templates.length === 0 ? messages.recurrenceNeedsTemplate : messages.recurrenceEmpty }) : /* @__PURE__ */ jsx22("ul", { className: "adc-rule-list", children: rules.data?.map((rule) => /* @__PURE__ */ jsx22(RuleRow, { rule, onChanged: rules.reload }, rule.id)) }),
|
|
2559
|
+
isCreating && /* @__PURE__ */ jsx22(
|
|
2560
|
+
CreateRecurrenceDialog,
|
|
2561
|
+
{
|
|
2562
|
+
...props,
|
|
2563
|
+
onClose: () => setIsCreating(false),
|
|
2564
|
+
onCreated: () => {
|
|
2565
|
+
setIsCreating(false);
|
|
2566
|
+
rules.reload();
|
|
2567
|
+
}
|
|
2568
|
+
}
|
|
2569
|
+
)
|
|
2570
|
+
] });
|
|
2571
|
+
}
|
|
2572
|
+
|
|
2573
|
+
// src/components/PostList.tsx
|
|
2574
|
+
import { jsx as jsx23, jsxs as jsxs20 } from "react/jsx-runtime";
|
|
2575
|
+
function PostList({
|
|
2576
|
+
onSelect,
|
|
2577
|
+
onCreate,
|
|
2578
|
+
pageSize = 20,
|
|
2579
|
+
reloadKey,
|
|
2580
|
+
syncUrl,
|
|
2581
|
+
renderDateTimeInput,
|
|
2582
|
+
renderSelect
|
|
2583
|
+
}) {
|
|
2584
|
+
const { messages } = useContentText();
|
|
2585
|
+
const api = useContentAdminApi();
|
|
2586
|
+
const [dialog, setDialog] = useState14();
|
|
2587
|
+
const list = usePostList({
|
|
2588
|
+
pageSize,
|
|
2589
|
+
...reloadKey !== void 0 ? { reloadKey } : {},
|
|
2590
|
+
...syncUrl ? { syncUrl } : {}
|
|
2591
|
+
});
|
|
2592
|
+
const { posts, state, tab } = list;
|
|
2593
|
+
const rows = posts.data?.data ?? [];
|
|
2594
|
+
function actionsFor(post) {
|
|
2595
|
+
if (post.isTemplate) {
|
|
2596
|
+
return api.createFromTemplate ? [
|
|
2597
|
+
{
|
|
2598
|
+
action: "fromTemplate",
|
|
2599
|
+
icon: FilePlus22,
|
|
2600
|
+
label: messages.newFromTemplate,
|
|
2601
|
+
tip: messages.newFromTemplateTip
|
|
2602
|
+
}
|
|
2603
|
+
] : [];
|
|
2604
|
+
}
|
|
2605
|
+
return [
|
|
2606
|
+
...post.status === "published" && api.republishPost ? [{ action: "republish", icon: RefreshCw2, label: messages.republish, tip: messages.republishTip }] : [],
|
|
2607
|
+
...api.saveAsTemplate ? [
|
|
2608
|
+
{
|
|
2609
|
+
action: "saveAsTemplate",
|
|
2610
|
+
icon: CopyPlus2,
|
|
2611
|
+
label: messages.saveAsTemplate,
|
|
2612
|
+
tip: messages.saveAsTemplateTip
|
|
2613
|
+
}
|
|
2614
|
+
] : []
|
|
2615
|
+
];
|
|
2616
|
+
}
|
|
2617
|
+
function handleActionDone(post) {
|
|
2618
|
+
const action = dialog?.action;
|
|
2619
|
+
setDialog(void 0);
|
|
2620
|
+
list.refresh();
|
|
2621
|
+
if (action === "fromTemplate") onSelect(post);
|
|
2622
|
+
if (action === "saveAsTemplate") list.setTab(POST_LIST_TAB.TEMPLATES);
|
|
2623
|
+
}
|
|
2624
|
+
function toggleAll() {
|
|
2625
|
+
list.setSelectedIds(list.selectedIds.size === rows.length ? /* @__PURE__ */ new Set() : new Set(rows.map((row) => row.id)));
|
|
2626
|
+
}
|
|
2627
|
+
return /* @__PURE__ */ jsxs20("section", { className: "adc-root adc-post-list", children: [
|
|
2628
|
+
/* @__PURE__ */ jsx23("header", { className: "adc-toolbar", children: /* @__PURE__ */ jsx23("h2", { className: "adc-title", children: messages.listTitle }) }),
|
|
2629
|
+
/* @__PURE__ */ jsx23(
|
|
2630
|
+
PostListToolbar,
|
|
2631
|
+
{
|
|
2632
|
+
search: state.search,
|
|
2633
|
+
onSearch: list.setSearch,
|
|
2634
|
+
tags: list.tags,
|
|
2635
|
+
selectedTags: state.tags,
|
|
2636
|
+
onToggleTag: list.toggleTag,
|
|
2637
|
+
hasFilters: list.hasFilters,
|
|
2638
|
+
onClear: list.clearFilters,
|
|
2639
|
+
onCreate
|
|
2640
|
+
}
|
|
2641
|
+
),
|
|
2642
|
+
tab && /* @__PURE__ */ jsx23(PostListTabs, { active: tab, counts: list.counts, onChange: list.setTab }),
|
|
2643
|
+
list.selectedIds.size > 0 && /* @__PURE__ */ jsx23(
|
|
2644
|
+
BatchBar,
|
|
2645
|
+
{
|
|
2646
|
+
ids: [...list.selectedIds],
|
|
2647
|
+
tab,
|
|
2648
|
+
onClearSelection: () => list.setSelectedIds(/* @__PURE__ */ new Set()),
|
|
2649
|
+
onDone: list.refresh
|
|
2650
|
+
}
|
|
2651
|
+
),
|
|
2652
|
+
posts.error !== void 0 && !posts.isLoading ? /* @__PURE__ */ jsxs20("div", { className: "adc-state adc-state--error", role: "alert", children: [
|
|
1169
2653
|
messages.loadError,
|
|
1170
|
-
/* @__PURE__ */
|
|
1171
|
-
] }) : posts.isLoading && !posts.data ? /* @__PURE__ */
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
2654
|
+
/* @__PURE__ */ jsx23("button", { type: "button", className: "adc-button", onClick: posts.reload, children: messages.retry })
|
|
2655
|
+
] }) : posts.isLoading && !posts.data ? /* @__PURE__ */ jsx23("p", { className: "adc-state", role: "status", children: messages.loading }) : rows.length === 0 ? /* @__PURE__ */ jsx23("p", { className: "adc-state", children: tab === POST_LIST_TAB.TEMPLATES ? messages.emptyTemplates : messages.empty }) : /* @__PURE__ */ jsx23(
|
|
2656
|
+
PostTable,
|
|
2657
|
+
{
|
|
2658
|
+
rows,
|
|
2659
|
+
sort: state.sort,
|
|
2660
|
+
order: state.order,
|
|
2661
|
+
onSort: list.toggleSort,
|
|
2662
|
+
selectedIds: list.selectedIds,
|
|
2663
|
+
onToggleSelected: list.toggleSelected,
|
|
2664
|
+
onToggleAll: toggleAll,
|
|
2665
|
+
onSelect,
|
|
2666
|
+
hasActions: Boolean(tab),
|
|
2667
|
+
isBusy: posts.isLoading,
|
|
2668
|
+
renderActions: (post) => actionsFor(post).map(({ action, icon: Icon, label, tip }) => /* @__PURE__ */ jsx23(Tooltip, { text: tip, children: /* @__PURE__ */ jsxs20(
|
|
2669
|
+
"button",
|
|
2670
|
+
{
|
|
2671
|
+
type: "button",
|
|
2672
|
+
className: "adc-button adc-button--compact",
|
|
2673
|
+
onClick: () => setDialog({ action, post }),
|
|
2674
|
+
children: [
|
|
2675
|
+
/* @__PURE__ */ jsx23(Icon, { "aria-hidden": "true", className: "adc-icon" }),
|
|
2676
|
+
label
|
|
2677
|
+
]
|
|
2678
|
+
}
|
|
2679
|
+
) }, action))
|
|
2680
|
+
}
|
|
2681
|
+
),
|
|
2682
|
+
posts.data && /* @__PURE__ */ jsx23(
|
|
2683
|
+
PostListFooter,
|
|
2684
|
+
{
|
|
2685
|
+
data: posts.data,
|
|
2686
|
+
pageSize: list.pageSize,
|
|
2687
|
+
onPage: list.setPage,
|
|
2688
|
+
onPageSize: list.setPageSize,
|
|
2689
|
+
renderSelect
|
|
2690
|
+
}
|
|
2691
|
+
),
|
|
2692
|
+
tab === POST_LIST_TAB.TEMPLATES && /* @__PURE__ */ jsx23(RecurrencePanel, { templates: rows, renderDateTimeInput, renderSelect }),
|
|
2693
|
+
dialog?.action === "saveAsTemplate" && /* @__PURE__ */ jsx23(SaveAsTemplateDialog, { post: dialog.post, onClose: () => setDialog(void 0), onDone: handleActionDone }),
|
|
2694
|
+
dialog?.action === "fromTemplate" && /* @__PURE__ */ jsx23(FromTemplateDialog, { post: dialog.post, onClose: () => setDialog(void 0), onDone: handleActionDone }),
|
|
2695
|
+
dialog?.action === "republish" && /* @__PURE__ */ jsx23(
|
|
2696
|
+
RepublishDialog,
|
|
2697
|
+
{
|
|
2698
|
+
post: dialog.post,
|
|
2699
|
+
renderDateTimeInput,
|
|
2700
|
+
onClose: () => setDialog(void 0),
|
|
2701
|
+
onDone: handleActionDone
|
|
2702
|
+
}
|
|
2703
|
+
)
|
|
1192
2704
|
] });
|
|
1193
2705
|
}
|
|
1194
2706
|
|
|
1195
2707
|
// src/components/ContentWorkspace.tsx
|
|
1196
|
-
import { jsx as
|
|
1197
|
-
function ContentWorkspace({
|
|
1198
|
-
|
|
1199
|
-
|
|
2708
|
+
import { jsx as jsx24 } from "react/jsx-runtime";
|
|
2709
|
+
function ContentWorkspace({
|
|
2710
|
+
pageSize,
|
|
2711
|
+
newPostDefaults,
|
|
2712
|
+
onPostSaved,
|
|
2713
|
+
renderDateTimeInput,
|
|
2714
|
+
renderSelect,
|
|
2715
|
+
syncUrl,
|
|
2716
|
+
showFormattingToolbar
|
|
2717
|
+
}) {
|
|
2718
|
+
const [view, setView] = useState15({ kind: "list" });
|
|
2719
|
+
const [reloadKey, setReloadKey] = useState15(0);
|
|
1200
2720
|
function handleSaved(post) {
|
|
1201
2721
|
setReloadKey((value) => value + 1);
|
|
1202
2722
|
setView({ kind: "editor", postId: post.id });
|
|
1203
2723
|
onPostSaved?.(post);
|
|
1204
2724
|
}
|
|
1205
2725
|
if (view.kind === "editor") {
|
|
1206
|
-
return /* @__PURE__ */
|
|
2726
|
+
return /* @__PURE__ */ jsx24(
|
|
1207
2727
|
PostEditor,
|
|
1208
2728
|
{
|
|
1209
2729
|
...view.postId ? { postId: view.postId } : {},
|
|
1210
2730
|
...newPostDefaults ? { defaults: newPostDefaults } : {},
|
|
2731
|
+
...showFormattingToolbar === void 0 ? {} : { showFormattingToolbar },
|
|
2732
|
+
...renderDateTimeInput ? { renderDateTimeInput } : {},
|
|
1211
2733
|
onSaved: handleSaved,
|
|
1212
2734
|
onArchived: () => {
|
|
1213
2735
|
setReloadKey((value) => value + 1);
|
|
@@ -1218,10 +2740,13 @@ function ContentWorkspace({ pageSize, newPostDefaults, onPostSaved }) {
|
|
|
1218
2740
|
view.postId ?? "new"
|
|
1219
2741
|
);
|
|
1220
2742
|
}
|
|
1221
|
-
return /* @__PURE__ */
|
|
2743
|
+
return /* @__PURE__ */ jsx24(
|
|
1222
2744
|
PostList,
|
|
1223
2745
|
{
|
|
1224
2746
|
reloadKey,
|
|
2747
|
+
...renderDateTimeInput ? { renderDateTimeInput } : {},
|
|
2748
|
+
...renderSelect ? { renderSelect } : {},
|
|
2749
|
+
...syncUrl ? { syncUrl } : {},
|
|
1225
2750
|
...pageSize ? { pageSize } : {},
|
|
1226
2751
|
onSelect: (post) => setView({ kind: "editor", postId: post.id }),
|
|
1227
2752
|
onCreate: () => setView({ kind: "editor" })
|
|
@@ -1230,13 +2755,14 @@ function ContentWorkspace({ pageSize, newPostDefaults, onPostSaved }) {
|
|
|
1230
2755
|
}
|
|
1231
2756
|
|
|
1232
2757
|
// src/components/PostCard.tsx
|
|
1233
|
-
import {
|
|
2758
|
+
import { formatTagLabel as formatTagLabel2 } from "@adatechnology/content-contracts";
|
|
2759
|
+
import { jsx as jsx25, jsxs as jsxs21 } from "react/jsx-runtime";
|
|
1234
2760
|
function PostCard({ post, href, headingLevel = 2 }) {
|
|
1235
2761
|
const { messages, locale, format } = useContentText();
|
|
1236
2762
|
const renderLink = useRenderLink();
|
|
1237
2763
|
const Heading = `h${headingLevel}`;
|
|
1238
|
-
return /* @__PURE__ */
|
|
1239
|
-
post.coverImageUrl && /* @__PURE__ */
|
|
2764
|
+
return /* @__PURE__ */ jsxs21("article", { className: "adc-card", children: [
|
|
2765
|
+
post.coverImageUrl && /* @__PURE__ */ jsx25(
|
|
1240
2766
|
"img",
|
|
1241
2767
|
{
|
|
1242
2768
|
className: "adc-card-cover",
|
|
@@ -1246,22 +2772,23 @@ function PostCard({ post, href, headingLevel = 2 }) {
|
|
|
1246
2772
|
decoding: "async"
|
|
1247
2773
|
}
|
|
1248
2774
|
),
|
|
1249
|
-
/* @__PURE__ */
|
|
1250
|
-
/* @__PURE__ */
|
|
1251
|
-
/* @__PURE__ */
|
|
1252
|
-
/* @__PURE__ */
|
|
1253
|
-
/* @__PURE__ */
|
|
2775
|
+
/* @__PURE__ */ jsxs21("div", { className: "adc-card-body", children: [
|
|
2776
|
+
/* @__PURE__ */ jsx25(Heading, { className: "adc-card-title", children: renderLink({ href, className: "adc-card-link", children: post.title }) }),
|
|
2777
|
+
/* @__PURE__ */ jsxs21("p", { className: "adc-meta", children: [
|
|
2778
|
+
/* @__PURE__ */ jsx25("time", { dateTime: post.publishedAt, children: formatPostDate(post.publishedAt, locale) }),
|
|
2779
|
+
/* @__PURE__ */ jsx25("span", { "aria-hidden": "true", children: " \xB7 " }),
|
|
1254
2780
|
format("readingTime", { minutes: post.readingTimeMinutes })
|
|
1255
2781
|
] }),
|
|
1256
|
-
post.excerpt && /* @__PURE__ */
|
|
1257
|
-
post.tags.length > 0 && /* @__PURE__ */
|
|
1258
|
-
/* @__PURE__ */
|
|
2782
|
+
post.excerpt && /* @__PURE__ */ jsx25("p", { className: "adc-card-excerpt", children: post.excerpt }),
|
|
2783
|
+
post.tags.length > 0 && /* @__PURE__ */ jsx25("ul", { className: "adc-tag-list", children: post.tags.map((tag) => /* @__PURE__ */ jsx25("li", { className: "adc-tag", children: formatTagLabel2(tag, post.tagLabels) }, tag)) }),
|
|
2784
|
+
/* @__PURE__ */ jsx25("span", { className: "adc-card-more", "aria-hidden": "true", children: messages.readMore })
|
|
1259
2785
|
] })
|
|
1260
2786
|
] });
|
|
1261
2787
|
}
|
|
1262
2788
|
|
|
1263
2789
|
// src/components/PostListPage.tsx
|
|
1264
|
-
import {
|
|
2790
|
+
import { formatTagLabel as formatTagLabel3 } from "@adatechnology/content-contracts";
|
|
2791
|
+
import { jsx as jsx26, jsxs as jsxs22 } from "react/jsx-runtime";
|
|
1265
2792
|
function PostListPage({ page = 1, tag, pageSize = 10, getPostHref, getListHref, title }) {
|
|
1266
2793
|
const api = useContentPublicApi();
|
|
1267
2794
|
const { messages } = useContentText();
|
|
@@ -1275,9 +2802,9 @@ function PostListPage({ page = 1, tag, pageSize = 10, getPostHref, getListHref,
|
|
|
1275
2802
|
"public-tags"
|
|
1276
2803
|
);
|
|
1277
2804
|
const withTag = (target) => getListHref({ page: target, ...tag ? { tag } : {} });
|
|
1278
|
-
return /* @__PURE__ */
|
|
1279
|
-
title && /* @__PURE__ */
|
|
1280
|
-
(tags.data?.length ?? 0) > 0 && /* @__PURE__ */
|
|
2805
|
+
return /* @__PURE__ */ jsxs22("section", { className: "adc-root adc-public-list", children: [
|
|
2806
|
+
title && /* @__PURE__ */ jsx26("h1", { className: "adc-page-title", children: title }),
|
|
2807
|
+
(tags.data?.length ?? 0) > 0 && /* @__PURE__ */ jsxs22("nav", { className: "adc-tag-filter", "aria-label": messages.tagsLabel, children: [
|
|
1281
2808
|
renderLink({
|
|
1282
2809
|
href: getListHref({ page: 1 }),
|
|
1283
2810
|
className: `adc-tag-chip${tag ? "" : " adc-tag-chip--active"}`,
|
|
@@ -1289,24 +2816,25 @@ function PostListPage({ page = 1, tag, pageSize = 10, getPostHref, getListHref,
|
|
|
1289
2816
|
href: getListHref({ page: 1, tag: entry.tag }),
|
|
1290
2817
|
className: `adc-tag-chip${entry.tag === tag ? " adc-tag-chip--active" : ""}`,
|
|
1291
2818
|
...entry.tag === tag ? { "aria-current": "page" } : {},
|
|
1292
|
-
children: `${entry.tag} (${entry.count})`
|
|
2819
|
+
children: `${formatTagLabel3(entry.tag)} (${entry.count})`
|
|
1293
2820
|
})
|
|
1294
2821
|
)
|
|
1295
2822
|
] }),
|
|
1296
|
-
posts.isLoading && !posts.data ? /* @__PURE__ */
|
|
2823
|
+
posts.isLoading && !posts.data ? /* @__PURE__ */ jsx26("p", { className: "adc-state", role: "status", children: messages.loading }) : posts.error !== void 0 ? /* @__PURE__ */ jsxs22("div", { className: "adc-state adc-state--error", role: "alert", children: [
|
|
1297
2824
|
messages.loadError,
|
|
1298
|
-
/* @__PURE__ */
|
|
1299
|
-
] }) : (posts.data?.data.length ?? 0) === 0 ? /* @__PURE__ */
|
|
1300
|
-
posts.data && /* @__PURE__ */
|
|
2825
|
+
/* @__PURE__ */ jsx26("button", { type: "button", className: "adc-button", onClick: posts.reload, children: messages.retry })
|
|
2826
|
+
] }) : (posts.data?.data.length ?? 0) === 0 ? /* @__PURE__ */ jsx26("p", { className: "adc-state", children: messages.postsEmpty }) : /* @__PURE__ */ jsx26("div", { className: "adc-card-grid", children: posts.data?.data.map((post) => /* @__PURE__ */ jsx26(PostCard, { post, href: getPostHref(post.slug) }, post.id)) }),
|
|
2827
|
+
posts.data && /* @__PURE__ */ jsx26(Pagination, { page, totalPages: posts.data.pagination.totalPages, getPageHref: withTag })
|
|
1301
2828
|
] });
|
|
1302
2829
|
}
|
|
1303
2830
|
|
|
1304
2831
|
// src/components/PostPage.tsx
|
|
1305
|
-
import {
|
|
2832
|
+
import { formatTagLabel as formatTagLabel4 } from "@adatechnology/content-contracts";
|
|
2833
|
+
import { useEffect as useEffect7 } from "react";
|
|
1306
2834
|
|
|
1307
2835
|
// src/components/ShareButtons.tsx
|
|
1308
|
-
import { Check, Link2, Share2 } from "lucide-react";
|
|
1309
|
-
import { useEffect as
|
|
2836
|
+
import { Check as Check2, Link2, Share2 } from "lucide-react";
|
|
2837
|
+
import { useEffect as useEffect6, useState as useState16 } from "react";
|
|
1310
2838
|
|
|
1311
2839
|
// src/lib/share.ts
|
|
1312
2840
|
var SHARE_NETWORK = {
|
|
@@ -1331,7 +2859,7 @@ function buildShareLinks(params) {
|
|
|
1331
2859
|
}
|
|
1332
2860
|
|
|
1333
2861
|
// src/components/ShareButtons.tsx
|
|
1334
|
-
import { jsx as
|
|
2862
|
+
import { jsx as jsx27, jsxs as jsxs23 } from "react/jsx-runtime";
|
|
1335
2863
|
var NETWORK_LABEL = {
|
|
1336
2864
|
[SHARE_NETWORK.WHATSAPP]: "shareWhatsApp",
|
|
1337
2865
|
[SHARE_NETWORK.FACEBOOK]: "shareFacebook",
|
|
@@ -1341,10 +2869,10 @@ var NETWORK_LABEL = {
|
|
|
1341
2869
|
var COPIED_FEEDBACK_MS = 2e3;
|
|
1342
2870
|
function ShareButtons({ url, title, networks }) {
|
|
1343
2871
|
const { messages, format } = useContentText();
|
|
1344
|
-
const [isCopied, setIsCopied] =
|
|
2872
|
+
const [isCopied, setIsCopied] = useState16(false);
|
|
1345
2873
|
const links = buildShareLinks({ url, title }).filter((link) => !networks || networks.includes(link.network));
|
|
1346
|
-
const [capabilities, setCapabilities] =
|
|
1347
|
-
|
|
2874
|
+
const [capabilities, setCapabilities] = useState16({ canShareNatively: false, canCopy: false });
|
|
2875
|
+
useEffect6(() => {
|
|
1348
2876
|
setCapabilities({
|
|
1349
2877
|
canShareNatively: typeof navigator.share === "function",
|
|
1350
2878
|
canCopy: Boolean(navigator.clipboard)
|
|
@@ -1356,21 +2884,21 @@ function ShareButtons({ url, title, networks }) {
|
|
|
1356
2884
|
setIsCopied(true);
|
|
1357
2885
|
window.setTimeout(() => setIsCopied(false), COPIED_FEEDBACK_MS);
|
|
1358
2886
|
}
|
|
1359
|
-
return /* @__PURE__ */
|
|
1360
|
-
/* @__PURE__ */
|
|
1361
|
-
canShareNatively && /* @__PURE__ */
|
|
2887
|
+
return /* @__PURE__ */ jsxs23("div", { className: "adc-share", role: "group", "aria-label": messages.shareLabel, children: [
|
|
2888
|
+
/* @__PURE__ */ jsx27("span", { className: "adc-label", children: messages.shareLabel }),
|
|
2889
|
+
canShareNatively && /* @__PURE__ */ jsxs23(
|
|
1362
2890
|
"button",
|
|
1363
2891
|
{
|
|
1364
2892
|
type: "button",
|
|
1365
2893
|
className: "adc-button",
|
|
1366
2894
|
onClick: () => void navigator.share({ url, title }).catch(() => void 0),
|
|
1367
2895
|
children: [
|
|
1368
|
-
/* @__PURE__ */
|
|
2896
|
+
/* @__PURE__ */ jsx27(Share2, { "aria-hidden": "true", className: "adc-icon" }),
|
|
1369
2897
|
messages.shareNative
|
|
1370
2898
|
]
|
|
1371
2899
|
}
|
|
1372
2900
|
),
|
|
1373
|
-
links.map((link) => /* @__PURE__ */
|
|
2901
|
+
links.map((link) => /* @__PURE__ */ jsx27(
|
|
1374
2902
|
"a",
|
|
1375
2903
|
{
|
|
1376
2904
|
className: `adc-button adc-share-link adc-share-link--${link.network}`,
|
|
@@ -1382,48 +2910,48 @@ function ShareButtons({ url, title, networks }) {
|
|
|
1382
2910
|
},
|
|
1383
2911
|
link.network
|
|
1384
2912
|
)),
|
|
1385
|
-
canCopy && /* @__PURE__ */
|
|
1386
|
-
isCopied ? /* @__PURE__ */
|
|
1387
|
-
/* @__PURE__ */
|
|
2913
|
+
canCopy && /* @__PURE__ */ jsxs23("button", { type: "button", className: "adc-button", onClick: () => void handleCopy().catch(() => void 0), children: [
|
|
2914
|
+
isCopied ? /* @__PURE__ */ jsx27(Check2, { "aria-hidden": "true", className: "adc-icon" }) : /* @__PURE__ */ jsx27(Link2, { "aria-hidden": "true", className: "adc-icon" }),
|
|
2915
|
+
/* @__PURE__ */ jsx27("span", { "aria-live": "polite", children: isCopied ? messages.linkCopied : messages.copyLink })
|
|
1388
2916
|
] })
|
|
1389
2917
|
] });
|
|
1390
2918
|
}
|
|
1391
2919
|
|
|
1392
2920
|
// src/components/PostPage.tsx
|
|
1393
|
-
import { Fragment, jsx as
|
|
2921
|
+
import { Fragment, jsx as jsx28, jsxs as jsxs24 } from "react/jsx-runtime";
|
|
1394
2922
|
function PostPage({ slug, shareUrl, shareNetworks, getTagHref, onLoaded, renderNotFound }) {
|
|
1395
2923
|
const api = useContentPublicApi();
|
|
1396
2924
|
const { messages, locale, format } = useContentText();
|
|
1397
2925
|
const renderLink = useRenderLink();
|
|
1398
2926
|
const resource = useAsyncResource(() => api.getPublishedPost(slug), slug);
|
|
1399
2927
|
const post = resource.data;
|
|
1400
|
-
|
|
2928
|
+
useEffect7(() => {
|
|
1401
2929
|
if (post) onLoaded?.(post);
|
|
1402
2930
|
}, [post, onLoaded]);
|
|
1403
2931
|
if (resource.isLoading && !post) {
|
|
1404
|
-
return /* @__PURE__ */
|
|
2932
|
+
return /* @__PURE__ */ jsx28("p", { className: "adc-root adc-state", role: "status", children: messages.loading });
|
|
1405
2933
|
}
|
|
1406
2934
|
if (!post) {
|
|
1407
|
-
return /* @__PURE__ */
|
|
2935
|
+
return /* @__PURE__ */ jsx28(Fragment, { children: renderNotFound ? renderNotFound() : /* @__PURE__ */ jsx28("p", { className: "adc-root adc-state", children: messages.notFound }) });
|
|
1408
2936
|
}
|
|
1409
2937
|
const url = shareUrl ?? (typeof window !== "undefined" ? window.location.href : "");
|
|
1410
|
-
return /* @__PURE__ */
|
|
1411
|
-
/* @__PURE__ */
|
|
1412
|
-
/* @__PURE__ */
|
|
1413
|
-
/* @__PURE__ */
|
|
1414
|
-
/* @__PURE__ */
|
|
1415
|
-
/* @__PURE__ */
|
|
2938
|
+
return /* @__PURE__ */ jsxs24("article", { className: "adc-root adc-post", children: [
|
|
2939
|
+
/* @__PURE__ */ jsxs24("header", { className: "adc-post-header", children: [
|
|
2940
|
+
/* @__PURE__ */ jsx28("h1", { className: "adc-page-title", children: post.title }),
|
|
2941
|
+
/* @__PURE__ */ jsxs24("p", { className: "adc-meta", children: [
|
|
2942
|
+
/* @__PURE__ */ jsx28("time", { dateTime: post.publishedAt, children: formatPostDate(post.publishedAt, locale) }),
|
|
2943
|
+
/* @__PURE__ */ jsx28("span", { "aria-hidden": "true", children: " \xB7 " }),
|
|
1416
2944
|
format("readingTime", { minutes: post.readingTimeMinutes }),
|
|
1417
|
-
post.authorName && /* @__PURE__ */
|
|
1418
|
-
/* @__PURE__ */
|
|
2945
|
+
post.authorName && /* @__PURE__ */ jsxs24(Fragment, { children: [
|
|
2946
|
+
/* @__PURE__ */ jsx28("span", { "aria-hidden": "true", children: " \xB7 " }),
|
|
1419
2947
|
format("byAuthor", { author: post.authorName })
|
|
1420
2948
|
] })
|
|
1421
2949
|
] }),
|
|
1422
|
-
post.tags.length > 0 && /* @__PURE__ */
|
|
2950
|
+
post.tags.length > 0 && /* @__PURE__ */ jsx28("ul", { className: "adc-tag-list", children: post.tags.map((tag) => /* @__PURE__ */ jsx28("li", { className: "adc-tag", children: getTagHref ? renderLink({ href: getTagHref(tag), children: formatTagLabel4(tag, post.tagLabels) }) : formatTagLabel4(tag, post.tagLabels) }, tag)) })
|
|
1423
2951
|
] }),
|
|
1424
|
-
post.coverImageUrl && /* @__PURE__ */
|
|
1425
|
-
/* @__PURE__ */
|
|
1426
|
-
url && shareNetworks?.length !== 0 && /* @__PURE__ */
|
|
2952
|
+
post.coverImageUrl && /* @__PURE__ */ jsx28("img", { className: "adc-post-cover", src: post.coverImageUrl, alt: post.coverImageAlt ?? "", decoding: "async" }),
|
|
2953
|
+
/* @__PURE__ */ jsx28(MarkdownContent, { markdown: post.body, headingLevelOffset: 1 }),
|
|
2954
|
+
url && shareNetworks?.length !== 0 && /* @__PURE__ */ jsx28(ShareButtons, { url, title: post.title, ...shareNetworks ? { networks: shareNetworks } : {} })
|
|
1427
2955
|
] });
|
|
1428
2956
|
}
|
|
1429
2957
|
|
|
@@ -1458,8 +2986,15 @@ export {
|
|
|
1458
2986
|
ContentWorkspace,
|
|
1459
2987
|
DEFAULT_CONTENT_LOCALE,
|
|
1460
2988
|
DRAFT_ERROR,
|
|
2989
|
+
EMOJI_BY_CATEGORY,
|
|
2990
|
+
EMOJI_CATEGORIES,
|
|
1461
2991
|
EMPTY_POST_DRAFT,
|
|
2992
|
+
EmojiPicker,
|
|
2993
|
+
FilePicker,
|
|
1462
2994
|
MarkdownContent,
|
|
2995
|
+
MarkdownEditor,
|
|
2996
|
+
PAGE_SIZE_OPTIONS,
|
|
2997
|
+
POST_LIST_TAB,
|
|
1463
2998
|
Pagination,
|
|
1464
2999
|
PostCard,
|
|
1465
3000
|
PostEditor,
|
|
@@ -1471,6 +3006,7 @@ export {
|
|
|
1471
3006
|
ShareButtons,
|
|
1472
3007
|
StatusChip,
|
|
1473
3008
|
TagsInput,
|
|
3009
|
+
Tooltip,
|
|
1474
3010
|
buildPageItems,
|
|
1475
3011
|
buildPostMeta,
|
|
1476
3012
|
buildShareLinks,
|
|
@@ -1479,11 +3015,19 @@ export {
|
|
|
1479
3015
|
draftToInput,
|
|
1480
3016
|
formatPostDate,
|
|
1481
3017
|
fromDateTimeLocalValue,
|
|
3018
|
+
insertImage,
|
|
3019
|
+
insertLink,
|
|
3020
|
+
insertText,
|
|
1482
3021
|
interpolate,
|
|
1483
3022
|
isDraftDirty,
|
|
3023
|
+
parseListUrlState,
|
|
1484
3024
|
resolveContentMessages,
|
|
3025
|
+
searchEmoji,
|
|
3026
|
+
serializeListUrlState,
|
|
1485
3027
|
splitTagInput,
|
|
1486
3028
|
toDateTimeLocalValue,
|
|
3029
|
+
toggleLinePrefix,
|
|
3030
|
+
toggleWrap,
|
|
1487
3031
|
useAsyncResource,
|
|
1488
3032
|
useContentAdminApi,
|
|
1489
3033
|
useContentPublicApi,
|