简体   繁体   中英

How to ignore images in the textAngular editor

Facing issue with the textAngular editor when user copy and paste text. (clip board contains text and image)

You can find library from here https://github.com/fraywing/textAngular .

Checkout this fiddle . It uses ta-past directive of textAngular and replaces all image elements by using regex .replace(/<img[^>]*>/g,""); on your input string.

View

<div ng-app="test">
    <div ng-controller="testController">
        <div text-angular 
             name="testEditor" 
             ng-model="htmlContent" 
             ta-paste="stripFormat($html)"></div>
    </div>
</div>

AngularJS Application

angular.module('test', ['textAngular'])
  .controller('testController', function($scope, $timeout, textAngularManager, $filter) {

  $scope.htmlContent = '<p>Hello There!</p>';

  $scope.stripFormat = function ($html) {
    return $html.replace(/<img[^>]*>/g,"");
  };
});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM