mirror of
https://github.com/status-im/codimd.git
synced 2025-01-15 02:44:11 +00:00
refactor: fix lint warning on public/js/lib/editor/utils.js
Signed-off-by: BoHong Li <a60814billy@gmail.com>
This commit is contained in:
parent
45ba0c646d
commit
bf727b5878
@ -51,7 +51,7 @@ export function insertText (cm, text, cursorEnd = 0) {
|
|||||||
let cursor = cm.getCursor()
|
let cursor = cm.getCursor()
|
||||||
cm.replaceSelection(text, cursor, cursor)
|
cm.replaceSelection(text, cursor, cursor)
|
||||||
cm.focus()
|
cm.focus()
|
||||||
cm.setCursor({line: cursor.line, ch: cursor.ch + cursorEnd})
|
cm.setCursor({ line: cursor.line, ch: cursor.ch + cursorEnd })
|
||||||
}
|
}
|
||||||
|
|
||||||
export function insertLink (cm, isImage) {
|
export function insertLink (cm, isImage) {
|
||||||
@ -80,7 +80,7 @@ export function insertLink (cm, isImage) {
|
|||||||
cm.setSelections(ranges)
|
cm.setSelections(ranges)
|
||||||
} else {
|
} else {
|
||||||
cm.replaceRange(symbol + linkEnd, cursor, cursor)
|
cm.replaceRange(symbol + linkEnd, cursor, cursor)
|
||||||
cm.setCursor({line: cursor.line, ch: cursor.ch + symbol.length + linkEnd.length})
|
cm.setCursor({ line: cursor.line, ch: cursor.ch + symbol.length + linkEnd.length })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
cm.focus()
|
cm.focus()
|
||||||
@ -88,8 +88,8 @@ export function insertLink (cm, isImage) {
|
|||||||
|
|
||||||
export function insertHeader (cm) {
|
export function insertHeader (cm) {
|
||||||
let cursor = cm.getCursor()
|
let cursor = cm.getCursor()
|
||||||
let startOfLine = {line: cursor.line, ch: 0}
|
let startOfLine = { line: cursor.line, ch: 0 }
|
||||||
let startOfLineText = cm.getRange(startOfLine, {line: cursor.line, ch: 1})
|
let startOfLineText = cm.getRange(startOfLine, { line: cursor.line, ch: 1 })
|
||||||
// See if it is already a header
|
// See if it is already a header
|
||||||
if (startOfLineText === '#') {
|
if (startOfLineText === '#') {
|
||||||
cm.replaceRange('#', startOfLine, startOfLine)
|
cm.replaceRange('#', startOfLine, startOfLine)
|
||||||
@ -108,14 +108,14 @@ export function insertOnStartOfLines (cm, symbol) {
|
|||||||
if (!range.empty()) {
|
if (!range.empty()) {
|
||||||
const from = range.from()
|
const from = range.from()
|
||||||
const to = range.to()
|
const to = range.to()
|
||||||
let selection = cm.getRange({line: from.line, ch: 0}, to)
|
let selection = cm.getRange({ line: from.line, ch: 0 }, to)
|
||||||
selection = selection.replace(/\n/g, '\n' + symbol)
|
selection = selection.replace(/\n/g, '\n' + symbol)
|
||||||
selection = symbol + selection
|
selection = symbol + selection
|
||||||
cm.replaceRange(selection, from, to)
|
cm.replaceRange(selection, from, to)
|
||||||
} else {
|
} else {
|
||||||
cm.replaceRange(symbol, {line: cursor.line, ch: 0}, {line: cursor.line, ch: 0})
|
cm.replaceRange(symbol, { line: cursor.line, ch: 0 }, { line: cursor.line, ch: 0 })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
cm.setCursor({line: cursor.line, ch: cursor.ch + symbol.length})
|
cm.setCursor({ line: cursor.line, ch: cursor.ch + symbol.length })
|
||||||
cm.focus()
|
cm.focus()
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user