bootstrap-wysiwyg icon indicating copy to clipboard operation
bootstrap-wysiwyg copied to clipboard

Angular Port ?

Open abhinavguptas opened this issue 10 years ago • 5 comments

Do we have any angular directive for the same ?

abhinavguptas avatar Dec 23 '14 07:12 abhinavguptas

I have forked this to remove bootstrap dependencies and create a base library that can then be wrapped by simple libraries to use with Foundation 5 or angular or whatever else. Should have my init commit up in a week or so. It will be here: http://github.com/phoenix-labs/wysiwyg-core.js and then whatever wrapper implementations will be angular-wysiwyg.js, foundation-wysiwyg.js and such.

I'd love feedback on how to make this more intuitive.

electricjones avatar Dec 29 '14 16:12 electricjones

@chrismichaels84 would be interested in seeing more on this! I mean, the idea behind the JQuery element is to be small and as independent as possible. Most of the dependancies are for iconography, etc, so happy to look at options here to reduce it further and make it more portable.

steveathon avatar Jan 18 '15 07:01 steveathon

I have completed my port and issued a pull request at Issue #18. I may create an angular wrapper this weekend if I have a couple hours.

electricjones avatar Jan 22 '15 20:01 electricjones

In Angular you can bind your model to the content of the editor in a directive like this

.directive('richTextEditor', function( ) {
            var initToolbarBootstrapBindings = function() {
            // your init stuff
};
return {
            restrict : "A",
            require: ['^ngModel'],
            scope: {
                ngModel : '='
            },
            replace : true,
            transclude : true,
            template : "<div id=\"editor\"></div>",
            link : function(scope, element, attrs, ctrl) {
                initToolbarBootstrapBindings();
                var editor = jQuery('#editor');
                editor.wysiwyg();

                editor.bind('blur keyup change', function() {
                    scope.$apply(function(){
                        scope.ngModel = editor.cleanHtml();
                    });
                });

                scope.$watch("ngModel",function(newVal){
                    if(newVal == editor.cleanHtml())
                        return;
                    if(newVal == undefined)
                        editor.html('');
                    else {
                        editor.html(newVal);
                    }
                });
            }
        };
});

Hope it helps someone :-)

poppywood avatar Jan 30 '15 10:01 poppywood

I'm leaving this open for the minute because I think the conversation is valid and is worth a longer and more indepth exploration - but marking it as enhancement/wont fix for now.

steveathon avatar Jun 15 '15 13:06 steveathon