mirror of
https://github.com/BoostIo/Boostnote
synced 2025-12-14 10:16:26 +00:00
Compare commits
11 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5f56d3e0de | ||
|
|
d6b86b902c | ||
|
|
3abc0fec38 | ||
|
|
c0619eb746 | ||
|
|
791ababe1e | ||
|
|
d829216c8d | ||
|
|
1cf6f3b1e2 | ||
|
|
4d5939aaf4 | ||
|
|
2695f62f3e | ||
|
|
ccd0355d0b | ||
|
|
6d6e3a51c0 |
@@ -1126,8 +1126,6 @@ class MarkdownPreview extends React.Component {
|
||||
const isStartWithHash = rawHref[0] === '#'
|
||||
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
|
||||
|
||||
const extractIdRegex = /file:\/\/.*main.?\w*.html#/ // file://path/to/main(.development.)html
|
||||
|
||||
@@ -215,6 +215,7 @@ class MarkdownSplitEditor extends React.Component {
|
||||
<div styleName='slider-hitbox' />
|
||||
</div>
|
||||
<MarkdownPreview
|
||||
ref='preview'
|
||||
style={previewStyle}
|
||||
theme={config.ui.theme}
|
||||
keyMap={config.editor.keyMap}
|
||||
|
||||
@@ -181,6 +181,7 @@ class Main extends React.Component {
|
||||
'menubar:togglemenubar',
|
||||
this.toggleMenuBarVisible.bind(this)
|
||||
)
|
||||
eventEmitter.on('dispatch:push', this.changeRoutePush.bind(this))
|
||||
}
|
||||
|
||||
componentWillUnmount() {
|
||||
@@ -189,6 +190,12 @@ class Main extends React.Component {
|
||||
'menubar:togglemenubar',
|
||||
this.toggleMenuBarVisible.bind(this)
|
||||
)
|
||||
eventEmitter.off('dispatch:push', this.changeRoutePush.bind(this))
|
||||
}
|
||||
|
||||
changeRoutePush(event, destination) {
|
||||
const { dispatch } = this.props
|
||||
dispatch(push(destination))
|
||||
}
|
||||
|
||||
toggleMenuBarVisible() {
|
||||
|
||||
@@ -1,22 +1,31 @@
|
||||
(function (mod) {
|
||||
if (typeof exports === 'object' && typeof module === 'object') { // Common JS
|
||||
;(function(mod) {
|
||||
if (typeof exports === 'object' && typeof module === 'object') {
|
||||
// Common JS
|
||||
mod(require('../codemirror/lib/codemirror'))
|
||||
} else if (typeof define === 'function' && define.amd) { // AMD
|
||||
} else if (typeof define === 'function' && define.amd) {
|
||||
// AMD
|
||||
define(['../codemirror/lib/codemirror'], mod)
|
||||
} else { // Plain browser env
|
||||
} else {
|
||||
// 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() {
|
||||
remote.getCurrentWindow().webContents.send.apply(null, arguments)
|
||||
}
|
||||
}
|
||||
const yOffset = 2
|
||||
|
||||
const macOS = global.process.platform === 'darwin'
|
||||
const modifier = macOS ? 'metaKey' : 'ctrlKey'
|
||||
|
||||
class HyperLink {
|
||||
constructor (cm) {
|
||||
constructor(cm) {
|
||||
this.cm = cm
|
||||
this.lineDiv = cm.display.lineDiv
|
||||
|
||||
@@ -28,11 +37,16 @@
|
||||
this.tooltip = document.createElement('div')
|
||||
this.tooltipContent = document.createElement('div')
|
||||
this.tooltipIndicator = document.createElement('div')
|
||||
this.tooltip.setAttribute('class', 'CodeMirror-hover CodeMirror-matchingbracket CodeMirror-selected')
|
||||
this.tooltip.setAttribute(
|
||||
'class',
|
||||
'CodeMirror-hover CodeMirror-matchingbracket CodeMirror-selected'
|
||||
)
|
||||
this.tooltip.setAttribute('cm-ignore-events', 'true')
|
||||
this.tooltip.appendChild(this.tooltipContent)
|
||||
this.tooltip.appendChild(this.tooltipIndicator)
|
||||
this.tooltipContent.textContent = `${macOS ? 'Cmd(⌘)' : 'Ctrl(^)'} + click to follow link`
|
||||
this.tooltipContent.textContent = `${
|
||||
macOS ? 'Cmd(⌘)' : 'Ctrl(^)'
|
||||
} + click to follow link`
|
||||
|
||||
this.lineDiv.addEventListener('mousedown', this.onMouseDown)
|
||||
this.lineDiv.addEventListener('mouseenter', this.onMouseEnter, {
|
||||
@@ -47,11 +61,20 @@
|
||||
passive: true
|
||||
})
|
||||
}
|
||||
getUrl (el) {
|
||||
getUrl(el) {
|
||||
const className = el.className.split(' ')
|
||||
|
||||
if (className.indexOf('cm-url') !== -1) {
|
||||
const match = /^\((.*)\)|\[(.*)\]|(.*)$/.exec(el.textContent)
|
||||
// multiple cm-url because of search term
|
||||
const cmUrlSpans = Array.from(
|
||||
el.parentNode.getElementsByClassName('cm-url')
|
||||
)
|
||||
const textContent =
|
||||
cmUrlSpans.length > 1
|
||||
? cmUrlSpans.map(span => span.textContent).join('')
|
||||
: el.textContent
|
||||
|
||||
const match = /^\((.*)\)|\[(.*)\]|(.*)$/.exec(textContent)
|
||||
const url = match[1] || match[2] || match[3]
|
||||
|
||||
// `:storage` is the value of the variable `STORAGE_FOLDER_PLACEHOLDER` defined in `browser/main/lib/dataApi/attachmentManagement`
|
||||
@@ -60,26 +83,106 @@
|
||||
|
||||
return null
|
||||
}
|
||||
onMouseDown (e) {
|
||||
specialLinkHandler(e, rawHref, linkHash) {
|
||||
const isStartWithHash = rawHref[0] === '#'
|
||||
|
||||
const extractIdRegex = /file:\/\/.*main.?\w*.html#/ // file://path/to/main(.development.)html
|
||||
const regexNoteInternalLink = new RegExp(`${extractIdRegex.source}(.+)`)
|
||||
if (isStartWithHash || regexNoteInternalLink.test(rawHref)) {
|
||||
const posOfHash = linkHash.indexOf('#')
|
||||
if (posOfHash > -1) {
|
||||
const extractedId = linkHash.slice(posOfHash + 1)
|
||||
const targetId = mdurl.encode(extractedId)
|
||||
const targetElement = document.getElementById(targetId) // this.getWindow().document.getElementById(targetId)
|
||||
|
||||
if (targetElement != null) {
|
||||
this.scrollTo(0, targetElement.offsetTop)
|
||||
}
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
// this will match the new uuid v4 hash and the old hash
|
||||
// e.g.
|
||||
// :note:1c211eb7dcb463de6490 and
|
||||
// :note:7dd23275-f2b4-49cb-9e93-3454daf1af9c
|
||||
const regexIsNoteLink = /^:note:([a-zA-Z0-9-]{20,36})$/
|
||||
if (regexIsNoteLink.test(linkHash)) {
|
||||
eventEmitter.emit('list:jump', linkHash.replace(':note:', ''))
|
||||
return
|
||||
}
|
||||
|
||||
const regexIsLine = /^:line:[0-9]/
|
||||
if (regexIsLine.test(linkHash)) {
|
||||
const numberPattern = /\d+/g
|
||||
|
||||
const lineNumber = parseInt(linkHash.match(numberPattern)[0])
|
||||
eventEmitter.emit('line:jump', lineNumber)
|
||||
return
|
||||
}
|
||||
|
||||
// this will match the old link format storage.key-note.key
|
||||
// e.g.
|
||||
// 877f99c3268608328037-1c211eb7dcb463de6490
|
||||
const regexIsLegacyNoteLink = /^(.{20})-(.{20})$/
|
||||
if (regexIsLegacyNoteLink.test(linkHash)) {
|
||||
eventEmitter.emit('list:jump', linkHash.split('-')[1])
|
||||
return
|
||||
}
|
||||
|
||||
const regexIsTagLink = /^:tag:([\w]+)$/
|
||||
if (regexIsTagLink.test(rawHref)) {
|
||||
const tag = rawHref.match(regexIsTagLink)[1]
|
||||
eventEmitter.emit('dispatch:push', `/tags/${encodeURIComponent(tag)}`)
|
||||
return
|
||||
}
|
||||
}
|
||||
onMouseDown(e) {
|
||||
const { target } = e
|
||||
if (!e[modifier]) {
|
||||
return
|
||||
}
|
||||
|
||||
// Create URL spans array used for special case "search term is hitting a link".
|
||||
const cmUrlSpans = Array.from(
|
||||
e.target.parentNode.getElementsByClassName('cm-url')
|
||||
)
|
||||
|
||||
const innerText =
|
||||
cmUrlSpans.length > 1
|
||||
? cmUrlSpans.map(span => span.textContent).join('')
|
||||
: e.target.innerText
|
||||
const rawHref = innerText.trim().slice(1, -1) // get link text from markdown text
|
||||
|
||||
if (!rawHref) return // not checked href because parser will create file://... string for [empty link]()
|
||||
|
||||
const parser = document.createElement('a')
|
||||
parser.href = rawHref
|
||||
const { href, hash } = parser
|
||||
|
||||
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)
|
||||
|
||||
const url = this.getUrl(target)
|
||||
|
||||
// all special cases handled --> other case
|
||||
if (url) {
|
||||
e.preventDefault()
|
||||
|
||||
shell.openExternal(url)
|
||||
}
|
||||
}
|
||||
onMouseEnter (e) {
|
||||
onMouseEnter(e) {
|
||||
const { target } = e
|
||||
|
||||
const url = this.getUrl(target)
|
||||
if (url) {
|
||||
if (e[modifier]) {
|
||||
target.classList.add('CodeMirror-activeline-background', 'CodeMirror-hyperlink')
|
||||
target.classList.add(
|
||||
'CodeMirror-activeline-background',
|
||||
'CodeMirror-hyperlink'
|
||||
)
|
||||
} else {
|
||||
target.classList.add('CodeMirror-activeline-background')
|
||||
}
|
||||
@@ -87,14 +190,17 @@
|
||||
this.showInfo(target)
|
||||
}
|
||||
}
|
||||
onMouseLeave (e) {
|
||||
onMouseLeave(e) {
|
||||
if (this.tooltip.parentElement === this.lineDiv) {
|
||||
e.target.classList.remove('CodeMirror-activeline-background', 'CodeMirror-hyperlink')
|
||||
e.target.classList.remove(
|
||||
'CodeMirror-activeline-background',
|
||||
'CodeMirror-hyperlink'
|
||||
)
|
||||
|
||||
this.lineDiv.removeChild(this.tooltip)
|
||||
}
|
||||
}
|
||||
onMouseMove (e) {
|
||||
onMouseMove(e) {
|
||||
if (this.tooltip.parentElement === this.lineDiv) {
|
||||
if (e[modifier]) {
|
||||
e.target.classList.add('CodeMirror-hyperlink')
|
||||
@@ -103,25 +209,25 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
showInfo (relatedTo) {
|
||||
showInfo(relatedTo) {
|
||||
const b1 = relatedTo.getBoundingClientRect()
|
||||
const b2 = this.lineDiv.getBoundingClientRect()
|
||||
const tdiv = this.tooltip
|
||||
|
||||
tdiv.style.left = (b1.left - b2.left) + 'px'
|
||||
tdiv.style.left = b1.left - b2.left + 'px'
|
||||
this.lineDiv.appendChild(tdiv)
|
||||
|
||||
const b3 = tdiv.getBoundingClientRect()
|
||||
const top = b1.top - b2.top - b3.height - yOffset
|
||||
if (top < 0) {
|
||||
tdiv.style.top = (b1.top - b2.top + b1.height + yOffset) + 'px'
|
||||
tdiv.style.top = b1.top - b2.top + b1.height + yOffset + 'px'
|
||||
} else {
|
||||
tdiv.style.top = top + 'px'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
CodeMirror.defineOption('hyperlink', true, (cm) => {
|
||||
CodeMirror.defineOption('hyperlink', true, cm => {
|
||||
const addon = new HyperLink(cm)
|
||||
})
|
||||
})
|
||||
|
||||
353
extra_scripts/codemirror/mode/bfm/bfm.js
vendored
353
extra_scripts/codemirror/mode/bfm/bfm.js
vendored
@@ -1,10 +1,20 @@
|
||||
(function(mod) {
|
||||
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
||||
mod(require("../codemirror/lib/codemirror"), require("../codemirror/mode/gfm/gfm"), require("../codemirror/mode/yaml-frontmatter/yaml-frontmatter"))
|
||||
else if (typeof define == "function" && define.amd) // AMD
|
||||
define(["../codemirror/lib/codemirror", "../codemirror/mode/gfm/gfm", "../codemirror/mode/yaml-frontmatter/yaml-frontmatter"], mod)
|
||||
else // Plain browser env
|
||||
mod(CodeMirror)
|
||||
;(function(mod) {
|
||||
if (typeof exports == 'object' && typeof module == 'object')
|
||||
// CommonJS
|
||||
mod(
|
||||
require('../codemirror/lib/codemirror'),
|
||||
require('../codemirror/mode/gfm/gfm'),
|
||||
require('../codemirror/mode/yaml-frontmatter/yaml-frontmatter')
|
||||
)
|
||||
else if (typeof define == 'function' && define.amd)
|
||||
// AMD
|
||||
define([
|
||||
'../codemirror/lib/codemirror',
|
||||
'../codemirror/mode/gfm/gfm',
|
||||
'../codemirror/mode/yaml-frontmatter/yaml-frontmatter'
|
||||
], mod)
|
||||
// Plain browser env
|
||||
else mod(CodeMirror)
|
||||
})(function(CodeMirror) {
|
||||
'use strict'
|
||||
|
||||
@@ -45,189 +55,208 @@
|
||||
}
|
||||
}
|
||||
|
||||
CodeMirror.defineMode('bfm', function (config, baseConfig) {
|
||||
baseConfig.name = 'yaml-frontmatter'
|
||||
const baseMode = CodeMirror.getMode(config, baseConfig)
|
||||
CodeMirror.defineMode(
|
||||
'bfm',
|
||||
function(config, baseConfig) {
|
||||
baseConfig.name = 'yaml-frontmatter'
|
||||
const baseMode = CodeMirror.getMode(config, baseConfig)
|
||||
|
||||
return {
|
||||
startState: function() {
|
||||
return {
|
||||
baseState: CodeMirror.startState(baseMode),
|
||||
return {
|
||||
startState: function() {
|
||||
return {
|
||||
baseState: CodeMirror.startState(baseMode),
|
||||
|
||||
basePos: 0,
|
||||
baseCur: null,
|
||||
overlayPos: 0,
|
||||
overlayCur: null,
|
||||
streamSeen: null,
|
||||
basePos: 0,
|
||||
baseCur: null,
|
||||
overlayPos: 0,
|
||||
overlayCur: null,
|
||||
streamSeen: null,
|
||||
|
||||
fencedEndRE: null,
|
||||
fencedEndRE: null,
|
||||
|
||||
inTable: false,
|
||||
rowIndex: 0
|
||||
}
|
||||
},
|
||||
copyState: function(s) {
|
||||
return {
|
||||
baseState: CodeMirror.copyState(baseMode, s.baseState),
|
||||
inTable: false,
|
||||
rowIndex: 0
|
||||
}
|
||||
},
|
||||
copyState: function(s) {
|
||||
return {
|
||||
baseState: CodeMirror.copyState(baseMode, s.baseState),
|
||||
|
||||
basePos: s.basePos,
|
||||
baseCur: null,
|
||||
overlayPos: s.overlayPos,
|
||||
overlayCur: null,
|
||||
basePos: s.basePos,
|
||||
baseCur: null,
|
||||
overlayPos: s.overlayPos,
|
||||
overlayCur: null,
|
||||
|
||||
fencedMode: s.fencedMode,
|
||||
fencedState: s.fencedMode ? CodeMirror.copyState(s.fencedMode, s.fencedState) : null,
|
||||
fencedMode: s.fencedMode,
|
||||
fencedState: s.fencedMode
|
||||
? CodeMirror.copyState(s.fencedMode, s.fencedState)
|
||||
: null,
|
||||
|
||||
fencedEndRE: s.fencedEndRE,
|
||||
fencedEndRE: s.fencedEndRE,
|
||||
|
||||
inTable: s.inTable,
|
||||
rowIndex: s.rowIndex
|
||||
}
|
||||
},
|
||||
token: function(stream, state) {
|
||||
const initialPos = stream.pos
|
||||
inTable: s.inTable,
|
||||
rowIndex: s.rowIndex
|
||||
}
|
||||
},
|
||||
token: function(stream, state) {
|
||||
const initialPos = stream.pos
|
||||
|
||||
if (state.fencedEndRE && stream.match(state.fencedEndRE)) {
|
||||
state.fencedEndRE = null
|
||||
state.fencedMode = null
|
||||
state.fencedState = null
|
||||
if (state.fencedEndRE && stream.match(state.fencedEndRE)) {
|
||||
state.fencedEndRE = null
|
||||
state.fencedMode = null
|
||||
state.fencedState = null
|
||||
|
||||
stream.pos = initialPos
|
||||
}
|
||||
else {
|
||||
if (state.fencedMode) {
|
||||
return state.fencedMode.token(stream, state.fencedState)
|
||||
stream.pos = initialPos
|
||||
} else {
|
||||
if (state.fencedMode) {
|
||||
return state.fencedMode.token(stream, state.fencedState)
|
||||
}
|
||||
|
||||
const match = stream.match(fencedCodeRE, true)
|
||||
if (match) {
|
||||
state.fencedEndRE = new RegExp(match[1] + '+ *$')
|
||||
|
||||
state.fencedMode = getMode(
|
||||
match[2],
|
||||
match[3],
|
||||
config,
|
||||
stream.lineOracle.doc.cm
|
||||
)
|
||||
if (state.fencedMode) {
|
||||
state.fencedState = CodeMirror.startState(state.fencedMode)
|
||||
}
|
||||
|
||||
stream.pos = initialPos
|
||||
}
|
||||
}
|
||||
|
||||
if (
|
||||
stream != state.streamSeen ||
|
||||
Math.min(state.basePos, state.overlayPos) < stream.start
|
||||
) {
|
||||
state.streamSeen = stream
|
||||
state.basePos = state.overlayPos = stream.start
|
||||
}
|
||||
|
||||
if (stream.start == state.basePos) {
|
||||
state.baseCur = baseMode.token(stream, state.baseState)
|
||||
state.basePos = stream.pos
|
||||
}
|
||||
if (stream.start == state.overlayPos) {
|
||||
stream.pos = stream.start
|
||||
state.overlayCur = this.overlayToken(stream, state)
|
||||
state.overlayPos = stream.pos
|
||||
}
|
||||
stream.pos = Math.min(state.basePos, state.overlayPos)
|
||||
|
||||
if (state.overlayCur == null) {
|
||||
return state.baseCur
|
||||
} else if (state.baseCur != null && state.combineTokens) {
|
||||
return state.baseCur + ' ' + state.overlayCur
|
||||
} else {
|
||||
return state.overlayCur
|
||||
}
|
||||
},
|
||||
overlayToken: function(stream, state) {
|
||||
state.combineTokens = false
|
||||
|
||||
if (state.fencedEndRE && stream.match(state.fencedEndRE)) {
|
||||
state.fencedEndRE = null
|
||||
state.localMode = null
|
||||
state.localState = null
|
||||
|
||||
return null
|
||||
}
|
||||
|
||||
if (state.localMode) {
|
||||
return state.localMode.token(stream, state.localState) || ''
|
||||
}
|
||||
|
||||
const match = stream.match(fencedCodeRE, true)
|
||||
if (match) {
|
||||
state.fencedEndRE = new RegExp(match[1] + '+ *$')
|
||||
|
||||
state.fencedMode = getMode(match[2], match[3], config, stream.lineOracle.doc.cm)
|
||||
if (state.fencedMode) {
|
||||
state.fencedState = CodeMirror.startState(state.fencedMode)
|
||||
state.localMode = getMode(
|
||||
match[2],
|
||||
match[3],
|
||||
config,
|
||||
stream.lineOracle.doc.cm
|
||||
)
|
||||
if (state.localMode) {
|
||||
state.localState = CodeMirror.startState(state.localMode)
|
||||
}
|
||||
|
||||
stream.pos = initialPos
|
||||
}
|
||||
}
|
||||
|
||||
if (stream != state.streamSeen || Math.min(state.basePos, state.overlayPos) < stream.start) {
|
||||
state.streamSeen = stream
|
||||
state.basePos = state.overlayPos = stream.start
|
||||
}
|
||||
|
||||
if (stream.start == state.basePos) {
|
||||
state.baseCur = baseMode.token(stream, state.baseState)
|
||||
state.basePos = stream.pos
|
||||
}
|
||||
if (stream.start == state.overlayPos) {
|
||||
stream.pos = stream.start
|
||||
state.overlayCur = this.overlayToken(stream, state)
|
||||
state.overlayPos = stream.pos
|
||||
}
|
||||
stream.pos = Math.min(state.basePos, state.overlayPos)
|
||||
|
||||
if (state.overlayCur == null) {
|
||||
return state.baseCur
|
||||
}
|
||||
else if (state.baseCur != null && state.combineTokens) {
|
||||
return state.baseCur + ' ' + state.overlayCur
|
||||
}
|
||||
else {
|
||||
return state.overlayCur
|
||||
}
|
||||
},
|
||||
overlayToken: function(stream, state) {
|
||||
state.combineTokens = false
|
||||
|
||||
if (state.fencedEndRE && stream.match(state.fencedEndRE)) {
|
||||
state.fencedEndRE = null
|
||||
state.localMode = null
|
||||
state.localState = null
|
||||
|
||||
return null
|
||||
}
|
||||
|
||||
if (state.localMode) {
|
||||
return state.localMode.token(stream, state.localState) || ''
|
||||
}
|
||||
|
||||
const match = stream.match(fencedCodeRE, true)
|
||||
if (match) {
|
||||
state.fencedEndRE = new RegExp(match[1] + '+ *$')
|
||||
|
||||
state.localMode = getMode(match[2], match[3], config, stream.lineOracle.doc.cm)
|
||||
if (state.localMode) {
|
||||
state.localState = CodeMirror.startState(state.localMode)
|
||||
}
|
||||
|
||||
return null
|
||||
}
|
||||
|
||||
state.combineTokens = true
|
||||
|
||||
if (state.inTable) {
|
||||
if (stream.match(/^\|/)) {
|
||||
++state.rowIndex
|
||||
|
||||
stream.skipToEnd()
|
||||
|
||||
if (state.rowIndex === 1) {
|
||||
return 'table table-separator'
|
||||
} else if (state.rowIndex % 2 === 0) {
|
||||
return 'table table-row table-row-even'
|
||||
} else {
|
||||
return 'table table-row table-row-odd'
|
||||
}
|
||||
} else {
|
||||
state.inTable = false
|
||||
|
||||
stream.skipToEnd()
|
||||
return null
|
||||
}
|
||||
} else if (stream.match(/^\|/)) {
|
||||
state.inTable = true
|
||||
state.rowIndex = 0
|
||||
|
||||
state.combineTokens = true
|
||||
|
||||
if (state.inTable) {
|
||||
if (stream.match(/^\|/)) {
|
||||
++state.rowIndex
|
||||
|
||||
stream.skipToEnd()
|
||||
|
||||
if (state.rowIndex === 1) {
|
||||
return 'table table-separator'
|
||||
} else if (state.rowIndex % 2 === 0) {
|
||||
return 'table table-row table-row-even'
|
||||
} else {
|
||||
return 'table table-row table-row-odd'
|
||||
}
|
||||
} else {
|
||||
state.inTable = false
|
||||
|
||||
stream.skipToEnd()
|
||||
return null
|
||||
}
|
||||
} else if (stream.match(/^\|/)) {
|
||||
state.inTable = true
|
||||
state.rowIndex = 0
|
||||
|
||||
stream.skipToEnd()
|
||||
return 'table table-header'
|
||||
}
|
||||
|
||||
stream.skipToEnd()
|
||||
return 'table table-header'
|
||||
}
|
||||
|
||||
stream.skipToEnd()
|
||||
return null
|
||||
},
|
||||
electricChars: baseMode.electricChars,
|
||||
innerMode: function(state) {
|
||||
if (state.fencedMode) {
|
||||
return {
|
||||
mode: state.fencedMode,
|
||||
state: state.fencedState
|
||||
return null
|
||||
},
|
||||
electricChars: baseMode.electricChars,
|
||||
innerMode: function(state) {
|
||||
if (state.fencedMode) {
|
||||
return {
|
||||
mode: state.fencedMode,
|
||||
state: state.fencedState
|
||||
}
|
||||
} else {
|
||||
return {
|
||||
mode: baseMode,
|
||||
state: state.baseState
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return {
|
||||
mode: baseMode,
|
||||
state: state.baseState
|
||||
}
|
||||
}
|
||||
},
|
||||
blankLine: function(state) {
|
||||
state.inTable = false
|
||||
},
|
||||
blankLine: function(state) {
|
||||
state.inTable = false
|
||||
|
||||
if (state.fencedMode) {
|
||||
return state.fencedMode.blankLine && state.fencedMode.blankLine(state.fencedState)
|
||||
} else {
|
||||
return baseMode.blankLine(state.baseState)
|
||||
if (state.fencedMode) {
|
||||
return (
|
||||
state.fencedMode.blankLine &&
|
||||
state.fencedMode.blankLine(state.fencedState)
|
||||
)
|
||||
} else {
|
||||
return baseMode.blankLine(state.baseState)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}, 'yaml-frontmatter')
|
||||
},
|
||||
'yaml-frontmatter'
|
||||
)
|
||||
|
||||
CodeMirror.defineMIME('text/x-bfm', 'bfm')
|
||||
|
||||
CodeMirror.modeInfo.push({
|
||||
name: "Boost Flavored Markdown",
|
||||
mime: "text/x-bfm",
|
||||
mode: "bfm"
|
||||
name: 'Boost Flavored Markdown',
|
||||
mime: 'text/x-bfm',
|
||||
mode: 'bfm'
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
157
extra_scripts/codemirror/mode/gfm/gfm.js
vendored
Normal file
157
extra_scripts/codemirror/mode/gfm/gfm.js
vendored
Normal file
@@ -0,0 +1,157 @@
|
||||
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
||||
// Distributed under an MIT license: https://codemirror.net/LICENSE
|
||||
|
||||
;(function(mod) {
|
||||
if (typeof exports == 'object' && typeof module == 'object')
|
||||
// CommonJS
|
||||
mod(
|
||||
require('../codemirror/lib/codemirror'),
|
||||
require('../codemirror/mode/markdown/markdown'),
|
||||
require('../codemirror/addon/mode/overlay')
|
||||
)
|
||||
else if (typeof define == 'function' && define.amd)
|
||||
// AMD
|
||||
define([
|
||||
'../codemirror/lib/codemirror',
|
||||
'../codemirror/mode/markdown/markdown',
|
||||
'../codemirror/addon/mode/overlay'
|
||||
], mod)
|
||||
// Plain browser env
|
||||
else mod(CodeMirror)
|
||||
})(function(CodeMirror) {
|
||||
'use strict'
|
||||
|
||||
var urlRE = /^((?:(?:aaas?|about|acap|adiumxtra|af[ps]|aim|apt|attachment|aw|beshare|bitcoin|bolo|callto|cap|chrome(?:-extension)?|cid|coap|com-eventbrite-attendee|content|crid|cvs|data|dav|dict|dlna-(?:playcontainer|playsingle)|dns|doi|dtn|dvb|ed2k|facetime|feed|file|finger|fish|ftp|geo|gg|git|gizmoproject|go|gopher|gtalk|h323|hcp|https?|iax|icap|icon|im|imap|info|ipn|ipp|irc[6s]?|iris(?:\.beep|\.lwz|\.xpc|\.xpcs)?|itms|jar|javascript|jms|keyparc|lastfm|ldaps?|magnet|mailto|maps|market|message|mid|mms|ms-help|msnim|msrps?|mtqp|mumble|mupdate|mvn|news|nfs|nih?|nntp|notes|oid|opaquelocktoken|palm|paparazzi|platform|pop|pres|proxy|psyc|query|res(?:ource)?|rmi|rsync|rtmp|rtsp|secondlife|service|session|sftp|sgn|shttp|sieve|sips?|skype|sm[bs]|snmp|soap\.beeps?|soldat|spotify|ssh|steam|svn|teamspeak|tel(?:net)?|tftp|things|thismessage|tip|tn3270|tv|udp|unreal|urn|ut2004|vemmi|ventrilo|view-source|webcal|wss?|wtai|wyciwyg|xcon(?:-userid)?|xfire|xmlrpc\.beeps?|xmpp|xri|ymsgr|z39\.50[rs]?):(?:\/{1,3}|[a-z0-9%])|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,4}\/)(?:[^\s()<>]|\([^\s()<>]*\))+(?:\([^\s()<>]*\)|[^\s`*!()\[\]{};:'".,<>?«»“”‘’]))/i
|
||||
|
||||
CodeMirror.defineMode(
|
||||
'gfm',
|
||||
function(config, modeConfig) {
|
||||
var codeDepth = 0
|
||||
function blankLine(state) {
|
||||
state.code = false
|
||||
return null
|
||||
}
|
||||
var gfmOverlay = {
|
||||
startState: function() {
|
||||
return {
|
||||
code: false,
|
||||
codeBlock: false,
|
||||
ateSpace: false
|
||||
}
|
||||
},
|
||||
copyState: function(s) {
|
||||
return {
|
||||
code: s.code,
|
||||
codeBlock: s.codeBlock,
|
||||
ateSpace: s.ateSpace
|
||||
}
|
||||
},
|
||||
token: function(stream, state) {
|
||||
state.combineTokens = null
|
||||
|
||||
// Hack to prevent formatting override inside code blocks (block and inline)
|
||||
if (state.codeBlock) {
|
||||
if (stream.match(/^```+/)) {
|
||||
state.codeBlock = false
|
||||
return null
|
||||
}
|
||||
stream.skipToEnd()
|
||||
return null
|
||||
}
|
||||
if (stream.sol()) {
|
||||
state.code = false
|
||||
}
|
||||
if (stream.sol() && stream.match(/^```+/)) {
|
||||
stream.skipToEnd()
|
||||
state.codeBlock = true
|
||||
return null
|
||||
}
|
||||
// If this block is changed, it may need to be updated in Markdown mode
|
||||
if (stream.peek() === '`') {
|
||||
stream.next()
|
||||
var before = stream.pos
|
||||
stream.eatWhile('`')
|
||||
var difference = 1 + stream.pos - before
|
||||
if (!state.code) {
|
||||
codeDepth = difference
|
||||
state.code = true
|
||||
} else {
|
||||
if (difference === codeDepth) {
|
||||
// Must be exact
|
||||
state.code = false
|
||||
}
|
||||
}
|
||||
return null
|
||||
} else if (state.code) {
|
||||
stream.next()
|
||||
return null
|
||||
}
|
||||
// Check if space. If so, links can be formatted later on
|
||||
if (stream.eatSpace()) {
|
||||
state.ateSpace = true
|
||||
return null
|
||||
}
|
||||
if (stream.sol() || state.ateSpace) {
|
||||
state.ateSpace = false
|
||||
if (modeConfig.gitHubSpice !== false) {
|
||||
if (
|
||||
stream.match(
|
||||
/^(?:[a-zA-Z0-9\-_]+\/)?(?:[a-zA-Z0-9\-_]+@)?(?=.{0,6}\d)(?:[a-f0-9]{7,40}\b)/
|
||||
)
|
||||
) {
|
||||
// User/Project@SHA
|
||||
// User@SHA
|
||||
// SHA
|
||||
state.combineTokens = true
|
||||
return 'link'
|
||||
} else if (
|
||||
stream.match(
|
||||
/^(?:[a-zA-Z0-9\-_]+\/)?(?:[a-zA-Z0-9\-_]+)?#[0-9]+\b/
|
||||
)
|
||||
) {
|
||||
// User/Project#Num
|
||||
// User#Num
|
||||
// #Num
|
||||
state.combineTokens = true
|
||||
return 'link'
|
||||
}
|
||||
}
|
||||
}
|
||||
if (
|
||||
stream.match(urlRE) &&
|
||||
stream.string.slice(stream.start - 2, stream.start) != '](' &&
|
||||
(stream.start == 0 ||
|
||||
/\W/.test(stream.string.charAt(stream.start - 1)))
|
||||
) {
|
||||
// URLs
|
||||
// Taken from http://daringfireball.net/2010/07/improved_regex_for_matching_urls
|
||||
// And then (issue #1160) simplified to make it not crash the Chrome Regexp engine
|
||||
// And then limited url schemes to the CommonMark list, so foo:bar isn't matched as a URL
|
||||
state.combineTokens = true
|
||||
return 'link'
|
||||
}
|
||||
stream.next()
|
||||
return null
|
||||
},
|
||||
blankLine: blankLine
|
||||
}
|
||||
|
||||
var markdownConfig = {
|
||||
taskLists: true,
|
||||
strikethrough: true,
|
||||
emoji: true
|
||||
}
|
||||
for (var attr in modeConfig) {
|
||||
markdownConfig[attr] = modeConfig[attr]
|
||||
}
|
||||
markdownConfig.name = 'markdown'
|
||||
return CodeMirror.overlayMode(
|
||||
CodeMirror.getMode(config, markdownConfig),
|
||||
gfmOverlay
|
||||
)
|
||||
},
|
||||
'markdown'
|
||||
)
|
||||
|
||||
CodeMirror.defineMIME('text/x-gfm', 'gfm')
|
||||
})
|
||||
@@ -108,12 +108,12 @@
|
||||
<script src="../node_modules/codemirror/addon/display/panel.js"></script>
|
||||
<script src="../node_modules/codemirror/mode/xml/xml.js"></script>
|
||||
<script src="../node_modules/codemirror/mode/markdown/markdown.js"></script>
|
||||
<script src="../node_modules/codemirror/mode/gfm/gfm.js"></script>
|
||||
<script src="../node_modules/codemirror/mode/yaml/yaml.js"></script>
|
||||
<script src="../node_modules/codemirror/mode/yaml-frontmatter/yaml-frontmatter.js"></script>
|
||||
|
||||
<script src="../extra_scripts/boost/boostNewLineIndentContinueMarkdownList.js"></script>
|
||||
<script src="../extra_scripts/codemirror/mode/bfm/bfm.js"></script>
|
||||
<script src="../extra_scripts/codemirror/mode/gfm/gfm.js"></script>
|
||||
<script src="../extra_scripts/codemirror/addon/hyperlink/hyperlink.js"></script>
|
||||
|
||||
<script src="../node_modules/codemirror/addon/edit/closebrackets.js"></script>
|
||||
|
||||
@@ -104,12 +104,12 @@
|
||||
<script src="../node_modules/codemirror/addon/display/panel.js"></script>
|
||||
<script src="../node_modules/codemirror/mode/xml/xml.js"></script>
|
||||
<script src="../node_modules/codemirror/mode/markdown/markdown.js"></script>
|
||||
<script src="../node_modules/codemirror/mode/gfm/gfm.js"></script>
|
||||
<script src="../node_modules/codemirror/mode/yaml/yaml.js"></script>
|
||||
<script src="../node_modules/codemirror/mode/yaml-frontmatter/yaml-frontmatter.js"></script>
|
||||
|
||||
<script src="../extra_scripts/boost/boostNewLineIndentContinueMarkdownList.js"></script>
|
||||
<script src="../extra_scripts/codemirror/mode/bfm/bfm.js"></script>
|
||||
<script src="../extra_scripts/codemirror/mode/gfm/gfm.js"></script>
|
||||
<script src="../extra_scripts/codemirror/addon/hyperlink/hyperlink.js"></script>
|
||||
|
||||
<script src="../node_modules/codemirror/addon/edit/closebrackets.js"></script>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "boost",
|
||||
"productName": "Boostnote",
|
||||
"version": "0.15.1",
|
||||
"version": "0.15.2",
|
||||
"main": "index.js",
|
||||
"description": "Boostnote",
|
||||
"license": "GPL-3.0",
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
> [We've launched desktop app of the new Boost Note now. We'll release its mobile app too in January 2020.](https://github.com/BoostIO/BoostNote.next)
|
||||
> [We've launched desktop and mobile app of the new Boost Note now.](https://github.com/BoostIO/BoostNote.next)
|
||||
|
||||

|
||||
|
||||
|
||||
10
yarn.lock
10
yarn.lock
@@ -5987,8 +5987,9 @@ locate-path@^3.0.0:
|
||||
path-exists "^3.0.0"
|
||||
|
||||
lodash-es@^4.2.1:
|
||||
version "4.17.10"
|
||||
resolved "https://registry.yarnpkg.com/lodash-es/-/lodash-es-4.17.10.tgz#62cd7104cdf5dd87f235a837f0ede0e8e5117e05"
|
||||
version "4.17.15"
|
||||
resolved "https://registry.yarnpkg.com/lodash-es/-/lodash-es-4.17.15.tgz#21bd96839354412f23d7a10340e5eac6ee455d78"
|
||||
integrity sha512-rlrc3yU3+JNOpZ9zj5pQtxnx2THmvRykwL4Xlxoa8I9lHBlVbbyPhgyPMioxVZ4NqyxaVVtaJnzsyOidQIhyyQ==
|
||||
|
||||
lodash-move@^1.1.1:
|
||||
version "1.1.1"
|
||||
@@ -6076,8 +6077,9 @@ lodash.merge@^4.6.0:
|
||||
resolved "https://registry.yarnpkg.com/lodash.merge/-/lodash.merge-4.6.1.tgz#adc25d9cb99b9391c59624f379fbba60d7111d54"
|
||||
|
||||
lodash.mergewith@^4.6.0:
|
||||
version "4.6.1"
|
||||
resolved "https://registry.yarnpkg.com/lodash.mergewith/-/lodash.mergewith-4.6.1.tgz#639057e726c3afbdb3e7d42741caa8d6e4335927"
|
||||
version "4.6.2"
|
||||
resolved "https://registry.yarnpkg.com/lodash.mergewith/-/lodash.mergewith-4.6.2.tgz#617121f89ac55f59047c7aec1ccd6654c6590f55"
|
||||
integrity sha512-GK3g5RPZWTRSeLSpgP8Xhra+pnjBC56q9FZYe1d5RN3TJ35dbkGy3YqBSMbyCrlbi+CM9Z3Jk5yTL7RCsqboyQ==
|
||||
|
||||
lodash.some@^4.5.1:
|
||||
version "4.6.0"
|
||||
|
||||
Reference in New Issue
Block a user