guardian / scribe

DEPRECATED: A rich text editor framework for the web platform
http://guardian.github.io/scribe/
Apache License 2.0
3.51k stars 245 forks source link

Documentation on plugins #315

Open christopherliu opened 9 years ago

christopherliu commented 9 years ago

Hello,

I'm starting to work on adding plugins to Scribe, and so I thought I'd write down the notes I've taken so far so others could look and correct/add. Eventually I'd like to add them to the source/wiki, but I'm still working on them and I haven't figured out which yet.


Q: How to add Commands to Scribe?

Required API for any Command added to Scribe
Command.execute = run the command
Command.queryState = whether the command has already been applied to the selection
Command.queryEnabled = whether a command is available to use

How does one "patch" a command with CommandPatch?
If a command already exists in document.execCommand, creating a CommandPatch for it will enable that command (and wrap it in a transactionManager). It will otherwise use the default command.

Scribe has a getCommand function that automatically creates a new command if necessary

You can see CommandPatches in plugins/core/patches
hmgibson23 commented 9 years ago

Be nice to say a bit more about the APIs for commands and that you can patch a command by replacing the default APIs with your own but otherwise this looks like a good start!