KM.registerUI( 'contextmenu', function () {
    var me = this;

    function getItemByLabel(label){
        var result;
        utils.each(me.getContextmenu(),function(i,item){
            if(item.label == label){
                result = item;
                return false;
            }
        });
        return result;
    }
    var $menu = $.kmuidropmenu({
        click:function(e,v,l){

            var item = getItemByLabel(l);

            if(item.exec){

                item.exec.apply(km)
            }else{
                me.execCommand(item.cmdName);
            }

            this.hide();
        }
    });
    me.$container.append($menu);
    me.on('contextmenu', function(e) {
        e.preventDefault();
    });
    me.on('mouseup', function (e) {
        //e.preventDefault();
        
        if (me.getStatus() == 'hand' || !e.isRightMB()) return;

        var node = e.getTargetNode();
        if(node){
            this.removeAllSelectedNodes();
            this.select(node);
        }


        var items = me.getContextmenu();
        var data = [];

        utils.each(items,function(i,item){
            if(item.divider){
                data.length &&  data.push(item);
                return;
            }
            if(me.queryCommandState(item.cmdName)!=-1){
                data.push({
                    label:item.label,
                    value:item.cmdName
                })
            }
        });
        if(data.length){
            var item = data[data.length-1];
            if(item.divider){
                data.pop();
            }
            $menu.kmui().setData({
                data:data
            }).position(e.getPosition()).show();
        }

    });
    me.on('afterclick',function(){
        $menu.kmui().hide();
    });
    me.on('beforemousedown',function(e){
        if(e.isRightMB()){
            //e.stopPropagationImmediately();
        }
    })
} );


@@ -1572,32 +1572,208 @@
 ;%0A            %7D%0A
+            var pos = e.getPosition('screen');%0A            var offset = $(me.getPaper().container).offset();%0A            pos.y -= offset.top;%0A            pos.x -= offset.left;%0A
             $men
@@ -1845,23 +1845,11 @@
 ion(
-e.getPosition()
+pos
 ).sh

fix context menu position