madebymany/sir-trevor-js

How to write plugins for scribe?

Closed this issue · 11 comments

I would like to extend the format bar by new icons and functionality. How does that work?

I've looked for kind of a guide round scribe, but found nothing helpful for that task.

What sort of functionality are you trying to add?
On Wed, Jul 27, 2016 at 08:34 Matthias Lindinger notifications@github.com
wrote:

I would like to extend the format bar by new icons and functionality. How
does that work?

I've looked for kind of a guide round scribe, but found nothing helpful
for that task.


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
#505, or mute the
thread
https://github.com/notifications/unsubscribe-auth/AABvmi0gRX1xjxtofI3llNC2G83pSb_6ks5qZwoegaJpZM4JV6jX
.

I would like to create links, but for that task I need to get data from a backend.

I'll get back to you shortly with some tips.

Step 1.

Define your toolbar commands
https://github.com/madebymany/sir-trevor-js/blob/master/src/config.js#L66-L112

Step 2.

Modify the linkPrompt plugin
https://github.com/guardian/scribe-plugin-link-prompt-command

The main file is
https://github.com/guardian/scribe-plugin-link-prompt-command/blob/master/src/scribe-plugin-link-prompt-command.js

You'll find this assigns scribe.commands.linkPrompt which is the cmd set in the config.
So what you'll do is write your own plugin and then assign it to something like scribe.commands.customLinkPrompt then modify the formatBar.commands in your config override.

Step 3.

You'll need to find a way to call scribe.usefor the plugin.

If it needs to be on all blocks then you'll need to patch something in:
https://github.com/madebymany/sir-trevor-js/blob/master/src/scribe-interface.js#L43

Per block you can define configureScribe
https://github.com/madebymany/sir-trevor-js/blob/master/src/blocks/text.js#L26

Oooo this might be an idea to add it to the wiki for future reference.

Going to improve it and then i'll add it to the docs. Along with a change to make it easier to include things to all scribe content areas.

Added some basic docs to: http://madebymany.github.io/sir-trevor-js/docs.html#5

More to come

Coolbeans - right then, that gives me something to play around with at home now (finally getting properly started with Git and grunt for building the projects at home) including looking at updates to v.0.6.

On a related note then, there might be a PR's of some bits and possiblity some new custom blocks too to add in the main repo but i'll do them as and when I have a better grasp of whats going on with v0.6 (namely tweaks for videos and images).

@SgtOddball i'd recommend creating some issues before doing any hefty pr's. SirTrevor is opinionated about the core code and it would be good to think more generally about what you are trying to achieve if it's something that might not get accepted.

If you want to share the custom blocks with others then when they are created let's add them to the wiki.

It's not going to be anything too heavy, just the image type check for the uploads and some further revised regex for validation of videos.

As for custom blocks that was the idea once i've finished rejigging them off jQuery (monkey.. meet back... now get off it).

Thank you very much for your tips, @raffij! That helped me a lot.