@blocknote/react
Version:
A "Notion-style" block-based extensible text editor built on top of Prosemirror and Tiptap.
5,598 lines • 181 kB
JavaScript
import { C as e, E as t, S as n, T as r, _ as i, a, b as o, c as s, d as c, f as l, g as u, h as d, i as f, l as p, m, n as h, o as g, p as _, r as v, s as y, t as b, u as x, v as S, w as C, x as w, y as T } from "./confirmDiscardUnsavedComment-BLTco3jJ.js";
import E, { Suspense as D, createContext as ee, forwardRef as O, lazy as te, memo as ne, useCallback as k, useContext as A, useEffect as j, useId as re, useImperativeHandle as ie, useLayoutEffect as ae, useMemo as M, useReducer as oe, useRef as N, useState as P, useSyncExternalStore as se } from "react";
import { CommentEditorSubmitExtension as F, CommentsExtension as I } from "@blocknote/core/comments";
import { CURRENT_VERSION_ID as L, DEFAULT_LINK_PROTOCOL as ce, FilePanelExtension as le, FormattingToolbarExtension as ue, LinkToolbarExtension as de, ShowSelectionExtension as fe, SideMenuExtension as R, SuggestionMenu as z, TableHandlesExtension as B, VALID_LINK_PROTOCOLS as pe, VersioningExtension as V, filterSuggestionItems as me, getDefaultEmojiPickerItems as he, getDefaultSlashMenuItems as ge } from "@blocknote/core/extensions";
import { autoPlacement as _e, autoUpdate as ve, flip as H, inline as ye, offset as U, safePolygon as be, shift as W, size as xe, useFloating as Se, useTransitionStyles as Ce } from "@floating-ui/react";
import { Fragment as G, jsx as K, jsxs as q } from "react/jsx-runtime";
import { EMPTY_CELL_HEIGHT as we, EMPTY_CELL_WIDTH as Te, SourceBlockWithPreviewExtension as Ee, SourceInlineContentWithPreviewExtension as De, UnreachableCaseError as Oe, addInlineContentAttributes as ke, addInlineContentKeyboardShortcuts as Ae, addStyleAttributes as je, audioParse as Me, blockHasType as J, camelToDataKebab as Ne, createAudioBlockConfig as Pe, createFileBlockConfig as Fe, createImageBlockConfig as Ie, createInternalInlineContentSpec as Le, createInternalStyleSpec as Re, createVideoBlockConfig as ze, defaultProps as Be, defaultToggledState as Ve, editorHasBlockWithType as Y, fileParse as He, filenameFromURL as Ue, formatKeyboardShortcut as We, getBlockFromPos as Ge, getColspan as Ke, getInlineContentParseRules as qe, getNodeById as Je, getPageBreakSlashMenuItems as Ye, getRowspan as Xe, getStyleParseRules as Ze, imageParse as Qe, inlineContentToNodes as $e, isSafari as et, isTableCell as tt, isTableCellSelection as nt, isTouchDevice as rt, mapTableCell as it, mergeCSSClasses as X, nodeToCustomInlineContent as at, nonFormattingMarks as ot, propsToAttributes as st, stylePropsToAttributes as ct, videoParse as lt } from "@blocknote/core";
import { Node as ut } from "@tiptap/core";
import { createPortal as dt, flushSync as ft } from "react-dom";
import { Mark as pt, NodeViewWrapper as mt, ReactMarkViewContext as ht, ReactMarkViewRenderer as gt, ReactNodeViewRenderer as _t, useReactNodeView as vt } from "@tiptap/react";
import { createRoot as yt } from "react-dom/client";
import { TextSelection as bt } from "@tiptap/pm/state";
//#region \0rolldown/runtime.js
var xt = Object.defineProperty, St = (e, t) => {
let n = {};
for (var r in e) xt(n, r, {
get: e[r],
enumerable: !0
});
return t || xt(n, Symbol.toStringTag, { value: "Module" }), n;
}, Ct = (e) => {
let { blockId: t, children: n, ...r } = e, i = C(), a = M(() => i.transact((e) => {
if (!t) return;
let n = Je(t, e.doc);
if (!n) return;
let { node: r } = i.prosemirrorView.domAtPos(n.posBeforeNode + 1);
if (r instanceof Element) return { element: r };
}), [i, t]);
return /* @__PURE__ */ K(p, {
reference: a,
...r,
children: t !== void 0 && n
});
}, wt = (e) => {
let t = s(), n = g(), r = C(), i = r.getBlock(e.blockId), [a, o] = P(""), c = k((e) => {
o(e.currentTarget.value);
}, []), l = k(() => {
r.getBlock(e.blockId) && r.updateBlock(e.blockId, { props: {
name: Ue(a),
url: a
} });
}, [
r,
e.blockId,
a
]);
return i ? /* @__PURE__ */ K(t.FilePanel.TabPanel, {
className: "bn-tab-panel",
children: /* @__PURE__ */ K(t.Generic.Form.Root, {
onSubmit: l,
submitButton: /* @__PURE__ */ K(t.FilePanel.Button, {
className: "bn-button",
type: "submit",
"data-test": "embed-input-button",
children: n.file_panel.embed.embed_button[i.type] || n.file_panel.embed.embed_button.file
}),
children: /* @__PURE__ */ K(t.FilePanel.TextInput, {
className: "bn-text-input",
placeholder: n.file_panel.embed.url_placeholder,
value: a,
onChange: c,
"data-test": "embed-input"
})
})
}) : null;
}, Tt = (e) => {
let t = s(), n = g(), { setLoading: r } = e, i = C(), a = i.getBlock(e.blockId), [o, c] = P(!1);
j(() => {
o && setTimeout(() => {
c(!1);
}, 3e3);
}, [o]);
let l = k((t) => {
if (t === null) return;
async function n(t) {
if (r(!0), i.uploadFile !== void 0) try {
let n = await i.uploadFile(t, e.blockId);
if (!i.getBlock(e.blockId)) return;
typeof n == "string" && (n = { props: {
name: t.name,
url: n
} }), i.updateBlock(e.blockId, n);
} catch {
c(!0);
} finally {
r(!1);
}
}
n(t);
}, [
e.blockId,
i,
r
]);
if (!a) return null;
let u = i.schema.blockSpecs[a.type], d = u.implementation.meta?.fileBlockAccept?.length ? u.implementation.meta.fileBlockAccept.join(",") : "*/*";
return /* @__PURE__ */ q(t.FilePanel.TabPanel, {
className: "bn-tab-panel",
children: [/* @__PURE__ */ K(t.FilePanel.FileInput, {
className: "bn-file-input",
"data-test": "upload-input",
accept: d,
placeholder: n.file_panel.upload.file_placeholder[a.type] || n.file_panel.upload.file_placeholder.file,
value: null,
onChange: l
}), o && /* @__PURE__ */ K("div", {
className: "bn-error-text",
children: n.file_panel.upload.upload_error
})]
});
}, Et = (e) => {
let t = s(), n = g(), r = C(), [i, a] = P(!1), o = e.tabs ?? [...r.uploadFile === void 0 ? [] : [{
name: n.file_panel.upload.title,
tabPanel: /* @__PURE__ */ K(Tt, {
blockId: e.blockId,
setLoading: a
})
}], {
name: n.file_panel.embed.title,
tabPanel: /* @__PURE__ */ K(wt, { blockId: e.blockId })
}], [c, l] = P(e.defaultOpenTab || o[0].name);
return /* @__PURE__ */ K(t.FilePanel.Root, {
className: "bn-panel",
defaultOpenTab: c,
openTab: c,
setOpenTab: l,
tabs: o,
loading: i
});
}, Dt = (e) => {
let t = C(), n = o(le), r = w(le), i = M(() => ({
...e.floatingUIOptions,
useFloatingOptions: {
open: !!r,
onOpenChange: (e, r, i) => {
e || n.closeMenu(), i === "escape-key" && t.focus();
},
middleware: [U(10), H()],
...e.floatingUIOptions?.useFloatingOptions
},
focusManagerProps: {
disabled: !0,
...e.floatingUIOptions?.focusManagerProps
},
elementProps: {
style: { zIndex: 90 },
...e.floatingUIOptions?.elementProps
}
}), [
r,
t,
n,
e.floatingUIOptions
]), a = e.filePanel || Et;
return /* @__PURE__ */ K(l, {
target: e.portalElement,
children: /* @__PURE__ */ K(Ct, {
blockId: r,
...i,
children: r && /* @__PURE__ */ K(a, { blockId: r })
})
});
}, Ot = {
color: void 0,
size: void 0,
className: void 0,
style: void 0,
attr: void 0
}, kt = E.createContext && /*#__PURE__*/ E.createContext(Ot), At = [
"attr",
"size",
"title"
];
function jt(e, t) {
if (e == null) return {};
var n, r, i = Mt(e, t);
if (Object.getOwnPropertySymbols) {
var a = Object.getOwnPropertySymbols(e);
for (r = 0; r < a.length; r++) n = a[r], t.indexOf(n) === -1 && {}.propertyIsEnumerable.call(e, n) && (i[n] = e[n]);
}
return i;
}
function Mt(e, t) {
if (e == null) return {};
var n = {};
for (var r in e) if ({}.hasOwnProperty.call(e, r)) {
if (t.indexOf(r) !== -1) continue;
n[r] = e[r];
}
return n;
}
function Nt() {
return Nt = Object.assign ? Object.assign.bind() : function(e) {
for (var t = 1; t < arguments.length; t++) {
var n = arguments[t];
for (var r in n) ({}).hasOwnProperty.call(n, r) && (e[r] = n[r]);
}
return e;
}, Nt.apply(null, arguments);
}
function Pt(e, t) {
var n = Object.keys(e);
if (Object.getOwnPropertySymbols) {
var r = Object.getOwnPropertySymbols(e);
t && (r = r.filter(function(t) {
return Object.getOwnPropertyDescriptor(e, t).enumerable;
})), n.push.apply(n, r);
}
return n;
}
function Ft(e) {
for (var t = 1; t < arguments.length; t++) {
var n = arguments[t] == null ? {} : arguments[t];
t % 2 ? Pt(Object(n), !0).forEach(function(t) {
It(e, t, n[t]);
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(n)) : Pt(Object(n)).forEach(function(t) {
Object.defineProperty(e, t, Object.getOwnPropertyDescriptor(n, t));
});
}
return e;
}
function It(e, t, n) {
return (t = Lt(t)) in e ? Object.defineProperty(e, t, {
value: n,
enumerable: !0,
configurable: !0,
writable: !0
}) : e[t] = n, e;
}
function Lt(e) {
var t = Rt(e, "string");
return typeof t == "symbol" ? t : t + "";
}
function Rt(e, t) {
if (typeof e != "object" || !e) return e;
var n = e[Symbol.toPrimitive];
if (n !== void 0) {
var r = n.call(e, t || "default");
if (typeof r != "object") return r;
throw TypeError("@@toPrimitive must return a primitive value.");
}
return (t === "string" ? String : Number)(e);
}
function zt(e) {
return e && e.map((e, t) => /*#__PURE__*/ E.createElement(e.tag, Ft({ key: t }, e.attr), zt(e.child)));
}
function Z(e) {
return (t) => /*#__PURE__*/ E.createElement(Bt, Nt({ attr: Ft({}, e.attr) }, t), zt(e.child));
}
function Bt(e) {
var t = (t) => {
var { attr: n, size: r, title: i } = e, a = jt(e, At), o = r || t.size || "1em", s;
return t.className && (s = t.className), e.className && (s = (s ? s + " " : "") + e.className), /*#__PURE__*/ E.createElement("svg", Nt({
stroke: "currentColor",
fill: "currentColor",
strokeWidth: "0"
}, t.attr, n, a, {
className: s,
style: Ft(Ft({ color: e.color || t.color }, t.style), e.style),
height: o,
width: o,
xmlns: "http://www.w3.org/2000/svg"
}), i && /*#__PURE__*/ E.createElement("title", null, i), e.children);
};
return kt === void 0 ? t(Ot) : /*#__PURE__*/ E.createElement(kt.Consumer, null, (e) => t(e));
}
//#endregion
//#region ../../node_modules/.pnpm/react-icons@5.6.0_react@19.2.5/node_modules/react-icons/ri/index.mjs
function Vt(e) {
return Z({
tag: "svg",
attr: {
viewBox: "0 0 24 24",
fill: "currentColor"
},
child: [{
tag: "path",
attr: { d: "M12 22C6.47715 22 2 17.5228 2 12C2 6.47715 6.47715 2 12 2C17.5228 2 22 6.47715 22 12C22 17.5228 17.5228 22 12 22ZM12 20C16.4183 20 20 16.4183 20 12C20 7.58172 16.4183 4 12 4C7.58172 4 4 7.58172 4 12C4 16.4183 7.58172 20 12 20ZM8 13H16C16 15.2091 14.2091 17 12 17C9.79086 17 8 15.2091 8 13ZM8 11C7.17157 11 6.5 10.3284 6.5 9.5C6.5 8.67157 7.17157 8 8 8C8.82843 8 9.5 8.67157 9.5 9.5C9.5 10.3284 8.82843 11 8 11ZM16 11C15.1716 11 14.5 10.3284 14.5 9.5C14.5 8.67157 15.1716 8 16 8C16.8284 8 17.5 8.67157 17.5 9.5C17.5 10.3284 16.8284 11 16 11Z" },
child: []
}]
})(e);
}
function Ht(e) {
return Z({
tag: "svg",
attr: {
viewBox: "0 0 24 24",
fill: "currentColor"
},
child: [{
tag: "path",
attr: { d: "M12 22C6.47715 22 2 17.5228 2 12C2 6.47715 6.47715 2 12 2C17.5228 2 22 6.47715 22 12C22 17.5228 17.5228 22 12 22ZM8 13C8 15.2091 9.79086 17 12 17C14.2091 17 16 15.2091 16 13H8ZM8 11C8.82843 11 9.5 10.3284 9.5 9.5C9.5 8.67157 8.82843 8 8 8C7.17157 8 6.5 8.67157 6.5 9.5C6.5 10.3284 7.17157 11 8 11ZM16 11C16.8284 11 17.5 10.3284 17.5 9.5C17.5 8.67157 16.8284 8 16 8C15.1716 8 14.5 8.67157 14.5 9.5C14.5 10.3284 15.1716 11 16 11Z" },
child: []
}]
})(e);
}
function Ut(e) {
return Z({
tag: "svg",
attr: {
viewBox: "0 0 24 24",
fill: "currentColor"
},
child: [{
tag: "path",
attr: { d: "M5 11V13H19V11H5Z" },
child: []
}]
})(e);
}
function Wt(e) {
return Z({
tag: "svg",
attr: {
viewBox: "0 0 24 24",
fill: "currentColor"
},
child: [{
tag: "path",
attr: { d: "M5 10C3.9 10 3 10.9 3 12C3 13.1 3.9 14 5 14C6.1 14 7 13.1 7 12C7 10.9 6.1 10 5 10ZM19 10C17.9 10 17 10.9 17 12C17 13.1 17.9 14 19 14C20.1 14 21 13.1 21 12C21 10.9 20.1 10 19 10ZM12 10C10.9 10 10 10.9 10 12C10 13.1 10.9 14 12 14C13.1 14 14 13.1 14 12C14 10.9 13.1 10 12 10Z" },
child: []
}]
})(e);
}
function Gt(e) {
return Z({
tag: "svg",
attr: {
viewBox: "0 0 24 24",
fill: "currentColor"
},
child: [{
tag: "path",
attr: { d: "M10 6V8H5V19H16V14H18V20C18 20.5523 17.5523 21 17 21H4C3.44772 21 3 20.5523 3 20V7C3 6.44772 3.44772 6 4 6H10ZM21 3V12L17.206 8.207L11.2071 14.2071L9.79289 12.7929L15.792 6.793L12 3H21Z" },
child: []
}]
})(e);
}
function Kt(e) {
return Z({
tag: "svg",
attr: {
viewBox: "0 0 24 24",
fill: "currentColor"
},
child: [{
tag: "path",
attr: { d: "M4 19H20V12H22V20C22 20.5523 21.5523 21 21 21H3C2.44772 21 2 20.5523 2 20V12H4V19ZM14 9H19L12 16L5 9H10V3H14V9Z" },
child: []
}]
})(e);
}
function qt(e) {
return Z({
tag: "svg",
attr: {
viewBox: "0 0 24 24",
fill: "currentColor"
},
child: [{
tag: "path",
attr: { d: "M17 6H22V8H20V21C20 21.5523 19.5523 22 19 22H5C4.44772 22 4 21.5523 4 21V8H2V6H7V3C7 2.44772 7.44772 2 8 2H16C16.5523 2 17 2.44772 17 3V6ZM18 8H6V20H18V8ZM9 11H11V17H9V11ZM13 11H15V17H13V11ZM9 4V6H15V4H9Z" },
child: []
}]
})(e);
}
function Jt(e) {
return Z({
tag: "svg",
attr: {
viewBox: "0 0 24 24",
fill: "currentColor"
},
child: [{
tag: "path",
attr: { d: "M17 6H22V8H20V21C20 21.5523 19.5523 22 19 22H5C4.44772 22 4 21.5523 4 21V8H2V6H7V3C7 2.44772 7.44772 2 8 2H16C16.5523 2 17 2.44772 17 3V6ZM9 11V17H11V11H9ZM13 11V17H15V11H13ZM9 4V6H15V4H9Z" },
child: []
}]
})(e);
}
function Yt(e) {
return Z({
tag: "svg",
attr: {
viewBox: "0 0 24 24",
fill: "currentColor"
},
child: [{
tag: "path",
attr: { d: "M17 6H22V8H20V21C20 21.5523 19.5523 22 19 22H5C4.44772 22 4 21.5523 4 21V8H2V6H7V3C7 2.44772 7.44772 2 8 2H16C16.5523 2 17 2.44772 17 3V6ZM18 8H6V20H18V8ZM9 4V6H15V4H9Z" },
child: []
}]
})(e);
}
function Xt(e) {
return Z({
tag: "svg",
attr: {
viewBox: "0 0 24 24",
fill: "currentColor"
},
child: [{
tag: "path",
attr: { d: "M11.9997 10.5865L16.9495 5.63672L18.3637 7.05093L13.4139 12.0007L18.3637 16.9504L16.9495 18.3646L11.9997 13.4149L7.04996 18.3646L5.63574 16.9504L10.5855 12.0007L5.63574 7.05093L7.04996 5.63672L11.9997 10.5865Z" },
child: []
}]
})(e);
}
function Zt(e) {
return Z({
tag: "svg",
attr: {
viewBox: "0 0 24 24",
fill: "currentColor"
},
child: [{
tag: "path",
attr: { d: "M9.9997 15.1709L19.1921 5.97852L20.6063 7.39273L9.9997 17.9993L3.63574 11.6354L5.04996 10.2212L9.9997 15.1709Z" },
child: []
}]
})(e);
}
function Qt(e) {
return Z({
tag: "svg",
attr: {
viewBox: "0 0 24 24",
fill: "currentColor"
},
child: [{
tag: "path",
attr: { d: "M11 11V5H13V11H19V13H13V19H11V13H5V11H11Z" },
child: []
}]
})(e);
}
function $t(e) {
return Z({
tag: "svg",
attr: {
viewBox: "0 0 24 24",
fill: "currentColor"
},
child: [{
tag: "path",
attr: { d: "M2 16.0001H5.88889L11.1834 20.3319C11.2727 20.405 11.3846 20.4449 11.5 20.4449C11.7761 20.4449 12 20.2211 12 19.9449V4.05519C12 3.93977 11.9601 3.8279 11.887 3.73857C11.7121 3.52485 11.3971 3.49335 11.1834 3.66821L5.88889 8.00007H2C1.44772 8.00007 1 8.44778 1 9.00007V15.0001C1 15.5524 1.44772 16.0001 2 16.0001ZM23 12C23 15.292 21.5539 18.2463 19.2622 20.2622L17.8445 18.8444C19.7758 17.1937 21 14.7398 21 12C21 9.26016 19.7758 6.80629 17.8445 5.15557L19.2622 3.73779C21.5539 5.75368 23 8.70795 23 12ZM18 12C18 10.0883 17.106 8.38548 15.7133 7.28673L14.2842 8.71584C15.3213 9.43855 16 10.64 16 12C16 13.36 15.3213 14.5614 14.2842 15.2841L15.7133 16.7132C17.106 15.6145 18 13.9116 18 12Z" },
child: []
}]
})(e);
}
function en(e) {
return Z({
tag: "svg",
attr: {
viewBox: "0 0 24 24",
fill: "currentColor"
},
child: [{
tag: "path",
attr: { d: "M3 3.9934C3 3.44476 3.44495 3 3.9934 3H20.0066C20.5552 3 21 3.44495 21 3.9934V20.0066C21 20.5552 20.5551 21 20.0066 21H3.9934C3.44476 21 3 20.5551 3 20.0066V3.9934ZM10.6219 8.41459C10.5562 8.37078 10.479 8.34741 10.4 8.34741C10.1791 8.34741 10 8.52649 10 8.74741V15.2526C10 15.3316 10.0234 15.4088 10.0672 15.4745C10.1897 15.6583 10.4381 15.708 10.6219 15.5854L15.5008 12.3328C15.5447 12.3035 15.5824 12.2658 15.6117 12.2219C15.7343 12.0381 15.6846 11.7897 15.5008 11.6672L10.6219 8.41459Z" },
child: []
}]
})(e);
}
function tn(e) {
return Z({
tag: "svg",
attr: {
viewBox: "0 0 24 24",
fill: "currentColor"
},
child: [{
tag: "path",
attr: { d: "M22 18V20H2V18H22ZM2 3.5L10 8.5L2 13.5V3.5ZM22 11V13H12V11H22ZM22 4V6H12V4H22Z" },
child: []
}]
})(e);
}
function nn(e) {
return Z({
tag: "svg",
attr: {
viewBox: "0 0 24 24",
fill: "currentColor"
},
child: [{
tag: "path",
attr: { d: "M20 3C20.5523 3 21 3.44772 21 4V5.757L19 7.757V5H5V13.1L9 9.1005L13.328 13.429L12.0012 14.7562L11.995 18.995L16.2414 19.0012L17.571 17.671L18.8995 19H19V16.242L21 14.242V20C21 20.5523 20.5523 21 20 21H4C3.44772 21 3 20.5523 3 20V4C3 3.44772 3.44772 3 4 3H20ZM21.7782 7.80761L23.1924 9.22183L15.4142 17L13.9979 16.9979L14 15.5858L21.7782 7.80761ZM15.5 7C16.3284 7 17 7.67157 17 8.5C17 9.32843 16.3284 10 15.5 10C14.6716 10 14 9.32843 14 8.5C14 7.67157 14.6716 7 15.5 7Z" },
child: []
}]
})(e);
}
function rn(e) {
return Z({
tag: "svg",
attr: {
viewBox: "0 0 24 24",
fill: "currentColor"
},
child: [{
tag: "path",
attr: { d: "M21 15V18H24V20H21V23H19V20H16V18H19V15H21ZM21.0082 3C21.556 3 22 3.44495 22 3.9934L22.0007 13.3417C21.3749 13.1204 20.7015 13 20 13V5H4L4.001 19L13.2929 9.70715C13.6528 9.34604 14.22 9.31823 14.6123 9.62322L14.7065 9.70772L18.2521 13.2586C15.791 14.0069 14 16.2943 14 19C14 19.7015 14.1204 20.3749 14.3417 21.0007L2.9918 21C2.44405 21 2 20.5551 2 20.0066V3.9934C2 3.44476 2.45531 3 2.9918 3H21.0082ZM8 7C9.10457 7 10 7.89543 10 9C10 10.1046 9.10457 11 8 11C6.89543 11 6 10.1046 6 9C6 7.89543 6.89543 7 8 7Z" },
child: []
}]
})(e);
}
function an(e) {
return Z({
tag: "svg",
attr: {
viewBox: "0 0 24 24",
fill: "currentColor"
},
child: [{
tag: "path",
attr: { d: "M5 11.1005L7 9.1005L12.5 14.6005L16 11.1005L19 14.1005V5H5V11.1005ZM4 3H20C20.5523 3 21 3.44772 21 4V20C21 20.5523 20.5523 21 20 21H4C3.44772 21 3 20.5523 3 20V4C3 3.44772 3.44772 3 4 3ZM15.5 10C14.6716 10 14 9.32843 14 8.5C14 7.67157 14.6716 7 15.5 7C16.3284 7 17 7.67157 17 8.5C17 9.32843 16.3284 10 15.5 10Z" },
child: []
}]
})(e);
}
function on(e) {
return Z({
tag: "svg",
attr: {
viewBox: "0 0 24 24",
fill: "currentColor"
},
child: [{
tag: "path",
attr: { d: "M2 3.9934C2 3.44476 2.45531 3 2.9918 3H21.0082C21.556 3 22 3.44495 22 3.9934V20.0066C22 20.5552 21.5447 21 21.0082 21H2.9918C2.44405 21 2 20.5551 2 20.0066V3.9934ZM8 5V19H16V5H8ZM4 5V7H6V5H4ZM18 5V7H20V5H18ZM4 9V11H6V9H4ZM18 9V11H20V9H18ZM4 13V15H6V13H4ZM18 13V15H20V13H18ZM4 17V19H6V17H4ZM18 17V19H20V17H18Z" },
child: []
}]
})(e);
}
function sn(e) {
return Z({
tag: "svg",
attr: {
viewBox: "0 0 24 24",
fill: "currentColor"
},
child: [{
tag: "path",
attr: { d: "M8 3V12C8 14.2091 9.79086 16 12 16C14.2091 16 16 14.2091 16 12V3H18V12C18 15.3137 15.3137 18 12 18C8.68629 18 6 15.3137 6 12V3H8ZM4 20H20V22H4V20Z" },
child: []
}]
})(e);
}
function cn(e) {
return Z({
tag: "svg",
attr: {
viewBox: "0 0 24 24",
fill: "currentColor"
},
child: [{
tag: "path",
attr: { d: "M13 6V21H11V6H5V4H19V6H13Z" },
child: []
}]
})(e);
}
function ln(e) {
return Z({
tag: "svg",
attr: {
viewBox: "0 0 24 24",
fill: "currentColor"
},
child: [{
tag: "path",
attr: { d: "M13 10V14H19V10H13ZM11 10H5V14H11V10ZM13 19H19V16H13V19ZM11 19V16H5V19H11ZM13 5V8H19V5H13ZM11 5H5V8H11V5ZM4 3H20C20.5523 3 21 3.44772 21 4V20C21 20.5523 20.5523 21 20 21H4C3.44772 21 3 20.5523 3 20V4C3 3.44772 3.44772 3 4 3Z" },
child: []
}]
})(e);
}
function un(e) {
return Z({
tag: "svg",
attr: {
viewBox: "0 0 24 24",
fill: "currentColor"
},
child: [{
tag: "path",
attr: { d: "M17.1538 14C17.3846 14.5161 17.5 15.0893 17.5 15.7196C17.5 17.0625 16.9762 18.1116 15.9286 18.867C14.8809 19.6223 13.4335 20 11.5862 20C9.94674 20 8.32335 19.6185 6.71592 18.8555V16.6009C8.23538 17.4783 9.7908 17.917 11.3822 17.917C13.9333 17.917 15.2128 17.1846 15.2208 15.7196C15.2208 15.0939 15.0049 14.5598 14.5731 14.1173C14.5339 14.0772 14.4939 14.0381 14.4531 14H3V12H21V14H17.1538ZM13.076 11H7.62908C7.4566 10.8433 7.29616 10.6692 7.14776 10.4778C6.71592 9.92084 6.5 9.24559 6.5 8.45207C6.5 7.21602 6.96583 6.165 7.89749 5.299C8.82916 4.43299 10.2706 4 12.2219 4C13.6934 4 15.1009 4.32808 16.4444 4.98426V7.13591C15.2448 6.44921 13.9293 6.10587 12.4978 6.10587C10.0187 6.10587 8.77917 6.88793 8.77917 8.45207C8.77917 8.87172 8.99709 9.23796 9.43293 9.55079C9.86878 9.86362 10.4066 10.1135 11.0463 10.3004C11.6665 10.4816 12.3431 10.7148 13.076 11H13.076Z" },
child: []
}]
})(e);
}
function dn(e) {
return Z({
tag: "svg",
attr: {
viewBox: "0 0 24 24",
fill: "currentColor"
},
child: [{
tag: "path",
attr: { d: "M21 4H3V6H21V4ZM21 11H8V13H21V11ZM21 18H8V20H21V18ZM5 11H3V20H5V11Z" },
child: []
}]
})(e);
}
function fn(e) {
return Z({
tag: "svg",
attr: {
viewBox: "0 0 24 24",
fill: "currentColor"
},
child: [{
tag: "path",
attr: { d: "M21 20C21 20.5523 20.5523 21 20 21H4C3.44772 21 3 20.5523 3 20V4C3 3.44772 3.44772 3 4 3H20C20.5523 3 21 3.44772 21 4V20ZM19 11V5H13.001V7H15L12 10L9 7H11V5H5V11H7V13H5V19H11V17H9L12 14L15 17H13.001V19H19V13H17V11H19ZM11 13H9V11H11V13ZM15 13H13V11H15V13Z" },
child: []
}]
})(e);
}
function pn(e) {
return Z({
tag: "svg",
attr: {
viewBox: "0 0 24 24",
fill: "currentColor"
},
child: [{
tag: "path",
attr: { d: "M20 3C20.5523 3 21 3.44772 21 4V20C21 20.5523 20.5523 21 20 21H4C3.44772 21 3 20.5523 3 20V4C3 3.44772 3.44772 3 4 3H20ZM11 5H5V10.999H7V9L10 12L7 15V13H5V19H11V17H13V19H19V13H17V15L14 12L17 9V10.999H19V5H13V7H11V5ZM13 13V15H11V13H13ZM13 9V11H11V9H13Z" },
child: []
}]
})(e);
}
function mn(e) {
return Z({
tag: "svg",
attr: {
viewBox: "0 0 24 24",
fill: "currentColor"
},
child: [{
tag: "path",
attr: { d: "M8 4H21V6H8V4ZM4.5 6.5C3.67157 6.5 3 5.82843 3 5C3 4.17157 3.67157 3.5 4.5 3.5C5.32843 3.5 6 4.17157 6 5C6 5.82843 5.32843 6.5 4.5 6.5ZM4.5 13.5C3.67157 13.5 3 12.8284 3 12C3 11.1716 3.67157 10.5 4.5 10.5C5.32843 10.5 6 11.1716 6 12C6 12.8284 5.32843 13.5 4.5 13.5ZM4.5 20.4C3.67157 20.4 3 19.7284 3 18.9C3 18.0716 3.67157 17.4 4.5 17.4C5.32843 17.4 6 18.0716 6 18.9C6 19.7284 5.32843 20.4 4.5 20.4ZM8 11H21V13H8V11ZM8 18H21V20H8V18Z" },
child: []
}]
})(e);
}
function hn(e) {
return Z({
tag: "svg",
attr: {
viewBox: "0 0 24 24",
fill: "currentColor"
},
child: [{
tag: "path",
attr: { d: "M8 4H21V6H8V4ZM5 3V6H6V7H3V6H4V4H3V3H5ZM3 14V11.5H5V11H3V10H6V12.5H4V13H6V14H3ZM5 19.5H3V18.5H5V18H3V17H6V21H3V20H5V19.5ZM8 11H21V13H8V11ZM8 18H21V20H8V18Z" },
child: []
}]
})(e);
}
function gn(e) {
return Z({
tag: "svg",
attr: {
viewBox: "0 0 24 24",
fill: "currentColor"
},
child: [{
tag: "path",
attr: { d: "M8.00008 6V9H5.00008V6H8.00008ZM3.00008 4V11H10.0001V4H3.00008ZM13.0001 4H21.0001V6H13.0001V4ZM13.0001 11H21.0001V13H13.0001V11ZM13.0001 18H21.0001V20H13.0001V18ZM10.7072 16.2071L9.29297 14.7929L6.00008 18.0858L4.20718 16.2929L2.79297 17.7071L6.00008 20.9142L10.7072 16.2071Z" },
child: []
}]
})(e);
}
function _n(e) {
return Z({
tag: "svg",
attr: {
viewBox: "0 0 24 24",
fill: "currentColor"
},
child: [{
tag: "path",
attr: { d: "M18.3638 15.5355L16.9496 14.1213L18.3638 12.7071C20.3164 10.7545 20.3164 7.58866 18.3638 5.63604C16.4112 3.68341 13.2453 3.68341 11.2927 5.63604L9.87849 7.05025L8.46428 5.63604L9.87849 4.22182C12.6122 1.48815 17.0443 1.48815 19.778 4.22182C22.5117 6.95549 22.5117 11.3876 19.778 14.1213L18.3638 15.5355ZM15.5353 18.364L14.1211 19.7782C11.3875 22.5118 6.95531 22.5118 4.22164 19.7782C1.48797 17.0445 1.48797 12.6123 4.22164 9.87868L5.63585 8.46446L7.05007 9.87868L5.63585 11.2929C3.68323 13.2455 3.68323 16.4113 5.63585 18.364C7.58847 20.3166 10.7543 20.3166 12.7069 18.364L14.1211 16.9497L15.5353 18.364ZM14.8282 7.75736L16.2425 9.17157L9.17139 16.2426L7.75717 14.8284L14.8282 7.75736Z" },
child: []
}]
})(e);
}
function vn(e) {
return Z({
tag: "svg",
attr: {
viewBox: "0 0 24 24",
fill: "currentColor"
},
child: [{
tag: "path",
attr: { d: "M17 17H22V19H19V22H17V17ZM7 7H2V5H5V2H7V7ZM18.364 15.5355L16.9497 14.1213L18.364 12.7071C20.3166 10.7545 20.3166 7.58866 18.364 5.63604C16.4113 3.68342 13.2455 3.68342 11.2929 5.63604L9.87868 7.05025L8.46447 5.63604L9.87868 4.22183C12.6123 1.48816 17.0445 1.48816 19.7782 4.22183C22.5118 6.9555 22.5118 11.3877 19.7782 14.1213L18.364 15.5355ZM15.5355 18.364L14.1213 19.7782C11.3877 22.5118 6.9555 22.5118 4.22183 19.7782C1.48816 17.0445 1.48816 12.6123 4.22183 9.87868L5.63604 8.46447L7.05025 9.87868L5.63604 11.2929C3.68342 13.2455 3.68342 16.4113 5.63604 18.364C7.58866 20.3166 10.7545 20.3166 12.7071 18.364L14.1213 16.9497L15.5355 18.364ZM14.8284 7.75736L16.2426 9.17157L9.17157 16.2426L7.75736 14.8284L14.8284 7.75736Z" },
child: []
}]
})(e);
}
function yn(e) {
return Z({
tag: "svg",
attr: {
viewBox: "0 0 24 24",
fill: "currentColor"
},
child: [{
tag: "path",
attr: { d: "M15 20H7V18H9.92661L12.0425 6H9V4H17V6H14.0734L11.9575 18H15V20Z" },
child: []
}]
})(e);
}
function bn(e) {
return Z({
tag: "svg",
attr: {
viewBox: "0 0 24 24",
fill: "currentColor"
},
child: [{
tag: "path",
attr: { d: "M8 5H11V19H8V21H16V19H13V5H16V3H8V5ZM2 7C1.44772 7 1 7.44772 1 8V16C1 16.5523 1.44772 17 2 17H8V15H3V9H8V7H2ZM16 9H21V15H16V17H22C22.5523 17 23 16.5523 23 16V8C23 7.44772 22.5523 7 22 7H16V9Z" },
child: []
}]
})(e);
}
function xn(e) {
return Z({
tag: "svg",
attr: {
viewBox: "0 0 24 24",
fill: "currentColor"
},
child: [{
tag: "path",
attr: { d: "M3 4H21V6H3V4ZM3 19H21V21H3V19ZM11 14H21V16H11V14ZM11 9H21V11H11V9ZM7 12.5L3 16V9L7 12.5Z" },
child: []
}]
})(e);
}
function Sn(e) {
return Z({
tag: "svg",
attr: {
viewBox: "0 0 24 24",
fill: "currentColor"
},
child: [{
tag: "path",
attr: { d: "M3 4H21V6H3V4ZM3 19H21V21H3V19ZM11 14H21V16H11V14ZM11 9H21V11H11V9ZM3 12.5L7 9V16L3 12.5Z" },
child: []
}]
})(e);
}
function Cn(e) {
return Z({
tag: "svg",
attr: {
viewBox: "0 0 24 24",
fill: "currentColor"
},
child: [{
tag: "path",
attr: { d: "M21.097 8L18.499 12.5C20.7091 12.5 22.5 14.2909 22.5 16.5C22.5 18.7091 20.7091 20.5 18.5 20.5C16.2909 20.5 14.5 18.7091 14.5 16.5C14.5 15.7636 14.699 15.0737 15.0461 14.4811L18.788 8H21.097ZM4 4V11H11V4H13V20H11V13H4V20H2V4H4ZM18.5 14.5C17.3954 14.5 16.5 15.3954 16.5 16.5C16.5 17.6046 17.3954 18.5 18.5 18.5C19.6046 18.5 20.5 17.6046 20.5 16.5C20.5 15.3954 19.6046 14.5 18.5 14.5Z" },
child: []
}]
})(e);
}
function wn(e) {
return Z({
tag: "svg",
attr: {
viewBox: "0 0 24 24",
fill: "currentColor"
},
child: [{
tag: "path",
attr: { d: "M22 8V10H17.6769L17.2126 12.6358C17.5435 12.5472 17.8912 12.5 18.25 12.5C20.4591 12.5 22.25 14.2909 22.25 16.5C22.25 18.7091 20.4591 20.5 18.25 20.5C16.4233 20.5 14.8827 19.2756 14.4039 17.6027L16.3271 17.0519C16.5667 17.8881 17.3369 18.5 18.25 18.5C19.3546 18.5 20.25 17.6046 20.25 16.5C20.25 15.3954 19.3546 14.5 18.25 14.5C17.6194 14.5 17.057 14.7918 16.6904 15.2478L14.8803 14.3439L16 8H22ZM4 4V11H11V4H13V20H11V13H4V20H2V4H4Z" },
child: []
}]
})(e);
}
function Tn(e) {
return Z({
tag: "svg",
attr: {
viewBox: "0 0 24 24",
fill: "currentColor"
},
child: [{
tag: "path",
attr: { d: "M13 20H11V13H4V20H2V4H4V11H11V4H13V20ZM22 8V16H23.5V18H22V20H20V18H14.5V16.66L19.5 8H22ZM20 11.133L17.19 16H20V11.133Z" },
child: []
}]
})(e);
}
function En(e) {
return Z({
tag: "svg",
attr: {
viewBox: "0 0 24 24",
fill: "currentColor"
},
child: [{
tag: "path",
attr: { d: "M22 8L21.9984 10L19.4934 12.883C21.0823 13.3184 22.25 14.7728 22.25 16.5C22.25 18.5711 20.5711 20.25 18.5 20.25C16.674 20.25 15.1528 18.9449 14.8184 17.2166L16.7821 16.8352C16.9384 17.6413 17.6481 18.25 18.5 18.25C19.4665 18.25 20.25 17.4665 20.25 16.5C20.25 15.5335 19.4665 14.75 18.5 14.75C18.214 14.75 17.944 14.8186 17.7056 14.9403L16.3992 13.3932L19.3484 10H15V8H22ZM4 4V11H11V4H13V20H11V13H4V20H2V4H4Z" },
child: []
}]
})(e);
}
function Dn(e) {
return Z({
tag: "svg",
attr: {
viewBox: "0 0 24 24",
fill: "currentColor"
},
child: [{
tag: "path",
attr: { d: "M4 4V11H11V4H13V20H11V13H4V20H2V4H4ZM18.5 8C20.5711 8 22.25 9.67893 22.25 11.75C22.25 12.6074 21.9623 13.3976 21.4781 14.0292L21.3302 14.2102L18.0343 18H22V20H15L14.9993 18.444L19.8207 12.8981C20.0881 12.5908 20.25 12.1893 20.25 11.75C20.25 10.7835 19.4665 10 18.5 10C17.5818 10 16.8288 10.7071 16.7558 11.6065L16.75 11.75H14.75C14.75 9.67893 16.4289 8 18.5 8Z" },
child: []
}]
})(e);
}
function On(e) {
return Z({
tag: "svg",
attr: {
viewBox: "0 0 24 24",
fill: "currentColor"
},
child: [{
tag: "path",
attr: { d: "M13 20H11V13H4V20H2V4H4V11H11V4H13V20ZM21.0005 8V20H19.0005L19 10.204L17 10.74V8.67L19.5005 8H21.0005Z" },
child: []
}]
})(e);
}
function kn(e) {
return Z({
tag: "svg",
attr: {
viewBox: "0 0 24 24",
fill: "currentColor"
},
child: [{
tag: "path",
attr: { d: "M5.55397 22H3.3999L10.9999 3H12.9999L20.5999 22H18.4458L16.0458 16H7.95397L5.55397 22ZM8.75397 14H15.2458L11.9999 5.88517L8.75397 14Z" },
child: []
}]
})(e);
}
function An(e) {
return Z({
tag: "svg",
attr: {
viewBox: "0 0 24 24",
fill: "currentColor"
},
child: [{
tag: "path",
attr: { d: "M3.41436 5.99995L5.70726 3.70706L4.29304 2.29285L0.585938 5.99995L4.29304 9.70706L5.70726 8.29285L3.41436 5.99995ZM9.58594 5.99995L7.29304 3.70706L8.70726 2.29285L12.4144 5.99995L8.70726 9.70706L7.29304 8.29285L9.58594 5.99995ZM14.0002 2.99995H21.0002C21.5524 2.99995 22.0002 3.44767 22.0002 3.99995V20C22.0002 20.5522 21.5524 21 21.0002 21H3.00015C2.44787 21 2.00015 20.5522 2.00015 20V12H4.00015V19H20.0002V4.99995H14.0002V2.99995Z" },
child: []
}]
})(e);
}
function jn(e) {
return Z({
tag: "svg",
attr: {
viewBox: "0 0 24 24",
fill: "currentColor"
},
child: [{
tag: "path",
attr: { d: "M8 11H12.5C13.8807 11 15 9.88071 15 8.5C15 7.11929 13.8807 6 12.5 6H8V11ZM18 15.5C18 17.9853 15.9853 20 13.5 20H6V4H12.5C14.9853 4 17 6.01472 17 8.5C17 9.70431 16.5269 10.7981 15.7564 11.6058C17.0979 12.3847 18 13.837 18 15.5ZM8 13V18H13.5C14.8807 18 16 16.8807 16 15.5C16 14.1193 14.8807 13 13.5 13H8Z" },
child: []
}]
})(e);
}
function Mn(e) {
return Z({
tag: "svg",
attr: {
viewBox: "0 0 24 24",
fill: "currentColor"
},
child: [{
tag: "path",
attr: { d: "M3 4H21V6H3V4ZM7 19H21V21H7V19ZM3 14H21V16H3V14ZM7 9H21V11H7V9Z" },
child: []
}]
})(e);
}
function Nn(e) {
return Z({
tag: "svg",
attr: {
viewBox: "0 0 24 24",
fill: "currentColor"
},
child: [{
tag: "path",
attr: { d: "M3 4H21V6H3V4ZM3 19H17V21H3V19ZM3 14H21V16H3V14ZM3 9H17V11H3V9Z" },
child: []
}]
})(e);
}
function Pn(e) {
return Z({
tag: "svg",
attr: {
viewBox: "0 0 24 24",
fill: "currentColor"
},
child: [{
tag: "path",
attr: { d: "M3 4H21V6H3V4ZM3 19H21V21H3V19ZM3 14H21V16H3V14ZM3 9H21V11H3V9Z" },
child: []
}]
})(e);
}
function Fn(e) {
return Z({
tag: "svg",
attr: {
viewBox: "0 0 24 24",
fill: "currentColor"
},
child: [{
tag: "path",
attr: { d: "M3 4H21V6H3V4ZM5 19H19V21H5V19ZM3 14H21V16H3V14ZM5 9H19V11H5V9Z" },
child: []
}]
})(e);
}
function In(e) {
return Z({
tag: "svg",
attr: {
viewBox: "0 0 24 24",
fill: "currentColor"
},
child: [{
tag: "path",
attr: { d: "M23 12L15.9289 19.0711L14.5147 17.6569L20.1716 12L14.5147 6.34317L15.9289 4.92896L23 12ZM3.82843 12L9.48528 17.6569L8.07107 19.0711L1 12L8.07107 4.92896L9.48528 6.34317L3.82843 12Z" },
child: []
}]
})(e);
}
function Ln(e) {
return Z({
tag: "svg",
attr: {
viewBox: "0 0 24 24",
fill: "currentColor"
},
child: [{
tag: "path",
attr: { d: "M3 8L9.00319 2H19.9978C20.5513 2 21 2.45531 21 2.9918V21.0082C21 21.556 20.5551 22 20.0066 22H3.9934C3.44476 22 3 21.5501 3 20.9932V8ZM10 4V9H5V20H19V4H10Z" },
child: []
}]
})(e);
}
function Rn(e) {
return Z({
tag: "svg",
attr: {
viewBox: "0 0 24 24",
fill: "currentColor"
},
child: [{
tag: "path",
attr: { d: "M7 19V13H17V19H19V7.82843L16.1716 5H5V19H7ZM4 3H17L21 7V20C21 20.5523 20.5523 21 20 21H4C3.44772 21 3 20.5523 3 20V4C3 3.44772 3.44772 3 4 3ZM9 15V19H15V15H9Z" },
child: []
}]
})(e);
}
function zn(e) {
return Z({
tag: "svg",
attr: {
viewBox: "0 0 24 24",
fill: "currentColor"
},
child: [{
tag: "path",
attr: { d: "M7.29117 20.8242L2 22L3.17581 16.7088C2.42544 15.3056 2 13.7025 2 12C2 6.47715 6.47715 2 12 2C17.5228 2 22 6.47715 22 12C22 17.5228 17.5228 22 12 22C10.2975 22 8.6944 21.5746 7.29117 20.8242ZM7.58075 18.711L8.23428 19.0605C9.38248 19.6745 10.6655 20 12 20C16.4183 20 20 16.4183 20 12C20 7.58172 16.4183 4 12 4C7.58172 4 4 7.58172 4 12C4 13.3345 4.32549 14.6175 4.93949 15.7657L5.28896 16.4192L4.63416 19.3658L7.58075 18.711Z" },
child: []
}]
})(e);
}
function Bn(e) {
return Z({
tag: "svg",
attr: {
viewBox: "0 0 24 24",
fill: "currentColor"
},
child: [{
tag: "path",
attr: { d: "M7.24264 17.9967H3V13.754L14.435 2.319C14.8256 1.92848 15.4587 1.92848 15.8492 2.319L18.6777 5.14743C19.0682 5.53795 19.0682 6.17112 18.6777 6.56164L7.24264 17.9967ZM3 19.9967H21V21.9967H3V19.9967Z" },
child: []
}]
})(e);
}
function Vn(e) {
return Z({
tag: "svg",
attr: {
viewBox: "0 0 24 24",
fill: "currentColor"
},
child: [{
tag: "path",
attr: { d: "M16.0503 12.0498L21 16.9996L16.0503 21.9493L14.636 20.5351L17.172 17.9988L4 17.9996V15.9996L17.172 15.9988L14.636 13.464L16.0503 12.0498ZM7.94975 2.0498L9.36396 3.46402L6.828 5.9988L20 5.99955V7.99955L6.828 7.9988L9.36396 10.5351L7.94975 11.9493L3 6.99955L7.94975 2.0498Z" },
child: []
}]
})(e);
}
function Hn(e) {
return Z({
tag: "svg",
attr: {
viewBox: "0 0 24 24",
fill: "currentColor"
},
child: [{
tag: "path",
attr: { d: "M8 7V11L2 6L8 1V5H13C17.4183 5 21 8.58172 21 13C21 17.4183 17.4183 21 13 21H4V19H13C16.3137 19 19 16.3137 19 13C19 9.68629 16.3137 7 13 7H8Z" },
child: []
}]
})(e);
}
//#endregion
//#region src/components/FormattingToolbar/DefaultButtons/BasicTextStyleButton.tsx
var Un = {
bold: jn,
italic: yn,
underline: sn,
strike: un,
code: In
};
function Wn(e, t) {
return e in t.schema.styleSchema && t.schema.styleSchema[e].type === e && t.schema.styleSchema[e].propSchema === "boolean";
}
var Gn = (e) => {
let t = g(), n = s(), r = C(), i = S({
editor: r,
selector: ({ editor: t }) => {
if (!(!t.isEditable || !Wn(e.basicTextStyle, t) || !(t.getSelection()?.blocks || [t.getTextCursorPosition().block]).find((e) => e.content !== void 0))) return e.basicTextStyle in t.getActiveStyles() ? { active: !0 } : { active: !1 };
}
}), a = k((e) => {
r.focus(), r.toggleStyles({ [e]: !0 });
}, [r]);
if (i === void 0) return null;
let o = Un[e.basicTextStyle];
return /* @__PURE__ */ K(n.FormattingToolbar.Button, {
className: "bn-button",
"data-test": e.basicTextStyle,
onClick: () => a(e.basicTextStyle),
isSelected: i.active,
label: t.formatting_toolbar[e.basicTextStyle].tooltip,
mainTooltip: t.formatting_toolbar[e.basicTextStyle].tooltip,
secondaryTooltip: We(t.formatting_toolbar[e.basicTextStyle].secondary_tooltip, t.generic.ctrl_shortcut),
icon: /* @__PURE__ */ K(o, {})
});
}, Kn = ee("desktop");
function qn() {
return A(Kn);
}
//#endregion
//#region src/components/ColorPicker/ColorIcon.tsx
var Jn = (e) => {
let t = e.textColor || "default", n = e.backgroundColor || "default", r = e.size || 16, i = M(() => ({
pointerEvents: "none",
fontSize: (r * .75).toString() + "px",
height: r.toString() + "px",
lineHeight: r.toString() + "px",
textAlign: "center",
width: r.toString() + "px"
}), [r]);
return /* @__PURE__ */ K("div", {
className: "bn-color-icon",
"data-background-color": n,
"data-text-color": t,
style: i,
children: "A"
});
}, Yn = [
"default",
"gray",
"brown",
"red",
"orange",
"yellow",
"green",
"blue",
"purple",
"pink"
], Xn = (e) => {
let t = s(), n = g();
return /* @__PURE__ */ q(G, { children: [/* @__PURE__ */ K(() => e.text ? /* @__PURE__ */ q(G, { children: [/* @__PURE__ */ K(t.Generic.Menu.Label, { children: n.color_picker.text_title }), Yn.map((r) => /* @__PURE__ */ K(t.Generic.Menu.Item, {
onClick: () => {
e.onClick?.(), e.text.setColor(r);
},
"data-test": "text-color-" + r,
icon: /* @__PURE__ */ K(Jn, {
textColor: r,
size: e.iconSize
}),
checked: e.text.color === r,
children: n.color_picker.colors[r]
}, "text-color-" + r))] }) : null, {}), /* @__PURE__ */ K(() => e.background ? /* @__PURE__ */ q(G, { children: [/* @__PURE__ */ K(t.Generic.Menu.Label, { children: n.color_picker.background_title }), Yn.map((r) => /* @__PURE__ */ K(t.Generic.Menu.Item, {
onClick: () => {
e.onClick?.(), e.background.setColor(r);
},
"data-test": "background-color-" + r,
icon: /* @__PURE__ */ K(Jn, {
backgroundColor: r,
size: e.iconSize
}),
checked: e.background.color === r,
children: n.color_picker.colors[r]
}, "background-color-" + r))] }) : null, {})] });
};
//#endregion
//#region src/components/FormattingToolbar/DefaultButtons/ColorStyleButton.tsx
function Zn(e, t) {
return `${e}Color` in t.schema.styleSchema && t.schema.styleSchema[`${e}Color`].type === `${e}Color` && t.schema.styleSchema[`${e}Color`].propSchema === "string";
}
var Qn = () => {
let e = s(), t = g(), n = qn(), r = m(), i = C(), a = Zn("text", i), o = Zn("background", i), c = S({
editor: i,
selector: ({ editor: e }) => {
if (!e.isEditable || !(e.getSelection()?.blocks || [e.getTextCursorPosition().block]).find((e) => e.content !== void 0)) return;
let t = Zn("text", e), n = Zn("background", e);
if (!(!t && !n)) return {
textColor: t ? e.getActiveStyles().textColor || "default" : void 0,
backgroundColor: n ? e.getActiveStyles().backgroundColor || "default" : void 0
};
}
}), l = k((e) => {
if (!a) throw Error("Tried to set text color, but style does not exist in editor schema.");
e === "default" ? i.removeStyles({ textColor: e }) : i.addStyles({ textColor: e }), i.focus();
}, [i, a]), u = k((e) => {
if (!o) throw Error("Tried to set background color, but style does not exist in editor schema.");
e === "default" ? i.removeStyles({ backgroundColor: e }) : i.addStyles({ backgroundColor: e }), i.focus();
}, [o, i]);
return c === void 0 ? null : /* @__PURE__ */ q(e.Generic.Menu.Root, {
portalElement: r,
preventFocusOnOpen: n === "mobile",
children: [/* @__PURE__ */ K(e.Generic.Menu.Trigger, { children: /* @__PURE__ */ K(e.FormattingToolbar.Button, {
className: "bn-button",
"data-test": "colors",
label: t.formatting_toolbar.colors.tooltip,
mainTooltip: t.formatting_toolbar.colors.tooltip,
icon: /* @__PURE__ */ K(Jn, {
textColor: c.textColor,
backgroundColor: c.backgroundColor,
size: 20
})
}) }), /* @__PURE__ */ K(e.Generic.Menu.Dropdown, {
className: "bn-menu-dropdown bn-color-picker-dropdown",
children: /* @__PURE__ */ K(Xn, {
text: c.textColor ? {
color: c.textColor,
setColor: l
} : void 0,
background: c.backgroundColor ? {
color: c.backgroundColor,
setColor: u
} : void 0
})
})]
});
};
//#endregion
//#region src/components/Form/ScreenReaderOnlySubmit.tsx
function $n() {
let e = g();
return /* @__PURE__ */ K("button", {
className: "bn-screen-reader-only-submit",
tabIndex: -1,
type: "submit",
children: e.generic.form_submit
});
}
//#endregion
//#region src/components/LinkToolbar/EditLinkMenuItems.tsx
var er = (e) => {
for (let t of pe) if (e.startsWith(t)) return e;
return `${ce}://${e}`;
}, tr = (e) => {
let t = s(), n = g(), { editLink: r } = o(de), { url: i, text: a, showTextField: c } = e, [l, u] = P(i), [d, f] = P(a);
j(() => {
u(i), f(a);
}, [a, i]);
let p = k((e) => u(e.currentTarget.value), []), m = k((e) => f(e.currentTarget.value), []), h = k(() => {
r(er(l), d, e.range.from), e.setToolbarOpen?.(!1), e.setToolbarPositionFrozen?.(!1);
}, [
r,
l,
d,
e
]);
return /* @__PURE__ */ q(t.Generic.Form.Root, {
onSubmit: h,
submitButton: /* @__PURE__ */ K($n, {}),
children: [/* @__PURE__ */ K(t.Generic.Form.TextInput, {
className: "bn-text-input",
name: "url",
icon: /* @__PURE__ */ K(_n, {}),
autoFocus: !0,
placeholder: n.link_toolbar.form.url_placeholder,
value: l,
onChange: p
}), c !== !1 && /* @__PURE__ */ K(t.Generic.Form.TextInput, {
className: "bn-text-input",
name: "title",
icon: /* @__PURE__ */ K(cn, {}),
placeholder: n.link_toolbar.form.title_placeholder,
value: d,
onChange: m
})]
});
};
//#endregion
//#region src/components/FormattingToolbar/DefaultButtons/CreateLinkButton.tsx
function nr(e) {
return "link" in e.schema.inlineContentSchema && e.schema.inlineContentSchema.link === "link";
}
var rr = () => {
let e = C(), t = i(), n = s(), r = g(), a = m(), c = o(ue), { showSelection: l } = o(fe), [u, d] = P(!1);
j(() => (l(u, "createLinkButton"), () => l(!1, "createLinkButton")), [u, l]);
let f = k((t) => {
t || e.focus(), d(t);
}, [e]), p = S({
editor: e,
selector: ({ editor: e }) => {
if (!(!e.isEditable || e.prosemirrorState.selection.empty || !nr(e) || nt(e.prosemirrorState.selection) || !(e.getSelection()?.blocks || [e.getTextCursorPosition().block]).find((e) => e.content !== void 0))) return {
url: e.getSelectedLinkUrl(),
text: e.getSelectedText(),
range: {
from: e.prosemirrorState.selection.from,
to: e.prosemirrorState.selection.to
}
};
}
});
return j(() => {
d(!1);
}, [p]), j(() => {
let e = (e) => {
(e.ctrlKey || e.metaKey) && e.key === "k" && (d(!0), e.preventDefault());
};
return t?.addEventListener("keydown", e), () => {
t?.removeEventListener("keydown", e);
};
}, [t]), p === void 0 ? null : /* @__PURE__ */ q(n.Generic.Popover.Root, {
open: u,
onOpenChange: f,
portalElement: a,
children: [/* @__PURE__ */ K(n.Generic.Popover.Trigger, { children: /* @__PURE__ */ K(n.FormattingToolbar.Button, {
className: "bn-button",
"data-test": "createLink",
label: r.formatting_toolbar.link.tooltip,
mainTooltip: r.formatting_toolbar.link.tooltip,
secondaryTooltip: We(r.formatting_toolbar.link.secondary_tooltip, r.generic.ctrl_shortcut),
icon: /* @__PURE__ */ K(_n, {}),
onClick: () => f(!u)
}) }), /* @__PURE__ */ K(n.Generic.Popover.Content, {
className: "bn-popover-content bn-form-popover",
variant: "form-popover",
children: /* @__PURE__ */ K(tr, {
url: p.url || "",
text: p.text,
range: p.range,
showTextField: !1,
setToolbarOpen: (e) => c.store.setState(e)
})
})]
});
}, ir = () => {
let e = g(), t = s(), n = m(), r = C(), i = S({
editor: r,
selector: ({ editor: e }) => {
if (!e.isEditable) return;
let t = e.getSelection()?.blocks || [e.getTextCursorPosition().block];
if (t.length !== 1) return;
let n = t[0];
if (J(n, e, n.type, {
url: "string",
caption: "string"
})) return n;
}
}), [a, o] = P(!1), c = k((e) => {
e || r.focus(), o(e);
}, [r]), l = k((e) => {
i !== void 0 && Y(r, i.type, { caption: "string" }) && r.updateBlock(i.id, { props: { caption: e.currentTarget.value } });
}, [i, r]);
return i === void 0 ? null : /* @__PURE__ */ q(t.Generic.Popover.Root, {
open: a,
onOpenChange: c,
portalElement: n,
children: [/* @__PURE__ */ K(t.Generic.Popover.Trigger, { children: /* @__PURE__ */ K(t.FormattingToolbar.Button, {
className: "bn-button",
label: e.formatting_toolbar.file_caption.tooltip,
mainTooltip: e.formatting_toolbar.file_caption.tooltip,
icon: /* @__PURE__ */ K(bn, {}),
onClick: () => c(!a)
}) }), /* @__PURE__ */ K(t.Generic.Popover.Content, {
className: "bn-popover-content bn-form-popover",
variant: "form-popover",
children: /* @__PURE__ */ K(t.Generic.Form.Root, {
onSubmit: () => c(!1),
submitButton: /* @__PURE__ */ K($n, {}),
children: /* @__PURE__ */ K(t.Generic.Form.TextInput, {
name: "file-caption",
icon: /* @__PURE__ */ K(bn, {}),
value: i.props.caption,
autoFocus: !0,
placeholder: e.formatting_toolbar.file_caption.input_placeholder,
onChange: l
})
})
})]
});
}, ar = () => {
let e = g(), t = s(), n = C(), r = S({
editor: n,
selector: ({ editor: e }) => {
if (!e.isEditable) return;
let t = e.getSelection()?.blocks || [e.getTextCursorPosition().block];
if (t.length !== 1) return;
let n = t[0];
if (J(n, e, n.type, { url: "string" })) return n;
}
}), i = k(() => {
r !== void 0 && (n.focus(), n.removeBlocks([r.id]));
}, [r, n]);
return r === void 0 ? null : /* @__PURE__ */ K(t.FormattingToolbar.Button, {
className: "bn-button",
label: e.formatting_toolbar.file_delete.tooltip[r.type] || e.formatting_toolbar.file_delete.tooltip.file,
mainTooltip: e.formatting_toolbar.file_delete.tooltip[r.type] || e.formatting_toolbar.file_delete.tooltip.file,
icon: /* @__PURE__ */ K(Yt, {}),
onClick: i
});
}, or = () => {
let e = g(), t = s(), n = m(), r = C(), i = S({
editor: r,
selector: ({ editor: e }) => {
if (!e.isEditable) return;
let t = e.getSelection()?.blocks || [e.getTextCursorPosition().block];
if (t.length !== 1) return;
let n = t[0];
if (J(n, e, n.type, {
url: "string",
name: "string"
})) return n;
}
}), [a, o] = P(!1), c = k((e) => {
e || r.focus(), o(e);
}, [r]), l = k((e) => {
i !== void 0 && Y(r, i.type, { name: "string" }) && r.updateBlock(i.id, { props: { name: e.currentTarget.value } });
}, [i, r]);
return i === void 0 ? null : /* @__PURE__ */ q(t.Generic.Popover.Root, {
open: a,
onOpenChange: c,
portalElement: n,
children: [/* @__PURE__ */ K(t.Generic.Popover.Trigger, { children: /* @__PURE__ */ K(t.FormattingToolbar.Button, {
className: "bn-button",
label: e.formatting_toolbar.file_rename.tooltip[i.type] || e.formatting_toolbar.file_rename.tooltip.file,
mainTooltip: e.formatting_toolbar.file_rename.tooltip[i.type] || e.formatting_toolbar.file_rename.tooltip.file,
icon: /* @__PURE__ */ K(kn, {}),
onClick: () => c(!a)
}) }), /* @__PURE__ */ K(t.Generic.Popover.Content, {
className: "bn-popover-content bn-form-popover",
variant: "form-popover",
children: /* @__PURE__ */ K(t.Generic.Form.Root, {
onSubmit: () => c(!1),
submitButton: /* @__PURE__ */ K($n, {}),
children: /* @__PURE__ */ K(t.Generic.Form.TextInput, {
name: "file-name",
icon: /* @__PURE__ */ K(kn, {}),
value: i.props.name,
autoFocus: !0,
placeholder: e.formatting_toolbar.file_rename.input_placeholder[i.type] || e.formatting_toolbar.file_rename.input_placeholder.file,
onChange: l
})
})
})]
});
}, sr = () => {
let e = g(), t = s(), n = m(), r = C(), i = S({
editor: r,
selector: ({ editor: e }) => {
if (!e.isEditable) return;
let t = e.getSelection()?.blocks || [e.getTextCursorPosition().block];
if (t.length !== 1) return;
let n = t[0];
if (J(n, e, n.type, { url: "string" })) return n;
}
});
return i === void 0 ? null : /* @__PURE__ */ q(t.Generic.Popover.Root, {
onOpenChange: (e) => {
e || r.focus();
},
portalElement: n,
children: [/* @__PURE__ */ K(t.Generic.Popover.Trigger, { children: /* @__PURE__ */ K(t.FormattingToolbar.Button, {
className: "bn-button",
mainTooltip: e.formatting_toolbar.file_replace.tooltip[i.type] || e.formatting_toolbar.file_replace.tooltip.file,
label: e.formatting_toolbar.file_replace.tooltip[i.type] || e.formatting_toolbar.file_replace.tooltip.file,
icon: /* @__PURE__ */ K(nn, {})
}) }), /* @__PURE__ */ K(t.Generic.Popover.Content, {
className: "bn-popover-content bn-panel-popover",
variant: "panel-popover",
children: /* @__PURE__ */ K(Et, { blockId: i.id })
})]
});
}, cr = () => {
let e = g(), t = s(), n = C(), r = S({
editor: n,
selector: ({ editor: e }) => {
if (!(!e.isEditable || !(e.getSelection()?.blocks || [e.getTextCursorPosition().block]).find((e) => e.content !== void 0))) return { canNestBlock: e.canNestBlock() };
}
}), i = k(() => {
r !== void 0 && r.canNestBlock && (n.focus(), n.nestBlock());
}, [n, r]);
return r === void 0 ? null : /* @__PURE__ */ K(t.FormattingToolbar.Button, {
className: "bn-button",
"data-test": "nestBlock",
onClick: i,
isDisabled: !r.canNestBlock,
label: e.formatting_toolbar.nest.tooltip,
mainTooltip: e.formatting_toolbar.nest.tooltip,
secondaryTooltip: We(e.formatting_toolbar.nest.secondary_tooltip, e.generic.ctrl_shortcut),
icon: /* @__PURE__ */ K(xn, {})
});
}, lr = () => {
let e = g(), t = s(), n = C(), r = S({
editor: n,
selector: ({ editor: e }) => {
if (!(!e.isEditable || !(e.getSelection()?.blocks || [e.getTextCursorPosition().block]).find((e) => e.content !== void 0))) return { canUnnestBlock: e.canUnnestBlock() };
}
}), i = k(() => {
r !== void 0 && r.canUnnestBlock && (n.focus(), n.unnestBlock());
}, [n, r]);
return r === void 0 ? null : /* @__PURE__ */ K(t.FormattingToolbar.Button, {
className: "bn-button",
"data-test": "unnestBlock",
onClick: i,
isDisabled: !r.canUnnestBlock,
label: e.formatting_toolbar.unnest.tooltip,
mainTooltip: e.formatting_toolbar.unnest.tooltip,
secondaryTooltip: We(e.formatting_toolbar.unnest.secondary_tooltip, e.generic.ctrl_shortcut),
icon: /* @__PURE__ */ K(Sn, {})
});
}, ur = (e) => [
{
name: e.slash_menu.paragraph.title,
type: "paragraph",
icon: cn
},
{
name: e.slash_menu.heading.title,
type: "heading",
props: {
level: 1,
isToggleable: !1
},
icon: On
},
{
name: e.slash_menu.heading_2.title,
type: "heading",
props: {
level: 2,
isToggleable: !1
},
icon: Dn
},
{
name: e.slash_menu.heading_3.title,
type: "heading",
props: {
level: 3,
isToggleable: !1
},
icon: En
},
{
name: e.slash_menu.heading_4.title,
type: "heading",
props: {
level: 4,
isToggleable: !1
},
icon: Tn
},
{
name: e.slash_menu.heading_5.title,
type: "heading",
props: {
level: 5,
isToggleable: !1
},
icon: wn
},
{
name: e.slash_menu.heading_6.title,
type: "heading",
props: {
level: 6,
isToggleable: !1
},
icon: Cn
},
{
name: e.slash_menu.toggle_heading.title,
type: "heading",
props: {
level: 1,
isToggleable: !0
},
icon: On
},
{
name: e.slash_menu.toggle_heading_2.title,
type: "heading",
props: {
level: 2,
isToggleable: !0
},
icon: Dn
},
{
name: e.slash_menu.toggle_heading_3.title,
type: "heading",
props: {
level: 3,
isToggleable: !0
},
icon: En
},
{
name: e.slash_menu.quote.title,
type: "quote",
icon: dn
},
{
name: e.slash_menu.toggle_list.title,
type: "toggleListItem",
icon: tn
},
{
name: e.slash_menu.bullet_list.title,
type: "bulletListItem",
icon: mn
},
{
name: e.slash_menu.numbered_list.title,
type: "numberedListItem",
icon: hn
},
{
name: e.slash_menu.check_list.title,
type: "checkListItem",
icon: gn
}
], dr = (e) => {
let t = s(), n = qn(), r = m(), i = C(), a = S({
editor: i,
selector: ({ editor: e }) => e.getSelection()?.blocks || [e.getTextCursorPosition().block]
}), o = a[0], c = M(() => (e.items || ur(i.dictionary)).filter((e) => Y(i, e.type, Object.fromEntries(Object.entries(e.props || {}).map(([e, t]) => [e, typeof t])))), [i, e.items]), l = M(() => c.map((e) => {
let t = e.icon, n = e.type === o.type, r = Object.entries(e.props || {}).filter(([e, t]) => t !== o.props[e]).length === 0;
return {
text: e.name,
icon: /* @__PURE__ */ K(t, { size: 16 }),
onClick: () => {
i.focus(), i.transact(() => {
for (let t of a) i.updateBlock(t, {
type: e.type,
props: e.props
});
});
},
isSelected: n && r
};
}), [
i,
c,
o.props,
o.type,
a
]);
return !M(() => l.find((e) => e.isSelected) !== void 0, [l]) || !i.isEditable ? null : /* @__PURE__ */ K(t.FormattingToolbar.Select, {
className: "bn-select",
items: l,
portalElement: r,
preventFocusOnOpen: n === "mobile"
});
}, fr = () => {
let e = g(), t = s(), n = C(), r = o("comments"), { store: i } = o(ue), a = S({
editor: n,
selector: ({ editor: e }) => e.prosemirrorState.selection.empty
}), c = k(() => {
r.startPendingComment(), i.setState(!1);
}, [r, i]);
return a ? null : /* @__PURE__ */ K(t.FormattingToolbar.Button, {
className: "bn-button",
label: e.formatting_toolbar.comment.tooltip,
mainTooltip: e.formatting_toolbar.comment.tooltip,
icon: /* @__PURE__ */ K(zn, {}),
onClick: c
});
}, pr = () => C().getExtension("comments") ? /* @__PURE__ */ K(fr, {}) : null, mr = () => {
let e = g(), t = s(), n = C(), r = S({
editor: n,
selector: ({ editor: e }) => e.prosemirrorState.selection.empty
}), i = k(() => {
n._tiptapEditor.chain().focus().addPendingComment().run();
}, [n]);
return !n._tiptapEditor.commands.addPendingComment || !n.isEditable || r ? null : /* @__PURE__ */ K(t.FormattingToolbar.Button, {
className: "bn-button",
label: e.formatting_toolbar.comment.tooltip,
mainTooltip: e.formatting_toolbar.comment.tooltip,
icon: /* @__PURE__ */ K(zn, {}),
onClick: i
});
};
//#endregion
//#region src/util/sanitizeUrl.ts
function hr(e, t) {
try {
let n = new URL(e, t);
if (n.protocol !== "javascript:") return n.href;
} catch {}
return "#";
}
//#endregion
//#region src/components/FormattingToolbar/DefaultButtons/FileDownloadButton.tsx
var gr = () => {
let e = g(), t = s(), n = C(), r = S({
editor: n,
selector: ({ editor: e }) => {
let t = e.getSelection()?.blocks || [e.getTextCursorPosition().block];
if (t.length !== 1) return;
let n = t[0];
if (J(n, e, n.type, { url: "string" })) return n;
}
}), i = k(() => {
r !== void 0 && (n.focus(), n.resolveFileUrl ? n.resolveFileUrl(r.props.url).then((e) => window.open(hr(e, window.location.href))) : window.open(hr(r.props.url, window.location.href)));
}, [r, n]);
return r === void 0 ? null : /* @__PURE__ */ K(t.FormattingToolbar.Button, {
className: "bn-button",
label: e.formatting_toolbar.file_download.tooltip[r.type] || e.formatting_toolbar.file_download.tooltip.file,
mainTooltip: e.formatting_toolbar.file_download.tooltip[r.type] || e.formatting_toolbar.file_download.tooltip.file,
icon: /* @__PURE__ */ K(Kt, {}),
onClick: i
});
}, _r = () => {
let e = g(), t = s(), n = C(), r = S({
editor: n,
selector: ({ editor: e }) => {
if (!e.isEditable) return;
let t = e.getSelection()?.blocks || [e.getTextCursorPosition().block];
if (t.length !== 1) return;
let n = t[0];
if (J(n, e, n.type, {
url: "string",
showPreview: "boolean"
})) return n;
}
}), i = k(() => {
r !== void 0 && Y(n, r.type, { showPreview: "boolean" }) && n.updateBlock(r.id, { props: { showPreview: !r.props.showPreview } });
}, [r, n]);
return r === void 0 ? null : /* @__PURE__ */ K(t.FormattingToolbar.Button, {
className: "bn-button",
label: "Toggle preview",
mainTooltip: e.formatting_toolbar.file_preview_toggle.tooltip,
icon: /* @__PURE__ */ K(rn, {}),
isSelected: r.props.showPreview,
onClick: i
});
}, vr = () => {
let e = g(), t = s(), n = C(), r = o(B), i = S({
editor: n,
selector: ({ editor: e }) => {
if (!e.isEditable || !e.settings.tables.splitCells) return;
let t = e.getSelection()?.blocks || [e.getTextCursorPosition().block];
if (t.length !== 1) return;
let n = t[0];
if (n.type === "table") return { mergeDirection: r.getMergeDirection(n) };
}
}), a = k(() => {
r?.mergeCells();
}, [r]);
return i === void 0 ? null : /* @__PURE__ */ K(t.FormattingToolbar.Button, {
className: "bn-button",
label: e.formatting_toolbar.table_cell_merge.tooltip,
mainTooltip: e.formatting_toolbar.table_cell_merge.tooltip,
icon: i.mergeDirection === "horizontal" ? /* @__PURE__ */ K(pn, {}) : /* @__PURE__ */ K(fn, {}),
onClick: a
});
}, yr = () => C().getExtension(B) ? /* @__PURE__ */ K(vr, {}) : null, br = {
left: Nn,
center: Fn,
right: Mn,
justify: Pn
}, xr = (e) => {
let t = s(), n = g(), r = C(), i = S({
editor: r,
selector: ({ editor: e }) => {
if (!e.isEditable) return;
let t = e.getSelection()?.blocks || [e.getTextCursorPosition().block], n = t[0];
if (J(n, e, n.type, { textAlignment: Be.textAlignment })) return {
textAlignment: n.props.textAlignment,
blocks: t
};
if (t.length === 1 && J(n, e, "table")) return e.getExtension(B)?.getCellSelection() ? {
textAlignment: it(n.content.rows[0].cells[0]).props.textAlignment,
blocks: [n]
} : void 0;
}
}), a = k((e) => {
if (i !== void 0) {
r.focus();
for (let t of i.blocks) if (J(t, r, t.type, { textAlignment: Be.textAlignment }) && Y(r, t.type, { textAlignment: Be.textAlignment })) r.updateBlock(t, { props: { textAlignment: e } });
else if (t.type === "table") {
let n = r.getExtension(B)?.getCellSelection();
if (!n) continue;
let i = t.content.rows.map((e) => ({
...e,
cells: e.cells.map((e) => it(e))
}));
n.cells.forEach(({ row: t, col: n }) => {
i[t].cells[n].props.textAlignment = e;
}), r.updateBlock(t, {
type: "table",
content: {
...t.content,
type: "tableContent",
rows: i
}
}), r.setTextCursorPosition(t);
}
}
}, [r, i]);
if (i === void 0) return null;
let o = br[e.textAlignment];
return /* @__PURE__ */ K(t.FormattingToolbar.Button, {
className: "bn-button",
"data-test": `alignText${e.textAlignment.slice(0, 1).toUpperCase() + e.textAlignment.slice(1)}`,
onClick: () => a(e.textAlignment),
isSelected: i.textAlignment === e.textAlignment,
label: n.formatting_toolbar[`align_${e.textAlignment}`].tooltip,
mainTooltip: n.formatting_toolbar[`align_${e.textAlignment}`].tooltip,
icon: /* @__PURE__ */ K(o, {})
});
}, Sr = (e) => [
/* @__PURE__ */ K(dr, { items: e }, "blockTypeSelect"),
/* @__PURE__ */ K(yr, {}, "tableCellMergeButton"),
/* @__PURE__ */ K(ir, {}, "fileCaptionButton"),
/* @__PURE__ */ K(sr, {}, "replaceFileButton"),
/* @__PURE__ */ K(or, {}, "fileRenameButton"),
/* @__PURE__ */ K(ar, {}, "fileDeleteButton"),
/* @__PURE__ */ K(gr, {}, "fileDownloadButton"),
/* @__PURE__ */ K(_r, {}, "filePreviewButton"),
/* @__PURE__ */ K(Gn, { basicTextStyle: "bold" }, "boldStyleButton"),
/* @__PURE__ */ K(Gn, { basicTextStyle: "italic" }, "italicStyleButton"),
/* @__PURE__ */ K(Gn, { basicTextStyle: "underline" }, "underlineStyleButton"),
/* @__PURE__ */ K(Gn, { basicTextStyle: "strike" }, "strikeStyleButton"),
/* @__PURE__ */ K(xr, { textAlignment: "left" }, "textAlignLeftButton"),
/* @__PURE__ */ K(xr, { textAlignment: "center" }, "textAlignCenterButton"),
/* @__PURE__ */ K(xr, { textAlignment: "right" }, "textAlignRightButton"),
/* @__PURE__ */ K(Qn, {}, "colorStyleButton"),
/* @__PURE__ */ K(cr, {}, "nestBlockButton"),
/* @__PURE__ */ K(lr, {}, "unnestBlockButton"),
/* @__PURE__ */ K(rr, {}, "createLinkButton"),
/* @__PURE__ */ K(pr, {}, "addCommentButton"),
/* @__PURE__ */ K(mr, {}, "addTiptapCommentButton")
], Cr = (e) => {
let t = s();
return /* @__PURE__ */ K(t.FormattingToolbar.Root, {
className: "bn-toolbar bn-formatting-toolbar",
children: e.children || Sr(e.blockTypeSelectItems)
});
}, wr = (e) => {
switch (e) {
case "left": return "top-start";
case "center": return "top";
case "right": return "top-end";
default: return "top-start";
}
}, Tr = (e) => {
let t = C(), n = o(ue, { editor: t }), r = w(ue, { editor: t }), i = S({
editor: t,
selector: ({ editor: e }) => n.store.state ? {
from: e.prosemirrorState.selection.from,
to: e.prosemirrorState.selection.to
} : void 0
}), s = S({
editor: t,
selector: ({ editor: e }) => {
let t = e.getTextCursorPosition().block;
return J(t, e, t.type, { textAlignment: Be.textAlignment }) ? wr(t.props.textAlignment) : "top-start";
}
}), c = M(() => ({
...e.floatingUIOptions,
useFloatingOptions: {
open: r,
onOpenChange: (e, r, i) => {
n.store.setState(e), i === "escape-key" && t.focus();
},
placement: s,
middleware: [
U(10),
W(),
H()
],
...e.floatingUIOptions?.useFloatingOptions
},
focusManagerProps: {
disabled: !0,
...e.floatingUIOptions?.focusManagerProps
},
elementProps: {
style: { zIndex: 40 },
...e.floatingUIOptions?.elementProps
}
}), [
r,
s,
e.floatingUIOptions,
n.store,
t
]), u = e.formattingToolbar || Cr;
return /* @__PURE__ */ K(l, {
target: e.portalElement,
children: /* @__PURE__ */ K(a, {
position: i,
...c,
children: r && /* @__PURE__ */ K(u, {})
})
});
};
//#endregion
//#region src/hooks/useEditorFocus.ts
function Er(e, n) {
let r = t(), i = n ?? r?.editor;
if (!i) throw Error("'editor' is required, either from BlockNoteContext or as a function argument");
let a = e?.includeEditorUI ?? !1, o = N(void 0);
(o.current === void 0 || o.current.editor !== i || o.current.includeEditorUI !== a) && (o.current = {
editor: i,
includeEditorUI: a,
value: i.isFocused({ includeEditorUI: a })
});
let s = k((e) => (o.current = {
editor: i,
includeEditorUI: a,
value: i.isFocused({ includeEditorUI: a })
}, e(), i.onFocusChange((t, n) => {
o.current = {
editor: i,
includeEditorUI: a,
value: n.focused
}, e();
}, { includeEditorUI: a })), [i, a]), c = k(() => o.current.value, []);
return se(s, c, c);
}
//#endregion
//#region src/components/FormattingToolbar/useVirtualKeyboard.ts
var Dr = 0, Or = 0;
function kr() {
if (typeof window > "u") return !1;
let e = window.visualViewport, t = e?.scale ?? 1, n = (e?.height ?? window.innerHeight) * t, r = document.documentElement.clientWidth;
return Math.abs(r - Or) > Or * .2 && (Or = r, Dr = 0), Dr = Math.max(Dr, n), Dr - n > 150;
}
var Ar = [
"--bn-vv-top",
"--bn-vv-left",
"--bn-vv-width",
"--bn-vv-height",
"--bn-vv-scale"
], jr = 0;
function Mr() {
let [e, t] = P(kr);
return ae(() => {
let e = document.documentElement, n = window.visualViewport, r = () => document.querySelectorAll(".bn-scroll-container"), i = () => {
e.style.setProperty("--bn-vv-top", `${n?.offsetTop ?? 0}px`), e.style.setProperty("--bn-vv-left", `${n?.offsetLeft ?? 0}px`), e.style.setProperty("--bn-vv-width", `${n?.width ?? window.innerWidth}px`), e.style.setProperty("--bn-vv-height", `${n?.height ?? window.innerHeight}px`), e.style.setProperty("--bn-vv-scale", `${n?.scale ?? 1}`);
}, a = (e, t) => e.toggleAttribute("data-bn-allow-pull-to-refresh", !t && e.scrollTop <= 0), o = () => {
let e = kr();
t(e), i();
for (let t of r()) a(t, e);
};
jr++, o(), n?.addEventListener("resize", o), n?.addEventListener("scroll", o), window.addEventListener("resize", o);
let s = (e) => {
e.target instanceof HTMLElement && e.target.classList.contains("bn-scroll-container") && a(e.target, kr());
};
return document.addEventListener("scroll", s, {
capture: !0,
passive: !0
}), () => {
if (n?.removeEventListener("resize", o), n?.removeEventListener("scroll", o), window.removeEventListener("resize", o), document.removeEventListener("scroll", s, { capture: !0 }), jr--, jr === 0) {
for (let t of Ar) e.style.removeProperty(t);
for (let e of r()) e.removeAttribute("data-bn-allow-pull-to-refresh");
Dr = 0, Or = 0;
}
};
}, []), e;
}
//#endregion
//#region src/components/FormattingToolbar/MobileFormattingToolbarController.tsx
var Nr = (e) => {
let t = Mr(), n = Er({ includeEditorUI: !0 });
return !t || !n ? null : /* @__PURE__ */ K(l, {
target: document.body,
children: /* @__PURE__ */ K(Kn.Provider, {
value: "mobile",
children: /* @__PURE__ */ K(Pr, { formattingToolbar: e.formattingToolbar || Cr })
})
});
};
function Pr(e) {
let t = m(), n = e.formattingToolbar;
return t ? dt(/* @__PURE__ */ K(c, { children: /* @__PURE__ */ K("div", {
className: "bn-mobile-formatting-toolbar",
children: /* @__PURE__ */ K(n, {})
}) }), t) : null;
}
//#endregion
//#region src/components/FormattingToolbar/FormattingToolbarController.tsx
var Fr = (e) => {
let t = Mr();
return rt() && t ? /* @__PURE__ */ K(Nr, { formattingToolbar: e.formattingToolbar }) : /* @__PURE__ */ K(Tr, { ...e });
}, Ir = (e) => {
let t = s(), n = g(), { deleteLink: r } = o(de);
return /* @__PURE__ */ K(t.LinkToolbar.Button, {
className: "bn-button",
label: n.link_toolbar.delete.tooltip,
mainTooltip: n.link_toolbar.delete.tooltip,
isSelected: !1,
onClick: () => {
r(e.range.from), e.setToolbarOpen?.(!1);
},
icon: /* @__PURE__ */ K(vn, {})
});
}, Lr = (e) => {
let t = s(), n = m(), r = g();
return /* @__PURE__ */ q(t.Generic.Popover.Root, {
onOpenChange: e.setToolbarPositionFrozen,
portalElement: n,
children: [/* @__PURE__ */ K(t.Generic.Popover.Trigger, { children: /* @__PURE__ */ K(t.LinkToolbar.Button, {
className: "bn-button",
mainTooltip: r.link_toolbar.edit.tooltip,
isSelected: !1,
children: r.link_toolbar.edit.text
}) }), /* @__PURE__ */ K(t.Generic.Popover.Content, {
className: "bn-popover-content bn-form-popover",
variant: "form-popover",
children: /* @__PURE__ */ K(tr, {
url: e.url,
text: e.text,
range: e.range,
setToolbarOpen: e.setToolbarOpen,
setToolbarPositionFrozen: e.setToolbarPositionFrozen
})
})]
});
}, Rr = (e) => {
let t = s(), n = g();
return /* @__PURE__ */ K(t.LinkToolbar.Button, {
className: "bn-button",
mainTooltip: n.link_toolbar.open.tooltip,
label: n.link_toolbar.open.tooltip,
isSelected: !1,
onClick: () => {
window.open(hr(e.url, window.location.href), "_blank");
},
icon: /* @__PURE__ */ K(Gt, {})
});
}, zr = (e) => {
let t = s();
return /* @__PURE__ */ K(t.LinkToolbar.Root, {
className: "bn-toolbar bn-link-toolbar",
children: e.children || /* @__PURE__ */ q(G, { children: [
/* @__PURE__ */ K(Lr, {
url: e.url,
text: e.text,
range: e.range,
setToolbarOpen: e.setToolbarOpen,
setToolbarPositionFrozen: e.setToolbarPositionFrozen
}),
/* @__PURE__ */ K(Rr, { url: e.url }),
/* @__PURE__ */ K(Ir, {
range: e.range,
setToolbarOpen: e.setToolbarOpen
})
] })
});
}, Br = (e) => {
let t = C(), [n, r] = P(!1), [a, s] = P(!1), c = i(), u = o(de), [d, f] = P(void 0);
j(() => {
let e = () => {
let e = u.getLinkAtSelection();
if (!e) {
f(void 0), a || r(!1);
return;
}
f({
cursorType: "text",
url: e.mark.attrs.href,
text: e.text,
range: e.range,
element: u.getLinkElementAtPos(e.range.from)
}), a || r(!0);
}, n = (e) => {
if (d !== void 0 && d.cursorType === "text" || !(e.target instanceof HTMLElement)) return;
let t = u.getLinkAtElement(e.target);
t && f({
cursorType: "mouse",
url: t.mark.attrs.href,
text: t.text,
range: t.range,
element: u.getLinkElementAtPos(t.range.from)
});
}, i = t.onChange(e), o = t.onSelectionChange(e);
return c?.addEventListener("mouseover", n), () => {
i(), o(), c?.removeEventListener("mouseover", n);
};
}, [
t,
c,
u,
d,
a
]);
let m = M(() => ({
...e.floatingUIOptions,
useFloatingOptions: {
open: n,
onOpenChange: (e, n, i) => {
a || (d === void 0 || d.cursorType !== "text" || i !== "hover") && (i === "escape-key" && t.focus(), r(e));
},
placement: "top-start",
middleware: [U(10), H()],
...e.floatingUIOptions?.useFloatingOptions
},
useHoverProps: {
enabled: d !== void 0 && d.cursorType === "mouse",
delay: {
open: 250,
close: 250
},
handleClose: be(),
...e.floatingUIOptions?.useHoverProps
},
focusManagerProps: {
disabled: !0,
...e.floatingUIOptions?.focusManagerProps
},
elementProps: {
style: { zIndex: 50 },
...e.floatingUIOptions?.elementProps
}
}), [
t,
d,
e.floatingUIOptions,
n,
a
]), h = M(() => d?.element ? { element: d.element } : void 0, [d?.element]);
if (!t.isEditable) return null;
let g = e.linkToolbar || zr;
return /* @__PURE__ */ K(l, {
target: e.portalElement,
children: /* @__PURE__ */ K(p, {
reference: h,
...m,
children: d && /* @__PURE__ */ K(g, {
url: d.url,
text: d.text,
range: d.range,
setToolbarOpen: r,
setToolbarPositionFrozen: s
})
})
});
};
//#endregion
//#region ../../node_modules/.pnpm/react-icons@5.6.0_react@19.2.5/node_modules/react-icons/ai/index.mjs
function Vr(e) {
return Z({
tag: "svg",
attr: { viewBox: "0 0 1024 1024" },
child: [{
tag: "path",
attr: { d: "M482 152h60q8 0 8 8v704q0 8-8 8h-60q-8 0-8-8V160q0-8 8-8Z" },
child: []
}, {
tag: "path",
attr: { d: "M192 474h672q8 0 8 8v60q0 8-8 8H160q-8 0-8-8v-60q0-8 8-8Z" },
child: []
}]
})(e);
}
//#endregion
//#region src/components/SideMenu/DefaultButtons/AddBlockButton.tsx
var Hr = () => {
let e = s(), t = g(), n = C(), r = o(z), i = w(R, {
editor: n,
selector: (e) => e?.block
}), a = k(() => {
if (i === void 0) return;
let e = i.content;
if (e !== void 0 && Array.isArray(e) && e.length === 0) n.setTextCursorPosition(i), r.openSuggestionMenu("/");
else {
let e = n.insertBlocks([{ type: "paragraph" }], i, "after")[0];
n.setTextCursorPosition(e), r.openSuggestionMenu("/");
}
}, [
i,
n,
r
]);
return i === void 0 ? null : /* @__PURE__ */ K(e.SideMenu.Button, {
className: "bn-button",
label: t.side_menu.add_block_label,
icon: /* @__PURE__ */ K(Vr, {
size: 24,
onClick: a,
"data-test": "dragHandleAdd"
})
});
};
//#endregion
//#region ../../node_modules/.pnpm/react-icons@5.6.0_react@19.2.5/node_modules/react-icons/md/index.mjs
function Ur(e) {
return Z({
tag: "svg",
attr: { viewBox: "0 0 24 24" },
child: [{
tag: "path",
attr: {
fill: "none",
d: "M0 0h24v24H0z"
},
child: []
}, {
tag: "path",
attr: { d: "m7 10 5 5 5-5z" },
child: []
}]
})(e);
}
function Wr(e) {
return Z({
tag: "svg",
attr: { viewBox: "0 0 24 24" },
child: [{
tag: "path",
attr: {
fill: "none",
d: "M0 0h24v24H0z"
},
child: []
}, {
tag: "path",
attr: { d: "M19 7v4H5.83l3.58-3.59L8 6l-6 6 6 6 1.41-1.41L5.83 13H21V7z" },
child: []
}]
})(e);
}
function Gr(e) {
return Z({
tag: "svg",
attr: { viewBox: "0 0 24 24" },
child: [{
tag: "path",
attr: {
fill: "none",
d: "M0 0h24v24H0V0z"
},
child: []
}, {
tag: "path",
attr: { d: "M11 15h2v2h-2zm0-8h2v6h-2zm.99-5C6.47 2 2 6.48 2 12s4.47 10 9.99 10C17.52 22 22 17.52 22 12S17.52 2 11.99 2zM12 20c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8z" },
child: []
}]
})(e);
}
function Kr(e) {
return Z({
tag: "svg",
attr: { viewBox: "0 0 24 24" },
child: [{
tag: "path",
attr: {
fill: "none",
d: "M0 0h24v24H0V0z"
},
child: []
}, {
tag: "path",
attr: { d: "M11 18c0 1.1-.9 2-2 2s-2-.9-2-2 .9-2 2-2 2 .9 2 2zm-2-8c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm0-6c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm6 4c1.1 0 2-.9 2-2s-.9-2-2-2-2 .9-2 2 .9 2 2 2zm0 2c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm0 6c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2z" },
child: []
}]
})(e);
}
//#endregion
//#region src/components/SideMenu/DragHandleMenu/DefaultItems/BlockColorsItem.tsx
var qr = (e) => {
let t = s(), n = m(), r = C(), i = w(R, {
editor: r,
selector: (e) => e?.block
});
return i === void 0 || !J(i, r, i.type, { textColor: "string" }) && !J(i, r, i.type, { backgroundColor: "string" }) ? null : /* @__PURE__ */ q(t.Generic.Menu.Root, {
position: "right",
sub: !0,
portalElement: n,
children: [/* @__PURE__ */ K(t.Generic.Menu.Trigger, {
sub: !0,
children: /* @__PURE__ */ K(t.Generic.Menu.Item, {
className: "bn-menu-item",
subTrigger: !0,
children: e.children
})
}), /* @__PURE__ */ K(t.Generic.Menu.Dropdown, {
sub: !0,
className: "bn-menu-dropdown bn-color-picker-dropdown",
children: /* @__PURE__ */ K(Xn, {
iconSize: 18,
text: J(i, r, i.type, { textColor: "string" }) && Y(r, i.type, { textColor: "string" }) ? {
color: i.props.textColor,
setColor: (e) => r.updateBlock(i, {
type: i.type,
props: { textColor: e }
})
} : void 0,
background: J(i, r, i.type, { backgroundColor: "string" }) && Y(r, i.type, { backgroundColor: "string" }) ? {
color: i.props.backgroundColor,
setColor: (e) => r.updateBlock(i, { props: { backgroundColor: e } })
} : void 0
})
})]
});
}, Jr = (e) => {
let t = s(), n = C(), r = w(R, {
editor: n,
selector: (e) => e?.block
});
return r === void 0 ? null : /* @__PURE__ */ K(t.Generic.Menu.Item, {
className: "bn-menu-item",
onClick: () => {
let e = n.getSelection()?.blocks, t = e && e.some((e) => e.id === r.id) ? e : [r];
n.removeBlocks(t);
},
children: e.children
});
}, Yr = (e) => {
let t = s(), n = C(), r = w(R, {
editor: n,
selector: (e) => e?.block
});
if (r === void 0 || r.type !== "table" || !n.settings.tables.headers) return null;
let i = !!r.content.headerRows;
return /* @__PURE__ */ K(t.Generic.Menu.Item, {
className: "bn-menu-item",
checked: i,
onClick: () => {
n.updateBlock(r, { content: {
...r.content,
headerRows: i ? void 0 : 1
} });
},
children: e.children
});
}, Xr = (e) => {
let t = s(), n = C(), r = w(R, {
editor: n,
selector: (e) => e?.block
});
if (r === void 0 || r.type !== "table" || !n.settings.tables.headers) return null;
let i = !!r.content.headerCols;
return /* @__PURE__ */ K(t.Generic.Menu.Item, {
className: "bn-menu-item",
checked: i,
onClick: () => {
n.updateBlock(r, { content: {
...r.content,
headerCols: i ? void 0 : 1
} });
},
children: e.children
});
}, Zr = (e) => {
let t = s(), n = g();
return /* @__PURE__ */ K(t.Generic.Menu.Dropdown, {
className: "bn-menu-dropdown bn-drag-handle-menu",
children: e.children || /* @__PURE__ */ q(G, { children: [
/* @__PURE__ */ K(Jr, { children: n.drag_handle.delete_menuitem }),
/* @__PURE__ */ K(qr, { children: n.drag_handle.colors_menuitem }),
/* @__PURE__ */ K(Yr, { children: n.drag_handle.header_row_menuitem }),
/* @__PURE__ */ K(Xr, { children: n.drag_handle.header_column_menuitem })
] })
});
}, Qr = (e) => {
let t = s(), n = m(), r = g(), i = o(R), a = w(R, { selector: (e) => e?.block });
if (a === void 0) return null;
let c = e.dragHandleMenu || Zr;
return /* @__PURE__ */ q(t.Generic.Menu.Root, {
onOpenChange: (e) => {
e ? i.freezeMenu() : i.unfreezeMenu();
},
position: "left",
portalElement: n,
children: [/* @__PURE__ */ K(t.Generic.Menu.Trigger, { children: /* @__PURE__ */ K(t.SideMenu.Button, {
label: r.side_menu.drag_handle_label,
draggable: !0,
onDragStart: (e) => i.blockDragStart(e, a),
onDragEnd: i.blockDragEnd,
className: "bn-button",
icon: /* @__PURE__ */ K(Kr, {
size: 24,
"data-test": "dragHandle"
})
}) }), /* @__PURE__ */ K(c, { children: e.children })]
});
}, $r = (e) => {
let t = s();
return /* @__PURE__ */ K(t.SideMenu.Root, {
className: "bn-side-menu",
children: e.children || /* @__PURE__ */ q(G, { children: [/* @__PURE__ */ K(Hr, {}), /* @__PURE__ */ K(Qr, { dragHandleMenu: e.dragHandleMenu })] })
});
};
//#endregion
//#region src/components/SideMenu/SideMenuController.tsx
function ei(e, t) {
if (t.type === "heading") switch (t.props.level) {
case 1: return 39;
case 2: return 27;
case 3: return 18.5;
default: return 0;
}
return e.schema.blockSpecs[t.type]?.implementation.meta?.fileBlockAccept && !t.props.url ? 12 : t.type === "file" ? 4 : t.type === "audio" || t.type === "table" ? 15 : 0;
}
var ti = (e) => {
let t = C(), { show: n, block: r } = w(R, { selector: (e) => e === void 0 ? void 0 : {
show: e.show,
block: e.block
} }) || {}, i = k((e, n, r) => {
let i = !1;
return ve(e, n, () => {
if (!i) {
i = !0;
return;
}
t.getExtension(R)?.hideMenuIfNotFrozen();
}, {
ancestorScroll: !0,
ancestorResize: !1,
elementResize: !1,
layoutShift: !1
});
}, [t]), a = M(() => ({
...e.floatingUIOptions,
useFloatingOptions: {
open: n,
placement: "left-start",
middleware: [U({ crossAxis: r ? ei(t, r) : 0 })],
whileElementsMounted: i,
...e.floatingUIOptions?.useFloatingOptions
},
useDismissProps: {
enabled: !1,
...e.floatingUIOptions?.useDismissProps
},
focusManagerProps: {
disabled: !0,
...e.floatingUIOptions?.focusManagerProps
},
elementProps: {
style: { zIndex: 20 },
...e.floatingUIOptions?.elementProps
}
}), [
e.floatingUIOptions,
n,
r,
t,
i
]), o = e.sideMenu || $r;
return /* @__PURE__ */ K(l, {
target: e.portalElement,
children: /* @__PURE__ */ K(Ct, {
blockId: n ? r?.id : void 0,
...a,
children: r?.id && /* @__PURE__ */ K(o, {})
})
});
}, ni = ({ format: e, dictionary: t }) => {
let n = t.suggestion_changes.formatting_change;
if (e.length === 0) return n;
let r = t.formatting_toolbar, i = [];
for (let t of e) {
let e = r[t], a = e && typeof e == "object" && "tooltip" in e ? e.tooltip : void 0;
if (typeof a != "string") return n;
i.push(a);
}
return i.join(", ");
}, ri = (e) => {
let t = s(), n = g(), r = M(() => {
let t = n.suggestion_changes, r = e.formatChangeLabel ?? ni, i = e.users.join(", ");
if (e.modificationType === "insert") return t.inserted_by(i);
if (e.modificationType === "delete") return t.deleted_by(i);
let a = e.format ? r({
format: e.format,
dictionary: n
}) : "";
return t.formatting_change_by(a, i);
}, [
n,
e.formatChangeLabel,
e.users,
e.modificationType,
e.format
]);
return /* @__PURE__ */ K(t.AttributionTooltip.Root, {
className: "bn-suggestion-tooltip",
markClassName: e.className,
backgroundColor: e.className ? void 0 : e.color,
children: r
});
}, ii = (e) => {
let t = w("attribution", { selector: (e) => e }), n = M(() => t ? {
element: t.anchor,
getBoundingClientRect: () => {
let e = t.anchor.firstElementChild ?? t.anchor, n = e.getBoundingClientRect();
return (n.width || n.height ? e : e.firstElementChild ?? e).getBoundingClientRect();
},
getClientRects: () => {
let e = t.anchor.firstElementChild ?? t.anchor, n = e.getBoundingClientRect();
return (n.width || n.height ? e : e.firstElementChild ?? e).getClientRects();
}
} : void 0, [t]), r = M(() => ({
...e.floatingUIOptions,
useFloatingOptions: {
open: !!t,
placement: "top-start",
middleware: [
ye(),
U(4),
H(),
W({ padding: 4 })
],
...e.floatingUIOptions?.useFloatingOptions
},
focusManagerProps: {
disabled: !0,
...e.floatingUIOptions?.focusManagerProps
},
elementProps: {
style: {
zIndex: 1e4,
pointerEvents: "none"
},
...e.floatingUIOptions?.elementProps
}
}), [e.floatingUIOptions, t]), i = e.attributionTooltip || ri, a = M(() => t ? {
color: t.color,
className: t.className,
modificationType: t.modificationType,
contentType: t.contentType,
users: t.users,
format: t.format,
formatChangeLabel: e.formatChangeLabel
} : void 0, [t, e.formatChangeLabel]);
return /* @__PURE__ */ K(l, {
target: e.portalElement,
children: /* @__PURE__ */ K(p, {
reference: n,
...r,
children: a && /* @__PURE__ */ K(i, { ...a })
})
});
};
//#endregion
//#region src/components/SuggestionMenu/GridSuggestionMenu/getDefaultReactEmojiPickerItems.tsx
async function ai(e, t) {
return (await he(e, t)).map(({ id: e, onItemClick: t }) => ({
id: e,
onItemClick: t,
icon: e
}));
}
//#endregion
//#region src/components/SuggestionMenu/GridSuggestionMenu/GridSuggestionMenu.tsx
function oi(e) {
let t = s(), n = g(), { items: r, loadingState: i, selectedIndex: a, onItemClick: o, columns: c } = e, l = i === "loading-initial" || i === "loading" ? /* @__PURE__ */ K(t.GridSuggestionMenu.Loader, {
className: "bn-grid-suggestion-menu-loader",
columns: c
}) : null, u = M(() => {
let e = [];
for (let n = 0; n < r.length; n++) {
let i = r[n];
e.push(/* @__PURE__ */ K(t.GridSuggestionMenu.Item, {
className: "bn-grid-suggestion-menu-item",
item: i,
id: `bn-grid-suggestion-menu-item-${n}`,
isSelected: n === a,
onClick: () => o?.(i)
}, i.id));
}
return e;
}, [
t,
r,
o,
a
]);
return /* @__PURE__ */ q(t.GridSuggestionMenu.Root, {
id: "bn-grid-suggestion-menu",
columns: c,
className: "bn-grid-suggestion-menu",
children: [
l,
u,
u.length === 0 && e.loadingState === "loaded" && /* @__PURE__ */ K(t.GridSuggestionMenu.EmptyItem, {
className: "bn-grid-suggestion-menu-empty-item",
columns: c,
children: n.suggestion_menu.no_items_title
})
]
});
}
//#endregion
//#region src/components/SuggestionMenu/getSuggestionMenuItemId.ts
function si(e) {
return e === void 0 ? void 0 : "bn-suggestion-menu-item-" + e;
}
//#endregion
//#region src/components/SuggestionMenu/hooks/useCloseSuggestionMenuNoItems.ts
function ci(e, t, n, r = 3) {
let i = N(0);
j(() => {
t !== void 0 && (e.length > 0 ? i.current = t.length : t.length - i.current > r && n());
}, [
n,
r,
e.length,
t
]);
}
//#endregion
//#region src/components/SuggestionMenu/hooks/useLoadSuggestionMenuItems.ts
function li(e, t) {
let [n, r] = P([]), [i, a] = P(!1), o = N(void 0), s = N(void 0);
return j(() => {
let n = e;
o.current = e, a(!0), t(e).then((e) => {
o.current === n && (r(e), a(!1), s.current = n);
});
}, [e, t]), {
items: n || [],
usedQuery: s.current,
loadingState: s.current === void 0 ? "loading-initial" : i ? "loading" : "loaded"
};
}
//#endregion
//#region src/components/SuggestionMenu/GridSuggestionMenu/hooks/useGridSuggestionMenuKeyboardNavigation.ts
function ui(e, t, n, r, a) {
let o = i(e), [s, c] = P(0);
return j(() => {
let e = (e) => (e.key === "ArrowLeft" && (e.preventDefault(), n.length && c((s - 1 + n.length) % n.length)), e.key === "ArrowRight" && (e.preventDefault(), n.length && c((s + 1 + n.length) % n.length)), e.key === "ArrowUp" ? (e.preventDefault(), n.length && c((s - r + n.length) % n.length), !0) : e.key === "ArrowDown" ? (e.preventDefault(), n.length && c((s + r) % n.length), !0) : e.key === "Enter" && !e.isComposing && (e.stopPropagation(), e.preventDefault(), n.length && a?.(n[s]), !0));
return o?.addEventListener("keydown", e, !0), () => {
o?.removeEventListener("keydown", e, !0);
};
}, [
o,
n,
s,
a,
r,
r !== void 0 && r > 1
]), j(() => {
c(0);
}, [t]), { selectedIndex: n.length === 0 ? void 0 : s };
}
//#endregion
//#region src/components/SuggestionMenu/GridSuggestionMenu/GridSuggestionMenuWrapper.tsx
function di(e) {
let n = t().setContentEditableProps, r = C(), { getItems: i, gridSuggestionMenuComponent: a, query: o, clearQuery: s, closeMenu: c, onItemClick: l, columns: u } = e, d = k((e) => {
c(), s(), l?.(e);
}, [
l,
c,
s
]), { items: f, usedQuery: p, loadingState: m } = li(o, i);
ci(f, p, c);
let { selectedIndex: h } = ui(r, o, f, u, d);
return j(() => (n((e) => ({
...e,
"aria-expanded": !0,
"aria-controls": "bn-suggestion-menu"
})), () => {
n((e) => ({
...e,
"aria-expanded": !1,
"aria-controls": void 0
}));
}), [n]), j(() => (n((e) => ({
...e,
"aria-activedescendant": si(h)
})), () => {
n((e) => ({
...e,
"aria-activedescendant": void 0
}));
}), [n, h]), /* @__PURE__ */ K(a, {
items: f,
onItemClick: d,
loadingState: m,
selectedIndex: h,
columns: u
});
}
//#endregion
//#region src/components/SuggestionMenu/GridSuggestionMenu/GridSuggestionMenuController.tsx
function fi(e) {
let t = C(), n = i(), { triggerCharacter: r, gridSuggestionMenuComponent: a, columns: s, shouldOpen: c, minQueryLength: u, onItemClick: d, getItems: f } = e, m = M(() => d || ((e) => {
e.onItemClick(t);
}), [t, d]), h = M(() => f || (async (e) => await ai(t, e)), [t, f]), g = o(z);
j(() => {
g.addSuggestionMenu({
triggerCharacter: r,
shouldOpen: c
});
}, [
g,
r,
c
]);
let _ = w(z), v = w(z, { selector: (e) => ({
element: n?.firstChild || void 0,
getBoundingClientRect: () => e?.referencePos || new DOMRect()
}) }), y = M(() => ({
...e.floatingUIOptions,
useFloatingOptions: {
open: _?.show && _?.triggerCharacter === r,
onOpenChange: (e) => {
e || g.closeMenu();
},
placement: "bottom-start",
middleware: [
U(10),
_e({
allowedPlacements: ["bottom-start", "top-start"],
padding: 10
}),
W(),
xe({
apply({ elements: e, availableHeight: t }) {
e.floating.style.maxHeight = `${Math.max(0, t)}px`;
},
padding: 10
})
],
...e.floatingUIOptions?.useFloatingOptions
},
focusManagerProps: {
disabled: !0,
...e.floatingUIOptions?.focusManagerProps
},
elementProps: {
onMouseDownCapture: (e) => e.preventDefault(),
style: { zIndex: 70 },
...e.floatingUIOptions?.elementProps
}
}), [
e.floatingUIOptions,
_?.show,
_?.triggerCharacter,
g,
r
]);
return !_ || !_.ignoreQueryLength && u && (_.query.startsWith(" ") || _.query.length < u) ? null : /* @__PURE__ */ K(l, {
target: e.portalElement,
children: /* @__PURE__ */ K(p, {
reference: v,
...y,
children: r && /* @__PURE__ */ K(di, {
query: _.query,
closeMenu: g.closeMenu,
clearQuery: g.clearQuery,
getItems: h,
columns: s,
gridSuggestionMenuComponent: a || oi,
onItemClick: m
})
})
});
}
//#endregion
//#region src/components/SuggestionMenu/SuggestionMenu.tsx
function pi(e) {
let t = s(), n = g(), { items: r, loadingState: i, selectedIndex: a, onItemClick: o } = e, c = i === "loading-initial" || i === "loading" ? /* @__PURE__ */ K(t.SuggestionMenu.Loader, { className: "bn-suggestion-menu-loader" }) : null, l = M(() => {
let e, n = [];
for (let i = 0; i < r.length; i++) {
let s = r[i];
s.group !== e && (e = s.group, n.push(/* @__PURE__ */ K(t.SuggestionMenu.Label, {
className: "bn-suggestion-menu-label",
children: e
}, e))), n.push(/* @__PURE__ */ K(t.SuggestionMenu.Item, {
className: X("bn-suggestion-menu-item", s.size === "small" ? "bn-suggestion-menu-item-small" : ""),
item: s,
id: `bn-suggestion-menu-item-${i}`,
isSelected: i === a,
onClick: () => o?.(s)
}, s.title));
}
return n;
}, [
t,
r,
o,
a
]);
return /* @__PURE__ */ q(t.SuggestionMenu.Root, {
id: "bn-suggestion-menu",
className: "bn-suggestion-menu",
children: [
l,
l.length === 0 && (e.loadingState === "loading" || e.loadingState === "loaded") && /* @__PURE__ */ K(t.SuggestionMenu.EmptyItem, {
className: "bn-suggestion-menu-item",
children: n.suggestion_menu.no_items_title
}),
c
]
});
}
//#endregion
//#region src/components/SuggestionMenu/hooks/useSuggestionMenuKeyboardHandler.ts
function mi(e, t) {
let [n, r] = P(0);
return {
selectedIndex: n,
setSelectedIndex: r,
handler: (i) => {
if (i.key === "ArrowUp") return i.preventDefault(), e.length && r((n - 1 + e.length) % e.length), !0;
if (i.key === "ArrowDown") return i.preventDefault(), e.length && r((n + 1) % e.length), !0;
if (i.key === "PageUp") return i.preventDefault(), e.length && r(0), !0;
if (i.key === "PageDown") return i.preventDefault(), e.length && r(e.length - 1), !0;
let a = hi(i) ? i.nativeEvent.isComposing : i.isComposing;
return i.key === "Enter" && !a && (i.preventDefault(), i.stopPropagation(), e.length && t?.(e[n]), !0);
}
};
}
function hi(e) {
return e.nativeEvent !== void 0;
}
//#endregion
//#region src/components/SuggestionMenu/hooks/useSuggestionMenuKeyboardNavigation.ts
function gi(e, t, n, r, a) {
let o = i(), { selectedIndex: s, setSelectedIndex: c, handler: l } = mi(n, r);
return j(() => {
let e = a || o;
return e?.addEventListener("keydown", l, !0), () => {
e?.removeEventListener("keydown", l, !0);
};
}, [
o,
n,
s,
r,
a,
l
]), j(() => {
c(0);
}, [t, c]), { selectedIndex: n.length === 0 ? void 0 : s };
}
//#endregion
//#region src/components/SuggestionMenu/SuggestionMenuWrapper.tsx
function _i(e) {
let n = t().setContentEditableProps, r = C(), { getItems: i, suggestionMenuComponent: a, query: o, clearQuery: s, closeMenu: c, onItemClick: l } = e, u = k((e) => {
c(), s(), l?.(e);
}, [
l,
c,
s
]), { items: d, usedQuery: f, loadingState: p } = li(o, i);
ci(d, f, c);
let { selectedIndex: m } = gi(r, o, d, u);
return j(() => (n((e) => ({
...e,
"aria-expanded": !0,
"aria-controls": "bn-suggestion-menu"
})), () => {
n((e) => ({
...e,
"aria-expanded": !1,
"aria-controls": void 0
}));
}), [n]), j(() => (n((e) => ({
...e,
"aria-activedescendant": si(m)
})), () => {
n((e) => ({
...e,
"aria-activedescendant": void 0
}));
}), [n, m]), /* @__PURE__ */ K(a, {
items: d,
onItemClick: u,
loadingState: p,
selectedIndex: m
});
}
//#endregion
//#region src/components/SuggestionMenu/getDefaultReactSlashMenuItems.tsx
var vi = {
heading: On,
heading_2: Dn,
heading_3: En,
heading_4: Tn,
heading_5: wn,
heading_6: Cn,
toggle_heading: On,
toggle_heading_2: Dn,
toggle_heading_3: En,
quote: dn,
toggle_list: tn,
numbered_list: hn,
bullet_list: mn,
check_list: gn,
paragraph: cn,
table: ln,
image: an,
video: on,
audio: $t,
file: Ln,
emoji: Ht,
code_block: An,
divider: Ut
};
function yi(e) {
return ge(e).map((e) => {
let t = vi[e.key];
return {
...e,
icon: /* @__PURE__ */ K(t, { size: 18 })
};
});
}
//#endregion
//#region src/components/SuggestionMenu/SuggestionMenuController.tsx
function bi(e) {
let t = C(), n = i(), { triggerCharacter: r, suggestionMenuComponent: a, shouldOpen: s, minQueryLength: c, onItemClick: u, getItems: d } = e, f = M(() => u || ((e) => {
e.onItemClick(t);
}), [t, u]), m = M(() => d || (async (e) => me(yi(t), e)), [t, d]), h = o(z);
j(() => {
h.addSuggestionMenu({
triggerCharacter: r,
shouldOpen: s
});
}, [
h,
r,
s
]);
let g = w(z), _ = w(z, { selector: (e) => ({
element: n?.firstChild || void 0,
getBoundingClientRect: () => e?.referencePos || new DOMRect()
}) }), v = M(() => ({
...e.floatingUIOptions,
useFloatingOptions: {
open: g?.show && g?.triggerCharacter === r,
onOpenChange: (e) => {
e || h.closeMenu();
},
placement: "bottom-start",
middleware: [
U(10),
_e({
allowedPlacements: ["bottom-start", "top-start"],
padding: 10
}),
W(),
xe({
apply({ elements: e, availableHeight: t }) {
e.floating.style.maxHeight = `${Math.max(0, t)}px`;
},
padding: 10
})
],
...e.floatingUIOptions?.useFloatingOptions
},
focusManagerProps: {
disabled: !0,
...e.floatingUIOptions?.focusManagerProps
},
elementProps: {
onMouseDownCapture: (e) => e.preventDefault(),
style: { zIndex: 80 },
...e.floatingUIOptions?.elementProps
}
}), [
e.floatingUIOptions,
g?.show,
g?.triggerCharacter,
h,
r
]);
return !g || !g.ignoreQueryLength && c && (g.query.startsWith(" ") || g.query.length < c) ? null : /* @__PURE__ */ K(l, {
target: e.portalElement,
children: /* @__PURE__ */ K(p, {
reference: _,
...v,
children: r && /* @__PURE__ */ K(_i, {
query: g.query,
closeMenu: h.closeMenu,
clearQuery: h.clearQuery,
getItems: m,
suggestionMenuComponent: a || pi,
onItemClick: f
})
})
});
}
//#endregion
//#region src/components/TableHandles/ExtendButton/ExtendButton.tsx
var xi = (e, t = .3) => {
let n = Math.floor(e) + t, r = Math.ceil(e) - t;
return e >= n && e <= r ? Math.round(e) : e < n ? Math.floor(e) : Math.ceil(e);
}, Si = (e) => {
let t = s(), n = C(), r = o(B), i = w(B, { selector: (e) => e?.block }), a = N(!1), [c, l] = P(), u = k((t) => {
r.freezeHandles(), e.hideOtherElements(!0), i && (l({
originalContent: i.content,
originalCroppedContent: { rows: r.cropEmptyRowsOrColumns(i, e.orientation === "addOrRemoveColumns" ? "columns" : "rows") },
startPos: e.orientation === "addOrRemoveColumns" ? t.clientX : t.clientY
}), a.current = !1, t.preventDefault());
}, [
i,
e,
r
]), d = k(() => {
!i || a.current || n.updateBlock(i, {
type: "table",
content: {
...i.content,
rows: e.orientation === "addOrRemoveColumns" ? r.addRowsOrColumns(i, "columns", 1) : r.addRowsOrColumns(i, "rows", 1)
}
});
}, [
i,
n,
e.orientation,
r
]);
return j(() => {
let t = (t) => {
if (!i) return;
if (!c) throw Error("editingState is undefined");
a.current = !0;
let o = (e.orientation === "addOrRemoveColumns" ? t.clientX : t.clientY) - c.startPos, s = e.orientation === "addOrRemoveColumns" ? c.originalCroppedContent.rows[0]?.cells.length ?? 0 : c.originalCroppedContent.rows.length, l = e.orientation === "addOrRemoveColumns" ? c.originalContent.rows[0]?.cells.length ?? 0 : c.originalContent.rows.length, u = e.orientation === "addOrRemoveColumns" ? i.content.rows[0].cells.length : i.content.rows.length, d = l + xi(o / (e.orientation === "addOrRemoveColumns" ? Te : we), .3);
d >= s && d > 0 && d !== u && (n.updateBlock(i, {
type: "table",
content: {
...i.content,
rows: e.orientation === "addOrRemoveColumns" ? r.addRowsOrColumns({
type: "table",
content: c.originalCroppedContent
}, "columns", d - s) : r.addRowsOrColumns({
type: "table",
content: c.originalCroppedContent
}, "rows", d - s)
}
}), i.content && n.setTextCursorPosition(i));
};
return c && window.addEventListener("mousemove", t), () => {
window.removeEventListener("mousemove", t);
};
}, [
i,
c,
n,
e.orientation,
r
]), j(() => {
let t = () => {
e.hideOtherElements(!1), r.unfreezeHandles(), l(void 0);
};
return c && window.addEventListener("mouseup", t), () => {
window.removeEventListener("mouseup", t);
};
}, [
c,
e,
r
]), n.isEditable ? /* @__PURE__ */ K(t.TableHandle.ExtendButton, {
className: X("bn-extend-button", e.orientation === "addOrRemoveColumns" ? "bn-extend-button-add-remove-columns" : "bn-extend-button-add-remove-rows", c === null ? "" : "bn-extend-button-editing"),
onClick: d,
onMouseDown: u,
children: e.children || /* @__PURE__ */ K(Qt, {
size: 18,
"data-test": "extendButton"
})
}) : null;
}, Ci = (e) => {
let t = s(), n = m(), r = g(), i = C(), { block: a, colIndex: o, rowIndex: c } = w(B, { selector: (e) => ({
block: e?.block,
colIndex: e?.colIndex,
rowIndex: e?.rowIndex
}) }), l = (e, t) => {
if (a === void 0 || o === void 0 || c === void 0) return;
let n = a.content.rows.map((e) => ({
...e,
cells: e.cells.map((e) => it(e))
}));
t === "text" ? n[c].cells[o].props.textColor = e : n[c].cells[o].props.backgroundColor = e, i.updateBlock(a, {
type: "table",
content: {
...a.content,
rows: n
}
}), i.setTextCursorPosition(a);
};
if (a === void 0 || o === void 0 || c === void 0) return null;
let u = a.content.rows[c]?.cells?.[o];
return !u || i.settings.tables.cellTextColor === !1 && i.settings.tables.cellBackgroundColor === !1 ? null : /* @__PURE__ */ q(t.Generic.Menu.Root, {
position: "right",
sub: !0,
portalElement: n,
children: [/* @__PURE__ */ K(t.Generic.Menu.Trigger, {
sub: !0,
children: /* @__PURE__ */ K(t.Generic.Menu.Item, {
className: "bn-menu-item",
subTrigger: !0,
children: e.children || r.drag_handle.colors_menuitem
})
}), /* @__PURE__ */ K(t.Generic.Menu.Dropdown, {
sub: !0,
className: "bn-menu-dropdown bn-color-picker-dropdown",
children: /* @__PURE__ */ K(Xn, {
iconSize: 18,
text: i.settings.tables.cellTextColor ? {
color: tt(u) ? u.props.textColor : "default",
setColor: (e) => l(e, "text")
} : void 0,
background: i.settings.tables.cellBackgroundColor ? {
color: tt(u) ? u.props.backgroundColor : "default",
setColor: (e) => l(e, "background")
} : void 0
})
})]
});
}, wi = () => {
let e = s(), t = g(), n = C(), r = o(B), { block: i, colIndex: a, rowIndex: c } = w(B, { selector: (e) => ({
block: e?.block,
colIndex: e?.colIndex,
rowIndex: e?.rowIndex
}) });
if (i === void 0 || a === void 0 || c === void 0) return null;
let l = i.content.rows[c]?.cells?.[a];
return !l || !tt(l) || Xe(l) === 1 && Ke(l) === 1 || !n.settings.tables.splitCells ? null : /* @__PURE__ */ K(e.Generic.Menu.Item, {
onClick: () => {
r.splitCell({
row: c,
col: a
});
},
children: t.table_handle.split_cell_menuitem
});
}, Ti = (e) => {
let t = s();
return /* @__PURE__ */ K(t.Generic.Menu.Dropdown, {
className: "bn-menu-dropdown bn-table-handle-menu",
children: e.children || /* @__PURE__ */ q(G, { children: [/* @__PURE__ */ K(wi, {}), /* @__PURE__ */ K(Ci, {})] })
});
}, Ei = (e) => {
let t = s(), n = m(), r = C(), i = o(B), a = e.tableCellMenu || Ti;
return !r.settings.tables.splitCells && !r.settings.tables.cellBackgroundColor && !r.settings.tables.cellTextColor ? null : /* @__PURE__ */ q(t.Generic.Menu.Root, {
onOpenChange: (t) => {
t ? (i.freezeHandles(), e.hideOtherElements(!0)) : (i.unfreezeHandles(), e.hideOtherElements(!1), r.focus());
},
position: "right",
portalElement: n,
children: [/* @__PURE__ */ K(t.Generic.Menu.Trigger, { children: /* @__PURE__ */ K(t.Generic.Menu.Button, {
className: "bn-table-cell-handle",
children: e.children || /* @__PURE__ */ K(Ur, {
size: 12,
"data-test": "tableCellHandle"
})
}) }), /* @__PURE__ */ K(a, {})]
});
}, Di = (e) => {
let t = s(), n = g(), r = o(B), i = w(B, { selector: (t) => e.orientation === "column" ? t?.colIndex : t?.rowIndex });
return r === void 0 || i === void 0 ? null : /* @__PURE__ */ K(t.Generic.Menu.Item, {
onClick: () => {
r.addRowOrColumn(i, e.orientation === "row" ? {
orientation: "row",
side: e.side
} : {
orientation: "column",
side: e.side
});
},
children: n.table_handle[`add_${e.side}_menuitem`]
});
}, Oi = (e) => {
let t = s(), n = g(), r = o(B), i = w(B, { selector: (t) => e.orientation === "column" ? t?.colIndex : t?.rowIndex });
return r === void 0 || i === void 0 ? null : /* @__PURE__ */ K(t.Generic.Menu.Item, {
onClick: () => r.removeRowOrColumn(i, e.orientation),
children: e.orientation === "row" ? n.table_handle.delete_row_menuitem : n.table_handle.delete_column_menuitem
});
}, ki = (e) => {
let t = s(), n = m(), r = g(), i = C(), a = o(B), { block: c, index: l } = w(B, { selector: (t) => ({
block: t?.block,
index: e.orientation === "column" ? t?.colIndex : t?.rowIndex
}) }), u = M(() => a === void 0 || c === void 0 || l === void 0 ? [] : e.orientation === "row" ? a.getCellsAtRowHandle(c, l) : a.getCellsAtColumnHandle(c, l), [
c,
l,
e.orientation,
a
]), d = (e, t) => {
if (c === void 0) return;
let n = c.content.rows.map((e) => ({
...e,
cells: e.cells.map((e) => it(e))
}));
u.forEach(({ row: r, col: i }) => {
t === "text" ? n[r].cells[i].props.textColor = e : n[r].cells[i].props.backgroundColor = e;
}), i.updateBlock(c, {
type: "table",
content: {
...c.content,
rows: n
}
}), i.setTextCursorPosition(c);
};
if (!u || !u[0] || !a || i.settings.tables.cellTextColor === !1 && i.settings.tables.cellBackgroundColor === !1) return null;
let f = it(u[0].cell);
return /* @__PURE__ */ q(t.Generic.Menu.Root, {
position: "right",
sub: !0,
portalElement: n,
children: [/* @__PURE__ */ K(t.Generic.Menu.Trigger, {
sub: !0,
children: /* @__PURE__ */ K(t.Generic.Menu.Item, {
className: "bn-menu-item",
subTrigger: !0,
children: e.children || r.drag_handle.colors_menuitem
})
}), /* @__PURE__ */ K(t.Generic.Menu.Dropdown, {
sub: !0,
className: "bn-menu-dropdown bn-color-picker-dropdown",
children: /* @__PURE__ */ K(Xn, {
iconSize: 18,
text: i.settings.tables.cellTextColor ? {
color: u.every(({ cell: e }) => tt(e) && e.props.textColor === f.props.textColor) ? f.props.textColor : "default",
setColor: (e) => {
d(e, "text");
}
} : void 0,
background: i.settings.tables.cellBackgroundColor ? {
color: u.every(({ cell: e }) => tt(e) && e.props.backgroundColor === f.props.backgroundColor) ? f.props.backgroundColor : "default",
setColor: (e) => d(e, "background")
} : void 0
})
})]
});
}, Ai = (e) => {
let t = s(), n = g(), r = C(), i = o(B), { block: a, index: c } = w(B, { selector: (t) => ({
block: t?.block,
index: e.orientation === "column" ? t?.colIndex : t?.rowIndex
}) });
if (i === void 0 || a === void 0 || c !== 0 || e.orientation !== "row" || !r.settings.tables.headers) return null;
let l = !!a.content.headerRows;
return /* @__PURE__ */ K(t.Generic.Menu.Item, {
className: "bn-menu-item",
checked: l,
onClick: () => {
r.updateBlock(a, {
...a,
content: {
...a.content,
headerRows: l ? void 0 : 1
}
});
},
children: n.drag_handle.header_row_menuitem
});
}, ji = (e) => {
let t = s(), n = g(), r = C(), i = o(B), a = w(B, { selector: (e) => e?.block }), c = w(B, { selector: (t) => e.orientation === "column" ? t?.colIndex : t?.rowIndex });
if (!i || c !== 0 || !a || e.orientation !== "column" || !r.settings.tables.headers) return null;
let l = !!a.content.headerCols;
return /* @__PURE__ */ K(t.Generic.Menu.Item, {
className: "bn-menu-item",
checked: l,
onClick: () => {
r.updateBlock(a, {
...a,
content: {
...a.content,
headerCols: l ? void 0 : 1
}
});
},
children: n.drag_handle.header_column_menuitem
});
}, Mi = (e) => {
let t = s();
return /* @__PURE__ */ K(t.Generic.Menu.Dropdown, {
className: "bn-table-handle-menu",
children: e.children || /* @__PURE__ */ q(G, { children: [
/* @__PURE__ */ K(Oi, { orientation: e.orientation }),
/* @__PURE__ */ K(Di, {
orientation: e.orientation,
side: e.orientation === "row" ? "above" : "left"
}),
/* @__PURE__ */ K(Di, {
orientation: e.orientation,
side: e.orientation === "row" ? "below" : "right"
}),
/* @__PURE__ */ K(Ai, { orientation: e.orientation }),
/* @__PURE__ */ K(ji, { orientation: e.orientation }),
/* @__PURE__ */ K(ki, { orientation: e.orientation })
] })
});
}, Ni = (e) => {
let t = C(), n = s(), r = m(), [i, a] = P(!1), c = e.tableHandleMenu || Mi, l = o(B), u = w(B), d = M(() => !l || !u || !u.block || u.block.type !== "table" ? !1 : e.orientation === "column" ? l.getCellsAtColumnHandle(u.block, u.colIndex).every(({ cell: e }) => Ke(e) === 1) : l.getCellsAtRowHandle(u.block, u.rowIndex).every(({ cell: e }) => Xe(e) === 1), [
e.orientation,
u,
l
]);
return u ? /* @__PURE__ */ q(n.Generic.Menu.Root, {
onOpenChange: (n) => {
n ? (l.freezeHandles(), e.hideOtherElements(!0)) : (l.unfreezeHandles(), e.hideOtherElements(!1), t.focus());
},
position: "right",
portalElement: r,
children: [/* @__PURE__ */ K(n.Generic.Menu.Trigger, { children: /* @__PURE__ */ K(n.TableHandle.Root, {
className: X("bn-table-handle", i ? "bn-table-handle-dragging" : "", d ? "" : "bn-table-handle-not-draggable"),
draggable: d,
onDragStart: (t) => {
a(!0), e.hideOtherElements(!0), e.orientation === "column" ? l.colDragStart(t) : l.rowDragStart(t);
},
onDragEnd: () => {
l.dragEnd(), e.hideOtherElements(!1), a(!1);
},
style: e.orientation === "column" ? { transform: "rotate(0.25turn)" } : void 0,
children: e.children || /* @__PURE__ */ K(Kr, {
size: 24,
"data-test": "tableHandle"
})
}) }), /* @__PURE__ */ K(c, { orientation: e.orientation })]
}) : null;
}, Pi = (e) => {
let t = C(), [n, r] = P(), i = w(B), a = M(() => {
let e = {};
if (i === void 0) return {};
let n = Je(i.block.id, t.prosemirrorState.doc);
if (!n) return {};
let r = n.posBeforeNode + 1, a = t.prosemirrorView.domAtPos(r + 1).node;
if (!(a instanceof Element)) return {};
if (e.tableReference = { element: a }, i.rowIndex === void 0 || i.colIndex === void 0) return e;
let o = t.prosemirrorState.doc.resolve(r + 1).posAtIndex(i.rowIndex), s = t.prosemirrorState.doc.resolve(o + 1).posAtIndex(i.colIndex), c = t.prosemirrorView.domAtPos(s + 1).node;
return c instanceof Element ? (e.cellReference = { element: c }, e.rowReference = {
element: a,
getBoundingClientRect: () => {
let e = a.getBoundingClientRect(), t = c.getBoundingClientRect();
return new DOMRect(e.x, i.draggingState && i.draggingState.draggedCellOrientation === "row" ? i.draggingState.mousePos - t.height / 2 : t.y, e.width, t.height);
}
}, e.columnReference = {
element: a,
getBoundingClientRect: () => {
let e = a.getBoundingClientRect(), t = c.getBoundingClientRect();
return new DOMRect(i.draggingState && i.draggingState.draggedCellOrientation === "col" ? i.draggingState.mousePos - t.width / 2 : t.x, e.y, t.width, e.height);
}
}, e) : {};
}, [t, i]), o = k((e, n, r) => {
let i = !1;
return ve(e, n, () => {
if (!i) {
i = !0;
return;
}
t.getExtension(B)?.hideHandlesIfNotFrozen();
}, {
ancestorScroll: !0,
ancestorResize: !1,
elementResize: !1,
layoutShift: !1
});
}, [t]), s = M(() => i === void 0 ? void 0 : {
rowTableHandle: {
useFloatingOptions: {
open: i.show && i.rowIndex !== void 0 && (!n || n === "rowTableHandle"),
placement: "left",
middleware: [U(-10)],
whileElementsMounted: o
},
focusManagerProps: { disabled: !0 },
elementProps: { style: { zIndex: 10 } }
},
columnTableHandle: {
useFloatingOptions: {
open: i.show && i.colIndex !== void 0 && (!n || n === "columnTableHandle"),
placement: "top",
middleware: [U(-12)],
whileElementsMounted: o
},
focusManagerProps: { disabled: !0 },
elementProps: { style: { zIndex: 10 } }
},
tableCellHandle: {
useFloatingOptions: {
open: i.show && i.rowIndex !== void 0 && i.colIndex !== void 0 && (!n || n === "tableCellHandle"),
placement: "top-end",
middleware: [U({
mainAxis: -15,
crossAxis: -1
})],
whileElementsMounted: o
},
focusManagerProps: { disabled: !0 },
elementProps: { style: { zIndex: 10 } }
},
extendRowsButton: {
useFloatingOptions: {
open: i.show && i.showAddOrRemoveRowsButton && (!n || n === "extendRowsButton"),
placement: "bottom",
whileElementsMounted: o,
middleware: [xe({ apply({ rects: e, elements: t }) {
Object.assign(t.floating.style, { width: `${e.reference.width}px` });
} })]
},
focusManagerProps: { disabled: !0 },
elementProps: { style: { zIndex: 10 } }
},
extendColumnsButton: {
useFloatingOptions: {
open: i.show && i.showAddOrRemoveColumnsButton && (!n || n === "extendColumnsButton"),
placement: "right",
whileElementsMounted: o,
middleware: [xe({ apply({ rects: e, elements: t }) {
Object.assign(t.floating.style, { height: `${e.reference.height}px` });
} })]
},
focusManagerProps: { disabled: !0 },
elementProps: { style: { zIndex: 10 } }
}
}, [
n,
i,
o
]);
if (!i) return null;
let c = e.tableHandle || Ni, u = e.extendButton || Si, d = e.tableCellHandle || Ei;
return /* @__PURE__ */ q(l, {
target: e.portalElement,
children: [
/* @__PURE__ */ K(p, {
reference: a?.rowReference,
...s?.rowTableHandle,
children: i.show && i.rowIndex !== void 0 && (!n || n === "rowTableHandle") && /* @__PURE__ */ K(c, {
orientation: "row",
hideOtherElements: (e) => r(e ? "rowTableHandle" : void 0)
})
}),
/* @__PURE__ */ K(p, {
reference: a?.columnReference,
...s?.columnTableHandle,
children: i.show && i.colIndex !== void 0 && (!n || n === "columnTableHandle") && /* @__PURE__ */ K(c, {
orientation: "column",
hideOtherElements: (e) => r(e ? "columnTableHandle" : void 0)
})
}),
/* @__PURE__ */ K(p, {
reference: a?.cellReference,
...s?.tableCellHandle,
children: i.show && i.rowIndex !== void 0 && i.colIndex !== void 0 && (!n || n === "tableCellHandle") && /* @__PURE__ */ K(d, { hideOtherElements: (e) => r(e ? "tableCellHandle" : void 0) })
}),
/* @__PURE__ */ K(p, {
reference: a?.tableReference,
...s?.extendRowsButton,
children: i.show && i.showAddOrRemoveRowsButton && (!n || n === "extendRowsButton") && /* @__PURE__ */ K(u, {
orientation: "addOrRemoveRows",
hideOtherElements: (e) => r(e ? "extendRowsButton" : void 0)
})
}),
/* @__PURE__ */ K(p, {
reference: a?.tableReference,
...s?.extendColumnsButton,
children: i.show && i.showAddOrRemoveColumnsButton && (!n || n === "extendColumnsButton") && /* @__PURE__ */ K(u, {
orientation: "addOrRemoveColumns",
hideOtherElements: (e) => r(e ? "extendColumnsButton" : void 0)
})
})
]
});
};
//#endregion
//#region src/editor/portalElements.ts
function Q(e) {
if (e !== void 0) {
if (typeof e == "string") {
if (typeof document > "u") return;
let t = document.querySelector(e);
if (!t) {
console.warn(`[BlockNote] portalElements selector "${e}" did not match any element`);
return;
}
return t;
}
return e;
}
}
//#endregion
//#region src/editor/BlockNoteDefaultUI.tsx
var Fi = te(() => Promise.resolve().then(() => to)), Ii = te(() => Promise.resolve().then(() => oo));
function Li(e) {
let t = C();
if (!t) throw Error("BlockNoteDefaultUI must be used within a BlockNoteContext.Provider");
let n = e.portalElements, r = Q(n?.formattingToolbar), i = Q(n?.linkToolbar), a = Q(n?.slashMenu), o = Q(n?.emojiPicker), s = Q(n?.sideMenu), c = Q(n?.filePanel), l = Q(n?.tableHandles), u = Q(n?.comments), d = Q(n?.attributionTooltip);
return /* @__PURE__ */ q(G, { children: [
t.getExtension(ue) && e.formattingToolbar !== !1 && /* @__PURE__ */ K(Fr, { portalElement: r }),
t.getExtension(de) && e.linkToolbar !== !1 && /* @__PURE__ */ K(Br, { portalElement: i }),
t.getExtension(z) && e.slashMenu !== !1 && /* @__PURE__ */ K(bi, {
triggerCharacter: "/",
shouldOpen: (e) => !e.selection.$from.parent.type.isInGroup("tableContent"),
portalElement: a
}),
t.getExtension(z) && e.emojiPicker !== !1 && /* @__PURE__ */ K(fi, {
triggerCharacter: ":",
columns: 10,
minQueryLength: 2,
portalElement: o
}),
t.getExtension(R) && e.sideMenu !== !1 && /* @__PURE__ */ K(ti, { portalElement: s }),
t.getExtension(le) && e.filePanel !== !1 && /* @__PURE__ */ K(Dt, { portalElement: c }),
t.getExtension(B) && e.tableHandles !== !1 && /* @__PURE__ */ K(Pi, { portalElement: l }),
t.getExtension(I) && e.comments !== !1 && /* @__PURE__ */ q(D, { children: [/* @__PURE__ */ K(Fi, { portalElement: u }), /* @__PURE__ */ K(Ii, { portalElement: u })] }),
t.getExtension("attribution") && e.attributionTooltip !== !1 && /* @__PURE__ */ K(ii, { portalElement: d })
] });
}
//#endregion
//#region src/components/FormattingToolbar/viewportMeta.ts
var Ri = !1;
function zi() {
typeof process < "u" && process.env.NODE_ENV === "production" || Ri || typeof document > "u" || (Ri = !0, (document.querySelector("meta[name=\"viewport\"]")?.getAttribute("content") ?? "").replace(/\s/g, "").includes("interactive-widget=resizes-content") || console.warn("[BlockNote] This page's viewport meta tag is missing \"interactive-widget=resizes-content\" in its content attribute. Add it to ensure proper mobile functionality, e.g. <meta name=\"viewport\" content=\"width=device-width, initial-scale=1, interactive-widget=resizes-content\">. See https://www.blocknotejs.org/docs/getting-started#mobile-compatibility for more information"));
}
//#endregion
//#region src/hooks/useEditorChange.ts
function Bi(e, n) {
let r = t();
n ||= r?.editor;
let i = N(e);
T(() => {
i.current = e;
}), j(() => {
if (!n) throw Error("'editor' is required, either from BlockNoteContext or as a function argument");
return n.onChange((...e) => i.current(...e));
}, [n]);
}
//#endregion
//#region src/hooks/useEditorSelectionChange.ts
function Vi(e, n, r) {
let i = t();
n ||= i?.editor;
let a = N(e);
T(() => {
a.current = e;
}), j(() => {
if (!n) throw Error("'editor' is required, either from BlockNoteContext or as a function argument");
return n.onSelectionChange((e) => a.current(e), r);
}, [n, r]);
}
//#endregion
//#region src/hooks/usePrefersColorScheme.ts
var Hi = () => {
let e = M(() => window.matchMedia?.("(prefers-color-scheme: dark)"), []), t = M(() => window.matchMedia?.("(prefers-color-scheme: light)"), []), n = e?.matches, r = t?.matches, [i, a] = P(n ? "dark" : r ? "light" : "no-preference");
return j(() => {
a(n ? "dark" : r ? "light" : "no-preference");
}, [n, r]), j(() => {
if (typeof e?.addEventListener == "function") {
let n = ({ matches: e }) => e && a("dark"), r = ({ matches: e }) => e && a("light");
return e?.addEventListener("change", n), t?.addEventListener("change", r), () => {
e?.removeEventListener("change", n), t?.removeEventListener("change", r);
};
}
{
let n = () => a(e.matches ? "dark" : t.matches ? "light" : "no-preference");
return e?.addEventListener("change", n), t?.addEventListener("change", n), () => {
e?.removeEventListener("change", n), t?.removeEventListener("change", n);
};
}
}, [e, t]), window.matchMedia, i;
};
//#endregion
//#region src/editor/EditorContent.tsx
function Ui() {
let e = /* @__PURE__ */ new Set(), t = {};
return {
subscribe(t) {
return e.add(t), () => {
e.delete(t);
};
},
getSnapshot() {
return t;
},
getServerSnapshot() {
return t;
},
setRenderer(n, r) {
t = {
...t,
[n]: dt(r.reactElement, r.element, n)
}, e.forEach((e) => e());
},
removeRenderer(n) {
let r = { ...t };
delete r[n], t = r, e.forEach((e) => e());
}
};
}
var Wi = ({ contentComponent: e }) => {
let t = se(e.subscribe, e.getSnapshot, e.getServerSnapshot);
return /* @__PURE__ */ K(G, { children: Object.values(t) });
}, Gi = O((e, t) => {
let [n, r] = P();
return ie(t, () => (e, t) => {
ft(() => {
r({
node: e,
container: t
});
}), r(void 0);
}, []), /* @__PURE__ */ K(G, { children: n && dt(n.node, n.container) });
}), Ki = () => {};
function qi(e, n) {
let { editor: i, className: a, theme: o, children: c, editable: l, onSelectionChange: u, onChange: f, formattingToolbar: p, linkToolbar: m, slashMenu: h, emojiPicker: g, sideMenu: _, filePanel: v, tableHandles: y, comments: b, portalElements: x, applyThemedRoot: S, autoFocus: C, renderEditor: w = !0, ...T } = e, E = M(() => Q(x?.default), [x?.default]), [D, ee] = P(), O = t(), te = Hi(), ne = O?.colorSchemePreference || te, A = o || (ne === "dark" ? "dark" : "light"), j = s(), re = M(() => ({
formattingToolbar: j ? p : !1,
linkToolbar: j ? m : !1,
sideMenu: j ? _ : !1,
slashMenu: j ? h : !1,
filePanel: j ? v : !1,
tableHandles: j ? y : !1,
emojiPicker: j ? g : !1,
comments: j ? b : !1,
portalElements: x
}), [
b,
j,
g,
v,
p,
m,
_,
h,
y,
x
]);
Bi(f || Ki, i), Vi(u || Ki, i);
let ie = k((e) => {
i.elementRenderer = e;
}, [i]), ae = k((e) => {
e.className = X("bn-root", A, a || ""), e.setAttribute("data-color-scheme", A), S?.(e);
}, [
A,
a,
S
]), oe = M(() => ({
...O,
editor: i,
setContentEditableProps: ee,
colorSchemePreference: A
}), [
O,
i,
A
]), N = M(() => ({
editorProps: {
autoFocus: C,
contentEditableProps: D,
editable: l
},
defaultUIProps: re,
applyThemedRoot: ae
}), [
C,
D,
l,
re,
ae
]);
return /* @__PURE__ */ K(r.Provider, {
value: oe,
children: /* @__PURE__ */ q(d.Provider, {
value: N,
children: [/* @__PURE__ */ K(Gi, { ref: ie }), /* @__PURE__ */ K(Ji, {
className: a,
renderEditor: w,
editorColorScheme: A,
defaultPortalElement: E,
ref: n,
...T,
children: c
})]
})
});
}
var Ji = E.forwardRef(({ className: e, renderEditor: t, editorColorScheme: n, defaultPortalElement: r, children: i, ...a }, o) => /* @__PURE__ */ K("div", {
className: X("bn-root", "bn-container", n, e),
"data-color-scheme": n,
...a,
ref: o,
children: /* @__PURE__ */ K(_, { children: /* @__PURE__ */ K(l, {
target: r,
children: t ? /* @__PURE__ */ K(Xi, { children: i }) : i
}) })
})), Yi = E.forwardRef(qi), Xi = (e) => {
let t = u(), n = C(), r = M(() => Ui(), []);
j(() => {
zi();
}, []);
let i = k((e) => {
n.isEditable = t.editorProps.editable !== !1, n._tiptapEditor.contentComponent = r, e ? n.mount(e) : n.unmount();
}, [
t.editorProps.editable,
n,
r
]);
return /* @__PURE__ */ q(G, { children: [
/* @__PURE__ */ K(Wi, { contentComponent: r }),
/* @__PURE__ */ K(Zi, {
...t.editorProps,
...e,
mount: i
}),
/* @__PURE__ */ K(Li, { ...t.defaultUIProps }),
e.children
] });
}, Zi = (e) => {
let { autoFocus: t, mount: n, contentEditableProps: r } = e;
return /* @__PURE__ */ K("div", {
"aria-autocomplete": "list",
"aria-haspopup": "listbox",
"data-bn-autofocus": t,
ref: n,
...r
});
};
//#endregion
//#region src/schema/@util/ReactRenderUtil.ts
function $(e, t) {
let n, r = document.createElement("div"), i;
if (t?.elementRenderer) t.elementRenderer(e((e) => n = e || void 0), r);
else {
if (!t?.headless) throw Error("elementRenderer not available, expected headless editor");
i = yt(r), ft(() => {
i.render(e((e) => n = e || void 0));
});
}
if (!r.childElementCount) return console.warn("ReactInlineContentSpec: renderHTML() failed"), { dom: document.createElement("span") };
n?.setAttribute("data-tmp-find", "true");
let a = r.cloneNode(!0), o = a.firstElementChild, s = a.querySelector("[data-tmp-find]");
return s?.removeAttribute("data-tmp-find"), i?.unmount(), {
dom: o,
contentDOM: s || void 0
};
}
//#endregion
//#region src/schema/useNodeViewBlock.ts
function Qi(e, t) {
let n = N(t), r = e.view.state.doc;
try {
n.current = Ge(e.getPos, r);
} catch {}
return n.current;
}
//#endregion
//#region src/schema/ReactBlockSpec.tsx
function $i(e) {
return /* @__PURE__ */ K(mt, {
onDragOver: (e) => e.preventDefault(),
...Object.fromEntries(Object.entries(e.domAttributes || {}).filter(([e]) => e !== "class")),
className: X("bn-block-content", e.domAttributes?.class || ""),
"data-content-type": e.blockType,
...Object.fromEntries(Object.entries(e.blockProps).filter(([t, n]) => n !== e.propSchema[t].default).map(([e, t]) => [Ne(e), t])),
"data-file-block": e.isFileBlock === !0 || void 0,
children: e.children
});
}
function ea(e, t, n) {
return (r = {}) => {
let i = typeof e == "function" ? e(r) : e, a = typeof t == "function" ? t(r) : t, o = n ? typeof n == "function" ? n(r) : n : void 0;
return {
config: i,
implementation: {
...a,
toExternalHTML(e, t, n) {
let r = a.toExternalHTML || a.render;
return $((o) => /* @__PURE__ */ K($i, {
blockType: e.type,
blockProps: e.props,
propSchema: i.propSchema,
domAttributes: this.blockContentDOMAttributes,
isFileBlock: a.meta?.fileBlockAccept !== void 0,
children: /* @__PURE__ */ K(r, {
block: e,
editor: t,
contentRef: (e) => {
o(e), e && (e.className = X("bn-inline-content", e.className));
},
context: n
})
}), t);
},
render(e, t) {
if (this.renderType === "nodeView") {
let n = e;
return _t((e) => {
let r = Qi(e, n), o = vt().nodeViewContentRef;
if (!o) throw Error("nodeViewContentRef is not set");
let s = a.render;
return /* @__PURE__ */ K($i, {
blockType: r.type,
blockProps: r.props,
propSchema: i.propSchema,
isFileBlock: !!a.meta?.fileBlockAccept,
domAttributes: this.blockContentDOMAttributes,
children: /* @__PURE__ */ K(s, {
block: r,
editor: t,
contentRef: (e) => {
o(e), e && (e.className = X("bn-inline-content", e.className), e.dataset.nodeViewContent = "");
}
})
});
}, { className: "bn-react-node-view-renderer" })(this.props);
}
{
let n = a.render;
return $((r) => /* @__PURE__ */ K($i, {
blockType: e.type,
blockProps: e.props,
propSchema: i.propSchema,
domAttributes: this.blockContentDOMAttributes,
children: /* @__PURE__ */ K(n, {
block: e,
editor: t,
contentRef: (e) => {
r(e), e && (e.className = X("bn-inline-content", e.className));
}
})
}), t);
}
}
},
extensions: o
};
};
}
//#endregion
//#region src/blocks/File/useResolveUrl.tsx
function ta(e) {
let t = C(), [n, r] = P("loading"), [i, a] = P();
if (j(() => {
let n = !0;
return (async () => {
let i = "";
r("loading");
try {
i = t.resolveFileUrl ? await t.resolveFileUrl(e) : e;
} catch {
r("error");
return;
}
n && (r("loaded"), a(i));
})(), () => {
n = !1;
};
}, [t, e]), n !== "loaded") return { loadingState: n };
if (!i) throw Error("Finished fetching file but did not get download URL.");
return {
loadingState: n,
downloadUrl: i
};
}
//#endregion
//#region src/blocks/File/helpers/toExternalHTML/FigureWithCaption.tsx
var na = (e) => /* @__PURE__ */ q("figure", { children: [e.children, /* @__PURE__ */ K("figcaption", { children: e.caption })] });
//#endregion
//#region src/hooks/useOnUploadEnd.ts
function ra(e) {
let t = C();
j(() => t.onUploadEnd(e), [e, t]);
}
//#endregion
//#region src/hooks/useOnUploadStart.ts
function ia(e) {
let t = C();
j(() => t.onUploadStart(e), [e, t]);
}
//#endregion
//#region src/hooks/useUploadLoading.ts
function aa(e) {
let [t, n] = P(!1);
return ia((t) => {
t === e && n(!0);
}), ra((t) => {
t === e && n(!1);
}), t;
}
//#endregion
//#region src/blocks/File/helpers/render/AddFileButton.tsx
var oa = (e) => {
let t = C(), n = g(), r = o(le), i = k((e) => {
e.preventDefault();
}, []), a = k(() => {
t.isEditable && e.editor.transact(() => r.showMenu(e.block.id));
}, [
t.isEditable,
r,
e.block.id,
e.editor
]);
return /* @__PURE__ */ q("div", {
className: "bn-add-file-button",
onMouseDown: i,
onClick: a,
children: [/* @__PURE__ */ K("div", {
className: "bn-add-file-button-icon",
children: e.buttonIcon || /* @__PURE__ */ K(Ln, { size: 24 })
}), /* @__PURE__ */ K("div", {
className: "bn-add-file-button-text",
children: e.block.type in n.file_blocks.add_button_text ? n.file_blocks.add_button_text[e.block.type] : n.file_blocks.add_button_text.file
})]
});
}, sa = (e) => /* @__PURE__ */ q("div", {
className: "bn-file-name-with-icon",
contentEditable: !1,
draggable: !1,
children: [/* @__PURE__ */ K("div", {
className: "bn-file-icon",
children: /* @__PURE__ */ K(Ln, { size: 24 })
}), /* @__PURE__ */ K("p", {
className: "bn-file-name",
children: e.block.props.name
})]
}), ca = (e) => {
let t = aa(e.block.id), n = e.block.props.url !== "" && e.block.props.caption && !t ? "figure" : "div";
return /* @__PURE__ */ K(n, {
className: "bn-file-block-content-wrapper",
onMouseEnter: e.onMouseEnter,
onMouseLeave: e.onMouseLeave,
style: e.style,
children: t ? /* @__PURE__ */ K("div", {
className: "bn-file-loading-preview",
children: "Loading..."
}) : e.block.props.url === "" ? /* @__PURE__ */ K(oa, { ...e }) : /* @__PURE__ */ q(G, { children: [e.block.props.showPreview === !1 || !e.children ? /* @__PURE__ */ K(sa, { ...e }) : e.children, e.block.props.caption && /* @__PURE__ */ K("figcaption", {
className: "bn-file-caption",
children: e.block.props.caption
})] })
});
}, la = (e) => /* @__PURE__ */ q("div", { children: [e.children, /* @__PURE__ */ K("p", { children: e.caption })] }), ua = (e) => {
let t = ta(e.block.props.url);
return /* @__PURE__ */ K("audio", {
className: "bn-audio",
src: t.loadingState === "loading" ? e.block.props.url : t.downloadUrl,
controls: !0,
contentEditable: !1,
draggable: !1
});
}, da = (e) => {
if (!e.block.props.url) return /* @__PURE__ */ K("p", { children: "Add audio" });
let t = e.block.props.showPreview ? /* @__PURE__ */ K("audio", { src: e.block.props.url }) : /* @__PURE__ */ K("a", {
href: e.block.props.url,
children: e.block.props.name || e.block.props.url
});
return e.block.props.caption ? e.block.props.showPreview ? /* @__PURE__ */ K(na, {
caption: e.block.props.caption,
children: t
}) : /* @__PURE__ */ K(la, {
caption: e.block.props.caption,
children: t
}) : t;
}, fa = (e) => /* @__PURE__ */ K(ca, {
...e,
buttonIcon: /* @__PURE__ */ K($t, { size: 24 }),
children: /* @__PURE__ */ K(ua, { ...e })
}), pa = ea(Pe, (e) => ({
meta: { fileBlockAccept: ["audio/*"] },
render: fa,
parse: Me(e),
toExternalHTML: da,
runsBefore: ["file"]
})), ma = ea(Fe, {
render: (e) => /* @__PURE__ */ K(ca, { ...e }),
parse: He(),
toExternalHTML: (e) => {
if (!e.block.props.url) return /* @__PURE__ */ K("p", { children: "Add file" });
let t = /* @__PURE__ */ K("a", {
href: e.block.props.url,
children: e.block.props.name || e.block.props.url
});
return e.block.props.caption ? /* @__PURE__ */ K(la, {
caption: e.block.props.caption,
children: t
}) : t;
}
}), ha = (e) => {
let [t, n] = P(void 0), [r, i] = P(e.block.props.previewWidth), [a, o] = P(!1), s = N(null);
j(() => {
let a = (n) => {
let r, a = "touches" in n ? n.touches[0].clientX : n.clientX;
r = e.block.props.textAlignment === "center" ? t.handleUsed === "left" ? t.initialWidth + (t.initialClientX - a) * 2 : t.initialWidth + (a - t.initialClientX) * 2 : t.handleUsed === "left" ? t.initialWidth + t.initialClientX - a : t.initialWidth + a - t.initialClientX, i(Math.min(Math.max(r, 64), e.editor.domElement?.firstElementChild?.clientWidth || Number.MAX_VALUE));
}, o = () => {
n(void 0), e.editor.updateBlock(e.block, { props: { previewWidth: r } });
};
return t && (window.addEventListener("mousemove", a), window.addEventListener("touchmove", a), window.addEventListener("mouseup", o), window.addEventListener("touchend", o)), () => {
window.removeEventListener("mousemove", a), window.removeEventListener("touchmove", a), window.removeEventListener("mouseup", o), window.removeEventListener("touchend", o);
};
}, [
e,
t,
r
]);
let c = k(() => {
e.editor.isEditable && o(!0);
}, [e.editor.isEditable]), l = k(() => {
o(!1);
}, []), u = k((e) => {
e.preventDefault();
let t = "touches" in e ? e.touches[0].clientX : e.clientX;
n({
handleUsed: "left",
initialWidth: s.current.clientWidth,
initialClientX: t
});
}, []), d = k((e) => {
e.preventDefault();
let t = "touches" in e ? e.touches[0].clientX : e.clientX;
n({
handleUsed: "right",
initialWidth: s.current.clientWidth,
initialClientX: t
});
}, []), f = aa(e.block.id);
return /* @__PURE__ */ K(ca, {
...e,
onMouseEnter: c,
onMouseLeave: l,
style: e.block.props.url && !f && e.block.props.showPreview ? { width: r ? `${r}px` : "fit-content" } : void 0,
children: /* @__PURE__ */ q("div", {
className: "bn-visual-media-wrapper",
style: { position: "relative" },
ref: s,
children: [
e.children,
/* @__PURE__ */ K("div", {
className: "bn-resize-handle",
style: {
left: "4px",
display: a || t ? "initial" : "none"
},
onMouseDown: u,
onTouchStart: u
}),
/* @__PURE__ */ K("div", {
className: "bn-resize-handle",
style: {
right: "4px",
display: a || t ? "initial" : "none"
},
onMouseDown: d,
onTouchStart: d
}),
t && /* @__PURE__ */ K("div", { style: {
position: "absolute",
height: "100%",
width: "100%"
} })
]
})
});
}, ga = (e) => {
let t = ta(e.block.props.url), n = e.block.props.name || "";
return /* @__PURE__ */ K("img", {
className: "bn-visual-media",
src: t.loadingState === "loading" ? e.block.props.url : t.downloadUrl,
alt: n,
width: e.block.props.previewWidth,
contentEditable: !1,
draggable: !1
});
}, _a = (e) => {
if (!e.block.props.url) return /* @__PURE__ */ K("p", { children: "Add image" });
let t = e.block.props.name || "", n = e.block.props.showPreview ? /* @__PURE__ */ K("img", {
src: e.block.props.url,
alt: t,
width: e.block.props.previewWidth
}) : /* @__PURE__ */ K("a", {
href: e.block.props.url,
children: e.block.props.name || e.block.props.url
});
return e.block.props.caption ? e.block.props.showPreview ? /* @__PURE__ */ K(na, {
caption: e.block.props.caption,
children: n
}) : /* @__PURE__ */ K(la, {
caption: e.block.props.caption,
children: n
}) : n;
}, va = (e) => /* @__PURE__ */ K(ha, {
...e,
buttonIcon: /* @__PURE__ */ K(an, { size: 24 }),
children: /* @__PURE__ */ K(ga, { ...e })
}), ya = ea(Ie, (e) => ({
meta: { fileBlockAccept: ["image/*"] },
render: va,
parse: Qe(e),
toExternalHTML: _a,
runsBefore: ["file"]
}));
//#endregion
//#region ../../node_modules/.pnpm/react-icons@5.6.0_react@19.2.5/node_modules/react-icons/tb/index.mjs
function ba(e) {
return Z({
tag: "svg",
attr: {
viewBox: "0 0 24 24",
fill: "none",
stroke: "currentColor",
strokeWidth: "2",
strokeLinecap: "round",
strokeLinejoin: "round"
},
child: [
{
tag: "path",
attr: { d: "M14 3v4a1 1 0 0 0 1 1h4" },
child: []
},
{
tag: "path",
attr: { d: "M19 18v1a2 2 0 0 1 -2 2h-10a2 2 0 0 1 -2 -2v-1" },
child: []
},
{
tag: "path",
attr: { d: "M3 14h3m4.5 0h3m4.5 0h3" },
child: []
},
{
tag: "path",
attr: { d: "M5 10v-5a2 2 0 0 1 2 -2h7l5 5v2" },
child: []
}
]
})(e);
}
//#endregion
//#region src/blocks/PageBreak/getPageBreakReactSlashMenuItems.tsx
var xa = { page_break: ba };
function Sa(e) {
return Ye(e).map((e) => {
let t = xa[e.key];
return {
...e,
icon: /* @__PURE__ */ K(t, { size: 18 })
};
});
}
//#endregion
//#region ../../node_modules/.pnpm/react-icons@5.6.0_react@19.2.5/node_modules/react-icons/fa/index.mjs
function Ca(e) {
return Z({
tag: "svg",
attr: { viewBox: "0 0 640 512" },
child: [{
tag: "path",
attr: { d: "M278.9 511.5l-61-17.7c-6.4-1.8-10-8.5-8.2-14.9L346.2 8.7c1.8-6.4 8.5-10 14.9-8.2l61 17.7c6.4 1.8 10 8.5 8.2 14.9L293.8 503.3c-1.9 6.4-8.5 10.1-14.9 8.2zm-114-112.2l43.5-46.4c4.6-4.9 4.3-12.7-.8-17.2L117 256l90.6-79.7c5.1-4.5 5.5-12.3.8-17.2l-43.5-46.4c-4.5-4.8-12.1-5.1-17-.5L3.8 247.2c-5.1 4.7-5.1 12.8 0 17.5l144.1 135.1c4.9 4.6 12.5 4.4 17-.5zm327.2.6l144.1-135.1c5.1-4.7 5.1-12.8 0-17.5L492.1 112.1c-4.8-4.5-12.4-4.3-17 .5L431.6 159c-4.6 4.9-4.3 12.7.8 17.2L523 256l-90.6 79.7c-5.1 4.5-5.5 12.3-.8 17.2l43.5 46.4c4.5 4.9 12.1 5.1 17 .6z" },
child: []
}]
})(e);
}
//#endregion
//#region src/blocks/SourceWithPreview/PreviewPlaceholder.tsx
var wa = (e) => /* @__PURE__ */ q("div", {
className: "bn-preview-placeholder" + (e.error ? " bn-preview-placeholder-error" : ""),
contentEditable: !1,
children: [/* @__PURE__ */ K("div", {
className: "bn-preview-placeholder-icon",
"aria-hidden": "true",
children: e.icon ?? (e.error ? /* @__PURE__ */ K(Gr, {}) : /* @__PURE__ */ K(Ca, {}))
}), /* @__PURE__ */ K("p", {
className: "bn-preview-placeholder-text",
children: e.text
})]
}), Ta = (e) => {
let { editor: t, popup: n, inline: r, enterSubmits: i = !0, contentRef: a, source: o, preview: s, error: c, emptySourcePlaceholder: l, errorPreview: u, sourcePlaceholder: d } = e, f = N(!1);
c == null ? f.current = !1 : n.isOpen || (f.current = !0);
let p = l == null || typeof l == "string" ? /* @__PURE__ */ K(wa, { text: l ?? t.dictionary.code_block.add_source_button_text }) : l, m = u == null || typeof u == "string" ? /* @__PURE__ */ K(wa, {
error: !0,
text: u ?? "Error"
}) : u, h = re(), g = o.length === 0 ? p : c != null && (f.current || s == null) ? m : s, _ = t.isEditable && (o.length === 0 || c != null && (f.current || s == null)), v = (e) => {
t.isEditable && (e.stopPropagation(), n.open());
}, y = (e) => {
e.stopPropagation(), n.close();
}, b = r ? "span" : "div", x = r ? "span" : "div";
return /* @__PURE__ */ q(b, {
className: "bn-preview-with-source-popup" + (n.isSelected ? " ProseMirror-selectednode" : ""),
"data-open": n.isOpen ? "true" : "false",
children: [/* @__PURE__ */ K(x, {
className: "bn-preview-container",
contentEditable: !1,
role: _ ? "button" : void 0,
onClick: v,
children: g
}), /* @__PURE__ */ q("div", {
className: "bn-source-block-popup",
children: [/* @__PURE__ */ q("div", {
className: "bn-code-block-source-popup-body",
children: [/* @__PURE__ */ q("pre", {
className: o.length === 0 && d ? "bn-code-block-source-popup-input-empty" : void 0,
"data-placeholder": d,
"aria-hidden": !n.isOpen || void 0,
children: [/* @__PURE__ */ K("code", {
ref: a,
"aria-label": d,
"aria-invalid": c ? !0 : void 0,
"aria-describedby": c ? h : void 0
}), r && o.length === 0 && /* @__PURE__ */ K("br", {
"aria-hidden": "true",
contentEditable: !1
})]
}), /* @__PURE__ */ K("div", {
className: "bn-code-block-source-popup-ok-button-wrapper",
contentEditable: !1,
inert: !n.isOpen,
children: /* @__PURE__ */ q("button", {
type: "button",
className: "bn-code-block-source-popup-ok-button",
onClick: y,
children: [t.dictionary.code_block.ok_button_text, i && /* @__PURE__ */ K(Wr, {
className: "bn-code-block-source-popup-ok-button-icon",
"aria-hidden": "true"
})]
})
})]
}), /* @__PURE__ */ K("div", {
id: h,
className: "bn-code-block-source-error",
contentEditable: !1,
style: { display: c ? "block" : "none" },
role: "alert",
inert: !n.isOpen,
children: c
})]
})]
});
}, Ea = (e) => {
let { editor: t, block: n } = e, { store: r } = o(Ee, { editor: t });
return {
isOpen: w(Ee, {
editor: t,
selector: (e) => e.popupOpen === n.id
}),
isSelected: w(Ee, {
editor: t,
selector: (e) => e.selected === n.id
}),
open: () => {
t.isEditable && (r.setState((e) => ({
...e,
popupOpen: n.id
})), t.setTextCursorPosition(n.id, "end"), t.focus());
},
close: () => {
r.setState((e) => ({
...e,
popupOpen: void 0
})), t.focus();
}
};
}, Da = (e) => {
let { block: t, editor: n, ...r } = e, i = Ea({
editor: n,
block: t
}), a = n.schema.blockSpecs[t.type]?.implementation?.meta?.hardBreakShortcut !== "enter";
return /* @__PURE__ */ K(Ta, {
editor: n,
popup: i,
enterSubmits: a,
...r
});
}, Oa = (e) => {
let { editor: t, node: n, getPos: r } = e, { store: i } = o(De, { editor: t }), a = w(De, {
editor: t,
selector: (e) => e.selected !== void 0 && e.selected === r()
});
return {
isOpen: a,
isSelected: a,
open: () => {
if (!t.isEditable) return;
let e = r();
if (!e) return;
i.setState({ selected: e });
let a = t.prosemirrorView;
a.dispatch(a.state.tr.setSelection(bt.create(a.state.tr.doc, e + n.nodeSize - 1))), t.focus();
},
close: () => {
if (!t.isEditable) return;
let e = r();
if (!e) return;
let i = t.prosemirrorView;
i.dispatch(i.state.tr.setSelection(bt.create(i.state.tr.doc, e + n.nodeSize))), t.focus();
}
};
}, ka = (e) => {
let { editor: t, node: n, getPos: r, ...i } = e, a = Oa({
editor: t,
node: n,
getPos: r
});
return /* @__PURE__ */ K(Ta, {
inline: !0,
editor: t,
popup: a,
...i
});
}, Aa = (e) => {
let t = ta(e.block.props.url);
return /* @__PURE__ */ K("video", {
className: "bn-visual-media",
src: t.loadingState === "loading" ? e.block.props.url : t.downloadUrl,
controls: !0,
width: e.block.props.previewWidth || void 0,
contentEditable: !1,
draggable: !1
});
}, ja = (e) => {
if (!e.block.props.url) return /* @__PURE__ */ K("p", { children: "Add video" });
let t = e.block.props.showPreview ? /* @__PURE__ */ K("video", {
src: e.block.props.url,
width: e.block.props.previewWidth || void 0
}) : /* @__PURE__ */ K("a", {
href: e.block.props.url,
children: e.block.props.name || e.block.props.url
});
return e.block.props.caption ? e.block.props.showPreview ? /* @__PURE__ */ K(na, {
caption: e.block.props.caption,
children: t
}) : /* @__PURE__ */ K(la, {
caption: e.block.props.caption,
children: t
}) : t;
}, Ma = (e) => /* @__PURE__ */ K(ha, {
...e,
buttonIcon: /* @__PURE__ */ K(en, { size: 24 }),
children: /* @__PURE__ */ K(Aa, { ...e })
}), Na = ea(ze, (e) => ({
meta: { fileBlockAccept: ["video/*"] },
render: Ma,
parse: lt(e),
toExternalHTML: ja,
runsBefore: ["file"]
})), Pa = (e, t) => {
if (t.type === "toggled") return !e;
if (t.type === "childAdded") return !0;
if (t.type === "lastChildRemoved") return !1;
throw new Oe(t);
}, Fa = (e) => {
let { block: t, editor: n, children: r, toggledState: i } = e, [a, o] = oe(Pa, (i || Ve).get(t)), s = (e) => {
let t = n.getBlock(e);
t && ((i || Ve).set(t, !a), o({ type: "toggled" }));
}, c = (e) => {
(i || Ve).set(e, !0), o({ type: "childAdded" });
}, l = (e) => {
(i || Ve).set(e, !1), o({ type: "lastChildRemoved" });
}, u = S({
editor: n,
selector: ({ editor: e }) => {
if (!J(t, e, t.type, { isToggleable: "boolean" }) && !t.props.isToggleable) return 0;
let n = e.getBlock(t);
if (!n) return 0;
let r = n.children.length || 0;
return r > u ? a || c(n) : r === 0 && r < u && a && l(n), r;
}
});
return "isToggleable" in t.props && !t.props.isToggleable ? r : /* @__PURE__ */ q("div", { children: [/* @__PURE__ */ q("div", {
className: "bn-toggle-wrapper",
"data-show-children": a,
children: [/* @__PURE__ */ K("button", {
className: "bn-toggle-button",
type: "button",
onMouseDown: (e) => e.preventDefault(),
onClick: () => s(t),
children: /* @__PURE__ */ K("svg", {
xmlns: "http://www.w3.org/2000/svg",
height: "1em",
viewBox: "0 -960 960 960",
width: "1em",
fill: "currentcolor",
children: /* @__PURE__ */ K("path", { d: "M472-480 332-620q-18-18-18-44t18-44q18-18 44-18t44 18l183 183q9 9 14 21t5 24q0 12-5 24t-14 21L420-252q-18 18-44 18t-44-18q-18-18-18-44t18-44l140-140Z" })
})
}), r]
}), n.isEditable && a && u === 0 && /* @__PURE__ */ K("button", {
className: "bn-toggle-add-block-button",
type: "button",
onClick: () => {
let e = n.updateBlock(t, { children: [{}] });
n.setTextCursorPosition(e.children[0].id, "end"), n.focus();
},
children: n.dictionary.toggle_blocks.add_block_button
})] });
};
//#endregion
//#region src/components/TableHandles/hooks/useExtendButtonsPositioning.ts
function Ia(e, t, n) {
let { refs: r, update: i, context: a, floatingStyles: o } = Se({
open: t,
placement: e === "addOrRemoveColumns" ? "right" : "bottom",
middleware: [xe({ apply({ rects: t, elements: n }) {
Object.assign(n.floating.style, e === "addOrRemoveColumns" ? { height: `${t.reference.height}px` } : { width: `${t.reference.width}px` });
} })]
}), { isMounted: s, styles: c } = Ce(a);
return j(() => {
i();
}, [n, i]), j(() => {
n !== null && r.setReference({ getBoundingClientRect: () => n });
}, [
e,
n,
r
]), M(() => ({
isMounted: s,
ref: r.setFloating,
style: {
display: "flex",
...c,
...o
}
}), [
o,
s,
r.setFloating,
c
]);
}
function La(e, t, n) {
let r = Ia("addOrRemoveRows", t, n), i = Ia("addOrRemoveColumns", e, n);
return M(() => ({
addOrRemoveRowsButton: r,
addOrRemoveColumnsButton: i
}), [i, r]);
}
//#endregion
//#region src/components/TableHandles/hooks/useTableHandlesPositioning.ts
function Ra(e, t, n) {
return n && n.draggedCellOrientation === "row" ? new DOMRect(t.x, n.mousePos, t.width, 0) : new DOMRect(t.x, e.y, t.width, e.height);
}
function za(e, t, n) {
return n && n.draggedCellOrientation === "col" ? new DOMRect(n.mousePos, t.y, 0, t.height) : new DOMRect(e.x, t.y, e.width, t.height);
}
function Ba(e) {
return new DOMRect(e.x, e.y, e.width, 0);
}
function Va(e, t, n, r, i) {
let { refs: a, update: o, context: s, floatingStyles: c } = Se({
open: t,
placement: e === "row" ? "left" : e === "col" ? "top" : "bottom-end",
middleware: [U(e === "row" ? -10 : e === "col" ? -12 : {
mainAxis: 1,
crossAxis: -1
})]
}), { isMounted: l, styles: u } = Ce(s);
return j(() => {
o();
}, [
n,
r,
o
]), j(() => {
n === null || r === null || i && e === "cell" || a.setReference({ getBoundingClientRect: () => (e === "row" ? Ra : e === "col" ? za : Ba)(n, r, i) });
}, [
i,
e,
n,
r,
a
]), M(() => ({
isMounted: l,
ref: a.setFloating,
style: {
display: "flex",
...u,
...c
}
}), [
c,
l,
a.setFloating,
u
]);
}
function Ha(e, t, n, r) {
let i = Va("row", e, t, n, r), a = Va("col", e, t, n, r), o = Va("cell", e, t, n, r);
return M(() => ({
rowHandle: i,
colHandle: a,
cellHandle: o
}), [
a,
i,
o
]);
}
//#endregion
//#region src/components/Comments/EmojiMartPicker.tsx
var Ua;
async function Wa() {
return Ua || (Ua = (async () => {
let [e, t] = await Promise.all([import("emoji-mart"), import("@emoji-mart/data")]), n = "default" in e ? e.default : e, r = "default" in t ? t.default : t;
return await n.init({ data: r }), {
emojiMart: n,
emojiData: r
};
})(), Ua);
}
function Ga(e) {
let t = N(null), n = N(null);
return n.current && n.current.update(e), j(() => ((async () => {
let { emojiMart: r } = await Wa();
n.current = new r.Picker({
...e,
ref: t
});
})(), () => {
n.current = null;
}), []), E.createElement("div", { ref: t });
}
//#endregion
//#region src/components/Comments/EmojiPicker.tsx
var Ka = (e) => {
let [n, r] = P(!1), i = s(), a = t(), o = m();
return /* @__PURE__ */ q(i.Generic.Popover.Root, {
open: n,
portalElement: o,
children: [/* @__PURE__ */ K(i.Generic.Popover.Trigger, { children: /* @__PURE__ */ K("div", {
onClick: (t) => {
t.preventDefault(), t.stopPropagation(), r(!n), e.onOpenChange?.(!n);
},
style: {
display: "flex",
justifyContent: "center",
alignItems: "center"
},
children: e.children
}) }), /* @__PURE__ */ K(i.Generic.Popover.Content, {
className: "bn-emoji-picker-popover",
variant: "panel-popover",
children: /* @__PURE__ */ K(Ga, {
perLine: 7,
onClickOutside: () => {
r(!1), e.onOpenChange?.(!1);
},
onEmojiSelect: (t) => {
e.onEmojiSelect(t), r(!1), e.onOpenChange?.(!1);
},
theme: a?.colorSchemePreference
})
})]
});
};
//#endregion
//#region src/components/Comments/useCommentUsers.ts
function qa(t) {
let { userStore: n } = o(I), r = t.join(",");
return j(() => {
n.loadUsers(t);
}, [n, r]), e(n.store, (e) => {
let n = /* @__PURE__ */ new Map();
for (let r of t) {
let t = e.get(r);
t && n.set(r, t);
}
return n;
});
}
function Ja(e) {
return qa([e]).get(e);
}
//#endregion
//#region src/components/Comments/ReactionBadge.tsx
var Ya = (e) => {
let t = s(), n = g(), r = o(I), i = e.comment.reactions.find((t) => t.emoji === e.emoji);
if (!i) throw Error("Trying to render reaction badge for non-existing reaction");
let [a, c] = P([]), l = qa(a);
return /* @__PURE__ */ K(t.Generic.Badge.Root, {
className: X("bn-badge", "bn-comment-reaction"),
text: i.userIds.length.toString(),
icon: i.emoji,
isSelected: r.threadStore.auth.canDeleteReaction(e.comment, i.emoji),
onClick: () => e.onReactionSelect(i.emoji),
onMouseEnter: () => c(i.userIds),
mainTooltip: n.comments.reactions.reacted_by,
secondaryTooltip: `${Array.from(l.values()).map((e) => e.username).join("\n")}`
}, i.emoji);
}, Xa = ne(({ isEmpty: e, comment: t, isEditing: n, threadStore: r, onReactionSelect: i, onEditSubmit: a, onEditCancel: o, onEmojiPickerOpenChange: s, Components: c, dict: l }) => {
let u = r.auth.canAddReaction(t);
return /* @__PURE__ */ q(G, { children: [t.reactions.length > 0 && !n && /* @__PURE__ */ q(c.Generic.Badge.Group, {
className: X("bn-badge-group", "bn-comment-reactions"),
children: [t.reactions.map((e) => /* @__PURE__ */ K(Ya, {
comment: t,
emoji: e.emoji,
onReactionSelect: i
}, e.emoji)), u && /* @__PURE__ */ K(Ka, {
onEmojiSelect: (e) => i(e.native),
onOpenChange: s,
children: /* @__PURE__ */ K(c.Generic.Badge.Root, {
className: X("bn-badge", "bn-comment-add-reaction"),
text: "+",
icon: /* @__PURE__ */ K(Vt, { size: 16 }),
mainTooltip: l.comments.actions.add_reaction
})
})]
}), n && /* @__PURE__ */ q(c.Generic.Toolbar.Root, {
variant: "action-toolbar",
className: X("bn-action-toolbar", "bn-comment-actions"),
children: [/* @__PURE__ */ K(c.Generic.Toolbar.Button, {
mainTooltip: l.comments.save_button_text,
variant: "compact",
onClick: a,
isDisabled: e,
children: l.comments.save_button_text
}), /* @__PURE__ */ K(c.Generic.Toolbar.Button, {
className: "bn-button",
mainTooltip: l.comments.cancel_button_text,
variant: "compact",
onClick: o,
children: l.comments.cancel_button_text
})]
})] });
}), Za = ({ comment: e, thread: t, showResolveButton: n }) => {
let r = o(I), i = g(), [a, c] = P(!1), l = f({
initialContent: e.body,
trailingBlock: !1,
dictionary: {
...i,
placeholders: { emptyDocument: i.placeholders.edit_comment }
},
schema: r.commentEditorSchema || h,
extensions: [F({
submitOnEnter: r.submitOnEnter,
onSubmit: async (n) => {
await r.threadStore.updateComment({
commentId: e.id,
comment: { body: n.document },
threadId: t.id
}), c(!1);
}
})]
}), u = s(), d = m(), [p, _] = P(!1), [y, b] = P(!1), x = r.threadStore, S = k(() => {
c(!0);
}, []), C = k(() => {
l.replaceBlocks(l.document, e.body), c(!1);
}, [l, e.body]), w = l.getExtension(F).submit, T = k(async () => {
await x.deleteComment({
commentId: e.id,
threadId: t.id
});
}, [
e,
t.id,
x
]), E = k(async (n) => {
x.auth.canAddReaction(e, n) ? await x.addReaction({
threadId: t.id,
commentId: e.id,
emoji: n
}) : x.auth.canDeleteReaction(e, n) && await x.deleteReaction({
threadId: t.id,
commentId: e.id,
emoji: n
});
}, [
x,
e,
t.id
]), D = k(async () => {
await x.resolveThread({ threadId: t.id });
}, [t.id, x]), ee = k(async () => {
await x.unresolveThread({ threadId: t.id });
}, [t.id, x]), O = Ja(e.userId);
if (!e.body) return null;
let te, ne = x.auth.canAddReaction(e), A = x.auth.canDeleteComment(e), j = x.auth.canUpdateComment(e), re = n && (t.resolved ? x.auth.canUnresolveThread(t) : x.auth.canResolveThread(t));
a || (te = /* @__PURE__ */ q(u.Generic.Toolbar.Root, {
className: X("bn-action-toolbar", "bn-comment-actions"),
variant: "action-toolbar",
children: [
ne && /* @__PURE__ */ K(Ka, {
onEmojiSelect: (e) => E(e.native),
onOpenChange: _,
children: /* @__PURE__ */ K(u.Generic.Toolbar.Button, {
mainTooltip: i.comments.actions.add_reaction,
variant: "compact",
children: /* @__PURE__ */ K(Vt, { size: 16 })
}, "add-reaction")
}),
re && (t.resolved ? /* @__PURE__ */ K(u.Generic.Toolbar.Button, {
mainTooltip: i.comments.actions.reopen,
variant: "compact",
onClick: ee,
children: /* @__PURE__ */ K(Hn, { size: 16 })
}, "reopen") : /* @__PURE__ */ K(u.Generic.Toolbar.Button, {
mainTooltip: i.comments.actions.resolve,
variant: "compact",
onClick: D,
children: /* @__PURE__ */ K(Zt, { size: 16 })
}, "resolve")),
(A || j) && /* @__PURE__ */ q(u.Generic.Menu.Root, {
position: "bottom-start",
onOpenChange: b,
portalElement: d,
children: [/* @__PURE__ */ K(u.Generic.Menu.Trigger, { children: /* @__PURE__ */ K(u.Generic.Toolbar.Button, {
mainTooltip: i.comments.actions.more_actions,
variant: "compact",
children: /* @__PURE__ */ K(Wt, { size: 16 })
}, "more-actions") }), /* @__PURE__ */ q(u.Generic.Menu.Dropdown, {
className: "bn-menu-dropdown",
children: [j && /* @__PURE__ */ K(u.Generic.Menu.Item, {
icon: /* @__PURE__ */ K(Bn, {}),
onClick: S,
children: i.comments.actions.edit_comment
}, "edit-comment"), A && /* @__PURE__ */ K(u.Generic.Menu.Item, {
icon: /* @__PURE__ */ K(Jt, {}),
onClick: T,
children: i.comments.actions.delete_comment
}, "delete-comment")]
})]
})
]
}));
let ie = e.createdAt.toLocaleDateString(void 0, {
month: "short",
day: "numeric"
});
if (!e.body) throw Error("soft deletes are not yet supported");
return /* @__PURE__ */ K(u.Comments.Comment, {
authorInfo: O ?? "loading",
timeString: ie,
edited: e.updatedAt.getTime() !== e.createdAt.getTime(),
showActions: y || "hover",
actions: te,
className: "bn-thread-comment",
emojiPickerOpen: p,
children: /* @__PURE__ */ K(v, {
autoFocus: a,
editor: l,
editable: a,
actions: e.reactions.length > 0 || a ? ({ isFocused: t, isEmpty: n }) => /* @__PURE__ */ K(Xa, {
isFocused: t,
isEmpty: n,
comment: e,
isEditing: a,
threadStore: x,
onReactionSelect: E,
onEditSubmit: w,
onEditCancel: C,
onEmojiPickerOpenChange: _,
Components: u,
dict: i
}) : void 0
})
});
}, Qa = ({ thread: e, maxCommentsBeforeCollapse: t }) => {
let n = s(), r = g(), i = qa(e.resolvedBy ? [e.resolvedBy] : []), a = e.comments.map((t, n) => /* @__PURE__ */ K(Za, {
thread: e,
comment: t,
showResolveButton: n === 0
}, t.id + JSON.stringify(t.body || "{}")));
if (e.resolved && e.resolvedUpdatedAt && e.resolvedBy) {
if (!i.get(e.resolvedBy)) throw Error(`User ${e.resolvedBy} resolved thread ${e.id}, but their data could not be found.`);
let t = e.comments.findLastIndex((t) => e.resolvedUpdatedAt.getTime() > t.createdAt.getTime()) + 1;
a.splice(t, 0, /* @__PURE__ */ K(n.Comments.Comment, {
className: "bn-thread-comment",
authorInfo: e.resolvedBy && i.get(e.resolvedBy) || "loading",
timeString: e.resolvedUpdatedAt.toLocaleDateString(void 0, {
month: "short",
day: "numeric"
}),
edited: !1,
showActions: !1,
children: /* @__PURE__ */ K("div", {
className: "bn-resolved-text",
children: r.comments.sidebar.marked_as_resolved
})
}, "resolved-comment"));
}
return t && a.length > t && a.splice(1, a.length - 2, /* @__PURE__ */ K(n.Comments.ExpandSectionsPrompt, {
className: "bn-thread-expand-prompt",
children: r.comments.sidebar.more_replies(e.comments.length - 2)
}, "expand-prompt")), a;
}, $a = ne(({ isEmpty: e, onSave: t, Components: n, dict: r }) => /* @__PURE__ */ K(n.Generic.Toolbar.Root, {
className: X("bn-action-toolbar", "bn-comment-actions"),
variant: "action-toolbar",
children: /* @__PURE__ */ K(n.Generic.Toolbar.Button, {
className: "bn-button",
mainTooltip: r.comments.save_button_text,
variant: "compact",
isDisabled: e,
onClick: t,
children: r.comments.save_button_text
})
}));
function eo(e) {
let t = e.newCommentEditor, n = s(), r = g(), i = t.getExtension(F);
if (!i) throw Error("FloatingComposer's newCommentEditor must include CommentEditorSubmitExtension.");
let a = i.submit;
return /* @__PURE__ */ K(n.Comments.Card, {
className: "bn-thread",
children: /* @__PURE__ */ K(v, {
autoFocus: !0,
editable: !0,
editor: t,
actions: ({ isFocused: e, isEmpty: t }) => /* @__PURE__ */ K($a, {
isFocused: e,
isEmpty: t,
onSave: a,
Components: n,
dict: r
})
})
});
}
//#endregion
//#region src/components/Comments/FloatingComposerController.tsx
var to = /* @__PURE__ */ St({ default: () => no });
function no(e) {
let t = C(), n = g(), r = o(I), i = w(I, {
editor: t,
selector: (e) => e.pendingComment
}), s = f({
trailingBlock: !1,
dictionary: {
...n,
placeholders: { emptyDocument: n.placeholders.new_comment }
},
schema: r.commentEditorSchema || h,
extensions: [F({
submitOnEnter: r.submitOnEnter,
onSubmit: async (e) => {
await r.createThread({ initialComment: { body: e.document } }), r.stopPendingComment(), t.transact((e) => {
e.setSelection(bt.create(e.doc, e.selection.to));
}), t.focus();
}
})]
}, [i]), c = S({
editor: t,
selector: ({ editor: e }) => i ? {
from: e.prosemirrorState.selection.from,
to: e.prosemirrorState.selection.to
} : void 0
}), u = M(() => ({
...e.floatingUIOptions,
useFloatingOptions: {
open: !!i,
onOpenChange: (e) => {
if (!e) {
if (!b({
hasUnsavedContent: !s.isEmpty,
confirmBeforeDiscard: r.confirmBeforeDiscard,
message: n.comments.discard_pending_comment
})) return;
r.stopPendingComment(), t.focus();
}
},
placement: "bottom",
middleware: [
U(10),
W(),
H()
],
...e.floatingUIOptions?.useFloatingOptions
},
focusManagerProps: { disabled: !1 },
elementProps: {
style: { zIndex: 60 },
...e.floatingUIOptions?.elementProps
}
}), [
r,
n,
t,
s,
i,
e.floatingUIOptions
]), d = e.floatingComposer || eo;
return /* @__PURE__ */ K(l, {
target: e.portalElement,
children: /* @__PURE__ */ K(a, {
position: c,
...u,
children: /* @__PURE__ */ K(d, { newCommentEditor: s })
})
});
}
//#endregion
//#region src/components/Comments/Thread.tsx
var ro = ne(({ isEmpty: e, onNewCommentSave: t, Components: n, dict: r }) => e ? null : /* @__PURE__ */ K(n.Generic.Toolbar.Root, {
variant: "action-toolbar",
className: X("bn-action-toolbar", "bn-comment-actions"),
children: /* @__PURE__ */ K(n.Generic.Toolbar.Button, {
mainTooltip: r.comments.save_button_text,
variant: "compact",
isDisabled: e,
onClick: t,
children: r.comments.save_button_text
})
})), io = ({ thread: e, selected: t, orphaned: n, referenceText: r, maxCommentsBeforeCollapse: i, onFocus: a, onBlur: c, tabIndex: l, newCommentEditor: u }) => {
let d = s(), p = g(), m = o(I), _ = N(e.id);
_.current = e.id;
let y = f({
trailingBlock: !1,
dictionary: {
...p,
placeholders: { emptyDocument: p.placeholders.comment_reply }
},
schema: m.commentEditorSchema || h,
extensions: [F({
submitOnEnter: m.submitOnEnter,
onSubmit: async (e) => {
await m.threadStore.addComment({
comment: { body: e.document },
threadId: _.current
}), e.removeBlocks(e.document);
}
})]
}), b = u ?? y, x = b.getExtension(F);
if (!x) throw Error("Thread's newCommentEditor must include CommentEditorSubmitExtension.");
let S = x.submit;
return /* @__PURE__ */ q(d.Comments.Card, {
className: X("bn-thread", n && "bn-thread-orphaned"),
headerText: r,
onFocus: a,
onBlur: c,
selected: t,
tabIndex: l,
children: [/* @__PURE__ */ K(d.Comments.CardSection, {
className: "bn-thread-comments",
children: /* @__PURE__ */ K(Qa, {
thread: e,
maxCommentsBeforeCollapse: t ? void 0 : i || 5
})
}), t && /* @__PURE__ */ K(d.Comments.CardSection, {
className: "bn-thread-composer",
children: /* @__PURE__ */ K(v, {
autoFocus: !1,
editable: !0,
editor: b,
actions: ({ isFocused: e, isEmpty: t }) => /* @__PURE__ */ K(ro, {
isFocused: e,
isEmpty: t,
onNewCommentSave: S,
Components: d,
dict: p
})
})
})]
});
};
//#endregion
//#region src/components/Comments/useThreads.ts
function ao() {
let e = o(I).threadStore, t = N(void 0);
t.current ||= e.getThreads();
let n = k((n) => e.subscribe((e) => {
t.current = e, n();
}), [e]);
return se(n, () => t.current);
}
//#endregion
//#region src/components/Comments/FloatingThreadController.tsx
var oo = /* @__PURE__ */ St({ default: () => so });
function so(e) {
let t = C(), n = g(), r = o(I), i = w(I, {
editor: t,
selector: (e) => e.selectedThreadId ? {
id: e.selectedThreadId,
position: e.threadPositions.get(e.selectedThreadId)
} : void 0
}), s = f({
trailingBlock: !1,
dictionary: {
...n,
placeholders: { emptyDocument: n.placeholders.comment_reply }
},
schema: r.commentEditorSchema || h,
extensions: [F({
submitOnEnter: r.submitOnEnter,
onSubmit: async (e) => {
i && (await r.threadStore.addComment({
comment: { body: e.document },
threadId: i.id
}), e.removeBlocks(e.document));
}
})]
}, [i?.id]), c = ao(), u = M(() => i ? c.get(i.id) : void 0, [i, c]), d = M(() => ({
...e.floatingUIOptions,
useFloatingOptions: {
open: !!i,
onOpenChange: (e, i, a) => {
if (!e) {
if (!b({
hasUnsavedContent: !s.isEmpty,
confirmBeforeDiscard: r.confirmBeforeDiscard,
message: n.comments.discard_pending_comment
})) return;
a === "escape-key" && t.focus(), r.selectThread(void 0);
}
},
placement: "bottom",
middleware: [
U(10),
W(),
H()
],
...e.floatingUIOptions?.useFloatingOptions
},
focusManagerProps: {
disabled: !0,
...e.floatingUIOptions?.focusManagerProps
},
elementProps: {
style: { zIndex: 30 },
...e.floatingUIOptions?.elementProps
}
}), [
r,
n,
t,
s,
e.floatingUIOptions,
i
]), p = e.floatingThread || io;
return /* @__PURE__ */ K(l, {
target: e.portalElement,
children: /* @__PURE__ */ K(a, {
position: i?.position,
...d,
children: u && /* @__PURE__ */ K(p, {
thread: u,
selected: !0,
newCommentEditor: s
})
})
});
}
//#endregion
//#region src/components/Comments/ThreadsSidebar.tsx
var co = E.memo(({ thread: e, selectedThreadId: t, maxCommentsBeforeCollapse: n, referenceText: r, orphaned: i }) => {
let a = o(I), s = k((t) => {
t.target.closest(".bn-action-toolbar") || a.selectThread(e.id);
}, [a, e.id]), c = k((e) => {
if (!e.relatedTarget || e.relatedTarget.closest(".bn-action-toolbar")) return;
let t = e.target instanceof Node ? e.target : null, n = e.relatedTarget instanceof Node ? e.relatedTarget.closest(".bn-thread") : null;
(!t || !n || !n.contains(t)) && a.selectThread(void 0);
}, [a]);
return /* @__PURE__ */ K(io, {
thread: e,
selected: e.id === t,
orphaned: i,
referenceText: r,
maxCommentsBeforeCollapse: n,
onFocus: s,
onBlur: c,
tabIndex: 0
});
});
function lo(e, t, n) {
if (t === "recent-activity") return e.sort((e, t) => t.comments[t.comments.length - 1].createdAt.getTime() - e.comments[e.comments.length - 1].createdAt.getTime());
if (t === "oldest") return e.sort((e, t) => e.createdAt.getTime() - t.createdAt.getTime());
if (t === "position") return e.sort((e, t) => (n?.get(e.id)?.from || Number.MAX_VALUE) - (n?.get(t.id)?.from || Number.MAX_VALUE));
throw new Oe(t);
}
function uo(e, t) {
return e.transact((n) => {
if (!t) return e.dictionary.comments.deleted_reference_text;
if (n.doc.nodeSize < t.to) return "";
let r = n.doc.textBetween(t.from, t.to);
return r.length > 15 ? `${r.slice(0, 15)}…` : r;
});
}
function fo(e) {
let t = C(), { selectedThreadId: n, threadPositions: r } = w(I), i = ao(), a = M(() => {
let n = lo(Array.from(i.values()), e.sort || "position", r), a = [];
for (let i of n) {
let n = r.get(i.id), o = n === void 0;
i.resolved ? (e.filter === "resolved" || e.filter === "all") && a.push({
thread: i,
referenceText: uo(t, n),
orphaned: o
}) : (e.filter === "open" || e.filter === "all") && a.push({
thread: i,
referenceText: uo(t, n),
orphaned: o
});
}
return a;
}, [
i,
e.sort,
e.filter,
r,
t
]);
return /* @__PURE__ */ K("div", {
className: "bn-threads-sidebar",
children: a.map((r) => /* @__PURE__ */ K(co, {
thread: r.thread,
selectedThreadId: n,
editor: t,
referenceText: r.referenceText,
orphaned: r.orphaned,
maxCommentsBeforeCollapse: e.maxCommentsBeforeCollapse
}, r.thread.id))
});
}
//#endregion
//#region src/components/Versioning/useVersionUsers.ts
function po(t) {
let { userStore: n } = o(V), r = t.join(",");
return j(() => {
n.loadUsers(t);
}, [n, r]), e(n.store, (e) => {
let n = /* @__PURE__ */ new Map();
for (let r of t) {
let t = e.get(r);
t && n.set(r, t);
}
return n;
});
}
function mo(e) {
let t = e?.by === void 0 ? [] : Array.isArray(e.by) ? e.by : [e.by], n = po(t);
if (e?.secondaryLabel !== void 0) return e.secondaryLabel;
if (t.length !== 0) return t.map((e) => n.get(e)?.username ?? e).join(", ");
}
//#endregion
//#region src/components/Versioning/dateToString.ts
var ho = (e) => `${e.toLocaleDateString(void 0, {
day: "numeric",
month: "long",
year: "numeric"
})}, ${e.toLocaleTimeString(void 0, {
hour: "numeric",
minute: "2-digit"
})}`, go = ee(void 0), _o = (e) => {
let { canCompare: t } = o(V), [n, r] = P(!0), [i, a] = P("history"), s = t, c = e.filter === void 0 ? void 0 : e.filter === "named" ? "named" : "history", l = c === void 0, u = c ?? i, d = M(() => ({
comparisonEnabled: s,
comparisonMode: s && n,
setComparisonMode: r,
activeTab: u,
setActiveTab: a,
showTabs: l
}), [
s,
n,
u,
l
]);
return /* @__PURE__ */ K(go.Provider, {
value: d,
children: e.children
});
}, vo = () => {
let e = A(go);
if (!e) throw Error("useVersioningSidebar must be used within a VersioningSidebarProvider");
return e;
}, yo = ({ snapshot: e, previousSnapshot: t }) => {
let n = s(), r = m(), { canPreviewCurrent: i, previewCurrentVersion: a, exitPreview: c } = o(V), l = w(V, { selector: (e) => e.previewedSnapshotId === L }), u = w(V, { selector: (e) => e.snapshots.filter((e) => e.id !== L) }), { comparisonEnabled: d, comparisonMode: f, setComparisonMode: p } = vo(), h = mo(e), g = () => {
f && a && t ? a({ compareTo: t.id }) : c();
}, _ = u[u.length - 1], v = d && i && a && _ ? /* @__PURE__ */ K(n.Generic.Toolbar.Root, {
variant: "action-toolbar",
className: "bn-action-toolbar",
children: /* @__PURE__ */ q(n.Generic.Menu.Root, {
position: "bottom-start",
portalElement: r,
children: [/* @__PURE__ */ K(n.Generic.Menu.Trigger, { children: /* @__PURE__ */ K(n.Generic.Toolbar.Button, {
className: "bn-snapshot-menu-trigger",
mainTooltip: "More",
variant: "compact",
onClick: (e) => {
e.preventDefault(), e.stopPropagation();
},
children: /* @__PURE__ */ K(Wt, { size: 16 })
}) }), /* @__PURE__ */ K(n.Generic.Menu.Dropdown, {
className: "bn-menu-dropdown",
children: /* @__PURE__ */ K(n.Generic.Menu.Item, {
icon: /* @__PURE__ */ K(Vn, {}),
onClick: () => {
p(!0), a({ compareTo: _.id });
},
children: "Compare since beginning"
})
})]
})
}) : void 0;
return /* @__PURE__ */ K(n.Versioning.Snapshot, {
className: "bn-snapshot",
selected: l,
onClick: g,
actions: v,
children: /* @__PURE__ */ q("div", {
className: "bn-snapshot-body",
children: [
/* @__PURE__ */ K("div", {
className: "bn-snapshot-name",
children: "Current version"
}),
h !== void 0 && /* @__PURE__ */ K("div", {
className: "bn-snapshot-date",
children: ho(new Date(e.createdAt))
}),
h !== void 0 && /* @__PURE__ */ K("div", {
className: "bn-snapshot-secondary-label",
children: h
})
]
})
});
}, bo = ({ snapshot: e, previousSnapshot: t }) => {
let n = s(), r = m(), { canRestore: i, restore: a, canRename: c, rename: l, canRemove: u, remove: d, previewSnapshot: f, previewCurrentVersion: p } = o(V), h = w(V, { selector: (t) => t.previewedSnapshotId === e.id }), g = w(V, { selector: (e) => e.previewedSnapshotId }), _ = w(V, { selector: (e) => e.compareToSnapshotId }), v = w(V, { selector: (t) => e?.restoredFromSnapshotId === void 0 ? void 0 : t.snapshots.find((t) => t.id === e.restoredFromSnapshotId) }), { comparisonEnabled: y, comparisonMode: b, setComparisonMode: x } = vo(), S = mo(e), C = ho(new Date(e?.createdAt || 0)), [T, E] = P(e?.name || C);
if (e === void 0) return null;
let D = _ === e.id && !h, ee = () => {
if (!b) {
f(e.id);
return;
}
f(e.id, { compareTo: t?.id });
}, O = y || i || u ? /* @__PURE__ */ K(n.Generic.Toolbar.Root, {
variant: "action-toolbar",
className: "bn-action-toolbar",
children: /* @__PURE__ */ q(n.Generic.Menu.Root, {
position: "bottom-start",
portalElement: r,
children: [/* @__PURE__ */ K(n.Generic.Menu.Trigger, { children: /* @__PURE__ */ K(n.Generic.Toolbar.Button, {
className: "bn-snapshot-menu-trigger",
mainTooltip: "More",
variant: "compact",
onClick: (e) => {
e.preventDefault(), e.stopPropagation();
},
children: /* @__PURE__ */ K(Wt, { size: 16 })
}) }), /* @__PURE__ */ q(n.Generic.Menu.Dropdown, {
className: "bn-menu-dropdown",
children: [
y && /* @__PURE__ */ K(n.Generic.Menu.Item, {
icon: /* @__PURE__ */ K(Vn, {}),
onClick: () => {
x(!0), g !== void 0 && g !== L && g !== e.id ? f(g, { compareTo: e.id }) : p && p({ compareTo: e.id });
},
children: "Compare with this version"
}),
i && /* @__PURE__ */ K(n.Generic.Menu.Item, {
icon: /* @__PURE__ */ K(Hn, {}),
onClick: () => {
a?.(e.id);
},
children: "Restore"
}),
u && /* @__PURE__ */ K(n.Generic.Menu.Item, {
icon: /* @__PURE__ */ K(qt, {}),
onClick: () => {
d?.(e.id);
},
children: "Delete"
})
]
})]
})
}) : void 0;
return /* @__PURE__ */ q(n.Versioning.Snapshot, {
className: "bn-snapshot",
selected: h,
comparing: D,
onClick: ee,
actions: O,
children: [D && /* @__PURE__ */ q("div", {
className: "bn-snapshot-comparing-to",
children: [/* @__PURE__ */ K(Vn, { size: 14 }), /* @__PURE__ */ K("span", { children: "Comparing to" })]
}), /* @__PURE__ */ q("div", {
className: "bn-snapshot-body",
children: [
c ? /* @__PURE__ */ K("input", {
className: "bn-snapshot-name",
type: "text",
value: T,
readOnly: !h,
style: { cursor: h ? "text" : "pointer" },
onChange: (e) => E(e.target.value),
onMouseDown: (e) => {
h || e.preventDefault();
},
onClick: (e) => {
h && e.stopPropagation();
},
onBlur: () => l?.(e.id, T === C ? void 0 : T)
}) : /* @__PURE__ */ K("div", {
className: "bn-snapshot-name",
children: T
}),
e.name && e.name !== C && /* @__PURE__ */ K("div", {
className: "bn-snapshot-date",
children: C
}),
v && /* @__PURE__ */ K("div", {
className: "bn-snapshot-original-date",
children: `Restored from ${ho(new Date(v.createdAt))}`
}),
S !== void 0 && /* @__PURE__ */ K("div", {
className: "bn-snapshot-secondary-label",
children: S
})
]
})]
});
}, xo = (e) => {
let t = s(), { exitPreview: n, previewSnapshot: r, previewCurrentVersion: i, create: a, canCreate: c } = o(V), l = w(V, { selector: (e) => e.previewedSnapshotId }), u = w(V, { selector: (e) => e.snapshots }), { comparisonEnabled: d, comparisonMode: f, setComparisonMode: p } = vo();
return /* @__PURE__ */ q("div", {
className: "bn-versioning-sidebar-header",
children: [/* @__PURE__ */ q("div", {
className: "bn-versioning-sidebar-header-title",
children: [/* @__PURE__ */ K("h2", {
className: "bn-versioning-sidebar-title",
children: "History"
}), /* @__PURE__ */ q(t.Generic.Toolbar.Root, {
variant: "action-toolbar",
className: "bn-action-toolbar bn-versioning-sidebar-header-actions",
children: [c && /* @__PURE__ */ K(t.Generic.Toolbar.Button, {
mainTooltip: "Save current version",
onClick: () => {
let e = window.prompt("Name this version (optional):");
e !== null && a?.({ name: e.trim() || void 0 });
},
children: /* @__PURE__ */ K(Rn, { size: 16 })
}), d && /* @__PURE__ */ K(t.Generic.Toolbar.Button, {
mainTooltip: f ? "Turn off comparison" : "Turn on comparison",
isSelected: f,
onClick: () => {
let e = f;
p((e) => !e);
let t = l !== void 0 && l !== L;
if (e) {
t ? r(l) : l === L && n();
return;
}
if (t) {
let e = u.findIndex((e) => e.id === l), t = e >= 0 ? u[e + 1] : void 0;
r(l, { compareTo: t?.id });
} else {
let e = u.find((e) => e.id !== L);
i && e && i({ compareTo: e.id });
}
},
children: /* @__PURE__ */ K(Vn, { size: 16 })
})]
})]
}), e.onClose && /* @__PURE__ */ K(t.Generic.Toolbar.Root, {
variant: "action-toolbar",
className: "bn-action-toolbar bn-versioning-sidebar-header-actions",
children: /* @__PURE__ */ K(t.Generic.Toolbar.Button, {
mainTooltip: "Close",
onClick: () => {
n(), e.onClose?.();
},
children: /* @__PURE__ */ K(Xt, { size: 16 })
})
})]
});
}, So = (e) => {
let t = s(), { list: n } = o(V), { snapshots: r } = w(V), { activeTab: i, setActiveTab: a, showTabs: c } = vo();
return j(() => {
n();
}, [n]), /* @__PURE__ */ q(t.Versioning.Sidebar, {
className: "bn-versioning-sidebar",
children: [
/* @__PURE__ */ K(xo, { onClose: e.onClose }),
c && /* @__PURE__ */ q("div", {
className: "bn-versioning-sidebar-tabs",
role: "tablist",
children: [/* @__PURE__ */ K("button", {
type: "button",
role: "tab",
className: "bn-versioning-sidebar-tab",
"aria-selected": i === "history",
onClick: () => a("history"),
children: "Version History"
}), /* @__PURE__ */ K("button", {
type: "button",
role: "tab",
className: "bn-versioning-sidebar-tab",
"aria-selected": i === "named",
onClick: () => a("named"),
children: "Named Versions"
})]
}),
r.filter((e) => e.id === L || i !== "named" || typeof e.id == "string" && !e.id.startsWith("history-") && e.name !== void 0).map((e, t, n) => e.id === L ? /* @__PURE__ */ K(yo, {
snapshot: e,
previousSnapshot: n[t + 1]
}, "current-version") : /* @__PURE__ */ K(bo, {
snapshot: e,
previousSnapshot: n[t + 1]
}, e.id))
]
});
}, Co = (e) => /* @__PURE__ */ K(_o, {
filter: e.filter,
children: /* @__PURE__ */ K(So, { onClose: e.onClose })
});
//#endregion
//#region src/hooks/useActiveStyles.ts
function wo(e) {
let n = t();
if (e ||= n?.editor, !e) throw Error("'editor' is required, either from BlockNoteContext or as a function argument");
return S({
editor: e,
selector: ({ editor: e }) => e.getActiveStyles()
});
}
//#endregion
//#region src/hooks/useAutoFocus.ts
function To(e) {
let t = N(null);
return j(() => {
e && t.current?.focus({ preventScroll: !0 });
}, [e]), t;
}
//#endregion
//#region src/hooks/useEditorSelectionBoundingBox.ts
function Eo(e, t) {
return S({
editor: t,
selector: ({ editor: t }) => e ? t.getSelectionBoundingBox() : void 0
});
}
//#endregion
//#region src/hooks/useFocusWithin.ts
function Do(e) {
return e.currentTarget instanceof HTMLElement && e.relatedTarget instanceof HTMLElement && e.currentTarget.contains(e.relatedTarget);
}
function Oo({ onBlur: e, onFocus: t } = {}) {
let n = N(null), [r, i] = P(!1), a = N(!1), o = (e) => {
i(e), a.current = e;
}, s = k((e) => {
a.current || (o(!0), t?.(e));
}, [t]), c = k((t) => {
a.current && !Do(t) && (o(!1), e?.(t));
}, [e]);
return j(() => {
let e = n.current;
if (e) return e.addEventListener("focusin", s), e.addEventListener("focusout", c), () => {
e?.removeEventListener("focusin", s), e?.removeEventListener("focusout", c);
};
}, [s, c]), {
ref: n,
focused: r
};
}
//#endregion
//#region src/hooks/useSelectedBlocks.ts
function ko(e) {
return S({
editor: e,
selector: ({ editor: e }) => e.getSelection()?.blocks || [e.getTextCursorPosition().block]
});
}
//#endregion
//#region src/schema/ReactInlineContentSpec.tsx
function Ao(e) {
return /* @__PURE__ */ K(mt, {
as: "span",
className: "bn-inline-content-section",
"data-inline-content-type": e.inlineContentType,
...Object.fromEntries(Object.entries(e.inlineContentProps).filter(([t, n]) => n !== e.propSchema[t].default).map(([e, t]) => [Ne(e), t])),
children: e.children
});
}
function jo(e, t, n) {
let r = ut.create({
name: e.type,
inline: !0,
group: "inline",
selectable: e.content !== "none",
atom: e.content === "none",
draggable: t.meta?.draggable,
code: t.meta?.code,
content: e.content === "styled" ? "inline*" : e.content === "plain" ? "text*" : "",
marks() {
return e.content === "plain" ? ot(this.editor) : void 0;
},
addAttributes() {
return st(e.propSchema);
},
addKeyboardShortcuts() {
return Ae(e);
},
parseHTML() {
return qe(e, t.parse, t.parseContent);
},
renderHTML({ node: n }) {
let r = this.options.editor, i = at(n, r.schema.inlineContentSchema, r.schema.styleSchema), a = t.toExternalHTML || t.render, o = $((e) => /* @__PURE__ */ K(a, {
contentRef: (t) => {
e(t), t && (t.dataset.editable = "");
},
inlineContent: i,
updateInlineContent: () => {},
editor: r,
node: n,
getPos: () => void 0
}), r);
return ke(o, e.type, n.attrs, e.propSchema);
},
addNodeView() {
let n = this.options.editor;
return (r) => _t((r) => {
let i = vt().nodeViewContentRef;
if (!i) throw Error("nodeViewContentRef is not set");
let a = t.render;
return /* @__PURE__ */ K(Ao, {
inlineContentProps: r.node.attrs,
inlineContentType: e.type,
propSchema: e.propSchema,
children: /* @__PURE__ */ K(a, {
contentRef: (e) => {
i(e), e && (e.dataset.editable = "");
},
editor: n,
node: r.node,
getPos: r.getPos,
inlineContent: at(r.node, n.schema.inlineContentSchema, n.schema.styleSchema),
updateInlineContent: (e) => {
let t = $e([e], n.pmSchema), i = r.getPos();
i !== void 0 && n.transact((e) => e.replaceWith(i, i + r.node.nodeSize, t));
}
})
});
}, {
className: "bn-ic-react-node-view-renderer",
as: "span"
})(r);
}
});
return Le(e, {
...t,
node: r,
render(n, r, i) {
let a = t.render, o = $e([n], i.pmSchema)[0];
return $((t) => /* @__PURE__ */ K(Ao, {
inlineContentProps: n.props,
inlineContentType: e.type,
propSchema: e.propSchema,
children: /* @__PURE__ */ K(a, {
contentRef: (e) => {
t(e), e && (e.dataset.editable = "");
},
editor: i,
inlineContent: n,
updateInlineContent: r,
node: o,
getPos: () => void 0
})
}), i);
},
toExternalHTML(n, r) {
let i = t.toExternalHTML || t.render, a = $e([n], r.pmSchema)[0];
return $((t) => /* @__PURE__ */ K(Ao, {
inlineContentProps: n.props,
inlineContentType: e.type,
propSchema: e.propSchema,
children: /* @__PURE__ */ K(i, {
contentRef: (e) => {
t(e), e && (e.dataset.editable = "");
},
editor: r,
inlineContent: n,
updateInlineContent: () => {},
node: a,
getPos: () => void 0
})
}), r);
}
}, n);
}
//#endregion
//#region src/schema/ReactStyleSpec.tsx
function Mo(e, t) {
let n = pt.create({
name: e.type,
addAttributes() {
return ct(e.propSchema);
},
parseHTML() {
return Ze(e);
},
renderHTML({ mark: n }) {
let r = t.render, i = $((t) => /* @__PURE__ */ K(r, {
editor: this.options.editor,
value: e.propSchema === "boolean" ? void 0 : n.attrs.stringValue,
contentRef: (e) => {
t(e), e && (e.dataset.editable = "");
}
}), this.options.editor);
return je(i, e.type, n.attrs.stringValue, e.propSchema);
},
addMarkView() {
let n = this.options.editor;
return (r) => {
let i = gt((r) => {
let i = A(ht).markViewContentRef;
if (!i) throw Error("markViewContentRef is not set");
let a = t.render;
return /* @__PURE__ */ K(a, {
editor: n,
contentRef: (e) => {
i(e), e && (e.dataset.markViewContent = "");
},
value: e.propSchema === "boolean" ? void 0 : r.mark.attrs.stringValue
});
})(r);
return i.didMountContentDomElement = !0, i;
};
}
});
return Re(e, {
...t,
mark: n,
render(n, r) {
let i = t.render, a = $((e) => /* @__PURE__ */ K(i, {
editor: r,
value: n,
contentRef: (t) => {
e(t), t && (t.dataset.editable = "");
}
}), r);
return je(a, e.type, n, e.propSchema);
},
toExternalHTML(n, r) {
let i = t.render, a = $((e) => /* @__PURE__ */ K(i, {
editor: r,
value: n,
contentRef: (t) => {
e(t), t && (t.dataset.editable = "");
}
}), r);
return je(a, e.type, n, e.propSchema);
}
});
}
//#endregion
//#region src/util/elementOverflow.ts
function No(e, t) {
let n = e.getBoundingClientRect(), r = t.getBoundingClientRect(), i = n.top < r.top, a = n.bottom > r.bottom;
return i && a ? "both" : i ? "top" : a ? "bottom" : "none";
}
//#endregion
//#region src/util/mergeRefs.ts
function Po(e) {
return (t) => {
e.forEach((e) => {
typeof e == "function" ? e(t) : e != null && (e.current = t);
});
};
}
function Fo(e) {
return M(() => Po(e), e);
}
//#endregion
//#region src/util/mouseDownFocus.ts
function Io(e) {
if (rt()) {
e.preventDefault();
return;
}
et() && e.currentTarget.focus();
}
//#endregion
export { Hr as AddBlockButton, Di as AddButton, pr as AddCommentButton, fr as AddCommentButtonInner, oa as AddFileButton, mr as AddTiptapCommentButton, ri as AttributionTooltip, ii as AttributionTooltipController, fa as AudioBlock, ua as AudioPreview, da as AudioToExternalHTML, Gn as BasicTextStyleButton, qr as BlockColorsItem, $i as BlockContentWrapper, r as BlockNoteContext, Li as BlockNoteDefaultUI, Xi as BlockNoteViewEditor, Yi as BlockNoteViewRaw, Ct as BlockPopover, dr as BlockTypeSelect, Ci as ColorPickerButton, Qn as ColorStyleButton, Za as Comment, Qa as Comments, y as ComponentsContext, rr as CreateLinkButton, Oi as DeleteButton, Ir as DeleteLinkButton, Tr as DesktopFormattingToolbarController, Qr as DragHandleButton, Zr as DragHandleMenu, Lr as EditLinkButton, tr as EditLinkMenuItems, wt as EmbedTab, Si as ExtendButton, na as FigureWithCaption, ca as FileBlockWrapper, ir as FileCaptionButton, ar as FileDeleteButton, gr as FileDownloadButton, sa as FileNameWithIcon, Et as FilePanel, Dt as FilePanelController, _r as FilePreviewButton, or as FileRenameButton, sr as FileReplaceButton, eo as FloatingComposer, no as FloatingComposerController, so as FloatingThreadController, Cr as FormattingToolbar, Fr as FormattingToolbarController, p as GenericPopover, fi as GridSuggestionMenuController, di as GridSuggestionMenuWrapper, va as ImageBlock, ga as ImagePreview, _a as ImageToExternalHTML, Ao as InlineContentWrapper, zr as LinkToolbar, Br as LinkToolbarController, la as LinkWithCaption, Nr as MobileFormattingToolbarController, cr as NestBlockButton, Rr as OpenLinkButton, l as PortalElementOverride, a as PositionPopover, wa as PreviewPlaceholder, pa as ReactAudioBlock, ma as ReactFileBlock, ya as ReactImageBlock, Na as ReactVideoBlock, Jr as RemoveBlockItem, ha as ResizableFileBlockWrapper, $n as ScreenReaderOnlySubmit, $r as SideMenu, ti as SideMenuController, Da as SourceBlockWithPreview, ka as SourceInlineContentWithPreview, Ta as SourceWithPreview, wi as SplitButton, bi as SuggestionMenuController, _i as SuggestionMenuWrapper, Ei as TableCellButton, Ti as TableCellMenu, yr as TableCellMergeButton, Xr as TableColumnHeaderItem, Ni as TableHandle, Mi as TableHandleMenu, Pi as TableHandlesController, Yr as TableRowHeaderItem, xr as TextAlignButton, io as Thread, fo as ThreadsSidebar, Fa as ToggleWrapper, Kn as UIModeContext, lr as UnnestBlockButton, Tt as UploadTab, Co as VersioningSidebar, Ma as VideoBlock, Aa as VideoPreview, ja as VideoToExternalHTML, ur as blockTypeSelectItems, ea as createReactBlockSpec, jo as createReactInlineContentSpec, Mo as createReactStyleSpec, ni as defaultFormatChangeLabel, No as elementOverflow, ai as getDefaultReactEmojiPickerItems, yi as getDefaultReactSlashMenuItems, Sr as getFormattingToolbarItems, x as getMountedBoundingClientRectCache, Sa as getPageBreakReactSlashMenuItems, uo as getReferenceText, Po as mergeRefs, Io as preventFocusOnTap, n as shallow, wo as useActiveStyles, To as useAutoFocus, t as useBlockNoteContext, C as useBlockNoteEditor, ci as useCloseSuggestionMenuNoItems, s as useComponentsContext, f as useCreateBlockNote, g as useDictionary, Bi as useEditorChange, i as useEditorDOMElement, Er as useEditorFocus, Eo as useEditorSelectionBoundingBox, Vi as useEditorSelectionChange, S as useEditorState, La as useExtendButtonsPositioning, o as useExtension, w as useExtensionState, Oo as useFocusWithin, ui as useGridSuggestionMenuKeyboardNavigation, li as useLoadSuggestionMenuItems, Fo as useMergeRefs, Qi as useNodeViewBlock, ra as useOnUploadEnd, ia as useOnUploadStart, m as usePortalElement, Hi as usePrefersColorScheme, ta as useResolveUrl, ko as useSelectedBlocks, mo as useSnapshotLabel, Ea as useSourceBlockPreviewPopup, Oa as useSourceInlineContentPreviewPopup, e as useStore, mi as useSuggestionMenuKeyboardHandler, gi as useSuggestionMenuKeyboardNavigation, Ha as useTableHandlesPositioning, ao as useThreads, qn as useUIMode, aa as useUploadLoading, po as useVersionUsers, Mr as useVirtualKeyboard };
//# sourceMappingURL=blocknote-react.js.map