mirror of
https://github.com/fastmail/Squire.git
synced 2025-01-03 05:00:13 -05:00
Require <html data-squireinit="true"> to auto-instantiate.
Explicit opt-in to autoinstantiation (included in the default document.html) means Squire may be loaded in sites that themselves are loaded in iframes, without unexpected consequences. Resolves #104.
This commit is contained in:
parent
32d56823ce
commit
522a481dd3
6 changed files with 15 additions and 11 deletions
|
@ -39,7 +39,9 @@ Installation and usage
|
|||
Advanced usage
|
||||
--------------
|
||||
|
||||
If you load the library into a top-level document (rather than an iframe), it will not turn the page into an editable document, but will instead add a function named `Squire` to the global scope. Call `new Squire( document )`, with the `document` from an iframe to instantiate multiple rich text areas on the same page efficiently. Note, for compatibility with all browsers (particularly Firefox), you MUST wait for the iframe's `onload` event to fire before instantiating Squire.
|
||||
If you load the library into a top-level document (rather than an iframe), or load it in an iframe without the `data-squireinit="true"` attribute on its `<html>` element, it will not turn the page into an editable document, but will instead add a constructor named `Squire` to the global scope.
|
||||
|
||||
Call `new Squire( document )`, with the `document` from an iframe to instantiate multiple rich text areas on the same page efficiently. Note, for compatibility with all browsers (particularly Firefox), you MUST wait for the iframe's `onload` event to fire before instantiating Squire.
|
||||
|
||||
### Setting the default block style
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<html lang="en" data-squireinit="true">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
|
||||
|
|
|
@ -3854,14 +3854,15 @@ proto.decreaseListLevel = command( 'modifyBlocks', decreaseListLevel );
|
|||
if ( typeof exports === 'object' ) {
|
||||
module.exports = Squire;
|
||||
} else {
|
||||
if ( top !== win ) {
|
||||
win.Squire = Squire;
|
||||
|
||||
if ( top !== win &&
|
||||
doc.documentElement.getAttribute( 'data-squireinit' ) === 'true' ) {
|
||||
win.editor = new Squire( doc );
|
||||
if ( win.onEditorLoad ) {
|
||||
win.onEditorLoad( win.editor );
|
||||
win.onEditorLoad = null;
|
||||
}
|
||||
} else {
|
||||
win.Squire = Squire;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -1,5 +1,5 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<html lang="en" data-squireinit="true">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
|
||||
|
|
|
@ -3,14 +3,15 @@
|
|||
if ( typeof exports === 'object' ) {
|
||||
module.exports = Squire;
|
||||
} else {
|
||||
if ( top !== win ) {
|
||||
win.Squire = Squire;
|
||||
|
||||
if ( top !== win &&
|
||||
doc.documentElement.getAttribute( 'data-squireinit' ) === 'true' ) {
|
||||
win.editor = new Squire( doc );
|
||||
if ( win.onEditorLoad ) {
|
||||
win.onEditorLoad( win.editor );
|
||||
win.onEditorLoad = null;
|
||||
}
|
||||
} else {
|
||||
win.Squire = Squire;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue