@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.
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 +4 -0
  5. package/src/locales/en/block-desc.ts +4 -11
  6. package/src/locales/en/block-style.ts +17 -6
  7. package/src/locales/en/block-titles.ts +38 -16
  8. package/src/locales/en/blocks.ts +36 -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 +241 -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 +6 -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 +4 -0
  23. package/src/locales/vi/block-desc.ts +7 -14
  24. package/src/locales/vi/block-style.ts +18 -7
  25. package/src/locales/vi/block-titles.ts +48 -26
  26. package/src/locales/vi/blocks.ts +36 -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 +241 -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 +7 -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 +331 -124
  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 +13 -19
  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 +30 -4
  50. package/src/v2/canvas/canvas-css.ts +81 -9
  51. package/src/v2/canvas/canvas.tsx +63 -7
  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 +2 -0
  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 +26 -6
  69. package/src/v2/ui/attr-hints.ts +115 -16
  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 +7 -2
  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 +62 -12
  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
@@ -77,6 +77,7 @@ export function RichText(props: RichTextProps) {
77
77
  v.updateState(next);
78
78
  syncEmpty(v);
79
79
  if (!tr.docChanged || tr.getMeta("external")) return;
80
+ ui.fresh.delete(propsRef.current.blockId);
80
81
  const inline = docToInline(next.doc);
81
82
  lastValue.current = inline;
82
83
  const p = propsRef.current;
@@ -94,14 +95,29 @@ export function RichText(props: RichTextProps) {
94
95
  handlePaste: (v, event) => (propsRef.current.onChange ? false : pasteIntoBlock(ctx, propsRef.current.blockId, v, event)),
95
96
  handleDOMEvents: {
96
97
  // Kéo chuột từ ô này sang khối chữ khác → chọn chữ qua nhiều khối
98
+ // Chữ mẫu chưa sửa: nhả chuột xong mà chỉ có con trỏ (không kéo chọn) → chọn hết để gõ là thay
99
+ mouseup: (v) => {
100
+ const p = propsRef.current;
101
+ if (ui.fresh.has(p.blockId) && v.state.selection.empty && v.state.doc.content.size > 0) setTimeout(() => { if (ui.fresh.has(p.blockId) && v.hasFocus() && v.state.selection.empty) v.dispatch(v.state.tr.setSelection(TextSelection.create(v.state.doc, 0, v.state.doc.content.size))); }, 0);
102
+ return false;
103
+ },
97
104
  mousedown: (v, e) => {
98
105
  const p = propsRef.current;
106
+ // Ô trống: bấm chỗ nào (kể cả giữa chữ gợi ý) con trỏ cũng về đầu ô — không để trình duyệt tự đặt theo toạ độ chuột lên chữ gợi ý
107
+ if (e.button === 0 && !e.shiftKey && !e.metaKey && !e.ctrlKey && v.state.doc.content.size === 0 && v.editable) {
108
+ e.preventDefault();
109
+ v.focus();
110
+ v.dispatch(v.state.tr.setSelection(TextSelection.create(v.state.doc, 0)));
111
+ return true;
112
+ }
99
113
  if (e.button === 0 && !e.shiftKey && !p.onChange && !p.field) trackRangeDrag(store, v, p.blockId);
100
114
  return false;
101
115
  },
102
116
  focus: () => {
103
117
  const p = propsRef.current;
104
118
  ui.activeRich = viewKey(p.blockId, p.field);
119
+ // Chữ mẫu của khối vừa chèn: chọn hết ở lần bấm đầu (sau khi chuột đặt con trỏ) để gõ là thay
120
+ if (ui.fresh.has(p.blockId) && viewRef.current) { const v = viewRef.current; setTimeout(() => { if (ui.fresh.has(p.blockId) && v.hasFocus() && v.state.doc.content.size > 0) v.dispatch(v.state.tr.setSelection(TextSelection.create(v.state.doc, 0, v.state.doc.content.size))); }, 0); }
105
121
  store.setEditing(p.blockId);
106
122
  ui.bump();
107
123
  return false;
@@ -201,10 +217,10 @@ function syncSelection(view: EditorView | undefined): EditorState | null {
201
217
  function atStart(view: EditorView) { const s = view.state.selection; return s.empty && s.from === 0; }
202
218
  function atEnd(view: EditorView) { const s = view.state.selection; return s.empty && s.from === view.state.doc.content.size; }
203
219
 
204
- /** Mục danh sách chứa khối chữ (khối chữ là con đầu của listItem/taskItem). */
220
+ /** Mục danh sách chứa khối chữ (khối chữ là con đầu của listItem). */
205
221
  function listItemOf(store: EditorStore, blockId: string): BNode | null {
206
222
  const loc = store.locate(blockId);
207
- return loc?.parent && (loc.parent.type === "listItem" || loc.parent.type === "taskItem") && loc.index === 0 ? loc.parent : null;
223
+ return loc?.parent && (loc.parent.type === "listItem") && loc.index === 0 ? loc.parent : null;
208
224
  }
209
225
 
210
226
  /** Ô gõ kế bên theo thứ tự trên khung soạn (đi xuyên qua header/footer lồng nhau). */
@@ -302,10 +318,10 @@ function richKeymap(store: EditorStore, ui: EditorUi, pr: PropsRef, keepCaret: (
302
318
  dispatch?.(state.tr.insertText("\n"));
303
319
  return true;
304
320
  }
305
- // "---" + Enter → đường kẻ
321
+ // "---" + Enter → khoảng cách có đường kẻ (Spacer)
306
322
  const blk = store.block(p.blockId);
307
323
  if (blk?.type === "paragraph" && state.doc.textContent === "---") {
308
- const hr = makeBlock("horizontalRule");
324
+ const hr = makeBlock("spacer", { height: "md", line: true });
309
325
  const para = makeBlock("paragraph");
310
326
  now(() => store.replace(p.blockId, [hr, para], { select: { ids: [], editing: para.id }, caret: { id: para.id, offset: 0 } }));
311
327
  return true;
@@ -391,7 +407,6 @@ const PREFIX_RULES: Array<{ re: RegExp; make(rest: RichNode[]): { blocks: BNode[
391
407
  })),
392
408
  { re: /^[-*+]$/, make: (rest) => { const p = makeBlock("paragraph", {}, rest); return { blocks: [makeBlock("bulletList", {}, [makeBlock("listItem", {}, [p])])], focus: p }; } },
393
409
  { re: /^1[.)]$/, make: (rest) => { const p = makeBlock("paragraph", {}, rest); return { blocks: [makeBlock("orderedList", {}, [makeBlock("listItem", {}, [p])])], focus: p }; } },
394
- { re: /^\[ ?\]$/, make: (rest) => { const p = makeBlock("paragraph", {}, rest); return { blocks: [makeBlock("taskList", {}, [makeBlock("taskItem", { checked: false }, [p])])], focus: p }; } },
395
410
  { re: /^>$/, make: (rest) => { const p = makeBlock("paragraph", {}, rest); return { blocks: [makeBlock("blockquote", {}, [p])], focus: p }; } },
396
411
  ];
397
412
 
@@ -0,0 +1,52 @@
1
+ import type { RichNode } from "@ecomcx/ecomweb-content";
2
+
3
+ /**
4
+ * Chữ AI trả về → khối dạng lưu. AI hay trả markdown nhẹ (## tiêu đề, - danh sách, **đậm**) dù được dặn trả chữ thuần:
5
+ * thay vì chèn nguyên ký hiệu `##` / `**` vào trang, ta đọc chúng thành tiêu đề, danh sách, chữ đậm / nghiêng thật.
6
+ * Chỉ nhận các dấu đơn giản; mọi thứ khác (bảng, mã, ảnh, HTML) giữ là chữ thường — không bao giờ sinh khối nguy hiểm.
7
+ */
8
+ const text = (t: string, marks?: Array<{ type: string }>): RichNode => ({ type: "text", text: t, ...(marks ? { marks } : {}) });
9
+
10
+ /** Chữ đậm / nghiêng trong một dòng: **đậm**, *nghiêng*; dấu lẻ loi giữ nguyên (không đọc `_` để khỏi phá tên_có_gạch_dưới). */
11
+ export function inlineNodes(src: string): RichNode[] {
12
+ const out: RichNode[] = [];
13
+ const re = /\*\*(?=\S)([\s\S]*?\S)\*\*|\*(?=\S)([^*]*?\S)\*/g;
14
+ let last = 0;
15
+ for (let m = re.exec(src); m; m = re.exec(src)) {
16
+ if (m.index > last) out.push(text(src.slice(last, m.index)));
17
+ out.push(m[1] != null ? text(m[1], [{ type: "bold" }]) : text(m[2], [{ type: "italic" }]));
18
+ last = m.index + m[0].length;
19
+ }
20
+ if (last < src.length) out.push(text(src.slice(last)));
21
+ return out.filter((n) => n.text !== "");
22
+ }
23
+
24
+ const para = (s: string): RichNode => ({ type: "paragraph", content: inlineNodes(s) });
25
+ const item = (s: string): RichNode => ({ type: "listItem", content: [para(s)] });
26
+
27
+ export function markdownToNodes(raw: string): RichNode[] {
28
+ const nodes: RichNode[] = [];
29
+ let list: RichNode | null = null;
30
+ let buf: string[] = [];
31
+ const flush = () => { if (buf.length) { nodes.push(para(buf.join(" "))); buf = []; } };
32
+ const closeList = () => { list = null; };
33
+ for (const line0 of raw.replace(/\r/g, "").split("\n")) {
34
+ const line = line0.trim();
35
+ if (!line) { flush(); closeList(); continue; }
36
+ const h = /^(#{1,6})\s+(.+?)\s*#*$/.exec(line);
37
+ if (h) { flush(); closeList(); nodes.push({ type: "heading", attrs: { level: Math.min(4, Math.max(2, h[1].length)) }, content: inlineNodes(h[2]) }); continue; }
38
+ const ul = /^(?:[-*•+])\s+(.+)$/.exec(line);
39
+ const ol = /^\d{1,3}[.)]\s+(.+)$/.exec(line);
40
+ if (ul || ol) {
41
+ flush();
42
+ const type = ul ? "bulletList" : "orderedList";
43
+ if (!list || (list as RichNode).type !== type) { list = { type, content: [] }; nodes.push(list); }
44
+ (list as RichNode).content!.push(item((ul ?? ol)![1]));
45
+ continue;
46
+ }
47
+ closeList();
48
+ buf.push(line);
49
+ }
50
+ flush();
51
+ return nodes;
52
+ }
package/src/v2/ui/ai.tsx CHANGED
@@ -4,6 +4,8 @@ import { useEditor } from "../context";
4
4
  import type { RichNode } from "@ecomcx/ecomweb-content";
5
5
  import { fromRich, inlineText, makeBlock, type BNode } from "../core/model";
6
6
  import { Modal } from "./options";
7
+ import { markdownToNodes } from "./ai-markdown";
8
+ import { useMsgs } from "../i18n";
7
9
  import { Dropdown, MenuItem, ToolButton } from "./toolbar";
8
10
 
9
11
  type Job = { task: string; label: string; language?: string; instruction?: string };
@@ -88,49 +90,114 @@ export function AiAltButton({ attrs, setAttrs }: { attrs: Record<string, unknown
88
90
  return <ToolButton label={labels.aiAlt} onClick={() => void run()} disabled={busy} data-ai-alt><Sparkles className="ecx-icon" /><span className="ecx-tool-text">Alt</span></ToolButton>;
89
91
  }
90
92
 
93
+ const TONES = ["auto", "friendly", "pro", "sell"] as const;
94
+ const LENGTHS = ["short", "medium", "long"] as const;
95
+ type Tone = (typeof TONES)[number];
96
+ type Length = (typeof LENGTHS)[number];
97
+ const TONE_HINT: Record<Tone, string> = { auto: "", friendly: "Tone: friendly and warm.", pro: "Tone: professional and precise.", sell: "Tone: persuasive, benefit-led, no exaggeration." };
98
+ const LENGTH_HINT: Record<Length, string> = { short: "Length: 1-2 short paragraphs.", medium: "Length: 3-4 paragraphs.", long: "Length: a full section of about 300-400 words with short H2/H3 headings." };
99
+
100
+ /** Lời nhắc đầy đủ gửi AI: yêu cầu của người dùng + giọng văn / độ dài / định dạng đã chọn. */
101
+ function composePrompt(prompt: string, o: { tone: Tone; length: Length; structured: boolean }) {
102
+ const hints = [TONE_HINT[o.tone], LENGTH_HINT[o.length], o.structured ? "Format: use '## ' for section headings, '- ' for bullet lists and **bold** for key words, only where they help." : "Format: plain paragraphs only."].filter(Boolean);
103
+ return `${prompt.trim()}\n\n${hints.join(" ")}`;
104
+ }
105
+
106
+ /** Lỗi từ máy chủ → câu người dùng hiểu và làm theo được (kèm thông báo gốc ngắn để dễ báo lỗi). */
107
+ function friendlyError(msg: string, t: Record<string, string>) {
108
+ if (/not_configured|chưa được bật|chưa bật|not configured|thiếu nhà cung cấp/i.test(msg)) return t.aiwErrOff;
109
+ if (/429|too.?fast|quá nhanh|too many/i.test(msg)) return t.aiwErrBusy;
110
+ return `${t.aiwErrOther}${msg ? ` (${msg.slice(0, 160)})` : ""}`;
111
+ }
112
+
113
+ /** Vẽ cây khối AI trả về (tiêu đề, đoạn, danh sách, đậm / nghiêng) đúng như sẽ chèn — không hiện ký hiệu markdown. */
114
+ function NodesView({ nodes }: { nodes: RichNode[] }) {
115
+ const inline = (n: RichNode, i: number): React.ReactNode => {
116
+ let el: React.ReactNode = n.text ?? "";
117
+ for (const m of n.marks ?? []) el = m.type === "bold" ? <strong>{el}</strong> : m.type === "italic" ? <em>{el}</em> : el;
118
+ return <span key={i}>{el}</span>;
119
+ };
120
+ const block = (n: RichNode, i: number): React.ReactNode => {
121
+ const kids = (n.content ?? []);
122
+ switch (n.type) {
123
+ case "heading": { const L = (`h${Math.min(4, Math.max(2, Number(n.attrs?.level) || 2))}`) as "h2"; return <L key={i}>{kids.map(inline)}</L>; }
124
+ case "bulletList": return <ul key={i}>{kids.map(block)}</ul>;
125
+ case "orderedList": return <ol key={i}>{kids.map(block)}</ol>;
126
+ case "listItem": return <li key={i}>{kids.map((k, j) => (k.type === "paragraph" ? <span key={j}>{(k.content ?? []).map(inline)}</span> : block(k, j)))}</li>;
127
+ default: return <p key={i}>{kids.map(inline)}</p>;
128
+ }
129
+ };
130
+ return <>{nodes.map(block)}</>;
131
+ }
132
+
133
+ const countWords = (nodes: RichNode[]): number => nodes.reduce((n, x) => n + (x.text ? x.text.trim().split(/\s+/).filter(Boolean).length : 0) + countWords(x.content ?? []), 0);
134
+
91
135
  /**
92
- * Lệnh /ai: hộp "Viết bằng AI" — gõ yêu cầu, xem kết quả, rồi chèn (thay khối chứa "/ai" nếu gọi từ lệnh gạch chéo).
93
- * Một bước hoàn tác; không tự chèn khi chưa bấm.
136
+ * Lệnh /ai: hộp "Viết bằng AI" — gõ yêu cầu (hoặc chọn gợi ý), chọn giọng văn / độ dài, xem kết quả đúng dạng sẽ chèn
137
+ * (tiêu đề, danh sách, chữ đậm thật), rồi chèn (thay khối chứa "/ai" nếu gọi từ lệnh gạch chéo). Một bước hoàn tác; không tự chèn khi chưa bấm.
94
138
  */
95
139
  export function AiWrite() {
96
140
  const { host, labels, store, ui } = useEditor();
141
+ const t = useMsgs("blocks") as Record<string, string>;
97
142
  const [at, setAt] = useState<{ blockId?: string; docId: string; parentId: string | null; index: number } | null>(null);
98
143
  const [prompt, setPrompt] = useState("");
144
+ const [tone, setTone] = useState<Tone>("auto");
145
+ const [length, setLength] = useState<Length>("medium");
146
+ const [structured, setStructured] = useState(true);
99
147
  const [state, setState] = useState<{ loading: boolean; text?: string; nodes?: RichNode[]; error?: string }>({ loading: false });
100
148
  useEffect(() => { ui.openAiWrite = (a) => { setAt(a); setPrompt(""); setState({ loading: false }); }; return () => { ui.openAiWrite = null; }; }, [ui]);
101
149
  if (!at || !host.ai) return null;
102
150
  const run = async () => {
103
- if (!prompt.trim()) return;
151
+ if (!prompt.trim() || state.loading) return;
104
152
  setState({ loading: true });
153
+ const full = composePrompt(prompt, { tone, length, structured });
105
154
  try {
106
- const r = host.ai!.write ? await host.ai!.write(prompt.trim()) : { text: await host.ai!.run("write", prompt.trim(), {}) };
107
- setState({ loading: false, text: r.text, nodes: Array.isArray(r.nodes) && r.nodes.length ? r.nodes as RichNode[] : undefined });
108
- } catch (e) { setState({ loading: false, error: (e as Error).message }); }
155
+ const r = host.ai!.write ? await host.ai!.write(full) : { text: await host.ai!.run("write", full, {}) };
156
+ const text = (r.text ?? "").trim();
157
+ // Khối dạng lưu của máy chủ (nếu có) thắng; không có thì đọc markdown nhẹ trong chữ AI trả về
158
+ const nodes = Array.isArray(r.nodes) && r.nodes.length ? (r.nodes as RichNode[]) : markdownToNodes(text);
159
+ if (!nodes.length) throw new Error("");
160
+ setState({ loading: false, text, nodes });
161
+ } catch (e) { setState({ loading: false, error: friendlyError((e as Error).message ?? "", t) }); }
109
162
  };
110
- const paragraphs = (state.text ?? "").split(/\n{2,}/).map((p) => p.trim()).filter(Boolean);
111
163
  const insert = () => {
112
- if (!paragraphs.length) return;
113
- // Có khối dạng lưu (tiêu đề, danh sách) thì chèn đúng khối; ứng dụng cũ chỉ trả chữ → mỗi đoạn một khối đoạn văn
114
- const nodes = state.nodes ? state.nodes.map(fromRich) : paragraphs.map((p) => makeBlock("paragraph", {}, p));
164
+ if (!state.nodes?.length) return;
165
+ const nodes = state.nodes.map(fromRich);
115
166
  store.batch(() => {
116
167
  if (at.blockId && store.block(at.blockId)) store.replace(at.blockId, nodes);
117
168
  else store.insert(at.docId, at.parentId, at.index, nodes);
118
169
  });
119
170
  setAt(null);
120
171
  };
172
+ const examples = [t.aiwEx1, t.aiwEx2, t.aiwEx3, t.aiwEx4];
173
+ const toneLabel: Record<Tone, string> = { auto: t.aiwToneAuto, friendly: t.aiwToneFriendly, pro: t.aiwTonePro, sell: t.aiwToneSell };
174
+ const lenLabel: Record<Length, string> = { short: t.aiwLenShort, medium: t.aiwLenMedium, long: t.aiwLenLong };
121
175
  return (
122
176
  <Modal title={labels.aiWrite} onClose={() => setAt(null)} wide>
123
177
  <div className="ecx-ai-body" data-ecx-ai-write>
124
- <textarea className="ecx-input" rows={3} value={prompt} onChange={(e) => setPrompt(e.target.value)} placeholder={labels.aiWritePrompt} data-ai-write-prompt
178
+ <textarea className="ecx-input" rows={3} autoFocus value={prompt} onChange={(e) => setPrompt(e.target.value)} placeholder={labels.aiWritePrompt} data-ai-write-prompt
125
179
  onKeyDown={(e) => { if (e.key === "Enter" && (e.metaKey || e.ctrlKey)) { e.preventDefault(); void run(); } }} />
180
+ {!prompt && !state.text && (
181
+ <div className="ecx-ai-chips" role="group" aria-label={t.aiwTryTitle}>
182
+ {examples.map((x) => <button key={x} type="button" className="ecx-chip" onClick={() => setPrompt(x)}>{x}</button>)}
183
+ </div>
184
+ )}
185
+ <div className="ecx-ai-opts">
186
+ <label className="ecx-ai-opt"><span>{t.aiwTone}</span>
187
+ <select className="ecx-input" value={tone} onChange={(e) => setTone(e.target.value as Tone)}>{TONES.map((k) => <option key={k} value={k}>{toneLabel[k]}</option>)}</select></label>
188
+ <label className="ecx-ai-opt"><span>{t.aiwLength}</span>
189
+ <select className="ecx-input" value={length} onChange={(e) => setLength(e.target.value as Length)}>{LENGTHS.map((k) => <option key={k} value={k}>{lenLabel[k]}</option>)}</select></label>
190
+ </div>
191
+ <label className="ecx-check"><input type="checkbox" checked={structured} onChange={(e) => setStructured(e.target.checked)} />{t.aiwStructured}</label>
126
192
  {state.loading && <p className="ecx-ai-wait" role="status">{labels.aiWorking}</p>}
127
193
  {state.error && <p className="ecx-ai-error" role="alert">{state.error}</p>}
128
- {state.text && <div className="ecx-ai-text" data-ecx-ai-result>{paragraphs.map((p, i) => <p key={i}>{p}</p>)}</div>}
194
+ {state.nodes && <div className="ecx-ai-text" data-ecx-ai-result aria-label={t.aiwPreview}><NodesView nodes={state.nodes} /></div>}
195
+ {state.nodes && <p className="ecx-ai-note">{countWords(state.nodes)} {t.aiwWords}</p>}
129
196
  <p className="ecx-ai-note">{labels.aiNote}</p>
130
197
  <div className="ecx-popover-actions">
131
198
  <button type="button" className="ecx-btn" onClick={() => setAt(null)}>{labels.cancel}</button>
132
- <button type="button" className="ecx-btn" onClick={() => void run()} disabled={state.loading || !prompt.trim()} data-ai-write-run>{state.text ? labels.aiRetry : labels.aiWriteRun}</button>
133
- {state.text && <button type="button" className="ecx-btn ecx-btn-primary" onClick={insert} data-ai-write-insert>{labels.aiInsert}</button>}
199
+ <button type="button" className="ecx-btn" onClick={() => void run()} disabled={state.loading || !prompt.trim()} data-ai-write-run>{state.nodes ? labels.aiRetry : labels.aiWriteRun}</button>
200
+ {state.nodes && <button type="button" className="ecx-btn ecx-btn-primary" onClick={insert} data-ai-write-insert>{labels.aiInsert}</button>}
134
201
  </div>
135
202
  </div>
136
203
  </Modal>
@@ -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(" ");
@@ -58,13 +59,25 @@ export function useChoices(kind: ChoiceKind | undefined, args: Record<string, st
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>
@@ -103,6 +116,9 @@ function MultiChoiceField({ hint, attrs, value, set, label }: { hint: AttrHint;
103
116
  }
104
117
 
105
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
+
106
122
  export function AttrForm({ type, attrs, onChange }: { type: BlockType; attrs: Record<string, any>; onChange(a: Record<string, unknown>): void }) {
107
123
  const { host, labels } = useEditor();
108
124
  const lang = labels.lang;
@@ -110,7 +126,7 @@ export function AttrForm({ type, attrs, onChange }: { type: BlockType; attrs: Re
110
126
  const translate = blockOptions(type.name).translate ?? host.translate;
111
127
  const entries = Object.entries(type.attributes ?? {})
112
128
  .map(([k, s]) => [k, s, hintOf(type.name, k)] as const)
113
- .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)));
114
130
  if (!entries.length) return null;
115
131
  const resetLabel = String(messages("controls", lang).reset ?? "Reset");
116
132
  return (
@@ -147,8 +163,12 @@ export function AttrForm({ type, attrs, onChange }: { type: BlockType; attrs: Re
147
163
  return <div key={k}><label className="ecx-check"><input type="checkbox" checked={!!value} onChange={(e) => set(e.target.checked)} /> {label}</label>{help}</div>;
148
164
  case "newTab":
149
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>;
150
- 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>;
151
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
+ }
152
172
  case "select": {
153
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
154
174
  const list = k === "level" ? opts().map(([v]) => [v, `H${v}`] as [string, string]) : opts();
@@ -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
 
@@ -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" } },
@@ -175,11 +211,24 @@ export const ATTR_HINTS: Record<string, AttrHint> = {
175
211
  "navigation.location": { control: "choice", choice: { kind: "menuLocation" }, help: true },
176
212
  "navigation.orientation": { control: "segmented", options: ["horizontal", "vertical"] },
177
213
  "navigation.overlayMenu": { control: "segmented", label: true, options: ["never", "mobile", "tablet", "always"] },
178
- "gallery.layout": { control: "segmented", label: true, options: ["grid", "masonry"] },
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,6 +239,8 @@ 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 },
@@ -212,16 +263,57 @@ export const ATTR_HINTS: Record<string, AttrHint> = {
212
263
  "loginout.logoutText": { label: true },
213
264
  "pageList.parentId": { label: true },
214
265
  "archives.showCount": { label: true },
215
- "icon.name": { control: "select", options: [...ICON_NAMES] },
266
+ "icon.name": { control: "icon", label: true },
267
+ "icon.tooltip": { label: true, placeholder: true, help: true },
216
268
  "icon.stroke": { control: "range", label: true, min: 0.5, max: 4, step: 0.5 },
217
269
  "icon.iconStyle": { control: "segmented", label: true, options: ["plain", "circle", "square"] },
218
270
  "icon.linkTarget": { control: "segmented", label: true, options: ["_self", "_blank"], when: (a) => !!a.href },
219
- "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" },
220
272
  "iconBox.position": { control: "segmented", label: true, options: ["top", "left", "right"] },
221
273
  "iconBox.level": { control: "select", options: levels(2, 6) },
222
274
  "imageBox.level": { control: "select", options: levels(2, 6) },
223
275
  "imageBox.src": { label: true },
224
- "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 },
225
317
  "iconList.layout": { control: "segmented", options: ["list", "inline"] },
226
318
  "iconList.columns": { control: "range", label: true, min: 1, max: 4, step: 1, when: (a) => a.layout !== "inline" },
227
319
  "iconList.iconAlign": { control: "segmented", label: true, options: ["top", "center", "bottom"] },
@@ -233,6 +325,7 @@ export const ATTR_HINTS: Record<string, AttrHint> = {
233
325
  "counter.duration": { help: true },
234
326
  "counter.decimals": { label: true, help: true },
235
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 },
236
329
  "testimonial.src": { label: true },
237
330
  "testimonial.variant": { control: "segmented", label: true, options: ["card", "plain", "bubble"] },
238
331
  "testimonial.rating": { control: "range", label: true, help: true, min: 0, max: 5, step: 1 },
@@ -273,10 +366,16 @@ export const ATTR_HINTS: Record<string, AttrHint> = {
273
366
  "query.authorCurrent": { label: true, when: notInherit },
274
367
  "query.urlFilters": { label: true, help: true },
275
368
  "queryFilter.taxonomy": { control: "choice", choice: { kind: "taxonomy" }, label: true, help: true },
276
- "queryFilter.termStyle": { control: "segmented", label: true, options: ["none", "links", "chips", "select"], when: (a) => !!a.taxonomy },
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 },
277
374
  "queryFilter.allLabel": { label: true, placeholder: true },
278
375
  "queryFilter.showSearch": { label: true },
279
376
  "queryFilter.showSort": { label: true },
377
+ "queryFilter.showYear": { label: true },
378
+ "queryFilter.showReset": { label: true },
280
379
  "queryFilter.sortOptions": { label: true, help: true, placeholder: true, when: (a) => a.showSort === true },
281
380
  "queryFilter.placeholder": { label: true, when: (a) => a.showSearch === true },
282
381
  "queryFilter.submitText": { label: true },