mirror of
https://github.com/ueberdosis/tiptap.git
synced 2025-06-08 01:53:04 +08:00
feat: add defaultBlockAt helper
This commit is contained in:
parent
fc5757a857
commit
403c147d4d
13
packages/core/src/helpers/defaultBlockAt.ts
Normal file
13
packages/core/src/helpers/defaultBlockAt.ts
Normal 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
|
||||||
|
}
|
@ -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'
|
||||||
|
Loading…
Reference in New Issue
Block a user