From 9fd57f52addaa4a521696f25cc1602fd40e1ff2e Mon Sep 17 00:00:00 2001 From: Juanfran Date: Thu, 9 Mar 2017 12:50:39 +0100 Subject: [PATCH] add title in code block --- app/locales/taiga/locale-en.json | 1 + .../components/wysiwyg/wysiwyg.directive.coffee | 15 ++++++++++----- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/app/locales/taiga/locale-en.json b/app/locales/taiga/locale-en.json index 1cd43791..f29ba12f 100644 --- a/app/locales/taiga/locale-en.json +++ b/app/locales/taiga/locale-en.json @@ -215,6 +215,7 @@ }, "WYSIWYG": { "CODE_SNIPPET": "Code Snippet", + "DB_CLICK": "double click to edit", "SELECT_LANGUAGE_PLACEHOLDER": "Select Language", "SELECT_LANGUAGE_REMOVE_FORMATING": "Remove formatting", "OUTDATED": "Another person has made changes while you were editing. Check the new version on the activiy tab before you save your changes.", diff --git a/app/modules/components/wysiwyg/wysiwyg.directive.coffee b/app/modules/components/wysiwyg/wysiwyg.directive.coffee index 43008899..37ee36a5 100644 --- a/app/modules/components/wysiwyg/wysiwyg.directive.coffee +++ b/app/modules/components/wysiwyg/wysiwyg.directive.coffee @@ -87,6 +87,8 @@ Medium = ($translate, $confirm, $storage, wysiwygService, animationFrame, tgLoad # prevent edit a pre pre.setAttribute('contenteditable', false) + pre.setAttribute('title', $translate.instant("COMMON.WYSIWYG.DB_CLICK")) + if pre.nextElementSibling && pre.nextElementSibling.nodeName.toLowerCase() == 'p' && !pre.nextElementSibling.children.length pre.nextElementSibling.appendChild(document.createElement('br')) @@ -207,6 +209,9 @@ Medium = ($translate, $confirm, $storage, wysiwygService, animationFrame, tgLoad wysiwygCodeHightlighterService.getLanguages().then (codeLans) -> $scope.codeLans = codeLans + setEditMode = (editMode) -> + $scope.editMode = editMode + setHtmlMedium = (markdown) -> html = wysiwygService.getHTML(markdown) editorMedium.html(html) @@ -271,7 +276,7 @@ Medium = ($translate, $confirm, $storage, wysiwygService, animationFrame, tgLoad e.preventDefault() if e if !isEditOnly - $scope.editMode = false + setEditMode(false) if notPersist clean() @@ -296,7 +301,7 @@ Medium = ($translate, $confirm, $storage, wysiwygService, animationFrame, tgLoad $scope.saving = false if !isEditOnly - $scope.editMode = false + setEditMode(false) if notPersist clean() @@ -481,7 +486,7 @@ Medium = ($translate, $confirm, $storage, wysiwygService, animationFrame, tgLoad mediumInstance.subscribe 'focus', (event) -> $scope.$applyAsync () -> if !$scope.editMode - $scope.editMode = true + setEditMode(true) mediumInstance.subscribe 'editableDrop', (event) -> $scope.onUploadFile({files: event.dataTransfer.files, cb: uploadEnd}) @@ -503,7 +508,7 @@ Medium = ($translate, $confirm, $storage, wysiwygService, animationFrame, tgLoad else if code == 27 editorMedium.blur() - $scope.editMode = editMode + setEditMode(editMode) $scope.$applyAsync () -> wysiwygCodeHightlighterService.addHightlighter(mediumInstance.elements[0]) @@ -523,7 +528,7 @@ Medium = ($translate, $confirm, $storage, wysiwygService, animationFrame, tgLoad $scope.outdated = isOutdated() if !mediumInstance && isDraft() - $scope.editMode = true + setEditMode(true) if ($scope.markdown.length || content.length) && $scope.markdown == content return