Can't invoke editor.insertText when codeview is enabled #2170

Open
mazavr opened this Issue Dec 27, 2016 · 0 comments

Projects

None yet

1 participant

@mazavr
mazavr commented Dec 27, 2016

steps to reproduce

  1. Enable codeview mode
  2. Call context.invoke('editor.insertText', ' Text to insert '); in
  3. Nothing happens

browser version and os version

Chrome 55.0.2883.87 m

Stackoverflow question

Custom button code:

    function paramsButton(context) {
        var ui = $.summernote.ui;

        // create button
        let event = ui.buttonGroup([
            ui.button({
                contents: '<span>Custom parameters</span> <span class="note-icon-caret"></span>',
                tooltip: 'Custom parameters',
                className: 'btn-codeview',
                data: {
                    toggle: 'dropdown'
                }
            }),
            ui.dropdown({
                items: vm.customParameters,
                callback: (items) => {
                    $(items).find('li a').on('click', (e) => {
                        context.invoke('editor.insertText', ` ${e.target.innerText} `);
                        e.preventDefault();
                    })
                }
            })
        ]);

        return event.render();   // return button as jquery object
    }

All works fine when codeview mode is disabled. But when codeview is enabled - noting happens.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment