@ecomcx/ecomweb-editor 1.33.0 → 1.34.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +3 -3
- package/src/locales/en/attrs.ts +2 -1
- package/src/locales/en/background.ts +5 -0
- package/src/locales/en/bindings.ts +4 -0
- package/src/locales/en/block-desc.ts +4 -11
- package/src/locales/en/block-style.ts +17 -6
- package/src/locales/en/block-titles.ts +38 -16
- package/src/locales/en/blocks.ts +36 -6
- package/src/locales/en/columns.ts +1 -0
- package/src/locales/en/controls.ts +1 -1
- package/src/locales/en/hints.ts +241 -12
- package/src/locales/en/index.ts +3 -1
- package/src/locales/en/layout.ts +13 -0
- package/src/locales/en/motion.ts +16 -0
- package/src/locales/en/palette.ts +8 -0
- package/src/locales/en/parts.ts +2 -1
- package/src/locales/en/pattern-overrides.ts +14 -0
- package/src/locales/en/placeholders.ts +6 -3
- package/src/locales/en/v2.ts +2 -0
- package/src/locales/vi/attrs.ts +3 -2
- package/src/locales/vi/background.ts +5 -0
- package/src/locales/vi/bindings.ts +4 -0
- package/src/locales/vi/block-desc.ts +7 -14
- package/src/locales/vi/block-style.ts +18 -7
- package/src/locales/vi/block-titles.ts +48 -26
- package/src/locales/vi/blocks.ts +36 -6
- package/src/locales/vi/columns.ts +1 -0
- package/src/locales/vi/controls.ts +1 -1
- package/src/locales/vi/hints.ts +241 -12
- package/src/locales/vi/index.ts +3 -1
- package/src/locales/vi/layout.ts +13 -0
- package/src/locales/vi/motion.ts +16 -0
- package/src/locales/vi/palette.ts +8 -0
- package/src/locales/vi/parts.ts +2 -1
- package/src/locales/vi/pattern-overrides.ts +14 -0
- package/src/locales/vi/placeholders.ts +7 -4
- package/src/locales/vi/v2.ts +2 -0
- package/src/v2/blocks/columns-inspector.tsx +11 -2
- package/src/v2/blocks/index.ts +9 -6
- package/src/v2/blocks/layout-options.tsx +80 -0
- package/src/v2/blocks/layout.tsx +331 -124
- package/src/v2/blocks/media.tsx +51 -21
- package/src/v2/blocks/resize.tsx +50 -19
- package/src/v2/blocks/social-icons.ts +22 -0
- package/src/v2/blocks/text.tsx +12 -50
- package/src/v2/blocks/theme.tsx +13 -19
- package/src/v2/blocks/tools.tsx +24 -2
- package/src/v2/blocks/widgets.tsx +84 -28
- package/src/v2/canvas/block-list.tsx +30 -4
- package/src/v2/canvas/canvas-css.ts +81 -9
- package/src/v2/canvas/canvas.tsx +63 -7
- package/src/v2/canvas/dnd.ts +7 -0
- package/src/v2/canvas/variation-picker.tsx +63 -0
- package/src/v2/context.tsx +48 -0
- package/src/v2/core/bindings.ts +6 -1
- package/src/v2/core/block-presets.ts +10 -0
- package/src/v2/core/clipboard.ts +5 -5
- package/src/v2/core/host.ts +2 -0
- package/src/v2/core/model.ts +6 -6
- package/src/v2/core/registry.ts +15 -0
- package/src/v2/core/store.ts +9 -9
- package/src/v2/core/structure.ts +1 -3
- package/src/v2/editor.css +74 -0
- package/src/v2/editor.tsx +22 -7
- package/src/v2/text/rich-text.tsx +20 -5
- package/src/v2/ui/ai-markdown.ts +52 -0
- package/src/v2/ui/ai.tsx +81 -14
- package/src/v2/ui/attr-form.tsx +26 -6
- package/src/v2/ui/attr-hints.ts +115 -16
- package/src/v2/ui/background-panel.tsx +22 -0
- package/src/v2/ui/bg-video-preview.tsx +7 -0
- package/src/v2/ui/bindings.tsx +7 -2
- package/src/v2/ui/block-icons.tsx +3 -10
- package/src/v2/ui/block-live-preview.tsx +21 -0
- package/src/v2/ui/block-style-panel.tsx +3 -1
- package/src/v2/ui/command-palette.tsx +125 -0
- package/src/v2/ui/icon-picker.tsx +88 -21
- package/src/v2/ui/icon-svg.tsx +21 -0
- package/src/v2/ui/inserter.tsx +62 -12
- package/src/v2/ui/inspector.tsx +12 -6
- package/src/v2/ui/layout-panel.tsx +1 -1
- package/src/v2/ui/motion-panel.tsx +22 -13
- package/src/v2/ui/option-thumbs.tsx +81 -0
- package/src/v2/ui/pattern-library.tsx +2 -1
- package/src/v2/ui/pattern-overrides.tsx +67 -0
- package/src/v2/ui/placeholders.tsx +21 -2
- package/src/v2/ui/preset-bar.tsx +5 -5
- package/src/v2/ui/style-supports.ts +2 -3
- package/src/v2/ui/style-tab.tsx +83 -20
- package/src/v2/ui/toolbar.tsx +40 -6
- package/src/v2/ui/transform-panel.tsx +77 -0
package/src/v2/blocks/media.tsx
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { makeBlock } from "../core/model";
|
|
2
|
+
import { SOCIAL_ICONS } from "./social-icons";
|
|
3
|
+
import { blockShell, carouselConfig, carouselData, carouselVars, embedInfo, imageFx, isSafeUrl } from "@ecomcx/ecomweb-content";
|
|
4
|
+
import { ArrowDown, ArrowUp, Code2, File as FileIcon, Image as ImageIcon, Images, ListTree, Music, Plus, Share2, Video, Globe, X } from "lucide-react";
|
|
5
|
+
import { useRef, useState, type CSSProperties, type ReactNode } from "react";
|
|
4
6
|
import { useEditor } from "../context";
|
|
5
7
|
import { AiAltButton } from "../ui/ai";
|
|
6
8
|
import type { BlockEditProps, BlockType } from "../core/registry";
|
|
@@ -35,7 +37,7 @@ function ImageEdit({ block, blockProps, setAttrs, editable, selected }: BlockEdi
|
|
|
35
37
|
return (
|
|
36
38
|
<figure {...blockProps} className={cx(blockProps.className, cls)} style={{ ...(blockProps.style ?? {}), position: "relative" }}>
|
|
37
39
|
{selected && editable && <ImageHandle blockId={block.id} />}
|
|
38
|
-
<img src={src} alt={bAlt.bound ? bAlt.value ?? "" : String(a.alt ?? "")} data-ecx-bound={bSrc.bound ? "" : undefined} title={bSrc.bound ? bSrc.label : undefined} width={Number(a.width) || undefined} height={Number(a.height) || undefined} draggable={false} style={Number(a.width) ? { width: Number(a.width), maxWidth: "100%", height: "auto" } : undefined} />
|
|
40
|
+
<img src={src} alt={bAlt.bound ? bAlt.value ?? "" : String(a.alt ?? "")} data-ecx-bound={bSrc.bound ? "" : undefined} title={bSrc.bound ? bSrc.label : undefined} width={Number(a.width) || undefined} height={Number(a.height) || undefined} draggable={false} className={imageFx(a).className || undefined} style={{ ...(Number(a.width) ? { width: Number(a.width), maxWidth: "100%", height: "auto" } : {}), ...(imageFx(a).style as CSSProperties | undefined) }} />
|
|
39
41
|
{bCap.bound ? <BoundText tagName="figcaption" preview={bCap} /> : (a.caption || editable) && (
|
|
40
42
|
<RichText blockId={block.id} field="caption" tagName="figcaption" value={String(a.caption ?? "")} onChange={(v) => setAttrs({ caption: v })} placeholder={tp.caption} editable={editable} />
|
|
41
43
|
)}
|
|
@@ -49,6 +51,8 @@ function GalleryEdit({ block, blockProps, setAttrs, editable, selected }: BlockE
|
|
|
49
51
|
if (!images.length) return <MediaDrop blockId={block.id} kind="gallery" blockProps={blockProps} />;
|
|
50
52
|
const cols = Math.min(6, Math.max(1, Number(block.attrs.columns) || 3));
|
|
51
53
|
const add = (items: MediaItem[]) => setAttrs({ images: [...images, ...((mediaAttrs("gallery", items).images ?? []) as typeof images)] });
|
|
54
|
+
// Dạng slider: giống website (mỗi ảnh một slide, cuộn ngang bám mép, nút trước / sau + chấm) — không còn xếp dọc như lưới 1 cột
|
|
55
|
+
if (block.attrs.layout === "slider" && images.length > 1) return <GallerySlider block={block} blockProps={blockProps} images={images} cols={cols} />;
|
|
52
56
|
return (
|
|
53
57
|
<figure {...blockProps} className={cx(blockProps.className, blockShell("gallery", block.attrs)!.className, (block.attrs.layout === "masonry" || block.attrs.imageCrop === false) && "is-natural")} style={{ ...(blockProps.style ?? {}), ...(blockShell("gallery", block.attrs)!.style as CSSProperties) }}>
|
|
54
58
|
{images.map((im, i) => <figure key={i} className="ecx-gallery-item cms-gallery-item" style={{ margin: 0 }}><img src={safe(im.src)} alt={im.alt ?? ""} draggable={false} style={block.attrs.layout === "masonry" || block.attrs.imageCrop === false ? { width: "100%", height: "auto", display: "block" } : { width: "100%", height: "100%", objectFit: "cover", aspectRatio: "1" }} /></figure>)}
|
|
@@ -59,6 +63,45 @@ function GalleryEdit({ block, blockProps, setAttrs, editable, selected }: BlockE
|
|
|
59
63
|
);
|
|
60
64
|
}
|
|
61
65
|
|
|
66
|
+
function GallerySlider({ block, blockProps, images, cols }: { block: BlockEditProps["block"]; blockProps: BlockEditProps["blockProps"]; images: Array<{ src: string; alt?: string }>; cols: number }) {
|
|
67
|
+
const tp = useMsgs("placeholders");
|
|
68
|
+
const track = useRef<HTMLDivElement>(null);
|
|
69
|
+
const [index, setIndex] = useState(0);
|
|
70
|
+
const c = carouselConfig({ slidesPerView: Math.min(4, cols), arrows: block.attrs.arrows, dots: block.attrs.dots, autoplay: false, loop: block.attrs.loop, gap: "var(--ecx-gallery-gap, 8px)" });
|
|
71
|
+
const last = Math.max(0, images.length - c.per);
|
|
72
|
+
const goTo = (i: number) => {
|
|
73
|
+
const el = track.current, kid = el?.children[i] as HTMLElement | undefined;
|
|
74
|
+
if (el && kid) { el.scrollTo({ left: kid.offsetLeft - (el.children[0] as HTMLElement).offsetLeft, behavior: "smooth" }); setIndex(i); }
|
|
75
|
+
};
|
|
76
|
+
const chev = (d: string) => <svg viewBox="0 0 24 24" width={20} height={20} fill="none" stroke="currentColor" strokeWidth={2} strokeLinecap="round" strokeLinejoin="round" aria-hidden="true"><path d={d} /></svg>;
|
|
77
|
+
const crop = block.attrs.imageCrop !== false;
|
|
78
|
+
return (
|
|
79
|
+
<figure {...blockProps} className={cx(blockProps.className, "ecx-gallery cms-gallery is-slider")} style={{ ...(blockProps.style ?? {}), margin: 0 }}>
|
|
80
|
+
<div className="ecx-carousel" style={carouselVars(c) as CSSProperties} {...carouselData({ ...c, effect: "slide" })}>
|
|
81
|
+
<div className="ecx-carousel-track" ref={track} onScroll={(e) => { const el = e.currentTarget, first = el.children[0] as HTMLElement | undefined, second = el.children[1] as HTMLElement | undefined; const step = first && second ? second.offsetLeft - first.offsetLeft : first?.offsetWidth || 1; setIndex(Math.max(0, Math.min(last, Math.round(el.scrollLeft / step)))); }}>
|
|
82
|
+
{images.map((im, i) => (
|
|
83
|
+
<div key={i} className="ecx-carousel-slide" role="group" aria-roledescription="slide" aria-label={`${i + 1} / ${images.length}`}>
|
|
84
|
+
<figure className="ecx-gallery-item cms-gallery-item" style={{ margin: 0 }}><img src={safe(im.src)} alt={im.alt ?? ""} draggable={false} style={crop ? { width: "100%", height: "100%", objectFit: "cover", aspectRatio: "1" } : { width: "100%", height: "auto", display: "block" }} /></figure>
|
|
85
|
+
</div>
|
|
86
|
+
))}
|
|
87
|
+
</div>
|
|
88
|
+
<div contentEditable={false} onMouseDown={(e) => e.preventDefault()}>
|
|
89
|
+
{c.arrows && last > 0 && <>
|
|
90
|
+
<button type="button" className="ecx-carousel-arrow is-prev" aria-label={tp.prevSlide} disabled={!c.loop && index <= 0} onClick={() => goTo(index <= 0 ? last : index - 1)}>{chev("m15 18-6-6 6-6")}</button>
|
|
91
|
+
<button type="button" className="ecx-carousel-arrow is-next" aria-label={tp.nextSlide} disabled={!c.loop && index >= last} onClick={() => goTo(index >= last ? 0 : index + 1)}>{chev("m9 18 6-6-6-6")}</button>
|
|
92
|
+
</>}
|
|
93
|
+
{c.dots && last > 0 && (
|
|
94
|
+
<div className="ecx-carousel-dots">
|
|
95
|
+
{Array.from({ length: last + 1 }, (_, i) => <button key={i} type="button" className="ecx-carousel-dot" aria-label={`${tp.slide} ${i + 1}`} aria-current={i === index ? "true" : undefined} onClick={() => goTo(i)} />)}
|
|
96
|
+
</div>
|
|
97
|
+
)}
|
|
98
|
+
</div>
|
|
99
|
+
</div>
|
|
100
|
+
{block.attrs.caption ? <figcaption className="ecx-gallery-caption cms-gallery-caption">{String(block.attrs.caption)}</figcaption> : null}
|
|
101
|
+
</figure>
|
|
102
|
+
);
|
|
103
|
+
}
|
|
104
|
+
|
|
62
105
|
function VideoEdit({ block, blockProps, labels }: BlockEditProps) {
|
|
63
106
|
const src = safe(block.attrs.src);
|
|
64
107
|
if (!src) return <MediaDrop blockId={block.id} kind="video" blockProps={blockProps} />;
|
|
@@ -78,18 +121,6 @@ function FileEdit({ block, blockProps }: BlockEditProps) {
|
|
|
78
121
|
return <div {...blockProps} className={cx(blockProps.className, "ecx-file cms-file")}><span className="ecx-file-link cms-file-link">{String(block.attrs.name || src)}</span></div>;
|
|
79
122
|
}
|
|
80
123
|
|
|
81
|
-
const YT = /(?:v=|youtu\.be\/|embed\/)([\w-]{11})/; // cùng mẫu với website (theme-sdk)
|
|
82
|
-
function YoutubeEdit({ block, blockProps, setAttrs }: BlockEditProps) {
|
|
83
|
-
const m = String(block.attrs.src ?? "").match(YT);
|
|
84
|
-
const tp = useMsgs("placeholders");
|
|
85
|
-
if (!m) return <LinkPlaceholder blockProps={blockProps} icon={Play} title={tp.pasteToEmbed} label="YouTube URL" validate={(u) => YT.test(u)} onSubmit={(src) => setAttrs({ src })} />;
|
|
86
|
-
return (
|
|
87
|
-
<div {...blockProps} className={cx(blockProps.className, "ecx-youtube embed")}>
|
|
88
|
-
<img src={`https://i.ytimg.com/vi/${m[1]}/hqdefault.jpg`} alt="YouTube" draggable={false} style={{ width: "100%", aspectRatio: "16/9", objectFit: "cover" }} />
|
|
89
|
-
</div>
|
|
90
|
-
);
|
|
91
|
-
}
|
|
92
|
-
|
|
93
124
|
function EmbedEdit({ block, blockProps, setAttrs }: BlockEditProps) {
|
|
94
125
|
const url = String(block.attrs.url ?? "");
|
|
95
126
|
const info = embedInfo(url);
|
|
@@ -160,7 +191,7 @@ function SocialEdit({ block, blockProps, setAttrs, editable }: BlockEditProps) {
|
|
|
160
191
|
if (!links.length) return <div {...(blockProps as object)} className={cx(blockProps.className, "ecx-media-placeholder ecx-ph-inline")} data-ecx-placeholder="social"><span className="ecx-ph-title"><Share2 className="ecx-icon" />{adder}</span></div>;
|
|
161
192
|
return (
|
|
162
193
|
<ul {...(blockProps as object)} className={cx(blockProps.className, "ecx-social", `is-${a.size ?? "medium"}`, typeof a.align === "string" && `is-${a.align}`, !!a.showLabels && "has-labels")}>
|
|
163
|
-
{links.map((l, i) => <li key={i}><a className={`ecx-social-${l.service}`} title={l.label || socialName(l.service)} onClick={(e) => e.preventDefault()}>{l.label || socialName(l.service)}</a></li>)}
|
|
194
|
+
{links.map((l, i) => <li key={i}><a className={`ecx-social-${l.service}`} title={l.label || socialName(l.service)} aria-label={l.label || socialName(l.service)} onClick={(e) => e.preventDefault()}><svg viewBox="0 0 24 24" width="1em" height="1em" fill="currentColor" aria-hidden="true"><path d={SOCIAL_ICONS[l.service] ?? SOCIAL_ICONS.website} fillRule={SOCIAL_ICONS[l.service] && !["email", "website", "linkedin"].includes(l.service) ? undefined : "evenodd"} /></svg>{a.showLabels ? <span>{l.label || socialName(l.service)}</span> : null}</a></li>)}
|
|
164
195
|
{adder ? <li className="ecx-ph-add">{adder}</li> : editable && <li className="ecx-ph-add"><button type="button" className="ecx-add-item" contentEditable={false} aria-label={tp.socialAdd} title={tp.socialAdd} onMouseDown={(e) => e.stopPropagation()} onClick={() => setAdding(true)}><Plus className="ecx-icon ecx-icon-sm" aria-hidden /></button></li>}
|
|
165
196
|
</ul>
|
|
166
197
|
);
|
|
@@ -270,17 +301,16 @@ export function mediaBlocks(): BlockType[] {
|
|
|
270
301
|
return [
|
|
271
302
|
{
|
|
272
303
|
name: "image", title: "Ảnh", icon: ImageIcon, category: "media", keywords: "anh hinh image photo", kind: "atom", edit: ImageEdit, toolbar: ImageAiTools,
|
|
273
|
-
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 } },
|
|
304
|
+
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 }, ratio: { type: "string", enum: ["auto", "1/1", "4/3", "3/2", "16/9", "21/9", "3/4", "2/3"], default: "auto" } },
|
|
274
305
|
supports: { style: true, anchor: true, className: true, blockStyle: true }, summary: (a) => a.alt || a.src,
|
|
275
306
|
},
|
|
276
|
-
{ name: "gallery", title: "Gallery", icon: Images, category: "media", keywords: "gallery bo suu tap nhieu anh album", kind: "atom", edit: GalleryEdit, inspector: GalleryInspector, attributes: { layout: { type: "string", enum: ["grid", "masonry"], default: "grid" }, 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 } },
|
|
307
|
+
{ name: "gallery", title: "Gallery", icon: Images, category: "media", keywords: "gallery bo suu tap nhieu anh album", kind: "atom", edit: GalleryEdit, inspector: GalleryInspector, attributes: { layout: { type: "string", enum: ["grid", "masonry", "mosaic", "tiles", "thumbs", "slider"], default: "grid" }, captionStyle: { type: "string", enum: ["below", "hover", "overlay"], default: "below" }, arrows: { type: "boolean", default: true }, dots: { type: "boolean", default: true }, autoplay: { type: "boolean", default: false }, interval: { type: "integer", default: 5, min: 2, max: 30 }, loop: { type: "boolean", default: true }, 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 } },
|
|
277
308
|
{ 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 } },
|
|
278
309
|
{ 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 } },
|
|
279
310
|
{ 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 } },
|
|
280
|
-
{ name: "youtube", title: "YouTube", icon: Play, category: "embed", keywords: "video youtube", kind: "atom", edit: YoutubeEdit, attributes: { src: { type: "url" }, start: { type: "integer" } }, supports: { style: true, anchor: true } },
|
|
281
311
|
{ name: "embed", title: "Nhúng", icon: Globe, category: "embed", keywords: "nhung embed youtube vimeo tiktok facebook twitter x instagram spotify google map", kind: "atom", edit: EmbedEdit, attributes: { url: { type: "url" }, caption: { type: "string" } }, supports: { style: true, anchor: true }, summary: (a) => a.url },
|
|
282
312
|
{ name: "customHtml", title: "HTML tuỳ chỉnh", icon: Code2, category: "widgets", keywords: "html tuy chinh custom code", kind: "atom", edit: HtmlEdit, attributes: { html: { type: "string", control: "textarea" } } },
|
|
283
|
-
{ name: "socialLinks", title: "Mạng xã hội", icon: Share2, category: "widgets", keywords: "mang xa hoi social facebook zalo youtube tiktok", kind: "atom", edit: SocialEdit, inspector: SocialInspector, attributes: { links: { type: "json", default: [] }, size: { type: "string", enum: ["small", "medium", "large"], default: "medium" }, align: { type: "string", enum: ["left", "center", "right"] }, showLabels: { type: "boolean", default: false } }, supports: { style: true, anchor: true, className: true } },
|
|
313
|
+
{ name: "socialLinks", title: "Mạng xã hội", icon: Share2, category: "widgets", keywords: "mang xa hoi social facebook zalo youtube tiktok", kind: "atom", edit: SocialEdit, inspector: SocialInspector, create: () => makeBlock("socialLinks", { links: [{ service: "facebook", url: "https://facebook.com" }, { service: "youtube", url: "https://youtube.com" }, { service: "zalo", url: "https://zalo.me" }], size: "medium", showLabels: false }), attributes: { links: { type: "json", default: [] }, size: { type: "string", enum: ["small", "medium", "large"], default: "medium" }, align: { type: "string", enum: ["left", "center", "right"] }, showLabels: { type: "boolean", default: false } }, supports: { style: true, anchor: true, className: true } },
|
|
284
314
|
{ name: "tableOfContents", title: "Mục lục", icon: ListTree, category: "widgets", keywords: "muc luc table of contents toc", kind: "atom", edit: TocEdit, attributes: { title: { type: "string" }, minLevel: { type: "integer", default: 2, min: 2, max: 6 }, maxLevel: { type: "integer", default: 3, min: 2, max: 6 }, collapsible: { type: "boolean", default: false }, startCollapsed: { type: "boolean", default: false }, listStyle: { type: "string", enum: ["numbers", "bullets", "none"], default: "numbers" }, columns: { type: "integer", default: 1, min: 1, max: 3 }, smoothScroll: { type: "boolean", default: false }, highlight: { type: "boolean", default: false }, showTitle: { type: "boolean", default: true } }, supports: { style: true, anchor: true } },
|
|
285
315
|
];
|
|
286
316
|
}
|
package/src/v2/blocks/resize.tsx
CHANGED
|
@@ -22,7 +22,7 @@ export function useActiveWithin(id: string) {
|
|
|
22
22
|
* Đặt tuyệt đối trong khối cột nên không ảnh hưởng bố cục flex.
|
|
23
23
|
*/
|
|
24
24
|
export function ColumnHandles({ block }: { block: BNode }) {
|
|
25
|
-
const { store, labels } = useEditor();
|
|
25
|
+
const { store, labels, ui } = useEditor();
|
|
26
26
|
const ref = useRef<HTMLSpanElement>(null);
|
|
27
27
|
const [gaps, setGaps] = useState<Array<{ left: number; top: number; height: number }>>([]);
|
|
28
28
|
const cols = block.content ?? [];
|
|
@@ -60,6 +60,23 @@ export function ColumnHandles({ block }: { block: BNode }) {
|
|
|
60
60
|
const handle = e.currentTarget as HTMLElement;
|
|
61
61
|
handle.setPointerCapture(e.pointerId);
|
|
62
62
|
handle.classList.add("is-dragging");
|
|
63
|
+
// Alt + kéo: đổi KHOẢNG CÁCH giữa các cột (ô "Khoảng giữa các cột") thay vì độ rộng; số px hiện cạnh tay nắm
|
|
64
|
+
if (e.altKey) {
|
|
65
|
+
const startGap = Math.max(0, Math.round(b.left - a.right)), x0 = e.clientX;
|
|
66
|
+
const device = ui.device === "desktop" ? "base" : ui.device;
|
|
67
|
+
const moveGap = (ev: PointerEvent) => {
|
|
68
|
+
const px = Math.max(0, Math.min(200, Math.round(startGap + (ev.clientX - x0) * 2)));
|
|
69
|
+
handle.dataset.left = `${px}px`; handle.dataset.right = "";
|
|
70
|
+
const cur = store.block(block.id)?.attrs.columnsGap;
|
|
71
|
+
const obj: Record<string, string> = cur && typeof cur === "object" ? { ...(cur as Record<string, string>) } : typeof cur === "string" && cur ? { base: cur } : {};
|
|
72
|
+
obj[device] = `${px}px`;
|
|
73
|
+
store.setAttrs([block.id], { columnsGap: obj });
|
|
74
|
+
};
|
|
75
|
+
const upGap = () => { handle.removeEventListener("pointermove", moveGap); handle.removeEventListener("pointerup", upGap); handle.classList.remove("is-dragging"); store.breakMerge(); focusCanvas(handle); };
|
|
76
|
+
handle.addEventListener("pointermove", moveGap);
|
|
77
|
+
handle.addEventListener("pointerup", upGap);
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
63
80
|
const move = (ev: PointerEvent) => {
|
|
64
81
|
const ratio = Math.min(0.9, Math.max(0.1, (ev.clientX - a.left) / (b.right - a.left)));
|
|
65
82
|
const wa = Math.round(pair * ratio), wb = Math.round(pair - pair * ratio);
|
|
@@ -80,7 +97,7 @@ export function ColumnHandles({ block }: { block: BNode }) {
|
|
|
80
97
|
return (
|
|
81
98
|
<span ref={ref} className="ecx-col-handles" contentEditable={false} aria-hidden="true">
|
|
82
99
|
{gaps.map((g, i) => (
|
|
83
|
-
<span key={i} className="ecx-col-handle" style={{ left: g.left, top: g.top, height: g.height }} title={labels.resize}
|
|
100
|
+
<span key={i} className="ecx-col-handle" style={{ left: g.left, top: g.top, height: g.height }} title={`${labels.resize} · Alt: ${labels.resizeGap}`}
|
|
84
101
|
data-ecx-col-handle={i} onPointerDown={(e) => start(i, e)} onMouseDown={(e) => e.stopPropagation()} />
|
|
85
102
|
))}
|
|
86
103
|
</span>
|
|
@@ -163,30 +180,33 @@ export function PaddingHandles({ blockId }: { blockId: string }) {
|
|
|
163
180
|
const { store, ui, labels: v2 } = useEditor();
|
|
164
181
|
const L = labelsLegacy(v2.lang);
|
|
165
182
|
const ref = useRef<HTMLSpanElement>(null);
|
|
166
|
-
|
|
167
|
-
|
|
183
|
+
type Side = "top" | "bottom" | "left" | "right";
|
|
184
|
+
// Cỡ thật (px) của đệm / lề từng cạnh: vùng kéo dày đúng bằng nó (tối thiểu 8px) — kéo ở bất kỳ đâu trong vùng
|
|
185
|
+
const [px, setPx] = useState({ pt: 0, pb: 0, pl: 0, pr: 0, mt: 0, mb: 0, ml: 0, mr: 0 });
|
|
168
186
|
useLayoutEffect(() => {
|
|
169
187
|
const el = ui.blockEl(blockId);
|
|
170
188
|
if (!el) return;
|
|
171
189
|
const cs = el.ownerDocument.defaultView!.getComputedStyle(el), n = (k: string) => Math.round(parseFloat(cs.getPropertyValue(k)) || 0);
|
|
172
|
-
const next = { pt: n("padding-top"), pb: n("padding-bottom"), mt: n("margin-top"), mb: n("margin-bottom") };
|
|
173
|
-
setPx((p) => (
|
|
190
|
+
const next = { pt: n("padding-top"), pb: n("padding-bottom"), pl: n("padding-left"), pr: n("padding-right"), mt: n("margin-top"), mb: n("margin-bottom"), ml: n("margin-left"), mr: n("margin-right") };
|
|
191
|
+
setPx((p) => (JSON.stringify(p) === JSON.stringify(next) ? p : next));
|
|
174
192
|
});
|
|
175
|
-
const start = (kind: "padding" | "margin", side:
|
|
193
|
+
const start = (kind: "padding" | "margin", side: Side, e: React.PointerEvent) => {
|
|
176
194
|
e.preventDefault();
|
|
177
195
|
e.stopPropagation();
|
|
178
196
|
const handle = e.currentTarget as HTMLElement;
|
|
179
197
|
const el = ui.blockEl(blockId);
|
|
180
198
|
if (!el) return;
|
|
199
|
+
const horizontal = side === "left" || side === "right";
|
|
181
200
|
const startPx = parseFloat(el.ownerDocument.defaultView!.getComputedStyle(el).getPropertyValue(`${kind}-${side}`)) || 0;
|
|
182
|
-
const
|
|
201
|
+
const p0 = horizontal ? e.clientX : e.clientY;
|
|
183
202
|
const device = ui.device === "desktop" ? "base" : ui.device;
|
|
184
203
|
handle.setPointerCapture(e.pointerId);
|
|
185
204
|
handle.classList.add("is-dragging");
|
|
186
205
|
const move = (ev: PointerEvent) => {
|
|
187
|
-
//
|
|
188
|
-
const d = ev.clientY -
|
|
189
|
-
const
|
|
206
|
+
// Cạnh dưới / phải: kéo ra xa (xuống / sang phải) là tăng; đệm cạnh trên / trái: kéo vào trong tăng; lề trên / trái: kéo ra ngoài (lên / sang trái) tăng
|
|
207
|
+
const d = (horizontal ? ev.clientX : ev.clientY) - p0;
|
|
208
|
+
const outward = side === "top" || side === "left";
|
|
209
|
+
const px = Math.max(0, Math.round(startPx + (kind === "margin" && outward ? -d : d) * (kind === "padding" && side === "right" ? -1 : 1)));
|
|
190
210
|
const node = store.block(blockId);
|
|
191
211
|
if (!node) return;
|
|
192
212
|
const style = (normalizeStyle(node.attrs.style) ?? {}) as BlockStyle & Record<"padding" | "margin", Record<string, unknown> | undefined>;
|
|
@@ -196,19 +216,28 @@ export function PaddingHandles({ blockId }: { blockId: string }) {
|
|
|
196
216
|
store.setAttrs([blockId], { style: normalizeStyle({ ...style, [kind]: { ...(style[kind] ?? {}), [device]: sides } }) ?? undefined });
|
|
197
217
|
requestAnimationFrame(() => showSpacingViz(ui.blockEl(blockId), kind, [side]));
|
|
198
218
|
};
|
|
219
|
+
// Nghe ở cả tài liệu khung soạn (không dựa vào pointer capture): tay nắm dịch chỗ khi giá trị đổi (cạnh phải / dưới) làm capture mất giữa chừng
|
|
220
|
+
const doc = el.ownerDocument;
|
|
199
221
|
const up = () => {
|
|
200
|
-
|
|
222
|
+
doc.removeEventListener("pointermove", move, true); doc.removeEventListener("pointerup", up, true); doc.removeEventListener("pointercancel", up, true);
|
|
201
223
|
handle.classList.remove("is-dragging"); hideSpacingViz(ui.canvasDoc); store.breakMerge(); focusCanvas(handle);
|
|
202
224
|
};
|
|
203
|
-
|
|
204
|
-
|
|
225
|
+
doc.addEventListener("pointermove", move, true);
|
|
226
|
+
doc.addEventListener("pointerup", up, true);
|
|
227
|
+
doc.addEventListener("pointercancel", up, true);
|
|
205
228
|
};
|
|
229
|
+
const w = (n: number) => Math.max(8, n);
|
|
206
230
|
const zones = [
|
|
207
|
-
["padding", "top", { top: 0, height:
|
|
208
|
-
["padding", "bottom", { bottom: 0, height:
|
|
209
|
-
["margin", "top", { top: -
|
|
210
|
-
["margin", "bottom", { bottom: -
|
|
211
|
-
|
|
231
|
+
["padding", "top", { top: 0, height: w(px.pt) }],
|
|
232
|
+
["padding", "bottom", { bottom: 0, height: w(px.pb) }],
|
|
233
|
+
["margin", "top", { top: -w(px.mt), height: w(px.mt) }],
|
|
234
|
+
["margin", "bottom", { bottom: -w(px.mb), height: w(px.mb) }],
|
|
235
|
+
// Hai cạnh ngang chỉ có tay nắm khi giá trị đã > 0 (dải rộng đúng bằng nó, nằm trong vùng đệm / lề) — không phủ lên chữ hay khối bên cạnh
|
|
236
|
+
...(px.pl > 0 ? [["padding", "left", { left: 0, width: px.pl }]] : []),
|
|
237
|
+
...(px.pr > 0 ? [["padding", "right", { right: 0, width: px.pr }]] : []),
|
|
238
|
+
...(px.ml > 0 ? [["margin", "left", { left: -px.ml, width: px.ml }]] : []),
|
|
239
|
+
...(px.mr > 0 ? [["margin", "right", { right: -px.mr, width: px.mr }]] : []),
|
|
240
|
+
] as ReadonlyArray<readonly ["padding" | "margin", Side, React.CSSProperties]>;
|
|
212
241
|
return (
|
|
213
242
|
<span ref={ref} className="ecx-pad-handles" contentEditable={false} aria-hidden="true">
|
|
214
243
|
{zones.map(([kind, side, pos]) => (
|
|
@@ -268,6 +297,8 @@ export function ContentWidthHandles({ blockId }: { blockId: string }) {
|
|
|
268
297
|
if (!box) return null;
|
|
269
298
|
return (
|
|
270
299
|
<span className="ecx-cw-handles" contentEditable={false} aria-hidden="true">
|
|
300
|
+
{/* Vùng nội dung hiện rõ giữa hai tay: nội dung canh giữa (chữ, logo) co lại đối xứng nên nhìn như đứng yên — khung này cho thấy độ rộng đang đổi */}
|
|
301
|
+
<span className={`ecx-cw-guide${drag !== null ? " is-dragging" : ""}`} style={{ left: box.left, width: box.right - box.left }} />
|
|
271
302
|
{([["left", box.left, -1], ["right", box.right, 1]] as const).map(([side, x, dir]) => (
|
|
272
303
|
<span key={side} className={`ecx-cw-handle is-${side}`} style={{ left: x }} data-ecx-zone={`content-width-${side}`}
|
|
273
304
|
onPointerDown={(e) => start(dir === 1 ? 1 : -1, e)} onMouseDown={(e) => e.stopPropagation()}>
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
// Bản sao của sdk/packages/theme-sdk/src/social-icons.ts (website vẽ cùng biểu tượng) — sửa một nơi thì sửa cả nơi kia.
|
|
2
|
+
/**
|
|
3
|
+
* Biểu tượng mạng xã hội (khối socialLinks): path SVG 24×24 trích từ simple-icons 16.33.0 (CC0-1.0, https://simpleicons.org).
|
|
4
|
+
* email, website, linkedin: biểu tượng chung tự vẽ. Sinh lại: lấy `.path` của gói simple-icons cùng tên.
|
|
5
|
+
*/
|
|
6
|
+
export const SOCIAL_ICONS: Record<string, string> = {
|
|
7
|
+
facebook: "M9.101 23.691v-7.98H6.627v-3.667h2.474v-1.58c0-4.085 1.848-5.978 5.858-5.978.401 0 .955.042 1.468.103a8.68 8.68 0 0 1 1.141.195v3.325a8.623 8.623 0 0 0-.653-.036 26.805 26.805 0 0 0-.733-.009c-.707 0-1.259.096-1.675.309a1.686 1.686 0 0 0-.679.622c-.258.42-.374.995-.374 1.752v1.297h3.919l-.386 2.103-.287 1.564h-3.246v8.245C19.396 23.238 24 18.179 24 12.044c0-6.627-5.373-12-12-12s-12 5.373-12 12c0 5.628 3.874 10.35 9.101 11.647Z",
|
|
8
|
+
x: "M14.234 10.162 22.977 0h-2.072l-7.591 8.824L7.251 0H.258l9.168 13.343L.258 24H2.33l8.016-9.318L16.749 24h6.993zm-2.837 3.299-.929-1.329L3.076 1.56h3.182l5.965 8.532.929 1.329 7.754 11.09h-3.182z",
|
|
9
|
+
twitter: "M14.234 10.162 22.977 0h-2.072l-7.591 8.824L7.251 0H.258l9.168 13.343L.258 24H2.33l8.016-9.318L16.749 24h6.993zm-2.837 3.299-.929-1.329L3.076 1.56h3.182l5.965 8.532.929 1.329 7.754 11.09h-3.182z",
|
|
10
|
+
instagram: "M7.0301.084c-1.2768.0602-2.1487.264-2.911.5634-.7888.3075-1.4575.72-2.1228 1.3877-.6652.6677-1.075 1.3368-1.3802 2.127-.2954.7638-.4956 1.6365-.552 2.914-.0564 1.2775-.0689 1.6882-.0626 4.947.0062 3.2586.0206 3.6671.0825 4.9473.061 1.2765.264 2.1482.5635 2.9107.308.7889.72 1.4573 1.388 2.1228.6679.6655 1.3365 1.0743 2.1285 1.38.7632.295 1.6361.4961 2.9134.552 1.2773.056 1.6884.069 4.9462.0627 3.2578-.0062 3.668-.0207 4.9478-.0814 1.28-.0607 2.147-.2652 2.9098-.5633.7889-.3086 1.4578-.72 2.1228-1.3881.665-.6682 1.0745-1.3378 1.3795-2.1284.2957-.7632.4966-1.636.552-2.9124.056-1.2809.0692-1.6898.063-4.948-.0063-3.2583-.021-3.6668-.0817-4.9465-.0607-1.2797-.264-2.1487-.5633-2.9117-.3084-.7889-.72-1.4568-1.3876-2.1228C21.2982 1.33 20.628.9208 19.8378.6165 19.074.321 18.2017.1197 16.9244.0645 15.6471.0093 15.236-.005 11.977.0014 8.718.0076 8.31.0215 7.0301.0839m.1402 21.6932c-1.17-.0509-1.8053-.2453-2.2287-.408-.5606-.216-.96-.4771-1.3819-.895-.422-.4178-.6811-.8186-.9-1.378-.1644-.4234-.3624-1.058-.4171-2.228-.0595-1.2645-.072-1.6442-.079-4.848-.007-3.2037.0053-3.583.0607-4.848.05-1.169.2456-1.805.408-2.2282.216-.5613.4762-.96.895-1.3816.4188-.4217.8184-.6814 1.3783-.9003.423-.1651 1.0575-.3614 2.227-.4171 1.2655-.06 1.6447-.072 4.848-.079 3.2033-.007 3.5835.005 4.8495.0608 1.169.0508 1.8053.2445 2.228.408.5608.216.96.4754 1.3816.895.4217.4194.6816.8176.9005 1.3787.1653.4217.3617 1.056.4169 2.2263.0602 1.2655.0739 1.645.0796 4.848.0058 3.203-.0055 3.5834-.061 4.848-.051 1.17-.245 1.8055-.408 2.2294-.216.5604-.4763.96-.8954 1.3814-.419.4215-.8181.6811-1.3783.9-.4224.1649-1.0577.3617-2.2262.4174-1.2656.0595-1.6448.072-4.8493.079-3.2045.007-3.5825-.006-4.848-.0608M16.953 5.5864A1.44 1.44 0 1 0 18.39 4.144a1.44 1.44 0 0 0-1.437 1.4424M5.8385 12.012c.0067 3.4032 2.7706 6.1557 6.173 6.1493 3.4026-.0065 6.157-2.7701 6.1506-6.1733-.0065-3.4032-2.771-6.1565-6.174-6.1498-3.403.0067-6.156 2.771-6.1496 6.1738M8 12.0077a4 4 0 1 1 4.008 3.9921A3.9996 3.9996 0 0 1 8 12.0077",
|
|
11
|
+
youtube: "M23.498 6.186a3.016 3.016 0 0 0-2.122-2.136C19.505 3.545 12 3.545 12 3.545s-7.505 0-9.377.505A3.017 3.017 0 0 0 .502 6.186C0 8.07 0 12 0 12s0 3.93.502 5.814a3.016 3.016 0 0 0 2.122 2.136c1.871.505 9.376.505 9.376.505s7.505 0 9.377-.505a3.015 3.015 0 0 0 2.122-2.136C24 15.93 24 12 24 12s0-3.93-.502-5.814zM9.545 15.568V8.432L15.818 12l-6.273 3.568z",
|
|
12
|
+
tiktok: "M12.525.02c1.31-.02 2.61-.01 3.91-.02.08 1.53.63 3.09 1.75 4.17 1.12 1.11 2.7 1.62 4.24 1.79v4.03c-1.44-.05-2.89-.35-4.2-.97-.57-.26-1.1-.59-1.62-.93-.01 2.92.01 5.84-.02 8.75-.08 1.4-.54 2.79-1.35 3.94-1.31 1.92-3.58 3.17-5.91 3.21-1.43.08-2.86-.31-4.08-1.03-2.02-1.19-3.44-3.37-3.65-5.71-.02-.5-.03-1-.01-1.49.18-1.9 1.12-3.72 2.58-4.96 1.66-1.44 3.98-2.13 6.15-1.72.02 1.48-.04 2.96-.04 4.44-.99-.32-2.15-.23-3.02.37-.63.41-1.11 1.04-1.36 1.75-.21.51-.15 1.07-.14 1.61.24 1.64 1.82 3.02 3.5 2.87 1.12-.01 2.19-.66 2.77-1.61.19-.33.4-.67.41-1.06.1-1.79.06-3.57.07-5.36.01-4.03-.01-8.05.02-12.07z",
|
|
13
|
+
zalo: "M12.49 10.2722v-.4496h1.3467v6.3218h-.7704a.576.576 0 01-.5763-.5729l-.0006.0005a3.273 3.273 0 01-1.9372.6321c-1.8138 0-3.2844-1.4697-3.2844-3.2823 0-1.8125 1.4706-3.2822 3.2844-3.2822a3.273 3.273 0 011.9372.6321l.0006.0005zM6.9188 7.7896v.205c0 .3823-.051.6944-.2995 1.0605l-.03.0343c-.0542.0615-.1815.206-.2421.2843L2.024 14.8h4.8948v.7682a.5764.5764 0 01-.5767.5761H0v-.3622c0-.4436.1102-.6414.2495-.8476L4.8582 9.23H.1922V7.7896h6.7266zm8.5513 8.3548a.4805.4805 0 01-.4803-.4798v-7.875h1.4416v8.3548H15.47zM20.6934 9.6C22.52 9.6 24 11.0807 24 12.9044c0 1.8252-1.4801 3.306-3.3066 3.306-1.8264 0-3.3066-1.4808-3.3066-3.306 0-1.8237 1.4802-3.3044 3.3066-3.3044zm-10.1412 5.253c1.0675 0 1.9324-.8645 1.9324-1.9312 0-1.065-.865-1.9295-1.9324-1.9295s-1.9324.8644-1.9324 1.9295c0 1.0667.865 1.9312 1.9324 1.9312zm10.1412-.0033c1.0737 0 1.945-.8707 1.945-1.9453 0-1.073-.8713-1.9436-1.945-1.9436-1.0753 0-1.945.8706-1.945 1.9436 0 1.0746.8697 1.9453 1.945 1.9453z",
|
|
14
|
+
github: "M12 .297c-6.63 0-12 5.373-12 12 0 5.303 3.438 9.8 8.205 11.385.6.113.82-.258.82-.577 0-.285-.01-1.04-.015-2.04-3.338.724-4.042-1.61-4.042-1.61C4.422 18.07 3.633 17.7 3.633 17.7c-1.087-.744.084-.729.084-.729 1.205.084 1.838 1.236 1.838 1.236 1.07 1.835 2.809 1.305 3.495.998.108-.776.417-1.305.76-1.605-2.665-.3-5.466-1.332-5.466-5.93 0-1.31.465-2.38 1.235-3.22-.135-.303-.54-1.523.105-3.176 0 0 1.005-.322 3.3 1.23.96-.267 1.98-.399 3-.405 1.02.006 2.04.138 3 .405 2.28-1.552 3.285-1.23 3.285-1.23.645 1.653.24 2.873.12 3.176.765.84 1.23 1.91 1.23 3.22 0 4.61-2.805 5.625-5.475 5.92.42.36.81 1.096.81 2.22 0 1.606-.015 2.896-.015 3.286 0 .315.21.69.825.57C20.565 22.092 24 17.592 24 12.297c0-6.627-5.373-12-12-12",
|
|
15
|
+
threads: "M18.263 11.097c-.03-3.486-1.92-5.586-5.111-5.586-2.13 0-3.922.963-4.863 2.499l2.062 1.438c.535-.843 1.272-1.543 2.628-1.543 1.528 0 2.318.85 2.544 2.431a15 15 0 0 0-2.236-.173c-4.125 0-6.068 1.867-6.068 4.336s1.943 3.99 4.804 3.99c3.139 0 5.013-2.115 5.781-4.735.798.361 1.348 1.204 1.348 2.47 0 3.387-3.907 5.232-7.22 5.232-4.885 0-8.077-3.207-8.077-8.424 0-6.392 4.223-10.487 9.9-10.487 3.808 0 5.69 1.671 6.97 3.914l2.108-1.475C21.44 2.078 18.331 0 13.663 0 6.227 0 1.168 5.277 1.168 12.934c0 7 4.953 11.066 10.856 11.066 4.878 0 9.809-2.846 9.809-7.716 0-2.545-1.46-4.231-3.569-5.187m-6.33 4.855c-1.077 0-2.026-.512-2.026-1.453 0-1.483 1.822-1.934 3.606-1.934.678 0 1.34.045 1.927.173-.422 1.927-1.671 3.215-3.508 3.214Z",
|
|
16
|
+
pinterest: "M12.017 0C5.396 0 .029 5.367.029 11.987c0 5.079 3.158 9.417 7.618 11.162-.105-.949-.199-2.403.041-3.439.219-.937 1.406-5.957 1.406-5.957s-.359-.72-.359-1.781c0-1.663.967-2.911 2.168-2.911 1.024 0 1.518.769 1.518 1.688 0 1.029-.653 2.567-.992 3.992-.285 1.193.6 2.165 1.775 2.165 2.128 0 3.768-2.245 3.768-5.487 0-2.861-2.063-4.869-5.008-4.869-3.41 0-5.409 2.562-5.409 5.199 0 1.033.394 2.143.889 2.741.099.12.112.225.085.345-.09.375-.293 1.199-.334 1.363-.053.225-.172.271-.401.165-1.495-.69-2.433-2.878-2.433-4.646 0-3.776 2.748-7.252 7.92-7.252 4.158 0 7.392 2.967 7.392 6.923 0 4.135-2.607 7.462-6.233 7.462-1.214 0-2.354-.629-2.758-1.379l-.749 2.848c-.269 1.045-1.004 2.352-1.498 3.146 1.123.345 2.306.535 3.55.535 6.607 0 11.985-5.365 11.985-11.987C23.97 5.39 18.592.026 11.985.026L12.017 0z",
|
|
17
|
+
telegram: "M11.944 0A12 12 0 0 0 0 12a12 12 0 0 0 12 12 12 12 0 0 0 12-12A12 12 0 0 0 12 0a12 12 0 0 0-.056 0zm4.962 7.224c.1-.002.321.023.465.14a.506.506 0 0 1 .171.325c.016.093.036.306.02.472-.18 1.898-.962 6.502-1.36 8.627-.168.9-.499 1.201-.82 1.23-.696.065-1.225-.46-1.9-.902-1.056-.693-1.653-1.124-2.678-1.8-1.185-.78-.417-1.21.258-1.91.177-.184 3.247-2.977 3.307-3.23.007-.032.014-.15-.056-.212s-.174-.041-.249-.024c-.106.024-1.793 1.14-5.061 3.345-.48.33-.913.49-1.302.48-.428-.008-1.252-.241-1.865-.44-.752-.245-1.349-.374-1.297-.789.027-.216.325-.437.893-.663 3.498-1.524 5.83-2.529 6.998-3.014 3.332-1.386 4.025-1.627 4.476-1.635z",
|
|
18
|
+
messenger: "M12 0C5.24 0 0 4.952 0 11.64c0 3.499 1.434 6.521 3.769 8.61a.96.96 0 0 1 .323.683l.065 2.135a.96.96 0 0 0 1.347.85l2.381-1.053a.96.96 0 0 1 .641-.046A13 13 0 0 0 12 23.28c6.76 0 12-4.952 12-11.64S18.76 0 12 0m6.806 7.44c.522-.03.971.567.63 1.094l-4.178 6.457a.707.707 0 0 1-.977.208l-3.87-2.504a.44.44 0 0 0-.49.007l-4.363 3.01c-.637.438-1.415-.317-.995-.966l4.179-6.457a.706.706 0 0 1 .977-.21l3.87 2.505c.15.097.344.094.491-.007l4.362-3.008a.7.7 0 0 1 .364-.13",
|
|
19
|
+
linkedin: "M4 3h16a1 1 0 0 1 1 1v16a1 1 0 0 1-1 1H4a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1Zm3 7v8h2.5v-8H7Zm1.25-1.25a1.4 1.4 0 1 0 0-2.8 1.4 1.4 0 0 0 0 2.8ZM11 10v8h2.5v-4.2c0-1.1.7-1.8 1.6-1.8.9 0 1.4.7 1.4 1.8V18H19v-4.8c0-2.2-1.2-3.4-3-3.4-1.1 0-1.9.5-2.5 1.2V10H11Z",
|
|
20
|
+
email: "M3 5h18a1 1 0 0 1 1 1v12a1 1 0 0 1-1 1H3a1 1 0 0 1-1-1V6a1 1 0 0 1 1-1Zm1 2.4V17h16V7.4l-8 5.3-8-5.3ZM5.8 7 12 11.1 18.2 7H5.8Z",
|
|
21
|
+
website: "M12 2a10 10 0 1 1 0 20 10 10 0 0 1 0-20Zm-1.6 2.2A8 8 0 0 0 4.06 11h3.98c.13-2.5.95-4.98 2.36-6.8Zm3.2 0c1.41 1.82 2.23 4.3 2.36 6.8h3.98a8 8 0 0 0-6.34-6.8ZM12 4.6c-1.3 1.6-2.1 3.9-2.24 6.4h4.48C14.1 8.5 13.3 6.2 12 4.6ZM4.06 13a8 8 0 0 0 6.34 6.8c-1.41-1.82-2.23-4.3-2.36-6.8H4.06Zm5.7 0c.14 2.5.94 4.8 2.24 6.4 1.3-1.6 2.1-3.9 2.24-6.4H9.76Zm6.2 0c-.13 2.5-.95 4.98-2.36 6.8a8 8 0 0 0 6.34-6.8h-3.98Z",
|
|
22
|
+
};
|
package/src/v2/blocks/text.tsx
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { blockCitation, blockShell , typedConfig } from "@ecomcx/ecomweb-content";
|
|
2
|
+
import { Heading1, Heading2, Heading3, Heading4, Heading5, Heading6, List, ListOrdered, Pilcrow, Quote, SquareCode, Type } from "lucide-react";
|
|
3
3
|
import type { CSSProperties } from "react";
|
|
4
4
|
import { InnerBlocks } from "../canvas/block-list";
|
|
5
5
|
import { inlineText, makeBlock, type BNode } from "../core/model";
|
|
@@ -29,16 +29,17 @@ function ParagraphEdit({ block, blockProps, editable }: BlockEditProps) {
|
|
|
29
29
|
if (bound.bound) return <BoundText tagName="p" preview={bound} blockProps={blockProps} style={align(block.attrs)} />;
|
|
30
30
|
// Gợi ý theo vai trò: mục danh sách / việc khác đoạn văn thường
|
|
31
31
|
const parent = store.locate(block.id)?.parent?.type;
|
|
32
|
-
const ph = parent === "listItem" ? tp.listItem :
|
|
32
|
+
const ph = parent === "listItem" ? tp.listItem : tp.paragraph;
|
|
33
33
|
return <RichText blockId={block.id} value={block.inline} tagName="p" blockProps={{ ...blockProps, title: iconProps(block.attrs).title }} className={iconProps(block.attrs).className} style={align(block.attrs)} placeholder={ph} placeholderAlways editable={editable} />;
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
function HeadingEdit({ block, blockProps, editable }: BlockEditProps) {
|
|
37
37
|
const tp = useMsgs("placeholders");
|
|
38
38
|
const level = Math.min(6, Math.max(1, Number(block.attrs.level) || 2));
|
|
39
|
+
const tag = block.attrs.htmlTag === "p" || block.attrs.htmlTag === "span" || block.attrs.htmlTag === "div" ? block.attrs.htmlTag : `h${level}`;
|
|
39
40
|
const bound = useBindingPreview(block, "content");
|
|
40
|
-
if (bound.bound) return <BoundText tagName={
|
|
41
|
-
return <RichText blockId={block.id} value={block.inline} tagName={
|
|
41
|
+
if (bound.bound) return <BoundText tagName={tag} preview={bound} blockProps={blockProps} style={align(block.attrs, "heading")} />;
|
|
42
|
+
return <RichText blockId={block.id} value={block.inline} tagName={tag} blockProps={{ ...blockProps, title: iconProps(block.attrs, "heading").title, ...(typedConfig(block.attrs) ? { "data-ecx-typed": typedConfig(block.attrs)!.words[0] } : {}) } as typeof blockProps} className={iconProps(block.attrs, "heading").className} style={align(block.attrs, "heading")} placeholder={tp.heading} placeholderAlways editable={editable} />;
|
|
42
43
|
}
|
|
43
44
|
|
|
44
45
|
const CODE_LANGS = ["html", "css", "javascript", "typescript", "json", "bash", "python", "php", "sql", "csharp", "yaml", "markdown"];
|
|
@@ -63,24 +64,6 @@ function CodeEdit({ block, blockProps, editable, setAttrs }: BlockEditProps) {
|
|
|
63
64
|
);
|
|
64
65
|
}
|
|
65
66
|
|
|
66
|
-
function PreformattedEdit({ block, blockProps, editable }: BlockEditProps) {
|
|
67
|
-
const tp = useMsgs("placeholders");
|
|
68
|
-
return <RichText blockId={block.id} value={block.inline} tagName="pre" className="ecx-pre" blockProps={blockProps} breakOnEnter placeholder={tp.preformatted} placeholderAlways editable={editable} />;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
function PullquoteEdit({ block, blockProps, editable, setAttrs }: BlockEditProps) {
|
|
72
|
-
const tp = useMsgs("placeholders");
|
|
73
|
-
const cite = blockCitation(block.attrs) ?? "";
|
|
74
|
-
const sh = blockShell("pullquote", block.attrs)!;
|
|
75
|
-
return (
|
|
76
|
-
<figure {...blockProps} className={`${blockProps.className} ${sh.className}`}>
|
|
77
|
-
<blockquote><RichText blockId={block.id} value={block.inline} tagName="p" placeholder={tp.quote} placeholderAlways editable={editable} /></blockquote>
|
|
78
|
-
{/* website chỉ in nguồn khi có chữ: trình soạn luôn có ô người nói để thấy chỗ gõ */}
|
|
79
|
-
{(cite || editable) && <RichText blockId={block.id} field="citation" tagName="figcaption" value={cite} onChange={(v) => setAttrs({ citation: v })} placeholder={tp.speaker} placeholderAlways editable={editable} />}
|
|
80
|
-
</figure>
|
|
81
|
-
);
|
|
82
|
-
}
|
|
83
|
-
|
|
84
67
|
function ListEdit({ block, blockProps, setAttrs, editable }: BlockEditProps) {
|
|
85
68
|
const Tag = block.type === "orderedList" ? "ol" : "ul";
|
|
86
69
|
const start = Number(block.attrs.start);
|
|
@@ -103,15 +86,6 @@ function ListItemEdit({ block, blockProps }: BlockEditProps) {
|
|
|
103
86
|
return <li {...(blockProps as object)}><InnerBlocks parent={block} appender="none" /></li>;
|
|
104
87
|
}
|
|
105
88
|
|
|
106
|
-
function TaskItemEdit({ block, blockProps, setAttrs, editable }: BlockEditProps) {
|
|
107
|
-
return (
|
|
108
|
-
<li {...(blockProps as object)} className={`${blockProps.className} ecx-task-item task-item`}>
|
|
109
|
-
<input type="checkbox" checked={!!block.attrs.checked} disabled={!editable} onChange={(e) => setAttrs({ checked: e.target.checked || undefined })} contentEditable={false} />{" "}
|
|
110
|
-
<InnerBlocks parent={block} appender="none" />
|
|
111
|
-
</li>
|
|
112
|
-
);
|
|
113
|
-
}
|
|
114
|
-
|
|
115
89
|
function QuoteEdit({ block, blockProps, editable, setAttrs }: BlockEditProps) {
|
|
116
90
|
const cite = blockCitation(block.attrs);
|
|
117
91
|
const tp = useMsgs("placeholders");
|
|
@@ -148,12 +122,14 @@ export function textBlocks(): BlockType[] {
|
|
|
148
122
|
return [
|
|
149
123
|
{
|
|
150
124
|
name: "paragraph", title: "Đoạn văn", icon: Pilcrow, category: "text", keywords: "doan van text paragraph p", kind: "text", edit: ParagraphEdit,
|
|
151
|
-
attributes: { textAlign: { type: "string", enum: ["left", "center", "right", "justify"] }, icon: { type: "string"
|
|
125
|
+
attributes: { textAlign: { type: "string", enum: ["left", "center", "right", "justify"] }, icon: { type: "string" }, iconPosition: { type: "string", enum: ["left", "right"], default: "left" }, iconTitle: { type: "string" } },
|
|
152
126
|
supports: { style: true, anchor: true, className: true }, transforms: textTransforms("paragraph"),
|
|
153
127
|
},
|
|
154
128
|
{
|
|
155
129
|
name: "heading", title: "Tiêu đề", icon: Heading2, category: "text", keywords: "tieu de heading h1 h2 h3 h4", kind: "text", edit: HeadingEdit,
|
|
156
|
-
attributes: { level: { type: "integer", default: 2, min: 1, max: 6 }, textAlign: { type: "string", enum: ["left", "center", "right", "justify"] }, icon: { type: "string"
|
|
130
|
+
attributes: { htmlTag: { type: "string", enum: ["p", "span", "div"] }, level: { type: "integer", default: 2, min: 1, max: 6 }, textAlign: { type: "string", enum: ["left", "center", "right", "justify"] }, icon: { type: "string" }, iconPosition: { type: "string", enum: ["left", "right"], default: "left" }, iconTitle: { type: "string" }, tocTitle: { type: "string" },
|
|
131
|
+
href: { type: "url" }, linkTarget: { type: "string", enum: ["_self", "_blank"] }, linkRel: { type: "string" },
|
|
132
|
+
typedWords: { type: "string" }, typedSpeed: { type: "integer", default: 80, min: 30, max: 200 }, typedPause: { type: "integer", default: 1800, min: 600, max: 6000 }, typedLoop: { type: "boolean", default: true } },
|
|
157
133
|
create: (attrs) => makeBlock("heading", { level: 2, ...attrs }),
|
|
158
134
|
variations: [1, 2, 3, 4, 5, 6].map((level) => ({ name: `h${level}`, title: `H${level}`, icon: HEADING_ICONS[level], keywords: `h${level}`, attrs: { level }, isActive: (a) => Number(a.level) === level })),
|
|
159
135
|
supports: { style: true, anchor: true, className: true }, transforms: textTransforms("heading"),
|
|
@@ -171,31 +147,17 @@ export function textBlocks(): BlockType[] {
|
|
|
171
147
|
supports: { style: true, anchor: true, className: true }, transforms: textTransforms("orderedList"),
|
|
172
148
|
},
|
|
173
149
|
{ name: "listItem", title: "Mục danh sách", icon: List, kind: "container", edit: ListItemEdit, hidden: true },
|
|
174
|
-
{
|
|
175
|
-
name: "taskList", title: "Danh sách việc", icon: ListChecks, category: "text", keywords: "viec can lam todo task checklist", kind: "container", edit: ListEdit,
|
|
176
|
-
create: () => makeBlock("taskList", {}, [makeBlock("taskItem", { checked: false }, [makeBlock("paragraph")])]),
|
|
177
|
-
},
|
|
178
|
-
{ name: "taskItem", title: "Việc", icon: ListChecks, kind: "container", edit: TaskItemEdit, hidden: true, attributes: { checked: { type: "boolean", default: false } } },
|
|
179
150
|
{
|
|
180
151
|
name: "blockquote", title: "Trích dẫn", icon: Quote, category: "text", keywords: "trich dan quote blockquote", kind: "container", edit: QuoteEdit,
|
|
181
152
|
attributes: { citation: { type: "string" } },
|
|
182
153
|
create: () => makeBlock("blockquote", {}, [makeBlock("paragraph")]),
|
|
183
154
|
supports: { style: true, anchor: true, className: true, blockStyle: true },
|
|
184
|
-
transforms: [{ to: "paragraph", convert: toTextBlocks("paragraph"), multiple: true }
|
|
155
|
+
transforms: [{ to: "paragraph", convert: toTextBlocks("paragraph"), multiple: true }],
|
|
185
156
|
},
|
|
186
157
|
{
|
|
187
158
|
name: "codeBlock", title: "Mã nguồn", icon: SquareCode, category: "text", keywords: "ma code nguon", kind: "text", edit: CodeEdit, multiline: true, plain: true,
|
|
188
159
|
attributes: { language: { type: "string" } }, // nhãn lấy từ locales/*/attrs.ts (language) theo ngôn ngữ đang dùng
|
|
189
|
-
transforms: [{ to: "paragraph", convert: (b) => textsOf(b).map((i) => makeBlock("paragraph", {}, inlineText(i))) }
|
|
190
|
-
},
|
|
191
|
-
{
|
|
192
|
-
name: "preformatted", title: "Định dạng sẵn", icon: Code, category: "text", keywords: "dinh dang san preformatted pre khoang trang", kind: "text", edit: PreformattedEdit,
|
|
193
|
-
supports: { style: true, anchor: true, className: true }, transforms: textTransforms("preformatted"),
|
|
194
|
-
},
|
|
195
|
-
{
|
|
196
|
-
name: "pullquote", title: "Trích dẫn nổi bật", icon: TextQuote, category: "text", keywords: "trich dan noi bat pullquote", kind: "text", edit: PullquoteEdit,
|
|
197
|
-
attributes: { citation: { type: "string" } }, supports: { style: true, anchor: true, className: true },
|
|
198
|
-
transforms: [{ to: "blockquote", convert: toQuote }, { to: "paragraph", convert: toTextBlocks("paragraph") }],
|
|
160
|
+
transforms: [{ to: "paragraph", convert: (b) => textsOf(b).map((i) => makeBlock("paragraph", {}, inlineText(i))) }],
|
|
199
161
|
},
|
|
200
162
|
];
|
|
201
163
|
}
|
package/src/v2/blocks/theme.tsx
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
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 {
|
|
3
|
+
import { SEARCH_ICON_PATH, resolveIcon, spacingValue } from "@ecomcx/ecomweb-content";
|
|
4
|
+
import { IconSvg } from "../ui/icon-svg";
|
|
4
5
|
import { useChoices } from "../ui/attr-form";
|
|
5
6
|
import { Block, DocBlocks, InnerBlocks, NestedDoc } from "../canvas/block-list";
|
|
6
7
|
import { DocScopeProvider, LoopPostContext, useDocScope, useDynamicData, useEditor, useEditorState } from "../context";
|
|
@@ -212,18 +213,10 @@ function LoginOutEdit({ block, blockProps }: BlockEditProps) {
|
|
|
212
213
|
}
|
|
213
214
|
function IconEdit({ block, blockProps }: BlockEditProps) {
|
|
214
215
|
const size = Math.min(128, Math.max(12, Number(block.attrs.size) || 24));
|
|
215
|
-
const path = ICON_PATHS[String(block.attrs.name ?? "star")] ?? ICON_PATHS.star;
|
|
216
216
|
const stroke = Math.min(4, Math.max(0.5, Number(block.attrs.stroke) || 2));
|
|
217
217
|
const shape = block.attrs.iconStyle === "circle" || block.attrs.iconStyle === "square" ? block.attrs.iconStyle : undefined;
|
|
218
|
-
return <div {...merge(blockProps, "ecx-icon-block", align(block.attrs))}><span className={`ecx-icon-shape${shape ? ` is-${shape}` : ""}`} style={shape ? {
|
|
219
|
-
}
|
|
220
|
-
function FootnotesEdit({ block, blockProps }: BlockEditProps) {
|
|
221
|
-
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>;
|
|
222
|
-
}
|
|
223
|
-
function PageBreakEdit({ blockProps }: BlockEditProps) {
|
|
224
|
-
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>;
|
|
225
|
-
}
|
|
226
|
-
function PageListEdit({ blockProps }: BlockEditProps) {
|
|
218
|
+
return <div {...merge(blockProps, "ecx-icon-block", align(block.attrs))}><span className={`ecx-icon-shape${shape ? ` is-${shape}` : ""}`} data-ecx-tip={typeof block.attrs.tooltip === "string" && block.attrs.tooltip.trim() ? block.attrs.tooltip.trim().slice(0, 120) : undefined} style={shape ? ({ "--ecx-icon-pad-auto": `${Math.round(size * 0.4)}px` } as CSSProperties) : undefined}><IconSvg name={resolveIcon(block.attrs.name) ? block.attrs.name : "star"} size={size} stroke={stroke} /></span></div>;
|
|
219
|
+
}function PageListEdit({ blockProps }: BlockEditProps) {
|
|
227
220
|
return <nav {...merge(blockProps, "ecx-page-list")}><ul><li>Trang A<ul><li>Trang con</li></ul></li><li>Trang B</li></ul></nav>;
|
|
228
221
|
}
|
|
229
222
|
function ArchivesEdit({ block, blockProps }: BlockEditProps) {
|
|
@@ -434,16 +427,19 @@ function PaginationEdit({ block, blockProps }: BlockEditProps) {
|
|
|
434
427
|
function QueryFilterEdit({ block, blockProps }: BlockEditProps) {
|
|
435
428
|
const t = useMsgs("blocks");
|
|
436
429
|
const a = block.attrs;
|
|
437
|
-
const style = ["none", "links", "chips", "select"].includes(String(a.termStyle)) ? String(a.termStyle) : "links";
|
|
430
|
+
const style = ["none", "links", "chips", "select", "checks"].includes(String(a.termStyle)) ? String(a.termStyle) : "links";
|
|
438
431
|
const choices = useChoices("term", { taxonomy: String(a.taxonomy ?? "") });
|
|
439
432
|
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
433
|
return (
|
|
441
434
|
<div {...merge(blockProps, "ecx-query-filter")}>
|
|
442
435
|
{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>}
|
|
436
|
+
{(style === "links" || style === "chips" || style === "checks") && <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
437
|
{a.showSearch === true && <input type="search" readOnly tabIndex={-1} placeholder={String(a.placeholder || t.filterSearch)} />}
|
|
445
438
|
{a.showSort === true && <select tabIndex={-1} aria-label={t.filterSort}><option>{t.filterNewest}</option></select>}
|
|
446
|
-
{
|
|
439
|
+
{a.showRange === true && <span className="ecx-filter-range"><input type="number" readOnly tabIndex={-1} placeholder="Từ" /> – <input type="number" readOnly tabIndex={-1} placeholder="Đến" /></span>}
|
|
440
|
+
{a.showYear === true && <select tabIndex={-1} aria-label={t.filterYear}><option>{t.filterYear}</option></select>}
|
|
441
|
+
{a.showReset === true && <a className="ecx-filter-reset">{t.filterReset}</a>}
|
|
442
|
+
{style === "none" && !a.showSearch && !a.showSort && !a.showYear && !a.showReset && <span className="ecx-muted">{t.filterEmpty}</span>}
|
|
447
443
|
</div>
|
|
448
444
|
);
|
|
449
445
|
}
|
|
@@ -514,9 +510,7 @@ export function themeBlocks(): BlockType[] {
|
|
|
514
510
|
{ 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"] } },
|
|
515
511
|
{ 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 },
|
|
516
512
|
{ 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 } },
|
|
517
|
-
{ name: "icon", title: "Icon", icon: Star, category: theme, keywords: "icon bieu tuong", kind: "atom", edit: IconEdit, attributes: {
|
|
518
|
-
{ 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 } },
|
|
519
|
-
{ name: "pageBreak", title: "Ngắt trang", icon: PanelTop, category: theme, keywords: "ngat trang page break nextpage", kind: "atom", edit: PageBreakEdit, supports: { className: true } },
|
|
513
|
+
{ name: "icon", title: "Icon", icon: Star, category: theme, keywords: "icon bieu tuong", kind: "atom", edit: IconEdit, attributes: { tooltip: { type: "string" }, name: { type: "string", default: "star" }, size: { type: "integer", default: 24, min: 12, max: 128 }, label: { type: "string" }, textAlign: TEXT_ALIGN, stroke: { type: "number", default: 2, min: 0.5, max: 4 }, iconStyle: { type: "string", enum: ["plain", "circle", "square"], default: "plain" }, href: { type: "url" }, linkTarget: { type: "string", enum: ["_self", "_blank"] } }, supports: { style: true, className: true }, summary: (a) => a.name },
|
|
520
514
|
{ 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 } },
|
|
521
515
|
{ 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 } },
|
|
522
516
|
{ 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 } },
|
|
@@ -525,14 +519,14 @@ export function themeBlocks(): BlockType[] {
|
|
|
525
519
|
{ 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 } },
|
|
526
520
|
{
|
|
527
521
|
name: "query", title: "Danh sách bài", icon: Rows3, category: theme, keywords: "danh sach bai query loop tin tuc", kind: "container", edit: QueryEdit,
|
|
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" },
|
|
522
|
+
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" }, 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 } },
|
|
529
523
|
// 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)
|
|
530
524
|
create: () => makeBlock("query", { inherit: true }, []),
|
|
531
525
|
supports: { style: true, className: true },
|
|
532
526
|
},
|
|
533
527
|
{ 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"] } },
|
|
534
528
|
{ 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 } },
|
|
529
|
+
{ 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", "checks"], default: "links" }, showRange: { type: "boolean", default: false }, rangeParam: { type: "string" }, rangeLabel: { type: "string" }, rangeMax: { type: "number" }, allLabel: { type: "string" }, showSearch: { type: "boolean", default: false }, showSort: { type: "boolean", default: false }, showYear: { type: "boolean", default: false }, showReset: { type: "boolean", default: false }, sortOptions: { type: "string" }, placeholder: { type: "string" }, submitText: { type: "string" }, action: { type: "string" } }, supports: { style: true, className: true, align: true } },
|
|
536
530
|
{ name: "queryEmpty", title: "Khi không có bài", icon: SquareDashed, kind: "container", edit: QueryEmptyEdit, hidden: true, structure: { parents: ["query"] } },
|
|
537
531
|
{ 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 },
|
|
538
532
|
{ 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 },
|
package/src/v2/blocks/tools.tsx
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
|
-
import { AlignCenter, AlignCenterHorizontal, AlignEndHorizontal, AlignHorizontalSpaceBetween, AlignLeft, AlignRight, AlignStartHorizontal, Link2, StretchHorizontal, Columns2, Minus, Plus, Table2, ArrowUpToLine, ArrowDownToLine, ArrowLeftToLine, ArrowRightToLine, Trash2, Heading, TableCellsMerge, TableCellsSplit } from "lucide-react";
|
|
1
|
+
import { Star, AlignCenter, AlignCenterHorizontal, AlignEndHorizontal, AlignHorizontalSpaceBetween, AlignLeft, AlignRight, AlignStartHorizontal, Link2, StretchHorizontal, Columns2, Minus, Plus, Table2, ArrowUpToLine, ArrowDownToLine, ArrowLeftToLine, ArrowRightToLine, Trash2, Heading, TableCellsMerge, TableCellsSplit } from "lucide-react";
|
|
2
2
|
import { useEditor } from "../context";
|
|
3
3
|
import { makeBlock, type BNode } from "../core/model";
|
|
4
4
|
import { addColumn, addRow, canMerge, canSplit, deleteColumn, deleteRow, hasHeaderRow, mergeCells, splitCell, tableContext, toggleHeaderRow } from "../core/tables";
|
|
5
5
|
import { Dropdown, MenuItem, ToolButton } from "../ui/toolbar";
|
|
6
6
|
import { useState } from "react";
|
|
7
7
|
import { useMsgs } from "../i18n";
|
|
8
|
-
import { isSafeUrl } from "@ecomcx/ecomweb-content";
|
|
8
|
+
import { isSafeUrl, resolveIcon } from "@ecomcx/ecomweb-content";
|
|
9
|
+
import { IconSvg } from "../ui/icon-svg";
|
|
9
10
|
import type { BlockEditProps } from "../core/registry";
|
|
11
|
+
import { IconGrid } from "../ui/icon-picker";
|
|
10
12
|
|
|
11
13
|
/** Công cụ bảng khi đang gõ trong ô (hoặc chọn cả bảng). */
|
|
12
14
|
export function TableTools({ ancestor, currentId }: { ancestor: BNode; currentId: string }) {
|
|
@@ -98,6 +100,26 @@ export function ButtonsTools({ ancestor }: { ancestor: BNode; currentId: string
|
|
|
98
100
|
);
|
|
99
101
|
}
|
|
100
102
|
|
|
103
|
+
/** Chọn icon ngay trên thanh công cụ (icon là thuộc tính chính của Icon Box / Icon List / Nút): bấm nút mở lưới icon có ô tìm. */
|
|
104
|
+
export function IconTool({ value, onChange, allowNone }: { value?: string; onChange(v: string | undefined): void; allowNone?: boolean }) {
|
|
105
|
+
const t = useMsgs("controls");
|
|
106
|
+
const has = !!value && !!resolveIcon(value);
|
|
107
|
+
return (
|
|
108
|
+
<Dropdown label={t.chooseIcon} trigger={has ? <IconSvg className="ecx-icon" name={value} size={20} /> : <Star className="ecx-icon" />}>
|
|
109
|
+
{(close) => <IconGrid className="ecx-tool-icon-pop" value={value} label={t.chooseIcon} allowNone={allowNone} onPick={(v) => { onChange(v); close(); }} />}
|
|
110
|
+
</Dropdown>
|
|
111
|
+
);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
export function ButtonIconTool({ block, setAttrs }: BlockEditProps) {
|
|
115
|
+
return <IconTool value={block.attrs.icon as string | undefined} onChange={(v) => setAttrs({ icon: v })} allowNone />;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/** Thanh của nút: icon + liên kết. */
|
|
119
|
+
export function ButtonTools(p: BlockEditProps) {
|
|
120
|
+
return <><ButtonIconTool {...p} /><ButtonLinkTool {...p} /></>;
|
|
121
|
+
}
|
|
122
|
+
|
|
101
123
|
/** Liên kết của nút ngay trên thanh: ô địa chỉ + mở tab mới (cùng thuộc tính href / target với bảng bên phải). */
|
|
102
124
|
export function ButtonLinkTool({ block, setAttrs }: BlockEditProps) {
|
|
103
125
|
const { labels } = useEditor();
|