mirror of
https://github.com/fastmail/Squire.git
synced 2024-12-22 07:13:08 -05:00
Export useful Node helper functions
This commit is contained in:
parent
504b40c857
commit
bb40d03899
4 changed files with 44 additions and 1 deletions
13
Demo.html
13
Demo.html
|
@ -85,6 +85,7 @@
|
|||
<span id="makeLink" class="prompt">Link</span>
|
||||
</p>
|
||||
<p>
|
||||
<span id="makeHeader">Make Header</span>
|
||||
<span id="increaseQuoteLevel">Quote</span>
|
||||
<span id="decreaseQuoteLevel">Dequote</span>
|
||||
|
||||
|
@ -114,6 +115,18 @@
|
|||
a: {'target': '_blank'}
|
||||
}
|
||||
});
|
||||
Squire.prototype.makeHeader = function() {
|
||||
return this.modifyBlocks( function( frag ) {
|
||||
var output = this._doc.createDocumentFragment();
|
||||
var block = frag;
|
||||
while ( block = Squire.getNextBlock( block ) ) {
|
||||
output.appendChild(
|
||||
this.createElement( 'h2', [ Squire.empty( block ) ] )
|
||||
);
|
||||
}
|
||||
return output;
|
||||
});
|
||||
};
|
||||
|
||||
document.addEventListener( 'click', function ( e ) {
|
||||
var id = e.target.id,
|
||||
|
|
|
@ -4481,6 +4481,21 @@ proto.removeList = command( 'modifyBlocks', removeList );
|
|||
proto.increaseListLevel = command( 'modifyBlocks', increaseListLevel );
|
||||
proto.decreaseListLevel = command( 'modifyBlocks', decreaseListLevel );
|
||||
|
||||
// Node.js exports
|
||||
Squire.isInline = isInline;
|
||||
Squire.isBlock = isBlock;
|
||||
Squire.isContainer = isContainer;
|
||||
Squire.getBlockWalker = getBlockWalker;
|
||||
Squire.getPreviousBlock = getPreviousBlock;
|
||||
Squire.getNextBlock = getNextBlock;
|
||||
Squire.areAlike = areAlike;
|
||||
Squire.hasTagAttributes = hasTagAttributes;
|
||||
Squire.getNearest = getNearest;
|
||||
Squire.isOrContains = isOrContains;
|
||||
Squire.detach = detach;
|
||||
Squire.replaceWith = replaceWith;
|
||||
Squire.empty = empty;
|
||||
|
||||
// Range.js exports
|
||||
Squire.getNodeBefore = getNodeBefore;
|
||||
Squire.getNodeAfter = getNodeAfter;
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -1,5 +1,20 @@
|
|||
/*jshint ignore:start */
|
||||
|
||||
// Node.js exports
|
||||
Squire.isInline = isInline;
|
||||
Squire.isBlock = isBlock;
|
||||
Squire.isContainer = isContainer;
|
||||
Squire.getBlockWalker = getBlockWalker;
|
||||
Squire.getPreviousBlock = getPreviousBlock;
|
||||
Squire.getNextBlock = getNextBlock;
|
||||
Squire.areAlike = areAlike;
|
||||
Squire.hasTagAttributes = hasTagAttributes;
|
||||
Squire.getNearest = getNearest;
|
||||
Squire.isOrContains = isOrContains;
|
||||
Squire.detach = detach;
|
||||
Squire.replaceWith = replaceWith;
|
||||
Squire.empty = empty;
|
||||
|
||||
// Range.js exports
|
||||
Squire.getNodeBefore = getNodeBefore;
|
||||
Squire.getNodeAfter = getNodeAfter;
|
||||
|
|
Loading…
Reference in a new issue