Configurable cursor focus

This commit is contained in:
benweet 2014-04-27 13:43:57 +01:00
parent bf778a9945
commit 0a1057d860
11 changed files with 806 additions and 771 deletions

View File

@ -117,6 +117,8 @@ Markdown Extra
> **Tip:** You can disable any **Markdown Extra** feature in the `Extensions` tab of the <i class="icon-cog"></i> `Settings` dialog. > **Tip:** You can disable any **Markdown Extra** feature in the `Extensions` tab of the <i class="icon-cog"></i> `Settings` dialog.
> **Note:** You can find more information about **Markdown** syntax [here][2] and **Markdown Extra** extension [here][3].
### Tables ### Tables
@ -166,6 +168,11 @@ var bar = 0;
> **Tip:** To use **Highlight.js** instead of **Prettify**, just configure the `Markdown Extra` extension in the <i class="icon-cog"></i> `Settings` dialog. > **Tip:** To use **Highlight.js** instead of **Prettify**, just configure the `Markdown Extra` extension in the <i class="icon-cog"></i> `Settings` dialog.
> **Note:** You can find more information:
> - about **Prettify** syntax highlighting [here][5],
> - about **Highlight.js** syntax highlighting [here][6].
### Footnotes ### Footnotes
@ -202,19 +209,42 @@ $$
\Gamma(z) = \int_0^\infty t^{z-1}e^{-t}dt\,. \Gamma(z) = \int_0^\infty t^{z-1}e^{-t}dt\,.
$$ $$
> **Tip:** Make sure you include **MathJax** into your publications to render mathematical expression correctly. Your page/template should include something like: > **Tip:** Make sure you include **MathJax** into your publications to render mathematical expression properly. Your page/template should include something like this:
``` ```
<script type="text/javascript" src="https://stackedit.io/libs/MathJax/MathJax.js?config=TeX-AMS_HTML"></script> <script type="text/javascript" src="https://stackedit.io/libs/MathJax/MathJax.js?config=TeX-AMS_HTML"></script>
``` ```
> **NOTE:** You can find more information: > **Note:** You can find more information about **LaTeX** mathematical expressions [here][4].
> - about **Markdown** syntax [here][2],
> - about **Markdown Extra** extension [here][3], ### UML diagrams
> - about **LaTeX** mathematical expressions [here][4],
> - about **Prettify** syntax highlighting [here][5], You can also render sequence diagrams like this:
> - about **Highlight.js** syntax highlighting [here][6].
```sequence
Alice->Bob: Hello Bob, how are you?
Note right of Bob: Bob thinks
Bob-->Alice: I am good thanks!
```
And flow charts like this:
```flow
st=>start: Start
e=>end
op=>operation: My Operation
cond=>condition: Yes or No?
st->op->cond
cond(yes)->e
cond(no)->op
```
> **Note:** You can find more information:
> - about **Sequence diagrams** syntax [here][7],
> - about **Flow charts** syntax [here][8].
[^stackedit]: [StackEdit](https://stackedit.io/) is a full-featured, open-source Markdown editor based on PageDown, the Markdown library used by Stack Overflow and the other Stack Exchange sites. [^stackedit]: [StackEdit](https://stackedit.io/) is a full-featured, open-source Markdown editor based on PageDown, the Markdown library used by Stack Overflow and the other Stack Exchange sites.
@ -227,3 +257,5 @@ $$
[4]: http://meta.math.stackexchange.com/questions/5020/mathjax-basic-tutorial-and-quick-reference [4]: http://meta.math.stackexchange.com/questions/5020/mathjax-basic-tutorial-and-quick-reference
[5]: https://code.google.com/p/google-code-prettify/ [5]: https://code.google.com/p/google-code-prettify/
[6]: http://highlightjs.org/ [6]: http://highlightjs.org/
[7]: http://bramp.github.io/js-sequence-diagrams/
[8]: http://adrai.github.io/flowchart.js/

View File

@ -119,6 +119,8 @@ define([
utils.setInputValue("#input-settings-font-size", settings.fontSizeRatio); utils.setInputValue("#input-settings-font-size", settings.fontSizeRatio);
// Max width ratio // Max width ratio
utils.setInputValue("#input-settings-max-width", settings.maxWidthRatio); utils.setInputValue("#input-settings-max-width", settings.maxWidthRatio);
// Cursor locking ratio
utils.setInputValue("#input-settings-cursor-focus", settings.cursorFocusRatio);
// Default content // Default content
utils.setInputValue("#textarea-settings-default-content", settings.defaultContent); utils.setInputValue("#textarea-settings-default-content", settings.defaultContent);
// Edit mode // Edit mode
@ -164,6 +166,8 @@ define([
newSettings.fontSizeRatio = utils.getInputFloatValue("#input-settings-font-size", event, 0.1, 10); newSettings.fontSizeRatio = utils.getInputFloatValue("#input-settings-font-size", event, 0.1, 10);
// Max width ratio // Max width ratio
newSettings.maxWidthRatio = utils.getInputFloatValue("#input-settings-max-width", event, 0.1, 10); newSettings.maxWidthRatio = utils.getInputFloatValue("#input-settings-max-width", event, 0.1, 10);
// Cursor locking ratio
newSettings.cursorFocusRatio = utils.getInputFloatValue("#input-settings-cursor-focus", event, 0, 1);
// Default content // Default content
newSettings.defaultContent = utils.getInputValue("#textarea-settings-default-content"); newSettings.defaultContent = utils.getInputValue("#textarea-settings-default-content");
// Edit mode // Edit mode

View File

@ -149,11 +149,8 @@ define([
this.cursorY = coordinates.y; this.cursorY = coordinates.y;
eventMgr.onCursorCoordinates(coordinates.x, coordinates.y); eventMgr.onCursorCoordinates(coordinates.x, coordinates.y);
} }
if(this.adjustScroll) { if(this.adjustScroll && settings.cursorFocusRatio) {
var adjust = inputElt.offsetHeight / 2; var adjust = inputElt.offsetHeight / 2 * settings.cursorFocusRatio;
if(adjust > 130) {
adjust = 130;
}
var cursorMinY = inputElt.scrollTop + adjust; var cursorMinY = inputElt.scrollTop + adjust;
var cursorMaxY = inputElt.scrollTop + inputElt.offsetHeight - adjust; var cursorMaxY = inputElt.scrollTop + inputElt.offsetHeight - adjust;
if(selectionMgr.cursorY < cursorMinY) { if(selectionMgr.cursorY < cursorMinY) {

View File

@ -137,53 +137,6 @@ define([
_.delay(doFlowChart, 0, cb); _.delay(doFlowChart, 0, cb);
} }
function doHighlight(cb) {
if(highlightEltList.length === 0) {
return cb();
}
var highlightElt = highlightEltList.pop();
hljs.highlightBlock(highlightElt);
highlightElt.highlighted = true;
_.delay(doHighlight, 0, cb);
}
function doPrettify(cb) {
if(prettifyEltList.length === 0) {
return cb();
}
var prettifyElt = prettifyEltList.pop();
var html = prettify.prettyPrintOne(prettifyElt.innerHTML);
prettifyElt.innerHTML = html;
prettifyElt.highlighted = true;
_.delay(doPrettify, 0, cb);
}
if(markdownExtra.config.highlighter == "highlight") {
extraOptions.highlighter = "prettify";
var afterHighlight = onAsyncPreview;
onAsyncPreview = function(cb) {
highlightEltList = _.filter(previewContentsElt.querySelectorAll('.prettyprint > code'), function(elt) {
return !elt.highlighted;
});
_.delay(doHighlight, 0, function() {
afterHighlight(cb);
});
};
}
if(markdownExtra.config.highlighter == "prettify") {
extraOptions.highlighter = "prettify";
var afterPrettify = onAsyncPreview;
onAsyncPreview = function(cb) {
prettifyEltList = _.filter(previewContentsElt.querySelectorAll('.prettyprint > code'), function(elt) {
return !elt.highlighted;
});
_.delay(doPrettify, 0, function() {
afterPrettify(cb);
});
};
}
if(markdownExtra.config.diagrams) { if(markdownExtra.config.diagrams) {
extraOptions.highlighter = "prettify"; extraOptions.highlighter = "prettify";
var afterDiagrams = onAsyncPreview; var afterDiagrams = onAsyncPreview;
@ -219,6 +172,20 @@ define([
}); });
}); });
} }
if(markdownExtra.config.highlighter == "highlight") {
extraOptions.highlighter = "prettify";
var previewContentsElt = document.getElementById('preview-contents');
editor.hooks.chain("onPreviewRefresh", function() {
_.each(previewContentsElt.querySelectorAll('.prettyprint > code'), function(elt) {
!elt.highlighted && hljs.highlightBlock(elt);
elt.highlighted = true;
});
});
}
else if(markdownExtra.config.highlighter == "prettify") {
extraOptions.highlighter = "prettify";
editor.hooks.chain("onPreviewRefresh", prettify.prettyPrint);
}
Markdown.Extra.init(converter, extraOptions); Markdown.Extra.init(converter, extraOptions);
}; };

View File

@ -68,6 +68,7 @@ define([
' <li>New contenteditable based editor (credit to Dabblet, Editorially...)</li>', ' <li>New contenteditable based editor (credit to Dabblet, Editorially...)</li>',
' <li>New layout with CSS3 transitions (lighter supposedly)</li>', ' <li>New layout with CSS3 transitions (lighter supposedly)</li>',
' <li>Comments/discussions support (see the new icon in the navigation bar)</li>', ' <li>Comments/discussions support (see the new icon in the navigation bar)</li>',
' <li>UML diagrams support</li>',
' <li>Auto-merge and conflict detection using standard synchronization</li>', ' <li>Auto-merge and conflict detection using standard synchronization</li>',
' <li>Dropped real time sync support :( since you can collaborate simultaneously using standard synchronization</li>', ' <li>Dropped real time sync support :( since you can collaborate simultaneously using standard synchronization</li>',
'</ul>', '</ul>',

View File

@ -110,13 +110,13 @@
<li><a href="#" class="submenu-sync-gdrive action-sync-export-dialog-gdrive"><i <li><a href="#" class="submenu-sync-gdrive action-sync-export-dialog-gdrive"><i
class="icon-provider-gdrive"></i> Save on Google Drive</a></li> class="icon-provider-gdrive"></i> Save on Google Drive</a></li>
<li><a href="#" class="submenu-sync-gdrivesec action-sync-import-gdrivesec"><i <li><a href="#" class="submenu-sync-gdrivesec action-sync-import-gdrivesec"><i
class="icon-provider-gdrive"></i> Open from Google Drive <small>(2nd account)</small></a></li> class="icon-provider-gdrive"></i> Open from Google Drive<br><small>(2nd account)</small></a></li>
<li><a href="#" class="submenu-sync-gdrivesec action-sync-export-dialog-gdrivesec"><i <li><a href="#" class="submenu-sync-gdrivesec action-sync-export-dialog-gdrivesec"><i
class="icon-provider-gdrive"></i> Save on Google Drive <small>(2nd account)</small></a></li> class="icon-provider-gdrive"></i> Save on Google Drive<br><small>(2nd account)</small></a></li>
<li><a href="#" class="submenu-sync-gdriveter action-sync-import-gdriveter"><i <li><a href="#" class="submenu-sync-gdriveter action-sync-import-gdriveter"><i
class="icon-provider-gdrive"></i> Open from Google Drive <small>(3rd account)</small></a></li> class="icon-provider-gdrive"></i> Open from Google Drive<br><small>(3rd account)</small></a></li>
<li><a href="#" class="submenu-sync-gdriveter action-sync-export-dialog-gdriveter"><i <li><a href="#" class="submenu-sync-gdriveter action-sync-export-dialog-gdriveter"><i
class="icon-provider-gdrive"></i> Save on Google Drive <small>(3rd account)</small></a></li> class="icon-provider-gdrive"></i> Save on Google Drive<br><small>(3rd account)</small></a></li>
</ul> </ul>
</div> </div>
<a href="#" data-toggle="collapse" data-target=".collapse-publish-on" <a href="#" data-toggle="collapse" data-target=".collapse-publish-on"
@ -870,6 +870,8 @@
"<span class="file-title"></span>" can be shared using the following link(s): "<span class="file-title"></span>" can be shared using the following link(s):
</p> </p>
<div class="msg-share-list share-list hide"></div> <div class="msg-share-list share-list hide"></div>
<p class="msg-no-share hide"><b>No sharing link yet!</b>
</p>
<p class="msg-no-share hide">To collaborate on this document, use <i class="icon-provider-gdrive"></i> <b>Google Drive</b> <p class="msg-no-share hide">To collaborate on this document, use <i class="icon-provider-gdrive"></i> <b>Google Drive</b>
or <i class="icon-provider-dropbox"></i> <b>Dropbox</b> synchronization from the <i class="icon-provider-stackedit"></i> menu. or <i class="icon-provider-dropbox"></i> <b>Dropbox</b> synchronization from the <i class="icon-provider-stackedit"></i> menu.
</p> </p>
@ -1028,6 +1030,14 @@
class="form-control col-sm-2"> class="form-control col-sm-2">
</div> </div>
</div> </div>
<div class="form-group">
<label class="col-sm-4 control-label"
for="input-settings-cursor-focus">Cursor focus ratio</label>
<div class="col-sm-8 form-inline">
<input type="text" id="input-settings-cursor-focus"
class="form-control col-sm-2">
</div>
</div>
<div class="form-group"> <div class="form-group">
<label class="col-sm-4 control-label" <label class="col-sm-4 control-label"
for="input-settings-lazy-rendering">Lazy rendering <a for="input-settings-lazy-rendering">Lazy rendering <a

View File

@ -33,11 +33,11 @@
<dl> <dl>
<dt>Developers:</dt> <dt>Developers:</dt>
<dd> <dd>
<a target="_blank" href="http://www.benoitschweblin.com">Benoit <a target="_blank" href="https://twitter.com/benweet">Benoit Schweblin</a><br />
Schweblin</a><br />
Pete Eigel (contributor)<br /> Pete Eigel (contributor)<br />
wiibaa (contributor) wiibaa (contributor)<br />
</dd> <a target="_blank" href="http://www.hugwebdesign.com/">Daniel Hug (contributor)</a><br />
</dd>
</dl> </dl>
<dl> <dl>
<dt>Credit:</dt> <dt>Credit:</dt>

File diff suppressed because it is too large Load Diff

View File

@ -1,70 +1,71 @@
define([ define([
"underscore", "underscore",
"constants", "constants",
"storage", "storage"
], function (_, constants, storage) { ], function(_, constants, storage) {
var settings = { var settings = {
layoutOrientation: "horizontal", layoutOrientation: "horizontal",
editMode: 'ltr', editMode: 'ltr',
lazyRendering: true, lazyRendering: true,
editorFontClass: 'font-rich', editorFontClass: 'font-rich',
fontSizeRatio: 1, fontSizeRatio: 1,
maxWidthRatio: 1, maxWidthRatio: 1,
defaultContent: "\n\n\n> Written with [StackEdit](" + constants.MAIN_URL + ").", cursorFocusRatio: 0.5,
commitMsg: "Published with " + constants.MAIN_URL, defaultContent: "\n\n\n> Written with [StackEdit](" + constants.MAIN_URL + ").",
conflictMode: 'merge', commitMsg: "Published with " + constants.MAIN_URL,
markdownMimeType: 'text/x-markdown', conflictMode: 'merge',
gdriveMultiAccount: 1, markdownMimeType: 'text/x-markdown',
gdriveFullAccess: true, gdriveMultiAccount: 1,
dropboxFullAccess: true, gdriveFullAccess: true,
githubFullAccess: true, dropboxFullAccess: true,
template: [ githubFullAccess: true,
'<!DOCTYPE html>\n', template: [
'<html>\n', '<!DOCTYPE html>\n',
'<head>\n', '<html>\n',
'<meta charset="utf-8">\n', '<head>\n',
'<title><%= documentTitle %></title>\n', '<meta charset="utf-8">\n',
'<link rel="stylesheet" href="', '<title><%= documentTitle %></title>\n',
constants.MAIN_URL, '<link rel="stylesheet" href="',
'res-min/themes/base.css" />\n', constants.MAIN_URL,
'<script type="text/javascript" src="', 'res-min/themes/base.css" />\n',
constants.MAIN_URL, '<script type="text/javascript" src="',
'libs/MathJax/MathJax.js?config=TeX-AMS_HTML"></script>\n', constants.MAIN_URL,
'</head>\n', 'libs/MathJax/MathJax.js?config=TeX-AMS_HTML"></script>\n',
'<body><div class="container"><%= documentHTML %></div></body>\n', '</head>\n',
'</html>' '<body><div class="container"><%= documentHTML %></div></body>\n',
].join(""), '</html>'
pdfTemplate: [ ].join(""),
'<!DOCTYPE html>\n', pdfTemplate: [
'<html>\n', '<!DOCTYPE html>\n',
'<head>\n', '<html>\n',
'<meta charset="utf-8">\n', '<head>\n',
'<title><%= documentTitle %></title>\n', '<meta charset="utf-8">\n',
'<link rel="stylesheet" href="', '<title><%= documentTitle %></title>\n',
constants.MAIN_URL, '<link rel="stylesheet" href="',
'res-min/themes/base.css" />\n', constants.MAIN_URL,
'<script type="text/x-mathjax-config">\n', 'res-min/themes/base.css" />\n',
'MathJax.Hub.Config({ messageStyle: "none" });\n', '<script type="text/x-mathjax-config">\n',
'</script>\n', 'MathJax.Hub.Config({ messageStyle: "none" });\n',
'<script type="text/javascript" src="', '</script>\n',
constants.MAIN_URL, '<script type="text/javascript" src="',
'libs/MathJax/MathJax.js?config=TeX-AMS_HTML"></script>\n', constants.MAIN_URL,
'</head>\n', 'libs/MathJax/MathJax.js?config=TeX-AMS_HTML"></script>\n',
'<body class="pdf"><%= documentHTML %></body>\n', '</head>\n',
'</html>' '<body class="pdf"><%= documentHTML %></body>\n',
].join(""), '</html>'
pdfPageSize: 'A4', ].join(""),
sshProxy: constants.SSH_PROXY_URL, pdfPageSize: 'A4',
extensionSettings: {} sshProxy: constants.SSH_PROXY_URL,
}; extensionSettings: {}
};
try { try {
_.extend(settings, JSON.parse(storage.settings)); _.extend(settings, JSON.parse(storage.settings));
} }
catch (e) { catch(e) {
// Ignore parsing error // Ignore parsing error
} }
return settings; return settings;
}); });

View File

@ -3,6 +3,7 @@
@import (less) "../libs/highlight/styles/default.css"; @import (less) "../libs/highlight/styles/default.css";
@import (less) "../libs/fontello/css/fontello.css"; @import (less) "../libs/fontello/css/fontello.css";
@body-bg: #fff;
@text-color: #000; @text-color: #000;
@kbd-color: #333; @kbd-color: #333;
@kbd-bg-color: #FFF; @kbd-bg-color: #FFF;
@ -138,7 +139,7 @@ hr {
font-family: @font-family-sans-serif !important; font-family: @font-family-sans-serif !important;
} }
[fill="#ffffff"] { [fill="#ffffff"] {
fill: none; fill: @body-bg;
} }
[stroke="#000000"] { [stroke="#000000"] {
stroke: @text-color; stroke: @text-color;
@ -239,7 +240,7 @@ kbd {
border: 1px solid @kbd-border-color; border: 1px solid @kbd-border-color;
.box-shadow(0 1px 0px @kbd-border-color); .box-shadow(0 1px 0px @kbd-border-color);
font-size: 0.7em; font-size: 0.7em;
font-family: Arial, Helvetica, sans-serif; font-family: sans-serif;
background-color: @kbd-bg-color; background-color: @kbd-bg-color;
color: @kbd-color; color: @kbd-color;
border-radius: 3px; border-radius: 3px;

View File

@ -1092,6 +1092,7 @@ a {
overflow: auto; overflow: auto;
white-space: pre-wrap; white-space: pre-wrap;
word-wrap: break-word; word-wrap: break-word;
word-break: normal;
> .editor-content { > .editor-content {
padding-bottom: 230px; padding-bottom: 230px;
} }