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

@apostrophecms/rich-text-example-extensions

v1.0.0

Published

Adds new functionality to the ApostropheCMS rich-text-widget

Downloads

16

Readme

This module bundle adds three new extensions to the @apostrophecms/rich-text-widget. While you may find these new extensions useful, they are also a great learning resource and the basis for a series of upcoming tutorials.

Typography

The first extension, @apostrophecms/typography adds a whole series of autocomplete actions to your editor. One example, typing (tm) will autoconvert to . For a whole list check out the documentation. Note that some auto-convert rules (like fractions) won't work if you have the insert menu turned on. You can configure this module either at the project level in the modules/@apostrophecms/rich-text-editor/index.js file, or in the configuration section for the rich-text-widget of individual areas. Example:

widgets: {
  '@apostrophecms/rich-text': {
    insert: [
      ...
    ],
    toolbar: [
      ...
    ],
    styles: [
      ...
    ],
    typoConfig: {
      // Will no longer convert `(tm)` to ™
      trademark: false,
      // Will convert `->` to `=>`
      rightArrow: '=>'
    }
  },
  '@apostrophecms/image': {},
  '@apostrophecms/video': {}
}

Wow! Cool! Neat! But... why? Because this extension shows how to take an existing tiptap extension, that doesn't require a new button or any other control element, and add it to the rich text editor.

Smilies 😀

The second extension, @apostrophecms/smilies adds a host of keyboard shortcuts for smilie emojis, plus my favorite non-emoji ( :ashrug , ¯\_(ツ)_/¯). You can see the full list in the code. Wow! Cool! Neat! But... isn't there a keyboard shortcut for that now? Yup, but this extension is a great way to learn how to create your own small tiptap extension and add it to the rich-text-widget! You can configure this module either at the project level in the modules/@apostrophecms/rich-text-editor/index.js file, or in the configuration section for the rich-text-widget of individual areas to select what skin tone (1 = lightest, 5 = darkest) for the replacement emojis. Note that not all operating systems can display skin tone emojis correctly, so some may not appear as expected. Example:

widgets: {
  '@apostrophecms/rich-text': {
    insert: [
      ...
    ],
    toolbar: [
      ...
    ],
    styles: [
      ...
    ],
    smiliesConfig: {
      tone: 2
    }
  },
  '@apostrophecms/image': {},
  '@apostrophecms/video': {}
}

Character Count

The third extension, @apostrophecms/characterCount allows you to display how many characters and words you have typed in your editor box. You can either open the box from the toolbar or the insert menu. If you add it to the toolbar, it will also tell you how many characters you have highlighted. You can limit the number of characters that can be added to the editor box through the configuration.

widgets: {
  '@apostrophecms/rich-text': {
    insert: [
      'table',
      'image',
      // optionally, add here to have it appear on the insert menu
      'characterCount'
    ],
    toolbar: [
      ...
      // optionally, add it here to have it appear on the toolbar
      'characterCount',
    ],
    styles: [
      ...
    ],
    charCountConfig: {
      // How X!
      limit: 280
    }
  },
  '@apostrophecms/image': {},
  '@apostrophecms/video': {}
}

Wow... okay, okay. Even I can't get that excited about this one. So, why? This extension will show you how to implement a new button on the toolbar or item in the insert menu to bring up the character count box. It will also give you a basic overview of how you would implement the Vue components for each.

Installation

To install the module, use the command line to run this command in an Apostrophe project's root directory:

npm install @apostrophecms/rich-text-example-extensions

Usage

Configure the modules in the app.js file:

require('apostrophe')({
  shortName: 'my-project',
  // Activate the bundle -> subject to change with renaming/ownership change
  bundles: [ 'rich-text-example-extensions' ],
  modules: {
    // The typography module
    '@apostrophecms/typography': {},
    // The smilies module
    '@apostrophecms/smilies': {},
    // The character count module
    '@apostrophecms/characterCount': {}
  }
});

Enabling any of these modules will improve the rich-text-widget, making them available without additional configurations. You will only need to add the characterCount to the toolbar or insert menu (or both!) configuration as shown above.