|
1 |
| -;(function (mod) { |
| 1 | +;(function(mod) { |
2 | 2 | if (typeof exports === 'object' && typeof module === 'object') {
|
3 | 3 | // Common JS
|
4 | 4 | mod(require('../codemirror/lib/codemirror'))
|
|
9 | 9 | // Plain browser env
|
10 | 10 | mod(CodeMirror)
|
11 | 11 | }
|
12 |
| -})(function (CodeMirror) { |
| 12 | +})(function(CodeMirror) { |
13 | 13 | 'use strict'
|
14 | 14 |
|
15 | 15 | const shell = require('electron').shell
|
16 | 16 | const remote = require('electron').remote
|
17 | 17 | const eventEmitter = {
|
18 |
| - emit: function () { |
| 18 | + emit: function() { |
19 | 19 | remote.getCurrentWindow().webContents.send.apply(null, arguments)
|
20 | 20 | }
|
21 | 21 | }
|
|
25 | 25 | const modifier = macOS ? 'metaKey' : 'ctrlKey'
|
26 | 26 |
|
27 | 27 | class HyperLink {
|
28 |
| - constructor (cm) { |
| 28 | + constructor(cm) { |
29 | 29 | this.cm = cm
|
30 | 30 | this.lineDiv = cm.display.lineDiv
|
31 | 31 |
|
|
61 | 61 | passive: true
|
62 | 62 | })
|
63 | 63 | }
|
64 |
| - getUrl (el) { |
| 64 | + getUrl(el) { |
65 | 65 | const className = el.className.split(' ')
|
66 | 66 |
|
67 | 67 | if (className.indexOf('cm-url') !== -1) {
|
|
74 | 74 |
|
75 | 75 | return null
|
76 | 76 | }
|
77 |
| - specialLinkHandler (e, rawHref, linkHash) { |
| 77 | + specialLinkHandler(e, rawHref, linkHash) { |
78 | 78 | const isStartWithHash = rawHref[0] === '#'
|
79 | 79 |
|
80 | 80 | const extractIdRegex = /file:\/\/.*main.?\w*.html#/ // file://path/to/main(.development.)html
|
|
128 | 128 | return
|
129 | 129 | }
|
130 | 130 | }
|
131 |
| - onMouseDown (e) { |
| 131 | + onMouseDown(e) { |
132 | 132 | const { target } = e
|
133 | 133 | if (!e[modifier]) {
|
134 | 134 | return
|
|
155 | 155 | shell.openExternal(url)
|
156 | 156 | }
|
157 | 157 | }
|
158 |
| - onMouseEnter (e) { |
| 158 | + onMouseEnter(e) { |
159 | 159 | const { target } = e
|
160 | 160 |
|
161 | 161 | const url = this.getUrl(target)
|
|
172 | 172 | this.showInfo(target)
|
173 | 173 | }
|
174 | 174 | }
|
175 |
| - onMouseLeave (e) { |
| 175 | + onMouseLeave(e) { |
176 | 176 | if (this.tooltip.parentElement === this.lineDiv) {
|
177 | 177 | e.target.classList.remove(
|
178 | 178 | 'CodeMirror-activeline-background',
|
|
182 | 182 | this.lineDiv.removeChild(this.tooltip)
|
183 | 183 | }
|
184 | 184 | }
|
185 |
| - onMouseMove (e) { |
| 185 | + onMouseMove(e) { |
186 | 186 | if (this.tooltip.parentElement === this.lineDiv) {
|
187 | 187 | if (e[modifier]) {
|
188 | 188 | e.target.classList.add('CodeMirror-hyperlink')
|
|
191 | 191 | }
|
192 | 192 | }
|
193 | 193 | }
|
194 |
| - showInfo (relatedTo) { |
| 194 | + showInfo(relatedTo) { |
195 | 195 | const b1 = relatedTo.getBoundingClientRect()
|
196 | 196 | const b2 = this.lineDiv.getBoundingClientRect()
|
197 | 197 | const tdiv = this.tooltip
|
|
0 commit comments