3

I use Trumbowyg editor (https://github.com/Alex-D/Trumbowyg) and I've wanted to override behavior of Enter (which I've already done).

I've wanted also to make Ctrl+Enter key combination to add a newline to the editor (like it is binded for plain Enter by default) but I couldn't find exact method which is used for that in the source code - does anyone know how is it solved?

Developer Guy
  • 2,318
  • 6
  • 19
  • 37
lukaszkups
  • 5,790
  • 9
  • 47
  • 85

3 Answers3

2

I've managed to do this - I've added a keypress event for e.ctrlKey && (e.keyCode === 13 || e.keyCode === 10) keys with such behaviour:

this.editor.trumbowyg('execCmd', {
  cmd: 'insertHTML',
  param: '<p></p>',
  forceCss: false
})

I haven't noticed any weird behavior in working of the editor yet, but will report if I find any.

Dagmar
  • 2,968
  • 23
  • 27
lukaszkups
  • 5,790
  • 9
  • 47
  • 85
1

There's an issue closed because this behavior is not possible. Sorry.

Check this: https://github.com/Alex-D/Trumbowyg/issues/617

Ignacio Ara
  • 2,476
  • 2
  • 26
  • 37
  • thanks for the comment! I was aware of that issue but haven't stopped there and tried make it working (and I hopefully managed to solve that problem already - added my own answer) :) – lukaszkups Apr 19 '18 at 11:46
0

comment out these ↓↓

Ln:1020

// t.semanticCode(false, true);

Ln:617

// t.semanticCode(false, compositionEndIE && keyCode === 13);

I could solve " auto <p> tag insert ISSUE ".

Dharman
  • 30,962
  • 25
  • 85
  • 135