@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.
- package/package.json +3 -3
- package/src/locales/en/attrs.ts +2 -1
- package/src/locales/en/background.ts +5 -0
- package/src/locales/en/bindings.ts +5 -1
- package/src/locales/en/block-desc.ts +5 -11
- package/src/locales/en/block-style.ts +17 -6
- package/src/locales/en/block-titles.ts +38 -15
- package/src/locales/en/blocks.ts +37 -6
- package/src/locales/en/columns.ts +1 -0
- package/src/locales/en/controls.ts +1 -1
- package/src/locales/en/hints.ts +315 -12
- package/src/locales/en/index.ts +3 -1
- package/src/locales/en/layout.ts +13 -0
- package/src/locales/en/motion.ts +16 -0
- package/src/locales/en/palette.ts +8 -0
- package/src/locales/en/parts.ts +2 -1
- package/src/locales/en/pattern-overrides.ts +14 -0
- package/src/locales/en/placeholders.ts +9 -3
- package/src/locales/en/v2.ts +2 -0
- package/src/locales/vi/attrs.ts +3 -2
- package/src/locales/vi/background.ts +5 -0
- package/src/locales/vi/bindings.ts +5 -1
- package/src/locales/vi/block-desc.ts +8 -14
- package/src/locales/vi/block-style.ts +18 -7
- package/src/locales/vi/block-titles.ts +48 -25
- package/src/locales/vi/blocks.ts +37 -6
- package/src/locales/vi/columns.ts +1 -0
- package/src/locales/vi/controls.ts +1 -1
- package/src/locales/vi/hints.ts +315 -12
- package/src/locales/vi/index.ts +3 -1
- package/src/locales/vi/layout.ts +13 -0
- package/src/locales/vi/motion.ts +16 -0
- package/src/locales/vi/palette.ts +8 -0
- package/src/locales/vi/parts.ts +2 -1
- package/src/locales/vi/pattern-overrides.ts +14 -0
- package/src/locales/vi/placeholders.ts +10 -4
- package/src/locales/vi/v2.ts +2 -0
- package/src/v2/blocks/columns-inspector.tsx +11 -2
- package/src/v2/blocks/index.ts +9 -6
- package/src/v2/blocks/layout-options.tsx +80 -0
- package/src/v2/blocks/layout.tsx +349 -106
- package/src/v2/blocks/media.tsx +51 -21
- package/src/v2/blocks/resize.tsx +50 -19
- package/src/v2/blocks/social-icons.ts +22 -0
- package/src/v2/blocks/text.tsx +12 -50
- package/src/v2/blocks/theme.tsx +62 -29
- package/src/v2/blocks/tools.tsx +24 -2
- package/src/v2/blocks/widgets.tsx +84 -28
- package/src/v2/canvas/block-list.tsx +36 -5
- package/src/v2/canvas/canvas-css.ts +95 -7
- package/src/v2/canvas/canvas.tsx +65 -9
- package/src/v2/canvas/dnd.ts +7 -0
- package/src/v2/canvas/variation-picker.tsx +63 -0
- package/src/v2/context.tsx +48 -0
- package/src/v2/core/bindings.ts +6 -1
- package/src/v2/core/block-presets.ts +10 -0
- package/src/v2/core/clipboard.ts +5 -5
- package/src/v2/core/host.ts +3 -1
- package/src/v2/core/model.ts +6 -6
- package/src/v2/core/registry.ts +15 -0
- package/src/v2/core/store.ts +9 -9
- package/src/v2/core/structure.ts +1 -3
- package/src/v2/editor.css +74 -0
- package/src/v2/editor.tsx +22 -7
- package/src/v2/text/rich-text.tsx +20 -5
- package/src/v2/ui/ai-markdown.ts +52 -0
- package/src/v2/ui/ai.tsx +81 -14
- package/src/v2/ui/attr-form.tsx +45 -7
- package/src/v2/ui/attr-hints.ts +151 -19
- package/src/v2/ui/background-panel.tsx +22 -0
- package/src/v2/ui/bg-video-preview.tsx +7 -0
- package/src/v2/ui/bindings.tsx +9 -1
- package/src/v2/ui/block-icons.tsx +3 -10
- package/src/v2/ui/block-live-preview.tsx +21 -0
- package/src/v2/ui/block-style-panel.tsx +3 -1
- package/src/v2/ui/command-palette.tsx +125 -0
- package/src/v2/ui/icon-picker.tsx +88 -21
- package/src/v2/ui/icon-svg.tsx +21 -0
- package/src/v2/ui/inserter.tsx +72 -17
- package/src/v2/ui/inspector.tsx +12 -6
- package/src/v2/ui/layout-panel.tsx +1 -1
- package/src/v2/ui/motion-panel.tsx +22 -13
- package/src/v2/ui/option-thumbs.tsx +81 -0
- package/src/v2/ui/pattern-library.tsx +2 -1
- package/src/v2/ui/pattern-overrides.tsx +67 -0
- package/src/v2/ui/placeholders.tsx +21 -2
- package/src/v2/ui/preset-bar.tsx +5 -5
- package/src/v2/ui/style-supports.ts +2 -3
- package/src/v2/ui/style-tab.tsx +83 -20
- package/src/v2/ui/toolbar.tsx +40 -6
- package/src/v2/ui/transform-panel.tsx +77 -0
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { PLACE_TYPES, TRANSFORM_ORIGINS, normalizeStyle, type BlockStyle, type Device } from "@ecomcx/ecomweb-content";
|
|
2
|
+
import { useMsgs } from "../i18n";
|
|
3
|
+
import { Row, Section, Seg } from "./style-controls";
|
|
4
|
+
import { UnitInput } from "./unit-controls";
|
|
5
|
+
|
|
6
|
+
type Style = BlockStyle & Record<string, any>;
|
|
7
|
+
type Resp<T> = Partial<Record<Device, T>> | undefined;
|
|
8
|
+
|
|
9
|
+
/** Giá trị của khổ đang xem; chưa đặt thì hiện giá trị kế thừa (khổ lớn hơn) để người dùng biết đang thừa hưởng gì. */
|
|
10
|
+
const own = <T,>(r: Resp<T>, d: Device): T | undefined => r?.[d];
|
|
11
|
+
const inherit = <T,>(r: Resp<T>, d: Device): T | undefined => (d === "base" ? undefined : d === "mobile" ? r?.tablet ?? r?.base : r?.base);
|
|
12
|
+
const put = <T,>(r: Resp<T>, d: Device, v: T | undefined): Resp<T> => {
|
|
13
|
+
const next = { ...(r ?? {}) };
|
|
14
|
+
if (v === undefined) delete next[d]; else next[d] = v;
|
|
15
|
+
return Object.keys(next).length ? next : undefined;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Hai mục của tab Nâng cao: "Vị trí" (relative / absolute / fixed + lệch trên / phải / dưới / trái) và "Biến đổi" (xoay, phóng, nghiêng, dịch, điểm gốc).
|
|
20
|
+
* Mọi giá trị theo khổ màn hình đang chọn (ở đầu tab); khổ nhỏ chưa đặt thì kế thừa khổ lớn — như Elementor.
|
|
21
|
+
*/
|
|
22
|
+
export function PlaceTransformPanels({ style, device, commit }: { style: Style; device: Device; commit(next: Style): void }) {
|
|
23
|
+
const t = useMsgs("layout");
|
|
24
|
+
const place = style.place as Style["place"];
|
|
25
|
+
const tr = style.transform as Style["transform"];
|
|
26
|
+
const setPlace = (patch: Partial<NonNullable<Style["place"]>> | null) => commit({ ...style, place: patch === null ? undefined : { ...(place ?? { type: "relative" }), ...patch } as never });
|
|
27
|
+
const setTr = (patch: Partial<NonNullable<Style["transform"]>>) => {
|
|
28
|
+
const next = { ...(tr ?? {}), ...patch } as NonNullable<Style["transform"]>;
|
|
29
|
+
for (const k of Object.keys(next) as Array<keyof typeof next>) if (next[k] === undefined) delete next[k];
|
|
30
|
+
commit({ ...style, transform: Object.keys(next).length ? next : undefined } as never);
|
|
31
|
+
};
|
|
32
|
+
const num = (key: "rotate" | "scale" | "skewX" | "skewY", label: string, min: number, max: number, step: number, unit: string) => {
|
|
33
|
+
const v = own(tr?.[key], device), inh = inherit(tr?.[key], device);
|
|
34
|
+
const shown = v ?? inh ?? (key === "scale" ? 1 : 0);
|
|
35
|
+
return (
|
|
36
|
+
<Row key={key} label={label} device={device} onReset={v !== undefined ? () => setTr({ [key]: put(tr?.[key], device, undefined) }) : undefined}>
|
|
37
|
+
<div className="ecx-unit-row">
|
|
38
|
+
<input type="range" className="ecx-range" min={min} max={max} step={step} aria-label={label} value={shown} onChange={(e) => setTr({ [key]: put(tr?.[key], device, Number(e.target.value)) })} />
|
|
39
|
+
<span className="ecx-range-value">{shown}{unit}{v === undefined && inh !== undefined ? ` (${t.inheritedValue})` : ""}</span>
|
|
40
|
+
</div>
|
|
41
|
+
</Row>
|
|
42
|
+
);
|
|
43
|
+
};
|
|
44
|
+
const len = (key: "x" | "y", label: string) => (
|
|
45
|
+
<Row key={key} label={label} device={device}>
|
|
46
|
+
<UnitInput label={label} value={own(tr?.[key], device)} placeholder={inherit(tr?.[key], device)} max={300} onChange={(v) => setTr({ [key]: put(tr?.[key], device, v) })} />
|
|
47
|
+
</Row>
|
|
48
|
+
);
|
|
49
|
+
const side = (k: "top" | "right" | "bottom" | "left", label: string) => (
|
|
50
|
+
<Row key={k} label={label} device={device}>
|
|
51
|
+
<UnitInput label={`${t.placeTitle}: ${label}`} value={own(place?.[k], device)} placeholder={inherit(place?.[k], device)} max={400} onChange={(v) => setPlace({ [k]: put(place?.[k], device, v) })} />
|
|
52
|
+
</Row>
|
|
53
|
+
);
|
|
54
|
+
return (
|
|
55
|
+
<>
|
|
56
|
+
<Section title={t.placeTitle} modified={!!place} defaultOpen={!!place} onReset={() => setPlace(null)} summary={place ? (t as Record<string, string>)[`placeType${place.type[0].toUpperCase()}${place.type.slice(1)}`] : undefined}>
|
|
57
|
+
<Row label={t.placeType}>
|
|
58
|
+
<Seg label={t.placeType} value={place?.type} options={[...PLACE_TYPES.map((p): [typeof p, string, string] => { const l = (t as Record<string, string>)[`placeType${p[0].toUpperCase()}${p.slice(1)}`]; return [p, l, l]; })]} onChange={(v) => (v ? setPlace({ type: v }) : setPlace(null))} />
|
|
59
|
+
</Row>
|
|
60
|
+
{place && <>{side("top", t.placeTop)}{side("right", t.placeRight)}{side("bottom", t.placeBottom)}{side("left", t.placeLeft)}<p className="ecx-field-help">{place.type === "absolute" ? t.placeHelpAbsolute : place.type === "fixed" ? t.placeHelpFixed : t.placeHelpRelative}</p></>}
|
|
61
|
+
</Section>
|
|
62
|
+
<Section title={t.transformTitle} modified={!!tr} defaultOpen={!!tr} onReset={() => commit({ ...style, transform: undefined } as never)}>
|
|
63
|
+
{num("rotate", t.rotate, -180, 180, 1, "°")}
|
|
64
|
+
{num("scale", t.scale, 0.1, 3, 0.05, "×")}
|
|
65
|
+
{num("skewX", t.skewX, -45, 45, 1, "°")}
|
|
66
|
+
{num("skewY", t.skewY, -45, 45, 1, "°")}
|
|
67
|
+
{len("x", t.moveX)}
|
|
68
|
+
{len("y", t.moveY)}
|
|
69
|
+
<Row label={t.origin}>
|
|
70
|
+
<select className="ecx-input" aria-label={t.origin} value={tr?.origin ?? "center"} onChange={(e) => setTr({ origin: e.target.value === "center" ? undefined : e.target.value })}>
|
|
71
|
+
{TRANSFORM_ORIGINS.map((o) => <option key={o} value={o}>{(t as Record<string, string>)[`origin_${o.replace(" ", "_")}`]}</option>)}
|
|
72
|
+
</select>
|
|
73
|
+
</Row>
|
|
74
|
+
</Section>
|
|
75
|
+
</>
|
|
76
|
+
);
|
|
77
|
+
}
|