PluginProbe
Blockenberg — 600+ Advanced Gutenberg Blocks & AI Agent for WordPress Block Editor / 2.0.11
Blockenberg — 600+ Advanced Gutenberg Blocks & AI Agent for WordPress Block Editor v2.0.11
2.0.13 2.0.12 2.0.11 2.0.10 2.0.9 trunk 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 2.0.7 2.0.8
blockenberg / blocks / release-notes / index.js

index.js in Blockenberg — 600+ Advanced Gutenberg Blocks & AI Agent for WordPress Block Editor 2.0.11, at blocks/release-notes/index.js

254 lines 19.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 ( function () {
2 var el = wp.element.createElement;
3 var Fragment = wp.element.Fragment;
4 var registerBlockType = wp.blocks.registerBlockType;
5 var InspectorControls = wp.blockEditor.InspectorControls;
6 var useBlockProps = wp.blockEditor.useBlockProps;
7 var PanelBody = wp.components.PanelBody;
8 var PanelColorSettings = wp.blockEditor.PanelColorSettings;
9 var ToggleControl = wp.components.ToggleControl;
10 var RangeControl = wp.components.RangeControl;
11 var SelectControl = wp.components.SelectControl;
12 var TextControl = wp.components.TextControl;
13 var TextareaControl = wp.components.TextareaControl;
14 var Button = wp.components.Button;
15 var __ = wp.i18n.__;
16 var _tc; function getTypoControl() { return _tc || (_tc = window.bkbgTypographyControl); }
17 var _tv; function getTypoCssVars() { return _tv || (_tv = window.bkbgTypoCssVars); }
18
19 // ── section type metadata ─────────────────────────────────────
20 var sectionTypes = [
21 { value: 'added', label: '�
22 Added', emoji: '�
23 ' },
24 { value: 'changed', label: '🔄 Changed', emoji: '🔄' },
25 { value: 'fixed', label: '🐛 Fixed', emoji: '🐛' },
26 { value: 'removed', label: '🗑️ Removed', emoji: '🗑️' },
27 { value: 'security', label: '🔒 Security', emoji: '🔒' },
28 { value: 'deprecated', label: '⚠️ Deprecated', emoji: '⚠️' }
29 ];
30
31 var releaseTypeOptions = [
32 { label: '🚀 Major', value: 'major' },
33 { label: '✨ Minor', value: 'minor' },
34 { label: '🐛 Patch', value: 'patch' },
35 { label: '🔥 Hotfix', value: 'hotfix' }
36 ];
37
38 function releaseTypeInfo(t) {
39 if (t === 'major') return { label: '🚀 Major', bg: '#fee2e2', color: '#991b1b' };
40 if (t === 'patch') return { label: '🐛 Patch', bg: '#fef9c3', color: '#713f12' };
41 if (t === 'hotfix') return { label: '🔥 Hotfix', bg: '#ffedd5', color: '#9a3412' };
42 return { label: '✨ Minor', bg: '#dbeafe', color: '#1e3a8a' };
43 }
44
45 function sectionMeta(type, a) {
46 if (type === 'added') return { label: 'Added', bg: a.addedBg, color: a.addedColor, dot: '#16a34a' };
47 if (type === 'changed') return { label: 'Changed', bg: a.changedBg, color: a.changedColor, dot: '#2563eb' };
48 if (type === 'fixed') return { label: 'Fixed', bg: a.fixedBg, color: a.fixedColor, dot: '#ca8a04' };
49 if (type === 'removed') return { label: 'Removed', bg: a.removedBg, color: a.removedColor, dot: '#dc2626' };
50 if (type === 'security') return { label: 'Security', bg: a.securityBg, color: a.securityColor, dot: '#7c3aed' };
51 if (type === 'deprecated') return { label: 'Deprecated', bg: a.deprecatedBg, color: a.deprecatedColor, dot: '#64748b' };
52 return { label: type, bg: '#f1f5f9', color: '#374151', dot: '#64748b' };
53 }
54
55 // Update a single item inside a section
56 function updItem(sections, si, ii, val) {
57 return sections.map(function (sec, s) {
58 if (s !== si) return sec;
59 var items = sec.items.map(function (it, i) { return i === ii ? val : it; });
60 return Object.assign({}, sec, { items: items });
61 });
62 }
63
64 registerBlockType('blockenberg/release-notes', {
65 edit: function (props) {
66 var a = props.attributes;
67 var set = props.setAttributes;
68 var TC = getTypoControl();
69 var blockProps = useBlockProps((function () {
70 var _tvFn = getTypoCssVars();
71 var s = {};
72 if (_tvFn) {
73 Object.assign(s, _tvFn(a.titleTypo || {}, '--bkrn-tt-'));
74 Object.assign(s, _tvFn(a.bodyTypo || {}, '--bkrn-bt-'));
75 }
76 return { className: 'bkbg-rn-editor-wrap', style: s };
77 })());
78 var rtInfo = releaseTypeInfo(a.releaseType);
79
80 // ── preview ───────────────────────────────────────────
81 var preview = el('div', { style: { border: '1px solid ' + a.borderColor, borderRadius: a.borderRadius + 'px', overflow: 'hidden', background: a.bgColor } },
82 // Header
83 el('div', { style: { background: a.headerBg, padding: '20px 24px' } },
84 el('div', { style: { display: 'flex', alignItems: 'center', gap: 10, flexWrap: 'wrap', marginBottom: 8 } },
85 el('span', { className: 'bkbg-rn-version', style: { color: a.headerColor } }, 'v' + a.version),
86 a.showReleaseType && el('span', { style: { background: rtInfo.bg, color: rtInfo.color, padding: '2px 10px', borderRadius: 100, fontSize: 11, fontWeight: 700 } }, rtInfo.label),
87 el('span', { style: { color: a.headerColor, opacity: .6, fontSize: a.productNameSize || 13 } }, a.productName)
88 ),
89 a.showMeta && a.releaseDate && el('div', { style: { fontSize: 12, color: a.headerColor, opacity: .55 } }, '�
90 Released ' + a.releaseDate)
91 ),
92 // Intro
93 a.showIntro && a.intro && el('div', { className: 'bkbg-rn-intro', style: { background: a.introBg, borderBottom: '1px solid ' + a.borderColor, padding: '14px 24px', color: a.introColor } }, a.intro),
94 // Sections
95 el('div', { style: { padding: '20px 24px' } },
96 a.sections.map(function (sec, si) {
97 var m = sectionMeta(sec.type, a);
98 return el('div', { key: si, style: { marginBottom: si < a.sections.length - 1 ? 20 : 0 } },
99 // Section heading
100 el('div', { style: { display: 'flex', alignItems: 'center', gap: 8, marginBottom: 10 } },
101 el('span', { style: { background: m.bg, color: m.color, padding: '3px 12px 3px 8px', borderRadius: 100, fontSize: 12, fontWeight: 700, display: 'flex', alignItems: 'center', gap: 5 } },
102 el('span', { style: { width: 8, height: 8, borderRadius: '50%', background: m.dot, display: 'inline-block' } }),
103 m.label
104 ),
105 el('span', { style: { fontSize: 11, color: '#9ca3af' } }, sec.items.length + ' item' + (sec.items.length !== 1 ? 's' : ''))
106 ),
107 // Items
108 el('ul', { style: { margin: 0, padding: 0, listStyle: 'none' } },
109 sec.items.map(function (item, ii) {
110 return el('li', { key: ii, className: 'bkbg-rn-item', style: { display: 'flex', alignItems: 'flex-start', gap: 8, padding: a.itemSpacing + 'px 0', borderBottom: ii < sec.items.length - 1 ? '1px dashed ' + a.borderColor : 'none', color: a.textColor } },
111 el('span', { style: { color: m.dot, marginTop: 4, flexShrink: 0, fontWeight: 700 } }, ''),
112 el('span', null, item)
113 );
114 })
115 )
116 );
117 }),
118 // Links
119 a.showLinks && (a.changelogUrl || a.compareUrl) && el('div', { style: { marginTop: 20, paddingTop: 16, borderTop: '1px solid ' + a.borderColor, display: 'flex', gap: 16, flexWrap: 'wrap' } },
120 a.changelogUrl && el('a', { href: a.changelogUrl, style: { fontSize: 13, color: a.accentColor, fontWeight: 600, textDecoration: 'none' } }, '📋 Full Changelog →'),
121 a.compareUrl && el('a', { href: a.compareUrl, style: { fontSize: 13, color: a.accentColor, fontWeight: 600, textDecoration: 'none' } }, '🔀 Compare Changes →')
122 )
123 )
124 );
125
126 return el(Fragment, null,
127 el('div', blockProps, preview),
128 el(InspectorControls, null,
129 // Release Info
130 el(PanelBody, { title: 'Release Info', initialOpen: true },
131 el(TextControl, { label: 'Product Name', value: a.productName, __nextHasNoMarginBottom: true, onChange: function (v) { set({ productName: v }); } }),
132 el('div', { style: { marginTop: 8, display: 'grid', gridTemplateColumns: '1fr 1fr', gap: 8 } },
133 el(TextControl, { label: 'Version', value: a.version, __nextHasNoMarginBottom: true, onChange: function (v) { set({ version: v }); } }),
134 el(SelectControl, { label: 'Type', value: a.releaseType, options: releaseTypeOptions, __nextHasNoMarginBottom: true, onChange: function (v) { set({ releaseType: v }); } })
135 ),
136 el('div', { style: { marginTop: 8 } },
137 el(TextControl, { label: 'Release Date', value: a.releaseDate, __nextHasNoMarginBottom: true, onChange: function (v) { set({ releaseDate: v }); } })
138 ),
139 el('div', { style: { marginTop: 8, display: 'grid', gridTemplateColumns: '1fr 1fr', gap: 4 } },
140 el(ToggleControl, { label: 'Show Meta', checked: a.showMeta, __nextHasNoMarginBottom: true, onChange: function (v) { set({ showMeta: v }); } }),
141 el(ToggleControl, { label: 'Show Type Badge', checked: a.showReleaseType, __nextHasNoMarginBottom: true, onChange: function (v) { set({ showReleaseType: v }); } })
142 )
143 ),
144 // Intro
145 el(PanelBody, { title: 'Introduction', initialOpen: false },
146 el(ToggleControl, { label: 'Show Introduction', checked: a.showIntro, __nextHasNoMarginBottom: true, onChange: function (v) { set({ showIntro: v }); } }),
147 el('div', { style: { marginTop: 8 } },
148 el(TextareaControl, { value: a.intro, rows: 4, __nextHasNoMarginBottom: true, onChange: function (v) { set({ intro: v }); } })
149 )
150 ),
151 // Change Sections
152 el(PanelBody, { title: 'Change Sections', initialOpen: true },
153 a.sections.map(function (sec, si) {
154 return el('div', { key: si, style: { marginBottom: 16, border: '1px solid #e5e7eb', borderRadius: 8, overflow: 'hidden' } },
155 // Section header
156 el('div', { style: { background: '#f8fafc', padding: '8px 12px', display: 'flex', justifyContent: 'space-between', alignItems: 'center' } },
157 el(SelectControl, { value: sec.type, options: sectionTypes, __nextHasNoMarginBottom: true, style: { marginBottom: 0 }, onChange: function (v) { set({ sections: a.sections.map(function (s, i) { return i === si ? Object.assign({}, s, { type: v }) : s; }) }); } }),
158 el(Button, { isDestructive: true, variant: 'link', style: { fontSize: 11 }, onClick: function () { set({ sections: a.sections.filter(function (_, i) { return i !== si; }) }); } }, '')
159 ),
160 // Items
161 el('div', { style: { padding: '8px 12px' } },
162 sec.items.map(function (item, ii) {
163 return el('div', { key: ii, style: { display: 'flex', gap: 4, alignItems: 'center', marginBottom: 6 } },
164 el('div', { style: { flex: 1 } },
165 el(TextControl, { value: item, __nextHasNoMarginBottom: true, onChange: function (v) { set({ sections: updItem(a.sections, si, ii, v) }); } })
166 ),
167 el(Button, { variant: 'link', isDestructive: true, style: { fontSize: 11, padding: 0 }, onClick: function () {
168 var items = sec.items.filter(function (_, i) { return i !== ii; });
169 set({ sections: a.sections.map(function (s, i) { return i === si ? Object.assign({}, s, { items: items }) : s; }) });
170 } }, '')
171 );
172 }),
173 el(Button, { variant: 'secondary', style: { width: '100%', marginTop: 4, justifyContent: 'center' }, onClick: function () {
174 var items = sec.items.concat(['New change item']);
175 set({ sections: a.sections.map(function (s, i) { return i === si ? Object.assign({}, s, { items: items }) : s; }) });
176 } }, '+ Add Item')
177 )
178 );
179 }),
180 el(Button, { variant: 'primary', style: { width: '100%', justifyContent: 'center', marginTop: 4 }, onClick: function () {
181 set({ sections: a.sections.concat([{ type: 'changed', items: ['New change item'] }]) });
182 } }, '+ Add Section')
183 ),
184 // Links
185 el(PanelBody, { title: 'Links', initialOpen: false },
186 el(ToggleControl, { label: 'Show Links', checked: a.showLinks, __nextHasNoMarginBottom: true, onChange: function (v) { set({ showLinks: v }); } }),
187 el('div', { style: { marginTop: 8 } },
188 el(TextControl, { label: 'Full Changelog URL', value: a.changelogUrl, __nextHasNoMarginBottom: true, onChange: function (v) { set({ changelogUrl: v }); } })
189 ),
190 el('div', { style: { marginTop: 8 } },
191 el(TextControl, { label: 'Compare Changes URL', value: a.compareUrl, __nextHasNoMarginBottom: true, onChange: function (v) { set({ compareUrl: v }); } })
192 )
193 ),
194 // Typography
195 el(PanelBody, { title: 'Typography', initialOpen: false },
196 TC && el(TC, { label: __('Title / Version', 'blockenberg'), value: a.titleTypo || {}, onChange: function(v) { set({ titleTypo: v }); } }),
197 TC && el(TC, { label: __('Body Text', 'blockenberg'), value: a.bodyTypo || {}, onChange: function(v) { set({ bodyTypo: v }); } }),
198 el(RangeControl, { label: 'Product Name Size (px)', value: a.productNameSize, min: 10, max: 22, __nextHasNoMarginBottom: true, onChange: function(v) { set({ productNameSize: v }); } })
199 ),
200 el(PanelBody, { title: 'Spacing', initialOpen: false },
201 el(RangeControl, { label: 'Border Radius (px)', value: a.borderRadius, min: 0, max: 24, __nextHasNoMarginBottom: true, onChange: function (v) { set({ borderRadius: v }); } }),
202 el('div', { style: { marginTop: 8 } },
203 el(RangeControl, { label: 'Item Spacing (px)', value: a.itemSpacing, min: 2, max: 16, __nextHasNoMarginBottom: true, onChange: function (v) { set({ itemSpacing: v }); } })
204 )
205 ),
206 // Colors
207 el(PanelColorSettings, {
208 title: 'Header & Structure Colors',
209 initialOpen: false,
210 colorSettings: [
211 { label: 'Block Background', value: a.bgColor, onChange: function (v) { set({ bgColor: v || '#ffffff' }); } },
212 { label: 'Border', value: a.borderColor, onChange: function (v) { set({ borderColor: v || '#e5e7eb' }); } },
213 { label: 'Header BG', value: a.headerBg, onChange: function (v) { set({ headerBg: v || '#0f172a' }); } },
214 { label: 'Header Text', value: a.headerColor, onChange: function (v) { set({ headerColor: v || '#ffffff' }); } },
215 { label: 'Intro BG', value: a.introBg, onChange: function (v) { set({ introBg: v || '#f8fafc' }); } },
216 { label: 'Intro Text', value: a.introColor, onChange: function (v) { set({ introColor: v || '#374151' }); } },
217 { label: 'List Text', value: a.textColor, onChange: function (v) { set({ textColor: v || '#374151' }); } },
218 { label: 'Accent (links)', value: a.accentColor, onChange: function (v) { set({ accentColor: v || '#3b82f6' }); } }
219 ]
220 }),
221 el(PanelColorSettings, {
222 title: 'Section Type Colors',
223 initialOpen: false,
224 colorSettings: [
225 { label: 'Added BG', value: a.addedBg, onChange: function (v) { set({ addedBg: v || '#dcfce7' }); } },
226 { label: 'Added Text', value: a.addedColor, onChange: function (v) { set({ addedColor: v || '#14532d' }); } },
227 { label: 'Changed BG', value: a.changedBg, onChange: function (v) { set({ changedBg: v || '#dbeafe' }); } },
228 { label: 'Changed Text', value: a.changedColor, onChange: function (v) { set({ changedColor: v || '#1e3a8a' }); } },
229 { label: 'Fixed BG', value: a.fixedBg, onChange: function (v) { set({ fixedBg: v || '#fef9c3' }); } },
230 { label: 'Fixed Text', value: a.fixedColor, onChange: function (v) { set({ fixedColor: v || '#713f12' }); } },
231 { label: 'Removed BG', value: a.removedBg, onChange: function (v) { set({ removedBg: v || '#fee2e2' }); } },
232 { label: 'Removed Text', value: a.removedColor, onChange: function (v) { set({ removedColor: v || '#991b1b' }); } },
233 { label: 'Security BG', value: a.securityBg, onChange: function (v) { set({ securityBg: v || '#f3e8ff' }); } },
234 { label: 'Security Text', value: a.securityColor, onChange: function (v) { set({ securityColor: v || '#581c87' }); } },
235 { label: 'Deprecated BG', value: a.deprecatedBg, onChange: function (v) { set({ deprecatedBg: v || '#f1f5f9' }); } },
236 { label: 'Deprecated Text', value: a.deprecatedColor, onChange: function (v) { set({ deprecatedColor: v || '#475569' }); } }
237 ]
238 })
239 )
240 );
241 },
242
243 save: function (props) {
244 var useBlockProps = wp.blockEditor.useBlockProps;
245 return wp.element.createElement('div', useBlockProps.save(),
246 wp.element.createElement('div', {
247 className: 'bkbg-release-notes-app',
248 'data-opts': JSON.stringify(props.attributes)
249 })
250 );
251 }
252 });
253 }() );
254