mirror of
https://github.com/fastmail/Squire.git
synced 2024-12-31 11:54:03 -05:00
Working: on getting text selection to work
This commit is contained in:
parent
632dd68a2f
commit
8479a7e1c7
2 changed files with 72 additions and 40 deletions
|
@ -1,30 +1,51 @@
|
|||
<div class="menu" contenteditable="false">
|
||||
<div class="group">
|
||||
<div data-action="bold" data-value="" class="item"><i class="fa fa-bold"></i></div>
|
||||
<div data-action="italic" data-value="" class="item"><i class="fa fa-italic"></i></div>
|
||||
<div data-action="underline" data-value="" class="item"><i class="fa fa-underline"></i></div>
|
||||
<div data-action="" data-value="" id="font" class="item">
|
||||
<i class="fa fa-font"></i>
|
||||
</div>
|
||||
<div class="item fa fa-bold" data-action="bold" data-value="" style=
|
||||
"font-style: italic"></div>
|
||||
|
||||
<div class="item fa fa-italic" data-action="italic" data-value="" style=
|
||||
"font-style: italic"></div>
|
||||
|
||||
<div class="item fa fa-underline" data-action="underline" data-value=""
|
||||
style="font-style: italic"></div>
|
||||
|
||||
<div class="item fa fa-font" data-action="" data-value="" id="font"
|
||||
style="font-style: italic"></div>
|
||||
</div>
|
||||
|
||||
<div class="group">
|
||||
<div data-action="link" data-value=""class="item"><i class="fa fa-link"></i></div>
|
||||
<div data-action="quote" data-value="" class="item"><i class="fa fa-quote-right"></i></div>
|
||||
<div data-action="list" data-value="" class="item"><i class="fa fa-list"></i></div>
|
||||
<div data-action="image" data-value="" class="item">
|
||||
<i class="fa fa-picture-o"></i>
|
||||
</div>
|
||||
<div class="item fa fa-link" data-action="link" data-value="" style=
|
||||
"font-style: italic"></div>
|
||||
|
||||
<div class="item fa fa-quote-right" data-action="quote" data-value=""
|
||||
style="font-style: italic"></div>
|
||||
|
||||
<div class="item fa fa-list" data-action="list" data-value="" style=
|
||||
"font-style: italic"></div>
|
||||
|
||||
<div class="item fa fa-picture-o" data-action="image" data-value=""
|
||||
style="font-style: italic"></div>
|
||||
</div>
|
||||
|
||||
<div class="group">
|
||||
<div data-action="undo" data-value="" class="item"><i class="fa fa-undo"></i></div>
|
||||
<div data-action="redo" data-value="" class="item"><i class="fa fa-undo flip"></i></div>
|
||||
<div class="item fa fa-link" data-action="link" data-value="" style=
|
||||
"font-style: italic"></div>
|
||||
|
||||
<div class="item fa fa-quote-right" data-action="quote" data-value=""
|
||||
style="font-style: italic"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="templates hidden">
|
||||
<div class="drop-font">
|
||||
<i class="fa fa-chevron-up quit"></i>
|
||||
Text Size: <input type="number" min="12" max="72" step="6" value="12" name="font-size">
|
||||
<br>
|
||||
Font: <input type="text">
|
||||
|
||||
<div class="group">
|
||||
<div class="item fa fa-undo" data-action="undo" data-value="" style=
|
||||
"font-style: italic"></div>
|
||||
|
||||
<div class="item fa fa-undo flip" data-action="redo" data-value="" style=
|
||||
"font-style: italic"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="templates hidden drop-font">
|
||||
<i class="fa fa-chevron-up quit"></i> Text Size: <input max="72" min="12"
|
||||
name="font-size" step="6" type="number" value="12"><br>
|
||||
Font: <input type="text">
|
||||
</div>
|
|
@ -26,29 +26,40 @@ $(document).ready(function () {
|
|||
var div = document.createElement('div');
|
||||
div.className = 'Squire-UI';
|
||||
|
||||
$(div).load(buildPath + 'Squire-UI.html', function () {
|
||||
$('.item').click(function () {
|
||||
var me = $(this);
|
||||
|
||||
var iFrame = me.parents('.Squire-UI').next('iframe').first()[0];
|
||||
editor = iFrame.contentWindow.document;
|
||||
console.log(me.data('action'), me.data('value'));
|
||||
try {
|
||||
editor[me.data('action')](me.data('value'));
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
|
||||
});
|
||||
});
|
||||
$(div).load(buildPath + 'Squire-UI.html', this.menuAction);
|
||||
|
||||
$(container).append(div);
|
||||
$(container).append(iframe);
|
||||
|
||||
editor = new Squire(iframe.contentWindow.document);
|
||||
return editor;
|
||||
iframe.contentWindow.editor = new Squire(iframe.contentWindow.document);
|
||||
return iframe.contentWindow.editor;
|
||||
};
|
||||
|
||||
|
||||
SquireUI.menuAction = function() {
|
||||
$('.item').click(function() {
|
||||
var me = $(this);
|
||||
var iFrame = me.parents('.Squire-UI').next('iframe').first()[0];
|
||||
var editor = iFrame.contentWindow.editor;
|
||||
try {
|
||||
editor[me.data('action')](me.data('value'));
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
SquireUI.isBold = isPresent( 'B', ( />B\b/ ) );
|
||||
SquireUI.isItalic = isPresent( 'I', ( />I\b/ ) );
|
||||
SquireUI.isUnderlined = isPresent( 'U', ( />U\b/ ) );
|
||||
SquireUI.isStriked = isPresent( 'S', ( />S\b/ ) );
|
||||
SquireUI.isLink = isPresent( 'A', ( />A\b/ ) );
|
||||
SquireUI.isPresent = function () {
|
||||
editor.getPath()
|
||||
};
|
||||
|
||||
SquireUI.whenTextSelected = function () {
|
||||
|
||||
}
|
||||
|
||||
|
||||
});
|
Loading…
Reference in a new issue