@ecomcx/ecomweb-editor 1.30.0 → 1.31.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/package.json +3 -3
- package/src/locales/en/index.ts +2 -1
- package/src/locales/en/placeholders.ts +96 -0
- package/src/locales/vi/index.ts +2 -1
- package/src/locales/vi/placeholders.ts +95 -0
- package/src/v2/blocks/compat.tsx +91 -5
- package/src/v2/blocks/form.tsx +3 -0
- package/src/v2/blocks/layout.tsx +143 -52
- package/src/v2/blocks/media.tsx +72 -71
- package/src/v2/blocks/text.tsx +48 -17
- package/src/v2/blocks/theme.tsx +73 -12
- package/src/v2/blocks/widgets.tsx +48 -11
- package/src/v2/canvas/block-list.tsx +4 -4
- package/src/v2/canvas/canvas-css.ts +88 -6
- package/src/v2/canvas/server-block.tsx +7 -4
- package/src/v2/core/host.ts +9 -0
- package/src/v2/core/registry.ts +3 -1
- package/src/v2/core/structure.ts +2 -1
- package/src/v2/editor.css +6 -2
- package/src/v2/index.ts +3 -0
- package/src/v2/ui/ai.tsx +9 -5
- package/src/v2/ui/attr-form.tsx +2 -2
- package/src/v2/{blocks → ui}/media-actions.tsx +4 -3
- package/src/v2/ui/placeholders.tsx +205 -0
- package/src/v2/ui/toolbar.tsx +7 -3
package/src/v2/blocks/media.tsx
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { blockShell, embedInfo, isSafeUrl } from "@ecomcx/ecomweb-content";
|
|
2
2
|
import { ArrowDown, ArrowUp, Code2, File as FileIcon, Image as ImageIcon, Images, ListTree, Music, Plus, Share2, Video, Play, Globe, X } from "lucide-react";
|
|
3
|
-
import { useState, type CSSProperties } from "react";
|
|
3
|
+
import { useState, type CSSProperties, type ReactNode } from "react";
|
|
4
4
|
import { useEditor } from "../context";
|
|
5
5
|
import { AiAltButton } from "../ui/ai";
|
|
6
6
|
import type { BlockEditProps, BlockType } from "../core/registry";
|
|
7
7
|
import { RichText } from "../text/rich-text";
|
|
8
8
|
import { BoundText, useBindingPreview } from "../ui/bindings";
|
|
9
9
|
import { ImageHandle } from "./resize";
|
|
10
|
-
import {
|
|
10
|
+
import { mediaAttrs } from "../ui/media-actions";
|
|
11
|
+
import { LinkPlaceholder, MediaPlaceholder } from "../ui/placeholders";
|
|
11
12
|
import type { MediaItem, MediaKind } from "../../shared/types";
|
|
12
13
|
import { useMsgs } from "../i18n";
|
|
13
14
|
import { format } from "../../i18n";
|
|
@@ -15,48 +16,44 @@ import { format } from "../../i18n";
|
|
|
15
16
|
const cx = (...c: unknown[]) => c.filter((x): x is string => typeof x === "string" && x !== "").join(" ");
|
|
16
17
|
const safe = (u: unknown) => (typeof u === "string" && isSafeUrl(u) ? u : "");
|
|
17
18
|
|
|
18
|
-
/** Ô trống của khối media:
|
|
19
|
-
function
|
|
20
|
-
const { store
|
|
21
|
-
|
|
22
|
-
const drop = useFileDrop(kind, select);
|
|
23
|
-
return (
|
|
24
|
-
<div {...blockProps} {...drop.props} className={cx(blockProps.className, "ecx-media-placeholder", drop.over && "is-drop-target")}>
|
|
25
|
-
<span className="ecx-placeholder-title"><Icon className="ecx-icon" />{title}</span>
|
|
26
|
-
<p className="ecx-placeholder-hint">{labels.dropHint[kind] ?? labels.dropHint.file}</p>
|
|
27
|
-
<MediaActions kind={kind} onSelect={select} onUrl={kind === "gallery" ? undefined : (url) => store.setAttrs([blockId], { src: url })} />
|
|
28
|
-
</div>
|
|
29
|
-
);
|
|
19
|
+
/** Ô trống của khối media: vùng kéo thả + Tải lên / Thư viện / URL (bộ ô giữ chỗ dùng chung). */
|
|
20
|
+
function MediaDrop({ blockId, kind, blockProps }: { blockId: string; kind: MediaKind; blockProps: BlockEditProps["blockProps"] }) {
|
|
21
|
+
const { store } = useEditor();
|
|
22
|
+
return <MediaPlaceholder kind={kind} blockProps={blockProps} onSelect={(items) => store.setAttrs([blockId], mediaAttrs(kind, items))} onUrl={kind === "gallery" ? undefined : (url) => store.setAttrs([blockId], { src: url })} />;
|
|
30
23
|
}
|
|
31
24
|
|
|
32
25
|
function ImageAiTools({ attrs, setAttrs }: BlockEditProps) { return <AiAltButton attrs={attrs} setAttrs={setAttrs} />; }
|
|
33
26
|
|
|
34
|
-
function ImageEdit({ block, blockProps, setAttrs, editable,
|
|
27
|
+
function ImageEdit({ block, blockProps, setAttrs, editable, selected }: BlockEditProps) {
|
|
35
28
|
const a = block.attrs;
|
|
29
|
+
const tp = useMsgs("placeholders");
|
|
36
30
|
const bSrc = useBindingPreview(block, "src"), bAlt = useBindingPreview(block, "alt"), bCap = useBindingPreview(block, "caption");
|
|
37
31
|
const src = bSrc.bound ? safe(bSrc.value) : safe(a.src);
|
|
38
32
|
if (bSrc.bound && !src) return <figure {...blockProps} className={cx(blockProps.className, "ecx-image cms-image")}><BoundText tagName="div" className="ecx-bound-media" preview={bSrc} /></figure>;
|
|
39
|
-
if (!src) return <
|
|
33
|
+
if (!src) return <MediaDrop blockId={block.id} kind="image" blockProps={blockProps} />;
|
|
40
34
|
const cls = blockShell("image", a)!.className;
|
|
41
35
|
return (
|
|
42
36
|
<figure {...blockProps} className={cx(blockProps.className, cls)} style={{ ...(blockProps.style ?? {}), position: "relative" }}>
|
|
43
37
|
{selected && editable && <ImageHandle blockId={block.id} />}
|
|
44
38
|
<img src={src} alt={bAlt.bound ? bAlt.value ?? "" : String(a.alt ?? "")} data-ecx-bound={bSrc.bound ? "" : undefined} title={bSrc.bound ? bSrc.label : undefined} width={Number(a.width) || undefined} height={Number(a.height) || undefined} draggable={false} style={Number(a.width) ? { width: Number(a.width), maxWidth: "100%", height: "auto" } : undefined} />
|
|
45
39
|
{bCap.bound ? <BoundText tagName="figcaption" preview={bCap} /> : (a.caption || editable) && (
|
|
46
|
-
<RichText blockId={block.id} field="caption" tagName="figcaption" value={String(a.caption ?? "")} onChange={(v) => setAttrs({ caption: v })} placeholder={
|
|
40
|
+
<RichText blockId={block.id} field="caption" tagName="figcaption" value={String(a.caption ?? "")} onChange={(v) => setAttrs({ caption: v })} placeholder={tp.caption} editable={editable} />
|
|
47
41
|
)}
|
|
48
42
|
</figure>
|
|
49
43
|
);
|
|
50
44
|
}
|
|
51
45
|
|
|
52
|
-
function GalleryEdit({ block, blockProps,
|
|
46
|
+
function GalleryEdit({ block, blockProps, setAttrs, editable, selected }: BlockEditProps) {
|
|
53
47
|
const images = (Array.isArray(block.attrs.images) ? block.attrs.images : []) as Array<{ src: string; alt?: string }>;
|
|
54
|
-
|
|
48
|
+
const tp = useMsgs("placeholders");
|
|
49
|
+
if (!images.length) return <MediaDrop blockId={block.id} kind="gallery" blockProps={blockProps} />;
|
|
55
50
|
const cols = Math.min(6, Math.max(1, Number(block.attrs.columns) || 3));
|
|
56
|
-
|
|
51
|
+
const add = (items: MediaItem[]) => setAttrs({ images: [...images, ...((mediaAttrs("gallery", items).images ?? []) as typeof images)] });
|
|
57
52
|
return (
|
|
58
53
|
<figure {...blockProps} className={cx(blockProps.className, blockShell("gallery", block.attrs)!.className)} style={{ ...(blockProps.style ?? {}), ...(blockShell("gallery", block.attrs)!.style as CSSProperties) }}>
|
|
59
54
|
{images.map((im, i) => <figure key={i} className="ecx-gallery-item cms-gallery-item" style={{ margin: 0 }}><img src={safe(im.src)} alt={im.alt ?? ""} draggable={false} style={{ width: "100%", height: "100%", objectFit: "cover", aspectRatio: "1" }} /></figure>)}
|
|
55
|
+
{/* Có ảnh rồi vẫn còn ô "+" cuối lưới để thêm tiếp (chỉ khi đang chọn: website không có ô này) */}
|
|
56
|
+
{editable && selected && <MediaPlaceholder kind="gallery" compact title={tp.addImage} icon={Plus} className="ecx-gallery-add" onSelect={add} />}
|
|
60
57
|
{block.attrs.caption ? <figcaption className="ecx-gallery-caption cms-gallery-caption" style={{ gridColumn: "1 / -1" }}>{String(block.attrs.caption)}</figcaption> : null}
|
|
61
58
|
</figure>
|
|
62
59
|
);
|
|
@@ -64,61 +61,40 @@ function GalleryEdit({ block, blockProps, labels }: BlockEditProps) {
|
|
|
64
61
|
|
|
65
62
|
function VideoEdit({ block, blockProps, labels }: BlockEditProps) {
|
|
66
63
|
const src = safe(block.attrs.src);
|
|
67
|
-
if (!src) return <
|
|
64
|
+
if (!src) return <MediaDrop blockId={block.id} kind="video" blockProps={blockProps} />;
|
|
68
65
|
void labels;
|
|
69
66
|
return <figure {...blockProps} className={cx(blockProps.className, "ecx-video cms-video")}><video src={src} controls preload="metadata" style={{ width: "100%", pointerEvents: "none" }} /></figure>;
|
|
70
67
|
}
|
|
71
68
|
|
|
72
69
|
function AudioEdit({ block, blockProps }: BlockEditProps) {
|
|
73
70
|
const src = safe(block.attrs.src);
|
|
74
|
-
if (!src) return <
|
|
71
|
+
if (!src) return <MediaDrop blockId={block.id} kind="audio" blockProps={blockProps} />;
|
|
75
72
|
return <figure {...blockProps} className={cx(blockProps.className, "ecx-audio cms-audio")}><audio src={src} controls preload="metadata" style={{ width: "100%", pointerEvents: "none" }} /></figure>;
|
|
76
73
|
}
|
|
77
74
|
|
|
78
75
|
function FileEdit({ block, blockProps }: BlockEditProps) {
|
|
79
76
|
const src = safe(block.attrs.src);
|
|
80
|
-
if (!src) return <
|
|
77
|
+
if (!src) return <MediaDrop blockId={block.id} kind="file" blockProps={blockProps} />;
|
|
81
78
|
return <div {...blockProps} className={cx(blockProps.className, "ecx-file cms-file")}><span className="ecx-file-link cms-file-link">{String(block.attrs.name || src)}</span></div>;
|
|
82
79
|
}
|
|
83
80
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
const
|
|
87
|
-
const
|
|
88
|
-
if (!m) {
|
|
89
|
-
return (
|
|
90
|
-
<div {...blockProps} className={cx(blockProps.className, "ecx-media-placeholder")}>
|
|
91
|
-
<span className="ecx-placeholder-title"><Play className="ecx-icon" />YouTube</span>
|
|
92
|
-
<p className="ecx-placeholder-hint">{t.pasteAYoutubeLink}</p>
|
|
93
|
-
<form className="ecx-media-actions" contentEditable={false} onMouseDown={(e) => e.stopPropagation()} onSubmit={(e) => { e.preventDefault(); if (/(?:v=|youtu\.be\/|embed\/)[\w-]{11}/.test(draft)) setAttrs({ src: draft.trim() }); }}>
|
|
94
|
-
<input className="ecx-input" type="url" placeholder="https://youtu.be/…" value={draft} onChange={(e) => setDraft(e.target.value)} aria-label="YouTube URL" />
|
|
95
|
-
<button type="submit" className="ecx-btn ecx-btn-primary">{t.embed}</button>
|
|
96
|
-
</form>
|
|
97
|
-
</div>
|
|
98
|
-
);
|
|
99
|
-
}
|
|
81
|
+
const YT = /(?:v=|youtu\.be\/|embed\/)([\w-]{11})/; // cùng mẫu với website (theme-sdk)
|
|
82
|
+
function YoutubeEdit({ block, blockProps, setAttrs }: BlockEditProps) {
|
|
83
|
+
const m = String(block.attrs.src ?? "").match(YT);
|
|
84
|
+
const tp = useMsgs("placeholders");
|
|
85
|
+
if (!m) return <LinkPlaceholder blockProps={blockProps} icon={Play} title={tp.pasteToEmbed} label="YouTube URL" validate={(u) => YT.test(u)} onSubmit={(src) => setAttrs({ src })} />;
|
|
100
86
|
return (
|
|
101
87
|
<div {...blockProps} className={cx(blockProps.className, "ecx-youtube embed")}>
|
|
102
|
-
|
|
88
|
+
<img src={`https://i.ytimg.com/vi/${m[1]}/hqdefault.jpg`} alt="YouTube" draggable={false} style={{ width: "100%", aspectRatio: "16/9", objectFit: "cover" }} />
|
|
103
89
|
</div>
|
|
104
90
|
);
|
|
105
91
|
}
|
|
106
92
|
|
|
107
|
-
function EmbedEdit({ block, blockProps, setAttrs
|
|
93
|
+
function EmbedEdit({ block, blockProps, setAttrs }: BlockEditProps) {
|
|
108
94
|
const url = String(block.attrs.url ?? "");
|
|
109
95
|
const info = embedInfo(url);
|
|
110
|
-
const
|
|
111
|
-
if (!url) {
|
|
112
|
-
return (
|
|
113
|
-
<div {...blockProps} className={cx(blockProps.className, "ecx-media-placeholder")}>
|
|
114
|
-
<span className="ecx-placeholder-title"><Globe className="ecx-icon" />{labels.embed}</span>
|
|
115
|
-
<form className="ecx-media-actions" contentEditable={false} onMouseDown={(e) => e.stopPropagation()} onSubmit={(e) => { e.preventDefault(); if (isSafeUrl(draft)) setAttrs({ url: draft.trim() }); }}>
|
|
116
|
-
<input className="ecx-input" type="url" placeholder="https://…" value={draft} onChange={(e) => setDraft(e.target.value)} aria-label={labels.embed} />
|
|
117
|
-
<button type="submit" className="ecx-btn">{labels.apply}</button>
|
|
118
|
-
</form>
|
|
119
|
-
</div>
|
|
120
|
-
);
|
|
121
|
-
}
|
|
96
|
+
const tp = useMsgs("placeholders");
|
|
97
|
+
if (!url) return <LinkPlaceholder blockProps={blockProps} icon={Globe} title={tp.pasteToEmbed} hint={tp.embedHint} embed onSubmit={(u) => setAttrs({ url: u })} />;
|
|
122
98
|
const shell = blockShell("embed", block.attrs); // vỏ dùng chung với website
|
|
123
99
|
return (
|
|
124
100
|
<figure {...blockProps} className={cx(blockProps.className, shell?.className ?? "ecx-embed")} style={{ ...(blockProps.style ?? {}), ...(shell?.style as CSSProperties | undefined) }}>
|
|
@@ -128,14 +104,27 @@ function EmbedEdit({ block, blockProps, setAttrs, labels }: BlockEditProps) {
|
|
|
128
104
|
);
|
|
129
105
|
}
|
|
130
106
|
|
|
131
|
-
|
|
107
|
+
/** HTML: chuyển Mã / Xem trước ngay trên khối (mã trống → ô gõ mã luôn hiện). */
|
|
108
|
+
const htmlPreview = new Set<string>();
|
|
109
|
+
function HtmlEdit({ block, blockProps, setAttrs, editable }: BlockEditProps) {
|
|
132
110
|
const html = String(block.attrs.html ?? "");
|
|
111
|
+
const tp = useMsgs("placeholders");
|
|
112
|
+
const [, bump] = useState(0);
|
|
113
|
+
const preview = !!html && (htmlPreview.has(block.id) || !editable);
|
|
114
|
+
const show = (p: boolean) => { if (p) htmlPreview.add(block.id); else htmlPreview.delete(block.id); bump((n) => n + 1); };
|
|
133
115
|
return (
|
|
134
116
|
<div {...blockProps} className={cx(blockProps.className, blockShell("customHtml", block.attrs)!.className)}>
|
|
135
|
-
{
|
|
136
|
-
|
|
117
|
+
{editable && (
|
|
118
|
+
<div className="ecx-ph-tabs" role="tablist" contentEditable={false} onMouseDown={(e) => e.stopPropagation()}>
|
|
119
|
+
<Code2 className="ecx-icon" aria-hidden /> HTML
|
|
120
|
+
<button type="button" role="tab" aria-selected={!preview} className={cx("ecx-ph-tab", !preview && "is-active")} onClick={() => show(false)}>{tp.htmlCode}</button>
|
|
121
|
+
<button type="button" role="tab" aria-selected={preview} disabled={!html} className={cx("ecx-ph-tab", preview && "is-active")} onClick={() => show(true)}>{tp.htmlPreview}</button>
|
|
122
|
+
</div>
|
|
123
|
+
)}
|
|
124
|
+
{preview
|
|
137
125
|
// Xem trước trong iframe không cho chạy script (HTML do người khác soạn không chạy được trong trang quản trị)
|
|
138
|
-
|
|
126
|
+
? <iframe className="ecx-html-preview" sandbox="" srcDoc={html} title="HTML" />
|
|
127
|
+
: <textarea className="ecx-code-input" value={html} placeholder={tp.htmlPlaceholder} rows={Math.min(20, Math.max(4, html.split("\n").length + 1))} readOnly={!editable} onChange={(e) => setAttrs({ html: e.target.value })} onMouseDown={(e) => e.stopPropagation()} aria-label="HTML" spellCheck={false} />}
|
|
139
128
|
</div>
|
|
140
129
|
);
|
|
141
130
|
}
|
|
@@ -149,21 +138,30 @@ const socialName = (s: string) => SOCIAL.find(([v]) => v === s)?.[1] ?? s;
|
|
|
149
138
|
type SocialLink = { service: string; url: string; label?: string };
|
|
150
139
|
const linksOf = (a: Record<string, unknown>) => (Array.isArray(a.links) ? a.links : []) as SocialLink[];
|
|
151
140
|
|
|
152
|
-
function SocialEdit({ block, blockProps,
|
|
153
|
-
const
|
|
154
|
-
const
|
|
141
|
+
function SocialEdit({ block, blockProps, setAttrs, editable }: BlockEditProps) {
|
|
142
|
+
const tp = useMsgs("placeholders");
|
|
143
|
+
const all = linksOf(block.attrs);
|
|
144
|
+
const links = all.filter((l) => l.url);
|
|
155
145
|
const a = block.attrs;
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
</
|
|
162
|
-
|
|
163
|
-
|
|
146
|
+
const [adding, setAdding] = useState(false);
|
|
147
|
+
const [service, setService] = useState("facebook");
|
|
148
|
+
// Bấm "+" chọn mạng và dán link ngay trên khối (danh sách đầy đủ vẫn ở bảng cài đặt)
|
|
149
|
+
const adder = editable && (adding || !links.length) ? (
|
|
150
|
+
<span className="ecx-social-add" contentEditable={false} onMouseDown={(e) => e.stopPropagation()}>
|
|
151
|
+
{!adding ? <button type="button" className="ecx-add-item" onClick={() => setAdding(true)}><Plus className="ecx-icon ecx-icon-sm" aria-hidden />{tp.socialAdd}</button> : (
|
|
152
|
+
<form className="ecx-ph-row" onSubmit={(e) => { e.preventDefault(); const url = String(new FormData(e.currentTarget).get("url") ?? "").trim(); if (!url || !isSafeUrl(url)) return; setAttrs({ links: [...all, { service, url }] }); setAdding(false); }}>
|
|
153
|
+
<select className="ecx-input" aria-label={tp.socialNetwork} value={service} onChange={(e) => setService(e.target.value)}>{SOCIAL.map(([v, n]) => <option key={v} value={v}>{n}</option>)}</select>
|
|
154
|
+
<input className="ecx-input" name="url" type="url" aria-label={tp.link} placeholder={service === "email" ? "mailto:ban@congty.vn" : "https://…"} autoFocus />
|
|
155
|
+
<button type="submit" className="ecx-btn ecx-btn-primary">OK</button>
|
|
156
|
+
</form>
|
|
157
|
+
)}
|
|
158
|
+
</span>
|
|
159
|
+
) : null;
|
|
160
|
+
if (!links.length) return <div {...(blockProps as object)} className={cx(blockProps.className, "ecx-media-placeholder ecx-ph-inline")} data-ecx-placeholder="social"><span className="ecx-ph-title"><Share2 className="ecx-icon" />{adder}</span></div>;
|
|
164
161
|
return (
|
|
165
162
|
<ul {...(blockProps as object)} className={cx(blockProps.className, "ecx-social", `is-${a.size ?? "medium"}`, typeof a.align === "string" && `is-${a.align}`, !!a.showLabels && "has-labels")}>
|
|
166
163
|
{links.map((l, i) => <li key={i}><a className={`ecx-social-${l.service}`} title={l.label || socialName(l.service)} onClick={(e) => e.preventDefault()}>{l.label || socialName(l.service)}</a></li>)}
|
|
164
|
+
{adder ? <li className="ecx-ph-add">{adder}</li> : editable && <li className="ecx-ph-add"><button type="button" className="ecx-add-item" contentEditable={false} aria-label={tp.socialAdd} title={tp.socialAdd} onMouseDown={(e) => e.stopPropagation()} onClick={() => setAdding(true)}><Plus className="ecx-icon ecx-icon-sm" aria-hidden /></button></li>}
|
|
167
165
|
</ul>
|
|
168
166
|
);
|
|
169
167
|
}
|
|
@@ -232,18 +230,20 @@ function GalleryInspector({ attrs, setAttrs }: BlockEditProps) {
|
|
|
232
230
|
);
|
|
233
231
|
}
|
|
234
232
|
|
|
235
|
-
function TocEdit({ block, blockProps
|
|
233
|
+
function TocEdit({ block, blockProps }: BlockEditProps) {
|
|
236
234
|
const t = useMsgs("blocks");
|
|
235
|
+
const tp = useMsgs("placeholders");
|
|
236
|
+
const max = Math.min(4, Math.max(2, Number(block.attrs.maxLevel) || 3));
|
|
237
237
|
return (
|
|
238
238
|
<nav {...(blockProps as object)} className={cx(blockProps.className, "ecx-toc")}>
|
|
239
239
|
<p className="ecx-toc-title">{String(block.attrs.title || (t.contents))}</p>
|
|
240
|
-
<TocItems maxLevel={
|
|
240
|
+
<TocItems maxLevel={max} empty={<p className="ecx-placeholder-hint ecx-ph-note" contentEditable={false}>{tp.tocHint.replace("{n}", String(max))}</p>} />
|
|
241
241
|
</nav>
|
|
242
242
|
);
|
|
243
243
|
}
|
|
244
244
|
|
|
245
245
|
/** Mục lục xem trước: tiêu đề của tài liệu đang soạn. */
|
|
246
|
-
function TocItems({ maxLevel }: { maxLevel: number }) {
|
|
246
|
+
function TocItems({ maxLevel, empty }: { maxLevel: number; empty?: ReactNode }) {
|
|
247
247
|
const { store } = useEditor();
|
|
248
248
|
const doc = store.getState().docs[store.activeDocId];
|
|
249
249
|
const items: Array<{ level: number; text: string }> = [];
|
|
@@ -252,6 +252,7 @@ function TocItems({ maxLevel }: { maxLevel: number }) {
|
|
|
252
252
|
if (b.content) walk(b.content);
|
|
253
253
|
});
|
|
254
254
|
if (doc) walk(doc.blocks);
|
|
255
|
+
if (!items.length && empty) return <>{empty}</>;
|
|
255
256
|
return <ol>{items.map((h, i) => <li key={i} style={h.level > 2 ? { marginLeft: `${h.level - 2}em` } : undefined}>{h.text || "…"}</li>)}</ol>;
|
|
256
257
|
}
|
|
257
258
|
|
package/src/v2/blocks/text.tsx
CHANGED
|
@@ -8,56 +8,86 @@ import type { BlockEditProps, BlockTransform, BlockType } from "../core/registry
|
|
|
8
8
|
import { RichText } from "../text/rich-text";
|
|
9
9
|
import { useActiveWithin } from "./resize";
|
|
10
10
|
import { BoundText, useBindingPreview } from "../ui/bindings";
|
|
11
|
+
import { useMsgs } from "../i18n";
|
|
12
|
+
import { useEditor } from "../context";
|
|
11
13
|
|
|
12
14
|
// Căn chữ lấy từ vỏ dùng chung với website: căn trái không in style (trước đây canvas in thừa)
|
|
13
15
|
const align = (a: Record<string, unknown>, type = "paragraph"): CSSProperties | undefined => blockShell(type, a)?.style as CSSProperties | undefined;
|
|
14
16
|
const HEADING_ICONS = [Heading1, Heading1, Heading2, Heading3, Heading4, Heading5, Heading6];
|
|
15
17
|
|
|
16
|
-
function ParagraphEdit({ block, blockProps, editable
|
|
18
|
+
function ParagraphEdit({ block, blockProps, editable }: BlockEditProps) {
|
|
17
19
|
const bound = useBindingPreview(block, "content");
|
|
20
|
+
const tp = useMsgs("placeholders");
|
|
21
|
+
const { store } = useEditor();
|
|
18
22
|
if (bound.bound) return <BoundText tagName="p" preview={bound} blockProps={blockProps} style={align(block.attrs)} />;
|
|
19
|
-
|
|
23
|
+
// Gợi ý theo vai trò: mục danh sách / việc khác đoạn văn thường
|
|
24
|
+
const parent = store.locate(block.id)?.parent?.type;
|
|
25
|
+
const ph = parent === "listItem" ? tp.listItem : parent === "taskItem" ? tp.taskItem : tp.paragraph;
|
|
26
|
+
return <RichText blockId={block.id} value={block.inline} tagName="p" blockProps={blockProps} style={align(block.attrs)} placeholder={ph} placeholderAlways editable={editable} />;
|
|
20
27
|
}
|
|
21
28
|
|
|
22
|
-
function HeadingEdit({ block, blockProps, editable
|
|
29
|
+
function HeadingEdit({ block, blockProps, editable }: BlockEditProps) {
|
|
30
|
+
const tp = useMsgs("placeholders");
|
|
23
31
|
const level = Math.min(6, Math.max(1, Number(block.attrs.level) || 2));
|
|
24
32
|
const bound = useBindingPreview(block, "content");
|
|
25
33
|
if (bound.bound) return <BoundText tagName={`h${level}`} preview={bound} blockProps={blockProps} style={align(block.attrs, "heading")} />;
|
|
26
|
-
return <RichText blockId={block.id} value={block.inline} tagName={`h${level}`} blockProps={blockProps} style={align(block.attrs, "heading")} placeholder={
|
|
34
|
+
return <RichText blockId={block.id} value={block.inline} tagName={`h${level}`} blockProps={blockProps} style={align(block.attrs, "heading")} placeholder={tp.heading} placeholderAlways editable={editable} />;
|
|
27
35
|
}
|
|
28
36
|
|
|
29
|
-
|
|
37
|
+
const CODE_LANGS = ["html", "css", "javascript", "typescript", "json", "bash", "python", "php", "sql", "csharp", "yaml", "markdown"];
|
|
38
|
+
function CodeEdit({ block, blockProps, editable, setAttrs }: BlockEditProps) {
|
|
30
39
|
const lang = typeof block.attrs.language === "string" ? block.attrs.language : undefined;
|
|
40
|
+
const tp = useMsgs("placeholders");
|
|
41
|
+
const active = useActiveWithin(block.id);
|
|
31
42
|
return (
|
|
32
43
|
<pre {...blockProps}>
|
|
33
|
-
|
|
44
|
+
{/* Chọn ngôn ngữ ngay trên khối (chỉ trình soạn) */}
|
|
45
|
+
{editable && active && (
|
|
46
|
+
<label className="ecx-ph-corner" contentEditable={false} onMouseDown={(e) => e.stopPropagation()}>
|
|
47
|
+
<span className="ecx-ph-label">{tp.language}</span>
|
|
48
|
+
<select className="ecx-input" value={lang ?? ""} onChange={(e) => setAttrs({ language: e.target.value || undefined })}>
|
|
49
|
+
<option value="">{tp.languageAuto}</option>
|
|
50
|
+
{[...new Set([...(lang ? [lang] : []), ...CODE_LANGS])].map((l) => <option key={l} value={l}>{l}</option>)}
|
|
51
|
+
</select>
|
|
52
|
+
</label>
|
|
53
|
+
)}
|
|
54
|
+
<RichText blockId={block.id} value={block.inline} tagName="code" className={lang ? `language-${lang}` : undefined} multiline plain placeholder={tp.code} placeholderAlways editable={editable} />
|
|
34
55
|
</pre>
|
|
35
56
|
);
|
|
36
57
|
}
|
|
37
58
|
|
|
38
|
-
function PreformattedEdit({ block, blockProps, editable
|
|
39
|
-
|
|
59
|
+
function PreformattedEdit({ block, blockProps, editable }: BlockEditProps) {
|
|
60
|
+
const tp = useMsgs("placeholders");
|
|
61
|
+
return <RichText blockId={block.id} value={block.inline} tagName="pre" className="ecx-pre" blockProps={blockProps} breakOnEnter placeholder={tp.preformatted} placeholderAlways editable={editable} />;
|
|
40
62
|
}
|
|
41
63
|
|
|
42
|
-
function PullquoteEdit({ block, blockProps, editable,
|
|
43
|
-
const
|
|
64
|
+
function PullquoteEdit({ block, blockProps, editable, setAttrs }: BlockEditProps) {
|
|
65
|
+
const tp = useMsgs("placeholders");
|
|
44
66
|
const cite = blockCitation(block.attrs) ?? "";
|
|
45
67
|
const sh = blockShell("pullquote", block.attrs)!;
|
|
46
68
|
return (
|
|
47
69
|
<figure {...blockProps} className={`${blockProps.className} ${sh.className}`}>
|
|
48
|
-
<blockquote><RichText blockId={block.id} value={block.inline} tagName="p" placeholder={
|
|
49
|
-
{/* website chỉ in nguồn khi có chữ:
|
|
50
|
-
{(cite ||
|
|
70
|
+
<blockquote><RichText blockId={block.id} value={block.inline} tagName="p" placeholder={tp.quote} placeholderAlways editable={editable} /></blockquote>
|
|
71
|
+
{/* website chỉ in nguồn khi có chữ: trình soạn luôn có ô người nói để thấy chỗ gõ */}
|
|
72
|
+
{(cite || editable) && <RichText blockId={block.id} field="citation" tagName="figcaption" value={cite} onChange={(v) => setAttrs({ citation: v })} placeholder={tp.speaker} placeholderAlways editable={editable} />}
|
|
51
73
|
</figure>
|
|
52
74
|
);
|
|
53
75
|
}
|
|
54
76
|
|
|
55
|
-
function ListEdit({ block, blockProps }: BlockEditProps) {
|
|
77
|
+
function ListEdit({ block, blockProps, setAttrs, editable }: BlockEditProps) {
|
|
56
78
|
const Tag = block.type === "orderedList" ? "ol" : "ul";
|
|
57
79
|
const start = Number(block.attrs.start);
|
|
80
|
+
const tp = useMsgs("placeholders");
|
|
81
|
+
const active = useActiveWithin(block.id);
|
|
58
82
|
return (
|
|
59
83
|
<Tag {...(blockProps as object)} className={`${blockProps.className}${block.type === "taskList" ? " ecx-task-list task-list" : ""}`} start={Tag === "ol" && start > 1 ? start : undefined}>
|
|
60
84
|
<InnerBlocks parent={block} appender="none" />
|
|
85
|
+
{/* Số bắt đầu chỉnh ngay trên khối (chỉ khi đang thao tác trong danh sách số) */}
|
|
86
|
+
{Tag === "ol" && editable && active && (
|
|
87
|
+
<li className="ecx-ph-corner is-list" contentEditable={false} onMouseDown={(e) => e.stopPropagation()} role="presentation">
|
|
88
|
+
<label><span className="ecx-ph-label">{tp.startAt}</span> <input className="ecx-input" type="number" min={1} value={start > 0 ? start : 1} onChange={(e) => setAttrs({ start: Math.max(1, Number(e.target.value) || 1) })} /></label>
|
|
89
|
+
</li>
|
|
90
|
+
)}
|
|
61
91
|
</Tag>
|
|
62
92
|
);
|
|
63
93
|
}
|
|
@@ -75,13 +105,14 @@ function TaskItemEdit({ block, blockProps, setAttrs, editable }: BlockEditProps)
|
|
|
75
105
|
);
|
|
76
106
|
}
|
|
77
107
|
|
|
78
|
-
function QuoteEdit({ block, blockProps, editable, setAttrs
|
|
108
|
+
function QuoteEdit({ block, blockProps, editable, setAttrs }: BlockEditProps) {
|
|
79
109
|
const cite = blockCitation(block.attrs);
|
|
80
|
-
|
|
110
|
+
const tp = useMsgs("placeholders");
|
|
111
|
+
// Website in <cite> sau nội dung khi có nguồn: trình soạn luôn có ô nguồn ("— Thêm nguồn…") để sửa tại chỗ
|
|
81
112
|
return (
|
|
82
113
|
<blockquote {...blockProps}>
|
|
83
114
|
<InnerBlocks parent={block} />
|
|
84
|
-
{cite !== undefined && <RichText blockId={block.id} field="citation" tagName="cite" value={cite} onChange={(v) => setAttrs({ citation: v || undefined })} placeholder={
|
|
115
|
+
{(cite !== undefined || editable) && <RichText blockId={block.id} field="citation" tagName="cite" value={cite ?? ""} onChange={(v) => setAttrs({ citation: v || undefined })} placeholder={tp.citation} placeholderAlways editable={editable} />}
|
|
85
116
|
</blockquote>
|
|
86
117
|
);
|
|
87
118
|
}
|
package/src/v2/blocks/theme.tsx
CHANGED
|
@@ -8,6 +8,7 @@ import type { BNode } from "../core/model";
|
|
|
8
8
|
import { blocksFromDoc, makeBlock } from "../core/model";
|
|
9
9
|
import type { BlockEditProps, BlockType } from "../core/registry";
|
|
10
10
|
import { useMsgs } from "../i18n";
|
|
11
|
+
import { MediaPlaceholder } from "../ui/placeholders";
|
|
11
12
|
|
|
12
13
|
const cx = (...c: unknown[]) => c.filter((x): x is string => typeof x === "string" && x !== "").join(" ");
|
|
13
14
|
const align = (a: Record<string, unknown>): CSSProperties | undefined => (typeof a.textAlign === "string" ? { textAlign: a.textAlign as CSSProperties["textAlign"] } : undefined);
|
|
@@ -29,10 +30,35 @@ function SiteTaglineEdit({ block, blockProps }: BlockEditProps) {
|
|
|
29
30
|
const d = useDynamic();
|
|
30
31
|
return <p {...merge(blockProps, "ecx-site-tagline", align(block.attrs))}>{d.site?.tagline || "Tagline"}</p>;
|
|
31
32
|
}
|
|
32
|
-
|
|
33
|
+
/** Nhãn của ô giữ chỗ khối giao diện: cam = thiếu dữ liệu (kèm nút đi tới chỗ nhập). */
|
|
34
|
+
function Missing({ children }: { children: ReactNode }) {
|
|
35
|
+
return <span className="ecx-ph-badge is-missing" contentEditable={false}>{children}</span>;
|
|
36
|
+
}
|
|
37
|
+
/** Nút đi tới trang quản trị nhập dữ liệu còn thiếu (host.openAdmin). */
|
|
38
|
+
function AdminButton({ target, args, children, primary }: { target: Parameters<NonNullable<ReturnType<typeof useEditor>["host"]["openAdmin"]>>[0]; args?: Record<string, string>; children: ReactNode; primary?: boolean }) {
|
|
39
|
+
const { host } = useEditor();
|
|
40
|
+
if (!host.openAdmin) return null;
|
|
41
|
+
return <button type="button" className={cx("ecx-btn", primary && "ecx-btn-primary")} contentEditable={false} onMouseDown={(e) => e.stopPropagation()} onClick={() => host.openAdmin!(target, args)}>{children}</button>;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
function SiteLogoEdit({ block, blockProps, editable }: BlockEditProps) {
|
|
33
45
|
const d = useDynamic();
|
|
46
|
+
const { host } = useEditor();
|
|
47
|
+
const tp = useMsgs("placeholders");
|
|
48
|
+
const [saved, setSaved] = useState<string | null>(null);
|
|
34
49
|
const w = Number(block.attrs.width) || 120;
|
|
35
|
-
|
|
50
|
+
const logo = d.site?.logo || saved;
|
|
51
|
+
if (logo || !editable) return <div {...merge(blockProps, "ecx-site-logo")}>{logo ? <img src={logo} alt="" width={w} draggable={false} /> : <span className="ecx-logo-placeholder" style={{ width: w }}><ImageIcon className="ecx-icon" /></span>}</div>;
|
|
52
|
+
// Chưa có logo: ô thả logo — chọn xong là đổi logo cho cả website (host.setSiteLogo); không có thì nút mở Tuỳ biến
|
|
53
|
+
return (
|
|
54
|
+
<div {...merge(blockProps, "ecx-site-logo ecx-ph-theme is-missing")} data-ecx-placeholder="logo">
|
|
55
|
+
<Missing>{tp.noLogo}</Missing>
|
|
56
|
+
{host.setSiteLogo
|
|
57
|
+
? <MediaPlaceholder kind="image" compact title={tp.dropLogo} onSelect={(items) => { host.setSiteLogo!(items[0]).then(() => setSaved(items[0].url), () => {}); }} />
|
|
58
|
+
: <AdminButton target="customize" primary>{tp.openSettings}</AdminButton>}
|
|
59
|
+
<p className="ecx-placeholder-hint">{tp.logoAll}</p>
|
|
60
|
+
</div>
|
|
61
|
+
);
|
|
36
62
|
}
|
|
37
63
|
/** Menu: cùng markup với website (theme-sdk) — nav.ecx-navigation-menu > ul > li > a, nút ☰ cho điện thoại. */
|
|
38
64
|
/** Nút nhỏ trên khối Menu đang chọn: mở nơi sửa menu của ứng dụng nhúng. */
|
|
@@ -49,12 +75,20 @@ function NavigationEdit({ block, blockProps, selected }: BlockEditProps) {
|
|
|
49
75
|
const items = d.menus?.[location];
|
|
50
76
|
const mobile = block.attrs.mobile !== false;
|
|
51
77
|
const t = useMsgs("blocks");
|
|
78
|
+
const tp = useMsgs("placeholders");
|
|
79
|
+
const { host } = useEditor();
|
|
52
80
|
if (!items?.length) {
|
|
81
|
+
// Vị trí chưa có menu: nhãn cam + nút tạo / chọn menu (thay cho cột liên kết trống)
|
|
53
82
|
return (
|
|
54
|
-
<div {...merge(blockProps, "ecx-navigation ecx-placeholder-
|
|
55
|
-
<span className="ecx-placeholder-title"><Menu className="ecx-icon" /> {t.menu}
|
|
56
|
-
<
|
|
57
|
-
|
|
83
|
+
<div {...merge(blockProps, "ecx-navigation ecx-media-placeholder ecx-ph-theme is-missing")} data-ecx-placeholder="menu">
|
|
84
|
+
<span className="ecx-placeholder-title"><Menu className="ecx-icon" /> {t.menu}</span>
|
|
85
|
+
<Missing>{tp.menuEmpty.replace("{location}", location)}</Missing>
|
|
86
|
+
{host.editMenu && (
|
|
87
|
+
<span className="ecx-ph-row" contentEditable={false} onMouseDown={(e) => e.stopPropagation()}>
|
|
88
|
+
<button type="button" className="ecx-btn ecx-btn-primary" onClick={() => host.editMenu!(location)}>{tp.createMenu}</button>
|
|
89
|
+
<button type="button" className="ecx-btn" onClick={() => host.editMenu!(location)}>{tp.pickMenu}</button>
|
|
90
|
+
</span>
|
|
91
|
+
)}
|
|
58
92
|
</div>
|
|
59
93
|
);
|
|
60
94
|
}
|
|
@@ -105,10 +139,14 @@ function PostExcerptEdit({ block, blockProps }: BlockEditProps) {
|
|
|
105
139
|
}
|
|
106
140
|
function FeaturedImageEdit({ block, blockProps }: BlockEditProps) {
|
|
107
141
|
const d = useDynamic();
|
|
142
|
+
const tp = useMsgs("placeholders");
|
|
108
143
|
const ratio = block.attrs.aspect && block.attrs.aspect !== "auto" ? String(block.attrs.aspect) : undefined;
|
|
109
144
|
return (
|
|
110
145
|
<div {...merge(blockProps, "ecx-featured-image", { aspectRatio: ratio ?? (d.post?.image ? undefined : "16/9"), overflow: "hidden" })}>
|
|
111
|
-
{d.post?.image ? <img src={d.post.image} alt="" draggable={false} style={{ width: "100%", height: "100%", objectFit: "cover" }} /> :
|
|
146
|
+
{d.post?.image ? <img src={d.post.image} alt="" draggable={false} style={{ width: "100%", height: "100%", objectFit: "cover" }} /> : (
|
|
147
|
+
// Giải thích thay vì khung trống
|
|
148
|
+
<span className="ecx-image-placeholder ecx-ph-theme" data-ecx-placeholder="featured"><ImageIcon className="ecx-icon" /><Missing>{tp.noFeatured}</Missing><span className="ecx-placeholder-hint">{tp.noFeaturedHint}</span></span>
|
|
149
|
+
)}
|
|
112
150
|
</div>
|
|
113
151
|
);
|
|
114
152
|
}
|
|
@@ -246,7 +284,7 @@ function sampleContentNodes(content: unknown): BNode[] | null {
|
|
|
246
284
|
return nodes.length ? nodes : null;
|
|
247
285
|
}
|
|
248
286
|
function PostContentEdit({ blockProps }: BlockEditProps) {
|
|
249
|
-
const
|
|
287
|
+
const tp = useMsgs("placeholders");
|
|
250
288
|
const sample = sampleContentNodes(useDynamicData().post?.content);
|
|
251
289
|
const t = useMsgs("blocks");
|
|
252
290
|
const scope = useDocScope();
|
|
@@ -262,10 +300,31 @@ function PostContentEdit({ blockProps }: BlockEditProps) {
|
|
|
262
300
|
}
|
|
263
301
|
// Có bài mẫu → nội dung thật của bài (chỉ xem; sửa nội dung ở trình soạn bài); chưa có → khung giữ chỗ
|
|
264
302
|
if (sample) return <div {...merge(blockProps, "ecx-post-content ecx-content")}><PreviewBlocks nodes={sample} tag="sample-content" /></div>;
|
|
265
|
-
return <div {...merge(blockProps, "ecx-post-content ecx-content-placeholder")}><FileText className="ecx-icon" /> {t.postContent}</div>;
|
|
303
|
+
return <div {...merge(blockProps, "ecx-post-content ecx-content-placeholder")} data-ecx-placeholder="post-content"><FileText className="ecx-icon" /> <span><strong>{t.postContent}</strong><br /><span className="ecx-placeholder-hint">{tp.postContentHint}</span></span></div>;
|
|
266
304
|
}
|
|
267
305
|
|
|
268
|
-
|
|
306
|
+
/** Kiểu hiển thị của danh sách bài khi chèn (như Query Loop của WordPress: chọn mẫu trước rồi hiện bài thật). */
|
|
307
|
+
const QUERY_LAYOUTS = {
|
|
308
|
+
list: () => [makeBlock("postTemplate", { layout: "list" }, [makeBlock("postTitle", { level: 2, link: true }), makeBlock("postDate"), makeBlock("postExcerpt")]), makeBlock("pagination")],
|
|
309
|
+
grid: () => [makeBlock("postTemplate", { layout: "grid", columns: 3 }, [makeBlock("postTitle", { level: 3, link: true }), makeBlock("postExcerpt")]), makeBlock("pagination")],
|
|
310
|
+
cards: () => [makeBlock("postTemplate", { layout: "grid", columns: 3 }, [makeBlock("featuredImage", { link: true, aspect: "16/9" }), makeBlock("postTitle", { level: 3, link: true }), makeBlock("postDate")]), makeBlock("pagination")],
|
|
311
|
+
};
|
|
312
|
+
function QueryEdit({ block, blockProps, editable }: BlockEditProps) {
|
|
313
|
+
const { store } = useEditor();
|
|
314
|
+
const tp = useMsgs("placeholders");
|
|
315
|
+
if (editable && !block.content?.length) {
|
|
316
|
+
const items: Array<[keyof typeof QUERY_LAYOUTS, typeof Rows3, string]> = [["list", Rows3, tp.queryList], ["grid", LayoutTemplate, tp.queryGrid], ["cards", ImageIcon, tp.queryCards]];
|
|
317
|
+
return (
|
|
318
|
+
<div {...merge(blockProps, "ecx-query")} data-ecx-placeholder="query">
|
|
319
|
+
<div className="ecx-media-placeholder ecx-ph-choose" contentEditable={false} onMouseDown={(e) => e.stopPropagation()}>
|
|
320
|
+
<p className="ecx-ph-title">{tp.queryChoose}</p>
|
|
321
|
+
<div className="ecx-ph-choices">
|
|
322
|
+
{items.map(([k, I, label]) => <button key={k} type="button" className="ecx-ph-choice" onClick={() => store.replace(block.id, [{ ...block, content: QUERY_LAYOUTS[k]() }])}><I className="ecx-icon" aria-hidden />{label}</button>)}
|
|
323
|
+
</div>
|
|
324
|
+
</div>
|
|
325
|
+
</div>
|
|
326
|
+
);
|
|
327
|
+
}
|
|
269
328
|
return <div {...merge(blockProps, "ecx-query")}><InnerBlocks parent={block} /></div>;
|
|
270
329
|
}
|
|
271
330
|
/** Thiết lập của khối query (mặc định giống website). */
|
|
@@ -315,9 +374,10 @@ function PostTemplateEdit({ block, blockProps, editable, labels }: BlockEditProp
|
|
|
315
374
|
const count = posts ? Math.max(1, Math.min(posts.length, q.perPage, 6)) : 3;
|
|
316
375
|
const current = Math.min(active, count - 1);
|
|
317
376
|
const t = useMsgs("blocks");
|
|
377
|
+
const tp = useMsgs("placeholders");
|
|
318
378
|
return (
|
|
319
379
|
<ul {...(merge(blockProps, cx("ecx-post-template", grid && "is-grid"), grid ? { display: "grid", gridTemplateColumns: `repeat(${cols}, minmax(0, 1fr))`, gap: "1.5rem" } : undefined) as object)} data-ecx-posts={posts ? posts.length : ""}>
|
|
320
|
-
{posts && !posts.length && <li className="ecx-post ecx-post-none">{
|
|
380
|
+
{posts && !posts.length && <li className="ecx-post ecx-post-none ecx-ph-theme is-missing" data-ecx-placeholder="no-posts"><Missing>{tp.noPosts}</Missing> <span className="ecx-placeholder-hint">{tp.noPostsHint}</span> <AdminButton target="newPost" args={{ postType: q.postType }}>+ {tp.writeFirst}</AdminButton></li>}
|
|
321
381
|
{Array.from({ length: count }, (_, i) => {
|
|
322
382
|
const post = posts?.[i] ?? null;
|
|
323
383
|
if (i === current) return <li key="edit" className={cx("ecx-post", count > 1 && "is-active")}><LoopPostContext.Provider value={post}><InnerBlocks parent={block} /></LoopPostContext.Provider></li>;
|
|
@@ -423,7 +483,8 @@ export function themeBlocks(): BlockType[] {
|
|
|
423
483
|
{
|
|
424
484
|
name: "query", title: "Danh sách bài", icon: Rows3, category: theme, keywords: "danh sach bai query loop tin tuc", kind: "container", edit: QueryEdit,
|
|
425
485
|
attributes: { inherit: { type: "boolean", default: true }, postType: { type: "string", default: "post" }, perPage: { type: "integer", default: 10, min: 1, max: 100 }, category: { type: "string" }, tag: { type: "string" }, orderBy: { type: "string", enum: ["date", "title", "modified", "menu_order", "comment_count", "rand"], default: "date" }, order: { type: "string", enum: ["desc", "asc"], default: "desc" }, authorId: { type: "integer", min: 1 }, search: { type: "string" }, exclude: { type: "string" }, sticky: { type: "string", enum: ["any", "only", "exclude"], default: "any" }, orderByMeta: { type: "string" }, paginate: { type: "boolean", default: false } },
|
|
426
|
-
|
|
486
|
+
// Mới chèn: chưa có khuôn → hỏi kiểu hiển thị trước (Danh sách / Lưới / Thẻ có ảnh)
|
|
487
|
+
create: () => makeBlock("query", { inherit: true }, []),
|
|
427
488
|
supports: { style: true, className: true },
|
|
428
489
|
},
|
|
429
490
|
{ name: "postTemplate", title: "Khuôn mỗi bài", icon: LayoutTemplate, kind: "container", edit: PostTemplateEdit, hidden: true, attributes: { layout: { type: "string", enum: ["list", "grid"], default: "list" }, columns: { type: "integer", default: 3, min: 1, max: 6 } }, structure: { parents: ["query"] } },
|