tiptap-editor-codeveda
Version:
A powerful, feature-rich WYSIWYG editor built with Tiptap, React, and TypeScript
2,217 lines • 243 kB
JavaScript
import * as ae from "react";
import _t, { useState as U, useRef as lt, useEffect as ge, useCallback as ze } from "react";
import { NodeViewWrapper as Be, NodeViewContent as Lt, ReactNodeViewRenderer as ct, useCurrentEditor as xn, useEditor as yn, EditorContent as vn } from "@tiptap/react";
import eo from "@tiptap/starter-kit";
import { Table as to } from "@tiptap/extension-table";
import En from "@tiptap/extension-table-row";
import Nn from "@tiptap/extension-table-cell";
import Tn from "@tiptap/extension-table-header";
import no from "@tiptap/extension-image";
import ro from "@tiptap/extension-link";
import { TextStyle as oo } from "@tiptap/extension-text-style";
import io from "@tiptap/extension-color";
import so from "@tiptap/extension-highlight";
import ao from "@tiptap/extension-code-block-lowlight";
import { createLowlight as lo, all as co } from "lowlight";
import uo from "@tiptap/extension-underline";
import fo from "@tiptap/extension-strike";
import ho from "@tiptap/extension-blockquote";
import po from "@tiptap/extension-horizontal-rule";
import { Node as Le, mergeAttributes as ke, isTextSelection as mo, posToDOMRect as Sn, Extension as kn, getText as go, getTextSerializersFromSchema as bo } from "@tiptap/core";
import { Trash2 as dt, Settings as wo, ExternalLink as xo, Copy as yo, Heading1 as Cn, Heading2 as An, Heading3 as Rn, FileText as On, List as vo, ListOrdered as Eo, Table as No, Quote as To, Minus as kt, Image as In, Video as So, Code as Mn, PanelTopOpen as ko, Frame as Co, Bold as Ao, Italic as Ro, Underline as Oo, Strikethrough as Io, Type as Mo, Palette as _o, Link as Lo, Plus as Ke, Terminal as jo, Lock as Do, LockOpen as Po } from "lucide-react";
import { Slot as zo } from "@radix-ui/react-slot";
import { cva as Uo } from "class-variance-authority";
import { clsx as Bo } from "clsx";
import { twMerge as Ho } from "tailwind-merge";
import { useMergeRefs as _n, FloatingPortal as $o, FloatingDelayGroup as Fo, useFloating as Jo, offset as Vo, flip as Wo, shift as Ko, autoUpdate as Go, useHover as qo, useFocus as Yo, useDismiss as Zo, useRole as Xo, useInteractions as Qo } from "@floating-ui/react";
import { createPortal as Ln } from "react-dom";
var Ge = { exports: {} }, De = {};
/**
* @license React
* react-jsx-runtime.production.js
*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
var Kt;
function ei() {
if (Kt) return De;
Kt = 1;
var t = Symbol.for("react.transitional.element"), e = Symbol.for("react.fragment");
function n(r, o, i) {
var s = null;
if (i !== void 0 && (s = "" + i), o.key !== void 0 && (s = "" + o.key), "key" in o) {
i = {};
for (var a in o)
a !== "key" && (i[a] = o[a]);
} else i = o;
return o = i.ref, {
$$typeof: t,
type: r,
key: s,
ref: o !== void 0 ? o : null,
props: i
};
}
return De.Fragment = e, De.jsx = n, De.jsxs = n, De;
}
var Pe = {};
/**
* @license React
* react-jsx-runtime.development.js
*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
var Gt;
function ti() {
return Gt || (Gt = 1, process.env.NODE_ENV !== "production" && (function() {
function t(g) {
if (g == null) return null;
if (typeof g == "function")
return g.$$typeof === S ? null : g.displayName || g.name || null;
if (typeof g == "string") return g;
switch (g) {
case w:
return "Fragment";
case E:
return "Profiler";
case p:
return "StrictMode";
case v:
return "Suspense";
case x:
return "SuspenseList";
case O:
return "Activity";
}
if (typeof g == "object")
switch (typeof g.tag == "number" && console.error(
"Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."
), g.$$typeof) {
case b:
return "Portal";
case N:
return (g.displayName || "Context") + ".Provider";
case y:
return (g._context.displayName || "Context") + ".Consumer";
case A:
var C = g.render;
return g = g.displayName, g || (g = C.displayName || C.name || "", g = g !== "" ? "ForwardRef(" + g + ")" : "ForwardRef"), g;
case T:
return C = g.displayName || null, C !== null ? C : t(g.type) || "Memo";
case k:
C = g._payload, g = g._init;
try {
return t(g(C));
} catch {
}
}
return null;
}
function e(g) {
return "" + g;
}
function n(g) {
try {
e(g);
var C = !1;
} catch {
C = !0;
}
if (C) {
C = console;
var _ = C.error, H = typeof Symbol == "function" && Symbol.toStringTag && g[Symbol.toStringTag] || g.constructor.name || "Object";
return _.call(
C,
"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",
H
), e(g);
}
}
function r(g) {
if (g === w) return "<>";
if (typeof g == "object" && g !== null && g.$$typeof === k)
return "<...>";
try {
var C = t(g);
return C ? "<" + C + ">" : "<...>";
} catch {
return "<...>";
}
}
function o() {
var g = M.A;
return g === null ? null : g.getOwner();
}
function i() {
return Error("react-stack-top-frame");
}
function s(g) {
if (B.call(g, "key")) {
var C = Object.getOwnPropertyDescriptor(g, "key").get;
if (C && C.isReactWarning) return !1;
}
return g.key !== void 0;
}
function a(g, C) {
function _() {
W || (W = !0, console.error(
"%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",
C
));
}
_.isReactWarning = !0, Object.defineProperty(g, "key", {
get: _,
configurable: !0
});
}
function l() {
var g = t(this.type);
return $[g] || ($[g] = !0, console.error(
"Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release."
)), g = this.props.ref, g !== void 0 ? g : null;
}
function d(g, C, _, H, ye, se, gt, bt) {
return _ = se.ref, g = {
$$typeof: m,
type: g,
key: C,
props: se,
_owner: ye
}, (_ !== void 0 ? _ : null) !== null ? Object.defineProperty(g, "ref", {
enumerable: !1,
get: l
}) : Object.defineProperty(g, "ref", { enumerable: !1, value: null }), g._store = {}, Object.defineProperty(g._store, "validated", {
configurable: !1,
enumerable: !1,
writable: !0,
value: 0
}), Object.defineProperty(g, "_debugInfo", {
configurable: !1,
enumerable: !1,
writable: !0,
value: null
}), Object.defineProperty(g, "_debugStack", {
configurable: !1,
enumerable: !1,
writable: !0,
value: gt
}), Object.defineProperty(g, "_debugTask", {
configurable: !1,
enumerable: !1,
writable: !0,
value: bt
}), Object.freeze && (Object.freeze(g.props), Object.freeze(g)), g;
}
function u(g, C, _, H, ye, se, gt, bt) {
var G = C.children;
if (G !== void 0)
if (H)
if (F(G)) {
for (H = 0; H < G.length; H++)
f(G[H]);
Object.freeze && Object.freeze(G);
} else
console.error(
"React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead."
);
else f(G);
if (B.call(C, "key")) {
G = t(g);
var Ce = Object.keys(C).filter(function(Qr) {
return Qr !== "key";
});
H = 0 < Ce.length ? "{key: someKey, " + Ce.join(": ..., ") + ": ...}" : "{key: someKey}", z[G + H] || (Ce = 0 < Ce.length ? "{" + Ce.join(": ..., ") + ": ...}" : "{}", console.error(
`A props object containing a "key" prop is being spread into JSX:
let props = %s;
<%s {...props} />
React keys must be passed directly to JSX without using spread:
let props = %s;
<%s key={someKey} {...props} />`,
H,
G,
Ce,
G
), z[G + H] = !0);
}
if (G = null, _ !== void 0 && (n(_), G = "" + _), s(C) && (n(C.key), G = "" + C.key), "key" in C) {
_ = {};
for (var wt in C)
wt !== "key" && (_[wt] = C[wt]);
} else _ = C;
return G && a(
_,
typeof g == "function" ? g.displayName || g.name || "Unknown" : g
), d(
g,
G,
se,
ye,
o(),
_,
gt,
bt
);
}
function f(g) {
typeof g == "object" && g !== null && g.$$typeof === m && g._store && (g._store.validated = 1);
}
var h = _t, m = Symbol.for("react.transitional.element"), b = Symbol.for("react.portal"), w = Symbol.for("react.fragment"), p = Symbol.for("react.strict_mode"), E = Symbol.for("react.profiler"), y = Symbol.for("react.consumer"), N = Symbol.for("react.context"), A = Symbol.for("react.forward_ref"), v = Symbol.for("react.suspense"), x = Symbol.for("react.suspense_list"), T = Symbol.for("react.memo"), k = Symbol.for("react.lazy"), O = Symbol.for("react.activity"), S = Symbol.for("react.client.reference"), M = h.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, B = Object.prototype.hasOwnProperty, F = Array.isArray, P = console.createTask ? console.createTask : function() {
return null;
};
h = {
react_stack_bottom_frame: function(g) {
return g();
}
};
var W, $ = {}, J = h.react_stack_bottom_frame.bind(
h,
i
)(), R = P(r(i)), z = {};
Pe.Fragment = w, Pe.jsx = function(g, C, _, H, ye) {
var se = 1e4 > M.recentlyCreatedOwnerStacks++;
return u(
g,
C,
_,
!1,
H,
ye,
se ? Error("react-stack-top-frame") : J,
se ? P(r(g)) : R
);
}, Pe.jsxs = function(g, C, _, H, ye) {
var se = 1e4 > M.recentlyCreatedOwnerStacks++;
return u(
g,
C,
_,
!0,
H,
ye,
se ? Error("react-stack-top-frame") : J,
se ? P(r(g)) : R
);
};
})()), Pe;
}
var qt;
function ni() {
return qt || (qt = 1, process.env.NODE_ENV === "production" ? Ge.exports = ei() : Ge.exports = ti()), Ge.exports;
}
var c = ni();
const jn = eo.configure({
codeBlock: !1
// We'll use our own code block with syntax highlighting
}), Dn = to.configure({
resizable: !0
}), Pn = no.configure({
inline: !1,
allowBase64: !1,
// Disable base64 to force URL usage
HTMLAttributes: {
class: "max-w-full h-auto rounded-lg shadow-sm"
}
}), zn = ro.configure({
openOnClick: !1,
autolink: !0,
defaultProtocol: "https"
}), Un = oo, Bn = io.configure({
types: ["textStyle"]
}), Hn = so.configure({
multicolor: !0
}), ri = (t) => ({
IMPORTANT: {
scope: "meta",
begin: "!important"
},
BLOCK_COMMENT: t.C_BLOCK_COMMENT_MODE,
HEXCOLOR: {
scope: "number",
begin: /#(([0-9a-fA-F]{3,4})|(([0-9a-fA-F]{2}){3,4}))\b/
},
FUNCTION_DISPATCH: {
className: "built_in",
begin: /[\w-]+(?=\()/
},
ATTRIBUTE_SELECTOR_MODE: {
scope: "selector-attr",
begin: /\[/,
end: /\]/,
illegal: "$",
contains: [
t.APOS_STRING_MODE,
t.QUOTE_STRING_MODE
]
},
CSS_NUMBER_MODE: {
scope: "number",
begin: t.NUMBER_RE + "(%|em|ex|ch|rem|vw|vh|vmin|vmax|cm|mm|in|pt|pc|px|deg|grad|rad|turn|s|ms|Hz|kHz|dpi|dpcm|dppx)?",
relevance: 0
},
CSS_VARIABLE: {
className: "attr",
begin: /--[A-Za-z_][A-Za-z0-9_-]*/
}
}), oi = [
"a",
"abbr",
"address",
"article",
"aside",
"audio",
"b",
"blockquote",
"body",
"button",
"canvas",
"caption",
"cite",
"code",
"dd",
"del",
"details",
"dfn",
"div",
"dl",
"dt",
"em",
"fieldset",
"figcaption",
"figure",
"footer",
"form",
"h1",
"h2",
"h3",
"h4",
"h5",
"h6",
"header",
"hgroup",
"html",
"i",
"iframe",
"img",
"input",
"ins",
"kbd",
"label",
"legend",
"li",
"main",
"mark",
"menu",
"nav",
"object",
"ol",
"optgroup",
"option",
"p",
"picture",
"q",
"quote",
"samp",
"section",
"select",
"source",
"span",
"strong",
"summary",
"sup",
"table",
"tbody",
"td",
"textarea",
"tfoot",
"th",
"thead",
"time",
"tr",
"ul",
"var",
"video"
], ii = [
"defs",
"g",
"marker",
"mask",
"pattern",
"svg",
"switch",
"symbol",
"feBlend",
"feColorMatrix",
"feComponentTransfer",
"feComposite",
"feConvolveMatrix",
"feDiffuseLighting",
"feDisplacementMap",
"feFlood",
"feGaussianBlur",
"feImage",
"feMerge",
"feMorphology",
"feOffset",
"feSpecularLighting",
"feTile",
"feTurbulence",
"linearGradient",
"radialGradient",
"stop",
"circle",
"ellipse",
"image",
"line",
"path",
"polygon",
"polyline",
"rect",
"text",
"use",
"textPath",
"tspan",
"foreignObject",
"clipPath"
], si = [
...oi,
...ii
], ai = [
"any-hover",
"any-pointer",
"aspect-ratio",
"color",
"color-gamut",
"color-index",
"device-aspect-ratio",
"device-height",
"device-width",
"display-mode",
"forced-colors",
"grid",
"height",
"hover",
"inverted-colors",
"monochrome",
"orientation",
"overflow-block",
"overflow-inline",
"pointer",
"prefers-color-scheme",
"prefers-contrast",
"prefers-reduced-motion",
"prefers-reduced-transparency",
"resolution",
"scan",
"scripting",
"update",
"width",
// TODO: find a better solution?
"min-width",
"max-width",
"min-height",
"max-height"
].sort().reverse(), li = [
"active",
"any-link",
"blank",
"checked",
"current",
"default",
"defined",
"dir",
// dir()
"disabled",
"drop",
"empty",
"enabled",
"first",
"first-child",
"first-of-type",
"fullscreen",
"future",
"focus",
"focus-visible",
"focus-within",
"has",
// has()
"host",
// host or host()
"host-context",
// host-context()
"hover",
"indeterminate",
"in-range",
"invalid",
"is",
// is()
"lang",
// lang()
"last-child",
"last-of-type",
"left",
"link",
"local-link",
"not",
// not()
"nth-child",
// nth-child()
"nth-col",
// nth-col()
"nth-last-child",
// nth-last-child()
"nth-last-col",
// nth-last-col()
"nth-last-of-type",
//nth-last-of-type()
"nth-of-type",
//nth-of-type()
"only-child",
"only-of-type",
"optional",
"out-of-range",
"past",
"placeholder-shown",
"read-only",
"read-write",
"required",
"right",
"root",
"scope",
"target",
"target-within",
"user-invalid",
"valid",
"visited",
"where"
// where()
].sort().reverse(), ci = [
"after",
"backdrop",
"before",
"cue",
"cue-region",
"first-letter",
"first-line",
"grammar-error",
"marker",
"part",
"placeholder",
"selection",
"slotted",
"spelling-error"
].sort().reverse(), di = [
"accent-color",
"align-content",
"align-items",
"align-self",
"alignment-baseline",
"all",
"anchor-name",
"animation",
"animation-composition",
"animation-delay",
"animation-direction",
"animation-duration",
"animation-fill-mode",
"animation-iteration-count",
"animation-name",
"animation-play-state",
"animation-range",
"animation-range-end",
"animation-range-start",
"animation-timeline",
"animation-timing-function",
"appearance",
"aspect-ratio",
"backdrop-filter",
"backface-visibility",
"background",
"background-attachment",
"background-blend-mode",
"background-clip",
"background-color",
"background-image",
"background-origin",
"background-position",
"background-position-x",
"background-position-y",
"background-repeat",
"background-size",
"baseline-shift",
"block-size",
"border",
"border-block",
"border-block-color",
"border-block-end",
"border-block-end-color",
"border-block-end-style",
"border-block-end-width",
"border-block-start",
"border-block-start-color",
"border-block-start-style",
"border-block-start-width",
"border-block-style",
"border-block-width",
"border-bottom",
"border-bottom-color",
"border-bottom-left-radius",
"border-bottom-right-radius",
"border-bottom-style",
"border-bottom-width",
"border-collapse",
"border-color",
"border-end-end-radius",
"border-end-start-radius",
"border-image",
"border-image-outset",
"border-image-repeat",
"border-image-slice",
"border-image-source",
"border-image-width",
"border-inline",
"border-inline-color",
"border-inline-end",
"border-inline-end-color",
"border-inline-end-style",
"border-inline-end-width",
"border-inline-start",
"border-inline-start-color",
"border-inline-start-style",
"border-inline-start-width",
"border-inline-style",
"border-inline-width",
"border-left",
"border-left-color",
"border-left-style",
"border-left-width",
"border-radius",
"border-right",
"border-right-color",
"border-right-style",
"border-right-width",
"border-spacing",
"border-start-end-radius",
"border-start-start-radius",
"border-style",
"border-top",
"border-top-color",
"border-top-left-radius",
"border-top-right-radius",
"border-top-style",
"border-top-width",
"border-width",
"bottom",
"box-align",
"box-decoration-break",
"box-direction",
"box-flex",
"box-flex-group",
"box-lines",
"box-ordinal-group",
"box-orient",
"box-pack",
"box-shadow",
"box-sizing",
"break-after",
"break-before",
"break-inside",
"caption-side",
"caret-color",
"clear",
"clip",
"clip-path",
"clip-rule",
"color",
"color-interpolation",
"color-interpolation-filters",
"color-profile",
"color-rendering",
"color-scheme",
"column-count",
"column-fill",
"column-gap",
"column-rule",
"column-rule-color",
"column-rule-style",
"column-rule-width",
"column-span",
"column-width",
"columns",
"contain",
"contain-intrinsic-block-size",
"contain-intrinsic-height",
"contain-intrinsic-inline-size",
"contain-intrinsic-size",
"contain-intrinsic-width",
"container",
"container-name",
"container-type",
"content",
"content-visibility",
"counter-increment",
"counter-reset",
"counter-set",
"cue",
"cue-after",
"cue-before",
"cursor",
"cx",
"cy",
"direction",
"display",
"dominant-baseline",
"empty-cells",
"enable-background",
"field-sizing",
"fill",
"fill-opacity",
"fill-rule",
"filter",
"flex",
"flex-basis",
"flex-direction",
"flex-flow",
"flex-grow",
"flex-shrink",
"flex-wrap",
"float",
"flood-color",
"flood-opacity",
"flow",
"font",
"font-display",
"font-family",
"font-feature-settings",
"font-kerning",
"font-language-override",
"font-optical-sizing",
"font-palette",
"font-size",
"font-size-adjust",
"font-smooth",
"font-smoothing",
"font-stretch",
"font-style",
"font-synthesis",
"font-synthesis-position",
"font-synthesis-small-caps",
"font-synthesis-style",
"font-synthesis-weight",
"font-variant",
"font-variant-alternates",
"font-variant-caps",
"font-variant-east-asian",
"font-variant-emoji",
"font-variant-ligatures",
"font-variant-numeric",
"font-variant-position",
"font-variation-settings",
"font-weight",
"forced-color-adjust",
"gap",
"glyph-orientation-horizontal",
"glyph-orientation-vertical",
"grid",
"grid-area",
"grid-auto-columns",
"grid-auto-flow",
"grid-auto-rows",
"grid-column",
"grid-column-end",
"grid-column-start",
"grid-gap",
"grid-row",
"grid-row-end",
"grid-row-start",
"grid-template",
"grid-template-areas",
"grid-template-columns",
"grid-template-rows",
"hanging-punctuation",
"height",
"hyphenate-character",
"hyphenate-limit-chars",
"hyphens",
"icon",
"image-orientation",
"image-rendering",
"image-resolution",
"ime-mode",
"initial-letter",
"initial-letter-align",
"inline-size",
"inset",
"inset-area",
"inset-block",
"inset-block-end",
"inset-block-start",
"inset-inline",
"inset-inline-end",
"inset-inline-start",
"isolation",
"justify-content",
"justify-items",
"justify-self",
"kerning",
"left",
"letter-spacing",
"lighting-color",
"line-break",
"line-height",
"line-height-step",
"list-style",
"list-style-image",
"list-style-position",
"list-style-type",
"margin",
"margin-block",
"margin-block-end",
"margin-block-start",
"margin-bottom",
"margin-inline",
"margin-inline-end",
"margin-inline-start",
"margin-left",
"margin-right",
"margin-top",
"margin-trim",
"marker",
"marker-end",
"marker-mid",
"marker-start",
"marks",
"mask",
"mask-border",
"mask-border-mode",
"mask-border-outset",
"mask-border-repeat",
"mask-border-slice",
"mask-border-source",
"mask-border-width",
"mask-clip",
"mask-composite",
"mask-image",
"mask-mode",
"mask-origin",
"mask-position",
"mask-repeat",
"mask-size",
"mask-type",
"masonry-auto-flow",
"math-depth",
"math-shift",
"math-style",
"max-block-size",
"max-height",
"max-inline-size",
"max-width",
"min-block-size",
"min-height",
"min-inline-size",
"min-width",
"mix-blend-mode",
"nav-down",
"nav-index",
"nav-left",
"nav-right",
"nav-up",
"none",
"normal",
"object-fit",
"object-position",
"offset",
"offset-anchor",
"offset-distance",
"offset-path",
"offset-position",
"offset-rotate",
"opacity",
"order",
"orphans",
"outline",
"outline-color",
"outline-offset",
"outline-style",
"outline-width",
"overflow",
"overflow-anchor",
"overflow-block",
"overflow-clip-margin",
"overflow-inline",
"overflow-wrap",
"overflow-x",
"overflow-y",
"overlay",
"overscroll-behavior",
"overscroll-behavior-block",
"overscroll-behavior-inline",
"overscroll-behavior-x",
"overscroll-behavior-y",
"padding",
"padding-block",
"padding-block-end",
"padding-block-start",
"padding-bottom",
"padding-inline",
"padding-inline-end",
"padding-inline-start",
"padding-left",
"padding-right",
"padding-top",
"page",
"page-break-after",
"page-break-before",
"page-break-inside",
"paint-order",
"pause",
"pause-after",
"pause-before",
"perspective",
"perspective-origin",
"place-content",
"place-items",
"place-self",
"pointer-events",
"position",
"position-anchor",
"position-visibility",
"print-color-adjust",
"quotes",
"r",
"resize",
"rest",
"rest-after",
"rest-before",
"right",
"rotate",
"row-gap",
"ruby-align",
"ruby-position",
"scale",
"scroll-behavior",
"scroll-margin",
"scroll-margin-block",
"scroll-margin-block-end",
"scroll-margin-block-start",
"scroll-margin-bottom",
"scroll-margin-inline",
"scroll-margin-inline-end",
"scroll-margin-inline-start",
"scroll-margin-left",
"scroll-margin-right",
"scroll-margin-top",
"scroll-padding",
"scroll-padding-block",
"scroll-padding-block-end",
"scroll-padding-block-start",
"scroll-padding-bottom",
"scroll-padding-inline",
"scroll-padding-inline-end",
"scroll-padding-inline-start",
"scroll-padding-left",
"scroll-padding-right",
"scroll-padding-top",
"scroll-snap-align",
"scroll-snap-stop",
"scroll-snap-type",
"scroll-timeline",
"scroll-timeline-axis",
"scroll-timeline-name",
"scrollbar-color",
"scrollbar-gutter",
"scrollbar-width",
"shape-image-threshold",
"shape-margin",
"shape-outside",
"shape-rendering",
"speak",
"speak-as",
"src",
// @font-face
"stop-color",
"stop-opacity",
"stroke",
"stroke-dasharray",
"stroke-dashoffset",
"stroke-linecap",
"stroke-linejoin",
"stroke-miterlimit",
"stroke-opacity",
"stroke-width",
"tab-size",
"table-layout",
"text-align",
"text-align-all",
"text-align-last",
"text-anchor",
"text-combine-upright",
"text-decoration",
"text-decoration-color",
"text-decoration-line",
"text-decoration-skip",
"text-decoration-skip-ink",
"text-decoration-style",
"text-decoration-thickness",
"text-emphasis",
"text-emphasis-color",
"text-emphasis-position",
"text-emphasis-style",
"text-indent",
"text-justify",
"text-orientation",
"text-overflow",
"text-rendering",
"text-shadow",
"text-size-adjust",
"text-transform",
"text-underline-offset",
"text-underline-position",
"text-wrap",
"text-wrap-mode",
"text-wrap-style",
"timeline-scope",
"top",
"touch-action",
"transform",
"transform-box",
"transform-origin",
"transform-style",
"transition",
"transition-behavior",
"transition-delay",
"transition-duration",
"transition-property",
"transition-timing-function",
"translate",
"unicode-bidi",
"user-modify",
"user-select",
"vector-effect",
"vertical-align",
"view-timeline",
"view-timeline-axis",
"view-timeline-inset",
"view-timeline-name",
"view-transition-name",
"visibility",
"voice-balance",
"voice-duration",
"voice-family",
"voice-pitch",
"voice-range",
"voice-rate",
"voice-stress",
"voice-volume",
"white-space",
"white-space-collapse",
"widows",
"width",
"will-change",
"word-break",
"word-spacing",
"word-wrap",
"writing-mode",
"x",
"y",
"z-index",
"zoom"
].sort().reverse();
function ui(t) {
const e = t.regex, n = ri(t), r = { begin: /-(webkit|moz|ms|o)-(?=[a-z])/ }, o = "and or not only", i = /@-?\w[\w]*(-\w+)*/, s = "[a-zA-Z-][a-zA-Z0-9_-]*", a = [
t.APOS_STRING_MODE,
t.QUOTE_STRING_MODE
];
return {
name: "CSS",
case_insensitive: !0,
illegal: /[=|'\$]/,
keywords: { keyframePosition: "from to" },
classNameAliases: {
// for visual continuity with `tag {}` and because we
// don't have a great class for this?
keyframePosition: "selector-tag"
},
contains: [
n.BLOCK_COMMENT,
r,
// to recognize keyframe 40% etc which are outside the scope of our
// attribute value mode
n.CSS_NUMBER_MODE,
{
className: "selector-id",
begin: /#[A-Za-z0-9_-]+/,
relevance: 0
},
{
className: "selector-class",
begin: "\\." + s,
relevance: 0
},
n.ATTRIBUTE_SELECTOR_MODE,
{
className: "selector-pseudo",
variants: [
{ begin: ":(" + li.join("|") + ")" },
{ begin: ":(:)?(" + ci.join("|") + ")" }
]
},
// we may actually need this (12/2020)
// { // pseudo-selector params
// begin: /\(/,
// end: /\)/,
// contains: [ hljs.CSS_NUMBER_MODE ]
// },
n.CSS_VARIABLE,
{
className: "attribute",
begin: "\\b(" + di.join("|") + ")\\b"
},
// attribute values
{
begin: /:/,
end: /[;}{]/,
contains: [
n.BLOCK_COMMENT,
n.HEXCOLOR,
n.IMPORTANT,
n.CSS_NUMBER_MODE,
...a,
// needed to highlight these as strings and to avoid issues with
// illegal characters that might be inside urls that would tigger the
// languages illegal stack
{
begin: /(url|data-uri)\(/,
end: /\)/,
relevance: 0,
// from keywords
keywords: { built_in: "url data-uri" },
contains: [
...a,
{
className: "string",
// any character other than `)` as in `url()` will be the start
// of a string, which ends with `)` (from the parent mode)
begin: /[^)]/,
endsWithParent: !0,
excludeEnd: !0
}
]
},
n.FUNCTION_DISPATCH
]
},
{
begin: e.lookahead(/@/),
end: "[{;]",
relevance: 0,
illegal: /:/,
// break on Less variables @var: ...
contains: [
{
className: "keyword",
begin: i
},
{
begin: /\s/,
endsWithParent: !0,
excludeEnd: !0,
relevance: 0,
keywords: {
$pattern: /[a-z-]+/,
keyword: o,
attribute: ai.join(" ")
},
contains: [
{
begin: /[a-z-]+(?=:)/,
className: "attribute"
},
...a,
n.CSS_NUMBER_MODE
]
}
]
},
{
className: "selector-tag",
begin: "\\b(" + si.join("|") + ")\\b"
}
]
};
}
const Yt = "[A-Za-z$_][0-9A-Za-z$_]*", fi = [
"as",
// for exports
"in",
"of",
"if",
"for",
"while",
"finally",
"var",
"new",
"function",
"do",
"return",
"void",
"else",
"break",
"catch",
"instanceof",
"with",
"throw",
"case",
"default",
"try",
"switch",
"continue",
"typeof",
"delete",
"let",
"yield",
"const",
"class",
// JS handles these with a special rule
// "get",
// "set",
"debugger",
"async",
"await",
"static",
"import",
"from",
"export",
"extends",
// It's reached stage 3, which is "recommended for implementation":
"using"
], hi = [
"true",
"false",
"null",
"undefined",
"NaN",
"Infinity"
], $n = [
// Fundamental objects
"Object",
"Function",
"Boolean",
"Symbol",
// numbers and dates
"Math",
"Date",
"Number",
"BigInt",
// text
"String",
"RegExp",
// Indexed collections
"Array",
"Float32Array",
"Float64Array",
"Int8Array",
"Uint8Array",
"Uint8ClampedArray",
"Int16Array",
"Int32Array",
"Uint16Array",
"Uint32Array",
"BigInt64Array",
"BigUint64Array",
// Keyed collections
"Set",
"Map",
"WeakSet",
"WeakMap",
// Structured data
"ArrayBuffer",
"SharedArrayBuffer",
"Atomics",
"DataView",
"JSON",
// Control abstraction objects
"Promise",
"Generator",
"GeneratorFunction",
"AsyncFunction",
// Reflection
"Reflect",
"Proxy",
// Internationalization
"Intl",
// WebAssembly
"WebAssembly"
], Fn = [
"Error",
"EvalError",
"InternalError",
"RangeError",
"ReferenceError",
"SyntaxError",
"TypeError",
"URIError"
], Jn = [
"setInterval",
"setTimeout",
"clearInterval",
"clearTimeout",
"require",
"exports",
"eval",
"isFinite",
"isNaN",
"parseFloat",
"parseInt",
"decodeURI",
"decodeURIComponent",
"encodeURI",
"encodeURIComponent",
"escape",
"unescape"
], pi = [
"arguments",
"this",
"super",
"console",
"window",
"document",
"localStorage",
"sessionStorage",
"module",
"global"
// Node.js
], mi = [].concat(
Jn,
$n,
Fn
);
function gi(t) {
const e = t.regex, n = (R, { after: z }) => {
const g = "</" + R[0].slice(1);
return R.input.indexOf(g, z) !== -1;
}, r = Yt, o = {
begin: "<>",
end: "</>"
}, i = /<[A-Za-z0-9\\._:-]+\s*\/>/, s = {
begin: /<[A-Za-z0-9\\._:-]+/,
end: /\/[A-Za-z0-9\\._:-]+>|\/>/,
/**
* @param {RegExpMatchArray} match
* @param {CallbackResponse} response
*/
isTrulyOpeningTag: (R, z) => {
const g = R[0].length + R.index, C = R.input[g];
if (
// HTML should not include another raw `<` inside a tag
// nested type?
// `<Array<Array<number>>`, etc.
C === "<" || // the , gives away that this is not HTML
// `<T, A extends keyof T, V>`
C === ","
) {
z.ignoreMatch();
return;
}
C === ">" && (n(R, { after: g }) || z.ignoreMatch());
let _;
const H = R.input.substring(g);
if (_ = H.match(/^\s*=/)) {
z.ignoreMatch();
return;
}
if ((_ = H.match(/^\s+extends\s+/)) && _.index === 0) {
z.ignoreMatch();
return;
}
}
}, a = {
$pattern: Yt,
keyword: fi,
literal: hi,
built_in: mi,
"variable.language": pi
}, l = "[0-9](_?[0-9])*", d = `\\.(${l})`, u = "0|[1-9](_?[0-9])*|0[0-7]*[89][0-9]*", f = {
className: "number",
variants: [
// DecimalLiteral
{ begin: `(\\b(${u})((${d})|\\.)?|(${d}))[eE][+-]?(${l})\\b` },
{ begin: `\\b(${u})\\b((${d})\\b|\\.)?|(${d})\\b` },
// DecimalBigIntegerLiteral
{ begin: "\\b(0|[1-9](_?[0-9])*)n\\b" },
// NonDecimalIntegerLiteral
{ begin: "\\b0[xX][0-9a-fA-F](_?[0-9a-fA-F])*n?\\b" },
{ begin: "\\b0[bB][0-1](_?[0-1])*n?\\b" },
{ begin: "\\b0[oO][0-7](_?[0-7])*n?\\b" },
// LegacyOctalIntegerLiteral (does not include underscore separators)
// https://tc39.es/ecma262/#sec-additional-syntax-numeric-literals
{ begin: "\\b0[0-7]+n?\\b" }
],
relevance: 0
}, h = {
className: "subst",
begin: "\\$\\{",
end: "\\}",
keywords: a,
contains: []
// defined later
}, m = {
begin: ".?html`",
end: "",
starts: {
end: "`",
returnEnd: !1,
contains: [
t.BACKSLASH_ESCAPE,
h
],
subLanguage: "xml"
}
}, b = {
begin: ".?css`",
end: "",
starts: {
end: "`",
returnEnd: !1,
contains: [
t.BACKSLASH_ESCAPE,
h
],
subLanguage: "css"
}
}, w = {
begin: ".?gql`",
end: "",
starts: {
end: "`",
returnEnd: !1,
contains: [
t.BACKSLASH_ESCAPE,
h
],
subLanguage: "graphql"
}
}, p = {
className: "string",
begin: "`",
end: "`",
contains: [
t.BACKSLASH_ESCAPE,
h
]
}, y = {
className: "comment",
variants: [
t.COMMENT(
/\/\*\*(?!\/)/,
"\\*/",
{
relevance: 0,
contains: [
{
begin: "(?=@[A-Za-z]+)",
relevance: 0,
contains: [
{
className: "doctag",
begin: "@[A-Za-z]+"
},
{
className: "type",
begin: "\\{",
end: "\\}",
excludeEnd: !0,
excludeBegin: !0,
relevance: 0
},
{
className: "variable",
begin: r + "(?=\\s*(-)|$)",
endsParent: !0,
relevance: 0
},
// eat spaces (not newlines) so we can find
// types or variables
{
begin: /(?=[^\n])\s/,
relevance: 0
}
]
}
]
}
),
t.C_BLOCK_COMMENT_MODE,
t.C_LINE_COMMENT_MODE
]
}, N = [
t.APOS_STRING_MODE,
t.QUOTE_STRING_MODE,
m,
b,
w,
p,
// Skip numbers when they are part of a variable name
{ match: /\$\d+/ },
f
// This is intentional:
// See https://github.com/highlightjs/highlight.js/issues/3288
// hljs.REGEXP_MODE
];
h.contains = N.concat({
// we need to pair up {} inside our subst to prevent
// it from ending too early by matching another }
begin: /\{/,
end: /\}/,
keywords: a,
contains: [
"self"
].concat(N)
});
const A = [].concat(y, h.contains), v = A.concat([
// eat recursive parens in sub expressions
{
begin: /(\s*)\(/,
end: /\)/,
keywords: a,
contains: ["self"].concat(A)
}
]), x = {
className: "params",
// convert this to negative lookbehind in v12
begin: /(\s*)\(/,
// to match the parms with
end: /\)/,
excludeBegin: !0,
excludeEnd: !0,
keywords: a,
contains: v
}, T = {
variants: [
// class Car extends vehicle
{
match: [
/class/,
/\s+/,
r,
/\s+/,
/extends/,
/\s+/,
e.concat(r, "(", e.concat(/\./, r), ")*")
],
scope: {
1: "keyword",
3: "title.class",
5: "keyword",
7: "title.class.inherited"
}
},
// class Car
{
match: [
/class/,
/\s+/,
r
],
scope: {
1: "keyword",
3: "title.class"
}
}
]
}, k = {
relevance: 0,
match: e.either(
// Hard coded exceptions
/\bJSON/,
// Float32Array, OutT
/\b[A-Z][a-z]+([A-Z][a-z]*|\d)*/,
// CSSFactory, CSSFactoryT
/\b[A-Z]{2,}([A-Z][a-z]+|\d)+([A-Z][a-z]*)*/,
// FPs, FPsT
/\b[A-Z]{2,}[a-z]+([A-Z][a-z]+|\d)*([A-Z][a-z]*)*/
// P
// single letters are not highlighted
// BLAH
// this will be flagged as a UPPER_CASE_CONSTANT instead
),
className: "title.class",
keywords: {
_: [
// se we still get relevance credit for JS library classes
...$n,
...Fn
]
}
}, O = {
label: "use_strict",
className: "meta",
relevance: 10,
begin: /^\s*['"]use (strict|asm)['"]/
}, S = {
variants: [
{
match: [
/function/,
/\s+/,
r,
/(?=\s*\()/
]
},
// anonymous function
{
match: [
/function/,
/\s*(?=\()/
]
}
],
className: {
1: "keyword",
3: "title.function"
},
label: "func.def",
contains: [x],
illegal: /%/
}, M = {
relevance: 0,
match: /\b[A-Z][A-Z_0-9]+\b/,
className: "variable.constant"
};
function B(R) {
return e.concat("(?!", R.join("|"), ")");
}
const F = {
match: e.concat(
/\b/,
B([
...Jn,
"super",
"import"
].map((R) => `${R}\\s*\\(`)),
r,
e.lookahead(/\s*\(/)
),
className: "title.function",
relevance: 0
}, P = {
begin: e.concat(/\./, e.lookahead(
e.concat(r, /(?![0-9A-Za-z$_(])/)
)),
end: r,
excludeBegin: !0,
keywords: "prototype",
className: "property",
relevance: 0
}, W = {
match: [
/get|set/,
/\s+/,
r,
/(?=\()/
],
className: {
1: "keyword",
3: "title.function"
},
contains: [
{
// eat to avoid empty params
begin: /\(\)/
},
x
]
}, $ = "(\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)|" + t.UNDERSCORE_IDENT_RE + ")\\s*=>", J = {
match: [
/const|var|let/,
/\s+/,
r,
/\s*/,
/=\s*/,
/(async\s*)?/,
// async is optional
e.lookahead($)
],
keywords: "async",
className: {
1: "keyword",
3: "title.function"
},
contains: [
x
]
};
return {
name: "JavaScript",
aliases: ["js", "jsx", "mjs", "cjs"],
keywords: a,
// this will be extended by TypeScript
exports: { PARAMS_CONTAINS: v, CLASS_REFERENCE: k },
illegal: /#(?![$_A-z])/,
contains: [
t.SHEBANG({
label: "shebang",
binary: "node",
relevance: 5
}),
O,
t.APOS_STRING_MODE,
t.QUOTE_STRING_MODE,
m,
b,
w,
p,
y,
// Skip numbers when they are part of a variable name
{ match: /\$\d+/ },
f,
k,
{
scope: "attr",
match: r + e.lookahead(":"),
relevance: 0
},
J,
{
// "value" container
begin: "(" + t.RE_STARTERS_RE + "|\\b(case|return|throw)\\b)\\s*",
keywords: "return throw case",
relevance: 0,
contains: [
y,
t.REGEXP_MODE,
{
className: "function",
// we have to count the parens to make sure we actually have the
// correct bounding ( ) before the =>. There could be any number of
// sub-expressions inside also surrounded by parens.
begin: $,
returnBegin: !0,
end: "\\s*=>",
contains: [
{
className: "params",
variants: [
{
begin: t.UNDERSCORE_IDENT_RE,
relevance: 0
},
{
className: null,
begin: /\(\s*\)/,
skip: !0
},
{
begin: /(\s*)\(/,
end: /\)/,
excludeBegin: !0,
excludeEnd: !0,
keywords: a,
contains: v
}
]
}
]
},
{
// could be a comma delimited list of params to a function call
begin: /,/,
relevance: 0
},
{
match: /\s+/,
relevance: 0
},
{
// JSX
variants: [
{ begin: o.begin, end: o.end },
{ match: i },
{
begin: s.begin,
// we carefully check the opening tag to see if it truly
// is a tag and not a false positive
"on:begin": s.isTrulyOpeningTag,
end: s.end
}
],
subLanguage: "xml",
contains: [
{
begin: s.begin,
end: s.end,
skip: !0,
contains: ["self"]
}
]
}
]
},
S,
{
// prevent this from getting swallowed up by function
// since they appear "function like"
beginKeywords: "while if switch catch for"
},
{
// we have to count the parens to make sure we actually have the correct
// bounding ( ). There could be any number of sub-expressions inside
// also surrounded by parens.
begin: "\\b(?!function)" + t.UNDERSCORE_IDENT_RE + "\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)\\s*\\{",
// end parens
returnBegin: !0,
label: "func.def",
contains: [
x,
t.inherit(t.TITLE_MODE, { begin: r, className: "title.function" })
]
},
// catch ... so it won't trigger the property rule below
{
match: /\.\.\./,
relevance: 0
},
P,
// hack: prevents detection of keywords in some circumstances
// .keyword()
// $keyword = x
{
match: "\\$" + r,
relevance: 0
},
{
match: [/\bconstructor(?=\s*\()/],
className: { 1: "title.function" },
contains: [x]
},
F,
M,
T,
W,
{
match: /\$[(.]/
// relevance booster for a pattern common to JS libs: `$(something)` and `$.something`
}
]
};
}
const nt = "[A-Za-z$_][0-9A-Za-z$_]*", Vn = [
"as",
// for exports
"in",
"of",
"if",
"for",
"while",
"finally",
"var",
"new",
"function",
"do",
"return",
"void",
"else",
"break",
"catch",
"instanceof",
"with",
"throw",
"case",
"default",
"try",
"switch",
"continue",
"typeof",
"delete",
"let",
"yield",
"const",
"class",
// JS handles these with a special rule
// "get",
// "set",
"debugger",
"async",
"await",
"static",
"import",
"from",
"export",
"extends",
// It's reached stage 3, which is "recommended for implementation":
"using"
], Wn = [
"true",
"false",
"null",
"undefined",
"NaN",
"Infinity"
], Kn = [
// Fundamental objects
"Object",
"Function",
"Boolean",
"Symbol",
// numbers and dates
"Math",
"Date",
"Number",
"BigInt",
// text
"String",
"RegExp",
// Indexed collections
"Array",
"Float32Array",
"Float64Array",
"Int8Array",
"Uint8Array",
"Uint8ClampedArray",
"Int16Array",
"Int32Array",
"Uint16Array",
"Uint32Array",
"BigInt64Array",
"BigUint64Array",
// Keyed collections
"Set",
"Map",
"WeakSet",
"WeakMap",
// Structured data
"ArrayBuffer",
"SharedArrayBuffer",
"Atomics",
"DataView",
"JSON",
// Control abstraction objects
"Promise",
"Generator",
"GeneratorFunction",
"AsyncFunction",
// Reflection
"Reflect",
"Proxy",
// Internationalization
"Intl",
// WebAssembly
"WebAssembly"
], Gn = [
"Error",
"EvalError",
"InternalError",
"RangeError",
"ReferenceError",
"SyntaxError",
"TypeError",
"URIError"
], qn = [
"setInterval",
"setTimeout",
"clearInterval",
"clearTimeout",
"require",
"exports",
"eval",
"isFinite",
"isNaN",
"parseFloat",
"parseInt",
"decodeURI",
"decodeURIComponent",
"encodeURI",
"encodeURIComponent",
"escape",
"unescape"
], Yn = [
"arguments",
"this",
"super",
"console",
"window",
"document",
"localStorage",
"sessionStorage",
"module",
"global"
// Node.js
], Zn = [].concat(
qn,
Kn,
Gn
);
function bi(t) {
const e = t.regex, n = (R, { after: z }) => {
const g = "</" + R[0].slice(1);
return R.input.indexOf(g, z) !== -1;
}, r = nt, o = {
begin: "<>",
end: "</>"
}, i = /<[A-Za-z0-9\\._:-]+\s*\/>/, s = {
begin: /<[A-Za-z0-9\\._:-]+/,
end: /\/[A-Za-z0-9\\._:-]+>|\/>/,
/**
* @param {RegExpMatchArray} match
* @param {CallbackResponse} response
*/
isTrulyOpeningTag: (R, z) => {
const g = R[0].length + R.index, C = R.input[g];
if (
// HTML should not include another raw `<` inside a tag
// nested type?
// `<Array<Array<number>>`, etc.
C === "<" || // the , gives away that this is not HTML
// `<T, A extends keyof T, V>`
C === ","
) {
z.ignoreMatch();
return;
}
C === ">" && (n(R, { after: g }) || z.ignoreMatch());
let _;
const H = R.input.substring(g);
if (_ = H.match(/^\s*=/)) {
z.ignoreMatch();
return;
}
if ((_ = H.match(/^\s+extends\s+/)) && _.index === 0) {
z.ignoreMatch();
return;
}
}
}, a = {
$pattern: nt,
keyword: Vn,
literal: Wn,
built_in: Zn,
"variable.language": Yn
}, l = "[0-9](_?[0-9])*", d = `\\.(${l})`, u = "0|[1-9](_?[0-9])*|0[0-7]*[89][0-9]*", f = {
className: "number",
variants: [
// DecimalLiteral
{ begin: `(\\b(${u})((${d})|\\.)?|(${d}))[eE][+-]?(${l})\\b` },
{ begin: `\\b(${u})\\b((${d})\\b|\\.)?|(${d})\\b` },
// DecimalBigIntegerLiteral
{ begin: "\\b(0|[1-9](_?[0-9])*)n\\b" },
// NonDecimalIntegerLiteral
{ begin: "\\b0[xX][0-9a-fA-F](_?[0-9a-fA-F])*n?\\b" },
{ begin: "\\b0[bB][0-1](_?[0-1])*n?\\b" },
{ begin: "\\b0[oO][0-7](_?[0-7])*n?\\b" },
// LegacyOctalIntegerLiteral (does not include underscore separators)
// https://tc39.es/ecma262/#sec-additional-syntax-numeric-literals
{ begin: "\\b0[0-7]+n?\\b" }
],
relevance: 0
}, h = {
className: "subst",
begin: "\\$\\{",
end: "\\}",
keywords: a,
contains: []
// defined later
}, m = {
begin: ".?html`",
end: "",
starts: {
end: "`",
returnEnd: !1,
contains: [
t.BACKSLASH_ESCAPE,
h
],
subLanguage: "xml"
}
}, b = {
begin: ".?css`",
end: "",
starts: {
end: "`",
returnEnd: !1,
contains: [
t.BACKSLASH_ESCAPE,
h
],
subLanguage: "css"
}
}, w = {
begin: ".?gql`",
end: "",
starts: {
end: "`",
returnEnd: !1,
contains: [
t.BACKSLASH_ESCAPE,
h
],
subLanguage: "graphql"
}
}, p = {
className: "string",
begin: "`",
end: "`",
contains: [
t.BACKSLASH_ESCAPE,
h
]
}, y = {
className: "comment",
variants: [
t.COMMENT(
/\/\*\*(?!\/)/,
"\\*/",
{
relevance: 0,
contains: [
{
begin: "(?=@[A-Za-z]+)",
relevance: 0,
contains: [
{
className: "doctag",
begin: "@[A-Za-z]+"
},
{
className: "type",
begin: "\\{",
end: "\\}",
excludeEnd: !0,
excludeBegin: !0,
relevance: 0
},
{
className: "variable",
begin: r + "(?=\\s*(-)|$)",
endsParent: !0,
relevance: 0
},
// eat spaces (not newlines) so we can find
// types or variables
{
begin: /(?=[^\n])\s/,
relevance: 0
}
]
}
]
}
),
t.C_BLOCK_COMMENT_MODE,
t.C_LINE_COMMENT_MODE
]
}, N = [
t.APOS_STRING_MODE,
t.QUOTE_STRING_MODE,
m,
b,
w,
p,
// Skip numbers when they are part of a variable name
{ match: /\$\d+/ },
f
// This is intent