mirror of
https://github.com/fastmail/Squire.git
synced 2024-12-22 15:23:29 -05:00
override default properties by config
This commit is contained in:
parent
22408056bb
commit
21326b9fd1
1 changed files with 14 additions and 36 deletions
50
Demo.html
50
Demo.html
|
@ -52,19 +52,19 @@
|
|||
<span id="makeLink" class="prompt">Link</span>
|
||||
</p>
|
||||
<p>
|
||||
<span id="increaseQuoteLevel">Quote</span>
|
||||
<span id="decreaseQuoteLevel">Dequote</span>
|
||||
<span id="increaseQuoteLevel">Quote</span>
|
||||
<span id="decreaseQuoteLevel">Dequote</span>
|
||||
|
||||
<span id="makeUnorderedList">List</span>
|
||||
<span id="removeList">Unlist</span>
|
||||
<span id="increaseListLevel">Increase list level</span>
|
||||
<span id="decreaseListLevel">Decrease list level</span>
|
||||
<span id="makeUnorderedList">List</span>
|
||||
<span id="removeList">Unlist</span>
|
||||
<span id="increaseListLevel">Increase list level</span>
|
||||
<span id="decreaseListLevel">Decrease list level</span>
|
||||
|
||||
<span id="insertImage" class="prompt" value="https://pbs.twimg.com/profile_images/508277159681478656/hC9WIBpC_normal.jpeg">Insert image</span>
|
||||
<span id="insertImage" class="prompt">Insert image</span>
|
||||
<span id="setHTML" class="prompt">Set HTML</span>
|
||||
|
||||
<span id="undo">Undo</span>
|
||||
<span id="redo">Redo</span>
|
||||
<span id="undo">Undo</span>
|
||||
<span id="redo">Redo</span>
|
||||
</p>
|
||||
</header>
|
||||
<script type="text/template" id="editorStyles">
|
||||
|
@ -112,60 +112,38 @@
|
|||
</script>
|
||||
<script type="text/javascript" src="build/squire-raw.js"></script>
|
||||
<script type="text/javascript" charset="utf-8">
|
||||
var Squire = window.Squire;
|
||||
var editor;
|
||||
var iframe = document.createElement( 'iframe' );
|
||||
iframe.addEventListener( 'load', function () {
|
||||
// Make sure we're in standards mode.
|
||||
var doc = iframe.contentDocument;
|
||||
|
||||
if ( doc.compatMode !== 'CSS1Compat' ) {
|
||||
doc.open();
|
||||
doc.write( '<!DOCTYPE html><title></title>' );
|
||||
doc.close();
|
||||
doc.open();
|
||||
doc.write( '<!DOCTYPE html><title></title>' );
|
||||
doc.close();
|
||||
}
|
||||
|
||||
// doc.close() can cause a re-entrant load event in some browsers,
|
||||
// such as IE9.
|
||||
if ( editor ) {
|
||||
return;
|
||||
return;
|
||||
}
|
||||
|
||||
// Create Squire instance
|
||||
editor = new Squire( doc, {
|
||||
defaultBlockTag: 'P'
|
||||
} );
|
||||
|
||||
// Add styles to frame
|
||||
var style = doc.createElement( 'style' );
|
||||
style.type = 'text/css';
|
||||
style.textContent = document.getElementById( 'editorStyles' ).textContent;
|
||||
doc.querySelector( 'head' ).appendChild( style );
|
||||
|
||||
// plugins
|
||||
editor.addEventListener('mousedown', function(e) {
|
||||
if (e.target.nodeName === 'IMG') {
|
||||
this.selectNode(e.target);
|
||||
}
|
||||
});
|
||||
editor.addEventListener('select', function(e) {
|
||||
console.log(this.getSelectedNode() || this.getSelectedText());
|
||||
});
|
||||
editor.addEventListener('mouseup', function(e) {
|
||||
console.log(this.getPath(),
|
||||
this.getSelectedNode(),
|
||||
this.getSelectedText());
|
||||
});
|
||||
}, false );
|
||||
|
||||
document.body.appendChild( iframe );
|
||||
|
||||
document.addEventListener( 'click', function ( e ) {
|
||||
var id = e.target.id,
|
||||
value;
|
||||
if ( id && editor && editor[ id ] ) {
|
||||
if ( e.target.className === 'prompt' ) {
|
||||
value = prompt( 'Value:', e.target.getAttribute('value') );
|
||||
value = prompt( 'Value:' );
|
||||
}
|
||||
editor[ id ]( value );
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue