From d6ae7a36aeef3b5c261bb521f5e3f48898b65ede Mon Sep 17 00:00:00 2001 From: Yukai Huang Date: Sat, 24 Dec 2016 11:09:07 +0800 Subject: Fix module variable require --- public/js/index.js | 1 + 1 file changed, 1 insertion(+) (limited to 'public/js/index.js') diff --git a/public/js/index.js b/public/js/index.js index 96580fe3..4a466245 100644 --- a/public/js/index.js +++ b/public/js/index.js @@ -29,6 +29,7 @@ var DROPBOX_APP_KEY = common.DROPBOX_APP_KEY; var noteurl = common.noteurl; var checkLoginStateChanged = common.checkLoginStateChanged; +var loginStateChangeEvent = common.loginStateChangeEvent; var extra = require('./extra'); var md = extra.md; -- cgit v1.2.3 From 781f495f3e04b863be58226b5af8e6ab94d9355a Mon Sep 17 00:00:00 2001 From: Yukai Huang Date: Wed, 4 Jan 2017 23:01:44 +0800 Subject: Convert synscroll to es6 --- public/js/index.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'public/js/index.js') diff --git a/public/js/index.js b/public/js/index.js index 8921eda3..46dfffd9 100644 --- a/public/js/index.js +++ b/public/js/index.js @@ -51,11 +51,12 @@ var parseMeta = extra.parseMeta; var exportToHTML = extra.exportToHTML; var exportToRawHTML = extra.exportToRawHTML; -var syncScroll = require('./syncscroll'); -var setupSyncAreas = syncScroll.setupSyncAreas; -var clearMap = syncScroll.clearMap; -var syncScrollToEdit = syncScroll.syncScrollToEdit; -var syncScrollToView = syncScroll.syncScrollToView; +import { + clearMap, + setupSyncAreas, + syncScrollToEdit, + syncScrollToView +} from './syncscroll'; var historyModule = require('./history'); var writeHistory = historyModule.writeHistory; @@ -3693,6 +3694,7 @@ function checkCursorMenuInner() { var offsetLeft = 0; var offsetTop = defaultTextHeight; // set up side down + window.upSideDown = false; var lastUpSideDown = upSideDown = false; // only do when have width and height if (width > 0 && height > 0) { -- cgit v1.2.3 From 6a06c0bb9fea6d499d7fd2f7e6a65e16099cfb05 Mon Sep 17 00:00:00 2001 From: Yukai Huang Date: Thu, 5 Jan 2017 16:48:23 +0800 Subject: Convert common.js to es6 --- public/js/index.js | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) (limited to 'public/js/index.js') diff --git a/public/js/index.js b/public/js/index.js index 46dfffd9..381f051e 100644 --- a/public/js/index.js +++ b/public/js/index.js @@ -17,18 +17,18 @@ var _ = require("lodash"); var List = require('list.js'); -var common = require('./common.js'); -var urlpath = common.urlpath; -var noteid = common.noteid; -var debug = common.debug; -var version = common.version; -var GOOGLE_API_KEY = common.GOOGLE_API_KEY; -var GOOGLE_CLIENT_ID = common.GOOGLE_CLIENT_ID; -var DROPBOX_APP_KEY = common.DROPBOX_APP_KEY; -var noteurl = common.noteurl; - -var checkLoginStateChanged = common.checkLoginStateChanged; -var loginStateChangeEvent = common.loginStateChangeEvent; +import { + checkLoginStateChanged, + setloginStateChangeEvent, + debug, + DROPBOX_APP_KEY, + GOOGLE_API_KEY, + GOOGLE_CLIENT_ID, + noteid, + noteurl, + urlpath, + version +} from './common'; var extra = require('./extra'); var md = extra.md; @@ -963,10 +963,10 @@ function setNeedRefresh() { showStatus(statusType.offline); } -loginStateChangeEvent = function () { +setloginStateChangeEvent(function () { setRefreshModal('user-state-changed'); setNeedRefresh(); -}; +}); //visibility var wasFocus = false; -- cgit v1.2.3 From 47d7ff25617ba60790dd2018df56778eaa9bffdb Mon Sep 17 00:00:00 2001 From: Yukai Huang Date: Thu, 5 Jan 2017 17:52:32 +0800 Subject: Convert extra.js to es6 --- public/js/index.js | 41 +++++++++++++++++++++-------------------- 1 file changed, 21 insertions(+), 20 deletions(-) (limited to 'public/js/index.js') diff --git a/public/js/index.js b/public/js/index.js index 381f051e..7406c9a2 100644 --- a/public/js/index.js +++ b/public/js/index.js @@ -30,26 +30,27 @@ import { version } from './common'; -var extra = require('./extra'); -var md = extra.md; -var updateLastChange = extra.updateLastChange; -var postProcess = extra.postProcess; -var finishView = extra.finishView; -var autoLinkify = extra.autoLinkify; -var generateToc = extra.generateToc; -var smoothHashScroll = extra.smoothHashScroll; -var deduplicatedHeaderId = extra.deduplicatedHeaderId; -var renderTOC = extra.renderTOC; -var renderTitle = extra.renderTitle; -var renderFilename = extra.renderFilename; -var renderTags = extra.renderTags; -var isValidURL = extra.isValidURL; -var scrollToHash = extra.scrollToHash; -var updateLastChangeUser = extra.updateLastChangeUser; -var updateOwner = extra.updateOwner; -var parseMeta = extra.parseMeta; -var exportToHTML = extra.exportToHTML; -var exportToRawHTML = extra.exportToRawHTML; +import { + autoLinkify, + deduplicatedHeaderId, + exportToHTML, + exportToRawHTML, + finishView, + generateToc, + isValidURL, + md, + parseMeta, + postProcess, + renderFilename, + renderTOC, + renderTags, + renderTitle, + scrollToHash, + smoothHashScroll, + updateLastChange, + updateLastChangeUser, + updateOwner +} from './extra'; import { clearMap, -- cgit v1.2.3 From fce08cc164bb1ecc6b986fe6630381b630a1508c Mon Sep 17 00:00:00 2001 From: Yukai Huang Date: Thu, 5 Jan 2017 20:56:16 +0800 Subject: Convert history.js to es6 --- public/js/index.js | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'public/js/index.js') diff --git a/public/js/index.js b/public/js/index.js index 7406c9a2..660f73e4 100644 --- a/public/js/index.js +++ b/public/js/index.js @@ -59,12 +59,13 @@ import { syncScrollToView } from './syncscroll'; -var historyModule = require('./history'); -var writeHistory = historyModule.writeHistory; -var deleteServerHistory = historyModule.deleteServerHistory; -var getHistory = historyModule.getHistory; -var saveHistory = historyModule.saveHistory; -var removeHistory = historyModule.removeHistory; +import { + writeHistory, + deleteServerHistory, + getHistory, + saveHistory, + removeHistory +} from './history'; var renderer = require('./render'); var preventXSS = renderer.preventXSS; -- cgit v1.2.3 From 0fca629c34b83617b2d72e42aa0edb66fd2e71f6 Mon Sep 17 00:00:00 2001 From: Yukai Huang Date: Fri, 13 Jan 2017 22:51:44 +0800 Subject: Rename common.js to login.js --- public/js/index.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'public/js/index.js') diff --git a/public/js/index.js b/public/js/index.js index 660f73e4..3bf42ad4 100644 --- a/public/js/index.js +++ b/public/js/index.js @@ -19,7 +19,10 @@ var List = require('list.js'); import { checkLoginStateChanged, - setloginStateChangeEvent, + setloginStateChangeEvent +} from './lib/common/login'; + +import { debug, DROPBOX_APP_KEY, GOOGLE_API_KEY, @@ -28,7 +31,7 @@ import { noteurl, urlpath, version -} from './common'; +} from './lib/config'; import { autoLinkify, -- cgit v1.2.3 From e98278492e3c80816d54e1a6841548409c8a4d80 Mon Sep 17 00:00:00 2001 From: Wu Cheng-Han Date: Sat, 21 Jan 2017 12:50:02 +0800 Subject: Fix meta error not clear on before rendering --- public/js/index.js | 1 + 1 file changed, 1 insertion(+) (limited to 'public/js/index.js') diff --git a/public/js/index.js b/public/js/index.js index a018e513..6e55fa17 100644 --- a/public/js/index.js +++ b/public/js/index.js @@ -3445,6 +3445,7 @@ function updateViewInner() { var value = editor.getValue(); var lastMeta = md.meta; md.meta = {}; + delete md.metaError; var rendered = md.render(value); if (md.meta.type && md.meta.type === 'slide') { var slideOptions = { -- cgit v1.2.3 From e67a6ad3685289437e510906eeffb0d764ba4a37 Mon Sep 17 00:00:00 2001 From: Wu Cheng-Han Date: Fri, 3 Feb 2017 00:07:08 +0800 Subject: Fix missing type declaration --- public/js/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'public/js/index.js') diff --git a/public/js/index.js b/public/js/index.js index 39f28fbd..56f4fd38 100644 --- a/public/js/index.js +++ b/public/js/index.js @@ -2675,7 +2675,7 @@ editor.on('update', function () { }); // clear tooltip which described element has been removed $('[id^="tooltip"]').each(function (index, element) { - $ele = $(element); + var $ele = $(element); if ($('[aria-describedby="' + $ele.attr('id') + '"]').length <= 0) $ele.remove(); }); }); -- cgit v1.2.3 From 5a212b933548ccc5ef1cd45d8b86d7d86c8f7b9e Mon Sep 17 00:00:00 2001 From: NV Date: Fri, 3 Feb 2017 17:35:16 +0900 Subject: Removed UTF-8 BOM in download function --- public/js/index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'public/js/index.js') diff --git a/public/js/index.js b/public/js/index.js index 39f28fbd..176f0da7 100644 --- a/public/js/index.js +++ b/public/js/index.js @@ -1542,7 +1542,7 @@ ui.toolbar.download.markdown.click(function (e) { var blob = new Blob([markdown], { type: "text/markdown;charset=utf-8" }); - saveAs(blob, filename); + saveAs(blob, filename, true); }); //html ui.toolbar.download.html.click(function (e) { @@ -1922,7 +1922,7 @@ $('#revisionModalDownload').click(function () { var blob = new Blob([revision.content], { type: "text/markdown;charset=utf-8" }); - saveAs(blob, filename); + saveAs(blob, filename, true); }); $('#revisionModalRevert').click(function () { if (!revision) return; -- cgit v1.2.3 From 0a3baec5b6bf6340fb7dfee3dce18807b01acfa6 Mon Sep 17 00:00:00 2001 From: Wu Cheng-Han Date: Fri, 3 Feb 2017 21:59:26 +0800 Subject: Fix missing type declaration in text complete strategy --- public/js/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'public/js/index.js') diff --git a/public/js/index.js b/public/js/index.js index dd26d379..9b42e79c 100644 --- a/public/js/index.js +++ b/public/js/index.js @@ -3953,7 +3953,7 @@ $(editor.getInputField()) match: /(?:^|\n|\s)(\>.*|\s|)((\^|)\[(\^|)\](\[\]|\(\)|\:|)\s*\w*)$/, search: function (term, callback) { var line = editor.getLine(editor.getCursor().line); - quote = line.match(this.match)[1].trim(); + var quote = line.match(this.match)[1].trim(); var list = []; if (quote.indexOf('>') == 0) { $.map(supportExtraTags, function (extratag) { -- cgit v1.2.3 From f7149f5a834ea79ec82f04ef2da257fe72f1b330 Mon Sep 17 00:00:00 2001 From: Wu Cheng-Han Date: Sat, 18 Feb 2017 20:10:34 +0800 Subject: Fix to keep selections on save and restore info --- public/js/index.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'public/js/index.js') diff --git a/public/js/index.js b/public/js/index.js index 9b42e79c..3ad79d59 100644 --- a/public/js/index.js +++ b/public/js/index.js @@ -408,7 +408,8 @@ window.lastInfo = { cursor: { line: null, ch: null - } + }, + selections: null }, view: { scroll: { @@ -3394,6 +3395,7 @@ function saveInfo() { break; } lastInfo.edit.cursor = editor.getCursor(); + lastInfo.edit.selections = editor.listSelections(); lastInfo.needRestore = true; } @@ -3403,6 +3405,7 @@ function restoreInfo() { var line = lastInfo.edit.cursor.line; var ch = lastInfo.edit.cursor.ch; editor.setCursor(line, ch); + editor.setSelections(lastInfo.edit.selections); switch (currentMode) { case modeType.edit: if (scrollbarStyle == 'native') { -- cgit v1.2.3 From 0aaa59813018847c765624bcd8cfa22e9aa57284 Mon Sep 17 00:00:00 2001 From: Wu Cheng-Han Date: Sat, 18 Feb 2017 20:11:18 +0800 Subject: Fix not determine OT have pending operations properly --- public/js/index.js | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'public/js/index.js') diff --git a/public/js/index.js b/public/js/index.js index 3ad79d59..f0c476ef 100644 --- a/public/js/index.js +++ b/public/js/index.js @@ -2519,7 +2519,7 @@ var addStyleRule = (function () { }()); function updateAuthorshipInner() { // ignore when ot not synced yet - if (cmClient && Object.keys(cmClient.state).length > 0) return; + if (havePendingOperation()) return; authorMarks = {}; for (var i = 0; i < authorship.length; i++) { var atom = authorship[i]; @@ -2734,12 +2734,16 @@ var EditorClient = ot.EditorClient; var SocketIOAdapter = ot.SocketIOAdapter; var CodeMirrorAdapter = ot.CodeMirrorAdapter; var cmClient = null; +var synchronized_ = null; + +function havePendingOperation() { + return (cmClient && cmClient.state && cmClient.state.hasOwnProperty('outstanding')) ? true : false; +} socket.on('doc', function (obj) { var body = obj.str; var bodyMismatch = editor.getValue() !== body; - var havePendingOperation = cmClient && Object.keys(cmClient.state).length > 0; - var setDoc = !cmClient || (cmClient && (cmClient.revision === -1 || (cmClient.revision !== obj.revision && !havePendingOperation))) || obj.force; + var setDoc = !cmClient || (cmClient && (cmClient.revision === -1 || (cmClient.revision !== obj.revision && !havePendingOperation()))) || obj.force; saveInfo(); if (setDoc && bodyMismatch) { @@ -2764,16 +2768,17 @@ socket.on('doc', function (obj) { obj.revision, obj.clients, new SocketIOAdapter(socket), new CodeMirrorAdapter(editor) ); + synchronized_ = cmClient.state; } else if (setDoc) { if (bodyMismatch) { cmClient.undoManager.undoStack.length = 0; cmClient.undoManager.redoStack.length = 0; } cmClient.revision = obj.revision; - cmClient.setState(new ot.Client.Synchronized()); + cmClient.setState(synchronized_); cmClient.initializeClientList(); cmClient.initializeClients(obj.clients); - } else if (havePendingOperation) { + } else if (havePendingOperation()) { cmClient.serverReconnect(); } -- cgit v1.2.3