add title in code block

stable
Juanfran 2017-03-09 12:50:39 +01:00
parent 566ab02f5a
commit 9fd57f52ad
2 changed files with 11 additions and 5 deletions

View File

@ -215,6 +215,7 @@
}, },
"WYSIWYG": { "WYSIWYG": {
"CODE_SNIPPET": "Code Snippet", "CODE_SNIPPET": "Code Snippet",
"DB_CLICK": "double click to edit",
"SELECT_LANGUAGE_PLACEHOLDER": "Select Language", "SELECT_LANGUAGE_PLACEHOLDER": "Select Language",
"SELECT_LANGUAGE_REMOVE_FORMATING": "Remove formatting", "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.", "OUTDATED": "Another person has made changes while you were editing. Check the new version on the activiy tab before you save your changes.",

View File

@ -87,6 +87,8 @@ Medium = ($translate, $confirm, $storage, wysiwygService, animationFrame, tgLoad
# prevent edit a pre # prevent edit a pre
pre.setAttribute('contenteditable', false) 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 if pre.nextElementSibling && pre.nextElementSibling.nodeName.toLowerCase() == 'p' && !pre.nextElementSibling.children.length
pre.nextElementSibling.appendChild(document.createElement('br')) pre.nextElementSibling.appendChild(document.createElement('br'))
@ -207,6 +209,9 @@ Medium = ($translate, $confirm, $storage, wysiwygService, animationFrame, tgLoad
wysiwygCodeHightlighterService.getLanguages().then (codeLans) -> wysiwygCodeHightlighterService.getLanguages().then (codeLans) ->
$scope.codeLans = codeLans $scope.codeLans = codeLans
setEditMode = (editMode) ->
$scope.editMode = editMode
setHtmlMedium = (markdown) -> setHtmlMedium = (markdown) ->
html = wysiwygService.getHTML(markdown) html = wysiwygService.getHTML(markdown)
editorMedium.html(html) editorMedium.html(html)
@ -271,7 +276,7 @@ Medium = ($translate, $confirm, $storage, wysiwygService, animationFrame, tgLoad
e.preventDefault() if e e.preventDefault() if e
if !isEditOnly if !isEditOnly
$scope.editMode = false setEditMode(false)
if notPersist if notPersist
clean() clean()
@ -296,7 +301,7 @@ Medium = ($translate, $confirm, $storage, wysiwygService, animationFrame, tgLoad
$scope.saving = false $scope.saving = false
if !isEditOnly if !isEditOnly
$scope.editMode = false setEditMode(false)
if notPersist if notPersist
clean() clean()
@ -481,7 +486,7 @@ Medium = ($translate, $confirm, $storage, wysiwygService, animationFrame, tgLoad
mediumInstance.subscribe 'focus', (event) -> mediumInstance.subscribe 'focus', (event) ->
$scope.$applyAsync () -> $scope.$applyAsync () ->
if !$scope.editMode if !$scope.editMode
$scope.editMode = true setEditMode(true)
mediumInstance.subscribe 'editableDrop', (event) -> mediumInstance.subscribe 'editableDrop', (event) ->
$scope.onUploadFile({files: event.dataTransfer.files, cb: uploadEnd}) $scope.onUploadFile({files: event.dataTransfer.files, cb: uploadEnd})
@ -503,7 +508,7 @@ Medium = ($translate, $confirm, $storage, wysiwygService, animationFrame, tgLoad
else if code == 27 else if code == 27
editorMedium.blur() editorMedium.blur()
$scope.editMode = editMode setEditMode(editMode)
$scope.$applyAsync () -> $scope.$applyAsync () ->
wysiwygCodeHightlighterService.addHightlighter(mediumInstance.elements[0]) wysiwygCodeHightlighterService.addHightlighter(mediumInstance.elements[0])
@ -523,7 +528,7 @@ Medium = ($translate, $confirm, $storage, wysiwygService, animationFrame, tgLoad
$scope.outdated = isOutdated() $scope.outdated = isOutdated()
if !mediumInstance && isDraft() if !mediumInstance && isDraft()
$scope.editMode = true setEditMode(true)
if ($scope.markdown.length || content.length) && $scope.markdown == content if ($scope.markdown.length || content.length) && $scope.markdown == content
return return