mirror of
https://github.com/fastmail/Squire.git
synced 2024-12-22 15:23:29 -05:00
Merge pull request #80 from crossjs-master
This commit is contained in:
commit
1ec7956c97
3 changed files with 36 additions and 6 deletions
|
@ -1438,7 +1438,7 @@ function getSquireInstance ( doc ) {
|
|||
return null;
|
||||
}
|
||||
|
||||
function Squire ( doc ) {
|
||||
function Squire ( doc, config ) {
|
||||
var win = doc.defaultView;
|
||||
var body = doc.body;
|
||||
var mutation;
|
||||
|
@ -1504,6 +1504,9 @@ function Squire ( doc ) {
|
|||
// Add key handlers
|
||||
this._keyHandlers = Object.create( keyHandlers );
|
||||
|
||||
// Override default properties
|
||||
this.setConfig( config );
|
||||
|
||||
// Fix IE<10's buggy implementation of Text#splitText.
|
||||
// If the split is at the end of the node, it doesn't insert the newly split
|
||||
// node into the document, and sets its value to undefined rather than ''.
|
||||
|
@ -1534,7 +1537,6 @@ function Squire ( doc ) {
|
|||
}
|
||||
|
||||
body.setAttribute( 'contenteditable', 'true' );
|
||||
this.setHTML( '' );
|
||||
|
||||
// Remove Firefox's built-in controls
|
||||
try {
|
||||
|
@ -1543,10 +1545,23 @@ function Squire ( doc ) {
|
|||
} catch ( error ) {}
|
||||
|
||||
instances.push( this );
|
||||
|
||||
// Need to register instance before calling setHTML, so that the fixCursor
|
||||
// function can lookup any default block tag options set.
|
||||
this.setHTML( '' );
|
||||
}
|
||||
|
||||
var proto = Squire.prototype;
|
||||
|
||||
proto.setConfig = function ( config ) {
|
||||
for ( var prop in config ) {
|
||||
if ( config.hasOwnProperty( prop ) ) {
|
||||
this[ prop ] = config[ prop ];
|
||||
}
|
||||
}
|
||||
return this;
|
||||
};
|
||||
|
||||
proto.createElement = function ( tag, props, children ) {
|
||||
return createElement( this._doc, tag, props, children );
|
||||
};
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -14,7 +14,7 @@ function getSquireInstance ( doc ) {
|
|||
return null;
|
||||
}
|
||||
|
||||
function Squire ( doc ) {
|
||||
function Squire ( doc, config ) {
|
||||
var win = doc.defaultView;
|
||||
var body = doc.body;
|
||||
var mutation;
|
||||
|
@ -80,6 +80,9 @@ function Squire ( doc ) {
|
|||
// Add key handlers
|
||||
this._keyHandlers = Object.create( keyHandlers );
|
||||
|
||||
// Override default properties
|
||||
this.setConfig( config );
|
||||
|
||||
// Fix IE<10's buggy implementation of Text#splitText.
|
||||
// If the split is at the end of the node, it doesn't insert the newly split
|
||||
// node into the document, and sets its value to undefined rather than ''.
|
||||
|
@ -110,7 +113,6 @@ function Squire ( doc ) {
|
|||
}
|
||||
|
||||
body.setAttribute( 'contenteditable', 'true' );
|
||||
this.setHTML( '' );
|
||||
|
||||
// Remove Firefox's built-in controls
|
||||
try {
|
||||
|
@ -119,10 +121,23 @@ function Squire ( doc ) {
|
|||
} catch ( error ) {}
|
||||
|
||||
instances.push( this );
|
||||
|
||||
// Need to register instance before calling setHTML, so that the fixCursor
|
||||
// function can lookup any default block tag options set.
|
||||
this.setHTML( '' );
|
||||
}
|
||||
|
||||
var proto = Squire.prototype;
|
||||
|
||||
proto.setConfig = function ( config ) {
|
||||
for ( var prop in config ) {
|
||||
if ( config.hasOwnProperty( prop ) ) {
|
||||
this[ prop ] = config[ prop ];
|
||||
}
|
||||
}
|
||||
return this;
|
||||
};
|
||||
|
||||
proto.createElement = function ( tag, props, children ) {
|
||||
return createElement( this._doc, tag, props, children );
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue