npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

slider-doc

v1.1.4

Published

Make html element to be slider view

Downloads

7

Readme

slider-doc

Build status Test coverage NPM version NPM Downloads Prettier Conventional Commits

Make html element to be slider view

一建转换文档为 PPT 演示

在线 DEMO

快捷键列表:

  • ESC / O : 打开整体预览模式
  • Cmd + ESC / Ctrl + ESC: 退出 PPT 模式
  • 方向键:PPT 翻页

原理

image.png

解析 DOM 树,生成树结构如下:

<h1>标题</h1>
<p>内容</p>
<h2>标题2</h2>
<p>内容2</p>

会解析成

{
  type: 'lvl',
  level: 1,
  value: '标题',
  children: [
    {
      type: 'text',
      value: '内容'
    },
    {
      type: 'lvl',
      level: 2,
      value: '标题2',
      children: [
        {
          type: 'text',
          value: '内容2'
        }
      ]
    }
  ]
}

Installation

npm install slider-doc
# or use yarn
yarn add slider-doc

Usage

import sliderDoc from 'slider-doc'

const silder = sliderDoc({
  lvl0: '.doc h1',
  lvl1: '.doc h2',
  lvl2: '.doc h3',
  lvl3: '.doc h4',
  lvl4: '.doc h5'
})

API

sliderDoc(selectors, options?)

selectors

同时扩展了 code 类型的 text selector,方便展示代码块

{
  code: '.post pre'
}

options

document
  • Type: Document
  • Default: document
excludes

解析 dom 之前,需要剔除的 element

  • Type: Selector[] - see Selector
  • Default: []
revealConfig

Reveal.js 的配置

mountContainer

Reveal.js 挂载的节点

  • Type: Element
  • Default: document.body
renderers

自定义渲染

  • Type: Array<(vNode, ctx, next) => string>

  • Default: []

  • Example:

    ;[
      (vNode, ctx, next) => {
        if (vNode.type === 'text') {
          return `<span>${vNode.value}</span>`
        }
        return next()
      }
    ]
renderSectionAttrs

渲染外层 Section 时候注入的属性

  • Type: (vNode, ctx) => string
  • Default: () => 'data-transition="fade-in slide-out"'

Todo

  • [ ] Feat: 生成 reveal.js 的 dom 实例,而不是 html,可以带上 dom 交互(如 React 组件)

Contributing

  • Fork it!
  • Create your new branch:
    git checkout -b feature-new or git checkout -b fix-which-bug
  • Start your magic work now
  • Make sure npm test passes
  • Commit your changes:
    git commit -am 'feat: some description (close #123)' or git commit -am 'fix: some description (fix #123)'
  • Push to the branch: git push
  • Submit a pull request :)

Authors

This library is written and maintained by imcuttle, [email protected].

License

MIT - imcuttle 🐟