Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TextAngular fileDropHandler documentation

We have just upgraded our textangular to 1.2.2, as this now supports drag and drop.

have seen defaultFileDropHandler within the textAngualrSetup, how ever, struggling to find any documentation to support this or how to use it.

defaultFileDropHandler:
    /* istanbul ignore next: untestable image processing */
    function (file, insertAction)
    {
        debugger;
        var reader = new FileReader();
        if(file.type.substring(0, 5) === 'image'){
            reader.onload = function() {
                if(reader.result !== '') insertAction('insertImage', reader.result, true);
            };

            reader.readAsDataURL(file);
            return true;
        }
        return false;
    }

Basically, we want to allow users to drag multiple pdf's, word docs etc and to upload on submit.

We could prob get this working in a fashion adding in functionality into defaultFileDropHandler within the settings page,

we implement ta by :-

<div text-angular data-ng-model="NoteText" ></div>

however, is there a cleaner way to achieve this?

like image 559
Simon Avatar asked Jan 07 '15 09:01

Simon


1 Answers

Sorry about the lack of docs!

Basically the defaultFileDropHandler is triggered when the HTML element.on("drop") event is fired.

Implementing this via the textAngularSetup file is fine, but will be globally applied to all instances. To apply a handler for just one instance of textAngular use the ta-file-drop attribute which should be the name of a function on the scope with the same signature as defaultFileDropHandler. For Example:

JS In Controller

$scope.dropHandler = function(file, insertAction){...};

HTML

<div text-angular data-ng-model="NoteText" ta-file-drop="dropHandler"></div>
like image 199
Simeon Cheeseman Avatar answered Oct 11 '22 22:10

Simeon Cheeseman