Skip to content

Commit

Permalink
Merge branch 'endi/deps' into endi/assettags
Browse files Browse the repository at this point in the history
  • Loading branch information
endiliey committed Nov 29, 2019
2 parents e8db0c0 + 21b2bee commit 3559a11
Show file tree
Hide file tree
Showing 20 changed files with 447 additions and 360 deletions.
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,18 +34,18 @@
"@types/loader-utils": "^1.1.3",
"@types/lodash": "^4.14.149",
"@types/lodash.kebabcase": "^4.1.6",
"@types/node": "^12.12.11",
"@types/node": "^12.12.14",
"@types/react": "^16.9.13",
"@types/react-dev-utils": "^9.0.1",
"@types/semver": "^6.2.0",
"@types/shelljs": "^0.8.6",
"@types/webpack": "^4.41.0",
"@types/webpack-dev-server": "^3.4.0",
"@types/webpack-dev-server": "^3.9.0",
"@types/webpack-merge": "^4.1.5",
"babel-eslint": "^10.0.3",
"enzyme": "^3.10.0",
"enzyme-adapter-react-16": "^1.15.1",
"eslint": "^6.7.0",
"eslint": "^6.7.1",
"eslint-config-airbnb": "^18.0.1",
"eslint-config-prettier": "^6.7.0",
"eslint-plugin-header": "^3.0.0",
Expand All @@ -57,7 +57,7 @@
"jest": "^24.9.0",
"lerna": "^3.19.0",
"lerna-changelog": "^0.8.3",
"lint-staged": "^9.4.3",
"lint-staged": "^9.5.0",
"prettier": "^1.19.1",
"react": "^16.8.4",
"react-dom": "^16.8.4",
Expand Down
10 changes: 5 additions & 5 deletions packages/docusaurus-1.x/lib/static/js/codetabs.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,27 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

// Turn off ESLint for this file because it's sent down to users as-is.

