mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-11 08:25:46 +01:00
added linking to formatting opts in editor
This commit is contained in:
@@ -288,6 +288,7 @@ var socket,
|
||||
var cursorEnd = postContentEl.value.length,
|
||||
selectionStart = postContentEl.selectionStart,
|
||||
selectionEnd = postContentEl.selectionEnd,
|
||||
selectionLength = selectionEnd - selectionStart,
|
||||
target;
|
||||
if (e.target.nodeName === 'I') target = e.target;
|
||||
else if (e.target.nodeName === 'SPAN') target = e.target.querySelector('i');
|
||||
@@ -324,6 +325,19 @@ var socket,
|
||||
postContentEl.selectionStart = cursorEnd+4;
|
||||
postContentEl.selectionEnd = postContentEl.value.length;
|
||||
break;
|
||||
case 'icon-link':
|
||||
if (selectionStart === selectionEnd) {
|
||||
// Nothing selected
|
||||
postContentEl.value = postContentEl.value + '[link text](link url)';
|
||||
postContentEl.selectionStart = cursorEnd+12;
|
||||
postContentEl.selectionEnd = postContentEl.value.length - 1;
|
||||
} else {
|
||||
// Text selected
|
||||
postContentEl.value = postContentEl.value.slice(0, selectionStart) + '[' + postContentEl.value.slice(selectionStart, selectionEnd) + '](link url)' + postContentEl.value.slice(selectionEnd);
|
||||
postContentEl.selectionStart = selectionStart + selectionLength + 3;
|
||||
postContentEl.selectionEnd = selectionEnd + 11;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}, false);
|
||||
|
||||
@@ -66,6 +66,7 @@
|
||||
<span class="btn btn-link" tabindex="-1"><i class="icon-italic"></i></span>
|
||||
<!-- <span class="btn btn-link" tabindex="-1"><i class="icon-font"></i></span> -->
|
||||
<span class="btn btn-link" tabindex="-1"><i class="icon-list"></i></span>
|
||||
<span class="btn btn-link" tabindex="-1"><i class="icon-link"></i></span>
|
||||
</div>
|
||||
<div class="btn-group" style="float: right; margin-right: -12px">
|
||||
<button id="submit_post_btn" class="btn" tabIndex="3"><i class="icon-ok"></i> Submit</button>
|
||||
|
||||
@@ -38,12 +38,10 @@
|
||||
</div>
|
||||
</h3>
|
||||
|
||||
|
||||
<hr />
|
||||
<span class="{main_posts.edited-class} hidden-phone"> last edited by <strong><a href="/users/{main_posts.editor}">{main_posts.editor}</a></strong> {main_posts.relativeEditTime} ago</span>
|
||||
|
||||
<div id="content_{main_posts.pid}" class="post-content">{main_posts.content}</div>
|
||||
<div class="profile-block"></div>
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
|
||||
Reference in New Issue
Block a user