@ecomcx/ecomweb-editor 1.21.0 → 1.23.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.21.0",
3
+ "version": "1.23.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.16.0",
32
+ "@ecomcx/ecomweb-content": "^1.18.0",
33
33
  "react": ">=18",
34
34
  "react-dom": ">=18"
35
35
  },
@@ -60,7 +60,7 @@
60
60
  "prosemirror-view": "1.42.7"
61
61
  },
62
62
  "devDependencies": {
63
- "@ecomcx/ecomweb-content": "^1.16.0",
63
+ "@ecomcx/ecomweb-content": "^1.18.0",
64
64
  "@playwright/test": "1.53.0",
65
65
  "@types/react": "19.2.2",
66
66
  "@types/react-dom": "19.2.2",
@@ -24,17 +24,25 @@ const SPECS: Array<[string, LucideIcon, "none" | "blocks", Record<string, BlockA
24
24
  ["siteLogo", Image, "none", { width: i("width", { min: 16, max: 600, default: 120 }), link: b("link", { default: true }) }],
25
25
  ["siteTagline", Text, "none", { textAlign: align }],
26
26
  ["navigation", Menu, "none", { location: s("location", { default: "primary" }), orientation: s("orientation", { enum: ["horizontal", "vertical"], enumLabels: ["horizontal", "vertical"], default: "horizontal" }), mobile: b("mobile", { default: true }) }],
27
- ["search", Search, "none", { placeholder: s("placeholder"), buttonText: s("buttonText") }],
28
- ["languageSwitcher", Languages, "none", {}],
27
+ ["search", Search, "none", { placeholder: s("placeholder"), buttonText: s("buttonText"), postType: s("postType"), showLabel: b("showLabel", { default: false }), buttonPosition: s("buttonPosition", { enum: ["right", "left", "below"], enumLabels: ["right", "left", "below"], default: "right" }) }],
28
+ ["languageSwitcher", Languages, "none", { display: s("display", { enum: ["inline", "dropdown"], enumLabels: ["inline", "dropdown"], default: "inline" }) }],
29
29
  ["copyright", Copyright, "none", { text: s("text"), textAlign: align }],
30
30
  ["postTitle", Heading1, "none", { level: i("level", { min: 1, max: 6, default: 1 }), link: b("link", { default: false }), textAlign: align }],
31
31
  ["postContent", FileText, "none", {}],
32
32
  ["postExcerpt", AlignLeft, "none", { moreText: s("moreText") }],
33
33
  ["featuredImage", Image, "none", { size: s("size", { enum: ["medium", "medium_large", "large", "full"], default: "large" }), aspect: s("aspect", { enum: ["auto", "16/9", "4/3", "1/1", "3/4"], default: "auto" }), link: b("link", { default: false }) }],
34
34
  ["postDate", Calendar, "none", { textAlign: align }],
35
- ["postAuthor", User, "none", { avatar: b("avatar", { default: false }) }],
35
+ ["postAuthor", User, "none", { avatar: b("avatar", { default: false }), showName: b("showName", { default: true }), showBio: b("showBio", { default: false }), avatarSize: i("avatarSize", { min: 16, max: 128, default: 32 }), link: b("link", { default: true }) }],
36
36
  ["postTerms", Tags, "none", { taxonomy: s("taxonomy", { default: "category" }), separator: s("separator", { default: ", " }) }],
37
- ["comments", MessageSquare, "none", {}],
37
+ ["comments", MessageSquare, "none", { title: s("title"), perPage: i("perPage", { min: 1, max: 50 }), order: s("order", { enum: ["asc", "desc"], enumLabels: ["asc", "desc"] }), avatarSize: i("avatarSize", { min: 16, max: 128, default: 40 }), showDate: b("showDate", { default: true }) }],
38
+ ["readMore", ChevronsRight, "none", { text: s("text"), textAlign: align }],
39
+ ["commentsCount", MessageSquare, "none", { textAlign: align }],
40
+ ["avatar", User, "none", { size: i("size", { min: 16, max: 256, default: 48 }), link: b("link", { default: true }) }],
41
+ ["queryTotal", List, "none", { textAlign: align }],
42
+ ["termList", Tags, "none", { taxonomy: s("taxonomy", { default: "category" }), display: s("display", { enum: ["list", "cloud"], enumLabels: ["list", "cloud"], default: "list" }), showCount: b("showCount", { default: false }), hierarchical: b("hierarchical", { default: false }), hideEmpty: b("hideEmpty", { default: true }) }],
43
+ ["pageList", List, "none", { parentId: i("parentId", { min: 1 }), depth: i("depth", { min: 1, max: 3, default: 2 }) }],
44
+ ["archives", Calendar, "none", { showCount: b("showCount", { default: true }), limit: i("limit", { min: 1, max: 60, default: 12 }) }],
45
+ ["loginout", User, "none", { loginText: s("loginText"), logoutText: s("logoutText"), textAlign: align }],
38
46
  ["queryTitle", Heading1, "none", { level: i("level", { min: 1, max: 6, default: 1 }), prefix: b("prefix", { default: false }), textAlign: align }],
39
47
  ["termDescription", AlignLeft, "none", { textAlign: align }],
40
48
  ["breadcrumbs", ChevronsRight, "none", { separator: s("separator", { default: "›" }), showHome: b("showHome", { default: true }), showCurrent: b("showCurrent", { default: true }) }],
@@ -46,7 +54,7 @@ const SPECS: Array<[string, LucideIcon, "none" | "blocks", Record<string, BlockA
46
54
  order: s("order", { enum: ["desc", "asc"], enumLabels: ["desc", "asc"], default: "desc" }),
47
55
  }],
48
56
  ["postTemplate", Repeat, "blocks", { layout: s("layout", { enum: ["list", "grid"], enumLabels: ["list", "grid"], default: "list" }), columns: i("columns", { min: 1, max: 6, default: 3 }) }],
49
- ["pagination", MoreHorizontal, "none", {}],
57
+ ["pagination", MoreHorizontal, "none", { type: s("type", { enum: ["numbers", "prevNext", "both"], enumLabels: ["numbers", "prevNext", "both"], default: "both" }), midSize: i("midSize", { min: 0, max: 5, default: 2 }) }],
50
58
  ["queryEmpty", ListX, "blocks", {}],
51
59
  ["templatePart", PanelTop, "none", { slug: s("slug"), tagName: s("tagName", { enum: ["div", "header", "footer", "aside", "section"], default: "div" }) }],
52
60
  ];
