@roottale/cms-core 0.57.0 → 0.58.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/CHANGELOG.md +13 -0
- package/dist/index.cjs +65 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +28 -1
- package/dist/index.d.ts +28 -1
- package/dist/index.js +59 -0
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
# @roottale/cms-core
|
|
2
2
|
|
|
3
|
+
## 0.58.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- dd82c92: 공통 블록 표시 형태(presentation) — 블록의 모양(본문처럼/카드·배경색·링크 버튼·버튼 색)을 어드민이
|
|
8
|
+
정해 공개 API `presentation` 으로 내려준다. 사이트는 색·모양을 CSS 에 고정하지 않는다.
|
|
9
|
+
- `@roottale/cms-core`: `readSitePatternPresentation`·`sitePatternPresentationAttributes`·
|
|
10
|
+
`DEFAULT_SITE_PATTERN_PRESENTATION`.
|
|
11
|
+
- `@roottale/cms-client`: `CmsSitePattern.presentation`(구 서버는 기본값), `sitePatternPresentationAttributes`
|
|
12
|
+
(래퍼 data 속성 + `--rt-pattern-bg`·`--rt-pattern-btn-n` CSS 변수).
|
|
13
|
+
- `@roottale/cms-renderer-next`: `RootTaleBlogPost`·`RootTalePostPattern` 이 data 속성·변수를 얹고,
|
|
14
|
+
`cms-public.css` 가 카드/버튼 모양을 그 값으로만 그린다.
|
|
15
|
+
|
|
3
16
|
## 0.57.0
|
|
4
17
|
|
|
5
18
|
### Minor Changes
|
package/dist/index.cjs
CHANGED
|
@@ -31,6 +31,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
31
31
|
var src_exports = {};
|
|
32
32
|
__export(src_exports, {
|
|
33
33
|
BLOCK_NAME_PATTERN: () => BLOCK_NAME_PATTERN,
|
|
34
|
+
DEFAULT_SITE_PATTERN_PRESENTATION: () => DEFAULT_SITE_PATTERN_PRESENTATION,
|
|
34
35
|
EMPTY_SITE_PATTERN_PLACEMENTS: () => EMPTY_SITE_PATTERN_PLACEMENTS,
|
|
35
36
|
FIELD_BINDING_SOURCE: () => FIELD_BINDING_SOURCE,
|
|
36
37
|
FIELD_BINDING_SOURCE_ALIAS: () => FIELD_BINDING_SOURCE_ALIAS,
|
|
@@ -43,6 +44,7 @@ __export(src_exports, {
|
|
|
43
44
|
PHASE_1_CORE_BLOCKS: () => PHASE_1_CORE_BLOCKS,
|
|
44
45
|
PHASE_1_CSP: () => PHASE_1_CSP,
|
|
45
46
|
POST_FOOTER_SLOT: () => POST_FOOTER_SLOT,
|
|
47
|
+
SITE_PATTERN_BUTTON_COLORS_MAX: () => SITE_PATTERN_BUTTON_COLORS_MAX,
|
|
46
48
|
SITE_PATTERN_KEY_PATTERN: () => SITE_PATTERN_KEY_PATTERN,
|
|
47
49
|
SITE_PATTERN_PLACEMENTS_KEY: () => SITE_PATTERN_PLACEMENTS_KEY,
|
|
48
50
|
SITE_PATTERN_SLOTS: () => SITE_PATTERN_SLOTS,
|
|
@@ -73,12 +75,14 @@ __export(src_exports, {
|
|
|
73
75
|
isValidSitePatternKey: () => isValidSitePatternKey,
|
|
74
76
|
issuePreviewToken: () => issuePreviewToken,
|
|
75
77
|
normalizeEmbed: () => normalizeEmbed,
|
|
78
|
+
normalizeHexColor: () => normalizeHexColor,
|
|
76
79
|
normalizeImageAlt: () => normalizeImageAlt,
|
|
77
80
|
parseBlock: () => parseBlock,
|
|
78
81
|
postsForCollection: () => postsForCollection,
|
|
79
82
|
postsInAnyCollection: () => postsInAnyCollection,
|
|
80
83
|
postsNotInAnyCollection: () => postsNotInAnyCollection,
|
|
81
84
|
readSitePatternPlacements: () => readSitePatternPlacements,
|
|
85
|
+
readSitePatternPresentation: () => readSitePatternPresentation,
|
|
82
86
|
referencedSitePatternKeys: () => referencedSitePatternKeys,
|
|
83
87
|
renderInternalContentLinksInHtml: () => renderInternalContentLinksInHtml,
|
|
84
88
|
renderInternalContentLinksInText: () => renderInternalContentLinksInText,
|
|
@@ -98,6 +102,8 @@ __export(src_exports, {
|
|
|
98
102
|
scopeImportedCss: () => scopeImportedCss,
|
|
99
103
|
serializeBlock: () => serializeBlock,
|
|
100
104
|
setSitePatternPlacementRule: () => setSitePatternPlacementRule,
|
|
105
|
+
sitePatternButtonColor: () => sitePatternButtonColor,
|
|
106
|
+
sitePatternPresentationAttributes: () => sitePatternPresentationAttributes,
|
|
101
107
|
validateCollections: () => validateCollections,
|
|
102
108
|
verifyPreviewToken: () => verifyPreviewToken
|
|
103
109
|
});
|
|
@@ -1608,9 +1614,63 @@ function referencedSitePatternKeys(placements) {
|
|
|
1608
1614
|
placements.rules.map((rule) => rule.patternKey).filter((key) => key !== null)
|
|
1609
1615
|
);
|
|
1610
1616
|
}
|
|
1617
|
+
var DEFAULT_SITE_PATTERN_PRESENTATION = {
|
|
1618
|
+
layout: "plain",
|
|
1619
|
+
background: "#f8f9fa",
|
|
1620
|
+
linkStyle: "text",
|
|
1621
|
+
buttonColors: ["#03c75a", "#1a1a1a", "#666666"]
|
|
1622
|
+
};
|
|
1623
|
+
var SITE_PATTERN_BUTTON_COLORS_MAX = 4;
|
|
1624
|
+
var HEX_COLOR_RE2 = /^#[0-9a-f]{6}$/;
|
|
1625
|
+
function normalizeHexColor(value) {
|
|
1626
|
+
if (typeof value !== "string") return null;
|
|
1627
|
+
let hex = value.trim().toLowerCase();
|
|
1628
|
+
if (/^#[0-9a-f]{3}$/.test(hex)) hex = `#${hex[1]}${hex[1]}${hex[2]}${hex[2]}${hex[3]}${hex[3]}`;
|
|
1629
|
+
return HEX_COLOR_RE2.test(hex) ? hex : null;
|
|
1630
|
+
}
|
|
1631
|
+
function readSitePatternPresentation(raw) {
|
|
1632
|
+
let value = raw;
|
|
1633
|
+
if (typeof value === "string") {
|
|
1634
|
+
try {
|
|
1635
|
+
value = JSON.parse(value);
|
|
1636
|
+
} catch {
|
|
1637
|
+
value = null;
|
|
1638
|
+
}
|
|
1639
|
+
}
|
|
1640
|
+
const base = DEFAULT_SITE_PATTERN_PRESENTATION;
|
|
1641
|
+
if (!isRecord(value)) return base;
|
|
1642
|
+
const layout = value.layout === "card" ? "card" : "plain";
|
|
1643
|
+
const linkStyle = value.linkStyle === "buttons" ? "buttons" : "text";
|
|
1644
|
+
const background = normalizeHexColor(value.background) ?? base.background;
|
|
1645
|
+
const colors = Array.isArray(value.buttonColors) ? value.buttonColors.map(normalizeHexColor).filter((c) => c !== null).slice(0, SITE_PATTERN_BUTTON_COLORS_MAX) : [];
|
|
1646
|
+
return {
|
|
1647
|
+
layout,
|
|
1648
|
+
background,
|
|
1649
|
+
linkStyle,
|
|
1650
|
+
buttonColors: colors.length > 0 ? colors : base.buttonColors
|
|
1651
|
+
};
|
|
1652
|
+
}
|
|
1653
|
+
function sitePatternButtonColor(presentation, index) {
|
|
1654
|
+
const colors = presentation.buttonColors;
|
|
1655
|
+
return colors[Math.min(index, colors.length - 1)] ?? DEFAULT_SITE_PATTERN_PRESENTATION.buttonColors[0];
|
|
1656
|
+
}
|
|
1657
|
+
function sitePatternPresentationAttributes(presentation) {
|
|
1658
|
+
const cssVariables = { "--rt-pattern-bg": presentation.background };
|
|
1659
|
+
presentation.buttonColors.forEach((color, index) => {
|
|
1660
|
+
cssVariables[`--rt-pattern-btn-${index + 1}`] = color;
|
|
1661
|
+
});
|
|
1662
|
+
return {
|
|
1663
|
+
dataset: {
|
|
1664
|
+
"data-pattern-layout": presentation.layout,
|
|
1665
|
+
"data-pattern-link-style": presentation.linkStyle
|
|
1666
|
+
},
|
|
1667
|
+
cssVariables
|
|
1668
|
+
};
|
|
1669
|
+
}
|
|
1611
1670
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1612
1671
|
0 && (module.exports = {
|
|
1613
1672
|
BLOCK_NAME_PATTERN,
|
|
1673
|
+
DEFAULT_SITE_PATTERN_PRESENTATION,
|
|
1614
1674
|
EMPTY_SITE_PATTERN_PLACEMENTS,
|
|
1615
1675
|
FIELD_BINDING_SOURCE,
|
|
1616
1676
|
FIELD_BINDING_SOURCE_ALIAS,
|
|
@@ -1623,6 +1683,7 @@ function referencedSitePatternKeys(placements) {
|
|
|
1623
1683
|
PHASE_1_CORE_BLOCKS,
|
|
1624
1684
|
PHASE_1_CSP,
|
|
1625
1685
|
POST_FOOTER_SLOT,
|
|
1686
|
+
SITE_PATTERN_BUTTON_COLORS_MAX,
|
|
1626
1687
|
SITE_PATTERN_KEY_PATTERN,
|
|
1627
1688
|
SITE_PATTERN_PLACEMENTS_KEY,
|
|
1628
1689
|
SITE_PATTERN_SLOTS,
|
|
@@ -1653,12 +1714,14 @@ function referencedSitePatternKeys(placements) {
|
|
|
1653
1714
|
isValidSitePatternKey,
|
|
1654
1715
|
issuePreviewToken,
|
|
1655
1716
|
normalizeEmbed,
|
|
1717
|
+
normalizeHexColor,
|
|
1656
1718
|
normalizeImageAlt,
|
|
1657
1719
|
parseBlock,
|
|
1658
1720
|
postsForCollection,
|
|
1659
1721
|
postsInAnyCollection,
|
|
1660
1722
|
postsNotInAnyCollection,
|
|
1661
1723
|
readSitePatternPlacements,
|
|
1724
|
+
readSitePatternPresentation,
|
|
1662
1725
|
referencedSitePatternKeys,
|
|
1663
1726
|
renderInternalContentLinksInHtml,
|
|
1664
1727
|
renderInternalContentLinksInText,
|
|
@@ -1678,6 +1741,8 @@ function referencedSitePatternKeys(placements) {
|
|
|
1678
1741
|
scopeImportedCss,
|
|
1679
1742
|
serializeBlock,
|
|
1680
1743
|
setSitePatternPlacementRule,
|
|
1744
|
+
sitePatternButtonColor,
|
|
1745
|
+
sitePatternPresentationAttributes,
|
|
1681
1746
|
validateCollections,
|
|
1682
1747
|
verifyPreviewToken
|
|
1683
1748
|
});
|