@ecomcx/ecomweb-theme-sdk 1.41.0 → 1.42.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/dist/content.d.ts +5 -0
- package/dist/content.js +12 -1
- package/dist/page-full-width.d.ts +1 -1
- package/dist/page-full-width.js +5 -4
- package/dist/page-landing.d.ts +1 -1
- package/dist/page-landing.js +5 -4
- package/dist/rich.js +7 -5
- package/package.json +2 -2
package/dist/content.d.ts
CHANGED
|
@@ -24,3 +24,8 @@ export declare function EditableRegion({ name, data, className, children }: {
|
|
|
24
24
|
}): Promise<import("react").JSX.Element>;
|
|
25
25
|
/** Ngữ cảnh vẽ nội dung dùng chung cho bài viết và template khối. */
|
|
26
26
|
export declare function contentContext(site: Site, post?: Post | null, data?: ResolveResult): Promise<RenderContext>;
|
|
27
|
+
/**
|
|
28
|
+
* Header / footer của theme dựng bằng khối cho template có sẵn của SDK (full-width, landing): theme khối không có header/footer
|
|
29
|
+
* trong layout mà ở template part trong từng template khối → template có sẵn phải tự vẽ part "header" / "footer". Theme thường: null.
|
|
30
|
+
*/
|
|
31
|
+
export declare function blockThemeParts(site: Site, data?: ResolveResult): Promise<[ReactNode, ReactNode]>;
|
package/dist/content.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
2
|
import { ExtensionBoundary, Link, PostPasswordForm } from "./client.js";
|
|
3
|
-
import { applyFilters, findBlock, findRegion, findShortcode, getActiveExtensions } from "./runtime.js";
|
|
3
|
+
import { applyFilters, findBlock, findRegion, findShortcode, getActiveExtensions, getActiveTheme } from "./runtime.js";
|
|
4
4
|
import { getPattern, getSite, getTemplates } from "./api.js";
|
|
5
5
|
import { CORE_BINDING_SOURCES } from "./bindings.js";
|
|
6
6
|
import { getT } from "./i18n.js";
|
|
@@ -108,3 +108,14 @@ export async function contentContext(site, post, data) {
|
|
|
108
108
|
},
|
|
109
109
|
};
|
|
110
110
|
}
|
|
111
|
+
/**
|
|
112
|
+
* Header / footer của theme dựng bằng khối cho template có sẵn của SDK (full-width, landing): theme khối không có header/footer
|
|
113
|
+
* trong layout mà ở template part trong từng template khối → template có sẵn phải tự vẽ part "header" / "footer". Theme thường: null.
|
|
114
|
+
*/
|
|
115
|
+
export async function blockThemeParts(site, data) {
|
|
116
|
+
if ((await getActiveTheme(site)).chain[0]?.manifest.editing !== "blocks")
|
|
117
|
+
return [null, null];
|
|
118
|
+
const ctx = await contentContext(site, data?.post, data);
|
|
119
|
+
const part = async (slug) => _jsx(_Fragment, { children: await renderContent({ type: "doc", content: [{ type: "templatePart", attrs: { slug, tagName: slug } }] }, ctx) });
|
|
120
|
+
return [await part("header"), await part("footer")];
|
|
121
|
+
}
|
|
@@ -3,4 +3,4 @@ import type { TemplateProps } from "./types.js";
|
|
|
3
3
|
* Template "full-width": giữ header/footer của theme, vùng bài trải hết chiều ngang màn hình. Như WordPress: chữ vẫn ở cột giữa
|
|
4
4
|
* (--ecx-content-width), chỉ khối đặt độ rộng "Rộng" / "Toàn trang" mới tràn ra.
|
|
5
5
|
*/
|
|
6
|
-
export default function FullWidth({ data }: TemplateProps): import("react").JSX.Element
|
|
6
|
+
export default function FullWidth({ data, site }: TemplateProps): Promise<import("react").JSX.Element>;
|
package/dist/page-full-width.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { PostContent } from "./content.js";
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { blockThemeParts, PostContent } from "./content.js";
|
|
3
3
|
/**
|
|
4
4
|
* Template "full-width": giữ header/footer của theme, vùng bài trải hết chiều ngang màn hình. Như WordPress: chữ vẫn ở cột giữa
|
|
5
5
|
* (--ecx-content-width), chỉ khối đặt độ rộng "Rộng" / "Toàn trang" mới tràn ra.
|
|
6
6
|
*/
|
|
7
|
-
export default function FullWidth({ data }) {
|
|
8
|
-
|
|
7
|
+
export default async function FullWidth({ data, site }) {
|
|
8
|
+
const [header, footer] = await blockThemeParts(site, data);
|
|
9
|
+
return (_jsxs(_Fragment, { children: [header, _jsxs("div", { className: "ecx-full-width", children: [data.post?.title && _jsx("h1", { className: "entry-title ecx-page-title", children: data.post.title }), _jsx(PostContent, { post: data.post, className: "entry-content ecx-layout-constrained" })] }), footer] }));
|
|
9
10
|
}
|
package/dist/page-landing.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { TemplateProps } from "./types.js";
|
|
2
2
|
/** Template "landing": như "full-width" (giữ header/footer, khối "Toàn trang" tràn màn hình) nhưng không in tiêu đề — section đầu (hero) sát header. */
|
|
3
|
-
export default function Landing({ data }: TemplateProps): import("react").JSX.Element
|
|
3
|
+
export default function Landing({ data, site }: TemplateProps): Promise<import("react").JSX.Element>;
|
package/dist/page-landing.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { PostContent } from "./content.js";
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { blockThemeParts, PostContent } from "./content.js";
|
|
3
3
|
/** Template "landing": như "full-width" (giữ header/footer, khối "Toàn trang" tràn màn hình) nhưng không in tiêu đề — section đầu (hero) sát header. */
|
|
4
|
-
export default function Landing({ data }) {
|
|
5
|
-
|
|
4
|
+
export default async function Landing({ data, site }) {
|
|
5
|
+
const [header, footer] = await blockThemeParts(site, data);
|
|
6
|
+
return (_jsxs(_Fragment, { children: [header, _jsx("div", { className: "ecx-full-width ecx-landing", children: _jsx(PostContent, { post: data.post, className: "entry-content ecx-layout-constrained" }) }), footer] }));
|
|
6
7
|
}
|
package/dist/rich.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
2
|
import { Fragment, cloneElement, createElement, isValidElement } from "react";
|
|
3
|
-
import { DYNAMIC_NODES, ICON_PATHS, widgetMarkup, widthClass, blockCitation, blockShell, buttonWrapShell, coverParts, linkRel, embedInfo, motionClasses, normalizeContent, safeUrl, styleClass, styleCss, controlsCss } from "@ecomcx/ecomweb-content";
|
|
3
|
+
import { DYNAMIC_NODES, ICON_PATHS, widgetMarkup, widthClass, blockCitation, blockShell, buttonWrapShell, coverParts, linkRel, embedInfo, motionClasses, normalizeContent, safeUrl, styleClass, styleCss, controlsCss, CORE_CONTROLS } from "@ecomcx/ecomweb-content";
|
|
4
4
|
import { cx } from "./utils.js";
|
|
5
5
|
import { SOCIAL_ICONS } from "./social-icons.js";
|
|
6
6
|
import { CountdownClient, FormBlockClient, LightboxClient, Link, TabsClient } from "./client.js";
|
|
@@ -172,7 +172,8 @@ function decorate(el, a, key, ctx, type, ctrl, data) {
|
|
|
172
172
|
if (ctrl && ctx.styles && !ctx.styles.has(ctrl.cls))
|
|
173
173
|
ctx.styles.set(ctrl.cls, ctrl.css);
|
|
174
174
|
const extra = cx(cls, ctrl?.cls, motionClasses(style), widthClass(type, a), a.blockStyle && `ecx-is-${a.blockStyle}`, a.className);
|
|
175
|
-
|
|
175
|
+
// Link của SDK in thẳng <a> (nhận className / style / id) → gắn class lên chính thẻ như khung soạn, không bọc thêm <div> (nút trong nhóm nút)
|
|
176
|
+
if (isValidElement(el) && el.type !== Fragment && (typeof el.type === "string" || el.type === Link)) {
|
|
176
177
|
const e = el;
|
|
177
178
|
let inline = e.props.style;
|
|
178
179
|
if (inline && style) {
|
|
@@ -245,7 +246,8 @@ async function renderNode(node, key, ctx) {
|
|
|
245
246
|
for (const c of a.className.split(/\s+/))
|
|
246
247
|
ctx.used.classes.add(c);
|
|
247
248
|
}
|
|
248
|
-
|
|
249
|
+
// Ô Kiểu dáng của khối lõi (1.24) + của plugin — cùng controlsCss với khung soạn
|
|
250
|
+
const ctrl = node.type !== "text" && a ? controlsCss(ctx.controls?.length ? [...CORE_CONTROLS, ...ctx.controls] : CORE_CONTROLS, node.type, a) : null;
|
|
249
251
|
const pick = ctx.ready && node.type !== "text" ? ctx.ready[node.type] ?? ctx.ready["*"] : undefined;
|
|
250
252
|
// Có liệt kê thuộc tính → chỉ gắn khi khối có ít nhất một giá trị (không phình HTML mọi nhóm / bìa); [] = mọi khối loại đó
|
|
251
253
|
const given = pick?.filter((k) => !emptyAttr(a?.[k]));
|
|
@@ -392,9 +394,9 @@ async function renderNodeInner(node, key, ctx) {
|
|
|
392
394
|
return shelled("buttons", a, key, items);
|
|
393
395
|
}
|
|
394
396
|
case "cover": {
|
|
395
|
-
const { src, fixed, overlay,
|
|
397
|
+
const { src, fixed, overlay, imgStyle, overlayStyle } = coverParts(a);
|
|
396
398
|
const url = src ? safeUrl(src, "") : "";
|
|
397
|
-
return shelled("cover", a, key, _jsxs(_Fragment, { children: [url && !fixed && _jsx("img", { className: "ecx-cover-img", src: url, alt: a.alt ?? "", loading: "lazy", decoding: "async" }), overlay && _jsx("span", { className: "ecx-cover-overlay", "aria-hidden": "true", style:
|
|
399
|
+
return shelled("cover", a, key, _jsxs(_Fragment, { children: [url && !fixed && _jsx("img", { className: "ecx-cover-img", src: url, alt: a.alt ?? "", loading: "lazy", decoding: "async", style: imgStyle }), overlay && _jsx("span", { className: "ecx-cover-overlay", "aria-hidden": "true", style: overlayStyle }), _jsx("div", { className: "ecx-cover-inner", children: await children() })] }), undefined);
|
|
398
400
|
}
|
|
399
401
|
case "mediaText": return shelled("mediaText", a, key, _jsxs(_Fragment, { children: [_jsx("figure", { className: "ecx-media-text-media", style: { margin: 0 }, children: a.src && _jsx("img", { src: safeUrl(a.src, ""), alt: a.alt ?? "", loading: "lazy", decoding: "async" }) }), _jsx("div", { className: "ecx-media-text-content", children: await children() })] }));
|
|
400
402
|
case "pullquote":
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ecomcx/ecomweb-theme-sdk",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.42.0",
|
|
4
4
|
"description": "SDK để viết theme và phần frontend của plugin cho Ecomweb",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"README.md"
|
|
34
34
|
],
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@ecomcx/ecomweb-content": "^1.
|
|
36
|
+
"@ecomcx/ecomweb-content": "^1.24.0",
|
|
37
37
|
"intl-messageformat": "12.1.3"
|
|
38
38
|
},
|
|
39
39
|
"peerDependencies": {
|