@ecomcx/ecomweb-editor 1.32.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.
Files changed (91) hide show
  1. package/package.json +3 -3
  2. package/src/locales/en/attrs.ts +2 -1
  3. package/src/locales/en/background.ts +5 -0
  4. package/src/locales/en/bindings.ts +5 -1
  5. package/src/locales/en/block-desc.ts +5 -11
  6. package/src/locales/en/block-style.ts +17 -6
  7. package/src/locales/en/block-titles.ts +38 -15
  8. package/src/locales/en/blocks.ts +37 -6
  9. package/src/locales/en/columns.ts +1 -0
  10. package/src/locales/en/controls.ts +1 -1
  11. package/src/locales/en/hints.ts +315 -12
  12. package/src/locales/en/index.ts +3 -1
  13. package/src/locales/en/layout.ts +13 -0
  14. package/src/locales/en/motion.ts +16 -0
  15. package/src/locales/en/palette.ts +8 -0
  16. package/src/locales/en/parts.ts +2 -1
  17. package/src/locales/en/pattern-overrides.ts +14 -0
  18. package/src/locales/en/placeholders.ts +9 -3
  19. package/src/locales/en/v2.ts +2 -0
  20. package/src/locales/vi/attrs.ts +3 -2
  21. package/src/locales/vi/background.ts +5 -0
  22. package/src/locales/vi/bindings.ts +5 -1
  23. package/src/locales/vi/block-desc.ts +8 -14
  24. package/src/locales/vi/block-style.ts +18 -7
  25. package/src/locales/vi/block-titles.ts +48 -25
  26. package/src/locales/vi/blocks.ts +37 -6
  27. package/src/locales/vi/columns.ts +1 -0
  28. package/src/locales/vi/controls.ts +1 -1
  29. package/src/locales/vi/hints.ts +315 -12
  30. package/src/locales/vi/index.ts +3 -1
  31. package/src/locales/vi/layout.ts +13 -0
  32. package/src/locales/vi/motion.ts +16 -0
  33. package/src/locales/vi/palette.ts +8 -0
  34. package/src/locales/vi/parts.ts +2 -1
  35. package/src/locales/vi/pattern-overrides.ts +14 -0
  36. package/src/locales/vi/placeholders.ts +10 -4
  37. package/src/locales/vi/v2.ts +2 -0
  38. package/src/v2/blocks/columns-inspector.tsx +11 -2
  39. package/src/v2/blocks/index.ts +9 -6
  40. package/src/v2/blocks/layout-options.tsx +80 -0
  41. package/src/v2/blocks/layout.tsx +349 -106
  42. package/src/v2/blocks/media.tsx +51 -21
  43. package/src/v2/blocks/resize.tsx +50 -19
  44. package/src/v2/blocks/social-icons.ts +22 -0
  45. package/src/v2/blocks/text.tsx +12 -50
  46. package/src/v2/blocks/theme.tsx +62 -29
  47. package/src/v2/blocks/tools.tsx +24 -2
  48. package/src/v2/blocks/widgets.tsx +84 -28
  49. package/src/v2/canvas/block-list.tsx +36 -5
  50. package/src/v2/canvas/canvas-css.ts +95 -7
  51. package/src/v2/canvas/canvas.tsx +65 -9
  52. package/src/v2/canvas/dnd.ts +7 -0
  53. package/src/v2/canvas/variation-picker.tsx +63 -0
  54. package/src/v2/context.tsx +48 -0
  55. package/src/v2/core/bindings.ts +6 -1
  56. package/src/v2/core/block-presets.ts +10 -0
  57. package/src/v2/core/clipboard.ts +5 -5
  58. package/src/v2/core/host.ts +3 -1
  59. package/src/v2/core/model.ts +6 -6
  60. package/src/v2/core/registry.ts +15 -0
  61. package/src/v2/core/store.ts +9 -9
  62. package/src/v2/core/structure.ts +1 -3
  63. package/src/v2/editor.css +74 -0
  64. package/src/v2/editor.tsx +22 -7
  65. package/src/v2/text/rich-text.tsx +20 -5
  66. package/src/v2/ui/ai-markdown.ts +52 -0
  67. package/src/v2/ui/ai.tsx +81 -14
  68. package/src/v2/ui/attr-form.tsx +45 -7
  69. package/src/v2/ui/attr-hints.ts +151 -19
  70. package/src/v2/ui/background-panel.tsx +22 -0
  71. package/src/v2/ui/bg-video-preview.tsx +7 -0
  72. package/src/v2/ui/bindings.tsx +9 -1
  73. package/src/v2/ui/block-icons.tsx +3 -10
  74. package/src/v2/ui/block-live-preview.tsx +21 -0
  75. package/src/v2/ui/block-style-panel.tsx +3 -1
  76. package/src/v2/ui/command-palette.tsx +125 -0
  77. package/src/v2/ui/icon-picker.tsx +88 -21
  78. package/src/v2/ui/icon-svg.tsx +21 -0
  79. package/src/v2/ui/inserter.tsx +72 -17
  80. package/src/v2/ui/inspector.tsx +12 -6
  81. package/src/v2/ui/layout-panel.tsx +1 -1
  82. package/src/v2/ui/motion-panel.tsx +22 -13
  83. package/src/v2/ui/option-thumbs.tsx +81 -0
  84. package/src/v2/ui/pattern-library.tsx +2 -1
  85. package/src/v2/ui/pattern-overrides.tsx +67 -0
  86. package/src/v2/ui/placeholders.tsx +21 -2
  87. package/src/v2/ui/preset-bar.tsx +5 -5
  88. package/src/v2/ui/style-supports.ts +2 -3
  89. package/src/v2/ui/style-tab.tsx +83 -20
  90. package/src/v2/ui/toolbar.tsx +40 -6
  91. package/src/v2/ui/transform-panel.tsx +77 -0
@@ -1,5 +1,5 @@
1
1
  import type { BlockAttrSpec } from "@ecomcx/ecomweb-content";
2
- import { AlignCenter, AlignHorizontalSpaceBetween, AlignJustify, AlignLeft, AlignRight, RotateCcw } from "lucide-react";
2
+ import { AlignCenter, AlignHorizontalSpaceBetween, AlignJustify, AlignLeft, AlignRight, AlignVerticalJustifyCenter, AlignVerticalJustifyEnd, AlignVerticalJustifyStart, MoveHorizontal, MoveVertical, RotateCcw } from "lucide-react";
3
3
  import { useEffect, useState, type ComponentType, type ReactNode } from "react";
4
4
  import { useEditor } from "../context";
5
5
  import type { Choice, ChoiceKind } from "../core/host";
@@ -9,6 +9,7 @@ import { blockOptions } from "../../shared/block-defs";
9
9
  import { DEFAULT_IMAGE_SIZES, hintOf, hintText, imageSizeLabel, optionLabel, type AttrHint } from "./attr-hints";
10
10
  import { ColorInput } from "./color-field";
11
11
  import { IconPicker } from "./icon-picker";
12
+ import { PickTiles, frameThumb, iconHoverThumb } from "./option-thumbs";
12
13
  import { mediaSrcsets } from "../core/media";
13
14
 
14
15
  export const cx = (...c: unknown[]) => c.filter((x): x is string => typeof x === "string" && x !== "").join(" ");
