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 🙏

© 2026 – Pkg Stats / Ryan Hefner

pptx-custom

v0.5.4

Published

Custom content and theme utilities for PPTX JSON templates.

Readme

pptx-custom

English

用于对 json2pptx JSON deck 进行两阶段定制:

  • 内容阶段:将后端内容映射到模板 deck。
  • 主题阶段:替换主题色/字体/背景,并按范围应用媒体资源。

安装

npm i pptx-custom

导出 API

  • applyCustomContent(template, input)
  • parseCustomContent(raw)
  • applyCustomContentToTemplate(template, slides)
  • applyCustomTheme(deck, themeInput)

同时导出类型,包括: CustomSlidePresentationPresentationDataPresentationThemePptxCustomContentInputPptxCustomThemeInputPptxCustomOptionsTemplateJsonTemplateJsonSlideTemplateJsonElementTemplateJsonTheme

快速开始

import {
  applyCustomContent,
  applyCustomTheme,
  parseCustomContent,
  applyCustomContentToTemplate
} from 'pptx-custom'

const withContent = applyCustomContent(templateJSON, backendText)

const withTheme = applyCustomTheme(withContent, {
  themeColors: ['#111111', '#333333', '#555555', '#777777', '#999999', '#BBBBBB'],
  fontColor: '#222222',
  backgroundColor: '#FFFFFF',
  backgroundImage: {
    src: 'https://example.com/background.png',
    scope: {
      cover: false,
      contents: true,
      transition: true,
      content: true,
      end: false
    }
  },
  logoImage: {
    src: 'https://example.com/logo.png',
    position: 'right',
    scope: {
      cover: true,
      contents: true,
      transition: true,
      content: true,
      end: true
    }
  }
})

const slides = parseCustomContent(customContent)
const withContentDirect = applyCustomContentToTemplate(templateJSON, slides)

自定义内容输入格式

parseCustomContentapplyCustomContent 支持:

  1. NDJSON(每行一个 slide)
  2. JSON slide 数组
  3. slides 字段的 JSON 对象
  4. 单个 slide JSON 对象(包含 type

支持的 slide 类型:

  • cover
  • contents
  • transition
  • content
  • end

兼容的历史别名:

  • agenda -> contents
  • section -> transition
  • ending -> end

自定义内容示例:

{"type":"cover","data":{"title":"Title","text":"Subtitle"}}
{"type":"contents","data":{"items":["Part A","Part B"]}}
{"type":"transition","data":{"title":"Part A","text":"Section intro"}}
{"type":"content","data":{"title":"Topic","items":[{"title":"Point","text":"Detail"}]}}
{"type":"end"}

主题输入

applyCustomTheme 接收 PptxCustomThemeInput

  • themeColors: string[](最多使用前 6 个)
  • fontColor: string
  • backgroundColor?: string
  • backgroundImage?: { src, scope, width?, height? }
  • logoImage?: { src, scope, position, width?, height? }
  • clearBackgroundImage?: boolean
  • clearLogoImage?: boolean

scope 可选键: cover | contents | transition | content | end

行为说明

  • applyCustomContentapplyCustomTheme 都会在返回前经过 json2pptx-schema 的解析与规范化。
  • applyCustomContenttype 选模板页;对 contents/content 会优先选择 与输入条目数容量最接近的布局。
  • applyCustomContent 会规范化 logo 元素(imageType: "logo"): 保持在顶部边距内,并移除 logo 裁剪配置。
  • applyCustomTheme 会将背景图以元素形式写入(imageType: "background"), 并将 logo 以 imageType: "logo" 写入。
  • 当同时提供 backgroundImagebackgroundColor 时,会在目标页应用 50% 透明度的背景色叠加效果。
  • 当前行为下,clearBackgroundImage 也会同时清除 logo 图片。