StevenDevooght / tinyMCE-mention

Mention/Autocomplete plugin for tinyMCE WYSIWYG editor.
http://stevendevooght.github.io/tinyMCE-mention/
221 stars 97 forks source link

angular.js integration #37

Closed antonioaltamura closed 8 years ago

antonioaltamura commented 8 years ago

Is this plugin compatible with angular.js? as in docs, this is my setting

 $scope.tinymceOptions = {
        menubar:false,
        plugins: [
            'advlist autolink lists link image charmap print preview anchor',
            'searchreplace visualblocks code fullscreen',
            'insertdatetime media table contextmenu paste code','paste','autoresize','autolink',
            'mention'
        ],
        toolbar: 'undo redo | | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist | link',
        valid_elements : "a[href|target=_blank],strong/b,div[align],br,li,ol,ul,i",
        fix_list_elements : true,
        autoresize_bottom_margin: 4,
        content_css: [
            '//www.tinymce.com/css/codepen.min.css'
        ],
        mentions: {
            source: [
                { name: 'Jammie Marbury'},
                { name: 'Jenniffer Caffey'},
                { name: 'Paul Hollen'},
                { name: 'Isabel Lenzi'},
                { name: 'Rebecka Kennell'},
                { name: 'Collette Janis'},
                { name: 'Bryon Kawamoto'},
                { name: 'Jerald Mozingo'},
                { name: 'Carlena Bachelor'},
                { name: 'Jacinta Diver'}
            ]
        }};
<input type="text" class="form-control" placeholder="comment" ui-tinymce="tinymceOptions" ng-model="model.nationalLawSources[i].description">

I get an error plugin.min.js:1 Uncaught TypeError: Cannot read property 'top' of undefined from mention script (plugin.js)

StevenDevooght commented 8 years ago

I think the plugin should be compatible with angular.js. Can you post a fiddle or codepen with the issue?

antonioaltamura commented 8 years ago

please ignore that a.indexOf is not a function (not sure where it comes from) http://jsfiddle.net/alfredopacino/uLx361tp/1/

You can type "@" and you will see Cannot read property 'top' of undefined

StevenDevooght commented 8 years ago

Since the plugin internally uses a span element the valid_elements setting has to allow it. Updating the setting to a[href|target=_blank],strong/b,div[align],br,li,ol,ul,i,span[id=autocomplete] fixes the issue.

I also updated the fiddle.

antonioaltamura commented 8 years ago

thanks