mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2026-01-04 16:52:38 +00:00
Move import to be adjacent to existing requires
This commit is contained in:
@@ -18,6 +18,8 @@ const { printCurrentBrew } = require('../../../shared/helpers.js');
|
|||||||
|
|
||||||
const Themes = require('themes/themes.json');
|
const Themes = require('themes/themes.json');
|
||||||
|
|
||||||
|
import { safeHTML } from './safeHTML.js';
|
||||||
|
|
||||||
const PAGE_HEIGHT = 1056;
|
const PAGE_HEIGHT = 1056;
|
||||||
|
|
||||||
const INITIAL_CONTENT = dedent`
|
const INITIAL_CONTENT = dedent`
|
||||||
@@ -28,7 +30,6 @@ const INITIAL_CONTENT = dedent`
|
|||||||
<base target=_blank>
|
<base target=_blank>
|
||||||
</head><body style='overflow: hidden'><div></div></body></html>`;
|
</head><body style='overflow: hidden'><div></div></body></html>`;
|
||||||
|
|
||||||
import { safeHTML } from './safeHTML.js';
|
|
||||||
|
|
||||||
//v=====----------------------< Brew Page Component >---------------------=====v//
|
//v=====----------------------< Brew Page Component >---------------------=====v//
|
||||||
const BrewPage = (props)=>{
|
const BrewPage = (props)=>{
|
||||||
@@ -78,19 +79,19 @@ const BrewRenderer = (props)=>{
|
|||||||
rawPages = props.text.split(/^\\page$/gm);
|
rawPages = props.text.split(/^\\page$/gm);
|
||||||
}
|
}
|
||||||
|
|
||||||
const scrollToHash = (hash) => {
|
const scrollToHash = (hash)=>{
|
||||||
if (!hash) return;
|
if(!hash) return;
|
||||||
|
|
||||||
const iframeDoc = document.getElementById('BrewRenderer').contentDocument;
|
const iframeDoc = document.getElementById('BrewRenderer').contentDocument;
|
||||||
let anchor = iframeDoc.querySelector(hash);
|
let anchor = iframeDoc.querySelector(hash);
|
||||||
|
|
||||||
if (anchor) {
|
if(anchor) {
|
||||||
anchor.scrollIntoView({ behavior: 'smooth' });
|
anchor.scrollIntoView({ behavior: 'smooth' });
|
||||||
} else {
|
} else {
|
||||||
// Use MutationObserver to wait for the element if it's not immediately available
|
// Use MutationObserver to wait for the element if it's not immediately available
|
||||||
new MutationObserver((mutations, obs) => {
|
new MutationObserver((mutations, obs)=>{
|
||||||
anchor = iframeDoc.querySelector(hash);
|
anchor = iframeDoc.querySelector(hash);
|
||||||
if (anchor) {
|
if(anchor) {
|
||||||
anchor.scrollIntoView({ behavior: 'smooth' });
|
anchor.scrollIntoView({ behavior: 'smooth' });
|
||||||
obs.disconnect();
|
obs.disconnect();
|
||||||
}
|
}
|
||||||
@@ -202,8 +203,8 @@ const BrewRenderer = (props)=>{
|
|||||||
styleObject.backgroundImage = `url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' version='1.1' height='40px' width='200px'><text x='0' y='15' fill='%23fff7' font-size='20'>${global.config.deployment}</text></svg>")`;
|
styleObject.backgroundImage = `url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' version='1.1' height='40px' width='200px'><text x='0' y='15' fill='%23fff7' font-size='20'>${global.config.deployment}</text></svg>")`;
|
||||||
}
|
}
|
||||||
|
|
||||||
const renderedStyle = useMemo(()=> renderStyle(), [props.style, props.themeBundle]);
|
const renderedStyle = useMemo(()=>renderStyle(), [props.style, props.themeBundle]);
|
||||||
renderedPages = useMemo(() => renderPages(), [props.text]);
|
renderedPages = useMemo(()=>renderPages(), [props.text]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
|
|||||||
Reference in New Issue
Block a user