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 --- package.json | 3 ++- public/js/lib/editor/index.js | 54 ++++++++++++++----------------------- public/js/lib/editor/statusbar.html | 41 ++++++++++++++++++++++++++++ public/views/statusbar.html | 41 ---------------------------- webpackBaseConfig.js | 3 +++ yarn.lock | 4 +++ 6 files changed, 70 insertions(+), 76 deletions(-) create mode 100644 public/js/lib/editor/statusbar.html delete mode 100644 public/views/statusbar.html diff --git a/package.json b/package.json index 29c5c95d..3637fd58 100644 --- a/package.json +++ b/package.json @@ -162,8 +162,9 @@ "less-loader": "^2.2.3", "optimize-css-assets-webpack-plugin": "^1.3.0", "script-loader": "^0.7.0", - "style-loader": "^0.13.1", "standard": "^9.0.1", + "string-loader": "^0.0.1", + "style-loader": "^0.13.1", "url-loader": "^0.5.7", "webpack": "^1.14.0", "webpack-parallel-uglify-plugin": "^0.2.0" 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 @@ +
diff --git a/public/views/statusbar.html b/public/views/statusbar.html deleted file mode 100644 index 24cbf6c2..00000000 --- a/public/views/statusbar.html +++ /dev/null @@ -1,41 +0,0 @@ - diff --git a/webpackBaseConfig.js b/webpackBaseConfig.js index 87f7ceeb..36a49f25 100644 --- a/webpackBaseConfig.js +++ b/webpackBaseConfig.js @@ -412,6 +412,9 @@ module.exports = { }, { test: /\.eot(\?v=\d+\.\d+\.\d+)?$/, loader: 'file' + }, { + test: /\.html$/, + loader: 'string' }, { test: /\.(woff|woff2)(\?v=\d+\.\d+\.\d+)?$/, loader: 'url?prefix=font/&limit=5000' diff --git a/yarn.lock b/yarn.lock index 360c5752..88addc98 100644 --- a/yarn.lock +++ b/yarn.lock @@ -6529,6 +6529,10 @@ strict-uri-encode@^1.0.0: version "1.1.0" resolved "https://registry.yarnpkg.com/strict-uri-encode/-/strict-uri-encode-1.1.0.tgz#279b225df1d582b1f54e65addd4352e18faa0713" +string-loader@^0.0.1: + version "0.0.1" + resolved "https://registry.yarnpkg.com/string-loader/-/string-loader-0.0.1.tgz#496f3cccc990213e0dd5411499f9ac6a6a6f2ff8" + string-natural-compare@^2.0.2: version "2.0.2" resolved "https://registry.yarnpkg.com/string-natural-compare/-/string-natural-compare-2.0.2.tgz#c5ce4e278ab5d1265ae6fc55435aeb7b76fcb001" -- cgit v1.2.3