PageSourceSearch

https://app.lexmate.ai/assets/@tiptap--extension-code-f06b3837.js

js lexmate.ai collected 2026-10-05 15:02:13 UTC 2,450 bytes, 108 lines download raw bytes

1// @tiptap/[email protected] downloaded from https://cdn.jsdelivr.net/npm/@tiptap/[email protected]/dist/index.js
2
3// src/code.ts
4import { Mark, markInputRule, markPasteRule, mergeAttributes } from "@tiptap/core";
5var inputRegex = /(^|[^`])`([^`]+)`(?!`)$/;
6var pasteRegex = /(^|[^`])`([^`]+)`(?!`)/g;
7var inputRegexMatch = (text) => {
8  const match = /`([^`]+)`(?!`)$/.exec(text);
9  if (!match) {
10    return null;
11  }
12  if (match.index > 0 && text[match.index - 1] === "`") {
13    return null;
14  }
15  return {
16    index: match.index,
17    text: match[0],
18    replaceWith: match[1]
19  };
20};
21var pasteRegexMatch = (text) => {
22  const regex = /`([^`]+)`(?!`)/g;
23  const matches = [];
24  let match;
25  while ((match = regex.exec(text)) !== null) {
26    if (match.index > 0 && text[match.index - 1] === "`") {
27      continue;
28    }
29    matches.push({
30      index: match.index,
31      text: match[0],
32      replaceWith: match[1]
33    });
34  }
35  return matches;
36};
37var Code = Mark.create({
38  name: "code",
39  addOptions() {
40    return {
41      HTMLAttributes: {}
42    };
43  },
44  excludes: "_",
45  code: true,
46  exitable: true,
47  parseHTML() {
48    return [{ tag: "code" }];
49  },
50  renderHTML({ HTMLAttributes }) {
51    return ["code", mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), 0];
52  },
53  markdownTokenName: "codespan",
54  parseMarkdown: (token, helpers) => {
55    return helpers.applyMark("code", [{ type: "text", text: token.text || "" }]);
56  },
57  renderMarkdown: (node, h) => {
58    if (!node.content) {
59      return "";
60    }
61    return `\`${h.renderChildren(node.content)}\``;
62  },
63  addCommands() {
64    return {
65      setCode: () => ({ commands }) => {
66        return commands.setMark(this.name);
67      },
68      toggleCode: () => ({ commands }) => {
69        return commands.toggleMark(this.name);
70      },
71      unsetCode: () => ({ commands }) => {
72        return commands.unsetMark(this.name);
73      }
74    };
75  },
76  addKeyboardShortcuts() {
77    return {
78      "Mod-e": () => this.editor.commands.toggleCode()
79    };
80  },
81  addInputRules() {
82    return [
83      markInputRule({
84        find: inputRegexMatch,
85        type: this.type
86      })
87    ];
88  },
89  addPasteRules() {
90    return [
91      markPasteRule({
92        find: pasteRegexMatch,
93        type: this.type
94      })
95    ];
96  }
97});
98
99// src/index.ts
100var index_default = Code;
101export {
102  Code,
103  index_default as default,
104  inputRegex,
105  inputRegexMatch,
106  pasteRegex,
107  pasteRegexMatch
108};

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.