mirror of
https://github.com/BoostIo/Boostnote
synced 2025-12-14 02:06:29 +00:00
Smart numbered lists, too
Has auto increment, but no auto indent on tab, I don't know what to do
This commit is contained in:
@@ -86,10 +86,14 @@ export default class CodeEditor extends React.Component {
|
|||||||
const cursor = cm.getCursor()
|
const cursor = cm.getCursor()
|
||||||
const line = cm.getLine(cursor.line)
|
const line = cm.getLine(cursor.line)
|
||||||
const dash = line.trim().startsWith('- ')
|
const dash = line.trim().startsWith('- ')
|
||||||
if (line.trim().startsWith('- ') || line.trim().startsWith('* ')) {
|
const numberedListRegex = /(\d+)\. .+/
|
||||||
|
const match = line.trim().match(numberedListRegex)
|
||||||
|
if (line.trim().startsWith('- ') || line.trim().startsWith('* ') || match) {
|
||||||
cm.execCommand('newlineAndIndent')
|
cm.execCommand('newlineAndIndent')
|
||||||
const range = {line: cursor.line + 1, ch: cm.getLine(cursor.line + 1).length}
|
const range = {line: cursor.line + 1, ch: cm.getLine(cursor.line + 1).length}
|
||||||
if (dash) {
|
if (match) {
|
||||||
|
cm.replaceRange((parseInt(match[1]) + 1) + '. ', range)
|
||||||
|
} else if (dash) {
|
||||||
cm.replaceRange('- ', range)
|
cm.replaceRange('- ', range)
|
||||||
} else {
|
} else {
|
||||||
cm.replaceRange('* ', range)
|
cm.replaceRange('* ', range)
|
||||||
|
|||||||
Reference in New Issue
Block a user