@ecomcx/ecomweb-editor 1.29.0 → 1.29.1
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/controls.ts +2 -0
- package/src/locales/en/hints.ts +1 -0
- package/src/locales/vi/controls.ts +2 -0
- package/src/locales/vi/hints.ts +1 -0
- package/src/v2/ui/attr-hints.ts +1 -0
- package/src/v2/ui/background-panel.tsx +5 -0
- package/src/v2/ui/inspector.tsx +1 -1
- package/src/v2/ui/unit-controls.tsx +7 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ecomcx/ecomweb-editor",
|
|
3
|
-
"version": "1.29.
|
|
3
|
+
"version": "1.29.1",
|
|
4
4
|
"description": "Trình soạn nội dung dạng khối của CMS — dùng độc lập trong mọi dự án React (1.x: TipTap; ./v2: cây khối, khung soạn iframe, sửa header/footer tại chỗ).",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"*.css"
|
|
30
30
|
],
|
|
31
31
|
"peerDependencies": {
|
|
32
|
-
"@ecomcx/ecomweb-content": "^1.23.
|
|
32
|
+
"@ecomcx/ecomweb-content": "^1.23.1",
|
|
33
33
|
"react": ">=18",
|
|
34
34
|
"react-dom": ">=18"
|
|
35
35
|
},
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"prosemirror-view": "1.42.7"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
|
-
"@ecomcx/ecomweb-content": "^1.23.
|
|
48
|
+
"@ecomcx/ecomweb-content": "^1.23.1",
|
|
49
49
|
"@playwright/test": "1.53.0",
|
|
50
50
|
"@types/react": "19.2.2",
|
|
51
51
|
"@types/react-dom": "19.2.2",
|
|
@@ -19,4 +19,6 @@ export const controls = {
|
|
|
19
19
|
sideLeft: "left",
|
|
20
20
|
styles: "Styles",
|
|
21
21
|
advanced: "Advanced",
|
|
22
|
+
/** Tên biến thể kiểu khối của lõi (CORE_BLOCK_STYLES). */
|
|
23
|
+
blockStyle: { stripes: "Stripes", rounded: "Rounded", circle: "Circle", plain: "Plain", dots: "Dots", wide: "Wide", pill: "Pill", card: "Card" },
|
|
22
24
|
};
|
package/src/locales/en/hints.ts
CHANGED
|
@@ -144,6 +144,7 @@ export const hints = {
|
|
|
144
144
|
"gallery.linkTo.opt.media": "Open full image",
|
|
145
145
|
"gallery.imageCrop.label": "Crop images to fit",
|
|
146
146
|
"gallery.lightbox.label": "Enlarge on click",
|
|
147
|
+
"image.lightbox.label": "Enlarge on click",
|
|
147
148
|
"countdown.expiredText.label": "Text when expired",
|
|
148
149
|
"navigation.overlayMenu.label": "Collapse into menu button",
|
|
149
150
|
"navigation.overlayMenu.opt.never": "Never",
|
|
@@ -19,4 +19,6 @@ export const controls = {
|
|
|
19
19
|
sideLeft: "trái",
|
|
20
20
|
styles: "Kiểu dáng",
|
|
21
21
|
advanced: "Nâng cao",
|
|
22
|
+
/** Tên biến thể kiểu khối của lõi (CORE_BLOCK_STYLES). */
|
|
23
|
+
blockStyle: { stripes: "Kẻ sọc", rounded: "Bo góc", circle: "Tròn", plain: "Đơn giản", dots: "Chấm", wide: "Rộng", pill: "Viên thuốc", card: "Thẻ" },
|
|
22
24
|
};
|
package/src/locales/vi/hints.ts
CHANGED
|
@@ -144,6 +144,7 @@ export const hints = {
|
|
|
144
144
|
"gallery.linkTo.opt.media": "Mở ảnh gốc",
|
|
145
145
|
"gallery.imageCrop.label": "Cắt ảnh cho đều khung",
|
|
146
146
|
"gallery.lightbox.label": "Phóng to khi bấm",
|
|
147
|
+
"image.lightbox.label": "Phóng to khi bấm",
|
|
147
148
|
"countdown.expiredText.label": "Chữ khi hết giờ",
|
|
148
149
|
"navigation.overlayMenu.label": "Thu gọn thành nút menu",
|
|
149
150
|
"navigation.overlayMenu.opt.never": "Không",
|
package/src/v2/ui/attr-hints.ts
CHANGED
|
@@ -145,6 +145,7 @@ export const ATTR_HINTS: Record<string, AttrHint> = {
|
|
|
145
145
|
"query.exclude": { label: true, when: notInherit },
|
|
146
146
|
"query.sticky": { control: "select", options: ["any", "only", "exclude"], when: notInherit },
|
|
147
147
|
"image.href": { label: true },
|
|
148
|
+
"image.lightbox": { label: true },
|
|
148
149
|
"image.linkTarget": { control: "segmented", label: true, options: ["_self", "_blank"] },
|
|
149
150
|
"orderedList.reversed": { label: true },
|
|
150
151
|
"blockquote.citation": { label: true },
|
|
@@ -15,6 +15,10 @@ const POSITIONS = ["0% 0%", "50% 0%", "100% 0%", "0% 50%", "50% 50%", "100% 50%"
|
|
|
15
15
|
export function BackgroundPanel({ style: raw, onChange, device }: { style: unknown; onChange(style: BlockStyle | null): void; device: Device }) {
|
|
16
16
|
const { host } = useEditor();
|
|
17
17
|
const t = useMsgs("background");
|
|
18
|
+
// Ảnh nền chỉ nhận đường dẫn tương đối hoặc https → URL media cùng website (site http) đổi thành "/uploads/…"
|
|
19
|
+
const sameOriginPath = (v: string) => {
|
|
20
|
+
try { const u = new URL(v, location.href); return u.origin === location.origin ? u.pathname + u.search : v; } catch { return v; }
|
|
21
|
+
};
|
|
18
22
|
const style: BlockStyle = normalizeStyle(raw) ?? {};
|
|
19
23
|
const bg: BlockBackground = style.background ?? {};
|
|
20
24
|
const [url, setUrl] = useState("");
|
|
@@ -24,6 +28,7 @@ export function BackgroundPanel({ style: raw, onChange, device }: { style: unkno
|
|
|
24
28
|
/** Giá trị theo khổ đang chọn (ảnh, cách phủ, điểm lấy nét). */
|
|
25
29
|
const setAt = (k: "image" | "size" | "position", v: string | undefined) => {
|
|
26
30
|
const r: Record<string, string | undefined> = { ...(bg[k] ?? {}) };
|
|
31
|
+
if (v && k === "image") v = sameOriginPath(v);
|
|
27
32
|
if (v) r[device] = v; else delete r[device];
|
|
28
33
|
set({ [k]: Object.keys(r).length ? r : undefined });
|
|
29
34
|
};
|
package/src/v2/ui/inspector.tsx
CHANGED
|
@@ -34,7 +34,7 @@ export function Inspector({ blockStyles }: { blockStyles?: Record<string, Array<
|
|
|
34
34
|
const setAttrs = (a: Record<string, unknown>) => store.setAttrs(ids, a);
|
|
35
35
|
const Custom = same && nodes.length === 1 ? type?.inspector : undefined;
|
|
36
36
|
const bindable = type?.bindable ?? CORE_BINDABLE[first.type];
|
|
37
|
-
const variants = [...(CORE_BLOCK_STYLES[first.type] ?? []).map((name) => ({ name, label: name })), ...(blockStyles?.[first.type] ?? [])];
|
|
37
|
+
const variants = [...(CORE_BLOCK_STYLES[first.type] ?? []).map((name) => ({ name, label: (t.blockStyle as Record<string, string>)[name] ?? name })), ...(blockStyles?.[first.type] ?? [])];
|
|
38
38
|
return (
|
|
39
39
|
<div className="ecx-inspector">
|
|
40
40
|
<div className="ecx-block-card">
|
|
@@ -15,6 +15,12 @@ const parse = (v: unknown): { n: string; unit: string } | null => {
|
|
|
15
15
|
const m = typeof v === "string" ? /^(-?\d*\.?\d+)(px|rem|em|%|vw|vh)?$/.exec(v.trim()) : typeof v === "number" ? [String(v), String(v), "px"] : null;
|
|
16
16
|
return m ? { n: m[1], unit: m[2] ?? "px" } : null;
|
|
17
17
|
};
|
|
18
|
+
/** Đổi đơn vị giữ nguyên cỡ thật: px ↔ rem / em theo 16px (22px → 1.375rem). %, vw, vh phụ thuộc khung chứa → giữ số. */
|
|
19
|
+
export const convertUnit = (n: string, from: string, to: string): string => {
|
|
20
|
+
const px = (u: string) => (u === "px" ? 1 : u === "rem" || u === "em" ? 16 : 0);
|
|
21
|
+
if (n === "" || !px(from) || !px(to) || !Number.isFinite(Number(n))) return n;
|
|
22
|
+
return String(Math.round((Number(n) * px(from)) / px(to) * 1000) / 1000);
|
|
23
|
+
};
|
|
18
24
|
|
|
19
25
|
export function UnitInput({ value, onChange, label, max = 100, units = UNITS, slider = true, placeholder }: { value?: string; onChange(v: string | undefined): void; label: string; max?: number; units?: string[]; slider?: boolean; placeholder?: string }) {
|
|
20
26
|
const t = useMsgs("controls");
|
|
@@ -29,7 +35,7 @@ export function UnitInput({ value, onChange, label, max = 100, units = UNITS, sl
|
|
|
29
35
|
<div className="ecx-unit-input">
|
|
30
36
|
<input type="number" inputMode="decimal" aria-label={label} value={n} placeholder={p ? undefined : value ?? placeholder ?? ""} step={unit === "px" || unit === "%" ? 1 : 0.1}
|
|
31
37
|
onChange={(e) => { setN(e.target.value); emit(e.target.value, unit); }} />
|
|
32
|
-
<select aria-label={`${label}: ${t.unit}`} value={unit} onChange={(e) => {
|
|
38
|
+
<select aria-label={`${label}: ${t.unit}`} value={unit} onChange={(e) => { const u = e.target.value, m = convertUnit(n, unit, u); setUnit(u); setN(m); if (m !== "") emit(m, u); }}>
|
|
33
39
|
{units.map((u) => <option key={u} value={u}>{u}</option>)}
|
|
34
40
|
</select>
|
|
35
41
|
</div>
|