@ecomcx/ecomweb-editor 1.32.0 → 1.33.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ecomcx/ecomweb-editor",
3
- "version": "1.32.0",
3
+ "version": "1.33.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.26.0",
32
+ "@ecomcx/ecomweb-content": "^1.27.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.26.0",
48
+ "@ecomcx/ecomweb-content": "^1.27.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 bindings = {
3
3
  panelTitle: "Bind data",
4
4
  panelHelp: "Show a value from site data at render time (post title, meta field, plugin data…) instead of typed text.",
5
- notBound: "— Not bound —",
5
+ notBound: "— Not bound —", hideIfEmpty: "Hide the block when the source has no value",
6
6
  unbind: "Unbind",
7
7
  source: "source",
8
8
  field: "field",
@@ -73,6 +73,7 @@ export const blockDesc = {
73
73
  pageList: "The site’s pages, by level.",
74
74
  archives: "Links to posts by month.",
75
75
  postTemplate: "How each post looks inside a post list.",
76
+ queryFilter: "Filter bar for a post list: search, pick a category, sort. Turn on \"Use the filter bar\" on the post list block.",
76
77
  pagination: "Previous / next and page numbers for a post list.",
77
78
  queryEmpty: "Content shown when the post list is empty.",
78
79
  syncedPattern: "Shared pattern — edit once, changes on every page using it.",
@@ -50,6 +50,7 @@ export const blockTitles = {
50
50
  postNavigation: "Previous / next post",
51
51
  query: "Query loop",
52
52
  postTemplate: "Post template",
53
+ queryFilter: "Filter bar",
53
54
  pagination: "Pagination",
54
55
  queryEmpty: "No results",
55
56
  form: "Form",
@@ -25,7 +25,8 @@ export const blocks = {
25
25
  contents: "Contents",
26
26
  menu: "Menu",
27
27
  noMenuIsAssigned: "No menu is assigned to this location — assign one in Appearance › Menus, or pick another location.",
28
- searchLabel: "Search", searchPlaceholder: "Search the site…", searchButton: "Search",
28
+ filterAll: "All", filterSearch: "Search this list…", filterSort: "Sort by", filterNewest: "Newest", filterEmpty: "Empty filter bar: turn on search, sort or pick a taxonomy in the right panel",
29
+ searchLabel: "Search", searchScope: "Search in", searchAll: "All", searchPlaceholder: "Search the site…", searchButton: "Search",
29
30
  categoryName: "Category name",
30
31
  category: "Category: ",
31
32
  theDescriptionOfThe: "The description of the category / tag being viewed.",
@@ -160,6 +160,7 @@ export const hints = {
160
160
  "navigation.overlayMenu.label": "Collapse into menu button",
161
161
  "navigation.overlayMenu.opt.never": "Never",
162
162
  "navigation.overlayMenu.opt.mobile": "Mobile",
163
+ "navigation.overlayMenu.opt.tablet": "Tablet",
163
164
  "navigation.overlayMenu.opt.always": "Always",
164
165
  "search.showLabel.label": "Show label",
165
166
  "search.buttonPosition.label": "Button position",
@@ -421,6 +422,79 @@ export const hints = {
421
422
  "tabs.iconOnly.label": "Icon only",
422
423
  "tabs.iconOnly.help": "Hides the label of tabs that have an icon (kept for screen readers); tabs without an icon still show text",
423
424
  "tableOfContents.showTitle.label": "Show title",
425
+ "search.scopeSelect.label": "Search scope dropdown",
426
+ "search.scopeSelect.help": "Visitors choose between All and each content type (products, posts…)",
427
+ "search.scopes.label": "Types to choose from",
428
+ "search.scopes.help": "One entry per type as code:label, separated by commas. Example: product:Products, post:News, page:Pages",
429
+ "query.taxonomy.label": "Taxonomy",
430
+ "query.taxonomy.help": "Filter by a taxonomy other than category / tag, e.g. product categories (product_cat)",
431
+ "query.term.label": "Taxonomy term",
432
+ "postTemplate.layout.opt.carousel": "Horizontal scroll",
433
+ "postTemplate.gap.label": "Gap between cards",
434
+ "postTemplate.gap.help": "A size such as sm, md, lg or a length like 16px. Empty = 1.5rem",
435
+ "postTemplate.arrows.label": "Show previous / next buttons",
436
+ "postTemplate.columnsTablet.label": "Columns on tablet",
437
+ "postTemplate.columnsMobile.label": "Columns on phone",
438
+ "search.collapse.label": "Collapse to a magnifier button",
439
+ "search.collapse.help": "On small screens only the magnifier shows; tap to open the field (no need for two Search blocks)",
440
+ "search.collapse.opt.never": "No",
441
+ "search.collapse.opt.tablet": "From tablet",
442
+ "search.collapse.opt.mobile": "Phone",
443
+ "query.source.label": "Posts from",
444
+ "query.source.opt.latest": "Latest",
445
+ "query.source.opt.manual": "Hand-picked",
446
+ "query.source.opt.related": "Related",
447
+ "query.include.label": "Post ids (hand-picked)",
448
+ "query.include.help": "Post ids separated by commas, shown in this order",
449
+ "query.include.placeholder": "12, 7, 31",
450
+ "query.terms.label": "Taxonomy terms",
451
+ "query.termMode.label": "Match",
452
+ "query.termMode.opt.any": "Any term",
453
+ "query.termMode.opt.all": "All terms",
454
+ "query.termMode.opt.none": "Exclude",
455
+ "query.metaKey.label": "Custom field",
456
+ "query.metaKey.help": "Filter by the value of a custom field (ACF…)",
457
+ "query.metaKey.placeholder": "sale_price",
458
+ "query.metaCompare.label": "Compare",
459
+ "query.metaValue.label": "Value",
460
+ "query.dateRange.label": "Published in",
461
+ "query.dateRange.opt.any": "Any time",
462
+ "query.dateRange.opt.7": "Last 7 days",
463
+ "query.dateRange.opt.30": "Last 30 days",
464
+ "query.dateRange.opt.90": "Last 90 days",
465
+ "query.dateRange.opt.365": "Last year",
466
+ "query.after.label": "From date",
467
+ "query.after.placeholder": "2026-01-31",
468
+ "query.before.label": "Until date",
469
+ "query.before.placeholder": "2026-12-31",
470
+ "query.parent.label": "Children of id",
471
+ "query.parent.help": "Only posts whose parent is this page / post (id)",
472
+ "query.offset.label": "Skip the first N",
473
+ "query.offset.help": "Useful when a featured post is already shown elsewhere",
474
+ "query.excludeCurrent.label": "Skip the current post",
475
+ "query.excludeCurrent.help": "On a post / product page, do not repeat that post in the list",
476
+ "query.authorCurrent.label": "Same author as the current post",
477
+ "query.urlFilters.label": "Use the filter bar",
478
+ "query.urlFilters.help": "A Filter bar block on the page (search, terms, sort) filters this list",
479
+ "queryFilter.taxonomy.label": "Taxonomy",
480
+ "queryFilter.taxonomy.help": "What to filter by, e.g. product categories",
481
+ "queryFilter.termStyle.label": "Term style",
482
+ "queryFilter.termStyle.opt.none": "None",
483
+ "queryFilter.termStyle.opt.links": "Links",
484
+ "queryFilter.termStyle.opt.chips": "Filter buttons",
485
+ "queryFilter.termStyle.opt.select": "Dropdown",
486
+ "queryFilter.allLabel.label": "All label",
487
+ "queryFilter.allLabel.placeholder": "All",
488
+ "queryFilter.showSearch.label": "Show search",
489
+ "queryFilter.showSort.label": "Show sorting",
490
+ "queryFilter.sortOptions.label": "Sort choices",
491
+ "queryFilter.sortOptions.help": "Pick from: date_desc, date_asc, title_asc, title_desc, modified_desc, rand",
492
+ "queryFilter.sortOptions.placeholder": "date_desc,date_asc,title_asc",
493
+ "queryFilter.placeholder.label": "Search placeholder",
494
+ "queryFilter.submitText.label": "Filter button text",
495
+ "queryFilter.action.label": "Page that receives the filters",
496
+ "queryFilter.action.help": "Empty = this page",
497
+ "queryFilter.action.placeholder": "/product",
424
498
  "search.buttonStyle.label": "Button style",
425
499
  "search.buttonStyle.opt.text": "Text",
426
500
  "search.buttonStyle.opt.icon": "Magnifier icon",
@@ -33,6 +33,9 @@ export const placeholders: typeof vi = {
33
33
  addTab: "Add tab",
34
34
  addItem: "Add item",
35
35
  addSlide: "Add slide",
36
+ slide: "Slide",
37
+ prevSlide: "Previous slide",
38
+ nextSlide: "Next slide",
36
39
  addImage: "Add image",
37
40
  addRow: "Add row",
38
41
  addField: "Add field",
@@ -2,7 +2,7 @@
2
2
  export const bindings = {
3
3
  panelTitle: "Gắn dữ liệu",
4
4
  panelHelp: "Lấy giá trị từ dữ liệu của website khi hiển thị (tiêu đề bài, trường meta, dữ liệu của plugin…) thay cho chữ gõ tay.",
5
- notBound: "— Không gắn —",
5
+ notBound: "— Không gắn —", hideIfEmpty: "Ẩn khối khi nguồn không có giá trị",
6
6
  unbind: "Bỏ gắn",
7
7
  source: "nguồn",
8
8
  field: "trường",
@@ -73,6 +73,7 @@ export const blockDesc = {
73
73
  pageList: "Danh sách các trang của website, theo cấp.",
74
74
  archives: "Liên kết lưu trữ bài theo tháng.",
75
75
  postTemplate: "Khuôn hiển thị mỗi bài trong khối Danh sách bài.",
76
+ queryFilter: "Thanh lọc cho danh sách: tìm, chọn danh mục, sắp xếp. Bật \"Nhận bộ lọc từ thanh lọc\" ở khối Danh sách bài.",
76
77
  pagination: "Nút trang trước / sau và số trang của danh sách bài.",
77
78
  queryEmpty: "Nội dung hiện khi danh sách bài không có bài nào.",
78
79
  syncedPattern: "Mẫu dùng chung — sửa một nơi, đổi ở mọi trang dùng nó.",
@@ -50,6 +50,7 @@ export const blockTitles = {
50
50
  postNavigation: "Bài trước / bài sau",
51
51
  query: "Danh sách bài",
52
52
  postTemplate: "Khuôn mỗi bài",
53
+ queryFilter: "Thanh lọc",
53
54
  pagination: "Phân trang",
54
55
  queryEmpty: "Khi không có bài",
55
56
  form: "Form",
@@ -25,7 +25,8 @@ export const blocks = {
25
25
  contents: "Mục lục",
26
26
  menu: "Menu",
27
27
  noMenuIsAssigned: "Chưa có menu nào gán cho vị trí này — gán ở Giao diện › Menu, hoặc chọn vị trí khác trong bảng cài đặt.",
28
- searchLabel: "Tìm kiếm", searchPlaceholder: "Tìm trên website…", searchButton: "Tìm",
28
+ filterAll: "Tất cả", filterSearch: "Tìm trong danh sách…", filterSort: "Sắp xếp", filterNewest: "Mới nhất", filterEmpty: "Thanh lọc trống: bật tìm kiếm, sắp xếp hoặc chọn phân loại ở bảng bên phải",
29
+ searchLabel: "Tìm kiếm", searchScope: "Phạm vi tìm kiếm", searchAll: "Tất cả", searchPlaceholder: "Tìm trên website…", searchButton: "Tìm",
29
30
  categoryName: "Tên chuyên mục",
30
31
  category: "Chuyên mục: ",
31
32
  theDescriptionOfThe: "Mô tả của chuyên mục / thẻ đang xem.",
@@ -160,6 +160,7 @@ export const hints = {
160
160
  "navigation.overlayMenu.label": "Thu gọn thành nút menu",
161
161
  "navigation.overlayMenu.opt.never": "Không",
162
162
  "navigation.overlayMenu.opt.mobile": "Điện thoại",
163
+ "navigation.overlayMenu.opt.tablet": "Máy tính bảng",
163
164
  "navigation.overlayMenu.opt.always": "Luôn luôn",
164
165
  "search.showLabel.label": "Hiện nhãn",
165
166
  "search.buttonPosition.label": "Vị trí nút",
@@ -421,6 +422,79 @@ export const hints = {
421
422
  "tabs.iconOnly.label": "Chỉ hiện icon",
422
423
  "tabs.iconOnly.help": "Chữ của tab có icon được ẩn (vẫn dành cho trình đọc màn hình); tab không có icon vẫn hiện chữ",
423
424
  "tableOfContents.showTitle.label": "Hiện tiêu đề",
425
+ "search.scopeSelect.label": "Ô chọn phạm vi tìm kiếm",
426
+ "search.scopeSelect.help": "Khách chọn tìm trong Tất cả hoặc từng loại nội dung (sản phẩm, bài viết…)",
427
+ "search.scopes.label": "Các loại để chọn",
428
+ "search.scopes.help": "Mỗi loại một mục, dạng mã:nhãn, cách nhau bằng dấu phẩy. Ví dụ: product:Sản phẩm, post:Tin tức, page:Trang",
429
+ "query.taxonomy.label": "Phân loại",
430
+ "query.taxonomy.help": "Lọc theo phân loại khác chuyên mục / thẻ, ví dụ danh mục sản phẩm (product_cat)",
431
+ "query.term.label": "Mục của phân loại",
432
+ "postTemplate.layout.opt.carousel": "Cuộn ngang",
433
+ "postTemplate.gap.label": "Khoảng cách giữa các thẻ",
434
+ "postTemplate.gap.help": "Cỡ như sm, md, lg hoặc độ dài như 16px. Để trống = 1.5rem",
435
+ "postTemplate.arrows.label": "Hiện nút trước / sau",
436
+ "postTemplate.columnsTablet.label": "Số cột trên máy tính bảng",
437
+ "postTemplate.columnsMobile.label": "Số cột trên điện thoại",
438
+ "search.collapse.label": "Thu gọn thành nút kính lúp",
439
+ "search.collapse.help": "Trên màn hình nhỏ chỉ hiện nút kính lúp, bấm mới mở ô nhập (khỏi phải đặt hai khối Tìm kiếm cho máy tính và điện thoại)",
440
+ "search.collapse.opt.never": "Không",
441
+ "search.collapse.opt.tablet": "Từ tablet",
442
+ "search.collapse.opt.mobile": "Điện thoại",
443
+ "query.source.label": "Nguồn bài",
444
+ "query.source.opt.latest": "Mới nhất",
445
+ "query.source.opt.manual": "Chọn tay",
446
+ "query.source.opt.related": "Liên quan",
447
+ "query.include.label": "Mã bài (chọn tay)",
448
+ "query.include.help": "Các mã bài cách nhau dấu phẩy, hiện đúng thứ tự này",
449
+ "query.include.placeholder": "12, 7, 31",
450
+ "query.terms.label": "Mục của phân loại",
451
+ "query.termMode.label": "Cách lọc",
452
+ "query.termMode.opt.any": "Bất kỳ mục",
453
+ "query.termMode.opt.all": "Đủ mọi mục",
454
+ "query.termMode.opt.none": "Loại trừ",
455
+ "query.metaKey.label": "Trường tuỳ biến",
456
+ "query.metaKey.help": "Lọc theo giá trị của một trường tuỳ biến (ACF…)",
457
+ "query.metaKey.placeholder": "gia_ban",
458
+ "query.metaCompare.label": "So sánh",
459
+ "query.metaValue.label": "Giá trị",
460
+ "query.dateRange.label": "Đăng trong",
461
+ "query.dateRange.opt.any": "Mọi lúc",
462
+ "query.dateRange.opt.7": "7 ngày qua",
463
+ "query.dateRange.opt.30": "30 ngày qua",
464
+ "query.dateRange.opt.90": "90 ngày qua",
465
+ "query.dateRange.opt.365": "Năm qua",
466
+ "query.after.label": "Từ ngày",
467
+ "query.after.placeholder": "2026-01-31",
468
+ "query.before.label": "Đến ngày",
469
+ "query.before.placeholder": "2026-12-31",
470
+ "query.parent.label": "Bài con của mã",
471
+ "query.parent.help": "Chỉ lấy bài có cha là trang / bài này (mã bài)",
472
+ "query.offset.label": "Bỏ qua N bài đầu",
473
+ "query.offset.help": "Hữu ích khi bài nổi bật đã hiện ở khối khác",
474
+ "query.excludeCurrent.label": "Bỏ bài đang xem",
475
+ "query.excludeCurrent.help": "Trên trang bài viết / sản phẩm, không lặp lại chính bài đó trong danh sách",
476
+ "query.authorCurrent.label": "Cùng tác giả với bài đang xem",
477
+ "query.urlFilters.label": "Nhận bộ lọc từ thanh lọc",
478
+ "query.urlFilters.help": "Khối Thanh lọc trên trang (tìm, mục, sắp xếp) sẽ lọc danh sách này",
479
+ "queryFilter.taxonomy.label": "Phân loại",
480
+ "queryFilter.taxonomy.help": "Danh mục để lọc, ví dụ danh mục sản phẩm",
481
+ "queryFilter.termStyle.label": "Kiểu hiện mục",
482
+ "queryFilter.termStyle.opt.none": "Không",
483
+ "queryFilter.termStyle.opt.links": "Liên kết",
484
+ "queryFilter.termStyle.opt.chips": "Nút lọc",
485
+ "queryFilter.termStyle.opt.select": "Ô chọn",
486
+ "queryFilter.allLabel.label": "Chữ mục Tất cả",
487
+ "queryFilter.allLabel.placeholder": "Tất cả",
488
+ "queryFilter.showSearch.label": "Có ô tìm",
489
+ "queryFilter.showSort.label": "Có ô sắp xếp",
490
+ "queryFilter.sortOptions.label": "Các cách sắp xếp",
491
+ "queryFilter.sortOptions.help": "Chọn trong: date_desc, date_asc, title_asc, title_desc, modified_desc, rand",
492
+ "queryFilter.sortOptions.placeholder": "date_desc,date_asc,title_asc",
493
+ "queryFilter.placeholder.label": "Chữ gợi ý ô tìm",
494
+ "queryFilter.submitText.label": "Chữ nút lọc",
495
+ "queryFilter.action.label": "Trang nhận bộ lọc",
496
+ "queryFilter.action.help": "Để trống = chính trang này",
497
+ "queryFilter.action.placeholder": "/product",
424
498
  "search.buttonStyle.label": "Kiểu nút",
425
499
  "search.buttonStyle.opt.text": "Chữ",
426
500
  "search.buttonStyle.opt.icon": "Icon kính lúp",
@@ -32,6 +32,9 @@ export const placeholders = {
32
32
  moveTabRight: "Dời tab đang mở sang phải",
33
33
  addItem: "Thêm mục",
34
34
  addSlide: "Thêm slide",
35
+ slide: "Slide",
36
+ prevSlide: "Slide trước",
37
+ nextSlide: "Slide sau",
35
38
  addImage: "Thêm ảnh",
36
39
  addRow: "Thêm dòng",
37
40
  addField: "Thêm ô",
@@ -1,14 +1,14 @@
1
1
  import { COUNTDOWN_ZONES, ICON_NAMES, ICON_PATHS, countdownParts, countdownTarget, wallInZone, blockShell, buttonIcon, buttonWrapShell, colorCss, controlsCss, coverParts, spacingValue, tabsClass } from "@ecomcx/ecomweb-content";
2
2
  import { blockControls } from "../../shared/panel-store";
3
3
  import { ChevronLeft, ChevronRight, Plus, ChevronsUpDown, Columns2, Columns3, Columns4, Info, LayoutPanelLeft, Minus, MousePointerClick, PanelTop, RectangleHorizontal, Square, Table2, Image as ImageIcon } from "lucide-react";
4
- import { useEffect, useState, useSyncExternalStore, type CSSProperties } from "react";
4
+ import { useCallback, useEffect, useState, useSyncExternalStore, type CSSProperties } from "react";
5
5
  import { InnerBlocks } from "../canvas/block-list";
6
6
  import { withoutOverridden } from "./inline-style";
7
7
  import { makeBlock, type BNode } from "../core/model";
8
8
  import type { BlockEditProps, BlockType } from "../core/registry";
9
9
  import { RichText } from "../text/rich-text";
10
10
  import { BoundText, useBindingPreview } from "../ui/bindings";
11
- import { useEditor } from "../context";
11
+ import { useEditor, useEditorState } from "../context";
12
12
  import { ButtonLinkTool, ButtonsTools, ColumnsTools, TableTools, addColumnTo } from "./tools";
13
13
  import { ColumnHandles, ContentWidthHandles, HeightHandle, PaddingHandles, useActiveWithin } from "./resize";
14
14
  import { ColumnInspector, ColumnsInspector } from "./columns-inspector";
@@ -314,9 +314,45 @@ function TabEdit({ block, blockProps }: BlockEditProps) {
314
314
  );
315
315
  }
316
316
 
317
+ /**
318
+ * Carousel trên khung soạn: mỗi lần chỉ hiện `slidesPerView` slide cạnh nhau như website, thanh trên chuyển trang slide.
319
+ * Chọn khối nằm trong slide đang ẩn (danh sách khối, tìm kiếm…) → nhảy tới slide đó.
320
+ */
317
321
  function CarouselEdit({ block, blockProps, editable }: BlockEditProps) {
322
+ const { store } = useEditor();
318
323
  const tp = useMsgs("placeholders");
319
- return <div {...(merge(blockProps, "ecx-carousel") as object)}><InnerBlocks parent={block} />{editable && <AddChild block={block} label={tp.addSlide} make={() => makeBlock("group", {}, [makeBlock("paragraph")])} />}</div>;
324
+ const kids = block.content ?? [];
325
+ const per = Math.min(4, Math.max(1, Math.round(Number(block.attrs.slidesPerView) || 1)));
326
+ const max = Math.max(0, kids.length - per);
327
+ const start = Math.min(useOpenTab(block.id), max);
328
+ const sel = useEditorState(useCallback((s) => {
329
+ const cur = s.selection.ids.length ? s.selection.ids : s.selection.editing ? [s.selection.editing] : [];
330
+ return kids.findIndex((k) => cur.some((c) => c === k.id || !!store.locate(c)?.ancestors.includes(k.id)));
331
+ }, [kids, store]));
332
+ // Chỉ chạy khi vùng chọn đổi slide: bấm "Slide sau" lúc con trỏ còn ở slide cũ không bị kéo về
333
+ useEffect(() => {
334
+ if (sel < 0) return;
335
+ if (sel < start) setOpenTab(block.id, sel);
336
+ else if (sel >= start + per) setOpenTab(block.id, sel - per + 1);
337
+ }, [sel]); // eslint-disable-line react-hooks/exhaustive-deps
338
+ const hidden = kids.filter((_, i) => i < start || i >= start + per).map((k) => `[data-ecx-block="${k.id}"]`);
339
+ return (
340
+ <div {...(merge(blockProps, "ecx-carousel") as object)}>
341
+ {hidden.length > 0 && <style>{`${hidden.join(",")}{display:none!important}`}</style>}
342
+ <div className="ecx-carousel-track" style={{ display: "grid", gridTemplateColumns: `repeat(${per}, minmax(0, 1fr))`, gap: 16 }}>
343
+ <InnerBlocks parent={block} />
344
+ </div>
345
+ {/* Thanh chuyển slide nằm dưới (trên thì bị thanh công cụ của khối đang chọn che) */}
346
+ <div className="ecx-carousel-nav" contentEditable={false} onMouseDown={(e) => e.preventDefault()}>
347
+ {kids.length > per && <>
348
+ <button type="button" aria-label={tp.prevSlide} disabled={start <= 0} onClick={() => setOpenTab(block.id, start - 1)}><ChevronLeft className="ecx-icon" /></button>
349
+ {kids.map((k, i) => <button key={k.id} type="button" aria-label={`${tp.slide} ${i + 1}`} aria-current={i >= start && i < start + per ? "true" : undefined} onClick={() => setOpenTab(block.id, Math.min(i, max))}>{i + 1}</button>)}
350
+ <button type="button" aria-label={tp.nextSlide} disabled={start >= max} onClick={() => setOpenTab(block.id, start + 1)}><ChevronRight className="ecx-icon" /></button>
351
+ </>}
352
+ {editable && <AddChild block={block} label={tp.addSlide} make={() => makeBlock("group", {}, [makeBlock("paragraph")])} />}
353
+ </div>
354
+ </div>
355
+ );
320
356
  }
321
357
 
322
358
  /** Shortcode: ô nhập tên luôn hiện ngay trên khối. */
@@ -1,6 +1,7 @@
1
- import { Star, AlignLeft, ArrowLeftRight, CalendarDays, ChevronsRight, Heading1, Copyright, FileText, Globe2, Image as ImageIcon, LayoutTemplate, ListOrdered, Menu, MessageSquare, PanelTop, Repeat2, Rows3, Search, SquareDashed, Tag, Type, User } from "lucide-react";
1
+ import { ListFilter, Star, AlignLeft, ArrowLeftRight, CalendarDays, ChevronsRight, Heading1, Copyright, FileText, Globe2, Image as ImageIcon, LayoutTemplate, ListOrdered, Menu, MessageSquare, PanelTop, Repeat2, Rows3, Search, SquareDashed, Tag, Type, User } from "lucide-react";
2
2
  import { useCallback, useEffect, useMemo, useState, type CSSProperties, type ReactNode } from "react";
3
- import { ICON_PATHS, SEARCH_ICON_PATH } from "@ecomcx/ecomweb-content";
3
+ import { ICON_PATHS, SEARCH_ICON_PATH, spacingValue } from "@ecomcx/ecomweb-content";
4
+ import { useChoices } from "../ui/attr-form";
4
5
  import { Block, DocBlocks, InnerBlocks, NestedDoc } from "../canvas/block-list";
5
6
  import { DocScopeProvider, LoopPostContext, useDocScope, useDynamicData, useEditor, useEditorState } from "../context";
6
7
  import type { DynamicPost, QueryArgs } from "../core/host";
@@ -73,7 +74,8 @@ function NavigationEdit({ block, blockProps, selected }: BlockEditProps) {
73
74
  const { labels } = useEditor();
74
75
  const location = String(block.attrs.location ?? "primary");
75
76
  const items = d.menus?.[location];
76
- const mobile = block.attrs.mobile !== false;
77
+ const overlay = ["never", "mobile", "tablet", "always"].includes(String(block.attrs.overlayMenu)) ? String(block.attrs.overlayMenu) : block.attrs.mobile === false ? "never" : "mobile";
78
+ const mobile = overlay !== "never";
77
79
  const t = useMsgs("blocks");
78
80
  const tp = useMsgs("placeholders");
79
81
  const { host } = useEditor();
@@ -94,9 +96,9 @@ function NavigationEdit({ block, blockProps, selected }: BlockEditProps) {
94
96
  }
95
97
  const menu = <nav className="ecx-navigation-menu" aria-label={location}><ul>{items.map((it, i) => <li key={i}><a href={it.url} onClick={(e) => e.preventDefault()}>{it.title}</a></li>)}</ul></nav>;
96
98
  return (
97
- <div {...merge(blockProps, cx("ecx-navigation", `ecx-navigation-${block.attrs.orientation ?? "horizontal"}`, mobile && "has-mobile"))}>
98
- <div className="ecx-navigation-items">{menu}</div>
99
- {mobile && <details className="ecx-navigation-toggle"><summary aria-label={t.menu}>☰</summary>{menu}</details>}
99
+ <div {...merge(blockProps, cx("ecx-navigation", `ecx-navigation-${block.attrs.orientation ?? "horizontal"}`, mobile && "has-mobile", overlay === "tablet" && "bp-tablet", overlay === "always" && "overlay-always"))}>
100
+ {overlay !== "always" && <div className="ecx-navigation-items">{menu}</div>}
101
+ {mobile && <div className="ecx-nav-drawer"><button type="button" className="ecx-nav-burger" tabIndex={-1} aria-label={t.menu}><svg viewBox="0 0 24 24" width={24} height={24} fill="none" stroke="currentColor" strokeWidth={2} strokeLinecap="round" aria-hidden="true" focusable="false"><path d="M4 7h16M4 12h16M4 17h16" /></svg></button></div>}
100
102
  <EditMenuButton location={location} selected={selected} />
101
103
  </div>
102
104
  );
@@ -109,15 +111,30 @@ function SearchEdit({ block, blockProps }: BlockEditProps) {
109
111
  const button = block.attrs.buttonStyle === "icon"
110
112
  ? <button type="button" tabIndex={-1} aria-label={label} title={label}><svg viewBox="0 0 24 24" width={18} height={18} fill="none" stroke="currentColor" strokeWidth={2} strokeLinecap="round" strokeLinejoin="round" aria-hidden="true" focusable="false"><path d={SEARCH_ICON_PATH} /></svg></button>
111
113
  : <button type="button" tabIndex={-1}>{label}</button>;
112
- return (
113
- <div {...merge(blockProps, "ecx-search")}>
114
- <form role="search" onSubmit={(e) => e.preventDefault()} style={pos === "below" ? { display: "flex", flexDirection: "column", gap: 8 } : undefined}
114
+ const collapse = block.attrs.collapse === "tablet" || block.attrs.collapse === "mobile" ? String(block.attrs.collapse) : undefined;
115
+ const form = (
116
+ <form role="search" data-ecx-inert="" onSubmit={(e) => e.preventDefault()} style={pos === "below" ? { display: "flex", flexDirection: "column", gap: 8 } : undefined}
115
117
  className={`search-form${pos !== "right" ? ` search-button-${pos}` : ""}`}>
116
118
  {block.attrs.showLabel === true && <label className="search-label">{t.searchLabel}</label>}
117
119
  {pos === "left" && button}
118
120
  <input type="search" placeholder={String(block.attrs.placeholder || t.searchPlaceholder)} aria-label={t.searchLabel} readOnly tabIndex={-1} />
121
+ {block.attrs.scopeSelect === true && (
122
+ <select className="search-scope" aria-label={t.searchScope} tabIndex={-1} onMouseDown={(e) => e.preventDefault()}>
123
+ <option>{t.searchAll}</option>
124
+ {String(block.attrs.scopes ?? "").split(",").map((x) => x.trim()).filter(Boolean).map((x) => { const [v, ...r] = x.split(":"); return <option key={x}>{r.join(":").trim() || v}</option>; })}
125
+ </select>
126
+ )}
119
127
  {pos !== "left" && button}
120
128
  </form>
129
+ );
130
+ return (
131
+ <div {...merge(blockProps, "ecx-search")}>
132
+ {collapse ? (
133
+ <div className={`ecx-search-collapse collapse-${collapse}`}>
134
+ <button type="button" className="ecx-search-toggle" tabIndex={-1} aria-label={label}><svg viewBox="0 0 24 24" width={20} height={20} fill="none" stroke="currentColor" strokeWidth={2} strokeLinecap="round" strokeLinejoin="round" aria-hidden="true" focusable="false"><path d={SEARCH_ICON_PATH} /></svg></button>
135
+ <div className="ecx-search-panel">{form}</div>
136
+ </div>
137
+ ) : form}
121
138
  </div>
122
139
  );
123
140
  }
@@ -338,6 +355,7 @@ export function queryArgs(a: Record<string, unknown>): QueryArgs {
338
355
  inherit: a.inherit !== false, postType: typeof a.postType === "string" && a.postType ? a.postType : "post",
339
356
  perPage: Math.min(100, Math.max(1, Number(a.perPage) || 10)),
340
357
  category: typeof a.category === "string" && a.category ? a.category : undefined, tag: typeof a.tag === "string" && a.tag ? a.tag : undefined,
358
+ taxonomy: typeof a.taxonomy === "string" && a.taxonomy && (a.term || a.terms) ? a.taxonomy : undefined, term: typeof a.term === "string" && a.term ? a.term : typeof a.terms === "string" && a.terms ? a.terms.split(",")[0].trim() : undefined,
341
359
  orderBy: typeof a.orderBy === "string" ? a.orderBy : "date", order: a.order === "asc" ? "asc" : "desc",
342
360
  };
343
361
  }
@@ -374,14 +392,17 @@ function PostTemplateEdit({ block, blockProps, editable, labels }: BlockEditProp
374
392
  const q = queryArgs(queryAttrs);
375
393
  const posts = useQueryPosts(q);
376
394
  const [active, setActive] = useState(0);
377
- const grid = block.attrs.layout === "grid";
395
+ const grid = block.attrs.layout === "grid" || block.attrs.layout === "carousel";
396
+ const carousel = block.attrs.layout === "carousel";
397
+ const responsive = block.attrs.layout === "grid" && (Number(block.attrs.columnsTablet) > 0 || Number(block.attrs.columnsMobile) > 0);
378
398
  const cols = Math.min(6, Math.max(1, Number(block.attrs.columns) || 3));
379
- const count = posts ? Math.max(1, Math.min(posts.length, q.perPage, 6)) : 3;
399
+ const gap = spacingValue(block.attrs.gap) ?? "1.5rem";
400
+ const count = posts ? Math.max(1, Math.min(posts.length, q.perPage, carousel ? cols : 6)) : 3;
380
401
  const current = Math.min(active, count - 1);
381
402
  const t = useMsgs("blocks");
382
403
  const tp = useMsgs("placeholders");
383
404
  return (
384
- <ul {...(merge(blockProps, cx("ecx-post-template", grid && "is-grid"), grid ? { display: "grid", gridTemplateColumns: `repeat(${cols}, minmax(0, 1fr))`, gap: "1.5rem" } : undefined) as object)} data-ecx-posts={posts ? posts.length : ""}>
405
+ <ul {...(merge(blockProps, cx("ecx-post-template", grid && "is-grid", responsive && "is-responsive"), responsive ? { "--per": cols, "--per-tablet": Number(block.attrs.columnsTablet) || Math.min(cols, 3), "--per-mobile": Number(block.attrs.columnsMobile) || Math.min(cols, 2), "--gap": gap } as CSSProperties : grid ? { display: "grid", gridTemplateColumns: `repeat(${cols}, minmax(0, 1fr))`, gap } : undefined) as object)} data-ecx-posts={posts ? posts.length : ""}>
385
406
  {posts && !posts.length && <li className="ecx-post ecx-post-none ecx-ph-theme is-missing" data-ecx-placeholder="no-posts"><Missing>{tp.noPosts}</Missing> <span className="ecx-placeholder-hint">{tp.noPostsHint}</span> <AdminButton target="newPost" args={{ postType: q.postType }}>+ {tp.writeFirst}</AdminButton></li>}
386
407
  {Array.from({ length: count }, (_, i) => {
387
408
  const post = posts?.[i] ?? null;
@@ -409,6 +430,23 @@ function PaginationEdit({ block, blockProps }: BlockEditProps) {
409
430
  const single = posts !== undefined && posts.length < perPage;
410
431
  return <nav {...(merge(blockProps, cx("ecx-pagination", single && "is-single")) as object)} style={single ? { opacity: 0.45 } : undefined}>{single ? "‹ 1 ›" : "‹ 1 2 3 ›"}</nav>;
411
432
  }
433
+ /** Thanh lọc: cùng markup với website (QueryFilterBar) — mục phân loại thật lấy từ ứng dụng, không có thì mục mẫu. */
434
+ function QueryFilterEdit({ block, blockProps }: BlockEditProps) {
435
+ const t = useMsgs("blocks");
436
+ const a = block.attrs;
437
+ const style = ["none", "links", "chips", "select"].includes(String(a.termStyle)) ? String(a.termStyle) : "links";
438
+ const choices = useChoices("term", { taxonomy: String(a.taxonomy ?? "") });
439
+ const names = (a.taxonomy ? choices : null)?.map((c) => c.label).slice(0, 8) ?? ["Danh mục 1", "Danh mục 2", "Danh mục 3"];
440
+ return (
441
+ <div {...merge(blockProps, "ecx-query-filter")}>
442
+ {style === "select" && <select tabIndex={-1} aria-label={String(a.taxonomy ?? "")}><option>{String(a.allLabel || t.filterAll)}</option></select>}
443
+ {(style === "links" || style === "chips") && <nav className="ecx-filter-terms"><a className="is-active">{String(a.allLabel || t.filterAll)}</a>{names.map((n) => <a key={n}>{n}</a>)}</nav>}
444
+ {a.showSearch === true && <input type="search" readOnly tabIndex={-1} placeholder={String(a.placeholder || t.filterSearch)} />}
445
+ {a.showSort === true && <select tabIndex={-1} aria-label={t.filterSort}><option>{t.filterNewest}</option></select>}
446
+ {style === "none" && !a.showSearch && !a.showSort && <span className="ecx-muted">{t.filterEmpty}</span>}
447
+ </div>
448
+ );
449
+ }
412
450
  function QueryEmptyEdit({ block, blockProps, labels }: BlockEditProps) {
413
451
  const { posts } = useParentQueryPosts(block);
414
452
  // Danh sách đang có bài → khối "không có bài" không hiện trên website: thu gọn thành nhãn mờ (vẫn chọn / sửa được khi bấm vào)
@@ -458,8 +496,8 @@ export function themeBlocks(): BlockType[] {
458
496
  { name: "siteTitle", title: "Tên website", icon: Type, category: theme, keywords: "ten website site title", kind: "atom", edit: SiteTitleEdit, attributes: { level: { type: "integer", default: 0, min: 0, max: 6 }, link: { type: "boolean", default: true }, textAlign: TEXT_ALIGN }, supports: { style: true, className: true } },
459
497
  { name: "siteLogo", title: "Logo", icon: ImageIcon, category: theme, keywords: "logo", kind: "atom", edit: SiteLogoEdit, attributes: { width: { type: "number", default: 120 }, link: { type: "boolean", default: true } }, supports: { style: true, className: true } },
460
498
  { name: "siteTagline", title: "Khẩu hiệu", icon: Type, category: theme, keywords: "khau hieu tagline mo ta", kind: "atom", edit: SiteTaglineEdit, attributes: { textAlign: TEXT_ALIGN }, supports: { style: true, className: true } },
461
- { name: "navigation", title: "Menu", icon: Menu, category: theme, keywords: "menu dieu huong navigation", kind: "atom", edit: NavigationEdit, attributes: { location: { type: "string", default: "primary" }, orientation: { type: "string", enum: ["horizontal", "vertical"], default: "horizontal" }, mobile: { type: "boolean", default: true }, overlayMenu: { type: "string", enum: ["never", "mobile", "always"], default: "mobile" } }, supports: { style: true, className: true }, summary: (a) => a.location },
462
- { name: "search", title: "Tìm kiếm", icon: Search, category: theme, keywords: "tim kiem search", kind: "atom", edit: SearchEdit, attributes: { placeholder: { type: "string" }, buttonText: { type: "string" }, postType: { type: "string" }, showLabel: { type: "boolean", default: false }, buttonPosition: { type: "string", enum: ["right", "left", "below"], default: "right" }, buttonStyle: { type: "string", enum: ["text", "icon"], default: "text" } }, supports: { style: true, className: true } },
499
+ { name: "navigation", title: "Menu", icon: Menu, category: theme, keywords: "menu dieu huong navigation", kind: "atom", edit: NavigationEdit, attributes: { location: { type: "string", default: "primary" }, orientation: { type: "string", enum: ["horizontal", "vertical"], default: "horizontal" }, mobile: { type: "boolean", default: true }, overlayMenu: { type: "string", enum: ["never", "mobile", "tablet", "always"], default: "mobile" } }, supports: { style: true, className: true }, summary: (a) => a.location },
500
+ { name: "search", title: "Tìm kiếm", icon: Search, category: theme, keywords: "tim kiem search", kind: "atom", edit: SearchEdit, attributes: { placeholder: { type: "string" }, buttonText: { type: "string" }, postType: { type: "string" }, showLabel: { type: "boolean", default: false }, buttonPosition: { type: "string", enum: ["right", "left", "below"], default: "right" }, buttonStyle: { type: "string", enum: ["text", "icon"], default: "text" }, scopeSelect: { type: "boolean", default: false }, scopes: { type: "string" }, collapse: { type: "string", enum: ["never", "tablet", "mobile"], default: "never" } }, supports: { style: true, className: true } },
463
501
  { name: "languageSwitcher", title: "Chọn ngôn ngữ", icon: Globe2, category: theme, keywords: "ngon ngu language", kind: "atom", edit: LanguageEdit, attributes: { display: { type: "string", enum: ["inline", "dropdown"], default: "inline" } }, supports: { style: true, className: true } },
464
502
  { name: "copyright", title: "Bản quyền", icon: Copyright, category: theme, keywords: "ban quyen copyright", kind: "atom", edit: CopyrightEdit, attributes: { text: { type: "string" }, textAlign: TEXT_ALIGN }, supports: { style: true, className: true } },
465
503
  { name: "postTitle", title: "Tiêu đề bài", icon: Type, category: theme, keywords: "tieu de bai post title", kind: "atom", edit: PostTitleEdit, attributes: { level: { type: "integer", default: 1, min: 1, max: 6 }, link: { type: "boolean", default: false }, textAlign: TEXT_ALIGN }, supports: { style: true, className: true } },
@@ -487,13 +525,14 @@ export function themeBlocks(): BlockType[] {
487
525
  { name: "postNavigation", title: "Bài trước / bài sau", icon: ArrowLeftRight, category: theme, keywords: "bai truoc bai sau dieu huong post navigation", kind: "atom", edit: PostNavigationEdit, attributes: { showTitle: { type: "boolean", default: true } }, supports: { style: true, className: true } },
488
526
  {
489
527
  name: "query", title: "Danh sách bài", icon: Rows3, category: theme, keywords: "danh sach bai query loop tin tuc", kind: "container", edit: QueryEdit,
490
- attributes: { inherit: { type: "boolean", default: true }, postType: { type: "string", default: "post" }, perPage: { type: "integer", default: 10, min: 1, max: 100 }, category: { type: "string" }, tag: { type: "string" }, orderBy: { type: "string", enum: ["date", "title", "modified", "menu_order", "comment_count", "rand"], default: "date" }, order: { type: "string", enum: ["desc", "asc"], default: "desc" }, authorId: { type: "integer", min: 1 }, search: { type: "string" }, exclude: { type: "string" }, sticky: { type: "string", enum: ["any", "only", "exclude"], default: "any" }, orderByMeta: { type: "string" }, paginate: { type: "boolean", default: false } },
528
+ attributes: { inherit: { type: "boolean", default: true }, postType: { type: "string", default: "post" }, perPage: { type: "integer", default: 10, min: 1, max: 100 }, category: { type: "string" }, tag: { type: "string" }, taxonomy: { type: "string" }, term: { type: "string" }, terms: { type: "string" }, termMode: { type: "string", enum: ["any", "all", "none"], default: "any" }, source: { type: "string", enum: ["latest", "manual", "related"], default: "latest" }, include: { type: "string" }, metaKey: { type: "string" }, metaCompare: { type: "string", enum: ["=", "!=", ">", ">=", "<", "<=", "LIKE", "EXISTS", "NOT EXISTS"], default: "=" }, metaValue: { type: "string" }, metaValue2: { type: "string" }, dateRange: { type: "string", enum: ["any", "7", "30", "90", "365"], default: "any" }, after: { type: "string" }, before: { type: "string" }, parent: { type: "integer", min: 1 }, offset: { type: "integer", min: 0, max: 1000 }, excludeCurrent: { type: "boolean", default: true }, authorCurrent: { type: "boolean", default: false }, urlFilters: { type: "boolean", default: false }, orderBy: { type: "string", enum: ["date", "title", "modified", "menu_order", "comment_count", "rand"], default: "date" }, order: { type: "string", enum: ["desc", "asc"], default: "desc" }, authorId: { type: "integer", min: 1 }, search: { type: "string" }, exclude: { type: "string" }, sticky: { type: "string", enum: ["any", "only", "exclude"], default: "any" }, orderByMeta: { type: "string" }, paginate: { type: "boolean", default: false } },
491
529
  // Mới chèn: chưa có khuôn → hỏi kiểu hiển thị trước (Danh sách / Lưới / Thẻ có ảnh)
492
530
  create: () => makeBlock("query", { inherit: true }, []),
493
531
  supports: { style: true, className: true },
494
532
  },
495
- { name: "postTemplate", title: "Khuôn mỗi bài", icon: LayoutTemplate, kind: "container", edit: PostTemplateEdit, hidden: true, attributes: { layout: { type: "string", enum: ["list", "grid"], default: "list" }, columns: { type: "integer", default: 3, min: 1, max: 6 } }, structure: { parents: ["query"] } },
533
+ { name: "postTemplate", title: "Khuôn mỗi bài", icon: LayoutTemplate, kind: "container", edit: PostTemplateEdit, hidden: true, attributes: { layout: { type: "string", enum: ["list", "grid", "carousel"], default: "list" }, columns: { type: "integer", default: 3, min: 1, max: 6 }, columnsTablet: { type: "integer", min: 1, max: 6 }, columnsMobile: { type: "integer", min: 1, max: 4 }, gap: { type: "string" }, arrows: { type: "boolean", default: true } }, structure: { parents: ["query"] } },
496
534
  { name: "pagination", title: "Phân trang", icon: ListOrdered, kind: "atom", edit: PaginationEdit, attributes: { type: { type: "string", enum: ["numbers", "prevNext", "both"], default: "both" }, midSize: { type: "integer", default: 2, min: 0, max: 5 } }, hidden: true, structure: { parents: ["query"] } },
535
+ { name: "queryFilter", title: "Thanh lọc", icon: ListFilter, category: theme, keywords: "loc bo loc thanh loc filter danh muc sap xep tim", kind: "atom", edit: QueryFilterEdit, attributes: { taxonomy: { type: "string" }, termStyle: { type: "string", enum: ["none", "links", "chips", "select"], default: "links" }, allLabel: { type: "string" }, showSearch: { type: "boolean", default: false }, showSort: { type: "boolean", default: false }, sortOptions: { type: "string" }, placeholder: { type: "string" }, submitText: { type: "string" }, action: { type: "string" } }, supports: { style: true, className: true, align: true } },
497
536
  { name: "queryEmpty", title: "Khi không có bài", icon: SquareDashed, kind: "container", edit: QueryEmptyEdit, hidden: true, structure: { parents: ["query"] } },
498
537
  { name: "templatePart", title: "Phần dùng chung", icon: PanelTop, category: theme, keywords: "phan dung chung template part header footer", kind: "atom", edit: TemplatePartEdit, attributes: { slug: { type: "string" }, tagName: { type: "string", enum: ["div", "header", "footer", "aside", "section"], default: "div" } }, summary: (a) => a.slug },
499
538
  { name: "syncedPattern", title: "Mẫu đồng bộ", icon: Repeat2, category: "widgets", keywords: "mau dong bo synced pattern reusable", kind: "atom", edit: SyncedPatternEdit, attributes: { ref: { type: "integer" } }, hidden: true },
@@ -22,6 +22,9 @@ export function sectionOf(store: ReturnType<typeof useEditor>["store"], el: HTML
22
22
  }
23
23
 
24
24
  /** Props gắn vào phần tử gốc của khối: chọn, viền, kiểu dáng, neo. */
25
+ /** Khối chứa mà con phủ kín: có nhãn rê chuột để bấm chọn chính khối chứa (xem canvas-css). */
26
+ const LABELED = new Set(["query", "postTemplate", "queryEmpty", "templatePart", "tabs", "tab", "accordion", "details", "carousel", "columns", "column", "buttons", "form", "mediaText", "cover"]);
27
+
25
28
  export function useBlockProps(block: BNode, state: { selected: boolean; editing: boolean; mode: EditingMode }): BlockProps {
26
29
  const ctx = useEditor();
27
30
  const { store, registry, ui } = ctx;
@@ -44,7 +47,8 @@ export function useBlockProps(block: BNode, state: { selected: boolean; editing:
44
47
  if (store.modeOf(block.id) === "disabled") return;
45
48
  const rich = target.closest<HTMLElement>("[data-ecx-rich]");
46
49
  if (rich && rich.isContentEditable && !e.shiftKey) return; // bấm vào chữ: ProseMirror đặt con trỏ, focus báo đang gõ
47
- if (target.closest("input, textarea, select, button, [contenteditable=true]") && !e.shiftKey) return;
50
+ // Ô nhập / nút thật của khối đặt chỗ tự xử lý; riêng vùng đánh dấu data-ecx-inert (bản xem trước không bấm được, vd khối Tìm kiếm) thì bấm vào là chọn khối
51
+ if (target.closest("input, textarea, select, button, [contenteditable=true]") && !target.closest("[data-ecx-inert]") && !e.shiftKey) return;
48
52
  // Bấm vào phần đệm của ô bảng: con trỏ vào chữ trong ô (như bấm vào ô của Word / WordPress), không chọn cả ô
49
53
  if ((block.type === "tableCell" || block.type === "tableHeader") && !e.shiftKey && !e.metaKey && !e.ctrlKey) {
50
54
  const text = block.content?.find((b) => b.inline);
@@ -70,7 +74,7 @@ export function useBlockProps(block: BNode, state: { selected: boolean; editing:
70
74
  if (t.closest("[data-ecx-block]")?.getAttribute("data-ecx-block") !== block.id) return;
71
75
  // Chỉ xét trong khối (cả khung soạn là contenteditable)
72
76
  const hit = t.closest("[data-ecx-rich], input, textarea, select, button, a, [contenteditable=true], .ecx-pad-handles, .ecx-col-handles, .ecx-image-handle");
73
- if (hit && e.currentTarget.contains(hit)) return;
77
+ if (hit && e.currentTarget.contains(hit) && !hit.closest("[data-ecx-inert]")) return;
74
78
  const ids = store.getState().selection.ids;
75
79
  startDrag(ctx, e, ids.includes(block.id) ? ids : [block.id]);
76
80
  }, [block.id, ctx, store, ui]);
@@ -78,6 +82,7 @@ export function useBlockProps(block: BNode, state: { selected: boolean; editing:
78
82
  ref: null,
79
83
  "data-ecx-block": block.id,
80
84
  "data-type": block.type,
85
+ ...(LABELED.has(block.type) ? { "data-ecx-label": type?.title ?? block.type } : {}),
81
86
  tabIndex: type?.kind === "text" ? undefined : -1,
82
87
  id: typeof a.anchor === "string" ? a.anchor : undefined,
83
88
  className: cx(
@@ -276,6 +276,14 @@ img[data-ecx-bound] { outline: 2px solid color-mix(in srgb, var(--ecx-ui) 45%, t
276
276
  .ecx-add-item { display: inline-flex; align-items: center; gap: 4px; margin: 6px 0 0; padding: 6px 10px; border: 1px dashed color-mix(in srgb, currentColor 40%, transparent); border-radius: 6px; background: transparent; color: inherit; font: 600 13px/1.2 var(--ecx-ui-font); cursor: pointer; opacity: .85; }
277
277
  .ecx-add-item:hover, .ecx-add-item:focus-visible { opacity: 1; border-color: var(--ecx-ui); color: var(--ecx-ui); }
278
278
  .ecx-tabs-list .ecx-add-item { margin: 0 0 0 8px; align-self: center; }
279
+ /* Thanh chuyển slide của carousel (chỉ trên khung soạn) */
280
+ .ecx-carousel-nav { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; margin: 8px 0 0; font: 600 12px/1 var(--ecx-ui-font); user-select: none; }
281
+ .ecx-carousel-nav:empty { display: none; }
282
+ .ecx-carousel-nav .ecx-add-item { margin: 0 0 0 8px; }
283
+ .ecx-carousel-nav button { display: inline-flex; align-items: center; justify-content: center; min-width: 28px; height: 28px; padding: 0 6px; border: 1px solid #c9d0d7; border-radius: 6px; background: #fff; color: #1f2d38; font: inherit; cursor: pointer; }
284
+ .ecx-carousel-nav button[aria-current="true"] { border-color: var(--ecx-ui); background: var(--ecx-ui); color: #fff; }
285
+ .ecx-carousel-nav button:disabled { opacity: .4; cursor: default; }
286
+ .ecx-carousel-nav .ecx-icon { width: 16px; height: 16px; }
279
287
  .ecx-social .ecx-add-item, .ecx-social-add .ecx-add-item { margin: 0; }
280
288
  .ecx-ph-list-add { list-style: none; }
281
289
  .ecx-ph-list-add .ecx-add-item { margin-top: 2px; }
@@ -311,3 +319,11 @@ img[data-ecx-bound] { outline: 2px solid color-mix(in srgb, var(--ecx-ui) 45%, t
311
319
  hr.ecx-block { position: relative; overflow: visible; }
312
320
  hr.ecx-block::before { content: ""; position: absolute; left: 0; right: 0; top: -20px; bottom: -20px; }
313
321
  `;
322
+
323
+ export const CONTAINER_LABEL_CSS = `
324
+ /* Khối chứa mà con phủ kín (Danh sách bài, Khuôn mỗi bài, Phần mẫu, Tabs…): rê chuột hiện nhãn ở góc trên trái, bấm nhãn = chọn khối chứa */
325
+ .ecx-canvas-root [data-ecx-label]:hover { position: relative; }
326
+ .ecx-canvas-root [data-ecx-label]:hover:not(:has([data-ecx-label]:hover))::before {
327
+ content: attr(data-ecx-label); position: absolute; top: 0; left: 0; z-index: 30; padding: 2px 8px; border-radius: 0 0 6px 0; background: var(--ecx-ui, #1a597b); color: #fff;
328
+ font: 600 11px/18px var(--ecx-ui-font, system-ui); letter-spacing: .02em; cursor: pointer; pointer-events: auto; white-space: nowrap; }
329
+ `;
@@ -7,7 +7,7 @@ import { DocBlocks } from "./block-list";
7
7
  import { BLOCKS_MIME, blocksFromClipboard, serializeBlocks } from "../core/clipboard";
8
8
  import { DocScopeProvider, useEditor, useEditorState, useUiTick } from "../context";
9
9
  import { usePrefs } from "../prefs";
10
- import { CANVAS_CSS } from "./canvas-css";
10
+ import { CANVAS_CSS, CONTAINER_LABEL_CSS } from "./canvas-css";
11
11
  import { applyDocumentAttrs } from "./document-attrs";
12
12
  import { wrapperNodes } from "./wrapper-props";
13
13
  import { makeBlock, type BNode } from "../core/model";
@@ -160,7 +160,7 @@ function useCanvasStyles(doc: Document) {
160
160
  const add = (el: HTMLElement) => { head.appendChild(el); nodes.push(el); };
161
161
  const base = doc.createElement("style");
162
162
  base.dataset.ecx = "canvas";
163
- base.textContent = CANVAS_CSS;
163
+ base.textContent = CANVAS_CSS + CONTAINER_LABEL_CSS;
164
164
  add(base);
165
165
  for (const s of host.canvasStyles ?? []) {
166
166
  if (typeof s === "string") {
@@ -102,7 +102,7 @@ export interface DocumentHost {
102
102
  export type DynamicPost = { title?: string; date?: string; author?: string; excerpt?: string; image?: string | null; terms?: string[]; /** Chuyên mục đầu tiên (breadcrumb như website); không có = bài/trang không thuộc chuyên mục nào. */ category?: string; comments?: number; link?: string; /** Nội dung đã lưu của bài (ContentDoc) — khối "Nội dung bài" trong template vẽ nội dung thật thay vì khung giữ chỗ. */ content?: unknown };
103
103
 
104
104
  /** Thiết lập của khối "Danh sách bài" (attrs của query). */
105
- export interface QueryArgs { inherit: boolean; postType: string; perPage: number; category?: string; tag?: string; orderBy: string; order: "asc" | "desc" }
105
+ export interface QueryArgs { inherit: boolean; postType: string; perPage: number; category?: string; tag?: string; taxonomy?: string; term?: string; orderBy: string; order: "asc" | "desc" }
106
106
 
107
107
  export type ChoiceKind = "menuLocation" | "postType" | "taxonomy" | "term" | "templatePart" | "imageSize";
108
108
  export interface Choice { value: string; label: string }
@@ -40,7 +40,7 @@ export function Field({ label, children, group }: { label: string; children: Rea
40
40
  }
41
41
 
42
42
  /** Lựa chọn lấy từ ứng dụng (host.choices); null = ứng dụng không cung cấp → ô gõ tay. */
43
- function useChoices(kind: ChoiceKind | undefined, args: Record<string, string> | undefined): Choice[] | null | undefined {
43
+ export function useChoices(kind: ChoiceKind | undefined, args: Record<string, string> | undefined): Choice[] | null | undefined {
44
44
  const { host, labels } = useEditor();
45
45
  const key = JSON.stringify([kind, args]);
46
46
  const [state, setState] = useState<{ key: string; list: Choice[] | null } | null>(null);
@@ -86,6 +86,22 @@ function ChoiceField({ hint, attrs, value, set, label }: { hint: AttrHint; attrs
86
86
  );
87
87
  }
88
88
 
89
+ /** Chọn nhiều mục (danh sách tích): giá trị lưu là các mã cách nhau dấu phẩy. */
90
+ function MultiChoiceField({ hint, attrs, value, set, label }: { hint: AttrHint; attrs: Record<string, unknown>; value: unknown; set(v: unknown): void; label: string }) {
91
+ const { labels } = useEditor();
92
+ const list = useChoices(hint.choice?.kind, hint.choice?.args?.(attrs));
93
+ const picked = new Set(String(value ?? "").split(",").map((x) => x.trim()).filter(Boolean));
94
+ if (list === null) return <input className="ecx-input" aria-label={label} value={String(value ?? "")} onChange={(e) => set(e.target.value || undefined)} />;
95
+ if (list === undefined) return <span className="ecx-muted">{labels.choiceLoading}</span>;
96
+ const toggle = (v: string) => { const next = new Set(picked); if (next.has(v)) next.delete(v); else next.add(v); set(next.size ? [...next].join(",") : undefined); };
97
+ return (
98
+ <div className="ecx-multichoice" role="group" aria-label={label}>
99
+ {list.map((c) => <label key={c.value} className="ecx-check"><input type="checkbox" checked={picked.has(c.value)} onChange={() => toggle(c.value)} /> {c.label}</label>)}
100
+ {!list.length && <span className="ecx-muted">{labels.choiceSelect}</span>}
101
+ </div>
102
+ );
103
+ }
104
+
89
105
  /** Form thuộc tính tự sinh từ mô tả khối + gợi ý hiển thị (attr-hints): không phải viết giao diện cho từng khối. */
90
106
  export function AttrForm({ type, attrs, onChange }: { type: BlockType; attrs: Record<string, any>; onChange(a: Record<string, unknown>): void }) {
91
107
  const { host, labels } = useEditor();
@@ -150,6 +166,8 @@ export function AttrForm({ type, attrs, onChange }: { type: BlockType; attrs: Re
150
166
  }
151
167
  case "icon":
152
168
  return <Field key={k} label={label}><IconPicker label={label} value={value == null ? undefined : String(value)} allowNone={hint.allowNone} onChange={(v) => set(v)} />{help}</Field>;
169
+ case "multichoice":
170
+ return <Field key={k} label={label}><MultiChoiceField hint={hint} attrs={attrs} value={value} set={set} label={label} />{help}</Field>;
153
171
  case "choice":
154
172
  return <Field key={k} label={label}><ChoiceField hint={hint} attrs={attrs} value={value} set={set} label={label} />{help}</Field>;
155
173
  case "range": {
@@ -14,7 +14,7 @@ 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" | "icon";
17
+ control?: "select" | "segmented" | "range" | "choice" | "multichoice" | "newTab" | "suggest" | "code" | "hidden" | "icon";
18
18
  /** control "icon": có lựa chọn "Không có icon". */
19
19
  allowNone?: true;
20
20
  options?: Opt[];
@@ -174,7 +174,7 @@ export const ATTR_HINTS: Record<string, AttrHint> = {
174
174
  "socialLinks.align": { control: "segmented", options: ALIGN },
175
175
  "navigation.location": { control: "choice", choice: { kind: "menuLocation" }, help: true },
176
176
  "navigation.orientation": { control: "segmented", options: ["horizontal", "vertical"] },
177
- "navigation.overlayMenu": { control: "segmented", label: true, options: ["never", "mobile", "always"] },
177
+ "navigation.overlayMenu": { control: "segmented", label: true, options: ["never", "mobile", "tablet", "always"] },
178
178
  "gallery.layout": { control: "segmented", label: true, options: ["grid", "masonry"] },
179
179
  "gallery.linkTo": { control: "segmented", label: true, options: ["none", "media"] },
180
180
  "gallery.imageCrop": { label: true },
@@ -195,6 +195,9 @@ export const ATTR_HINTS: Record<string, AttrHint> = {
195
195
  "search.showLabel": { label: true },
196
196
  "search.buttonPosition": { control: "segmented", label: true, options: ["right", "left", "below"] },
197
197
  "search.buttonStyle": { control: "segmented", label: true, options: ["text", "icon"] },
198
+ "search.collapse": { control: "segmented", label: true, help: true, options: ["never", "tablet", "mobile"] },
199
+ "search.scopeSelect": { label: true, help: true },
200
+ "search.scopes": { label: true, help: true, when: (a) => a.scopeSelect === true },
198
201
  "postAuthor.showName": { label: true },
199
202
  "postAuthor.showBio": { label: true },
200
203
  "postAuthor.avatarSize": { label: true },
@@ -240,6 +243,8 @@ export const ATTR_HINTS: Record<string, AttrHint> = {
240
243
  "query.postType": { control: "choice", choice: { kind: "postType" }, when: notInherit },
241
244
  "query.category": { control: "choice", choice: { kind: "term", args: () => ({ taxonomy: "category" }) }, when: notInherit },
242
245
  "query.tag": { control: "choice", choice: { kind: "term", args: () => ({ taxonomy: "post_tag" }) }, when: notInherit },
246
+ "query.taxonomy": { control: "choice", choice: { kind: "taxonomy" }, label: true, help: true, when: notInherit },
247
+ "query.term": { control: "choice", choice: { kind: "term", args: (a) => ({ taxonomy: String(a.taxonomy ?? "") }) }, label: true, when: (a) => a.inherit === false && !!a.taxonomy },
243
248
  "query.perPage": { when: notInherit },
244
249
  "query.orderBy": { control: "select", options: ["date", "modified", "title", "comment_count", "menu_order", "rand"], when: notInherit },
245
250
  "query.authorId": { label: true, when: notInherit },
@@ -252,12 +257,40 @@ export const ATTR_HINTS: Record<string, AttrHint> = {
252
257
  "orderedList.reversed": { label: true },
253
258
  "blockquote.citation": { label: true },
254
259
  "postDate.displayType": { control: "segmented", label: true, options: ["published", "modified"] },
260
+ "query.source": { control: "segmented", label: true, options: ["latest", "manual", "related"], when: notInherit },
261
+ "query.include": { label: true, help: true, placeholder: true, when: (a) => a.inherit === false && a.source === "manual" },
262
+ "query.terms": { control: "multichoice", choice: { kind: "term", args: (a) => ({ taxonomy: String(a.taxonomy ?? "") }) }, label: true, when: (a) => !!a.taxonomy },
263
+ "query.termMode": { control: "segmented", label: true, options: ["any", "all", "none"], when: (a) => !!a.taxonomy && !!String(a.terms ?? "").trim() },
264
+ "query.metaKey": { label: true, help: true, placeholder: true, when: notInherit },
265
+ "query.metaCompare": { control: "select", label: true, options: ["=", "!=", ">", ">=", "<", "<=", "LIKE", "EXISTS", "NOT EXISTS"], when: (a) => a.inherit === false && !!a.metaKey },
266
+ "query.metaValue": { label: true, when: (a) => a.inherit === false && !!a.metaKey && !["EXISTS", "NOT EXISTS"].includes(String(a.metaCompare ?? "=")) },
267
+ "query.dateRange": { control: "select", label: true, options: ["any", "7", "30", "90", "365"], when: notInherit },
268
+ "query.after": { label: true, placeholder: true, when: notInherit },
269
+ "query.before": { label: true, placeholder: true, when: notInherit },
270
+ "query.parent": { label: true, help: true, when: notInherit },
271
+ "query.offset": { label: true, help: true, when: notInherit },
272
+ "query.excludeCurrent": { label: true, help: true, when: notInherit },
273
+ "query.authorCurrent": { label: true, when: notInherit },
274
+ "query.urlFilters": { label: true, help: true },
275
+ "queryFilter.taxonomy": { control: "choice", choice: { kind: "taxonomy" }, label: true, help: true },
276
+ "queryFilter.termStyle": { control: "segmented", label: true, options: ["none", "links", "chips", "select"], when: (a) => !!a.taxonomy },
277
+ "queryFilter.allLabel": { label: true, placeholder: true },
278
+ "queryFilter.showSearch": { label: true },
279
+ "queryFilter.showSort": { label: true },
280
+ "queryFilter.sortOptions": { label: true, help: true, placeholder: true, when: (a) => a.showSort === true },
281
+ "queryFilter.placeholder": { label: true, when: (a) => a.showSearch === true },
282
+ "queryFilter.submitText": { label: true },
283
+ "queryFilter.action": { label: true, help: true, placeholder: true },
255
284
  "query.paginate": { label: true, help: true, when: notInherit },
256
285
  "query.orderByMeta": { label: true, help: true, when: notInherit },
257
286
  "query.order": { control: "segmented", options: ["desc", "asc"], when: notInherit },
258
287
  "query.inherit": { help: true },
259
- "postTemplate.layout": { control: "segmented", options: ["list", "grid"] },
260
- "postTemplate.columns": { control: "range", min: 1, max: 6, step: 1, when: (a) => a.layout === "grid" },
288
+ "postTemplate.layout": { control: "segmented", options: ["list", "grid", "carousel"] },
289
+ "postTemplate.columns": { control: "range", min: 1, max: 6, step: 1, when: (a) => a.layout === "grid" || a.layout === "carousel" },
290
+ "postTemplate.columnsTablet": { control: "range", min: 1, max: 6, step: 1, label: true, when: (a) => a.layout === "grid" },
291
+ "postTemplate.columnsMobile": { control: "range", min: 1, max: 4, step: 1, label: true, when: (a) => a.layout === "grid" },
292
+ "postTemplate.gap": { label: true, help: true, when: (a) => a.layout === "grid" || a.layout === "carousel" },
293
+ "postTemplate.arrows": { label: true, when: (a) => a.layout === "carousel" },
261
294
  "templatePart.slug": { control: "choice", choice: { kind: "templatePart" } },
262
295
  "templatePart.tagName": { control: "select", options: ["div", "header", "footer", "aside", "section"] },
263
296
  };
@@ -66,6 +66,9 @@ export function BindingsPanel({ block, bindable, onChange }: { block: BNode; bin
66
66
  </select>
67
67
  : <input className="ecx-input" aria-label={`${ATTR[attr] ?? attr}: ${argKey}`} placeholder={argKey} value={String(b.args?.[argKey] ?? "")}
68
68
  onChange={(e) => set(attr, { ...b, args: { ...b.args, [argKey]: e.target.value.replace(/[^\w.-]/g, "").slice(0, 200) } })} />)}
69
+ {b && (attr === "content" || attr === "text") && (
70
+ <label className="ecx-check"><input type="checkbox" checked={b.args?.hideIfEmpty === true} onChange={(e) => { const { hideIfEmpty: _drop, ...rest } = b.args ?? {}; set(attr, { ...b, args: e.target.checked ? { ...rest, hideIfEmpty: true } : rest }); }} /> {t.hideIfEmpty}</label>
71
+ )}
69
72
  </div>
70
73
  );
71
74
  })}
@@ -7,7 +7,7 @@ import { cx } from "./attr-form";
7
7
  import type { MediaItem } from "../../shared/types";
8
8
  import { useEffect, useLayoutEffect, useMemo, useRef, useState, type ComponentType } from "react";
9
9
  import { norm } from "../../shared/util";
10
- import { useEditor, useUiTick, type InserterRequest } from "../context";
10
+ import { useEditor, useEditorState, useUiTick, type InserterRequest } from "../context";
11
11
  import { cloneBlock, inlineLength, makeBlock, type BNode } from "../core/model";
12
12
  import type { BlockType } from "../core/registry";
13
13
  import { canContain } from "../core/structure";
@@ -147,15 +147,20 @@ export function InserterPopover() {
147
147
  }, [ctx, ui]);
148
148
  useLayoutEffect(() => { listRef.current?.querySelector(`[data-index="${active}"]`)?.scrollIntoView({ block: "nearest" }); }, [active]);
149
149
 
150
- // Bấm ra ngoài: đóng
150
+ // Bấm ra ngoài: đóng. Pha capture vì nhiều khối chặn mousedown (stopPropagation) trước khi tới document.
151
151
  useEffect(() => {
152
152
  if (!req || req.mode === "slash") return;
153
153
  const close = (e: MouseEvent) => { if (!(e.target as Element).closest?.(".ecx-inserter-popover")) ui.openInserter(null); };
154
154
  const frameDoc = ui.canvasDoc;
155
- document.addEventListener("mousedown", close);
156
- frameDoc?.addEventListener("mousedown", close);
157
- return () => { document.removeEventListener("mousedown", close); frameDoc?.removeEventListener("mousedown", close); };
155
+ document.addEventListener("mousedown", close, true);
156
+ frameDoc?.addEventListener("mousedown", close, true);
157
+ return () => { document.removeEventListener("mousedown", close, true); frameDoc?.removeEventListener("mousedown", close, true); };
158
158
  }, [req, ui]);
159
+ // Chọn khối khác bằng đường không bấm chuột (danh sách khối, phím tắt…): đóng
160
+ const selKey = useEditorState((s) => (s.selection.ids.length ? s.selection.ids : [s.selection.editing ?? ""]).join(","));
161
+ const openSel = useRef<string | null>(null);
162
+ useEffect(() => { openSel.current = req && req.mode !== "slash" ? selKey : null; }, [req]); // eslint-disable-line react-hooks/exhaustive-deps
163
+ useEffect(() => { if (openSel.current !== null && selKey !== openSel.current) ui.openInserter(null); }, [selKey, ui]);
159
164
 
160
165
  if (!req) return null;
161
166
  if (req.mode === "slash" && !results.length) return null;