Toggle navigation
Toggle navigation
This project
Loading...
Sign in
Зуев Егор
/
wiki.dev
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
Authored by
Dan Brown
2016-05-28 13:51:07 +0100
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
Commit
5b9362ab0b7bf4f6ee36e3cca4b35fda99e8b316
5b9362ab
1 parent
f602b088
Added (Ctrl+s) draft force save
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
1 deletions
resources/assets/js/controllers.js
resources/assets/js/directives.js
resources/assets/js/controllers.js
View file @
5b9362a
...
...
@@ -379,6 +379,15 @@ module.exports = function (ngApp, events) {
saveDraft
();
};
// Listen to shortcuts coming via events
$scope
.
$on
(
'editor-keydown'
,
(
event
,
data
)
=>
{
// Save shortcut (ctrl+s)
if
(
data
.
keyCode
==
83
&&
(
navigator
.
platform
.
match
(
"Mac"
)
?
data
.
metaKey
:
data
.
ctrlKey
))
{
data
.
preventDefault
();
saveDraft
();
}
});
/**
* Discard the current draft and grab the current page
* content from the system via an AJAX request.
...
...
resources/assets/js/directives.js
View file @
5b9362a
...
...
@@ -185,6 +185,10 @@ module.exports = function (ngApp, events) {
scope
.
mceChange
(
content
);
});
editor
.
on
(
'keydown'
,
(
event
)
=>
{
scope
.
$emit
(
'editor-keydown'
,
event
);
});
editor
.
on
(
'init'
,
(
e
)
=>
{
scope
.
mceModel
=
editor
.
getContent
();
});
...
...
@@ -305,8 +309,9 @@ module.exports = function (ngApp, events) {
lastScroll
=
now
;
});
//
Insert image shortcut
//
Editor key-presses
input
.
keydown
(
event
=>
{
// Insert image shortcut
if
(
event
.
which
===
73
&&
event
.
ctrlKey
&&
event
.
shiftKey
)
{
event
.
preventDefault
();
var
caretPos
=
input
[
0
].
selectionStart
;
...
...
@@ -316,7 +321,10 @@ module.exports = function (ngApp, events) {
input
.
focus
();
input
[
0
].
selectionStart
=
caretPos
+
(
";
input
[
0
].
selectionEnd
=
caretPos
+
(
';
return
;
}
// Pass key presses to controller via event
scope
.
$emit
(
'editor-keydown'
,
event
);
});
// Insert image from image manager
...
...
Please
register
or
sign in
to post a comment