PageSourceSearch

https://app.lexmate.ai/assets/@tiptap--extension-horizontal-rule-ddb6856e.js

js lexmate.ai collected 2026-10-05 15:02:18 UTC 2,730 bytes, 86 lines download raw bytes

1// @tiptap/[email protected] downloaded from https://cdn.jsdelivr.net/npm/@tiptap/[email protected]/dist/index.js
2
3// src/horizontal-rule.ts
4import { canInsertNode, isNodeSelection, mergeAttributes, Node, nodeInputRule } from "@tiptap/core";
5import { NodeSelection, TextSelection } from "@tiptap/pm/state";
6var HorizontalRule = Node.create({
7  name: "horizontalRule",
8  addOptions() {
9    return {
10      HTMLAttributes: {},
11      nextNodeType: "paragraph"
12    };
13  },
14  group: "block",
15  parseHTML() {
16    return [{ tag: "hr" }];
17  },
18  renderHTML({ HTMLAttributes }) {
19    return ["hr", mergeAttributes(this.options.HTMLAttributes, HTMLAttributes)];
20  },
21  markdownTokenName: "hr",
22  parseMarkdown: (token, helpers) => {
23    return helpers.createNode("horizontalRule");
24  },
25  renderMarkdown: () => {
26    return "---";
27  },
28  addCommands() {
29    return {
30      setHorizontalRule: () => ({ chain, state }) => {
31        if (!canInsertNode(state, state.schema.nodes[this.name])) {
32          return false;
33        }
34        const { selection } = state;
35        const { $to: $originTo } = selection;
36        const currentChain = chain();
37        if (isNodeSelection(selection)) {
38          currentChain.insertContentAt($originTo.pos, {
39            type: this.name
40          });
41        } else {
42          currentChain.insertContent({ type: this.name });
43        }
44        return currentChain.command(({ state: chainState, tr, dispatch }) => {
45          if (dispatch) {
46            const { $to } = tr.selection;
47            const posAfter = $to.end();
48            if ($to.nodeAfter) {
49              if ($to.nodeAfter.isTextblock) {
50                tr.setSelection(TextSelection.create(tr.doc, $to.pos + 1));
51              } else if ($to.nodeAfter.isBlock) {
52                tr.setSelection(NodeSelection.create(tr.doc, $to.pos));
53              } else {
54                tr.setSelection(TextSelection.create(tr.doc, $to.pos));
55              }
56            } else {
57              const nodeType = chainState.schema.nodes[this.options.nextNodeType] || $to.parent.type.contentMatch.defaultType;
58              const node = nodeType == null ? void 0 : nodeType.create();
59              if (node) {
60                tr.insert(posAfter, node);
61                tr.setSelection(TextSelection.create(tr.doc, posAfter + 1));
62              }
63            }
64            tr.scrollIntoView();
65          }
66          return true;
67        }).run();
68      }
69    };
70  },
71  addInputRules() {
72    return [
73      nodeInputRule({
74        find: /^(?:---|—-|___\s|\*\*\*\s)$/,
75        type: this.type
76      })
77    ];
78  }
79});
80
81// src/index.ts
82var index_default = HorizontalRule;
83export {
84  HorizontalRule,
85  index_default as default
86};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.