@ecomcx/ecomweb-editor 1.29.1 → 1.31.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.
Files changed (38) hide show
  1. package/package.json +3 -3
  2. package/src/locales/en/block-desc.ts +5 -5
  3. package/src/locales/en/block-style.ts +55 -0
  4. package/src/locales/en/index.ts +3 -1
  5. package/src/locales/en/placeholders.ts +96 -0
  6. package/src/locales/vi/block-desc.ts +5 -5
  7. package/src/locales/vi/block-style.ts +58 -0
  8. package/src/locales/vi/index.ts +3 -1
  9. package/src/locales/vi/placeholders.ts +95 -0
  10. package/src/shared/panel-store.ts +5 -4
  11. package/src/v2/blocks/compat.tsx +91 -5
  12. package/src/v2/blocks/form.tsx +3 -0
  13. package/src/v2/blocks/index.ts +19 -1
  14. package/src/v2/blocks/layout.tsx +182 -61
  15. package/src/v2/blocks/media.tsx +72 -71
  16. package/src/v2/blocks/text.tsx +48 -17
  17. package/src/v2/blocks/theme.tsx +73 -12
  18. package/src/v2/blocks/widgets.tsx +48 -11
  19. package/src/v2/canvas/block-list.tsx +4 -4
  20. package/src/v2/canvas/canvas-css.ts +95 -6
  21. package/src/v2/canvas/server-block.tsx +7 -4
  22. package/src/v2/core/host.ts +9 -0
  23. package/src/v2/core/registry.ts +3 -1
  24. package/src/v2/core/structure.ts +2 -1
  25. package/src/v2/editor.css +6 -2
  26. package/src/v2/index.ts +3 -0
  27. package/src/v2/ui/ai.tsx +9 -5
  28. package/src/v2/ui/attr-form.tsx +2 -2
  29. package/src/v2/ui/attr-hints.ts +6 -2
  30. package/src/v2/ui/background-panel.tsx +116 -50
  31. package/src/v2/ui/block-style-panel.tsx +78 -0
  32. package/src/v2/ui/inspector.tsx +34 -14
  33. package/src/v2/ui/layout-panel.tsx +35 -26
  34. package/src/v2/{blocks → ui}/media-actions.tsx +4 -3
  35. package/src/v2/ui/placeholders.tsx +205 -0
  36. package/src/v2/ui/style-supports.ts +2 -0
  37. package/src/v2/ui/style-tab.tsx +16 -9
  38. package/src/v2/ui/toolbar.tsx +9 -4
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ecomcx/ecomweb-editor",
3
- "version": "1.29.1",
3
+ "version": "1.31.0",
4
4
  "description": "Trình soạn nội dung dạng khối của CMS — dùng độc lập trong mọi dự án React (1.x: TipTap; ./v2: cây khối, khung soạn iframe, sửa header/footer tại chỗ).",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -29,7 +29,7 @@
29
29
  "*.css"
30
30
  ],
31
31
  "peerDependencies": {
32
- "@ecomcx/ecomweb-content": "^1.23.1",
32
+ "@ecomcx/ecomweb-content": "^1.25.0",
33
33
  "react": ">=18",
34
34
  "react-dom": ">=18"
35
35
  },
@@ -45,7 +45,7 @@
45
45
  "prosemirror-view": "1.42.7"
46
46
  },
