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

ckeditor5-custom-element

v9.0.1

Published

Insert custom elements (html tags) in ckeditor5

Downloads

412

Readme

ckeditor5-custom-element

npm version Dependency Status devDependency Status

About

This is a plugin for ckeditor 5. It allows to add custom elements in the editor. The html conversion of the created elements looks like this:

	<CustomTag>placeholder text</CustomTag>

Install

Install using NPM:

npm install ckeditor5-custom-element

To add the functionality of this plugin you should make a custom build of the editor. Follow the instructions here.

To load the plugin, configure ckeditor (e.g. edit file ckeditor.js) like this:

Import plugin

import CustomElementPlugin from 'ckeditor5-custom-element/src/customelement';

Import toolbar icons (optional)

import Icon1 from 'path-to-icon/iconfile.svg';

Configure plugin

Assuming that the build is based on Classic Editor:

export default class ClassicEditor extends ClassicEditorBase {}

// Plugins to include in the build.
ClassicEditor.builtinPlugins = [
	...
	CustomElementPlugin,
	...
],

ClassicEditor.defaultConfig = {
	toolbar: {
		items: [
			...
			'custom-element-tagname1',
			'custom-element-tagname2',
			...
			]
	},

	CustomElement:{
		items:[
			{tag: 'tagname1', placeholder: 'some text', 
					attributes:{name:'ABCD'}, icon:Icon1, 
					inline:false, editable:false},
			{tag: 'tagname2'},
			...
		]
	},

	...OTHER OPTIONS
};

Note: the toolbar item names should have the format: custom-element-tagname, where tagname should be replaced by the respective tag of the custom element, the button is going to insert.

Custom element(s) options

The elements can be customized through the CustomElement object that is passed to the editor, as shown above. Many different custom elements can be defined. The following options are available for each one:

  • tag : (string) the tag name for the created custom elements,
  • placeholder : (optional)(string) the text to be displayed inside the custom element (as a text node). If missing, the tag name is displayed,
  • attributes: (optional)(object) any attributes for the created custom elements,
  • icon: (optional)(icon object) icon for the respective toolbar button. If missing, a default icon is used that looks like this: [#],
  • inline: (optional)(boolean) if true, the custom element can be nested within other blocks (e.g. between text), othrewise it is placed only as a root element. Defaults to false,
  • editable: (optional)(boolean) if true, the text inside the custom element can be modified. Defaults to false.

Use

For the time being only addition of custom elements is implemented. If you want to replace a custom element with another, delete first.