Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@rsuite/document-nav

Package Overview
Dependencies
Maintainers
5
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@rsuite/document-nav - npm Package Compare versions

Comparing version 1.0.10 to 1.0.11

6

lib/Nav.js

@@ -9,2 +9,4 @@ 'use strict';

var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();

@@ -95,2 +97,3 @@

value: function componentDidMount() {
console.log(typeof window === 'undefined' ? 'undefined' : _typeof(window), typeof document === 'undefined' ? 'undefined' : _typeof(document));
this.reload();

@@ -216,4 +219,3 @@ }

} else {
var _children = node.children;
var _children = node.children || [];
for (var i = 0; i < _children.length; i += 1) {

@@ -220,0 +222,0 @@ this.traverseTitle(_children[i], titleList, anchors, deep + 1);

{
"name": "@rsuite/document-nav",
"version": "1.0.10",
"version": "1.0.11",
"description": "Document navigation is automatically generated based on the HTML title (h1-h6) tag",

@@ -98,2 +98,3 @@ "main": "lib/index.js",

"jest": "^19.0.2",
"jsdom": "^16.0.1",
"json-loader": "^0.5.4",

@@ -100,0 +101,0 @@ "less": "^2.7.1",

@@ -14,3 +14,3 @@ # Document Nav

```js
import { NavProvider, Content, Nav } from '@rsuite/document-nav';
import { Content, Nav } from '@rsuite/document-nav';
import '@rsuite/document-nav/lib/less/index.less';

@@ -20,12 +20,10 @@

return (
<NavProvider>
<div className="row">
<div className="col col-md-4">
<Nav />
</div>
<div className="col col-md-20">
<Content>{require('redeme.md')}</Content>
</div>
<div className="row">
<div className="col col-md-4">
<Nav />
</div>
</NavProvider>
<div className="col col-md-20">
<Content>{require('redeme.md')}</Content>
</div>
</div>
);

@@ -50,6 +48,3 @@ }

`NavProvider` 负责 `Content` 与 `Nav` 的协作,需放在外层,中间可以任意布局。
```
<NavProvider>
<Nav />

@@ -59,3 +54,2 @@ <Content>

</Content>
</NavProvider>
```

@@ -65,2 +59,6 @@

`once` 设置为文档**只解析一次**,用于文章结构不会改变的情况,避免比较解析造成的性能损耗。**如果文档结构会动态改变,请务必设为 `false`**
`deep` 设置为最大解析深度,通常标题所在的层级不会太深,如果文档 DOM 很复杂同时解析层级过深的话会大大影响性能。
**注意**

@@ -71,3 +69,3 @@

```js
import { NavProvider, Content, Nav } from '@rsuite/document-nav';
import { Content, Nav } from '@rsuite/document-nav';
import '@rsuite/document-nav/lib/less/index.less';

@@ -77,12 +75,10 @@

return (
<NavProvider>
<div className="row">
<div className="col col-md-4">
<Nav />
</div>
<div className="col col-md-20">
<Content>{require('redeme.md')}</Content>
</div>
<div className="row">
<div className="col col-md-4">
<Nav />
</div>
</NavProvider>
<div className="col col-md-20">
<Content>{require('redeme.md')}</Content>
</div>
</div>
);

@@ -97,3 +93,3 @@ }

```js
import { NavProvider, Content, Nav } from '@rsuite/document-nav';
import { Content, Nav } from '@rsuite/document-nav';
import '@rsuite/document-nav/lib/less/index.less';

@@ -103,17 +99,15 @@

return (
<NavProvider>
<div className="row">
<div className="col col-md-4">
<Nav>
<Nav.Item anchor="h-3" title="二级标题---2">
<Nav.Item anchor="h-3-1" title="三级标题">
</Nav.Item>
<Nav.Item anchor="h-4" title="二级标题---3" />
</Nav>
</div>
<div className="col col-md-20">
<Content>{require('redeme.md')}</Content>
</div>
<div className="row">
<div className="col col-md-4">
<Nav>
<Nav.Item anchor="h-3" title="二级标题---2">
<Nav.Item anchor="h-3-1" title="三级标题">
</Nav.Item>
<Nav.Item anchor="h-4" title="二级标题---3" />
</Nav>
</div>
</NavProvider>
<div className="col col-md-20">
<Content>{require('redeme.md')}</Content>
</div>
</div>
);

@@ -138,3 +132,3 @@ }

| rtl | boolean `(false)` | 文档从右侧开始阅读 |
| deep | number `(10)` | 解析的 DOM 深度,避免和标题无关的 DOM 层级过深导致的性能损耗 |
| deep | number `(10)` | 解析的 DOM 深度,避免和标题无关的 DOM 层级过深导致的性能损耗 |

@@ -141,0 +135,0 @@ ### `<Nav.Item>`

@@ -92,2 +92,3 @@ // @flow

componentDidMount() {
console.log(typeof window, typeof document)
this.reload();

@@ -195,3 +196,3 @@ }

} else {
const { children } = node;
const children = node.children || [];
for (let i = 0; i < children.length; i += 1) {

@@ -198,0 +199,0 @@ this.traverseTitle(children[i], titleList, anchors, deep + 1);

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc