From 5ba8d3a60e7f212d41e5c5f489681b79b79f69c7 Mon Sep 17 00:00:00 2001 From: Alejandro Alonso Date: Thu, 23 Jul 2015 11:16:07 +0200 Subject: [PATCH] Fixing list edition on rich editor --- app/coffee/modules/common/wisiwyg.coffee | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/app/coffee/modules/common/wisiwyg.coffee b/app/coffee/modules/common/wisiwyg.coffee index 37ade9d3..cfd6a6bb 100644 --- a/app/coffee/modules/common/wisiwyg.coffee +++ b/app/coffee/modules/common/wisiwyg.coffee @@ -184,7 +184,12 @@ MarkitupDirective = ($rootscope, $rs, $selectedText, $template, $compile, $trans replaceWith: () -> "\n" afterInsert: (data) -> lines = data.textarea.value.split("\n") - cursorLine = data.textarea.value[0..(data.caretPosition - 1)].split("\n").length + # Detect if we are in this situation +- aa at the beginning if the textarea + if data.caretPosition > 0 + cursorLine = data.textarea.value[0..(data.caretPosition - 1)].split("\n").length + else + cursorLine = 1 + newLineContent = data.textarea.value[data.caretPosition..].split("\n")[0] lastLine = lines[cursorLine - 1]