From a91d82b8647fed301a44446b8fc1d7579527e8d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niels=20Lyngs=C3=B8?= Date: Tue, 25 Jun 2019 15:26:28 +0200 Subject: [PATCH] latest test version --- .../App_Plugins/TrixEditor/trix.directive.js | 31 ++++++++++++++----- 1 file changed, 24 insertions(+), 7 deletions(-) diff --git a/src/Umbraco.Web.UI.Client/src/App_Plugins/TrixEditor/trix.directive.js b/src/Umbraco.Web.UI.Client/src/App_Plugins/TrixEditor/trix.directive.js index ef282a105b..0bcfb3c185 100755 --- a/src/Umbraco.Web.UI.Client/src/App_Plugins/TrixEditor/trix.directive.js +++ b/src/Umbraco.Web.UI.Client/src/App_Plugins/TrixEditor/trix.directive.js @@ -20,6 +20,7 @@ link: function($scope, element, attr, ngModel) { + // TODO: retrive from configuration: var acceptedFileTypes = ["image/jpeg", "image/png"]; var maxFileSize = 37000000; @@ -28,6 +29,7 @@ var editorElement = element[0]; + function init() { // if we have some content, apply it to the Trix RTE. @@ -35,18 +37,22 @@ editorElement.editor.loadHTML(ngModel.$modelValue); } + editorElement.addEventListener('trix-change', update); + addUploadFeature(); } + function update() { + var html = editorElement.value; + ngModel.$setViewValue(html); + } + editorElement.addEventListener('trix-initialize', init); - // maintenance of ng-model - editorElement.addEventListener('trix-change', function() { - ngModel.$setViewValue(element.html()); - }); + // maintenance of ng-model ngModel.$render = function() { if (editorElement.editor) { @@ -131,8 +137,6 @@ if (attachment.file) { - console.log('trix-attachment-add', attachment.file.name); - /* // set caption @@ -228,7 +232,7 @@ - console.log("File uploaded, data: ", data); + console.log("File uploaded, data: ", data, attachment); /* var media = data.medias[0]; if(media) { @@ -244,12 +248,25 @@ attachment.remove(); } */ + + // TODO: Get the URL and UDI from upload response.. missing in response.. + attachment.setAttributes( + { + "udi": "1234567890", + "url": "/media/uxsduzyq/umbraco_cloudportal_login.png" + } + ); + + } //after processing, test if everthing is done uploadNextAttachment(); }) .error(function(evt, status, headers, config) { + + console.log("Attachment error..."); + // set status done file.uploadStatus = "error"; //if the service returns a detailed error