@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
@@ -8,7 +8,6 @@ import { useMsgs } from "../i18n";
8
8
  import { Row, Section, Seg, cx } from "../ui/style-controls";
9
9
  import { byStep } from "../ui/style-tab";
10
10
  import { UnitInput } from "../ui/unit-controls";
11
- import { DividerSection } from "../ui/divider-panel";
12
11
  import { makeBlock } from "../core/model";
13
12
 
14
13
  type Responsive<T> = T | Partial<Record<Device, T>>;
@@ -135,7 +134,6 @@ export function ColumnsInspector({ block, attrs, setAttrs }: BlockEditProps) {
135
134
  <UnitInput label={t.rowMaxWidth} value={rowMax} units={["px", "rem", "%"]} max={1600} onChange={setRowMax} />
136
135
  </Row>
137
136
  </Section>
138
- <DividerSection attrs={attrs} setAttrs={setAttrs} />
139
137
  </>
140
138
  );
141
139
  }
@@ -157,6 +155,9 @@ export function ColumnInspector({ attrs, setAttrs }: BlockEditProps) {
157
155
  const resp = <K extends "textAlign" | "maxWidth">(k: K) => atDevice<string>(style[k] as Responsive<string>, device);
158
156
  const setResp = (k: "textAlign" | "maxWidth", v: string | undefined) => setAttrs({ style: normalizeStyle({ ...style, [k]: mapDevice(style[k] as Responsive<string>, device, v) }) ?? undefined });
159
157
  const href = typeof attrs.href === "string" ? attrs.href : "";
158
+ const orderMobile = (style.order as { mobile?: number } | undefined)?.mobile;
159
+ const mobileOrder = typeof orderMobile === "number" ? Math.sign(orderMobile) : 0;
160
+ const setMobileOrder = (v: number) => setAttrs({ style: normalizeStyle({ ...style, order: { ...((style.order as object) ?? {}), mobile: v === 0 ? undefined : v } }) ?? undefined });
160
161
  const gap = atDevice<string>(style.gap as Responsive<string>, device);
161
162
  const setGap = (v: string | undefined) => setAttrs({ style: normalizeStyle({ ...style, gap: mapDevice(style.gap as Responsive<string>, device, v), ...(v === undefined ? {} : { layout }) }) ?? undefined });
162
163
  return (
@@ -194,6 +195,14 @@ export function ColumnInspector({ attrs, setAttrs }: BlockEditProps) {
194
195
  <UnitInput label={t.maxWidth} value={resp("maxWidth")} units={["px", "rem", "%"]} max={1600} onChange={(v) => setResp("maxWidth", v)} />
195
196
  </Row>
196
197
  </Section>
198
+ {/* Thứ tự khi các cột xếp chồng trên điện thoại: đưa cột này lên đầu / xuống cuối mà không phải đổi thứ tự trong khung soạn */}
199
+ <Section title={t.mobileOrder} modified={mobileOrder !== 0} defaultOpen={mobileOrder !== 0}>
200
+ <Row label={t.mobileOrder} onReset={mobileOrder !== 0 ? () => setMobileOrder(0) : undefined}>
201
+ <Seg label={t.mobileOrder} value={String(mobileOrder)} onChange={(v) => setMobileOrder(Number(v))}
202
+ options={[["0", ArrowDown, t.orderKeep], ["-1", ArrowUp, t.orderFirst], ["1", ArrowDown, t.orderLast]]} />
203
+ <p className="ecx-field-help">{t.mobileOrderHelp}</p>
204
+ </Row>
205
+ </Section>
197
206
  {/* Liên kết phủ cả cột (cả cột thành một vùng bấm) */}
198
207
  <Section title={t.overlayLink} modified={!!href} defaultOpen={!!href}>
199
208
  <Row label={t.linkUrl}>
@@ -14,9 +14,9 @@ import { blockDescription } from "../ui/block-descriptions";
14
14
  /** Tên khối theo ngôn ngữ giao diện (khối có nhãn trong bộ chữ). */
15
15
  const TITLE_KEYS: Partial<Record<string, keyof V2Labels>> = {
16
16
  paragraph: "paragraph", heading: "heading", bulletList: "list", orderedList: "orderedList", blockquote: "quote", codeBlock: "codeBlock",
17
- preformatted: "preformatted", horizontalRule: "separator", image: "image", group: "groupBlock", columns: "columns", column: "column", buttons: "buttons",
18
- button: "button", spacer: "spacer", callout: "callout", details: "details", table: "table", templatePart: "templatePart", syncedPattern: "syncedPattern",
19
- pullquote: "pullquote", cover: "cover", customHtml: "html", embed: "embed",
17
+ image: "image", group: "groupBlock", columns: "columns", column: "column", buttons: "buttons",
18
+ button: "button", spacer: "spacer", details: "details", table: "table", templatePart: "templatePart", syncedPattern: "syncedPattern",
19
+ cover: "cover", customHtml: "html", embed: "embed",
20
20
  };
21
21
 
22
22
  /**
@@ -41,15 +41,18 @@ function withStyleAttrs(t: BlockType): BlockType["attributes"] {
41
41
 
42
42
  export function coreBlockTypes(labels: V2Labels): BlockType[] {
43
43
  const names = messages("blockTitles", labels.lang);
44
- return [...textBlocks(), ...layoutBlocks(), ...mediaBlocks(), ...formBlocks(labels.lang), ...widgetBlocks(labels.lang), ...themeBlocks()].map((t) => {
44
+ return [...textBlocks(), ...layoutBlocks(labels.lang), ...mediaBlocks(), ...formBlocks(labels.lang), ...widgetBlocks(labels.lang), ...themeBlocks()].map((t) => {
45
45
  const key = TITLE_KEYS[t.name];
46
46
  const str = (v: unknown) => (typeof v === "string" ? v : undefined);
47
- const title = key ? String(labels[key]) : str(names[t.name]) ?? t.title;
47
+ const title = str(names[t.name]) ?? (key ? String(labels[key]) : t.title);
48
48
  // Biến thể đứng riêng (Hàng ngang / Xếp dọc / Lưới) theo ngôn ngữ
49
49
  // Icon 2 lớp của bộ lõi (block-icons.tsx); biến thể dùng icon riêng nếu có, không thì icon của khối
50
50
  const icon = BLOCK_ICONS[t.name] ?? t.icon;
51
51
  const variations = t.variations?.map((v) => { const vt = str(names[`${t.name}/${v.name}`]); return { ...v, ...(vt ? { title: vt } : {}), icon: BLOCK_ICONS[v.name] ?? (t.name === "columns" ? columnsIcon(v.name) : undefined) ?? (BLOCK_ICONS[t.name] ? icon : v.icon) }; });
52
- return { ...t, title, icon, variations, description: t.description ?? blockDescription(t.name, labels.lang), attributes: withStyleAttrs(t) };
52
+ // Nhóm rộng hết trang có khung nội dung = Section (ô "Section" ở bảng chèn): bảng phải ghi đúng tên người dùng vừa chèn
53
+ const titleOf = t.name === "group" ? (a: Record<string, unknown>) => (a.align === "full" && a.constrained === true ? str(names["group/section"]) : undefined) : t.titleOf;
54
+ const aliases = [...new Set([t.title, key ? String(labels[key]) : "", ...(t.aliases ?? [])].filter((x) => x && x !== title))];
55
+ return { ...t, title, aliases, titleOf, icon, variations, description: t.description ?? blockDescription(t.name, labels.lang), attributes: withStyleAttrs(t) };
53
56
  });
54
57
  }
55
58
 
@@ -0,0 +1,80 @@
1
+ import type { ReactElement } from "react";
2
+ import type { BlockLayout } from "../core/registry";
3
+ import { bar, box, Thumb } from "../canvas/variation-picker";
4
+
5
+ /**
6
+ * Bố cục chọn sẵn của các khối có nhiều kiểu bố trí (thẻ có hình thu nhỏ): hiện ngay sau khi chèn và ở đầu bảng phải.
7
+ * Mỗi bố cục chỉ đặt vài thuộc tính cấu trúc — nội dung giữ nguyên khi đổi bố cục.
8
+ */
9
+ type M = Record<string, string>;
10
+
11
+ const lines = (x: number, y: number, w: number) => [bar(x, y, w), bar(x, y + 9, w - 10), bar(x, y + 18, w - 4)];
12
+
13
+ export function tabsLayouts(m: M): BlockLayout[] {
14
+ const strip = (xs: number[], w: number) => xs.map((x, i) => bar(x, 9, w, 6, i === 0));
15
+ return [
16
+ { id: "left", label: m.layoutTabsLeft, attrs: { orientation: "horizontal", tabsAlign: "flex-start" }, thumb: <Thumb>{strip([8, 30, 52], 18)}{bar(8, 17, 80, 1)}{lines(8, 26, 80)}</Thumb> },
17
+ { id: "center", label: m.layoutTabsCenter, attrs: { orientation: "horizontal", tabsAlign: "center" }, thumb: <Thumb>{strip([19, 41, 63], 14)}{bar(8, 17, 80, 1)}{lines(8, 26, 80)}</Thumb> },
18
+ { id: "spread", label: m.layoutTabsSpread, attrs: { orientation: "horizontal", tabsAlign: "space-between" }, thumb: <Thumb>{strip([8, 35, 62], 26)}{bar(8, 17, 80, 1)}{lines(8, 26, 80)}</Thumb> },
19
+ { id: "vertical", label: m.layoutTabsVertical, attrs: { orientation: "vertical" }, thumb: <Thumb>{[10, 22, 34].map((y, i) => bar(8, y, 22, 8, i === 0))}{bar(33, 8, 1, 40)}{lines(39, 10, 49)}</Thumb> },
20
+ ];
21
+ }
22
+
23
+ const chevron = (x: number, y: number) => <path key={`c${x},${y}`} d={`M${x} ${y} l3 3 l3 -3`} className="is-line" />;
24
+ const plus = (x: number, y: number) => <path key={`p${x},${y}`} d={`M${x} ${y + 3} h6 M${x + 3} ${y} v6`} className="is-line" />;
25
+
26
+ export function accordionLayouts(m: M): BlockLayout[] {
27
+ const rows = (mark: (x: number, y: number) => ReactElement, side: "left" | "right") => [8, 26, 44].map((y) => [box(8, y, 80, 14), bar(side === "left" ? 22 : 14, y + 5, 40), mark(side === "left" ? 13 : 76, y + 5)]);
28
+ return [
29
+ { id: "arrow", label: m.layoutAcc1, attrs: { columns: 1, icon: "arrow", iconSide: "right" }, thumb: <Thumb>{rows(chevron, "right")}</Thumb> },
30
+ { id: "plus", label: m.layoutAccPlus, attrs: { columns: 1, icon: "plus", iconSide: "right" }, thumb: <Thumb>{rows(plus, "right")}</Thumb> },
31
+ { id: "two", label: m.layoutAcc2, attrs: { columns: 2, icon: "arrow", iconSide: "right" }, thumb: <Thumb>{[8, 36].flatMap((y) => [8, 50].map((x) => [box(x, y, 38, 22), bar(x + 6, y + 8, 18), chevron(x + 28, y + 8)]))}</Thumb> },
32
+ { id: "left", label: m.layoutAccLeft, attrs: { columns: 1, icon: "arrow", iconSide: "left" }, thumb: <Thumb>{rows(chevron, "left")}</Thumb> },
33
+ ];
34
+ }
35
+
36
+ const dot = (x: number, y: number, round = false) => <rect key={`d${x},${y}`} x={x} y={y} width={7} height={7} rx={round ? 3.5 : 1.5} className="is-accent" />;
37
+
38
+ export function iconListLayouts(m: M): BlockLayout[] {
39
+ return [
40
+ { id: "list", label: m.layoutListV, attrs: { layout: "list", columns: 1, iconStyle: "plain" }, thumb: <Thumb>{[10, 25, 40].flatMap((y) => [dot(10, y), bar(23, y + 1.5, 50)])}</Thumb> },
41
+ { id: "inline", label: m.layoutListInline, attrs: { layout: "inline" }, thumb: <Thumb>{[6, 36, 66].flatMap((x) => [dot(x, 28), bar(x + 10, 29.5, 14)])}</Thumb> },
42
+ { id: "two", label: m.layoutList2, attrs: { layout: "list", columns: 2, iconStyle: "plain" }, thumb: <Thumb>{[10, 25, 40].flatMap((y) => [8, 52].flatMap((x) => [dot(x, y), bar(x + 12, y + 1.5, 24)]))}</Thumb> },
43
+ { id: "circle", label: m.layoutListCircle, attrs: { layout: "list", columns: 1, iconStyle: "circle" }, thumb: <Thumb>{[10, 25, 40].flatMap((y) => [dot(10, y, true), bar(23, y + 1.5, 50)])}</Thumb> },
44
+ ];
45
+ }
46
+
47
+ export function testimonialLayouts(m: M): BlockLayout[] {
48
+ const quote = [bar(18, 16, 60), bar(18, 25, 52), bar(18, 34, 56)];
49
+ const who = [<circle key="a" cx={24} cy={48} r={4} className="is-accent" />, bar(32, 46, 24, 3)];
50
+ return [
51
+ { id: "card", label: m.layoutTestCard, attrs: { variant: "card" }, thumb: <Thumb>{box(8, 6, 80, 52)}{quote}{who}</Thumb> },
52
+ { id: "plain", label: m.layoutTestPlain, attrs: { variant: "plain" }, thumb: <Thumb>{quote}{who}</Thumb> },
53
+ { id: "bubble", label: m.layoutTestBubble, attrs: { variant: "bubble" }, thumb: <Thumb>{box(8, 6, 80, 38)}<polygon key="t" points="22,44 30,44 24,52" className="is-box" />{[bar(18, 14, 60), bar(18, 23, 52), bar(18, 32, 56)]}<circle key="a" cx={36} cy={56} r={3} className="is-accent" /></Thumb> },
54
+ ];
55
+ }
56
+
57
+ export function carouselLayouts(m: M): BlockLayout[] {
58
+ const slides = (n: number) => Array.from({ length: n }, (_, i) => { const w = (84 - (n - 1) * 6) / n; const x = 6 + i * (w + 6); return [box(x, 8, w, 38, i === 0), bar(x + 5, 20, Math.max(8, w - 10)), bar(x + 5, 29, Math.max(6, w - 16))]; });
59
+ const dots = [<circle key="d1" cx={42} cy={56} r={2.4} className="is-accent" />, <circle key="d2" cx={48} cy={56} r={2.4} />, <circle key="d3" cx={54} cy={56} r={2.4} />];
60
+ return [1, 2, 3].map((n) => ({ id: `s${n}`, label: m[`layoutSlides${n}`], attrs: { slidesPerView: n }, thumb: <Thumb>{slides(n)}{dots}</Thumb> }));
61
+ }
62
+
63
+ export function iconBoxLayouts(m: M): BlockLayout[] {
64
+ const text = (x: number, y: number, w: number) => [bar(x, y, w, 5), bar(x, y + 9, w - 6), bar(x, y + 17, w - 12)];
65
+ return [
66
+ { id: "top", label: m.layoutBoxTop, attrs: { position: "top", iconStyle: "plain" }, thumb: <Thumb>{dot(44, 8)}{text(22, 26, 52)}</Thumb> },
67
+ { id: "circle", label: m.layoutBoxCircle, attrs: { position: "top", iconStyle: "circle" }, thumb: <Thumb><circle key="c" cx={48} cy={15} r={8} className="is-accent" />{text(22, 28, 52)}</Thumb> },
68
+ { id: "left", label: m.layoutBoxLeft, attrs: { position: "left" }, thumb: <Thumb>{dot(8, 12)}{text(24, 12, 62)}</Thumb> },
69
+ { id: "right", label: m.layoutBoxRight, attrs: { position: "right" }, thumb: <Thumb>{dot(81, 12)}{text(8, 12, 62)}</Thumb> },
70
+ ];
71
+ }
72
+
73
+ export function progressLayouts(m: M): BlockLayout[] {
74
+ const track = (y: number, h = 6) => [<rect key={`t${y}`} x={8} y={y} width={80} height={h} rx={h / 2} />, <rect key={`f${y}`} x={8} y={y} width={56} height={h} rx={h / 2} className="is-accent" />];
75
+ return [
76
+ { id: "above", label: m.layoutBarAbove, attrs: { textPosition: "above" }, thumb: <Thumb>{bar(8, 14, 30)}{bar(76, 14, 12)}{track(26)}</Thumb> },
77
+ { id: "inside", label: m.layoutBarInside, attrs: { textPosition: "inside" }, thumb: <Thumb>{track(22, 16)}{bar(14, 28, 20, 3)}</Thumb> },
78
+ { id: "below", label: m.layoutBarBelow, attrs: { textPosition: "below" }, thumb: <Thumb>{track(16)}{bar(8, 30, 30)}{bar(76, 30, 12)}</Thumb> },
79
+ ];
80
+ }