@tiptap/extension-list-keymap 3.0.0-next.3 → 3.0.0-next.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +21 -0
- package/README.md +5 -1
- package/dist/index.cjs +11 -285
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -63
- package/dist/index.d.ts +2 -63
- package/dist/index.js +7 -286
- package/dist/index.js.map +1 -1
- package/package.json +10 -6
- package/src/index.ts +2 -3
- package/src/list-keymap.ts +0 -106
- package/src/listHelpers/findListItemPos.ts +0 -30
- package/src/listHelpers/getNextListDepth.ts +0 -16
- package/src/listHelpers/handleBackspace.ts +0 -80
- package/src/listHelpers/handleDelete.ts +0 -46
- package/src/listHelpers/hasListBefore.ts +0 -15
- package/src/listHelpers/hasListItemAfter.ts +0 -17
- package/src/listHelpers/hasListItemBefore.ts +0 -17
- package/src/listHelpers/index.ts +0 -10
- package/src/listHelpers/listItemHasSubList.ts +0 -21
- package/src/listHelpers/nextListIsDeeper.ts +0 -19
- package/src/listHelpers/nextListIsHigher.ts +0 -19
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { EditorState } from '@tiptap/pm/state'
|
|
2
|
-
|
|
3
|
-
export const hasListBefore = (editorState: EditorState, name: string, parentListTypes: string[]) => {
|
|
4
|
-
const { $anchor } = editorState.selection
|
|
5
|
-
|
|
6
|
-
const previousNodePos = Math.max(0, $anchor.pos - 2)
|
|
7
|
-
|
|
8
|
-
const previousNode = editorState.doc.resolve(previousNodePos).node()
|
|
9
|
-
|
|
10
|
-
if (!previousNode || !parentListTypes.includes(previousNode.type.name)) {
|
|
11
|
-
return false
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
return true
|
|
15
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { EditorState } from '@tiptap/pm/state'
|
|
2
|
-
|
|
3
|
-
export const hasListItemAfter = (typeOrName: string, state: EditorState): boolean => {
|
|
4
|
-
const { $anchor } = state.selection
|
|
5
|
-
|
|
6
|
-
const $targetPos = state.doc.resolve($anchor.pos - $anchor.parentOffset - 2)
|
|
7
|
-
|
|
8
|
-
if ($targetPos.index() === $targetPos.parent.childCount - 1) {
|
|
9
|
-
return false
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
if ($targetPos.nodeAfter?.type.name !== typeOrName) {
|
|
13
|
-
return false
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
return true
|
|
17
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { EditorState } from '@tiptap/pm/state'
|
|
2
|
-
|
|
3
|
-
export const hasListItemBefore = (typeOrName: string, state: EditorState): boolean => {
|
|
4
|
-
const { $anchor } = state.selection
|
|
5
|
-
|
|
6
|
-
const $targetPos = state.doc.resolve($anchor.pos - 2)
|
|
7
|
-
|
|
8
|
-
if ($targetPos.index() === 0) {
|
|
9
|
-
return false
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
if ($targetPos.nodeBefore?.type.name !== typeOrName) {
|
|
13
|
-
return false
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
return true
|
|
17
|
-
}
|
package/src/listHelpers/index.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
export * from './findListItemPos.js'
|
|
2
|
-
export * from './getNextListDepth.js'
|
|
3
|
-
export * from './handleBackspace.js'
|
|
4
|
-
export * from './handleDelete.js'
|
|
5
|
-
export * from './hasListBefore.js'
|
|
6
|
-
export * from './hasListItemAfter.js'
|
|
7
|
-
export * from './hasListItemBefore.js'
|
|
8
|
-
export * from './listItemHasSubList.js'
|
|
9
|
-
export * from './nextListIsDeeper.js'
|
|
10
|
-
export * from './nextListIsHigher.js'
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { getNodeType } from '@tiptap/core'
|
|
2
|
-
import { Node } from '@tiptap/pm/model'
|
|
3
|
-
import { EditorState } from '@tiptap/pm/state'
|
|
4
|
-
|
|
5
|
-
export const listItemHasSubList = (typeOrName: string, state: EditorState, node?: Node) => {
|
|
6
|
-
if (!node) {
|
|
7
|
-
return false
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
const nodeType = getNodeType(typeOrName, state.schema)
|
|
11
|
-
|
|
12
|
-
let hasSubList = false
|
|
13
|
-
|
|
14
|
-
node.descendants(child => {
|
|
15
|
-
if (child.type === nodeType) {
|
|
16
|
-
hasSubList = true
|
|
17
|
-
}
|
|
18
|
-
})
|
|
19
|
-
|
|
20
|
-
return hasSubList
|
|
21
|
-
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { EditorState } from '@tiptap/pm/state'
|
|
2
|
-
|
|
3
|
-
import { findListItemPos } from './findListItemPos.js'
|
|
4
|
-
import { getNextListDepth } from './getNextListDepth.js'
|
|
5
|
-
|
|
6
|
-
export const nextListIsDeeper = (typeOrName: string, state: EditorState) => {
|
|
7
|
-
const listDepth = getNextListDepth(typeOrName, state)
|
|
8
|
-
const listItemPos = findListItemPos(typeOrName, state)
|
|
9
|
-
|
|
10
|
-
if (!listItemPos || !listDepth) {
|
|
11
|
-
return false
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
if (listDepth > listItemPos.depth) {
|
|
15
|
-
return true
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
return false
|
|
19
|
-
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { EditorState } from '@tiptap/pm/state'
|
|
2
|
-
|
|
3
|
-
import { findListItemPos } from './findListItemPos.js'
|
|
4
|
-
import { getNextListDepth } from './getNextListDepth.js'
|
|
5
|
-
|
|
6
|
-
export const nextListIsHigher = (typeOrName: string, state: EditorState) => {
|
|
7
|
-
const listDepth = getNextListDepth(typeOrName, state)
|
|
8
|
-
const listItemPos = findListItemPos(typeOrName, state)
|
|
9
|
-
|
|
10
|
-
if (!listItemPos || !listDepth) {
|
|
11
|
-
return false
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
if (listDepth < listItemPos.depth) {
|
|
15
|
-
return true
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
return false
|
|
19
|
-
}
|