1
0
mirror of https://github.com/BoostIo/Boostnote synced 2025-12-15 02:36:36 +00:00

WIP: Change space before parens. Tag link handling issue present.

This commit is contained in:
AWolf81
2020-03-08 21:58:27 +01:00
committed by Junyoung Choi
parent 4d5939aaf4
commit 1cf6f3b1e2

View File

@@ -1,4 +1,4 @@
;(function (mod) { ;(function(mod) {
if (typeof exports === 'object' && typeof module === 'object') { if (typeof exports === 'object' && typeof module === 'object') {
// Common JS // Common JS
mod(require('../codemirror/lib/codemirror')) mod(require('../codemirror/lib/codemirror'))
@@ -9,13 +9,13 @@
// Plain browser env // Plain browser env
mod(CodeMirror) mod(CodeMirror)
} }
})(function (CodeMirror) { })(function(CodeMirror) {
'use strict' 'use strict'
const shell = require('electron').shell const shell = require('electron').shell
const remote = require('electron').remote const remote = require('electron').remote
const eventEmitter = { const eventEmitter = {
emit: function () { emit: function() {
remote.getCurrentWindow().webContents.send.apply(null, arguments) remote.getCurrentWindow().webContents.send.apply(null, arguments)
} }
} }
@@ -25,7 +25,7 @@
const modifier = macOS ? 'metaKey' : 'ctrlKey' const modifier = macOS ? 'metaKey' : 'ctrlKey'
class HyperLink { class HyperLink {
constructor (cm) { constructor(cm) {
this.cm = cm this.cm = cm
this.lineDiv = cm.display.lineDiv this.lineDiv = cm.display.lineDiv
@@ -61,7 +61,7 @@
passive: true passive: true
}) })
} }
getUrl (el) { getUrl(el) {
const className = el.className.split(' ') const className = el.className.split(' ')
if (className.indexOf('cm-url') !== -1) { if (className.indexOf('cm-url') !== -1) {
@@ -74,7 +74,7 @@
return null return null
} }
specialLinkHandler (e, rawHref, linkHash) { specialLinkHandler(e, rawHref, linkHash) {
const isStartWithHash = rawHref[0] === '#' const isStartWithHash = rawHref[0] === '#'
const extractIdRegex = /file:\/\/.*main.?\w*.html#/ // file://path/to/main(.development.)html const extractIdRegex = /file:\/\/.*main.?\w*.html#/ // file://path/to/main(.development.)html
@@ -128,7 +128,7 @@
return return
} }
} }
onMouseDown (e) { onMouseDown(e) {
const { target } = e const { target } = e
if (!e[modifier]) { if (!e[modifier]) {
return return
@@ -155,7 +155,7 @@
shell.openExternal(url) shell.openExternal(url)
} }
} }
onMouseEnter (e) { onMouseEnter(e) {
const { target } = e const { target } = e
const url = this.getUrl(target) const url = this.getUrl(target)
@@ -172,7 +172,7 @@
this.showInfo(target) this.showInfo(target)
} }
} }
onMouseLeave (e) { onMouseLeave(e) {
if (this.tooltip.parentElement === this.lineDiv) { if (this.tooltip.parentElement === this.lineDiv) {
e.target.classList.remove( e.target.classList.remove(
'CodeMirror-activeline-background', 'CodeMirror-activeline-background',
@@ -182,7 +182,7 @@
this.lineDiv.removeChild(this.tooltip) this.lineDiv.removeChild(this.tooltip)
} }
} }
onMouseMove (e) { onMouseMove(e) {
if (this.tooltip.parentElement === this.lineDiv) { if (this.tooltip.parentElement === this.lineDiv) {
if (e[modifier]) { if (e[modifier]) {
e.target.classList.add('CodeMirror-hyperlink') e.target.classList.add('CodeMirror-hyperlink')
@@ -191,7 +191,7 @@
} }
} }
} }
showInfo (relatedTo) { showInfo(relatedTo) {
const b1 = relatedTo.getBoundingClientRect() const b1 = relatedTo.getBoundingClientRect()
const b2 = this.lineDiv.getBoundingClientRect() const b2 = this.lineDiv.getBoundingClientRect()
const tdiv = this.tooltip const tdiv = this.tooltip