{
  "version": 3,
  "sources": ["../src/index.ts", "../src/selection.ts", "../src/helpers.ts", "../src/transforms.ts", "../src/node.ts"],
  "sourcesContent": ["export {\n  findParentNode,\n  findParentNodeClosestToPos,\n  findParentDomRef,\n  hasParentNode,\n  findParentNodeOfType,\n  findParentNodeOfTypeClosestToPos,\n  hasParentNodeOfType,\n  findParentDomRefOfType,\n  findSelectedNodeOfType,\n  findPositionOfNodeBefore,\n  findDomRefAtPos,\n} from './selection';\nexport {\n  flatten,\n  findChildren,\n  findTextNodes,\n  findInlineNodes,\n  findBlockNodes,\n  findChildrenByAttr,\n  findChildrenByType,\n  findChildrenByMark,\n  contains,\n} from './node';\nexport {\n  removeParentNodeOfType,\n  replaceParentNodeOfType,\n  removeSelectedNode,\n  replaceSelectedNode,\n  setTextSelection,\n  safeInsert,\n  setParentNodeMarkup,\n  selectParentNodeOfType,\n  removeNodeBefore,\n} from './transforms';\nexport { isNodeSelection, canInsert } from './helpers';\nexport type {\n  DomAtPos,\n  NodeTypeParam,\n  Predicate,\n  NodeWithPos,\n  ContentNodeWithPos,\n} from './types';\n", "import type { Node as PMNode, ResolvedPos } from 'prosemirror-model';\nimport { Selection } from 'prosemirror-state';\nimport type {\n  FindPredicate,\n  FindResult,\n  DomAtPos,\n  NodeTypeParam,\n} from './types';\nimport { equalNodeType, isNodeSelection } from './helpers';\n\n// Iterates over parent nodes, returning the closest node and its start position `predicate` returns truthy for. `start` points to the start position of the node, `pos` points directly before the node.\n//\n// ```javascript\n// const predicate = node => node.type === schema.nodes.blockquote;\n// const parent = findParentNode(predicate)(selection);\n// ```\nexport const findParentNode =\n  (predicate: FindPredicate) =>\n  (\n    { $from, $to }: Selection,\n    validateSameParent: boolean = false\n  ): FindResult => {\n    // Check if parent are different\n    if (validateSameParent && !$from.sameParent($to)) {\n      // If they are, I need to find a common parent\n      let depth = Math.min($from.depth, $to.depth);\n      while (depth >= 0) {\n        const fromNode = $from.node(depth);\n        const toNode = $to.node(depth);\n        if (toNode === fromNode) {\n          // The have the same parent\n          if (predicate(fromNode)) {\n            // Check the predicate\n            return {\n              // Return the resolved pos\n              pos: depth > 0 ? $from.before(depth) : 0,\n              start: $from.start(depth),\n              depth: depth,\n              node: fromNode,\n            };\n          }\n        }\n        depth = depth - 1; // Keep looking\n      }\n      return;\n    }\n\n    return findParentNodeClosestToPos($from, predicate);\n  };\n\n// Iterates over parent nodes starting from the given `$pos`, returning the closest node and its start position `predicate` returns truthy for. `start` points to the start position of the node, `pos` points directly before the node.\n//\n// ```javascript\n// const predicate = node => node.type === schema.nodes.blockquote;\n// const parent = findParentNodeClosestToPos(state.doc.resolve(5), predicate);\n// ```\nexport const findParentNodeClosestToPos = (\n  $pos: ResolvedPos,\n  predicate: FindPredicate\n): FindResult => {\n  for (let i = $pos.depth; i > 0; i--) {\n    const node = $pos.node(i);\n    if (predicate(node)) {\n      return {\n        pos: i > 0 ? $pos.before(i) : 0,\n        start: $pos.start(i),\n        depth: i,\n        node,\n      };\n    }\n  }\n};\n\n// Iterates over parent nodes, returning DOM reference of the closest node `predicate` returns truthy for.\n//\n// ```javascript\n// const domAtPos = view.domAtPos.bind(view);\n// const predicate = node => node.type === schema.nodes.table;\n// const parent = findParentDomRef(predicate, domAtPos)(selection); // <table>\n// ```\nexport const findParentDomRef =\n  (predicate: FindPredicate, domAtPos: DomAtPos) =>\n  (selection: Selection): Node | undefined => {\n    const parent = findParentNode(predicate)(selection);\n    if (parent) {\n      return findDomRefAtPos(parent.pos, domAtPos);\n    }\n  };\n\n// Checks if there's a parent node `predicate` returns truthy for.\n//\n// ```javascript\n// if (hasParentNode(node => node.type === schema.nodes.table)(selection)) {\n//   // ....\n// }\n// ```\nexport const hasParentNode =\n  (predicate: FindPredicate) =>\n  (selection: Selection): boolean => {\n    return !!findParentNode(predicate)(selection);\n  };\n\n// Iterates over parent nodes, returning closest node of a given `nodeType`. `start` points to the start position of the node, `pos` points directly before the node.\n//\n// ```javascript\n// const parent = findParentNodeOfType(schema.nodes.paragraph)(selection);\n// ```\nexport const findParentNodeOfType =\n  (nodeType: NodeTypeParam) =>\n  (selection: Selection): FindResult => {\n    return findParentNode((node) => equalNodeType(nodeType, node))(selection);\n  };\n\n// Iterates over parent nodes starting from the given `$pos`, returning closest node of a given `nodeType`. `start` points to the start position of the node, `pos` points directly before the node.\n//\n// ```javascript\n// const parent = findParentNodeOfTypeClosestToPos(state.doc.resolve(10), schema.nodes.paragraph);\n// ```\nexport const findParentNodeOfTypeClosestToPos = (\n  $pos: ResolvedPos,\n  nodeType: NodeTypeParam\n): FindResult => {\n  return findParentNodeClosestToPos($pos, (node: PMNode) =>\n    equalNodeType(nodeType, node)\n  );\n};\n\n// Checks if there's a parent node of a given `nodeType`.\n//\n// ```javascript\n// if (hasParentNodeOfType(schema.nodes.table)(selection)) {\n//   // ....\n// }\n// ```\nexport const hasParentNodeOfType =\n  (nodeType: NodeTypeParam) =>\n  (selection: Selection): boolean => {\n    return hasParentNode((node) => equalNodeType(nodeType, node))(selection);\n  };\n\n// Iterates over parent nodes, returning DOM reference of the closest node of a given `nodeType`.\n//\n// ```javascript\n// const domAtPos = view.domAtPos.bind(view);\n// const parent = findParentDomRefOfType(schema.nodes.codeBlock, domAtPos)(selection); // <pre>\n// ```\nexport const findParentDomRefOfType =\n  (nodeType: NodeTypeParam, domAtPos: DomAtPos) =>\n  (selection: Selection): Node | undefined => {\n    return findParentDomRef(\n      (node) => equalNodeType(nodeType, node),\n      domAtPos\n    )(selection);\n  };\n\n// Returns a node of a given `nodeType` if it is selected. `start` points to the start position of the node, `pos` points directly before the node.\n//\n// ```javascript\n// const { extension, inlineExtension, bodiedExtension } = schema.nodes;\n// const selectedNode = findSelectedNodeOfType([\n//   extension,\n//   inlineExtension,\n//   bodiedExtension,\n// ])(selection);\n// ```\nexport const findSelectedNodeOfType =\n  (nodeType: NodeTypeParam) =>\n  (selection: Selection): FindResult => {\n    if (isNodeSelection(selection)) {\n      const { node, $from } = selection;\n      if (equalNodeType(nodeType, node)) {\n        return {\n          node,\n          start: $from.start(),\n          pos: $from.pos,\n          depth: $from.depth,\n        };\n      }\n    }\n  };\n\n// Returns position of the previous node.\n//\n// ```javascript\n// const pos = findPositionOfNodeBefore(tr.selection);\n// ```\nexport const findPositionOfNodeBefore = (\n  selection: Selection\n): number | undefined => {\n  const { nodeBefore } = selection.$from;\n  const maybeSelection = Selection.findFrom(selection.$from, -1);\n  if (maybeSelection && nodeBefore) {\n    // leaf node\n    const parent = findParentNodeOfType(nodeBefore.type)(maybeSelection);\n    if (parent) {\n      return parent.pos;\n    }\n    return maybeSelection.$from.pos;\n  }\n};\n\n// Returns DOM reference of a node at a given `position`. If the node type is of type `TEXT_NODE` it will return the reference of the parent node.\n//\n// ```javascript\n// const domAtPos = view.domAtPos.bind(view);\n// const ref = findDomRefAtPos($from.pos, domAtPos);\n// ```\nexport const findDomRefAtPos = (position: number, domAtPos: DomAtPos): Node => {\n  const dom = domAtPos(position);\n  const node = dom.node.childNodes[dom.offset];\n\n  if (dom.node.nodeType === Node.TEXT_NODE && dom.node.parentNode) {\n    return dom.node.parentNode;\n  }\n\n  if (!node || node.nodeType === Node.TEXT_NODE) {\n    return dom.node;\n  }\n\n  return node;\n};\n", "import { Selection, NodeSelection, type Transaction } from 'prosemirror-state';\nimport { Fragment, Node as PMNode, type ResolvedPos } from 'prosemirror-model';\nimport { setTextSelection } from './transforms';\nimport type { NodeTypeParam, Content } from './types';\n\n// Checks if current selection is a `NodeSelection`.\n//\n// ```javascript\n// if (isNodeSelection(tr.selection)) {\n//   // ...\n// }\n// ```\nexport const isNodeSelection = (\n  selection: Selection\n): selection is NodeSelection => {\n  return selection instanceof NodeSelection;\n};\n\n// Checks if the type a given `node` equals to a given `nodeType`.\nexport const equalNodeType = (\n  nodeType: NodeTypeParam,\n  node: PMNode\n): boolean => {\n  return (\n    (Array.isArray(nodeType) && nodeType.indexOf(node.type) > -1) ||\n    node.type === nodeType\n  );\n};\n\n// Creates a new transaction object from a given transaction\nexport const cloneTr = (tr: Transaction): Transaction => {\n  return Object.assign(Object.create(tr), tr).setTime(Date.now());\n};\n\n// Returns a `replace` transaction that replaces a node at a given position with the given `content`.\n// It will return the original transaction if replacing is not possible.\n// `position` should point at the position immediately before the node.\nexport const replaceNodeAtPos =\n  (position: number, content: Content) =>\n  (tr: Transaction): Transaction => {\n    const node = tr.doc.nodeAt(position);\n    const $pos = tr.doc.resolve(position);\n    if (!node) {\n      return tr;\n    }\n\n    if (canReplace($pos, content)) {\n      tr = tr.replaceWith(position, position + node.nodeSize, content);\n      const start = tr.selection.$from.pos - 1;\n      // put cursor inside of the inserted node\n      tr = setTextSelection(Math.max(start, 0), -1)(tr);\n      // move cursor to the start of the node\n      tr = setTextSelection(tr.selection.$from.start())(tr);\n      return cloneTr(tr);\n    }\n    return tr;\n  };\n\n// Checks if replacing a node at a given `$pos` inside of the `doc` node with the given `content` is possible.\nexport const canReplace = ($pos: ResolvedPos, content: Content): boolean => {\n  const node = $pos.node($pos.depth);\n  return (\n    node &&\n    node.type.validContent(\n      content instanceof Fragment ? content : Fragment.from(content)\n    )\n  );\n};\n\n// Returns a `delete` transaction that removes a node at a given position with the given `node`.\n// `position` should point at the position immediately before the node.\nexport const removeNodeAtPos =\n  (position: number) =>\n  (tr: Transaction): Transaction => {\n    const node = tr.doc.nodeAt(position);\n    if (!node) {\n      return tr;\n    }\n\n    return cloneTr(tr.delete(position, position + node.nodeSize));\n  };\n\n// Checks if a given `content` can be inserted at the given `$pos`\n//\n// ```javascript\n// const { selection: { $from } } = state;\n// const node = state.schema.nodes.atom.createChecked();\n// if (canInsert($from, node)) {\n//   // ...\n// }\n// ```\nexport const canInsert = ($pos: ResolvedPos, content: Content): boolean => {\n  const index = $pos.index();\n\n  if (content instanceof Fragment) {\n    return $pos.parent.canReplace(index, index, content);\n  } else if (content instanceof PMNode) {\n    return $pos.parent.canReplaceWith(index, index, content.type);\n  }\n  return false;\n};\n\n// Checks if a given `node` is an empty paragraph\nexport const isEmptyParagraph = (node: PMNode): boolean => {\n  return !node || (node.type.name === 'paragraph' && node.nodeSize === 2);\n};\n\nexport const checkInvalidMovements = (\n  originIndex: number,\n  targetIndex: number,\n  targets: number[],\n  type: unknown\n): boolean => {\n  const direction = originIndex > targetIndex ? -1 : 1;\n  const errorMessage = `Target position is invalid, you can't move the ${type} ${originIndex} to ${targetIndex}, the target can't be split. You could use tryToFit option.`;\n\n  if (direction === 1) {\n    if (targets.slice(0, targets.length - 1).indexOf(targetIndex) !== -1) {\n      throw new Error(errorMessage);\n    }\n  } else {\n    if (targets.slice(1).indexOf(targetIndex) !== -1) {\n      throw new Error(errorMessage);\n    }\n  }\n\n  return true;\n};\n", "import { NodeSelection, Selection, type Transaction } from 'prosemirror-state';\nimport {\n  Fragment,\n  Node as PMNode,\n  type NodeType,\n  Mark,\n} from 'prosemirror-model';\nimport { findParentNodeOfType, findPositionOfNodeBefore } from './selection';\nimport {\n  cloneTr,\n  isNodeSelection,\n  replaceNodeAtPos,\n  removeNodeAtPos,\n  canInsert,\n  isEmptyParagraph,\n} from './helpers';\nimport type { Attrs, NodeTypeParam, Content } from './types';\n\n// Returns a new transaction that removes a node of a given `nodeType`. It will return an original transaction if parent node hasn't been found.\n//\n// ```javascript\n// dispatch(\n//   removeParentNodeOfType(schema.nodes.table)(tr)\n// );\n// ```\nexport const removeParentNodeOfType =\n  (nodeType: NodeTypeParam) =>\n  (tr: Transaction): Transaction => {\n    const parent = findParentNodeOfType(nodeType)(tr.selection);\n    if (parent) {\n      return removeNodeAtPos(parent.pos)(tr);\n    }\n    return tr;\n  };\n\n// Returns a new transaction that replaces parent node of a given `nodeType` with the given `content`. It will return an original transaction if either parent node hasn't been found or replacing is not possible.\n//\n// ```javascript\n// const node = schema.nodes.paragraph.createChecked({}, schema.text('new'));\n//\n// dispatch(\n//  replaceParentNodeOfType(schema.nodes.table, node)(tr)\n// );\n// ```\nexport const replaceParentNodeOfType =\n  (nodeType: NodeTypeParam, content: Content) =>\n  (tr: Transaction): Transaction => {\n    if (!Array.isArray(nodeType)) {\n      nodeType = [nodeType];\n    }\n    for (let i = 0, count = nodeType.length; i < count; i++) {\n      const parent = findParentNodeOfType(nodeType[i])(tr.selection);\n      if (parent) {\n        const newTr = replaceNodeAtPos(parent.pos, content)(tr);\n        if (newTr !== tr) {\n          return newTr;\n        }\n      }\n    }\n    return tr;\n  };\n\n// Returns a new transaction that removes selected node. It will return an original transaction if current selection is not a `NodeSelection`.\n//\n// ```javascript\n// dispatch(\n//   removeSelectedNode(tr)\n// );\n// ```\nexport const removeSelectedNode = (tr: Transaction): Transaction => {\n  if (isNodeSelection(tr.selection)) {\n    const from = tr.selection.$from.pos;\n    const to = tr.selection.$to.pos;\n    return cloneTr(tr.delete(from, to));\n  }\n  return tr;\n};\n\n// Returns a new transaction that replaces selected node with a given `node`, keeping NodeSelection on the new `node`.\n// It will return the original transaction if either current selection is not a NodeSelection or replacing is not possible.\n//\n// ```javascript\n// const node = schema.nodes.paragraph.createChecked({}, schema.text('new'));\n// dispatch(\n//   replaceSelectedNode(node)(tr)\n// );\n// ```\nexport const replaceSelectedNode =\n  (content: Content) =>\n  (tr: Transaction): Transaction => {\n    if (isNodeSelection(tr.selection)) {\n      const { $from, $to } = tr.selection;\n      if (\n        (content instanceof Fragment &&\n          $from.parent.canReplace(\n            $from.index(),\n            $from.indexAfter(),\n            content\n          )) ||\n        (content instanceof PMNode &&\n          $from.parent.canReplaceWith(\n            $from.index(),\n            $from.indexAfter(),\n            content.type\n          ))\n      ) {\n        return cloneTr(\n          tr\n            .replaceWith($from.pos, $to.pos, content)\n            // restore node selection\n            .setSelection(new NodeSelection(tr.doc.resolve($from.pos)))\n        );\n      }\n    }\n    return tr;\n  };\n\n// Returns a new transaction that tries to find a valid cursor selection starting at the given `position`\n// and searching back if `dir` is negative, and forward if positive.\n// If a valid cursor position hasn't been found, it will return the original transaction.\n//\n// ```javascript\n// dispatch(\n//   setTextSelection(5)(tr)\n// );\n// ```\nexport const setTextSelection =\n  (position: number, dir = 1) =>\n  (tr: Transaction): Transaction => {\n    const nextSelection = Selection.findFrom(\n      tr.doc.resolve(position),\n      dir,\n      true\n    );\n    if (nextSelection) {\n      return tr.setSelection(nextSelection);\n    }\n    return tr;\n  };\n\nconst isSelectableNode = (node: Content): node is PMNode =>\n  Boolean(node instanceof PMNode && node.type && node.type.spec.selectable);\nconst shouldSelectNode = (node: Content): boolean =>\n  isSelectableNode(node) && node.type.isLeaf;\n\nconst setSelection = (\n  node: Content,\n  pos: number,\n  tr: Transaction\n): Transaction => {\n  if (shouldSelectNode(node)) {\n    return tr.setSelection(new NodeSelection(tr.doc.resolve(pos)));\n  }\n  return setTextSelection(pos)(tr);\n};\n\n// Returns a new transaction that inserts a given `content` at the current cursor position, or at a given `position`, if it is allowed by schema. If schema restricts such nesting, it will try to find an appropriate place for a given node in the document, looping through parent nodes up until the root document node.\n// If `tryToReplace` is true and current selection is a NodeSelection, it will replace selected node with inserted content if its allowed by schema.\n// If cursor is inside of an empty paragraph, it will try to replace that paragraph with the given content. If insertion is successful and inserted node has content, it will set cursor inside of that content.\n// It will return an original transaction if the place for insertion hasn't been found.\n//\n// ```javascript\n// const node = schema.nodes.extension.createChecked({});\n// dispatch(\n//   safeInsert(node)(tr)\n// );\n// ```\nexport const safeInsert =\n  (content: Content, position?: number, tryToReplace?: boolean) =>\n  (tr: Transaction): Transaction => {\n    const hasPosition = typeof position === 'number';\n    const { $from } = tr.selection;\n    const $insertPos = hasPosition\n      ? tr.doc.resolve(position)\n      : isNodeSelection(tr.selection)\n      ? tr.doc.resolve($from.pos + 1)\n      : $from;\n    const { parent } = $insertPos;\n\n    // try to replace selected node\n    if (isNodeSelection(tr.selection) && tryToReplace) {\n      const oldTr = tr;\n      tr = replaceSelectedNode(content)(tr);\n      if (oldTr !== tr) {\n        return tr;\n      }\n    }\n\n    // try to replace an empty paragraph\n    if (isEmptyParagraph(parent)) {\n      const oldTr = tr;\n      tr = replaceParentNodeOfType(parent.type, content)(tr);\n      if (oldTr !== tr) {\n        const pos = isSelectableNode(content)\n          ? // for selectable node, selection position would be the position of the replaced parent\n            $insertPos.before($insertPos.depth)\n          : $insertPos.pos;\n        return setSelection(content, pos, tr);\n      }\n    }\n\n    // given node is allowed at the current cursor position\n    if (canInsert($insertPos, content)) {\n      tr.insert($insertPos.pos, content);\n      const pos = hasPosition\n        ? $insertPos.pos\n        : isSelectableNode(content)\n        ? // for atom nodes selection position after insertion is the previous pos\n          tr.selection.$anchor.pos - 1\n        : tr.selection.$anchor.pos;\n      return cloneTr(setSelection(content, pos, tr));\n    }\n\n    // looking for a place in the doc where the node is allowed\n    for (let i = $insertPos.depth; i > 0; i--) {\n      const pos = $insertPos.after(i);\n      const $pos = tr.doc.resolve(pos);\n      if (canInsert($pos, content)) {\n        tr.insert(pos, content);\n        return cloneTr(setSelection(content, pos, tr));\n      }\n    }\n    return tr;\n  };\n\n// Returns a transaction that changes the type, attributes, and/or marks of the parent node of a given `nodeType`.\n//\n// ```javascript\n// const node = schema.nodes.extension.createChecked({});\n// dispatch(\n//   setParentNodeMarkup(schema.nodes.panel, null, { panelType })(tr);\n// );\n// ```\nexport const setParentNodeMarkup =\n  (\n    nodeType: NodeTypeParam,\n    type: NodeType | null,\n    attrs?: Attrs | null,\n    marks?: Array<Mark> | ReadonlyArray<Mark>\n  ) =>\n  (tr: Transaction): Transaction => {\n    const parent = findParentNodeOfType(nodeType)(tr.selection);\n    if (parent) {\n      return cloneTr(\n        tr.setNodeMarkup(\n          parent.pos,\n          type,\n          Object.assign({}, parent.node.attrs, attrs),\n          marks\n        )\n      );\n    }\n    return tr;\n  };\n\n// Returns a new transaction that sets a `NodeSelection` on a parent node of a `given nodeType`.\n//\n// ```javascript\n// dispatch(\n//   selectParentNodeOfType([tableCell, tableHeader])(state.tr)\n// );\n// ```\nexport const selectParentNodeOfType =\n  (nodeType: NodeTypeParam) =>\n  (tr: Transaction): Transaction => {\n    if (!isNodeSelection(tr.selection)) {\n      const parent = findParentNodeOfType(nodeType)(tr.selection);\n      if (parent) {\n        return cloneTr(\n          tr.setSelection(NodeSelection.create(tr.doc, parent.pos))\n        );\n      }\n    }\n    return tr;\n  };\n\n// Returns a new transaction that deletes previous node.\n//\n// ```javascript\n// dispatch(\n//   removeNodeBefore(state.tr)\n// );\n// ```\nexport const removeNodeBefore = (tr: Transaction): Transaction => {\n  const position = findPositionOfNodeBefore(tr.selection);\n  if (typeof position === 'number') {\n    return removeNodeAtPos(position)(tr);\n  }\n  return tr;\n};\n", "import { type Node as PMNode, MarkType, NodeType } from 'prosemirror-model';\nimport type { Attrs } from './types';\n\ntype FindChildrenAttrsPredicate = (attrs: Attrs) => boolean;\ntype FindNodesResult = Array<{ node: PMNode; pos: number }>;\ntype FindChildrenPredicate = (node: PMNode) => boolean;\n\n// Flattens descendants of a given `node`. It doesn't descend into a node when descend argument is `false` (defaults to `true`).\n//\n// ```javascript\n// const children = flatten(node);\n// ```\nexport const flatten = (\n  node: PMNode,\n  descend: boolean = true\n): FindNodesResult => {\n  if (!node) {\n    throw new Error('Invalid \"node\" parameter');\n  }\n  const result: FindNodesResult = [];\n  node.descendants((child, pos) => {\n    result.push({ node: child, pos });\n    if (!descend) {\n      return false;\n    }\n  });\n  return result;\n};\n\n// Iterates over descendants of a given `node`, returning child nodes predicate returns truthy for. It doesn't descend into a node when descend argument is `false` (defaults to `true`).\n//\n// ```javascript\n// const textNodes = findChildren(node, child => child.isText, false);\n// ```\nexport const findChildren = (\n  node: PMNode,\n  predicate: FindChildrenPredicate,\n  descend: boolean = true\n): FindNodesResult => {\n  if (!node) {\n    throw new Error('Invalid \"node\" parameter');\n  } else if (!predicate) {\n    throw new Error('Invalid \"predicate\" parameter');\n  }\n  return flatten(node, descend).filter((child) => predicate(child.node));\n};\n\n// Returns text nodes of a given `node`. It doesn't descend into a node when descend argument is `false` (defaults to `true`).\n//\n// ```javascript\n// const textNodes = findTextNodes(node);\n// ```\nexport const findTextNodes = (\n  node: PMNode,\n  descend: boolean = true\n): FindNodesResult => {\n  return findChildren(node, (child) => child.isText, descend);\n};\n\n// Returns inline nodes of a given `node`. It doesn't descend into a node when descend argument is `false` (defaults to `true`).\n//\n// ```javascript\n// const inlineNodes = findInlineNodes(node);\n// ```\nexport const findInlineNodes = (\n  node: PMNode,\n  descend: boolean = true\n): FindNodesResult => {\n  return findChildren(node, (child) => child.isInline, descend);\n};\n\n// Returns block descendants of a given `node`. It doesn't descend into a node when descend argument is `false` (defaults to `true`).\n//\n// ```javascript\n// const blockNodes = findBlockNodes(node);\n// ```\nexport const findBlockNodes = (\n  node: PMNode,\n  descend: boolean = true\n): FindNodesResult => {\n  return findChildren(node, (child) => child.isBlock, descend);\n};\n\n// Iterates over descendants of a given `node`, returning child nodes predicate returns truthy for. It doesn't descend into a node when descend argument is `false` (defaults to `true`).\n//\n// ```javascript\n// const mergedCells = findChildrenByAttr(table, attrs => attrs.colspan === 2);\n// ```\nexport const findChildrenByAttr = (\n  node: PMNode,\n  predicate: FindChildrenAttrsPredicate,\n  descend: boolean = true\n): FindNodesResult => {\n  return findChildren(node, (child) => !!predicate(child.attrs), descend);\n};\n\n// Iterates over descendants of a given `node`, returning child nodes of a given nodeType. It doesn't descend into a node when descend argument is `false` (defaults to `true`).\n//\n// ```javascript\n// const cells = findChildrenByType(table, schema.nodes.tableCell);\n// ```\nexport const findChildrenByType = (\n  node: PMNode,\n  nodeType: NodeType,\n  descend: boolean = true\n): FindNodesResult => {\n  return findChildren(node, (child) => child.type === nodeType, descend);\n};\n\n// Iterates over descendants of a given `node`, returning child nodes that have a mark of a given markType. It doesn't descend into a `node` when descend argument is `false` (defaults to `true`).\n//\n// ```javascript\n// const nodes = findChildrenByMark(state.doc, schema.marks.strong);\n// ```\nexport const findChildrenByMark = (\n  node: PMNode,\n  markType: MarkType,\n  descend: boolean = true\n): FindNodesResult => {\n  return findChildren(\n    node,\n    (child) => Boolean(markType.isInSet(child.marks)),\n    descend\n  );\n};\n\n// Returns `true` if a given node contains nodes of a given `nodeType`\n//\n// ```javascript\n// if (contains(panel, schema.nodes.listItem)) {\n//   // ...\n// }\n// ```\nexport const contains = (node: PMNode, nodeType: NodeType): boolean => {\n  return !!findChildrenByType(node, nodeType).length;\n};\n"],
  "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACCA,IAAAA,4BAA0B;;;ACD1B,IAAAC,4BAA2D;AAC3D,IAAAC,4BAA2D;;;ACD3D,+BAA2D;AAC3D,+BAKO;AAmBA,IAAM,yBACX,CAAC,aACD,CAAC,OAAiC;AAChC,QAAM,SAAS,qBAAqB,QAAQ,EAAE,GAAG,SAAS;AAC1D,MAAI,QAAQ;AACV,WAAO,gBAAgB,OAAO,GAAG,EAAE,EAAE;AAAA,EACvC;AACA,SAAO;AACT;AAWK,IAAM,0BACX,CAAC,UAAyB,YAC1B,CAAC,OAAiC;AAChC,MAAI,CAAC,MAAM,QAAQ,QAAQ,GAAG;AAC5B,eAAW,CAAC,QAAQ;AAAA,EACtB;AACA,WAAS,IAAI,GAAG,QAAQ,SAAS,QAAQ,IAAI,OAAO,KAAK;AACvD,UAAM,SAAS,qBAAqB,SAAS,CAAC,CAAC,EAAE,GAAG,SAAS;AAC7D,QAAI,QAAQ;AACV,YAAM,QAAQ,iBAAiB,OAAO,KAAK,OAAO,EAAE,EAAE;AACtD,UAAI,UAAU,IAAI;AAChB,eAAO;AAAA,MACT;AAAA,IACF;AAAA,EACF;AACA,SAAO;AACT;AASK,IAAM,qBAAqB,CAAC,OAAiC;AAClE,MAAI,gBAAgB,GAAG,SAAS,GAAG;AACjC,UAAM,OAAO,GAAG,UAAU,MAAM;AAChC,UAAM,KAAK,GAAG,UAAU,IAAI;AAC5B,WAAO,QAAQ,G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,CAAC;AAAA,IAChD;AAAA,EACF;AACF;AASO,IAAM,WAAW,CAAC,MAAc,aAAgC;AACrE,SAAO,CAAC,CAAC,mBAAmB,MAAM,QAAQ,EAAE;AAC9C;",
  "names": ["import_prosemirror_state", "import_prosemirror_state", "import_prosemirror_model", "PMNode", "PMNode"]
}
