tiptap-markdown
Advanced tools
Comparing version 0.8.7 to 0.8.8
@@ -436,2 +436,11 @@ var __defProp = Object.defineProperty; | ||
}); | ||
function findIndexOfAdjacentNode(node, parent, index) { | ||
let i = 0; | ||
for (; index - i > 0; i++) { | ||
if (parent.child(index - i - 1).type.name !== node.type.name) { | ||
break; | ||
} | ||
} | ||
return i; | ||
} | ||
const OrderedList$1 = OrderedList.extend({ | ||
@@ -444,9 +453,11 @@ /** | ||
markdown: { | ||
serialize(state, node) { | ||
serialize(state, node, parent, index) { | ||
const start = node.attrs.start || 1; | ||
const maxW = String(start + node.childCount - 1).length; | ||
const space = state.repeat(" ", maxW + 2); | ||
const adjacentIndex = findIndexOfAdjacentNode(node, parent, index); | ||
const separator = adjacentIndex % 2 ? ") " : ". "; | ||
state.renderList(node, space, (i) => { | ||
const nStr = String(start + i); | ||
return state.repeat(" ", maxW - nStr.length) + nStr + ". "; | ||
return state.repeat(" ", maxW - nStr.length) + nStr + separator; | ||
}); | ||
@@ -453,0 +464,0 @@ }, |
@@ -434,2 +434,11 @@ (function(global, factory) { | ||
}); | ||
function findIndexOfAdjacentNode(node, parent, index) { | ||
let i = 0; | ||
for (; index - i > 0; i++) { | ||
if (parent.child(index - i - 1).type.name !== node.type.name) { | ||
break; | ||
} | ||
} | ||
return i; | ||
} | ||
const OrderedList$1 = OrderedList.extend({ | ||
@@ -442,9 +451,11 @@ /** | ||
markdown: { | ||
serialize(state2, node) { | ||
serialize(state2, node, parent, index) { | ||
const start = node.attrs.start || 1; | ||
const maxW = String(start + node.childCount - 1).length; | ||
const space = state2.repeat(" ", maxW + 2); | ||
const adjacentIndex = findIndexOfAdjacentNode(node, parent, index); | ||
const separator = adjacentIndex % 2 ? ") " : ". "; | ||
state2.renderList(node, space, (i) => { | ||
const nStr = String(start + i); | ||
return state2.repeat(" ", maxW - nStr.length) + nStr + ". "; | ||
return state2.repeat(" ", maxW - nStr.length) + nStr + separator; | ||
}); | ||
@@ -451,0 +462,0 @@ }, |
{ | ||
"name": "tiptap-markdown", | ||
"version": "0.8.7", | ||
"version": "0.8.8", | ||
"description": "Edit markdown content in tiptap editor.", | ||
@@ -5,0 +5,0 @@ "scripts": { |
@@ -6,3 +6,3 @@ # Tiptap markdown | ||
> **Warning** | ||
> Since v0.7.0, `createMarkdownEditor` as been dropped in favor of a more friendly `Markdown` Tiptap extension. See the [migration guide](https://github.com/aguingand/tiptap-markdown/blob/main/docs/migration.md). | ||
> Since v0.7.0, `createMarkdownEditor` has been dropped in favor of a more friendly `Markdown` Tiptap extension. See the [migration guide](https://github.com/aguingand/tiptap-markdown/blob/main/docs/migration.md). | ||
@@ -9,0 +9,0 @@ ## Installation |
import { Node } from "@tiptap/core"; | ||
import { defaultMarkdownSerializer } from "prosemirror-markdown"; | ||
@@ -9,2 +8,12 @@ | ||
function findIndexOfAdjacentNode(node, parent, index) { | ||
let i = 0; | ||
for (; index - i > 0; i++) { | ||
if (parent.child(index - i - 1).type.name !== node.type.name) { | ||
break; | ||
} | ||
} | ||
return i; | ||
} | ||
export default OrderedList.extend({ | ||
@@ -17,9 +26,11 @@ /** | ||
markdown: { | ||
serialize(state,node) { | ||
serialize(state, node, parent, index) { | ||
const start = node.attrs.start || 1 | ||
const maxW = String(start + node.childCount - 1).length | ||
const space = state.repeat(" ", maxW + 2) | ||
const adjacentIndex = findIndexOfAdjacentNode(node, parent, index); | ||
const separator = adjacentIndex % 2 ? ') ' : '. '; | ||
state.renderList(node, space, i => { | ||
const nStr = String(start + i) | ||
return state.repeat(" ", maxW - nStr.length) + nStr + ". " | ||
return state.repeat(" ", maxW - nStr.length) + nStr + separator; | ||
}) | ||
@@ -26,0 +37,0 @@ }, |
Sorry, the diff of this file is not supported yet
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
234081
3142
0