47
47
  "devDependencies": {
48
- "@ecomcx/ecomweb-content": "^1.23.1",
48
+ "@ecomcx/ecomweb-content": "^1.25.0",
49
49
  "@playwright/test": "1.53.0",
50
50
  "@types/react": "19.2.2",
51
51
  "@types/react-dom": "19.2.2",
@@ -2,7 +2,7 @@
2
2
  export const blockDesc = {
3
3
  paragraph: "Start with the basic building block of all narrative.",
4
4
  heading: "Introduce sections and organise content for readers and search engines.",
5
- bulletList: "A bulleted list.",
5
+ bulletList: "A bulleted list — marker type (✓, →…), marker colour, spacing and dividers in Style.",
6
6
  orderedList: "A numbered list.",
7
7
  taskList: "A checklist.",
8
8
  blockquote: "Give quoted text visual emphasis.",
@@ -13,14 +13,14 @@ export const blockDesc = {
13
13
  table: "Rows and columns of data; cells can be merged.",
14
14
  image: "An image with caption and alt text; drag to resize.",
15
15
  gallery: "Several images in a grid.",
16
- cover: "A large image or colour with text on top — a page hero.",
16
+ cover: "A covering image (or colour / gradient) with an overlay and text on top — a page hero; image, focal point and overlay in Background.",
17
17
  mediaText: "Media and text side by side for a richer layout.",
18
18
  video: "An uploaded or linked video.",
19
19
  audio: "An audio player.",
20
20
  file: "A downloadable file (PDF…), optionally embedded.",
21
21
  youtube: "Embed a YouTube video.",
22
22
  embed: "Embed content from a URL.",
23
- group: "Gather blocks in a container to style them together: background colour, gradient or background image (Styles), spacing, row / stack / grid layout.",
23
+ group: "Gather blocks in a container: Background (colour, gradient, image + overlay) right in Settings, spacing, row / stack / grid layout.",
24
24
  columns: "Display content in columns; drag to resize.",
25
25
  buttons: "Prompt visitors to take action with buttons.",
26
26
  spacer: "Add white space between blocks.",
@@ -53,9 +53,9 @@ export const blockDesc = {
53
53
  form: "Basic contact / sign-up form: submissions are kept in the admin and emailed. Advanced forms: plugins.",
54
54
  formField: "One field of a form: text, email, phone, message, choice, consent…",
55
55
  column: "One column inside Columns; set its width, can have its own background or background image.",
56
- button: "A linked button (primary / secondary / outline) inside Buttons.",
56
+ button: "A linked button (primary / secondary / outline) inside Buttons; Normal / Hover colours, size and radius in Style.",
57
57
  accordion: "Collapsible items (FAQ) — each item is a Details block.",
58
- tabs: "Content split into tabs; click a tab name to switch.",
58
+ tabs: "Content split into tabs; click a tab name to switch; normal / active title colours in Style.",
59
59
  tab: "One tab inside Tabs: its title and content.",
60
60
  carousel: "Sliding slides (images, cards, testimonials); choose how many show at once.",
61
61
  shortcode: "Insert a plugin feature by its shortcode.",
@@ -0,0 +1,55 @@
1
+ import type { vi } from "../vi";
2
+
3
+ export const blockStyle: (typeof vi)["blockStyle"] = {
4
+ tabContent: "Content",
5
+ tabStyle: "Style",
6
+ tabAdvanced: "Advanced",
7
+ normal: "Normal",
8
+ hover: "Hover",
9
+ active: "Active",
10
+ section: {
11
+ text: "Text", list: "List", button: "Button", image: "Image", table: "Table", tabs: "Tabs", accordion: "Accordion", columns: "Columns",
12
+ separator: "Separator", icon: "Icon", content: "Title & text", number: "Number", box: "Box", bar: "Bar",
13
+ },
14
+ attr: {
15
+ textShadow: "Text shadow",
16
+ listMarker: "Marker type", listMarkerColor: "Marker color", listGap: "Space between", listDivider: "Divider",
17
+ buttonColor: "Text color", buttonBg: "Background color", buttonHoverColor: "Text color", buttonHoverBg: "Background color", buttonSize: "Size", buttonRadius: "Border radius", buttonWeight: "Font weight", buttonShadow: "Box shadow",
18
+ imageWidth: "Width", imageHeight: "Height", imageFit: "Object fit", imageRadius: "Border radius", imageBorderWidth: "Border width", imageBorderColor: "Border color", imageShadow: "Box shadow",
19
+ imageOpacity: "Opacity", imageFilter: "CSS filter", imageHoverEffect: "Hover animation", imageHoverOpacity: "Opacity", imageHoverFilter: "CSS filter",
20
+ tableBorderColor: "Cell border color", tableBorderWidth: "Cell border width", tableHeaderBg: "Header background", tableHeaderColor: "Header text", tableStripe: "Striped rows", tableCellPadding: "Cell padding", tableAlign: "Cell alignment",
21
+ tabsTitleColor: "Title color", tabsTitleBg: "Title background", tabsActiveColor: "Title color", tabsActiveBg: "Title background", tabsAccent: "Underline", tabsBorderColor: "Divider color", tabsGap: "Space between titles", tabsContentPadding: "Content padding",
22
+ accTitleColor: "Title color", accTitleBg: "Title background", accActiveColor: "Title color", accBorderColor: "Border color", accGap: "Space between", accPadding: "Padding",
23
+ columnsGap: "Columns gap", columnsDirection: "Direction",
24
+ hrStyle: "Style", hrWeight: "Weight", hrColor: "Color", hrWidth: "Width", hrAlign: "Alignment",
25
+ iconBoxIconColor: "Icon color", iconBoxIconSize: "Icon size", iconBoxTitleColor: "Title color", iconBoxTextColor: "Description color",
26
+ imageBoxRadius: "Image radius", imageBoxTitleColor: "Title color", imageBoxTextColor: "Description color",
27
+ iconListGap: "Space between", iconListDivider: "Divider", iconListIconColor: "Icon color", iconListIconSize: "Icon size", iconListTextColor: "Text color",
28
+ counterNumberColor: "Number color", counterNumberSize: "Number size", counterTitleColor: "Title color",
29
+ testimonialBg: "Background color", testimonialBorderColor: "Border color", testimonialQuoteColor: "Quote color", testimonialNameColor: "Name color", testimonialRoleColor: "Role color",
30
+ progressBarColor: "Bar color", progressTrackColor: "Track color", progressHeight: "Bar height", progressTitleColor: "Title color",
31
+ },
32
+ opt: {
33
+ sm: "Small", md: "Medium", lg: "Large", xl: "Extra large", xs: "Extra small",
34
+ disc: "• Disc", circle: "○ Circle", square: "■ Square", decimal: "1. Number", "decimal-leading-zero": "01. Zero-padded", "lower-alpha": "a. Lowercase", "upper-alpha": "A. Uppercase",
35
+ "lower-roman": "i. Roman", "upper-roman": "I. Roman", check: "✓ Check", arrow: "→ Arrow", dash: "– Dash", none: "None",
36
+ cover: "Cover", contain: "Contain",
37
+ grayscale: "Grayscale", sepia: "Sepia", blur: "Blur", bright: "Brighter", dim: "Darker", saturate: "Saturate",
38
+ zoom: "Zoom", lift: "Lift", tilt: "Tilt",
39
+ start: "Start", center: "Center", end: "End",
40
+ row: "Row", "row-reverse": "Row, reversed", column: "Stacked", "column-reverse": "Stacked, reversed",
41
+ solid: "Solid", dashed: "Dashed", dotted: "Dotted", double: "Double",
42
+ "400": "Regular", "500": "Medium", "600": "Semi-bold", "700": "Bold", "800": "Extra bold",
43
+ },
44
+ bg: {
45
+ title: "Background",
46
+ type: "Background type",
47
+ color: "Color",
48
+ gradient: "Gradient",
49
+ image: "Image",
50
+ hoverColor: "Background color on hover",
51
+ hoverNote: "Hover only changes the background color; image / gradient stay.",
52
+ legacy: "Old group background color — pick another color to move it to the new style.",
53
+ },
54
+ tabTitle: "Tab {n}",
55
+ };
@@ -13,9 +13,11 @@ import { legacyBasic } from "./legacy-basic";
13
13
  import { legacyDynamic } from "./legacy-dynamic";
14
14
  import { motion } from "./motion";
15
15
  import { background } from "./background";
16
+ import { blockStyle } from "./block-style";
16
17
  import { patternLib } from "./pattern-lib";
17
18
  import { patterns } from "./patterns";
18
19
  import { shortcuts } from "./shortcuts";
20
+ import { placeholders } from "./placeholders";
19
21
 
20
22
  /** Tiếng Anh: đủ khoá như vi/ (thiếu khoá là lỗi biên dịch) và là ngôn ngữ dự phòng của mọi ngôn ngữ khác. */
21
- export const en: typeof vi = { v2, legacy, attrs, background, bindings, blockDesc, blockTitles, blocks, controls, hints, layout, legacyBasic, legacyDynamic, motion, patternLib, patterns, shortcuts };
23
+ export const en: typeof vi = { v2, legacy, attrs, background, bindings, blockStyle, blockDesc, blockTitles, blocks, controls, hints, layout, legacyBasic, legacyDynamic, motion, patternLib, patterns, placeholders, shortcuts };
@@ -0,0 +1,96 @@
1
+ import type { placeholders as vi } from "../vi/placeholders";
2
+
3
+ export const placeholders: typeof vi = {
4
+ drop: { image: "Drop an image here", gallery: "Drop several images at once", video: "Drop a video here", audio: "Drop an audio file here", file: "Drop a file here" },
5
+ dropSub: "or choose one of the options below",
6
+ dropCover: "Drop a background image here",
7
+ dropNow: "Drop to upload",
8
+ addBlock: "Add block",
9
+ link: "URL",
10
+ linkInvalid: "Invalid URL",
11
+ embedUnsupported: "This site can't be embedded yet — use YouTube, Vimeo, Google Maps, TikTok, Spotify…",
12
+ embedHint: "YouTube, Vimeo, Google Maps, TikTok, Spotify…",
13
+ pasteToEmbed: "Paste a link to embed",
14
+ embed: "Embed",
15
+ choose: "Choose…",
16
+ missing: "Missing: {fields}",
17
+ paragraph: "Write something, or type / to choose a block",
18
+ listItem: "List item…",
19
+ taskItem: "To-do…",
20
+ heading: "Heading…",
21
+ quote: "Add a quote…",
22
+ citation: "Add a source…",
23
+ speaker: "Add the speaker's name…",
24
+ caption: "Add a caption…",
25
+ detailsSummary: "Title when collapsed…",
26
+ calloutTitle: "Title (optional)…",
27
+ code: "// Paste or type code…",
28
+ preformatted: "Text that keeps its spacing…",
29
+ buttonText: "Add button text…",
30
+ tabTitle: "Tab name…",
31
+ addTab: "Add tab",
32
+ addItem: "Add item",
33
+ addSlide: "Add slide",
34
+ addImage: "Add image",
35
+ addRow: "Add row",
36
+ addField: "Add field",
37
+ language: "Language",
38
+ languageAuto: "Auto-detect",
39
+ startAt: "Start at",
40
+ chooseLayout: "Choose a layout",
41
+ layoutStack: "Stack",
42
+ layoutRow: "Row",
43
+ layoutGrid: "Grid",
44
+ createTable: "Create table",
45
+ columns: "Columns",
46
+ rows: "Rows",
47
+ create: "Create",
48
+ queryChoose: "Choose a display",
49
+ queryList: "List",
50
+ queryGrid: "3-column grid",
51
+ queryCards: "Cards with image",
52
+ shortcodeName: "Shortcode name",
53
+ htmlCode: "Code",
54
+ htmlPreview: "Preview",
55
+ htmlPlaceholder: "<!-- Paste HTML… -->",
56
+ countdownTarget: "Count down to",
57
+ counterHint: "Use real numbers only.",
58
+ counterEnd: "Number",
59
+ rateHint: "Click a star to rate",
60
+ rateStar: "{n} stars",
61
+ tocHint: "Lists the H2–H{n} headings of the post. No headings → the table of contents is empty on the website.",
62
+ socialAdd: "Add Facebook, Zalo, YouTube…",
63
+ socialNetwork: "Network",
64
+ spacer: "Spacer {size} · drag the bottom edge to resize",
65
+ separator: "Separator",
66
+ galleryAdd: "Add images to the gallery",
67
+ boxMedia: "Drop an image or choose an icon",
68
+ boxImage: "Image",
69
+ boxIcon: "Icon",
70
+ boxTitle: "Title…",
71
+ boxText: "Short description…",
72
+ testimonialQuote: "What did the customer say…",
73
+ testimonialName: "Customer name…",
74
+ testimonialRole: "Job title…",
75
+ skill: "Skill name…",
76
+ counterTitle: "Describe the number…",
77
+ iconListItem: "First benefit…",
78
+ realData: "Live data",
79
+ sampleData: "Sample data",
80
+ noData: "No data yet",
81
+ noLogo: "No logo yet",
82
+ dropLogo: "Drop your logo here",
83
+ logoAll: "The logo changes for the whole website.",
84
+ menuEmpty: "No menu in the “{location}” location",
85
+ createMenu: "Create menu",
86
+ pickMenu: "Choose an existing menu",
87
+ noFeatured: "The preview post has no image",
88
+ noFeaturedHint: "The website hides this block for posts without an image.",
89
+ postContentHint: "Each post's content appears here",
90
+ noPosts: "No matching posts",
91
+ noPostsHint: "Visitors will see “No posts yet” (edit it in the “No results” block).",
92
+ writeFirst: "Write the first post",
93
+ serverEmpty: "The website draws nothing for this block on the sample page",
94
+ otherSettings: "Display style and other options: sidebar › Block.",
95
+ openSettings: "Open settings",
96
+ };
@@ -2,7 +2,7 @@
2
2
  export const blockDesc = {
3
3
  paragraph: "Đoạn chữ thường — nền tảng của mọi nội dung.",
4
4
  heading: "Tiêu đề mục (H2–H6), giúp người đọc và Google hiểu cấu trúc trang.",
5
- bulletList: "Danh sách gạch đầu dòng.",
5
+ bulletList: "Danh sách gạch đầu dòng — kiểu dấu (✓, →…), màu dấu, khoảng cách và đường kẻ giữa mục ở Kiểu dáng.",
6
6
  orderedList: "Danh sách đánh số theo thứ tự.",
7
7
  taskList: "Danh sách việc có ô đánh dấu.",
8
8
  blockquote: "Trích dẫn lời của ai đó.",
@@ -13,14 +13,14 @@ export const blockDesc = {
13
13
  table: "Bảng dữ liệu hàng / cột, gộp ô được.",
14
14
  image: "Ảnh có chú thích, alt cho SEO, đổi cỡ bằng tay kéo.",
15
15
  gallery: "Nhiều ảnh xếp lưới.",
16
- cover: "Ảnh hoặc màu nền lớn với chữ đè lên — phần mở đầu trang.",
16
+ cover: "Ảnh phủ kín (hoặc màu / chuyển màu) với lớp phủ và chữ đè lên — phần mở đầu trang; ảnh, điểm lấy nét, lớp phủ ở mục Nền.",
17
17
  mediaText: "Ảnh và chữ đặt cạnh nhau để bố cục hấp dẫn hơn.",
18
18
  video: "Video tải lên hoặc từ địa chỉ.",
19
19
  audio: "Tệp âm thanh có trình phát.",
20
20
  file: "Liên kết tải tệp (PDF…), có thể xem ngay trên trang.",
21
21
  youtube: "Nhúng video YouTube.",
22
22
  embed: "Nhúng nội dung từ địa chỉ (Facebook, TikTok, bản đồ…).",
23
- group: "Gom nhiều khối vào một khung để tô nền (màu, chuyển màu, ảnh nền trong Kiểu dáng), căn lề, bố cục hàng / cột / lưới.",
23
+ group: "Gom nhiều khối vào một khung: Nền (màu, chuyển màu, ảnh + lớp phủ) ngay ở Cài đặt, căn lề, bố cục hàng / cột / lưới.",
24
24
  columns: "Chia nội dung thành nhiều cột, kéo để đổi độ rộng.",
25
25
  buttons: "Một hoặc nhiều nút kêu gọi hành động.",
26
26
  spacer: "Khoảng trống giữa các khối.",
@@ -53,9 +53,9 @@ export const blockDesc = {
53
53
  form: "Form liên hệ / đăng ký cơ bản: bài gửi lưu trong admin và báo qua email. Form nâng cao: plugin.",
54
54
  formField: "Một ô của form: chữ, email, điện thoại, nội dung, chọn, đồng ý…",
55
55
  column: "Một cột trong khối Cột; chỉnh độ rộng, có thể tô nền / ảnh nền riêng.",
56
- button: "Một nút bấm có liên kết (chính / phụ / viền) — nằm trong khối Nút.",
56
+ button: "Một nút bấm có liên kết (chính / phụ / viền) — nằm trong khối Nút; màu Thường / Rê chuột, cỡ, bo góc ở Kiểu dáng.",
57
57
  accordion: "Nhiều mục gập / mở (câu hỏi thường gặp) — mỗi mục là khối Nội dung ẩn.",
58
- tabs: "Nội dung chia thẻ, bấm tên thẻ để chuyển.",
58
+ tabs: "Nội dung chia thẻ, bấm tên thẻ để chuyển; màu tiêu đề thường / đang mở ở Kiểu dáng.",
59
59
  tab: "Một thẻ trong khối Thẻ: tên thẻ và nội dung bên trong.",
60
60
  carousel: "Trình chiếu nhiều trang trượt (ảnh, thẻ, lời chứng thực), chọn số trang hiện cùng lúc.",
61
61
  shortcode: "Chèn tính năng của plugin bằng mã ngắn.",
@@ -0,0 +1,58 @@
1
+ /** Ô Kiểu dáng riêng của khối lõi (@ecomcx/ecomweb-content core-controls) + ô Nền thống nhất. Khoá = tên thuộc tính / mục / giá trị. */
2
+ export const blockStyle = {
3
+ tabContent: "Nội dung",
4
+ tabStyle: "Kiểu dáng",
5
+ tabAdvanced: "Nâng cao",
6
+ normal: "Thường",
7
+ hover: "Rê chuột",
8
+ active: "Đang mở",
9
+ /** Mục của tab Kiểu dáng. */
10
+ section: {
11
+ text: "Chữ", list: "Danh sách", button: "Nút", image: "Ảnh", table: "Bảng", tabs: "Tabs", accordion: "Accordion", columns: "Cột",
12
+ separator: "Đường kẻ", icon: "Icon", content: "Tiêu đề & chữ", number: "Con số", box: "Khung", bar: "Thanh",
13
+ },
14
+ /** Tên ô (thuộc tính). */
15
+ attr: {
16
+ textShadow: "Bóng chữ",
17
+ listMarker: "Kiểu dấu đầu dòng", listMarkerColor: "Màu dấu", listGap: "Khoảng giữa các mục", listDivider: "Đường kẻ giữa các mục",
18
+ buttonColor: "Màu chữ", buttonBg: "Màu nền", buttonHoverColor: "Màu chữ", buttonHoverBg: "Màu nền", buttonSize: "Cỡ nút", buttonRadius: "Bo góc", buttonWeight: "Độ đậm chữ", buttonShadow: "Đổ bóng",
19
+ imageWidth: "Chiều rộng", imageHeight: "Chiều cao", imageFit: "Cách phủ", imageRadius: "Bo góc", imageBorderWidth: "Độ dày viền", imageBorderColor: "Màu viền", imageShadow: "Đổ bóng",
20
+ imageOpacity: "Độ trong", imageFilter: "Bộ lọc màu", imageHoverEffect: "Hiệu ứng", imageHoverOpacity: "Độ trong", imageHoverFilter: "Bộ lọc màu",
21
+ tableBorderColor: "Màu viền ô", tableBorderWidth: "Độ dày viền ô", tableHeaderBg: "Nền hàng tiêu đề", tableHeaderColor: "Chữ hàng tiêu đề", tableStripe: "Màu hàng xen kẽ", tableCellPadding: "Khoảng đệm ô", tableAlign: "Căn chữ trong ô",
22
+ tabsTitleColor: "Màu tiêu đề", tabsTitleBg: "Nền tiêu đề", tabsActiveColor: "Màu tiêu đề", tabsActiveBg: "Nền tiêu đề", tabsAccent: "Gạch chân", tabsBorderColor: "Màu đường kẻ", tabsGap: "Khoảng giữa tiêu đề", tabsContentPadding: "Khoảng đệm nội dung",
23
+ accTitleColor: "Màu tiêu đề", accTitleBg: "Nền tiêu đề", accActiveColor: "Màu tiêu đề", accBorderColor: "Màu viền", accGap: "Khoảng giữa các mục", accPadding: "Khoảng đệm",
24
+ columnsGap: "Khoảng giữa các cột", columnsDirection: "Hướng xếp",
25
+ hrStyle: "Kiểu", hrWeight: "Độ dày", hrColor: "Màu", hrWidth: "Chiều rộng", hrAlign: "Căn",
26
+ iconBoxIconColor: "Màu icon", iconBoxIconSize: "Cỡ icon", iconBoxTitleColor: "Màu tiêu đề", iconBoxTextColor: "Màu mô tả",
27
+ imageBoxRadius: "Bo góc ảnh", imageBoxTitleColor: "Màu tiêu đề", imageBoxTextColor: "Màu mô tả",
28
+ iconListGap: "Khoảng giữa các mục", iconListDivider: "Đường kẻ giữa các mục", iconListIconColor: "Màu icon", iconListIconSize: "Cỡ icon", iconListTextColor: "Màu chữ",
29
+ counterNumberColor: "Màu số", counterNumberSize: "Cỡ số", counterTitleColor: "Màu tiêu đề",
30
+ testimonialBg: "Màu nền", testimonialBorderColor: "Màu viền", testimonialQuoteColor: "Màu lời chứng thực", testimonialNameColor: "Màu tên", testimonialRoleColor: "Màu chức danh",
31
+ progressBarColor: "Màu thanh", progressTrackColor: "Màu rãnh", progressHeight: "Độ cao thanh", progressTitleColor: "Màu tiêu đề",
32
+ },
33
+ /** Nhãn giá trị của ô chọn. */
34
+ opt: {
35
+ sm: "Nhỏ", md: "Vừa", lg: "Lớn", xl: "Rất lớn", xs: "Rất nhỏ",
36
+ disc: "• Chấm tròn", circle: "○ Vòng tròn", square: "■ Vuông", decimal: "1. Số", "decimal-leading-zero": "01. Số có 0", "lower-alpha": "a. Chữ thường", "upper-alpha": "A. Chữ hoa",
37
+ "lower-roman": "i. La Mã thường", "upper-roman": "I. La Mã hoa", check: "✓ Dấu tích", arrow: "→ Mũi tên", dash: "– Gạch ngang", none: "Không",
38
+ cover: "Phủ kín", contain: "Vừa khung",
39
+ grayscale: "Đen trắng", sepia: "Màu cũ", blur: "Làm mờ", bright: "Sáng hơn", dim: "Tối hơn", saturate: "Rực hơn",
40
+ zoom: "Phóng to", lift: "Nhấc lên", tilt: "Nghiêng",
41
+ start: "Đầu", center: "Giữa", end: "Cuối",
42
+ row: "Ngang", "row-reverse": "Ngang, đảo thứ tự", column: "Xếp dọc", "column-reverse": "Xếp dọc, đảo thứ tự",
43
+ solid: "Liền", dashed: "Gạch", dotted: "Chấm", double: "Đôi",
44
+ "400": "Thường", "500": "Vừa", "600": "Hơi đậm", "700": "Đậm", "800": "Rất đậm",
45
+ },
46
+ /** Ô Nền thống nhất (như nhóm Background của Elementor). */
47
+ bg: {
48
+ title: "Nền",
49
+ type: "Loại nền",
50
+ color: "Màu",
51
+ gradient: "Chuyển màu",
52
+ image: "Ảnh",
53
+ hoverColor: "Màu nền khi rê chuột",
54
+ hoverNote: "Rê chuột chỉ đổi màu nền; ảnh / chuyển màu giữ nguyên.",
55
+ legacy: "Màu nền cũ của nhóm — chọn màu khác để chuyển sang kiểu dáng mới.",
56
+ },
57
+ tabTitle: "Tab {n}",
58
+ };
@@ -18,8 +18,10 @@ import { legacyBasic } from "./legacy-basic";
18
18
  import { legacyDynamic } from "./legacy-dynamic";
19
19
  import { motion } from "./motion";
20
20
  import { background } from "./background";
21
+ import { blockStyle } from "./block-style";
21
22
  import { patternLib } from "./pattern-lib";
22
23
  import { patterns } from "./patterns";
23
24
  import { shortcuts } from "./shortcuts";
25
+ import { placeholders } from "./placeholders";
24
26
 
25
- export const vi = { v2, legacy, attrs, background, bindings, blockDesc, blockTitles, blocks, controls, hints, layout, legacyBasic, legacyDynamic, motion, patternLib, patterns, shortcuts };
27
+ export const vi = { v2, legacy, attrs, background, bindings, blockStyle, blockDesc, blockTitles, blocks, controls, hints, layout, legacyBasic, legacyDynamic, motion, patternLib, patterns, placeholders, shortcuts };
@@ -0,0 +1,95 @@
1
+ /** Ô giữ chỗ trong khối (chỉ có trong trình soạn — website không vẽ gì khi ô trống). */
2
+ export const placeholders = {
3
+ drop: { image: "Kéo thả ảnh vào đây", gallery: "Kéo thả nhiều ảnh cùng lúc", video: "Kéo thả video vào đây", audio: "Kéo thả tệp âm thanh vào đây", file: "Kéo thả tệp vào đây" } as Record<string, string>,
4
+ dropSub: "hoặc chọn một cách bên dưới",
5
+ dropCover: "Kéo thả ảnh nền vào đây",
6
+ dropNow: "Thả để tải lên",
7
+ addBlock: "Thêm khối",
8
+ link: "Đường dẫn",
9
+ linkInvalid: "Đường dẫn không hợp lệ",
10
+ embedUnsupported: "Chưa hỗ trợ nhúng trang này — dùng YouTube, Vimeo, Google Maps, TikTok, Spotify…",
11
+ embedHint: "YouTube, Vimeo, Google Maps, TikTok, Spotify…",
12
+ pasteToEmbed: "Dán đường dẫn để nhúng",
13
+ embed: "Nhúng",
14
+ choose: "Chọn…",
15
+ missing: "Còn thiếu: {fields}",
16
+ paragraph: "Viết nội dung, hoặc gõ / để chọn khối",
17
+ listItem: "Mục danh sách…",
18
+ taskItem: "Việc cần làm…",
19
+ heading: "Tiêu đề…",
20
+ quote: "Nhập câu trích dẫn…",
21
+ citation: "Thêm nguồn…",
22
+ speaker: "Thêm tên người nói…",
23
+ caption: "Thêm chú thích…",
24
+ detailsSummary: "Tiêu đề khi thu gọn…",
25
+ calloutTitle: "Tiêu đề (không bắt buộc)…",
26
+ code: "// Dán hoặc gõ mã…",
27
+ preformatted: "Văn bản giữ nguyên khoảng trắng…",
28
+ buttonText: "Nhập chữ trên nút…",
29
+ tabTitle: "Tên tab…",
30
+ addTab: "Thêm tab",
31
+ addItem: "Thêm mục",
32
+ addSlide: "Thêm slide",
33
+ addImage: "Thêm ảnh",
34
+ addRow: "Thêm dòng",
35
+ addField: "Thêm ô",
36
+ language: "Ngôn ngữ",
37
+ languageAuto: "Tự nhận",
38
+ startAt: "Bắt đầu từ",
39
+ chooseLayout: "Chọn kiểu bố cục",
40
+ layoutStack: "Xếp dọc",
41
+ layoutRow: "Hàng ngang",
42
+ layoutGrid: "Lưới",
43
+ createTable: "Tạo bảng",
44
+ columns: "Số cột",
45
+ rows: "Số hàng",
46
+ create: "Tạo",
47
+ queryChoose: "Chọn kiểu hiển thị",
48
+ queryList: "Danh sách",
49
+ queryGrid: "Lưới 3 cột",
50
+ queryCards: "Thẻ có ảnh",
51
+ shortcodeName: "Tên shortcode",
52
+ htmlCode: "Mã",
53
+ htmlPreview: "Xem trước",
54
+ htmlPlaceholder: "<!-- Dán mã HTML… -->",
55
+ countdownTarget: "Đếm tới",
56
+ counterHint: "Chỉ dùng số thật.",
57
+ counterEnd: "Số",
58
+ rateHint: "Bấm vào sao để chấm",
59
+ rateStar: "{n} sao",
60
+ tocHint: "Tự lấy các tiêu đề H2–H{n} trong bài. Bài chưa có tiêu đề → mục lục trống trên website.",
61
+ socialAdd: "Thêm Facebook, Zalo, YouTube…",
62
+ socialNetwork: "Mạng",
63
+ spacer: "Khoảng trống {size} · kéo cạnh dưới để đổi",
64
+ separator: "Đường kẻ",
65
+ galleryAdd: "Thêm ảnh vào gallery",
66
+ boxMedia: "Thả ảnh hoặc chọn icon",
67
+ boxImage: "Ảnh",
68
+ boxIcon: "Icon",
69
+ boxTitle: "Tiêu đề…",
70
+ boxText: "Mô tả ngắn…",
71
+ testimonialQuote: "Nhập lời khách hàng nói…",
72
+ testimonialName: "Tên khách…",
73
+ testimonialRole: "Chức danh…",
74
+ skill: "Tên kỹ năng…",
75
+ counterTitle: "Mô tả con số…",
76
+ iconListItem: "Lợi ích thứ nhất…",
77
+ realData: "Dữ liệu thật",
78
+ sampleData: "Dữ liệu mẫu",
79
+ noData: "Chưa có dữ liệu",
80
+ noLogo: "Chưa có logo",
81
+ dropLogo: "Thả logo vào đây",
82
+ logoAll: "Chọn xong là đổi logo cho cả website.",
83
+ menuEmpty: "Vị trí “{location}” chưa có menu",
84
+ createMenu: "Tạo menu",
85
+ pickMenu: "Chọn menu có sẵn",
86
+ noFeatured: "Bài xem thử chưa có ảnh",
87
+ noFeaturedHint: "Website sẽ ẩn khối này với bài không có ảnh.",
88
+ postContentHint: "Nội dung của từng bài hiện ở đây",
89
+ noPosts: "Chưa có bài phù hợp",
90
+ noPostsHint: "Khách sẽ thấy: “Chưa có bài viết” (sửa chữ ở khối “Khi không có bài”).",
91
+ writeFirst: "Viết bài đầu tiên",
92
+ serverEmpty: "Website chưa vẽ gì cho khối này ở trang mẫu",
93
+ otherSettings: "Kiểu hiển thị và thuộc tính khác: thanh bên › Khối.",
94
+ openSettings: "Mở cài đặt",
95
+ };
@@ -1,6 +1,6 @@
1
1
  /** Kho panel plugin (registerBlockPanel) — đăng ký ở đây, trình soạn đọc. */
2
2
  import type { ComponentType } from "react";
3
- import { defineBlockControls, type BlockControls, type ControlSpec } from "@ecomcx/ecomweb-content";
3
+ import { CORE_CONTROLS, defineBlockControls, type BlockControls, type ControlSpec } from "@ecomcx/ecomweb-content";
4
4
 
5
5
  /** Props của panel plugin trong tab "Khối". */
6
6
  export interface BlockPanelProps {
@@ -40,12 +40,13 @@ const listeners = new Set<() => void>();
40
40
  let snapshot: BlockPanel[] = [];
41
41
  const changed = () => {
42
42
  snapshot = [...panels.values()].sort((a, b) => (a.order ?? 10) - (b.order ?? 10));
43
- controls = snapshot.flatMap((p) => { const t = typed(p); return Object.keys(t).length ? [{ id: p.id, blocks: p.blocks ?? "*", attributes: t }] : []; });
43
+ controls = [...CORE_CONTROLS, ...snapshot.flatMap((p) => { const t = typed(p); return Object.keys(t).length ? [{ id: p.id, blocks: p.blocks ?? "*", attributes: t }] : []; })];
44
44
  listeners.forEach((l) => l());
45
45
  };
46
46
  /** Thuộc tính có `type` + `css` → ô điều khiển khai CSS (kiểm khai báo ngay lúc đăng ký: sai → ném lỗi). */
47
47
  const typed = (p: BlockPanel) => Object.fromEntries(Object.entries(p.attributes ?? {}).filter(([, s]) => "type" in s && s.type)) as Record<string, ControlSpec>;
48
- let controls: BlockControls[] = [];
48
+ // Ô Kiểu dáng của khối lõi (1.24) luôn có, ô của plugin thêm sau
49
+ let controls: BlockControls[] = [...CORE_CONTROLS];
49
50
  export function registerBlockPanel(panel: BlockPanel) {
50
51
  const t = typed(panel);
51
52
  if (Object.keys(t).length) defineBlockControls({ id: panel.id, blocks: panel.blocks ?? "*", attributes: t });
@@ -55,7 +56,7 @@ export function unregisterBlockPanel(id: string) { const had = panels.delete(id)
55
56
 
56
57
  /** Panel áp dụng cho một loại khối. */
57
58
  export const blockPanelsFor = (type: string, tab: "block" | "style" = "block") => snapshot.filter((p) => (p.blocks === undefined || p.blocks === "*" || p.blocks.includes(type)) && (p.tab ?? "block") === tab);
58
- /** Ô điều khiển khai CSS của mọi panel (đầu vào của controlsCss — cùng hàm website dùng). */
59
+ /** Ô điều khiển khai CSS: của khối lõi + của mọi panel (đầu vào của controlsCss — cùng hàm website dùng). */
59
60
  export const blockControls = () => controls;
60
61
  export const blockPanels = () => snapshot;
61
62
  export function onBlockPanelsChange(l: () => void) { listeners.add(l); return () => { listeners.delete(l); }; }
@@ -1,6 +1,10 @@
1
- import { blockDefaults } from "@ecomcx/ecomweb-content";
2
- import { Blocks } from "lucide-react";
3
- import type { ComponentType } from "react";
1
+ import { blockDefaults, isSafeUrl, type BlockAttrSpec, type BlockDefinition } from "@ecomcx/ecomweb-content";
2
+ import { Blocks, X } from "lucide-react";
3
+ import { useId, type ComponentType, type ReactNode } from "react";
4
+ import { useEditor } from "../context";
5
+ import { useMsgs } from "../i18n";
6
+ import { attrLabel, controlOf } from "../ui/attr-form";
7
+ import { MediaPlaceholder, MissingNote, TextPlaceholder } from "../ui/placeholders";
4
8
  import { blockOptions, onBlockDefinitionsChange, registeredBlocks, type BlockEditProps as V1EditProps } from "../../shared/block-defs";
5
9
  import { InnerBlocks } from "../canvas/block-list";
6
10
  import { fromRich, makeBlock } from "../core/model";
@@ -19,6 +23,85 @@ function wrapV1Edit(Edit: ComponentType<V1EditProps>): ComponentType<BlockEditPr
19
23
  };
20
24
  }
21
25
 
26
+ /** Loại ô core tự vẽ trong khối plugin; select / checkbox / color là tuỳ chọn → ở thanh bên. */
27
+ const INLINE_CONTROLS = new Set(["media", "text", "textarea", "url", "number"]);
28
+ const TECH_ATTRS = new Set(["_v", "style", "className", "anchor", "blockStyle", "mediaId", "id", "lock", "templateLock", "bindings", "metadata"]);
29
+ const empty = (v: unknown) => v == null || v === "" || (Array.isArray(v) && !v.length);
30
+
31
+ /** Ô của khối plugin theo `placeholder.fields` (mặc định: mọi thuộc tính media / text / textarea / url / number). */
32
+ export function placeholderFields(def: Pick<BlockDefinition, "attributes"> & { placeholder?: { fields?: string[]; required?: string[] } }): { fields: string[]; required: string[] } {
33
+ const attrs = def.attributes ?? {};
34
+ const auto = Object.keys(attrs).filter((k) => !TECH_ATTRS.has(k) && INLINE_CONTROLS.has(controlOf(attrs[k])));
35
+ const fields = (def.placeholder?.fields ?? auto).filter((k) => attrs[k]);
36
+ return { fields, required: (def.placeholder?.required ?? []).filter((k) => attrs[k]) };
37
+ }
38
+
39
+ /** Một ô giữ chỗ tự sinh (có <label> cho trình đọc màn hình). */
40
+ function AutoField({ name, spec, label, value, required, set }: { name: string; spec: BlockAttrSpec; label: string; value: unknown; required: boolean; set(v: unknown): void }) {
41
+ const id = useId();
42
+ const tp = useMsgs("placeholders");
43
+ const control = controlOf(spec);
44
+ const head = <span className="ecx-ph-label">{label}{required && <span className="ecx-ph-req" aria-hidden> *</span>}</span>;
45
+ if (control === "media") {
46
+ const url = typeof value === "string" && isSafeUrl(value) ? value : "";
47
+ return (
48
+ <div className="ecx-ph-field is-media" role="group" aria-label={label} data-field={name}>
49
+ {head}
50
+ {url ? (
51
+ <span className="ecx-ph-thumb" contentEditable={false}>
52
+ <img src={url} alt="" draggable={false} />
53
+ <button type="button" className="ecx-tool" aria-label={`${label}: ×`} onMouseDown={(e) => e.stopPropagation()} onClick={() => set(undefined)}><X className="ecx-icon ecx-icon-sm" /></button>
54
+ </span>
55
+ ) : <MediaPlaceholder kind="image" compact title={tp.drop.image} onSelect={(items) => set(items[0].url)} onUrl={(u) => set(u)} />}
56
+ </div>
57
+ );
58
+ }
59
+ const num = control === "number";
60
+ const bad = control === "url" && typeof value === "string" && value !== "" && !isSafeUrl(value);
61
+ return (
62
+ <label className="ecx-ph-field" htmlFor={id} data-field={name} contentEditable={false} onMouseDown={(e) => e.stopPropagation()}>
63
+ {head}
64
+ {control === "text" || control === "textarea"
65
+ ? <TextPlaceholder id={id} value={String(value ?? "")} onChange={(v) => set(v)} placeholder={`${label}…`} multiline={control === "textarea"} required={required} label={label} className="ecx-input" />
66
+ : <input id={id} className="ecx-input" type={num ? "number" : "url"} inputMode={num ? "decimal" : "url"} min={spec.min} max={spec.max} placeholder={num ? "0" : "https://…"} required={required}
67
+ value={value == null ? "" : String(value)} aria-invalid={bad || undefined} onChange={(e) => set(e.target.value === "" ? undefined : num ? Number(e.target.value) : e.target.value.trim())} />}
68
+ {bad && <span className="ecx-media-error" role="alert">{tp.linkInvalid}</span>}
69
+ </label>
70
+ );
71
+ }
72
+
73
+ /**
74
+ * Khối plugin không có giao diện riêng: core tự vẽ ô giữ chỗ từ `attributes` (ô thả media, ô gõ, ô link, ô số; khối chứa → "+ Thêm khối").
75
+ * Đang chọn / website chưa vẽ được → các ô này; bấm ra ngoài và website vẽ được → bản website vẽ (ServerBlock).
76
+ */
77
+ function autoEdit(def: BlockDefinition, translate: (s: string) => string, Icon: ComponentType<{ className?: string }>): ComponentType<BlockEditProps> {
78
+ const { fields, required } = placeholderFields(def as never);
79
+ return function AutoPlaceholderEdit({ block, blockProps, setAttrs, editable, labels }: BlockEditProps) {
80
+ const { store } = useEditor();
81
+ const tp = useMsgs("placeholders");
82
+ const label = (k: string) => attrLabel(k, def.attributes[k], labels.lang, translate);
83
+ const missing = required.filter((k) => empty(block.attrs[k]));
84
+ const others = Object.keys(def.attributes).some((k) => !TECH_ATTRS.has(k) && !fields.includes(k) && controlOf(def.attributes[k]) !== "hidden");
85
+ let body: ReactNode = null;
86
+ if (editable && fields.length) body = (
87
+ // Gõ vào ô của khối → chọn khối (thanh công cụ + bảng cài đặt đúng khối)
88
+ <div className="ecx-ph-fields" onFocusCapture={() => { if (!store.getState().selection.ids.includes(block.id)) store.select([block.id], { editing: null }); }}>
89
+ {fields.map((k) => <AutoField key={k} name={k} spec={def.attributes[k]} label={label(k)} value={block.attrs[k]} required={required.includes(k)} set={(v) => setAttrs({ [k]: v })} />)}
90
+ </div>
91
+ );
92
+ return (
93
+ <div {...blockProps} className={cx(blockProps.className, "ecx-placeholder-block ecx-ph-auto", missing.length && "is-missing")} data-ecx-placeholder="auto">
94
+ <span className="ecx-placeholder-title"><Icon className="ecx-icon" />{translate(def.title)}</span>
95
+ {body}
96
+ {block.inline && <RichText blockId={block.id} value={block.inline} tagName="div" placeholder={`${translate(def.title)}…`} placeholderAlways editable={editable} />}
97
+ {editable && <MissingNote fields={missing.map(label)} />}
98
+ {editable && others && <span className="ecx-placeholder-summary">{tp.otherSettings}</span>}
99
+ {block.content && <InnerBlocks parent={block} />}
100
+ </div>
101
+ );
102
+ };
103
+ }
104
+
22
105
  /**
23
106
  * Khối plugin đăng ký bằng registerBlock(defineBlock(...)) → khối v2 (form cài đặt tự sinh, xem trước của plugin nếu có).
24
107
  * Plugin cài sau khi mở trình soạn vẫn hiện (theo dõi thay đổi). Trả về hàm huỷ theo dõi.
@@ -38,9 +121,12 @@ export function syncPluginBlocks(registry: BlockTypeRegistry): () => void {
38
121
  icon: o.icon ?? Blocks,
39
122
  templateOnly: o.templateOnly,
40
123
  ...(o.styleGroups ? { supports: { style: o.styleGroups.length ? o.styleGroups : false } } : {}),
41
- edit: o.edit ? wrapV1Edit(o.edit) : undefined,
42
- // Không có xem trước riêng và không chứa khối con → website vẽ bằng renderer của theme/plugin (viết khối một lần)
124
+ // Không có xem trước riêng: core tự sinh ô giữ chỗ từ thuộc tính (plugin cũ không sửa gì vẫn có)
125
+ edit: o.edit ? wrapV1Edit(o.edit) : autoEdit(def, t, o.icon ?? Blocks),
126
+ // Không có xem trước riêng và không chứa khối con → website vẽ bằng renderer của theme/plugin (viết khối một lần);
127
+ // đang chọn khối → ô giữ chỗ để nhập ngay trên khối
43
128
  serverRender: !o.edit && def.content !== "blocks",
129
+ editWhenSelected: !o.edit,
44
130
  create: (attrs) => {
45
131
  // blockDefaults kèm "_v" = phiên bản khối: thiếu nó website coi dữ liệu mới là bản 1 rồi chạy migrate lên dữ liệu đã ở bản mới
46
132
  const defaults = blockDefaults(def);
@@ -9,6 +9,7 @@ import { messages } from "../../i18n";
9
9
  import { RichText } from "../text/rich-text";
10
10
  import { Field } from "../ui/attr-form";
11
11
  import { useEditor } from "../context";
12
+ import { AddBlockButton } from "../ui/placeholders";
12
13
 
13
14
  const cx = (...c: unknown[]) => c.filter((x): x is string => typeof x === "string" && x !== "").join(" ");
14
15
  const merge = (bp: BlockEditProps["blockProps"], className: string, style?: CSSProperties) => ({ ...bp, className: cx(bp.className, className), style: { ...(bp.style ?? {}), ...style } });
@@ -26,12 +27,14 @@ export function fieldNameFrom(label: string, taken: string[] = []): string {
26
27
 
27
28
  function FormEdit({ block, blockProps, setAttrs, editable }: BlockEditProps) {
28
29
  const t = useMsgs("blocks");
30
+ const tp = useMsgs("placeholders");
29
31
  const a = block.attrs;
30
32
  // Mẫu (pattern) chèn vào chưa có mã: tạo một lần để máy chủ nhận ra form này
31
33
  useEffect(() => { if (editable && !a.formId) setAttrs({ formId: newFormId() }); }, [editable, a.formId, setAttrs]);
32
34
  return (
33
35
  <div {...merge(blockProps, "ecx-form-blocks")} data-form-id={String(a.formId ?? "")}>
34
36
  <InnerBlocks parent={block} />
37
+ {editable && <AddBlockButton parentId={block.id} label={tp.addField} className="is-inline" />}
35
38
  <div className="ecx-form-actions">
36
39
  <span className={blockShell("button", { variant: "primary" })?.className} style={blockShell("button", { variant: "primary" })?.style as CSSProperties} role="presentation">
37
40
  <RichText blockId={block.id} field="submitText" tagName="span" value={String(a.submitText ?? "")} onChange={(v) => setAttrs({ submitText: v })} placeholder={t.formSubmit} placeholderAlways editable={editable} />