Moved back to quote text on reply. <blockquote> is not working with medium.js.

This commit is contained in:
Martin Edenhofer 2015-01-05 23:21:08 +01:00
parent c8cf4b6bf8
commit 7e1e6c6b6e
4 changed files with 87 additions and 8 deletions

View file

@ -890,7 +890,7 @@ class Edit extends App.Controller
)
@$('[data-name="body"]').ce({
mode: 'textonly'
mode: 'richtext'
multiline: true
maxlength: 2500
})
@ -1494,10 +1494,10 @@ class ArticleView extends App.Controller
# quote text
selectedText = App.Utils.textCleanup( selectedText )
selectedText = App.Utils.quote( selectedText )
# convert to html
selectedText = App.Utils.text2html( selectedText )
selectedText = '<blockquote type="cite">' + selectedText + '</blockquote>'
articleNew.body = selectedText + body

View file

@ -5,7 +5,7 @@ class App.Utils
$.trim( ascii )
.replace(/(\r\n|\n\r)/g, "\n") # cleanup
.replace(/\r/g, "\n") # cleanup
.replace(/[ ]\n/g, "\n") # remove tailing spaces
.replace(/[ ]\n/g, "\n") # remove tailing spaces
.replace(/\n{3,9}/g, "\n\n") # remove multible empty lines
# htmlEscapedAndLinkified = App.Utils.text2html( rawText )
@ -28,9 +28,49 @@ class App.Utils
@linkify: (ascii) ->
window.linkify( ascii )
# wrappedText = App.Utils.wrap( rawText, maxLineLength )
@wrap: (ascii, max = 82) ->
result = ''
counter_lines = 0
lines = ascii.split(/\n/)
for line in lines
counter_lines += 1
counter_parts = 0
part_length = 0
result_part = ''
parts = line.split(/\s/)
for part in parts
counter_parts += 1
# put overflow of parts to result and start new line
if (part_length + part.length) > max
part_length = 0
result_part = result_part.trim()
result_part += "\n"
result += result_part
result_part = ''
part_length += part.length
result_part += part
# add spacer at the end
if counter_parts isnt parts.length
part_length += 1
result_part += ' '
# put parts to result
result += result_part
result_part = ''
# add new line
if counter_lines isnt lines.length
result += "\n"
result
# quotedText = App.Utils.quote( rawText )
@quote: (ascii) ->
@quote: (ascii, max = 82) ->
ascii = @textCleanup(ascii)
ascii = @wrap(ascii, max)
$.trim( ascii )
.replace /^(.*)$/mg, (match) =>
if match

View file

@ -36,9 +36,6 @@ small {
font-size: 12px;
}
blockquote {
font-size: inherit;
}
.u-unclickable {
pointer-events: none;

View file

@ -160,6 +160,41 @@ test( "linkify", function() {
});
// wrap
test( "wrap", function() {
var source = "some text"
var should = 'some text'
var result = App.Utils.wrap( source )
equal( result, should, source )
source = "some text\nsome other text\n"
should = "some text\nsome other text\n"
result = App.Utils.wrap( source )
equal( result, should, source )
source = "some text with some line to wrap"
should = "some text with\nsome line to\nwrap"
result = App.Utils.wrap( source, 14 )
equal( result, should, source )
source = "some text\nsome other text\n"
should = "some text\nsome other text\n"
result = App.Utils.wrap( source )
equal( result, should, source )
source = "1234567890 1234567890 1234567890 1234567890"
should = "1234567890 1234567890 1234567890 1234567890"
result = App.Utils.wrap( source )
equal( result, should, source )
source = "123456789012 123456789012 123456789012"
should = "123456789012\n123456789012\n123456789012"
result = App.Utils.wrap( source, 14 )
equal( result, should, source )
});
// quote
test( "quote", function() {
@ -183,6 +218,13 @@ test( "quote", function() {
result = App.Utils.quote( source )
equal( result, should, source )
source = "Welcome! Thank you for installing Zammad. You will find ..."
should = "> Welcome! Thank you\n> for installing\n> Zammad. You will\n> find ..."
result = App.Utils.quote( source, 20 )
equal( result, should, source )
});
}