@ecomcx/ecomweb-editor 1.20.0 → 1.21.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/README.md +15 -0
- package/package.json +3 -3
- package/src/i18n/index.ts +74 -0
- package/src/index.ts +3 -1
- package/src/legacy/basic.tsx +8 -30
- package/src/legacy/dynamic.tsx +7 -35
- package/src/locales/en/attrs.ts +72 -0
- package/src/locales/en/bindings.ts +26 -0
- package/src/locales/en/block-desc.ts +53 -0
- package/src/locales/en/block-titles.ts +43 -0
- package/src/locales/en/blocks.ts +39 -0
- package/src/locales/en/controls.ts +18 -0
- package/src/locales/en/hints.ts +142 -0
- package/src/locales/en/index.ts +20 -0
- package/src/locales/en/layout.ts +37 -0
- package/src/locales/en/legacy-basic.ts +54 -0
- package/src/locales/en/legacy-dynamic.ts +73 -0
- package/src/locales/en/legacy.ts +67 -0
- package/src/locales/en/motion.ts +33 -0
- package/src/locales/en/pattern-lib.ts +151 -0
- package/src/locales/en/patterns.ts +45 -0
- package/src/locales/en/shortcuts.ts +19 -0
- package/src/locales/en/v2.ts +177 -0
- package/src/locales/vi/attrs.ts +72 -0
- package/src/locales/vi/bindings.ts +26 -0
- package/src/locales/vi/block-desc.ts +53 -0
- package/src/locales/vi/block-titles.ts +43 -0
- package/src/locales/vi/blocks.ts +39 -0
- package/src/locales/vi/controls.ts +18 -0
- package/src/locales/vi/hints.ts +142 -0
- package/src/locales/vi/index.ts +24 -0
- package/src/locales/vi/layout.ts +37 -0
- package/src/locales/vi/legacy-basic.ts +54 -0
- package/src/locales/vi/legacy-dynamic.ts +73 -0
- package/src/locales/vi/legacy.ts +67 -0
- package/src/locales/vi/motion.ts +33 -0
- package/src/locales/vi/pattern-lib.ts +151 -0
- package/src/locales/vi/patterns.ts +45 -0
- package/src/locales/vi/shortcuts.ts +19 -0
- package/src/locales/vi/v2.ts +177 -0
- package/src/shared/animation-store.ts +38 -0
- package/src/shared/labels.ts +11 -134
- package/src/shared/patterns-kit.ts +7 -0
- package/src/shared/patterns-library.ts +152 -0
- package/src/shared/patterns.ts +6 -32
- package/src/v2/blocks/index.ts +5 -11
- package/src/v2/blocks/inline-style.ts +30 -0
- package/src/v2/blocks/layout.tsx +19 -14
- package/src/v2/blocks/media.tsx +19 -15
- package/src/v2/blocks/theme.tsx +20 -17
- package/src/v2/canvas/canvas.tsx +9 -1
- package/src/v2/core/bindings.ts +9 -8
- package/src/v2/editor.tsx +7 -4
- package/src/v2/i18n.ts +14 -0
- package/src/v2/index.ts +3 -1
- package/src/v2/labels.ts +11 -348
- package/src/v2/ui/attr-form.tsx +14 -29
- package/src/v2/ui/attr-hints.ts +84 -74
- package/src/v2/ui/bindings.tsx +10 -12
- package/src/v2/ui/block-descriptions.ts +6 -33
- package/src/v2/ui/inserter.tsx +2 -2
- package/src/v2/ui/inspector.tsx +7 -5
- package/src/v2/ui/layout-panel.tsx +3 -14
- package/src/v2/ui/motion-panel.tsx +99 -0
- package/src/v2/ui/options.tsx +6 -13
- package/src/v2/ui/style-controls.tsx +7 -6
- package/src/v2/ui/style-tab.tsx +9 -4
- package/src/v2/ui/unit-controls.tsx +6 -5
package/src/v2/ui/attr-hints.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { format, messages } from "../../i18n";
|
|
1
2
|
import type { ChoiceKind } from "../core/host";
|
|
2
3
|
|
|
3
4
|
/**
|
|
@@ -5,10 +6,13 @@ import type { ChoiceKind } from "../core/host";
|
|
|
5
6
|
* "horizontal"), ô chọn lấy dữ liệu thật từ ứng dụng (vị trí menu, loại bài, chuyên mục…), thanh kéo, gợi ý,
|
|
6
7
|
* và điều kiện hiện. Khoá: "khối.thuộc_tính" hoặc "*.thuộc_tính" (mọi khối).
|
|
7
8
|
*/
|
|
8
|
-
|
|
9
|
+
/** Giá trị của một lựa chọn; nhãn lấy từ src/locales/<ngôn ngữ>/hints.ts (khoá "khối.thuộc_tính.opt.<giá trị>"). */
|
|
10
|
+
export type Opt = string | number;
|
|
9
11
|
export interface AttrHint {
|
|
10
|
-
/**
|
|
11
|
-
label?:
|
|
12
|
+
/** Thuộc tính có nhãn riêng ở khối này (chữ: hints "<khoá>.label"). */
|
|
13
|
+
label?: true;
|
|
14
|
+
/** Khoá của hint (do hintOf điền) — dùng tra chữ. */
|
|
15
|
+
key?: string;
|
|
12
16
|
control?: "select" | "segmented" | "range" | "choice" | "newTab" | "suggest" | "code" | "hidden";
|
|
13
17
|
options?: Opt[];
|
|
14
18
|
/** Ô chọn lấy dữ liệu từ ứng dụng (host.choices); tham số tính từ thuộc tính hiện tại. */
|
|
@@ -20,110 +24,116 @@ export interface AttrHint {
|
|
|
20
24
|
unit?: string;
|
|
21
25
|
/** Chỉ hiện khi điều kiện đúng (vd chuyên mục chỉ khi không "theo trang đang xem"). */
|
|
22
26
|
when?: (attrs: Record<string, unknown>) => boolean;
|
|
23
|
-
/**
|
|
24
|
-
help?:
|
|
27
|
+
/** Có ghi chú dưới ô (chữ: hints "<khoá>.help"). */
|
|
28
|
+
help?: true;
|
|
25
29
|
}
|
|
26
30
|
|
|
27
|
-
const ALIGN: Opt[] = [
|
|
28
|
-
const V_ALIGN: Opt[] = [
|
|
29
|
-
const SIZES: Opt[] = [
|
|
30
|
-
const levels = (from: number, to: number, zero?:
|
|
31
|
-
...(zero ? [
|
|
32
|
-
...Array.from({ length: to - from + 1 }, (_, i) =>
|
|
31
|
+
const ALIGN: Opt[] = ["left", "center", "right"];
|
|
32
|
+
const V_ALIGN: Opt[] = ["top", "center", "bottom"];
|
|
33
|
+
const SIZES: Opt[] = ["small", "medium", "large"];
|
|
34
|
+
const levels = (from: number, to: number, zero?: boolean): Opt[] => [
|
|
35
|
+
...(zero ? [0] : []),
|
|
36
|
+
...Array.from({ length: to - from + 1 }, (_, i) => from + i),
|
|
33
37
|
];
|
|
34
38
|
const notInherit = (a: Record<string, unknown>) => a.inherit === false;
|
|
35
39
|
|
|
36
40
|
export const ATTR_HINTS: Record<string, AttrHint> = {
|
|
37
|
-
"*.textAlign": { control: "segmented", options: [...ALIGN,
|
|
41
|
+
"*.textAlign": { control: "segmented", options: [...ALIGN, "justify"] },
|
|
38
42
|
"*.mime": { control: "hidden" },
|
|
39
43
|
"video.name": { control: "hidden" },
|
|
40
|
-
"video.autoplay": { label:
|
|
41
|
-
"video.loop": { label:
|
|
42
|
-
"video.muted": { label:
|
|
43
|
-
"video.controls": { label:
|
|
44
|
-
"video.playsInline": { label:
|
|
45
|
-
"video.preload": { control: "select", label:
|
|
46
|
-
"audio.autoplay": { label:
|
|
47
|
-
"audio.loop": { label:
|
|
48
|
-
"audio.preload": { control: "select", label:
|
|
44
|
+
"video.autoplay": { label: true },
|
|
45
|
+
"video.loop": { label: true },
|
|
46
|
+
"video.muted": { label: true },
|
|
47
|
+
"video.controls": { label: true },
|
|
48
|
+
"video.playsInline": { label: true },
|
|
49
|
+
"video.preload": { control: "select", label: true, options: ["none", "metadata", "auto"] },
|
|
50
|
+
"audio.autoplay": { label: true },
|
|
51
|
+
"audio.loop": { label: true },
|
|
52
|
+
"audio.preload": { control: "select", label: true, options: ["none", "metadata", "auto"] },
|
|
49
53
|
"file.size": { control: "hidden" },
|
|
50
|
-
"file.name": { label:
|
|
51
|
-
"file.src": { label:
|
|
52
|
-
"video.src": { label:
|
|
53
|
-
"audio.src": { label:
|
|
54
|
-
"youtube.src": { label:
|
|
55
|
-
"youtube.start": { label:
|
|
56
|
-
"image.src": { label:
|
|
57
|
-
"cover.src": { label:
|
|
58
|
-
"pullquote.citation": { label:
|
|
54
|
+
"file.name": { label: true },
|
|
55
|
+
"file.src": { label: true },
|
|
56
|
+
"video.src": { label: true },
|
|
57
|
+
"audio.src": { label: true },
|
|
58
|
+
"youtube.src": { label: true },
|
|
59
|
+
"youtube.start": { label: true },
|
|
60
|
+
"image.src": { label: true },
|
|
61
|
+
"cover.src": { label: true },
|
|
62
|
+
"pullquote.citation": { label: true },
|
|
59
63
|
"audio.name": { control: "hidden" },
|
|
60
|
-
"heading.level": { control: "select", options: levels(1, 6), help:
|
|
64
|
+
"heading.level": { control: "select", options: levels(1, 6), help: true },
|
|
61
65
|
"postTitle.level": { control: "select", options: levels(1, 6) },
|
|
62
|
-
"queryTitle.level": { control: "select", options: levels(1, 6), help:
|
|
63
|
-
"breadcrumbs.separator": { control: "segmented", options: [
|
|
64
|
-
"siteTitle.level": { control: "select", options: levels(1, 6,
|
|
66
|
+
"queryTitle.level": { control: "select", options: levels(1, 6), help: true },
|
|
67
|
+
"breadcrumbs.separator": { control: "segmented", options: ["›", "/", "»", "→"] },
|
|
68
|
+
"siteTitle.level": { control: "select", options: levels(1, 6, true) },
|
|
65
69
|
"tableOfContents.maxLevel": { control: "select", options: levels(2, 6) },
|
|
66
70
|
"codeBlock.language": { control: "suggest", suggestions: ["plaintext", "html", "css", "javascript", "typescript", "jsx", "tsx", "json", "php", "python", "bash", "sql", "csharp", "java", "go", "rust", "yaml", "markdown", "xml"] },
|
|
67
71
|
"customHtml.html": { control: "code" },
|
|
68
|
-
"group.padding": { control: "segmented", options: [
|
|
72
|
+
"group.padding": { control: "segmented", options: ["none", "small", "medium", "large"] },
|
|
69
73
|
"columns.verticalAlign": { control: "segmented", options: V_ALIGN },
|
|
70
74
|
"mediaText.verticalAlign": { control: "segmented", options: V_ALIGN },
|
|
71
75
|
"cover.contentAlign": { control: "segmented", options: V_ALIGN },
|
|
72
76
|
"cover.opacity": { control: "range", min: 0, max: 100, step: 5, unit: "%" },
|
|
73
|
-
"mediaText.position": { control: "segmented", options: [
|
|
77
|
+
"mediaText.position": { control: "segmented", options: ["left", "right"] },
|
|
74
78
|
"mediaText.width": { control: "range", min: 15, max: 85, step: 5, unit: "%" },
|
|
75
|
-
"buttons.align": { control: "segmented", options: [...ALIGN,
|
|
76
|
-
"button.variant": { control: "segmented", options: [
|
|
79
|
+
"buttons.align": { control: "segmented", options: [...ALIGN, "space-between"] },
|
|
80
|
+
"button.variant": { control: "segmented", options: ["primary", "secondary", "outline"] },
|
|
77
81
|
"button.target": { control: "newTab" },
|
|
78
|
-
"button.rel": { when: (a) => !!a.href, help:
|
|
79
|
-
"spacer.height": { control: "suggest", suggestions: ["xs", "sm", "md", "lg", "xl", "2xl", "2rem", "4rem", "80px"], help:
|
|
80
|
-
"callout.tone": { control: "segmented", options: [
|
|
81
|
-
"image.align": { control: "select", options: [...ALIGN,
|
|
82
|
+
"button.rel": { when: (a) => !!a.href, help: true },
|
|
83
|
+
"spacer.height": { control: "suggest", suggestions: ["xs", "sm", "md", "lg", "xl", "2xl", "2rem", "4rem", "80px"], help: true },
|
|
84
|
+
"callout.tone": { control: "segmented", options: ["info", "success", "warning", "danger"] },
|
|
85
|
+
"image.align": { control: "select", options: [...ALIGN, "wide", "full"] },
|
|
82
86
|
"image.size": { control: "choice", choice: { kind: "imageSize" } },
|
|
83
87
|
"featuredImage.size": { control: "choice", choice: { kind: "imageSize" } },
|
|
84
|
-
"featuredImage.aspect": { control: "select", options: [
|
|
88
|
+
"featuredImage.aspect": { control: "select", options: ["auto", "16/9", "4/3", "1/1", "3/4"] },
|
|
85
89
|
"socialLinks.size": { control: "segmented", options: SIZES },
|
|
86
90
|
"socialLinks.align": { control: "segmented", options: ALIGN },
|
|
87
|
-
"navigation.location": { control: "choice", choice: { kind: "menuLocation" }, help:
|
|
88
|
-
"navigation.orientation": { control: "segmented", options: [
|
|
91
|
+
"navigation.location": { control: "choice", choice: { kind: "menuLocation" }, help: true },
|
|
92
|
+
"navigation.orientation": { control: "segmented", options: ["horizontal", "vertical"] },
|
|
89
93
|
"postTerms.taxonomy": { control: "choice", choice: { kind: "taxonomy" } },
|
|
90
94
|
"query.postType": { control: "choice", choice: { kind: "postType" }, when: notInherit },
|
|
91
95
|
"query.category": { control: "choice", choice: { kind: "term", args: () => ({ taxonomy: "category" }) }, when: notInherit },
|
|
92
96
|
"query.tag": { control: "choice", choice: { kind: "term", args: () => ({ taxonomy: "post_tag" }) }, when: notInherit },
|
|
93
97
|
"query.perPage": { when: notInherit },
|
|
94
|
-
"query.orderBy": { control: "select", options: [
|
|
95
|
-
"query.authorId": { label:
|
|
96
|
-
"query.search": { label:
|
|
97
|
-
"query.exclude": { label:
|
|
98
|
-
"query.sticky": { control: "select", options: [
|
|
99
|
-
"image.href": { label:
|
|
100
|
-
"image.linkTarget": { control: "segmented", label:
|
|
101
|
-
"orderedList.reversed": { label:
|
|
102
|
-
"blockquote.citation": { label:
|
|
103
|
-
"postDate.displayType": { control: "segmented", label:
|
|
104
|
-
"query.paginate": { label:
|
|
105
|
-
"query.orderByMeta": { label:
|
|
106
|
-
"query.order": { control: "segmented", options: [
|
|
107
|
-
"query.inherit": { help:
|
|
108
|
-
"postTemplate.layout": { control: "segmented", options: [
|
|
98
|
+
"query.orderBy": { control: "select", options: ["date", "modified", "title", "comment_count", "menu_order", "rand"], when: notInherit },
|
|
99
|
+
"query.authorId": { label: true, when: notInherit },
|
|
100
|
+
"query.search": { label: true, when: notInherit },
|
|
101
|
+
"query.exclude": { label: true, when: notInherit },
|
|
102
|
+
"query.sticky": { control: "select", options: ["any", "only", "exclude"], when: notInherit },
|
|
103
|
+
"image.href": { label: true },
|
|
104
|
+
"image.linkTarget": { control: "segmented", label: true, options: ["_self", "_blank"] },
|
|
105
|
+
"orderedList.reversed": { label: true },
|
|
106
|
+
"blockquote.citation": { label: true },
|
|
107
|
+
"postDate.displayType": { control: "segmented", label: true, options: ["published", "modified"] },
|
|
108
|
+
"query.paginate": { label: true, help: true, when: notInherit },
|
|
109
|
+
"query.orderByMeta": { label: true, help: true, when: notInherit },
|
|
110
|
+
"query.order": { control: "segmented", options: ["desc", "asc"], when: notInherit },
|
|
111
|
+
"query.inherit": { help: true },
|
|
112
|
+
"postTemplate.layout": { control: "segmented", options: ["list", "grid"] },
|
|
109
113
|
"postTemplate.columns": { control: "range", min: 1, max: 6, step: 1, when: (a) => a.layout === "grid" },
|
|
110
114
|
"templatePart.slug": { control: "choice", choice: { kind: "templatePart" } },
|
|
111
|
-
"templatePart.tagName": { control: "select", options: [
|
|
115
|
+
"templatePart.tagName": { control: "select", options: ["div", "header", "footer", "aside", "section"] },
|
|
112
116
|
};
|
|
113
117
|
|
|
114
|
-
|
|
115
|
-
const
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
118
|
+
export function hintOf(block: string, attr: string): AttrHint {
|
|
119
|
+
const key = ATTR_HINTS[`${block}.${attr}`] ? `${block}.${attr}` : ATTR_HINTS[`*.${attr}`] ? `*.${attr}` : "";
|
|
120
|
+
return { ...(key ? ATTR_HINTS[key] : {}), key };
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
const text = (v: unknown): string | undefined => (typeof v === "string" ? v : undefined);
|
|
124
|
+
|
|
125
|
+
/** Chữ nhãn / ghi chú của hint theo ngôn ngữ (undefined nếu hint không khai báo). */
|
|
126
|
+
export const hintText = (hint: AttrHint, part: "label" | "help", lang: string): string | undefined =>
|
|
127
|
+
hint[part] && hint.key ? text(messages("hints", lang)[`${hint.key}.${part}`]) : undefined;
|
|
120
128
|
|
|
121
|
-
|
|
122
|
-
export function optionLabel(hint: AttrHint, value: unknown, lang:
|
|
123
|
-
const
|
|
124
|
-
|
|
125
|
-
|
|
129
|
+
/** Nhãn của giá trị chọn: riêng của hint, rồi mẫu "Tiêu đề N", rồi nhãn chung của giá trị, cuối cùng là giá trị thô. */
|
|
130
|
+
export function optionLabel(hint: AttrHint, value: unknown, lang: string, fallback?: string): string {
|
|
131
|
+
const t = messages("hints", lang);
|
|
132
|
+
const v = String(value);
|
|
133
|
+
if (hint.options?.some((x) => String(x) === v)) return text(t[`${hint.key}.opt.${v}`]) ?? (typeof value === "number" && value > 0 ? format(text(t.levelOption) ?? v, { n: value }) : undefined) ?? text(t[`value.${v}`]) ?? v;
|
|
134
|
+
return fallback ?? text(t[`value.${v}`]) ?? v;
|
|
126
135
|
}
|
|
127
136
|
|
|
128
|
-
/** Cỡ ảnh mặc định khi ứng dụng không khai báo. */
|
|
129
|
-
export const DEFAULT_IMAGE_SIZES: Opt[] = [
|
|
137
|
+
/** Cỡ ảnh mặc định khi ứng dụng không khai báo (nhãn: hints "imageSize.<cỡ>"). */
|
|
138
|
+
export const DEFAULT_IMAGE_SIZES: Opt[] = ["thumbnail", "medium", "large", "full"];
|
|
139
|
+
export const imageSizeLabel = (size: string, lang: string): string => text(messages("hints", lang)[`imageSize.${size}`]) ?? size;
|
package/src/v2/ui/bindings.tsx
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Database, Unlink } from "lucide-react";
|
|
2
2
|
import { createElement, useEffect, useState, useSyncExternalStore, type CSSProperties } from "react";
|
|
3
|
-
import { useDynamicData
|
|
3
|
+
import { useDynamicData } from "../context";
|
|
4
|
+
import { useMsgs } from "../i18n";
|
|
4
5
|
import { bindingSource, bindingSources, bindingsOf, subscribeBindingSources, type Binding } from "../core/bindings";
|
|
5
6
|
import type { BNode } from "../core/model";
|
|
6
7
|
import type { BlockProps } from "../core/registry";
|
|
@@ -29,13 +30,10 @@ export function useBindingPreview(block: BNode, attr: string): { bound: boolean;
|
|
|
29
30
|
|
|
30
31
|
/** Mục "Gắn dữ liệu" của bảng cài đặt: mỗi thuộc tính gắn được một dòng chọn nguồn + trường. */
|
|
31
32
|
export function BindingsPanel({ block, bindable, onChange }: { block: BNode; bindable: string[]; onChange(bindings: Record<string, Binding> | undefined): void }) {
|
|
32
|
-
const { labels } = useEditor();
|
|
33
33
|
const all = useSyncExternalStore(subscribeBindingSources, bindingSources, bindingSources);
|
|
34
34
|
const current = bindingsOf(block) ?? {};
|
|
35
|
-
const
|
|
36
|
-
const ATTR: Record<string, string> =
|
|
37
|
-
? { content: "Nội dung", src: "Ảnh", alt: "Mô tả ảnh", caption: "Chú thích", text: "Chữ trên nút", href: "Liên kết" }
|
|
38
|
-
: { content: "Content", src: "Image", alt: "Alt text", caption: "Caption", text: "Button text", href: "Link" };
|
|
35
|
+
const t = useMsgs("bindings");
|
|
36
|
+
const ATTR: Record<string, string> = { content: t.attrContent, src: t.attrSrc, alt: t.attrAlt, caption: t.attrCaption, text: t.attrText, href: t.attrHref };
|
|
39
37
|
const set = (attr: string, b: Binding | undefined) => {
|
|
40
38
|
const next = { ...current };
|
|
41
39
|
if (b) next[attr] = b; else delete next[attr];
|
|
@@ -43,8 +41,8 @@ export function BindingsPanel({ block, bindable, onChange }: { block: BNode; bin
|
|
|
43
41
|
};
|
|
44
42
|
return (
|
|
45
43
|
<details className="ecx-advanced ecx-bindings" open={Object.keys(current).length > 0}>
|
|
46
|
-
<summary><Database className="ecx-icon ecx-icon-sm" /> {
|
|
47
|
-
<p className="ecx-muted">{
|
|
44
|
+
<summary><Database className="ecx-icon ecx-icon-sm" /> {t.panelTitle}</summary>
|
|
45
|
+
<p className="ecx-muted">{t.panelHelp}</p>
|
|
48
46
|
{bindable.map((attr) => {
|
|
49
47
|
const b = current[attr];
|
|
50
48
|
const src = b ? all.find((s) => s.name === b.source) : undefined;
|
|
@@ -54,16 +52,16 @@ export function BindingsPanel({ block, bindable, onChange }: { block: BNode; bin
|
|
|
54
52
|
<div key={attr} className="ecx-binding-row" data-binding={attr}>
|
|
55
53
|
<span className="ecx-field-label">{ATTR[attr] ?? attr}</span>
|
|
56
54
|
<div className="ecx-color-row">
|
|
57
|
-
<select className="ecx-input" aria-label={`${ATTR[attr] ?? attr}: ${
|
|
55
|
+
<select className="ecx-input" aria-label={`${ATTR[attr] ?? attr}: ${t.source}`} value={b?.source ?? ""}
|
|
58
56
|
onChange={(e) => { const s = all.find((x) => x.name === e.target.value); set(attr, s ? { source: s.name, args: s.fields?.length ? { [s.argKey ?? "field"]: s.fields[0].value } : {} } : undefined); }}>
|
|
59
|
-
<option value="">{
|
|
57
|
+
<option value="">{t.notBound}</option>
|
|
60
58
|
{options.map((s) => <option key={s.name} value={s.name}>{s.label}</option>)}
|
|
61
59
|
{b && !src && <option value={b.source}>{b.source}</option>}
|
|
62
60
|
</select>
|
|
63
|
-
{b && <button type="button" className="ecx-tool" aria-label={
|
|
61
|
+
{b && <button type="button" className="ecx-tool" aria-label={t.unbind} title={t.unbind} onClick={() => set(attr, undefined)}><Unlink className="ecx-icon" /></button>}
|
|
64
62
|
</div>
|
|
65
63
|
{b && (src?.fields?.length
|
|
66
|
-
? <select className="ecx-input" aria-label={`${ATTR[attr] ?? attr}: ${
|
|
64
|
+
? <select className="ecx-input" aria-label={`${ATTR[attr] ?? attr}: ${t.field}`} value={String(b.args?.[argKey] ?? "")} onChange={(e) => set(attr, { ...b, args: { ...b.args, [argKey]: e.target.value } })}>
|
|
67
65
|
{src.fields.map((f) => <option key={f.value} value={f.value}>{f.label}</option>)}
|
|
68
66
|
</select>
|
|
69
67
|
: <input className="ecx-input" aria-label={`${ATTR[attr] ?? attr}: ${argKey}`} placeholder={argKey} value={String(b.args?.[argKey] ?? "")}
|
|
@@ -1,34 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
codeBlock: ["Hiện mã nguồn, giữ nguyên khoảng trắng.", "Display code snippets that respect spacing."], preformatted: ["Chữ giữ nguyên khoảng trắng và xuống dòng.", "Text that respects spacing and tabs."],
|
|
8
|
-
pullquote: ["Trích dẫn nổi bật, chữ lớn ở giữa trang.", "A large, eye-catching quote."], details: ["Nội dung ẩn, bấm để mở (câu hỏi thường gặp…).", "Hide content until the visitor opens it (FAQ…)."],
|
|
9
|
-
table: ["Bảng dữ liệu hàng / cột, gộp ô được.", "Rows and columns of data; cells can be merged."],
|
|
10
|
-
image: ["Ảnh có chú thích, alt cho SEO, đổi cỡ bằng tay kéo.", "An image with caption and alt text; drag to resize."],
|
|
11
|
-
gallery: ["Nhiều ảnh xếp lưới.", "Several images in a grid."], cover: ["Ảnh hoặc màu nền lớn với chữ đè lên — phần mở đầu trang.", "A large image or colour with text on top — a page hero."],
|
|
12
|
-
mediaText: ["Ảnh và chữ đặt cạnh nhau để bố cục hấp dẫn hơn.", "Media and text side by side for a richer layout."],
|
|
13
|
-
video: ["Video tải lên hoặc từ địa chỉ.", "An uploaded or linked video."], audio: ["Tệp âm thanh có trình phát.", "An audio player."],
|
|
14
|
-
file: ["Liên kết tải tệp (PDF…), có thể xem ngay trên trang.", "A downloadable file (PDF…), optionally embedded."],
|
|
15
|
-
youtube: ["Nhúng video YouTube.", "Embed a YouTube video."], embed: ["Nhúng nội dung từ địa chỉ (Facebook, TikTok, bản đồ…).", "Embed content from a URL."],
|
|
16
|
-
group: ["Gom nhiều khối vào một khung để tô nền, căn lề, bố cục chung.", "Gather blocks in a container to style them together."],
|
|
17
|
-
columns: ["Chia nội dung thành nhiều cột, kéo để đổi độ rộng.", "Display content in columns; drag to resize."],
|
|
18
|
-
buttons: ["Một hoặc nhiều nút kêu gọi hành động.", "Prompt visitors to take action with buttons."], spacer: ["Khoảng trống giữa các khối.", "Add white space between blocks."],
|
|
19
|
-
horizontalRule: ["Đường kẻ ngăn cách các phần.", "Separate sections with a line."], callout: ["Hộp lưu ý / cảnh báo nổi bật.", "Highlight a tip or warning."],
|
|
20
|
-
customHtml: ["Chèn HTML tự viết (đã được làm sạch).", "Add custom (sanitised) HTML."], socialLinks: ["Biểu tượng liên kết mạng xã hội.", "Icons linking to social profiles."],
|
|
21
|
-
tableOfContents: ["Mục lục tự sinh từ các tiêu đề trong bài.", "An automatic table of contents from headings."],
|
|
22
|
-
siteTitle: ["Tên website (lấy từ Cài đặt).", "The site title from Settings."], siteLogo: ["Logo của website.", "The site logo."], siteTagline: ["Khẩu hiệu của website.", "The site tagline."],
|
|
23
|
-
navigation: ["Menu điều hướng theo vị trí của theme.", "A navigation menu for a theme location."], search: ["Ô tìm kiếm.", "A search form."],
|
|
24
|
-
languageSwitcher: ["Chuyển ngôn ngữ của website.", "Switch the site language."], copyright: ["Dòng bản quyền với năm hiện tại.", "A copyright line with the current year."],
|
|
25
|
-
postTitle: ["Tiêu đề của bài đang xem.", "The current post's title."], postContent: ["Nội dung của bài đang xem.", "The current post's content."],
|
|
26
|
-
postExcerpt: ["Tóm tắt của bài.", "The post excerpt."], featuredImage: ["Ảnh đại diện của bài.", "The post's featured image."], postDate: ["Ngày đăng bài.", "The publish date."],
|
|
27
|
-
postAuthor: ["Tác giả bài viết.", "The post author."], postTerms: ["Chuyên mục / thẻ của bài.", "The post's categories or tags."], comments: ["Bình luận của bài.", "The post comments."],
|
|
28
|
-
queryTitle: ["Tiêu đề (H1) của trang chuyên mục, thẻ, tác giả, kết quả tìm kiếm.", "The H1 of category, tag, author and search pages."],
|
|
29
|
-
termDescription: ["Mô tả của chuyên mục / thẻ đang xem.", "The current category / tag description."],
|
|
30
|
-
breadcrumbs: ["Đường dẫn Trang chủ › Chuyên mục › Bài, kèm dữ liệu cấu trúc cho Google.", "Home › Category › Post trail with structured data for Google."],
|
|
31
|
-
postNavigation: ["Liên kết tới bài trước và bài sau.", "Links to the previous and next posts."],
|
|
32
|
-
query: ["Danh sách bài theo điều kiện (chuyên mục, số bài, sắp xếp).", "A list of posts by criteria."], templatePart: ["Phần dùng chung (header, footer…) — sửa một nơi, đổi mọi trang.", "A shared part (header, footer…) — edit once, update everywhere."],
|
|
1
|
+
import { messages } from "../../i18n";
|
|
2
|
+
|
|
3
|
+
/** Mô tả ngắn của khối lõi (thẻ xem trước khi rê chuột trong thư viện khối). Chữ nằm ở src/locales/<ngôn ngữ>/blockDesc.ts, khoá = tên khối. */
|
|
4
|
+
export const blockDescription = (type: string, lang: string): string | undefined => {
|
|
5
|
+
const d = messages("blockDesc", lang)[type];
|
|
6
|
+
return typeof d === "string" ? d : undefined;
|
|
33
7
|
};
|
|
34
|
-
export const blockDescription = (type: string, lang: "vi" | "en") => D[type]?.[lang === "vi" ? 0 : 1];
|
package/src/v2/ui/inserter.tsx
CHANGED
|
@@ -10,7 +10,7 @@ import { startDragNew } from "../canvas/dnd";
|
|
|
10
10
|
import { usePrefs } from "../prefs";
|
|
11
11
|
import { onPatternsChange, patternBlocks, registeredPatterns, type Pattern } from "../core/patterns";
|
|
12
12
|
import { useSyncExternalStore } from "react";
|
|
13
|
-
import {
|
|
13
|
+
import { labelsLegacy } from "../../shared/labels";
|
|
14
14
|
|
|
15
15
|
export interface InsertOption {
|
|
16
16
|
key: string;
|
|
@@ -269,7 +269,7 @@ function PatternList({ query, onInserted }: { query: string; onInserted?(): void
|
|
|
269
269
|
const q = norm(query.trim());
|
|
270
270
|
const list = q ? all.filter((p) => norm(`${p.title} ${p.keywords ?? ""} ${p.category}`).includes(q)) : all;
|
|
271
271
|
const cats = [...new Set(list.map((p) => p.category))];
|
|
272
|
-
const v1 = labels.lang
|
|
272
|
+
const v1 = labelsLegacy(labels.lang);
|
|
273
273
|
const catName = (c: string) => String((v1 as Record<string, unknown>)[`cat_${c}`] ?? c);
|
|
274
274
|
const insert = (p: Pattern) => {
|
|
275
275
|
const nodes = patternBlocks(p);
|
package/src/v2/ui/inspector.tsx
CHANGED
|
@@ -5,13 +5,15 @@ import { useState, useSyncExternalStore } from "react";
|
|
|
5
5
|
import { blockPanelsFor, onBlockPanelsChange } from "../../shared/panel-store";
|
|
6
6
|
import { useEditor, useEditorState } from "../context";
|
|
7
7
|
import type { BNode } from "../core/model";
|
|
8
|
-
import {
|
|
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 { useMsgs } from "../i18n";
|
|
11
12
|
|
|
12
13
|
/** Bảng cài đặt của khối đang chọn: thẻ khối, tab Cài đặt (form + phần riêng của khối), tab Kiểu dáng. */
|
|
13
14
|
export function Inspector({ blockStyles }: { blockStyles?: Record<string, Array<{ name: string; label: string }>> }) {
|
|
14
15
|
const { store, registry, labels } = useEditor();
|
|
16
|
+
const t = useMsgs("controls");
|
|
15
17
|
const sel = useEditorState((s) => s.selection);
|
|
16
18
|
useEditorState((s) => s.revision);
|
|
17
19
|
const [tab, setTab] = useState<"settings" | "style">("settings");
|
|
@@ -38,7 +40,7 @@ export function Inspector({ blockStyles }: { blockStyles?: Record<string, Array<
|
|
|
38
40
|
<>
|
|
39
41
|
<div className="ecx-tabs" role="tablist">
|
|
40
42
|
<button type="button" role="tab" aria-selected={tab === "settings"} className={cx(tab === "settings" && "is-active")} onClick={() => setTab("settings")}>{labels.settings}</button>
|
|
41
|
-
{type?.supports?.style !== false && !store.isContentOnly(first.id) && <button type="button" role="tab" aria-selected={tab === "style"} className={cx(tab === "style" && "is-active")} onClick={() => setTab("style")}>{
|
|
43
|
+
{type?.supports?.style !== false && !store.isContentOnly(first.id) && <button type="button" role="tab" aria-selected={tab === "style"} className={cx(tab === "style" && "is-active")} onClick={() => setTab("style")}>{t.styles}</button>}
|
|
42
44
|
</div>
|
|
43
45
|
{tab === "settings" ? (
|
|
44
46
|
<div className="ecx-panel">
|
|
@@ -48,9 +50,9 @@ export function Inspector({ blockStyles }: { blockStyles?: Record<string, Array<
|
|
|
48
50
|
{nodes.length === 1 && bindable?.length && <BindingsPanel block={first} bindable={bindable} onChange={(b) => setAttrs({ bindings: b })} />}
|
|
49
51
|
{nodes.length === 1 && (
|
|
50
52
|
<details className="ecx-advanced">
|
|
51
|
-
<summary>{
|
|
52
|
-
<Field label={
|
|
53
|
-
<Field label={
|
|
53
|
+
<summary>{t.advanced}</summary>
|
|
54
|
+
<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>
|
|
55
|
+
<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>
|
|
54
56
|
</details>
|
|
55
57
|
)}
|
|
56
58
|
</div>
|
|
@@ -2,6 +2,7 @@ import { normalizeGradient, normalizeStyle, type BlockLayout, type BlockStyle, t
|
|
|
2
2
|
import { AlignCenterVertical, AlignEndVertical, AlignStartVertical, ArrowDown, ArrowRight, Columns3, LayoutGrid, Rows3, Square, StretchVertical, AlignHorizontalSpaceBetween, AlignHorizontalJustifyCenter, AlignHorizontalJustifyEnd, AlignHorizontalJustifyStart } from "lucide-react";
|
|
3
3
|
import { useState } from "react";
|
|
4
4
|
import { useEditor } from "../context";
|
|
5
|
+
import { useMsgs } from "../i18n";
|
|
5
6
|
import { ColorInput } from "./color-field";
|
|
6
7
|
import { Row, Section, Seg, cx } from "./style-controls";
|
|
7
8
|
|
|
@@ -9,18 +10,6 @@ import { Row, Section, Seg, cx } from "./style-controls";
|
|
|
9
10
|
* Bố cục, nền chuyển màu, bóng, tỉ lệ, ghim và hover (@ecomcx/ecomweb-content 1.15) — phần thêm của tab Kiểu dáng.
|
|
10
11
|
* 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`).
|
|
11
12
|
*/
|
|
12
|
-
const V = { vi: {
|
|
13
|
-
layout: "Bố cục", type: "Kiểu", flow: "Nhóm", row: "Hàng ngang", stack: "Xếp dọc", grid: "Lưới", direction: "Hướng", justify: "Căn ngang", align: "Căn dọc",
|
|
14
|
-
wrap: "Cho xuống dòng", columns: "Số cột", auto: "Tự chia", minWidth: "Rộng tối thiểu mỗi cột", effects: "Nền & hiệu ứng", gradient: "Nền chuyển màu",
|
|
15
|
-
angle: "Góc", from: "Từ", to: "Đến", none: "Không", shadow: "Đổ bóng", ratio: "Tỉ lệ khung", sticky: "Ghim khi cuộn", top: "Cách mép trên",
|
|
16
|
-
hover: "Khi rê chuột", text: "Màu chữ", background: "Màu nền", border: "Màu viền", lift: "Nhấc lên", start: "Đầu", center: "Giữa", end: "Cuối", between: "Dàn đều", stretch: "Kéo giãn",
|
|
17
|
-
}, en: {
|
|
18
|
-
layout: "Layout", type: "Type", flow: "Group", row: "Row", stack: "Stack", grid: "Grid", direction: "Direction", justify: "Justify", align: "Align",
|
|
19
|
-
wrap: "Allow wrapping", columns: "Columns", auto: "Auto", minWidth: "Minimum column width", effects: "Background & effects", gradient: "Gradient",
|
|
20
|
-
angle: "Angle", from: "From", to: "To", none: "None", shadow: "Shadow", ratio: "Aspect ratio", sticky: "Sticky", top: "Top offset",
|
|
21
|
-
hover: "Hover", text: "Text color", background: "Background", border: "Border color", lift: "Lift", start: "Start", center: "Center", end: "End", between: "Space between", stretch: "Stretch",
|
|
22
|
-
} };
|
|
23
|
-
|
|
24
13
|
/** Khối chứa (có khối con) mới có mục Bố cục. */
|
|
25
14
|
const CONTAINERS = new Set(["group", "column", "cover", "blockquote", "callout", "details", "query", "postTemplate", "mediaText"]);
|
|
26
15
|
|
|
@@ -34,7 +23,7 @@ export function layoutFor(kind: Kind, prev?: BlockLayout): BlockLayout | undefin
|
|
|
34
23
|
|
|
35
24
|
export function LayoutEffectsPanel({ type, style: raw, onChange, device }: { type: string; style: unknown; onChange(style: BlockStyle | null): void; device: Device }) {
|
|
36
25
|
const { labels, host } = useEditor();
|
|
37
|
-
const t =
|
|
26
|
+
const t = useMsgs("layout");
|
|
38
27
|
const style: BlockStyle = normalizeStyle(raw) ?? {};
|
|
39
28
|
const set = (patch: Partial<BlockStyle>) => {
|
|
40
29
|
const next = { ...style, ...patch } as Record<string, unknown>;
|
|
@@ -111,7 +100,7 @@ export function LayoutEffectsPanel({ type, style: raw, onChange, device }: { typ
|
|
|
111
100
|
<button key={name} type="button" className={cx("ecx-chip ecx-chip-swatch", style.gradient === name && "is-active")} title={name} aria-label={name}
|
|
112
101
|
style={{ background: host.presets!.gradients![name] }} onClick={() => set({ gradient: name })} />
|
|
113
102
|
))}
|
|
114
|
-
<button type="button" className={cx("ecx-chip ecx-chip-swatch", g && "is-active")} title={
|
|
103
|
+
<button type="button" className={cx("ecx-chip ecx-chip-swatch", g && "is-active")} title={t.custom}
|
|
115
104
|
style={{ background: `linear-gradient(${angle}deg, ${c1}, ${c2})` }} onClick={() => applyCustom()} />
|
|
116
105
|
</div>
|
|
117
106
|
{g && (
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { MOTION_HOVER, MOTION_IN, normalizeStyle, type BlockStyle } from "@ecomcx/ecomweb-content";
|
|
2
|
+
import { Play } from "lucide-react";
|
|
3
|
+
import { useSyncExternalStore } from "react";
|
|
4
|
+
import { onAnimationsChange, pluginAnimations } from "../../shared/animation-store";
|
|
5
|
+
import { useEditor, useEditorState } from "../context";
|
|
6
|
+
import { useMsgs } from "../i18n";
|
|
7
|
+
import { Row, Section, Seg, cx } from "./style-controls";
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Mục "Chuyển động" của tab Kiểu dáng (attrs.style.motion, @ecomcx/ecomweb-content 1.16): hiệu ứng khi cuộn tới và khi rê chuột,
|
|
11
|
+
* chọn bằng một cú bấm. Hiệu ứng lõi hiện thành chip; hiệu ứng của plugin (registerAnimation) nằm trong danh sách "Hiệu ứng khác".
|
|
12
|
+
* Chọn xong tự chạy thử ngay trong khung soạn; nút "Xem thử" chạy lại. Khung soạn không bao giờ ẩn khối (chỉ website mới ẩn trước khi cuộn tới).
|
|
13
|
+
*/
|
|
14
|
+
type Motion = NonNullable<BlockStyle["motion"]>;
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
const DELAYS = [0, 100, 200, 300, 500, 800, 1200];
|
|
18
|
+
const DURATION_MS = { fast: 300, normal: 600, slow: 1000 } as const;
|
|
19
|
+
|
|
20
|
+
/** Chạy lại hiệu ứng cuộn của một khối trong khung soạn: gỡ rồi đặt lại `is-in` (CSS của khối gắn animation vào `.is-in`). */
|
|
21
|
+
export function previewMotion(el: HTMLElement | null, m: Motion | undefined) {
|
|
22
|
+
if (!el || !m?.in) return;
|
|
23
|
+
el.classList.remove("is-in");
|
|
24
|
+
void el.offsetWidth; // đo lại để trình duyệt khởi động lại animation
|
|
25
|
+
el.classList.add("is-in");
|
|
26
|
+
const total = DURATION_MS[m.duration ?? "normal"] + (m.delay ?? 0) + (m.stagger ? 12 * 80 : 0) + 100;
|
|
27
|
+
window.setTimeout(() => el.classList.remove("is-in"), total);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export function MotionPanel({ type, style: raw, onChange }: { type: string; style: unknown; onChange(style: BlockStyle | null): void }) {
|
|
31
|
+
const { labels, registry, ui } = useEditor();
|
|
32
|
+
const t = useMsgs("motion");
|
|
33
|
+
const plugin = useSyncExternalStore(onAnimationsChange, pluginAnimations, pluginAnimations);
|
|
34
|
+
const sel = useEditorState((s) => s.selection);
|
|
35
|
+
const blockId = sel.ids[0] ?? sel.editing;
|
|
36
|
+
const style: BlockStyle = normalizeStyle(raw) ?? {};
|
|
37
|
+
const m: Motion = style.motion ?? {};
|
|
38
|
+
const container = registry.get(type)?.kind === "container";
|
|
39
|
+
|
|
40
|
+
const set = (patch: Partial<Motion>, preview = false) => {
|
|
41
|
+
const next: Record<string, unknown> = { ...m, ...patch };
|
|
42
|
+
for (const k of Object.keys(next)) if (next[k] === undefined || next[k] === false) delete next[k];
|
|
43
|
+
const merged = normalizeStyle({ ...style, motion: Object.keys(next).length ? next : undefined }) ?? null;
|
|
44
|
+
onChange(merged);
|
|
45
|
+
// Chờ khung soạn nhận CSS mới của khối rồi mới chạy thử
|
|
46
|
+
if (preview) window.setTimeout(() => previewMotion(blockId ? ui.blockEl(blockId) : null, merged?.motion), 120);
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
const coreIn = MOTION_IN as readonly string[];
|
|
50
|
+
const isPlugin = !!m.in && !coreIn.includes(m.in);
|
|
51
|
+
const groups = new Map<string, typeof plugin>();
|
|
52
|
+
for (const e of plugin) groups.set(e.group ?? t.plugin, [...(groups.get(e.group ?? t.plugin) ?? []), e]);
|
|
53
|
+
|
|
54
|
+
return (
|
|
55
|
+
<Section title={t.title} defaultOpen={!!style.motion} modified={!!style.motion} onReset={() => onChange(normalizeStyle({ ...style, motion: undefined }) ?? null)}>
|
|
56
|
+
<Row label={t.scroll}>
|
|
57
|
+
<div className="ecx-chip-row" role="radiogroup" aria-label={t.scroll}>
|
|
58
|
+
<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>
|
|
59
|
+
{MOTION_IN.map((id) => (
|
|
60
|
+
<button key={id} type="button" role="radio" aria-checked={m.in === id} className={cx("ecx-chip", m.in === id && "is-active")} onClick={() => set({ in: id }, true)}>{t.in[id]}</button>
|
|
61
|
+
))}
|
|
62
|
+
</div>
|
|
63
|
+
{plugin.length > 0 && (
|
|
64
|
+
<select className="ecx-input" aria-label={t.more} value={isPlugin ? m.in : ""} onChange={(e) => e.target.value && set({ in: e.target.value }, true)}>
|
|
65
|
+
<option value="">{t.more}…</option>
|
|
66
|
+
{[...groups].map(([g, list]) => <optgroup key={g} label={g}>{list.map((e) => <option key={e.id} value={e.id}>{e.label}</option>)}</optgroup>)}
|
|
67
|
+
</select>
|
|
68
|
+
)}
|
|
69
|
+
{isPlugin && !plugin.some((e) => e.id === m.in) && <p className="ecx-muted">{m.in}</p>}
|
|
70
|
+
</Row>
|
|
71
|
+
|
|
72
|
+
{m.in && (
|
|
73
|
+
<>
|
|
74
|
+
<Row label={t.speed}>
|
|
75
|
+
<Seg label={t.speed} value={m.duration ?? "normal"} onChange={(v) => set({ duration: !v || v === "normal" ? undefined : v }, true)}
|
|
76
|
+
options={[["fast", t.fast, t.fast], ["normal", t.normal, t.normal], ["slow", t.slow, t.slow]]} />
|
|
77
|
+
</Row>
|
|
78
|
+
<Row label={t.delay}>
|
|
79
|
+
<select className="ecx-input" aria-label={t.delay} value={m.delay ?? 0} onChange={(e) => set({ delay: Number(e.target.value) || undefined }, true)}>
|
|
80
|
+
{[...new Set([...DELAYS, m.delay ?? 0])].sort((a, b) => a - b).map((d) => <option key={d} value={d}>{d} ms</option>)}
|
|
81
|
+
</select>
|
|
82
|
+
</Row>
|
|
83
|
+
{container && <label className="ecx-check"><input type="checkbox" checked={!!m.stagger} onChange={(e) => set({ stagger: e.target.checked || undefined }, true)} /> {t.stagger}</label>}
|
|
84
|
+
<label className="ecx-check"><input type="checkbox" checked={!!m.repeat} onChange={(e) => set({ repeat: e.target.checked || undefined })} /> {t.repeat}</label>
|
|
85
|
+
<button type="button" className="ecx-link-btn" onClick={() => previewMotion(blockId ? ui.blockEl(blockId) : null, m)}><Play className="ecx-icon ecx-icon-sm" aria-hidden /> {t.preview}</button>
|
|
86
|
+
</>
|
|
87
|
+
)}
|
|
88
|
+
|
|
89
|
+
<Row label={t.hover}>
|
|
90
|
+
<div className="ecx-chip-row" role="radiogroup" aria-label={t.hover}>
|
|
91
|
+
<button type="button" role="radio" aria-checked={!m.hover} className={cx("ecx-chip", !m.hover && "is-active")} onClick={() => set({ hover: undefined })}>{t.none}</button>
|
|
92
|
+
{MOTION_HOVER.map((id) => (
|
|
93
|
+
<button key={id} type="button" role="radio" aria-checked={m.hover === id} className={cx("ecx-chip", m.hover === id && "is-active")} onClick={() => set({ hover: id })}>{t.hv[id]}</button>
|
|
94
|
+
))}
|
|
95
|
+
</div>
|
|
96
|
+
</Row>
|
|
97
|
+
</Section>
|
|
98
|
+
);
|
|
99
|
+
}
|
package/src/v2/ui/options.tsx
CHANGED
|
@@ -3,6 +3,7 @@ import { Check, ChevronRight, Code2, Copy, Keyboard, MoreVertical, SlidersHorizo
|
|
|
3
3
|
import { useEffect, useMemo, useRef, useState, type ReactNode } from "react";
|
|
4
4
|
import { serializeBlocks } from "../core/clipboard";
|
|
5
5
|
import { useEditor, useEditorState } from "../context";
|
|
6
|
+
import { useMsgs } from "../i18n";
|
|
6
7
|
import { blocksFromDoc, type BNode } from "../core/model";
|
|
7
8
|
import { usePrefs, type EditorPrefs } from "../prefs";
|
|
8
9
|
import { blockLabel } from "./list-view";
|
|
@@ -169,19 +170,11 @@ export function PreferencesModal({ onClose }: { onClose(): void }) {
|
|
|
169
170
|
/** Bảng phím tắt. */
|
|
170
171
|
export function ShortcutsModal({ onClose }: { onClose(): void }) {
|
|
171
172
|
const { labels } = useEditor();
|
|
172
|
-
const
|
|
173
|
-
const rows: Array<[string, string]> =
|
|
174
|
-
[`${MOD}+Z / ${MOD}+⇧+Z`,
|
|
175
|
-
[
|
|
176
|
-
[`${MOD}+
|
|
177
|
-
[`${MOD}+⇧+⌥+T / Y`, "Đưa khối lên / xuống"], ["Alt+F10", "Lên thanh công cụ của khối"], [`${MOD}+B / I / U`, "Đậm / nghiêng / gạch chân"],
|
|
178
|
-
[`${MOD}+K`, "Liên kết"], [`${MOD}+E`, "Mã trong dòng"], ["## · - · 1. · > · ``` · ---", "Gõ tắt: tiêu đề, danh sách, trích dẫn, mã, đường kẻ"],
|
|
179
|
-
] : [
|
|
180
|
-
[`${MOD}+Z / ${MOD}+⇧+Z`, "Undo / redo (across header and footer)"], [`${MOD}+S`, "Save every changed part"], ["/", "Insert a block (in an empty paragraph)"],
|
|
181
|
-
["Enter / ⇧+Enter", "Split block / line break"], ["Tab / ⇧+Tab", "Indent / outdent list item"], ["Esc", "Select the whole block"],
|
|
182
|
-
[`${MOD}+A ×2`, "Select all blocks"], [`${MOD}+⇧+D`, "Duplicate"], ["⇧+⌥+Z", "Delete block"], [`${MOD}+⌥+T / Y`, "Insert before / after"],
|
|
183
|
-
[`${MOD}+⇧+⌥+T / Y`, "Move up / down"], ["Alt+F10", "Go to the block toolbar"], [`${MOD}+B / I / U`, "Bold / italic / underline"],
|
|
184
|
-
[`${MOD}+K`, "Link"], [`${MOD}+E`, "Inline code"], ["## · - · 1. · > · ``` · ---", "Shortcuts: heading, list, quote, code, separator"],
|
|
173
|
+
const t = useMsgs("shortcuts");
|
|
174
|
+
const rows: Array<[string, string]> = [
|
|
175
|
+
[`${MOD}+Z / ${MOD}+⇧+Z`, t.undo], [`${MOD}+S`, t.save], ["/", t.insert], ["Enter / ⇧+Enter", t.split], ["Tab / ⇧+Tab", t.indent], ["Esc", t.esc],
|
|
176
|
+
[`${MOD}+A ×2`, t.selectAll], [`${MOD}+⇧+D`, t.duplicate], ["⇧+⌥+Z", t.remove], [`${MOD}+⌥+T / Y`, t.around], [`${MOD}+⇧+⌥+T / Y`, t.move],
|
|
177
|
+
["Alt+F10", t.toolbar], [`${MOD}+B / I / U`, t.marks], [`${MOD}+K`, t.link], [`${MOD}+E`, t.code], ["## · - · 1. · > · ``` · ---", t.markdown],
|
|
185
178
|
];
|
|
186
179
|
return (
|
|
187
180
|
<Modal title={labels.shortcuts} onClose={onClose}>
|