@ecomcx/ecomweb-editor 1.31.0 → 1.32.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/block-desc.ts +1 -0
- package/src/locales/en/block-style.ts +7 -4
- package/src/locales/en/block-titles.ts +1 -0
- package/src/locales/en/blocks.ts +10 -2
- package/src/locales/en/columns.ts +12 -0
- package/src/locales/en/controls.ts +21 -0
- package/src/locales/en/hints.ts +215 -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 +9 -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/block-desc.ts +1 -0
- package/src/locales/vi/block-style.ts +7 -4
- package/src/locales/vi/block-titles.ts +1 -0
- package/src/locales/vi/blocks.ts +10 -2
- package/src/locales/vi/columns.ts +12 -0
- package/src/locales/vi/controls.ts +21 -0
- package/src/locales/vi/hints.ts +216 -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 +9 -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 +173 -42
- 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 +10 -5
- package/src/v2/blocks/tools.tsx +50 -5
- package/src/v2/blocks/widgets.tsx +44 -16
- package/src/v2/canvas/block-list.tsx +17 -2
- package/src/v2/canvas/canvas-css.ts +54 -4
- package/src/v2/canvas/canvas.tsx +20 -3
- 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 +5 -0
- 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 +40 -11
- package/src/v2/ui/attr-hints.ts +104 -6
- package/src/v2/ui/background-panel.tsx +65 -21
- 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 +51 -7
- 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/attr-hints.ts
CHANGED
|
@@ -14,7 +14,9 @@ export interface AttrHint {
|
|
|
14
14
|
label?: true;
|
|
15
15
|
/** Khoá của hint (do hintOf điền) — dùng tra chữ. */
|
|
16
16
|
key?: string;
|
|
17
|
-
control?: "select" | "segmented" | "range" | "choice" | "newTab" | "suggest" | "code" | "hidden";
|
|
17
|
+
control?: "select" | "segmented" | "range" | "choice" | "newTab" | "suggest" | "code" | "hidden" | "icon";
|
|
18
|
+
/** control "icon": có lựa chọn "Không có icon". */
|
|
19
|
+
allowNone?: true;
|
|
18
20
|
options?: Opt[];
|
|
19
21
|
/** Ô 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
22
|
choice?: { kind: ChoiceKind; args?: (attrs: Record<string, unknown>) => Record<string, string> };
|
|
@@ -27,6 +29,8 @@ export interface AttrHint {
|
|
|
27
29
|
when?: (attrs: Record<string, unknown>) => boolean;
|
|
28
30
|
/** Có ghi chú dưới ô (chữ: hints "<khoá>.help"). */
|
|
29
31
|
help?: true;
|
|
32
|
+
/** Có chữ gợi ý trong ô trống (chữ: hints "<khoá>.placeholder"). */
|
|
33
|
+
placeholder?: true;
|
|
30
34
|
}
|
|
31
35
|
|
|
32
36
|
const ALIGN: Opt[] = ["left", "center", "right"];
|
|
@@ -39,6 +43,81 @@ const levels = (from: number, to: number, zero?: boolean): Opt[] => [
|
|
|
39
43
|
const notInherit = (a: Record<string, unknown>) => a.inherit === false;
|
|
40
44
|
|
|
41
45
|
export const ATTR_HINTS: Record<string, AttrHint> = {
|
|
46
|
+
// v3: chọn icon bằng lưới có ô tìm (mọi khối có thuộc tính icon); nút: icon trái / phải, rộng hết khung, nhãn trình đọc màn hình
|
|
47
|
+
"*.icon": { control: "icon" },
|
|
48
|
+
"button.icon": { control: "icon", allowNone: true },
|
|
49
|
+
"tab.icon": { control: "icon", allowNone: true, label: true },
|
|
50
|
+
"tab.subtitle": { label: true },
|
|
51
|
+
"tabs.orientation": { control: "segmented", label: true, options: ["horizontal", "vertical"] },
|
|
52
|
+
"tabs.mobileAccordion": { label: true },
|
|
53
|
+
"tabs.iconPosition": { control: "segmented", label: true, options: ["left", "right", "top"] },
|
|
54
|
+
"tabs.iconOnly": { label: true, help: true },
|
|
55
|
+
"buttons.orientation": { control: "segmented", label: true, options: ["horizontal", "vertical"] },
|
|
56
|
+
"button.iconOnly": { label: true, when: (a) => !!a.icon },
|
|
57
|
+
"button.iconReveal": { label: true, when: (a) => !!a.icon && a.iconOnly !== true },
|
|
58
|
+
"countdown.layout": { control: "segmented", label: true, options: ["block", "inline"] },
|
|
59
|
+
"countdown.divider": { label: true },
|
|
60
|
+
"countdown.pad": { label: true },
|
|
61
|
+
"countdown.postText": { label: true },
|
|
62
|
+
"countdown.showDays": { label: true },
|
|
63
|
+
"countdown.showSeconds": { label: true },
|
|
64
|
+
"countdown.daysLabel": { label: true, when: (a) => a.showDays !== false },
|
|
65
|
+
"countdown.hoursLabel": { label: true },
|
|
66
|
+
"countdown.minutesLabel": { label: true },
|
|
67
|
+
"countdown.secondsLabel": { label: true, when: (a) => a.showSeconds !== false },
|
|
68
|
+
"map.address": { label: true, help: true },
|
|
69
|
+
"map.title": { label: true, help: true },
|
|
70
|
+
"map.zoom": { control: "range", label: true, min: 1, max: 20, step: 1 },
|
|
71
|
+
"map.height": { control: "range", label: true, min: 150, max: 1000, step: 10, unit: "px" },
|
|
72
|
+
"map.mapType": { control: "segmented", label: true, options: ["roadmap", "satellite"] },
|
|
73
|
+
"progressBar.max": { label: true },
|
|
74
|
+
"progressBar.prefix": { label: true, when: (a) => a.showValue !== false },
|
|
75
|
+
"progressBar.suffix": { label: true, help: true, when: (a) => a.showValue !== false },
|
|
76
|
+
"progressBar.textPosition": { control: "segmented", label: true, options: ["above", "inside", "below"] },
|
|
77
|
+
"progressBar.duration": { label: true, help: true, when: (a) => a.animate !== false },
|
|
78
|
+
"progressBar.decimals": { control: "segmented", label: true, options: ["0", "1", "2"], when: (a) => a.showValue !== false },
|
|
79
|
+
"progressBar.animate": { label: true },
|
|
80
|
+
"progressBar.easing": { control: "select", label: true, options: ["ease", "linear", "ease-in", "ease-out", "ease-in-out"], when: (a) => a.animate !== false },
|
|
81
|
+
"progressBar.ariaLabel": { label: true, help: true },
|
|
82
|
+
"iconBox.media": { control: "segmented", label: true, options: ["icon", "image", "number", "none"] },
|
|
83
|
+
"iconBox.src": { label: true, when: (a) => a.media === "image" },
|
|
84
|
+
"iconBox.alt": { when: (a) => a.media === "image" },
|
|
85
|
+
"iconBox.width": { when: (a) => a.media === "image" },
|
|
86
|
+
"iconBox.height": { when: (a) => a.media === "image" },
|
|
87
|
+
"iconBox.verticalAlign": { control: "segmented", label: true, options: ["top", "center", "bottom"], when: (a) => a.media !== "none" && (a.position === "left" || a.position === "right") },
|
|
88
|
+
"iconBox.fullHeight": { label: true, help: true },
|
|
89
|
+
"iconBox.number": { label: true, when: (a) => a.media === "number" },
|
|
90
|
+
"iconBox.iconStyle": { control: "segmented", label: true, options: ["plain", "circle", "square"], when: (a) => a.media !== "none" && a.media !== "image" },
|
|
91
|
+
"iconBox.hover": { control: "segmented", label: true, options: ["none", "grow", "flip"], when: (a) => a.media !== "none" },
|
|
92
|
+
"iconBox.linkMode": { control: "segmented", label: true, options: ["title", "box", "button"] },
|
|
93
|
+
"iconBox.buttonText": { label: true, help: true, when: (a) => a.linkMode === "button" },
|
|
94
|
+
"tableOfContents.minLevel": { control: "select", label: true, options: levels(2, 6) },
|
|
95
|
+
"tableOfContents.showTitle": { label: true, when: (a) => a.collapsible !== true },
|
|
96
|
+
"tableOfContents.collapsible": { label: true },
|
|
97
|
+
"tableOfContents.startCollapsed": { label: true, when: (a) => a.collapsible === true },
|
|
98
|
+
"tableOfContents.listStyle": { control: "segmented", label: true, options: ["numbers", "bullets", "none"] },
|
|
99
|
+
"tableOfContents.columns": { control: "segmented", label: true, options: [1, 2, 3] },
|
|
100
|
+
"tableOfContents.smoothScroll": { label: true },
|
|
101
|
+
"tableOfContents.highlight": { label: true },
|
|
102
|
+
"accordion.columns": { control: "segmented", label: true, options: [1, 2] },
|
|
103
|
+
"accordion.icon": { control: "segmented", label: true, options: ["arrow", "plus", "none"] },
|
|
104
|
+
"accordion.iconSide": { control: "segmented", label: true, options: ["left", "right"] },
|
|
105
|
+
"accordion.titleTag": { control: "segmented", label: true, help: true },
|
|
106
|
+
"accordion.faq": { label: true, help: true },
|
|
107
|
+
"accordion.startOpen": { control: "segmented", label: true, help: true, options: ["none", "first", "all"] },
|
|
108
|
+
"paragraph.icon": { control: "icon", allowNone: true, label: true },
|
|
109
|
+
"paragraph.iconPosition": { control: "segmented", label: true, options: ["left", "right"], when: (a) => !!a.icon },
|
|
110
|
+
"paragraph.iconTitle": { label: true, help: true, when: (a) => !!a.icon },
|
|
111
|
+
"heading.icon": { control: "icon", allowNone: true, label: true },
|
|
112
|
+
"heading.iconPosition": { control: "segmented", label: true, options: ["left", "right"], when: (a) => !!a.icon },
|
|
113
|
+
"heading.iconTitle": { label: true, help: true, when: (a) => !!a.icon },
|
|
114
|
+
"heading.tocTitle": { label: true, help: true },
|
|
115
|
+
"button.iconPosition": { control: "segmented", options: ["left", "right"], when: (a) => !!a.icon },
|
|
116
|
+
"button.text": { placeholder: true },
|
|
117
|
+
"button.href": { placeholder: true },
|
|
118
|
+
"button.width": { control: "segmented", options: ["auto", "full"] },
|
|
119
|
+
"button.ariaLabel": { help: true },
|
|
120
|
+
"tabs.tabsAlign": { control: "segmented", options: ["flex-start", "center", "flex-end", "space-between"] },
|
|
42
121
|
"*.textAlign": { control: "segmented", options: [...ALIGN, "justify"] },
|
|
43
122
|
"*.mime": { control: "hidden" },
|
|
44
123
|
"video.name": { control: "hidden" },
|
|
@@ -96,6 +175,7 @@ export const ATTR_HINTS: Record<string, AttrHint> = {
|
|
|
96
175
|
"navigation.location": { control: "choice", choice: { kind: "menuLocation" }, help: true },
|
|
97
176
|
"navigation.orientation": { control: "segmented", options: ["horizontal", "vertical"] },
|
|
98
177
|
"navigation.overlayMenu": { control: "segmented", label: true, options: ["never", "mobile", "always"] },
|
|
178
|
+
"gallery.layout": { control: "segmented", label: true, options: ["grid", "masonry"] },
|
|
99
179
|
"gallery.linkTo": { control: "segmented", label: true, options: ["none", "media"] },
|
|
100
180
|
"gallery.imageCrop": { label: true },
|
|
101
181
|
"gallery.lightbox": { label: true },
|
|
@@ -103,12 +183,18 @@ export const ATTR_HINTS: Record<string, AttrHint> = {
|
|
|
103
183
|
// 1.27: form cơ bản
|
|
104
184
|
"form.formId": { control: "hidden" },
|
|
105
185
|
"form.notifyEmail": { help: true },
|
|
186
|
+
"form.notifyCc": { label: true, help: true },
|
|
187
|
+
"form.emailSubject": { label: true, help: true },
|
|
188
|
+
"form.redirect": { label: true, help: true },
|
|
189
|
+
"form.inputSize": { control: "segmented", label: true, options: ["sm", "md", "lg"] },
|
|
106
190
|
"formField.kind": { control: "select", options: ["text", "email", "tel", "textarea", "select", "radio", "checkbox", "consent", "number", "date"] },
|
|
107
191
|
"formField.name": { label: true, help: true },
|
|
108
192
|
"formField.label": { label: true, help: true },
|
|
109
|
-
"formField.width": { control: "segmented", options: ["full", "half"] },
|
|
193
|
+
"formField.width": { control: "segmented", options: ["full", "half", "third"] },
|
|
194
|
+
"formField.autocomplete": { control: "select", label: true, help: true, when: (a) => !["checkbox", "consent", "radio", "select"].includes(String(a.kind ?? "text")), options: ["off", "name", "given-name", "family-name", "email", "tel", "organization", "street-address", "address-level1", "address-level2", "postal-code", "country-name", "bday"] },
|
|
110
195
|
"search.showLabel": { label: true },
|
|
111
196
|
"search.buttonPosition": { control: "segmented", label: true, options: ["right", "left", "below"] },
|
|
197
|
+
"search.buttonStyle": { control: "segmented", label: true, options: ["text", "icon"] },
|
|
112
198
|
"postAuthor.showName": { label: true },
|
|
113
199
|
"postAuthor.showBio": { label: true },
|
|
114
200
|
"postAuthor.avatarSize": { label: true },
|
|
@@ -124,19 +210,31 @@ export const ATTR_HINTS: Record<string, AttrHint> = {
|
|
|
124
210
|
"pageList.parentId": { label: true },
|
|
125
211
|
"archives.showCount": { label: true },
|
|
126
212
|
"icon.name": { control: "select", options: [...ICON_NAMES] },
|
|
127
|
-
"
|
|
128
|
-
"
|
|
213
|
+
"icon.stroke": { control: "range", label: true, min: 0.5, max: 4, step: 0.5 },
|
|
214
|
+
"icon.iconStyle": { control: "segmented", label: true, options: ["plain", "circle", "square"] },
|
|
215
|
+
"icon.linkTarget": { control: "segmented", label: true, options: ["_self", "_blank"], when: (a) => !!a.href },
|
|
216
|
+
"iconBox.icon": { control: "select", options: [...ICON_NAMES], when: (a) => a.media !== "number" && a.media !== "none" && a.media !== "image" },
|
|
217
|
+
"iconBox.position": { control: "segmented", label: true, options: ["top", "left", "right"] },
|
|
129
218
|
"iconBox.level": { control: "select", options: levels(2, 6) },
|
|
130
219
|
"imageBox.level": { control: "select", options: levels(2, 6) },
|
|
131
220
|
"imageBox.src": { label: true },
|
|
132
221
|
"iconList.icon": { control: "select", options: [...ICON_NAMES] },
|
|
133
222
|
"iconList.layout": { control: "segmented", options: ["list", "inline"] },
|
|
223
|
+
"iconList.columns": { control: "range", label: true, min: 1, max: 4, step: 1, when: (a) => a.layout !== "inline" },
|
|
224
|
+
"iconList.iconAlign": { control: "segmented", label: true, options: ["top", "center", "bottom"] },
|
|
225
|
+
"iconList.iconStyle": { control: "segmented", label: true, options: ["plain", "circle", "square"] },
|
|
226
|
+
"iconList.stroke": { control: "range", label: true, min: 0.5, max: 4, step: 0.5 },
|
|
134
227
|
"counter.start": { label: true },
|
|
135
228
|
"counter.prefix": { label: true },
|
|
136
229
|
"counter.separator": { control: "select", label: true, options: ["none", ",", ".", "space"] },
|
|
137
230
|
"counter.duration": { help: true },
|
|
231
|
+
"counter.decimals": { label: true, help: true },
|
|
232
|
+
"counter.titleTag": { control: "select", label: true, options: ["p", "div", "h2", "h3", "h4", "h5", "h6"] },
|
|
138
233
|
"testimonial.src": { label: true },
|
|
139
|
-
"
|
|
234
|
+
"testimonial.variant": { control: "segmented", label: true, options: ["card", "plain", "bubble"] },
|
|
235
|
+
"testimonial.rating": { control: "range", label: true, help: true, min: 0, max: 5, step: 1 },
|
|
236
|
+
"testimonial.quoteMark": { label: true },
|
|
237
|
+
"progressBar.value": { label: true },
|
|
140
238
|
"languageSwitcher.display": { control: "segmented", options: ["inline", "dropdown"] },
|
|
141
239
|
"postTerms.taxonomy": { control: "choice", choice: { kind: "taxonomy" } },
|
|
142
240
|
"query.postType": { control: "choice", choice: { kind: "postType" }, when: notInherit },
|
|
@@ -172,7 +270,7 @@ export function hintOf(block: string, attr: string): AttrHint {
|
|
|
172
270
|
const text = (v: unknown): string | undefined => (typeof v === "string" ? v : undefined);
|
|
173
271
|
|
|
174
272
|
/** Chữ nhãn / ghi chú của hint theo ngôn ngữ (undefined nếu hint không khai báo). */
|
|
175
|
-
export const hintText = (hint: AttrHint, part: "label" | "help", lang: string): string | undefined =>
|
|
273
|
+
export const hintText = (hint: AttrHint, part: "label" | "help" | "placeholder", lang: string): string | undefined =>
|
|
176
274
|
hint[part] && hint.key ? text(messages("hints", lang)[`${hint.key}.${part}`]) : undefined;
|
|
177
275
|
|
|
178
276
|
/** 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ô. */
|
|
@@ -4,7 +4,7 @@ import { useEditor } from "../context";
|
|
|
4
4
|
import { useMsgs } from "../i18n";
|
|
5
5
|
import { ColorInput } from "./color-field";
|
|
6
6
|
import { GradientField } from "./layout-panel";
|
|
7
|
-
import { Row, Section, Seg, cx } from "./style-controls";
|
|
7
|
+
import { Row, Section, Seg, StateTabs, cx } from "./style-controls";
|
|
8
8
|
|
|
9
9
|
/** Điểm lấy nét chọn nhanh: lưới 3×3 (trên-trái … dưới-phải). */
|
|
10
10
|
const POSITIONS = ["0% 0%", "50% 0%", "100% 0%", "0% 50%", "50% 50%", "100% 50%", "0% 100%", "50% 100%", "100% 100%"];
|
|
@@ -41,7 +41,14 @@ export function BackgroundControl({ type, attrs, setAttrs, device }: { type: str
|
|
|
41
41
|
if (v) r[device] = v; else delete r[device];
|
|
42
42
|
setBg({ [k]: Object.keys(r).length ? r : undefined });
|
|
43
43
|
};
|
|
44
|
+
/** Màu riêng của khổ tablet / điện thoại (máy tính dùng style.color.background). */
|
|
45
|
+
const setBgColorAt = (v: string | undefined) => {
|
|
46
|
+
const r: Record<string, string | undefined> = { ...(bg.color ?? {}) };
|
|
47
|
+
if (v) r[device] = v; else delete r[device];
|
|
48
|
+
setBg({ color: Object.keys(r).length ? r : undefined });
|
|
49
|
+
};
|
|
44
50
|
const setColor = (v: string | undefined) => {
|
|
51
|
+
if (device !== "base") return setBgColorAt(v);
|
|
45
52
|
const next: BlockStyle = { ...style, color: { ...style.color, background: v } };
|
|
46
53
|
if (legacy === undefined) return commitStyle(next);
|
|
47
54
|
// Màu cũ của nhóm kéo theo khoảng đệm + bo góc trong vỏ → giữ nguyên dáng khi chuyển sang style
|
|
@@ -69,18 +76,58 @@ export function BackgroundControl({ type, attrs, setAttrs, device }: { type: str
|
|
|
69
76
|
commitStyle(next, { ...(legacy ? { background: undefined } : {}), ...(cover ? { src: undefined, mediaId: undefined, overlay: undefined, opacity: undefined, fixed: undefined, focal: undefined } : {}) });
|
|
70
77
|
};
|
|
71
78
|
|
|
79
|
+
const ovKind: "color" | "gradient" | "image" = bg.overlayImage ? "image" : bg.overlayGradient ? "gradient" : "color";
|
|
80
|
+
const [ovTab, setOvTab] = useState<"color" | "gradient" | "image" | null>(null);
|
|
81
|
+
const ovShown = ovTab ?? ovKind;
|
|
82
|
+
const hasOv = !!(overlay || bg.overlayGradient || bg.overlayImage);
|
|
83
|
+
const pickOverlayImage = async () => {
|
|
84
|
+
const [item] = (await host.media?.pick({ kind: "image", multiple: false })) ?? [];
|
|
85
|
+
if (item) setBg({ overlayImage: item.sizes?.large?.url ?? item.url, overlayOpacity: bg.overlayOpacity });
|
|
86
|
+
};
|
|
87
|
+
const BLENDS = ["multiply", "screen", "overlay", "darken", "lighten", "color-dodge", "color-burn", "difference", "exclusion", "hue", "saturation", "color", "luminosity"];
|
|
88
|
+
const overlayFields = (
|
|
89
|
+
<>
|
|
90
|
+
{!cover && (
|
|
91
|
+
<Row label={t.overlayType}>
|
|
92
|
+
<div role="radiogroup" aria-label={t.overlayType} className="ecx-seg is-text">
|
|
93
|
+
{(["color", "gradient", "image"] as const).map((k) => (
|
|
94
|
+
<button key={k} type="button" role="radio" aria-checked={ovShown === k} className={cx("ecx-seg-btn", ovShown === k && "is-active")} onClick={() => setOvTab(k)}>{b.bg[k]}</button>
|
|
95
|
+
))}
|
|
96
|
+
</div>
|
|
97
|
+
</Row>
|
|
98
|
+
)}
|
|
99
|
+
{(cover || ovShown === "color") && <ColorInput label={t.overlay} value={overlay} onChange={setOverlay} />}
|
|
100
|
+
{!cover && ovShown === "gradient" && <Row label={b.bg.gradient}><GradientField value={bg.overlayGradient} onChange={(g) => setBg({ overlayGradient: g, overlayOpacity: g ? bg.overlayOpacity : undefined })} /></Row>}
|
|
101
|
+
{!cover && ovShown === "image" && (
|
|
102
|
+
<Row label={t.image}>
|
|
103
|
+
<div className="ecx-bg-actions">
|
|
104
|
+
{host.media && <button type="button" className="ecx-btn" onClick={pickOverlayImage}>{bg.overlayImage ? t.replace : t.choose}</button>}
|
|
105
|
+
{bg.overlayImage && <button type="button" className="ecx-btn" onClick={() => setBg({ overlayImage: undefined })}>{t.remove}</button>}
|
|
106
|
+
</div>
|
|
107
|
+
</Row>
|
|
108
|
+
)}
|
|
109
|
+
{!cover && hasOv && (
|
|
110
|
+
<Row label={t.overlayBlend}>
|
|
111
|
+
<select className="ecx-input" aria-label={t.overlayBlend} value={bg.overlayBlend ?? ""} onChange={(e) => setBg({ overlayBlend: e.target.value || undefined })}>
|
|
112
|
+
<option value="">{t.blendNormal}</option>
|
|
113
|
+
{BLENDS.map((x) => <option key={x} value={x}>{(t as Record<string, string>)[`blend_${x.replace(/-/g, "_")}`] ?? x}</option>)}
|
|
114
|
+
</select>
|
|
115
|
+
</Row>
|
|
116
|
+
)}
|
|
117
|
+
{(hasOv || (cover && attrs.src)) && (
|
|
118
|
+
<Row label={`${t.opacity}: ${opacity}%`}>
|
|
119
|
+
<input type="range" min={0} max={100} step={5} value={opacity} aria-label={t.opacity} onChange={(e) => setOpacity(Number(e.target.value))} />
|
|
120
|
+
</Row>
|
|
121
|
+
)}
|
|
122
|
+
</>
|
|
123
|
+
);
|
|
72
124
|
return (
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
<button key={s} type="button" role="tab" aria-selected={state === s} className={cx("ecx-seg-btn", state === s && "is-active")} onClick={() => setState(s)}>{b[s]}</button>
|
|
77
|
-
))}
|
|
78
|
-
</div>
|
|
125
|
+
<>
|
|
126
|
+
<Section title={b.bg.title} modified={modified} onReset={reset} defaultOpen={type === "group" ? true : undefined}>
|
|
127
|
+
<StateTabs value={state} onChange={setState} />
|
|
79
128
|
{state === "hover" ? (
|
|
80
129
|
<>
|
|
81
|
-
<
|
|
82
|
-
<ColorInput label={b.bg.hoverColor} value={style.hover?.color?.background} onChange={(v) => commitStyle({ ...style, hover: { ...style.hover, color: { ...style.hover?.color, background: v } } })} />
|
|
83
|
-
</Row>
|
|
130
|
+
<ColorInput label={b.bg.hoverColor} value={style.hover?.color?.background} onChange={(v) => commitStyle({ ...style, hover: { ...style.hover, color: { ...style.hover?.color, background: v } } })} />
|
|
84
131
|
<p className="ecx-muted">{b.bg.hoverNote}</p>
|
|
85
132
|
</>
|
|
86
133
|
) : (
|
|
@@ -93,10 +140,11 @@ export function BackgroundControl({ type, attrs, setAttrs, device }: { type: str
|
|
|
93
140
|
</div>
|
|
94
141
|
</Row>
|
|
95
142
|
{kind === "color" && (
|
|
96
|
-
|
|
97
|
-
<ColorInput label={b.bg.color} value={style.color?.background ?? legacy} onChange={setColor} />
|
|
143
|
+
<>
|
|
144
|
+
<ColorInput label={b.bg.color} value={device === "base" ? style.color?.background ?? legacy : bg.color?.[device]} onChange={setColor} />
|
|
145
|
+
{device !== "base" && !bg.color?.[device] && <p className="ecx-muted">{b.bg.colorInherit}</p>}
|
|
98
146
|
{legacy && !style.color?.background && <p className="ecx-muted">{b.bg.legacy}</p>}
|
|
99
|
-
|
|
147
|
+
</>
|
|
100
148
|
)}
|
|
101
149
|
{kind === "gradient" && <Row label={b.bg.gradient}><GradientField value={style.gradient} onChange={(g) => commitStyle({ ...style, gradient: g })} /></Row>}
|
|
102
150
|
{kind === "image" && (
|
|
@@ -137,18 +185,14 @@ export function BackgroundControl({ type, attrs, setAttrs, device }: { type: str
|
|
|
137
185
|
<label className="ecx-check"><input type="checkbox" checked={cover ? !!attrs.fixed : !!bg.fixed} onChange={(e) => (cover ? setAttrs({ fixed: e.target.checked || undefined }) : setBg({ fixed: e.target.checked || undefined }))} /> {t.fixed}</label>
|
|
138
186
|
</>
|
|
139
187
|
)}
|
|
140
|
-
|
|
141
|
-
<ColorInput label={t.overlay} value={overlay} onChange={setOverlay} />
|
|
142
|
-
</Row>
|
|
143
|
-
{(overlay || (cover && attrs.src)) && (
|
|
144
|
-
<Row label={`${t.opacity}: ${opacity}%`}>
|
|
145
|
-
<input type="range" min={0} max={100} step={5} value={opacity} aria-label={t.opacity} onChange={(e) => setOpacity(Number(e.target.value))} />
|
|
146
|
-
</Row>
|
|
147
|
-
)}
|
|
188
|
+
{cover && overlayFields}
|
|
148
189
|
</>
|
|
149
190
|
)}
|
|
150
191
|
</>
|
|
151
192
|
)}
|
|
152
193
|
</Section>
|
|
194
|
+
{/* Lớp phủ nền: mục riêng (phủ lên màu / chuyển màu / ảnh), như bộ khối lớn */}
|
|
195
|
+
{!cover && <Section title={t.overlayTitle} modified={hasOv} onReset={() => setBg({ overlay: undefined, overlayOpacity: undefined, overlayGradient: undefined, overlayImage: undefined, overlayBlend: undefined })} defaultOpen={hasOv ? true : undefined}>{overlayFields}</Section>}
|
|
196
|
+
</>
|
|
153
197
|
);
|
|
154
198
|
}
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
import type { ComponentType } from "react";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Bộ icon 2 lớp của khối lõi (tự vẽ, lưới 24px): lớp nền nhạt (0) + lớp đặc màu thương hiệu (1) + chi tiết trắng (2).
|
|
5
|
+
* Màu lấy từ biến CSS `--ecx-ico-a` / `--ecx-ico-b` (editor.css) → cùng một bộ hợp sáng / tối, đang chọn / không.
|
|
6
|
+
*/
|
|
7
|
+
type Shape = ["r", number, number, number, number, number?, Layer?] | ["c", number, number, number, Layer?] | ["p", string, Layer?] | ["s", string, Layer?];
|
|
8
|
+
type Layer = 0 | 1 | 2;
|
|
9
|
+
const FILL = ["var(--ecx-ico-b)", "var(--ecx-ico-a)", "var(--ecx-ico-w, #fff)"];
|
|
10
|
+
|
|
11
|
+
function draw(shapes: Shape[]): ComponentType<{ className?: string }> {
|
|
12
|
+
const Icon = ({ className }: { className?: string }) => (
|
|
13
|
+
<svg className={className ? `${className} ecx-duo` : "ecx-duo"} viewBox="0 0 24 24" width={24} height={24} aria-hidden="true" focusable="false">
|
|
14
|
+
{shapes.map((s, i) => {
|
|
15
|
+
if (s[0] === "r") return <rect key={i} x={s[1]} y={s[2]} width={s[3]} height={s[4]} rx={s[5] ?? 0} fill={FILL[s[6] ?? 1]} />;
|
|
16
|
+
if (s[0] === "c") return <circle key={i} cx={s[1]} cy={s[2]} r={s[3]} fill={FILL[s[4] ?? 1]} />;
|
|
17
|
+
if (s[0] === "s") return <path key={i} d={s[1]} fill="none" stroke={FILL[s[2] ?? 1]} strokeWidth={1.8} strokeLinecap="round" strokeLinejoin="round" />;
|
|
18
|
+
return <path key={i} d={s[1]} fill={FILL[s[2] ?? 1]} />;
|
|
19
|
+
})}
|
|
20
|
+
</svg>
|
|
21
|
+
);
|
|
22
|
+
return Icon;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// Mảnh dùng lại
|
|
26
|
+
const lines = (x: number, y: number, w: number[], gap = 4, h = 2): Shape[] => w.map((wi, i) => ["r", x, y + i * gap, wi, h, h / 2, 1] as Shape);
|
|
27
|
+
const frame = (layer: Layer = 0): Shape => ["r", 2, 3, 20, 18, 3, layer];
|
|
28
|
+
const photo: Shape[] = [["r", 2, 4, 20, 16, 3, 0], ["c", 8, 9, 2], ["p", "M3 18l6-6 3.5 3.5L16 11l5 6v1.5A1.5 1.5 0 0 1 19.5 20h-15A1.5 1.5 0 0 1 3 18.5z"]];
|
|
29
|
+
const H = "M7 6h2.6v4.7h4.8V6H17v12h-2.6v-5h-4.8v5H7z";
|
|
30
|
+
const quote = "M6 8h4v4c0 2.3-1.3 3.7-3.5 4l-.5-1.6c1-.4 1.5-1.1 1.5-2.4H6zm8 0h4v4c0 2.3-1.3 3.7-3.5 4l-.5-1.6c1-.4 1.5-1.1 1.5-2.4H14z";
|
|
31
|
+
const star = "M12 3.5l2.6 5.3 5.8.8-4.2 4.1 1 5.8L12 16.8l-5.2 2.7 1-5.8-4.2-4.1 5.8-.8z";
|
|
32
|
+
const pin = "M12 2a6.5 6.5 0 0 1 6.5 6.5c0 4.6-6.5 12.5-6.5 12.5S5.5 13.1 5.5 8.5A6.5 6.5 0 0 1 12 2z";
|
|
33
|
+
const play = "M10 8.5l6 3.5-6 3.5z";
|
|
34
|
+
|
|
35
|
+
const I = {
|
|
36
|
+
// Chữ
|
|
37
|
+
paragraph: draw([["r", 2, 2, 20, 20, 4, 0], ["p", "M10 5h7v2h-2v12h-2V7h-1v12H10v-6.2A3.9 3.9 0 0 1 10 5z"]]),
|
|
38
|
+
heading: draw([["r", 2, 2, 20, 20, 4, 0], ["p", H]]),
|
|
39
|
+
bulletList: draw([["c", 5, 6, 2], ["c", 5, 12, 2], ["c", 5, 18, 2], ["r", 9, 5, 13, 2.2, 1.1, 0], ["r", 9, 11, 13, 2.2, 1.1, 0], ["r", 9, 17, 10, 2.2, 1.1, 0]]),
|
|
40
|
+
orderedList: draw([["p", "M4 4h2v5H4.5V5.5H4zM3.5 13.5c0-1 .8-1.6 1.7-1.6s1.6.6 1.6 1.4c0 .9-.7 1.4-1.6 2.2h1.7V17H3.5v-1c1.6-1.3 2-1.8 2-2.3 0-.3-.2-.5-.4-.5s-.4.2-.4.5z"], ["r", 9, 5, 13, 2.2, 1.1, 0], ["r", 9, 11, 13, 2.2, 1.1, 0], ["r", 9, 17, 10, 2.2, 1.1, 0]]),
|
|
41
|
+
taskList: draw([["r", 2, 3, 6, 6, 1.5], ["s", "M3.6 6l1.3 1.3L6.6 5", 2], ["r", 2, 14, 6, 6, 1.5, 0], ["r", 10, 5, 12, 2.2, 1.1, 0], ["r", 10, 16, 9, 2.2, 1.1, 0]]),
|
|
42
|
+
blockquote: draw([["r", 2, 3, 20, 18, 3, 0], ["p", quote]]),
|
|
43
|
+
pullquote: draw([["r", 2, 3, 20, 2, 1], ["r", 2, 19, 20, 2, 1], ["r", 2, 6.5, 20, 11, 2, 0], ["p", "M7 9h3v3c0 1.7-1 2.8-2.6 3l-.4-1.2c.8-.3 1.1-.8 1.1-1.8H7zm7 0h3v3c0 1.7-1 2.8-2.6 3l-.4-1.2c.8-.3 1.1-.8 1.1-1.8H14z"]]),
|
|
44
|
+
codeBlock: draw([frame(), ["p", "M9.5 8.5L6 12l3.5 3.5 1.2-1.2L8.4 12l2.3-2.3zm5 0l-1.2 1.2 2.3 2.3-2.3 2.3 1.2 1.2L18 12z"]]),
|
|
45
|
+
preformatted: draw([frame(), ...lines(5, 7, [12, 8, 10])]),
|
|
46
|
+
customHtml: draw([frame(), ["p", "M8 8.5L4.5 12 8 15.5l1.2-1.2L6.9 12l2.3-2.3zm8 0l-1.2 1.2 2.3 2.3-2.3 2.3 1.2 1.2L19.5 12zM13.2 7l-3.6 10h1.7L14.9 7z"]]),
|
|
47
|
+
callout: draw([["r", 2, 3, 20, 18, 3, 0], ["r", 2, 3, 3, 18, 1.5], ["c", 12, 8, 1.5], ["r", 10.7, 11, 2.6, 7, 1.3]]),
|
|
48
|
+
details: draw([["r", 2, 3, 20, 6, 2], ["s", "M17 5l1.5 1.5L20 5", 2], ["r", 2, 11, 20, 10, 2, 0], ...lines(5, 14, [12, 8])]),
|
|
49
|
+
accordion: draw([["r", 2, 2, 20, 6, 2], ["s", "M16.5 4.3l1.5 1.5 1.5-1.5", 2], ["r", 2, 9.5, 20, 5.5, 2, 0], ["r", 2, 16.5, 20, 5.5, 2, 0]]),
|
|
50
|
+
tabs: draw([["r", 2, 8, 20, 13, 2.5, 0], ["p", "M2 6.5A2.5 2.5 0 0 1 4.5 4H10l1.5 4H2z"], ["r", 12, 4, 6, 3.5, 1.2, 0], ...lines(5, 12, [10, 7])]),
|
|
51
|
+
tab: draw([["p", "M2 6.5A2.5 2.5 0 0 1 4.5 4H10l1.5 4H2z"], ["r", 2, 8, 20, 13, 2.5, 0], ...lines(5, 12, [10, 7])]),
|
|
52
|
+
footnotes: draw([["r", 2, 3, 20, 18, 3, 0], ...lines(5, 7, [14, 10]), ["r", 5, 14, 2, 2, 1], ["r", 9, 14, 10, 2, 1]]),
|
|
53
|
+
// Media
|
|
54
|
+
image: draw(photo),
|
|
55
|
+
gallery: draw([["r", 2, 2, 9, 12, 2, 0], ["r", 13, 2, 9, 7, 2], ["r", 2, 16, 9, 6, 2], ["r", 13, 11, 9, 11, 2, 0]]),
|
|
56
|
+
cover: draw([["r", 2, 3, 20, 18, 3], ["r", 6, 10, 12, 2.2, 1.1, 2], ["r", 8, 14, 8, 1.8, .9, 2]]),
|
|
57
|
+
mediaText: draw([["r", 2, 4, 9, 16, 2], ["c", 5.5, 8.5, 1.4, 2], ...lines(13, 7, [9, 7, 8]), ["r", 13, 15, 6, 3, 1.5, 0]]),
|
|
58
|
+
video: draw([["r", 2, 4, 20, 16, 3, 0], ["c", 12, 12, 5], ["p", play, 2]]),
|
|
59
|
+
youtube: draw([["r", 2, 5, 20, 14, 4], ["p", play, 2]]),
|
|
60
|
+
audio: draw([["r", 2, 2, 20, 20, 4, 0], ["p", "M15 5v8.2A2.8 2.8 0 1 1 13 10.6V7l-4 1v7.2A2.8 2.8 0 1 1 7 12.6V6.5z"]]),
|
|
61
|
+
file: draw([["p", "M6 2h8l5 5v13a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2z", 0], ["p", "M14 2l5 5h-3a2 2 0 0 1-2-2z"], ...lines(7, 12, [10, 7])]),
|
|
62
|
+
embed: draw([["r", 2, 3, 20, 18, 3, 0], ["p", "M10.6 13.4a3 3 0 0 0 4.2 0l2.5-2.5a3 3 0 1 0-4.2-4.2l-.8.8 1.2 1.2.8-.8a1.3 1.3 0 0 1 1.8 1.8l-2.5 2.5a1.3 1.3 0 0 1-1.8 0zM13.4 10.6a3 3 0 0 0-4.2 0l-2.5 2.5a3 3 0 1 0 4.2 4.2l.8-.8-1.2-1.2-.8.8a1.3 1.3 0 0 1-1.8-1.8l2.5-2.5a1.3 1.3 0 0 1 1.8 0z"]]),
|
|
63
|
+
// Bố cục
|
|
64
|
+
group: draw([["r", 2, 3, 20, 18, 3, 0], ["r", 5, 6, 14, 12, 2]]),
|
|
65
|
+
row: draw([["r", 2, 5, 20, 14, 3, 0], ["r", 4, 8, 4.5, 8, 1.2], ["r", 9.75, 8, 4.5, 8, 1.2], ["r", 15.5, 8, 4.5, 8, 1.2]]),
|
|
66
|
+
stack: draw([["r", 4, 2, 16, 20, 3, 0], ["r", 6.5, 5, 11, 4, 1.2], ["r", 6.5, 10, 11, 4, 1.2], ["r", 6.5, 15, 11, 4, 1.2]]),
|
|
67
|
+
grid: draw([["r", 2, 2, 20, 20, 3, 0], ["r", 4.5, 4.5, 6.5, 6.5, 1.5], ["r", 13, 4.5, 6.5, 6.5, 1.5], ["r", 4.5, 13, 6.5, 6.5, 1.5], ["r", 13, 13, 6.5, 6.5, 1.5]]),
|
|
68
|
+
columns: draw([["r", 2, 4, 20, 16, 3, 0], ["r", 4, 6, 7, 12, 1.5], ["r", 13, 6, 7, 12, 1.5]]),
|
|
69
|
+
column: draw([["r", 2, 4, 20, 16, 3, 0], ["r", 8, 6, 8, 12, 1.5]]),
|
|
70
|
+
spacer: draw([["r", 2, 2, 20, 3, 1.5, 0], ["r", 2, 19, 20, 3, 1.5, 0], ["p", "M12 6.5l3 3h-2v5h2l-3 3-3-3h2v-5H9z"]]),
|
|
71
|
+
horizontalRule: draw([["r", 2, 5, 20, 3, 1.5, 0], ["r", 2, 10.75, 20, 2.5, 1.25], ["r", 2, 16, 20, 3, 1.5, 0]]),
|
|
72
|
+
pageBreak: draw([["r", 4, 2, 16, 7, 2, 0], ["r", 4, 15, 16, 7, 2, 0], ["r", 2, 11, 4, 2, 1], ["r", 9, 11, 6, 2, 1], ["r", 18, 11, 4, 2, 1]]),
|
|
73
|
+
carousel: draw([["r", 5, 4, 14, 14, 2.5], ["r", 1, 6, 3, 10, 1.5, 0], ["r", 20, 6, 3, 10, 1.5, 0], ["c", 9.5, 20.5, 1], ["c", 12, 20.5, 1, 0], ["c", 14.5, 20.5, 1, 0]]),
|
|
74
|
+
// Thiết kế / widget
|
|
75
|
+
buttons: draw([["r", 1, 7, 10, 10, 5], ["r", 13, 7, 10, 10, 5, 0]]),
|
|
76
|
+
button: draw([["r", 1, 6, 22, 12, 6, 0], ["r", 3, 8, 18, 8, 4], ["r", 7, 11, 10, 2, 1, 2]]),
|
|
77
|
+
table: draw([["r", 2, 3, 20, 18, 2.5, 0], ["r", 2, 3, 20, 5, 2.5], ["r", 8.5, 8, 1.5, 13, 0, 1], ["r", 15, 8, 1.5, 13, 0, 1], ["r", 2, 13.5, 20, 1.5, 0, 1]]),
|
|
78
|
+
tableRow: draw([["r", 2, 3, 20, 18, 2.5, 0], ["r", 2, 9.5, 20, 5, 1]]),
|
|
79
|
+
tableCell: draw([["r", 2, 3, 20, 18, 2.5, 0], ["r", 8.5, 9.5, 7, 5, 1]]),
|
|
80
|
+
tableHeader: draw([["r", 2, 3, 20, 18, 2.5, 0], ["r", 2, 3, 20, 5, 2.5]]),
|
|
81
|
+
iconBox: draw([["r", 2, 2, 20, 20, 4, 0], ["c", 12, 8.5, 3.5], ["r", 6, 14, 12, 2, 1], ["r", 8, 17.5, 8, 1.6, .8]]),
|
|
82
|
+
imageBox: draw([["r", 2, 2, 20, 20, 4, 0], ["r", 5, 5, 14, 8, 2], ["p", "M6 12l3.5-3.5 2 2L14 8l4 4z", 2], ["r", 6, 15, 12, 2, 1], ["r", 8, 18.5, 8, 1.4, .7]]),
|
|
83
|
+
iconList: draw([["c", 5, 6, 2.5], ["c", 5, 12, 2.5], ["c", 5, 18, 2.5], ["r", 9.5, 4.8, 12, 2.4, 1.2, 0], ["r", 9.5, 10.8, 12, 2.4, 1.2, 0], ["r", 9.5, 16.8, 9, 2.4, 1.2, 0]]),
|
|
84
|
+
icon: draw([["r", 2, 2, 20, 20, 5, 0], ["p", star]]),
|
|
85
|
+
counter: draw([["r", 1.5, 5, 21, 14, 3, 0], ["r", 4, 8, 4.5, 8, 1.2], ["r", 9.75, 8, 4.5, 8, 1.2], ["r", 15.5, 8, 4.5, 8, 1.2]]),
|
|
86
|
+
countdown: draw([["c", 12, 13, 9, 0], ["r", 9, 1.5, 6, 2.5, 1.2], ["p", "M12 6.5a6.5 6.5 0 1 1-6.5 6.5H12z"]]),
|
|
87
|
+
progressBar: draw([["r", 2, 6, 20, 4, 2, 0], ["r", 2, 6, 13, 4, 2], ["r", 2, 14, 20, 4, 2, 0], ["r", 2, 14, 7, 4, 2]]),
|
|
88
|
+
testimonial: draw([["p", "M3 4h18a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2h-9l-5 4v-4H3a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2z", 0], ["p", quote]]),
|
|
89
|
+
rating: draw([["r", 2, 2, 20, 20, 5, 0], ["p", star]]),
|
|
90
|
+
socialLinks: draw([["c", 6, 12, 3.2], ["c", 18, 6, 3.2], ["c", 18, 18, 3.2], ["p", "M7.6 10.9l8.6-4.5.9 1.6-8.6 4.5zm0 2.2l.9-1.6 8.6 4.5-.9 1.6z", 0]]),
|
|
91
|
+
tableOfContents: draw([["r", 2, 2, 20, 20, 3, 0], ["r", 5, 6, 10, 2.2, 1.1], ["r", 8, 11, 10, 2.2, 1.1], ["r", 8, 16, 7, 2.2, 1.1]]),
|
|
92
|
+
form: draw([["r", 2, 3, 20, 5, 2, 0], ["r", 2, 10, 20, 5, 2, 0], ["r", 12, 17, 10, 5, 2.5], ["r", 4, 4.8, 6, 1.4, .7]]),
|
|
93
|
+
formField: draw([["r", 2, 7, 20, 10, 2.5, 0], ["r", 5, 10.5, 1.6, 3, .8]]),
|
|
94
|
+
shortcode: draw([["r", 2, 3, 20, 18, 3, 0], ["p", "M8 7h3v1.6H9.6v6.8H11V17H8zm8 0h-3v1.6h1.4v6.8H13V17h3z"]]),
|
|
95
|
+
syncedPattern: draw([["r", 2, 2, 9, 9, 2], ["r", 13, 2, 9, 9, 2, 0], ["r", 2, 13, 9, 9, 2, 0], ["r", 13, 13, 9, 9, 2]]),
|
|
96
|
+
templatePart: draw([["r", 2, 2, 20, 5, 2], ["r", 2, 9, 20, 6, 2, 0], ["r", 2, 17, 20, 5, 2]]),
|
|
97
|
+
// Giao diện / dữ liệu
|
|
98
|
+
siteLogo: draw([["c", 12, 12, 10, 0], ["p", "M6.5 16l4-6 3 4 1.5-2 2.5 4z"]]),
|
|
99
|
+
siteTitle: draw([["r", 2, 5, 20, 14, 3, 0], ["p", "M6 8h12v2.5h-4.7V17h-2.6v-6.5H6z"]]),
|
|
100
|
+
siteTagline: draw([["r", 2, 5, 20, 14, 3, 0], ...lines(5, 9, [14, 9], 4, 2)]),
|
|
101
|
+
navigation: draw([["r", 2, 8, 20, 8, 3, 0], ["r", 4.5, 11, 4, 2, 1], ["r", 10, 11, 4, 2, 1], ["r", 15.5, 11, 4, 2, 1]]),
|
|
102
|
+
search: draw([["c", 10, 10, 7, 0], ["c", 10, 10, 4.2, 2], ["p", "M14.6 13.2l7 7-1.6 1.6-7-7z"], ["p", "M10 3a7 7 0 1 1 0 14 7 7 0 0 1 0-14zm0 2.8a4.2 4.2 0 1 0 0 8.4 4.2 4.2 0 0 0 0-8.4z"]]),
|
|
103
|
+
languageSwitcher: draw([["c", 12, 12, 10, 0], ["p", "M12 2c2.5 2.7 3.8 6 3.8 10S14.5 19.3 12 22c-2.5-2.7-3.8-6-3.8-10S9.5 4.7 12 2zm0 2.9C10.7 6.8 10 9.2 10 12s.7 5.2 2 7.1c1.3-1.9 2-4.3 2-7.1s-.7-5.2-2-7.1zM2.5 11h19v2h-19z"]]),
|
|
104
|
+
copyright: draw([["c", 12, 12, 10, 0], ["p", "M12 6.5a5.5 5.5 0 0 1 5 3.2l-2 .9a3.3 3.3 0 1 0 0 2.8l2 .9A5.5 5.5 0 1 1 12 6.5z"]]),
|
|
105
|
+
loginout: draw([["r", 10, 3, 11, 18, 3, 0], ["p", "M3 11h8.2L9 8.8l1.4-1.4L15 12l-4.6 4.6L9 15.2l2.2-2.2H3z"]]),
|
|
106
|
+
query: draw([["r", 2, 2, 20, 9, 2.5, 0], ["r", 4, 4, 6, 5, 1.2], ...lines(12, 4.5, [8, 5], 3.2, 1.8), ["r", 2, 13, 20, 9, 2.5, 0], ["r", 4, 15, 6, 5, 1.2], ...lines(12, 15.5, [8, 5], 3.2, 1.8)]),
|
|
107
|
+
postTemplate: draw([["r", 2, 3, 20, 18, 3, 0], ["r", 5, 6, 14, 6, 1.5], ...lines(5, 14, [14, 9])]),
|
|
108
|
+
queryEmpty: draw([["r", 2, 3, 20, 18, 3, 0], ["c", 12, 12, 4.5], ["p", "M9.8 9.8l4.4 4.4-1 .9-4.3-4.3z", 2]]),
|
|
109
|
+
queryTotal: draw([["r", 2, 5, 20, 14, 3, 0], ["p", "M7 8h2v8H7zm4 0h6v2h-4v1h3a1 1 0 0 1 1 1v3a1 1 0 0 1-1 1h-5v-2h4v-1h-3a1 1 0 0 1-1-1v-3a1 1 0 0 1 1-1z"]]),
|
|
110
|
+
queryTitle: draw([["r", 2, 3, 20, 18, 3, 0], ["p", H]]),
|
|
111
|
+
pagination: draw([["r", 1, 8, 6, 8, 2], ["r", 9, 8, 6, 8, 2, 0], ["r", 17, 8, 6, 8, 2, 0]]),
|
|
112
|
+
postTitle: draw([["r", 2, 2, 20, 20, 4, 0], ["p", "M6 6h12v2.6h-4.7V18h-2.6V8.6H6z"]]),
|
|
113
|
+
postContent: draw([["r", 4, 2, 16, 20, 3, 0], ...lines(7, 6, [10, 10, 10, 6])]),
|
|
114
|
+
postExcerpt: draw([["r", 2, 4, 20, 16, 3, 0], ...lines(5, 8, [14, 10]), ["c", 17, 15.5, 1], ["c", 13.5, 15.5, 1]]),
|
|
115
|
+
featuredImage: draw([...photo, ["c", 18.5, 5.5, 3.5], ["p", "M18.5 3.4l.6 1.4 1.5.1-1.1 1 .3 1.5-1.3-.8-1.3.8.3-1.5-1.1-1 1.5-.1z", 2]]),
|
|
116
|
+
postDate: draw([["r", 2, 4, 20, 18, 3, 0], ["r", 2, 4, 20, 5, 3], ["r", 6, 2, 2, 4, 1], ["r", 16, 2, 2, 4, 1], ["r", 6, 12, 3, 3, 1], ["r", 10.5, 12, 3, 3, 1], ["r", 15, 12, 3, 3, 1]]),
|
|
117
|
+
postAuthor: draw([["c", 12, 12, 10, 0], ["c", 12, 9.5, 3.5], ["p", "M5.5 18.5a7.5 7.5 0 0 1 13 0A10 10 0 0 1 12 22a10 10 0 0 1-6.5-3.5z"]]),
|
|
118
|
+
avatar: draw([["c", 12, 12, 10, 0], ["c", 12, 9.5, 3.5], ["p", "M5.5 18.5a7.5 7.5 0 0 1 13 0A10 10 0 0 1 12 22a10 10 0 0 1-6.5-3.5z"]]),
|
|
119
|
+
postTerms: draw([["p", "M3 4.5A1.5 1.5 0 0 1 4.5 3h7l9.4 9.4a1.5 1.5 0 0 1 0 2.1l-6.4 6.4a1.5 1.5 0 0 1-2.1 0L3 11.5z", 0], ["c", 7.5, 7.5, 2]]),
|
|
120
|
+
termList: draw([["p", "M3 4.5A1.5 1.5 0 0 1 4.5 3H10l7 7-6 6-8-8z", 0], ["c", 7, 7, 1.6], ["r", 13, 17, 9, 2, 1], ["r", 13, 20, 6, 2, 1]]),
|
|
121
|
+
termDescription: draw([["r", 2, 3, 20, 18, 3, 0], ["p", "M5 6h5.5l3 3-3 3H5z"], ...lines(5, 15, [14])]),
|
|
122
|
+
comments: draw([["p", "M3 3h14a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H9l-4 3.5V15H3a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z", 0], ...lines(4.5, 6.5, [10, 7], 3.5, 1.8), ["p", "M21 9h1a1 1 0 0 1 1 1v8a1 1 0 0 1-1 1h-1v3l-3.5-3H11a1 1 0 0 1-1-1v-1h8a3 3 0 0 0 3-3z"]]),
|
|
123
|
+
commentsCount: draw([["p", "M3 3h18a2 2 0 0 1 2 2v11a2 2 0 0 1-2 2h-9l-5 4v-4H3a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z", 0], ["p", "M10 7h2v7h-2zm-3 2.5h2v4.5H7zM13 9.5h2v4.5h-2zm3-1.5h2v6h-2z"]]),
|
|
124
|
+
readMore: draw([["r", 2, 6, 20, 12, 6, 0], ["p", "M12 9.2l4.3 2.8-4.3 2.8V13H7v-2h5z"]]),
|
|
125
|
+
postNavigation: draw([["r", 1, 6, 10, 12, 3, 0], ["r", 13, 6, 10, 12, 3], ["p", "M7.5 9L4.5 12l3 3 1-1-2-2 2-2zM16.5 9l-1 1 2 2-2 2 1 1 3-3z", 2]]),
|
|
126
|
+
breadcrumbs: draw([["r", 1, 8, 6, 8, 2], ["s", "M8.5 9.5l2.5 2.5-2.5 2.5", 0], ["r", 12, 8, 4.5, 8, 2, 0], ["r", 18.5, 8, 4.5, 8, 2, 0]]),
|
|
127
|
+
pageList: draw([["r", 2, 2, 8, 6, 1.5], ["r", 7, 10, 15, 4, 1.5, 0], ["r", 7, 17, 15, 4, 1.5, 0], ["r", 4, 8, 1.6, 11, .8, 0]]),
|
|
128
|
+
archives: draw([["r", 2, 3, 20, 6, 2], ["r", 3.5, 10, 17, 11, 2, 0], ["r", 9, 13, 6, 2, 1]]),
|
|
129
|
+
listItem: draw([["c", 6, 12, 2.5], ["r", 10.5, 10.8, 11, 2.4, 1.2, 0]]),
|
|
130
|
+
taskItem: draw([["r", 3, 8, 8, 8, 2], ["r", 13, 10.8, 9, 2.4, 1.2, 0]]),
|
|
131
|
+
map: draw([["p", "M2 6l6-3 8 3 6-3v15l-6 3-8-3-6 3z", 0], ["p", pin], ["c", 12, 8.5, 2.3, 2]]),
|
|
132
|
+
videoPopup: draw([["r", 2, 4, 20, 16, 3, 0], ["c", 12, 12, 5], ["p", play, 2]]),
|
|
133
|
+
};
|
|
134
|
+
|
|
135
|
+
/** Icon bộ cột theo tỉ lệ ("33-66" → hai cột 1/3, 2/3). */
|
|
136
|
+
const colsCache = new Map<string, ComponentType<{ className?: string }>>();
|
|
137
|
+
export function columnsIcon(name: string): ComponentType<{ className?: string }> | undefined {
|
|
138
|
+
const rep = /^(\d+)x(\d+)$/.exec(name); // "25x4" = 4 cột 25
|
|
139
|
+
const w = rep ? Array.from({ length: Number(rep[2]) }, () => Number(rep[1])) : name.split("-").map(Number);
|
|
140
|
+
if (w.length < 2 || w.some((x) => !(x > 0))) return undefined;
|
|
141
|
+
if (!colsCache.has(name)) {
|
|
142
|
+
const gap = 1.5, inner = 16 - gap * (w.length - 1), sum = w.reduce((a, b) => a + b, 0);
|
|
143
|
+
let x = 4;
|
|
144
|
+
const shapes: Shape[] = [["r", 2, 4, 20, 16, 3, 0]];
|
|
145
|
+
for (const wi of w) { const cw = (inner * wi) / sum; shapes.push(["r", x, 6, cw, 12, 1.2, 1]); x += cw + gap; }
|
|
146
|
+
colsCache.set(name, draw(shapes));
|
|
147
|
+
}
|
|
148
|
+
return colsCache.get(name);
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
/** Icon 2 lớp theo tên khối lõi; khối plugin / khối lạ giữ icon của chính nó. */
|
|
152
|
+
export const BLOCK_ICONS: Record<string, ComponentType<{ className?: string }>> = I;
|
package/src/v2/ui/block-menu.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import type { BNode } from "../core/model";
|
|
2
|
+
import type { EditorStore } from "../core/store";
|
|
1
3
|
/** Chép / dán kiểu dáng (chỉ `attrs.style`) + vị trí menu chuột phải. */
|
|
2
4
|
|
|
3
5
|
// shortcut: chỉ nhớ trong phiên (bộ nhớ của trang admin, giữ khi chuyển bài trong SPA), mất khi tải lại — cần chép giữa tab thì chuyển sang localStorage.
|
|
@@ -17,3 +19,23 @@ export function menuPosition(x: number, y: number, w: number, h: number, vw: num
|
|
|
17
19
|
const top = y + h > vh - 8 ? y - h : y;
|
|
18
20
|
return { left: Math.round(Math.max(8, Math.min(left, vw - 8 - w))), top: Math.round(Math.max(8, Math.min(top, vh - 8 - h))) };
|
|
19
21
|
}
|
|
22
|
+
|
|
23
|
+
const ALL_DEVICES = ["desktop", "tablet", "mobile"] as const;
|
|
24
|
+
/** Khối ẩn hẳn (mọi khổ màn hình) — dùng chung `style.hide` của ô "Ẩn trên thiết bị". */
|
|
25
|
+
export const isHidden = (b: BNode) => { const h = (b.attrs.style as { hide?: string[] } | undefined)?.hide; return !!h && ALL_DEVICES.every((d) => h.includes(d)); };
|
|
26
|
+
/** Ẩn / hiện các khối: ẩn = ẩn mọi khổ; hiện = bỏ hết ẩn (cả ẩn theo từng khổ). */
|
|
27
|
+
export function toggleHidden(store: EditorStore, ids: string[]) {
|
|
28
|
+
const first = store.block(ids[0]);
|
|
29
|
+
if (!first) return;
|
|
30
|
+
const hide = !isHidden(first);
|
|
31
|
+
store.batch(() => {
|
|
32
|
+
for (const id of ids) {
|
|
33
|
+
const b = store.block(id);
|
|
34
|
+
if (!b) continue;
|
|
35
|
+
const { hide: _drop, ...rest } = (b.attrs.style as Record<string, unknown> | undefined) ?? {};
|
|
36
|
+
const style = hide ? { ...rest, hide: [...ALL_DEVICES] } : rest;
|
|
37
|
+
store.setAttrs([id], { style: Object.keys(style).length ? style : undefined });
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
|
|
@@ -6,21 +6,32 @@ import { Row, Section, cx } from "./style-controls";
|
|
|
6
6
|
import { UnitInput } from "./unit-controls";
|
|
7
7
|
|
|
8
8
|
type State = "normal" | "hover" | "active";
|
|
9
|
+
/** Ô rời mà phần (attrs.parts) chưa thay được — luôn hiện ở khối đã chia phần. */
|
|
10
|
+
const KEEP = new Set(["imageFit", "imageOpacity", "imageFilter", "imageHoverEffect", "imageHoverOpacity", "imageHoverFilter", "iconListGap", "iconListColumnGap", "iconListIconGap", "iconListDivider", "tabsGap", "accGap", "buttonSize", "buttonWidth", "buttonIconColor", "buttonIconHoverColor", "buttonIconSize", "progressHeight", "iconBoxImageWidth", "tabsTitleWidth", "tabsPanelMinHeight", "searchPlaceholderColor", "searchMaxWidth", "galleryGap"]);
|
|
9
11
|
|
|
10
12
|
/**
|
|
11
13
|
* Mục Kiểu dáng riêng của khối lõi (như tab Style của từng widget Elementor: Danh sách › khoảng cách, đường kẻ; Icon › màu, cỡ…).
|
|
12
14
|
* Ô khai ở @ecomcx/ecomweb-content core-controls → website và khung soạn sinh cùng CSS (controlsCss). Ô `responsive` sửa theo khổ
|
|
13
15
|
* đang chọn ở đầu tab; ô có `state` nằm trong thẻ Rê chuột / Đang mở của mục.
|
|
14
16
|
*/
|
|
15
|
-
|
|
17
|
+
/** `legacyOnly`: khối đã chia phần (attrs.parts) — chỉ hiện mục ô rời đã có giá trị (nội dung cũ), để sửa / xoá. */
|
|
18
|
+
export function BlockStyleSections({ type, attrs, setAttrs, device, legacyOnly }: { type: string; attrs: Record<string, any>; setAttrs(a: Record<string, unknown>): void; device: Device; legacyOnly?: boolean }) {
|
|
16
19
|
const t = useMsgs("blockStyle");
|
|
17
20
|
const sections = new Map<string, Array<[string, ControlSpec]>>();
|
|
18
21
|
for (const [name, spec] of Object.entries(coreControlsFor(type))) {
|
|
22
|
+
if (name === "tabsAlign") continue; // sửa ở tab Cài đặt
|
|
19
23
|
const k = spec.section ?? "text";
|
|
20
24
|
sections.set(k, [...(sections.get(k) ?? []), [name, spec]]);
|
|
21
25
|
}
|
|
26
|
+
const reduced = new Set<string>(); // mục chỉ còn ô phần chưa thay: tên "… · tuỳ chọn khác" để khỏi trùng tên phần
|
|
27
|
+
sections.delete("columns"); // khe cột / khe hàng / hướng xếp: đã có ở tab Cài đặt (ColumnsInspector)
|
|
28
|
+
if (legacyOnly) for (const [k, list] of sections) {
|
|
29
|
+
if (list.some(([n]) => attrs[n] !== undefined)) continue;
|
|
30
|
+
const keep = list.filter(([n]) => KEEP.has(n));
|
|
31
|
+
if (keep.length) { sections.set(k, keep); if (keep.length < list.length) reduced.add(k); } else sections.delete(k);
|
|
32
|
+
}
|
|
22
33
|
if (!sections.size) return null;
|
|
23
|
-
return <>{[...sections].map(([key, list]) => <ControlSection key={key} title={(t.section as Record<string, string>)[key] ?? key} list={list} attrs={attrs} setAttrs={setAttrs} device={device} />)}</>;
|
|
34
|
+
return <>{[...sections].map(([key, list]) => <ControlSection key={key} title={`${(t.section as Record<string, string>)[key] ?? key}${reduced.has(key) ? ` · ${t.more}` : ""}`} list={list} attrs={attrs} setAttrs={setAttrs} device={device} />)}</>;
|
|
24
35
|
}
|
|
25
36
|
|
|
26
37
|
function ControlSection({ title, list, attrs, setAttrs, device }: { title: string; list: Array<[string, ControlSpec]>; attrs: Record<string, any>; setAttrs(a: Record<string, unknown>): void; device: Device }) {
|
|
@@ -58,7 +69,7 @@ function ControlField({ name, spec, value, device, onChange }: { name: string; s
|
|
|
58
69
|
onChange(!keys.length ? undefined : keys.length === 1 && keys[0] === "base" ? next.base : next);
|
|
59
70
|
};
|
|
60
71
|
const dev = spec.responsive ? device : undefined;
|
|
61
|
-
if (spec.type === "color") return <Row label={label} device={dev}><ColorInput label={label} value={typeof v === "string" ? v : undefined} onChange={set} /></Row
|
|
72
|
+
if (spec.type === "color") return dev ? <Row label={label} device={dev}><ColorInput label={label} value={typeof v === "string" ? v : undefined} onChange={set} /></Row> : <ColorInput label={label} value={typeof v === "string" ? v : undefined} onChange={set} />;
|
|
62
73
|
if (spec.type === "length") return <Row label={label} device={dev}><UnitInput label={label} value={typeof v === "string" ? v : undefined} placeholder={typeof inherited === "string" ? inherited : undefined} units={["px", "rem", "em", "%"]} onChange={set} /></Row>;
|
|
63
74
|
if (spec.type === "number") return (
|
|
64
75
|
<Row label={`${label}${typeof v === "number" ? `: ${v}` : ""}`} device={dev}>
|