@@ -31,6 +31,8 @@ export const v2 = {
31
31
  highlight: "Highlight",
32
32
  moreFormats: "More formatting",
33
33
  code: "Code",
34
+ kbd: "Keyboard key",
35
+ footnote: "Footnote",
34
36
  link: "Link",
35
37
  unlink: "Remove link",
36
38
  linkUrl: "Link URL",
@@ -31,6 +31,8 @@ export const v2 = {
31
31
  highlight: "Làm nổi bật",
32
32
  moreFormats: "Định dạng khác",
33
33
  code: "Mã",
34
+ kbd: "Phím bấm",
35
+ footnote: "Chú thích",
34
36
  link: "Liên kết",
35
37
  unlink: "Bỏ liên kết",
36
38
  linkUrl: "Địa chỉ liên kết",
@@ -129,6 +129,41 @@ function DetailsEdit({ block, blockProps, setAttrs, editable }: BlockEditProps)
129
129
  );
130
130
  }
131
131
 
132
+ function AccordionEdit({ block, blockProps }: BlockEditProps) {
133
+ return <div {...(merge(blockProps, "ecx-accordion") as object)}><InnerBlocks parent={block} /></div>;
134
+ }
135
+
136
+ function TabsEdit({ block, blockProps }: BlockEditProps) {
137
+ return <div {...(merge(blockProps, "ecx-tabs") as object)}><InnerBlocks parent={block} /></div>;
138
+ }
139
+
140
+ function TabEdit({ block, blockProps, setAttrs, editable }: BlockEditProps) {
141
+ return (
142
+ <div {...(merge(blockProps, "ecx-tab", { borderLeft: "3px solid rgba(127,127,127,.4)", paddingLeft: 12, marginBlock: 8 }) as object)}>
143
+ <RichText blockId={block.id} field="title" tagName="strong" value={String(block.attrs.title ?? "")} onChange={(v) => setAttrs({ title: v })} placeholder="Tab…" placeholderAlways editable={editable} />
144
+ <InnerBlocks parent={block} />
145
+ </div>
146
+ );
147
+ }
148
+
149
+ function CarouselEdit({ block, blockProps }: BlockEditProps) {
150
+ return <div {...(merge(blockProps, "ecx-carousel") as object)}><InnerBlocks parent={block} /></div>;
151
+ }
152
+
153
+ function ShortcodeEdit({ block, blockProps }: BlockEditProps) {
154
+ return <div {...(merge(blockProps, "ecx-shortcode", { fontFamily: "monospace", opacity: 0.8 }) as object)}>[{String(block.attrs.name || "shortcode")}]</div>;
155
+ }
156
+
157
+ function CountdownEdit({ block, blockProps }: BlockEditProps) {
158
+ const a = block.attrs;
159
+ return <div {...(merge(blockProps, "ecx-countdown", { textAlign: "center" }) as object)}>{a.label ? <p style={{ margin: 0 }}>{String(a.label)}</p> : null}<strong>{a.target ? String(a.target) : "00 : 00 : 00 : 00"}</strong></div>;
160
+ }
161
+
162
+ function RatingEdit({ block, blockProps }: BlockEditProps) {
163
+ const max = Math.min(10, Math.max(1, Number(block.attrs.max) || 5)), v = Number(block.attrs.value) || 0;
164
+ return <div {...(merge(blockProps, "ecx-rating") as object)} aria-label={`${v}/${max}`}>{Array.from({ length: max }, (_, i) => <span key={i} style={{ color: i < Math.round(v) ? "#f59e0b" : "#d4d4d8" }}>★</span>)}</div>;
165
+ }
166
+
132
167
  function CoverEdit({ block, blockProps, setAttrs, labels }: BlockEditProps) {
133
168
  const a = block.attrs;
134
169
  const src = typeof a.src === "string" ? a.src : "";
@@ -262,6 +297,36 @@ export function layoutBlocks(): BlockType[] {
262
297
  attributes: { summary: { type: "string" }, open: { type: "boolean", default: false } },
263
298
  create: () => makeBlock("details", {}, [makeBlock("paragraph")]), supports: { style: true, anchor: true, className: true },
264
299
  },
300
+ {
301
+ name: "accordion", title: "Accordion", icon: PanelTop, category: "text", keywords: "accordion faq hoi dap nhieu muc", kind: "container", edit: AccordionEdit,
302
+ attributes: { multiple: { type: "boolean", default: false } },
303
+ create: () => makeBlock("accordion", {}, [makeBlock("details", { summary: "" }, [makeBlock("paragraph")]), makeBlock("details", { summary: "" }, [makeBlock("paragraph")])]), supports: { style: true, anchor: true, className: true },
304
+ },
305
+ {
306
+ name: "tabs", title: "Tabs", icon: PanelTop, category: "text", keywords: "tabs the tab chuyen doi noi dung", kind: "container", edit: TabsEdit,
307
+ create: () => makeBlock("tabs", {}, [makeBlock("tab", { title: "" }, [makeBlock("paragraph")]), makeBlock("tab", { title: "" }, [makeBlock("paragraph")])]), supports: { style: true, anchor: true, className: true },
308
+ },
309
+ {
310
+ name: "tab", title: "Tab", icon: PanelTop, category: "text", keywords: "tab", kind: "container", edit: TabEdit, hidden: true, structure: { parents: ["tabs"] },
311
+ attributes: { title: { type: "string" } }, create: () => makeBlock("tab", { title: "" }, [makeBlock("paragraph")]),
312
+ },
313
+ {
314
+ name: "carousel", title: "Carousel", icon: Columns3, category: "design", keywords: "carousel slider slide truot anh", kind: "container", edit: CarouselEdit,
315
+ attributes: { slidesPerView: { type: "integer", default: 1, min: 1, max: 4 } },
316
+ create: () => makeBlock("carousel", { slidesPerView: 1 }, [makeBlock("group", {}, [makeBlock("paragraph")]), makeBlock("group", {}, [makeBlock("paragraph")])]), supports: { style: true, anchor: true, className: true },
317
+ },
318
+ {
319
+ name: "shortcode", title: "Shortcode", icon: Square, category: "design", keywords: "shortcode ma nhung plugin", kind: "atom", edit: ShortcodeEdit,
320
+ attributes: { name: { type: "string" }, args: { type: "json", default: {} } }, supports: { style: true, anchor: true, className: true },
321
+ },
322
+ {
323
+ name: "countdown", title: "Đếm ngược", icon: Square, category: "design", keywords: "dem nguoc countdown khuyen mai sale", kind: "atom", edit: CountdownEdit,
324
+ attributes: { target: { type: "string" }, label: { type: "string" }, expiredText: { type: "string" } }, supports: { style: true, anchor: true, className: true },
325
+ },
326
+ {
327
+ name: "rating", title: "Đánh giá sao", icon: Square, category: "design", keywords: "danh gia sao rating review", kind: "atom", edit: RatingEdit,
328
+ attributes: { value: { type: "number", default: 5, min: 0, max: 10 }, max: { type: "integer", default: 5, min: 1, max: 10 }, label: { type: "string" } }, supports: { style: true, anchor: true, className: true },
329
+ },
265
330
  {
266
331
  name: "cover", title: "Ảnh bìa", icon: ImageIcon, category: "media", keywords: "anh bia cover banner hero", kind: "container", edit: CoverEdit,
267
332
  attributes: { src: { type: "url", control: "media" }, alt: { type: "string" }, overlay: { type: "string", control: "color" }, opacity: { type: "integer", default: 50, min: 0, max: 100 }, minHeight: { type: "string", default: "400px" }, contentAlign: { type: "string", enum: ["top", "center", "bottom"], default: "center" }, fixed: { type: "boolean", default: false } },
@@ -222,10 +222,10 @@ export function mediaBlocks(): BlockType[] {
222
222
  return [
223
223
  {
224
224
  name: "image", title: "Ảnh", icon: ImageIcon, category: "media", keywords: "anh hinh image photo", kind: "atom", edit: ImageEdit,
225
- attributes: { ...media, alt: { type: "string", control: "textarea" }, title: { type: "string" }, width: { type: "number" }, height: { type: "number" }, size: { type: "string", default: "large" }, align: { type: "string", enum: ["left", "right", "center", "wide", "full"] }, href: { type: "url" }, linkTarget: { type: "string", enum: ["_self", "_blank"] } },
225
+ attributes: { ...media, alt: { type: "string", control: "textarea" }, title: { type: "string" }, width: { type: "number" }, height: { type: "number" }, size: { type: "string", default: "large" }, align: { type: "string", enum: ["left", "right", "center", "wide", "full"] }, href: { type: "url" }, linkTarget: { type: "string", enum: ["_self", "_blank"] }, lightbox: { type: "boolean", default: false } },
226
226
  supports: { style: true, anchor: true, className: true, blockStyle: true }, summary: (a) => a.alt || a.src,
227
227
  },
228
- { name: "gallery", title: "Gallery", icon: Images, category: "media", keywords: "gallery bo suu tap nhieu anh album", kind: "atom", edit: GalleryEdit, attributes: { images: { type: "json", default: [] }, columns: { type: "integer", default: 3, min: 1, max: 6 }, caption: { type: "string" } }, supports: { style: true, anchor: true, className: true } },
228
+ { name: "gallery", title: "Gallery", icon: Images, category: "media", keywords: "gallery bo suu tap nhieu anh album", kind: "atom", edit: GalleryEdit, attributes: { images: { type: "json", default: [] }, columns: { type: "integer", default: 3, min: 1, max: 6 }, caption: { type: "string" }, linkTo: { type: "string", enum: ["none", "media"], default: "media" }, imageCrop: { type: "boolean", default: true }, lightbox: { type: "boolean", default: false } }, supports: { style: true, anchor: true, className: true } },
229
229
  { name: "video", title: "Video", icon: Video, category: "media", keywords: "video mp4 phim", kind: "atom", edit: VideoEdit, attributes: { ...media, name: { type: "string" }, mime: { type: "string" }, poster: { type: "url", control: "media" }, autoplay: { type: "boolean", default: false }, loop: { type: "boolean", default: false }, muted: { type: "boolean", default: false }, controls: { type: "boolean", default: true }, playsInline: { type: "boolean", default: true }, preload: { type: "string", enum: ["none", "metadata", "auto"], default: "metadata" } }, supports: { style: true, anchor: true } },
230
230
  { name: "audio", title: "Âm thanh", icon: Music, category: "media", keywords: "am thanh audio nhac mp3 podcast", kind: "atom", edit: AudioEdit, attributes: { ...media, name: { type: "string" }, mime: { type: "string" }, autoplay: { type: "boolean", default: false }, loop: { type: "boolean", default: false }, preload: { type: "string", enum: ["none", "metadata", "auto"], default: "metadata" } }, supports: { style: true, anchor: true } },
231
231
  { name: "file", title: "Tệp", icon: FileIcon, category: "media", keywords: "tep file pdf tai xuong download tai lieu", kind: "atom", edit: FileEdit, attributes: { ...media, name: { type: "string" }, mime: { type: "string" }, size: { type: "number" }, embed: { type: "boolean", default: true }, download: { type: "boolean" } }, supports: { style: true, anchor: true } },
@@ -1,4 +1,4 @@
1
- import { 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 { 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
3
  import { Block, DocBlocks, InnerBlocks, NestedDoc } from "../canvas/block-list";
4
4
  import { DocScopeProvider, LoopPostContext, useDocScope, useDynamicData, useEditor, useEditorState } from "../context";
@@ -100,6 +100,47 @@ function PostTermsEdit({ block, blockProps }: BlockEditProps) {
100
100
  const d = useDynamic();
101
101
  return <p {...merge(blockProps, "ecx-post-terms")}>{(d.post?.terms?.length ? d.post.terms : block.attrs.taxonomy === "post_tag" ? ["Thẻ A", "Thẻ B"] : ["Chuyên mục A", "Chuyên mục B"]).join(String(block.attrs.separator ?? ", "))}</p>;
102
102
  }
103
+ function ReadMoreEdit({ block, blockProps }: BlockEditProps) {
104
+ return <p {...merge(blockProps, "ecx-read-more", align(block.attrs))}><a href="#" onClick={(e) => e.preventDefault()}>{String(block.attrs.text || "Đọc tiếp")}</a></p>;
105
+ }
106
+ function CommentsCountEdit({ block, blockProps }: BlockEditProps) {
107
+ const d = useDynamic();
108
+ return <p {...merge(blockProps, "ecx-comments-count", align(block.attrs))}>{d.post?.comments ?? 0}</p>;
109
+ }
110
+ function AvatarEdit({ block, blockProps }: BlockEditProps) {
111
+ const size = Math.min(256, Math.max(16, Number(block.attrs.size) || 48));
112
+ return <span {...merge(blockProps, "ecx-avatar")}><span style={{ display: "inline-block", width: size, height: size, borderRadius: "50%", background: "rgba(127,127,127,.3)" }} /></span>;
113
+ }
114
+ function QueryTotalEdit({ blockProps, block }: BlockEditProps) {
115
+ return <p {...merge(blockProps, "ecx-query-total", align(block.attrs))}>0</p>;
116
+ }
117
+ function TermListEdit({ block, blockProps }: BlockEditProps) {
118
+ const cloud = block.attrs.display === "cloud";
119
+ const sample = block.attrs.taxonomy === "post_tag" ? ["Thẻ A", "Thẻ B", "Thẻ C"] : ["Chuyên mục A", "Chuyên mục B", "Chuyên mục C"];
120
+ const n = (i: number) => (block.attrs.showCount ? ` (${3 - i})` : "");
121
+ return cloud
122
+ ? <p {...merge(blockProps, "ecx-term-list is-cloud")}>{sample.map((x, i) => <span key={x} style={{ marginRight: "0.5em", fontSize: `${1.3 - i * 0.2}em` }}>{x}{n(i)}</span>)}</p>
123
+ : <ul {...merge(blockProps, "ecx-term-list")}>{sample.map((x, i) => <li key={x}>{x}{n(i)}</li>)}</ul>;
124
+ }
125
+ function LoginOutEdit({ block, blockProps }: BlockEditProps) {
126
+ return <p {...merge(blockProps, "ecx-loginout", align(block.attrs))}><a href="#" onClick={(e) => e.preventDefault()}>{String(block.attrs.loginText || "Đăng nhập")}</a></p>;
127
+ }
128
+ function IconEdit({ block, blockProps }: BlockEditProps) {
129
+ const size = Math.min(128, Math.max(12, Number(block.attrs.size) || 24));
130
+ return <div {...merge(blockProps, "ecx-icon-block", align(block.attrs))}><span style={{ display: "inline-flex", alignItems: "center", gap: 6 }}><Star width={size} height={size} />{String(block.attrs.name ?? "star")}</span></div>;
131
+ }
132
+ function FootnotesEdit({ block, blockProps }: BlockEditProps) {
133
+ return <aside {...merge(blockProps, "ecx-footnotes")}>{block.attrs.title ? <p className="ecx-footnotes-title">{String(block.attrs.title)}</p> : null}<ol><li>Chú thích 1</li><li>Chú thích 2</li></ol></aside>;
134
+ }
135
+ function PageBreakEdit({ blockProps }: BlockEditProps) {
136
+ return <div {...merge(blockProps, "ecx-page-break")} style={{ ...(blockProps.style ?? {}), borderTop: "2px dashed currentColor", opacity: 0.5, textAlign: "center", fontSize: 12 }}>Ngắt trang</div>;
137
+ }
138
+ function PageListEdit({ blockProps }: BlockEditProps) {
139
+ return <nav {...merge(blockProps, "ecx-page-list")}><ul><li>Trang A<ul><li>Trang con</li></ul></li><li>Trang B</li></ul></nav>;
140
+ }
141
+ function ArchivesEdit({ block, blockProps }: BlockEditProps) {
142
+ return <ul {...merge(blockProps, "ecx-archives")}>{["11/2026", "10/2026"].map((m, i) => <li key={m}>{m}{block.attrs.showCount === false ? "" : ` (${4 - i})`}</li>)}</ul>;
143
+ }
103
144
  function CommentsEdit({ blockProps }: BlockEditProps) {
104
145
  const d = useDynamic();
105
146
  return <div {...merge(blockProps, "ecx-comments")}><MessageSquare className="ecx-icon" /> {d.post?.comments ?? 0}</div>;
@@ -265,18 +306,29 @@ export function themeBlocks(): BlockType[] {
265
306
  { 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 } },
266
307
  { 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 } },
267
308
  { 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 } },
268
- { 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 } }, supports: { style: true, className: true }, summary: (a) => a.location },
269
- { 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" } }, supports: { style: true, className: true } },
270
- { name: "languageSwitcher", title: "Chọn ngôn ngữ", icon: Globe2, category: theme, keywords: "ngon ngu language", kind: "atom", edit: LanguageEdit, supports: { style: true, className: true } },
309
+ { 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 },
310
+ { 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" } }, supports: { style: true, className: true } },
311
+ { 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 } },
271
312
  { 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 } },
272
313
  { 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 } },
273
314
  { name: "postContent", title: "Nội dung bài", icon: FileText, category: theme, keywords: "noi dung bai post content", kind: "atom", edit: PostContentEdit },
274
315
  { name: "postExcerpt", title: "Tóm tắt bài", icon: FileText, category: theme, keywords: "tom tat excerpt", kind: "atom", edit: PostExcerptEdit, attributes: { moreText: { type: "string" } }, supports: { style: true, className: true } },
275
316
  { name: "featuredImage", title: "Ảnh đại diện", icon: ImageIcon, category: theme, keywords: "anh dai dien featured image thumbnail", kind: "atom", edit: FeaturedImageEdit, attributes: { size: { type: "string", default: "large" }, link: { type: "boolean", default: false }, aspect: { type: "string", enum: ["auto", "16/9", "4/3", "1/1", "3/4"], default: "auto" } }, supports: { style: true, className: true } },
276
317
  { name: "postDate", title: "Ngày đăng", icon: CalendarDays, category: theme, keywords: "ngay dang date", kind: "atom", edit: PostDateEdit, attributes: { textAlign: TEXT_ALIGN, displayType: { type: "string", enum: ["published", "modified"], default: "published" } }, supports: { style: true, className: true } },
277
- { name: "postAuthor", title: "Tác giả", icon: User, category: theme, keywords: "tac gia author", kind: "atom", edit: PostAuthorEdit, attributes: { avatar: { type: "boolean", default: false } }, supports: { style: true, className: true } },
318
+ { name: "postAuthor", title: "Tác giả", icon: User, category: theme, keywords: "tac gia author", kind: "atom", edit: PostAuthorEdit, attributes: { avatar: { type: "boolean", default: false }, showName: { type: "boolean", default: true }, showBio: { type: "boolean", default: false }, avatarSize: { type: "integer", default: 32, min: 16, max: 128 }, link: { type: "boolean", default: true } }, supports: { style: true, className: true } },
278
319
  { name: "postTerms", title: "Chuyên mục / thẻ", icon: Tag, category: theme, keywords: "chuyen muc the category tag terms", kind: "atom", edit: PostTermsEdit, attributes: { taxonomy: { type: "string", default: "category" }, separator: { type: "string", default: ", " } }, supports: { style: true, className: true } },
279
- { name: "comments", title: "Bình luận", icon: MessageSquare, category: theme, keywords: "binh luan comments", kind: "atom", edit: CommentsEdit },
320
+ { name: "comments", title: "Bình luận", icon: MessageSquare, category: theme, keywords: "binh luan comments", kind: "atom", edit: CommentsEdit, attributes: { title: { type: "string" }, perPage: { type: "integer", min: 1, max: 50 }, order: { type: "string", enum: ["asc", "desc"] }, avatarSize: { type: "integer", default: 40, min: 16, max: 128 }, showDate: { type: "boolean", default: true } } },
321
+ { name: "readMore", title: "Đọc tiếp", icon: ChevronsRight, category: theme, keywords: "doc tiep read more", kind: "atom", edit: ReadMoreEdit, attributes: { text: { type: "string" }, textAlign: TEXT_ALIGN }, supports: { style: true, className: true } },
322
+ { name: "commentsCount", title: "Số bình luận", icon: MessageSquare, category: theme, keywords: "so binh luan comments count", kind: "atom", edit: CommentsCountEdit, attributes: { textAlign: TEXT_ALIGN }, supports: { style: true, className: true } },
323
+ { name: "avatar", title: "Ảnh đại diện tác giả", icon: ImageIcon, category: theme, keywords: "avatar anh dai dien tac gia", kind: "atom", edit: AvatarEdit, attributes: { size: { type: "integer", default: 48, min: 16, max: 256 }, link: { type: "boolean", default: true } }, supports: { style: true, className: true } },
324
+ { name: "queryTotal", title: "Tổng số bài", icon: ListOrdered, category: theme, keywords: "tong so bai total", kind: "atom", edit: QueryTotalEdit, attributes: { textAlign: TEXT_ALIGN }, supports: { style: true, className: true }, structure: { parents: ["query"] } },
325
+ { name: "termList", title: "Danh sách chuyên mục / thẻ", icon: Tag, category: theme, keywords: "danh sach chuyen muc the category tag cloud term list", kind: "atom", edit: TermListEdit, attributes: { taxonomy: { type: "string", default: "category" }, display: { type: "string", enum: ["list", "cloud"], default: "list" }, showCount: { type: "boolean", default: false }, hierarchical: { type: "boolean", default: false }, hideEmpty: { type: "boolean", default: true } }, supports: { style: true, className: true }, summary: (a) => a.taxonomy },
326
+ { name: "loginout", title: "Đăng nhập / Đăng xuất", icon: User, category: theme, keywords: "dang nhap dang xuat login logout", kind: "atom", edit: LoginOutEdit, attributes: { loginText: { type: "string" }, logoutText: { type: "string" }, textAlign: TEXT_ALIGN }, supports: { style: true, className: true } },
327
+ { name: "icon", title: "Icon", icon: Star, category: theme, keywords: "icon bieu tuong", kind: "atom", edit: IconEdit, attributes: { name: { type: "string", enum: ["check", "x", "star", "heart", "arrowRight", "phone", "mail", "mapPin", "clock", "info", "alert", "externalLink"], default: "star" }, size: { type: "integer", default: 24, min: 12, max: 128 }, label: { type: "string" }, textAlign: TEXT_ALIGN }, supports: { style: true, className: true }, summary: (a) => a.name },
328
+ { name: "footnotes", title: "Chú thích cuối bài", icon: ListOrdered, category: theme, keywords: "chu thich cuoi bai footnotes", kind: "atom", edit: FootnotesEdit, attributes: { title: { type: "string" } }, supports: { style: true, className: true } },
329
+ { name: "pageBreak", title: "Ngắt trang", icon: PanelTop, category: theme, keywords: "ngat trang page break nextpage", kind: "atom", edit: PageBreakEdit, supports: { className: true } },
330
+ { name: "pageList", title: "Danh sách trang", icon: ListOrdered, category: theme, keywords: "danh sach trang page list sitemap", kind: "atom", edit: PageListEdit, attributes: { parentId: { type: "integer", min: 1 }, depth: { type: "integer", default: 2, min: 1, max: 3 } }, supports: { style: true, className: true } },
331
+ { name: "archives", title: "Lưu trữ theo tháng", icon: CalendarDays, category: theme, keywords: "luu tru thang archives", kind: "atom", edit: ArchivesEdit, attributes: { showCount: { type: "boolean", default: true }, limit: { type: "integer", default: 12, min: 1, max: 60 } }, supports: { style: true, className: true } },
280
332
  { name: "queryTitle", title: "Tiêu đề trang lưu trữ", icon: Heading1, category: theme, keywords: "tieu de luu tru chuyen muc archive query title h1", kind: "atom", edit: QueryTitleEdit, attributes: { level: { type: "integer", default: 1, min: 1, max: 6 }, prefix: { type: "boolean", default: false }, textAlign: TEXT_ALIGN }, supports: { style: true, className: true } },
281
333
  { name: "termDescription", title: "Mô tả chuyên mục", icon: AlignLeft, category: theme, keywords: "mo ta chuyen muc term description", kind: "atom", edit: TermDescriptionEdit, attributes: { textAlign: TEXT_ALIGN }, supports: { style: true, className: true } },
282
334
  { name: "breadcrumbs", title: "Breadcrumb", icon: ChevronsRight, category: theme, keywords: "breadcrumb duong dan dieu huong", kind: "atom", edit: BreadcrumbsEdit, attributes: { separator: { type: "string", default: "›" }, showHome: { type: "boolean", default: true }, showCurrent: { type: "boolean", default: true } }, supports: { style: true, className: true } },
@@ -288,7 +340,7 @@ export function themeBlocks(): BlockType[] {
288
340
  supports: { style: true, className: true },
289
341
  },
290
342
  { 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"] } },
291
- { name: "pagination", title: "Phân trang", icon: ListOrdered, kind: "atom", edit: PaginationEdit, hidden: true, structure: { parents: ["query"] } },
343
+ { 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"] } },
292
344
  { name: "queryEmpty", title: "Khi không có bài", icon: SquareDashed, kind: "container", edit: QueryEmptyEdit, hidden: true, structure: { parents: ["query"] } },
293
345
  { 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 },
294
346
  { 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 },
@@ -10,7 +10,7 @@ export const BLOCKS_MIME = "application/x-ecx-blocks";
10
10
  // ---------------------------------------------------------------------------
11
11
  // HTML → khối
12
12
  // ---------------------------------------------------------------------------
13
- const MARK_TAGS: Record<string, string> = { STRONG: "bold", B: "bold", EM: "italic", I: "italic", U: "underline", S: "strike", DEL: "strike", STRIKE: "strike", CODE: "code", SUB: "subscript", SUP: "superscript", MARK: "highlight" };
13
+ const MARK_TAGS: Record<string, string> = { STRONG: "bold", B: "bold", EM: "italic", I: "italic", U: "underline", S: "strike", DEL: "strike", STRIKE: "strike", CODE: "code", KBD: "kbd", SUB: "subscript", SUP: "superscript", MARK: "highlight" };
14
14
  const BLOCK_TAGS = new Set(["P", "DIV", "H1", "H2", "H3", "H4", "H5", "H6", "UL", "OL", "LI", "BLOCKQUOTE", "PRE", "HR", "TABLE", "FIGURE", "IMG", "SECTION", "ARTICLE", "HEADER", "FOOTER", "MAIN", "ASIDE", "NAV", "DL", "DT", "DD"]);
15
15
 
16
16
  function inlineOf(node: globalThis.Node, marks: RichMark[] = [], out: RichNode[] = []): RichNode[] {
@@ -187,7 +187,7 @@ export function serializeBlocks(nodes: BNode[]): { json: string; text: string; h
187
187
  }
188
188
 
189
189
  const esc = (s: string) => s.replace(/[&<>"]/g, (c) => ({ "&": "&amp;", "<": "&lt;", ">": "&gt;", '"': "&quot;" })[c]!);
190
- const MARK_HTML: Record<string, string> = { bold: "strong", italic: "em", underline: "u", strike: "s", code: "code", subscript: "sub", superscript: "sup", highlight: "mark" };
190
+ const MARK_HTML: Record<string, string> = { bold: "strong", italic: "em", underline: "u", strike: "s", code: "code", kbd: "kbd", subscript: "sub", superscript: "sup", highlight: "mark" };
191
191
  /** HTML đơn giản (dán sang Word, email…). */
192
192
  export function richToHtml(nodes: RichNode[]): string {
193
193
  const inl = (list: RichNode[] = []) => list.map((n) => {
@@ -31,11 +31,11 @@ const CORE_KINDS: Record<string, BlockKind> = {
31
31
  paragraph: "text", heading: "text", codeBlock: "text", preformatted: "text",
32
32
  bulletList: "container", orderedList: "container", listItem: "container", taskList: "container", taskItem: "container",
33
33
  blockquote: "container", columns: "container", column: "container", group: "container", callout: "container",
34
- buttons: "container", cover: "container", mediaText: "container", pullquote: "text", details: "container",
34
+ buttons: "container", cover: "container", mediaText: "container", pullquote: "text", details: "container", accordion: "container", tabs: "container", tab: "container", carousel: "container",
35
35
  table: "container", tableRow: "container", tableCell: "container", tableHeader: "container",
36
36
  query: "container", postTemplate: "container", queryEmpty: "container", stack: "container",
37
37
  horizontalRule: "atom", image: "atom", gallery: "atom", video: "atom", audio: "atom", file: "atom", youtube: "atom",
38
- button: "atom", embed: "atom", spacer: "atom", customHtml: "atom", socialLinks: "atom", tableOfContents: "atom",
38
+ button: "atom", embed: "atom", spacer: "atom", customHtml: "atom", socialLinks: "atom", tableOfContents: "atom", countdown: "atom", rating: "atom", shortcode: "atom",
39
39
  };
40
40
  const kindOverrides = new Map<string, BlockKind>();
41
41
  export function setBlockKind(type: string, kind: BlockKind) { kindOverrides.set(type, kind); }
@@ -23,6 +23,8 @@ const marks: Record<string, MarkSpec> = {
23
23
  underline: simple("u"),
24
24
  strike: simple("s", ["del", "strike"]),
25
25
  code: { ...simple("code"), excludes: "_" },
26
+ footnote: { attrs: { note: { default: "" } }, inclusive: false, parseDOM: [{ tag: "span[data-ecx-footnote]", getAttrs: (d) => ({ note: (d as HTMLElement).getAttribute("data-ecx-footnote") ?? "" }) }], toDOM: (m) => ["span", { "data-ecx-footnote": String(m.attrs.note), class: "ecx-footnote-mark" }, 0] },
27
+ kbd: { ...simple("kbd"), excludes: "_" },
26
28
  subscript: { ...simple("sub"), excludes: "superscript" },
27
29
  superscript: { ...simple("sup"), excludes: "subscript" },
28
30
  highlight: { attrs: { color: { default: null } }, parseDOM: [{ tag: "mark" }], toDOM: (m) => ["mark", m.attrs.color ? { style: `background:${m.attrs.color}` } : {}, 0] },
@@ -90,6 +90,9 @@ export const ATTR_HINTS: Record<string, AttrHint> = {
90
90
  "socialLinks.align": { control: "segmented", options: ALIGN },
91
91
  "navigation.location": { control: "choice", choice: { kind: "menuLocation" }, help: true },
92
92
  "navigation.orientation": { control: "segmented", options: ["horizontal", "vertical"] },
93
+ "navigation.overlayMenu": { control: "segmented", options: ["never", "mobile", "always"] },
94
+ "languageSwitcher.display": { control: "segmented", options: ["inline", "dropdown"] },
95
+ "gallery.linkTo": { control: "segmented", options: ["none", "media"] },
93
96
  "postTerms.taxonomy": { control: "choice", choice: { kind: "taxonomy" } },
94
97
  "query.postType": { control: "choice", choice: { kind: "postType" }, when: notInherit },
95
98
  "query.category": { control: "choice", choice: { kind: "term", args: () => ({ taxonomy: "category" }) }, when: notInherit },
@@ -1,4 +1,4 @@
1
- import { AlignCenter, AlignLeft, AlignRight, ArrowUpLeft, Bold, ChevronDown, ChevronUp, Code, Copy, CopyPlus, GripVertical, IndentDecrease, IndentIncrease, Italic, Link2, Link2Off, MoreVertical, PanelTop, Strikethrough, Trash2, Underline, Ungroup, Group as GroupIcon, Blocks, ArrowUpToLine, ArrowDownToLine, Shapes, Lock, Subscript, Superscript, Highlighter } from "lucide-react";
1
+ import { StickyNote, Keyboard, AlignCenter, AlignLeft, AlignRight, ArrowUpLeft, Bold, ChevronDown, ChevronUp, Code, Copy, CopyPlus, GripVertical, IndentDecrease, IndentIncrease, Italic, Link2, Link2Off, MoreVertical, PanelTop, Strikethrough, Trash2, Underline, Ungroup, Group as GroupIcon, Blocks, ArrowUpToLine, ArrowDownToLine, Shapes, Lock, Subscript, Superscript, Highlighter } from "lucide-react";
2
2
  import { TextSelection } from "prosemirror-state";
3
3
  import type { EditorView } from "prosemirror-view";
4
4
  import { useEffect, useLayoutEffect, useRef, useState, type ComponentType, type ReactNode } from "react";
@@ -276,14 +276,19 @@ function MarkTools({ view, onLink }: { view: EditorView; onLink(): void }) {
276
276
  const type = view.state.schema.marks[name];
277
277
  const { from, to, empty } = view.state.selection;
278
278
  const tr = view.state.tr;
279
- if (empty) tr.setStoredMarks(isActive(name) ? (view.state.storedMarks ?? view.state.selection.$from.marks()).filter((m) => m.type !== type) : [...(view.state.storedMarks ?? view.state.selection.$from.marks()), type.create()]);
279
+ if (name === "footnote") {
280
+ // shortcut: hỏi nội dung bằng prompt() của trình duyệt, nâng thành popover khi cần sửa chú thích có sẵn
281
+ if (empty) return;
282
+ if (isActive(name)) tr.removeMark(from, to, type);
283
+ else { const note = window.prompt(labels.footnote)?.trim(); if (!note) return; tr.addMark(from, to, type.create({ note })); }
284
+ } else if (empty) tr.setStoredMarks(isActive(name) ? (view.state.storedMarks ?? view.state.selection.$from.marks()).filter((m) => m.type !== type) : [...(view.state.storedMarks ?? view.state.selection.$from.marks()), type.create()]);
280
285
  else if (isActive(name)) tr.removeMark(from, to, type);
281
286
  else tr.addMark(from, to, type.create());
282
287
  view.dispatch(tr);
283
288
  view.focus();
284
289
  };
285
290
  const main: Array<[string, typeof Bold, string, string]> = [["bold", Bold, labels.bold, `${mod}B`], ["italic", Italic, labels.italic, `${mod}I`], ["underline", Underline, labels.underline, `${mod}U`]];
286
- const more: Array<[string, typeof Bold, string]> = [["strike", Strikethrough, labels.strike], ["code", Code, labels.code], ["subscript", Subscript, labels.subscript], ["superscript", Superscript, labels.superscript], ["highlight", Highlighter, labels.highlight]];
291
+ const more: Array<[string, typeof Bold, string]> = [["strike", Strikethrough, labels.strike], ["code", Code, labels.code], ["kbd", Keyboard, labels.kbd], ["footnote", StickyNote, labels.footnote], ["subscript", Subscript, labels.subscript], ["superscript", Superscript, labels.superscript], ["highlight", Highlighter, labels.highlight]];
287
292
  return (
288
293
  <div className="ecx-tool-group">
289
294
  {main.map(([name, I, l, k]) => <ToolButton key={name} label={`${l} (${k})`} active={isActive(name)} onClick={() => toggle(name)}><I className="ecx-icon" /></ToolButton>)}