Skip to content
This repository has been archived by the owner on Jun 17, 2021. It is now read-only.

Commit

Permalink
Merge branch 'hotfix/2.0.4'
Browse files Browse the repository at this point in the history
  • Loading branch information
Yago committed Mar 9, 2018
2 parents e56cdae + 985c771 commit 4589a3a
Show file tree
Hide file tree
Showing 11 changed files with 30 additions and 23 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Changelog

*2.0.4* (2018-03-09)
- ✨ better inner link handling (ea7dcc8)

*2.0.3* (2018-03-09)
- ✨ relaunch ready hook when route change (0f37a5e)

Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.0.3
2.0.4
4 changes: 2 additions & 2 deletions build/asset-manifest.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"main.css": "static/css/main.99b383b5.css",
"main.css.map": "static/css/main.99b383b5.css.map",
"main.js": "static/js/main.631160b2.js",
"main.js.map": "static/js/main.631160b2.js.map"
"main.js": "static/js/main.4016f53e.js",
"main.js.map": "static/js/main.4016f53e.js.map"
}
2 changes: 1 addition & 1 deletion build/service-worker.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions build/static/js/main.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion build/static/js/main.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "toolbox-reader",
"version": "2.0.3",
"version": "2.0.4",
"private": true,
"eslintConfig": {
"parser": "babel-eslint",
Expand Down
1 change: 1 addition & 0 deletions src/components/App/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ class App extends Component {
}

componentDidMount() {
// Send a ToolboxReady event when App is mounted and on each page change
this.updateHook();
this.props.history.listen(() => this.updateHook());
}
Expand Down
5 changes: 3 additions & 2 deletions src/components/Item/Item.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import SyntaxHighlighter, { registerLanguage } from 'react-syntax-highlighter/di
import xml from 'react-syntax-highlighter/dist/languages/xml';
import { atomOneDark } from 'react-syntax-highlighter/dist/styles';

import parentUrl from '../../helpers/parentUrl';
import './Item.css';

registerLanguage('html', xml);
Expand All @@ -31,8 +32,8 @@ class Item extends Component {
}

handleItemClick(e) {
// Disable all inner links
e.preventDefault();
// If it's a link related event, prevent default
if (parentUrl(e.target)) e.preventDefault();
}

render() {
Expand Down
12 changes: 12 additions & 0 deletions src/helpers/parentUrl.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
const parentUrl = (child) => {
if (child.tagName === 'A') return child;
if (child.parentNode) {
if (child.parentNode.tagName === 'A') {
return child.parentNode;
}
return parentUrl(child.parentNode);
}
return false;
};

export default parentUrl;
16 changes: 3 additions & 13 deletions src/views/Single/SinglePage.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { connect } from 'react-redux';
import PropTypes from 'prop-types';

import { getComponentMarkup } from '../../actions/atomic';
import parentUrl from '../../helpers/parentUrl';

import Single from './Single';

Expand Down Expand Up @@ -31,23 +32,11 @@ class SinglePage extends Single {
handlePageClick(e) {
e.preventDefault();

const parentUrl = (child) => {
if (child.tagName === 'A') return child;
if (child.parentNode) {
if (child.parentNode.tagName === 'A') {
return child.parentNode;
}
return parentUrl(child.parentNode);
}
return false;
};

// If it's a link related event, redirect to page
const linkParent = parentUrl(e.target);
if (linkParent) {
const slug = linkParent.href.split('/pages/').slice(-1)[0];
this.getContent({ Store: this.props.store, match: { params: { slug } } });
this.props.history.push('/pages/homepage');
this.props.history.push(`/pages/${slug}`);
}
}

Expand All @@ -59,6 +48,7 @@ class SinglePage extends Single {
}

SinglePage.propTypes = {
history: PropTypes.object.isRequired,
components: PropTypes.object,
};

Expand Down

0 comments on commit 4589a3a

Please sign in to comment.