taqueci / redmine_wysiwyg_editor

Redmine WYSIWYG Editor plugin
GNU General Public License v2.0
116 stars 28 forks source link

Editor configuration by external tool #24

Closed taqueci closed 6 years ago

taqueci commented 6 years ago

Add ability to configure editor by external tool. e.g. View customize plugin

taqueci commented 6 years ago

Variable WYSIWYG_EDITOR_CONFIG is used as TinyMCE editor initialization.

If you want to set editor height with 320px, set View customize plugin setting with:

var WYSIWYG_EDITOR_CONFIG = {
  height: 320
};
taqueci commented 6 years ago

Variable name is changed from WYSIWYG_EDITOR_CONFIG to WYSIWYG_EDITOR_SETTING.

If you want to set editor height with 320px, set View customize plugin setting with:

var WYSIWYG_EDITOR_SETTING = {
  height: 320
};
chevi commented 6 years ago

Hi @taqueci

I've tried this solution with Tampermonkey Chrome plugin, which do the same as View customize plugin, but have no luck to change height. Where should this code to be placed? At the start of the page? Or before what element loads I should define this variable?

var WYSIWYG_EDITOR_SETTING = {
  height: 320
};

My script is:

var WYSIWYG_EDITOR_SETTING = {
      height: 720
  };

// next lines to check variable, when editor is loaded
waitForKeyElements("#mce_0_ifr", actionFunction);

function actionFunction(jNode) {
  console.log(WYSIWYG_EDITOR_SETTING);
}

Result: console: {height: 720} height is not changed NOTE: I tried height: "720px" - no luck too

Could you please add a screenshot from the "View customize plugin" with this setting defining?

Thanks!

chevi commented 6 years ago

Hi @taqueci

Tried your script from https://github.com/taqueci/redmine_wysiwyg_editor/issues/25#issuecomment-425889059 and it works on Tampermonkey. But still have a trouble how to set WYSIWYG_EDITOR_SETTING variable

taqueci commented 6 years ago

Hi @chevi

Tampermonkey may not set global variable. I have no idea to solve so far.

Please use View Customize plugin.

Tampermonkey is useful. I want to consider it when I have time.

chevi commented 6 years ago

Hi @taqueci

Just for note This is script in Tampermonkey

var WYSIWYG_EDITOR_SETTING = {
    height: 720,
    plugins: 'link lists hr table textcolor paste',
    paste_as_text: true
};
console.log("just script beginning");
console.log(WYSIWYG_EDITOR_SETTING);

$(function() {
    try {
        tinymce.on('AddEditor', function(e) {
            console.log("added editor");
            console.log(WYSIWYG_EDITOR_SETTING);
            var id = '#' + e.editor.id + '_ifr';

            e.editor.on('init', function(e) {
                var tab = $(id).closest('.wysiwyg-editor').parent().find('.wysiwyg-editor-tab');
                console.log("init editor");
                console.log(WYSIWYG_EDITOR_SETTING);
                tab.find('a[data-type=visual]').trigger('click');
                tab.hide();
            });
        });
    } catch (e) {}
});

console output: image

After page loaded global variable is not accessible image

I think that variable is set and accessible in the moment of the editor initiation. Maybe there is a bug?!