feat: add defaultBlockAt helper

This commit is contained in:
Philipp Kühn 2021-11-23 14:32:54 +01:00
parent fc5757a857
commit 403c147d4d
2 changed files with 14 additions and 0 deletions

View File

@ -0,0 +1,13 @@
import { ContentMatch, NodeType } from 'prosemirror-model'
export default function defaultBlockAt(match: ContentMatch): NodeType | null {
for (let i = 0; i < match.edgeCount; i += 1) {
const { type } = match.edge(i)
if (type.isTextblock && !type.hasRequiredAttrs()) {
return type
}
}
return null
}

View File

@ -23,6 +23,7 @@ export { default as textPasteRule } from './pasteRules/textPasteRule'
export { default as callOrReturn } from './utilities/callOrReturn' export { default as callOrReturn } from './utilities/callOrReturn'
export { default as mergeAttributes } from './utilities/mergeAttributes' export { default as mergeAttributes } from './utilities/mergeAttributes'
export { default as defaultBlockAt } from './helpers/defaultBlockAt'
export { default as getExtensionField } from './helpers/getExtensionField' export { default as getExtensionField } from './helpers/getExtensionField'
export { default as findChildren } from './helpers/findChildren' export { default as findChildren } from './helpers/findChildren'
export { default as findChildrenInRange } from './helpers/findChildrenInRange' export { default as findChildrenInRange } from './helpers/findChildrenInRange'