@ecomcx/ecomweb-editor 1.33.0 → 1.34.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/attrs.ts +2 -1
- package/src/locales/en/background.ts +5 -0
- package/src/locales/en/bindings.ts +4 -0
- package/src/locales/en/block-desc.ts +4 -11
- package/src/locales/en/block-style.ts +17 -6
- package/src/locales/en/block-titles.ts +38 -16
- package/src/locales/en/blocks.ts +36 -6
- package/src/locales/en/columns.ts +1 -0
- package/src/locales/en/controls.ts +1 -1
- package/src/locales/en/hints.ts +241 -12
- package/src/locales/en/index.ts +3 -1
- package/src/locales/en/layout.ts +13 -0
- package/src/locales/en/motion.ts +16 -0
- package/src/locales/en/palette.ts +8 -0
- package/src/locales/en/parts.ts +2 -1
- package/src/locales/en/pattern-overrides.ts +14 -0
- package/src/locales/en/placeholders.ts +6 -3
- package/src/locales/en/v2.ts +2 -0
- package/src/locales/vi/attrs.ts +3 -2
- package/src/locales/vi/background.ts +5 -0
- package/src/locales/vi/bindings.ts +4 -0
- package/src/locales/vi/block-desc.ts +7 -14
- package/src/locales/vi/block-style.ts +18 -7
- package/src/locales/vi/block-titles.ts +48 -26
- package/src/locales/vi/blocks.ts +36 -6
- package/src/locales/vi/columns.ts +1 -0
- package/src/locales/vi/controls.ts +1 -1
- package/src/locales/vi/hints.ts +241 -12
- package/src/locales/vi/index.ts +3 -1
- package/src/locales/vi/layout.ts +13 -0
- package/src/locales/vi/motion.ts +16 -0
- package/src/locales/vi/palette.ts +8 -0
- package/src/locales/vi/parts.ts +2 -1
- package/src/locales/vi/pattern-overrides.ts +14 -0
- package/src/locales/vi/placeholders.ts +7 -4
- package/src/locales/vi/v2.ts +2 -0
- package/src/v2/blocks/columns-inspector.tsx +11 -2
- package/src/v2/blocks/index.ts +9 -6
- package/src/v2/blocks/layout-options.tsx +80 -0
- package/src/v2/blocks/layout.tsx +331 -124
- package/src/v2/blocks/media.tsx +51 -21
- package/src/v2/blocks/resize.tsx +50 -19
- package/src/v2/blocks/social-icons.ts +22 -0
- package/src/v2/blocks/text.tsx +12 -50
- package/src/v2/blocks/theme.tsx +13 -19
- package/src/v2/blocks/tools.tsx +24 -2
- package/src/v2/blocks/widgets.tsx +84 -28
- package/src/v2/canvas/block-list.tsx +30 -4
- package/src/v2/canvas/canvas-css.ts +81 -9
- package/src/v2/canvas/canvas.tsx +63 -7
- package/src/v2/canvas/dnd.ts +7 -0
- package/src/v2/canvas/variation-picker.tsx +63 -0
- package/src/v2/context.tsx +48 -0
- package/src/v2/core/bindings.ts +6 -1
- package/src/v2/core/block-presets.ts +10 -0
- package/src/v2/core/clipboard.ts +5 -5
- package/src/v2/core/host.ts +2 -0
- package/src/v2/core/model.ts +6 -6
- package/src/v2/core/registry.ts +15 -0
- package/src/v2/core/store.ts +9 -9
- package/src/v2/core/structure.ts +1 -3
- package/src/v2/editor.css +74 -0
- package/src/v2/editor.tsx +22 -7
- package/src/v2/text/rich-text.tsx +20 -5
- package/src/v2/ui/ai-markdown.ts +52 -0
- package/src/v2/ui/ai.tsx +81 -14
- package/src/v2/ui/attr-form.tsx +26 -6
- package/src/v2/ui/attr-hints.ts +115 -16
- package/src/v2/ui/background-panel.tsx +22 -0
- package/src/v2/ui/bg-video-preview.tsx +7 -0
- package/src/v2/ui/bindings.tsx +7 -2
- package/src/v2/ui/block-icons.tsx +3 -10
- package/src/v2/ui/block-live-preview.tsx +21 -0
- package/src/v2/ui/block-style-panel.tsx +3 -1
- package/src/v2/ui/command-palette.tsx +125 -0
- package/src/v2/ui/icon-picker.tsx +88 -21
- package/src/v2/ui/icon-svg.tsx +21 -0
- package/src/v2/ui/inserter.tsx +62 -12
- package/src/v2/ui/inspector.tsx +12 -6
- package/src/v2/ui/layout-panel.tsx +1 -1
- package/src/v2/ui/motion-panel.tsx +22 -13
- package/src/v2/ui/option-thumbs.tsx +81 -0
- package/src/v2/ui/pattern-library.tsx +2 -1
- package/src/v2/ui/pattern-overrides.tsx +67 -0
- package/src/v2/ui/placeholders.tsx +21 -2
- package/src/v2/ui/preset-bar.tsx +5 -5
- package/src/v2/ui/style-supports.ts +2 -3
- package/src/v2/ui/style-tab.tsx +83 -20
- package/src/v2/ui/toolbar.tsx +40 -6
- package/src/v2/ui/transform-panel.tsx +77 -0
package/src/v2/blocks/layout.tsx
CHANGED
|
@@ -1,29 +1,33 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { resolveIcon, coverVideo, countdownRules, nextTarget, CORE_NODES, testimonialsConfig, testimonialsVars, popupClass, popupConfig, popupPlayStyle, popupVars, carouselConfig, carouselData, carouselVars, COUNTDOWN_ZONES, countdownParts, countdownTarget, wallInZone, blockShell, buttonIcon, buttonWrapShell, controlsCss, coverParts, tabsClass } from "@ecomcx/ecomweb-content";
|
|
2
|
+
import { IconPicker } from "../ui/icon-picker";
|
|
3
|
+
import { BgVideoPreview } from "../ui/bg-video-preview";
|
|
4
|
+
import { IconSvg } from "../ui/icon-svg";
|
|
2
5
|
import { blockControls } from "../../shared/panel-store";
|
|
3
|
-
import { ChevronLeft, ChevronRight, Plus, ChevronsUpDown, Columns2, Columns3, Columns4,
|
|
4
|
-
import { useCallback, useEffect, useState, useSyncExternalStore, type CSSProperties } from "react";
|
|
6
|
+
import { ChevronLeft, ChevronRight, Plus, ChevronsUpDown, Columns2, Columns3, Columns4, LayoutPanelLeft, MousePointerClick, PanelTop, RectangleHorizontal, Square, Table2, Image as ImageIcon } from "lucide-react";
|
|
7
|
+
import { useCallback, useEffect, useLayoutEffect, useRef, useState, useSyncExternalStore, type CSSProperties } from "react";
|
|
5
8
|
import { InnerBlocks } from "../canvas/block-list";
|
|
6
9
|
import { withoutOverridden } from "./inline-style";
|
|
7
10
|
import { makeBlock, type BNode } from "../core/model";
|
|
11
|
+
import { messages } from "../../i18n";
|
|
12
|
+
import { accordionLayouts, carouselLayouts, tabsLayouts } from "./layout-options";
|
|
8
13
|
import type { BlockEditProps, BlockType } from "../core/registry";
|
|
9
14
|
import { RichText } from "../text/rich-text";
|
|
10
15
|
import { BoundText, useBindingPreview } from "../ui/bindings";
|
|
11
16
|
import { useEditor, useEditorState } from "../context";
|
|
12
|
-
import {
|
|
17
|
+
import { ButtonTools, ButtonsTools, ColumnsTools, TableTools, addColumnTo } from "./tools";
|
|
13
18
|
import { ColumnHandles, ContentWidthHandles, HeightHandle, PaddingHandles, useActiveWithin } from "./resize";
|
|
14
19
|
import { ColumnInspector, ColumnsInspector } from "./columns-inspector";
|
|
15
20
|
import { layoutFor, layoutKind } from "../ui/layout-panel";
|
|
16
|
-
import { normalizeStyle, type BlockStyle } from "@ecomcx/ecomweb-content";
|
|
21
|
+
import { normalizeStyle, tableClass, type BlockStyle } from "@ecomcx/ecomweb-content";
|
|
17
22
|
import { Dropdown, MenuItem, ToolButton } from "../ui/toolbar";
|
|
18
23
|
import { useSiteColors } from "../ui/color-field";
|
|
19
24
|
import { AddItemButton, MediaPlaceholder } from "../ui/placeholders";
|
|
20
25
|
import type { MediaItem } from "../../shared/types";
|
|
21
|
-
import { LayoutGrid, Rows3, Columns3 as RowIcon, MoveHorizontal, Palette } from "lucide-react";
|
|
26
|
+
import { Copy, LayoutGrid, Rows3, Columns3 as RowIcon, MoveHorizontal, Palette, Trash2 } from "lucide-react";
|
|
22
27
|
import { useMsgs } from "../i18n";
|
|
28
|
+
import { Section } from "../ui/style-controls";
|
|
23
29
|
|
|
24
30
|
const cx = (...c: unknown[]) => c.filter((x): x is string => typeof x === "string" && x !== "").join(" ");
|
|
25
|
-
const PADDING: Record<string, string> = { none: "0", small: "0.75rem", medium: "1.5rem", large: "3rem" };
|
|
26
|
-
const TONES: Record<string, string> = { info: "#1a597b", success: "#16a34a", warning: "#d97706", danger: "#dc2626" };
|
|
27
31
|
/** Gộp props của khối với class + style inline riêng; `attrs` có `style` thì bỏ phần inline mà kiểu dáng đã thay (khớp website). */
|
|
28
32
|
const merge = (bp: BlockEditProps["blockProps"], className: string, style?: CSSProperties, attrs?: Record<string, unknown>) =>
|
|
29
33
|
({ ...bp, className: cx(bp.className, className), style: { ...(bp.style ?? {}), ...(attrs?.style ? withoutOverridden(style ?? {}, attrs.style) : style) } });
|
|
@@ -36,6 +40,23 @@ const shellProps = (bp: BlockEditProps["blockProps"], type: string, attrs: Recor
|
|
|
36
40
|
return { ...merge(bp, sh.className ?? "", sh.style as CSSProperties, self ? { style: { ...self, ...(normalizeStyle(attrs.style) ?? {}) } } : attrs), ...sh.attrs };
|
|
37
41
|
};
|
|
38
42
|
|
|
43
|
+
/** Biểu tượng hai lớp của Phần: dải nền + hai dòng chữ — mỗi kiểu nền một biểu tượng để nhận ra ngay trong bảng chèn. */
|
|
44
|
+
const sectionIcon = (fill: string, ink: string, stroke?: string) => function SectionIcon({ className }: { className?: string }) {
|
|
45
|
+
return (
|
|
46
|
+
<svg className={className} viewBox="0 0 24 24" aria-hidden="true">
|
|
47
|
+
<rect x="1.5" y="5" width="21" height="14" rx="2" fill={fill} stroke={stroke ?? "none"} strokeWidth="1.5" />
|
|
48
|
+
<rect x="6" y="9" width="12" height="2" rx="1" fill={ink} />
|
|
49
|
+
<rect x="8" y="13" width="8" height="2" rx="1" fill={ink} opacity=".7" />
|
|
50
|
+
</svg>
|
|
51
|
+
);
|
|
52
|
+
};
|
|
53
|
+
const SECTION_ICONS = { plain: sectionIcon("none", "currentColor", "currentColor"), light: sectionIcon("#e5e7eb", "#6b7280"), brand: sectionIcon("#1a597b", "#ffffff"), dark: sectionIcon("#111827", "#ffffff") };
|
|
54
|
+
|
|
55
|
+
/** Phần (Section): nhóm rộng hết trang + khung nội dung + đệm lớn, có sẵn tiêu đề và đoạn mẫu để thấy ngay đây là một phần của trang. */
|
|
56
|
+
function sectionWith(m: Record<string, string>, extra: Record<string, unknown>): BNode {
|
|
57
|
+
return makeBlock("group", { align: "full", constrained: true, padding: "large", ...extra }, [makeBlock("heading", { level: 2, textAlign: "center" }, m.sampleSectionTitle), makeBlock("paragraph", { textAlign: "center" }, m.sampleSectionText)]);
|
|
58
|
+
}
|
|
59
|
+
|
|
39
60
|
function GroupEdit({ block, blockProps, setAttrs, editable, selected }: BlockEditProps) {
|
|
40
61
|
const tp = useMsgs("placeholders");
|
|
41
62
|
const { store } = useEditor();
|
|
@@ -46,6 +67,7 @@ function GroupEdit({ block, blockProps, setAttrs, editable, selected }: BlockEdi
|
|
|
46
67
|
const items: Array<["stack" | "row" | "grid", typeof Square, string]> = [["stack", Rows3, tp.layoutStack], ["row", RowIcon, tp.layoutRow], ["grid", LayoutGrid, tp.layoutGrid]];
|
|
47
68
|
return (
|
|
48
69
|
<div {...shellProps(blockProps, "group", block.attrs)} data-ecx-placeholder={fresh ? "layout" : undefined}>
|
|
70
|
+
<BgVideoPreview style={block.attrs.style} />
|
|
49
71
|
<InnerBlocks parent={block} />
|
|
50
72
|
{/* Chọn bố cục nằm dưới đoạn văn: thanh công cụ nổi của đoạn nằm phía trên, không che các nút */}
|
|
51
73
|
{fresh && (
|
|
@@ -133,6 +155,7 @@ function ColumnsEdit({ block, blockProps, editable, labels, selected }: BlockEdi
|
|
|
133
155
|
);
|
|
134
156
|
return (
|
|
135
157
|
<div {...merge(blockProps, shell.className!, shell.style as CSSProperties, block.attrs)}>
|
|
158
|
+
<BgVideoPreview style={block.attrs.style} />
|
|
136
159
|
<InnerBlocks parent={block} appender="none" />
|
|
137
160
|
{active && editable && block.content!.length > 1 && <ColumnHandles block={block} />}
|
|
138
161
|
{selected && editable && <PaddingHandles blockId={block.id} />}
|
|
@@ -150,6 +173,7 @@ function ColumnEdit({ block, blockProps, selected, editable }: BlockEditProps) {
|
|
|
150
173
|
const shell = blockShell("column", block.attrs, parent ? { type: parent.type, attrs: parent.attrs } : undefined)!;
|
|
151
174
|
return (
|
|
152
175
|
<div {...merge(blockProps, shell.className!, shell.style as CSSProperties, block.attrs)}>
|
|
176
|
+
<BgVideoPreview style={block.attrs.style} />
|
|
153
177
|
<InnerBlocks parent={block} />
|
|
154
178
|
{selected && editable && <PaddingHandles blockId={block.id} />}
|
|
155
179
|
</div>
|
|
@@ -171,7 +195,7 @@ function ButtonEdit({ block, blockProps, setAttrs, editable }: BlockEditProps) {
|
|
|
171
195
|
const icon = ic && <svg className="ecx-widget-icon" viewBox="0 0 24 24" width={24} height={24} fill="none" stroke="currentColor" strokeWidth={2} strokeLinecap="round" strokeLinejoin="round" aria-hidden="true"><path d={String((ic.children?.[0] as { props?: { d?: string } })?.props?.d ?? "")} /></svg>;
|
|
172
196
|
// Website: nút đứng riêng nằm trong đoạn <p class="ecx-buttons"> (căn lề); trong khối "buttons" thì là chính thẻ <a>
|
|
173
197
|
const link = (
|
|
174
|
-
<a {...shellProps(inGroup ? blockProps : ({} as BlockEditProps["blockProps"]), "button", a)} onClick={(e) => e.preventDefault()}>
|
|
198
|
+
<a {...shellProps(inGroup ? blockProps : ({} as BlockEditProps["blockProps"]), "button", a)} title={typeof a.tooltip === "string" && a.tooltip ? a.tooltip : undefined} onClick={(e) => e.preventDefault()}>
|
|
175
199
|
{icon && (a.iconPosition !== "right" || a.iconOnly === true) && icon}
|
|
176
200
|
{/* Chỉ icon: chữ sửa ở ô "Chữ" bên phải (thành nhãn cho trình đọc màn hình) */}
|
|
177
201
|
{icon && a.iconOnly === true ? null : bound.bound ? <BoundText preview={bound} /> : <RichText blockId={block.id} field="text" tagName="span" value={String(a.text ?? "")} onChange={(v) => setAttrs({ text: v })} placeholder={tp.buttonText} placeholderAlways editable={editable} />}
|
|
@@ -186,23 +210,42 @@ function ButtonEdit({ block, blockProps, setAttrs, editable }: BlockEditProps) {
|
|
|
186
210
|
function SpacerEdit({ block, blockProps, selected, editable }: BlockEditProps) {
|
|
187
211
|
const tp = useMsgs("placeholders");
|
|
188
212
|
const props = shellProps(blockProps, "spacer", block.attrs);
|
|
189
|
-
const h =
|
|
213
|
+
const h = block.attrs.height ?? "lg"; // tên cỡ (xl) hoặc độ dài người nhập — không in chuỗi var(--…) thô
|
|
190
214
|
// Nhãn kích thước chỉ trong trình soạn (CSS ::before, không thêm phần tử con — website là div rỗng)
|
|
191
215
|
return <div {...props} data-ecx-size={tp.spacer.replace("{size}", String(h ?? ""))}>{selected && editable && <HeightHandle blockId={block.id} />}</div>;
|
|
192
216
|
}
|
|
193
217
|
|
|
194
|
-
|
|
195
|
-
|
|
218
|
+
/** Popup khi soạn: nút mở (sửa chữ ngay trên nút) + khung "Nội dung popup" luôn mở để dựng nội dung bên trong như mọi khối khác. */
|
|
219
|
+
function PopupEdit({ block, blockProps, setAttrs, editable }: BlockEditProps) {
|
|
220
|
+
const tp = useMsgs("placeholders");
|
|
221
|
+
const c = popupConfig(block.attrs);
|
|
222
|
+
const shell = c.triggerStyle === "link" || c.triggerStyle === "play" ? null : blockShell("button", { variant: c.triggerStyle });
|
|
223
|
+
const [preview, setPreview] = useState(false);
|
|
224
|
+
return (
|
|
225
|
+
<div {...(merge(blockProps, cx(popupClass(c), preview && "is-previewing"), popupVars(c) as CSSProperties) as object)}>
|
|
226
|
+
<div className="ecx-popup-trigger-row">
|
|
227
|
+
<span className={`ecx-popup-trigger ${shell ? shell.className : c.triggerStyle === "play" ? "is-play" : "is-link"}`} style={(shell?.style ?? (c.triggerStyle === "play" ? popupPlayStyle(block.attrs) : undefined)) as CSSProperties}>
|
|
228
|
+
<RichText blockId={block.id} field="triggerText" tagName="span" value={String(block.attrs.triggerText ?? "")} onChange={(v) => setAttrs({ triggerText: v })} placeholder={tp.popupTrigger} placeholderAlways editable={editable} />
|
|
229
|
+
</span>
|
|
230
|
+
<button type="button" className="ecx-popup-preview-btn" contentEditable={false} data-ecx-ui onMouseDown={(e) => e.preventDefault()} onClick={() => setPreview(true)}>{tp.popupPreview}</button>
|
|
231
|
+
</div>
|
|
232
|
+
<div className="ecx-popup-frame">
|
|
233
|
+
<span className="ecx-popup-frame-label" contentEditable={false} data-ecx-ui>{preview ? tp.popupPreviewing : tp.popupContent}</span>
|
|
234
|
+
{preview && <button type="button" className="ecx-popup-preview-close" contentEditable={false} data-ecx-ui aria-label={tp.popupPreviewClose} title={tp.popupPreviewClose} onMouseDown={(e) => e.preventDefault()} onClick={() => setPreview(false)}>×</button>}
|
|
235
|
+
<InnerBlocks parent={block} />
|
|
236
|
+
</div>
|
|
237
|
+
</div>
|
|
238
|
+
);
|
|
196
239
|
}
|
|
197
240
|
|
|
198
|
-
|
|
241
|
+
/** Lời chứng thực nhiều mục: khung soạn luôn xếp lưới (kể cả dạng slider) để thấy và sửa được mọi mục; website chạy slider khi chọn dạng đó. */
|
|
242
|
+
function TestimonialsEdit({ block, blockProps, editable }: BlockEditProps) {
|
|
199
243
|
const tp = useMsgs("placeholders");
|
|
200
|
-
const
|
|
244
|
+
const c = testimonialsConfig(block.attrs);
|
|
201
245
|
return (
|
|
202
|
-
<div {...
|
|
203
|
-
{
|
|
204
|
-
{
|
|
205
|
-
<InnerBlocks parent={block} />
|
|
246
|
+
<div {...(merge(blockProps, "ecx-testimonials", testimonialsVars(c) as CSSProperties) as object)} data-layout={c.layout}>
|
|
247
|
+
<InnerBlocks parent={block} appender="none" />
|
|
248
|
+
{editable && <AddChild block={block} label={tp.addTestimonial} make={() => makeBlock("testimonial", { quote: "", name: "", role: "", rating: 5 })} />}
|
|
206
249
|
</div>
|
|
207
250
|
);
|
|
208
251
|
}
|
|
@@ -241,6 +284,34 @@ const tabListeners = new Set<() => void>();
|
|
|
241
284
|
const setOpenTab = (id: string, i: number) => { openTabs.set(id, i); tabListeners.forEach((l) => l()); };
|
|
242
285
|
const useOpenTab = (id: string) => useSyncExternalStore((l) => { tabListeners.add(l); return () => { tabListeners.delete(l); }; }, () => openTabs.get(id) ?? 0);
|
|
243
286
|
|
|
287
|
+
/** Danh sách tab ở bảng phải (như Kadence: tiêu đề, icon, phụ đề của TỪNG tab ngay trong khối cha — không phải chọn từng tab con). Chọn hàng = mở tab đó trên khung soạn. */
|
|
288
|
+
function TabsInspector({ block }: BlockEditProps) {
|
|
289
|
+
const t = useMsgs("blocks") as Record<string, string>;
|
|
290
|
+
const h = useMsgs("hints") as Record<string, string>;
|
|
291
|
+
const { store } = useEditor();
|
|
292
|
+
const active = useOpenTab(block.id);
|
|
293
|
+
const tabs = (block.content ?? []).filter((c) => c.type === "tab");
|
|
294
|
+
const set = (id: string, a: Record<string, unknown>) => store.setAttrs([id], a);
|
|
295
|
+
return (
|
|
296
|
+
<Section title={t.tabsItems} defaultOpen>
|
|
297
|
+
{tabs.map((tab, i) => (
|
|
298
|
+
<div key={tab.id} className={cx("ecx-item-row", i === active && "is-active")} data-tab-row onFocusCapture={() => setOpenTab(block.id, i)} onMouseDown={() => setOpenTab(block.id, i)}>
|
|
299
|
+
<div className="ecx-item-row-head">
|
|
300
|
+
<span className="ecx-item-n" aria-hidden="true">{i + 1}</span>
|
|
301
|
+
<input className="ecx-input" aria-label={`${t.tabTitleField} ${i + 1}`} placeholder={t.tabTitleField} value={String(tab.attrs.title ?? "")} onChange={(e) => set(tab.id, { title: e.target.value })} />
|
|
302
|
+
</div>
|
|
303
|
+
{i === active && (
|
|
304
|
+
<div className="ecx-item-row-sub">
|
|
305
|
+
<IconPicker label={`${t.tabIconField} ${i + 1}`} value={typeof tab.attrs.icon === "string" ? tab.attrs.icon : undefined} allowNone onChange={(v) => set(tab.id, { icon: v })} />
|
|
306
|
+
<input className="ecx-input" aria-label={`${t.tabSubtitleField} ${i + 1}`} placeholder={t.tabSubtitleField} value={String(tab.attrs.subtitle ?? "")} onChange={(e) => set(tab.id, { subtitle: e.target.value || undefined })} />
|
|
307
|
+
</div>
|
|
308
|
+
)}
|
|
309
|
+
</div>
|
|
310
|
+
))}
|
|
311
|
+
</Section>
|
|
312
|
+
);
|
|
313
|
+
}
|
|
314
|
+
|
|
244
315
|
/** Tabs như website (TabsClient): thanh tiêu đề (vai trò tablist / tab) + một thẻ hiện; tiêu đề gõ ngay trên thanh, trống = "Tab N". */
|
|
245
316
|
function TabsEdit({ block, blockProps, editable }: BlockEditProps) {
|
|
246
317
|
const { store } = useEditor();
|
|
@@ -251,10 +322,9 @@ function TabsEdit({ block, blockProps, editable }: BlockEditProps) {
|
|
|
251
322
|
<div {...(merge(blockProps, tabsClass(block.attrs)) as object)}>
|
|
252
323
|
<div role="tablist" className="ecx-tabs-list" aria-orientation={block.attrs.orientation === "vertical" ? "vertical" : undefined}>
|
|
253
324
|
{tabs.map((tab, i) => {
|
|
254
|
-
const icon = ICON_PATHS[String(tab.attrs.icon ?? "")];
|
|
255
325
|
return (
|
|
256
326
|
<div key={tab.id} role="tab" aria-selected={i === active} tabIndex={-1} className={cx("ecx-tab-button", i === active && "is-active")} style={{ "--i": i } as CSSProperties} onMouseDown={() => setOpenTab(block.id, i)}>
|
|
257
|
-
{icon && <
|
|
327
|
+
{resolveIcon(tab.attrs.icon) && <IconSvg className="ecx-tab-icon" name={tab.attrs.icon} size={18} />}
|
|
258
328
|
<span className="ecx-tab-label">
|
|
259
329
|
<RichText blockId={tab.id} field="title" tagName="span" value={String(tab.attrs.title ?? "")} onChange={(v) => store.setAttrs([tab.id], { title: v })} placeholder={tp.tabTitle} placeholderAlways editable={editable} />
|
|
260
330
|
{!!tab.attrs.subtitle && <small className="ecx-tab-subtitle">{String(tab.attrs.subtitle)}</small>}
|
|
@@ -315,46 +385,117 @@ function TabEdit({ block, blockProps }: BlockEditProps) {
|
|
|
315
385
|
}
|
|
316
386
|
|
|
317
387
|
/**
|
|
318
|
-
* Carousel trên khung soạn
|
|
319
|
-
*
|
|
388
|
+
* Carousel trên khung soạn — cùng DOM / CSS với website (.ecx-carousel › .ecx-carousel-track): cuộn ngang bám mép slide, số slide thấy cùng lúc theo khổ,
|
|
389
|
+
* nút trước / sau hai bên, chấm theo vị trí. Gõ / chọn trong slide nào thì track tự cuộn tới slide đó; thêm, nhân đôi, xoá, đổi chỗ slide ở thanh công cụ (CarouselTools)
|
|
390
|
+
* và hàng dưới khối. Không còn cách "ẩn slide bằng CSS" — slide nào cũng nằm thật trong track nên chọn, kéo thả, danh sách khối đều đúng.
|
|
320
391
|
*/
|
|
321
392
|
function CarouselEdit({ block, blockProps, editable }: BlockEditProps) {
|
|
322
393
|
const { store } = useEditor();
|
|
323
394
|
const tp = useMsgs("placeholders");
|
|
395
|
+
const c = carouselConfig(block.attrs);
|
|
324
396
|
const kids = block.content ?? [];
|
|
325
|
-
const
|
|
326
|
-
const
|
|
327
|
-
const
|
|
397
|
+
const track = useRef<HTMLDivElement>(null);
|
|
398
|
+
const [pos, setPos] = useState({ index: 0, visible: c.per });
|
|
399
|
+
const count = kids.length;
|
|
400
|
+
const measure = useCallback(() => {
|
|
401
|
+
const el = track.current, first = el?.children[0] as HTMLElement | undefined;
|
|
402
|
+
if (!el || !first) return;
|
|
403
|
+
const step = ((el.children[1] as HTMLElement | undefined)?.offsetLeft ?? first.offsetLeft + first.offsetWidth) - first.offsetLeft || first.offsetWidth || 1;
|
|
404
|
+
const gap = Math.max(0, step - first.offsetWidth);
|
|
405
|
+
const visible = Math.max(1, Math.min(count, Math.round((el.clientWidth + gap) / step)));
|
|
406
|
+
setPos((p) => { const index = Math.max(0, Math.min(Math.max(0, count - visible), Math.round(el.scrollLeft / step))); return p.index === index && p.visible === visible ? p : { index, visible }; });
|
|
407
|
+
}, [count]);
|
|
408
|
+
useLayoutEffect(() => { measure(); });
|
|
409
|
+
useEffect(() => {
|
|
410
|
+
const el = track.current;
|
|
411
|
+
if (!el || typeof ResizeObserver === "undefined") return;
|
|
412
|
+
const ro = new ResizeObserver(measure);
|
|
413
|
+
ro.observe(el);
|
|
414
|
+
return () => ro.disconnect();
|
|
415
|
+
}, [measure]);
|
|
416
|
+
const goTo = useCallback((i: number, smooth = true) => {
|
|
417
|
+
const el = track.current, kid = el?.children[i] as HTMLElement | undefined;
|
|
418
|
+
if (el && kid) el.scrollTo({ left: kid.offsetLeft - (el.children[0] as HTMLElement).offsetLeft, behavior: smooth ? "smooth" : "auto" });
|
|
419
|
+
}, []);
|
|
328
420
|
const sel = useEditorState(useCallback((s) => {
|
|
329
421
|
const cur = s.selection.ids.length ? s.selection.ids : s.selection.editing ? [s.selection.editing] : [];
|
|
330
|
-
return kids.findIndex((k) => cur.some((
|
|
422
|
+
return kids.findIndex((k) => cur.some((x) => x === k.id || !!store.locate(x)?.ancestors.includes(k.id)));
|
|
331
423
|
}, [kids, store]));
|
|
332
|
-
//
|
|
424
|
+
// Chọn / gõ trong slide đang ngoài khung nhìn (từ danh sách khối, tìm kiếm, phím mũi tên) → cuộn tới slide đó
|
|
333
425
|
useEffect(() => {
|
|
334
426
|
if (sel < 0) return;
|
|
335
|
-
|
|
336
|
-
|
|
427
|
+
const el = track.current, kid = el?.children[sel] as HTMLElement | undefined;
|
|
428
|
+
if (!el || !kid) return;
|
|
429
|
+
if (kid.offsetLeft < el.scrollLeft - 2 || kid.offsetLeft + kid.offsetWidth > el.scrollLeft + el.clientWidth + 2) goTo(sel);
|
|
337
430
|
}, [sel]); // eslint-disable-line react-hooks/exhaustive-deps
|
|
338
|
-
|
|
431
|
+
// Thêm / nhân đôi slide → căn slide mới nằm trọn khung nhìn. Trình duyệt cũng tự cuộn theo con trỏ (chỉ vừa đủ thấy con trỏ, lệch mép) —
|
|
432
|
+
// nên đợi cuộn dừng hẳn rồi mới căn, để không bị bước cuộn tự động đó ghi đè.
|
|
433
|
+
const seen = useRef<string[] | null>(null);
|
|
434
|
+
const pending = useRef<number | null>(null);
|
|
435
|
+
const timer = useRef<ReturnType<typeof setTimeout> | undefined>(undefined);
|
|
436
|
+
const settle = useCallback(() => {
|
|
437
|
+
clearTimeout(timer.current);
|
|
438
|
+
timer.current = setTimeout(() => { const i = pending.current; pending.current = null; if (i != null) goTo(i, false); }, 160);
|
|
439
|
+
}, [goTo]);
|
|
440
|
+
useEffect(() => () => clearTimeout(timer.current), []);
|
|
441
|
+
useEffect(() => {
|
|
442
|
+
const ids = kids.map((k) => k.id), before = seen.current;
|
|
443
|
+
seen.current = ids;
|
|
444
|
+
if (!before || ids.length <= before.length) return;
|
|
445
|
+
const added = ids.findIndex((id) => !before.includes(id));
|
|
446
|
+
if (added >= 0) { pending.current = added; settle(); }
|
|
447
|
+
}, [kids, settle]);
|
|
448
|
+
const last = Math.max(0, count - pos.visible);
|
|
449
|
+
const cur = sel >= 0 ? sel : Math.min(pos.index, Math.max(0, count - 1));
|
|
450
|
+
const many = last > 0;
|
|
451
|
+
const prev = () => goTo(pos.index <= 0 ? (c.loop ? last : 0) : pos.index - 1);
|
|
452
|
+
const next = () => goTo(pos.index >= last ? (c.loop ? 0 : last) : pos.index + 1);
|
|
453
|
+
const chev = (d: string) => <svg viewBox="0 0 24 24" width={20} height={20} fill="none" stroke="currentColor" strokeWidth={2} strokeLinecap="round" strokeLinejoin="round" aria-hidden="true"><path d={d} /></svg>;
|
|
339
454
|
return (
|
|
340
|
-
<div {...(merge(blockProps, "ecx-carousel") as object)}>
|
|
341
|
-
{
|
|
342
|
-
<div className="ecx-carousel-track" style={{ display: "grid", gridTemplateColumns: `repeat(${per}, minmax(0, 1fr))`, gap: 16 }}>
|
|
455
|
+
<div {...(merge(blockProps, "ecx-carousel", carouselVars(c) as CSSProperties) as object)} {...carouselData({ ...c, effect: "slide" })}>
|
|
456
|
+
<div className="ecx-carousel-track" ref={track} onScroll={() => { measure(); if (pending.current != null) settle(); }}>
|
|
343
457
|
<InnerBlocks parent={block} />
|
|
344
458
|
</div>
|
|
345
|
-
{
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
<button type="button" aria-label={tp.
|
|
349
|
-
{kids.map((k, i) => <button key={k.id} type="button" aria-label={`${tp.slide} ${i + 1}`} aria-current={i >= start && i < start + per ? "true" : undefined} onClick={() => setOpenTab(block.id, Math.min(i, max))}>{i + 1}</button>)}
|
|
350
|
-
<button type="button" aria-label={tp.nextSlide} disabled={start >= max} onClick={() => setOpenTab(block.id, start + 1)}><ChevronRight className="ecx-icon" /></button>
|
|
459
|
+
<div contentEditable={false} onMouseDown={(e) => e.preventDefault()}>
|
|
460
|
+
{c.arrows && many && <>
|
|
461
|
+
<button type="button" className="ecx-carousel-arrow is-prev" aria-label={tp.prevSlide} disabled={!c.loop && pos.index <= 0} onClick={prev}>{chev("m15 18-6-6 6-6")}</button>
|
|
462
|
+
<button type="button" className="ecx-carousel-arrow is-next" aria-label={tp.nextSlide} disabled={!c.loop && pos.index >= last} onClick={next}>{chev("m9 18 6-6-6-6")}</button>
|
|
351
463
|
</>}
|
|
352
|
-
{
|
|
464
|
+
{c.dots && many && (
|
|
465
|
+
<div className="ecx-carousel-dots">
|
|
466
|
+
{Array.from({ length: last + 1 }, (_, i) => <button key={i} type="button" className="ecx-carousel-dot" aria-label={`${tp.slide} ${i + 1}`} aria-current={i === pos.index ? "true" : undefined} onClick={() => goTo(i)} />)}
|
|
467
|
+
</div>
|
|
468
|
+
)}
|
|
469
|
+
</div>
|
|
470
|
+
{/* Hàng thao tác chỉ có trên khung soạn (website không vẽ): thêm / nhân đôi / xoá slide + vị trí */}
|
|
471
|
+
<div className="ecx-carousel-nav" contentEditable={false} onMouseDown={(e) => e.preventDefault()}>
|
|
472
|
+
{editable && <AddChild block={block} label={tp.addSlide} make={() => makeBlock("group", {}, [makeBlock("heading", { level: 3 }), makeBlock("paragraph")])} />}
|
|
473
|
+
{editable && count > 0 && <button type="button" aria-label={tp.duplicateSlide} title={tp.duplicateSlide} onClick={() => store.duplicate([kids[cur].id])}><Copy className="ecx-icon" /></button>}
|
|
474
|
+
{editable && count > 1 && <button type="button" className="ecx-carousel-del" aria-label={tp.removeSlide} title={tp.removeSlide} onClick={() => store.remove([kids[cur].id])}><Trash2 className="ecx-icon" /></button>}
|
|
475
|
+
{count > 0 && <span className="ecx-carousel-count" aria-hidden="true">{tp.slide} {cur + 1} / {count}</span>}
|
|
353
476
|
</div>
|
|
354
477
|
</div>
|
|
355
478
|
);
|
|
356
479
|
}
|
|
357
480
|
|
|
481
|
+
/** Thanh công cụ khi đang trong một slide: đổi chỗ trái / phải, nhân đôi, thêm, xoá slide hiện tại. */
|
|
482
|
+
function CarouselTools({ ancestor, currentId }: { ancestor: BNode; currentId: string }) {
|
|
483
|
+
const { store } = useEditor();
|
|
484
|
+
const tp = useMsgs("placeholders");
|
|
485
|
+
const kids = ancestor.content ?? [];
|
|
486
|
+
const i = kids.findIndex((k) => k.id === currentId || !!store.locate(currentId)?.ancestors.includes(k.id));
|
|
487
|
+
if (i < 0) return null;
|
|
488
|
+
const canEdit = store.canInsertInto(ancestor.id);
|
|
489
|
+
return (
|
|
490
|
+
<>
|
|
491
|
+
<ToolButton label={tp.moveSlideLeft} disabled={!canEdit || i <= 0} onClick={() => store.moveBy([kids[i].id], -1)}><ChevronLeft className="ecx-icon" /></ToolButton>
|
|
492
|
+
<ToolButton label={tp.moveSlideRight} disabled={!canEdit || i >= kids.length - 1} onClick={() => store.moveBy([kids[i].id], 1)}><ChevronRight className="ecx-icon" /></ToolButton>
|
|
493
|
+
<ToolButton label={tp.duplicateSlide} disabled={!canEdit} onClick={() => store.duplicate([kids[i].id])}><Copy className="ecx-icon" /></ToolButton>
|
|
494
|
+
<ToolButton label={tp.removeSlide} disabled={!canEdit || kids.length <= 1} onClick={() => store.remove([kids[i].id])}><Trash2 className="ecx-icon" /></ToolButton>
|
|
495
|
+
</>
|
|
496
|
+
);
|
|
497
|
+
}
|
|
498
|
+
|
|
358
499
|
/** Shortcode: ô nhập tên luôn hiện ngay trên khối. */
|
|
359
500
|
function ShortcodeEdit({ block, blockProps, setAttrs, editable }: BlockEditProps) {
|
|
360
501
|
const tp = useMsgs("placeholders");
|
|
@@ -375,22 +516,39 @@ const pad2 = (n: number) => String(n).padStart(2, "0");
|
|
|
375
516
|
/** ISO / chuỗi ngày → giá trị ô datetime-local (giờ máy). */
|
|
376
517
|
const toLocalInput = (v: unknown) => { const d = new Date(String(v ?? "")); return Number.isFinite(d.getTime()) ? `${d.getFullYear()}-${pad2(d.getMonth() + 1)}-${pad2(d.getDate())}T${pad2(d.getHours())}:${pad2(d.getMinutes())}` : ""; };
|
|
377
518
|
|
|
378
|
-
|
|
379
|
-
|
|
519
|
+
/** Ngày giờ kết thúc + múi giờ (dùng ở dải dưới đồng hồ và ở bảng phải — cùng một chỗ chỉnh, cùng logic đổi múi giờ giữ nguyên thời điểm). */
|
|
520
|
+
function CountdownTimeFields({ attrs: a, setAttrs }: { attrs: Record<string, any>; setAttrs(v: Record<string, unknown>): void }) {
|
|
380
521
|
const tp = useMsgs("placeholders");
|
|
381
|
-
const valid = Number.isFinite(countdownTarget(a));
|
|
382
522
|
const tz = typeof a.timezone === "string" && a.timezone ? a.timezone : "";
|
|
383
|
-
const
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
523
|
+
const evergreen = a.mode === "evergreen";
|
|
524
|
+
const mode = (
|
|
525
|
+
<div className="ecx-ph-row" role="radiogroup" aria-label={tp.countdownMode}>
|
|
526
|
+
{([["date", tp.countdownModeDate], ["evergreen", tp.countdownModeEvergreen]] as const).map(([v, label]) => (
|
|
527
|
+
<button key={v} type="button" role="radio" aria-checked={(a.mode ?? "date") === v} className={cx("ecx-btn", (a.mode ?? "date") === v && "is-active")} onClick={() => setAttrs({ mode: v === "date" ? undefined : v, ...(v === "evergreen" && !a.evergreenHours && !a.evergreenMinutes ? { evergreenHours: 24 } : {}) })}>{label}</button>
|
|
528
|
+
))}
|
|
529
|
+
</div>
|
|
530
|
+
);
|
|
531
|
+
if (evergreen) return (
|
|
532
|
+
<>
|
|
533
|
+
{mode}
|
|
534
|
+
<div className="ecx-ph-row">
|
|
535
|
+
<label className="ecx-ph-inline-field"><span className="ecx-ph-label">{tp.countdownHours}</span>
|
|
536
|
+
<input className="ecx-input" type="number" min={0} max={2160} value={Number(a.evergreenHours ?? 0)} onChange={(e) => setAttrs({ evergreenHours: Math.max(0, Math.min(2160, Math.round(Number(e.target.value) || 0))) || undefined })} /></label>
|
|
537
|
+
<label className="ecx-ph-inline-field"><span className="ecx-ph-label">{tp.countdownMinutes}</span>
|
|
538
|
+
<input className="ecx-input" type="number" min={0} max={59} value={Number(a.evergreenMinutes ?? 0)} onChange={(e) => setAttrs({ evergreenMinutes: Math.max(0, Math.min(59, Math.round(Number(e.target.value) || 0))) || undefined })} /></label>
|
|
539
|
+
</div>
|
|
540
|
+
<p className="ecx-placeholder-hint">{tp.countdownEvergreenHint}</p>
|
|
541
|
+
</>
|
|
542
|
+
);
|
|
543
|
+
return (
|
|
544
|
+
<>
|
|
545
|
+
{mode}
|
|
546
|
+
<label className="ecx-ph-row">
|
|
389
547
|
<span className="ecx-ph-label">{tp.countdownTarget}</span>
|
|
390
548
|
<input className="ecx-input" type="datetime-local" value={tz ? String(a.target ?? "").slice(0, 16) : toLocalInput(a.target)}
|
|
391
549
|
onChange={(e) => setAttrs({ target: e.target.value ? (tz ? e.target.value : new Date(e.target.value).toISOString()) : undefined })} />
|
|
392
|
-
</label>
|
|
393
|
-
|
|
550
|
+
</label>
|
|
551
|
+
<label className="ecx-ph-row">
|
|
394
552
|
<span className="ecx-ph-label">{tp.countdownZone}</span>
|
|
395
553
|
<select className="ecx-input" aria-label={tp.countdownZone} value={tz} onChange={(e) => {
|
|
396
554
|
const next = e.target.value, ms = countdownTarget(a);
|
|
@@ -400,8 +558,44 @@ function CountdownEdit({ block, blockProps, setAttrs, editable, labels }: BlockE
|
|
|
400
558
|
<option value="">{tp.countdownZoneLocal}</option>
|
|
401
559
|
{COUNTDOWN_ZONES.map((z) => <option key={z} value={z}>{z}</option>)}
|
|
402
560
|
</select>
|
|
403
|
-
</label>
|
|
404
|
-
|
|
561
|
+
</label>
|
|
562
|
+
</>
|
|
563
|
+
);
|
|
564
|
+
}
|
|
565
|
+
|
|
566
|
+
/** Bảng phải của Đếm ngược: chọn ngày giờ bằng lịch + múi giờ (trước đây ô "Mở ở" là ô chữ gõ tay). */
|
|
567
|
+
function CountdownInspector({ attrs, setAttrs }: BlockEditProps) {
|
|
568
|
+
const t = useMsgs("blocks") as Record<string, string>;
|
|
569
|
+
return (
|
|
570
|
+
<Section title={t.countdownWhen} defaultOpen>
|
|
571
|
+
<div className="ecx-countdown-fields"><CountdownTimeFields attrs={attrs} setAttrs={setAttrs} /></div>
|
|
572
|
+
</Section>
|
|
573
|
+
);
|
|
574
|
+
}
|
|
575
|
+
|
|
576
|
+
function CountdownEdit({ block, blockProps, setAttrs, editable, labels }: BlockEditProps) {
|
|
577
|
+
const a = block.attrs;
|
|
578
|
+
const tp = useMsgs("placeholders");
|
|
579
|
+
const valid = countdownRules(a).evergreenMs ? true : Number.isFinite(countdownTarget(a));
|
|
580
|
+
const active = useActiveWithin(block.id);
|
|
581
|
+
// Ngày giờ + múi giờ: một dải gọn ngay dưới đồng hồ (đồng hồ vẫn chạy thật để thấy kết quả khi chỉnh)
|
|
582
|
+
const strip = editable && (
|
|
583
|
+
<div className="ecx-countdown-setup" contentEditable={false} onMouseDown={(e) => e.stopPropagation()}>
|
|
584
|
+
<CountdownTimeFields attrs={a} setAttrs={setAttrs} />
|
|
585
|
+
</div>
|
|
586
|
+
);
|
|
587
|
+
// Thiếu / sai thời điểm: website không vẽ khối → nói rõ, không để khối "mất tích" im lặng
|
|
588
|
+
if (!valid) return (
|
|
589
|
+
<div {...(merge(blockProps, "ecx-countdown ecx-media-placeholder", {}) as object)} data-ecx-placeholder="countdown">
|
|
590
|
+
<span className="ecx-ph-digits" aria-hidden>00 : 00 : 00 : 00</span>
|
|
591
|
+
{strip}
|
|
592
|
+
<p className="ecx-placeholder-hint">{labels.countdownNoTarget}</p>
|
|
593
|
+
</div>
|
|
594
|
+
);
|
|
595
|
+
if (editable && active) return (
|
|
596
|
+
<div {...(merge(blockProps, "ecx-countdown-edit") as object)}>
|
|
597
|
+
<CountdownPreview block={block} blockProps={{} as BlockEditProps["blockProps"]} />
|
|
598
|
+
{strip}
|
|
405
599
|
</div>
|
|
406
600
|
);
|
|
407
601
|
return <CountdownPreview block={block} blockProps={blockProps} />;
|
|
@@ -413,32 +607,25 @@ function CountdownPreview({ block, blockProps }: Pick<BlockEditProps, "block" |
|
|
|
413
607
|
const tp = useMsgs("placeholders");
|
|
414
608
|
const [now, setNow] = useState(() => Date.now());
|
|
415
609
|
useEffect(() => { const id = setInterval(() => setNow(Date.now()), 1000); return () => clearInterval(id); }, []);
|
|
416
|
-
|
|
417
|
-
const
|
|
418
|
-
|
|
610
|
+
// Evergreen: trên khung soạn luôn đếm từ đầu thời lượng khi mở trang (website thì theo từng người xem); lặp lại: dời mốc như website
|
|
611
|
+
const rules = countdownRules(a);
|
|
612
|
+
const [openedAt] = useState(() => Date.now());
|
|
613
|
+
const target = rules.evergreenMs ? openedAt + rules.evergreenMs : nextTarget(countdownTarget(a), rules.repeat, now);
|
|
614
|
+
const left = Math.max(0, target - now);
|
|
615
|
+
const cls = cx("ecx-countdown", a.layout === "inline" && "is-inline", a.divider === true && "has-divider", rules.pause && "has-pause");
|
|
616
|
+
// Trên khung soạn "ẩn" và "chuyển trang" không thật sự chạy (khối vẫn phải thấy để sửa) — chỉ chữ thay thế mới hiện
|
|
617
|
+
if (left === 0 && rules.action === "message" && a.expiredText) return <div {...(merge(blockProps, "ecx-countdown is-expired") as object)}>{String(a.expiredText)}</div>;
|
|
419
618
|
return (
|
|
420
619
|
<div {...(merge(blockProps, cls) as object)} role="timer">
|
|
421
620
|
{a.label ? <p className="ecx-countdown-label">{String(a.label)}</p> : null}
|
|
422
621
|
<div className="ecx-countdown-parts">{countdownParts(a, left, { d: tp.cdDays, h: tp.cdHours, m: tp.cdMinutes, s: tp.cdSeconds }).map((p) => <span key={p.u} className={`ecx-countdown-${p.u}`}><strong>{p.value}</strong><small>{p.label}</small></span>)}</div>
|
|
423
622
|
{a.postText ? <p className="ecx-countdown-post">{String(a.postText)}</p> : null}
|
|
623
|
+
{rules.pause && <button type="button" className="ecx-countdown-pause" contentEditable={false} aria-label="⏸" onMouseDown={(e) => e.preventDefault()}>⏸</button>}
|
|
424
624
|
</div>
|
|
425
625
|
);
|
|
426
626
|
}
|
|
427
627
|
|
|
428
628
|
/** Sao xám → bấm vào sao để chấm ngay trên khối. */
|
|
429
|
-
function RatingEdit({ block, blockProps, setAttrs, editable }: BlockEditProps) {
|
|
430
|
-
const tp = useMsgs("placeholders");
|
|
431
|
-
const max = Math.min(10, Math.max(1, Number(block.attrs.max) || 5)), v = Number(block.attrs.value) || 0;
|
|
432
|
-
return (
|
|
433
|
-
<div {...(merge(blockProps, "ecx-rating") as object)} aria-label={`${v}/${max}`} title={editable ? tp.rateHint : undefined} data-ecx-placeholder={editable && !v ? "rating" : undefined}>
|
|
434
|
-
{Array.from({ length: max }, (_, i) => editable
|
|
435
|
-
? <button key={i} type="button" className="ecx-ph-star" contentEditable={false} aria-label={tp.rateStar.replace("{n}", String(i + 1))} aria-pressed={i < Math.round(v)} onMouseDown={(e) => e.stopPropagation()} onClick={() => setAttrs({ value: i + 1 })} style={{ color: i < Math.round(v) ? "#f59e0b" : "#d4d4d8" }}>★</button>
|
|
436
|
-
: <span key={i} style={{ color: i < Math.round(v) ? "#f59e0b" : "#d4d4d8" }}>★</span>)}
|
|
437
|
-
{editable && !v && <span className="ecx-placeholder-hint" contentEditable={false}>{tp.rateHint}</span>}
|
|
438
|
-
</div>
|
|
439
|
-
);
|
|
440
|
-
}
|
|
441
|
-
|
|
442
629
|
function CoverEdit({ block, blockProps, setAttrs, labels }: BlockEditProps) {
|
|
443
630
|
const a = block.attrs;
|
|
444
631
|
const src = typeof a.src === "string" ? a.src : "";
|
|
@@ -463,24 +650,14 @@ function CoverEdit({ block, blockProps, setAttrs, labels }: BlockEditProps) {
|
|
|
463
650
|
const { overlay, fixed, imgStyle, overlayStyle } = coverParts(a);
|
|
464
651
|
return (
|
|
465
652
|
<div {...shellProps(blockProps, "cover", a)}>
|
|
466
|
-
{
|
|
653
|
+
{coverVideo(a) && <video className="ecx-cover-video" src={coverVideo(a)!} poster={src || undefined} autoPlay muted loop playsInline preload="metadata" aria-hidden="true" tabIndex={-1} style={imgStyle as CSSProperties} />}
|
|
654
|
+
{src && !fixed && !coverVideo(a) && <img className="ecx-cover-img" src={src} alt={String(a.alt ?? "")} draggable={false} style={imgStyle as CSSProperties} />}
|
|
467
655
|
{overlay && <span className="ecx-cover-overlay" aria-hidden="true" style={overlayStyle as CSSProperties} />}
|
|
468
656
|
<div className="ecx-cover-inner"><InnerBlocks parent={block} /></div>
|
|
469
657
|
</div>
|
|
470
658
|
);
|
|
471
659
|
}
|
|
472
660
|
|
|
473
|
-
function MediaTextEdit({ block, blockProps }: BlockEditProps) {
|
|
474
|
-
// Ô ảnh rỗng = vùng thả lớn (cùng kiểu ô thả với khối Ảnh)
|
|
475
|
-
const a = block.attrs;
|
|
476
|
-
return (
|
|
477
|
-
<div {...shellProps(blockProps, "mediaText", a)}>
|
|
478
|
-
<figure className="ecx-media-text-media" style={{ margin: 0 }}>{typeof a.src === "string" && a.src ? <img src={a.src} alt={String(a.alt ?? "")} draggable={false} /> : <MediaPick blockId={block.id} />}</figure>
|
|
479
|
-
<div className="ecx-media-text-content"><InnerBlocks parent={block} /></div>
|
|
480
|
-
</div>
|
|
481
|
-
);
|
|
482
|
-
}
|
|
483
|
-
|
|
484
661
|
/** Chỗ chọn ảnh trong khối (ảnh + chữ, hộp ảnh, lời chứng thực…): vùng thả + Tải lên / Thư viện / URL. */
|
|
485
662
|
export function MediaPick({ blockId, compact }: { blockId: string; compact?: boolean }) {
|
|
486
663
|
const { store } = useEditor();
|
|
@@ -513,8 +690,8 @@ function TableEdit(props: BlockEditProps) {
|
|
|
513
690
|
const { block, blockProps } = props;
|
|
514
691
|
if (!block.content?.length && props.editable) return <TableSetup {...props} />;
|
|
515
692
|
return (
|
|
516
|
-
<div {...merge(blockProps,
|
|
517
|
-
<table className={block.attrs.fixed ? "is-fixed" : undefined}
|
|
693
|
+
<div {...merge(blockProps, tableClass(block.attrs))}>
|
|
694
|
+
<table className={block.attrs.fixed ? "is-fixed" : undefined}>{typeof block.attrs.caption === "string" && block.attrs.caption.trim() && <caption>{block.attrs.caption}</caption>}<tbody><InnerBlocks parent={block} appender="none" /></tbody></table>
|
|
518
695
|
</div>
|
|
519
696
|
);
|
|
520
697
|
}
|
|
@@ -532,32 +709,42 @@ const col = (width?: number) => makeBlock("column", width ? { width } : {}, []);
|
|
|
532
709
|
const columns = (...widths: number[]) => makeBlock("columns", {}, widths.map((w) => col(w)));
|
|
533
710
|
const cell = (header = false) => makeBlock(header ? "tableHeader" : "tableCell", {}, [makeBlock("paragraph")]);
|
|
534
711
|
|
|
535
|
-
export function layoutBlocks(): BlockType[] {
|
|
712
|
+
export function layoutBlocks(lang?: string): BlockType[] {
|
|
713
|
+
const m = messages("blocks", lang) as Record<string, string>;
|
|
714
|
+
const p = (t = "") => makeBlock("paragraph", {}, t);
|
|
715
|
+
/** Hạn mặc định của đếm ngược: 3 ngày sau, 23:59 (giờ máy người soạn). */
|
|
716
|
+
const soon = () => { const d = new Date(Date.now() + 3 * 864e5); d.setHours(23, 59, 0, 0); const z = (n: number) => String(n).padStart(2, "0"); return `${d.getFullYear()}-${z(d.getMonth() + 1)}-${z(d.getDate())}T${z(d.getHours())}:${z(d.getMinutes())}`; };
|
|
536
717
|
return [
|
|
537
718
|
{
|
|
538
719
|
name: "group", title: "Nhóm", icon: Square, category: "design", keywords: "nhom group khung section container", kind: "container", edit: GroupEdit,
|
|
539
|
-
attributes: { background: { type: "string", control: "color" }, textColor: { type: "string", control: "color" }, padding: { type: "string", enum: ["none", "small", "medium", "large"], default: "medium" }, constrained: { type: "boolean", default: false, control: "hidden" }, contentWidth: { type: "string", control: "hidden" }
|
|
720
|
+
attributes: { background: { type: "string", control: "color" }, textColor: { type: "string", control: "color" }, padding: { type: "string", enum: ["none", "small", "medium", "large"], default: "medium" }, constrained: { type: "boolean", default: false, control: "hidden" }, contentWidth: { type: "string", control: "hidden" },
|
|
721
|
+
href: { type: "url" }, linkTarget: { type: "string", enum: ["_self", "_blank"] }, linkLabel: { type: "string" }, collapseHeight: { type: "string" }, collapseFade: { type: "boolean", default: true }, collapseOnce: { type: "boolean", default: false }, moreText: { type: "string" }, lessText: { type: "string" } },
|
|
540
722
|
create: (attrs) => makeBlock("group", attrs ?? {}, [makeBlock("paragraph")]),
|
|
541
723
|
toolbar: GroupLayoutTools,
|
|
542
724
|
variations: [
|
|
543
|
-
{ name: "row", title: "Hàng ngang", standalone: true, icon: RowIcon, keywords: "hang ngang row flex xep ngang", create: () => groupWith(layoutFor("row"), 2) },
|
|
544
|
-
{ name: "stack", title: "Xếp dọc", standalone: true, icon: Rows3, keywords: "xep doc stack flex cot", create: () => groupWith(layoutFor("stack"), 2) },
|
|
545
|
-
{ name: "grid", title: "Lưới", standalone: true, icon: LayoutGrid, keywords: "luoi grid o cot", create: () => groupWith(layoutFor("grid"), 3) },
|
|
725
|
+
{ name: "row", title: "Hàng ngang", standalone: true, legacy: true, icon: RowIcon, keywords: "hang ngang row flex xep ngang", create: () => groupWith(layoutFor("row"), 2) },
|
|
726
|
+
{ name: "stack", title: "Xếp dọc", standalone: true, legacy: true, icon: Rows3, keywords: "xep doc stack flex cot", create: () => groupWith(layoutFor("stack"), 2) },
|
|
727
|
+
{ name: "grid", title: "Lưới", standalone: true, legacy: true, icon: LayoutGrid, keywords: "luoi grid o cot", create: () => groupWith(layoutFor("grid"), 3) },
|
|
728
|
+
// Phần (Section): dải rộng hết trang, nội dung nằm trong khung, đệm lớn — cái người dùng thường tìm đầu tiên khi dựng trang
|
|
729
|
+
{ name: "section", title: "Section", standalone: true, icon: SECTION_ICONS.plain, keywords: "phan section dai rong full width hero khoi lon trang", create: () => sectionWith(m, {}) },
|
|
730
|
+
{ name: "section-light", title: "Phần nền sáng", standalone: true, legacy: true, icon: SECTION_ICONS.light, keywords: "phan section nen sang xam nhat xen ke", create: () => sectionWith(m, { style: { color: { background: "muted/10" } } }) },
|
|
731
|
+
{ name: "section-brand", title: "Phần nền màu thương hiệu", standalone: true, legacy: true, icon: SECTION_ICONS.brand, keywords: "phan section nen mau thuong hieu primary noi bat", create: () => sectionWith(m, { background: "primary", textColor: "#ffffff" }) },
|
|
732
|
+
{ name: "section-dark", title: "Phần nền tối", standalone: true, legacy: true, icon: SECTION_ICONS.dark, keywords: "phan section nen toi dark den", create: () => sectionWith(m, { background: "#111827", textColor: "#ffffff" }) },
|
|
546
733
|
],
|
|
547
734
|
supports: { style: true, anchor: true, className: true, blockStyle: true },
|
|
548
735
|
transforms: [{ to: "columns", convert: (b) => [makeBlock("columns", {}, b.flatMap((g) => g.content ?? []).map((c) => makeBlock("column", {}, [c])))] }],
|
|
549
736
|
},
|
|
550
737
|
{
|
|
551
|
-
name: "columns", title: "
|
|
738
|
+
name: "columns", title: "Row Layout", icon: Columns2, category: "design", keywords: "hang bo cuc row layout cot columns chia cot luoi", kind: "container", edit: ColumnsEdit,
|
|
552
739
|
// Cài đặt vẽ ở ColumnsInspector (số cột, bố cục theo khổ, khe, căn dọc) — ô tự sinh ẩn
|
|
553
740
|
attributes: { verticalAlign: { type: "string", enum: ["top", "center", "bottom", "stretch"], control: "hidden" }, stack: { type: "boolean", default: true, control: "hidden" } },
|
|
554
741
|
create: () => columns(), contextToolbar: ColumnsTools, inspector: ColumnsInspector,
|
|
555
742
|
variations: [
|
|
556
|
-
{ name: "50-50", title: "50 / 50", icon: Columns2, create: () => columns(0, 0) },
|
|
557
|
-
{ name: "33-33-33", title: "33 / 33 / 33", icon: Columns3, create: () => columns(0, 0, 0) },
|
|
558
|
-
{ name: "33-66", title: "33 / 66", icon: LayoutPanelLeft, create: () => columns(33, 67) },
|
|
559
|
-
{ name: "66-33", title: "66 / 33", icon: LayoutPanelLeft, create: () => columns(67, 33) },
|
|
560
|
-
{ name: "25x4", title: "25 / 25 / 25 / 25", icon: Columns4, create: () => columns(0, 0, 0, 0) },
|
|
743
|
+
{ name: "50-50", title: "50 / 50", legacy: true, icon: Columns2, create: () => columns(0, 0) },
|
|
744
|
+
{ name: "33-33-33", title: "33 / 33 / 33", legacy: true, icon: Columns3, create: () => columns(0, 0, 0) },
|
|
745
|
+
{ name: "33-66", title: "33 / 66", legacy: true, icon: LayoutPanelLeft, create: () => columns(33, 67) },
|
|
746
|
+
{ name: "66-33", title: "66 / 33", legacy: true, icon: LayoutPanelLeft, create: () => columns(67, 33) },
|
|
747
|
+
{ name: "25x4", title: "25 / 25 / 25 / 25", legacy: true, icon: Columns4, create: () => columns(0, 0, 0, 0) },
|
|
561
748
|
],
|
|
562
749
|
supports: { style: true, anchor: true, className: true },
|
|
563
750
|
},
|
|
@@ -565,78 +752,98 @@ export function layoutBlocks(): BlockType[] {
|
|
|
565
752
|
{
|
|
566
753
|
name: "buttons", title: "Nút", icon: MousePointerClick, category: "design", keywords: "nut button cta lien ket", kind: "container", edit: ButtonsEdit,
|
|
567
754
|
attributes: { align: { type: "string", enum: ["left", "center", "right", "space-between"] }, orientation: { type: "string", enum: ["horizontal", "vertical"], default: "horizontal" } },
|
|
568
|
-
create: () => makeBlock("buttons", {}, [makeBlock("button", { variant: "primary" })]), contextToolbar: ButtonsTools,
|
|
755
|
+
create: () => makeBlock("buttons", {}, [makeBlock("button", { variant: "primary", text: m.sampleButton })]), contextToolbar: ButtonsTools,
|
|
569
756
|
supports: { style: true, anchor: true, className: true },
|
|
570
757
|
},
|
|
571
758
|
{
|
|
572
759
|
name: "button", title: "Nút", icon: MousePointerClick, kind: "atom", edit: ButtonEdit, hidden: true,
|
|
573
|
-
attributes: { text: { type: "string" }, href: { type: "url" }, target: { type: "string", enum: ["_self", "_blank"] }, rel: { type: "string" }, variant: { type: "string", enum: ["primary", "secondary", "outline"], default: "primary" },
|
|
760
|
+
attributes: { text: { type: "string" }, href: { type: "url" }, target: { type: "string", enum: ["_self", "_blank"] }, rel: { type: "string" }, tooltip: { type: "string" }, variant: { type: "string", enum: ["primary", "secondary", "outline"], default: "primary" },
|
|
574
761
|
icon: { type: "string" }, iconPosition: { type: "string", enum: ["left", "right"] }, width: { type: "string", enum: ["auto", "full"] }, ariaLabel: { type: "string" },
|
|
575
762
|
iconOnly: { type: "boolean", default: false }, iconReveal: { type: "boolean", default: false } },
|
|
576
|
-
create: (attrs) => makeBlock("button", { variant: "primary", ...attrs }), toolbar:
|
|
763
|
+
create: (attrs) => makeBlock("button", { variant: "primary", ...attrs }), toolbar: ButtonTools,
|
|
577
764
|
supports: { style: true, className: true }, summary: (a) => a.text,
|
|
578
765
|
},
|
|
579
766
|
{
|
|
580
|
-
name: "spacer", title: "Khoảng
|
|
581
|
-
attributes: { height: { type: "string", default: "lg" } },
|
|
767
|
+
name: "spacer", title: "Khoảng cách / Đường kẻ", icon: ChevronsUpDown, category: "design", keywords: "khoang trong spacer cach duong ke divider hr separator ngan cach", kind: "atom", edit: SpacerEdit,
|
|
768
|
+
attributes: { height: { type: "string", default: "lg" }, line: { type: "boolean", default: false }, lineStyle: { type: "string", enum: ["solid", "dashed", "dotted", "double"], default: "solid" }, lineWeight: { type: "integer", min: 1, max: 12, default: 1 },
|
|
769
|
+
lineWidth: { type: "integer", min: 5, max: 100, default: 100 }, lineAlign: { type: "string", enum: ["left", "center", "right"], default: "center" }, lineColor: { type: "string", control: "color" } }, summary: (a) => a.height,
|
|
770
|
+
},
|
|
771
|
+
{
|
|
772
|
+
name: "popup", title: "Popup", icon: PanelTop, category: "design", keywords: "popup hop thoai modal cua so noi bat nut mo dialog lightbox", kind: "container", edit: PopupEdit,
|
|
773
|
+
attributes: { ...CORE_NODES.popup.attrs, align: { type: "string", enum: ["wide", "full"], control: "hidden" }, triggerText: { type: "string", control: "hidden" }, label: { type: "string" } },
|
|
774
|
+
create: () => makeBlock("popup", { triggerText: m.samplePopupButton }, [makeBlock("heading", { level: 3 }, m.samplePopupTitle), p(m.samplePopupText)]),
|
|
775
|
+
supports: { style: true, anchor: true, className: true },
|
|
582
776
|
},
|
|
583
|
-
{ name: "horizontalRule", title: "Đường kẻ", icon: Minus, category: "design", keywords: "duong ke divider hr separator", kind: "atom", edit: SeparatorEdit, supports: { style: true, className: true, blockStyle: true } },
|
|
584
777
|
{
|
|
585
|
-
name: "
|
|
586
|
-
attributes: {
|
|
587
|
-
create: () => makeBlock("
|
|
778
|
+
name: "testimonials", title: "Đánh giá khách hàng", icon: Square, category: "design", keywords: "loi chung thuc danh gia khach hang review testimonial luoi slider nhieu", kind: "container", edit: TestimonialsEdit,
|
|
779
|
+
attributes: { ...CORE_NODES.testimonials.attrs, align: { type: "string", enum: ["wide", "full"], control: "hidden" }, columnsTablet: { ...CORE_NODES.testimonials.attrs!.columnsTablet, default: 2 }, columnsMobile: { ...CORE_NODES.testimonials.attrs!.columnsMobile, default: 1 } },
|
|
780
|
+
create: () => makeBlock("testimonials", { columns: 3 }, [[m.sampleQuote, m.sampleName, m.sampleRole], [m.sampleQuote2, m.sampleName2, m.sampleRole2], [m.sampleQuote3, m.sampleName3, m.sampleRole3]].map(([quote, name, role]) => makeBlock("testimonial", { quote, name, role, rating: 5 }))),
|
|
781
|
+
variations: [{ name: "slider", title: "Đánh giá khách hàng (Slider)", standalone: true, icon: Square, keywords: "loi chung thuc slider carousel truot",
|
|
782
|
+
create: () => makeBlock("testimonials", { layout: "carousel", columns: 1, autoplay: true }, [[m.sampleQuote, m.sampleName, m.sampleRole], [m.sampleQuote2, m.sampleName2, m.sampleRole2], [m.sampleQuote3, m.sampleName3, m.sampleRole3]].map(([quote, name, role]) => makeBlock("testimonial", { quote, name, role, rating: 5 }))) }],
|
|
783
|
+
supports: { style: true, anchor: true, className: true },
|
|
588
784
|
},
|
|
589
785
|
{
|
|
590
786
|
name: "details", title: "Chi tiết", icon: PanelTop, category: "text", keywords: "chi tiet details accordion faq hoi dap an hien", kind: "container", edit: DetailsEdit,
|
|
591
787
|
attributes: { summary: { type: "string" }, open: { type: "boolean", default: false } },
|
|
592
|
-
create: () => makeBlock("details", {}, [
|
|
788
|
+
create: () => makeBlock("details", { summary: m.sampleDetails }, [p(m.sampleDetailsBody)]), supports: { style: true, anchor: true, className: true },
|
|
593
789
|
},
|
|
594
790
|
{
|
|
595
791
|
name: "accordion", title: "Accordion", icon: PanelTop, category: "text", keywords: "accordion faq hoi dap nhieu muc", kind: "container", edit: AccordionEdit,
|
|
596
792
|
attributes: { multiple: { type: "boolean", default: false }, columns: { type: "number", enum: [1, 2], default: 1 }, icon: { type: "string", enum: ["arrow", "plus", "none"], default: "arrow" }, iconSide: { type: "string", enum: ["left", "right"], default: "right" }, titleTag: { type: "string", enum: ["div", "h2", "h3", "h4", "h5", "h6"], default: "div" }, startOpen: { type: "string", enum: ["none", "first", "all"], default: "none" }, faq: { type: "boolean", default: false } },
|
|
597
|
-
create: () => makeBlock("accordion", {}, [makeBlock("details", { summary:
|
|
793
|
+
layouts: accordionLayouts(m), create: () => makeBlock("accordion", {}, [makeBlock("details", { summary: m.sampleFaq1 }, [p(m.sampleFaqBody)]), makeBlock("details", { summary: m.sampleFaq2 }, [p(m.sampleFaqBody)])]), supports: { style: true, anchor: true, className: true },
|
|
598
794
|
},
|
|
599
795
|
{
|
|
600
796
|
name: "tabs", title: "Tabs", icon: PanelTop, category: "text", keywords: "tabs the tab chuyen doi noi dung", kind: "container", edit: TabsEdit,
|
|
601
797
|
attributes: { tabsAlign: { type: "string", enum: ["flex-start", "center", "flex-end", "space-between"] }, initial: { type: "number", min: 1 }, orientation: { type: "string", enum: ["horizontal", "vertical"], default: "horizontal" }, mobileAccordion: { type: "boolean", default: false }, iconPosition: { type: "string", enum: ["left", "right", "top"], default: "left" }, iconOnly: { type: "boolean", default: false } },
|
|
602
|
-
create: () => makeBlock("tabs", {}, [makeBlock("tab", { title:
|
|
798
|
+
layouts: tabsLayouts(m), layoutOwns: ["orientation"], inspector: TabsInspector, create: () => makeBlock("tabs", {}, [makeBlock("tab", { title: m.sampleTab1 }, [p(m.sampleTabBody)]), makeBlock("tab", { title: m.sampleTab2 }, [p(m.sampleTabBody)])]), contextToolbar: TabsTools, supports: { style: true, anchor: true, className: true },
|
|
603
799
|
},
|
|
604
800
|
{
|
|
605
801
|
name: "tab", title: "Tab", icon: PanelTop, category: "text", keywords: "tab", kind: "container", edit: TabEdit, hidden: true, structure: { parents: ["tabs"] },
|
|
606
|
-
attributes: { title: { type: "string" }, icon: { type: "string"
|
|
802
|
+
attributes: { title: { type: "string" }, icon: { type: "string" }, subtitle: { type: "string" } }, supports: { anchor: true }, create: () => makeBlock("tab", { title: "" }, [makeBlock("paragraph")]),
|
|
607
803
|
},
|
|
608
804
|
{
|
|
609
|
-
name: "carousel", title: "
|
|
610
|
-
attributes: {
|
|
611
|
-
|
|
805
|
+
name: "carousel", title: "Slider", icon: Columns3, category: "design", keywords: "slider carousel slide truot anh trinh chieu banner hero", kind: "container", edit: CarouselEdit,
|
|
806
|
+
attributes: {
|
|
807
|
+
slidesPerView: { type: "integer", default: 1, min: 1, max: 4 }, slidesTablet: { type: "integer", min: 1, max: 4 }, slidesMobile: { type: "integer", min: 1, max: 4 },
|
|
808
|
+
arrows: { type: "boolean", default: true }, dots: { type: "boolean", default: true }, autoplay: { type: "boolean", default: false },
|
|
809
|
+
interval: { type: "integer", default: 5, min: 2, max: 30 }, loop: { type: "boolean", default: true }, gap: { type: "string" },
|
|
810
|
+
effect: { type: "string", enum: ["slide", "fade"], default: "slide" }, speed: { type: "integer", default: 400, min: 150, max: 1500 },
|
|
811
|
+
heightMode: { type: "string", enum: ["auto", "ratio", "min"], default: "auto" }, ratio: { type: "string", enum: ["16/9", "4/3", "3/2", "1/1", "21/9", "3/1"], default: "16/9" }, minHeight: { type: "string" },
|
|
812
|
+
arrowStyle: { type: "string", enum: ["circle", "square", "plain", "light"], default: "circle" }, dotStyle: { type: "string", enum: ["dot", "line", "light"], default: "dot" },
|
|
813
|
+
arrowPos: { type: "string", enum: ["center", "bottom"], default: "center" }, hoverPause: { type: "boolean", default: true } },
|
|
814
|
+
layouts: carouselLayouts(m), contextToolbar: CarouselTools,
|
|
815
|
+
// Slider ảnh bìa (hero): mờ dần, tự chạy, nút + chấm trắng; mỗi slide là Nhóm có nền màu thương hiệu — đổi sang ảnh ở Kiểu dáng › Nền
|
|
816
|
+
variations: [{ name: "hero", title: "Hero Slider", standalone: true, icon: Columns3, keywords: "slider hero banner anh bia trinh chieu mo dan",
|
|
817
|
+
create: () => makeBlock("carousel", { slidesPerView: 1, effect: "fade", heightMode: "min", minHeight: "26rem", autoplay: true, interval: 6, arrowStyle: "light", dotStyle: "light" },
|
|
818
|
+
[m.sampleSlide1, m.sampleSlide2, m.sampleSlide3].map((title, i) => makeBlock("group", { background: ["primary", "#111827", "accent"][i], textColor: "#ffffff", padding: "large" }, [makeBlock("heading", { level: 2, textAlign: "center" }, title), makeBlock("paragraph", { textAlign: "center" }, m.sampleHeroText)]))) }], create: () => makeBlock("carousel", { slidesPerView: 1 }, [m.sampleSlide1, m.sampleSlide2, m.sampleSlide3].map((title) => makeBlock("group", {}, [makeBlock("heading", { level: 3 }, title), p(m.sampleSlideText)]))), supports: { style: true, anchor: true, className: true },
|
|
612
819
|
},
|
|
613
820
|
{
|
|
614
821
|
name: "shortcode", title: "Shortcode", icon: Square, category: "design", keywords: "shortcode ma nhung plugin", kind: "atom", edit: ShortcodeEdit,
|
|
615
822
|
attributes: { name: { type: "string" }, args: { type: "json", default: {} } }, supports: { style: true, anchor: true, className: true },
|
|
616
823
|
},
|
|
617
824
|
{
|
|
618
|
-
name: "countdown", title: "Đếm ngược", icon: Square, category: "design", keywords: "dem nguoc countdown khuyen mai sale", kind: "atom", edit: CountdownEdit,
|
|
619
|
-
attributes: { target: { type: "string" }, timezone: { type: "string", enum: [...COUNTDOWN_ZONES], control: "hidden" }, label: { type: "string" }, postText: { type: "string" }, expiredText: { type: "string" }, layout: { type: "string", enum: ["block", "inline"], default: "block" }, divider: { type: "boolean", default: false }, pad: { type: "boolean", default: true }, showDays: { type: "boolean", default: true }, showSeconds: { type: "boolean", default: true }, daysLabel: { type: "string" }, hoursLabel: { type: "string" }, minutesLabel: { type: "string" }, secondsLabel: { type: "string" }
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
attributes: { value: { type: "number", default: 5, min: 0, max: 10 }, max: { type: "integer", default: 5, min: 1, max: 10 }, label: { type: "string" } }, supports: { style: true, anchor: true, className: true },
|
|
825
|
+
name: "countdown", title: "Đếm ngược", icon: Square, category: "design", inspector: CountdownInspector, keywords: "dem nguoc countdown khuyen mai sale", kind: "atom", edit: CountdownEdit, create: () => makeBlock("countdown", { target: soon(), label: m.sampleCountdownLabel, layout: "block", pad: true, showDays: true, showSeconds: true }),
|
|
826
|
+
attributes: { target: { type: "string", control: "hidden" }, timezone: { type: "string", enum: [...COUNTDOWN_ZONES], control: "hidden" }, label: { type: "string" }, postText: { type: "string" }, expiredText: { type: "string" }, layout: { type: "string", enum: ["block", "inline"], default: "block" }, divider: { type: "boolean", default: false }, pad: { type: "boolean", default: true }, showDays: { type: "boolean", default: true }, showSeconds: { type: "boolean", default: true }, daysLabel: { type: "string" }, hoursLabel: { type: "string" }, minutesLabel: { type: "string" }, secondsLabel: { type: "string" },
|
|
827
|
+
expireAction: { type: "string", enum: ["zero", "message", "hide", "redirect"] }, redirectUrl: { type: "url" }, repeat: { type: "string", enum: ["none", "daily", "weekly", "monthly", "yearly"], default: "none" },
|
|
828
|
+
mode: { type: "string", enum: ["date", "evergreen"], default: "date", control: "hidden" }, evergreenHours: { type: "integer", min: 0, max: 2160, control: "hidden" }, evergreenMinutes: { type: "integer", min: 0, max: 59, control: "hidden" },
|
|
829
|
+
evergreenReset: { type: "integer", min: 0, max: 365, default: 30 }, pauseButton: { type: "boolean", default: false } }, supports: { style: true, anchor: true, className: true },
|
|
624
830
|
},
|
|
625
831
|
{
|
|
626
832
|
name: "cover", title: "Ảnh bìa", icon: ImageIcon, category: "media", keywords: "anh bia cover banner hero", kind: "container", edit: CoverEdit,
|
|
627
|
-
attributes: { src: { type: "url", control: "media" }, alt: { type: "string" }, overlay: { type: "string", control: "color" }, opacity: { type: "integer", default: 50, min: 0, max: 100 }, minHeight: { type: "string", default: "400px" }, contentAlign: { type: "string", enum: ["top", "center", "bottom"], default: "center" }, fixed: { type: "boolean", default: false }, constrained: { type: "boolean", default: false } },
|
|
833
|
+
attributes: { src: { type: "url", control: "media" }, alt: { type: "string" }, overlay: { type: "string", control: "color" }, opacity: { type: "integer", default: 50, min: 0, max: 100 }, minHeight: { type: "string", default: "400px" }, contentAlign: { type: "string", enum: ["top", "center", "bottom"], default: "center" }, fixed: { type: "boolean", default: false }, constrained: { type: "boolean", default: false }, videoSrc: { type: "url" } },
|
|
628
834
|
create: () => makeBlock("cover", { opacity: 50, minHeight: "400px" }, [makeBlock("heading", { level: 2, textAlign: "center" })]),
|
|
629
835
|
supports: { style: true, anchor: true, className: true },
|
|
630
836
|
},
|
|
631
|
-
{
|
|
632
|
-
name: "mediaText", title: "Ảnh + chữ", icon: LayoutPanelLeft, category: "media", keywords: "anh chu media text", kind: "container", edit: MediaTextEdit,
|
|
633
|
-
attributes: { src: { type: "url", control: "media" }, alt: { type: "string" }, position: { type: "string", enum: ["left", "right"], default: "left" }, width: { type: "integer", default: 50, min: 20, max: 80 }, verticalAlign: { type: "string", enum: ["top", "center", "bottom"], default: "center" }, stack: { type: "boolean", default: true } },
|
|
634
|
-
create: () => makeBlock("mediaText", {}, [makeBlock("heading", { level: 3 }), makeBlock("paragraph")]), supports: { style: true, anchor: true, className: true },
|
|
635
|
-
},
|
|
636
837
|
{
|
|
637
838
|
name: "table", title: "Bảng", icon: Table2, category: "text", keywords: "bang table", kind: "container", edit: TableEdit,
|
|
638
|
-
attributes: {
|
|
639
|
-
|
|
839
|
+
attributes: {
|
|
840
|
+
footer: { type: "boolean", default: false }, fixed: { type: "boolean", default: false },
|
|
841
|
+
striped: { type: "boolean", default: false }, hoverRows: { type: "boolean", default: false },
|
|
842
|
+
lines: { type: "string", enum: ["all", "rows", "columns", "none"], default: "all" },
|
|
843
|
+
density: { type: "string", enum: ["compact", "normal", "roomy"], default: "normal" },
|
|
844
|
+
stickyHead: { type: "boolean", default: false }, caption: { type: "string" },
|
|
845
|
+
},
|
|
846
|
+
create: () => makeBlock("table", {}, [[m.sampleTh1, m.sampleTh2, m.sampleTh3], [m.sampleTd1, m.sampleTd2, m.sampleTd3], [m.sampleTd4, m.sampleTd5, m.sampleTd6]].map((row, r) => makeBlock("tableRow", {}, row.map((t) => makeBlock(r === 0 ? "tableHeader" : "tableCell", {}, [p(t)]))))), contextToolbar: TableTools,
|
|
640
847
|
supports: { style: true, anchor: true, className: true, blockStyle: true },
|
|
641
848
|
},
|
|
642
849
|
{ name: "tableRow", title: "Hàng", icon: Table2, kind: "container", edit: RowEdit, hidden: true },
|