import {
Decoration,
DecorationSet,
Extension,
Fragment,
Mapping,
Mark,
Node3,
NodeSelection,
Plugin,
PluginKey,
Selection,
Slice,
TextSelection,
callOrReturn,
canInsertNode,
combineTransactionSteps,
dropPoint,
findChildrenInRange,
getAttributes,
getChangedRanges,
getExtensionField,
getMarksBetween,
getNodeAtPosition,
getNodeType,
getRenderedAttributes,
isAtEndOfNode,
isAtStartOfNode,
isNodeActive,
isNodeEmpty,
isNodeSelection,
keydownHandler,
markInputRule,
markPasteRule,
mergeAttributes,
nodeInputRule,
parseIndentedBlocks,
renderNestedMarkdownContent,
textblockTypeInputRule,
wrappingInputRule
} from "./chunk-Y2TX42W2.js";
import "./chunk-UVKRO5ER.js";
// node_modules/@tiptap/core/dist/jsx-runtime/jsx-runtime.js
var h = (tag, attributes) => {
if (tag === "slot") {
return 0;
}
if (tag instanceof Function) {
return tag(attributes);
}
const { children, ...rest } = attributes != null ? attributes : {};
if (tag === "svg") {
throw new Error(
"SVG elements are not supported in the JSX syntax, use the array syntax instead"
);
}
return [tag, rest, children];
};
// node_modules/@tiptap/extension-blockquote/dist/index.js
var inputRegex = /^\s*>\s$/;
var Blockquote = Node3.create({
name: "blockquote",
addOptions() {
return {
HTMLAttributes: {}
};
},
content: "block+",
group: "block",
defining: true,
parseHTML() {
return [{ tag: "blockquote" }];
},
renderHTML({ HTMLAttributes }) {
return h("blockquote", { ...mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), children: h("slot", {}) });
},
parseMarkdown: (token, helpers) => {
var _a;
const parseBlockChildren = (_a = helpers.parseBlockChildren) != null ? _a : helpers.parseChildren;
return helpers.createNode("blockquote", void 0, parseBlockChildren(token.tokens || []));
},
renderMarkdown: (node, h2) => {
if (!node.content) {
return "";
}
const prefix = ">";
const result = [];
node.content.forEach((child, index) => {
var _a, _b;
const childContent = (_b = (_a = h2.renderChild) == null ? void 0 : _a.call(h2, child, index)) != null ? _b : h2.renderChildren([child]);
const lines = childContent.split("\n");
const linesWithPrefix = lines.map((line) => {
if (line.trim() === "") {
return prefix;
}
return `${prefix} ${line}`;
});
result.push(linesWithPrefix.join("\n"));
});
return result.join(`
${prefix}
`);
},
addCommands() {
return {
setBlockquote: () => ({ commands }) => {
return commands.wrapIn(this.name);
},
toggleBlockquote: () => ({ commands }) => {
return commands.toggleWrap(this.name);
},
unsetBlockquote: () => ({ commands }) => {
return commands.lift(this.name);
}
};
},
addKeyboardShortcuts() {
return {
"Mod-Shift-b": () => this.editor.commands.toggleBlockquote()
};
},
addInputRules() {
return [
wrappingInputRule({
find: inputRegex,
type: this.type
})
];
}
});
// node_modules/@tiptap/extension-bold/dist/index.js
var starInputRegex = /(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/;
var starPasteRegex = /(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g;
var underscoreInputRegex = /(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/;
var underscorePasteRegex = /(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g;
var Bold = Mark.create({
name: "bold",
addOptions() {
return {
HTMLAttributes: {}
};
},
parseHTML() {
return [
{
tag: "strong"
},
{
tag: "b",
getAttrs: (node) => node.style.fontWeight !== "normal" && null
},
{
style: "font-weight=400",
clearMark: (mark) => mark.type.name === this.name
},
{
style: "font-weight",
getAttrs: (value) => /^(bold(er)?|[5-9]\d{2,})$/.test(value) && null
}
];
},
renderHTML({ HTMLAttributes }) {
return h("strong", { ...mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), children: h("slot", {}) });
},
markdownTokenName: "strong",
parseMarkdown: (token, helpers) => {
return helpers.applyMark("bold", helpers.parseInline(token.tokens || []));
},
markdownOptions: {
htmlReopen: {
open: "",
close: ""
}
},
renderMarkdown: (node, h2) => {
return `**${h2.renderChildren(node)}**`;
},
addCommands() {
return {
setBold: () => ({ commands }) => {
return commands.setMark(this.name);
},
toggleBold: () => ({ commands }) => {
return commands.toggleMark(this.name);
},
unsetBold: () => ({ commands }) => {
return commands.unsetMark(this.name);
}
};
},
addKeyboardShortcuts() {
return {
"Mod-b": () => this.editor.commands.toggleBold(),
"Mod-B": () => this.editor.commands.toggleBold()
};
},
addInputRules() {
return [
markInputRule({
find: starInputRegex,
type: this.type
}),
markInputRule({
find: underscoreInputRegex,
type: this.type
})
];
},
addPasteRules() {
return [
markPasteRule({
find: starPasteRegex,
type: this.type
}),
markPasteRule({
find: underscorePasteRegex,
type: this.type
})
];
}
});
// node_modules/@tiptap/extension-code/dist/index.js
var inputRegexMatch = (text) => {
const match = /`([^`]+)`(?!`)$/.exec(text);
if (!match) {
return null;
}
if (match.index > 0 && text[match.index - 1] === "`") {
return null;
}
return {
index: match.index,
text: match[0],
replaceWith: match[1]
};
};
var pasteRegexMatch = (text) => {
const regex = /`([^`]+)`(?!`)/g;
const matches = [];
let match;
while ((match = regex.exec(text)) !== null) {
if (match.index > 0 && text[match.index - 1] === "`") {
continue;
}
matches.push({
index: match.index,
text: match[0],
replaceWith: match[1]
});
}
return matches;
};
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, h2) => {
if (!node.content) {
return "";
}
return `\`${h2.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: inputRegexMatch,
type: this.type
})
];
},
addPasteRules() {
return [
markPasteRule({
find: pasteRegexMatch,
type: this.type
})
];
}
});
// node_modules/@tiptap/extension-code-block/dist/index.js
var DEFAULT_TAB_SIZE = 4;
var backtickInputRegex = /^```([a-z]+)?[\s\n]$/;
var tildeInputRegex = /^~~~([a-z]+)?[\s\n]$/;
var CodeBlock = Node3.create({
name: "codeBlock",
addOptions() {
return {
languageClassPrefix: "language-",
exitOnTripleEnter: true,
exitOnArrowDown: true,
defaultLanguage: null,
enableTabIndentation: false,
tabSize: DEFAULT_TAB_SIZE,
HTMLAttributes: {}
};
},
content: "text*",
marks: "",
group: "block",
code: true,
defining: true,
addAttributes() {
return {
language: {
default: this.options.defaultLanguage,
parseHTML: (element) => {
var _a;
const { languageClassPrefix } = this.options;
if (!languageClassPrefix) {
return null;
}
const classNames = [...((_a = element.firstElementChild) == null ? void 0 : _a.classList) || []];
const languages = classNames.filter((className) => className.startsWith(languageClassPrefix)).map((className) => className.replace(languageClassPrefix, ""));
const language = languages[0];
if (!language) {
return null;
}
return language;
},
rendered: false
}
};
},
parseHTML() {
return [
{
tag: "pre",
preserveWhitespace: "full"
}
];
},
renderHTML({ node, HTMLAttributes }) {
return [
"pre",
mergeAttributes(this.options.HTMLAttributes, HTMLAttributes),
[
"code",
{
class: node.attrs.language ? this.options.languageClassPrefix + node.attrs.language : null
},
0
]
];
},
markdownTokenName: "code",
parseMarkdown: (token, helpers) => {
var _a, _b;
if (((_a = token.raw) == null ? void 0 : _a.startsWith("```")) === false && ((_b = token.raw) == null ? void 0 : _b.startsWith("~~~")) === false && token.codeBlockStyle !== "indented") {
return [];
}
return helpers.createNode(
"codeBlock",
{ language: token.lang || null },
token.text ? [helpers.createTextNode(token.text)] : []
);
},
renderMarkdown: (node, h2) => {
var _a;
let output = "";
const language = ((_a = node.attrs) == null ? void 0 : _a.language) || "";
if (!node.content) {
output = `\`\`\`${language}
\`\`\``;
} else {
const lines = [`\`\`\`${language}`, h2.renderChildren(node.content), "```"];
output = lines.join("\n");
}
return output;
},
addCommands() {
return {
setCodeBlock: (attributes) => ({ commands }) => {
return commands.setNode(this.name, attributes);
},
toggleCodeBlock: (attributes) => ({ commands }) => {
return commands.toggleNode(this.name, "paragraph", attributes);
}
};
},
addKeyboardShortcuts() {
return {
"Mod-Alt-c": () => this.editor.commands.toggleCodeBlock(),
// remove code block when at start of document or code block is empty
Backspace: () => {
const { empty, $anchor } = this.editor.state.selection;
const isAtStart = $anchor.pos === 1;
if (!empty || $anchor.parent.type.name !== this.name) {
return false;
}
if (isAtStart || !$anchor.parent.textContent.length) {
return this.editor.commands.clearNodes();
}
return false;
},
// handle tab indentation
Tab: ({ editor }) => {
var _a;
if (!this.options.enableTabIndentation) {
return false;
}
const tabSize = (_a = this.options.tabSize) != null ? _a : DEFAULT_TAB_SIZE;
const { state } = editor;
const { selection } = state;
const { $from, empty } = selection;
if ($from.parent.type !== this.type) {
return false;
}
const indent = " ".repeat(tabSize);
if (empty) {
return editor.commands.insertContent(indent);
}
return editor.commands.command(({ tr: tr2 }) => {
const { from: from2, to } = selection;
const text = state.doc.textBetween(from2, to, "\n", "\n");
const lines = text.split("\n");
const indentedText = lines.map((line) => indent + line).join("\n");
tr2.replaceWith(from2, to, state.schema.text(indentedText));
return true;
});
},
// handle shift+tab reverse indentation
"Shift-Tab": ({ editor }) => {
var _a;
if (!this.options.enableTabIndentation) {
return false;
}
const tabSize = (_a = this.options.tabSize) != null ? _a : DEFAULT_TAB_SIZE;
const { state } = editor;
const { selection } = state;
const { $from, empty } = selection;
if ($from.parent.type !== this.type) {
return false;
}
if (empty) {
return editor.commands.command(({ tr: tr2 }) => {
var _a2;
const { pos } = $from;
const codeBlockStart = $from.start();
const codeBlockEnd = $from.end();
const allText = state.doc.textBetween(codeBlockStart, codeBlockEnd, "\n", "\n");
const lines = allText.split("\n");
let currentLineIndex = 0;
let charCount = 0;
const relativeCursorPos = pos - codeBlockStart;
for (let i = 0; i < lines.length; i += 1) {
if (charCount + lines[i].length >= relativeCursorPos) {
currentLineIndex = i;
break;
}
charCount += lines[i].length + 1;
}
const currentLine = lines[currentLineIndex];
const leadingSpaces = ((_a2 = currentLine.match(/^ */)) == null ? void 0 : _a2[0]) || "";
const spacesToRemove = Math.min(leadingSpaces.length, tabSize);
if (spacesToRemove === 0) {
return true;
}
let lineStartPos = codeBlockStart;
for (let i = 0; i < currentLineIndex; i += 1) {
lineStartPos += lines[i].length + 1;
}
tr2.delete(lineStartPos, lineStartPos + spacesToRemove);
const cursorPosInLine = pos - lineStartPos;
if (cursorPosInLine <= spacesToRemove) {
tr2.setSelection(TextSelection.create(tr2.doc, lineStartPos));
}
return true;
});
}
return editor.commands.command(({ tr: tr2 }) => {
const { from: from2, to } = selection;
const text = state.doc.textBetween(from2, to, "\n", "\n");
const lines = text.split("\n");
const reverseIndentText = lines.map((line) => {
var _a2;
const leadingSpaces = ((_a2 = line.match(/^ */)) == null ? void 0 : _a2[0]) || "";
const spacesToRemove = Math.min(leadingSpaces.length, tabSize);
return line.slice(spacesToRemove);
}).join("\n");
tr2.replaceWith(from2, to, state.schema.text(reverseIndentText));
return true;
});
},
// exit node on triple enter
Enter: ({ editor }) => {
if (!this.options.exitOnTripleEnter) {
return false;
}
const { state } = editor;
const { selection } = state;
const { $from, empty } = selection;
if (!empty || $from.parent.type !== this.type) {
return false;
}
const isAtEnd = $from.parentOffset === $from.parent.nodeSize - 2;
const endsWithDoubleNewline = $from.parent.textContent.endsWith("\n\n");
if (!isAtEnd || !endsWithDoubleNewline) {
return false;
}
return editor.chain().command(({ tr: tr2 }) => {
tr2.delete($from.pos - 2, $from.pos);
return true;
}).exitCode().run();
},
// exit node on arrow down
ArrowDown: ({ editor }) => {
if (!this.options.exitOnArrowDown) {
return false;
}
const { state } = editor;
const { selection, doc } = state;
const { $from, empty } = selection;
if (!empty || $from.parent.type !== this.type) {
return false;
}
const isAtEnd = $from.parentOffset === $from.parent.nodeSize - 2;
if (!isAtEnd) {
return false;
}
const after = $from.after();
if (after === void 0) {
return false;
}
const nodeAfter = doc.nodeAt(after);
if (nodeAfter) {
return editor.commands.command(({ tr: tr2 }) => {
tr2.setSelection(Selection.near(doc.resolve(after)));
return true;
});
}
return editor.commands.exitCode();
}
};
},
addInputRules() {
return [
textblockTypeInputRule({
find: backtickInputRegex,
type: this.type,
getAttributes: (match) => ({
language: match[1]
})
}),
textblockTypeInputRule({
find: tildeInputRegex,
type: this.type,
getAttributes: (match) => ({
language: match[1]
})
})
];
},
addProseMirrorPlugins() {
return [
// this plugin creates a code block for pasted content from VS Code
// we can also detect the copied code language
new Plugin({
key: new PluginKey("codeBlockVSCodeHandler"),
props: {
handlePaste: (view, event) => {
if (!event.clipboardData) {
return false;
}
if (this.editor.isActive(this.type.name)) {
return false;
}
const text = event.clipboardData.getData("text/plain");
const vscode = event.clipboardData.getData("vscode-editor-data");
const vscodeData = vscode ? JSON.parse(vscode) : void 0;
const language = vscodeData == null ? void 0 : vscodeData.mode;
if (!text || !language) {
return false;
}
const { tr: tr2, schema } = view.state;
const textNode = schema.text(text.replace(/\r\n?/g, "\n"));
tr2.replaceSelectionWith(this.type.create({ language }, textNode));
if (tr2.selection.$from.parent.type !== this.type) {
tr2.setSelection(
TextSelection.near(tr2.doc.resolve(Math.max(0, tr2.selection.from - 2)))
);
}
tr2.setMeta("paste", true);
view.dispatch(tr2);
return true;
}
}
})
];
}
});
// node_modules/@tiptap/extension-document/dist/index.js
var Document = Node3.create({
name: "doc",
topNode: true,
content: "block+",
renderMarkdown: (node, h2) => {
if (!node.content) {
return "";
}
return h2.renderChildren(node.content, "\n\n");
}
});
// node_modules/@tiptap/extension-hard-break/dist/index.js
var HardBreak = Node3.create({
name: "hardBreak",
markdownTokenName: "br",
addOptions() {
return {
keepMarks: true,
HTMLAttributes: {}
};
},
inline: true,
group: "inline",
selectable: false,
linebreakReplacement: true,
parseHTML() {
return [{ tag: "br" }];
},
renderHTML({ HTMLAttributes }) {
return ["br", mergeAttributes(this.options.HTMLAttributes, HTMLAttributes)];
},
renderText() {
return "\n";
},
renderMarkdown: () => `
`,
parseMarkdown: () => {
return {
type: "hardBreak"
};
},
addCommands() {
return {
setHardBreak: () => ({ commands, chain, state, editor }) => {
return commands.first([
() => commands.exitCode(),
() => commands.command(() => {
const { selection, storedMarks } = state;
if (selection.$from.parent.type.spec.isolating) {
return false;
}
const { keepMarks } = this.options;
const { splittableMarks } = editor.extensionManager;
const marks = storedMarks || selection.$to.parentOffset && selection.$from.marks();
return chain().insertContent({ type: this.name }).command(({ tr: tr2, dispatch }) => {
if (dispatch && marks && keepMarks) {
const filteredMarks = marks.filter(
(mark) => splittableMarks.includes(mark.type.name)
);
tr2.ensureMarks(filteredMarks);
}
return true;
}).run();
})
]);
}
};
},
addKeyboardShortcuts() {
return {
"Mod-Enter": () => this.editor.commands.setHardBreak(),
"Shift-Enter": () => this.editor.commands.setHardBreak()
};
}
});
// node_modules/@tiptap/extension-heading/dist/index.js
var Heading = Node3.create({
name: "heading",
addOptions() {
return {
levels: [1, 2, 3, 4, 5, 6],
HTMLAttributes: {}
};
},
content: "inline*",
group: "block",
defining: true,
addAttributes() {
return {
level: {
default: 1,
rendered: false
}
};
},
parseHTML() {
return this.options.levels.map((level) => ({
tag: `h${level}`,
attrs: { level }
}));
},
renderHTML({ node, HTMLAttributes }) {
const hasLevel = this.options.levels.includes(node.attrs.level);
const level = hasLevel ? node.attrs.level : this.options.levels[0];
return [`h${level}`, mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), 0];
},
parseMarkdown: (token, helpers) => {
return helpers.createNode(
"heading",
{ level: token.depth || 1 },
helpers.parseInline(token.tokens || [])
);
},
renderMarkdown: (node, h2) => {
var _a;
const level = ((_a = node.attrs) == null ? void 0 : _a.level) ? parseInt(node.attrs.level, 10) : 1;
const headingChars = "#".repeat(level);
if (!node.content) {
return "";
}
return `${headingChars} ${h2.renderChildren(node.content)}`;
},
addCommands() {
return {
setHeading: (attributes) => ({ commands }) => {
if (!this.options.levels.includes(attributes.level)) {
return false;
}
return commands.setNode(this.name, attributes);
},
toggleHeading: (attributes) => ({ commands }) => {
if (!this.options.levels.includes(attributes.level)) {
return false;
}
return commands.toggleNode(this.name, "paragraph", attributes);
}
};
},
addKeyboardShortcuts() {
return this.options.levels.reduce(
(items, level) => ({
...items,
[`Mod-Alt-${level}`]: () => this.editor.commands.toggleHeading({ level })
}),
{}
);
},
addInputRules() {
return this.options.levels.map((level) => {
return textblockTypeInputRule({
find: new RegExp(`^(#{${Math.min(...this.options.levels)},${level}})\\s$`),
type: this.type,
getAttributes: {
level
}
});
});
}
});
// node_modules/@tiptap/extension-horizontal-rule/dist/index.js
var HorizontalRule = Node3.create({
name: "horizontalRule",
addOptions() {
return {
HTMLAttributes: {},
nextNodeType: "paragraph"
};
},
group: "block",
parseHTML() {
return [{ tag: "hr" }];
},
renderHTML({ HTMLAttributes }) {
return ["hr", mergeAttributes(this.options.HTMLAttributes, HTMLAttributes)];
},
markdownTokenName: "hr",
parseMarkdown: (token, helpers) => {
return helpers.createNode("horizontalRule");
},
renderMarkdown: () => {
return "---";
},
addCommands() {
return {
setHorizontalRule: () => ({ chain, state }) => {
if (!canInsertNode(state, state.schema.nodes[this.name])) {
return false;
}
const { selection } = state;
const { $to: $originTo } = selection;
const currentChain = chain();
if (isNodeSelection(selection)) {
currentChain.insertContentAt($originTo.pos, {
type: this.name
});
} else {
currentChain.insertContent({ type: this.name });
}
return currentChain.command(({ state: chainState, tr: tr2, dispatch }) => {
if (dispatch) {
const { $to } = tr2.selection;
const posAfter = $to.end();
if ($to.nodeAfter) {
if ($to.nodeAfter.isTextblock) {
tr2.setSelection(TextSelection.create(tr2.doc, $to.pos + 1));
} else if ($to.nodeAfter.isBlock) {
tr2.setSelection(NodeSelection.create(tr2.doc, $to.pos));
} else {
tr2.setSelection(TextSelection.create(tr2.doc, $to.pos));
}
} else {
const nodeType = chainState.schema.nodes[this.options.nextNodeType] || $to.parent.type.contentMatch.defaultType;
const node = nodeType == null ? void 0 : nodeType.create();
if (node) {
tr2.insert(posAfter, node);
tr2.setSelection(TextSelection.create(tr2.doc, posAfter + 1));
}
}
tr2.scrollIntoView();
}
return true;
}).run();
}
};
},
addInputRules() {
return [
nodeInputRule({
find: /^(?:---|—-|___\s|\*\*\*\s)$/,
type: this.type
})
];
}
});
// node_modules/@tiptap/extension-italic/dist/index.js
var starInputRegex2 = /(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/;
var starPasteRegex2 = /(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g;
var underscoreInputRegex2 = /(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/;
var underscorePasteRegex2 = /(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g;
var Italic = Mark.create({
name: "italic",
addOptions() {
return {
HTMLAttributes: {}
};
},
parseHTML() {
return [
{
tag: "em"
},
{
tag: "i",
getAttrs: (node) => node.style.fontStyle !== "normal" && null
},
{
style: "font-style=normal",
clearMark: (mark) => mark.type.name === this.name
},
{
style: "font-style=italic"
}
];
},
renderHTML({ HTMLAttributes }) {
return ["em", mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), 0];
},
addCommands() {
return {
setItalic: () => ({ commands }) => {
return commands.setMark(this.name);
},
toggleItalic: () => ({ commands }) => {
return commands.toggleMark(this.name);
},
unsetItalic: () => ({ commands }) => {
return commands.unsetMark(this.name);
}
};
},
markdownTokenName: "em",
parseMarkdown: (token, helpers) => {
return helpers.applyMark("italic", helpers.parseInline(token.tokens || []));
},
markdownOptions: {
htmlReopen: {
open: "",
close: ""
}
},
renderMarkdown: (node, h2) => {
return `*${h2.renderChildren(node)}*`;
},
addKeyboardShortcuts() {
return {
"Mod-i": () => this.editor.commands.toggleItalic(),
"Mod-I": () => this.editor.commands.toggleItalic()
};
},
addInputRules() {
return [
markInputRule({
find: starInputRegex2,
type: this.type
}),
markInputRule({
find: underscoreInputRegex2,
type: this.type
})
];
},
addPasteRules() {
return [
markPasteRule({
find: starPasteRegex2,
type: this.type
}),
markPasteRule({
find: underscorePasteRegex2,
type: this.type
})
];
}
});
// node_modules/linkifyjs/dist/linkify.mjs
var encodedTlds = "aaa1rp3bb0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4w0s2x0a2z0ure5ba0by2idu3namex4d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zz3v1w1y1z0h3ca0b1fe2l0l1vinklein9m0era3p2non3petown5ital0one8r0avan4ds2e0er0s4s2sa1e1h1ino4t0ering5holic7ba1n1re3c1d1enter4o1rn3f0a1d2g1h0anel2nel4rity4se2t2eap3intai5ristmas6ome4urch5i0priani6rcle4sco3tadel4i0c2y3k1l0aims4eaning6ick2nic1que6othing5ud3ub0med6m1n1o0ach3des3ffee4llege4ogne5m0mbank4unity6pany2re3uter5sec4ndos3struction8ulting7tact3ractors9oking4l1p2rsica5untry4pon0s4rses6pa2r0edit0card4union9icket5own3s1uise0s6u0isinella9v1w1x1y0mru3ou3z2dad1nce3ta1e1ing3sun4y2clk3ds2e0al0er2s3gree4livery5l1oitte5ta3mocrat6ntal2ist5si0gn4v2hl2iamonds6et2gital5rect0ory7scount3ver5h2y2j1k1m1np2o0cs1tor4g1mains5t1wnload7rive4tv2ubai3pont4rban5vag2r2z2earth3t2c0o2deka3u0cation8e1g1mail3erck5nergy4gineer0ing9terprises10pson4quipment8r0icsson6ni3s0q1tate5t1u0rovision8s2vents5xchange6pert3osed4ress5traspace10fage2il1rwinds6th3mily4n0s2rm0ers5shion4t3edex3edback6rrari3ero6i0delity5o2lm2nal1nce1ial7re0stone6mdale6sh0ing5t0ness6j1k1lickr3ghts4r2orist4wers5y2m1o0o0d1tball6rd1ex2sale4um3undation8x2r0ee1senius7l1ogans4ntier7tr2ujitsu5n0d2rniture7tbol5yi3ga0l0lery3o1up4me0s3p1rden4y2b0iz3d0n2e0a1nt0ing5orge5f1g0ee3h1i0ft0s3ves2ing5l0ass3e1obal2o4m0ail3bh2o1x2n1odaddy5ld0point6f2odyear5g0le4p1t1v2p1q1r0ainger5phics5tis4een3ipe3ocery4up4s1t1u0cci3ge2ide2tars5ru3w1y2hair2mburg5ngout5us3bo2dfc0bank7ealth0care8lp1sinki6re1mes5iphop4samitsu7tachi5v2k0t2m1n1ockey4ldings5iday5medepot5goods5s0ense7nda3rse3spital5t0ing5t0els3mail5use3w2r1sbc3t1u0ghes5yatt3undai7ibm2cbc2e1u2d1e0ee3fm2kano4l1m0amat4db2mo0bilien9n0c1dustries8finiti5o2g1k1stitute6urance4e4t0ernational10uit4vestments10o1piranga7q1r0ish4s0maili5t0anbul7t0au2v3jaguar4va3cb2e0ep2tzt3welry6io2ll2m0p2nj2o0bs1urg4t1y2p0morgan6rs3uegos4niper7kaufen5ddi3e0rryhotels6properties14fh2g1h1i0a1ds2m1ndle4tchen5wi3m1n1oeln3matsu5sher5p0mg2n2r0d1ed3uokgroup8w1y0oto4z2la0caixa5mborghini8er3nd0rover6xess5salle5t0ino3robe5w0yer5b1c1ds2ease3clerc5frak4gal2o2xus4gbt3i0dl2fe0insurance9style7ghting6ke2lly3mited4o2ncoln4k2ve1ing5k1lc1p2oan0s3cker3us3l1ndon4tte1o3ve3pl0financial11r1s1t0d0a3u0ndbeck6xe1ury5v1y2ma0drid4if1son4keup4n0agement7go3p1rket0ing3s4riott5shalls7ttel5ba2c0kinsey7d1e0d0ia3et2lbourne7me1orial6n0u2rck0msd7g1h1iami3crosoft7l1ni1t2t0subishi9k1l0b1s2m0a2n1o0bi0le4da2e1i1m1nash3ey2ster5rmon3tgage6scow4to0rcycles9v0ie4p1q1r1s0d2t0n1r2u0seum3ic4v1w1x1y1z2na0b1goya4me2vy3ba2c1e0c1t0bank4flix4work5ustar5w0s2xt0direct7us4f0l2g0o2hk2i0co2ke1on3nja3ssan1y5l1o0kia3rton4w0ruz3tv4p1r0a1w2tt2u1yc2z2obi1server7ffice5kinawa6layan0group9lo3m0ega4ne1g1l0ine5oo2pen3racle3nge4g0anic5igins6saka4tsuka4t2vh3pa0ge2nasonic7ris2s1tners4s1y3y2ccw3e0t2f0izer5g1h0armacy6d1ilips5one2to0graphy6s4ysio5ics1tet2ures6d1n0g1k2oneer5zza4k1l0ace2y0station9umbing5s3m1n0c2ohl2ker3litie5rn2st3r0axi3ess3ime3o0d0uctions8f1gressive8mo2perties3y5tection8u0dential9s1t1ub2w0c2y2qa1pon3uebec3st5racing4dio4e0ad1lestate6tor2y4cipes5d0umbrella9hab3ise0n3t2liance6n0t0als5pair3ort3ublican8st0aurant8view0s5xroth6ich0ardli6oh3l1o1p2o0cks3deo3gers4om3s0vp3u0gby3hr2n2w0e2yukyu6sa0arland6fe0ty4kura4le1on3msclub4ung5ndvik0coromant12ofi4p1rl2s1ve2xo3b0i1s2c0b1haeffler7midt4olarships8ol3ule3warz5ience5ot3d1e0arch3t2cure1ity6ek2lect4ner3rvices6ven3w1x0y3fr2g1h0angrila6rp3ell3ia1ksha5oes2p0ping5uji3w3i0lk2na1gles5te3j1k0i0n2y0pe4l0ing4m0art3ile4n0cf3o0ccer3ial4ftbank4ware6hu2lar2utions7ng1y2y2pa0ce3ort2t3r0l2s1t0ada2ples4r1tebank4farm7c0group6ockholm6rage3e3ream4udio2y3yle4u0cks3pplies3y2ort5rf1gery5zuki5v1watch4iss4x1y0dney4stems6z2tab1ipei4lk2obao4rget4tamotors6r2too4x0i3c0i2d0k2eam2ch0nology8l1masek5nnis4va3f1g1h0d1eater2re6iaa2ckets5enda4ps2res2ol4j0maxx4x2k0maxx5l1m0all4n1o0day3kyo3ols3p1ray3shiba5tal3urs3wn2yota3s3r0ade1ing4ining5vel0ers0insurance16ust3v2t1ube2i1nes3shu4v0s2w1z2ua1bank3s2g1k1nicom3versity8o2ol2ps2s1y1z2va0cations7na1guard7c1e0gas3ntures6risign5mögensberater2ung14sicherung10t2g1i0ajes4deo3g1king4llas4n1p1rgin4sa1ion4va1o3laanderen9n1odka3lvo3te1ing3o2yage5u2wales2mart4ter4ng0gou5tch0es6eather0channel12bcam3er2site5d0ding5ibo2r3f1hoswho6ien2ki2lliamhill9n0dows4e1ners6me2oodside6rk0s2ld3w2s1tc1f3xbox3erox4ihuan4n2xx2yz3yachts4hoo3maxun5ndex5e1odobashi7ga2kohama6u0tube6t1un3za0ppos4ra3ero3ip2m1one3uerich6w2";
var encodedUtlds = "ελ1υ2бг1ел3дети4ею2католик6ом3мкд2он1сква6онлайн5рг3рус2ф2сайт3рб3укр3қаз3հայ3ישראל5קום3ابوظبي5رامكو5لاردن4بحرين5جزائر5سعودية6عليان5مغرب5مارات5یران5بارت2زار4يتك3ھارت5تونس4سودان3رية5شبكة4عراق2ب2مان4فلسطين6قطر3كاثوليك6وم3مصر2ليسيا5وريتانيا7قع4همراه5پاکستان7ڀارت4कॉम3नेट3भारत0म्3ोत5संगठन5বাংলা5ভারত2ৰত4ਭਾਰਤ4ભારત4ଭାରତ4இந்தியா6லங்கை6சிங்கப்பூர்11భారత్5ಭಾರತ4ഭാരതം5ලංකා4คอม3ไทย3ລາວ3გე2みんな3アマゾン4クラウド4グーグル4コム2ストア3セール3ファッション6ポイント4世界2中信1国1國1文网3亚马逊3企业2佛山2信息2健康2八卦2公司1益2台湾1灣2商城1店1标2嘉里0大酒店5在线2大拿2天主教3娱乐2家電2广东2微博2慈善2我爱你3手机2招聘2政务1府2新加坡2闻2时尚2書籍2机构2淡马锡3游戏2澳門2点看2移动2组织机构4网址1店1站1络2联通2谷歌2购物2通販2集团2電訊盈科4飞利浦3食品2餐厅2香格里拉3港2닷넷1컴2삼성2한국2";
var numeric = "numeric";
var ascii = "ascii";
var alpha = "alpha";
var asciinumeric = "asciinumeric";
var alphanumeric = "alphanumeric";
var domain = "domain";
var emoji = "emoji";
var scheme = "scheme";
var slashscheme = "slashscheme";
var whitespace = "whitespace";
function registerGroup(name, groups) {
if (!(name in groups)) {
groups[name] = [];
}
return groups[name];
}
function addToGroups(t, flags, groups) {
if (flags[numeric]) {
flags[asciinumeric] = true;
flags[alphanumeric] = true;
}
if (flags[ascii]) {
flags[asciinumeric] = true;
flags[alpha] = true;
}
if (flags[asciinumeric]) {
flags[alphanumeric] = true;
}
if (flags[alpha]) {
flags[alphanumeric] = true;
}
if (flags[alphanumeric]) {
flags[domain] = true;
}
if (flags[emoji]) {
flags[domain] = true;
}
for (const k in flags) {
const group = registerGroup(k, groups);
if (group.indexOf(t) < 0) {
group.push(t);
}
}
}
function flagsForToken(t, groups) {
const result = {};
for (const c in groups) {
if (groups[c].indexOf(t) >= 0) {
result[c] = true;
}
}
return result;
}
function State(token = null) {
this.j = {};
this.jr = [];
this.jd = null;
this.t = token;
}
State.groups = {};
State.prototype = {
accepts() {
return !!this.t;
},
/**
* Follow an existing transition from the given input to the next state.
* Does not mutate.
* @param {string} input character or token type to transition on
* @returns {?State} the next state, if any
*/
go(input) {
const state = this;
const nextState = state.j[input];
if (nextState) {
return nextState;
}
for (let i = 0; i < state.jr.length; i++) {
const regex = state.jr[i][0];
const nextState2 = state.jr[i][1];
if (nextState2 && regex.test(input)) {
return nextState2;
}
}
return state.jd;
},
/**
* Whether the state has a transition for the given input. Set the second
* argument to true to only look for an exact match (and not a default or
* regular-expression-based transition)
* @param {string} input
* @param {boolean} exactOnly
*/
has(input, exactOnly = false) {
return exactOnly ? input in this.j : !!this.go(input);
},
/**
* Short for "transition all"; create a transition from the array of items
* in the given list to the same final resulting state.
* @param {string | string[]} inputs Group of inputs to transition on
* @param {Transition | State} [next] Transition options
* @param {Flags} [flags] Collections flags to add token to
* @param {Collections} [groups] Master list of token groups
*/
ta(inputs, next, flags, groups) {
for (let i = 0; i < inputs.length; i++) {
this.tt(inputs[i], next, flags, groups);
}
},
/**
* Short for "take regexp transition"; defines a transition for this state
* when it encounters a token which matches the given regular expression
* @param {RegExp} regexp Regular expression transition (populate first)
* @param {T | State} [next] Transition options
* @param {Flags} [flags] Collections flags to add token to
* @param {Collections} [groups] Master list of token groups
* @returns {State} taken after the given input
*/
tr(regexp2, next, flags, groups) {
groups = groups || State.groups;
let nextState;
if (next && next.j) {
nextState = next;
} else {
nextState = new State(next);
if (flags && groups) {
addToGroups(next, flags, groups);
}
}
this.jr.push([regexp2, nextState]);
return nextState;
},
/**
* Short for "take transitions", will take as many sequential transitions as
* the length of the given input and returns the
* resulting final state.
* @param {string | string[]} input
* @param {T | State} [next] Transition options
* @param {Flags} [flags] Collections flags to add token to
* @param {Collections} [groups] Master list of token groups
* @returns {State} taken after the given input
*/
ts(input, next, flags, groups) {
let state = this;
const len = input.length;
if (!len) {
return state;
}
for (let i = 0; i < len - 1; i++) {
state = state.tt(input[i]);
}
return state.tt(input[len - 1], next, flags, groups);
},
/**
* Short for "take transition", this is a method for building/working with
* state machines.
*
* If a state already exists for the given input, returns it.
*
* If a token is specified, that state will emit that token when reached by
* the linkify engine.
*
* If no state exists, it will be initialized with some default transitions
* that resemble existing default transitions.
*
* If a state is given for the second argument, that state will be
* transitioned to on the given input regardless of what that input
* previously did.
*
* Specify a token group flags to define groups that this token belongs to.
* The token will be added to corresponding entires in the given groups
* object.
*
* @param {string} input character, token type to transition on
* @param {T | State} [next] Transition options
* @param {Flags} [flags] Collections flags to add token to
* @param {Collections} [groups] Master list of groups
* @returns {State} taken after the given input
*/
tt(input, next, flags, groups) {
groups = groups || State.groups;
const state = this;
if (next && next.j) {
state.j[input] = next;
return next;
}
const t = next;
let nextState, templateState = state.go(input);
if (templateState) {
nextState = new State();
Object.assign(nextState.j, templateState.j);
nextState.jr.push.apply(nextState.jr, templateState.jr);
nextState.jd = templateState.jd;
nextState.t = templateState.t;
} else {
nextState = new State();
}
if (t) {
if (groups) {
if (nextState.t && typeof nextState.t === "string") {
const allFlags = Object.assign(flagsForToken(nextState.t, groups), flags);
addToGroups(t, allFlags, groups);
} else if (flags) {
addToGroups(t, flags, groups);
}
}
nextState.t = t;
}
state.j[input] = nextState;
return nextState;
}
};
var ta = (state, input, next, flags, groups) => state.ta(input, next, flags, groups);
var tr = (state, regexp2, next, flags, groups) => state.tr(regexp2, next, flags, groups);
var ts = (state, input, next, flags, groups) => state.ts(input, next, flags, groups);
var tt = (state, input, next, flags, groups) => state.tt(input, next, flags, groups);
var WORD = "WORD";
var UWORD = "UWORD";
var ASCIINUMERICAL = "ASCIINUMERICAL";
var ALPHANUMERICAL = "ALPHANUMERICAL";
var LOCALHOST = "LOCALHOST";
var TLD = "TLD";
var UTLD = "UTLD";
var SCHEME = "SCHEME";
var SLASH_SCHEME = "SLASH_SCHEME";
var NUM = "NUM";
var WS = "WS";
var NL = "NL";
var OPENBRACE = "OPENBRACE";
var CLOSEBRACE = "CLOSEBRACE";
var OPENBRACKET = "OPENBRACKET";
var CLOSEBRACKET = "CLOSEBRACKET";
var OPENPAREN = "OPENPAREN";
var CLOSEPAREN = "CLOSEPAREN";
var OPENANGLEBRACKET = "OPENANGLEBRACKET";
var CLOSEANGLEBRACKET = "CLOSEANGLEBRACKET";
var FULLWIDTHLEFTPAREN = "FULLWIDTHLEFTPAREN";
var FULLWIDTHRIGHTPAREN = "FULLWIDTHRIGHTPAREN";
var LEFTCORNERBRACKET = "LEFTCORNERBRACKET";
var RIGHTCORNERBRACKET = "RIGHTCORNERBRACKET";
var LEFTWHITECORNERBRACKET = "LEFTWHITECORNERBRACKET";
var RIGHTWHITECORNERBRACKET = "RIGHTWHITECORNERBRACKET";
var FULLWIDTHLESSTHAN = "FULLWIDTHLESSTHAN";
var FULLWIDTHGREATERTHAN = "FULLWIDTHGREATERTHAN";
var AMPERSAND = "AMPERSAND";
var APOSTROPHE = "APOSTROPHE";
var ASTERISK = "ASTERISK";
var AT = "AT";
var BACKSLASH = "BACKSLASH";
var BACKTICK = "BACKTICK";
var CARET = "CARET";
var COLON = "COLON";
var COMMA = "COMMA";
var DOLLAR = "DOLLAR";
var DOT = "DOT";
var EQUALS = "EQUALS";
var EXCLAMATION = "EXCLAMATION";
var HYPHEN = "HYPHEN";
var PERCENT = "PERCENT";
var PIPE = "PIPE";
var PLUS = "PLUS";
var POUND = "POUND";
var QUERY = "QUERY";
var QUOTE = "QUOTE";
var FULLWIDTHMIDDLEDOT = "FULLWIDTHMIDDLEDOT";
var SEMI = "SEMI";
var SLASH = "SLASH";
var TILDE = "TILDE";
var UNDERSCORE = "UNDERSCORE";
var EMOJI$1 = "EMOJI";
var SYM = "SYM";
var tk = Object.freeze({
__proto__: null,
ALPHANUMERICAL,
AMPERSAND,
APOSTROPHE,
ASCIINUMERICAL,
ASTERISK,
AT,
BACKSLASH,
BACKTICK,
CARET,
CLOSEANGLEBRACKET,
CLOSEBRACE,
CLOSEBRACKET,
CLOSEPAREN,
COLON,
COMMA,
DOLLAR,
DOT,
EMOJI: EMOJI$1,
EQUALS,
EXCLAMATION,
FULLWIDTHGREATERTHAN,
FULLWIDTHLEFTPAREN,
FULLWIDTHLESSTHAN,
FULLWIDTHMIDDLEDOT,
FULLWIDTHRIGHTPAREN,
HYPHEN,
LEFTCORNERBRACKET,
LEFTWHITECORNERBRACKET,
LOCALHOST,
NL,
NUM,
OPENANGLEBRACKET,
OPENBRACE,
OPENBRACKET,
OPENPAREN,
PERCENT,
PIPE,
PLUS,
POUND,
QUERY,
QUOTE,
RIGHTCORNERBRACKET,
RIGHTWHITECORNERBRACKET,
SCHEME,
SEMI,
SLASH,
SLASH_SCHEME,
SYM,
TILDE,
TLD,
UNDERSCORE,
UTLD,
UWORD,
WORD,
WS
});
var ASCII_LETTER = /[a-z]/;
var LETTER = new RegExp("\\p{L}", "u");
var EMOJI = new RegExp("\\p{Emoji}", "u");
var EMOJI_VARIATION$1 = /\ufe0f/;
var DIGIT = /\d/;
var SPACE = /\s/;
var regexp = Object.freeze({
__proto__: null,
ASCII_LETTER,
DIGIT,
EMOJI,
EMOJI_VARIATION: EMOJI_VARIATION$1,
LETTER,
SPACE
});
var CR = "\r";
var LF = "\n";
var EMOJI_VARIATION = "️";
var EMOJI_JOINER = "";
var OBJECT_REPLACEMENT = "";
var tlds = null;
var utlds = null;
function init$2(customSchemes = []) {
const groups = {};
State.groups = groups;
const Start = new State();
if (tlds == null) {
tlds = decodeTlds(encodedTlds);
}
if (utlds == null) {
utlds = decodeTlds(encodedUtlds);
}
tt(Start, "'", APOSTROPHE);
tt(Start, "{", OPENBRACE);
tt(Start, "}", CLOSEBRACE);
tt(Start, "[", OPENBRACKET);
tt(Start, "]", CLOSEBRACKET);
tt(Start, "(", OPENPAREN);
tt(Start, ")", CLOSEPAREN);
tt(Start, "<", OPENANGLEBRACKET);
tt(Start, ">", CLOSEANGLEBRACKET);
tt(Start, "(", FULLWIDTHLEFTPAREN);
tt(Start, ")", FULLWIDTHRIGHTPAREN);
tt(Start, "「", LEFTCORNERBRACKET);
tt(Start, "」", RIGHTCORNERBRACKET);
tt(Start, "『", LEFTWHITECORNERBRACKET);
tt(Start, "』", RIGHTWHITECORNERBRACKET);
tt(Start, "<", FULLWIDTHLESSTHAN);
tt(Start, ">", FULLWIDTHGREATERTHAN);
tt(Start, "&", AMPERSAND);
tt(Start, "*", ASTERISK);
tt(Start, "@", AT);
tt(Start, "`", BACKTICK);
tt(Start, "^", CARET);
tt(Start, ":", COLON);
tt(Start, ",", COMMA);
tt(Start, "$", DOLLAR);
tt(Start, ".", DOT);
tt(Start, "=", EQUALS);
tt(Start, "!", EXCLAMATION);
tt(Start, "-", HYPHEN);
tt(Start, "%", PERCENT);
tt(Start, "|", PIPE);
tt(Start, "+", PLUS);
tt(Start, "#", POUND);
tt(Start, "?", QUERY);
tt(Start, '"', QUOTE);
tt(Start, "/", SLASH);
tt(Start, ";", SEMI);
tt(Start, "~", TILDE);
tt(Start, "_", UNDERSCORE);
tt(Start, "\\", BACKSLASH);
tt(Start, "・", FULLWIDTHMIDDLEDOT);
const Num = tr(Start, DIGIT, NUM, {
[numeric]: true
});
tr(Num, DIGIT, Num);
const Asciinumeric = tr(Num, ASCII_LETTER, ASCIINUMERICAL, {
[asciinumeric]: true
});
const Alphanumeric = tr(Num, LETTER, ALPHANUMERICAL, {
[alphanumeric]: true
});
const Word = tr(Start, ASCII_LETTER, WORD, {
[ascii]: true
});
tr(Word, DIGIT, Asciinumeric);
tr(Word, ASCII_LETTER, Word);
tr(Asciinumeric, DIGIT, Asciinumeric);
tr(Asciinumeric, ASCII_LETTER, Asciinumeric);
const UWord = tr(Start, LETTER, UWORD, {
[alpha]: true
});
tr(UWord, ASCII_LETTER);
tr(UWord, DIGIT, Alphanumeric);
tr(UWord, LETTER, UWord);
tr(Alphanumeric, DIGIT, Alphanumeric);
tr(Alphanumeric, ASCII_LETTER);
tr(Alphanumeric, LETTER, Alphanumeric);
const Nl2 = tt(Start, LF, NL, {
[whitespace]: true
});
const Cr = tt(Start, CR, WS, {
[whitespace]: true
});
const Ws = tr(Start, SPACE, WS, {
[whitespace]: true
});
tt(Start, OBJECT_REPLACEMENT, Ws);
tt(Cr, LF, Nl2);
tt(Cr, OBJECT_REPLACEMENT, Ws);
tr(Cr, SPACE, Ws);
tt(Ws, CR);
tt(Ws, LF);
tr(Ws, SPACE, Ws);
tt(Ws, OBJECT_REPLACEMENT, Ws);
const Emoji = tr(Start, EMOJI, EMOJI$1, {
[emoji]: true
});
tt(Emoji, "#");
tr(Emoji, EMOJI, Emoji);
tt(Emoji, EMOJI_VARIATION, Emoji);
const EmojiJoiner = tt(Emoji, EMOJI_JOINER);
tt(EmojiJoiner, "#");
tr(EmojiJoiner, EMOJI, Emoji);
const wordjr = [[ASCII_LETTER, Word], [DIGIT, Asciinumeric]];
const uwordjr = [[ASCII_LETTER, null], [LETTER, UWord], [DIGIT, Alphanumeric]];
for (let i = 0; i < tlds.length; i++) {
fastts(Start, tlds[i], TLD, WORD, wordjr);
}
for (let i = 0; i < utlds.length; i++) {
fastts(Start, utlds[i], UTLD, UWORD, uwordjr);
}
addToGroups(TLD, {
tld: true,
ascii: true
}, groups);
addToGroups(UTLD, {
utld: true,
alpha: true
}, groups);
fastts(Start, "file", SCHEME, WORD, wordjr);
fastts(Start, "mailto", SCHEME, WORD, wordjr);
fastts(Start, "http", SLASH_SCHEME, WORD, wordjr);
fastts(Start, "https", SLASH_SCHEME, WORD, wordjr);
fastts(Start, "ftp", SLASH_SCHEME, WORD, wordjr);
fastts(Start, "ftps", SLASH_SCHEME, WORD, wordjr);
addToGroups(SCHEME, {
scheme: true,
ascii: true
}, groups);
addToGroups(SLASH_SCHEME, {
slashscheme: true,
ascii: true
}, groups);
customSchemes = customSchemes.sort((a, b) => a[0] > b[0] ? 1 : -1);
for (let i = 0; i < customSchemes.length; i++) {
const sch = customSchemes[i][0];
const optionalSlashSlash = customSchemes[i][1];
const flags = optionalSlashSlash ? {
[scheme]: true
} : {
[slashscheme]: true
};
if (sch.indexOf("-") >= 0) {
flags[domain] = true;
} else if (!ASCII_LETTER.test(sch)) {
flags[numeric] = true;
} else if (DIGIT.test(sch)) {
flags[asciinumeric] = true;
} else {
flags[ascii] = true;
}
ts(Start, sch, sch, flags);
}
ts(Start, "localhost", LOCALHOST, {
ascii: true
});
Start.jd = new State(SYM);
return {
start: Start,
tokens: Object.assign({
groups
}, tk)
};
}
function run$1(start, str) {
const iterable = stringToArray(str.replace(/[A-Z]/g, (c) => c.toLowerCase()));
const charCount = iterable.length;
const tokens = [];
let cursor = 0;
let charCursor = 0;
while (charCursor < charCount) {
let state = start;
let nextState = null;
let tokenLength = 0;
let latestAccepting = null;
let sinceAccepts = -1;
let charsSinceAccepts = -1;
while (charCursor < charCount && (nextState = state.go(iterable[charCursor]))) {
state = nextState;
if (state.accepts()) {
sinceAccepts = 0;
charsSinceAccepts = 0;
latestAccepting = state;
} else if (sinceAccepts >= 0) {
sinceAccepts += iterable[charCursor].length;
charsSinceAccepts++;
}
tokenLength += iterable[charCursor].length;
cursor += iterable[charCursor].length;
charCursor++;
}
cursor -= sinceAccepts;
charCursor -= charsSinceAccepts;
tokenLength -= sinceAccepts;
tokens.push({
t: latestAccepting.t,
// token type/name
v: str.slice(cursor - tokenLength, cursor),
// string value
s: cursor - tokenLength,
// start index
e: cursor
// end index (excluding)
});
}
return tokens;
}
function stringToArray(str) {
const result = [];
const len = str.length;
let index = 0;
while (index < len) {
let first = str.charCodeAt(index);
let second;
let char = first < 55296 || first > 56319 || index + 1 === len || (second = str.charCodeAt(index + 1)) < 56320 || second > 57343 ? str[index] : str.slice(index, index + 2);
result.push(char);
index += char.length;
}
return result;
}
function fastts(state, input, t, defaultt, jr) {
let next;
const len = input.length;
for (let i = 0; i < len - 1; i++) {
const char = input[i];
if (state.j[char]) {
next = state.j[char];
} else {
next = new State(defaultt);
next.jr = jr.slice();
state.j[char] = next;
}
state = next;
}
next = new State(t);
next.jr = jr.slice();
state.j[input[len - 1]] = next;
return next;
}
function decodeTlds(encoded) {
const words = [];
const stack = [];
let i = 0;
let digits = "0123456789";
while (i < encoded.length) {
let popDigitCount = 0;
while (digits.indexOf(encoded[i + popDigitCount]) >= 0) {
popDigitCount++;
}
if (popDigitCount > 0) {
words.push(stack.join(""));
for (let popCount = parseInt(encoded.substring(i, i + popDigitCount), 10); popCount > 0; popCount--) {
stack.pop();
}
i += popDigitCount;
} else {
stack.push(encoded[i]);
i++;
}
}
return words;
}
var defaults = {
defaultProtocol: "http",
events: null,
format: noop,
formatHref: noop,
nl2br: false,
tagName: "a",
target: null,
rel: null,
validate: true,
truncate: Infinity,
className: null,
attributes: null,
ignoreTags: [],
render: null
};
function Options(opts, defaultRender = null) {
let o = Object.assign({}, defaults);
if (opts) {
o = Object.assign(o, opts instanceof Options ? opts.o : opts);
}
const ignoredTags = o.ignoreTags;
const uppercaseIgnoredTags = [];
for (let i = 0; i < ignoredTags.length; i++) {
uppercaseIgnoredTags.push(ignoredTags[i].toUpperCase());
}
this.o = o;
if (defaultRender) {
this.defaultRender = defaultRender;
}
this.ignoreTags = uppercaseIgnoredTags;
}
Options.prototype = {
o: defaults,
/**
* @type string[]
*/
ignoreTags: [],
/**
* @param {IntermediateRepresentation} ir
* @returns {any}
*/
defaultRender(ir) {
return ir;
},
/**
* Returns true or false based on whether a token should be displayed as a
* link based on the user options.
* @param {MultiToken} token
* @returns {boolean}
*/
check(token) {
return this.get("validate", token.toString(), token);
},
// Private methods
/**
* Resolve an option's value based on the value of the option and the given
* params. If operator and token are specified and the target option is
* callable, automatically calls the function with the given argument.
* @template {keyof Opts} K
* @param {K} key Name of option to use
* @param {string} [operator] will be passed to the target option if it's a
* function. If not specified, RAW function value gets returned
* @param {MultiToken} [token] The token from linkify.tokenize
* @returns {Opts[K] | any}
*/
get(key, operator, token) {
const isCallable = operator != null;
let option = this.o[key];
if (!option) {
return option;
}
if (typeof option === "object") {
option = token.t in option ? option[token.t] : defaults[key];
if (typeof option === "function" && isCallable) {
option = option(operator, token);
}
} else if (typeof option === "function" && isCallable) {
option = option(operator, token.t, token);
}
return option;
},
/**
* @template {keyof Opts} L
* @param {L} key Name of options object to use
* @param {string} [operator]
* @param {MultiToken} [token]
* @returns {Opts[L] | any}
*/
getObj(key, operator, token) {
let obj = this.o[key];
if (typeof obj === "function" && operator != null) {
obj = obj(operator, token.t, token);
}
return obj;
},
/**
* Convert the given token to a rendered element that may be added to the
* calling-interface's DOM
* @param {MultiToken} token Token to render to an HTML element
* @returns {any} Render result; e.g., HTML string, DOM element, React
* Component, etc.
*/
render(token) {
const ir = token.render(this);
const renderFn = this.get("render", null, token) || this.defaultRender;
return renderFn(ir, token.t, token);
}
};
function noop(val) {
return val;
}
var options = Object.freeze({
__proto__: null,
Options,
defaults
});
function MultiToken(value, tokens) {
this.t = "token";
this.v = value;
this.tk = tokens;
}
MultiToken.prototype = {
isLink: false,
/**
* Return the string this token represents.
* @return {string}
*/
toString() {
return this.v;
},
/**
* What should the value for this token be in the `href` HTML attribute?
* Returns the `.toString` value by default.
* @param {string} [scheme]
* @return {string}
*/
toHref(scheme2) {
return this.toString();
},
/**
* @param {Options} options Formatting options
* @returns {string}
*/
toFormattedString(options2) {
const val = this.toString();
const truncate = options2.get("truncate", val, this);
const formatted = options2.get("format", val, this);
return truncate && formatted.length > truncate ? formatted.substring(0, truncate) + "…" : formatted;
},
/**
*
* @param {Options} options
* @returns {string}
*/
toFormattedHref(options2) {
return options2.get("formatHref", this.toHref(options2.get("defaultProtocol")), this);
},
/**
* The start index of this token in the original input string
* @returns {number}
*/
startIndex() {
return this.tk[0].s;
},
/**
* The end index of this token in the original input string (up to this
* index but not including it)
* @returns {number}
*/
endIndex() {
return this.tk[this.tk.length - 1].e;
},
/**
Returns an object of relevant values for this token, which includes keys
* type - Kind of token ('url', 'email', etc.)
* value - Original text
* href - The value that should be added to the anchor tag's href
attribute
@method toObject
@param {string} [protocol] `'http'` by default
*/
toObject(protocol = defaults.defaultProtocol) {
return {
type: this.t,
value: this.toString(),
isLink: this.isLink,
href: this.toHref(protocol),
start: this.startIndex(),
end: this.endIndex()
};
},
/**
*
* @param {Options} options Formatting option
*/
toFormattedObject(options2) {
return {
type: this.t,
value: this.toFormattedString(options2),
isLink: this.isLink,
href: this.toFormattedHref(options2),
start: this.startIndex(),
end: this.endIndex()
};
},
/**
* Whether this token should be rendered as a link according to the given options
* @param {Options} options
* @returns {boolean}
*/
validate(options2) {
return options2.get("validate", this.toString(), this);
},
/**
* Return an object that represents how this link should be rendered.
* @param {Options} options Formattinng options
*/
render(options2) {
const token = this;
const href = this.toHref(options2.get("defaultProtocol"));
const formattedHref = options2.get("formatHref", href, this);
const tagName = options2.get("tagName", href, token);
const content = this.toFormattedString(options2);
const attributes = {};
const className = options2.get("className", href, token);
const target = options2.get("target", href, token);
const rel = options2.get("rel", href, token);
const attrs = options2.getObj("attributes", href, token);
const eventListeners = options2.getObj("events", href, token);
attributes.href = formattedHref;
if (className) {
attributes.class = className;
}
if (target) {
attributes.target = target;
}
if (rel) {
attributes.rel = rel;
}
if (attrs) {
Object.assign(attributes, attrs);
}
return {
tagName,
attributes,
content,
eventListeners
};
}
};
function createTokenClass(type, props) {
class Token extends MultiToken {
constructor(value, tokens) {
super(value, tokens);
this.t = type;
}
}
for (const p in props) {
Token.prototype[p] = props[p];
}
Token.t = type;
return Token;
}
var Email = createTokenClass("email", {
isLink: true,
toHref() {
return "mailto:" + this.toString();
}
});
var Text = createTokenClass("text");
var Nl = createTokenClass("nl");
var Url = createTokenClass("url", {
isLink: true,
/**
Lowercases relevant parts of the domain and adds the protocol if
required. Note that this will not escape unsafe HTML characters in the
URL.
@param {string} [scheme] default scheme (e.g., 'https')
@return {string} the full href
*/
toHref(scheme2 = defaults.defaultProtocol) {
return this.hasProtocol() ? this.v : `${scheme2}://${this.v}`;
},
/**
* Check whether this URL token has a protocol
* @return {boolean}
*/
hasProtocol() {
const tokens = this.tk;
return tokens.length >= 2 && tokens[0].t !== LOCALHOST && tokens[1].t === COLON;
}
});
var multi = Object.freeze({
__proto__: null,
Base: MultiToken,
Email,
MultiToken,
Nl,
Text,
Url,
createTokenClass
});
var makeState = (arg) => new State(arg);
function init$1({
groups
}) {
const qsAccepting = groups.domain.concat([AMPERSAND, ASTERISK, AT, BACKSLASH, BACKTICK, CARET, DOLLAR, EQUALS, HYPHEN, NUM, PERCENT, PIPE, PLUS, POUND, SLASH, SYM, TILDE, UNDERSCORE]);
const qsNonAccepting = [APOSTROPHE, COLON, COMMA, DOT, EXCLAMATION, PERCENT, QUERY, QUOTE, SEMI, OPENANGLEBRACKET, CLOSEANGLEBRACKET, OPENBRACE, CLOSEBRACE, CLOSEBRACKET, OPENBRACKET, OPENPAREN, CLOSEPAREN, FULLWIDTHLEFTPAREN, FULLWIDTHRIGHTPAREN, LEFTCORNERBRACKET, RIGHTCORNERBRACKET, LEFTWHITECORNERBRACKET, RIGHTWHITECORNERBRACKET, FULLWIDTHLESSTHAN, FULLWIDTHGREATERTHAN];
const localpartAccepting = [AMPERSAND, APOSTROPHE, ASTERISK, BACKSLASH, BACKTICK, CARET, DOLLAR, EQUALS, HYPHEN, OPENBRACE, CLOSEBRACE, PERCENT, PIPE, PLUS, POUND, QUERY, SLASH, SYM, TILDE, UNDERSCORE];
const Start = makeState();
const Localpart = tt(Start, TILDE);
ta(Localpart, localpartAccepting, Localpart);
ta(Localpart, groups.domain, Localpart);
const Domain = makeState(), Scheme = makeState(), SlashScheme = makeState();
ta(Start, groups.domain, Domain);
ta(Start, groups.scheme, Scheme);
ta(Start, groups.slashscheme, SlashScheme);
ta(Domain, localpartAccepting, Localpart);
ta(Domain, groups.domain, Domain);
const LocalpartAt = tt(Domain, AT);
tt(Localpart, AT, LocalpartAt);
tt(Scheme, AT, LocalpartAt);
tt(SlashScheme, AT, LocalpartAt);
const LocalpartDot = tt(Localpart, DOT);
ta(LocalpartDot, localpartAccepting, Localpart);
ta(LocalpartDot, groups.domain, Localpart);
const EmailDomain = makeState();
ta(LocalpartAt, groups.domain, EmailDomain);
ta(EmailDomain, groups.domain, EmailDomain);
const EmailDomainDot = tt(EmailDomain, DOT);
ta(EmailDomainDot, groups.domain, EmailDomain);
const Email$1 = makeState(Email);
ta(EmailDomainDot, groups.tld, Email$1);
ta(EmailDomainDot, groups.utld, Email$1);
tt(LocalpartAt, LOCALHOST, Email$1);
const EmailDomainHyphen = tt(EmailDomain, HYPHEN);
tt(EmailDomainHyphen, HYPHEN, EmailDomainHyphen);
ta(EmailDomainHyphen, groups.domain, EmailDomain);
ta(Email$1, groups.domain, EmailDomain);
tt(Email$1, DOT, EmailDomainDot);
tt(Email$1, HYPHEN, EmailDomainHyphen);
const DomainHyphen = tt(Domain, HYPHEN);
const DomainDot = tt(Domain, DOT);
tt(DomainHyphen, HYPHEN, DomainHyphen);
ta(DomainHyphen, groups.domain, Domain);
ta(DomainDot, localpartAccepting, Localpart);
ta(DomainDot, groups.domain, Domain);
const DomainDotTld = makeState(Url);
ta(DomainDot, groups.tld, DomainDotTld);
ta(DomainDot, groups.utld, DomainDotTld);
ta(DomainDotTld, groups.domain, Domain);
ta(DomainDotTld, localpartAccepting, Localpart);
tt(DomainDotTld, DOT, DomainDot);
tt(DomainDotTld, HYPHEN, DomainHyphen);
tt(DomainDotTld, AT, LocalpartAt);
const DomainDotTldColon = tt(DomainDotTld, COLON);
const DomainDotTldColonPort = makeState(Url);
ta(DomainDotTldColon, groups.numeric, DomainDotTldColonPort);
const Url$1 = makeState(Url);
const UrlNonaccept = makeState();
ta(Url$1, qsAccepting, Url$1);
ta(Url$1, qsNonAccepting, UrlNonaccept);
ta(UrlNonaccept, qsAccepting, Url$1);
ta(UrlNonaccept, qsNonAccepting, UrlNonaccept);
tt(DomainDotTld, SLASH, Url$1);
tt(DomainDotTldColonPort, SLASH, Url$1);
const SchemeColon = tt(Scheme, COLON);
const SlashSchemeColon = tt(SlashScheme, COLON);
const SlashSchemeColonSlash = tt(SlashSchemeColon, SLASH);
const UriPrefix = tt(SlashSchemeColonSlash, SLASH);
ta(Scheme, groups.domain, Domain);
tt(Scheme, DOT, DomainDot);
tt(Scheme, HYPHEN, DomainHyphen);
ta(SlashScheme, groups.domain, Domain);
tt(SlashScheme, DOT, DomainDot);
tt(SlashScheme, HYPHEN, DomainHyphen);
ta(SchemeColon, groups.domain, Url$1);
tt(SchemeColon, SLASH, Url$1);
tt(SchemeColon, QUERY, Url$1);
ta(UriPrefix, groups.domain, Url$1);
ta(UriPrefix, qsAccepting, Url$1);
tt(UriPrefix, SLASH, Url$1);
const bracketPairs = [
[OPENBRACE, CLOSEBRACE],
// {}
[OPENBRACKET, CLOSEBRACKET],
// []
[OPENPAREN, CLOSEPAREN],
// ()
[OPENANGLEBRACKET, CLOSEANGLEBRACKET],
// <>
[FULLWIDTHLEFTPAREN, FULLWIDTHRIGHTPAREN],
// ()
[LEFTCORNERBRACKET, RIGHTCORNERBRACKET],
// 「」
[LEFTWHITECORNERBRACKET, RIGHTWHITECORNERBRACKET],
// 『』
[FULLWIDTHLESSTHAN, FULLWIDTHGREATERTHAN]
// <>
];
for (let i = 0; i < bracketPairs.length; i++) {
const [OPEN, CLOSE] = bracketPairs[i];
const UrlOpen = tt(Url$1, OPEN);
tt(UrlNonaccept, OPEN, UrlOpen);
const UrlOpenQ = makeState(Url);
ta(UrlOpen, qsAccepting, UrlOpenQ);
const UrlOpenSyms = makeState();
ta(UrlOpen, qsNonAccepting, UrlOpenSyms);
tt(UrlOpen, CLOSE, Url$1);
ta(UrlOpenQ, qsAccepting, UrlOpenQ);
ta(UrlOpenQ, qsNonAccepting, UrlOpenSyms);
ta(UrlOpenSyms, qsAccepting, UrlOpenQ);
ta(UrlOpenSyms, qsNonAccepting, UrlOpenSyms);
tt(UrlOpenQ, CLOSE, Url$1);
tt(UrlOpenSyms, CLOSE, Url$1);
}
tt(Start, LOCALHOST, DomainDotTld);
tt(Start, NL, Nl);
return {
start: Start,
tokens: tk
};
}
function run(start, input, tokens) {
let len = tokens.length;
let cursor = 0;
let multis = [];
let textTokens = [];
while (cursor < len) {
let state = start;
let secondState = null;
let nextState = null;
let multiLength = 0;
let latestAccepting = null;
let sinceAccepts = -1;
while (cursor < len && !(secondState = state.go(tokens[cursor].t))) {
textTokens.push(tokens[cursor++]);
}
while (cursor < len && (nextState = secondState || state.go(tokens[cursor].t))) {
secondState = null;
state = nextState;
if (state.accepts()) {
sinceAccepts = 0;
latestAccepting = state;
} else if (sinceAccepts >= 0) {
sinceAccepts++;
}
cursor++;
multiLength++;
}
if (sinceAccepts < 0) {
cursor -= multiLength;
if (cursor < len) {
textTokens.push(tokens[cursor]);
cursor++;
}
} else {
if (textTokens.length > 0) {
multis.push(initMultiToken(Text, input, textTokens));
textTokens = [];
}
cursor -= sinceAccepts;
multiLength -= sinceAccepts;
const Multi = latestAccepting.t;
const subtokens = tokens.slice(cursor - multiLength, cursor);
multis.push(initMultiToken(Multi, input, subtokens));
}
}
if (textTokens.length > 0) {
multis.push(initMultiToken(Text, input, textTokens));
}
return multis;
}
function initMultiToken(Multi, input, tokens) {
const startIdx = tokens[0].s;
const endIdx = tokens[tokens.length - 1].e;
const value = input.slice(startIdx, endIdx);
return new Multi(value, tokens);
}
var warn = typeof console !== "undefined" && console && console.warn || (() => {
});
var warnAdvice = "until manual call of linkify.init(). Register all schemes and plugins before invoking linkify the first time.";
var INIT = {
scanner: null,
parser: null,
tokenQueue: [],
pluginQueue: [],
customSchemes: [],
initialized: false
};
function reset() {
State.groups = {};
INIT.scanner = null;
INIT.parser = null;
INIT.tokenQueue = [];
INIT.pluginQueue = [];
INIT.customSchemes = [];
INIT.initialized = false;
return INIT;
}
function registerCustomProtocol(scheme2, optionalSlashSlash = false) {
if (INIT.initialized) {
warn(`linkifyjs: already initialized - will not register custom scheme "${scheme2}" ${warnAdvice}`);
}
if (!/^[0-9a-z]+(-[0-9a-z]+)*$/.test(scheme2)) {
throw new Error(`linkifyjs: incorrect scheme format.
1. Must only contain digits, lowercase ASCII letters or "-"
2. Cannot start or end with "-"
3. "-" cannot repeat`);
}
INIT.customSchemes.push([scheme2, optionalSlashSlash]);
}
function init() {
INIT.scanner = init$2(INIT.customSchemes);
for (let i = 0; i < INIT.tokenQueue.length; i++) {
INIT.tokenQueue[i][1]({
scanner: INIT.scanner
});
}
INIT.parser = init$1(INIT.scanner.tokens);
for (let i = 0; i < INIT.pluginQueue.length; i++) {
INIT.pluginQueue[i][1]({
scanner: INIT.scanner,
parser: INIT.parser
});
}
INIT.initialized = true;
return INIT;
}
function tokenize(str) {
if (!INIT.initialized) {
init();
}
return run(INIT.parser.start, str, run$1(INIT.scanner.start, str));
}
tokenize.scan = run$1;
function find(str, type = null, opts = null) {
if (type && typeof type === "object") {
if (opts) {
throw Error(`linkifyjs: Invalid link type ${type}; must be a string`);
}
opts = type;
type = null;
}
const options2 = new Options(opts);
const tokens = tokenize(str);
const filtered = [];
for (let i = 0; i < tokens.length; i++) {
const token = tokens[i];
if (token.isLink && (!type || token.t === type) && options2.check(token)) {
filtered.push(token.toFormattedObject(options2));
}
}
return filtered;
}
// node_modules/@tiptap/extension-link/dist/index.js
var UNICODE_WHITESPACE_PATTERN = "[\0- -\u2029 ]";
var UNICODE_WHITESPACE_REGEX = new RegExp(UNICODE_WHITESPACE_PATTERN);
var UNICODE_WHITESPACE_REGEX_END = new RegExp(`${UNICODE_WHITESPACE_PATTERN}$`);
var UNICODE_WHITESPACE_REGEX_GLOBAL = new RegExp(UNICODE_WHITESPACE_PATTERN, "g");
function isValidLinkStructure(tokens) {
if (tokens.length === 1) {
return tokens[0].isLink;
}
if (tokens.length === 3 && tokens[1].isLink) {
return ["()", "[]"].includes(tokens[0].value + tokens[2].value);
}
return false;
}
function autolink(options2) {
return new Plugin({
key: new PluginKey("autolink"),
appendTransaction: (transactions, oldState, newState) => {
const docChanges = transactions.some((transaction) => transaction.docChanged) && !oldState.doc.eq(newState.doc);
const preventAutolink = transactions.some(
(transaction) => transaction.getMeta("preventAutolink")
);
if (!docChanges || preventAutolink) {
return;
}
const { tr: tr2 } = newState;
const transform = combineTransactionSteps(oldState.doc, [...transactions]);
const changes = getChangedRanges(transform);
changes.forEach(({ newRange }) => {
const nodesInChangedRanges = findChildrenInRange(
newState.doc,
newRange,
(node) => node.isTextblock
);
let textBlock;
let textBeforeWhitespace;
if (nodesInChangedRanges.length > 1) {
textBlock = nodesInChangedRanges[0];
textBeforeWhitespace = newState.doc.textBetween(
textBlock.pos,
textBlock.pos + textBlock.node.nodeSize,
void 0,
" "
);
} else if (nodesInChangedRanges.length) {
const endText = newState.doc.textBetween(newRange.from, newRange.to, " ", " ");
if (!UNICODE_WHITESPACE_REGEX_END.test(endText)) {
return;
}
textBlock = nodesInChangedRanges[0];
textBeforeWhitespace = newState.doc.textBetween(
textBlock.pos,
newRange.to,
void 0,
" "
);
}
if (textBlock && textBeforeWhitespace) {
const wordsBeforeWhitespace = textBeforeWhitespace.split(UNICODE_WHITESPACE_REGEX).filter(Boolean);
if (wordsBeforeWhitespace.length <= 0) {
return false;
}
const lastWordBeforeSpace = wordsBeforeWhitespace[wordsBeforeWhitespace.length - 1];
const lastWordAndBlockOffset = textBlock.pos + textBeforeWhitespace.lastIndexOf(lastWordBeforeSpace);
if (!lastWordBeforeSpace) {
return false;
}
const linksBeforeSpace = tokenize(lastWordBeforeSpace).map(
(t) => t.toObject(options2.defaultProtocol)
);
if (!isValidLinkStructure(linksBeforeSpace)) {
return false;
}
linksBeforeSpace.filter((link) => link.isLink).map((link) => ({
...link,
from: lastWordAndBlockOffset + link.start + 1,
to: lastWordAndBlockOffset + link.end + 1
})).filter((link) => {
if (!newState.schema.marks.code) {
return true;
}
return !newState.doc.rangeHasMark(link.from, link.to, newState.schema.marks.code);
}).filter((link) => options2.validate(link.value)).filter((link) => options2.shouldAutoLink(link.value)).forEach((link) => {
if (getMarksBetween(link.from, link.to, newState.doc).some(
(item) => item.mark.type === options2.type
)) {
return;
}
tr2.addMark(
link.from,
link.to,
options2.type.create({
href: link.href
})
);
});
}
});
if (!tr2.steps.length) {
return;
}
return tr2;
}
});
}
function clickHandler(options2) {
return new Plugin({
key: new PluginKey("handleClickLink"),
props: {
handleClick: (view, pos, event) => {
var _a, _b;
if (event.button !== 0) {
return false;
}
if (!view.editable) {
return false;
}
let link = null;
if (event.target instanceof HTMLAnchorElement) {
link = event.target;
} else {
const target = event.target;
if (!target) {
return false;
}
const root = options2.editor.view.dom;
link = target.closest("a");
if (link && !root.contains(link)) {
link = null;
}
}
if (!link) {
return false;
}
let handled = false;
if (options2.enableClickSelection) {
const commandResult = options2.editor.commands.extendMarkRange(options2.type.name);
handled = commandResult;
}
if (options2.openOnClick) {
const attrs = getAttributes(view.state, options2.type.name);
const href = (_a = link.href) != null ? _a : attrs.href;
const target = (_b = link.target) != null ? _b : attrs.target;
if (href) {
window.open(href, target);
handled = true;
}
}
return handled;
}
}
});
}
function pasteHandler(options2) {
return new Plugin({
key: new PluginKey("handlePasteLink"),
props: {
handlePaste: (view, _event, slice2) => {
const { shouldAutoLink } = options2;
const { state } = view;
const { selection } = state;
const { empty } = selection;
if (empty) {
return false;
}
let textContent = "";
slice2.content.forEach((node) => {
textContent += node.textContent;
});
const link = find(textContent, { defaultProtocol: options2.defaultProtocol }).find(
(item) => item.isLink && item.value === textContent
);
if (!textContent || !link || shouldAutoLink !== void 0 && !shouldAutoLink(link.value)) {
return false;
}
return options2.editor.commands.setMark(options2.type, {
href: link.href
});
}
}
});
}
function isAllowedUri(uri, protocols) {
const allowedProtocols = [
"http",
"https",
"ftp",
"ftps",
"mailto",
"tel",
"callto",
"sms",
"cid",
"xmpp"
];
if (protocols) {
protocols.forEach((protocol) => {
const nextProtocol = typeof protocol === "string" ? protocol : protocol.scheme;
if (nextProtocol) {
allowedProtocols.push(nextProtocol);
}
});
}
return !uri || uri.replace(UNICODE_WHITESPACE_REGEX_GLOBAL, "").match(
new RegExp(
// oxlint-disable-next-line no-useless-escape
`^(?:(?:${allowedProtocols.join("|")}):|[^a-z]|[a-z0-9+.-]+(?:[^a-z+.-:]|$))`,
"i"
)
);
}
var Link = Mark.create({
name: "link",
priority: 1e3,
keepOnSplit: false,
exitable: true,
onCreate() {
if (this.options.validate && !this.options.shouldAutoLink) {
this.options.shouldAutoLink = this.options.validate;
console.warn(
"The `validate` option is deprecated. Rename to the `shouldAutoLink` option instead."
);
}
this.options.protocols.forEach((protocol) => {
if (typeof protocol === "string") {
registerCustomProtocol(protocol);
return;
}
registerCustomProtocol(protocol.scheme, protocol.optionalSlashes);
});
},
onDestroy() {
reset();
},
inclusive() {
return this.options.autolink;
},
addOptions() {
return {
openOnClick: true,
enableClickSelection: false,
linkOnPaste: true,
autolink: true,
protocols: [],
defaultProtocol: "http",
HTMLAttributes: {
target: "_blank",
rel: "noopener noreferrer nofollow",
class: null
},
isAllowedUri: (url, ctx) => !!isAllowedUri(url, ctx.protocols),
validate: (url) => !!url,
shouldAutoLink: (url) => {
const hasProtocol = /^[a-z][a-z0-9+.-]*:\/\//i.test(url);
const hasMaybeProtocol = /^[a-z][a-z0-9+.-]*:/i.test(url);
if (hasProtocol || hasMaybeProtocol && !url.includes("@")) {
return true;
}
const urlWithoutUserinfo = url.includes("@") ? url.split("@").pop() : url;
const hostname = urlWithoutUserinfo.split(/[/?#:]/)[0];
if (/^\d{1,3}(\.\d{1,3}){3}$/.test(hostname)) {
return false;
}
if (!/\./.test(hostname)) {
return false;
}
return true;
}
};
},
addAttributes() {
return {
href: {
default: null,
parseHTML(element) {
return element.getAttribute("href");
}
},
target: {
default: this.options.HTMLAttributes.target
},
rel: {
default: this.options.HTMLAttributes.rel
},
class: {
default: this.options.HTMLAttributes.class
},
title: {
default: null
}
};
},
parseHTML() {
return [
{
tag: "a[href]",
getAttrs: (dom) => {
const href = dom.getAttribute("href");
if (!href || !this.options.isAllowedUri(href, {
defaultValidate: (url) => !!isAllowedUri(url, this.options.protocols),
protocols: this.options.protocols,
defaultProtocol: this.options.defaultProtocol
})) {
return false;
}
return null;
}
}
];
},
renderHTML({ HTMLAttributes }) {
if (!this.options.isAllowedUri(HTMLAttributes.href, {
defaultValidate: (href) => !!isAllowedUri(href, this.options.protocols),
protocols: this.options.protocols,
defaultProtocol: this.options.defaultProtocol
})) {
return ["a", mergeAttributes(this.options.HTMLAttributes, { ...HTMLAttributes, href: "" }), 0];
}
return ["a", mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), 0];
},
markdownTokenName: "link",
parseMarkdown: (token, helpers) => {
return helpers.applyMark("link", helpers.parseInline(token.tokens || []), {
href: token.href,
title: token.title || null
});
},
renderMarkdown: (node, h2) => {
var _a, _b, _c, _d;
const href = (_b = (_a = node.attrs) == null ? void 0 : _a.href) != null ? _b : "";
const title = (_d = (_c = node.attrs) == null ? void 0 : _c.title) != null ? _d : "";
const text = h2.renderChildren(node);
return title ? `[${text}](${href} "${title}")` : `[${text}](${href})`;
},
addCommands() {
return {
setLink: (attributes) => ({ chain }) => {
const { href } = attributes;
if (!this.options.isAllowedUri(href, {
defaultValidate: (url) => !!isAllowedUri(url, this.options.protocols),
protocols: this.options.protocols,
defaultProtocol: this.options.defaultProtocol
})) {
return false;
}
return chain().setMark(this.name, attributes).setMeta("preventAutolink", true).run();
},
toggleLink: (attributes) => ({ chain }) => {
const { href } = attributes || {};
if (href && !this.options.isAllowedUri(href, {
defaultValidate: (url) => !!isAllowedUri(url, this.options.protocols),
protocols: this.options.protocols,
defaultProtocol: this.options.defaultProtocol
})) {
return false;
}
return chain().toggleMark(this.name, attributes, { extendEmptyMarkRange: true }).setMeta("preventAutolink", true).run();
},
unsetLink: () => ({ chain }) => {
return chain().unsetMark(this.name, { extendEmptyMarkRange: true }).setMeta("preventAutolink", true).run();
}
};
},
addPasteRules() {
return [
markPasteRule({
find: (text) => {
const foundLinks = [];
if (text) {
const { protocols, defaultProtocol } = this.options;
const links = find(text).filter(
(item) => item.isLink && this.options.isAllowedUri(item.value, {
defaultValidate: (href) => !!isAllowedUri(href, protocols),
protocols,
defaultProtocol
})
);
if (links.length) {
links.forEach((link) => {
if (!this.options.shouldAutoLink(link.value)) {
return;
}
foundLinks.push({
text: link.value,
data: {
href: link.href
},
index: link.start
});
});
}
}
return foundLinks;
},
type: this.type,
getAttributes: (match) => {
var _a;
return {
href: (_a = match.data) == null ? void 0 : _a.href
};
}
})
];
},
addProseMirrorPlugins() {
const plugins = [];
const { protocols, defaultProtocol } = this.options;
if (this.options.autolink) {
plugins.push(
autolink({
type: this.type,
defaultProtocol: this.options.defaultProtocol,
validate: (url) => this.options.isAllowedUri(url, {
defaultValidate: (href) => !!isAllowedUri(href, protocols),
protocols,
defaultProtocol
}),
shouldAutoLink: this.options.shouldAutoLink
})
);
}
plugins.push(
clickHandler({
type: this.type,
editor: this.editor,
openOnClick: this.options.openOnClick === "whenNotEditable" ? true : this.options.openOnClick,
enableClickSelection: this.options.enableClickSelection
})
);
if (this.options.linkOnPaste) {
plugins.push(
pasteHandler({
editor: this.editor,
defaultProtocol: this.options.defaultProtocol,
type: this.type,
shouldAutoLink: this.options.shouldAutoLink
})
);
}
return plugins;
}
});
// node_modules/@tiptap/extension-list/dist/index.js
var __defProp = Object.defineProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var ListItemName = "listItem";
var TextStyleName = "textStyle";
var bulletListInputRegex = /^\s*([-+*])\s$/;
var BulletList = Node3.create({
name: "bulletList",
addOptions() {
return {
itemTypeName: "listItem",
HTMLAttributes: {},
keepMarks: false,
keepAttributes: false
};
},
group: "block list",
content() {
return `${this.options.itemTypeName}+`;
},
parseHTML() {
return [{ tag: "ul" }];
},
renderHTML({ HTMLAttributes }) {
return ["ul", mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), 0];
},
markdownTokenName: "list",
parseMarkdown: (token, helpers) => {
if (token.type !== "list" || token.ordered) {
return [];
}
return {
type: "bulletList",
content: token.items ? helpers.parseChildren(token.items) : []
};
},
renderMarkdown: (node, h2) => {
if (!node.content) {
return "";
}
return h2.renderChildren(node.content, "\n");
},
markdownOptions: {
indentsContent: true
},
addCommands() {
return {
toggleBulletList: () => ({ commands, chain }) => {
if (this.options.keepAttributes) {
return chain().toggleList(this.name, this.options.itemTypeName, this.options.keepMarks).updateAttributes(ListItemName, this.editor.getAttributes(TextStyleName)).run();
}
return commands.toggleList(this.name, this.options.itemTypeName, this.options.keepMarks);
}
};
},
addKeyboardShortcuts() {
return {
"Mod-Shift-8": () => this.editor.commands.toggleBulletList()
};
},
addInputRules() {
let inputRule = wrappingInputRule({
find: bulletListInputRegex,
type: this.type
});
if (this.options.keepMarks || this.options.keepAttributes) {
inputRule = wrappingInputRule({
find: bulletListInputRegex,
type: this.type,
keepMarks: this.options.keepMarks,
keepAttributes: this.options.keepAttributes,
getAttributes: () => {
return this.editor.getAttributes(TextStyleName);
},
editor: this.editor
});
}
return [inputRule];
}
});
var getBranchingNestedListAtCursor = (state, itemName, wrapperNames) => {
const { selection } = state;
if (!selection.empty) {
return null;
}
const { $from } = selection;
if (!$from.parent.isTextblock) {
return null;
}
if ($from.parentOffset !== $from.parent.content.size) {
return null;
}
let listItemDepth = -1;
for (let depth = $from.depth; depth > 0; depth -= 1) {
if ($from.node(depth).type.name === itemName) {
listItemDepth = depth;
break;
}
}
if (listItemDepth < 0) {
return null;
}
const listItem = $from.node(listItemDepth);
const indexInListItem = $from.index(listItemDepth);
if (indexInListItem + 1 >= listItem.childCount) {
return null;
}
const nextChild = listItem.child(indexInListItem + 1);
if (!wrapperNames.includes(nextChild.type.name)) {
return null;
}
const itemType = state.schema.nodes[itemName];
let hasBranching = false;
nextChild.forEach((child) => {
if (child.type === itemType && child.childCount > 1) {
hasBranching = true;
}
});
if (!hasBranching) {
return null;
}
const nodeAfter = state.doc.resolve($from.after()).nodeAfter;
if (!nodeAfter || !wrapperNames.includes(nodeAfter.type.name)) {
return null;
}
const items = [];
nodeAfter.forEach((child) => {
items.push(child);
});
if (items.length === 0) {
return null;
}
return {
listItemDepth,
nestedList: nodeAfter,
nestedListPos: $from.after(),
insertPos: $from.after(listItemDepth),
items
};
};
var hoistBranchingNestedList = (state, dispatch, itemName, wrapperNames) => {
const context = getBranchingNestedListAtCursor(state, itemName, wrapperNames);
if (!context) {
return false;
}
const { selection } = state;
const { nestedList, nestedListPos, insertPos, items } = context;
const tr2 = state.tr;
tr2.delete(nestedListPos, nestedListPos + nestedList.nodeSize);
const mappedInsertPos = tr2.mapping.map(insertPos);
tr2.insert(mappedInsertPos, Fragment.from(items));
tr2.setSelection(selection.map(tr2.doc, tr2.mapping));
if (dispatch) {
dispatch(tr2);
}
return true;
};
var handleDeleteBranchingNestedList = (editor, itemName, wrapperNames) => {
return hoistBranchingNestedList(editor.state, editor.view.dispatch, itemName, wrapperNames);
};
var createBranchingListDeleteKeymap = (itemName, wrapperNames) => {
return Extension.create({
name: `${itemName}BranchingDeleteKeymap`,
priority: 101,
addKeyboardShortcuts() {
const handleDelete2 = () => handleDeleteBranchingNestedList(this.editor, itemName, wrapperNames);
return {
Delete: handleDelete2,
"Mod-Delete": handleDelete2
};
}
});
};
function isSameLineOrderedListToken(token) {
var _a, _b;
const nestedToken = (_a = token.tokens) == null ? void 0 : _a[0];
return Boolean(
token.text && ((_b = token.tokens) == null ? void 0 : _b.length) === 1 && (nestedToken == null ? void 0 : nestedToken.type) === "list" && nestedToken.ordered && nestedToken.raw === token.text
);
}
function parseSameLineOrderedListText(text, helpers) {
if (helpers.tokenizeInline) {
return helpers.parseInline(helpers.tokenizeInline(text));
}
return helpers.parseInline([
{
type: "text",
raw: text,
text
}
]);
}
var ListItem = Node3.create({
name: "listItem",
addOptions() {
return {
HTMLAttributes: {},
bulletListTypeName: "bulletList",
orderedListTypeName: "orderedList"
};
},
content: "paragraph block*",
defining: true,
parseHTML() {
return [
{
tag: "li"
}
];
},
renderHTML({ HTMLAttributes }) {
return ["li", mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), 0];
},
markdownTokenName: "list_item",
parseMarkdown: (token, helpers) => {
var _a;
if (token.type !== "list_item") {
return [];
}
const parseBlockChildren = (_a = helpers.parseBlockChildren) != null ? _a : helpers.parseChildren;
let content = [];
if (token.tokens && token.tokens.length > 0) {
if (isSameLineOrderedListToken(token)) {
return {
type: "listItem",
content: [
{
type: "paragraph",
content: parseSameLineOrderedListText(token.text || "", helpers)
}
]
};
}
const hasParagraphTokens = token.tokens.some((t) => t.type === "paragraph");
if (hasParagraphTokens) {
content = parseBlockChildren(token.tokens);
} else {
const firstToken = token.tokens[0];
if (firstToken && firstToken.type === "text" && firstToken.tokens && firstToken.tokens.length > 0) {
const inlineContent = helpers.parseInline(firstToken.tokens);
content = [
{
type: "paragraph",
content: inlineContent
}
];
if (token.tokens.length > 1) {
const remainingTokens = token.tokens.slice(1);
const additionalContent = parseBlockChildren(remainingTokens);
content.push(...additionalContent);
}
} else {
content = parseBlockChildren(token.tokens);
}
}
}
if (content.length === 0) {
content = [
{
type: "paragraph",
content: []
}
];
}
return {
type: "listItem",
content
};
},
renderMarkdown: (node, h2, ctx) => {
return renderNestedMarkdownContent(
node,
h2,
(context) => {
var _a, _b;
if (context.parentType === "bulletList") {
return "- ";
}
if (context.parentType === "orderedList") {
const start = ((_b = (_a = context.meta) == null ? void 0 : _a.parentAttrs) == null ? void 0 : _b.start) || 1;
return `${start + context.index}. `;
}
return "- ";
},
ctx
);
},
addExtensions() {
return [
createBranchingListDeleteKeymap(this.name, [
this.options.bulletListTypeName,
this.options.orderedListTypeName
])
];
},
addKeyboardShortcuts() {
return {
Enter: () => this.editor.commands.splitListItem(this.name),
Tab: () => this.editor.commands.sinkListItem(this.name),
"Shift-Tab": () => this.editor.commands.liftListItem(this.name)
};
}
});
var listHelpers_exports = {};
__export(listHelpers_exports, {
findListItemPos: () => findListItemPos,
getNextListDepth: () => getNextListDepth,
handleBackspace: () => handleBackspace,
handleDelete: () => handleDelete,
hasListBefore: () => hasListBefore,
hasListItemAfter: () => hasListItemAfter,
hasListItemBefore: () => hasListItemBefore,
listItemHasSubList: () => listItemHasSubList,
nextListIsDeeper: () => nextListIsDeeper,
nextListIsHigher: () => nextListIsHigher
});
var findListItemPos = (typeOrName, state) => {
const { $from } = state.selection;
const nodeType = getNodeType(typeOrName, state.schema);
let currentNode = null;
let currentDepth = $from.depth;
let currentPos = $from.pos;
let targetDepth = null;
while (currentDepth > 0 && targetDepth === null) {
currentNode = $from.node(currentDepth);
if (currentNode.type === nodeType) {
targetDepth = currentDepth;
} else {
currentDepth -= 1;
currentPos -= 1;
}
}
if (targetDepth === null) {
return null;
}
return { $pos: state.doc.resolve(currentPos), depth: targetDepth };
};
var getNextListDepth = (typeOrName, state) => {
const listItemPos = findListItemPos(typeOrName, state);
if (!listItemPos) {
return false;
}
const [, depth] = getNodeAtPosition(state, typeOrName, listItemPos.$pos.pos + 4);
return depth;
};
var hasListBefore = (editorState, name, parentListTypes) => {
const { $anchor } = editorState.selection;
const previousNodePos = Math.max(0, $anchor.pos - 2);
const previousNode = editorState.doc.resolve(previousNodePos).node();
if (!previousNode || !parentListTypes.includes(previousNode.type.name)) {
return false;
}
return true;
};
var handleBackspace = (editor, name, parentListTypes) => {
if (editor.commands.undoInputRule()) {
return true;
}
if (editor.state.selection.from !== editor.state.selection.to) {
return false;
}
if (!isNodeActive(editor.state, name) && hasListBefore(editor.state, name, parentListTypes)) {
const { $anchor } = editor.state.selection;
const $listPos = editor.state.doc.resolve($anchor.before() - 1);
const listDescendants = [];
$listPos.node().descendants((node, pos) => {
if (node.type.name === name) {
listDescendants.push({ node, pos });
}
});
const lastItem = listDescendants.at(-1);
if (!lastItem) {
return false;
}
const $lastItemPos = editor.state.doc.resolve($listPos.start() + lastItem.pos + 1);
return editor.chain().cut({ from: $anchor.start() - 1, to: $anchor.end() + 1 }, $lastItemPos.end()).joinForward().run();
}
if (!isNodeActive(editor.state, name)) {
return false;
}
if (!isAtStartOfNode(editor.state)) {
return false;
}
return editor.chain().liftListItem(name).run();
};
var nextListIsDeeper = (typeOrName, state) => {
const listDepth = getNextListDepth(typeOrName, state);
const listItemPos = findListItemPos(typeOrName, state);
if (!listItemPos || !listDepth) {
return false;
}
if (listDepth > listItemPos.depth) {
return true;
}
return false;
};
var nextListIsHigher = (typeOrName, state) => {
const listDepth = getNextListDepth(typeOrName, state);
const listItemPos = findListItemPos(typeOrName, state);
if (!listItemPos || !listDepth) {
return false;
}
if (listDepth < listItemPos.depth) {
return true;
}
return false;
};
var handleDelete = (editor, name) => {
if (!isNodeActive(editor.state, name)) {
return false;
}
if (!isAtEndOfNode(editor.state, name)) {
return false;
}
const { selection } = editor.state;
const { $from, $to } = selection;
if (!selection.empty && $from.sameParent($to)) {
return false;
}
if (nextListIsDeeper(name, editor.state)) {
return editor.chain().focus(editor.state.selection.from + 4).lift(name).joinBackward().run();
}
if (nextListIsHigher(name, editor.state)) {
return editor.chain().joinForward().joinBackward().run();
}
return editor.commands.joinItemForward();
};
var hasListItemAfter = (typeOrName, state) => {
var _a;
const { $anchor } = state.selection;
const $targetPos = state.doc.resolve($anchor.pos - $anchor.parentOffset - 2);
if ($targetPos.index() === $targetPos.parent.childCount - 1) {
return false;
}
if (((_a = $targetPos.nodeAfter) == null ? void 0 : _a.type.name) !== typeOrName) {
return false;
}
return true;
};
var hasListItemBefore = (typeOrName, state) => {
var _a;
const { $anchor } = state.selection;
const $targetPos = state.doc.resolve($anchor.pos - 2);
if ($targetPos.index() === 0) {
return false;
}
if (((_a = $targetPos.nodeBefore) == null ? void 0 : _a.type.name) !== typeOrName) {
return false;
}
return true;
};
var listItemHasSubList = (typeOrName, state, node) => {
if (!node) {
return false;
}
const nodeType = getNodeType(typeOrName, state.schema);
let hasSubList = false;
node.descendants((child) => {
if (child.type === nodeType) {
hasSubList = true;
}
});
return hasSubList;
};
var ListKeymap = Extension.create({
name: "listKeymap",
addOptions() {
return {
listTypes: [
{
itemName: "listItem",
wrapperNames: ["bulletList", "orderedList"]
},
{
itemName: "taskItem",
wrapperNames: ["taskList"]
}
]
};
},
addKeyboardShortcuts() {
return {
Delete: ({ editor }) => {
let handled = false;
this.options.listTypes.forEach(({ itemName }) => {
if (editor.state.schema.nodes[itemName] === void 0) {
return;
}
if (handleDelete(editor, itemName)) {
handled = true;
}
});
return handled;
},
"Mod-Delete": ({ editor }) => {
let handled = false;
this.options.listTypes.forEach(({ itemName }) => {
if (editor.state.schema.nodes[itemName] === void 0) {
return;
}
if (handleDelete(editor, itemName)) {
handled = true;
}
});
return handled;
},
Backspace: ({ editor }) => {
let handled = false;
this.options.listTypes.forEach(({ itemName, wrapperNames }) => {
if (editor.state.schema.nodes[itemName] === void 0) {
return;
}
if (handleBackspace(editor, itemName, wrapperNames)) {
handled = true;
}
});
return handled;
},
"Mod-Backspace": ({ editor }) => {
let handled = false;
this.options.listTypes.forEach(({ itemName, wrapperNames }) => {
if (editor.state.schema.nodes[itemName] === void 0) {
return;
}
if (handleBackspace(editor, itemName, wrapperNames)) {
handled = true;
}
});
return handled;
}
};
}
});
var ORDERED_LIST_ITEM_REGEX = /^(\s*)(\d+)\.\s+(.*)$/;
var INDENTED_LINE_REGEX = /^\s/;
function isBlockContentLine(line) {
const trimmedLine = line.trimStart();
return (
// oxlint-disable-next-line prefer-string-starts-ends-with
/^[-+*]\s+/.test(trimmedLine) || // oxlint-disable-next-line prefer-string-starts-ends-with
/^\d+\.\s+/.test(trimmedLine) || // oxlint-disable-next-line prefer-string-starts-ends-with
/^>\s?/.test(trimmedLine) || // oxlint-disable-next-line prefer-string-starts-ends-with
/^```/.test(trimmedLine) || // oxlint-disable-next-line prefer-string-starts-ends-with
/^~~~/.test(trimmedLine)
);
}
function splitItemContent(contentLines) {
const paragraphLines = [];
const blockLines = [];
let reachedBlockBoundary = false;
contentLines.forEach((line) => {
if (reachedBlockBoundary) {
blockLines.push(line);
return;
}
if (line.trim() === "") {
reachedBlockBoundary = true;
blockLines.push(line);
return;
}
if (paragraphLines.length > 0 && isBlockContentLine(line)) {
reachedBlockBoundary = true;
blockLines.push(line);
return;
}
paragraphLines.push(line);
});
return {
paragraphLines,
blockLines
};
}
function collectOrderedListItems(lines) {
const listItems = [];
let currentLineIndex = 0;
let consumed = 0;
while (currentLineIndex < lines.length) {
const line = lines[currentLineIndex];
const match = line.match(ORDERED_LIST_ITEM_REGEX);
if (!match) {
break;
}
const [, indent, number, content] = match;
const indentLevel = indent.length;
const itemContentLines = [content];
let nextLineIndex = currentLineIndex + 1;
const itemLines = [line];
let sawBlankLine = false;
while (nextLineIndex < lines.length) {
const nextLine = lines[nextLineIndex];
const nextMatch = nextLine.match(ORDERED_LIST_ITEM_REGEX);
if (nextMatch) {
break;
}
if (nextLine.trim() === "") {
itemLines.push(nextLine);
itemContentLines.push("");
sawBlankLine = true;
nextLineIndex += 1;
} else if (nextLine.match(INDENTED_LINE_REGEX)) {
itemLines.push(nextLine);
itemContentLines.push(nextLine.slice(indentLevel + 2));
nextLineIndex += 1;
} else {
if (sawBlankLine) {
break;
}
itemLines.push(nextLine);
itemContentLines.push(nextLine);
nextLineIndex += 1;
}
}
listItems.push({
indent: indentLevel,
number: parseInt(number, 10),
content: itemContentLines.join("\n").trim(),
contentLines: itemContentLines,
raw: itemLines.join("\n")
});
consumed = nextLineIndex;
currentLineIndex = nextLineIndex;
}
return [listItems, consumed];
}
function buildNestedStructure(items, baseIndent, lexer) {
const result = [];
let currentIndex = 0;
while (currentIndex < items.length) {
const item = items[currentIndex];
if (item.indent === baseIndent) {
const { paragraphLines, blockLines } = splitItemContent(item.contentLines);
const mainText = paragraphLines.join("\n").trim();
const tokens = [];
if (mainText) {
tokens.push({
type: "paragraph",
raw: mainText,
tokens: lexer.inlineTokens(mainText)
});
}
const additionalContent = blockLines.join("\n").trim();
if (additionalContent) {
const blockTokens = lexer.blockTokens(additionalContent);
tokens.push(...blockTokens);
}
let lookAheadIndex = currentIndex + 1;
const nestedItems = [];
while (lookAheadIndex < items.length && items[lookAheadIndex].indent > baseIndent) {
nestedItems.push(items[lookAheadIndex]);
lookAheadIndex += 1;
}
if (nestedItems.length > 0) {
const nextIndent = Math.min(...nestedItems.map((nestedItem) => nestedItem.indent));
const nestedListItems = buildNestedStructure(nestedItems, nextIndent, lexer);
tokens.push({
type: "list",
ordered: true,
start: nestedItems[0].number,
items: nestedListItems,
raw: nestedItems.map((nestedItem) => nestedItem.raw).join("\n")
});
}
result.push({
type: "list_item",
raw: item.raw,
tokens
});
currentIndex = lookAheadIndex;
} else {
currentIndex += 1;
}
}
return result;
}
function parseListItems(items, helpers) {
return items.map((item) => {
if (item.type !== "list_item") {
return helpers.parseChildren([item])[0];
}
const content = [];
if (item.tokens && item.tokens.length > 0) {
item.tokens.forEach((itemToken) => {
if (itemToken.type === "paragraph" || itemToken.type === "list" || itemToken.type === "blockquote" || itemToken.type === "code") {
content.push(...helpers.parseChildren([itemToken]));
} else if (itemToken.type === "text" && itemToken.tokens) {
const inlineContent = helpers.parseChildren([itemToken]);
content.push({
type: "paragraph",
content: inlineContent
});
} else {
const parsed = helpers.parseChildren([itemToken]);
if (parsed.length > 0) {
content.push(...parsed);
}
}
});
}
return {
type: "listItem",
content
};
});
}
var ListItemName2 = "listItem";
var TextStyleName2 = "textStyle";
var orderedListInputRegex = /^(\d+)\.\s$/;
var OrderedList = Node3.create({
name: "orderedList",
addOptions() {
return {
itemTypeName: "listItem",
HTMLAttributes: {},
keepMarks: false,
keepAttributes: false
};
},
group: "block list",
content() {
return `${this.options.itemTypeName}+`;
},
addAttributes() {
return {
start: {
default: 1,
parseHTML: (element) => {
return element.hasAttribute("start") ? parseInt(element.getAttribute("start") || "", 10) : 1;
}
},
type: {
default: null,
parseHTML: (element) => element.getAttribute("type")
}
};
},
parseHTML() {
return [
{
tag: "ol"
}
];
},
renderHTML({ HTMLAttributes }) {
const { start, ...attributesWithoutStart } = HTMLAttributes;
return start === 1 ? ["ol", mergeAttributes(this.options.HTMLAttributes, attributesWithoutStart), 0] : ["ol", mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), 0];
},
markdownTokenName: "list",
parseMarkdown: (token, helpers) => {
if (token.type !== "list" || !token.ordered) {
return [];
}
const startValue = token.start || 1;
const content = token.items ? parseListItems(token.items, helpers) : [];
if (startValue !== 1) {
return {
type: "orderedList",
attrs: { start: startValue },
content
};
}
return {
type: "orderedList",
content
};
},
renderMarkdown: (node, h2) => {
if (!node.content) {
return "";
}
return h2.renderChildren(node.content, "\n");
},
markdownTokenizer: {
name: "orderedList",
level: "block",
start: (src) => {
const match = src.match(/^(\s*)(\d+)\.\s+/);
const index = match == null ? void 0 : match.index;
return index !== void 0 ? index : -1;
},
tokenize: (src, _tokens, lexer) => {
var _a;
const lines = src.split("\n");
const [listItems, consumed] = collectOrderedListItems(lines);
if (listItems.length === 0) {
return void 0;
}
const items = buildNestedStructure(listItems, 0, lexer);
if (items.length === 0) {
return void 0;
}
const startValue = ((_a = listItems[0]) == null ? void 0 : _a.number) || 1;
return {
type: "list",
ordered: true,
start: startValue,
items,
raw: lines.slice(0, consumed).join("\n")
};
}
},
markdownOptions: {
indentsContent: true
},
addCommands() {
return {
toggleOrderedList: () => ({ commands, chain }) => {
if (this.options.keepAttributes) {
return chain().toggleList(this.name, this.options.itemTypeName, this.options.keepMarks).updateAttributes(ListItemName2, this.editor.getAttributes(TextStyleName2)).run();
}
return commands.toggleList(this.name, this.options.itemTypeName, this.options.keepMarks);
}
};
},
addKeyboardShortcuts() {
return {
"Mod-Shift-7": () => this.editor.commands.toggleOrderedList()
};
},
addInputRules() {
let inputRule = wrappingInputRule({
find: orderedListInputRegex,
type: this.type,
getAttributes: (match) => ({ start: +match[1] }),
joinPredicate: (match, node) => node.childCount + node.attrs.start === +match[1]
});
if (this.options.keepMarks || this.options.keepAttributes) {
inputRule = wrappingInputRule({
find: orderedListInputRegex,
type: this.type,
keepMarks: this.options.keepMarks,
keepAttributes: this.options.keepAttributes,
getAttributes: (match) => ({ start: +match[1], ...this.editor.getAttributes(TextStyleName2) }),
joinPredicate: (match, node) => node.childCount + node.attrs.start === +match[1],
editor: this.editor
});
}
return [inputRule];
}
});
var inputRegex2 = /^\s*(\[([( |x])?\])\s$/;
var TaskItem = Node3.create({
name: "taskItem",
addOptions() {
return {
nested: false,
HTMLAttributes: {},
taskListTypeName: "taskList",
a11y: void 0
};
},
content() {
return this.options.nested ? "paragraph block*" : "paragraph+";
},
defining: true,
addAttributes() {
return {
checked: {
default: false,
keepOnSplit: false,
parseHTML: (element) => {
const dataChecked = element.getAttribute("data-checked");
return dataChecked === "" || dataChecked === "true";
},
renderHTML: (attributes) => ({
"data-checked": attributes.checked
})
}
};
},
parseHTML() {
return [
{
tag: `li[data-type="${this.name}"]`,
priority: 51
}
];
},
renderHTML({ node, HTMLAttributes }) {
return [
"li",
mergeAttributes(this.options.HTMLAttributes, HTMLAttributes, {
"data-type": this.name
}),
[
"label",
[
"input",
{
type: "checkbox",
checked: node.attrs.checked ? "checked" : null
}
],
["span"]
],
["div", 0]
];
},
parseMarkdown: (token, h2) => {
const content = [];
if (token.tokens && token.tokens.length > 0) {
content.push(h2.createNode("paragraph", {}, h2.parseInline(token.tokens)));
} else if (token.text) {
content.push(h2.createNode("paragraph", {}, [h2.createNode("text", { text: token.text })]));
} else {
content.push(h2.createNode("paragraph", {}, []));
}
if (token.nestedTokens && token.nestedTokens.length > 0) {
const nestedContent = h2.parseChildren(token.nestedTokens);
content.push(...nestedContent);
}
return h2.createNode("taskItem", { checked: token.checked || false }, content);
},
renderMarkdown: (node, h2) => {
var _a;
const checkedChar = ((_a = node.attrs) == null ? void 0 : _a.checked) ? "x" : " ";
const prefix = `- [${checkedChar}] `;
return renderNestedMarkdownContent(node, h2, prefix);
},
addExtensions() {
if (!this.options.nested) {
return [];
}
return [createBranchingListDeleteKeymap(this.name, [this.options.taskListTypeName])];
},
addKeyboardShortcuts() {
const shortcuts = {
Enter: () => this.editor.commands.splitListItem(this.name),
"Shift-Tab": () => this.editor.commands.liftListItem(this.name)
};
if (!this.options.nested) {
return shortcuts;
}
return {
...shortcuts,
Tab: () => this.editor.commands.sinkListItem(this.name)
};
},
addNodeView() {
return ({ node, HTMLAttributes, getPos, editor }) => {
const listItem = document.createElement("li");
const checkboxWrapper = document.createElement("label");
const checkboxStyler = document.createElement("span");
const checkbox = document.createElement("input");
const content = document.createElement("div");
const updateA11Y = (currentNode) => {
var _a, _b;
checkbox.ariaLabel = ((_b = (_a = this.options.a11y) == null ? void 0 : _a.checkboxLabel) == null ? void 0 : _b.call(_a, currentNode, checkbox.checked)) || `Task item checkbox for ${currentNode.textContent || "empty task item"}`;
};
updateA11Y(node);
checkboxWrapper.contentEditable = "false";
checkbox.type = "checkbox";
checkbox.addEventListener("mousedown", (event) => event.preventDefault());
checkbox.addEventListener("change", (event) => {
if (!editor.isEditable && !this.options.onReadOnlyChecked) {
checkbox.checked = !checkbox.checked;
return;
}
const { checked } = event.target;
if (editor.isEditable && typeof getPos === "function") {
editor.chain().focus(void 0, { scrollIntoView: false }).command(({ tr: tr2 }) => {
const position = getPos();
if (typeof position !== "number") {
return false;
}
const currentNode = tr2.doc.nodeAt(position);
tr2.setNodeMarkup(position, void 0, {
...currentNode == null ? void 0 : currentNode.attrs,
checked
});
return true;
}).run();
}
if (!editor.isEditable && this.options.onReadOnlyChecked) {
if (!this.options.onReadOnlyChecked(node, checked)) {
checkbox.checked = !checkbox.checked;
}
}
});
Object.entries(this.options.HTMLAttributes).forEach(([key, value]) => {
listItem.setAttribute(key, value);
});
listItem.dataset.checked = node.attrs.checked;
checkbox.checked = node.attrs.checked;
checkboxWrapper.append(checkbox, checkboxStyler);
listItem.append(checkboxWrapper, content);
Object.entries(HTMLAttributes).forEach(([key, value]) => {
listItem.setAttribute(key, value);
});
let prevRenderedAttributeKeys = new Set(Object.keys(HTMLAttributes));
return {
dom: listItem,
contentDOM: content,
update: (updatedNode) => {
if (updatedNode.type !== this.type) {
return false;
}
listItem.dataset.checked = updatedNode.attrs.checked;
checkbox.checked = updatedNode.attrs.checked;
updateA11Y(updatedNode);
const extensionAttributes = editor.extensionManager.attributes;
const newHTMLAttributes = getRenderedAttributes(updatedNode, extensionAttributes);
const newKeys = new Set(Object.keys(newHTMLAttributes));
const staticAttrs = this.options.HTMLAttributes;
prevRenderedAttributeKeys.forEach((key) => {
if (!newKeys.has(key)) {
if (key in staticAttrs) {
listItem.setAttribute(key, staticAttrs[key]);
} else {
listItem.removeAttribute(key);
}
}
});
Object.entries(newHTMLAttributes).forEach(([key, value]) => {
if (value === null || value === void 0) {
if (key in staticAttrs) {
listItem.setAttribute(key, staticAttrs[key]);
} else {
listItem.removeAttribute(key);
}
} else {
listItem.setAttribute(key, value);
}
});
prevRenderedAttributeKeys = newKeys;
return true;
}
};
};
},
addInputRules() {
return [
wrappingInputRule({
find: inputRegex2,
type: this.type,
getAttributes: (match) => ({
checked: match[match.length - 1] === "x"
})
})
];
}
});
var TaskList = Node3.create({
name: "taskList",
addOptions() {
return {
itemTypeName: "taskItem",
HTMLAttributes: {}
};
},
group: "block list",
content() {
return `${this.options.itemTypeName}+`;
},
parseHTML() {
return [
{
tag: `ul[data-type="${this.name}"]`,
priority: 51
}
];
},
renderHTML({ HTMLAttributes }) {
return [
"ul",
mergeAttributes(this.options.HTMLAttributes, HTMLAttributes, { "data-type": this.name }),
0
];
},
parseMarkdown: (token, h2) => {
return h2.createNode("taskList", {}, h2.parseChildren(token.items || []));
},
renderMarkdown: (node, h2) => {
if (!node.content) {
return "";
}
return h2.renderChildren(node.content, "\n");
},
markdownTokenizer: {
name: "taskList",
level: "block",
start(src) {
var _a;
const index = (_a = src.match(/^\s*[-+*]\s+\[([ xX])\]\s+/)) == null ? void 0 : _a.index;
return index !== void 0 ? index : -1;
},
tokenize(src, tokens, lexer) {
const parseTaskListContent = (content) => {
const nestedResult = parseIndentedBlocks(
content,
{
itemPattern: /^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,
extractItemData: (match) => ({
indentLevel: match[1].length,
mainContent: match[4],
checked: match[3].toLowerCase() === "x"
}),
createToken: (data, nestedTokens) => ({
type: "taskItem",
raw: "",
mainContent: data.mainContent,
indentLevel: data.indentLevel,
checked: data.checked,
text: data.mainContent,
tokens: lexer.inlineTokens(data.mainContent),
nestedTokens
}),
// Allow recursive nesting
customNestedParser: parseTaskListContent
},
lexer
);
if (nestedResult) {
return [
{
type: "taskList",
raw: nestedResult.raw,
items: nestedResult.items
}
];
}
return lexer.blockTokens(content);
};
const result = parseIndentedBlocks(
src,
{
itemPattern: /^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,
extractItemData: (match) => ({
indentLevel: match[1].length,
mainContent: match[4],
checked: match[3].toLowerCase() === "x"
}),
createToken: (data, nestedTokens) => ({
type: "taskItem",
raw: "",
mainContent: data.mainContent,
indentLevel: data.indentLevel,
checked: data.checked,
text: data.mainContent,
tokens: lexer.inlineTokens(data.mainContent),
nestedTokens
}),
// Use the recursive parser for nested content
customNestedParser: parseTaskListContent
},
lexer
);
if (!result) {
return void 0;
}
return {
type: "taskList",
raw: result.raw,
items: result.items
};
}
},
markdownOptions: {
indentsContent: true
},
addCommands() {
return {
toggleTaskList: () => ({ commands }) => {
return commands.toggleList(this.name, this.options.itemTypeName);
}
};
},
addKeyboardShortcuts() {
return {
"Mod-Shift-9": () => this.editor.commands.toggleTaskList()
};
}
});
var ListKit = Extension.create({
name: "listKit",
addExtensions() {
const extensions = [];
if (this.options.bulletList !== false) {
extensions.push(BulletList.configure(this.options.bulletList));
}
if (this.options.listItem !== false) {
extensions.push(ListItem.configure(this.options.listItem));
}
if (this.options.listKeymap !== false) {
extensions.push(ListKeymap.configure(this.options.listKeymap));
}
if (this.options.orderedList !== false) {
extensions.push(OrderedList.configure(this.options.orderedList));
}
if (this.options.taskItem !== false) {
extensions.push(TaskItem.configure(this.options.taskItem));
}
if (this.options.taskList !== false) {
extensions.push(TaskList.configure(this.options.taskList));
}
return extensions;
}
});
// node_modules/@tiptap/extension-paragraph/dist/index.js
var EMPTY_PARAGRAPH_MARKDOWN = " ";
var NBSP_CHAR = " ";
var Paragraph = Node3.create({
name: "paragraph",
priority: 1e3,
addOptions() {
return {
HTMLAttributes: {}
};
},
group: "block",
content: "inline*",
parseHTML() {
return [{ tag: "p" }];
},
renderHTML({ HTMLAttributes }) {
return ["p", mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), 0];
},
parseMarkdown: (token, helpers) => {
const tokens = token.tokens || [];
if (tokens.length === 1 && tokens[0].type === "image") {
return helpers.parseChildren([tokens[0]]);
}
const content = helpers.parseInline(tokens);
const hasExplicitEmptyParagraphMarker = tokens.length === 1 && tokens[0].type === "text" && (tokens[0].raw === EMPTY_PARAGRAPH_MARKDOWN || tokens[0].text === EMPTY_PARAGRAPH_MARKDOWN || tokens[0].raw === NBSP_CHAR || tokens[0].text === NBSP_CHAR);
if (hasExplicitEmptyParagraphMarker && content.length === 1 && content[0].type === "text" && (content[0].text === EMPTY_PARAGRAPH_MARKDOWN || content[0].text === NBSP_CHAR)) {
return helpers.createNode("paragraph", void 0, []);
}
return helpers.createNode("paragraph", void 0, content);
},
renderMarkdown: (node, h2, ctx) => {
var _a, _b;
if (!node) {
return "";
}
const content = Array.isArray(node.content) ? node.content : [];
if (content.length === 0) {
const previousContent = Array.isArray((_a = ctx == null ? void 0 : ctx.previousNode) == null ? void 0 : _a.content) ? ctx.previousNode.content : [];
const previousNodeIsEmptyParagraph = ((_b = ctx == null ? void 0 : ctx.previousNode) == null ? void 0 : _b.type) === "paragraph" && previousContent.length === 0;
return previousNodeIsEmptyParagraph ? EMPTY_PARAGRAPH_MARKDOWN : "";
}
return h2.renderChildren(content);
},
addCommands() {
return {
setParagraph: () => ({ commands }) => {
return commands.setNode(this.name);
}
};
},
addKeyboardShortcuts() {
return {
"Mod-Alt-0": () => this.editor.commands.setParagraph()
};
}
});
// node_modules/@tiptap/extension-strike/dist/index.js
var inputRegex3 = /(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/;
var pasteRegex = /(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g;
var Strike = Mark.create({
name: "strike",
addOptions() {
return {
HTMLAttributes: {}
};
},
parseHTML() {
return [
{
tag: "s"
},
{
tag: "del"
},
{
tag: "strike"
},
{
style: "text-decoration",
consuming: false,
getAttrs: (style) => style.includes("line-through") ? {} : false
}
];
},
renderHTML({ HTMLAttributes }) {
return ["s", mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), 0];
},
markdownTokenName: "del",
parseMarkdown: (token, helpers) => {
return helpers.applyMark("strike", helpers.parseInline(token.tokens || []));
},
renderMarkdown: (node, h2) => {
return `~~${h2.renderChildren(node)}~~`;
},
addCommands() {
return {
setStrike: () => ({ commands }) => {
return commands.setMark(this.name);
},
toggleStrike: () => ({ commands }) => {
return commands.toggleMark(this.name);
},
unsetStrike: () => ({ commands }) => {
return commands.unsetMark(this.name);
}
};
},
addKeyboardShortcuts() {
return {
"Mod-Shift-s": () => this.editor.commands.toggleStrike()
};
},
addInputRules() {
return [
markInputRule({
find: inputRegex3,
type: this.type
})
];
},
addPasteRules() {
return [
markPasteRule({
find: pasteRegex,
type: this.type
})
];
}
});
// node_modules/@tiptap/extension-text/dist/index.js
var Text2 = Node3.create({
name: "text",
group: "inline",
parseMarkdown: (token) => {
return {
type: "text",
text: token.text || ""
};
},
renderMarkdown: (node) => node.text || ""
});
// node_modules/@tiptap/extension-underline/dist/index.js
var Underline = Mark.create({
name: "underline",
addOptions() {
return {
HTMLAttributes: {}
};
},
parseHTML() {
return [
{
tag: "u"
},
{
style: "text-decoration",
consuming: false,
getAttrs: (style) => style.includes("underline") ? {} : false
}
];
},
renderHTML({ HTMLAttributes }) {
return ["u", mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), 0];
},
parseMarkdown(token, helpers) {
return helpers.applyMark(this.name || "underline", helpers.parseInline(token.tokens || []));
},
renderMarkdown(node, helpers) {
return `++${helpers.renderChildren(node)}++`;
},
markdownTokenizer: {
name: "underline",
level: "inline",
start(src) {
return src.indexOf("++");
},
tokenize(src, _tokens, lexer) {
const rule = /^(\+\+)([\s\S]+?)(\+\+)/;
const match = rule.exec(src);
if (!match) {
return void 0;
}
const innerContent = match[2].trim();
return {
type: "underline",
raw: match[0],
text: innerContent,
tokens: lexer.inlineTokens(innerContent)
};
}
},
addCommands() {
return {
setUnderline: () => ({ commands }) => {
return commands.setMark(this.name);
},
toggleUnderline: () => ({ commands }) => {
return commands.toggleMark(this.name);
},
unsetUnderline: () => ({ commands }) => {
return commands.unsetMark(this.name);
}
};
},
addKeyboardShortcuts() {
return {
"Mod-u": () => this.editor.commands.toggleUnderline(),
"Mod-U": () => this.editor.commands.toggleUnderline()
};
}
});
// node_modules/prosemirror-dropcursor/dist/index.js
function dropCursor(options2 = {}) {
return new Plugin({
view(editorView) {
return new DropCursorView(editorView, options2);
}
});
}
var DropCursorView = class {
constructor(editorView, options2) {
var _a;
this.editorView = editorView;
this.cursorPos = null;
this.element = null;
this.timeout = -1;
this.width = (_a = options2.width) !== null && _a !== void 0 ? _a : 1;
this.color = options2.color === false ? void 0 : options2.color || "black";
this.class = options2.class;
this.handlers = ["dragover", "dragend", "drop", "dragleave"].map((name) => {
let handler = (e) => {
this[name](e);
};
editorView.dom.addEventListener(name, handler);
return { name, handler };
});
}
destroy() {
this.handlers.forEach(({ name, handler }) => this.editorView.dom.removeEventListener(name, handler));
}
update(editorView, prevState) {
if (this.cursorPos != null && prevState.doc != editorView.state.doc) {
if (this.cursorPos > editorView.state.doc.content.size)
this.setCursor(null);
else
this.updateOverlay();
}
}
setCursor(pos) {
if (pos == this.cursorPos)
return;
this.cursorPos = pos;
if (pos == null) {
this.element.parentNode.removeChild(this.element);
this.element = null;
} else {
this.updateOverlay();
}
}
updateOverlay() {
let $pos = this.editorView.state.doc.resolve(this.cursorPos);
let isBlock = !$pos.parent.inlineContent, rect;
let editorDOM = this.editorView.dom, editorRect = editorDOM.getBoundingClientRect();
let scaleX = editorRect.width / editorDOM.offsetWidth, scaleY = editorRect.height / editorDOM.offsetHeight;
if (isBlock) {
let before = $pos.nodeBefore, after = $pos.nodeAfter;
if (before || after) {
let node = this.editorView.nodeDOM(this.cursorPos - (before ? before.nodeSize : 0));
if (node) {
let nodeRect = node.getBoundingClientRect();
let top = before ? nodeRect.bottom : nodeRect.top;
if (before && after)
top = (top + this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top) / 2;
let halfWidth = this.width / 2 * scaleY;
rect = { left: nodeRect.left, right: nodeRect.right, top: top - halfWidth, bottom: top + halfWidth };
}
}
}
if (!rect) {
let coords = this.editorView.coordsAtPos(this.cursorPos);
let halfWidth = this.width / 2 * scaleX;
rect = { left: coords.left - halfWidth, right: coords.left + halfWidth, top: coords.top, bottom: coords.bottom };
}
let parent = this.editorView.dom.offsetParent;
if (!this.element) {
this.element = parent.appendChild(document.createElement("div"));
if (this.class)
this.element.className = this.class;
this.element.style.cssText = "position: absolute; z-index: 50; pointer-events: none;";
if (this.color) {
this.element.style.backgroundColor = this.color;
}
}
this.element.classList.toggle("prosemirror-dropcursor-block", isBlock);
this.element.classList.toggle("prosemirror-dropcursor-inline", !isBlock);
let parentLeft, parentTop;
if (!parent || parent == document.body && getComputedStyle(parent).position == "static") {
parentLeft = -pageXOffset;
parentTop = -pageYOffset;
} else {
let rect2 = parent.getBoundingClientRect();
let parentScaleX = rect2.width / parent.offsetWidth, parentScaleY = rect2.height / parent.offsetHeight;
parentLeft = rect2.left - parent.scrollLeft * parentScaleX;
parentTop = rect2.top - parent.scrollTop * parentScaleY;
}
this.element.style.left = (rect.left - parentLeft) / scaleX + "px";
this.element.style.top = (rect.top - parentTop) / scaleY + "px";
this.element.style.width = (rect.right - rect.left) / scaleX + "px";
this.element.style.height = (rect.bottom - rect.top) / scaleY + "px";
}
scheduleRemoval(timeout) {
clearTimeout(this.timeout);
this.timeout = setTimeout(() => this.setCursor(null), timeout);
}
dragover(event) {
if (!this.editorView.editable)
return;
let pos = this.editorView.posAtCoords({ left: event.clientX, top: event.clientY });
let node = pos && pos.inside >= 0 && this.editorView.state.doc.nodeAt(pos.inside);
let disableDropCursor = node && node.type.spec.disableDropCursor;
let disabled = typeof disableDropCursor == "function" ? disableDropCursor(this.editorView, pos, event) : disableDropCursor;
if (pos && !disabled) {
let target = pos.pos;
if (this.editorView.dragging && this.editorView.dragging.slice) {
let point = dropPoint(this.editorView.state.doc, target, this.editorView.dragging.slice);
if (point != null)
target = point;
}
this.setCursor(target);
this.scheduleRemoval(5e3);
}
}
dragend() {
this.scheduleRemoval(20);
}
drop() {
this.scheduleRemoval(20);
}
dragleave(event) {
if (!this.editorView.dom.contains(event.relatedTarget))
this.setCursor(null);
}
};
// node_modules/prosemirror-gapcursor/dist/index.js
var GapCursor = class _GapCursor extends Selection {
/**
Create a gap cursor.
*/
constructor($pos) {
super($pos, $pos);
}
map(doc, mapping) {
let $pos = doc.resolve(mapping.map(this.head));
return _GapCursor.valid($pos) ? new _GapCursor($pos) : Selection.near($pos);
}
content() {
return Slice.empty;
}
eq(other) {
return other instanceof _GapCursor && other.head == this.head;
}
toJSON() {
return { type: "gapcursor", pos: this.head };
}
/**
@internal
*/
static fromJSON(doc, json) {
if (typeof json.pos != "number")
throw new RangeError("Invalid input for GapCursor.fromJSON");
return new _GapCursor(doc.resolve(json.pos));
}
/**
@internal
*/
getBookmark() {
return new GapBookmark(this.anchor);
}
/**
@internal
*/
static valid($pos) {
let parent = $pos.parent;
if (parent.inlineContent || !closedBefore($pos) || !closedAfter($pos))
return false;
let override = parent.type.spec.allowGapCursor;
if (override != null)
return override;
let deflt = parent.contentMatchAt($pos.index()).defaultType;
return deflt && deflt.isTextblock;
}
/**
@internal
*/
static findGapCursorFrom($pos, dir, mustMove = false) {
search: for (; ; ) {
if (!mustMove && _GapCursor.valid($pos))
return $pos;
let pos = $pos.pos, next = null;
for (let d = $pos.depth; ; d--) {
let parent = $pos.node(d);
if (dir > 0 ? $pos.indexAfter(d) < parent.childCount : $pos.index(d) > 0) {
next = parent.child(dir > 0 ? $pos.indexAfter(d) : $pos.index(d) - 1);
break;
} else if (d == 0) {
return null;
}
pos += dir;
let $cur = $pos.doc.resolve(pos);
if (_GapCursor.valid($cur))
return $cur;
}
for (; ; ) {
let inside = dir > 0 ? next.firstChild : next.lastChild;
if (!inside) {
if (next.isAtom && !next.isText && !NodeSelection.isSelectable(next)) {
$pos = $pos.doc.resolve(pos + next.nodeSize * dir);
mustMove = false;
continue search;
}
break;
}
next = inside;
pos += dir;
let $cur = $pos.doc.resolve(pos);
if (_GapCursor.valid($cur))
return $cur;
}
return null;
}
}
};
GapCursor.prototype.visible = false;
GapCursor.findFrom = GapCursor.findGapCursorFrom;
Selection.jsonID("gapcursor", GapCursor);
var GapBookmark = class _GapBookmark {
constructor(pos) {
this.pos = pos;
}
map(mapping) {
return new _GapBookmark(mapping.map(this.pos));
}
resolve(doc) {
let $pos = doc.resolve(this.pos);
return GapCursor.valid($pos) ? new GapCursor($pos) : Selection.near($pos);
}
};
function needsGap(type) {
return type.isAtom || type.spec.isolating || type.spec.createGapCursor;
}
function closedBefore($pos) {
for (let d = $pos.depth; d >= 0; d--) {
let index = $pos.index(d), parent = $pos.node(d);
if (index == 0) {
if (parent.type.spec.isolating)
return true;
continue;
}
for (let before = parent.child(index - 1); ; before = before.lastChild) {
if (before.childCount == 0 && !before.inlineContent || needsGap(before.type))
return true;
if (before.inlineContent)
return false;
}
}
return true;
}
function closedAfter($pos) {
for (let d = $pos.depth; d >= 0; d--) {
let index = $pos.indexAfter(d), parent = $pos.node(d);
if (index == parent.childCount) {
if (parent.type.spec.isolating)
return true;
continue;
}
for (let after = parent.child(index); ; after = after.firstChild) {
if (after.childCount == 0 && !after.inlineContent || needsGap(after.type))
return true;
if (after.inlineContent)
return false;
}
}
return true;
}
function gapCursor() {
return new Plugin({
props: {
decorations: drawGapCursor,
createSelectionBetween(_view, $anchor, $head) {
return $anchor.pos == $head.pos && GapCursor.valid($head) ? new GapCursor($head) : null;
},
handleClick,
handleKeyDown,
handleDOMEvents: { beforeinput }
}
});
}
var handleKeyDown = keydownHandler({
"ArrowLeft": arrow("horiz", -1),
"ArrowRight": arrow("horiz", 1),
"ArrowUp": arrow("vert", -1),
"ArrowDown": arrow("vert", 1)
});
function arrow(axis, dir) {
const dirStr = axis == "vert" ? dir > 0 ? "down" : "up" : dir > 0 ? "right" : "left";
return function(state, dispatch, view) {
let sel = state.selection;
let $start = dir > 0 ? sel.$to : sel.$from, mustMove = sel.empty;
if (sel instanceof TextSelection) {
if (!view.endOfTextblock(dirStr) || $start.depth == 0)
return false;
mustMove = false;
$start = state.doc.resolve(dir > 0 ? $start.after() : $start.before());
}
let $found = GapCursor.findGapCursorFrom($start, dir, mustMove);
if (!$found)
return false;
if (dispatch)
dispatch(state.tr.setSelection(new GapCursor($found)));
return true;
};
}
function handleClick(view, pos, event) {
if (!view || !view.editable)
return false;
let $pos = view.state.doc.resolve(pos);
if (!GapCursor.valid($pos))
return false;
let clickPos = view.posAtCoords({ left: event.clientX, top: event.clientY });
if (clickPos && clickPos.inside > -1 && NodeSelection.isSelectable(view.state.doc.nodeAt(clickPos.inside)))
return false;
view.dispatch(view.state.tr.setSelection(new GapCursor($pos)));
return true;
}
function beforeinput(view, event) {
if (event.inputType != "insertCompositionText" || !(view.state.selection instanceof GapCursor))
return false;
let { $from } = view.state.selection;
let insert = $from.parent.contentMatchAt($from.index()).findWrapping(view.state.schema.nodes.text);
if (!insert)
return false;
let frag = Fragment.empty;
for (let i = insert.length - 1; i >= 0; i--)
frag = Fragment.from(insert[i].createAndFill(null, frag));
let tr2 = view.state.tr.replace($from.pos, $from.pos, new Slice(frag, 0, 0));
tr2.setSelection(TextSelection.near(tr2.doc.resolve($from.pos + 1)));
view.dispatch(tr2);
return false;
}
function drawGapCursor(state) {
if (!(state.selection instanceof GapCursor))
return null;
let node = document.createElement("div");
node.className = "ProseMirror-gapcursor";
return DecorationSet.create(state.doc, [Decoration.widget(state.selection.head, node, { key: "gapcursor" })]);
}
// node_modules/rope-sequence/dist/index.js
var GOOD_LEAF_SIZE = 200;
var RopeSequence = function RopeSequence2() {
};
RopeSequence.prototype.append = function append(other) {
if (!other.length) {
return this;
}
other = RopeSequence.from(other);
return !this.length && other || other.length < GOOD_LEAF_SIZE && this.leafAppend(other) || this.length < GOOD_LEAF_SIZE && other.leafPrepend(this) || this.appendInner(other);
};
RopeSequence.prototype.prepend = function prepend(other) {
if (!other.length) {
return this;
}
return RopeSequence.from(other).append(this);
};
RopeSequence.prototype.appendInner = function appendInner(other) {
return new Append(this, other);
};
RopeSequence.prototype.slice = function slice(from2, to) {
if (from2 === void 0) from2 = 0;
if (to === void 0) to = this.length;
if (from2 >= to) {
return RopeSequence.empty;
}
return this.sliceInner(Math.max(0, from2), Math.min(this.length, to));
};
RopeSequence.prototype.get = function get(i) {
if (i < 0 || i >= this.length) {
return void 0;
}
return this.getInner(i);
};
RopeSequence.prototype.forEach = function forEach(f, from2, to) {
if (from2 === void 0) from2 = 0;
if (to === void 0) to = this.length;
if (from2 <= to) {
this.forEachInner(f, from2, to, 0);
} else {
this.forEachInvertedInner(f, from2, to, 0);
}
};
RopeSequence.prototype.map = function map(f, from2, to) {
if (from2 === void 0) from2 = 0;
if (to === void 0) to = this.length;
var result = [];
this.forEach(function(elt, i) {
return result.push(f(elt, i));
}, from2, to);
return result;
};
RopeSequence.from = function from(values) {
if (values instanceof RopeSequence) {
return values;
}
return values && values.length ? new Leaf(values) : RopeSequence.empty;
};
var Leaf = (function(RopeSequence3) {
function Leaf2(values) {
RopeSequence3.call(this);
this.values = values;
}
if (RopeSequence3) Leaf2.__proto__ = RopeSequence3;
Leaf2.prototype = Object.create(RopeSequence3 && RopeSequence3.prototype);
Leaf2.prototype.constructor = Leaf2;
var prototypeAccessors = { length: { configurable: true }, depth: { configurable: true } };
Leaf2.prototype.flatten = function flatten() {
return this.values;
};
Leaf2.prototype.sliceInner = function sliceInner(from2, to) {
if (from2 == 0 && to == this.length) {
return this;
}
return new Leaf2(this.values.slice(from2, to));
};
Leaf2.prototype.getInner = function getInner(i) {
return this.values[i];
};
Leaf2.prototype.forEachInner = function forEachInner(f, from2, to, start) {
for (var i = from2; i < to; i++) {
if (f(this.values[i], start + i) === false) {
return false;
}
}
};
Leaf2.prototype.forEachInvertedInner = function forEachInvertedInner(f, from2, to, start) {
for (var i = from2 - 1; i >= to; i--) {
if (f(this.values[i], start + i) === false) {
return false;
}
}
};
Leaf2.prototype.leafAppend = function leafAppend(other) {
if (this.length + other.length <= GOOD_LEAF_SIZE) {
return new Leaf2(this.values.concat(other.flatten()));
}
};
Leaf2.prototype.leafPrepend = function leafPrepend(other) {
if (this.length + other.length <= GOOD_LEAF_SIZE) {
return new Leaf2(other.flatten().concat(this.values));
}
};
prototypeAccessors.length.get = function() {
return this.values.length;
};
prototypeAccessors.depth.get = function() {
return 0;
};
Object.defineProperties(Leaf2.prototype, prototypeAccessors);
return Leaf2;
})(RopeSequence);
RopeSequence.empty = new Leaf([]);
var Append = (function(RopeSequence3) {
function Append2(left, right) {
RopeSequence3.call(this);
this.left = left;
this.right = right;
this.length = left.length + right.length;
this.depth = Math.max(left.depth, right.depth) + 1;
}
if (RopeSequence3) Append2.__proto__ = RopeSequence3;
Append2.prototype = Object.create(RopeSequence3 && RopeSequence3.prototype);
Append2.prototype.constructor = Append2;
Append2.prototype.flatten = function flatten() {
return this.left.flatten().concat(this.right.flatten());
};
Append2.prototype.getInner = function getInner(i) {
return i < this.left.length ? this.left.get(i) : this.right.get(i - this.left.length);
};
Append2.prototype.forEachInner = function forEachInner(f, from2, to, start) {
var leftLen = this.left.length;
if (from2 < leftLen && this.left.forEachInner(f, from2, Math.min(to, leftLen), start) === false) {
return false;
}
if (to > leftLen && this.right.forEachInner(f, Math.max(from2 - leftLen, 0), Math.min(this.length, to) - leftLen, start + leftLen) === false) {
return false;
}
};
Append2.prototype.forEachInvertedInner = function forEachInvertedInner(f, from2, to, start) {
var leftLen = this.left.length;
if (from2 > leftLen && this.right.forEachInvertedInner(f, from2 - leftLen, Math.max(to, leftLen) - leftLen, start + leftLen) === false) {
return false;
}
if (to < leftLen && this.left.forEachInvertedInner(f, Math.min(from2, leftLen), to, start) === false) {
return false;
}
};
Append2.prototype.sliceInner = function sliceInner(from2, to) {
if (from2 == 0 && to == this.length) {
return this;
}
var leftLen = this.left.length;
if (to <= leftLen) {
return this.left.slice(from2, to);
}
if (from2 >= leftLen) {
return this.right.slice(from2 - leftLen, to - leftLen);
}
return this.left.slice(from2, leftLen).append(this.right.slice(0, to - leftLen));
};
Append2.prototype.leafAppend = function leafAppend(other) {
var inner = this.right.leafAppend(other);
if (inner) {
return new Append2(this.left, inner);
}
};
Append2.prototype.leafPrepend = function leafPrepend(other) {
var inner = this.left.leafPrepend(other);
if (inner) {
return new Append2(inner, this.right);
}
};
Append2.prototype.appendInner = function appendInner2(other) {
if (this.left.depth >= Math.max(this.right.depth, other.depth) + 1) {
return new Append2(this.left, new Append2(this.right, other));
}
return new Append2(this, other);
};
return Append2;
})(RopeSequence);
var dist_default = RopeSequence;
// node_modules/prosemirror-history/dist/index.js
var max_empty_items = 500;
var Branch = class _Branch {
constructor(items, eventCount) {
this.items = items;
this.eventCount = eventCount;
}
// Pop the latest event off the branch's history and apply it
// to a document transform.
popEvent(state, preserveItems) {
if (this.eventCount == 0)
return null;
let end = this.items.length;
for (; ; end--) {
let next = this.items.get(end - 1);
if (next.selection) {
--end;
break;
}
}
let remap, mapFrom;
if (preserveItems) {
remap = this.remapping(end, this.items.length);
mapFrom = remap.maps.length;
}
let transform = state.tr;
let selection, remaining;
let addAfter = [], addBefore = [];
this.items.forEach((item, i) => {
if (!item.step) {
if (!remap) {
remap = this.remapping(end, i + 1);
mapFrom = remap.maps.length;
}
mapFrom--;
addBefore.push(item);
return;
}
if (remap) {
addBefore.push(new Item(item.map));
let step = item.step.map(remap.slice(mapFrom)), map2;
if (step && transform.maybeStep(step).doc) {
map2 = transform.mapping.maps[transform.mapping.maps.length - 1];
addAfter.push(new Item(map2, void 0, void 0, addAfter.length + addBefore.length));
}
mapFrom--;
if (map2)
remap.appendMap(map2, mapFrom);
} else {
transform.maybeStep(item.step);
}
if (item.selection) {
selection = remap ? item.selection.map(remap.slice(mapFrom)) : item.selection;
remaining = new _Branch(this.items.slice(0, end).append(addBefore.reverse().concat(addAfter)), this.eventCount - 1);
return false;
}
}, this.items.length, 0);
return { remaining, transform, selection };
}
// Create a new branch with the given transform added.
addTransform(transform, selection, histOptions, preserveItems) {
let newItems = [], eventCount = this.eventCount;
let oldItems = this.items, lastItem = !preserveItems && oldItems.length ? oldItems.get(oldItems.length - 1) : null;
for (let i = 0; i < transform.steps.length; i++) {
let step = transform.steps[i].invert(transform.docs[i]);
let item = new Item(transform.mapping.maps[i], step, selection), merged;
if (merged = lastItem && lastItem.merge(item)) {
item = merged;
if (i)
newItems.pop();
else
oldItems = oldItems.slice(0, oldItems.length - 1);
}
newItems.push(item);
if (selection) {
eventCount++;
selection = void 0;
}
if (!preserveItems)
lastItem = item;
}
let overflow = eventCount - histOptions.depth;
if (overflow > DEPTH_OVERFLOW) {
oldItems = cutOffEvents(oldItems, overflow);
eventCount -= overflow;
}
return new _Branch(oldItems.append(newItems), eventCount);
}
remapping(from2, to) {
let maps = new Mapping();
this.items.forEach((item, i) => {
let mirrorPos = item.mirrorOffset != null && i - item.mirrorOffset >= from2 ? maps.maps.length - item.mirrorOffset : void 0;
maps.appendMap(item.map, mirrorPos);
}, from2, to);
return maps;
}
addMaps(array) {
if (this.eventCount == 0)
return this;
return new _Branch(this.items.append(array.map((map2) => new Item(map2))), this.eventCount);
}
// When the collab module receives remote changes, the history has
// to know about those, so that it can adjust the steps that were
// rebased on top of the remote changes, and include the position
// maps for the remote changes in its array of items.
rebased(rebasedTransform, rebasedCount) {
if (!this.eventCount)
return this;
let rebasedItems = [], start = Math.max(0, this.items.length - rebasedCount);
let mapping = rebasedTransform.mapping;
let newUntil = rebasedTransform.steps.length;
let eventCount = this.eventCount;
this.items.forEach((item) => {
if (item.selection)
eventCount--;
}, start);
let iRebased = rebasedCount;
this.items.forEach((item) => {
let pos = mapping.getMirror(--iRebased);
if (pos == null)
return;
newUntil = Math.min(newUntil, pos);
let map2 = mapping.maps[pos];
if (item.step) {
let step = rebasedTransform.steps[pos].invert(rebasedTransform.docs[pos]);
let selection = item.selection && item.selection.map(mapping.slice(iRebased + 1, pos));
if (selection)
eventCount++;
rebasedItems.push(new Item(map2, step, selection));
} else {
rebasedItems.push(new Item(map2));
}
}, start);
let newMaps = [];
for (let i = rebasedCount; i < newUntil; i++)
newMaps.push(new Item(mapping.maps[i]));
let items = this.items.slice(0, start).append(newMaps).append(rebasedItems);
let branch = new _Branch(items, eventCount);
if (branch.emptyItemCount() > max_empty_items)
branch = branch.compress(this.items.length - rebasedItems.length);
return branch;
}
emptyItemCount() {
let count = 0;
this.items.forEach((item) => {
if (!item.step)
count++;
});
return count;
}
// Compressing a branch means rewriting it to push the air (map-only
// items) out. During collaboration, these naturally accumulate
// because each remote change adds one. The `upto` argument is used
// to ensure that only the items below a given level are compressed,
// because `rebased` relies on a clean, untouched set of items in
// order to associate old items with rebased steps.
compress(upto = this.items.length) {
let remap = this.remapping(0, upto), mapFrom = remap.maps.length;
let items = [], events = 0;
this.items.forEach((item, i) => {
if (i >= upto) {
items.push(item);
if (item.selection)
events++;
} else if (item.step) {
let step = item.step.map(remap.slice(mapFrom)), map2 = step && step.getMap();
mapFrom--;
if (map2)
remap.appendMap(map2, mapFrom);
if (step) {
let selection = item.selection && item.selection.map(remap.slice(mapFrom));
if (selection)
events++;
let newItem = new Item(map2.invert(), step, selection), merged, last = items.length - 1;
if (merged = items.length && items[last].merge(newItem))
items[last] = merged;
else
items.push(newItem);
}
} else if (item.map) {
mapFrom--;
}
}, this.items.length, 0);
return new _Branch(dist_default.from(items.reverse()), events);
}
};
Branch.empty = new Branch(dist_default.empty, 0);
function cutOffEvents(items, n) {
let cutPoint;
items.forEach((item, i) => {
if (item.selection && n-- == 0) {
cutPoint = i;
return false;
}
});
return items.slice(cutPoint);
}
var Item = class _Item {
constructor(map2, step, selection, mirrorOffset) {
this.map = map2;
this.step = step;
this.selection = selection;
this.mirrorOffset = mirrorOffset;
}
merge(other) {
if (this.step && other.step && !other.selection) {
let step = other.step.merge(this.step);
if (step)
return new _Item(step.getMap().invert(), step, this.selection);
}
}
};
var HistoryState = class {
constructor(done, undone, prevRanges, prevTime, prevComposition) {
this.done = done;
this.undone = undone;
this.prevRanges = prevRanges;
this.prevTime = prevTime;
this.prevComposition = prevComposition;
}
};
var DEPTH_OVERFLOW = 20;
function applyTransaction(history2, state, tr2, options2) {
let historyTr = tr2.getMeta(historyKey), rebased;
if (historyTr)
return historyTr.historyState;
if (tr2.getMeta(closeHistoryKey))
history2 = new HistoryState(history2.done, history2.undone, null, 0, -1);
let appended = tr2.getMeta("appendedTransaction");
if (tr2.steps.length == 0) {
return history2;
} else if (appended && appended.getMeta(historyKey)) {
if (appended.getMeta(historyKey).redo)
return new HistoryState(history2.done.addTransform(tr2, void 0, options2, mustPreserveItems(state)), history2.undone, rangesFor(tr2.mapping.maps), history2.prevTime, history2.prevComposition);
else
return new HistoryState(history2.done, history2.undone.addTransform(tr2, void 0, options2, mustPreserveItems(state)), null, history2.prevTime, history2.prevComposition);
} else if (tr2.getMeta("addToHistory") !== false && !(appended && appended.getMeta("addToHistory") === false)) {
let composition = tr2.getMeta("composition");
let newGroup = history2.prevTime == 0 || !appended && history2.prevComposition != composition && (history2.prevTime < (tr2.time || 0) - options2.newGroupDelay || !isAdjacentTo(tr2, history2.prevRanges));
let prevRanges = appended ? mapRanges(history2.prevRanges, tr2.mapping) : rangesFor(tr2.mapping.maps);
return new HistoryState(history2.done.addTransform(tr2, newGroup ? state.selection.getBookmark() : void 0, options2, mustPreserveItems(state)), Branch.empty, prevRanges, tr2.time, composition == null ? history2.prevComposition : composition);
} else if (rebased = tr2.getMeta("rebased")) {
return new HistoryState(history2.done.rebased(tr2, rebased), history2.undone.rebased(tr2, rebased), mapRanges(history2.prevRanges, tr2.mapping), history2.prevTime, history2.prevComposition);
} else {
return new HistoryState(history2.done.addMaps(tr2.mapping.maps), history2.undone.addMaps(tr2.mapping.maps), mapRanges(history2.prevRanges, tr2.mapping), history2.prevTime, history2.prevComposition);
}
}
function isAdjacentTo(transform, prevRanges) {
if (!prevRanges)
return false;
if (!transform.docChanged)
return true;
let adjacent = false;
transform.mapping.maps[0].forEach((start, end) => {
for (let i = 0; i < prevRanges.length; i += 2)
if (start <= prevRanges[i + 1] && end >= prevRanges[i])
adjacent = true;
});
return adjacent;
}
function rangesFor(maps) {
let result = [];
for (let i = maps.length - 1; i >= 0 && result.length == 0; i--)
maps[i].forEach((_from, _to, from2, to) => result.push(from2, to));
return result;
}
function mapRanges(ranges, mapping) {
if (!ranges)
return null;
let result = [];
for (let i = 0; i < ranges.length; i += 2) {
let from2 = mapping.map(ranges[i], 1), to = mapping.map(ranges[i + 1], -1);
if (from2 <= to)
result.push(from2, to);
}
return result;
}
function histTransaction(history2, state, redo2) {
let preserveItems = mustPreserveItems(state);
let histOptions = historyKey.get(state).spec.config;
let pop = (redo2 ? history2.undone : history2.done).popEvent(state, preserveItems);
if (!pop)
return null;
let selection = pop.selection.resolve(pop.transform.doc);
let added = (redo2 ? history2.done : history2.undone).addTransform(pop.transform, state.selection.getBookmark(), histOptions, preserveItems);
let newHist = new HistoryState(redo2 ? added : pop.remaining, redo2 ? pop.remaining : added, null, 0, -1);
return pop.transform.setSelection(selection).setMeta(historyKey, { redo: redo2, historyState: newHist });
}
var cachedPreserveItems = false;
var cachedPreserveItemsPlugins = null;
function mustPreserveItems(state) {
let plugins = state.plugins;
if (cachedPreserveItemsPlugins != plugins) {
cachedPreserveItems = false;
cachedPreserveItemsPlugins = plugins;
for (let i = 0; i < plugins.length; i++)
if (plugins[i].spec.historyPreserveItems) {
cachedPreserveItems = true;
break;
}
}
return cachedPreserveItems;
}
var historyKey = new PluginKey("history");
var closeHistoryKey = new PluginKey("closeHistory");
function history(config = {}) {
config = {
depth: config.depth || 100,
newGroupDelay: config.newGroupDelay || 500
};
return new Plugin({
key: historyKey,
state: {
init() {
return new HistoryState(Branch.empty, Branch.empty, null, 0, -1);
},
apply(tr2, hist, state) {
return applyTransaction(hist, state, tr2, config);
}
},
config,
props: {
handleDOMEvents: {
beforeinput(view, e) {
let inputType = e.inputType;
let command = inputType == "historyUndo" ? undo : inputType == "historyRedo" ? redo : null;
if (!command || !view.editable)
return false;
e.preventDefault();
return command(view.state, view.dispatch);
}
}
}
});
}
function buildCommand(redo2, scroll) {
return (state, dispatch) => {
let hist = historyKey.getState(state);
if (!hist || (redo2 ? hist.undone : hist.done).eventCount == 0)
return false;
if (dispatch) {
let tr2 = histTransaction(hist, state, redo2);
if (tr2)
dispatch(scroll ? tr2.scrollIntoView() : tr2);
}
return true;
};
}
var undo = buildCommand(false, true);
var redo = buildCommand(true, true);
var undoNoScroll = buildCommand(false, false);
var redoNoScroll = buildCommand(true, false);
// node_modules/@tiptap/extensions/dist/index.js
var CharacterCount = Extension.create({
name: "characterCount",
addOptions() {
return {
limit: null,
autoTrim: true,
mode: "textSize",
textCounter: (text) => text.length,
wordCounter: (text) => text.split(" ").filter((word) => word !== "").length
};
},
addStorage() {
return {
characters: () => 0,
words: () => 0
};
},
onBeforeCreate() {
this.storage.characters = (options2) => {
const node = (options2 == null ? void 0 : options2.node) || this.editor.state.doc;
const mode = (options2 == null ? void 0 : options2.mode) || this.options.mode;
if (mode === "textSize") {
const text = node.textBetween(0, node.content.size, void 0, " ");
return this.options.textCounter(text);
}
return node.nodeSize;
};
this.storage.words = (options2) => {
const node = (options2 == null ? void 0 : options2.node) || this.editor.state.doc;
const text = node.textBetween(0, node.content.size, " ", " ");
return this.options.wordCounter(text);
};
},
addProseMirrorPlugins() {
let initialEvaluationDone = false;
return [
new Plugin({
key: new PluginKey("characterCount"),
appendTransaction: (transactions, oldState, newState) => {
if (initialEvaluationDone) {
return;
}
const limit = this.options.limit;
const autoTrim = this.options.autoTrim;
if (limit === null || limit === void 0 || limit === 0 || autoTrim === false) {
initialEvaluationDone = true;
return;
}
const initialContentSize = this.storage.characters({ node: newState.doc });
if (initialContentSize > limit) {
const over = initialContentSize - limit;
const from2 = 0;
const to = over;
console.warn(
`[CharacterCount] Initial content exceeded limit of ${limit} characters. Content was automatically trimmed.`
);
const tr2 = newState.tr.deleteRange(from2, to);
initialEvaluationDone = true;
return tr2;
}
initialEvaluationDone = true;
},
filterTransaction: (transaction, state) => {
const limit = this.options.limit;
if (!transaction.docChanged || limit === 0 || limit === null || limit === void 0) {
return true;
}
const oldSize = this.storage.characters({ node: state.doc });
const newSize = this.storage.characters({ node: transaction.doc });
if (newSize <= limit) {
return true;
}
if (oldSize > limit && newSize > limit && newSize <= oldSize) {
return true;
}
if (oldSize > limit && newSize > limit && newSize > oldSize) {
return false;
}
const isPaste = transaction.getMeta("paste");
if (!isPaste) {
return false;
}
const pos = transaction.selection.$head.pos;
const over = newSize - limit;
const from2 = pos - over;
const to = pos;
transaction.deleteRange(from2, to);
const updatedSize = this.storage.characters({ node: transaction.doc });
if (updatedSize > limit) {
return false;
}
return true;
}
})
];
}
});
var Dropcursor = Extension.create({
name: "dropCursor",
addOptions() {
return {
color: "currentColor",
width: 1,
class: void 0
};
},
addProseMirrorPlugins() {
return [dropCursor(this.options)];
}
});
var Focus = Extension.create({
name: "focus",
addOptions() {
return {
className: "has-focus",
mode: "all"
};
},
addProseMirrorPlugins() {
return [
new Plugin({
key: new PluginKey("focus"),
props: {
decorations: ({ doc, selection }) => {
const { isEditable, isFocused } = this.editor;
const { anchor } = selection;
const decorations = [];
if (!isEditable || !isFocused) {
return DecorationSet.create(doc, []);
}
let maxLevels = 0;
if (this.options.mode === "deepest") {
doc.descendants((node, pos) => {
if (node.isText) {
return;
}
const isCurrent = anchor >= pos && anchor <= pos + node.nodeSize - 1;
if (!isCurrent) {
return false;
}
maxLevels += 1;
});
}
let currentLevel = 0;
doc.descendants((node, pos) => {
if (node.isText) {
return false;
}
const isCurrent = anchor >= pos && anchor <= pos + node.nodeSize - 1;
if (!isCurrent) {
return false;
}
currentLevel += 1;
const outOfScope = this.options.mode === "deepest" && maxLevels - currentLevel > 0 || this.options.mode === "shallowest" && currentLevel > 1;
if (outOfScope) {
return this.options.mode === "deepest";
}
decorations.push(
Decoration.node(pos, pos + node.nodeSize, {
class: this.options.className
})
);
});
return DecorationSet.create(doc, decorations);
}
}
})
];
}
});
var Gapcursor = Extension.create({
name: "gapCursor",
addProseMirrorPlugins() {
return [gapCursor()];
},
extendNodeSchema(extension) {
var _a;
const context = {
name: extension.name,
options: extension.options,
storage: extension.storage
};
return {
allowGapCursor: (_a = callOrReturn(getExtensionField(extension, "allowGapCursor", context))) != null ? _a : null
};
}
});
var DEFAULT_DATA_ATTRIBUTE = "placeholder";
var PLUGIN_KEY = new PluginKey("tiptap__placeholder");
var VIEWPORT_OVERSCAN_PX = 200;
function createPlaceholderDecoration(options2) {
const {
editor,
placeholder,
dataAttribute,
pos,
node,
isEmptyDoc,
hasAnchor,
classes: { emptyNode, emptyEditor }
} = options2;
const classes = [emptyNode];
if (isEmptyDoc) {
classes.push(emptyEditor);
}
return Decoration.node(pos, pos + node.nodeSize, {
class: classes.join(" "),
[dataAttribute]: typeof placeholder === "function" ? placeholder({
editor,
node,
pos,
hasAnchor
}) : placeholder
});
}
function resolveEmptyNodeClass(emptyNodeClass, props) {
return typeof emptyNodeClass === "function" ? emptyNodeClass(props) : emptyNodeClass;
}
function buildPlaceholderDecorations({
editor,
options: options2,
dataAttribute,
doc,
selection
}) {
var _a, _b;
const active = editor.isEditable || !options2.showOnlyWhenEditable;
if (!active) {
return null;
}
const { anchor } = selection;
const decorations = [];
const isEmptyDoc = editor.isEmpty;
const useResolvedPath = options2.showOnlyCurrent && !options2.includeChildren;
if (useResolvedPath) {
const resolved = doc.resolve(anchor);
const node = resolved.depth > 0 ? resolved.node(1) : resolved.nodeAfter;
const nodeStart = resolved.depth > 0 ? resolved.before(1) : anchor;
if (node && node.type.isTextblock && isNodeEmpty(node)) {
const hasAnchor = anchor >= nodeStart && anchor <= nodeStart + node.nodeSize;
decorations.push(
createPlaceholderDecoration({
editor,
isEmptyDoc,
dataAttribute,
hasAnchor,
placeholder: options2.placeholder,
classes: {
emptyEditor: options2.emptyEditorClass,
emptyNode: resolveEmptyNodeClass(options2.emptyNodeClass, {
editor,
node,
pos: nodeStart,
hasAnchor
})
},
node,
pos: nodeStart
})
);
}
} else {
const pluginState = PLUGIN_KEY.getState(editor.state);
const from2 = (_a = pluginState == null ? void 0 : pluginState.topPos) != null ? _a : 0;
const to = (_b = pluginState == null ? void 0 : pluginState.bottomPos) != null ? _b : doc.content.size;
doc.nodesBetween(from2, to, (node, pos) => {
const hasAnchor = anchor >= pos && anchor <= pos + node.nodeSize;
const isEmpty = !node.isLeaf && isNodeEmpty(node);
if (!node.type.isTextblock) {
return options2.includeChildren;
}
if ((hasAnchor || !options2.showOnlyCurrent) && isEmpty) {
decorations.push(
createPlaceholderDecoration({
editor,
isEmptyDoc,
dataAttribute,
hasAnchor,
placeholder: options2.placeholder,
classes: {
emptyEditor: options2.emptyEditorClass,
emptyNode: resolveEmptyNodeClass(options2.emptyNodeClass, {
editor,
node,
pos,
hasAnchor
})
},
node,
pos
})
);
}
return options2.includeChildren;
});
}
return DecorationSet.create(doc, decorations);
}
function preparePlaceholderAttribute(attr) {
return attr.replace(/\s+/g, "-").replace(/[^a-zA-Z0-9-]/g, "").replace(/^[0-9-]+/, "").replace(/^-+/, "").toLowerCase();
}
function isScrollable(el) {
const style = getComputedStyle(el);
const overflow = `${style.overflow} ${style.overflowY} ${style.overflowX}`;
return /auto|scroll|overlay/.test(overflow);
}
function findScrollParent(element) {
let el = element;
while (el) {
if (isScrollable(el)) {
return el;
}
const parent = el.parentElement;
if (!parent) {
const root = el.getRootNode();
if (root instanceof ShadowRoot) {
el = root.host;
continue;
}
return window;
}
el = parent;
}
return window;
}
function getContainerRect(container) {
if (container === window) {
return { top: 0, bottom: window.innerHeight };
}
return container.getBoundingClientRect();
}
function getViewportBoundaryPositions({
doc,
view,
scrollContainer
}) {
const editorRect = view.dom.getBoundingClientRect();
const containerRect = scrollContainer ? getContainerRect(scrollContainer) : { top: 0, bottom: window.innerHeight };
const visibleTop = Math.max(editorRect.top, containerRect.top) - VIEWPORT_OVERSCAN_PX;
const visibleBottom = Math.min(editorRect.bottom, containerRect.bottom) + VIEWPORT_OVERSCAN_PX;
if (visibleTop >= visibleBottom) {
return { top: 0, bottom: doc.content.size };
}
const isRTL = getComputedStyle(view.dom).direction === "rtl";
const x = isRTL ? Math.max(editorRect.right - 2, editorRect.left + 2) : editorRect.left + 2;
const topPos = view.posAtCoords({ left: x, top: visibleTop + 2 });
const bottomPos = view.posAtCoords({ left: x, top: visibleBottom - 2 });
return {
top: topPos ? topPos.pos : 0,
bottom: bottomPos ? bottomPos.pos : doc.content.size
};
}
var viewportPluginState = {
/**
* Initialises the viewport state with no known positions.
* @returns The initial viewport state.
*/
init() {
return { topPos: null, bottomPos: null };
},
/**
* Updates the viewport state from incoming transactions.
* @param tr - The transaction being applied.
* @param prev - The previous viewport state.
* @returns The next viewport state.
*/
apply(tr2, prev) {
const meta = tr2.getMeta(PLUGIN_KEY);
if (meta == null ? void 0 : meta.positions) {
return { topPos: meta.positions.top, bottomPos: meta.positions.bottom };
}
if (!tr2.docChanged) {
return prev;
}
return {
topPos: prev.topPos !== null ? tr2.mapping.map(prev.topPos) : null,
bottomPos: prev.bottomPos !== null ? tr2.mapping.map(prev.bottomPos) : null
};
}
};
function createViewportPluginView(view) {
const scrollContainer = findScrollParent(view.dom);
const computeAndDispatch = () => {
const positions = getViewportBoundaryPositions({
view,
doc: view.state.doc,
scrollContainer
});
const prev = PLUGIN_KEY.getState(view.state);
if ((prev == null ? void 0 : prev.topPos) === positions.top && (prev == null ? void 0 : prev.bottomPos) === positions.bottom) {
return;
}
const tr2 = view.state.tr.setMeta(PLUGIN_KEY, { positions });
view.dispatch(tr2);
};
let frame = null;
let lastCompute = 0;
const MIN_SCROLL_INTERVAL = 150;
const scheduleFrame = () => {
if (frame !== null) return;
frame = requestAnimationFrame(() => {
frame = null;
const now = performance.now();
if (now - lastCompute >= MIN_SCROLL_INTERVAL) {
lastCompute = now;
computeAndDispatch();
} else {
scheduleFrame();
}
});
};
scrollContainer.addEventListener("scroll", scheduleFrame, { passive: true });
computeAndDispatch();
return {
update(_view, prevState) {
if (view.state.doc.content.size !== prevState.doc.content.size) {
scheduleFrame();
}
},
destroy: () => {
if (frame !== null) {
cancelAnimationFrame(frame);
}
scrollContainer.removeEventListener("scroll", scheduleFrame);
}
};
}
function createPlaceholderPlugin({ editor, options: options2 }) {
const dataAttribute = options2.dataAttribute ? `data-${preparePlaceholderAttribute(options2.dataAttribute)}` : `data-${DEFAULT_DATA_ATTRIBUTE}`;
return new Plugin({
key: PLUGIN_KEY,
state: viewportPluginState,
view: createViewportPluginView,
props: {
decorations: ({ doc, selection }) => buildPlaceholderDecorations({ editor, options: options2, dataAttribute, doc, selection })
}
});
}
var Placeholder = Extension.create({
name: "placeholder",
addOptions() {
return {
emptyEditorClass: "is-editor-empty",
emptyNodeClass: "is-empty",
dataAttribute: DEFAULT_DATA_ATTRIBUTE,
placeholder: "Write something …",
showOnlyWhenEditable: true,
showOnlyCurrent: true,
includeChildren: false
};
},
addProseMirrorPlugins() {
return [createPlaceholderPlugin({ editor: this.editor, options: this.options })];
}
});
var Selection2 = Extension.create({
name: "selection",
addOptions() {
return {
className: "selection"
};
},
addProseMirrorPlugins() {
const { editor, options: options2 } = this;
return [
new Plugin({
key: new PluginKey("selection"),
props: {
decorations(state) {
if (state.selection.empty || editor.isFocused || !editor.isEditable || isNodeSelection(state.selection) || editor.view.dragging) {
return null;
}
return DecorationSet.create(state.doc, [
Decoration.inline(state.selection.from, state.selection.to, {
class: options2.className
})
]);
}
}
})
];
}
});
var skipTrailingNodeMeta = "skipTrailingNode";
function nodeEqualsType({
types,
node
}) {
return node && Array.isArray(types) && types.includes(node.type) || (node == null ? void 0 : node.type) === types;
}
var TrailingNode = Extension.create({
name: "trailingNode",
addOptions() {
return {
node: void 0,
notAfter: []
};
},
addProseMirrorPlugins() {
var _a;
const plugin = new PluginKey(this.name);
const defaultNode = this.options.node || ((_a = this.editor.schema.topNodeType.contentMatch.defaultType) == null ? void 0 : _a.name) || "paragraph";
const disabledNodes = Object.entries(this.editor.schema.nodes).map(([, value]) => value).filter((node) => (this.options.notAfter || []).concat(defaultNode).includes(node.name));
return [
new Plugin({
key: plugin,
appendTransaction: (transactions, __, state) => {
const { doc, tr: tr2, schema } = state;
const shouldInsertNodeAtEnd = plugin.getState(state);
const endPosition = doc.content.size;
const type = schema.nodes[defaultNode];
if (transactions.some((transaction) => transaction.getMeta(skipTrailingNodeMeta))) {
return;
}
if (!shouldInsertNodeAtEnd) {
return;
}
return tr2.insert(endPosition, type.create());
},
state: {
init: (_, state) => {
const lastNode = state.tr.doc.lastChild;
return !nodeEqualsType({ node: lastNode, types: disabledNodes });
},
apply: (tr2, value) => {
if (!tr2.docChanged) {
return value;
}
if (tr2.getMeta("__uniqueIDTransaction")) {
return value;
}
const lastNode = tr2.doc.lastChild;
return !nodeEqualsType({ node: lastNode, types: disabledNodes });
}
}
})
];
}
});
var UndoRedo = Extension.create({
name: "undoRedo",
addOptions() {
return {
depth: 100,
newGroupDelay: 500
};
},
addCommands() {
return {
undo: () => ({ state, dispatch }) => {
return undo(state, dispatch);
},
redo: () => ({ state, dispatch }) => {
return redo(state, dispatch);
}
};
},
addProseMirrorPlugins() {
return [history(this.options)];
},
addKeyboardShortcuts() {
return {
"Mod-z": () => this.editor.commands.undo(),
"Shift-Mod-z": () => this.editor.commands.redo(),
"Mod-y": () => this.editor.commands.redo(),
// Russian keyboard layouts
"Mod-я": () => this.editor.commands.undo(),
"Shift-Mod-я": () => this.editor.commands.redo()
};
}
});
// node_modules/@tiptap/starter-kit/dist/index.js
var StarterKit = Extension.create({
name: "starterKit",
addExtensions() {
var _a, _b, _c, _d;
const extensions = [];
if (this.options.bold !== false) {
extensions.push(Bold.configure(this.options.bold));
}
if (this.options.blockquote !== false) {
extensions.push(Blockquote.configure(this.options.blockquote));
}
if (this.options.bulletList !== false) {
extensions.push(BulletList.configure(this.options.bulletList));
}
if (this.options.code !== false) {
extensions.push(Code.configure(this.options.code));
}
if (this.options.codeBlock !== false) {
extensions.push(CodeBlock.configure(this.options.codeBlock));
}
if (this.options.document !== false) {
extensions.push(Document.configure(this.options.document));
}
if (this.options.dropcursor !== false) {
extensions.push(Dropcursor.configure(this.options.dropcursor));
}
if (this.options.gapcursor !== false) {
extensions.push(Gapcursor.configure(this.options.gapcursor));
}
if (this.options.hardBreak !== false) {
extensions.push(HardBreak.configure(this.options.hardBreak));
}
if (this.options.heading !== false) {
extensions.push(Heading.configure(this.options.heading));
}
if (this.options.undoRedo !== false) {
extensions.push(UndoRedo.configure(this.options.undoRedo));
}
if (this.options.horizontalRule !== false) {
extensions.push(HorizontalRule.configure(this.options.horizontalRule));
}
if (this.options.italic !== false) {
extensions.push(Italic.configure(this.options.italic));
}
if (this.options.listItem !== false) {
extensions.push(ListItem.configure(this.options.listItem));
}
if (this.options.listKeymap !== false) {
extensions.push(ListKeymap.configure((_a = this.options) == null ? void 0 : _a.listKeymap));
}
if (this.options.link !== false) {
extensions.push(Link.configure((_b = this.options) == null ? void 0 : _b.link));
}
if (this.options.orderedList !== false) {
extensions.push(OrderedList.configure(this.options.orderedList));
}
if (this.options.paragraph !== false) {
extensions.push(Paragraph.configure(this.options.paragraph));
}
if (this.options.strike !== false) {
extensions.push(Strike.configure(this.options.strike));
}
if (this.options.text !== false) {
extensions.push(Text2.configure(this.options.text));
}
if (this.options.underline !== false) {
extensions.push(Underline.configure((_c = this.options) == null ? void 0 : _c.underline));
}
if (this.options.trailingNode !== false) {
extensions.push(TrailingNode.configure((_d = this.options) == null ? void 0 : _d.trailingNode));
}
return extensions;
}
});
var index_default = StarterKit;
export {
StarterKit,
index_default as default
};
//# sourceMappingURL=@tiptap_starter-kit.js.map