[backport] add hightlight code on save

stable
Juanfran 2017-03-17 08:45:51 +01:00
parent 3932d2a94a
commit e030ac2d4e
1 changed files with 5 additions and 4 deletions

View File

@ -98,7 +98,7 @@ Medium = ($translate, $confirm, $storage, wysiwygService, animationFrame, tgLoad
pre.nextElementSibling.appendChild(document.createElement('br')) pre.nextElementSibling.appendChild(document.createElement('br'))
# add p after every pre # add p after every pre
else if !pre.nextElementSibling || pre.nextElementSibling.nodeName.toLowerCase() != 'p' else if !pre.nextElementSibling || ['p', 'ul', 'h1', 'h2', 'h3'].indexOf(pre.nextElementSibling.nodeName.toLowerCase()) == -1
p = document.createElement('p') p = document.createElement('p')
p.appendChild(document.createElement('br')) p.appendChild(document.createElement('br'))
@ -221,7 +221,9 @@ Medium = ($translate, $confirm, $storage, wysiwygService, animationFrame, tgLoad
html = wysiwygService.getHTML(markdown) html = wysiwygService.getHTML(markdown)
editorMedium.html(html) editorMedium.html(html)
wysiwygCodeHightlighterService.addHightlighter(mediumInstance.elements[0]) wysiwygCodeHightlighterService.addHightlighter(mediumInstance.elements[0])
refreshCodeBlocks(mediumInstance)
if $scope.editMode
refreshCodeBlocks(mediumInstance)
$scope.saveSnippet = (lan, code) -> $scope.saveSnippet = (lan, code) ->
$scope.codeEditorVisible = false $scope.codeEditorVisible = false
@ -268,8 +270,7 @@ Medium = ($translate, $confirm, $storage, wysiwygService, animationFrame, tgLoad
if $scope.mode == 'html' if $scope.mode == 'html'
updateMarkdownWithCurrentHtml() updateMarkdownWithCurrentHtml()
html = wysiwygService.getHTML($scope.markdown) setHtmlMedium($scope.markdown)
editorMedium.html(html)
return if $scope.required && !$scope.markdown.length return if $scope.required && !$scope.markdown.length