Skip to content

Commit

Permalink
Making heading block plain text
Browse files Browse the repository at this point in the history
  • Loading branch information
andflett committed Oct 23, 2012
1 parent 1444128 commit 7334cd2
Showing 1 changed file with 30 additions and 3 deletions.
33 changes: 30 additions & 3 deletions src/heading.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,38 @@ SirTrevor.Blocks.Heading = SirTrevor.Block.extend({
formattingEnabled: false,

editorHTML: function() {
return _.template('<h2 class="required text-block <%= className %>" contenteditable="true"></h2>', this);
return _.template('<div class="expanding-textarea"><pre><span></span><br></pre><textarea class="required <%= className %>"></textarea></div>', this);
},

loadData: function(data){
this.$$('.text-block').html(data.text);
loadData: function(data){
this.$$('.heading').html(data.text);
},

onBlockRender: function(){
/* Make our expanding text area */

var cont = this.$$('.expanding-textarea'),
area = cont.find('textarea'),
span = cont.find('span');

area.bind('input', function(){
span.text(area.val());
});

cont.addClass('active');

area.focus();

},

toData: function() {
var bl = this.$el,
dataObj = {}

dataObj.text = this.$$('.heading').val();

this.setData(dataObj)

}

});

0 comments on commit 7334cd2

Please sign in to comment.