link: function (scope, element, attrs) {
function tinyMceSetup(editor) {
- editor.on('ExecCommand change NodeChange ObjectResized', (e) => {
+ editor.on('ExecCommand change input NodeChange ObjectResized', (e) => {
let content = editor.getContent();
$timeout(() => {
scope.mceModel = content;
});
editor.on('keydown', (event) => {
- scope.$emit('editor-keydown', event);
+ if (event.keyCode === 83 && (navigator.platform.match("Mac") ? event.metaKey : event.ctrlKey)) {
+ event.preventDefault();
+ scope.$emit('save-draft', event);
+ }
});
editor.on('init', (e) => {
extraKeys[`${metaKey}-7`] = function(cm) {wrapSelection('\n```\n', '\n```');};
extraKeys[`${metaKey}-8`] = function(cm) {wrapSelection('`', '`');};
extraKeys[`Shift-${metaKey}-E`] = function(cm) {wrapSelection('`', '`');};
- extraKeys[`${metaKey}-9`] = function(cm) {wrapSelection('<p class="callout info">', '</div>');};
+ extraKeys[`${metaKey}-9`] = function(cm) {wrapSelection('<p class="callout info">', '</p>');};
cm.setOption('extraKeys', extraKeys);
// Update data on content change
}
cm.replaceRange(newLineContent, {line: cursor.line, ch: 0}, {line: cursor.line, ch: lineLen});
- cm.setCursor({line: cursor.line, ch: cursor.ch + (newLineContent.length - lineLen)});
+ cm.setCursor({line: cursor.line, ch: cursor.ch + start.length});
}
function wrapSelection(start, end) {
let selection = cm.getSelection();
if (selection === '') return wrapLine(start, end);
+
let newSelection = selection;
let frontDiff = 0;
let endDiff = 0;
}
}
}]);
-
- ngApp.directive('commentReply', [function () {
- return {
- restrict: 'E',
- templateUrl: 'comment-reply.html',
- scope: {
- pageId: '=',
- parentId: '=',
- parent: '='
- },
- link: function (scope, element) {
- scope.isReply = true;
- element.find('textarea').focus();
- scope.$on('evt.comment-success', function (event) {
- // no need for the event to do anything more.
- event.stopPropagation();
- event.preventDefault();
- scope.closeBox();
- });
-
- scope.closeBox = function () {
- element.remove();
- scope.$destroy();
- };
- }
- };
- }]);
-
- ngApp.directive('commentEdit', [function () {
- return {
- restrict: 'E',
- templateUrl: 'comment-reply.html',
- scope: {
- comment: '='
- },
- link: function (scope, element) {
- scope.isEdit = true;
- element.find('textarea').focus();
- scope.$on('evt.comment-success', function (event, commentId) {
- // no need for the event to do anything more.
- event.stopPropagation();
- event.preventDefault();
- if (commentId === scope.comment.id && !scope.isNew) {
- scope.closeBox();
- }
- });
-
- scope.closeBox = function () {
- element.remove();
- scope.$destroy();
- };
- }
- };
- }]);
-
-
- ngApp.directive('commentReplyLink', ['$document', '$compile', function ($document, $compile) {
- return {
- scope: {
- comment: '='
- },
- link: function (scope, element, attr) {
- element.on('$destroy', function () {
- element.off('click');
- scope.$destroy();
- });
-
- element.on('click', function (e) {
- e.preventDefault();
- var $container = element.parents('.comment-actions').first();
- if (!$container.length) {
- console.error('commentReplyLink directive should be placed inside a container with class comment-box!');
- return;
- }
- if (attr.noCommentReplyDupe) {
- removeDupe();
- }
-
- compileHtml($container, scope, attr.isReply === 'true');
- });
- }
- };
-
- function compileHtml($container, scope, isReply) {
- let lnkFunc = null;
- if (isReply) {
- lnkFunc = $compile('<comment-reply page-id="comment.pageId" parent-id="comment.id" parent="comment"></comment-reply>');
- } else {
- lnkFunc = $compile('<comment-edit comment="comment"></comment-add>');
- }
- var compiledHTML = lnkFunc(scope);
- $container.append(compiledHTML);
- }
-
- function removeDupe() {
- let $existingElement = $document.find('.comments-list comment-reply, .comments-list comment-edit');
- if (!$existingElement.length) {
- return;
- }
-
- $existingElement.remove();
- }
- }]);
-
- ngApp.directive('commentDeleteLink', ['$window', function ($window) {
- return {
- controller: 'CommentDeleteController',
- scope: {
- comment: '='
- },
- link: function (scope, element, attr, ctrl) {
-
- element.on('click', function(e) {
- e.preventDefault();
- var resp = $window.confirm(trans('entities.comment_delete_confirm'));
- if (!resp) {
- return;
- }
-
- ctrl.delete(scope.comment);
- });
- }
- };
- }]);
};