Gathering detailed insights and metrics for typewriter-editor
Gathering detailed insights and metrics for typewriter-editor
Gathering detailed insights and metrics for typewriter-editor
Gathering detailed insights and metrics for typewriter-editor
@typewriter/editor
The core editor for typewriter. Manages the data model and updates. Can be run headless.
@typewriter/document
An immutable text document format using Delta format broken into lines for optimized rendering.
editorjs-typewriter
Editor.js — Native JS, based on API and Open Source
@typewriter/view-vdom
A view powered by a light-weight virtual DOM to render editor contents to the DOM.
npm install typewriter-editor
Typescript
Module System
Node Version
NPM Version
75.4
Supply Chain
96.1
Quality
87.4
Maintenance
100
Vulnerability
100
License
TypeScript (77.93%)
Svelte (19.8%)
CSS (1.05%)
JavaScript (1.04%)
HTML (0.18%)
Total Downloads
89,849
Last Day
9
Last Week
74
Last Month
841
Last Year
13,310
402 Stars
614 Commits
32 Forks
9 Watching
8 Branches
6 Contributors
Minified
Minified + Gzipped
Latest Version
0.9.4
Package Id
typewriter-editor@0.9.4
Unpacked Size
1.55 MB
Size
329.02 kB
File Count
157
NPM Version
10.9.0
Node Version
18.20.2
Publised On
21 Nov 2024
Cumulative downloads
Total Downloads
Last day
-60.9%
9
Compared to previous day
Last week
-58.4%
74
Compared to previous week
Last month
-31.5%
841
Compared to previous month
Last year
14.2%
13,310
Compared to previous year
2
1
Built on the same data model as Quill.js, the Delta format, and using a tiny virtual DOM, Superfine, Typewriter aims to make custom rich text editors faster, easier, and more powerful. Need something out-of-the-box? Typewriter is not for you. Typewriter provides the tools to easily create your own custom editor. Build the user interface with Svelte renderless components using its slot features.
Typewriter was built for Dabble, an in-browser app for novelists to write their stories (think Google Docs but just for Novels). Dabble required the ability to customize the editor to look and work a certain way, great performance on large documents, a mechanism for decorating the display without altering the underlying data (for find-and-replace and collaboration), and conceptual simplicity so Dabble could be customized without brain meltdown. Some of the editors available provided some of these things, but none provided all. And none provided the performance needed for working smoothly with documents 10k+ words long on low-powered Chromebooks and mobile devices.
A new class of rich text editors for the web has emerged in recent years backed by their own data model and using ContentEditable as an input mechanism. These editors provide consistent display across every browser, bypass many of the bugs inherent with ContentEditable, give the ability to create your own custom editor with the building blocks provided, and allow realtime updates with collaborators (using operational transforms or CRDTs).
Some of these editors are dependent on a large framework such as Vue or React. These are good choices if you are already paying the cost of the framework overhead. If you are not, they add a lot of code size for your editor. Examples of these are React’s Draft.js and Slate.
Some of these editors—such as ProseMirror and CKEditor5—use a hierarchical data model similar to HTML. This gives complete control over what is allowed in the editor but comes with a high complexity cost. It is more difficult to conceptualize a hierarchical document that can be any depth than it is a plain text document, a flat list of characters. Because of this, it can also be more difficult to customize editors using a hierarchical data model because the API is more complex, but ultimately it is more flexible and powerful.
Other editors such as Quill.js and Medium's editor use a linear data model which is much easier to reason about and simpler to work with. These editors do not allow as much flexibility over the output as their hierarchical cousins, but many (perhaps most) types of content can be represented linearly, and you don’t need a PhD in the editor to customize it.
Typewriter pulls bits from all these editors and takes the best of each of them.
Typewriter goes with the linear approach, building off the same data model as Quill.js, the [Delta](https://github.com/quilljs/delta/)
format. Typewriter modifies Delta
to provide better memory usage with an immutable approach and adds a layer on top, TextDocument
, which splits a Delta
document into lines to add even more memory benefits for large documents. This model is more similar to the Medium editor (which is line-based) and provides greater runtime performance, especially on larger documents. It also paves the way for document virtualization which allows documents with hundreds of thousands of words to render as quickly as a hundred word document and gives responsive typing.
Typewriter avoids large frameworks by using a tiny virtual DOM for rendering its own content. For toolbars, it provides optional renderless Svelte components that help you build your own toolbars and popup menus. Svelte is a framework which doesn't include a library of framework code. It avoids the virtual DOM overhead and only includes the code you use for your component. Of course, you can create your own toolbars and UI in your framework of choice and contribute them back to the community.
Typewriter adds Decorations like ProseMirror which support changes to how the document is displayed without changing the document. It does this in a performant manner. This is used for features like highlighting find-replace words or inserting a collaborator's cursor.
For an overview of the Typerwriter concepts and how it works, see the Typewriter Guide.
Typewriter is influenced by Quill.js, being built on the same data model. Here are some notable differences:
select([ startIndex, endIndes ])
rather than setSelection(index, length)
).insert
replaces Quill's insertText
and insertEmbed
methods and allows overwriting selected content in one operation. With Quill you need call deleteText
first to do the same, creating 2 operations.<br>
tags to be inserted when Shift+Enter
is pressed when your instance allows.Typewriter has recently undergone a huge rewrite, moving from using just the Delta
format to its new TextDocument
model for enhanced performance in decorations and rendering and opening the way for even more performance with virtualized rendering. Many smaller things learned from the previous iterations have been incorporated. There are still bugs and may be some API changes, but those should decrease as Typewriter settles into its new trajectory.
Virtualized rendering is buggy and not ready for production.
If you are interested in being a part of something new:
Add Typewriter to your project:
npm install --save typewriter-editor
Import it in your app, create an editor and add it to the page:
1import { Editor } from 'typewriter-editor'; 2 3const editor = new Editor(); 4 5document.body.appendChild(editor.root);
Your editor root is a plain <div>
and will assume the styling of the page. Add additional styling as required.
To test Typewriter out locally, clone this repo to your computer and run:
npm install
npm start
Then open https://localhost:9000/ to view the examples app.
To run the few tests:
npm test
There are some examples of use in the examples folder. You can run this locally after cloning Typewriter to your machine by running:
$ npm install
$ npm start
Then opening your browser to localhost:9000.
Thanks for taking the time to help! We intend Typewriter to be a useful tool and always appreciate any contributions in building it, no matter how big or small.
Please submit issues, discuss things, contribute PRs to add or fix things.
Our Contribution guidelines are available at CONTRIBUTING.md
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
8 existing vulnerabilities detected
Details
Reason
2 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 1
Reason
Found 0/29 approved changesets -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Score
Last Scanned on 2024-12-16
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More