@@ -40,7 +41,7 @@ export function Field({ label, children, group }: { label: string; children: Rea
40
41
  }
41
42
 
42
43
  /** Lựa chọn lấy từ ứng dụng (host.choices); null = ứng dụng không cung cấp → ô gõ tay. */
43
- function useChoices(kind: ChoiceKind | undefined, args: Record<string, string> | undefined): Choice[] | null | undefined {
44
+ export function useChoices(kind: ChoiceKind | undefined, args: Record<string, string> | undefined): Choice[] | null | undefined {
44
45
  const { host, labels } = useEditor();
45
46
  const key = JSON.stringify([kind, args]);
46
47
  const [state, setState] = useState<{ key: string; list: Choice[] | null } | null>(null);
@@ -58,13 +59,25 @@ function useChoices(kind: ChoiceKind | undefined, args: Record<string, string> |
58
59
 
59
60
  /** Giá trị căn → biểu tượng (như thanh căn chữ của WP): hàng chọn căn chỉ toàn các giá trị này thì vẽ bằng biểu tượng, chữ nằm ở tooltip / nhãn đọc màn hình. */
60
61
  const ALIGN_ICONS: Record<string, ComponentType<{ className?: string }>> = { left: AlignLeft, center: AlignCenter, right: AlignRight, justify: AlignJustify, "space-between": AlignHorizontalSpaceBetween };
61
- function SegText({ value, options, onChange, label }: { value: string | undefined; options: Array<[string, string]>; onChange(v: string | undefined): void; label: string }) {
62
+ /** Căn dọc (trên / giữa / dưới): giá trị giữa vẽ biểu tượng dọc, không dùng biểu tượng căn ngang. */
63
+ const VALIGN_ICONS: Record<string, ComponentType<{ className?: string }>> = { top: AlignVerticalJustifyStart, start: AlignVerticalJustifyStart, center: AlignVerticalJustifyCenter, middle: AlignVerticalJustifyCenter, bottom: AlignVerticalJustifyEnd, end: AlignVerticalJustifyEnd };
64
+ const ORIENT_ICONS: Record<string, ComponentType<{ className?: string }>> = { horizontal: MoveHorizontal, vertical: MoveVertical };
65
+ /** Bộ biểu tượng cho một hàng lựa chọn: căn ngang / căn dọc (từ 3 lựa chọn) hoặc ngang – dọc (đúng hai lựa chọn); không khớp thì null (nút chữ). */
66
+ function iconSetFor(options: Array<[string, string]>): Record<string, ComponentType<{ className?: string }>> | null {
67
+ const vs = options.map(([v]) => v);
68
+ if (vs.length === 2 && vs.every((v) => ORIENT_ICONS[v])) return ORIENT_ICONS;
62
69
  // Từ 3 lựa chọn trở lên: hai lựa chọn trái / phải thường là vị trí (icon trước / sau chữ), không phải căn
63
- const icons = options.length > 2 && options.every(([v]) => ALIGN_ICONS[v]);
70
+ if (vs.length > 2 && vs.some((v) => v === "top" || v === "bottom") && vs.every((v) => VALIGN_ICONS[v])) return VALIGN_ICONS;
71
+ if (vs.length > 2 && vs.every((v) => ALIGN_ICONS[v])) return ALIGN_ICONS;
72
+ return null;
73
+ }
74
+ function SegText({ value, options, onChange, label }: { value: string | undefined; options: Array<[string, string]>; onChange(v: string | undefined): void; label: string }) {
75
+ const set = iconSetFor(options);
76
+ const icons = !!set;
64
77
  return (
65
78
  <div role="radiogroup" aria-label={label} className={cx("ecx-seg", !icons && "is-text")}>
66
79
  {options.map(([v, text]) => {
67
- const Icon = icons ? ALIGN_ICONS[v] : undefined;
80
+ const Icon = set ? set[v] : undefined;
68
81
  return <button key={v} type="button" role="radio" aria-checked={value === v} aria-label={Icon ? text : undefined} title={Icon ? text : undefined} className={cx("ecx-seg-btn", value === v && "is-active")} onClick={() => onChange(value === v ? undefined : v)}>{Icon ? <Icon className="ecx-icon" /> : text}</button>;
69
82
  })}
70
83
  </div>
@@ -86,7 +99,26 @@ function ChoiceField({ hint, attrs, value, set, label }: { hint: AttrHint; attrs
86
99
  );
87
100
  }
88
101
 
102
+ /** Chọn nhiều mục (danh sách tích): giá trị lưu là các mã cách nhau dấu phẩy. */
103
+ function MultiChoiceField({ hint, attrs, value, set, label }: { hint: AttrHint; attrs: Record<string, unknown>; value: unknown; set(v: unknown): void; label: string }) {
104
+ const { labels } = useEditor();
105
+ const list = useChoices(hint.choice?.kind, hint.choice?.args?.(attrs));
106
+ const picked = new Set(String(value ?? "").split(",").map((x) => x.trim()).filter(Boolean));
107
+ if (list === null) return <input className="ecx-input" aria-label={label} value={String(value ?? "")} onChange={(e) => set(e.target.value || undefined)} />;
108
+ if (list === undefined) return <span className="ecx-muted">{labels.choiceLoading}</span>;
109
+ const toggle = (v: string) => { const next = new Set(picked); if (next.has(v)) next.delete(v); else next.add(v); set(next.size ? [...next].join(",") : undefined); };
110
+ return (
111
+ <div className="ecx-multichoice" role="group" aria-label={label}>
112
+ {list.map((c) => <label key={c.value} className="ecx-check"><input type="checkbox" checked={picked.has(c.value)} onChange={() => toggle(c.value)} /> {c.label}</label>)}
113
+ {!list.length && <span className="ecx-muted">{labels.choiceSelect}</span>}
114
+ </div>
115
+ );
116
+ }
117
+
89
118
  /** Form thuộc tính tự sinh từ mô tả khối + gợi ý hiển thị (attr-hints): không phải viết giao diện cho từng khối. */
119
+ /** Ô segmented có hình minh hoạ: `<khối>.<thuộc tính>` → hàm vẽ hình theo giá trị. */
120
+ const ATTR_THUMBS: Record<string, (v: string) => ReactNode> = { "iconBox.iconStyle": frameThumb, "icon.iconStyle": frameThumb, "iconList.iconStyle": frameThumb, "iconBox.hover": iconHoverThumb };
121
+
90
122
  export function AttrForm({ type, attrs, onChange }: { type: BlockType; attrs: Record<string, any>; onChange(a: Record<string, unknown>): void }) {
91
123
  const { host, labels } = useEditor();
92
124
  const lang = labels.lang;
@@ -94,7 +126,7 @@ export function AttrForm({ type, attrs, onChange }: { type: BlockType; attrs: Re
94
126
  const translate = blockOptions(type.name).translate ?? host.translate;
95
127
  const entries = Object.entries(type.attributes ?? {})
96
128
  .map(([k, s]) => [k, s, hintOf(type.name, k)] as const)
97
- .filter(([k, s, h]) => !HIDDEN_ATTRS.has(k) && controlOf(s) !== "hidden" && h.control !== "hidden" && (!h.when || h.when(attrs)));
129
+ .filter(([k, s, h]) => !type.layoutOwns?.includes(k) && !HIDDEN_ATTRS.has(k) && controlOf(s) !== "hidden" && h.control !== "hidden" && (!h.when || h.when(attrs)));
98
130
  if (!entries.length) return null;
99
131
  const resetLabel = String(messages("controls", lang).reset ?? "Reset");
100
132
  return (
@@ -131,8 +163,12 @@ export function AttrForm({ type, attrs, onChange }: { type: BlockType; attrs: Re
131
163
  return <div key={k}><label className="ecx-check"><input type="checkbox" checked={!!value} onChange={(e) => set(e.target.checked)} /> {label}</label>{help}</div>;
132
164
  case "newTab":
133
165
  return <label key={k} className="ecx-check"><input type="checkbox" checked={value === "_blank"} onChange={(e) => set(e.target.checked ? "_blank" : undefined)} /> {labels.openInNewTab}</label>;
134
- case "segmented":
166
+ case "segmented": {
167
+ // Ô có hình minh hoạ (khung icon, hiệu ứng rê chuột…): thẻ hình hai lớp thay cho dãy nút chữ
168
+ const thumbs = ATTR_THUMBS[`${type.name}.${k}`];
169
+ if (thumbs) return <Field key={k} label={label} group><PickTiles label={label} value={value == null ? undefined : String(value)} options={opts().map(([v, text]) => ({ id: v, label: text, thumb: thumbs(v) }))} onChange={(v) => set(v === undefined ? undefined : parse(v))} />{help}</Field>;
135
170
  return <Field key={k} label={label} group><SegText label={label} value={value == null ? undefined : String(value)} options={opts()} onChange={(v) => set(v === undefined ? undefined : parse(v))} />{help}</Field>;
171
+ }
136
172
  case "select": {
137
173
  // Ít lựa chọn, chữ ngắn → dãy nút bấm (một chạm, thấy hết lựa chọn) như bảng của các bộ khối lớn; cấp tiêu đề → H1…H6
138
174
  const list = k === "level" ? opts().map(([v]) => [v, `H${v}`] as [string, string]) : opts();
@@ -150,6 +186,8 @@ export function AttrForm({ type, attrs, onChange }: { type: BlockType; attrs: Re
150
186
  }
151
187
  case "icon":
152
188
  return <Field key={k} label={label}><IconPicker label={label} value={value == null ? undefined : String(value)} allowNone={hint.allowNone} onChange={(v) => set(v)} />{help}</Field>;
189
+ case "multichoice":
190
+ return <Field key={k} label={label}><MultiChoiceField hint={hint} attrs={attrs} value={value} set={set} label={label} />{help}</Field>;
153
191
  case "choice":
154
192
  return <Field key={k} label={label}><ChoiceField hint={hint} attrs={attrs} value={value} set={set} label={label} />{help}</Field>;
155
193
  case "range": {
@@ -1,4 +1,3 @@
1
- import { ICON_NAMES } from "@ecomcx/ecomweb-content";
2
1
  import { format, messages } from "../../i18n";
3
2
  import type { ChoiceKind } from "../core/host";
4
3
 
@@ -14,7 +13,7 @@ export interface AttrHint {
14
13
  label?: true;
15
14
  /** Khoá của hint (do hintOf điền) — dùng tra chữ. */
16
15
  key?: string;
17
- control?: "select" | "segmented" | "range" | "choice" | "newTab" | "suggest" | "code" | "hidden" | "icon";
16
+ control?: "select" | "segmented" | "range" | "choice" | "multichoice" | "newTab" | "suggest" | "code" | "hidden" | "icon";
18
17
  /** control "icon": có lựa chọn "Không có icon". */
19
18
  allowNone?: true;
20
19
  options?: Opt[];
@@ -55,6 +54,12 @@ export const ATTR_HINTS: Record<string, AttrHint> = {
55
54
  "buttons.orientation": { control: "segmented", label: true, options: ["horizontal", "vertical"] },
56
55
  "button.iconOnly": { label: true, when: (a) => !!a.icon },
57
56
  "button.iconReveal": { label: true, when: (a) => !!a.icon && a.iconOnly !== true },
57
+ "table.striped": { label: true },
58
+ "table.hoverRows": { label: true },
59
+ "table.lines": { control: "segmented", label: true, options: ["all", "rows", "columns", "none"] },
60
+ "table.density": { control: "segmented", label: true, options: ["compact", "normal", "roomy"] },
61
+ "table.stickyHead": { label: true },
62
+ "table.caption": { label: true },
58
63
  "countdown.layout": { control: "segmented", label: true, options: ["block", "inline"] },
59
64
  "countdown.divider": { label: true },
60
65
  "countdown.pad": { label: true },
@@ -70,10 +75,25 @@ export const ATTR_HINTS: Record<string, AttrHint> = {
70
75
  "map.zoom": { control: "range", label: true, min: 1, max: 20, step: 1 },
71
76
  "map.height": { control: "range", label: true, min: 150, max: 1000, step: 10, unit: "px" },
72
77
  "map.mapType": { control: "segmented", label: true, options: ["roadmap", "satellite"] },
78
+ "carousel.effect": { control: "segmented", label: true, options: ["slide", "fade"] },
79
+ "carousel.speed": { control: "range", label: true, min: 150, max: 1500, step: 50, unit: "ms" },
80
+ "carousel.heightMode": { control: "segmented", label: true, options: ["auto", "ratio", "min"] },
81
+ "carousel.ratio": { control: "segmented", label: true, options: ["16/9", "4/3", "3/2", "1/1", "21/9", "3/1"], when: (a) => a.heightMode === "ratio" },
82
+ "carousel.minHeight": { label: true, help: true, when: (a) => a.heightMode === "min" },
83
+ "carousel.arrowStyle": { control: "segmented", label: true, options: ["circle", "square", "plain", "light"], when: (a) => a.arrows !== false },
84
+ "carousel.arrowPos": { control: "segmented", label: true, options: ["center", "bottom"], when: (a) => a.arrows !== false },
85
+ "carousel.dotStyle": { control: "segmented", label: true, options: ["dot", "line", "light"], when: (a) => a.dots !== false },
86
+ "carousel.hoverPause": { label: true, when: (a) => a.autoplay === true },
87
+ "carousel.slidesPerView": { when: (a) => a.effect !== "fade" },
88
+ "carousel.slidesTablet": { when: (a) => a.effect !== "fade" },
89
+ "carousel.slidesMobile": { when: (a) => a.effect !== "fade" },
90
+ "carousel.interval": { when: (a) => a.autoplay === true },
91
+ "carousel.loop": { when: (a) => a.autoplay === true || a.arrows !== false },
73
92
  "progressBar.max": { label: true },
74
93
  "progressBar.prefix": { label: true, when: (a) => a.showValue !== false },
75
94
  "progressBar.suffix": { label: true, help: true, when: (a) => a.showValue !== false },
76
- "progressBar.textPosition": { control: "segmented", label: true, options: ["above", "inside", "below"] },
95
+ "progressBar.shape": { control: "segmented", label: true, options: ["bar", "circle", "half"] },
96
+ "progressBar.textPosition": { control: "segmented", label: true, options: ["above", "inside", "below"], when: (a) => !a.shape || a.shape === "bar" },
77
97
  "progressBar.duration": { label: true, help: true, when: (a) => a.animate !== false },
78
98
  "progressBar.decimals": { control: "segmented", label: true, options: ["0", "1", "2"], when: (a) => a.showValue !== false },
79
99
  "progressBar.animate": { label: true },
@@ -108,10 +128,14 @@ export const ATTR_HINTS: Record<string, AttrHint> = {
108
128
  "paragraph.icon": { control: "icon", allowNone: true, label: true },
109
129
  "paragraph.iconPosition": { control: "segmented", label: true, options: ["left", "right"], when: (a) => !!a.icon },
110
130
  "paragraph.iconTitle": { label: true, help: true, when: (a) => !!a.icon },
131
+ "heading.htmlTag": { control: "select", label: true, help: true, options: ["", "p", "span", "div"] },
111
132
  "heading.icon": { control: "icon", allowNone: true, label: true },
112
133
  "heading.iconPosition": { control: "segmented", label: true, options: ["left", "right"], when: (a) => !!a.icon },
113
134
  "heading.iconTitle": { label: true, help: true, when: (a) => !!a.icon },
114
135
  "heading.tocTitle": { label: true, help: true },
136
+ "heading.href": { label: true, help: true, placeholder: true },
137
+ "heading.linkTarget": { control: "newTab", when: (a) => !!a.href },
138
+ "heading.linkRel": { control: "select", label: true, options: ["", "nofollow", "sponsored", "nofollow sponsored"], when: (a) => !!a.href },
115
139
  "button.iconPosition": { control: "segmented", options: ["left", "right"], when: (a) => !!a.icon },
116
140
  "button.text": { placeholder: true },
117
141
  "button.href": { placeholder: true },
@@ -135,15 +159,12 @@ export const ATTR_HINTS: Record<string, AttrHint> = {
135
159
  "file.src": { label: true },
136
160
  "video.src": { label: true },
137
161
  "audio.src": { label: true },
138
- "youtube.src": { label: true },
139
- "youtube.start": { label: true },
140
162
  "image.src": { label: true },
141
163
  "cover.src": { label: true, control: "hidden" }, // ảnh, lớp phủ, cố định: ô Nền (background-panel.tsx)
142
164
  "cover.overlay": { control: "hidden" },
143
165
  "cover.fixed": { control: "hidden" },
144
166
  "group.background": { control: "hidden" }, // màu nền cũ của nhóm: ô Nền (chuyển sang style.color.background khi sửa)
145
167
  "group.textColor": { when: (a) => !!a.textColor }, // màu chữ cũ: chỉ hiện khi có giá trị — màu chữ mới ở tab Kiểu dáng
146
- "pullquote.citation": { label: true },
147
168
  "audio.name": { control: "hidden" },
148
169
  "heading.level": { control: "select", options: levels(1, 6), help: true },
149
170
  "postTitle.level": { control: "select", options: levels(1, 6) },
@@ -155,17 +176,32 @@ export const ATTR_HINTS: Record<string, AttrHint> = {
155
176
  "customHtml.html": { control: "code" },
156
177
  "group.padding": { control: "segmented", options: ["none", "small", "medium", "large"] },
157
178
  "columns.verticalAlign": { control: "segmented", options: V_ALIGN },
158
- "mediaText.verticalAlign": { control: "segmented", options: V_ALIGN },
159
179
  "cover.contentAlign": { control: "segmented", options: V_ALIGN },
160
180
  "cover.opacity": { control: "hidden" },
161
- "mediaText.position": { control: "segmented", options: ["left", "right"] },
162
- "mediaText.width": { control: "range", min: 15, max: 85, step: 5, unit: "%" },
163
181
  "buttons.align": { control: "segmented", options: [...ALIGN, "space-between"] },
164
182
  "button.variant": { control: "segmented", options: ["primary", "secondary", "outline"] },
165
183
  "button.target": { control: "newTab" },
184
+ "heading.typedWords": { label: true, help: true, placeholder: true },
185
+ "heading.typedSpeed": { control: "range", label: true, min: 30, max: 200, step: 10, unit: "ms", when: (a) => !!a.typedWords },
186
+ "heading.typedPause": { control: "range", label: true, min: 600, max: 6000, step: 200, unit: "ms", when: (a) => !!a.typedWords },
187
+ "heading.typedLoop": { label: true, when: (a) => !!a.typedWords },
188
+ "group.collapseHeight": { label: true, help: true, placeholder: true },
189
+ "group.collapseFade": { label: true, when: (a) => !!a.collapseHeight },
190
+ "group.collapseOnce": { label: true, when: (a) => !!a.collapseHeight },
191
+ "group.moreText": { label: true, placeholder: true, when: (a) => !!a.collapseHeight },
192
+ "group.lessText": { label: true, placeholder: true, when: (a) => !!a.collapseHeight },
193
+ "group.href": { label: true, help: true, placeholder: true },
194
+ "group.linkTarget": { control: "newTab", when: (a) => !!a.href },
195
+ "group.linkLabel": { label: true, help: true, when: (a) => !!a.href },
196
+ "button.tooltip": { label: true, help: true },
166
197
  "button.rel": { when: (a) => !!a.href, help: true },
198
+ "spacer.line": { label: true },
199
+ "spacer.lineStyle": { control: "segmented", label: true, options: ["solid", "dashed", "dotted", "double"], when: (a) => a.line === true },
200
+ "spacer.lineWeight": { control: "range", label: true, min: 1, max: 12, step: 1, unit: "px", when: (a) => a.line === true },
201
+ "spacer.lineWidth": { control: "range", label: true, min: 5, max: 100, step: 5, unit: "%", when: (a) => a.line === true },
202
+ "spacer.lineAlign": { control: "segmented", label: true, options: ["left", "center", "right"], when: (a) => a.line === true && Number(a.lineWidth ?? 100) < 100 },
203
+ "spacer.lineColor": { label: true, when: (a) => a.line === true },
167
204
  "spacer.height": { control: "suggest", suggestions: ["xs", "sm", "md", "lg", "xl", "2xl", "2rem", "4rem", "80px"], help: true },
168
- "callout.tone": { control: "segmented", options: ["info", "success", "warning", "danger"] },
169
205
  "image.align": { control: "select", options: [...ALIGN, "wide", "full"] },
170
206
  "image.size": { control: "choice", choice: { kind: "imageSize" } },
171
207
  "featuredImage.size": { control: "choice", choice: { kind: "imageSize" } },
@@ -174,12 +210,25 @@ export const ATTR_HINTS: Record<string, AttrHint> = {
174
210
  "socialLinks.align": { control: "segmented", options: ALIGN },
175
211
  "navigation.location": { control: "choice", choice: { kind: "menuLocation" }, help: true },
176
212
  "navigation.orientation": { control: "segmented", options: ["horizontal", "vertical"] },
177
- "navigation.overlayMenu": { control: "segmented", label: true, options: ["never", "mobile", "always"] },
178
- "gallery.layout": { control: "segmented", label: true, options: ["grid", "masonry"] },
213
+ "navigation.overlayMenu": { control: "segmented", label: true, options: ["never", "mobile", "tablet", "always"] },
214
+ "cover.videoSrc": { label: true, help: true },
215
+ "image.ratio": { control: "segmented", label: true, options: ["auto", "1/1", "4/3", "3/2", "16/9", "21/9", "3/4", "2/3"] },
216
+ "gallery.layout": { control: "segmented", label: true, options: ["grid", "masonry", "mosaic", "tiles", "thumbs", "slider"] },
217
+ "gallery.captionStyle": { control: "segmented", label: true, options: ["below", "hover", "overlay"] },
218
+ "gallery.arrows": { when: (a) => a.layout === "slider" },
219
+ "gallery.dots": { when: (a) => a.layout === "slider" },
220
+ "gallery.autoplay": { when: (a) => a.layout === "slider" },
221
+ "gallery.interval": { when: (a) => a.layout === "slider" && a.autoplay === true },
222
+ "gallery.loop": { when: (a) => a.layout === "slider" },
179
223
  "gallery.linkTo": { control: "segmented", label: true, options: ["none", "media"] },
180
- "gallery.imageCrop": { label: true },
224
+ "gallery.imageCrop": { label: true, when: (a) => a.layout !== "masonry" },
181
225
  "gallery.lightbox": { label: true },
182
- "countdown.expiredText": { label: true },
226
+ "countdown.expiredText": { label: true, when: (a) => (a.expireAction ?? (a.expiredText ? "message" : "zero")) === "message" || !a.expireAction },
227
+ "countdown.expireAction": { control: "select", label: true, options: ["zero", "message", "hide", "redirect"] },
228
+ "countdown.redirectUrl": { label: true, help: true, when: (a) => a.expireAction === "redirect" },
229
+ "countdown.repeat": { control: "select", label: true, options: ["none", "daily", "weekly", "monthly", "yearly"], when: (a) => a.mode !== "evergreen" },
230
+ "countdown.evergreenReset": { control: "range", label: true, help: true, min: 0, max: 365, step: 1, unit: "ngày", when: (a) => a.mode === "evergreen" },
231
+ "countdown.pauseButton": { label: true },
183
232
  // 1.27: form cơ bản
184
233
  "form.formId": { control: "hidden" },
185
234
  "form.notifyEmail": { help: true },
@@ -190,11 +239,16 @@ export const ATTR_HINTS: Record<string, AttrHint> = {
190
239
  "formField.kind": { control: "select", options: ["text", "email", "tel", "textarea", "select", "radio", "checkbox", "consent", "number", "date"] },
191
240
  "formField.name": { label: true, help: true },
192
241
  "formField.label": { label: true, help: true },
242
+ "formField.showIf": { label: true, help: true, placeholder: true },
243
+ "formField.step": { label: true, help: true },
193
244
  "formField.width": { control: "segmented", options: ["full", "half", "third"] },
194
245
  "formField.autocomplete": { control: "select", label: true, help: true, when: (a) => !["checkbox", "consent", "radio", "select"].includes(String(a.kind ?? "text")), options: ["off", "name", "given-name", "family-name", "email", "tel", "organization", "street-address", "address-level1", "address-level2", "postal-code", "country-name", "bday"] },
195
246
  "search.showLabel": { label: true },
196
247
  "search.buttonPosition": { control: "segmented", label: true, options: ["right", "left", "below"] },
197
248
  "search.buttonStyle": { control: "segmented", label: true, options: ["text", "icon"] },
249
+ "search.collapse": { control: "segmented", label: true, help: true, options: ["never", "tablet", "mobile"] },
250
+ "search.scopeSelect": { label: true, help: true },
251
+ "search.scopes": { label: true, help: true, when: (a) => a.scopeSelect === true },
198
252
  "postAuthor.showName": { label: true },
199
253
  "postAuthor.showBio": { label: true },
200
254
  "postAuthor.avatarSize": { label: true },
@@ -209,16 +263,57 @@ export const ATTR_HINTS: Record<string, AttrHint> = {
209
263
  "loginout.logoutText": { label: true },
210
264
  "pageList.parentId": { label: true },
211
265
  "archives.showCount": { label: true },
212
- "icon.name": { control: "select", options: [...ICON_NAMES] },
266
+ "icon.name": { control: "icon", label: true },
267
+ "icon.tooltip": { label: true, placeholder: true, help: true },
213
268
  "icon.stroke": { control: "range", label: true, min: 0.5, max: 4, step: 0.5 },
214
269
  "icon.iconStyle": { control: "segmented", label: true, options: ["plain", "circle", "square"] },
215
270
  "icon.linkTarget": { control: "segmented", label: true, options: ["_self", "_blank"], when: (a) => !!a.href },
216
- "iconBox.icon": { control: "select", options: [...ICON_NAMES], when: (a) => a.media !== "number" && a.media !== "none" && a.media !== "image" },
271
+ "iconBox.icon": { control: "icon", label: true, when: (a) => a.media !== "number" && a.media !== "none" && a.media !== "image" },
217
272
  "iconBox.position": { control: "segmented", label: true, options: ["top", "left", "right"] },
218
273
  "iconBox.level": { control: "select", options: levels(2, 6) },
219
274
  "imageBox.level": { control: "select", options: levels(2, 6) },
220
275
  "imageBox.src": { label: true },
221
- "iconList.icon": { control: "select", options: [...ICON_NAMES] },
276
+ "testimonials.layout": { control: "segmented", label: true, options: ["grid", "carousel"] },
277
+ "testimonials.columns": { control: "range", label: true, min: 1, max: 4, step: 1 },
278
+ "testimonials.columnsTablet": { control: "range", label: true, min: 1, max: 4, step: 1 },
279
+ "testimonials.columnsMobile": { control: "range", label: true, min: 1, max: 2, step: 1 },
280
+ "testimonials.gap": { label: true, help: true },
281
+ "testimonials.arrows": { label: true, when: (a) => a.layout === "carousel" },
282
+ "testimonials.dots": { label: true, when: (a) => a.layout === "carousel" },
283
+ "testimonials.autoplay": { label: true, when: (a) => a.layout === "carousel" },
284
+ "testimonials.interval": { label: true, when: (a) => a.layout === "carousel" && a.autoplay === true },
285
+ "testimonials.loop": { label: true, when: (a) => a.layout === "carousel" },
286
+ "popup.triggerStyle": { control: "segmented", label: true, options: ["primary", "outline", "link", "play"] },
287
+ "popup.popupId": { label: true, help: true, placeholder: true },
288
+ "popup.autoOpen": { control: "select", label: true, help: true, options: ["none", "delay", "scroll", "exit", "idle"] },
289
+ "popup.autoDelay": { control: "range", label: true, min: 1, max: 120, step: 1, when: (a) => a.autoOpen === "delay" || a.autoOpen === "idle" },
290
+ "popup.autoScroll": { control: "range", label: true, min: 5, max: 100, step: 5, when: (a) => a.autoOpen === "scroll" },
291
+ "popup.onceDays": { control: "range", label: true, help: true, min: 0, max: 90, step: 1, when: (a) => !!a.autoOpen && a.autoOpen !== "none" },
292
+ "popup.triggerImage": { label: true, help: true, when: (a) => a.triggerStyle === "play" },
293
+ "popup.triggerAlign": { control: "segmented", label: true, options: ["left", "center", "right"] },
294
+ "popup.size": { control: "segmented", label: true, options: ["sm", "md", "lg", "xl"] },
295
+ "popup.anim": { control: "segmented", label: true, options: ["fade", "up", "zoom", "none"] },
296
+ "popup.overlayOpacity": { control: "range", label: true, min: 0, max: 100, step: 5, unit: "%" },
297
+ "popup.vAlign": { control: "segmented", label: true, options: ["top", "center"] },
298
+ "popup.closeButton": { label: true },
299
+ "popup.closeOnOverlay": { label: true },
300
+ "popup.label": { label: true, help: true },
301
+ "imageOverlay.src": { label: true },
302
+ "imageOverlay.subtitle": { label: true },
303
+ "imageOverlay.level": { control: "select", options: levels(2, 6) },
304
+ "imageOverlay.linkTarget": { control: "segmented", label: true, options: ["_self", "_blank"], when: (a) => !!a.href },
305
+ "imageOverlay.ratio": { control: "segmented", label: true, options: ["auto", "1/1", "4/3", "3/2", "16/9", "3/4", "2/3"] },
306
+ "imageOverlay.hAlign": { control: "segmented", label: true, options: ["left", "center", "right"] },
307
+ "imageOverlay.vAlign": { control: "segmented", label: true, options: ["top", "center", "bottom"] },
308
+ "imageOverlay.subtitleMode": { control: "segmented", label: true, options: ["hover", "always"], when: (a) => !!a.subtitle },
309
+ "imageOverlay.imageEffect": { control: "segmented", label: true, options: ["none", "zoom", "grayscale", "blur", "slide"] },
310
+ "imageOverlay.overlayColor": { label: true },
311
+ "imageOverlay.overlayOpacity": { control: "range", label: true, min: 0, max: 100, step: 5, unit: "%" },
312
+ "imageOverlay.restOpacity": { control: "range", label: true, help: true, min: 0, max: 100, step: 5, unit: "%" },
313
+ "imageOverlay.frame": { label: true },
314
+ "imageOverlay.frameInset": { control: "range", label: true, min: 0, max: 40, step: 2, unit: "px", when: (a) => a.frame !== false },
315
+ "imageOverlay.divider": { label: true, when: (a) => !!a.title },
316
+ "iconList.icon": { control: "icon", label: true },
222
317
  "iconList.layout": { control: "segmented", options: ["list", "inline"] },
223
318
  "iconList.columns": { control: "range", label: true, min: 1, max: 4, step: 1, when: (a) => a.layout !== "inline" },
224
319
  "iconList.iconAlign": { control: "segmented", label: true, options: ["top", "center", "bottom"] },
@@ -230,6 +325,7 @@ export const ATTR_HINTS: Record<string, AttrHint> = {
230
325
  "counter.duration": { help: true },
231
326
  "counter.decimals": { label: true, help: true },
232
327
  "counter.titleTag": { control: "select", label: true, options: ["p", "div", "h2", "h3", "h4", "h5", "h6"] },
328
+ "testimonial.mediaIcon": { control: "icon", allowNone: true, label: true, help: true },
233
329
  "testimonial.src": { label: true },
234
330
  "testimonial.variant": { control: "segmented", label: true, options: ["card", "plain", "bubble"] },
235
331
  "testimonial.rating": { control: "range", label: true, help: true, min: 0, max: 5, step: 1 },
@@ -240,6 +336,8 @@ export const ATTR_HINTS: Record<string, AttrHint> = {
240
336
  "query.postType": { control: "choice", choice: { kind: "postType" }, when: notInherit },
241
337
  "query.category": { control: "choice", choice: { kind: "term", args: () => ({ taxonomy: "category" }) }, when: notInherit },
242
338
  "query.tag": { control: "choice", choice: { kind: "term", args: () => ({ taxonomy: "post_tag" }) }, when: notInherit },
339
+ "query.taxonomy": { control: "choice", choice: { kind: "taxonomy" }, label: true, help: true, when: notInherit },
340
+ "query.term": { control: "choice", choice: { kind: "term", args: (a) => ({ taxonomy: String(a.taxonomy ?? "") }) }, label: true, when: (a) => a.inherit === false && !!a.taxonomy },
243
341
  "query.perPage": { when: notInherit },
244
342
  "query.orderBy": { control: "select", options: ["date", "modified", "title", "comment_count", "menu_order", "rand"], when: notInherit },
245
343
  "query.authorId": { label: true, when: notInherit },
@@ -252,12 +350,46 @@ export const ATTR_HINTS: Record<string, AttrHint> = {
252
350
  "orderedList.reversed": { label: true },
253
351
  "blockquote.citation": { label: true },
254
352
  "postDate.displayType": { control: "segmented", label: true, options: ["published", "modified"] },
353
+ "query.source": { control: "segmented", label: true, options: ["latest", "manual", "related"], when: notInherit },
354
+ "query.include": { label: true, help: true, placeholder: true, when: (a) => a.inherit === false && a.source === "manual" },
355
+ "query.terms": { control: "multichoice", choice: { kind: "term", args: (a) => ({ taxonomy: String(a.taxonomy ?? "") }) }, label: true, when: (a) => !!a.taxonomy },
356
+ "query.termMode": { control: "segmented", label: true, options: ["any", "all", "none"], when: (a) => !!a.taxonomy && !!String(a.terms ?? "").trim() },
357
+ "query.metaKey": { label: true, help: true, placeholder: true, when: notInherit },
358
+ "query.metaCompare": { control: "select", label: true, options: ["=", "!=", ">", ">=", "<", "<=", "LIKE", "EXISTS", "NOT EXISTS"], when: (a) => a.inherit === false && !!a.metaKey },
359
+ "query.metaValue": { label: true, when: (a) => a.inherit === false && !!a.metaKey && !["EXISTS", "NOT EXISTS"].includes(String(a.metaCompare ?? "=")) },
360
+ "query.dateRange": { control: "select", label: true, options: ["any", "7", "30", "90", "365"], when: notInherit },
361
+ "query.after": { label: true, placeholder: true, when: notInherit },
362
+ "query.before": { label: true, placeholder: true, when: notInherit },
363
+ "query.parent": { label: true, help: true, when: notInherit },
364
+ "query.offset": { label: true, help: true, when: notInherit },
365
+ "query.excludeCurrent": { label: true, help: true, when: notInherit },
366
+ "query.authorCurrent": { label: true, when: notInherit },
367
+ "query.urlFilters": { label: true, help: true },
368
+ "queryFilter.taxonomy": { control: "choice", choice: { kind: "taxonomy" }, label: true, help: true },
369
+ "queryFilter.termStyle": { control: "segmented", label: true, options: ["none", "links", "chips", "select", "checks"], when: (a) => !!a.taxonomy },
370
+ "queryFilter.showRange": { label: true },
371
+ "queryFilter.rangeParam": { label: true, help: true, placeholder: true, when: (a) => a.showRange === true },
372
+ "queryFilter.rangeLabel": { label: true, placeholder: true, when: (a) => a.showRange === true },
373
+ "queryFilter.rangeMax": { label: true, when: (a) => a.showRange === true },
374
+ "queryFilter.allLabel": { label: true, placeholder: true },
375
+ "queryFilter.showSearch": { label: true },
376
+ "queryFilter.showSort": { label: true },
377
+ "queryFilter.showYear": { label: true },
378
+ "queryFilter.showReset": { label: true },
379
+ "queryFilter.sortOptions": { label: true, help: true, placeholder: true, when: (a) => a.showSort === true },
380
+ "queryFilter.placeholder": { label: true, when: (a) => a.showSearch === true },
381
+ "queryFilter.submitText": { label: true },
382
+ "queryFilter.action": { label: true, help: true, placeholder: true },
255
383
  "query.paginate": { label: true, help: true, when: notInherit },
256
384
  "query.orderByMeta": { label: true, help: true, when: notInherit },
257
385
  "query.order": { control: "segmented", options: ["desc", "asc"], when: notInherit },
258
386
  "query.inherit": { help: true },
259
- "postTemplate.layout": { control: "segmented", options: ["list", "grid"] },
260
- "postTemplate.columns": { control: "range", min: 1, max: 6, step: 1, when: (a) => a.layout === "grid" },
387
+ "postTemplate.layout": { control: "segmented", options: ["list", "grid", "carousel"] },
388
+ "postTemplate.columns": { control: "range", min: 1, max: 6, step: 1, when: (a) => a.layout === "grid" || a.layout === "carousel" },
389
+ "postTemplate.columnsTablet": { control: "range", min: 1, max: 6, step: 1, label: true, when: (a) => a.layout === "grid" },
390
+ "postTemplate.columnsMobile": { control: "range", min: 1, max: 4, step: 1, label: true, when: (a) => a.layout === "grid" },
391
+ "postTemplate.gap": { label: true, help: true, when: (a) => a.layout === "grid" || a.layout === "carousel" },
392
+ "postTemplate.arrows": { label: true, when: (a) => a.layout === "carousel" },
261
393
  "templatePart.slug": { control: "choice", choice: { kind: "templatePart" } },
262
394
  "templatePart.tagName": { control: "select", options: ["div", "header", "footer", "aside", "section"] },
263
395
  };
@@ -163,6 +163,12 @@ export function BackgroundControl({ type, attrs, setAttrs, device }: { type: str
163
163
  {inherited && !image && <p className="ecx-muted">{t.inherited}</p>}
164
164
  </div>
165
165
  </Row>
166
+ {!cover && (
167
+ <Row label={t.video}>
168
+ <input className="ecx-input" type="url" inputMode="url" aria-label={t.video} placeholder="/uploads/video.mp4" value={bg.video ?? ""} onChange={(e) => setBg({ video: e.target.value.trim() || undefined })} />
169
+ <p className="ecx-field-help">{t.videoHint}</p>
170
+ </Row>
171
+ )}
166
172
  {hasImage && (
167
173
  <>
168
174
  {!cover && (
@@ -183,6 +189,22 @@ export function BackgroundControl({ type, attrs, setAttrs, device }: { type: str
183
189
  </Row>
184
190
  {!cover && <label className="ecx-check"><input type="checkbox" checked={!!bg.repeat} onChange={(e) => setBg({ repeat: e.target.checked || undefined })} /> {t.repeat}</label>}
185
191
  <label className="ecx-check"><input type="checkbox" checked={cover ? !!attrs.fixed : !!bg.fixed} onChange={(e) => (cover ? setAttrs({ fixed: e.target.checked || undefined }) : setBg({ fixed: e.target.checked || undefined }))} /> {t.fixed}</label>
192
+ {!cover && (
193
+ <>
194
+ <Row label={`${t.imageOpacity}: ${bg.imageOpacity ?? 100}%`}>
195
+ <input type="range" min={0} max={100} step={5} value={bg.imageOpacity ?? 100} aria-label={t.imageOpacity} onChange={(e) => setBg({ imageOpacity: Number(e.target.value) >= 100 ? undefined : Number(e.target.value) })} />
196
+ </Row>
197
+ <Row label={`${t.imageBlur}: ${bg.imageBlur ?? 0}px`}>
198
+ <input type="range" min={0} max={40} step={1} value={bg.imageBlur ?? 0} aria-label={t.imageBlur} onChange={(e) => setBg({ imageBlur: Number(e.target.value) || undefined })} />
199
+ </Row>
200
+ <Row label={t.imageBlend}>
201
+ <select className="ecx-input" aria-label={t.imageBlend} value={bg.imageBlend ?? ""} onChange={(e) => setBg({ imageBlend: e.target.value || undefined })}>
202
+ <option value="">{t.blendNormal}</option>
203
+ {BLENDS.map((x) => <option key={x} value={x}>{(t as Record<string, string>)[`blend_${x.replace(/-/g, "_")}`] ?? x}</option>)}
204
+ </select>
205
+ </Row>
206
+ </>
207
+ )}
186
208
  </>
187
209
  )}
188
210
  {cover && overlayFields}
@@ -0,0 +1,7 @@
1
+ import { blockBgVideo } from "@ecomcx/ecomweb-content";
2
+
3
+ /** Xem trước video nền (style.background.video) của Section / Row / Column ngay trong khung soạn — cùng thẻ và class với website. */
4
+ export function BgVideoPreview({ style }: { style: unknown }) {
5
+ const src = blockBgVideo(style);
6
+ return src ? <video className="ecx-bg-video" src={src} autoPlay muted loop playsInline preload="metadata" aria-hidden="true" tabIndex={-1} contentEditable={false} data-ecx-ui /> : null;
7
+ }
@@ -33,7 +33,12 @@ export function BindingsPanel({ block, bindable, onChange }: { block: BNode; bin
33
33
  const all = useSyncExternalStore(subscribeBindingSources, bindingSources, bindingSources);
34
34
  const current = bindingsOf(block) ?? {};
35
35
  const t = useMsgs("bindings");
36
- const ATTR: Record<string, string> = { content: t.attrContent, src: t.attrSrc, alt: t.attrAlt, caption: t.attrCaption, text: t.attrText, href: t.attrHref };
36
+ const ATTR: Record<string, string> = {
37
+ content: t.attrContent, src: t.attrSrc, alt: t.attrAlt, caption: t.attrCaption, text: t.attrText, href: t.attrHref,
38
+ title: t.attrTitle, subtitle: t.attrSubtitle, quote: t.attrQuote, name: t.attrName, role: t.attrRole, poster: t.attrPoster, address: t.attrAddress,
39
+ placeholder: t.attrPlaceholder, buttonText: t.attrButtonText, summary: t.attrSummary, citation: t.attrCitation, label: t.attrLabel, tooltip: t.attrTooltip,
40
+ prefix: t.attrPrefix, suffix: t.attrSuffix, target: t.attrTarget,
41
+ };
37
42
  const set = (attr: string, b: Binding | undefined) => {
38
43
  const next = { ...current };
39
44
  if (b) next[attr] = b; else delete next[attr];
@@ -66,6 +71,9 @@ export function BindingsPanel({ block, bindable, onChange }: { block: BNode; bin
66
71
  </select>
67
72
  : <input className="ecx-input" aria-label={`${ATTR[attr] ?? attr}: ${argKey}`} placeholder={argKey} value={String(b.args?.[argKey] ?? "")}
68
73
  onChange={(e) => set(attr, { ...b, args: { ...b.args, [argKey]: e.target.value.replace(/[^\w.-]/g, "").slice(0, 200) } })} />)}
74
+ {b && !["src", "href", "poster"].includes(attr) && (
75
+ <label className="ecx-check"><input type="checkbox" checked={b.args?.hideIfEmpty === true} onChange={(e) => { const { hideIfEmpty: _drop, ...rest } = b.args ?? {}; set(attr, { ...b, args: e.target.checked ? { ...rest, hideIfEmpty: true } : rest }); }} /> {t.hideIfEmpty}</label>
76
+ )}
69
77
  </div>
70
78
  );
71
79
  })}
@@ -38,25 +38,20 @@ const I = {
38
38
  heading: draw([["r", 2, 2, 20, 20, 4, 0], ["p", H]]),
39
39
  bulletList: draw([["c", 5, 6, 2], ["c", 5, 12, 2], ["c", 5, 18, 2], ["r", 9, 5, 13, 2.2, 1.1, 0], ["r", 9, 11, 13, 2.2, 1.1, 0], ["r", 9, 17, 10, 2.2, 1.1, 0]]),
40
40
  orderedList: draw([["p", "M4 4h2v5H4.5V5.5H4zM3.5 13.5c0-1 .8-1.6 1.7-1.6s1.6.6 1.6 1.4c0 .9-.7 1.4-1.6 2.2h1.7V17H3.5v-1c1.6-1.3 2-1.8 2-2.3 0-.3-.2-.5-.4-.5s-.4.2-.4.5z"], ["r", 9, 5, 13, 2.2, 1.1, 0], ["r", 9, 11, 13, 2.2, 1.1, 0], ["r", 9, 17, 10, 2.2, 1.1, 0]]),
41
- taskList: draw([["r", 2, 3, 6, 6, 1.5], ["s", "M3.6 6l1.3 1.3L6.6 5", 2], ["r", 2, 14, 6, 6, 1.5, 0], ["r", 10, 5, 12, 2.2, 1.1, 0], ["r", 10, 16, 9, 2.2, 1.1, 0]]),
42
41
  blockquote: draw([["r", 2, 3, 20, 18, 3, 0], ["p", quote]]),
43
- pullquote: draw([["r", 2, 3, 20, 2, 1], ["r", 2, 19, 20, 2, 1], ["r", 2, 6.5, 20, 11, 2, 0], ["p", "M7 9h3v3c0 1.7-1 2.8-2.6 3l-.4-1.2c.8-.3 1.1-.8 1.1-1.8H7zm7 0h3v3c0 1.7-1 2.8-2.6 3l-.4-1.2c.8-.3 1.1-.8 1.1-1.8H14z"]]),
44
42
  codeBlock: draw([frame(), ["p", "M9.5 8.5L6 12l3.5 3.5 1.2-1.2L8.4 12l2.3-2.3zm5 0l-1.2 1.2 2.3 2.3-2.3 2.3 1.2 1.2L18 12z"]]),
45
- preformatted: draw([frame(), ...lines(5, 7, [12, 8, 10])]),
46
43
  customHtml: draw([frame(), ["p", "M8 8.5L4.5 12 8 15.5l1.2-1.2L6.9 12l2.3-2.3zm8 0l-1.2 1.2 2.3 2.3-2.3 2.3 1.2 1.2L19.5 12zM13.2 7l-3.6 10h1.7L14.9 7z"]]),
47
- callout: draw([["r", 2, 3, 20, 18, 3, 0], ["r", 2, 3, 3, 18, 1.5], ["c", 12, 8, 1.5], ["r", 10.7, 11, 2.6, 7, 1.3]]),
44
+ testimonials: draw([["r", 1.5, 4, 6.5, 16, 2, 0], ["r", 8.75, 4, 6.5, 16, 2, 0], ["r", 16, 4, 6.5, 16, 2, 0], ["r", 3, 14, 3.5, 1.4, .7], ["r", 10.25, 14, 3.5, 1.4, .7], ["r", 17.5, 14, 3.5, 1.4, .7]]),
45
+ popup: draw([["r", 2, 3, 20, 18, 2.5, 0], ["r", 6, 7, 12, 8, 1.5], ["r", 8, 17, 8, 2, 1]]),
48
46
  details: draw([["r", 2, 3, 20, 6, 2], ["s", "M17 5l1.5 1.5L20 5", 2], ["r", 2, 11, 20, 10, 2, 0], ...lines(5, 14, [12, 8])]),
49
47
  accordion: draw([["r", 2, 2, 20, 6, 2], ["s", "M16.5 4.3l1.5 1.5 1.5-1.5", 2], ["r", 2, 9.5, 20, 5.5, 2, 0], ["r", 2, 16.5, 20, 5.5, 2, 0]]),
50
48
  tabs: draw([["r", 2, 8, 20, 13, 2.5, 0], ["p", "M2 6.5A2.5 2.5 0 0 1 4.5 4H10l1.5 4H2z"], ["r", 12, 4, 6, 3.5, 1.2, 0], ...lines(5, 12, [10, 7])]),
51
49
  tab: draw([["p", "M2 6.5A2.5 2.5 0 0 1 4.5 4H10l1.5 4H2z"], ["r", 2, 8, 20, 13, 2.5, 0], ...lines(5, 12, [10, 7])]),
52
- footnotes: draw([["r", 2, 3, 20, 18, 3, 0], ...lines(5, 7, [14, 10]), ["r", 5, 14, 2, 2, 1], ["r", 9, 14, 10, 2, 1]]),
53
50
  // Media
54
51
  image: draw(photo),
55
52
  gallery: draw([["r", 2, 2, 9, 12, 2, 0], ["r", 13, 2, 9, 7, 2], ["r", 2, 16, 9, 6, 2], ["r", 13, 11, 9, 11, 2, 0]]),
56
53
  cover: draw([["r", 2, 3, 20, 18, 3], ["r", 6, 10, 12, 2.2, 1.1, 2], ["r", 8, 14, 8, 1.8, .9, 2]]),
57
- mediaText: draw([["r", 2, 4, 9, 16, 2], ["c", 5.5, 8.5, 1.4, 2], ...lines(13, 7, [9, 7, 8]), ["r", 13, 15, 6, 3, 1.5, 0]]),
58
54
  video: draw([["r", 2, 4, 20, 16, 3, 0], ["c", 12, 12, 5], ["p", play, 2]]),
59
- youtube: draw([["r", 2, 5, 20, 14, 4], ["p", play, 2]]),
60
55
  audio: draw([["r", 2, 2, 20, 20, 4, 0], ["p", "M15 5v8.2A2.8 2.8 0 1 1 13 10.6V7l-4 1v7.2A2.8 2.8 0 1 1 7 12.6V6.5z"]]),
61
56
  file: draw([["p", "M6 2h8l5 5v13a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2z", 0], ["p", "M14 2l5 5h-3a2 2 0 0 1-2-2z"], ...lines(7, 12, [10, 7])]),
62
57
  embed: draw([["r", 2, 3, 20, 18, 3, 0], ["p", "M10.6 13.4a3 3 0 0 0 4.2 0l2.5-2.5a3 3 0 1 0-4.2-4.2l-.8.8 1.2 1.2.8-.8a1.3 1.3 0 0 1 1.8 1.8l-2.5 2.5a1.3 1.3 0 0 1-1.8 0zM13.4 10.6a3 3 0 0 0-4.2 0l-2.5 2.5a3 3 0 1 0 4.2 4.2l.8-.8-1.2-1.2-.8.8a1.3 1.3 0 0 1-1.8-1.8l2.5-2.5a1.3 1.3 0 0 1 1.8 0z"]]),
@@ -68,8 +63,6 @@ const I = {
68
63
  columns: draw([["r", 2, 4, 20, 16, 3, 0], ["r", 4, 6, 7, 12, 1.5], ["r", 13, 6, 7, 12, 1.5]]),
69
64
  column: draw([["r", 2, 4, 20, 16, 3, 0], ["r", 8, 6, 8, 12, 1.5]]),
70
65
  spacer: draw([["r", 2, 2, 20, 3, 1.5, 0], ["r", 2, 19, 20, 3, 1.5, 0], ["p", "M12 6.5l3 3h-2v5h2l-3 3-3-3h2v-5H9z"]]),
71
- horizontalRule: draw([["r", 2, 5, 20, 3, 1.5, 0], ["r", 2, 10.75, 20, 2.5, 1.25], ["r", 2, 16, 20, 3, 1.5, 0]]),
72
- pageBreak: draw([["r", 4, 2, 16, 7, 2, 0], ["r", 4, 15, 16, 7, 2, 0], ["r", 2, 11, 4, 2, 1], ["r", 9, 11, 6, 2, 1], ["r", 18, 11, 4, 2, 1]]),
73
66
  carousel: draw([["r", 5, 4, 14, 14, 2.5], ["r", 1, 6, 3, 10, 1.5, 0], ["r", 20, 6, 3, 10, 1.5, 0], ["c", 9.5, 20.5, 1], ["c", 12, 20.5, 1, 0], ["c", 14.5, 20.5, 1, 0]]),
74
67
  // Thiết kế / widget
75
68
  buttons: draw([["r", 1, 7, 10, 10, 5], ["r", 13, 7, 10, 10, 5, 0]]),
@@ -80,6 +73,7 @@ const I = {
80
73
  tableHeader: draw([["r", 2, 3, 20, 18, 2.5, 0], ["r", 2, 3, 20, 5, 2.5]]),
81
74
  iconBox: draw([["r", 2, 2, 20, 20, 4, 0], ["c", 12, 8.5, 3.5], ["r", 6, 14, 12, 2, 1], ["r", 8, 17.5, 8, 1.6, .8]]),
82
75
  imageBox: draw([["r", 2, 2, 20, 20, 4, 0], ["r", 5, 5, 14, 8, 2], ["p", "M6 12l3.5-3.5 2 2L14 8l4 4z", 2], ["r", 6, 15, 12, 2, 1], ["r", 8, 18.5, 8, 1.4, .7]]),
76
+ imageOverlay: draw([["r", 2, 2, 20, 20, 3, 0], ["r", 5, 5, 14, 14, 1.5, 0], ["r", 7, 10.5, 10, 2.2, 1.1], ["r", 9, 14.5, 6, 1.6, .8]]),
83
77
  iconList: draw([["c", 5, 6, 2.5], ["c", 5, 12, 2.5], ["c", 5, 18, 2.5], ["r", 9.5, 4.8, 12, 2.4, 1.2, 0], ["r", 9.5, 10.8, 12, 2.4, 1.2, 0], ["r", 9.5, 16.8, 9, 2.4, 1.2, 0]]),
84
78
  icon: draw([["r", 2, 2, 20, 20, 5, 0], ["p", star]]),
85
79
  counter: draw([["r", 1.5, 5, 21, 14, 3, 0], ["r", 4, 8, 4.5, 8, 1.2], ["r", 9.75, 8, 4.5, 8, 1.2], ["r", 15.5, 8, 4.5, 8, 1.2]]),
@@ -127,7 +121,6 @@ const I = {
127
121
  pageList: draw([["r", 2, 2, 8, 6, 1.5], ["r", 7, 10, 15, 4, 1.5, 0], ["r", 7, 17, 15, 4, 1.5, 0], ["r", 4, 8, 1.6, 11, .8, 0]]),
128
122
  archives: draw([["r", 2, 3, 20, 6, 2], ["r", 3.5, 10, 17, 11, 2, 0], ["r", 9, 13, 6, 2, 1]]),
129
123
  listItem: draw([["c", 6, 12, 2.5], ["r", 10.5, 10.8, 11, 2.4, 1.2, 0]]),
130
- taskItem: draw([["r", 3, 8, 8, 8, 2], ["r", 13, 10.8, 9, 2.4, 1.2, 0]]),
131
124
  map: draw([["p", "M2 6l6-3 8 3 6-3v15l-6 3-8-3-6 3z", 0], ["p", pin], ["c", 12, 8.5, 2.3, 2]]),
132
125
  videoPopup: draw([["r", 2, 4, 20, 16, 3, 0], ["c", 12, 12, 5], ["p", play, 2]]),
133
126
  };
@@ -0,0 +1,21 @@
1
+ import { CONTENT_VERSION } from "@ecomcx/ecomweb-content";
2
+ import { useEffect, useMemo, useState } from "react";
3
+ import { useEditor } from "../context";
4
+ import { docFromBlocks, type BNode } from "../core/model";
5
+
6
+ /**
7
+ * Xem trước thật của khối khi rê chuột ở bảng chèn: vẽ đúng khối mẫu sẽ được chèn bằng khung soạn chỉ xem (giống thư viện mẫu),
8
+ * nên đồng hồ chạy, thẻ, tab… hiện y như sau khi chèn. Đợi một nhịp để rê qua nhanh không dựng khung.
9
+ */
10
+ export function LiveBlockPreview({ id, create }: { id: string; create(): BNode }) {
11
+ const { ui } = useEditor();
12
+ const [on, setOn] = useState(false);
13
+ useEffect(() => { setOn(false); const t = setTimeout(() => setOn(true), 160); return () => clearTimeout(t); }, [id]);
14
+ const value = useMemo(() => { try { return { version: CONTENT_VERSION, blocks: [{ type: "richtext", data: docFromBlocks([create()]) }] }; } catch { return null; } }, [id]); // eslint-disable-line react-hooks/exhaustive-deps
15
+ if (!ui.renderPreview || !value) return null;
16
+ return (
17
+ <div className="ecx-block-preview-live" aria-hidden="true">
18
+ {on && <div className="ecx-block-preview-live-inner ecx-lib-preview-inner" style={{ width: 440, transform: `scale(${288 / 440})`, marginTop: -28, height: 190 / (288 / 440) + 28 }}>{ui.renderPreview(value)}</div>}
19
+ </div>
20
+ );
21
+ }
@@ -15,11 +15,13 @@ const KEEP = new Set(["imageFit", "imageOpacity", "imageFilter", "imageHoverEffe
15
15
  * đang chọn ở đầu tab; ô có `state` nằm trong thẻ Rê chuột / Đang mở của mục.
16
16
  */
17
17
  /** `legacyOnly`: khối đã chia phần (attrs.parts) — chỉ hiện mục ô rời đã có giá trị (nội dung cũ), để sửa / xoá. */
18
- export function BlockStyleSections({ type, attrs, setAttrs, device, legacyOnly }: { type: string; attrs: Record<string, any>; setAttrs(a: Record<string, unknown>): void; device: Device; legacyOnly?: boolean }) {
18
+ /** `tab="settings"`: chỉ các ô khai `tab: "settings"` (bố cục / cách hiển thị) — hiện ở tab Cài đặt; mặc định là các ô còn lại (tab Kiểu dáng). */
19
+ export function BlockStyleSections({ type, attrs, setAttrs, device, legacyOnly, tab = "style" }: { type: string; attrs: Record<string, any>; setAttrs(a: Record<string, unknown>): void; device: Device; legacyOnly?: boolean; tab?: "style" | "settings" }) {
19
20
  const t = useMsgs("blockStyle");
20
21
  const sections = new Map<string, Array<[string, ControlSpec]>>();
21
22
  for (const [name, spec] of Object.entries(coreControlsFor(type))) {
22
23
  if (name === "tabsAlign") continue; // sửa ở tab Cài đặt
24
+ if ((spec.tab ?? "style") !== tab) continue;
23
25
  const k = spec.section ?? "text";
24
26
  sections.set(k, [...(sections.get(k) ?? []), [name, spec]]);
25
27
  }