@tiptap/extension-list-keymap 3.0.0 → 3.0.2-beta.0
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 +34 -285
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +10 -281
- package/dist/index.js.map +1 -1
- package/package.json +11 -9
- package/src/index.ts +3 -3
- package/dist/index.umd.js +0 -291
- package/dist/index.umd.js.map +0 -1
- package/dist/packages/core/src/CommandManager.d.ts +0 -20
- package/dist/packages/core/src/Editor.d.ts +0 -161
- package/dist/packages/core/src/EventEmitter.d.ts +0 -11
- package/dist/packages/core/src/Extension.d.ts +0 -343
- package/dist/packages/core/src/ExtensionManager.d.ts +0 -55
- package/dist/packages/core/src/InputRule.d.ts +0 -42
- package/dist/packages/core/src/Mark.d.ts +0 -451
- package/dist/packages/core/src/Node.d.ts +0 -611
- package/dist/packages/core/src/NodePos.d.ts +0 -44
- package/dist/packages/core/src/NodeView.d.ts +0 -31
- package/dist/packages/core/src/PasteRule.d.ts +0 -50
- package/dist/packages/core/src/Tracker.d.ts +0 -11
- package/dist/packages/core/src/commands/blur.d.ts +0 -13
- package/dist/packages/core/src/commands/clearContent.d.ts +0 -14
- package/dist/packages/core/src/commands/clearNodes.d.ts +0 -13
- package/dist/packages/core/src/commands/command.d.ts +0 -18
- package/dist/packages/core/src/commands/createParagraphNear.d.ts +0 -13
- package/dist/packages/core/src/commands/cut.d.ts +0 -20
- package/dist/packages/core/src/commands/deleteCurrentNode.d.ts +0 -13
- package/dist/packages/core/src/commands/deleteNode.d.ts +0 -15
- package/dist/packages/core/src/commands/deleteRange.d.ts +0 -14
- package/dist/packages/core/src/commands/deleteSelection.d.ts +0 -13
- package/dist/packages/core/src/commands/enter.d.ts +0 -13
- package/dist/packages/core/src/commands/exitCode.d.ts +0 -13
- package/dist/packages/core/src/commands/extendMarkRange.d.ts +0 -25
- package/dist/packages/core/src/commands/first.d.ts +0 -14
- package/dist/packages/core/src/commands/focus.d.ts +0 -27
- package/dist/packages/core/src/commands/forEach.d.ts +0 -14
- package/dist/packages/core/src/commands/index.d.ts +0 -55
- package/dist/packages/core/src/commands/insertContent.d.ts +0 -34
- package/dist/packages/core/src/commands/insertContentAt.d.ts +0 -47
- package/dist/packages/core/src/commands/join.d.ts +0 -41
- package/dist/packages/core/src/commands/joinItemBackward.d.ts +0 -13
- package/dist/packages/core/src/commands/joinItemForward.d.ts +0 -13
- package/dist/packages/core/src/commands/joinTextblockBackward.d.ts +0 -12
- package/dist/packages/core/src/commands/joinTextblockForward.d.ts +0 -12
- package/dist/packages/core/src/commands/keyboardShortcut.d.ts +0 -14
- package/dist/packages/core/src/commands/lift.d.ts +0 -17
- package/dist/packages/core/src/commands/liftEmptyBlock.d.ts +0 -13
- package/dist/packages/core/src/commands/liftListItem.d.ts +0 -15
- package/dist/packages/core/src/commands/newlineInCode.d.ts +0 -13
- package/dist/packages/core/src/commands/resetAttributes.d.ts +0 -16
- package/dist/packages/core/src/commands/scrollIntoView.d.ts +0 -13
- package/dist/packages/core/src/commands/selectAll.d.ts +0 -13
- package/dist/packages/core/src/commands/selectNodeBackward.d.ts +0 -13
- package/dist/packages/core/src/commands/selectNodeForward.d.ts +0 -13
- package/dist/packages/core/src/commands/selectParentNode.d.ts +0 -13
- package/dist/packages/core/src/commands/selectTextblockEnd.d.ts +0 -13
- package/dist/packages/core/src/commands/selectTextblockStart.d.ts +0 -13
- package/dist/packages/core/src/commands/setContent.d.ts +0 -40
- package/dist/packages/core/src/commands/setMark.d.ts +0 -15
- package/dist/packages/core/src/commands/setMeta.d.ts +0 -15
- package/dist/packages/core/src/commands/setNode.d.ts +0 -16
- package/dist/packages/core/src/commands/setNodeSelection.d.ts +0 -14
- package/dist/packages/core/src/commands/setTextSelection.d.ts +0 -14
- package/dist/packages/core/src/commands/sinkListItem.d.ts +0 -15
- package/dist/packages/core/src/commands/splitBlock.d.ts +0 -17
- package/dist/packages/core/src/commands/splitListItem.d.ts +0 -15
- package/dist/packages/core/src/commands/toggleList.d.ts +0 -18
- package/dist/packages/core/src/commands/toggleMark.d.ts +0 -30
- package/dist/packages/core/src/commands/toggleNode.d.ts +0 -17
- package/dist/packages/core/src/commands/toggleWrap.d.ts +0 -16
- package/dist/packages/core/src/commands/undoInputRule.d.ts +0 -13
- package/dist/packages/core/src/commands/unsetAllMarks.d.ts +0 -13
- package/dist/packages/core/src/commands/unsetMark.d.ts +0 -25
- package/dist/packages/core/src/commands/updateAttributes.d.ts +0 -24
- package/dist/packages/core/src/commands/wrapIn.d.ts +0 -16
- package/dist/packages/core/src/commands/wrapInList.d.ts +0 -16
- package/dist/packages/core/src/extensions/clipboardTextSerializer.d.ts +0 -5
- package/dist/packages/core/src/extensions/commands.d.ts +0 -3
- package/dist/packages/core/src/extensions/editable.d.ts +0 -2
- package/dist/packages/core/src/extensions/focusEvents.d.ts +0 -2
- package/dist/packages/core/src/extensions/index.d.ts +0 -6
- package/dist/packages/core/src/extensions/keymap.d.ts +0 -2
- package/dist/packages/core/src/extensions/tabindex.d.ts +0 -2
- package/dist/packages/core/src/helpers/combineTransactionSteps.d.ts +0 -10
- package/dist/packages/core/src/helpers/createChainableState.d.ts +0 -10
- package/dist/packages/core/src/helpers/createDocument.d.ts +0 -12
- package/dist/packages/core/src/helpers/createNodeFromContent.d.ts +0 -15
- package/dist/packages/core/src/helpers/defaultBlockAt.d.ts +0 -7
- package/dist/packages/core/src/helpers/findChildren.d.ts +0 -9
- package/dist/packages/core/src/helpers/findChildrenInRange.d.ts +0 -10
- package/dist/packages/core/src/helpers/findParentNode.d.ts +0 -16
- package/dist/packages/core/src/helpers/findParentNodeClosestToPos.d.ts +0 -17
- package/dist/packages/core/src/helpers/generateHTML.d.ts +0 -8
- package/dist/packages/core/src/helpers/generateJSON.d.ts +0 -8
- package/dist/packages/core/src/helpers/generateText.d.ts +0 -12
- package/dist/packages/core/src/helpers/getAttributes.d.ts +0 -9
- package/dist/packages/core/src/helpers/getAttributesFromExtensions.d.ts +0 -6
- package/dist/packages/core/src/helpers/getChangedRanges.d.ts +0 -11
- package/dist/packages/core/src/helpers/getDebugJSON.d.ts +0 -8
- package/dist/packages/core/src/helpers/getExtensionField.d.ts +0 -9
- package/dist/packages/core/src/helpers/getHTMLFromFragment.d.ts +0 -2
- package/dist/packages/core/src/helpers/getMarkAttributes.d.ts +0 -3
- package/dist/packages/core/src/helpers/getMarkRange.d.ts +0 -3
- package/dist/packages/core/src/helpers/getMarkType.d.ts +0 -2
- package/dist/packages/core/src/helpers/getMarksBetween.d.ts +0 -3
- package/dist/packages/core/src/helpers/getNodeAtPosition.d.ts +0 -11
- package/dist/packages/core/src/helpers/getNodeAttributes.d.ts +0 -3
- package/dist/packages/core/src/helpers/getNodeType.d.ts +0 -2
- package/dist/packages/core/src/helpers/getRenderedAttributes.d.ts +0 -3
- package/dist/packages/core/src/helpers/getSchema.d.ts +0 -4
- package/dist/packages/core/src/helpers/getSchemaByResolvedExtensions.d.ts +0 -10
- package/dist/packages/core/src/helpers/getSchemaTypeByName.d.ts +0 -8
- package/dist/packages/core/src/helpers/getSchemaTypeNameByName.d.ts +0 -8
- package/dist/packages/core/src/helpers/getSplittedAttributes.d.ts +0 -9
- package/dist/packages/core/src/helpers/getText.d.ts +0 -15
- package/dist/packages/core/src/helpers/getTextBetween.d.ts +0 -14
- package/dist/packages/core/src/helpers/getTextContentFromNodes.d.ts +0 -8
- package/dist/packages/core/src/helpers/getTextSerializersFromSchema.d.ts +0 -8
- package/dist/packages/core/src/helpers/index.d.ts +0 -50
- package/dist/packages/core/src/helpers/injectExtensionAttributesToParseRule.d.ts +0 -9
- package/dist/packages/core/src/helpers/isActive.d.ts +0 -2
- package/dist/packages/core/src/helpers/isAtEndOfNode.d.ts +0 -2
- package/dist/packages/core/src/helpers/isAtStartOfNode.d.ts +0 -2
- package/dist/packages/core/src/helpers/isExtensionRulesEnabled.d.ts +0 -2
- package/dist/packages/core/src/helpers/isList.d.ts +0 -2
- package/dist/packages/core/src/helpers/isMarkActive.d.ts +0 -3
- package/dist/packages/core/src/helpers/isNodeActive.d.ts +0 -3
- package/dist/packages/core/src/helpers/isNodeEmpty.d.ts +0 -2
- package/dist/packages/core/src/helpers/isNodeSelection.d.ts +0 -2
- package/dist/packages/core/src/helpers/isTextSelection.d.ts +0 -2
- package/dist/packages/core/src/helpers/posToDOMRect.d.ts +0 -2
- package/dist/packages/core/src/helpers/resolveFocusPosition.d.ts +0 -4
- package/dist/packages/core/src/helpers/selectionToInsertionEnd.d.ts +0 -2
- package/dist/packages/core/src/helpers/splitExtensions.d.ts +0 -9
- package/dist/packages/core/src/index.d.ts +0 -24
- package/dist/packages/core/src/inputRules/index.d.ts +0 -5
- package/dist/packages/core/src/inputRules/markInputRule.d.ts +0 -13
- package/dist/packages/core/src/inputRules/nodeInputRule.d.ts +0 -23
- package/dist/packages/core/src/inputRules/textInputRule.d.ts +0 -10
- package/dist/packages/core/src/inputRules/textblockTypeInputRule.d.ts +0 -15
- package/dist/packages/core/src/inputRules/wrappingInputRule.d.ts +0 -28
- package/dist/packages/core/src/pasteRules/index.d.ts +0 -3
- package/dist/packages/core/src/pasteRules/markPasteRule.d.ts +0 -13
- package/dist/packages/core/src/pasteRules/nodePasteRule.d.ts +0 -13
- package/dist/packages/core/src/pasteRules/textPasteRule.d.ts +0 -10
- package/dist/packages/core/src/style.d.ts +0 -1
- package/dist/packages/core/src/types.d.ts +0 -255
- package/dist/packages/core/src/utilities/callOrReturn.d.ts +0 -9
- package/dist/packages/core/src/utilities/createStyleTag.d.ts +0 -1
- package/dist/packages/core/src/utilities/deleteProps.d.ts +0 -6
- package/dist/packages/core/src/utilities/elementFromString.d.ts +0 -1
- package/dist/packages/core/src/utilities/escapeForRegEx.d.ts +0 -1
- package/dist/packages/core/src/utilities/findDuplicates.d.ts +0 -1
- package/dist/packages/core/src/utilities/fromString.d.ts +0 -1
- package/dist/packages/core/src/utilities/index.d.ts +0 -20
- package/dist/packages/core/src/utilities/isAndroid.d.ts +0 -1
- package/dist/packages/core/src/utilities/isEmptyObject.d.ts +0 -1
- package/dist/packages/core/src/utilities/isFunction.d.ts +0 -1
- package/dist/packages/core/src/utilities/isMacOS.d.ts +0 -1
- package/dist/packages/core/src/utilities/isNumber.d.ts +0 -1
- package/dist/packages/core/src/utilities/isPlainObject.d.ts +0 -1
- package/dist/packages/core/src/utilities/isRegExp.d.ts +0 -1
- package/dist/packages/core/src/utilities/isString.d.ts +0 -1
- package/dist/packages/core/src/utilities/isiOS.d.ts +0 -1
- package/dist/packages/core/src/utilities/mergeAttributes.d.ts +0 -1
- package/dist/packages/core/src/utilities/mergeDeep.d.ts +0 -1
- package/dist/packages/core/src/utilities/minMax.d.ts +0 -1
- package/dist/packages/core/src/utilities/objectIncludes.d.ts +0 -8
- package/dist/packages/core/src/utilities/removeDuplicates.d.ts +0 -8
- package/dist/packages/extension-list-keymap/src/index.d.ts +0 -4
- package/dist/packages/extension-list-keymap/src/list-keymap.d.ts +0 -20
- package/dist/packages/extension-list-keymap/src/listHelpers/findListItemPos.d.ts +0 -6
- package/dist/packages/extension-list-keymap/src/listHelpers/getNextListDepth.d.ts +0 -2
- package/dist/packages/extension-list-keymap/src/listHelpers/handleBackspace.d.ts +0 -2
- package/dist/packages/extension-list-keymap/src/listHelpers/handleDelete.d.ts +0 -2
- package/dist/packages/extension-list-keymap/src/listHelpers/hasListBefore.d.ts +0 -2
- package/dist/packages/extension-list-keymap/src/listHelpers/hasListItemAfter.d.ts +0 -2
- package/dist/packages/extension-list-keymap/src/listHelpers/hasListItemBefore.d.ts +0 -2
- package/dist/packages/extension-list-keymap/src/listHelpers/index.d.ts +0 -10
- package/dist/packages/extension-list-keymap/src/listHelpers/listItemHasSubList.d.ts +0 -3
- package/dist/packages/extension-list-keymap/src/listHelpers/nextListIsDeeper.d.ts +0 -2
- package/dist/packages/extension-list-keymap/src/listHelpers/nextListIsHigher.d.ts +0 -2
- 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 -74
- package/src/listHelpers/handleDelete.ts +0 -37
- 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,74 +0,0 @@
|
|
|
1
|
-
import { Editor, isAtStartOfNode, isNodeActive } from '@tiptap/core'
|
|
2
|
-
import { Node } from '@tiptap/pm/model'
|
|
3
|
-
|
|
4
|
-
import { findListItemPos } from './findListItemPos.js'
|
|
5
|
-
import { hasListBefore } from './hasListBefore.js'
|
|
6
|
-
import { hasListItemBefore } from './hasListItemBefore.js'
|
|
7
|
-
import { listItemHasSubList } from './listItemHasSubList.js'
|
|
8
|
-
|
|
9
|
-
export const handleBackspace = (editor: Editor, name: string, parentListTypes: string[]) => {
|
|
10
|
-
// this is required to still handle the undo handling
|
|
11
|
-
if (editor.commands.undoInputRule()) {
|
|
12
|
-
return true
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
// if the current item is NOT inside a list item &
|
|
16
|
-
// the previous item is a list (orderedList or bulletList)
|
|
17
|
-
// move the cursor into the list and delete the current item
|
|
18
|
-
if (!isNodeActive(editor.state, name) && hasListBefore(editor.state, name, parentListTypes)) {
|
|
19
|
-
const { $anchor } = editor.state.selection
|
|
20
|
-
|
|
21
|
-
const $listPos = editor.state.doc.resolve($anchor.before() - 1)
|
|
22
|
-
|
|
23
|
-
const listDescendants: Array<{ node: Node, pos: number }> = []
|
|
24
|
-
|
|
25
|
-
$listPos.node().descendants((node, pos) => {
|
|
26
|
-
if (node.type.name === name) {
|
|
27
|
-
listDescendants.push({ node, pos })
|
|
28
|
-
}
|
|
29
|
-
})
|
|
30
|
-
|
|
31
|
-
const lastItem = listDescendants.at(-1)
|
|
32
|
-
|
|
33
|
-
if (!lastItem) {
|
|
34
|
-
return false
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
const $lastItemPos = editor.state.doc.resolve($listPos.start() + lastItem.pos + 1)
|
|
38
|
-
|
|
39
|
-
return editor.chain().cut({ from: $anchor.start() - 1, to: $anchor.end() + 1 }, $lastItemPos.end()).joinForward().run()
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
// if the cursor is not inside the current node type
|
|
43
|
-
// do nothing and proceed
|
|
44
|
-
if (!isNodeActive(editor.state, name)) {
|
|
45
|
-
return false
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
// if the cursor is not at the start of a node
|
|
49
|
-
// do nothing and proceed
|
|
50
|
-
if (!isAtStartOfNode(editor.state)) {
|
|
51
|
-
return false
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
const listItemPos = findListItemPos(name, editor.state)
|
|
55
|
-
|
|
56
|
-
if (!listItemPos) {
|
|
57
|
-
return false
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
const $prev = editor.state.doc.resolve(listItemPos.$pos.pos - 2)
|
|
61
|
-
const prevNode = $prev.node(listItemPos.depth)
|
|
62
|
-
|
|
63
|
-
const previousListItemHasSubList = listItemHasSubList(name, editor.state, prevNode)
|
|
64
|
-
|
|
65
|
-
// if the previous item is a list item and doesn't have a sublist, join the list items
|
|
66
|
-
if (hasListItemBefore(name, editor.state) && !previousListItemHasSubList) {
|
|
67
|
-
return editor.commands.joinItemBackward()
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
// otherwise in the end, a backspace should
|
|
71
|
-
// always just lift the list item if
|
|
72
|
-
// joining / merging is not possible
|
|
73
|
-
return editor.chain().liftListItem(name).run()
|
|
74
|
-
}
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { Editor, isAtEndOfNode, isNodeActive } from '@tiptap/core'
|
|
2
|
-
|
|
3
|
-
import { nextListIsDeeper } from './nextListIsDeeper.js'
|
|
4
|
-
import { nextListIsHigher } from './nextListIsHigher.js'
|
|
5
|
-
|
|
6
|
-
export const handleDelete = (editor: Editor, name: string) => {
|
|
7
|
-
// if the cursor is not inside the current node type
|
|
8
|
-
// do nothing and proceed
|
|
9
|
-
if (!isNodeActive(editor.state, name)) {
|
|
10
|
-
return false
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
// if the cursor is not at the end of a node
|
|
14
|
-
// do nothing and proceed
|
|
15
|
-
if (!isAtEndOfNode(editor.state, name)) {
|
|
16
|
-
return false
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
// check if the next node is a list with a deeper depth
|
|
20
|
-
if (nextListIsDeeper(name, editor.state)) {
|
|
21
|
-
return editor
|
|
22
|
-
.chain()
|
|
23
|
-
.focus(editor.state.selection.from + 4)
|
|
24
|
-
.lift(name)
|
|
25
|
-
.joinBackward()
|
|
26
|
-
.run()
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
if (nextListIsHigher(name, editor.state)) {
|
|
30
|
-
return editor.chain()
|
|
31
|
-
.joinForward()
|
|
32
|
-
.joinBackward()
|
|
33
|
-
.run()
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
return editor.commands.joinItemForward()
|
|
37
|
-
}
|
|
@@ -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
|
-
}
|