From 3a305b8258782797b328f2ce46e8bb74e9603594 Mon Sep 17 00:00:00 2001 From: Wu Cheng-Han Date: Mon, 28 Nov 2016 01:20:23 +0800 Subject: Update editor other cursor classes and adding option for other cursors features in CodeMirror --- public/js/index.js | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'public/js') diff --git a/public/js/index.js b/public/js/index.js index f49c9da1..341db69e 100644 --- a/public/js/index.js +++ b/public/js/index.js @@ -455,6 +455,7 @@ window.editor = CodeMirror.fromTextArea(textit, { addModeClass: true, readOnly: true, autoRefresh: true, + otherCursors: true, placeholder: "← Start by entering a title here\n===\nVisit /features if you don't know what to do.\nHappy hacking :)" }); var inlineAttach = inlineAttachment.editors.codemirror4.attach(editor); @@ -2719,7 +2720,7 @@ socket.on('online users', function (data) { console.debug(data); onlineUsers = data.users; updateOnlineStatus(); - $('.other-cursors').children().each(function (key, value) { + $('.CodeMirror-other-cursors').children().each(function (key, value) { var found = false; for (var i = 0; i < data.users.length; i++) { var user = data.users[i]; @@ -3044,11 +3045,11 @@ function buildCursor(user) { iconClass = 'fa-desktop'; break; } - if ($('.other-cursors').length <= 0) { - $("
").insertAfter('.CodeMirror-cursors'); + if ($('.CodeMirror-other-cursors').length <= 0) { + $("
").insertAfter('.CodeMirror-cursors'); } if ($('div[data-clientid="' + user.id + '"]').length <= 0) { - var cursor = $(''); + var cursor = $(''); cursor.attr('data-line', user.cursor.line); cursor.attr('data-ch', user.cursor.ch); cursor.attr('data-offset-left', 0); @@ -3119,7 +3120,7 @@ function buildCursor(user) { cursor[0].style.left = coord.left + 'px'; cursor[0].style.top = coord.top + 'px'; - $('.other-cursors').append(cursor); + $('.CodeMirror-other-cursors').append(cursor); if (!user.idle) cursor.stop(true).fadeIn(); @@ -3622,8 +3623,8 @@ function checkCursorMenuInner() { // get cursor var cursor = editor.getCursor(); // set element cursor data - if (!dropdown.hasClass('other-cursor')) - dropdown.addClass('other-cursor'); + if (!dropdown.hasClass('CodeMirror-other-cursor')) + dropdown.addClass('CodeMirror-other-cursor'); dropdown.attr('data-line', cursor.line); dropdown.attr('data-ch', cursor.ch); // get coord position -- cgit v1.2.3