Browse Source

disable line breaks for title

Artal Druk 8 years ago
parent
commit
1cbe66cf53
2 changed files with 12 additions and 1 deletions
  1. 11
    0
      src/ZSSRichTextEditor/ZSSRichTextEditor.js
  2. 1
    1
      src/editor.html

+ 11
- 0
src/ZSSRichTextEditor/ZSSRichTextEditor.js View File

@@ -63,8 +63,19 @@ function setupTouchEndFocus(editorId) {
63 63
     });
64 64
 }
65 65
 
66
+function disableLineBreakIfNecessary(editorId) {
67
+    var editor = $(`#${editorId}`);
68
+    var disableLineBreaks = editor.attr("disableLineBreaks");
69
+    if (disableLineBreaks) {
70
+        editor.keypress(function(e){ return e.which != 13; });
71
+    }
72
+}
73
+
66 74
 zss_editor.init = function() {
67 75
 
76
+    disableLineBreakIfNecessary('zss_editor_title');
77
+    disableLineBreakIfNecessary('zss_editor_content');
78
+
68 79
     setupTouchEndEnableEditing('zss_editor_title');
69 80
     setupTouchEndEnableEditing('zss_editor_content');
70 81
 

+ 1
- 1
src/editor.html View File

@@ -15,7 +15,7 @@
15 15
 
16 16
 	<body onLoad="zss_editor.init();">
17 17
 		<!-- ZSSRichTextEditor Editable Content -->
18
-		<div id="zss_editor_title" class="zs_editor_content" contenteditable="true" placeholder=""></div>
18
+		<div id="zss_editor_title" class="zs_editor_content" contenteditable="true" placeholder="" disableLineBreaks="true"></div>
19 19
 		<div><hr></div>
20 20
 		<div id="zss_editor_content" class="zs_editor_content" contenteditable="true" placeholder=""></div>
21 21
 	</body>