mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2026-05-07 18:48:39 +00:00
Merge branch 'fixLinkNavigation' of https://github.com/G-Ambatte/homebrewery into v3.21-fixes
This commit is contained in:
@@ -33,7 +33,7 @@ const INITIAL_CONTENT = dedent`
|
|||||||
<link href='/homebrew/bundle.css' type="text/css" rel='stylesheet' />
|
<link href='/homebrew/bundle.css' type="text/css" rel='stylesheet' />
|
||||||
<link href="${brewRendererStylesUrl}" rel="stylesheet" />
|
<link href="${brewRendererStylesUrl}" rel="stylesheet" />
|
||||||
<link href="${headerNavStylesUrl}" rel="stylesheet" />
|
<link href="${headerNavStylesUrl}" rel="stylesheet" />
|
||||||
<base target=_blank>
|
<base target="_top">
|
||||||
</head><body style='overflow: hidden'><div></div></body></html>`;
|
</head><body style='overflow: hidden'><div></div></body></html>`;
|
||||||
|
|
||||||
|
|
||||||
@@ -272,6 +272,13 @@ const BrewRenderer = (props)=>{
|
|||||||
const frameDidMount = ()=>{ //This triggers when iFrame finishes internal "componentDidMount"
|
const frameDidMount = ()=>{ //This triggers when iFrame finishes internal "componentDidMount"
|
||||||
scrollToHash(window.location.hash);
|
scrollToHash(window.location.hash);
|
||||||
|
|
||||||
|
navigation.addEventListener('navigate', (e)=>{
|
||||||
|
if(e.hashChange && e.destination.sameDocument){
|
||||||
|
const dest = e.destination.url.slice(e.destination.url.indexOf('#'));
|
||||||
|
scrollToHash(dest);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
setTimeout(()=>{ //We still see a flicker where the style isn't applied yet, so wait 100ms before showing iFrame
|
setTimeout(()=>{ //We still see a flicker where the style isn't applied yet, so wait 100ms before showing iFrame
|
||||||
renderPages(); //Make sure page is renderable before showing
|
renderPages(); //Make sure page is renderable before showing
|
||||||
setState((prevState)=>({
|
setState((prevState)=>({
|
||||||
|
|||||||
@@ -104,7 +104,7 @@ const HeaderNavItem = ({ link, text, depth, className })=>{
|
|||||||
if(!link || !text) return;
|
if(!link || !text) return;
|
||||||
|
|
||||||
return <li>
|
return <li>
|
||||||
<a href={`#${link}`} target='_self' className={`depth-${depth} ${className ?? ''}`}>
|
<a href={`#${link}`} className={`depth-${depth} ${className ?? ''}`}>
|
||||||
{trimString(text, depth)}
|
{trimString(text, depth)}
|
||||||
</a>
|
</a>
|
||||||
</li>;
|
</li>;
|
||||||
|
|||||||
+3
-3
@@ -70,9 +70,9 @@ renderer.link = function (token) {
|
|||||||
if(title) {
|
if(title) {
|
||||||
out += ` title="${escape(title)}"`;
|
out += ` title="${escape(title)}"`;
|
||||||
}
|
}
|
||||||
if(self) {
|
// if(self) {
|
||||||
out += ' target="_self"';
|
// out += ' target="_self"';
|
||||||
}
|
// }
|
||||||
out += `>${text}</a>`;
|
out += `>${text}</a>`;
|
||||||
return out;
|
return out;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -34,9 +34,9 @@ renderer.link = function (href, title, text) {
|
|||||||
if(title) {
|
if(title) {
|
||||||
out += ` title="${title}"`;
|
out += ` title="${title}"`;
|
||||||
}
|
}
|
||||||
if(self) {
|
// if(self) {
|
||||||
out += ' target="_self"';
|
// out += ' target="_self"';
|
||||||
}
|
// }
|
||||||
out += `>${text}</a>`;
|
out += `>${text}</a>`;
|
||||||
return out;
|
return out;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -8,8 +8,10 @@ test('Processes the markdown within an HTML block if its just a class wrapper',
|
|||||||
expect(rendered).toBe('<div> <p><em>Bold text</em></p>\n </div>');
|
expect(rendered).toBe('<div> <p><em>Bold text</em></p>\n </div>');
|
||||||
});
|
});
|
||||||
|
|
||||||
test('Check markdown is using the custom renderer; specifically that it adds target=_self attribute to internal links in HTML blocks', function() {
|
// TEST REMOVED AS IT IS NO LONGER REQUIRED
|
||||||
const source = '<div>[Has _self Attribute?](#p1)</div>';
|
//
|
||||||
const rendered = Markdown.render(source);
|
// test('Check markdown is using the custom renderer; specifically that it adds target=_self attribute to internal links in HTML blocks', function() {
|
||||||
expect(rendered).toBe('<div> <p><a href="#p1" target="_self">Has _self Attribute?</a></p>\n </div>');
|
// const source = '<div>[Has _self Attribute?](#p1)</div>';
|
||||||
});
|
// const rendered = Markdown.render(source);
|
||||||
|
// expect(rendered).toBe('<div> <p><a href="#p1" target="_self">Has _self Attribute?</a></p>\n </div>');
|
||||||
|
// });
|
||||||
|
|||||||
Reference in New Issue
Block a user