Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/icewind1991/files_markdown.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/js
diff options
context:
space:
mode:
authorRobin Appelman <robin@icewind.nl>2017-09-10 19:46:11 +0300
committerRobin Appelman <robin@icewind.nl>2017-09-13 16:08:04 +0300
commit63d8d7225a410b2c9ce70c1fba3b62f147c9938c (patch)
tree9d13ce7fb971852692099019a52f005cf62546ad /js
parent28ade42c85064775f7fa5d56e005136be49f3631 (diff)
improve scrollMode resetting
Signed-off-by: Robin Appelman <robin@icewind.nl>
Diffstat (limited to 'js')
-rw-r--r--js/PreviewPlugin.ts19
-rw-r--r--js/editor.ts6
2 files changed, 11 insertions, 14 deletions
diff --git a/js/PreviewPlugin.ts b/js/PreviewPlugin.ts
index 2b81ba9..b4e5aec 100644
--- a/js/PreviewPlugin.ts
+++ b/js/PreviewPlugin.ts
@@ -109,9 +109,7 @@ export class PreviewPlugin {
if (typeof previewOffset !== 'undefined') {
$('#preview').scrollTop(previewOffset);
}
- setTimeout(() => {
- this.scrollMode = null;
- }, 100);
+ this.resetScrollMode();
}, 100);
onScrollPreview = _.throttle(() => {
@@ -121,15 +119,18 @@ export class PreviewPlugin {
this.scrollMode = 'preview';
const top = this.previewElement.scrollTop() as number;
const previewLine = this.offsetMap.findIndex(offset => offset >= (top - 1));
- aceEditor.scrollToLine(Math.max(previewLine - scrollOffsetLines, 0), false, true, () => {
- });
- setTimeout(() => {
- this.scrollMode = null;
- }, 100);
+ if (previewLine < this.session.getLength()) {
+ aceEditor.scrollToLine(Math.max(previewLine - scrollOffsetLines, 0), false, true, () => {
+ });
+ }
+ this.resetScrollMode();
}, 100);
+ resetScrollMode = _.debounce(() => {
+ this.scrollMode = null;
+ }, 500);
+
handleImage = (image: HTMLImageElement, file) => {
- console.log(file);
OC.dialogs.prompt('Enter the name for the image', 'Upload image', (ok, name) => {
if (!ok) {
return;
diff --git a/js/editor.ts b/js/editor.ts
index 2e5369e..077ba34 100644
--- a/js/editor.ts
+++ b/js/editor.ts
@@ -9,12 +9,8 @@ $(document).ready(function () {
}
});
-// fix editor closing when click on dialog
-
-// OCA.Files_Texteditor._onClickDocument
-
// coerce webpack into loading scripts properly
__webpack_require__.p = OC.filePath('files_markdown', 'js', '../build/');
-__webpack_require__.nc = $('script[nonce]')[0].getAttribute('nonce');
+__webpack_require__.nc = $('script[nonce][src]')[0].getAttribute('nonce');
OC.Plugins.register('OCA.Files.SidebarPreviewManager', new SidebarPreview());