fix: resolve TypeScript errors in frontend build

This commit is contained in:
Hiro
2026-03-30 23:16:07 +00:00
parent b733306773
commit 24925e1acb
2941 changed files with 418042 additions and 49 deletions

21
node_modules/@tiptap/extension-code/LICENSE.md generated vendored Normal file
View File

@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2025, Tiptap GmbH
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

18
node_modules/@tiptap/extension-code/README.md generated vendored Normal file
View File

@@ -0,0 +1,18 @@
# @tiptap/extension-code
[![Version](https://img.shields.io/npm/v/@tiptap/extension-code.svg?label=version)](https://www.npmjs.com/package/@tiptap/extension-code)
[![Downloads](https://img.shields.io/npm/dm/@tiptap/extension-code.svg)](https://npmcharts.com/compare/tiptap?minimal=true)
[![License](https://img.shields.io/npm/l/@tiptap/extension-code.svg)](https://www.npmjs.com/package/@tiptap/extension-code)
[![Sponsor](https://img.shields.io/static/v1?label=Sponsor&message=%E2%9D%A4&logo=GitHub)](https://github.com/sponsors/ueberdosis)
## Introduction
Tiptap is a headless wrapper around [ProseMirror](https://ProseMirror.net) a toolkit for building rich text WYSIWYG editors, which is already in use at many well-known companies such as _New York Times_, _The Guardian_ or _Atlassian_.
## Official Documentation
Documentation can be found on the [Tiptap website](https://tiptap.dev).
## License
Tiptap is open sourced software licensed under the [MIT license](https://github.com/ueberdosis/tiptap/blob/main/LICENSE.md).

104
node_modules/@tiptap/extension-code/dist/index.cjs generated vendored Normal file
View File

@@ -0,0 +1,104 @@
"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
// src/index.ts
var index_exports = {};
__export(index_exports, {
Code: () => Code,
default: () => index_default,
inputRegex: () => inputRegex,
pasteRegex: () => pasteRegex
});
module.exports = __toCommonJS(index_exports);
// src/code.ts
var import_core = require("@tiptap/core");
var inputRegex = /(^|[^`])`([^`]+)`(?!`)$/;
var pasteRegex = /(^|[^`])`([^`]+)`(?!`)/g;
var Code = import_core.Mark.create({
name: "code",
addOptions() {
return {
HTMLAttributes: {}
};
},
excludes: "_",
code: true,
exitable: true,
parseHTML() {
return [{ tag: "code" }];
},
renderHTML({ HTMLAttributes }) {
return ["code", (0, import_core.mergeAttributes)(this.options.HTMLAttributes, HTMLAttributes), 0];
},
markdownTokenName: "codespan",
parseMarkdown: (token, helpers) => {
return helpers.applyMark("code", [{ type: "text", text: token.text || "" }]);
},
renderMarkdown: (node, h) => {
if (!node.content) {
return "";
}
return `\`${h.renderChildren(node.content)}\``;
},
addCommands() {
return {
setCode: () => ({ commands }) => {
return commands.setMark(this.name);
},
toggleCode: () => ({ commands }) => {
return commands.toggleMark(this.name);
},
unsetCode: () => ({ commands }) => {
return commands.unsetMark(this.name);
}
};
},
addKeyboardShortcuts() {
return {
"Mod-e": () => this.editor.commands.toggleCode()
};
},
addInputRules() {
return [
(0, import_core.markInputRule)({
find: inputRegex,
type: this.type
})
];
},
addPasteRules() {
return [
(0, import_core.markPasteRule)({
find: pasteRegex,
type: this.type
})
];
}
});
// src/index.ts
var index_default = Code;
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
Code,
inputRegex,
pasteRegex
});
//# sourceMappingURL=index.cjs.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../src/index.ts","../src/code.ts"],"sourcesContent":["import { Code } from './code.js'\n\nexport * from './code.js'\n\nexport default Code\n","import { Mark, markInputRule, markPasteRule, mergeAttributes } from '@tiptap/core'\n\nexport interface CodeOptions {\n /**\n * The HTML attributes applied to the code element.\n * @default {}\n * @example { class: 'foo' }\n */\n HTMLAttributes: Record<string, any>\n}\n\ndeclare module '@tiptap/core' {\n interface Commands<ReturnType> {\n code: {\n /**\n * Set a code mark\n */\n setCode: () => ReturnType\n /**\n * Toggle inline code\n */\n toggleCode: () => ReturnType\n /**\n * Unset a code mark\n */\n unsetCode: () => ReturnType\n }\n }\n}\n\n/**\n * Regular expressions to match inline code blocks enclosed in backticks.\n * It matches:\n * - An opening backtick, followed by\n * - Any text that doesn't include a backtick (captured for marking), followed by\n * - A closing backtick as the final character.\n * This ensures that any text between backticks is formatted as code,\n * regardless of the surrounding characters (exception being another backtick).\n */\nexport const inputRegex = /(^|[^`])`([^`]+)`(?!`)$/\n\n/**\n * Matches inline code while pasting.\n */\nexport const pasteRegex = /(^|[^`])`([^`]+)`(?!`)/g\n\n/**\n * This extension allows you to mark text as inline code.\n * @see https://tiptap.dev/api/marks/code\n */\nexport const Code = Mark.create<CodeOptions>({\n name: 'code',\n\n addOptions() {\n return {\n HTMLAttributes: {},\n }\n },\n\n excludes: '_',\n\n code: true,\n\n exitable: true,\n\n parseHTML() {\n return [{ tag: 'code' }]\n },\n\n renderHTML({ HTMLAttributes }) {\n return ['code', mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), 0]\n },\n\n markdownTokenName: 'codespan',\n\n parseMarkdown: (token, helpers) => {\n // Convert 'codespan' token to code mark\n // For codespan tokens, we use the raw text content, not tokens\n return helpers.applyMark('code', [{ type: 'text', text: token.text || '' }])\n },\n\n renderMarkdown: (node, h) => {\n if (!node.content) {\n return ''\n }\n\n return `\\`${h.renderChildren(node.content)}\\``\n },\n\n addCommands() {\n return {\n setCode:\n () =>\n ({ commands }) => {\n return commands.setMark(this.name)\n },\n toggleCode:\n () =>\n ({ commands }) => {\n return commands.toggleMark(this.name)\n },\n unsetCode:\n () =>\n ({ commands }) => {\n return commands.unsetMark(this.name)\n },\n }\n },\n\n addKeyboardShortcuts() {\n return {\n 'Mod-e': () => this.editor.commands.toggleCode(),\n }\n },\n\n addInputRules() {\n return [\n markInputRule({\n find: inputRegex,\n type: this.type,\n }),\n ]\n },\n\n addPasteRules() {\n return [\n markPasteRule({\n find: pasteRegex,\n type: this.type,\n }),\n ]\n },\n})\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,kBAAoE;AAuC7D,IAAM,aAAa;AAKnB,IAAM,aAAa;AAMnB,IAAM,OAAO,iBAAK,OAAoB;AAAA,EAC3C,MAAM;AAAA,EAEN,aAAa;AACX,WAAO;AAAA,MACL,gBAAgB,CAAC;AAAA,IACnB;AAAA,EACF;AAAA,EAEA,UAAU;AAAA,EAEV,MAAM;AAAA,EAEN,UAAU;AAAA,EAEV,YAAY;AACV,WAAO,CAAC,EAAE,KAAK,OAAO,CAAC;AAAA,EACzB;AAAA,EAEA,WAAW,EAAE,eAAe,GAAG;AAC7B,WAAO,CAAC,YAAQ,6BAAgB,KAAK,QAAQ,gBAAgB,cAAc,GAAG,CAAC;AAAA,EACjF;AAAA,EAEA,mBAAmB;AAAA,EAEnB,eAAe,CAAC,OAAO,YAAY;AAGjC,WAAO,QAAQ,UAAU,QAAQ,CAAC,EAAE,MAAM,QAAQ,MAAM,MAAM,QAAQ,GAAG,CAAC,CAAC;AAAA,EAC7E;AAAA,EAEA,gBAAgB,CAAC,MAAM,MAAM;AAC3B,QAAI,CAAC,KAAK,SAAS;AACjB,aAAO;AAAA,IACT;AAEA,WAAO,KAAK,EAAE,eAAe,KAAK,OAAO,CAAC;AAAA,EAC5C;AAAA,EAEA,cAAc;AACZ,WAAO;AAAA,MACL,SACE,MACA,CAAC,EAAE,SAAS,MAAM;AAChB,eAAO,SAAS,QAAQ,KAAK,IAAI;AAAA,MACnC;AAAA,MACF,YACE,MACA,CAAC,EAAE,SAAS,MAAM;AAChB,eAAO,SAAS,WAAW,KAAK,IAAI;AAAA,MACtC;AAAA,MACF,WACE,MACA,CAAC,EAAE,SAAS,MAAM;AAChB,eAAO,SAAS,UAAU,KAAK,IAAI;AAAA,MACrC;AAAA,IACJ;AAAA,EACF;AAAA,EAEA,uBAAuB;AACrB,WAAO;AAAA,MACL,SAAS,MAAM,KAAK,OAAO,SAAS,WAAW;AAAA,IACjD;AAAA,EACF;AAAA,EAEA,gBAAgB;AACd,WAAO;AAAA,UACL,2BAAc;AAAA,QACZ,MAAM;AAAA,QACN,MAAM,KAAK;AAAA,MACb,CAAC;AAAA,IACH;AAAA,EACF;AAAA,EAEA,gBAAgB;AACd,WAAO;AAAA,UACL,2BAAc;AAAA,QACZ,MAAM;AAAA,QACN,MAAM,KAAK;AAAA,MACb,CAAC;AAAA,IACH;AAAA,EACF;AACF,CAAC;;;ADhID,IAAO,gBAAQ;","names":[]}

49
node_modules/@tiptap/extension-code/dist/index.d.cts generated vendored Normal file
View File

@@ -0,0 +1,49 @@
import { Mark } from '@tiptap/core';
interface CodeOptions {
/**
* The HTML attributes applied to the code element.
* @default {}
* @example { class: 'foo' }
*/
HTMLAttributes: Record<string, any>;
}
declare module '@tiptap/core' {
interface Commands<ReturnType> {
code: {
/**
* Set a code mark
*/
setCode: () => ReturnType;
/**
* Toggle inline code
*/
toggleCode: () => ReturnType;
/**
* Unset a code mark
*/
unsetCode: () => ReturnType;
};
}
}
/**
* Regular expressions to match inline code blocks enclosed in backticks.
* It matches:
* - An opening backtick, followed by
* - Any text that doesn't include a backtick (captured for marking), followed by
* - A closing backtick as the final character.
* This ensures that any text between backticks is formatted as code,
* regardless of the surrounding characters (exception being another backtick).
*/
declare const inputRegex: RegExp;
/**
* Matches inline code while pasting.
*/
declare const pasteRegex: RegExp;
/**
* This extension allows you to mark text as inline code.
* @see https://tiptap.dev/api/marks/code
*/
declare const Code: Mark<CodeOptions, any>;
export { Code, type CodeOptions, Code as default, inputRegex, pasteRegex };

49
node_modules/@tiptap/extension-code/dist/index.d.ts generated vendored Normal file
View File

@@ -0,0 +1,49 @@
import { Mark } from '@tiptap/core';
interface CodeOptions {
/**
* The HTML attributes applied to the code element.
* @default {}
* @example { class: 'foo' }
*/
HTMLAttributes: Record<string, any>;
}
declare module '@tiptap/core' {
interface Commands<ReturnType> {
code: {
/**
* Set a code mark
*/
setCode: () => ReturnType;
/**
* Toggle inline code
*/
toggleCode: () => ReturnType;
/**
* Unset a code mark
*/
unsetCode: () => ReturnType;
};
}
}
/**
* Regular expressions to match inline code blocks enclosed in backticks.
* It matches:
* - An opening backtick, followed by
* - Any text that doesn't include a backtick (captured for marking), followed by
* - A closing backtick as the final character.
* This ensures that any text between backticks is formatted as code,
* regardless of the surrounding characters (exception being another backtick).
*/
declare const inputRegex: RegExp;
/**
* Matches inline code while pasting.
*/
declare const pasteRegex: RegExp;
/**
* This extension allows you to mark text as inline code.
* @see https://tiptap.dev/api/marks/code
*/
declare const Code: Mark<CodeOptions, any>;
export { Code, type CodeOptions, Code as default, inputRegex, pasteRegex };

75
node_modules/@tiptap/extension-code/dist/index.js generated vendored Normal file
View File

@@ -0,0 +1,75 @@
// src/code.ts
import { Mark, markInputRule, markPasteRule, mergeAttributes } from "@tiptap/core";
var inputRegex = /(^|[^`])`([^`]+)`(?!`)$/;
var pasteRegex = /(^|[^`])`([^`]+)`(?!`)/g;
var Code = Mark.create({
name: "code",
addOptions() {
return {
HTMLAttributes: {}
};
},
excludes: "_",
code: true,
exitable: true,
parseHTML() {
return [{ tag: "code" }];
},
renderHTML({ HTMLAttributes }) {
return ["code", mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), 0];
},
markdownTokenName: "codespan",
parseMarkdown: (token, helpers) => {
return helpers.applyMark("code", [{ type: "text", text: token.text || "" }]);
},
renderMarkdown: (node, h) => {
if (!node.content) {
return "";
}
return `\`${h.renderChildren(node.content)}\``;
},
addCommands() {
return {
setCode: () => ({ commands }) => {
return commands.setMark(this.name);
},
toggleCode: () => ({ commands }) => {
return commands.toggleMark(this.name);
},
unsetCode: () => ({ commands }) => {
return commands.unsetMark(this.name);
}
};
},
addKeyboardShortcuts() {
return {
"Mod-e": () => this.editor.commands.toggleCode()
};
},
addInputRules() {
return [
markInputRule({
find: inputRegex,
type: this.type
})
];
},
addPasteRules() {
return [
markPasteRule({
find: pasteRegex,
type: this.type
})
];
}
});
// src/index.ts
var index_default = Code;
export {
Code,
index_default as default,
inputRegex,
pasteRegex
};
//# sourceMappingURL=index.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../src/code.ts","../src/index.ts"],"sourcesContent":["import { Mark, markInputRule, markPasteRule, mergeAttributes } from '@tiptap/core'\n\nexport interface CodeOptions {\n /**\n * The HTML attributes applied to the code element.\n * @default {}\n * @example { class: 'foo' }\n */\n HTMLAttributes: Record<string, any>\n}\n\ndeclare module '@tiptap/core' {\n interface Commands<ReturnType> {\n code: {\n /**\n * Set a code mark\n */\n setCode: () => ReturnType\n /**\n * Toggle inline code\n */\n toggleCode: () => ReturnType\n /**\n * Unset a code mark\n */\n unsetCode: () => ReturnType\n }\n }\n}\n\n/**\n * Regular expressions to match inline code blocks enclosed in backticks.\n * It matches:\n * - An opening backtick, followed by\n * - Any text that doesn't include a backtick (captured for marking), followed by\n * - A closing backtick as the final character.\n * This ensures that any text between backticks is formatted as code,\n * regardless of the surrounding characters (exception being another backtick).\n */\nexport const inputRegex = /(^|[^`])`([^`]+)`(?!`)$/\n\n/**\n * Matches inline code while pasting.\n */\nexport const pasteRegex = /(^|[^`])`([^`]+)`(?!`)/g\n\n/**\n * This extension allows you to mark text as inline code.\n * @see https://tiptap.dev/api/marks/code\n */\nexport const Code = Mark.create<CodeOptions>({\n name: 'code',\n\n addOptions() {\n return {\n HTMLAttributes: {},\n }\n },\n\n excludes: '_',\n\n code: true,\n\n exitable: true,\n\n parseHTML() {\n return [{ tag: 'code' }]\n },\n\n renderHTML({ HTMLAttributes }) {\n return ['code', mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), 0]\n },\n\n markdownTokenName: 'codespan',\n\n parseMarkdown: (token, helpers) => {\n // Convert 'codespan' token to code mark\n // For codespan tokens, we use the raw text content, not tokens\n return helpers.applyMark('code', [{ type: 'text', text: token.text || '' }])\n },\n\n renderMarkdown: (node, h) => {\n if (!node.content) {\n return ''\n }\n\n return `\\`${h.renderChildren(node.content)}\\``\n },\n\n addCommands() {\n return {\n setCode:\n () =>\n ({ commands }) => {\n return commands.setMark(this.name)\n },\n toggleCode:\n () =>\n ({ commands }) => {\n return commands.toggleMark(this.name)\n },\n unsetCode:\n () =>\n ({ commands }) => {\n return commands.unsetMark(this.name)\n },\n }\n },\n\n addKeyboardShortcuts() {\n return {\n 'Mod-e': () => this.editor.commands.toggleCode(),\n }\n },\n\n addInputRules() {\n return [\n markInputRule({\n find: inputRegex,\n type: this.type,\n }),\n ]\n },\n\n addPasteRules() {\n return [\n markPasteRule({\n find: pasteRegex,\n type: this.type,\n }),\n ]\n },\n})\n","import { Code } from './code.js'\n\nexport * from './code.js'\n\nexport default Code\n"],"mappings":";AAAA,SAAS,MAAM,eAAe,eAAe,uBAAuB;AAuC7D,IAAM,aAAa;AAKnB,IAAM,aAAa;AAMnB,IAAM,OAAO,KAAK,OAAoB;AAAA,EAC3C,MAAM;AAAA,EAEN,aAAa;AACX,WAAO;AAAA,MACL,gBAAgB,CAAC;AAAA,IACnB;AAAA,EACF;AAAA,EAEA,UAAU;AAAA,EAEV,MAAM;AAAA,EAEN,UAAU;AAAA,EAEV,YAAY;AACV,WAAO,CAAC,EAAE,KAAK,OAAO,CAAC;AAAA,EACzB;AAAA,EAEA,WAAW,EAAE,eAAe,GAAG;AAC7B,WAAO,CAAC,QAAQ,gBAAgB,KAAK,QAAQ,gBAAgB,cAAc,GAAG,CAAC;AAAA,EACjF;AAAA,EAEA,mBAAmB;AAAA,EAEnB,eAAe,CAAC,OAAO,YAAY;AAGjC,WAAO,QAAQ,UAAU,QAAQ,CAAC,EAAE,MAAM,QAAQ,MAAM,MAAM,QAAQ,GAAG,CAAC,CAAC;AAAA,EAC7E;AAAA,EAEA,gBAAgB,CAAC,MAAM,MAAM;AAC3B,QAAI,CAAC,KAAK,SAAS;AACjB,aAAO;AAAA,IACT;AAEA,WAAO,KAAK,EAAE,eAAe,KAAK,OAAO,CAAC;AAAA,EAC5C;AAAA,EAEA,cAAc;AACZ,WAAO;AAAA,MACL,SACE,MACA,CAAC,EAAE,SAAS,MAAM;AAChB,eAAO,SAAS,QAAQ,KAAK,IAAI;AAAA,MACnC;AAAA,MACF,YACE,MACA,CAAC,EAAE,SAAS,MAAM;AAChB,eAAO,SAAS,WAAW,KAAK,IAAI;AAAA,MACtC;AAAA,MACF,WACE,MACA,CAAC,EAAE,SAAS,MAAM;AAChB,eAAO,SAAS,UAAU,KAAK,IAAI;AAAA,MACrC;AAAA,IACJ;AAAA,EACF;AAAA,EAEA,uBAAuB;AACrB,WAAO;AAAA,MACL,SAAS,MAAM,KAAK,OAAO,SAAS,WAAW;AAAA,IACjD;AAAA,EACF;AAAA,EAEA,gBAAgB;AACd,WAAO;AAAA,MACL,cAAc;AAAA,QACZ,MAAM;AAAA,QACN,MAAM,KAAK;AAAA,MACb,CAAC;AAAA,IACH;AAAA,EACF;AAAA,EAEA,gBAAgB;AACd,WAAO;AAAA,MACL,cAAc;AAAA,QACZ,MAAM;AAAA,QACN,MAAM,KAAK;AAAA,MACb,CAAC;AAAA,IACH;AAAA,EACF;AACF,CAAC;;;AChID,IAAO,gBAAQ;","names":[]}

48
node_modules/@tiptap/extension-code/package.json generated vendored Normal file
View File

@@ -0,0 +1,48 @@
{
"name": "@tiptap/extension-code",
"description": "code extension for tiptap",
"version": "3.21.0",
"homepage": "https://tiptap.dev",
"keywords": [
"tiptap",
"tiptap extension"
],
"license": "MIT",
"funding": {
"type": "github",
"url": "https://github.com/sponsors/ueberdosis"
},
"type": "module",
"exports": {
".": {
"types": {
"import": "./dist/index.d.ts",
"require": "./dist/index.d.cts"
},
"import": "./dist/index.js",
"require": "./dist/index.cjs"
}
},
"main": "dist/index.cjs",
"module": "dist/index.js",
"types": "dist/index.d.ts",
"files": [
"src",
"dist"
],
"devDependencies": {
"@tiptap/core": "^3.21.0"
},
"peerDependencies": {
"@tiptap/core": "^3.21.0"
},
"repository": {
"type": "git",
"url": "https://github.com/ueberdosis/tiptap",
"directory": "packages/extension-code"
},
"scripts": {
"build": "tsup",
"lint": "prettier ./src/ --check && eslint --cache --quiet --no-error-on-unmatched-pattern ./src/"
}
}

133
node_modules/@tiptap/extension-code/src/code.ts generated vendored Normal file
View File

@@ -0,0 +1,133 @@
import { Mark, markInputRule, markPasteRule, mergeAttributes } from '@tiptap/core'
export interface CodeOptions {
/**
* The HTML attributes applied to the code element.
* @default {}
* @example { class: 'foo' }
*/
HTMLAttributes: Record<string, any>
}
declare module '@tiptap/core' {
interface Commands<ReturnType> {
code: {
/**
* Set a code mark
*/
setCode: () => ReturnType
/**
* Toggle inline code
*/
toggleCode: () => ReturnType
/**
* Unset a code mark
*/
unsetCode: () => ReturnType
}
}
}
/**
* Regular expressions to match inline code blocks enclosed in backticks.
* It matches:
* - An opening backtick, followed by
* - Any text that doesn't include a backtick (captured for marking), followed by
* - A closing backtick as the final character.
* This ensures that any text between backticks is formatted as code,
* regardless of the surrounding characters (exception being another backtick).
*/
export const inputRegex = /(^|[^`])`([^`]+)`(?!`)$/
/**
* Matches inline code while pasting.
*/
export const pasteRegex = /(^|[^`])`([^`]+)`(?!`)/g
/**
* This extension allows you to mark text as inline code.
* @see https://tiptap.dev/api/marks/code
*/
export const Code = Mark.create<CodeOptions>({
name: 'code',
addOptions() {
return {
HTMLAttributes: {},
}
},
excludes: '_',
code: true,
exitable: true,
parseHTML() {
return [{ tag: 'code' }]
},
renderHTML({ HTMLAttributes }) {
return ['code', mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), 0]
},
markdownTokenName: 'codespan',
parseMarkdown: (token, helpers) => {
// Convert 'codespan' token to code mark
// For codespan tokens, we use the raw text content, not tokens
return helpers.applyMark('code', [{ type: 'text', text: token.text || '' }])
},
renderMarkdown: (node, h) => {
if (!node.content) {
return ''
}
return `\`${h.renderChildren(node.content)}\``
},
addCommands() {
return {
setCode:
() =>
({ commands }) => {
return commands.setMark(this.name)
},
toggleCode:
() =>
({ commands }) => {
return commands.toggleMark(this.name)
},
unsetCode:
() =>
({ commands }) => {
return commands.unsetMark(this.name)
},
}
},
addKeyboardShortcuts() {
return {
'Mod-e': () => this.editor.commands.toggleCode(),
}
},
addInputRules() {
return [
markInputRule({
find: inputRegex,
type: this.type,
}),
]
},
addPasteRules() {
return [
markPasteRule({
find: pasteRegex,
type: this.type,
}),
]
},
})

5
node_modules/@tiptap/extension-code/src/index.ts generated vendored Normal file
View File

@@ -0,0 +1,5 @@
import { Code } from './code.js'
export * from './code.js'
export default Code