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

Configuring options via a plugin #446

Closed chrishutchinson closed 8 years ago

chrishutchinson commented 8 years ago

Hey folks,

I'm pretty sure I'm missing something, but have trawled through various plugins and haven't been able to see a solution.

I want to change the allowBlockElements option depending on some specific configuration I have (I'm running multiple Scribe instances).

This is my plugin code at present, but it doesn't actually change the value of scribe.options.allowBlockElements. What am I missing?

var ScribeBlockElementsPlugin = function() { 
    return function(scribe) {
        // ...
        scribe.options.allowsBlockElements = false;
        // ...
    };
};
rrees commented 8 years ago

Off the top of my head I think this is correct as options should be immutable once Scribe is in action. Can you run your logic when generating the options block for the initialiser?

chrishutchinson commented 8 years ago

Cheers @rrees! Kept digging and found the Object.freeze(). Thanks for clarifying.

We initially didn't think we could change the configuration before initialisation, but have figured out a solution! Thanks, this can be closed.