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

@pspdfkit/document-authoring

v1.1.0

Published

A web SDK for word processing and rich text capabilities.

Downloads

78

Readme

Document Authoring SDK

The Document Authoring SDK provides a way to seamlessly embed document authoring capabilities into your web app. It's a WYSIWYG editor that provides features traditionally found only in desktop word processors. You can read more and try a demo on our dedicated product page.

✨ Feature Requests & Feedback

To help us shape this new authoring experience, we highly value your feedback! Please submit any feature requests or bug reports to [email protected] with the subject line "Document Authoring: Feature Request/Bug Report". We appreciate your contributions and are excited to hear your thoughts!

💻 Installation

The package is available on npm, and can be installed with your package manager of choice. The package name is @pspdfkit/document-authoring.

npm install @pspdfkit/document-authoring

⚡️ Quickstart

The visual editor needs a suitable target DOM element:

<!--
  IMPORTANT: An editor target element needs to have its `position` set to a value other than the default or `static`!
  If unsure use `relative`.
-->
<div id="editor" style="position: relative; border: 1px solid black; width: 1024px; height: 600px;"></div>

The npm package can then be imported and the target set to the element:

import DocAuth from '@pspdfkit/document-authoring';

const docAuthSystem = await DocAuth.createDocAuthSystem()

const editor = await docAuthSystem.createEditor(document.getElementById('editor'),{
  document: await docAuthSystem.createDocumentFromPlaintext('Hi there!'),
})

For a typical setup, this is all that's needed.

Other methods

In a static context (with no bundler) you can use the file found at lib/docauth.es.js in the package (located in node_modules/@pspdfkit/document-authoring/lib/docauth.es.js if you installed the SDK via npm).

With the default configuration (CDN assets) this is the only file you need at runtime. If you use this file in your application you will need to use a dynamic import:

// Replace `/lib/docauth.es.js` with the path where the file is available in your setup.
const DocAuth = await import('/lib/docauth.es.js');

const docAuthSystem = await DocAuth.createDocAuthSystem()

const editor = await docAuthSystem.createEditor(document.getElementById('editor'),{
  document: await docAuthSystem.createDocumentFromPlaintext('Hi there!'),
})

Alternatively a version that can be included via a script tag is available at lib/docauth.umd.js in the package (located in node_modules/@pspdfkit/document-authoring/lib/docauth.umd.js if you installed the SDK via npm).

<script src="lib/docauth.umd.js"></script>
<script>
  (async()=>{
    const docAuthSystem = await DocAuth.createDocAuthSystem()
    const editor = await docAuthSystem.createEditor(document.getElementById('editor'),{
      document: await docAuthSystem.createDocumentFromPlaintext('Hi there!'),
    })
  })()
</script>

Example

You can download an example project demoing both TypeScript and JavaScript integration from here, unzip it and run:

npm install
npx vite serve

Fetching assets

By default, the Document Authoring SDK will fetch the required files (fonts, emoji data, etc.) from a public CDN, and no further configuration is needed. See below for instructions on how to self-host assets.

Self-hosting the assets

To host the assets on your own infrastructure you can download them from here and deploy them to a suitable location. Provide an appropriate base path when initializing the Document Authoring SDK.

Example:

// Alternatively you can use `import DocAuth from '@pspdfkit/document-authoring'` if you have a bundler set up.
// Replace `/lib/docauth.es.js` with the path where the file is available in your setup.
const DocAuth = await import('/lib/docauth.es.js');

const docAuthSystem = await DocAuth.createDocAuthSystem({
  assets: {
    // Replace '/document-authoring-assets/' with the path where the assets are available.
    base: '/document-authoring-assets/',
  },
});

Entry points and TypeScript declarations

Typescript type declarations are provided (lib/docauth.d.ts).

The DocAuth.createDocAuthSystem method and the DocAuthSystem type are the main entry points when using this library.

🧾 License

Copyright (c) 2024-present PSPDFKit GmbH. See the evaluation license for more information.