Skip to content

Commit

Permalink
now using fork of ui-tinymce
Browse files Browse the repository at this point in the history
  • Loading branch information
christophbuehler committed Apr 6, 2017
1 parent a4ee49c commit 299286e
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 474 deletions.
7 changes: 5 additions & 2 deletions bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,15 @@
"2sxc-eav-languages": "2sic/2sxc-eav-languages#30e0fab6",
"2sxc-icons": "2sic/2sxc-icons#3baf9dc9c0e9635cc1a9a980e587289235c52d3c",
"angular-ui-ace": "0.2.3",
"angular-ui-tinymce": "0.0.17",
"angular-ui-tinymce": "2sic/ui-tinymce#b1769d255386164b097edacc12b03e9df30f7c20",
"i18next": "3.4.3",
"i18next-xhr-backend": "1.2.0",
"jquery-i18next": "1.1.0",
"tinymce-dist": "4.4.3",
"shake.js": "2sic/shake.js#4e43bd79824d396bc231e458c52515801e38be93"
},
"private": true
"private": true,
"resolutions": {
"tinymce": "~4.5.1"
}
}
2 changes: 1 addition & 1 deletion dist/edit/extensions/field-string-wysiwyg-tinymce/set.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

235 changes: 1 addition & 234 deletions dist/sxc-edit/sxc-edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -806,239 +806,6 @@ angular.module("sxcFieldTemplates")


})();
/**
* Binds a TinyMCE widget to <textarea> elements.
*/
angular.module('sxcFieldTemplates')
.value('uiTinymceConfig', {})
.directive('uiTinymceTwo', ['$rootScope', '$compile', '$timeout', '$window', '$sce', 'uiTinymceConfig', 'uiTinymceService', function ($rootScope, $compile, $timeout, $window, $sce, uiTinymceConfig, uiTinymceService) {
uiTinymceConfig = uiTinymceConfig || {};

if (uiTinymceConfig.baseUrl) {
tinymce.baseURL = uiTinymceConfig.baseUrl;
}

return {
require: ['ngModel', '^?form'],
priority: 599,
link: function (scope, element, attrs, ctrls) {
if (!$window.tinymce) {
return;
}

var ngModel = ctrls[0],
form = ctrls[1] || null;

var expression, options = {
debounce: true
}, tinyInstance,
updateView = function (editor) {
var content = editor.getContent({ format: options.format }).trim();
content = $sce.trustAsHtml(content);

ngModel.$setViewValue(content);
if (!$rootScope.$$phase) {
scope.$digest();
}
};

function toggleDisable(disabled) {
if (disabled) {
ensureInstance();

if (tinyInstance) {
tinyInstance.getBody().setAttribute('contenteditable', false);
}
} else {
ensureInstance();

if (tinyInstance && !tinyInstance.settings.readonly && tinyInstance.getDoc()) {
tinyInstance.getBody().setAttribute('contenteditable', true);
}
}
}

// fetch a unique ID from the service
var uniqueId = uiTinymceService.getUniqueId();
attrs.$set('id', uniqueId);

expression = {};

angular.extend(expression, scope.$eval(attrs.uiTinymceTwo));

//Debounce update and save action
var debouncedUpdate = (function (debouncedUpdateDelay) {
var debouncedUpdateTimer;
return function (ed) {
$timeout.cancel(debouncedUpdateTimer);
debouncedUpdateTimer = $timeout(function () {
return (function (ed) {
if (ed.isDirty()) {
ed.save();
updateView(ed);
}
})(ed);
}, debouncedUpdateDelay);
};
})(400);

var setupOptions = {
// Update model when calling setContent
// (such as from the source editor popup)
setup: function (ed) {
ed.on('init', function () {
ngModel.$render();
ngModel.$setPristine();
ngModel.$setUntouched();
if (form) {
form.$setPristine();
}
});

// Update model when:
// - a button has been clicked [ExecCommand]
// - the editor content has been modified [change]
// - the node has changed [NodeChange]
// - an object has been resized (table, image) [ObjectResized]
ed.on('ExecCommand change NodeChange ObjectResized', function () {
if (options.debounce) debouncedUpdate(ed);
else if (ed.isDirty()) {
ed.save();
updateView(ed);
}
});

ed.on('blur', function () {
element[0].blur();
ngModel.$setTouched();
if (!$rootScope.$$phase) {
scope.$digest();
}
});

ed.on('remove', function () {
element.remove();
});

if (uiTinymceConfig.setup) {
uiTinymceConfig.setup(ed, {
updateView: updateView
});
}

if (expression.setup) {
expression.setup(ed, {
updateView: updateView
});
}
},
format: expression.format || 'html',
selector: '#' + attrs.id
};
// extend options with initial uiTinymceConfig and
// options from directive attribute value
angular.extend(options, uiTinymceConfig, expression, setupOptions);
// Wrapped in $timeout due to $tinymce:refresh implementation, requires
// element to be present in DOM before instantiating editor when
// re-rendering directive
$timeout(function () {
if (options.baseURL) {
tinymce.baseURL = options.baseURL;
}
var maybeInitPromise = tinymce.init(options);
if (maybeInitPromise && typeof maybeInitPromise.then === 'function') {
maybeInitPromise.then(function () {
toggleDisable(scope.$eval(attrs.ngDisabled));
});
} else {
toggleDisable(scope.$eval(attrs.ngDisabled));
}
});

ngModel.$formatters.unshift(function (modelValue) {
return modelValue ? $sce.trustAsHtml(modelValue) : '';
});

ngModel.$parsers.unshift(function (viewValue) {
return viewValue ? $sce.getTrustedHtml(viewValue) : '';
});

ngModel.$render = function () {
ensureInstance();

var viewValue = ngModel.$viewValue ?
$sce.getTrustedHtml(ngModel.$viewValue) : '';

// instance.getDoc() check is a guard against null value
// when destruction & recreation of instances happen
if (tinyInstance &&
tinyInstance.getDoc()
) {
tinyInstance.setContent(viewValue);
// Triggering change event due to TinyMCE not firing event &
// becoming out of sync for change callbacks
tinyInstance.fire('change');
}
};

attrs.$observe('disabled', toggleDisable);

// This block is because of TinyMCE not playing well with removal and
// recreation of instances, requiring instances to have different
// selectors in order to render new instances properly
scope.$on('$tinymce:refresh', function (e, id) {
var eid = attrs.id;
if (angular.isUndefined(id) || id === eid) {
var parentElement = element.parent();
var clonedElement = element.clone();
clonedElement.removeAttr('id');
clonedElement.removeAttr('style');
clonedElement.removeAttr('aria-hidden');
tinymce.execCommand('mceRemoveEditor', false, eid);
parentElement.append($compile(clonedElement)(scope));
}
});

scope.$on('$destroy', function () {
ensureInstance();

if (tinyInstance) {
tinyInstance.remove();
tinyInstance = null;
}
});

function ensureInstance() {
if (!tinyInstance) {
tinyInstance = tinymce.get(attrs.id);
}
}
}
};
}])
.service('uiTinymceService', [
/**
* A service is used to create unique ID's, this prevents duplicate ID's if there are multiple editors on screen.
*/
function () {
var UITinymceService = function () {
var ID_ATTR = 'ui-tinymce';
// uniqueId keeps track of the latest assigned ID
var uniqueId = 0;
// getUniqueId returns a unique ID
var getUniqueId = function () {
uniqueId++;
return ID_ATTR + '-' + uniqueId;
};
// return the function as a public method of the service
return {
getUniqueId: getUniqueId
};
};
// return a new instance of the service
return new UITinymceService();
}
]);
/*!
Math.uuid.js (v1.4)
http://www.broofa.com
Expand Down Expand Up @@ -2138,4 +1905,4 @@ $templateCache.put("fields/string/string-font-icon-picker.html","<div>\r\n <d
$templateCache.put("fields/string/string-template-picker.html","<div>\r\n <div class=\"input-group\">\r\n\r\n <select class=\"form-control input-material material\"\r\n ng-model=\"value.Value\"\r\n ng-disabled=\"!readyToUse()\">\r\n <option value=\"\">(no file selected)</option>\r\n <option ng-repeat=\"item in templates | isValidFile:file.ext\"\r\n ng-selected=\"{{item == value.Value}}\"\r\n value=\"{{item}}\">\r\n {{item}}\r\n </option>\r\n </select>\r\n <span class=\"input-group-btn\" style=\"vertical-align: top;\">\r\n <button class=\"btn btn-default icon-field-button\" type=\"button\" ng-click=\"add()\" ng-disabled=\"!readyToUse()\">\r\n <span class=\"icon-eav-plus\"></span>\r\n </button>\r\n </span>\r\n </div>\r\n</div>");
$templateCache.put("fields/string/string-wysiwyg-adv.html","<div>\r\n this would be an advanced, configurable WYSIWYG. It does not exist yet :). \r\n</div>");
$templateCache.put("fields/string/string-wysiwyg-dnn.html","<iframe style=\"width:100%; border: 0;\" web-forms-bridge=\"vm.bridge\" bridge-type=\"wysiwyg\" bridge-sync-height=\"true\"></iframe>");
$templateCache.put("fields/string/string-wysiwyg-tinymce.html","<div>\r\n <div class=\"dropzone\">\r\n <div> <!-- Needed because after a refresh, the editor can\'t be placed at the same location -->\r\n <div ui-tinymce-two=\"tinymceOptions\" ng-model=\"value.Value\" class=\"field-string-wysiwyg-mce-box\"></div>\r\n </div>\r\n\r\n <!-- The ADAM file browser, requires the uploader wrapped around it -->\r\n <adam-browser content-type-name=\"to.header.ContentTypeName\"\r\n entity-guid=\"to.header.Guid\"\r\n field-name=\"options.key\"\r\n auto-load=\"false\"\r\n folder-depth=\"0\"\r\n sub-folder=\"\"\r\n update-callback=\"vm.setValue\"\r\n register-self=\"vm.registerAdam\"\r\n show-images-only=\"vm.adamModeImage\"\r\n ng-disabled=\"to.disabled\"></adam-browser>\r\n\r\n <!-- dummy item to set focus on in script-->\r\n <span id=\"dummyfocus\" tabindex=\"-1\"></span>\r\n\r\n <!-- the preview of the uploader -->\r\n <dropzone-upload-preview></dropzone-upload-preview>\r\n <adam-hint class=\"field-hints\"></adam-hint>\r\n\r\n </div>\r\n</div>");}]);
$templateCache.put("fields/string/string-wysiwyg-tinymce.html","<div>\r\n <div class=\"dropzone\">\r\n <div> <!-- Needed because after a refresh, the editor can\'t be placed at the same location -->\r\n <div ui-tinymce=\"tinymceOptions\" ng-model=\"value.Value\" class=\"field-string-wysiwyg-mce-box\"></div>\r\n </div>\r\n\r\n <!-- The ADAM file browser, requires the uploader wrapped around it -->\r\n <adam-browser content-type-name=\"to.header.ContentTypeName\"\r\n entity-guid=\"to.header.Guid\"\r\n field-name=\"options.key\"\r\n auto-load=\"false\"\r\n folder-depth=\"0\"\r\n sub-folder=\"\"\r\n update-callback=\"vm.setValue\"\r\n register-self=\"vm.registerAdam\"\r\n show-images-only=\"vm.adamModeImage\"\r\n ng-disabled=\"to.disabled\"></adam-browser>\r\n\r\n <!-- dummy item to set focus on in script-->\r\n <span id=\"dummyfocus\" tabindex=\"-1\"></span>\r\n\r\n <!-- the preview of the uploader -->\r\n <dropzone-upload-preview></dropzone-upload-preview>\r\n <adam-hint class=\"field-hints\"></adam-hint>\r\n\r\n </div>\r\n</div>");}]);
4 changes: 2 additions & 2 deletions dist/sxc-edit/sxc-edit.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/sxc-edit/sxc-edit.min.js.map

Large diffs are not rendered by default.

Loading

0 comments on commit 299286e

Please sign in to comment.