From db06a51299e0888b07062cefd780d514d09ebd37 Mon Sep 17 00:00:00 2001 From: Yukai Huang Date: Sun, 9 Apr 2017 20:05:48 +0800 Subject: Load statusbar template by string-loader --- public/js/lib/editor/index.js | 54 ++++++++++++++----------------------- public/js/lib/editor/statusbar.html | 41 ++++++++++++++++++++++++++++ 2 files changed, 61 insertions(+), 34 deletions(-) create mode 100644 public/js/lib/editor/statusbar.html (limited to 'public/js/lib/editor') diff --git a/public/js/lib/editor/index.js b/public/js/lib/editor/index.js index c807a17f..8cab486c 100644 --- a/public/js/lib/editor/index.js +++ b/public/js/lib/editor/index.js @@ -1,5 +1,6 @@ import * as utils from './utils' import config from './config' +import statusBarTemplate from './statusbar.html' /* config section */ const isMac = CodeMirror.keyMap.default === CodeMirror.keyMap.macDefault @@ -132,40 +133,27 @@ export default class Editor { }) } - getStatusBarTemplate () { - return new Promise((resolve, reject) => { - $.get(window.serverurl + '/views/statusbar.html').done(template => { - this.statusBarTemplate = template - resolve() - }).fail(reject) - }) - } - addStatusBar () { - if (!this.statusBarTemplate) { - this.getStatusBarTemplate.then(this.addStatusBar) - } else { - this.statusBar = $(this.statusBarTemplate) - this.statusCursor = this.statusBar.find('.status-cursor > .status-line-column') - this.statusSelection = this.statusBar.find('.status-cursor > .status-selection') - this.statusFile = this.statusBar.find('.status-file') - this.statusIndicators = this.statusBar.find('.status-indicators') - this.statusIndent = this.statusBar.find('.status-indent') - this.statusKeymap = this.statusBar.find('.status-keymap') - this.statusLength = this.statusBar.find('.status-length') - this.statusTheme = this.statusBar.find('.status-theme') - this.statusSpellcheck = this.statusBar.find('.status-spellcheck') - this.statusPreferences = this.statusBar.find('.status-preferences') - this.statusPanel = this.editor.addPanel(this.statusBar[0], { - position: 'bottom' - }) + this.statusBar = $(statusBarTemplate) + this.statusCursor = this.statusBar.find('.status-cursor > .status-line-column') + this.statusSelection = this.statusBar.find('.status-cursor > .status-selection') + this.statusFile = this.statusBar.find('.status-file') + this.statusIndicators = this.statusBar.find('.status-indicators') + this.statusIndent = this.statusBar.find('.status-indent') + this.statusKeymap = this.statusBar.find('.status-keymap') + this.statusLength = this.statusBar.find('.status-length') + this.statusTheme = this.statusBar.find('.status-theme') + this.statusSpellcheck = this.statusBar.find('.status-spellcheck') + this.statusPreferences = this.statusBar.find('.status-preferences') + this.statusPanel = this.editor.addPanel(this.statusBar[0], { + position: 'bottom' + }) - this.setIndent() - this.setKeymap() - this.setTheme() - this.setSpellcheck() - this.setPreferences() - } + this.setIndent() + this.setKeymap() + this.setTheme() + this.setSpellcheck() + this.setPreferences() } updateStatusBar () { @@ -508,8 +496,6 @@ export default class Editor { placeholder: "← Start by entering a title here\n===\nVisit /features if you don't know what to do.\nHappy hacking :)" }) - this.getStatusBarTemplate() - return this.editor } diff --git a/public/js/lib/editor/statusbar.html b/public/js/lib/editor/statusbar.html new file mode 100644 index 00000000..24cbf6c2 --- /dev/null +++ b/public/js/lib/editor/statusbar.html @@ -0,0 +1,41 @@ +
+
+
+ + +
+
+
+
+
+ + +
+
Spaces:
+
4
+ +
+
+ +
+
+ +
+
+
-- cgit v1.2.3 From c6c11c54ef62ed5c87dc7eb8139805a2889cbcc8 Mon Sep 17 00:00:00 2001 From: Yukai Huang Date: Sun, 9 Apr 2017 21:14:23 +0800 Subject: Expose internal editor config variable --- public/js/lib/editor/index.js | 1 + 1 file changed, 1 insertion(+) (limited to 'public/js/lib/editor') diff --git a/public/js/lib/editor/index.js b/public/js/lib/editor/index.js index 8cab486c..2991998b 100644 --- a/public/js/lib/editor/index.js +++ b/public/js/lib/editor/index.js @@ -119,6 +119,7 @@ export default class Editor { } } this.eventListeners = {} + this.config = config } on (event, cb) { -- cgit v1.2.3 From 68ccee20b3709b9a0499d659c74ac0a298a9ffeb Mon Sep 17 00:00:00 2001 From: Yukai Huang Date: Tue, 11 Apr 2017 11:48:59 +0800 Subject: Extract modeType --- public/js/lib/editor/modeType.js | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 public/js/lib/editor/modeType.js (limited to 'public/js/lib/editor') diff --git a/public/js/lib/editor/modeType.js b/public/js/lib/editor/modeType.js new file mode 100644 index 00000000..f3212105 --- /dev/null +++ b/public/js/lib/editor/modeType.js @@ -0,0 +1,11 @@ +export default { + edit: { + name: 'edit' + }, + view: { + name: 'view' + }, + both: { + name: 'both' + } +} -- cgit v1.2.3 From 4839838d0cdfca29a9e87fcf966ec026ee99a14f Mon Sep 17 00:00:00 2001 From: Yukai Huang Date: Wed, 12 Apr 2017 09:21:13 +0800 Subject: Manage syncscroll / currentMode in appState --- public/js/lib/editor/modeType.js | 11 ----------- 1 file changed, 11 deletions(-) delete mode 100644 public/js/lib/editor/modeType.js (limited to 'public/js/lib/editor') diff --git a/public/js/lib/editor/modeType.js b/public/js/lib/editor/modeType.js deleted file mode 100644 index f3212105..00000000 --- a/public/js/lib/editor/modeType.js +++ /dev/null @@ -1,11 +0,0 @@ -export default { - edit: { - name: 'edit' - }, - view: { - name: 'view' - }, - both: { - name: 'both' - } -} -- cgit v1.2.3