Security News
RubyGems.org Adds New Maintainer Role
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
compose-editor
Advanced tools
Compose is a rich text editor for the web. It’s still under development — it’s fairly stable, but there are still a few major issues that need to be resolved before it’s production-ready.
If you like what you see, and would like to contribute, please do! Claim an issue as your own by commenting on it — see below for the very basics of how Compose works, and, beyond that, I’d be happy to answer any questions you may have.
Node.js and npm are needed for development on Compose. Clone the repository, then run npm install -D
wherever you cloned Compose to, and you should good to go. Some useful shortcuts for once you’re all set up:
npm run dev
: watches files and rebuilds Compose when they change. You can play around with your changes by opening test/functional/test.html
in a browser; hitting the tab key will initialize an empty editor and focus it.
npm test
: unsurprisingly, this runs the test suite. By default, tests are run in Firefox; to run the tests in Chrome, just do:
$ npm install karma-chrome-launcher
$ BROWSER=chrome npm test
At the heart of Compose are two modules: serialize-elem
and choice
. The user’s selection is saved using choice
, and the coordinates of that selection can then be used to manipulate rich text using serialize-elem
. For example, say an user has entered text like so (the |
denote the endpoints of a left-to-right selection):
<article contenteditable="true">
<p>Stuff |and| things</p>
</article>
Now let’s suppose the user wants to make the selected text italic. We can accomplish this by first saving the selection, using choice
; it will look like:
/**
* These are the start and end points of the selection; it starts in
* paragraph 0, after the sixth character, and ends in paragraph 0
* after the ninth character.
*/
{
start: [0, 6],
end: [0, 9]
}
Now, we convert the selected paragraph into an instance of serialize-elem
, which will allow us to work with it much more easily. We can then make text italic by using some of the serialization’s methods. What we essentially end up doing is:
var paragraph = new Serialize(thatParagraph)
paragraph.addMarkups({
type: Serialize.types.italic,
start: 6,
end: 9
})
thatParagraph.parentNode.replaceChild(paragraph.toElement(), thatParagraph)
All that’s left is to restore the user’s saved selection using choice
, resulting in:
<article contenteditable="true">
<p>Stuff <em>|and|</em> things</p>
</article>
That’s the basic idea behind Compose. If you’d like to dig deeper, here and here are good places to get a better understanding of how it works in practice. If you have any questions, feel free to ask them via GitHub’s issue tracker — I’ll try and get back to you as soon as possible. There’s also a relatively thorough test suite, so, if you would like to see what a particular piece of code does, try commenting it out and see which tests start failing.
MIT.
FAQs
Yet another rich text editor thing.
The npm package compose-editor receives a total of 3 weekly downloads. As such, compose-editor popularity was classified as not popular.
We found that compose-editor demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
Security News
Node.js will be enforcing stricter semver-major PR policies a month before major releases to enhance stability and ensure reliable release candidates.
Security News
Research
Socket's threat research team has detected five malicious npm packages targeting Roblox developers, deploying malware to steal credentials and personal data.