mirror of
https://github.com/BoostIo/Boostnote
synced 2025-12-13 09:46:22 +00:00
address requested changes - tag link & redundant line
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
;(function(mod) {
|
||||
;(function (mod) {
|
||||
if (typeof exports === 'object' && typeof module === 'object') {
|
||||
// Common JS
|
||||
mod(require('../codemirror/lib/codemirror'))
|
||||
@@ -9,13 +9,13 @@
|
||||
// Plain browser env
|
||||
mod(CodeMirror)
|
||||
}
|
||||
})(function(CodeMirror) {
|
||||
})(function (CodeMirror) {
|
||||
'use strict'
|
||||
|
||||
const shell = require('electron').shell
|
||||
const remote = require('electron').remote
|
||||
const eventEmitter = {
|
||||
emit: function() {
|
||||
emit: function () {
|
||||
remote.getCurrentWindow().webContents.send.apply(null, arguments)
|
||||
}
|
||||
}
|
||||
@@ -25,7 +25,7 @@
|
||||
const modifier = macOS ? 'metaKey' : 'ctrlKey'
|
||||
|
||||
class HyperLink {
|
||||
constructor(cm) {
|
||||
constructor (cm) {
|
||||
this.cm = cm
|
||||
this.lineDiv = cm.display.lineDiv
|
||||
|
||||
@@ -61,7 +61,7 @@
|
||||
passive: true
|
||||
})
|
||||
}
|
||||
getUrl(el) {
|
||||
getUrl (el) {
|
||||
const className = el.className.split(' ')
|
||||
|
||||
if (className.indexOf('cm-url') !== -1) {
|
||||
@@ -74,7 +74,7 @@
|
||||
|
||||
return null
|
||||
}
|
||||
specialLinkHandler(e, rawHref, linkHash) {
|
||||
specialLinkHandler (e, rawHref, linkHash) {
|
||||
const isStartWithHash = rawHref[0] === '#'
|
||||
|
||||
const extractIdRegex = /file:\/\/.*main.?\w*.html#/ // file://path/to/main(.development.)html
|
||||
@@ -121,14 +121,14 @@
|
||||
return
|
||||
}
|
||||
|
||||
const regexIsTagLink = /^:tag:#([\w]+)$/
|
||||
const regexIsTagLink = /^:tag:([\w]+)$/
|
||||
if (regexIsTagLink.test(rawHref)) {
|
||||
const tag = rawHref.match(regexIsTagLink)[1]
|
||||
eventEmitter.emit('dispatch:push', `/tags/${encodeURIComponent(tag)}`)
|
||||
return
|
||||
}
|
||||
}
|
||||
onMouseDown(e) {
|
||||
onMouseDown (e) {
|
||||
const { target } = e
|
||||
if (!e[modifier]) {
|
||||
return
|
||||
@@ -142,8 +142,6 @@
|
||||
parser.href = rawHref
|
||||
const { href, hash } = parser
|
||||
|
||||
if (!rawHref) return // not checked href because parser will create file://... string for [empty link]()
|
||||
|
||||
const linkHash = hash === '' ? rawHref : hash // needed because we're having special link formats that are removed by parser e.g. :line:10
|
||||
|
||||
this.specialLinkHandler(target, rawHref, linkHash)
|
||||
@@ -157,7 +155,7 @@
|
||||
shell.openExternal(url)
|
||||
}
|
||||
}
|
||||
onMouseEnter(e) {
|
||||
onMouseEnter (e) {
|
||||
const { target } = e
|
||||
|
||||
const url = this.getUrl(target)
|
||||
@@ -174,7 +172,7 @@
|
||||
this.showInfo(target)
|
||||
}
|
||||
}
|
||||
onMouseLeave(e) {
|
||||
onMouseLeave (e) {
|
||||
if (this.tooltip.parentElement === this.lineDiv) {
|
||||
e.target.classList.remove(
|
||||
'CodeMirror-activeline-background',
|
||||
@@ -184,7 +182,7 @@
|
||||
this.lineDiv.removeChild(this.tooltip)
|
||||
}
|
||||
}
|
||||
onMouseMove(e) {
|
||||
onMouseMove (e) {
|
||||
if (this.tooltip.parentElement === this.lineDiv) {
|
||||
if (e[modifier]) {
|
||||
e.target.classList.add('CodeMirror-hyperlink')
|
||||
@@ -193,7 +191,7 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
showInfo(relatedTo) {
|
||||
showInfo (relatedTo) {
|
||||
const b1 = relatedTo.getBoundingClientRect()
|
||||
const b2 = this.lineDiv.getBoundingClientRect()
|
||||
const tdiv = this.tooltip
|
||||
|
||||
Reference in New Issue
Block a user