Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Call variable lists and env from summernote to custom plugin #3277

Closed
gzai opened this issue Jun 24, 2019 · 1 comment
Closed

Call variable lists and env from summernote to custom plugin #3277

gzai opened this issue Jun 24, 2019 · 1 comment

Comments

@gzai
Copy link

gzai commented Jun 24, 2019

Hello,
How to call variable lists and env from summernote.js to my custom plugin?
I want to make a plugin that can display popover from my custom plugin.
The variable dom included in $.summernote, why variable lists and env not included in $.summernote

I made a popover from the modification in the popover table.
Or anyone have simple create custom plugin popover inside summernote editor?


var MyCustomPopover = (function () {
        function MyCustomPopover(context) {
            var _this = this;
            this.context = context;
            this.ui = $.summernote.ui;
            this.options = context.options;
            this.events = {
                'summernote.mousedown': function (we, e) {
                    _this.update(e.target);
                },
                'summernote.keyup summernote.scroll summernote.change': function () {
                    _this.update();
                },
                'summernote.disable': function () {
                    _this.hide();
                }
            };
        };
        MyCustomPopover.prototype.shouldInitialize = function () {
            return !lists.isEmpty(this.options.popover.myCustomePopover);
        };
        MyCustomPopover.prototype.initialize = function () {
            this.$popover = this.ui.popover({
                className: 'note-mycustom-popover'
            }).render().appendTo(this.options.container);
            var $content = this.$popover.find('.popover-content,.note-popover-content');
            this.context.invoke('buttons.build', $content, this.options.popover.myCustomePopover);
        };
        MyCustomPopover.prototype.update = function (target) {
            if (this.context.isDisabled()) {
                return false;
            }
            var isCustom = dom.isCustom(target);
            if (isCustom) {
                var pos = dom.posFromPlaceholder(target);
                this.$popover.css({
                    display: 'block',
                    left: pos.left,
                    top: pos.top
                });
            }
            else {
                this.hide();
            }
            return isCell;
        };
        MyCustomPopover.prototype.destroy = function () {
            this.$popover.remove();
        };
        MyCustomPopover.prototype.hide = function () {
            this.$popover.hide();
        };
        return MyCustomPopover;
    }());

    $.extend(true, $.summernote, {
        options: {
            modules: {
                'myCustomPopover': MyCustomPopover,
            }
        }
    });

hackerwins added a commit that referenced this issue Jul 3, 2019
@lqez
Copy link
Member

lqez commented Dec 28, 2019

Closed by #3285

@lqez lqez closed this as completed Dec 28, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants