Skip to content
1 change: 1 addition & 0 deletions assets/before-after/frontblocks-before-after-option.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,7 @@ function BeforeAfterEdit( props ) {

// Register the block.
registerBlockType( 'frontblocks/before-after', {
apiVersion: 3,
title: __( 'FrontBlocks - Before After', 'frontblocks' ),
description: __( 'Compare two images with a draggable before/after slider.', 'frontblocks' ),
category: 'media',
Expand Down
1 change: 1 addition & 0 deletions assets/before-after/frontblocks-before-after.js
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,7 @@ function BeforeAfterEdit(props) {

// Register the block.
registerBlockType('frontblocks/before-after', {
apiVersion: 3,
title: __('FrontBlocks - Before After', 'frontblocks'),
description: __('Compare two images with a draggable before/after slider.', 'frontblocks'),
category: 'media',
Expand Down
32 changes: 20 additions & 12 deletions assets/google-signin/frontblocks-google-signin-block.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
var __ = i18n.__;
var registerBlockType = blocks.registerBlockType;
var InspectorControls = blockEditor.InspectorControls;
var useBlockProps = blockEditor.useBlockProps;
var PanelBody = components.PanelBody;
var SelectControl = components.SelectControl;
var TextControl = components.TextControl;
Expand All @@ -27,10 +28,13 @@
);

registerBlockType( 'frontblocks/google-login', {
apiVersion: 3,
icon: googleIcon,
edit: function ( props ) {
var attributes = props.attributes;
var setAttributes = props.setAttributes;
// API version 3: the root element of the edit output must carry the block props.
var blockProps = useBlockProps();

return el(
Fragment,
Expand Down Expand Up @@ -62,18 +66,22 @@
} )
)
),
ServerSideRender
? el( ServerSideRender, {
block: 'frontblocks/google-login',
attributes: attributes,
} )
: el(
'p',
{},
'signup' === attributes.mode
? __( 'Sign up with Google', 'frontblocks' )
: __( 'Sign in with Google', 'frontblocks' )
)
el(
'div',
blockProps,
ServerSideRender
? el( ServerSideRender, {
block: 'frontblocks/google-login',
attributes: attributes,
} )
: el(
'p',
{},
'register' === attributes.mode
? __( 'Sign up with Google', 'frontblocks' )
: __( 'Sign in with Google', 'frontblocks' )
)
)
);
},
save: function () {
Expand Down
1 change: 1 addition & 0 deletions assets/insert-post/frontblocks-insert-post-option.js
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,7 @@ function InsertPostBlock(props) {
// Register the custom block
var registerBlockType = wp.blocks.registerBlockType;
registerBlockType('frontblocks/insert-post', {
apiVersion: 3,
title: __('FrontBlocks - Insert Post', 'frontblocks'),
description: __('Display content from another post or page', 'frontblocks'),
category: 'generateblocks',
Expand Down
1 change: 1 addition & 0 deletions assets/insert-post/frontblocks-insert-post-option.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,7 @@ function InsertPostBlock(props) {
const { registerBlockType } = wp.blocks;

registerBlockType('frontblocks/insert-post', {
apiVersion: 3,
title: __('FrontBlocks - Insert Post', 'frontblocks'),
description: __('Display content from another post or page', 'frontblocks'),
category: 'generateblocks',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -611,6 +611,7 @@ function ProductCategoriesEdit(props) {
}

registerBlockType('frontblocks/product-categories', {
apiVersion: 3,
title: __('FrontBlocks - Product Categories', 'frontblocks'),
description: __('Display a list of WooCommerce Product Categories.', 'frontblocks'),
category: 'woocommerce',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -757,6 +757,7 @@ function ProductCategoriesEdit(props) {
}))));
}
registerBlockType('frontblocks/product-categories', {
apiVersion: 3,
title: __('FrontBlocks - Product Categories', 'frontblocks'),
description: __('Display a list of WooCommerce Product Categories.', 'frontblocks'),
category: 'woocommerce',
Expand Down
1 change: 1 addition & 0 deletions assets/reading-time/frontblocks-reading-time-option.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,7 @@ function ReadingTimeEdit(props) {

// Register the block.
registerBlockType('frontblocks/reading-time', {
apiVersion: 3,
title: __('FrontBlocks - Reading Time', 'frontblocks'),
description: __('Display estimated reading time for the current post or page.', 'frontblocks'),
category: 'common',
Expand Down
1 change: 1 addition & 0 deletions assets/reading-time/frontblocks-reading-time.js
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,7 @@ function ReadingTimeEdit(props) {

// Register the block.
registerBlockType('frontblocks/reading-time', {
apiVersion: 3,
title: __('FrontBlocks - Reading Time', 'frontblocks'),
description: __('Display estimated reading time for the current post or page.', 'frontblocks'),
category: 'common',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ function StackedImagesEdit(props) {

// Register the block.
registerBlockType('frontblocks/stacked-images', {
apiVersion: 3,
title: __('FrontBlocks - Stacked Images', 'frontblocks'),
description: __('Display images with stacked animation effect from different directions.', 'frontblocks'),
category: 'media',
Expand Down
1 change: 1 addition & 0 deletions assets/stacked-images/frontblocks-stacked-images.js
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ function StackedImagesEdit(props) {

// Register the block.
registerBlockType('frontblocks/stacked-images', {
apiVersion: 3,
title: __('FrontBlocks - Stacked Images', 'frontblocks'),
description: __('Display images with stacked animation effect from different directions.', 'frontblocks'),
category: 'media',
Expand Down
10 changes: 8 additions & 2 deletions assets/table-of-contents/frontblocks-toc-option.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
"use strict";

function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
function _toConsumableArray(r) { return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread(); }
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
Expand Down Expand Up @@ -162,7 +167,7 @@ function TableOfContentsEdit(props) {
},
label: __('Accent color', 'frontblocks')
}]
})), /*#__PURE__*/React.createElement("nav", _extends({}, blockProps, {
})), /*#__PURE__*/React.createElement("nav", _objectSpread(_objectSpread({}, blockProps), {}, {
style: accentColor ? {
'--frbl-toc-accent': accentColor
} : undefined
Expand All @@ -184,6 +189,7 @@ function TableOfContentsEdit(props) {
}))));
}
registerBlockType('frontblocks/table-of-contents', {
apiVersion: 3,
title: __('FrontBlocks - Table of Content', 'frontblocks'),
description: __('An accessible table of contents generated from the headings in this post.', 'frontblocks'),
category: 'widgets',
Expand Down
1 change: 1 addition & 0 deletions assets/table-of-contents/frontblocks-toc-option.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ function TableOfContentsEdit( props ) {
}

registerBlockType( 'frontblocks/table-of-contents', {
apiVersion: 3,
title: __( 'FrontBlocks - Table of Content', 'frontblocks' ),
description: __( 'An accessible table of contents generated from the headings in this post.', 'frontblocks' ),
category: 'widgets',
Expand Down
30 changes: 18 additions & 12 deletions assets/text-animation/frontblocks-text-animation-option.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -415,8 +415,8 @@ const ANIMATION_PREVIEWS = {
if ( ! el ) return;
el.innerHTML = '';

const textSpan = document.createElement( 'span' );
const cursor = document.createElement( 'span' );
const textSpan = el.ownerDocument.createElement( 'span' );
const cursor = el.ownerDocument.createElement( 'span' );
cursor.style.cssText = 'display:inline-block;width:0.6em;height:1.1em;background:currentColor;margin-left:4px;vertical-align:middle;animation:frblBlinkCursor 1s infinite;';

el.appendChild( textSpan );
Expand Down Expand Up @@ -469,11 +469,11 @@ const ANIMATION_PREVIEWS = {
el.style.overflow = 'hidden';
el.innerHTML = '';

const textSpan = document.createElement( 'span' );
const textSpan = el.ownerDocument.createElement( 'span' );
textSpan.textContent = text;
textSpan.style.cssText = 'display:inline-block;opacity:0;';

const block = document.createElement( 'span' );
const block = el.ownerDocument.createElement( 'span' );
block.style.cssText = 'position:absolute;top:0;left:0;width:100%;height:100%;background:currentColor;transform-origin:left;transform:scaleX(0);transition:transform 0.5s cubic-bezier(0.86,0,0.07,1);';

el.appendChild( textSpan );
Expand Down Expand Up @@ -530,7 +530,7 @@ const ANIMATION_PREVIEWS = {
const indices = chars.map( ( _, i ) => i ).sort( () => Math.random() - 0.5 );

const spanList = chars.map( ( char ) => {
const span = document.createElement( 'span' );
const span = el.ownerDocument.createElement( 'span' );
span.className = 'frbl-char';
span.textContent = char;
span.style.cssText = 'display:inline-block;white-space:pre;opacity:0;';
Expand Down Expand Up @@ -831,7 +831,7 @@ const ANIMATION_PREVIEWS = {

const chars = text.split( '' );
const spanList = chars.map( ( char ) => {
const span = document.createElement( 'span' );
const span = el.ownerDocument.createElement( 'span' );
span.className = 'frbl-char';
el.appendChild( span );
return { el: span, char, isSpace: char === ' ' };
Expand Down Expand Up @@ -1245,12 +1245,17 @@ function TextAnimationEdit( props ) {
</InspectorControls>

{ showPreview ? (
<AnimationPreview
animationType={ animationType }
text={ stripHtml( content ) || __( 'Write your text here…', 'frontblocks' ) }
style={ previewStyle }
Tag={ htmlTag }
/>
// API version 3: the edit output must always carry the block props on its
// root element. The preview Tag has its own typography, so the wrapper only
// keeps the block identity (ref, data attributes, classes) and the margins.
<div { ...blockProps } style={ { marginLeft: 0, marginRight: 'auto' } }>
<AnimationPreview
animationType={ animationType }
text={ stripHtml( content ) || __( 'Write your text here…', 'frontblocks' ) }
style={ previewStyle }
Tag={ htmlTag }
/>
</div>
) : (
<RichText
{ ...blockProps }
Expand All @@ -1266,6 +1271,7 @@ function TextAnimationEdit( props ) {
}

registerBlockType( 'frontblocks/text-animation', {
apiVersion: 3,
title: __( 'FrontBlocks - Text Animation', 'frontblocks' ),
description: __( 'Animated text block with typography controls. Add animation effects from the sidebar.', 'frontblocks' ),
category: 'text',
Expand Down
28 changes: 19 additions & 9 deletions assets/text-animation/frontblocks-text-animation.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
"use strict";

function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
function _toConsumableArray(r) { return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread(); }
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
function _iterableToArray(r) { if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r); }
Expand Down Expand Up @@ -705,8 +704,8 @@ var ANIMATION_PREVIEWS = {
var el = containerRef.current;
if (!el) return;
el.innerHTML = '';
var textSpan = document.createElement('span');
var cursor = document.createElement('span');
var textSpan = el.ownerDocument.createElement('span');
var cursor = el.ownerDocument.createElement('span');
cursor.style.cssText = 'display:inline-block;width:0.6em;height:1.1em;background:currentColor;margin-left:4px;vertical-align:middle;animation:frblBlinkCursor 1s infinite;';
el.appendChild(textSpan);
el.appendChild(cursor);
Expand Down Expand Up @@ -772,10 +771,10 @@ var ANIMATION_PREVIEWS = {
el.style.position = 'relative';
el.style.overflow = 'hidden';
el.innerHTML = '';
var textSpan = document.createElement('span');
var textSpan = el.ownerDocument.createElement('span');
textSpan.textContent = text;
textSpan.style.cssText = 'display:inline-block;opacity:0;';
var block = document.createElement('span');
var block = el.ownerDocument.createElement('span');
block.style.cssText = 'position:absolute;top:0;left:0;width:100%;height:100%;background:currentColor;transform-origin:left;transform:scaleX(0);transition:transform 0.5s cubic-bezier(0.86,0,0.07,1);';
el.appendChild(textSpan);
el.appendChild(block);
Expand Down Expand Up @@ -851,7 +850,7 @@ var ANIMATION_PREVIEWS = {
return Math.random() - 0.5;
});
var spanList = chars.map(function (char) {
var span = document.createElement('span');
var span = el.ownerDocument.createElement('span');
span.className = 'frbl-char';
span.textContent = char;
span.style.cssText = 'display:inline-block;white-space:pre;opacity:0;';
Expand Down Expand Up @@ -1274,7 +1273,7 @@ var ANIMATION_PREVIEWS = {
el.innerHTML = '';
var chars = text.split('');
var spanList = chars.map(function (char) {
var span = document.createElement('span');
var span = el.ownerDocument.createElement('span');
span.className = 'frbl-char';
el.appendChild(span);
return {
Expand Down Expand Up @@ -1866,12 +1865,22 @@ function TextAnimationEdit(props) {
});
}
}]
})), showPreview ? /*#__PURE__*/React.createElement(AnimationPreview, {
})), showPreview ?
/*#__PURE__*/
// API version 3: the edit output must always carry the block props on its
// root element. The preview Tag has its own typography, so the wrapper only
// keeps the block identity (ref, data attributes, classes) and the margins.
React.createElement("div", _objectSpread(_objectSpread({}, blockProps), {}, {
style: {
marginLeft: 0,
marginRight: 'auto'
}
}), /*#__PURE__*/React.createElement(AnimationPreview, {
animationType: animationType,
text: stripHtml(content) || __('Write your text here…', 'frontblocks'),
style: previewStyle,
Tag: htmlTag
}) : /*#__PURE__*/React.createElement(RichText, _extends({}, blockProps, {
})) : /*#__PURE__*/React.createElement(RichText, _objectSpread(_objectSpread({}, blockProps), {}, {
tagName: htmlTag,
value: content,
onChange: function onChange(value) {
Expand All @@ -1884,6 +1893,7 @@ function TextAnimationEdit(props) {
})));
}
registerBlockType('frontblocks/text-animation', {
apiVersion: 3,
title: __('FrontBlocks - Text Animation', 'frontblocks'),
description: __('Animated text block with typography controls. Add animation effects from the sidebar.', 'frontblocks'),
category: 'text',
Expand Down
24 changes: 18 additions & 6 deletions assets/user-text/frontblocks-user-text-option.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const { registerBlockType } = wp.blocks;
const { Fragment, useState, useEffect } = wp.element;
const { Fragment, useState, useEffect, useRef } = wp.element;
const { useSelect } = wp.data;
const {
InspectorControls,
Expand Down Expand Up @@ -51,19 +51,28 @@ const TEXT_ALIGN_OPTIONS = [

/**
* Resolve a CSS var like "var(--wp--preset--font-size--large)" to a real value
* using computed styles on the document root.
* using computed styles on the root of the document that holds the block.
*
* The editor canvas is an iframe (block API version 3) and the theme presets
* are defined inside it, so the lookup must go through the block's own
* ownerDocument rather than the global document of the wp-admin page.
*/
function resolveCssVar( value ) {
function resolveCssVar( value, element ) {
if ( ! value || ! value.startsWith( 'var(' ) ) return value;
const match = value.match( /var\(\s*(--[^,)]+)/ );
if ( ! match ) return value;
const resolved = getComputedStyle( document.documentElement )
const doc = element ? element.ownerDocument : null;
const view = doc ? doc.defaultView : null;
if ( ! doc || ! view ) return value;
const resolved = view
.getComputedStyle( doc.documentElement )
.getPropertyValue( match[1] )
.trim();
return resolved || value;
}

registerBlockType( 'frontblocks/user-text', {
apiVersion: 3,
title: __( 'User Text', 'frontblocks' ),
description: __( 'Text pattern with logged-in user data placeholders.', 'frontblocks' ),
category: 'text',
Expand All @@ -88,6 +97,9 @@ registerBlockType( 'frontblocks/user-text', {
fontFamily, fontWeight, textAlign, loggedOutText,
} = attributes;

// Ref on the block root, used to reach the (iframed) canvas document.
const blockRef = useRef( null );

// ── Current user (with email, needs context=edit) ──────────────────
const [ currentUser, setCurrentUser ] = useState( null );
useEffect( () => {
Expand Down Expand Up @@ -116,7 +128,7 @@ registerBlockType( 'frontblocks/user-text', {
// Resolve CSS vars to real values for display
const resolved = {};
Object.keys( merged ).forEach( ( k ) => {
resolved[ k ] = resolveCssVar( merged[ k ] );
resolved[ k ] = resolveCssVar( merged[ k ], blockRef.current );
} );
setThemeTypo( resolved );
} )
Expand Down Expand Up @@ -151,7 +163,7 @@ registerBlockType( 'frontblocks/user-text', {
textAlign: textAlign || undefined,
};

const blockProps = useBlockProps();
const blockProps = useBlockProps( { ref: blockRef } );
const Tag = htmlTag || 'p';

// Helper: placeholder showing theme default when field is empty
Expand Down
Loading
Loading