Fixed issue #880 - No chat message over 5000 chars possible. E. g. if image is pasted.
This commit is contained in:
parent
de7fef8c18
commit
e26aa1f599
5 changed files with 38 additions and 11 deletions
|
@ -474,9 +474,10 @@ class ChatWindow extends App.Controller
|
||||||
event.data.callback()
|
event.data.callback()
|
||||||
|
|
||||||
@$('.js-customerChatInput').ce({
|
@$('.js-customerChatInput').ce({
|
||||||
mode: 'richtext'
|
mode: 'richtext'
|
||||||
multiline: true
|
multiline: true
|
||||||
maxlength: 40000
|
maxlength: 40000
|
||||||
|
imageWidth: 'relative'
|
||||||
})
|
})
|
||||||
|
|
||||||
disconnect: =>
|
disconnect: =>
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
# maxlength: 123
|
# maxlength: 123
|
||||||
# multiline: true / disable enter + strip on paste
|
# multiline: true / disable enter + strip on paste
|
||||||
# placeholder: 'some placeholder'
|
# placeholder: 'some placeholder'
|
||||||
|
# imageWidth: absolute (<img style="width: XXpx; height: XXXpx" src="">) || relative (<img style="width: 100%; max-width: XXpx;" src="">)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
var pluginName = 'ce',
|
var pluginName = 'ce',
|
||||||
|
@ -13,6 +14,7 @@
|
||||||
debug: false,
|
debug: false,
|
||||||
mode: 'richtext',
|
mode: 'richtext',
|
||||||
multiline: true,
|
multiline: true,
|
||||||
|
imageWidth: 'absolute',
|
||||||
allowKey: {
|
allowKey: {
|
||||||
8: true, // backspace
|
8: true, // backspace
|
||||||
9: true, // tab
|
9: true, // tab
|
||||||
|
@ -284,7 +286,12 @@
|
||||||
}
|
}
|
||||||
_this.log('image inserted')
|
_this.log('image inserted')
|
||||||
result = dataUrl
|
result = dataUrl
|
||||||
img = "<img style=\"width: " + width + "px; height: " + height + "px\" src=\"" + result + "\">"
|
if (_this.options.imageWidth == 'absolute') {
|
||||||
|
img = "<img style=\"width: " + width + "px; height: " + height + "px\" src=\"" + result + "\">"
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
img = "<img style=\"width: 100%; max-width: " + width + "px;\" src=\"" + result + "\">"
|
||||||
|
}
|
||||||
document.execCommand('insertHTML', false, img)
|
document.execCommand('insertHTML', false, img)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -399,7 +406,12 @@
|
||||||
//console.log('dataUrl', dataUrl)
|
//console.log('dataUrl', dataUrl)
|
||||||
_this.log('image inserted')
|
_this.log('image inserted')
|
||||||
result = dataUrl
|
result = dataUrl
|
||||||
img = $("<img style=\"width: " + width + "px; height: " + height + "px\" src=\"" + result + "\">")
|
if (_this.options.imageWidth == 'absolute') {
|
||||||
|
img = $("<img style=\"width: " + width + "px; height: " + height + "px\" src=\"" + result + "\">")
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
img = $("<img style=\"width: 100%; max-width: " + width + "px;\" src=\"" + result + "\">")
|
||||||
|
}
|
||||||
img = img.get(0)
|
img = img.get(0)
|
||||||
|
|
||||||
if (document.caretPositionFromPoint) {
|
if (document.caretPositionFromPoint) {
|
||||||
|
|
|
@ -434,7 +434,7 @@ class CreateTicket < ActiveRecord::Migration
|
||||||
|
|
||||||
create_table :chat_messages do |t|
|
create_table :chat_messages do |t|
|
||||||
t.integer :chat_session_id, null: false
|
t.integer :chat_session_id, null: false
|
||||||
t.string :content, limit: 5000, null: false
|
t.text :content, limit: 20.megabytes + 1, null: false
|
||||||
t.integer :created_by_id, null: true
|
t.integer :created_by_id, null: true
|
||||||
t.timestamps limit: 3, null: false
|
t.timestamps limit: 3, null: false
|
||||||
end
|
end
|
||||||
|
|
10
db/migrate/20170420000001_chat_increase_message_size.rb
Normal file
10
db/migrate/20170420000001_chat_increase_message_size.rb
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
class ChatIncreaseMessageSize < ActiveRecord::Migration
|
||||||
|
def up
|
||||||
|
|
||||||
|
# return if it's a new setup
|
||||||
|
return if !Setting.find_by(name: 'system_init_done')
|
||||||
|
|
||||||
|
change_column :chat_messages, :content, :text, limit: 20.megabytes + 1, null: false
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
|
@ -7,13 +7,17 @@ class Sessions::Event
|
||||||
begin
|
begin
|
||||||
backend = load_adapter(adapter)
|
backend = load_adapter(adapter)
|
||||||
rescue => e
|
rescue => e
|
||||||
return { error: "No such event #{params[:event]}" }
|
return { event: 'error', data: { error: "No such event #{params[:event]}", payload: params[:payload] } }
|
||||||
end
|
end
|
||||||
|
|
||||||
instance = backend.new(params)
|
begin
|
||||||
result = instance.run
|
instance = backend.new(params)
|
||||||
instance.destroy
|
result = instance.run
|
||||||
result
|
instance.destroy
|
||||||
|
result
|
||||||
|
rescue => e
|
||||||
|
return { event: 'error', data: { error: e.message, payload: params[:payload] } }
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue