Limit the number of character in tinyMCE

后端 未结 16 1128
心在旅途
心在旅途 2020-11-29 07:44

Im using tinyMCe for my project.Everything is working fine but now i want to restrict the number of character that will be insert into tinyMce text

16条回答
  •  北海茫月
    2020-11-29 07:56

    TinyMCE + AngularJS

    Here's how you can limit max number of characters on frontend using ng-maxlength directive from AngularJS.

    Param : ngMaxlength
    Type : number
    Details : Sets maxlength validation error key if the value is longer than maxlength.

    Please note that this directive doesn't just count the displayed text characters, it counts all the text inside Reached limit!/span>

    JavaScript:

    angular.module('myApp', ['ui.tinymce'])
    .config(['$sceProvider', function($sceProvider) {
        // Disable Strict Contextual Escaping
        $sceProvider.enabled(false);
    }])
    .constant('uiTinymceConfig', {/*...*/})
    .controller('myCtrl', ['$scope', function($scope) {
        // ...
    }]);
    

    jsFiddle

    ! Attention !

    Read the manual before using this solution to fully understand consequences of disabling SCE in AngularJS: $sce service.

提交回复
热议问题