diff --git a/build/squire-raw.js b/build/squire-raw.js index 4a68bed..40a7f0d 100644 --- a/build/squire-raw.js +++ b/build/squire-raw.js @@ -1117,7 +1117,15 @@ function Squire ( doc, options ) { var settings = { blockTag: 'DIV', tagAttributes: { - block: null + // Some of these properties don't even need default values, + // since there are checks on them in changeFormat etc. + block: null, + ul: null, + ol: null, + li: null, + blockquote: null, + img: null, + a: null } } settings = MergeObjects(settings, options); @@ -1977,18 +1985,23 @@ proto.changeFormat = function ( add, remove, range, partial ) { if ( !range && !( range = this.getSelection() ) ) { return; } + var addAttrs, removeAttrs; // Save undo checkpoint this._recordUndoState( range ); this._getRangeAndRemoveBookmark( range ); if ( remove ) { + removeAttrs = this.getSettings().tagAttributes[remove.tag.toLowerCase()]; + removeAttrs = removeAttrs && (typeof(removeAttrs) === 'object') ? removeAttrs : {}; range = this._removeFormat( remove.tag.toUpperCase(), - remove.attributes || {}, range, partial ); + remove.attributes || removeAttrs, range, partial ); } if ( add ) { + addAttrs = this.getSettings().tagAttributes[add.tag.toLowerCase()]; + addAttrs = addAttrs && (typeof(addAttrs) === 'object') ? addAttrs : {}; range = this._addFormat( add.tag.toUpperCase(), - add.attributes || {}, range ); + add.attributes || addAttrs, range ); } this.setSelection( range ); @@ -2113,7 +2126,7 @@ proto.modifyBlocks = function ( modify, range ) { }; var increaseBlockQuoteLevel = function ( frag ) { - return this.createElement( 'BLOCKQUOTE', [ + return this.createElement( 'BLOCKQUOTE', this.getSettings().tagAttributes.blockquote, [ frag ]); }; @@ -2143,15 +2156,23 @@ var removeBlockQuote = function (/* frag */) { var makeList = function ( self, frag, type ) { var walker = getBlockWalker( frag ), - node, tag, prev, newLi; + node, tag, prev, newLi, + listAttrs = self.getSettings().tagAttributes[type.toLowerCase()], + listItemAttrs = self.getSettings().tagAttributes.li, + liAttrs; + + listItemAttrs = listItemAttrs && (typeof(listItemAttrs) === 'object') ? + listItemAttrs : {}; while ( node = walker.nextNode() ) { tag = node.parentNode.nodeName; if ( tag !== 'LI' ) { - newLi = self.createElement( 'LI', { - 'class': node.dir === 'rtl' ? 'dir-rtl' : undefined, - dir: node.dir || undefined - }); + liAttrs = MergeObjects(listItemAttrs, {dir: node.dir || undefined}); + liAttrs['class'] = ( liAttrs['class'] ? liAttrs['class'] : '') + + ( node.dir === 'rtl' ? ' dir-rtl' : '' ); + liAttrs['class'] = liAttrs['class'] ? liAttrs['class'] : undefined; + + newLi = self.createElement( 'LI', liAttrs); // Have we replaced the previous block with a new