@codemirror/lang-markdown
Advanced tools
Comparing version 6.2.3 to 6.2.4
@@ -0,1 +1,7 @@ | ||
## 6.2.4 (2024-01-16) | ||
### Bug fixes | ||
Starting at the third list item, `insertNewlineContinueMarkup` will now keep the tightness of the list, and only require two presses to clear an empty list item. | ||
## 6.2.3 (2023-11-27) | ||
@@ -2,0 +8,0 @@ |
@@ -226,4 +226,5 @@ import { EditorSelection, countColumn, Prec, EditorState } from '@codemirror/state'; | ||
if (inner.item && emptyLine) { | ||
// First list item or blank line before: delete a level of markup | ||
if (inner.node.firstChild.to >= pos || | ||
let first = inner.node.firstChild, second = inner.node.getChild("ListItem", "ListItem"); | ||
// Not second item or blank line before: delete a level of markup | ||
if (first.to >= pos || second && second.to < pos || | ||
line.from > 0 && !/[^\s>]/.test(doc.lineAt(line.from - 1).text)) { | ||
@@ -246,8 +247,4 @@ let next = context.length > 1 ? context[context.length - 2] : null; | ||
} | ||
else { // Move this line down | ||
let insert = ""; | ||
for (let i = 0, e = context.length - 2; i <= e; i++) { | ||
insert += context[i].blank(i < e ? countColumn(line.text, 4, context[i + 1].from) - insert.length : null, i < e); | ||
} | ||
insert = normalizeIndent(insert, state); | ||
else { // Move second item down, making tight two-item list non-tight | ||
let insert = blankLine(context, state, line); | ||
return { range: EditorSelection.cursor(pos + insert.length + 1), | ||
@@ -282,2 +279,4 @@ changes: { from: line.from, insert: insert + state.lineBreak } }; | ||
insert = normalizeIndent(insert, state); | ||
if (nonTightList(inner.node, state.doc)) | ||
insert = blankLine(context, state, line) + state.lineBreak + insert; | ||
changes.push({ from, to: pos, insert: state.lineBreak + insert }); | ||
@@ -294,2 +293,19 @@ return { range: EditorSelection.cursor(from + insert.length + 1), changes }; | ||
} | ||
function nonTightList(node, doc) { | ||
if (node.name != "OrderedList" && node.name != "BulletList") | ||
return false; | ||
let first = node.firstChild, second = node.getChild("ListItem", "ListItem"); | ||
if (!second) | ||
return false; | ||
let line1 = doc.lineAt(first.to), line2 = doc.lineAt(second.from); | ||
let empty = /^[\s>]*$/.test(line1.text); | ||
return line1.number + (empty ? 0 : 1) < line2.number; | ||
} | ||
function blankLine(context, state, line) { | ||
let insert = ""; | ||
for (let i = 0, e = context.length - 2; i <= e; i++) { | ||
insert += context[i].blank(i < e ? countColumn(line.text, 4, context[i + 1].from) - insert.length : null, i < e); | ||
} | ||
return normalizeIndent(insert, state); | ||
} | ||
function contextNodeForDelete(tree, pos) { | ||
@@ -296,0 +312,0 @@ let node = tree.resolveInner(pos, -1), scan = pos; |
{ | ||
"name": "@codemirror/lang-markdown", | ||
"version": "6.2.3", | ||
"version": "6.2.4", | ||
"description": "Markdown language support for the CodeMirror code editor", | ||
@@ -35,3 +35,3 @@ "scripts": { | ||
"@lezer/markdown": "^1.0.0", | ||
"@lezer/common": "^1.0.0" | ||
"@lezer/common": "^1.2.1" | ||
}, | ||
@@ -38,0 +38,0 @@ "devDependencies": { |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
60147
960
Updated@lezer/common@^1.2.1