function removeMarkFromNodes(nodes, markType) {
    return nodes.map(node => {
      const newNode = { ...node };
      switch (node.type) {
        case 'link': {
          const updatedNodes = removeMarkFromNodes(node.children, markType);
          return {
            ...node,
            children: updatedNodes,
          };
        }

        case 'image':
        case 'break': {
          const data = omit(node.data, 'marks');
          return { ...node, data };
        }

        default:
          delete newNode[markType];
          newNode.marks = newNode.marks
            ? newNode.marks.filter(({ type }) => type !== markType)
            : [];

          if (newNode.marks.length === 0) {
            delete newNode.marks;
          }
          return newNode;
      }
    });
  }
Combine adjacent text and inline nodes before processing so they can
share marks.