Skip to content

Commit db06a51

Browse files
committed
Load statusbar template by string-loader
1 parent 5343a61 commit db06a51

5 files changed

Lines changed: 29 additions & 35 deletions

File tree

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,8 +162,9 @@
162162
"less-loader": "^2.2.3",
163163
"optimize-css-assets-webpack-plugin": "^1.3.0",
164164
"script-loader": "^0.7.0",
165-
"style-loader": "^0.13.1",
166165
"standard": "^9.0.1",
166+
"string-loader": "^0.0.1",
167+
"style-loader": "^0.13.1",
167168
"url-loader": "^0.5.7",
168169
"webpack": "^1.14.0",
169170
"webpack-parallel-uglify-plugin": "^0.2.0"

public/js/lib/editor/index.js

Lines changed: 20 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import * as utils from './utils'
22
import config from './config'
3+
import statusBarTemplate from './statusbar.html'
34

45
/* config section */
56
const isMac = CodeMirror.keyMap.default === CodeMirror.keyMap.macDefault
@@ -132,40 +133,27 @@ export default class Editor {
132133
})
133134
}
134135

135-
getStatusBarTemplate () {
136-
return new Promise((resolve, reject) => {
137-
$.get(window.serverurl + '/views/statusbar.html').done(template => {
138-
this.statusBarTemplate = template
139-
resolve()
140-
}).fail(reject)
141-
})
142-
}
143-
144136
addStatusBar () {
145-
if (!this.statusBarTemplate) {
146-
this.getStatusBarTemplate.then(this.addStatusBar)
147-
} else {
148-
this.statusBar = $(this.statusBarTemplate)
149-
this.statusCursor = this.statusBar.find('.status-cursor > .status-line-column')
150-
this.statusSelection = this.statusBar.find('.status-cursor > .status-selection')
151-
this.statusFile = this.statusBar.find('.status-file')
152-
this.statusIndicators = this.statusBar.find('.status-indicators')
153-
this.statusIndent = this.statusBar.find('.status-indent')
154-
this.statusKeymap = this.statusBar.find('.status-keymap')
155-
this.statusLength = this.statusBar.find('.status-length')
156-
this.statusTheme = this.statusBar.find('.status-theme')
157-
this.statusSpellcheck = this.statusBar.find('.status-spellcheck')
158-
this.statusPreferences = this.statusBar.find('.status-preferences')
159-
this.statusPanel = this.editor.addPanel(this.statusBar[0], {
160-
position: 'bottom'
161-
})
137+
this.statusBar = $(statusBarTemplate)
138+
this.statusCursor = this.statusBar.find('.status-cursor > .status-line-column')
139+
this.statusSelection = this.statusBar.find('.status-cursor > .status-selection')
140+
this.statusFile = this.statusBar.find('.status-file')
141+
this.statusIndicators = this.statusBar.find('.status-indicators')
142+
this.statusIndent = this.statusBar.find('.status-indent')
143+
this.statusKeymap = this.statusBar.find('.status-keymap')
144+
this.statusLength = this.statusBar.find('.status-length')
145+
this.statusTheme = this.statusBar.find('.status-theme')
146+
this.statusSpellcheck = this.statusBar.find('.status-spellcheck')
147+
this.statusPreferences = this.statusBar.find('.status-preferences')
148+
this.statusPanel = this.editor.addPanel(this.statusBar[0], {
149+
position: 'bottom'
150+
})
162151

163-
this.setIndent()
164-
this.setKeymap()
165-
this.setTheme()
166-
this.setSpellcheck()
167-
this.setPreferences()
168-
}
152+
this.setIndent()
153+
this.setKeymap()
154+
this.setTheme()
155+
this.setSpellcheck()
156+
this.setPreferences()
169157
}
170158

171159
updateStatusBar () {
@@ -508,8 +496,6 @@ export default class Editor {
508496
placeholder: "← Start by entering a title here\n===\nVisit /features if you don't know what to do.\nHappy hacking :)"
509497
})
510498

511-
this.getStatusBarTemplate()
512-
513499
return this.editor
514500
}
515501

webpackBaseConfig.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -412,6 +412,9 @@ module.exports = {
412412
}, {
413413
test: /\.eot(\?v=\d+\.\d+\.\d+)?$/,
414414
loader: 'file'
415+
}, {
416+
test: /\.html$/,
417+
loader: 'string'
415418
}, {
416419
test: /\.(woff|woff2)(\?v=\d+\.\d+\.\d+)?$/,
417420
loader: 'url?prefix=font/&limit=5000'

yarn.lock

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6529,6 +6529,10 @@ strict-uri-encode@^1.0.0:
65296529
version "1.1.0"
65306530
resolved "https://registry.yarnpkg.com/strict-uri-encode/-/strict-uri-encode-1.1.0.tgz#279b225df1d582b1f54e65addd4352e18faa0713"
65316531

6532+
string-loader@^0.0.1:
6533+
version "0.0.1"
6534+
resolved "https://registry.yarnpkg.com/string-loader/-/string-loader-0.0.1.tgz#496f3cccc990213e0dd5411499f9ac6a6a6f2ff8"
6535+
65326536
string-natural-compare@^2.0.2:
65336537
version "2.0.2"
65346538
resolved "https://registry.yarnpkg.com/string-natural-compare/-/string-natural-compare-2.0.2.tgz#c5ce4e278ab5d1265ae6fc55435aeb7b76fcb001"

0 commit comments

Comments
 (0)