
Research
Security News
Malicious PyPI Package Exploits Deezer API for Coordinated Music Piracy
Socket researchers uncovered a malicious PyPI package exploiting Deezer’s API to enable coordinated music piracy through API abuse and C2 server control.
scribe-editor
Advanced tools
Scribe [](https://travis-ci.org/guardian/scribe) ======
A rich text editor framework for the web platform, with patches for browser inconsistencies and sensible defaults.
For an introduction, you may want to read the blog post Inside the Guardian’s CMS: meet Scribe, an extensible rich text editor.
Please note: There is a lot of missing documentation for Scribe and many of its plugins. We plan to improve this, however in the meantime we encourage you to look at the code. Scribe is very small in comparison to other libraries of its kind.
You can join us on IRC at [#scribejs] on freenode, or via the Google Group.
At the core of Scribe we have:
contenteditable
;Scribe patches many browser inconsistencies in the native command API.
Natively, contenteditable
will produce DIVs for new lines. This is not a bug.
However, this is not ideal because in most cases we require semantic HTML to be
produced.
Scribe overrides this behaviour to produce paragraphs (Ps; default) or BRs (with block element mode turned off) for new lines instead.
bower install scribe
Alternatively, you can access the distribution files through GitHub releases.
allowBlockElements
Scribe is an AMD module:
require(['scribe', 'scribe-plugin-blockquote-command', 'scribe-plugin-toolbar'],
function (Scribe, scribePluginBlockquoteCommand, scribePluginToolbar) {
var scribeElement = document.querySelector('.scribe');
// Create an instance of Scribe
var scribe = new Scribe(scribeElement);
// Use some plugins
scribe.use(scribePluginBlockquoteCommand());
var toolbarElement = document.querySelector('.toolbar');
scribe.use(scribePluginToolbar(toolbarElement));
});
You can see a live example here, or view the code here.
Also be sure to check the examples
directory for an
AMD syntax example as well as a CommonJS (browserify) example.
A plugin is simply a function that receives Scribe as an argument:
function myPlugin(scribe) {}
A consumer can then use your plugin with Scribe.use
:
scribe.use(myPlugin);
Plugins may package whatever functionality you desire, and you are free to use native APIs to do so. However, you are required to wrap any DOM manipulation in a transaction, so that we can capture state changes for the history. For example:
function myPlugin(scribe) {
scribe.transactionManager.run(function () {
// Do some fancy DOM manipulation
});
}
Theoretically, Scribe should work in any browser with the Selection API, the Range API, and support for most of the non-standardised list of commands that appears in this MDN article. It has been tested in Firefox >= 21, Chrome >= 27, and Safari 7.
See the status of our integration tests for more up-to-date support information.
Commands are objects that describe formatting operations. For example, the bold command.
Commands tell Scribe:
document.queryCommand
);document.queryCommandState
);document.queryCommandEnabled
)To ensure a separation of concerns, commands are split into multiple layers. When a command method is called by Scribe, it will be filtered through these layers sequentially.
We have created a collection of plugins for advanced rich text editing purposes, all of which can be seen in use in our example.
Yes. The Guardian is using Scribe as the basis for their internal CMS’ rich text editor.
It is likely that there will be unknown edge cases, but these will be addressed when they are discovered.
The native API for formatting content in a
contenteditable
has many browser inconsistencies.
Scribe has to manipulate the DOM directly on top of using these commands in order to patch
those inconsistencies. What’s more, there is no widely supported command for
telling contenteditable
to insert Ps or BRs for line breaks. Thus, to add
this behaviour Scribe needs to manipulate the DOM once again.
The undo stack breaks whenever DOM manipulation is used instead of the native command API, therefore we have to use our own.
FAQs
A rich text editor framework for the web platform, with patches for browser inconsistencies and sensible defaults.
The npm package scribe-editor receives a total of 2,127 weekly downloads. As such, scribe-editor popularity was classified as popular.
We found that scribe-editor demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 11 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket researchers uncovered a malicious PyPI package exploiting Deezer’s API to enable coordinated music piracy through API abuse and C2 server control.
Research
The Socket Research Team discovered a malicious npm package, '@ton-wallet/create', stealing cryptocurrency wallet keys from developers and users in the TON ecosystem.
Security News
Newly introduced telemetry in devenv 1.4 sparked a backlash over privacy concerns, leading to the removal of its AI-powered feature after strong community pushback.