@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
package/src/v2/ui/inserter.tsx
CHANGED
|
@@ -1,9 +1,13 @@
|
|
|
1
|
+
import { freshWithDefaults } from "../core/block-presets";
|
|
1
2
|
import { leavesItem } from "../core/structure";
|
|
2
3
|
import { blockDescription } from "./block-descriptions";
|
|
3
|
-
import { Blocks, Sparkles } from "lucide-react";
|
|
4
|
+
import { Blocks, Sparkles, X } from "lucide-react";
|
|
5
|
+
import { mediaAttrs } from "./media-actions";
|
|
6
|
+
import { cx } from "./attr-form";
|
|
7
|
+
import type { MediaItem } from "../../shared/types";
|
|
4
8
|
import { useEffect, useLayoutEffect, useMemo, useRef, useState, type ComponentType } from "react";
|
|
5
9
|
import { norm } from "../../shared/util";
|
|
6
|
-
import { useEditor, useUiTick, type InserterRequest } from "../context";
|
|
10
|
+
import { useEditor, useEditorState, useUiTick, type InserterRequest } from "../context";
|
|
7
11
|
import { cloneBlock, inlineLength, makeBlock, type BNode } from "../core/model";
|
|
8
12
|
import type { BlockType } from "../core/registry";
|
|
9
13
|
import { canContain } from "../core/structure";
|
|
@@ -75,7 +79,7 @@ export function applyInsert(ctx: ReturnType<typeof useEditor>, req: InserterRequ
|
|
|
75
79
|
ui.openAiWrite?.({ blockId: req.mode === "slash" ? req.blockId : undefined, docId: req.docId, parentId: req.parentId ?? null, index: req.index ?? 0 });
|
|
76
80
|
return;
|
|
77
81
|
}
|
|
78
|
-
const node = opt.create();
|
|
82
|
+
const node = freshWithDefaults(opt.create());
|
|
79
83
|
prefs.countInsert(opt.type);
|
|
80
84
|
if (req.mode === "slash" && req.blockId) {
|
|
81
85
|
const b = store.block(req.blockId);
|
|
@@ -143,15 +147,20 @@ export function InserterPopover() {
|
|
|
143
147
|
}, [ctx, ui]);
|
|
144
148
|
useLayoutEffect(() => { listRef.current?.querySelector(`[data-index="${active}"]`)?.scrollIntoView({ block: "nearest" }); }, [active]);
|
|
145
149
|
|
|
146
|
-
// Bấm ra ngoài: đóng
|
|
150
|
+
// Bấm ra ngoài: đóng. Pha capture vì nhiều khối chặn mousedown (stopPropagation) trước khi tới document.
|
|
147
151
|
useEffect(() => {
|
|
148
152
|
if (!req || req.mode === "slash") return;
|
|
149
153
|
const close = (e: MouseEvent) => { if (!(e.target as Element).closest?.(".ecx-inserter-popover")) ui.openInserter(null); };
|
|
150
154
|
const frameDoc = ui.canvasDoc;
|
|
151
|
-
document.addEventListener("mousedown", close);
|
|
152
|
-
frameDoc?.addEventListener("mousedown", close);
|
|
153
|
-
return () => { document.removeEventListener("mousedown", close); frameDoc?.removeEventListener("mousedown", close); };
|
|
155
|
+
document.addEventListener("mousedown", close, true);
|
|
156
|
+
frameDoc?.addEventListener("mousedown", close, true);
|
|
157
|
+
return () => { document.removeEventListener("mousedown", close, true); frameDoc?.removeEventListener("mousedown", close, true); };
|
|
154
158
|
}, [req, ui]);
|
|
159
|
+
// Chọn khối khác bằng đường không bấm chuột (danh sách khối, phím tắt…): đóng
|
|
160
|
+
const selKey = useEditorState((s) => (s.selection.ids.length ? s.selection.ids : [s.selection.editing ?? ""]).join(","));
|
|
161
|
+
const openSel = useRef<string | null>(null);
|
|
162
|
+
useEffect(() => { openSel.current = req && req.mode !== "slash" ? selKey : null; }, [req]); // eslint-disable-line react-hooks/exhaustive-deps
|
|
163
|
+
useEffect(() => { if (openSel.current !== null && selKey !== openSel.current) ui.openInserter(null); }, [selKey, ui]);
|
|
155
164
|
|
|
156
165
|
if (!req) return null;
|
|
157
166
|
if (req.mode === "slash" && !results.length) return null;
|
|
@@ -247,7 +256,7 @@ export function InserterPanel({ onInserted, onClose }: { onInserted?(): void; on
|
|
|
247
256
|
return () => { document.removeEventListener("keydown", onKey); frameDoc?.removeEventListener("keydown", onKey); };
|
|
248
257
|
}, [onClose, ctx.ui]);
|
|
249
258
|
const [query, setQuery] = useState("");
|
|
250
|
-
const [tab, setTab] = useState<"blocks" | "patterns">("blocks");
|
|
259
|
+
const [tab, setTab] = useState<"blocks" | "patterns" | "media">("blocks");
|
|
251
260
|
const [hover, setHover] = useState<{ o: InsertOption; rect: DOMRect; y: number } | null>(null);
|
|
252
261
|
const results = rankOptions(options, query);
|
|
253
262
|
const catLabel: Record<string, string> = { text: labels.catText, media: labels.catMedia, design: labels.catDesign, widgets: labels.catWidgets, theme: labels.catTheme, embed: labels.catEmbed };
|
|
@@ -258,7 +267,7 @@ export function InserterPanel({ onInserted, onClose }: { onInserted?(): void; on
|
|
|
258
267
|
const lastInserted = useRef<string | null>(null);
|
|
259
268
|
const groups = query ? [["", results] as const] : [...CATEGORY_ORDER, ...new Set(results.map((r) => r.category).filter((c) => !CATEGORY_ORDER.includes(c)))].map((c) => [c, results.filter((r) => r.category === c)] as const).filter(([, l]) => l.length);
|
|
260
269
|
const insert = (o: InsertOption) => {
|
|
261
|
-
const node = o.create();
|
|
270
|
+
const node = freshWithDefaults(o.create());
|
|
262
271
|
ctx.prefs.countInsert(o.type);
|
|
263
272
|
const cur = store.currentIds[store.currentIds.length - 1];
|
|
264
273
|
// Đoạn trống đang chọn mà chính lần chèn trước vừa tạo thì giữ lại (chèn tiếp ra sau nó); đoạn trống của người dùng thì thay như WordPress
|
|
@@ -284,12 +293,17 @@ export function InserterPanel({ onInserted, onClose }: { onInserted?(): void; on
|
|
|
284
293
|
<p>{hover.o.description ?? blockDescription(hover.o.type, labels.lang) ?? ""}</p>
|
|
285
294
|
</div>
|
|
286
295
|
)}
|
|
287
|
-
<div className="ecx-tabs"
|
|
296
|
+
<div className="ecx-tabs">
|
|
297
|
+
<div className="ecx-tablist" role="tablist">
|
|
288
298
|
<button type="button" role="tab" aria-selected={tab === "blocks"} className={tab === "blocks" ? "is-active" : undefined} onClick={() => setTab("blocks")}>{labels.blocks}</button>
|
|
289
299
|
<button type="button" role="tab" aria-selected={tab === "patterns"} className={tab === "patterns" ? "is-active" : undefined} onClick={() => setTab("patterns")}>{labels.patterns}</button>
|
|
300
|
+
{ctx.host.media?.list && <button type="button" role="tab" aria-selected={tab === "media"} className={tab === "media" ? "is-active" : undefined} onClick={() => setTab("media")}>{labels.mediaTab}</button>}
|
|
301
|
+
</div>
|
|
302
|
+
{onClose && <button type="button" className="ecx-left-close" aria-label={labels.close} title={labels.close} onClick={onClose}><X className="ecx-icon" /></button>}
|
|
290
303
|
</div>
|
|
291
|
-
<input className="ecx-search" placeholder={labels.search} value={query} onChange={(e) => setQuery(e.target.value)} aria-label={labels.search} />
|
|
292
|
-
{tab === "
|
|
304
|
+
<input className="ecx-search" placeholder={tab === "media" ? labels.searchMedia : labels.search} value={query} onChange={(e) => setQuery(e.target.value)} aria-label={tab === "media" ? labels.searchMedia : labels.search} />
|
|
305
|
+
{tab === "media" ? <MediaList query={query} onPick={(kind, m) => insert({ key: kind, title: kind, keywords: "", category: "media", type: kind, create: () => makeBlock(kind, { ...ctx.registry.create(kind).attrs, ...mediaAttrs(kind, [m]) }) })} />
|
|
306
|
+
: tab === "patterns" ? <PatternList query={query} onInserted={onInserted} /> : <>
|
|
293
307
|
{mostUsed.length > 0 && (
|
|
294
308
|
<section data-section="most-used">
|
|
295
309
|
<h3 className="ecx-panel-heading">{labels.mostUsedTitle}</h3>
|
|
@@ -322,6 +336,41 @@ export function InserterPanel({ onInserted, onClose }: { onInserted?(): void; on
|
|
|
322
336
|
);
|
|
323
337
|
}
|
|
324
338
|
|
|
339
|
+
type MediaTabKind = "image" | "video" | "audio";
|
|
340
|
+
/** Tab Media: tệp mới nhất của thư viện theo loại; bấm = chèn khối Ảnh / Video / Âm thanh sau khối đang chọn. */
|
|
341
|
+
function MediaList({ query, onPick }: { query: string; onPick(kind: MediaTabKind, m: MediaItem): void }) {
|
|
342
|
+
const { host, labels } = useEditor();
|
|
343
|
+
const [kind, setKind] = useState<MediaTabKind>("image");
|
|
344
|
+
const [items, setItems] = useState<MediaItem[] | null>(null);
|
|
345
|
+
const [failed, setFailed] = useState(false);
|
|
346
|
+
useEffect(() => {
|
|
347
|
+
let live = true;
|
|
348
|
+
setItems(null); setFailed(false);
|
|
349
|
+
// Gõ tìm: chờ ngừng gõ rồi mới hỏi thư viện
|
|
350
|
+
const t = setTimeout(() => {
|
|
351
|
+
host.media!.list!({ kind, search: query.trim() || undefined }).then((l) => { if (live) setItems(l); }, () => { if (live) setFailed(true); });
|
|
352
|
+
}, query ? 250 : 0);
|
|
353
|
+
return () => { live = false; clearTimeout(t); };
|
|
354
|
+
}, [host.media, kind, query]);
|
|
355
|
+
const kinds: Array<[MediaTabKind, string]> = [["image", labels.image], ["video", "Video"], ["audio", labels.audio]];
|
|
356
|
+
return (
|
|
357
|
+
<>
|
|
358
|
+
<div className="ecx-seg is-text ecx-media-kinds" role="radiogroup" aria-label={labels.mediaTab}>
|
|
359
|
+
{kinds.map(([k, l]) => <button key={k} type="button" role="radio" aria-checked={kind === k} className={cx("ecx-seg-btn", kind === k && "is-active")} onClick={() => setKind(k)}>{l}</button>)}
|
|
360
|
+
</div>
|
|
361
|
+
{failed ? <p className="ecx-muted">{labels.loadFailed}</p> : !items ? <p className="ecx-muted">{labels.loading}</p> : !items.length ? <p className="ecx-muted">{labels.noResults}</p> : (
|
|
362
|
+
<div className={cx("ecx-media-grid", kind !== "image" && "is-files")}>
|
|
363
|
+
{items.map((m) => (
|
|
364
|
+
<button key={m.id} type="button" className="ecx-media-item" title={m.title || m.fileName} onClick={() => onPick(kind, m)}>
|
|
365
|
+
{kind === "image" ? <img src={m.sizes?.thumbnail?.url ?? m.sizes?.medium?.url ?? m.url} alt={m.alt || m.fileName} loading="lazy" /> : <span>{m.title || m.fileName}</span>}
|
|
366
|
+
</button>
|
|
367
|
+
))}
|
|
368
|
+
</div>
|
|
369
|
+
)}
|
|
370
|
+
</>
|
|
371
|
+
);
|
|
372
|
+
}
|
|
373
|
+
|
|
325
374
|
/** Mẫu (lõi, theme, plugin, người dùng tạo): bấm chèn sau khối đang chọn; mẫu đồng bộ chèn thành tham chiếu. */
|
|
326
375
|
function PatternList({ query, onInserted, at }: { query: string; onInserted?(): void; at?: { docId: string; parentId: string | null; index: number } }) {
|
|
327
376
|
const ctx = useEditor();
|
package/src/v2/ui/inspector.tsx
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Device } from "@ecomcx/ecomweb-content";
|
|
2
|
-
import { CORE_BLOCK_STYLES, controlValue, optionValue } from "@ecomcx/ecomweb-content";
|
|
3
|
-
import { Blocks } from "lucide-react";
|
|
2
|
+
import { CONTAINER_TAGS, CORE_BLOCK_STYLES, controlValue, optionValue } from "@ecomcx/ecomweb-content";
|
|
3
|
+
import { Blocks, Info, LayoutPanelTop, Paintbrush, SlidersHorizontal } from "lucide-react";
|
|
4
4
|
import { useState, useSyncExternalStore } from "react";
|
|
5
5
|
import { blockPanelsFor, onBlockPanelsChange, type BlockPanel } from "../../shared/panel-store";
|
|
6
6
|
import { useEditor, useEditorState, useUiTick } from "../context";
|
|
@@ -8,15 +8,26 @@ import type { BNode } from "../core/model";
|
|
|
8
8
|
import { AttrForm, Field, attrName, cx } from "./attr-form";
|
|
9
9
|
import { BindingsPanel, CORE_BINDABLE } from "./bindings";
|
|
10
10
|
import { StyleTab } from "./style-tab";
|
|
11
|
+
import { LayoutSection } from "./layout-panel";
|
|
12
|
+
import { GroupWidthSection } from "./group-width";
|
|
13
|
+
import { DividerSection } from "./divider-panel";
|
|
14
|
+
import { Row, Section, SectionGroup } from "./style-controls";
|
|
11
15
|
import { BackgroundControl } from "./background-panel";
|
|
12
16
|
import { BlockStyleSections } from "./block-style-panel";
|
|
17
|
+
import { PartsSections } from "./parts-panel";
|
|
18
|
+
import { PresetBar } from "./preset-bar";
|
|
19
|
+
import { blockControls } from "../../shared/panel-store";
|
|
13
20
|
import { styleGroups } from "./style-supports";
|
|
14
21
|
import { ColorInput } from "./color-field";
|
|
15
22
|
import { UnitInput } from "./unit-controls";
|
|
16
23
|
import { useMsgs } from "../i18n";
|
|
17
24
|
|
|
18
25
|
/** Khối "khung" (như Container / Section của Elementor): ô Nền đặt ngay tab Cài đặt — chỗ người dùng tìm đầu tiên. */
|
|
19
|
-
|
|
26
|
+
// Nền của Nhóm / Cột nằm ở tab Kiểu dáng như bộ khối lớn; ảnh bìa: nền là nội dung chính nên ở Cài đặt
|
|
27
|
+
const BG_IN_SETTINGS = new Set(["cover", "group"]);
|
|
28
|
+
/** Khối chứa đổi được thẻ HTML (attrs.tagName). */
|
|
29
|
+
const TAGGED = new Set(["group", "column", "columns"]);
|
|
30
|
+
const BG_FIRST = new Set(["column", "columns", "row", "stack", "grid"]);
|
|
20
31
|
|
|
21
32
|
/**
|
|
22
33
|
* Bảng cài đặt của khối đang chọn (như Elementor): thẻ khối, tab Cài đặt (nội dung: form + phần riêng của khối), tab Kiểu dáng
|
|
@@ -42,6 +53,8 @@ export function Inspector({ blockStyles }: { blockStyles?: Record<string, Array<
|
|
|
42
53
|
const disabled = store.modeOf(first.id) === "disabled";
|
|
43
54
|
const setAttrs = (a: Record<string, unknown>) => store.setAttrs(ids, a);
|
|
44
55
|
const single = same && nodes.length === 1;
|
|
56
|
+
// Phần thay hẳn Kiểu chữ / Màu chung (khối ghép) — khối chỉ có phần phụ (tiêu đề: chữ tô sáng, liên kết) vẫn giữ mục chung
|
|
57
|
+
const hasParts = single && blockControls().some((c) => c.partsOnly && c.parts && (c.blocks === "*" || c.blocks.includes(first.type)));
|
|
45
58
|
const Custom = single ? type?.inspector : undefined;
|
|
46
59
|
const styled = type?.supports?.style !== false && !store.isContentOnly(first.id);
|
|
47
60
|
const bindable = type?.bindable ?? CORE_BINDABLE[first.type];
|
|
@@ -50,44 +63,64 @@ export function Inspector({ blockStyles }: { blockStyles?: Record<string, Array<
|
|
|
50
63
|
<div className="ecx-inspector">
|
|
51
64
|
<div className="ecx-block-card">
|
|
52
65
|
<Icon className="ecx-icon ecx-card-icon" />
|
|
53
|
-
<
|
|
66
|
+
<strong>{nodes.length > 1 ? `${nodes.length} ${labels.blocks}` : (typeof first.attrs.customName === "string" && first.attrs.customName) || (type?.title ?? first.type)}</strong>
|
|
67
|
+
{/* Mô tả khối: nút ⓘ (rê / bấm) thay cho 2–3 dòng chữ chiếm chỗ đầu bảng */}
|
|
68
|
+
{type?.description && nodes.length === 1 && <span className="ecx-card-info" tabIndex={0} role="note" aria-label={type.description} title={type.description}><Info className="ecx-icon" /><span className="ecx-card-tip">{type.description}</span></span>}
|
|
54
69
|
</div>
|
|
70
|
+
{single && styled && !disabled && <PresetBar block={first} setAttrs={setAttrs} />}
|
|
55
71
|
{disabled ? <p className="ecx-muted">{labels.readOnly}</p> : (
|
|
56
72
|
<>
|
|
57
73
|
<div className="ecx-tabs" role="tablist">
|
|
58
|
-
<button type="button" role="tab" aria-selected={tab === "settings"} className={cx(tab === "settings" && "is-active")} onClick={() => setTab("settings")}
|
|
59
|
-
{styled && <button type="button" role="tab" aria-selected={tab === "style"} className={cx(tab === "style" && "is-active")} onClick={() => setTab("style")}
|
|
60
|
-
{(styled || nodes.length === 1) && <button type="button" role="tab" aria-selected={tab === "advanced"} className={cx(tab === "advanced" && "is-active")} onClick={() => setTab("advanced")}
|
|
74
|
+
<button type="button" role="tab" aria-selected={tab === "settings"} className={cx(tab === "settings" && "is-active")} onClick={() => setTab("settings")}><LayoutPanelTop className="ecx-icon" />{labels.settings}</button>
|
|
75
|
+
{styled && <button type="button" role="tab" aria-selected={tab === "style"} className={cx(tab === "style" && "is-active")} onClick={() => setTab("style")}><Paintbrush className="ecx-icon" />{t.styles}</button>}
|
|
76
|
+
{(styled || nodes.length === 1) && <button type="button" role="tab" aria-selected={tab === "advanced"} className={cx(tab === "advanced" && "is-active")} onClick={() => setTab("advanced")}><SlidersHorizontal className="ecx-icon" />{t.advanced}</button>}
|
|
61
77
|
</div>
|
|
78
|
+
<SectionGroup key={`${first.id}:${tab}`}>
|
|
62
79
|
{tab === "settings" || (tab === "style" && !styled) ? (
|
|
63
80
|
<div className="ecx-panel">
|
|
81
|
+
{single && first.type === "group" && <GroupWidthSection attrs={first.attrs} setAttrs={setAttrs} />}
|
|
64
82
|
{same && type && <AttrForm type={type} attrs={first.attrs} onChange={setAttrs} />}
|
|
65
83
|
{styled && single && BG_IN_SETTINGS.has(first.type) && <BackgroundControl key={first.id} type={first.type} attrs={first.attrs} setAttrs={setAttrs} device={device} />}
|
|
84
|
+
{styled && single && first.type === "group" && <DividerSection key={`d${first.id}`} attrs={first.attrs} setAttrs={setAttrs} />}
|
|
85
|
+
{styled && single && <LayoutSection type={first.type} style={first.attrs.style} onChange={(st) => setAttrs({ style: st ?? undefined })} device={device} />}
|
|
66
86
|
{Custom && <Custom block={first} attrs={first.attrs} setAttrs={setAttrs} blockProps={null as never} selected editable labels={labels} />}
|
|
67
87
|
{same && nodes.length === 1 && <PluginPanels type={first.type} attrs={first.attrs} setAttrs={setAttrs} />}
|
|
68
88
|
{nodes.length === 1 && bindable?.length && <BindingsPanel block={first} bindable={bindable} onChange={(b) => setAttrs({ bindings: b })} />}
|
|
69
89
|
</div>
|
|
70
90
|
) : tab === "style" ? (
|
|
71
91
|
<div className="ecx-panel">
|
|
92
|
+
{/* Khối chứa: Nền là mục đầu của tab Kiểu dáng (như bộ khối lớn) */}
|
|
93
|
+
{single && BG_FIRST.has(first.type) && <BackgroundControl key={first.id} type={first.type} attrs={first.attrs} setAttrs={setAttrs} device={device} />}
|
|
72
94
|
<StyleTab type={first.type} style={first.attrs.style} onChange={(st) => setAttrs({ style: st ?? undefined })} device={device} onDeviceChange={setDevice} part="style"
|
|
73
95
|
variants={variants.length ? variants : undefined} variant={(first.attrs.blockStyle as string) ?? null} onVariantChange={(v) => setAttrs({ blockStyle: v ?? undefined })}
|
|
96
|
+
parts={hasParts}
|
|
74
97
|
lead={single && <>
|
|
75
|
-
<
|
|
76
|
-
|
|
98
|
+
<PartsSections blockId={first.id} type={first.type} attrs={first.attrs} setAttrs={setAttrs} device={device} />
|
|
99
|
+
<BlockStyleSections type={first.type} attrs={first.attrs} setAttrs={setAttrs} device={device} legacyOnly={hasParts} />
|
|
100
|
+
{!BG_IN_SETTINGS.has(first.type) && !BG_FIRST.has(first.type) && (styleGroups(first.type, type).has("background") || !!(first.attrs.style as { background?: unknown } | undefined)?.background) && <BackgroundControl key={first.id} type={first.type} attrs={first.attrs} setAttrs={setAttrs} device={device} />}
|
|
77
101
|
</>} />
|
|
78
102
|
{single && <PluginPanels type={first.type} attrs={first.attrs} setAttrs={setAttrs} tab="style" />}
|
|
79
103
|
</div>
|
|
80
104
|
) : (
|
|
81
105
|
<div className="ecx-panel">
|
|
82
|
-
{styled && <StyleTab type={first.type} style={first.attrs.style} onChange={(st) => setAttrs({ style: st ?? undefined })} device={device} onDeviceChange={setDevice} part="advanced"
|
|
106
|
+
{styled && <StyleTab type={first.type} style={first.attrs.style} onChange={(st) => setAttrs({ style: st ?? undefined })} device={device} onDeviceChange={setDevice} part="advanced"
|
|
107
|
+
structure={single && TAGGED.has(first.type) && (
|
|
108
|
+
<Row label={t.htmlTag} onReset={first.attrs.tagName ? () => setAttrs({ tagName: undefined }) : undefined}>
|
|
109
|
+
<select className="ecx-input" aria-label={t.htmlTag} value={String(first.attrs.tagName ?? "div")} onChange={(e) => setAttrs({ tagName: e.target.value === "div" ? undefined : e.target.value })}>
|
|
110
|
+
{CONTAINER_TAGS.map((x) => <option key={x} value={x}>{x}</option>)}
|
|
111
|
+
</select>
|
|
112
|
+
</Row>
|
|
113
|
+
)} />}
|
|
83
114
|
{nodes.length === 1 && (
|
|
84
|
-
<
|
|
115
|
+
<Section title={t.advanced} defaultOpen>
|
|
85
116
|
<Field label={attrName("anchor", labels.lang) ?? "anchor"}><input className="ecx-input" value={String(first.attrs.anchor ?? "")} onChange={(e) => setAttrs({ anchor: e.target.value.replace(/[^\w-]/g, "") || undefined })} /></Field>
|
|
86
117
|
<Field label={attrName("className", labels.lang) ?? "className"}><input className="ecx-input" value={String(first.attrs.className ?? "")} onChange={(e) => setAttrs({ className: e.target.value || undefined })} /></Field>
|
|
87
|
-
</
|
|
118
|
+
</Section>
|
|
88
119
|
)}
|
|
120
|
+
{nodes.length === 1 && <PluginPanels type={first.type} attrs={first.attrs} setAttrs={setAttrs} tab="advanced" />}
|
|
89
121
|
</div>
|
|
90
122
|
)}
|
|
123
|
+
</SectionGroup>
|
|
91
124
|
</>
|
|
92
125
|
)}
|
|
93
126
|
</div>
|
|
@@ -95,7 +128,7 @@ export function Inspector({ blockStyles }: { blockStyles?: Record<string, Array<
|
|
|
95
128
|
}
|
|
96
129
|
|
|
97
130
|
/** Panel của plugin (registerBlockPanel) cho loại khối đang chọn. */
|
|
98
|
-
function PluginPanels({ type, attrs, setAttrs, tab = "block" }: { type: string; attrs: Record<string, any>; setAttrs(a: Record<string, unknown>): void; tab?: "block" | "style" }) {
|
|
131
|
+
function PluginPanels({ type, attrs, setAttrs, tab = "block" }: { type: string; attrs: Record<string, any>; setAttrs(a: Record<string, unknown>): void; tab?: "block" | "style" | "advanced" }) {
|
|
99
132
|
const { host } = useEditor();
|
|
100
133
|
useSyncExternalStore(onBlockPanelsChange, () => blockPanelsFor(type, tab).length, () => 0);
|
|
101
134
|
const panels = blockPanelsFor(type, tab);
|
|
@@ -103,10 +136,9 @@ function PluginPanels({ type, attrs, setAttrs, tab = "block" }: { type: string;
|
|
|
103
136
|
return (
|
|
104
137
|
<>
|
|
105
138
|
{panels.map((p) => (
|
|
106
|
-
<
|
|
107
|
-
<summary>{host.translate ? host.translate(p.title) : p.title}</summary>
|
|
139
|
+
<Section key={p.id} title={host.translate ? host.translate(p.title) : p.title} defaultOpen={false}>
|
|
108
140
|
{p.component ? <p.component type={type} attrs={attrs} setAttrs={setAttrs} /> : <ControlFields panel={p} attrs={attrs} setAttrs={setAttrs} />}
|
|
109
|
-
</
|
|
141
|
+
</Section>
|
|
110
142
|
))}
|
|
111
143
|
</>
|
|
112
144
|
);
|
|
@@ -3,7 +3,6 @@ import { AlignCenterVertical, AlignEndVertical, AlignStartVertical, ArrowDown, A
|
|
|
3
3
|
import { useState } from "react";
|
|
4
4
|
import { useEditor } from "../context";
|
|
5
5
|
import { useMsgs } from "../i18n";
|
|
6
|
-
import { ColorInput } from "./color-field";
|
|
7
6
|
import { Row, Section, Seg, cx } from "./style-controls";
|
|
8
7
|
|
|
9
8
|
/**
|
|
@@ -11,7 +10,7 @@ import { Row, Section, Seg, cx } from "./style-controls";
|
|
|
11
10
|
* Giá trị theo khổ (hướng, căn, số cột) sửa theo khổ đang chọn ở bảng Kiểu dáng (`device`).
|
|
12
11
|
*/
|
|
13
12
|
/** Khối chứa (có khối con) mới có mục Bố cục. */
|
|
14
|
-
const CONTAINERS = new Set(["group", "
|
|
13
|
+
const CONTAINERS = new Set(["group", "cover", "blockquote", "callout", "details", "query", "postTemplate", "mediaText"]);
|
|
15
14
|
|
|
16
15
|
type Kind = "flow" | "row" | "stack" | "grid";
|
|
17
16
|
export const layoutKind = (l?: BlockLayout): Kind => (!l ? "flow" : l.type === "grid" ? "grid" : l.direction?.base === "column" ? "stack" : "row");
|
|
@@ -53,9 +52,8 @@ export function GradientField({ value, onChange }: { value?: string; onChange(g:
|
|
|
53
52
|
);
|
|
54
53
|
}
|
|
55
54
|
|
|
56
|
-
/**
|
|
57
|
-
export function
|
|
58
|
-
const { labels, host } = useEditor();
|
|
55
|
+
/** Mục Bố cục của khối chứa (tab Cài đặt): nhóm / hàng ngang / xếp dọc / lưới, hướng, căn, số cột — theo khổ đang chọn. */
|
|
56
|
+
export function LayoutSection({ type, style: raw, onChange, device }: { type: string; style: unknown; onChange(style: BlockStyle | null): void; device: Device }) {
|
|
59
57
|
const t = useMsgs("layout");
|
|
60
58
|
const style: BlockStyle = normalizeStyle(raw) ?? {};
|
|
61
59
|
const set = (patch: Partial<BlockStyle>) => {
|
|
@@ -73,12 +71,9 @@ export function LayoutEffectsPanel({ type, style: raw, onChange, device, effects
|
|
|
73
71
|
return Object.keys(next).length ? next : undefined;
|
|
74
72
|
};
|
|
75
73
|
|
|
76
|
-
|
|
77
|
-
|
|
74
|
+
if (!CONTAINERS.has(type)) return null;
|
|
78
75
|
return (
|
|
79
|
-
|
|
80
|
-
{CONTAINERS.has(type) && (
|
|
81
|
-
<Section title={t.layout}>
|
|
76
|
+
<Section title={t.layout} defaultOpen={l ? true : undefined}>
|
|
82
77
|
<Row label={t.type}>
|
|
83
78
|
<Seg<Kind> label={t.type} value={kind} onChange={(k) => set({ layout: layoutFor(k ?? "flow", l) })}
|
|
84
79
|
options={[["flow", Square, t.flow], ["row", Columns3, t.row], ["stack", Rows3, t.stack], ["grid", LayoutGrid, t.grid]]} />
|
|
@@ -116,42 +111,5 @@ export function LayoutEffectsPanel({ type, style: raw, onChange, device, effects
|
|
|
116
111
|
)}
|
|
117
112
|
</>}
|
|
118
113
|
</Section>
|
|
119
|
-
)}
|
|
120
|
-
|
|
121
|
-
{effects && <Section title={t.effects} defaultOpen={!!(style.gradient || style.shadow || style.aspectRatio || style.position)}>
|
|
122
|
-
{gradient && <Row label={t.gradient}><GradientField value={style.gradient} onChange={(g) => set({ gradient: g })} /></Row>}
|
|
123
|
-
<Row label={t.shadow}>
|
|
124
|
-
<select className="ecx-input" aria-label={t.shadow} value={style.shadow ?? ""} onChange={(e) => set({ shadow: e.target.value || undefined })}>
|
|
125
|
-
<option value="">—</option><option value="none">{t.none}</option>
|
|
126
|
-
{shadows.map((s) => <option key={s} value={s}>{s.toUpperCase()}</option>)}
|
|
127
|
-
</select>
|
|
128
|
-
</Row>
|
|
129
|
-
<Row label={t.ratio}>
|
|
130
|
-
<select className="ecx-input" aria-label={t.ratio} value={style.aspectRatio ?? ""} onChange={(e) => set({ aspectRatio: e.target.value || undefined })}>
|
|
131
|
-
<option value="">—</option>
|
|
132
|
-
{["1/1", "4/3", "3/2", "16/9", "21/9", "3/4", "2/3", "9/16"].map((r) => <option key={r} value={r}>{r.replace("/", ":")}</option>)}
|
|
133
|
-
</select>
|
|
134
|
-
</Row>
|
|
135
|
-
<label className="ecx-check"><input type="checkbox" checked={!!style.position} onChange={(e) => set({ position: e.target.checked ? { type: "sticky" } : undefined })} /> {t.sticky}</label>
|
|
136
|
-
</Section>}
|
|
137
|
-
|
|
138
|
-
{hover && <Section title={t.hover} defaultOpen={!!style.hover}>
|
|
139
|
-
{(["text", "background"] as const).map((k) => (
|
|
140
|
-
<Row key={k} label={t[k]}>
|
|
141
|
-
<ColorInput label={t[k]} value={style.hover?.color?.[k]} onChange={(v) => set({ hover: { ...style.hover, color: { ...style.hover?.color, [k]: v } } })} />
|
|
142
|
-
</Row>
|
|
143
|
-
))}
|
|
144
|
-
<Row label={t.border}>
|
|
145
|
-
<ColorInput label={t.border} value={style.hover?.border?.color} onChange={(v) => set({ hover: { ...style.hover, border: v ? { color: v } : undefined } })} />
|
|
146
|
-
</Row>
|
|
147
|
-
<Row label={t.shadow}>
|
|
148
|
-
<select className="ecx-input" aria-label={`${t.hover} ${t.shadow}`} value={style.hover?.shadow ?? ""} onChange={(e) => set({ hover: { ...style.hover, shadow: e.target.value || undefined } })}>
|
|
149
|
-
<option value="">—</option>{shadows.map((s) => <option key={s} value={s}>{s.toUpperCase()}</option>)}
|
|
150
|
-
</select>
|
|
151
|
-
</Row>
|
|
152
|
-
<label className="ecx-check"><input type="checkbox" checked={!!style.hover?.lift} onChange={(e) => set({ hover: { ...style.hover, lift: e.target.checked || undefined } })} /> {t.lift}</label>
|
|
153
|
-
</Section>}
|
|
154
|
-
</div>
|
|
155
114
|
);
|
|
156
115
|
}
|
|
157
|
-
|
package/src/v2/ui/list-view.tsx
CHANGED
|
@@ -1,16 +1,18 @@
|
|
|
1
|
-
import { ChevronDown, ChevronRight, GripVertical, Lock, Blocks } from "lucide-react";
|
|
1
|
+
import { ChevronDown, ChevronRight, GripVertical, Lock, Blocks, MoreVertical, X, EyeOff } from "lucide-react";
|
|
2
2
|
import { useCallback, useState } from "react";
|
|
3
3
|
import { startDrag } from "../canvas/dnd";
|
|
4
4
|
import { useEditor, useEditorState } from "../context";
|
|
5
5
|
import { inlineText, type BNode } from "../core/model";
|
|
6
6
|
import type { BlockType } from "../core/registry";
|
|
7
7
|
import { cx } from "./attr-form";
|
|
8
|
+
import { isHidden } from "./block-menu";
|
|
8
9
|
|
|
9
10
|
// ---------------------------------------------------------------------------
|
|
10
11
|
// Cây khối
|
|
11
12
|
// ---------------------------------------------------------------------------
|
|
12
13
|
/** Tên hiển thị của một khối trong cây: loại + đoạn chữ đầu. */
|
|
13
14
|
export function blockLabel(node: BNode, type: BlockType | undefined): string {
|
|
15
|
+
if (typeof node.attrs.customName === "string" && node.attrs.customName) return node.attrs.customName;
|
|
14
16
|
const text = node.inline ? inlineText(node.inline).trim() : node.content?.find((c) => c.inline && inlineText(c.inline).trim()) ? inlineText(node.content.find((c) => c.inline && inlineText(c.inline).trim())!.inline).trim() : "";
|
|
15
17
|
const summary = type?.summary?.(node.attrs);
|
|
16
18
|
const base = type?.title ?? node.type;
|
|
@@ -18,16 +20,77 @@ export function blockLabel(node: BNode, type: BlockType | undefined): string {
|
|
|
18
20
|
return extra ? `${base} · ${extra.slice(0, 40)}` : base;
|
|
19
21
|
}
|
|
20
22
|
|
|
21
|
-
|
|
23
|
+
/** Cột trái "Cây khối": tab Cây khối / Dàn ý (tiêu đề + số chữ) và nút đóng. */
|
|
24
|
+
export function ListView({ onClose }: { onClose?(): void }) {
|
|
22
25
|
const { labels } = useEditor();
|
|
26
|
+
const [tab, setTab] = useState<"tree" | "outline">("tree");
|
|
23
27
|
const activeId = useEditorState((s) => s.focus[s.focus.length - 1] ?? s.rootId);
|
|
24
28
|
const doc = useEditorState(useCallback((s) => s.docs[activeId], [activeId]));
|
|
25
29
|
if (!doc) return null;
|
|
26
30
|
return (
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
+
<>
|
|
32
|
+
<div className="ecx-tabs ecx-left-tabs">
|
|
33
|
+
<div className="ecx-tablist" role="tablist">
|
|
34
|
+
<button type="button" role="tab" aria-selected={tab === "tree"} className={tab === "tree" ? "is-active" : undefined} onClick={() => setTab("tree")}>{labels.listView}</button>
|
|
35
|
+
<button type="button" role="tab" aria-selected={tab === "outline"} className={tab === "outline" ? "is-active" : undefined} onClick={() => setTab("outline")}>{labels.outline}</button>
|
|
36
|
+
</div>
|
|
37
|
+
{onClose && <button type="button" className="ecx-left-close" aria-label={labels.close} title={labels.close} onClick={onClose}><X className="ecx-icon" /></button>}
|
|
38
|
+
</div>
|
|
39
|
+
{tab === "outline" ? <Outline blocks={doc.blocks} /> : (
|
|
40
|
+
<div className="ecx-listview" role="tree" aria-label={labels.listView}>
|
|
41
|
+
{doc.blocks.map((b, i) => <ListRow key={b.id} node={b} depth={0} first={i === 0} />)}
|
|
42
|
+
{!doc.blocks.length && <p className="ecx-muted ecx-list-empty">{labels.listEmpty}</p>}
|
|
43
|
+
</div>
|
|
44
|
+
)}
|
|
45
|
+
</>
|
|
46
|
+
);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/** Thống kê chữ + dàn ý tiêu đề của tài liệu (như tab Outline của WordPress): báo cấp tiêu đề nhảy cóc, tiêu đề trống. */
|
|
50
|
+
export function outlineOf(blocks: BNode[]) {
|
|
51
|
+
const heads: Array<{ id: string; level: number; text: string; skipped: boolean }> = [];
|
|
52
|
+
let text = "";
|
|
53
|
+
let prev = 0;
|
|
54
|
+
const walk = (list: BNode[]) => list.forEach((b) => {
|
|
55
|
+
if (b.inline) {
|
|
56
|
+
const t = inlineText(b.inline);
|
|
57
|
+
text += ` ${t}`;
|
|
58
|
+
if (b.type === "heading") {
|
|
59
|
+
const level = Number(b.attrs.level) || 2;
|
|
60
|
+
heads.push({ id: b.id, level, text: t.trim(), skipped: prev > 0 && level > prev + 1 });
|
|
61
|
+
prev = level;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
if (b.content) walk(b.content);
|
|
65
|
+
});
|
|
66
|
+
walk(blocks);
|
|
67
|
+
const words = text.trim() ? text.trim().split(/\s+/).length : 0;
|
|
68
|
+
return { heads, words, chars: text.replace(/\s+/g, "").length, minutes: Math.max(1, Math.ceil(words / 200)) };
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
function Outline({ blocks }: { blocks: BNode[] }) {
|
|
72
|
+
const { store, ui, labels } = useEditor();
|
|
73
|
+
const o = outlineOf(blocks);
|
|
74
|
+
return (
|
|
75
|
+
<div className="ecx-outline">
|
|
76
|
+
<dl className="ecx-outline-stats">
|
|
77
|
+
<div><dt>{labels.outlineChars}</dt><dd>{o.chars.toLocaleString()}</dd></div>
|
|
78
|
+
<div><dt>{labels.outlineWords}</dt><dd>{o.words.toLocaleString()}</dd></div>
|
|
79
|
+
<div><dt>{labels.outlineTime}</dt><dd>{o.minutes} {labels.outlineMinutes}</dd></div>
|
|
80
|
+
</dl>
|
|
81
|
+
{o.heads.length ? (
|
|
82
|
+
<ul className="ecx-outline-heads">
|
|
83
|
+
{o.heads.map((h) => (
|
|
84
|
+
<li key={h.id} style={{ paddingLeft: (h.level - 1) * 12 }}>
|
|
85
|
+
<button type="button" onClick={() => { store.select([h.id], { editing: null }); ui.blockEl(h.id)?.scrollIntoView({ block: "center", behavior: "smooth" }); }}>
|
|
86
|
+
<span className="ecx-outline-level">H{h.level}</span>
|
|
87
|
+
<span className={cx(!h.text && "ecx-muted")}>{h.text || labels.outlineEmpty}</span>
|
|
88
|
+
{h.skipped && <em className="ecx-outline-warn">{labels.outlineSkipped}</em>}
|
|
89
|
+
</button>
|
|
90
|
+
</li>
|
|
91
|
+
))}
|
|
92
|
+
</ul>
|
|
93
|
+
) : <p className="ecx-muted">{labels.outlineNone}</p>}
|
|
31
94
|
</div>
|
|
32
95
|
);
|
|
33
96
|
}
|
|
@@ -46,6 +109,13 @@ function ListRow({ node, depth, first }: { node: BNode; depth: number; first?: b
|
|
|
46
109
|
const nestedBlocks = useEditorState(useCallback((s) => (nestedId ? s.docs[nestedId]?.blocks ?? null : null), [nestedId]));
|
|
47
110
|
const kids = node.content ?? nestedBlocks ?? [];
|
|
48
111
|
const hasKids = kids.length > 0;
|
|
112
|
+
// Menu ⋮ / chuột phải của dòng = menu khối dùng chung (chọn khối trước, như WordPress); khối trong phần dùng chung lồng thì không
|
|
113
|
+
const openMenu = (x: number, y: number) => {
|
|
114
|
+
if (!store.locate(node.id)) return;
|
|
115
|
+
if (!selected) store.select([node.id], { editing: null });
|
|
116
|
+
const ids = store.getState().selection.ids.includes(node.id) ? store.getState().selection.ids : [node.id];
|
|
117
|
+
ui.openContextMenu({ x, y, ids });
|
|
118
|
+
};
|
|
49
119
|
return (
|
|
50
120
|
<div role="treeitem" aria-selected={selected} aria-expanded={hasKids ? open : undefined} aria-level={depth + 1}>
|
|
51
121
|
<div className={cx("ecx-list-row", selected && "is-selected", nestedId && "is-nested")} style={{ paddingLeft: 8 + depth * 14 }} data-block={node.id}
|
|
@@ -56,11 +126,15 @@ function ListRow({ node, depth, first }: { node: BNode; depth: number; first?: b
|
|
|
56
126
|
if (e.shiftKey) store.selectRange(node.id);
|
|
57
127
|
else store.select([node.id], { editing: null });
|
|
58
128
|
ui.blockEl(node.id)?.scrollIntoView({ block: "nearest", behavior: "smooth" });
|
|
59
|
-
}}
|
|
129
|
+
}}
|
|
130
|
+
onContextMenu={(e) => { e.preventDefault(); openMenu(e.clientX, e.clientY); }}>
|
|
60
131
|
{hasKids ? <button type="button" className="ecx-twisty" aria-label={open ? ctx.labels.collapse : ctx.labels.expand} onClick={(e) => { e.stopPropagation(); setOpen(!open); }}>{open ? <ChevronDown className="ecx-icon" /> : <ChevronRight className="ecx-icon" />}</button> : <span className="ecx-twisty" />}
|
|
61
132
|
<Icon className="ecx-icon" />
|
|
62
133
|
<span className="ecx-list-title">{blockLabel(node, type)}</span>
|
|
134
|
+
{isHidden(node) && <EyeOff className="ecx-icon ecx-icon-sm" aria-label={ctx.labels.hidden} />}
|
|
63
135
|
{!!(node.attrs.lock || node.attrs.templateLock) && <Lock className="ecx-icon ecx-icon-sm" aria-label={ctx.labels.locked} />}
|
|
136
|
+
<button type="button" className="ecx-list-menu" aria-label={ctx.labels.options} title={ctx.labels.options} tabIndex={-1}
|
|
137
|
+
onClick={(e) => { e.stopPropagation(); const r = e.currentTarget.getBoundingClientRect(); openMenu(r.left, r.bottom + 4); }}><MoreVertical className="ecx-icon" /></button>
|
|
64
138
|
<span className="ecx-list-drag" onPointerDown={(e) => { e.stopPropagation(); startDrag(ctx, e, [node.id]); }} title={ctx.labels.drag}><GripVertical className="ecx-icon" /></span>
|
|
65
139
|
</div>
|
|
66
140
|
{hasKids && open && <div role="group">{kids.map((k) => <ListRow key={k.id} node={k} depth={depth + 1} />)}</div>}
|
|
@@ -46,13 +46,14 @@ export function MotionPanel({ type, style: raw, onChange }: { type: string; styl
|
|
|
46
46
|
if (preview) window.setTimeout(() => previewMotion(blockId ? ui.blockEl(blockId) : null, merged?.motion), 120);
|
|
47
47
|
};
|
|
48
48
|
|
|
49
|
+
const ct = useMsgs("controls");
|
|
49
50
|
const coreIn = MOTION_IN as readonly string[];
|
|
50
51
|
const isPlugin = !!m.in && !coreIn.includes(m.in);
|
|
51
52
|
const groups = new Map<string, typeof plugin>();
|
|
52
53
|
for (const e of plugin) groups.set(e.group ?? t.plugin, [...(groups.get(e.group ?? t.plugin) ?? []), e]);
|
|
53
54
|
|
|
54
55
|
return (
|
|
55
|
-
<Section title={t.title} defaultOpen={
|
|
56
|
+
<Section title={t.title} defaultOpen={false} modified={!!style.motion} summary={m.in ? (t.in as Record<string, string>)[m.in] ?? m.in : ct.noMotion} onReset={() => onChange(normalizeStyle({ ...style, motion: undefined }) ?? null)}>
|
|
56
57
|
<Row label={t.scroll}>
|
|
57
58
|
<div className="ecx-chip-row" role="radiogroup" aria-label={t.scroll}>
|
|
58
59
|
<button type="button" role="radio" aria-checked={!m.in} className={cx("ecx-chip", !m.in && "is-active")} onClick={() => set({ in: undefined, duration: undefined, delay: undefined, repeat: undefined, stagger: undefined })}>{t.none}</button>
|