mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
Merge pull request #2100 from velesin/synchronized_editor
Synced editor scrolling PoC.
This commit is contained in:
2409
app/assets/javascripts/discourse/lib/Markdown.Editor.js
Normal file
2409
app/assets/javascripts/discourse/lib/Markdown.Editor.js
Normal file
File diff suppressed because it is too large
Load Diff
@@ -411,7 +411,7 @@ Discourse.Composer = Discourse.Model.extend({
|
||||
raw: this.get('reply'),
|
||||
editReason: opts.editReason,
|
||||
imageSizes: opts.imageSizes,
|
||||
cooked: $('#wmd-preview').html()
|
||||
cooked: this.getCookedHtml()
|
||||
});
|
||||
this.set('composeState', CLOSED);
|
||||
|
||||
@@ -448,7 +448,7 @@ Discourse.Composer = Discourse.Model.extend({
|
||||
topic_id: this.get('topic.id'),
|
||||
reply_to_post_number: post ? post.get('post_number') : null,
|
||||
imageSizes: opts.imageSizes,
|
||||
cooked: $('#wmd-preview').html(),
|
||||
cooked: this.getCookedHtml(),
|
||||
reply_count: 0,
|
||||
display_username: currentUser.get('name'),
|
||||
username: currentUser.get('username'),
|
||||
@@ -534,6 +534,10 @@ Discourse.Composer = Discourse.Model.extend({
|
||||
});
|
||||
},
|
||||
|
||||
getCookedHtml: function() {
|
||||
return $('#wmd-preview').html().replace(/<span class="marker"><\/span>/g, '');
|
||||
},
|
||||
|
||||
saveDraft: function() {
|
||||
// Do not save when drafts are disabled
|
||||
if (this.get('disableDrafts')) return;
|
||||
|
||||
@@ -56,6 +56,7 @@
|
||||
<div class='wmd-controls'>
|
||||
<div class='textarea-wrapper'>
|
||||
<div class='wmd-button-bar' id='wmd-button-bar'></div>
|
||||
<div id='wmd-preview-scroller'></div>
|
||||
{{view Discourse.NotifyingTextArea parentBinding="view" tabindex="3" valueBinding="model.reply" id="wmd-input" placeholderKey="composer.reply_placeholder"}}
|
||||
{{popupInputTip validation=view.replyValidation shownAt=view.showReplyTip}}
|
||||
</div>
|
||||
|
||||
@@ -52,14 +52,6 @@ Discourse.ComposerView = Discourse.View.extend(Ember.Evented, {
|
||||
refreshPreview: Discourse.debounce(function() {
|
||||
if (this.editor) {
|
||||
this.editor.refreshPreview();
|
||||
// if the caret is on the last line ensure preview scrolled to bottom
|
||||
var caretPosition = Discourse.Utilities.caretPosition(this.wmdInput[0]);
|
||||
if (!this.wmdInput.val().substring(caretPosition).match(/\n/)) {
|
||||
var $wmdPreview = $('#wmd-preview');
|
||||
if ($wmdPreview.is(':visible')) {
|
||||
$wmdPreview.scrollTop($wmdPreview[0].scrollHeight);
|
||||
}
|
||||
}
|
||||
}
|
||||
}, 30),
|
||||
|
||||
|
||||
@@ -10,7 +10,6 @@
|
||||
//= require_tree ./discourse/ember
|
||||
//= require LAB.js
|
||||
//= require Markdown.Converter.js
|
||||
//= require Markdown.Editor.js
|
||||
//= require better_markdown.js
|
||||
//= require bootbox.js
|
||||
//= require bootstrap-alert.js
|
||||
|
||||
Reference in New Issue
Block a user