Commit 8366ce36 authored by Robert Speicher's avatar Robert Speicher

Merge branch 'rs-update-note' into 'master'

Ensure updated notes are syntax highlighted

See merge request !1444
parents 529cf138 b35dd6b9
......@@ -25,6 +25,7 @@ v 8.1.0 (unreleased)
- Add support of multibyte characters in LDAP UID (Roman Petrov)
- Show additions/deletions stats on merge request diff
- Remove footer text in emails (Zeger-Jan van de Weg)
- Ensure code blocks are properly highlighted after a note is updated
v 8.0.3
- Fix URL shown in Slack notifications
......
......@@ -277,13 +277,15 @@ class @Notes
Updates the current note field.
###
updateNote: (xhr, note, status) =>
note_li = $(".note-row-" + note.id)
note_li.replaceWith(note.html)
note_li.find('.note-edit-form').hide()
note_li.find('.note-body > .note-text').show()
note_li.find('js-task-list-container').taskList('enable')
@enableTaskList()
updateNote: (_xhr, note, _status) =>
# Convert returned HTML to a jQuery object so we can modify it further
$html = $(note.html)
$html.syntaxHighlight()
$html.find('.js-task-list-container').taskList('enable')
# Find the note's `li` element by ID and replace it with the updated HTML
$note_li = $("#note_#{note.id}")
$note_li.replaceWith($html)
###
Called in response to clicking the edit note link
......
......@@ -366,6 +366,6 @@ class Note < ActiveRecord::Base
end
def editable?
!read_attribute(:system)
!system?
end
end
......@@ -59,7 +59,9 @@
.note-text
= preserve do
= markdown(note.note, {no_header_anchors: true})
= render 'projects/notes/edit_form', note: note
- unless note.system?
-# System notes can't be edited
= render 'projects/notes/edit_form', note: note
- if note.attachment.url
.note-attachment
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment