snowgoon88 / TW5-extendedit

Try to extend the editor of TiddlyWiki5
MIT License
38 stars 10 forks source link

Editor Independent Implementation #8

Open tgrosinger opened 6 years ago

tgrosinger commented 6 years ago

Maybe this is completely unreasonable, I have not actually looked at the code for this plugin. But would it be possible to have an editor-independent implementation? I use the codemirror editor, but would love to have this functionality.

Thanks.

snowgoon88 commented 6 years ago

I've tried to make my code as modular as possible but I fear that to adapt it to another editor, a bit of coding will be required. For example, to add my 'plugin' to the basic editor (file simple.js), I copied the simple.js of Tiddlyiki and, to this file, I juste have to add a few lines for the completion to be added. More specifically, in the current version I've added At the start

// Configuration tiddler
var COMPLETION_OPTIONS = "$:/plugins/snowgoon88/edit-comptext/config";
var Completion = require("$:/plugins/snowgoon88/edit-comptext/completion.js").Completion;

Within the definiition of the Editor

        // Completion
    // Load Completion configuration as JSON
        this._configOptions = $tw.wiki.getTiddlerData( COMPLETION_OPTIONS, {} );

and at the end of the definition

// add Completion popup
    this._completion = new Completion( this.widget, this.domNode, this._configOptions );

And this is it, basically... So, not quite editor independant, but maybe quite easy to use in other settings. I hope.