@ecomcx/ecomweb-editor 1.31.0 → 1.33.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 +10 -0
- package/src/locales/en/background.ts +17 -0
- package/src/locales/en/bindings.ts +1 -1
- package/src/locales/en/block-desc.ts +2 -0
- package/src/locales/en/block-style.ts +7 -4
- package/src/locales/en/block-titles.ts +2 -0
- package/src/locales/en/blocks.ts +12 -3
- package/src/locales/en/columns.ts +12 -0
- package/src/locales/en/controls.ts +21 -0
- package/src/locales/en/hints.ts +289 -1
- package/src/locales/en/index.ts +5 -2
- package/src/locales/en/layout.ts +32 -0
- package/src/locales/en/legacy.ts +1 -1
- package/src/locales/en/library.ts +38 -0
- package/src/locales/en/parts.ts +12 -0
- package/src/locales/en/placeholders.ts +12 -1
- package/src/locales/en/presets.ts +6 -0
- package/src/locales/en/v2.ts +21 -0
- package/src/locales/vi/attrs.ts +10 -0
- package/src/locales/vi/background.ts +17 -0
- package/src/locales/vi/bindings.ts +1 -1
- package/src/locales/vi/block-desc.ts +2 -0
- package/src/locales/vi/block-style.ts +7 -4
- package/src/locales/vi/block-titles.ts +2 -0
- package/src/locales/vi/blocks.ts +12 -3
- package/src/locales/vi/columns.ts +12 -0
- package/src/locales/vi/controls.ts +21 -0
- package/src/locales/vi/hints.ts +290 -2
- package/src/locales/vi/index.ts +5 -2
- package/src/locales/vi/layout.ts +32 -0
- package/src/locales/vi/legacy.ts +1 -1
- package/src/locales/vi/library.ts +38 -0
- package/src/locales/vi/parts.ts +12 -0
- package/src/locales/vi/placeholders.ts +12 -1
- package/src/locales/vi/presets.ts +6 -0
- package/src/locales/vi/v2.ts +21 -0
- package/src/shared/panel-store.ts +3 -3
- package/src/shared/patterns.ts +3 -52
- package/src/shared/style-panel.tsx +2 -2
- package/src/shared/types.ts +2 -0
- package/src/v2/blocks/columns-inspector.tsx +210 -0
- package/src/v2/blocks/form.tsx +4 -4
- package/src/v2/blocks/index.ts +10 -4
- package/src/v2/blocks/inline-style.ts +1 -1
- package/src/v2/blocks/layout.tsx +211 -44
- package/src/v2/blocks/media.tsx +22 -13
- package/src/v2/blocks/resize.tsx +172 -4
- package/src/v2/blocks/text.tsx +14 -7
- package/src/v2/blocks/theme.tsx +63 -19
- package/src/v2/blocks/tools.tsx +50 -5
- package/src/v2/blocks/widgets.tsx +44 -16
- package/src/v2/canvas/block-list.tsx +23 -3
- package/src/v2/canvas/canvas-css.ts +70 -4
- package/src/v2/canvas/canvas.tsx +22 -5
- package/src/v2/canvas/dnd.ts +34 -3
- package/src/v2/canvas/move-animation.ts +94 -0
- package/src/v2/canvas/spacing-viz.ts +51 -0
- package/src/v2/core/block-presets.ts +68 -0
- package/src/v2/core/host.ts +6 -1
- package/src/v2/core/structure.ts +2 -1
- package/src/v2/editor.css +238 -9
- package/src/v2/editor.tsx +8 -2
- package/src/v2/ui/attr-form.tsx +59 -12
- package/src/v2/ui/attr-hints.ts +140 -9
- package/src/v2/ui/background-panel.tsx +65 -21
- package/src/v2/ui/bindings.tsx +3 -0
- package/src/v2/ui/block-icons.tsx +152 -0
- package/src/v2/ui/block-menu.ts +22 -0
- package/src/v2/ui/block-style-panel.tsx +14 -3
- package/src/v2/ui/color-field.tsx +74 -9
- package/src/v2/ui/divider-panel.tsx +58 -0
- package/src/v2/ui/group-width.tsx +38 -0
- package/src/v2/ui/icon-picker.tsx +51 -0
- package/src/v2/ui/inserter.tsx +61 -12
- package/src/v2/ui/inspector.tsx +48 -16
- package/src/v2/ui/layout-panel.tsx +5 -47
- package/src/v2/ui/list-view.tsx +81 -7
- package/src/v2/ui/motion-panel.tsx +2 -1
- package/src/v2/ui/parts-panel.tsx +164 -0
- package/src/v2/ui/pattern-library.tsx +228 -0
- package/src/v2/ui/preset-bar.tsx +83 -0
- package/src/v2/ui/style-controls.tsx +65 -15
- package/src/v2/ui/style-supports.ts +1 -1
- package/src/v2/ui/style-tab.tsx +127 -41
- package/src/v2/ui/toolbar.tsx +52 -13
- package/src/v2/ui/unit-controls.tsx +88 -39
- package/src/locales/en/patterns.ts +0 -50
- package/src/locales/vi/patterns.ts +0 -50
- package/src/shared/patterns-kit.ts +0 -7
- package/src/shared/patterns-library.ts +0 -172
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tô vùng đệm (padding — bên trong khối) hoặc lề (margin — bên ngoài khối) của một khối trên khung soạn, kèm giá trị:
|
|
3
|
+
* rê chuột lên ô cạnh ở bảng bên phải → thấy ngay vùng đó trên khối. Lớp phủ riêng (position: fixed trong iframe), không đổi HTML của khối.
|
|
4
|
+
*/
|
|
5
|
+
export type SpacingKind = "padding" | "margin";
|
|
6
|
+
export type Side = "top" | "right" | "bottom" | "left";
|
|
7
|
+
const SIDES: Side[] = ["top", "right", "bottom", "left"];
|
|
8
|
+
const CLS = "ecx-spacing-viz";
|
|
9
|
+
|
|
10
|
+
export function hideSpacingViz(doc: Document | null | undefined) {
|
|
11
|
+
doc?.querySelectorAll(`.${CLS}`).forEach((n) => n.remove());
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/** Hình chữ nhật của từng cạnh (toạ độ khung nhìn của iframe). */
|
|
15
|
+
export function spacingRects(r: { left: number; top: number; right: number; bottom: number; width: number; height: number }, px: Record<Side, number>, kind: SpacingKind) {
|
|
16
|
+
const out: Record<Side, { left: number; top: number; width: number; height: number }> = {} as never;
|
|
17
|
+
if (kind === "padding") {
|
|
18
|
+
out.top = { left: r.left, top: r.top, width: r.width, height: px.top };
|
|
19
|
+
out.bottom = { left: r.left, top: r.bottom - px.bottom, width: r.width, height: px.bottom };
|
|
20
|
+
out.left = { left: r.left, top: r.top + px.top, width: px.left, height: Math.max(0, r.height - px.top - px.bottom) };
|
|
21
|
+
out.right = { left: r.right - px.right, top: r.top + px.top, width: px.right, height: Math.max(0, r.height - px.top - px.bottom) };
|
|
22
|
+
} else {
|
|
23
|
+
out.top = { left: r.left - px.left, top: r.top - px.top, width: r.width + px.left + px.right, height: px.top };
|
|
24
|
+
out.bottom = { left: r.left - px.left, top: r.bottom, width: r.width + px.left + px.right, height: px.bottom };
|
|
25
|
+
out.left = { left: r.left - px.left, top: r.top, width: px.left, height: r.height };
|
|
26
|
+
out.right = { left: r.right, top: r.top, width: px.right, height: r.height };
|
|
27
|
+
}
|
|
28
|
+
return out;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/** Vẽ lớp tô cho các cạnh `sides` (rỗng = cả 4). `names`: tên bậc hiện cạnh giá trị px (vd "MD · 20px"). */
|
|
32
|
+
export function showSpacingViz(el: HTMLElement | null, kind: SpacingKind, sides: Side[] = SIDES, names: Partial<Record<Side, string>> = {}) {
|
|
33
|
+
if (!el) return;
|
|
34
|
+
const doc = el.ownerDocument;
|
|
35
|
+
hideSpacingViz(doc);
|
|
36
|
+
const cs = doc.defaultView!.getComputedStyle(el);
|
|
37
|
+
const px = Object.fromEntries(SIDES.map((s) => [s, parseFloat(cs.getPropertyValue(`${kind}-${s}`)) || 0])) as Record<Side, number>;
|
|
38
|
+
const rects = spacingRects(el.getBoundingClientRect(), px, kind);
|
|
39
|
+
for (const s of sides.length ? sides : SIDES) {
|
|
40
|
+
const r = rects[s];
|
|
41
|
+
const box = doc.createElement("div");
|
|
42
|
+
box.className = `${CLS} is-${kind}`;
|
|
43
|
+
Object.assign(box.style, { left: `${r.left}px`, top: `${r.top}px`, width: `${Math.max(0, r.width)}px`, height: `${Math.max(0, r.height)}px` });
|
|
44
|
+
if (px[s] >= 1) {
|
|
45
|
+
const tag = doc.createElement("span");
|
|
46
|
+
tag.textContent = names[s] ? `${names[s]} · ${Math.round(px[s])}px` : `${Math.round(px[s])}px`;
|
|
47
|
+
box.appendChild(tag);
|
|
48
|
+
}
|
|
49
|
+
doc.body.appendChild(box);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import type { BlockControls } from "@ecomcx/ecomweb-content";
|
|
2
|
+
import type { BNode } from "./model";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Kiểu đặt sẵn + mặc định khi chèn của từng loại khối (toàn website, host.blockPresets):
|
|
6
|
+
* { "<loại>": { default?: attrs, presets?: [{ name, attrs }] } }. Chỉ chứa thuộc tính KIỂU (style, parts, biến thể, ô kiểu dáng của khối),
|
|
7
|
+
* không chứa nội dung (chữ, ảnh, liên kết) — "Mặc định của khối" không đổi khối đã có, không lưu nội dung.
|
|
8
|
+
*/
|
|
9
|
+
export interface BlockPreset { name: string; attrs: Record<string, unknown> }
|
|
10
|
+
export interface BlockPresetEntry { default?: Record<string, unknown>; presets?: BlockPreset[] }
|
|
11
|
+
export type BlockPresetMap = Record<string, BlockPresetEntry>;
|
|
12
|
+
|
|
13
|
+
/** Thuộc tính kiểu chung của mọi khối. */
|
|
14
|
+
const COMMON = ["style", "parts", "blockStyle"];
|
|
15
|
+
|
|
16
|
+
/** Tên thuộc tính kiểu của một loại khối: chung + ô điều khiển khai CSS (lõi + plugin). */
|
|
17
|
+
export function styleKeys(type: string, controls: readonly BlockControls[]): string[] {
|
|
18
|
+
const own = controls.filter((c) => c.blocks === "*" || c.blocks.includes(type)).flatMap((c) => Object.keys(c.attributes));
|
|
19
|
+
return [...new Set([...COMMON, ...own])];
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/** Lấy phần kiểu của attrs (bỏ ô trống). */
|
|
23
|
+
export function pickStyle(attrs: Record<string, unknown>, keys: string[]): Record<string, unknown> {
|
|
24
|
+
const out: Record<string, unknown> = {};
|
|
25
|
+
for (const k of keys) if (attrs[k] !== undefined && attrs[k] !== null && attrs[k] !== "") out[k] = attrs[k];
|
|
26
|
+
return out;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/** Áp một bộ kiểu: xoá mọi thuộc tính kiểu đang có rồi đặt theo bộ kiểu (nội dung giữ nguyên). */
|
|
30
|
+
export function applyStyle(keys: string[], style: Record<string, unknown>): Record<string, unknown> {
|
|
31
|
+
const patch: Record<string, unknown> = {};
|
|
32
|
+
for (const k of keys) patch[k] = style[k];
|
|
33
|
+
return patch;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/** So sánh hai bộ kiểu (thứ tự khoá không quan trọng). */
|
|
37
|
+
export const sameStyle = (a: Record<string, unknown>, b: Record<string, unknown>) => stable(a) === stable(b);
|
|
38
|
+
function stable(v: unknown): string {
|
|
39
|
+
if (v && typeof v === "object" && !Array.isArray(v)) return `{${Object.keys(v).sort().map((k) => `${JSON.stringify(k)}:${stable((v as Record<string, unknown>)[k])}`).join(",")}}`;
|
|
40
|
+
if (Array.isArray(v)) return `[${v.map(stable).join(",")}]`;
|
|
41
|
+
return JSON.stringify(v);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/** Khối mới chèn: thêm kiểu mặc định của loại khối (chỉ thuộc tính chưa có — mẫu / biến thể đã đặt thì giữ). */
|
|
45
|
+
export function withDefaults(node: BNode, map: BlockPresetMap | null): BNode {
|
|
46
|
+
const def = map?.[node.type]?.default;
|
|
47
|
+
if (!def) return node;
|
|
48
|
+
const attrs = { ...node.attrs };
|
|
49
|
+
for (const [k, v] of Object.entries(def)) if (attrs[k] === undefined) attrs[k] = v;
|
|
50
|
+
return { ...node, attrs };
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// Kho trong bộ nhớ (một lần nạp mỗi phiên soạn); UI đăng ký nghe thay đổi
|
|
54
|
+
let current: BlockPresetMap | null = null;
|
|
55
|
+
let loading: Promise<void> | null = null;
|
|
56
|
+
const listeners = new Set<() => void>();
|
|
57
|
+
export const presetsSnapshot = () => current;
|
|
58
|
+
export const onPresetsChange = (l: () => void) => { listeners.add(l); return () => { listeners.delete(l); }; };
|
|
59
|
+
export function setPresets(m: BlockPresetMap | null) { current = m; listeners.forEach((l) => l()); }
|
|
60
|
+
export function ensurePresets(load?: () => Promise<Record<string, unknown>>) {
|
|
61
|
+
if (current || loading || !load) return;
|
|
62
|
+
loading = load().then((m) => setPresets((m ?? {}) as BlockPresetMap), () => setPresets({})).finally(() => { loading = null; });
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/** Như withDefaults cho kết quả tạo khối (một khối hoặc mẫu nhiều khối). */
|
|
66
|
+
export function freshWithDefaults<T extends BNode | BNode[]>(made: T): T {
|
|
67
|
+
return (Array.isArray(made) ? made.map((n) => withDefaults(n, current)) : withDefaults(made, current)) as T;
|
|
68
|
+
}
|
package/src/v2/core/host.ts
CHANGED
|
@@ -45,6 +45,11 @@ export interface EditorHost {
|
|
|
45
45
|
scope?: "template" | "content";
|
|
46
46
|
/** Preset của theme (biến --ecx-*). */
|
|
47
47
|
presets?: StylePresets;
|
|
48
|
+
/**
|
|
49
|
+
* v3: kiểu đặt sẵn + mặc định khi chèn của từng loại khối (toàn website). `save` không có = người dùng không có quyền lưu (chỉ chọn kiểu).
|
|
50
|
+
* Dạng dữ liệu: core/block-presets BlockPresetMap.
|
|
51
|
+
*/
|
|
52
|
+
blockPresets?: { load(): Promise<Record<string, unknown>>; save?(map: Record<string, unknown>): Promise<Record<string, unknown>> };
|
|
48
53
|
/** Chữ "%khoá%" của plugin → chữ theo ngôn ngữ. */
|
|
49
54
|
translate?(text: string): string;
|
|
50
55
|
/**
|
|
@@ -97,7 +102,7 @@ export interface DocumentHost {
|
|
|
97
102
|
export type DynamicPost = { title?: string; date?: string; author?: string; excerpt?: string; image?: string | null; terms?: string[]; /** Chuyên mục đầu tiên (breadcrumb như website); không có = bài/trang không thuộc chuyên mục nào. */ category?: string; comments?: number; link?: string; /** Nội dung đã lưu của bài (ContentDoc) — khối "Nội dung bài" trong template vẽ nội dung thật thay vì khung giữ chỗ. */ content?: unknown };
|
|
98
103
|
|
|
99
104
|
/** Thiết lập của khối "Danh sách bài" (attrs của query). */
|
|
100
|
-
export interface QueryArgs { inherit: boolean; postType: string; perPage: number; category?: string; tag?: string; orderBy: string; order: "asc" | "desc" }
|
|
105
|
+
export interface QueryArgs { inherit: boolean; postType: string; perPage: number; category?: string; tag?: string; taxonomy?: string; term?: string; orderBy: string; order: "asc" | "desc" }
|
|
101
106
|
|
|
102
107
|
export type ChoiceKind = "menuLocation" | "postType" | "taxonomy" | "term" | "templatePart" | "imageSize";
|
|
103
108
|
export interface Choice { value: string; label: string }
|
package/src/v2/core/structure.ts
CHANGED
|
@@ -28,7 +28,8 @@ const RULES: Record<string, StructureRule> = {
|
|
|
28
28
|
listItem: { parents: ["bulletList", "orderedList"], wrapSelfWith: "bulletList", required: p, firstChild: "paragraph" },
|
|
29
29
|
taskList: { allowedChildren: ["taskItem"], wrapChildrenWith: "taskItem", removeWhenEmpty: true },
|
|
30
30
|
taskItem: { parents: ["taskList"], wrapSelfWith: "taskList", required: p, firstChild: "paragraph" },
|
|
31
|
-
|
|
31
|
+
// Bộ cột rỗng (vừa chèn, chưa chọn bố cục) giữ lại như bảng rỗng: trình soạn hiện lưới chọn bố cục cột
|
|
32
|
+
columns: { allowedChildren: ["column"], wrapChildrenWith: "column" },
|
|
32
33
|
column: { parents: ["columns"], wrapSelfWith: "columns" },
|
|
33
34
|
buttons: { allowedChildren: ["button"], removeWhenEmpty: true },
|
|
34
35
|
button: { parents: ["buttons"], wrapSelfWith: "buttons" },
|
package/src/v2/editor.css
CHANGED
|
@@ -25,6 +25,8 @@
|
|
|
25
25
|
.ecx-editor :focus-visible { outline: 2px solid var(--ecx-ed-accent); outline-offset: 1px; }
|
|
26
26
|
.ecx-icon { width: 16px; height: 16px; flex: none; }
|
|
27
27
|
.ecx-icon-sm { width: 14px; height: 14px; }
|
|
28
|
+
/* Icon 2 lớp của khối (block-icons.tsx): đặc = màu nhấn, nền = màu nhấn nhạt */
|
|
29
|
+
.ecx-duo { --ecx-ico-a: var(--ecx-ed-accent); --ecx-ico-b: color-mix(in srgb, var(--ecx-ed-accent) 22%, transparent); --ecx-ico-w: var(--ecx-ed-panel); }
|
|
28
30
|
.ecx-muted { color: var(--ecx-ed-muted); margin: 0; font-size: 12px; }
|
|
29
31
|
@keyframes ecx-pop { from { opacity: 0; transform: translateY(4px) scale(.98); } to { opacity: 1; transform: none; } }
|
|
30
32
|
@keyframes ecx-slide-r { from { transform: translateX(-12px); opacity: 0; } to { transform: none; opacity: 1; } }
|
|
@@ -34,7 +36,7 @@
|
|
|
34
36
|
.ecx-topbar { display: flex; align-items: center; justify-content: space-between; gap: 8px; height: 52px; padding: 0 10px; border-bottom: 1px solid var(--ecx-ed-line); background: var(--ecx-ed-panel); flex: none; }
|
|
35
37
|
.ecx-topbar-start, .ecx-topbar-end { display: flex; align-items: center; gap: 4px; min-width: 0; }
|
|
36
38
|
.ecx-topbar .ecx-tool-group { gap: 2px; padding: 2px; border-radius: 8px; background: var(--ecx-ed-subtle); }
|
|
37
|
-
.ecx-body { display: flex; flex: 1; min-height: 0; position: relative; }
|
|
39
|
+
.ecx-body { display: flex; flex: 1; min-height: 0; position: relative; overflow-x: clip; } /* bảng bên trượt vào (translateX) không làm trang tràn ngang lúc đầu */
|
|
38
40
|
.ecx-left { width: 300px; flex: none; border-right: 1px solid var(--ecx-ed-line); overflow: auto; background: var(--ecx-ed-panel); animation: ecx-slide-r .2s var(--ecx-ed-ease); }
|
|
39
41
|
.ecx-right { width: 296px; flex: none; border-left: 1px solid var(--ecx-ed-line); overflow: auto; background: var(--ecx-ed-panel); animation: ecx-slide-l .2s var(--ecx-ed-ease); }
|
|
40
42
|
.ecx-main { flex: 1; min-width: 0; display: flex; background: var(--ecx-ed-bg); }
|
|
@@ -49,6 +51,20 @@
|
|
|
49
51
|
.ecx-right, .ecx-left { position: absolute; top: 0; bottom: 0; z-index: 20; box-shadow: var(--ecx-ed-shadow); }
|
|
50
52
|
.ecx-right { right: 0; } .ecx-left { left: 0; }
|
|
51
53
|
}
|
|
54
|
+
/* Điện thoại: thanh trên cuộn ngang (không tràn trang, không chồng nút), bảng hai bên rộng tối đa 92% màn hình */
|
|
55
|
+
@media (max-width: 640px) {
|
|
56
|
+
.ecx-topbar { padding: 0 6px; gap: 6px; overflow-x: auto; overflow-y: hidden; scrollbar-width: none; justify-content: flex-start; }
|
|
57
|
+
.ecx-topbar::-webkit-scrollbar { display: none; }
|
|
58
|
+
.ecx-topbar-start, .ecx-topbar-end { flex: none; }
|
|
59
|
+
.ecx-topbar-end { margin-left: auto; }
|
|
60
|
+
.ecx-topbar-start > :first-child { white-space: nowrap; }
|
|
61
|
+
.ecx-right, .ecx-left { width: min(92vw, 340px); }
|
|
62
|
+
/* Rút gọn để nút Lưu luôn thấy: bỏ nhóm đổi khổ (trên điện thoại xem thử bằng chính màn hình) và chữ của nút Thư viện mẫu */
|
|
63
|
+
.ecx-topbar .ecx-tool-group[aria-label] { display: none; }
|
|
64
|
+
.ecx-topbar .ecx-lib-open { font-size: 0; gap: 0; padding: 0 8px; }
|
|
65
|
+
.ecx-topbar .ecx-lib-open svg { font-size: 14px; }
|
|
66
|
+
.ecx-topbar-end { position: sticky; right: 0; background: var(--ecx-ed-panel); padding-left: 6px; }
|
|
67
|
+
}
|
|
52
68
|
|
|
53
69
|
/* Nút */
|
|
54
70
|
.ecx-tool { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-width: 32px; height: 32px; padding: 0 8px; border: 0; border-radius: 6px;
|
|
@@ -119,6 +135,7 @@
|
|
|
119
135
|
.ecx-block-tile { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 12px 4px 10px; border: 1px solid transparent; border-radius: 8px; background: none; color: var(--ecx-ed-fg);
|
|
120
136
|
font: inherit; font-size: 12px; line-height: 1.3; text-align: center; cursor: pointer; touch-action: none; user-select: none; transition: background-color .12s ease, border-color .12s ease; }
|
|
121
137
|
.ecx-block-tile .ecx-icon { width: 22px; height: 22px; color: var(--ecx-ed-muted); }
|
|
138
|
+
.ecx-block-tile .ecx-icon.ecx-duo { width: 28px; height: 28px; }
|
|
122
139
|
.ecx-block-tile:hover { background: var(--ecx-ed-hover); border-color: var(--ecx-ed-line); }
|
|
123
140
|
.ecx-block-tile:hover .ecx-icon { color: var(--ecx-ed-accent); }
|
|
124
141
|
.ecx-pattern-card { display: flex; flex-direction: column; gap: 2px; width: 100%; margin-bottom: 6px; padding: 10px 12px; border: 1px solid var(--ecx-ed-line); border-radius: 8px; background: var(--ecx-ed-panel);
|
|
@@ -130,7 +147,7 @@
|
|
|
130
147
|
.ecx-inspector.is-empty { padding-top: 24px; }
|
|
131
148
|
.ecx-block-card { display: flex; gap: 10px; align-items: flex-start; }
|
|
132
149
|
.ecx-card-icon { width: 32px; height: 32px; padding: 7px; border-radius: 8px; background: var(--ecx-ed-accent-soft); color: var(--ecx-ed-accent); }
|
|
133
|
-
.ecx-block-card strong { display: block; font-size:
|
|
150
|
+
.ecx-block-card strong { display: block; font-size: 14px; font-weight: 600; margin: 0; }
|
|
134
151
|
.ecx-tabs { display: flex; gap: 2px; margin: 0 -16px; padding: 0 16px; border-bottom: 1px solid var(--ecx-ed-line); }
|
|
135
152
|
.ecx-tabs button { position: relative; flex: 1; height: 40px; border: 0; background: none; font: inherit; font-weight: 500; color: var(--ecx-ed-muted); cursor: pointer; }
|
|
136
153
|
.ecx-tabs button:hover { color: var(--ecx-ed-fg); }
|
|
@@ -144,6 +161,8 @@
|
|
|
144
161
|
select.ecx-input { padding-right: 6px; }
|
|
145
162
|
.ecx-check { display: flex; align-items: center; gap: 8px; cursor: pointer; }
|
|
146
163
|
.ecx-check input { accent-color: var(--ecx-ed-accent); width: 15px; height: 15px; }
|
|
164
|
+
/* Ô nhập nhỏ trong menu của thanh công cụ (vd liên kết của nút) */
|
|
165
|
+
.ecx-tool-form { display: grid; gap: 8px; width: 280px; padding: 8px; }
|
|
147
166
|
.ecx-color-row { display: flex; gap: 6px; align-items: center; }
|
|
148
167
|
.ecx-color-row input[type="color"] { width: 32px; height: 32px; padding: 2px; border: 1px solid var(--ecx-ed-line); border-radius: 6px; background: var(--ecx-ed-panel); }
|
|
149
168
|
.ecx-advanced { display: flex; flex-direction: column; gap: 12px; border-top: 1px solid var(--ecx-ed-line); padding-top: 10px; }
|
|
@@ -170,6 +189,33 @@ select.ecx-input { padding-right: 6px; }
|
|
|
170
189
|
.ecx-twisty { display: inline-flex; align-items: center; justify-content: center; width: 20px; height: 20px; padding: 0; border: 0; border-radius: 4px; background: none; color: var(--ecx-ed-muted); cursor: pointer; flex: none; }
|
|
171
190
|
.ecx-twisty:hover { background: var(--ecx-ed-hover); }
|
|
172
191
|
.ecx-twisty .ecx-icon { width: 14px; height: 14px; }
|
|
192
|
+
.ecx-list-menu { display: inline-flex; align-items: center; justify-content: center; width: 22px; height: 22px; margin-left: auto; padding: 0; border: 0; border-radius: 4px; background: none; color: inherit; cursor: pointer; opacity: 0; }
|
|
193
|
+
.ecx-list-row:hover .ecx-list-menu, .ecx-list-row.is-selected .ecx-list-menu, .ecx-list-menu:focus-visible { opacity: 1; }
|
|
194
|
+
.ecx-list-menu:hover { background: var(--ecx-ed-hover); }
|
|
195
|
+
.ecx-left-tabs { position: sticky; top: 0; z-index: 1; margin: 0; padding: 0 4px 0 8px; background: var(--ecx-ed-panel); }
|
|
196
|
+
.ecx-left-tabs button[role=tab] { flex: none; padding: 0 10px; }
|
|
197
|
+
.ecx-left-close { display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; margin: 4px 0 4px auto; border: 0; border-radius: 6px; background: none; color: var(--ecx-ed-muted); cursor: pointer; }
|
|
198
|
+
.ecx-left-close:hover { background: var(--ecx-ed-hover); color: var(--ecx-ed-fg); }
|
|
199
|
+
.ecx-tabs .ecx-left-close { flex: none; height: 32px; }
|
|
200
|
+
.ecx-tablist { display: flex; flex: 1; gap: 2px; }
|
|
201
|
+
.ecx-left-tabs .ecx-tablist { flex: none; }
|
|
202
|
+
.ecx-outline { padding: 12px 16px; }
|
|
203
|
+
.ecx-outline-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 0 0 14px; }
|
|
204
|
+
.ecx-outline-stats div { padding: 8px; border-radius: 8px; background: var(--ecx-ed-subtle); }
|
|
205
|
+
.ecx-outline-stats dt { font-size: 11px; color: var(--ecx-ed-muted); }
|
|
206
|
+
.ecx-outline-stats dd { margin: 2px 0 0; font-weight: 600; }
|
|
207
|
+
.ecx-outline-heads { list-style: none; margin: 0; padding: 0; }
|
|
208
|
+
.ecx-outline-heads button { display: flex; align-items: baseline; gap: 6px; width: 100%; padding: 5px 6px; border: 0; border-radius: 6px; background: none; color: inherit; font: inherit; text-align: left; cursor: pointer; }
|
|
209
|
+
.ecx-outline-heads button:hover { background: var(--ecx-ed-hover); }
|
|
210
|
+
.ecx-outline-level { flex: none; font: 600 11px var(--ecx-ed-font); color: var(--ecx-ed-muted); }
|
|
211
|
+
.ecx-outline-warn { font-size: 11px; font-style: normal; color: var(--ecx-ed-danger, #b42318); }
|
|
212
|
+
.ecx-media-kinds { margin: 4px 0 10px; }
|
|
213
|
+
.ecx-media-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
|
|
214
|
+
.ecx-media-grid.is-files { grid-template-columns: 1fr; }
|
|
215
|
+
.ecx-media-item { display: block; aspect-ratio: 1; padding: 0; overflow: hidden; border: 1px solid var(--ecx-ed-line); border-radius: 8px; background: var(--ecx-ed-subtle); cursor: pointer; }
|
|
216
|
+
.ecx-media-grid.is-files .ecx-media-item { aspect-ratio: auto; padding: 8px 10px; text-align: left; font: inherit; color: inherit; overflow-wrap: anywhere; }
|
|
217
|
+
.ecx-media-item:hover, .ecx-media-item:focus-visible { border-color: var(--ecx-ed-accent); }
|
|
218
|
+
.ecx-media-item img { width: 100%; height: 100%; object-fit: cover; display: block; }
|
|
173
219
|
.ecx-list-drag { opacity: 0; cursor: grab; touch-action: none; display: inline-flex; color: var(--ecx-ed-faint); }
|
|
174
220
|
.ecx-list-row:hover .ecx-list-drag { opacity: 1; }
|
|
175
221
|
|
|
@@ -248,10 +294,58 @@ body.is-dragging, body.is-dragging * { cursor: grabbing !important; user-select:
|
|
|
248
294
|
/* Bố cục, nền & hiệu ứng, hover (tab Kiểu dáng) */
|
|
249
295
|
.ecx-layout-panel { display: flex; flex-direction: column; border-top: 1px solid var(--ecx-ed-line); margin-top: 4px; }
|
|
250
296
|
.ecx-style-section { border-bottom: 1px solid var(--ecx-ed-line); }
|
|
251
|
-
.ecx-style-section-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; height:
|
|
252
|
-
.ecx-style-section-toggle { display: flex; align-items: center; gap:
|
|
253
|
-
.ecx-
|
|
297
|
+
.ecx-style-section-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 44px; }
|
|
298
|
+
.ecx-style-section-toggle { display: flex; align-items: center; gap: 8px; flex: 1; min-width: 0; min-height: 44px; padding: 0; border: 0; background: none; color: var(--ecx-ed-fg); font: inherit; font-weight: 600; cursor: pointer; text-align: left; transition: color .05s linear; }
|
|
299
|
+
.ecx-style-section-toggle:hover { color: var(--ecx-ed-accent); }
|
|
300
|
+
.ecx-style-section-title { display: inline-flex; align-items: center; gap: 6px; flex: none; }
|
|
301
|
+
.ecx-style-section-title .ecx-dot { background: #e8890c; }
|
|
302
|
+
/* Mục gập: một dòng tóm tắt bên phải tiêu đề (vd "Chưa có hiệu ứng") */
|
|
303
|
+
.ecx-style-section-summary { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: right; font-weight: 400; font-size: 12px; color: var(--ecx-ed-muted); }
|
|
304
|
+
.ecx-chevron { margin-left: auto; flex: none; color: var(--ecx-ed-muted); transition: transform .15s var(--ecx-ed-ease); }
|
|
254
305
|
.ecx-chevron.is-open { transform: rotate(90deg); }
|
|
306
|
+
/* Hàng điều khiển: nhãn · ↶ · (công cụ) · cụm khổ màn hình */
|
|
307
|
+
.ecx-row-head { display: flex; align-items: center; gap: 4px; min-height: 20px; }
|
|
308
|
+
.ecx-row-head .ecx-field-label { flex: none; }
|
|
309
|
+
.ecx-row-tools { display: inline-flex; align-items: center; gap: 4px; margin-left: auto; }
|
|
310
|
+
.ecx-row-reset { display: inline-grid; place-items: center; width: 18px; height: 18px; padding: 0; border: 0; border-radius: 4px; background: none; color: #e8890c; cursor: pointer; }
|
|
311
|
+
.ecx-row-reset:hover { background: var(--ecx-ed-subtle); }
|
|
312
|
+
.ecx-row-reset .ecx-icon { width: 12px; height: 12px; }
|
|
313
|
+
.ecx-field-wrap { position: relative; }
|
|
314
|
+
.ecx-field-reset { position: absolute; top: 0; right: 0; }
|
|
315
|
+
.ecx-row-devices { display: inline-flex; gap: 1px; }
|
|
316
|
+
.ecx-row-devices button { display: inline-grid; place-items: center; width: 20px; height: 18px; padding: 0; border: 0; border-radius: 4px; background: none; color: var(--ecx-ed-faint, #a3adb7); cursor: pointer; transition: color .05s linear; }
|
|
317
|
+
.ecx-row-devices button:hover { background: var(--ecx-ed-subtle); color: var(--ecx-ed-fg); }
|
|
318
|
+
.ecx-row-devices button.is-active { color: var(--ecx-ed-accent); }
|
|
319
|
+
.ecx-row-devices .ecx-icon { width: 13px; height: 13px; }
|
|
320
|
+
/* Ô màu gọn + bảng màu */
|
|
321
|
+
.ecx-color-field { position: relative; }
|
|
322
|
+
.ecx-color-row-btn { display: flex; align-items: center; gap: 10px; width: 100%; height: 36px; padding: 0 10px; border: 1px solid var(--ecx-ed-line); border-radius: 8px; background: var(--ecx-ed-panel); color: var(--ecx-ed-fg); font: inherit; cursor: pointer; text-align: left; transition: border-color .05s linear; }
|
|
323
|
+
.ecx-color-row-btn:hover, .ecx-color-row-btn.is-open { border-color: var(--ecx-ed-accent); }
|
|
324
|
+
.ecx-color-dot { flex: none; width: 20px; height: 20px; border-radius: 50%; box-shadow: inset 0 0 0 1px rgb(0 0 0 / .12); position: relative; overflow: hidden; }
|
|
325
|
+
.ecx-color-dot.is-none { background: var(--ecx-ed-panel); }
|
|
326
|
+
.ecx-color-dot.is-none::after { content: ""; position: absolute; inset: 0; background: linear-gradient(135deg, transparent 45%, #e05252 45%, #e05252 55%, transparent 55%); }
|
|
327
|
+
.ecx-color-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
|
|
328
|
+
.ecx-color-value { flex: none; font-size: 12px; color: var(--ecx-ed-muted); }
|
|
329
|
+
.ecx-color-pop { position: absolute; z-index: 20; top: calc(100% + 6px); right: 0; width: 248px; padding: 10px; border: 1px solid var(--ecx-ed-line); border-radius: 10px; background: var(--ecx-ed-panel); box-shadow: var(--ecx-ed-shadow); animation: ecx-pop .1s linear; }
|
|
330
|
+
.ecx-pop-title { margin: 0 2px 8px; font-size: 10.5px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--ecx-ed-muted); }
|
|
331
|
+
.ecx-color-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; }
|
|
332
|
+
.ecx-color-cell { height: 28px; padding: 0; border: 1px solid rgb(0 0 0 / .1); border-radius: 7px; cursor: pointer; }
|
|
333
|
+
.ecx-color-cell.is-active { outline: 2px solid var(--ecx-ed-accent); outline-offset: 2px; }
|
|
334
|
+
.ecx-color-alpha { display: grid; grid-template-columns: auto 1fr 3ch; align-items: center; gap: 8px; margin: 10px 2px 0; font-size: 12.5px; }
|
|
335
|
+
.ecx-color-alpha input[type=range] { width: 100%; accent-color: var(--ecx-ed-accent); }
|
|
336
|
+
.ecx-color-alpha output { text-align: end; color: var(--ecx-ed-muted); font-variant-numeric: tabular-nums; }
|
|
337
|
+
.ecx-pop-hint { margin: 8px 2px 0; font-size: 11.5px; line-height: 1.4; color: var(--ecx-ed-muted); }
|
|
338
|
+
.ecx-pop-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--ecx-ed-line); }
|
|
339
|
+
.ecx-pop-custom { display: inline-flex; align-items: center; gap: 8px; font-size: 12.5px; }
|
|
340
|
+
/* Mô tả khối: nút ⓘ + chú thích khi rê */
|
|
341
|
+
.ecx-block-card { align-items: center; }
|
|
342
|
+
.ecx-card-info { position: relative; display: inline-grid; place-items: center; width: 20px; height: 20px; margin-left: -4px; border-radius: 50%; color: var(--ecx-ed-muted); cursor: help; }
|
|
343
|
+
.ecx-card-info .ecx-icon { width: 14px; height: 14px; }
|
|
344
|
+
.ecx-card-tip { position: absolute; z-index: 30; top: calc(100% + 6px); left: -40px; width: 230px; padding: 8px 10px; border-radius: 8px; background: var(--ecx-ed-fg, #0f1e29); color: var(--ecx-ed-panel, #fff); font-size: 12px; font-weight: 400; line-height: 1.45; opacity: 0; pointer-events: none; transition: opacity .1s linear .3s; }
|
|
345
|
+
.ecx-card-info:hover .ecx-card-tip, .ecx-card-info:focus .ecx-card-tip { opacity: 1; }
|
|
346
|
+
/* Tab có icon */
|
|
347
|
+
.ecx-inspector .ecx-tabs button { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; height: 54px; font-size: 12.5px; }
|
|
348
|
+
.ecx-inspector .ecx-tabs button .ecx-icon { width: 17px; height: 17px; }
|
|
255
349
|
.ecx-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--ecx-ed-accent); }
|
|
256
350
|
.ecx-link-btn { padding: 2px 4px; border: 0; background: none; color: var(--ecx-ed-accent); font: 500 12.5px var(--ecx-ed-font); cursor: pointer; border-radius: 4px; }
|
|
257
351
|
.ecx-link-btn:hover { text-decoration: underline; }
|
|
@@ -268,10 +362,14 @@ body.is-dragging, body.is-dragging * { cursor: grabbing !important; user-select:
|
|
|
268
362
|
.ecx-style-section-body { display: flex; flex-direction: column; gap: 12px; padding-bottom: 14px; }
|
|
269
363
|
.ecx-style-row { display: flex; flex-direction: column; gap: 6px; }
|
|
270
364
|
.ecx-device-tag { margin-left: 6px; padding: 0 5px; border-radius: 4px; background: var(--ecx-ed-accent-soft); color: var(--ecx-ed-accent); font-style: normal; font-size: 10px; }
|
|
271
|
-
|
|
272
|
-
.ecx-seg
|
|
273
|
-
.ecx-seg-btn
|
|
274
|
-
.ecx-seg-btn
|
|
365
|
+
/* Cụm nút chọn: khung viền kín hết chiều ngang, ô đang chọn tô đặc màu chính (dễ thấy lựa chọn hiện tại) */
|
|
366
|
+
.ecx-seg { display: flex; width: 100%; gap: 2px; padding: 2px; border: 1px solid var(--ecx-ed-line-strong); border-radius: 7px; background: var(--ecx-ed-panel); }
|
|
367
|
+
.ecx-seg-btn { display: inline-flex; align-items: center; justify-content: center; flex: 1 1 0; min-width: 28px; height: 30px; padding: 0 6px; border: 0; border-radius: 5px; background: none; color: var(--ecx-ed-fg); cursor: pointer; transition: background-color .12s ease, color .12s ease; }
|
|
368
|
+
.ecx-seg-btn:hover { background: var(--ecx-ed-hover); }
|
|
369
|
+
.ecx-seg-btn.is-active { background: var(--ecx-ed-accent); color: var(--ecx-ed-accent-fg); }
|
|
370
|
+
.ecx-state-tabs { border: 0; padding: 3px; background: var(--ecx-ed-subtle); }
|
|
371
|
+
.ecx-state-tabs .ecx-seg-btn { color: var(--ecx-ed-muted); }
|
|
372
|
+
.ecx-state-tabs .ecx-seg-btn.is-active { background: var(--ecx-ed-panel); color: var(--ecx-ed-accent); box-shadow: 0 1px 2px rgb(14 40 58 / .12); }
|
|
275
373
|
.ecx-seg.is-text { display: flex; flex-wrap: wrap; width: 100%; }
|
|
276
374
|
.ecx-seg.is-text .ecx-seg-btn { flex: 1 1 auto; font: 500 12.5px var(--ecx-ed-font); white-space: nowrap; }
|
|
277
375
|
.ecx-field-help { display: block; margin-top: 4px; font-size: 12px; line-height: 1.4; color: var(--ecx-ed-muted); }
|
|
@@ -359,7 +457,138 @@ body.is-dragging, body.is-dragging * { cursor: grabbing !important; user-select:
|
|
|
359
457
|
/* Nút "+ Thêm section" giữa hai section cấp trên cùng */
|
|
360
458
|
.ecx-section-adder { position: fixed; z-index: 30; display: grid; place-items: center; width: 28px; height: 28px; border-radius: 999px; border: 0; background: var(--ecx-ed-accent); color: var(--ecx-ed-accent-fg); box-shadow: var(--ecx-ed-shadow); cursor: pointer; }
|
|
361
459
|
.ecx-section-adder:hover { background: var(--ecx-ed-accent-hover); }
|
|
460
|
+
/* Đang kéo khối: nút không chen giữa đường kéo */
|
|
461
|
+
body.is-dragging .ecx-section-adder { display: none; }
|
|
362
462
|
.ecx-section-adder:focus-visible { outline: 2px solid var(--ecx-ed-accent); outline-offset: 2px; }
|
|
363
463
|
.ecx-section-adder .ecx-icon { width: 16px; height: 16px; }
|
|
364
464
|
.ecx-inserter-popover .ecx-tabs { margin-bottom: 6px; }
|
|
365
465
|
.ecx-inserter-patterns { max-height: 320px; overflow-y: auto; }
|
|
466
|
+
|
|
467
|
+
/* Đệm / lề 4 cạnh: vạch đậm ở đúng cạnh của mỗi ô; bảng chọn bậc */
|
|
468
|
+
.ecx-box4 { position: relative; }
|
|
469
|
+
.ecx-box4-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; }
|
|
470
|
+
.ecx-four { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 8px; }
|
|
471
|
+
.ecx-four-cell { display: grid; gap: 2px; min-width: 0; }
|
|
472
|
+
.ecx-four-cell small { font-size: 11px; color: var(--ecx-ed-muted); }
|
|
473
|
+
.ecx-box4-cell { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; height: 42px; padding: 0; border: 1px solid var(--ecx-ed-line); border-radius: 7px; background: var(--ecx-ed-panel); color: var(--ecx-ed-fg); font: inherit; cursor: pointer; transition: border-color .05s linear; }
|
|
474
|
+
.ecx-box4-cell small { font-size: 9.5px; letter-spacing: .04em; text-transform: uppercase; color: var(--ecx-ed-muted); }
|
|
475
|
+
.ecx-box4-cell b { font-size: 12.5px; font-weight: 600; }
|
|
476
|
+
.ecx-box4-cell::after { content: ""; position: absolute; background: var(--ecx-ed-line-strong, #c9d0d7); border-radius: 2px; }
|
|
477
|
+
.ecx-box4-cell.is-top::after { top: -1px; left: 8px; right: 8px; height: 3px; }
|
|
478
|
+
.ecx-box4-cell.is-bottom::after { bottom: -1px; left: 8px; right: 8px; height: 3px; }
|
|
479
|
+
.ecx-box4-cell.is-left::after { left: -1px; top: 8px; bottom: 8px; width: 3px; }
|
|
480
|
+
.ecx-box4-cell.is-right::after { right: -1px; top: 8px; bottom: 8px; width: 3px; }
|
|
481
|
+
.ecx-box4-cell.is-set::after { background: var(--ecx-ed-accent); }
|
|
482
|
+
.ecx-box4-cell:hover, .ecx-box4-cell.is-open { border-color: var(--ecx-ed-accent); }
|
|
483
|
+
.ecx-link-toggle { display: inline-grid; place-items: center; width: 22px; height: 20px; padding: 0; border: 0; border-radius: 5px; background: none; color: var(--ecx-ed-muted); cursor: pointer; }
|
|
484
|
+
.ecx-link-toggle.is-on { background: var(--ecx-ed-accent); color: var(--ecx-ed-accent-fg); }
|
|
485
|
+
.ecx-link-toggle .ecx-icon { width: 13px; height: 13px; }
|
|
486
|
+
.ecx-box4-pop { position: absolute; z-index: 20; left: 0; right: 0; top: calc(100% + 6px); display: flex; flex-direction: column; gap: 10px; padding: 10px; border: 1px solid var(--ecx-ed-line); border-radius: 10px; background: var(--ecx-ed-panel); box-shadow: var(--ecx-ed-shadow); animation: ecx-pop .1s linear; }
|
|
487
|
+
.ecx-box4-pop .ecx-pop-title { margin: 0; }
|
|
488
|
+
.ecx-box4-steps { display: flex; flex-wrap: wrap; gap: 4px; }
|
|
489
|
+
.ecx-box4-steps .ecx-chip { min-width: 36px; font-weight: 600; }
|
|
490
|
+
.ecx-box4-pop .ecx-pop-foot { margin-top: 0; }
|
|
491
|
+
.ecx-style-section-head .ecx-switch { margin-right: 2px; }
|
|
492
|
+
/* Bộ cột: bộ đếm số cột, hình bố cục */
|
|
493
|
+
.ecx-stepper { display: flex; align-items: center; height: 34px; border: 1px solid var(--ecx-ed-line); border-radius: 8px; overflow: hidden; }
|
|
494
|
+
.ecx-stepper button { width: 36px; height: 100%; border: 0; background: var(--ecx-ed-subtle); color: var(--ecx-ed-fg); font: 600 16px var(--ecx-ed-font); cursor: pointer; }
|
|
495
|
+
.ecx-stepper button:disabled { opacity: .4; cursor: default; }
|
|
496
|
+
.ecx-stepper output { flex: 1; text-align: center; font-weight: 600; }
|
|
497
|
+
.ecx-layout-thumbs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
|
|
498
|
+
.ecx-layout-thumb { display: flex; gap: 3px; height: 40px; padding: 7px; border: 1px solid var(--ecx-ed-line); border-radius: 8px; background: var(--ecx-ed-panel); cursor: pointer; transition: border-color .05s linear; }
|
|
499
|
+
.ecx-layout-thumb i { flex: 1; min-width: 4px; border-radius: 2px; background: var(--ecx-ed-line-strong, #c9d0d7); }
|
|
500
|
+
.ecx-layout-thumb.is-stack { flex-direction: column; }
|
|
501
|
+
.ecx-layout-thumb.is-stack i { flex: 1; }
|
|
502
|
+
.ecx-layout-thumb:hover { border-color: var(--ecx-ed-accent); }
|
|
503
|
+
.ecx-layout-thumb.is-active { border-color: var(--ecx-ed-accent); background: var(--ecx-ed-accent-soft); }
|
|
504
|
+
.ecx-layout-thumb.is-active i { background: var(--ecx-ed-accent); }
|
|
505
|
+
/* Hàng Kiểu (kiểu đặt sẵn) */
|
|
506
|
+
.ecx-preset { position: relative; display: flex; flex-direction: column; gap: 6px; }
|
|
507
|
+
.ecx-preset-row { display: flex; gap: 6px; }
|
|
508
|
+
.ecx-preset-btn { flex: 1; display: flex; align-items: center; justify-content: space-between; gap: 8px; height: 34px; padding: 0 10px; border: 1px solid var(--ecx-ed-line); border-radius: 8px; background: var(--ecx-ed-panel); color: var(--ecx-ed-fg); font: inherit; cursor: pointer; transition: border-color .05s linear; }
|
|
509
|
+
.ecx-preset-btn:hover, .ecx-preset-btn.is-open { border-color: var(--ecx-ed-accent); }
|
|
510
|
+
.ecx-preset-edited { font-style: normal; color: #e8890c; }
|
|
511
|
+
.ecx-preset-reset { width: 34px; height: 34px; display: grid; place-items: center; border: 1px solid var(--ecx-ed-line); border-radius: 8px; background: var(--ecx-ed-panel); color: var(--ecx-ed-muted); cursor: pointer; }
|
|
512
|
+
.ecx-preset-reset:disabled { opacity: .4; cursor: default; }
|
|
513
|
+
.ecx-preset-menu { position: absolute; z-index: 25; top: calc(100% + 6px); left: 0; right: 0; display: flex; flex-direction: column; gap: 2px; padding: 8px; border: 1px solid var(--ecx-ed-line); border-radius: 10px; background: var(--ecx-ed-panel); box-shadow: var(--ecx-ed-shadow); animation: ecx-pop .1s linear; }
|
|
514
|
+
.ecx-preset-menu hr { width: 100%; margin: 6px 0; border: 0; border-top: 1px solid var(--ecx-ed-line); }
|
|
515
|
+
.ecx-preset-line { display: flex; align-items: center; }
|
|
516
|
+
.ecx-preset-item { flex: 1; display: flex; align-items: center; gap: 8px; min-height: 32px; padding: 0 8px; border: 0; border-radius: 6px; background: none; color: var(--ecx-ed-fg); font: inherit; text-align: left; cursor: pointer; }
|
|
517
|
+
.ecx-preset-item:hover { background: var(--ecx-ed-subtle); }
|
|
518
|
+
.ecx-preset-item .ecx-icon { width: 15px; height: 15px; }
|
|
519
|
+
.ecx-preset-item[aria-checked=true] { font-weight: 600; }
|
|
520
|
+
.ecx-preset-item[aria-checked=true] .ecx-icon { margin-left: auto; color: var(--ecx-ed-accent); }
|
|
521
|
+
.ecx-preset-del { width: 28px; height: 28px; display: grid; place-items: center; border: 0; border-radius: 6px; background: none; color: var(--ecx-ed-muted); cursor: pointer; }
|
|
522
|
+
.ecx-preset-del:hover { background: var(--ecx-ed-subtle); color: #c0392b; }
|
|
523
|
+
.ecx-preset-name { display: flex; gap: 6px; padding: 2px; }
|
|
524
|
+
/* Ô chọn icon: lưới có ô tìm */
|
|
525
|
+
.ecx-icon-picker { position: relative; }
|
|
526
|
+
.ecx-icon-picker-btn { display: flex; align-items: center; gap: 10px; width: 100%; height: 40px; padding: 0 10px; border: 1px solid var(--ecx-ed-line); border-radius: 8px; background: var(--ecx-ed-panel); color: var(--ecx-ed-fg); font: inherit; cursor: pointer; transition: border-color .05s linear; }
|
|
527
|
+
.ecx-icon-picker-btn:hover, .ecx-icon-picker-btn.is-open { border-color: var(--ecx-ed-accent); }
|
|
528
|
+
.ecx-icon-picker-name { flex: 1; text-align: left; font-size: 12px; color: var(--ecx-ed-muted); }
|
|
529
|
+
.ecx-icon-pop { position: absolute; z-index: 25; top: calc(100% + 6px); left: 0; right: 0; display: flex; flex-direction: column; gap: 8px; padding: 10px; border: 1px solid var(--ecx-ed-line); border-radius: 10px; background: var(--ecx-ed-panel); box-shadow: var(--ecx-ed-shadow); animation: ecx-pop .1s linear; }
|
|
530
|
+
.ecx-icon-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 4px; max-height: 220px; overflow: auto; }
|
|
531
|
+
.ecx-icon-cell { display: grid; place-items: center; aspect-ratio: 1; border: 1px solid transparent; border-radius: 7px; background: none; color: var(--ecx-ed-fg); cursor: pointer; }
|
|
532
|
+
.ecx-icon-cell:hover { background: var(--ecx-ed-subtle); }
|
|
533
|
+
.ecx-icon-cell.is-active { border-color: var(--ecx-ed-accent); background: var(--ecx-ed-accent-soft); color: var(--ecx-ed-accent); }
|
|
534
|
+
|
|
535
|
+
.ecx-check-row { display: flex; align-items: center; gap: 8px; font-size: 13px; }
|
|
536
|
+
|
|
537
|
+
/* Thư viện mẫu (pattern-library.tsx): hộp gần toàn màn hình, cột trái danh mục, lưới xem trước thật */
|
|
538
|
+
.ecx-lib-open { gap: 6px; height: 32px; padding: 0 10px; font-weight: 500; }
|
|
539
|
+
.ecx-lib-backdrop { z-index: 1000; }
|
|
540
|
+
.ecx-lib { position: fixed; inset: 24px; display: grid; grid-template-columns: 240px 1fr; overflow: hidden; border-radius: 14px; background: var(--ecx-ed-panel); color: var(--ecx-ed-fg); box-shadow: 0 24px 64px rgb(14 40 58 / .3); font: 14px/1.45 var(--ecx-ed-font); }
|
|
541
|
+
.ecx-lib-side { display: flex; flex-direction: column; gap: 12px; padding: 16px; overflow: auto; border-right: 1px solid var(--ecx-ed-line); background: var(--ecx-ed-subtle); }
|
|
542
|
+
.ecx-lib-side .ecx-tabs { margin: 0 -16px; }
|
|
543
|
+
.ecx-lib-mode { display: flex; border: 1px solid var(--ecx-ed-line); border-radius: 8px; overflow: hidden; background: var(--ecx-ed-panel); }
|
|
544
|
+
.ecx-lib-mode button { flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 4px; height: 34px; border: 0; background: none; color: var(--ecx-ed-fg); font: inherit; font-size: 13px; cursor: pointer; }
|
|
545
|
+
.ecx-lib-mode button.is-active { background: var(--ecx-ed-accent); color: var(--ecx-ed-accent-fg); }
|
|
546
|
+
.ecx-lib-cats { display: flex; flex-direction: column; gap: 1px; }
|
|
547
|
+
.ecx-lib-cats button { padding: 7px 10px; border: 0; border-radius: 6px; background: none; color: inherit; font: inherit; text-align: left; cursor: pointer; }
|
|
548
|
+
.ecx-lib-cats button:hover { background: var(--ecx-ed-hover); }
|
|
549
|
+
.ecx-lib-cats button[aria-current] { background: var(--ecx-ed-panel); font-weight: 600; box-shadow: 0 1px 2px rgb(14 40 58 / .08); }
|
|
550
|
+
.ecx-lib-scheme { margin-top: auto; display: flex; align-items: center; justify-content: space-between; font-weight: 600; }
|
|
551
|
+
.ecx-lib-scheme div { display: flex; gap: 8px; }
|
|
552
|
+
.ecx-lib-scheme button { width: 26px; height: 26px; padding: 0; border: 2px solid var(--ecx-ed-panel); border-radius: 50%; box-shadow: 0 0 0 1px var(--ecx-ed-line); cursor: pointer; }
|
|
553
|
+
.ecx-lib-scheme .is-light { background: #fff; } .ecx-lib-scheme .is-dark { background: #0f1b24; } .ecx-lib-scheme .is-brand { background: var(--ecx-ed-accent); }
|
|
554
|
+
.ecx-lib-scheme button.is-active { box-shadow: 0 0 0 2px var(--ecx-ed-accent); }
|
|
555
|
+
.ecx-lib-main { display: flex; flex-direction: column; min-width: 0; overflow: hidden; }
|
|
556
|
+
.ecx-lib-bar { display: flex; align-items: center; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--ecx-ed-line); }
|
|
557
|
+
.ecx-lib-search { display: flex; align-items: center; gap: 8px; width: min(320px, 50%); height: 36px; padding: 0 10px; border: 1px solid var(--ecx-ed-line); border-radius: 8px; }
|
|
558
|
+
.ecx-lib-search input { flex: 1; min-width: 0; border: 0; outline: 0; background: none; color: inherit; font: inherit; }
|
|
559
|
+
.ecx-lib-close { margin-left: auto; display: inline-grid; place-items: center; width: 34px; height: 34px; border: 0; border-radius: 8px; background: none; color: var(--ecx-ed-muted); cursor: pointer; }
|
|
560
|
+
.ecx-lib-close:hover { background: var(--ecx-ed-hover); color: var(--ecx-ed-fg); }
|
|
561
|
+
.ecx-lib-ai { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 14px; padding: 14px 18px; border-bottom: 1px solid var(--ecx-ed-line); background: var(--ecx-ed-subtle); }
|
|
562
|
+
.ecx-lib-ai label { display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; color: var(--ecx-ed-muted); }
|
|
563
|
+
.ecx-lib-ai .is-wide { grid-column: 1 / -1; }
|
|
564
|
+
.ecx-lib-ai .ecx-btn { align-self: end; justify-self: start; gap: 6px; }
|
|
565
|
+
.ecx-lib-error { grid-column: 1 / -1; margin: 0; color: var(--ecx-ed-danger); }
|
|
566
|
+
.ecx-lib-grid { flex: 1; display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 20px; align-content: start; padding: 18px; overflow: auto; }
|
|
567
|
+
.ecx-lib-grid.is-pages { grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); }
|
|
568
|
+
.ecx-lib-card { display: block; padding: 0; border: 1px solid var(--ecx-ed-line); border-radius: 10px; background: var(--ecx-ed-panel); color: inherit; font: inherit; text-align: left; cursor: pointer; transition: border-color .1s linear, box-shadow .1s linear; }
|
|
569
|
+
.ecx-lib-card:hover, .ecx-lib-card:focus-visible { border-color: var(--ecx-ed-accent); box-shadow: 0 6px 18px rgb(14 40 58 / .12); outline: none; }
|
|
570
|
+
.ecx-lib-card-name { display: flex; justify-content: space-between; gap: 8px; padding: 9px 12px; border-top: 1px solid var(--ecx-ed-line); font-size: 13px; }
|
|
571
|
+
.ecx-lib-card-name em { font-style: normal; color: var(--ecx-ed-muted); }
|
|
572
|
+
.ecx-lib-preview { position: relative; overflow: hidden; border-radius: 9px 9px 0 0; background: #fff; pointer-events: none; }
|
|
573
|
+
.ecx-lib-preview-inner { transform-origin: 0 0; }
|
|
574
|
+
.ecx-lib-preview-inner .ecx-canvas-wrap, .ecx-lib-preview-inner .ecx-canvas { height: 100%; }
|
|
575
|
+
@media (max-width: 720px) { .ecx-lib { inset: 0; border-radius: 0; grid-template-columns: 1fr; } .ecx-lib-side { display: none; } }
|
|
576
|
+
|
|
577
|
+
/* Hàng sửa một mục của danh sách (chữ; icon + liên kết + xoá) */
|
|
578
|
+
.ecx-item-row { display: flex; flex-direction: column; gap: 4px; padding: 8px; border: 1px solid var(--ecx-ed-line); border-radius: 8px; }
|
|
579
|
+
.ecx-item-row-sub { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 28px; gap: 4px; align-items: center; }
|
|
580
|
+
|
|
581
|
+
.ecx-quick-colors { display: flex; flex-wrap: wrap; gap: 8px; padding: 8px; max-width: 200px; }
|
|
582
|
+
.ecx-quick-colors .ecx-color-dot { width: 24px; height: 24px; border: 0; padding: 0; cursor: pointer; }
|
|
583
|
+
.ecx-quick-colors .ecx-color-dot:hover, .ecx-quick-colors .ecx-color-dot:focus-visible { outline: 2px solid var(--ecx-ed-accent, #1a597b); outline-offset: 2px; }
|
|
584
|
+
|
|
585
|
+
.ecx-divider-side + .ecx-divider-side { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--ecx-ed-line, #e5e7eb); }
|
|
586
|
+
.ecx-divider-shapes { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 4px; }
|
|
587
|
+
.ecx-divider-shape { min-width: 0; height: 32px; padding: 0 2px; border: 1px solid var(--ecx-ed-line, #d1d5db); border-radius: 6px; background: var(--ecx-ed-panel, #fff); color: var(--ecx-ed-muted, #5d6a75); font: inherit; font-size: 11px; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; }
|
|
588
|
+
.ecx-divider-shape svg { width: 22px; height: 12px; }
|
|
589
|
+
.ecx-divider-shape:hover { border-color: var(--ecx-ed-accent, #1a597b); }
|
|
590
|
+
.ecx-divider-shape.is-active { border-color: var(--ecx-ed-accent, #1a597b); background: var(--ecx-ed-accent, #1a597b); color: #fff; }
|
|
591
|
+
|
|
592
|
+
.ecx-textshadow { display: grid; gap: 10px; margin-top: 10px; }
|
|
593
|
+
.ecx-textshadow-row { display: grid; gap: 4px; font-size: 12px; color: var(--ecx-ed-muted, #5d6a75); }
|
|
594
|
+
.ecx-textshadow-row .ecx-range { width: 100%; }
|
package/src/v2/editor.tsx
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ensurePresets } from "./core/block-presets";
|
|
1
2
|
import type { RichNode } from "@ecomcx/ecomweb-content";
|
|
2
3
|
import { normalizeContent } from "@ecomcx/ecomweb-content";
|
|
3
4
|
import { ListTree, Monitor, Plus, Redo2, Smartphone, Tablet, Undo2, X, PanelRight, ZoomOut } from "lucide-react";
|
|
@@ -18,6 +19,7 @@ import { blocksFromDoc, docFromBlocks, type BNode } from "./core/model";
|
|
|
18
19
|
import { BlockTypeRegistry } from "./core/registry";
|
|
19
20
|
import { Inspector } from "./ui/inspector";
|
|
20
21
|
import { ListView } from "./ui/list-view";
|
|
22
|
+
import { PatternLibraryButton } from "./ui/pattern-library";
|
|
21
23
|
import { PrefsStore, usePrefs, type PrefsStorage } from "./prefs";
|
|
22
24
|
import { Breadcrumbs, CodeEditor, MoreMenu } from "./ui/options";
|
|
23
25
|
import { EditorStore, type DocRecord } from "./core/store";
|
|
@@ -106,6 +108,8 @@ export function EditorProvider({ store: given, value, kind, title, host = {}, la
|
|
|
106
108
|
}, []);
|
|
107
109
|
// Khối của plugin (registerBlock) + mẫu có sẵn của lõi
|
|
108
110
|
useEffect(() => syncPluginBlocks(registry), [registry]);
|
|
111
|
+
// Kiểu đặt sẵn / mặc định khi chèn: nạp ngay khi mở trình soạn (khối chèn đầu tiên đã nhận mặc định)
|
|
112
|
+
useEffect(() => ensurePresets(host.blockPresets?.load), [host]);
|
|
109
113
|
useEffect(() => { registerCoreBindingSources(allLabels.lang); }, [allLabels.lang]);
|
|
110
114
|
useEffect(() => { if (!registeredPatterns().some((p) => p.name.startsWith("core/"))) registerCorePatterns(allLabels.lang); }, [allLabels.lang]);
|
|
111
115
|
const ctx: EditorContextValue = useMemo(() => ({ store, registry, host, labels: allLabels, ui, prefs }), [store, registry, host, allLabels, ui, prefs]);
|
|
@@ -181,7 +185,8 @@ function EditorShell({ className, onSave, header, actions, menuExtra, canvasBefo
|
|
|
181
185
|
const p = usePrefs(ctx.prefs);
|
|
182
186
|
const [left, setLeft] = useState<"inserter" | "list" | null>(() => (ctx.prefs.get().showListView ? "list" : null));
|
|
183
187
|
useEffect(() => { ctx.ui.browseAll = () => setLeft("inserter"); return () => { ctx.ui.browseAll = null; }; }, [ctx.ui]);
|
|
184
|
-
|
|
188
|
+
// Điện thoại: bảng bên phải mở đè lên canvas nên mặc định đóng (mở bằng nút ở thanh trên)
|
|
189
|
+
const [right, setRight] = useState(() => typeof window === "undefined" || window.innerWidth > 640);
|
|
185
190
|
// Khổ ban đầu do ứng dụng chọn; sau đó dùng chung qua ui.device (DeviceSwitcher, tab Kiểu dáng)
|
|
186
191
|
useEffect(() => { if (defaultDevice) ctx.ui.setDevice(defaultDevice); }, [ctx.ui, defaultDevice]);
|
|
187
192
|
const [saving, setSaving] = useState<"idle" | "saving" | "saved" | "error">("idle");
|
|
@@ -233,6 +238,7 @@ function EditorShell({ className, onSave, header, actions, menuExtra, canvasBefo
|
|
|
233
238
|
<ToolButton label={labels.undo} disabled={!store.canUndo} onClick={() => store.undo()}><Undo2 className="ecx-icon" /></ToolButton>
|
|
234
239
|
<ToolButton label={labels.redo} disabled={!store.canRedo} onClick={() => store.redo()}><Redo2 className="ecx-icon" /></ToolButton>
|
|
235
240
|
{!p.distractionFree && <ToolButton label={labels.listView} active={left === "list"} onClick={() => setLeft(left === "list" ? null : "list")}><ListTree className="ecx-icon" /></ToolButton>}
|
|
241
|
+
{!p.distractionFree && p.mode === "visual" && <PatternLibraryButton renderPreview={(value) => <EditorProvider value={value} kind="pattern-preview" registry={ctx.registry} labels={ctx.labels} host={{ ...ctx.host, documents: undefined, ai: undefined }}><Canvas /></EditorProvider>} />}
|
|
236
242
|
<FrameToggle />
|
|
237
243
|
{p.mode === "visual" && <ZoomToggle />}
|
|
238
244
|
</div>
|
|
@@ -251,7 +257,7 @@ function EditorShell({ className, onSave, header, actions, menuExtra, canvasBefo
|
|
|
251
257
|
{error && <div className="ecx-notice is-error" role="alert">{error}</div>}
|
|
252
258
|
{p.fixedToolbar && p.mode === "visual" && <div className="ecx-fixed-toolbar"><BlockToolbar placement="fixed" /></div>}
|
|
253
259
|
<div className="ecx-body">
|
|
254
|
-
{left && !p.distractionFree && <aside className="ecx-left">{left === "inserter" ? <InserterPanel onClose={() => setLeft(null)} /> : <ListView />}</aside>}
|
|
260
|
+
{left && !p.distractionFree && <aside className="ecx-left">{left === "inserter" ? <InserterPanel onClose={() => setLeft(null)} onInserted={() => { /* Điện thoại: bảng đè lên canvas nên chèn xong thì đóng để tiếp tục soạn */ if (window.innerWidth <= 640) setLeft(null); }} /> : <ListView onClose={() => setLeft(null)} />}</aside>}
|
|
255
261
|
<main className="ecx-main">{p.mode === "code" ? <CodeEditor /> : <Canvas before={canvasBefore} />}</main>
|
|
256
262
|
{right && !p.distractionFree && <aside className="ecx-right"><Inspector blockStyles={blockStyles} /></aside>}
|
|
257
263
|
</div>
|