🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.
TypeScript agentagent-collaborationagent-harnessloop-engineeringmcppersonal-assistantproactive-agentskillssuper-agenttask-management
import { $getNodeByKey, $isRootOrShadowRoot, type LexicalEditor, type NodeKey } from 'lexical';
export const getSectionTitle = (editor: LexicalEditor, nodeKey: NodeKey): string | undefined =>
editor.getEditorState().read(() => {
const node = $getNodeByKey(nodeKey);
if (!node || $isRootOrShadowRoot(node)) return undefined;
let block = node.getTopLevelElement();
while (block) {
if (block.getType() === 'heading') return block.getTextContent().trim() || undefined;
block = block.getPreviousSibling();
}
return undefined;
});