/* eslint-disable */
window.addEventListener('load', function() {
// add event listener for all tab
document.querySelectorAll('.nav-link').forEach(function(el) {
el.addEventListener('click', function(e) {
const groupId = e.target.getAttribute('data-group');
var groupId = e.target.getAttribute('data-group');
document
.querySelectorAll(`.nav-link[data-group=${groupId}]`)
.querySelectorAll('.nav-link[data-group='.concat(groupId, ']'))
.forEach(function(el) {
el.classList.remove('active');
});
document
.querySelectorAll(`.tab-pane[data-group=${groupId}]`)
.querySelectorAll('.tab-pane[data-group='.concat(groupId, ']'))
.forEach(function(el) {
el.classList.remove('active');
});
e.target.classList.add('active');
document
.querySelector(`#${e.target.getAttribute('data-tab')}`)
.querySelector('#'.concat(e.target.getAttribute('data-tab')))
.classList.add('active');
});
});
Expand Down
37 changes: 22 additions & 15 deletions packages/docusaurus-1.x/lib/static/js/scrollSpy.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,57 +5,64 @@
* LICENSE file in the root directory of this source tree.
*/

/* eslint-disable prefer-arrow-callback */
/* eslint-disable */
(function scrollSpy() {
const OFFSET = 10;
let timer;
let headingsCache;
const findHeadings = function findHeadings() {
var OFFSET = 10;
var timer;
var headingsCache;

var findHeadings = function findHeadings() {
return headingsCache || document.querySelectorAll('.toc-headings > li > a');
};
const onScroll = function onScroll() {

var onScroll = function onScroll() {
if (timer) {
// throttle
return;
}

timer = setTimeout(function() {
timer = null;
let activeNavFound = false;
const headings = findHeadings(); // toc nav anchors
var activeNavFound = false;
var headings = findHeadings(); // toc nav anchors

/**
* On every call, try to find header right after <-- next header
* the one whose content is on the current screen <-- highlight this
*/
for (let i = 0; i < headings.length; i++) {

for (var i = 0; i < headings.length; i++) {
// headings[i] is current element
// if an element is already active, then current element is not active
// if no element is already active, then current element is active
let currNavActive = !activeNavFound;
var currNavActive = !activeNavFound;
/**
* Enter the following check up only when an active nav header is not yet found
* Then, check the bounding rectangle of the next header
* The headers that are scrolled passed will have negative bounding rect top
* So the first one with positive bounding rect top will be the nearest next header
*/

if (currNavActive && i < headings.length - 1) {
const heading = headings[i + 1];
const next = decodeURIComponent(heading.href.split('#')[1]);
const nextHeader = document.getElementById(next);
var heading = headings[i + 1];
var next = decodeURIComponent(heading.href.split('#')[1]);
var nextHeader = document.getElementById(next);

if (nextHeader) {
const top = nextHeader.getBoundingClientRect().top;
var top = nextHeader.getBoundingClientRect().top;
currNavActive = top > OFFSET;
} else {
console.error('Can not find header element', {
id: next,
heading,
heading: heading,
});
}
}
/**
* Stop searching once a first such header is found,
* this makes sure the highlighted header is the most current one
*/

if (currNavActive) {
activeNavFound = true;
headings[i].classList.add('active');
Expand Down
1 change: 1 addition & 0 deletions packages/docusaurus-mdx-loader/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"@babel/traverse": "^7.7.4",
"@mdx-js/mdx": "^1.5.1",
"@mdx-js/react": "^1.5.1",
"escape-html": "^1.0.3",
"github-slugger": "^1.2.1",
"gray-matter": "^4.0.2",
"loader-utils": "^1.2.3",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,47 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`inline code should be escaped 1`] = `
"export const rightToc = [
{
value: '<code>&lt;Head /&gt;</code>',
id: 'head-',
children: [
{
value: '<code>&lt;Head&gt;Test&lt;/Head&gt;</code>',
id: 'headtesthead',
children: []
}
]
},
{
value: '<code>&lt;div /&gt;</code>',
id: 'div-',
children: []
},
{
value: '<code>&lt;div&gt; Test &lt;/div&gt;</code>',
id: 'div-test-div',
children: []
},
{
value: '<code>&lt;div&gt;&lt;i&gt;Test&lt;/i&gt;&lt;/div&gt;</code>',
id: 'divitestidiv',
children: []
}
];
## \`<Head />\`
### \`<Head>Test</Head>\`
## \`<div />\`
## \`<div> Test </div>\`
## \`<div><i>Test</i></div>\`
"
`;

exports[`non text phrasing content 1`] = `
"export const rightToc = [
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
## `<Head />`

### `<Head>Test</Head>`

## `<div />`

## `<div> Test </div>`

## `<div><i>Test</i></div>`
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ test('non text phrasing content', async () => {
expect(result).toMatchSnapshot();
});

test('inline code should be escaped', async () => {
const result = await processFixture('inline-code');
expect(result).toMatchSnapshot();
});

test('text content', async () => {
const result = await processFixture('just-content');
expect(result).toMatchInlineSnapshot(`
Expand Down
3 changes: 2 additions & 1 deletion packages/docusaurus-mdx-loader/src/remark/rightToc/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

const toString = require('mdast-util-to-string');
const visit = require('unist-util-visit');
const escapeHtml = require('escape-html');
const slugs = require('github-slugger')();

// https://github.com/syntax-tree/mdast#heading
Expand All @@ -18,7 +19,7 @@ function toValue(node) {
case 'heading':
return node.children.map(toValue).join('');
case 'inlineCode':
return `<code>${node.value}</code>`;
return `<code>${escapeHtml(node.value)}</code>`;
case 'emphasis':
return `<em>${node.children.map(toValue).join('')}</em>`;
case 'strong':
Expand Down
2 changes: 1 addition & 1 deletion packages/docusaurus-plugin-content-docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"dependencies": {
"@docusaurus/mdx-loader": "^2.0.0-alpha.36",
"@docusaurus/utils": "^2.0.0-alpha.36",
"execa": "^3.3.0",
"execa": "^3.4.0",
"fs-extra": "^8.1.0",
"globby": "^10.0.1",
"import-fresh": "^3.2.1",
Expand Down
7 changes: 6 additions & 1 deletion packages/docusaurus-theme-classic/src/theme/Heading/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,12 @@ const Heading = Tag => ({id, ...props}) => {
return (
<Tag {...props}>
<a aria-hidden="true" tabIndex="-1" className="anchor" id={id} />
<a aria-hidden="true" tabIndex="-1" className="hash-link" href={`#${id}`}>
<a
aria-hidden="true"
tabIndex="-1"
className="hash-link"
href={`#${id}`}
title="Direct link to heading">
#
</a>
{props.children}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,13 @@ export default {
}
return children;
},
a: Link,
a: props => {
if (/\.[^./]+$/.test(props.href)) {
// eslint-disable-next-line jsx-a11y/anchor-has-content
return <a {...props} />;
}
return <Link {...props} />;
},
pre: props => <pre className={styles.mdxCodeBlock} {...props} />,
h1: Heading('h1'),
h2: Heading('h2'),
Expand Down
2 changes: 1 addition & 1 deletion packages/docusaurus/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@
"semver": "^6.3.0",
"shelljs": "^0.8.3",
"std-env": "^2.2.1",
"style-loader": "^1.0.0",
"style-loader": "^1.0.1",
"terser-webpack-plugin": "^2.2.1",
"wait-file": "^1.0.5",
"webpack": "^4.41.2",
Expand Down
6 changes: 3 additions & 3 deletions website/docs/docusaurus-core.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ sidebar_label: Client API

Docusaurus provides some API on client that can be helpful when building your site.

## `<Head />`
## `Head`

This reusable React component will manage all of your changes to the document head. It takes plain HTML tags and outputs plain HTML tags and is beginner-friendly. It is a wrapper around [React Helmet](https://github.com/nfl/react-helmet).

Expand Down Expand Up @@ -55,7 +55,7 @@ Outputs
</head>
```

## `<Link />`
## `Link`

This component enables linking to internal pages as well as a powerful performance feature called preloading. Preloading is used to prefetch resources so that the resources are fetched by the time the user navigates with this component. We use an `IntersectionObserver` to fetch a low-priority request when the `<Link>` is in the viewport and then use an `onMouseOver` event to trigger a high-priority request when it is likely that a user will navigate to the requested resource.

Expand Down Expand Up @@ -145,7 +145,7 @@ function Help() {
}
```

## `<Redirect />`
## `Redirect`

Rendering a `<Redirect>` will navigate to a new location. The new location will override the current location in the history stack, like server-side redirects (HTTP 3xx) do. You can refer to [React Router's Redirect documentation](https://reacttraining.com/react-router/web/api/Redirect) for more info on available props.

Expand Down
2 changes: 1 addition & 1 deletion website/docs/introduction.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ Our shared goal — to help your users find what they need fast, and understand
- Share your code in live editors to get your users love your products on the spot
- 🔍 **Search** Your full site is searchable
- 🌍 **i18n** (_coming soon_)
- 💾 **Versioning** (_coming soon_)
- 💾 **Document Versioning** Helps you keep documentation in sync with project releases.

Docusaurus 2 is born to be compassionately accessible to all your users, and lightning fast.

Expand Down
Loading

0 comments on commit 3559a11

Please sign in to comment.