ui-ace icon indicating copy to clipboard operation
ui-ace copied to clipboard

ng-model deleted when pasting the same content to the editor

Open vrockai opened this issue 8 years ago • 1 comments

I've made a very basic plnkr to make this easy to test: http://plnkr.co/edit/PWh57DPNuks7rA5oI7r4

To reproduce, do:

  1. Select editor contents with ctrl-a and copy it to clipboard with ctrl-c. image

  2. Press ctrl-v to overwrite current selection. This will erase the ng-model contents, but in editor, everything looks all-right: image

Tested on Ubuntu with Firefox 55.0.2 and Chromium 60.0.3112.78

vrockai avatar Aug 25 '17 09:08 vrockai

I can confirm same issue. Tested with Angular v1.4.11 on Chrome 60.0.3112.101, OSX El Capitan.

I'm using this workaround to deal with this issue is to use the onChange event handler and check if action == 'insert' and ng-model is empty, I copy the lines to the ng-model like this: on HTML:

<div ui-ace="aceOptions" ng-model="foo"></div>

on AceCtrl controller:

$scope.aceOptions = {
  onChange: function (e) {
    if (($scope.foo.length == 0) && (e[0].action == 'insert')) {
        $scope.foo = e[0].lines[0];
      }
    }
}

gerzenstl avatar Sep 01 '17 20:09 gerzenstl