@blocknote/react
Version:
A "Notion-style" block-based extensible text editor built on top of Prosemirror and Tiptap.
5,470 lines • 176 kB
JavaScript
import { _ as e, a as t, c as n, d as r, f as i, g as a, h as o, i as s, l as c, m as l, n as u, o as d, p as f, r as p, s as m, t as h, u as g, v as _, y as v } from "./confirmDiscardUnsavedComment-D1Q3ha7c.js";
import y, { Suspense as b, createContext as x, forwardRef as S, lazy as C, memo as w, useCallback as T, useContext as E, useEffect as D, useId as ee, useImperativeHandle as O, useMemo as k, useReducer as te, useRef as A, useState as j, useSyncExternalStore as M } from "react";
import { CommentsExtension as N } from "@blocknote/core/comments";
import { CURRENT_VERSION_ID as P, DEFAULT_LINK_PROTOCOL as ne, FilePanelExtension as F, FormattingToolbarExtension as I, LinkToolbarExtension as re, ShowSelectionExtension as ie, SideMenuExtension as L, SuggestionMenu as R, TableHandlesExtension as z, VALID_LINK_PROTOCOLS as ae, VersioningExtension as B, filterSuggestionItems as oe, getDefaultEmojiPickerItems as se, getDefaultSlashMenuItems as ce } from "@blocknote/core/extensions";
import { autoPlacement as le, autoUpdate as ue, flip as V, inline as de, offset as H, safePolygon as fe, shift as U, size as W, useFloating as pe, useTransitionStyles as me } from "@floating-ui/react";
import { EMPTY_CELL_HEIGHT as he, EMPTY_CELL_WIDTH as ge, SourceBlockWithPreviewExtension as _e, SourceInlineContentWithPreviewExtension as ve, UnreachableCaseError as ye, addInlineContentAttributes as be, addInlineContentKeyboardShortcuts as xe, addStyleAttributes as Se, audioParse as Ce, blockHasType as G, camelToDataKebab as we, createAudioBlockConfig as Te, createFileBlockConfig as Ee, createImageBlockConfig as De, createInternalInlineContentSpec as Oe, createInternalStyleSpec as ke, createVideoBlockConfig as Ae, defaultProps as je, defaultToggledState as Me, editorHasBlockWithType as K, fileParse as Ne, filenameFromURL as Pe, formatKeyboardShortcut as Fe, getBlockFromPos as Ie, getColspan as Le, getInlineContentParseRules as Re, getNodeById as ze, getPageBreakSlashMenuItems as Be, getRowspan as Ve, getStyleParseRules as He, imageParse as Ue, inlineContentToNodes as We, isTableCell as Ge, isTableCellSelection as Ke, mapTableCell as qe, mergeCSSClasses as q, nodeToCustomInlineContent as Je, nonFormattingMarks as Ye, propsToAttributes as Xe, stylePropsToAttributes as Ze, videoParse as Qe } from "@blocknote/core";
import { Fragment as J, jsx as Y, jsxs as X } from "react/jsx-runtime";
import { Node as $e } from "@tiptap/core";
import { createPortal as et, flushSync as tt } from "react-dom";
import { Mark as nt, NodeViewWrapper as rt, ReactMarkViewContext as it, ReactMarkViewRenderer as at, ReactNodeViewRenderer as ot, useReactNodeView as st } from "@tiptap/react";
import { createRoot as ct } from "react-dom/client";
import { TextSelection as lt } from "@tiptap/pm/state";
//#region \0rolldown/runtime.js
var ut = Object.defineProperty, dt = (e, t) => {
let n = {};
for (var r in e) ut(n, r, {
get: e[r],
enumerable: !0
});
return t || ut(n, Symbol.toStringTag, { value: "Module" }), n;
}, ft = (t) => {
let { blockId: n, children: i, portalElement: a, ...o } = t, s = e(), c = k(() => s.transact((e) => {
if (!n) return;
let t = ze(n, e.doc);
if (!t) return;
let { node: r } = s.prosemirrorView.domAtPos(t.posBeforeNode + 1);
if (r instanceof Element) return { element: r };
}), [s, n]);
return /* @__PURE__ */ Y(r, {
reference: c,
portalElement: a,
...o,
children: n !== void 0 && i
});
}, pt = (t) => {
let r = g(), i = n(), a = e(), o = a.getBlock(t.blockId), [s, c] = j(""), l = T((e) => {
c(e.currentTarget.value);
}, []), u = T((e) => {
if (e.key === "Enter" && !e.nativeEvent.isComposing) {
if (e.preventDefault(), !a.getBlock(t.blockId)) return;
a.updateBlock(t.blockId, { props: {
name: Pe(s),
url: s
} });
}
}, [
a,
t.blockId,
s
]), d = T(() => {
a.getBlock(t.blockId) && a.updateBlock(t.blockId, { props: {
name: Pe(s),
url: s
} });
}, [
a,
t.blockId,
s
]);
return o ? /* @__PURE__ */ X(r.FilePanel.TabPanel, {
className: "bn-tab-panel",
children: [/* @__PURE__ */ Y(r.FilePanel.TextInput, {
className: "bn-text-input",
placeholder: i.file_panel.embed.url_placeholder,
value: s,
onChange: l,
onKeyDown: u,
"data-test": "embed-input"
}), /* @__PURE__ */ Y(r.FilePanel.Button, {
className: "bn-button",
onClick: d,
"data-test": "embed-input-button",
children: i.file_panel.embed.embed_button[o.type] || i.file_panel.embed.embed_button.file
})]
}) : null;
}, mt = (t) => {
let r = g(), i = n(), { setLoading: a } = t, o = e(), s = o.getBlock(t.blockId), [c, l] = j(!1);
D(() => {
c && setTimeout(() => {
l(!1);
}, 3e3);
}, [c]);
let u = T((e) => {
if (e === null) return;
async function n(e) {
if (a(!0), o.uploadFile !== void 0) try {
let n = await o.uploadFile(e, t.blockId);
if (!o.getBlock(t.blockId)) return;
typeof n == "string" && (n = { props: {
name: e.name,
url: n
} }), o.updateBlock(t.blockId, n);
} catch {
l(!0);
} finally {
a(!1);
}
}
n(e);
}, [
t.blockId,
o,
a
]);
if (!s) return null;
let d = o.schema.blockSpecs[s.type], f = d.implementation.meta?.fileBlockAccept?.length ? d.implementation.meta.fileBlockAccept.join(",") : "*/*";
return /* @__PURE__ */ X(r.FilePanel.TabPanel, {
className: "bn-tab-panel",
children: [/* @__PURE__ */ Y(r.FilePanel.FileInput, {
className: "bn-file-input",
"data-test": "upload-input",
accept: f,
placeholder: i.file_panel.upload.file_placeholder[s.type] || i.file_panel.upload.file_placeholder.file,
value: null,
onChange: u
}), c && /* @__PURE__ */ Y("div", {
className: "bn-error-text",
children: i.file_panel.upload.upload_error
})]
});
}, ht = (t) => {
let r = g(), i = n(), a = e(), [o, s] = j(!1), c = t.tabs ?? [...a.uploadFile === void 0 ? [] : [{
name: i.file_panel.upload.title,
tabPanel: /* @__PURE__ */ Y(mt, {
blockId: t.blockId,
setLoading: s
})
}], {
name: i.file_panel.embed.title,
tabPanel: /* @__PURE__ */ Y(pt, { blockId: t.blockId })
}], [l, u] = j(t.defaultOpenTab || c[0].name);
return /* @__PURE__ */ Y(r.FilePanel.Root, {
className: "bn-panel",
defaultOpenTab: l,
openTab: l,
setOpenTab: u,
tabs: c,
loading: o
});
}, gt = (t) => {
let n = e(), r = f(F), i = l(F), a = k(() => ({
...t.floatingUIOptions,
useFloatingOptions: {
open: !!i,
onOpenChange: (e, t, i) => {
e || r.closeMenu(), i === "escape-key" && n.focus();
},
middleware: [H(10), V()],
...t.floatingUIOptions?.useFloatingOptions
},
focusManagerProps: {
disabled: !0,
...t.floatingUIOptions?.focusManagerProps
},
elementProps: {
style: { zIndex: 90 },
...t.floatingUIOptions?.elementProps
}
}), [
i,
n,
r,
t.floatingUIOptions
]), o = t.filePanel || ht;
return /* @__PURE__ */ Y(ft, {
blockId: i,
portalElement: t.portalElement,
...a,
children: i && /* @__PURE__ */ Y(o, { blockId: i })
});
}, _t = {
color: void 0,
size: void 0,
className: void 0,
style: void 0,
attr: void 0
}, vt = y.createContext && /*#__PURE__*/ y.createContext(_t), yt = [
"attr",
"size",
"title"
];
function bt(e, t) {
if (e == null) return {};
var n, r, i = xt(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 xt(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 St() {
return St = 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;
}, St.apply(null, arguments);
}
function Ct(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 wt(e) {
for (var t = 1; t < arguments.length; t++) {
var n = arguments[t] == null ? {} : arguments[t];
t % 2 ? Ct(Object(n), !0).forEach(function(t) {
Tt(e, t, n[t]);
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(n)) : Ct(Object(n)).forEach(function(t) {
Object.defineProperty(e, t, Object.getOwnPropertyDescriptor(n, t));
});
}
return e;
}
function Tt(e, t, n) {
return (t = Et(t)) in e ? Object.defineProperty(e, t, {
value: n,
enumerable: !0,
configurable: !0,
writable: !0
}) : e[t] = n, e;
}
function Et(e) {
var t = Dt(e, "string");
return typeof t == "symbol" ? t : t + "";
}
function Dt(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 Ot(e) {
return e && e.map((e, t) => /*#__PURE__*/ y.createElement(e.tag, wt({ key: t }, e.attr), Ot(e.child)));
}
function Z(e) {
return (t) => /*#__PURE__*/ y.createElement(kt, St({ attr: wt({}, e.attr) }, t), Ot(e.child));
}
function kt(e) {
var t = (t) => {
var { attr: n, size: r, title: i } = e, a = bt(e, yt), o = r || t.size || "1em", s;
return t.className && (s = t.className), e.className && (s = (s ? s + " " : "") + e.className), /*#__PURE__*/ y.createElement("svg", St({
stroke: "currentColor",
fill: "currentColor",
strokeWidth: "0"
}, t.attr, n, a, {
className: s,
style: wt(wt({ color: e.color || t.color }, t.style), e.style),
height: o,
width: o,
xmlns: "http://www.w3.org/2000/svg"
}), i && /*#__PURE__*/ y.createElement("title", null, i), e.children);
};
return vt === void 0 ? t(_t) : /*#__PURE__*/ y.createElement(vt.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 At(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 jt(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 Mt(e) {
return Z({
tag: "svg",
attr: {
viewBox: "0 0 24 24",
fill: "currentColor"
},
child: [{
tag: "path",
attr: { d: "M5 11V13H19V11H5Z" },
child: []
}]
})(e);
}
function Nt(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 Pt(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 Ft(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 It(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 Lt(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 Rt(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 zt(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 Bt(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 Vt(e) {
return Z({
tag: "svg",
attr: {
viewBox: "0 0 24 24",
fill: "currentColor"
},
child: [{
tag: "path",
attr: { d: "M11 11V5H13V11H19V13H13V19H11V13H5V11H11Z" },
child: []
}]
})(e);
}
function Ht(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 Ut(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 Wt(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 Gt(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 Kt(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 qt(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 Jt(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 Yt(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 Xt(e) {
return Z({
tag: "svg",
attr: {
viewBox: "0 0 24 24",
fill: "currentColor"
},
child: [{
tag: "path",
attr: { d: "M13 6V21H11V6H5V4H19V6H13Z" },
child: []
}]
})(e);
}
function Zt(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 Qt(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 $t(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 en(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 tn(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 nn(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 rn(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 an(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 on(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 sn(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 cn(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 ln(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 un(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 dn(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 fn(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 pn(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 mn(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 hn(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 gn(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 _n(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 vn(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 yn(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 bn(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 xn(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 Sn(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 Cn(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 wn(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 Tn(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 En(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 Dn(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 On(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 kn(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 An(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 jn(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 Mn = {
bold: bn,
italic: cn,
underline: Yt,
strike: Qt,
code: Tn
};
function Nn(e, t) {
return e in t.schema.styleSchema && t.schema.styleSchema[e].type === e && t.schema.styleSchema[e].propSchema === "boolean";
}
var Pn = (t) => {
let r = n(), i = g(), a = e(), o = m({
editor: a,
selector: ({ editor: e }) => {
if (!(!e.isEditable || !Nn(t.basicTextStyle, e) || !(e.getSelection()?.blocks || [e.getTextCursorPosition().block]).find((e) => e.content !== void 0))) return t.basicTextStyle in e.getActiveStyles() ? { active: !0 } : { active: !1 };
}
}), s = T((e) => {
a.focus(), a.toggleStyles({ [e]: !0 });
}, [a]);
if (o === void 0) return null;
let c = Mn[t.basicTextStyle];
return /* @__PURE__ */ Y(i.FormattingToolbar.Button, {
className: "bn-button",
"data-test": t.basicTextStyle,
onClick: () => s(t.basicTextStyle),
isSelected: o.active,
label: r.formatting_toolbar[t.basicTextStyle].tooltip,
mainTooltip: r.formatting_toolbar[t.basicTextStyle].tooltip,
secondaryTooltip: Fe(r.formatting_toolbar[t.basicTextStyle].secondary_tooltip, r.generic.ctrl_shortcut),
icon: /* @__PURE__ */ Y(c, {})
});
}, Fn = (e) => {
let t = e.textColor || "default", n = e.backgroundColor || "default", r = e.size || 16, i = k(() => ({
pointerEvents: "none",
fontSize: (r * .75).toString() + "px",
height: r.toString() + "px",
lineHeight: r.toString() + "px",
textAlign: "center",
width: r.toString() + "px"
}), [r]);
return /* @__PURE__ */ Y("div", {
className: "bn-color-icon",
"data-background-color": n,
"data-text-color": t,
style: i,
children: "A"
});
}, In = [
"default",
"gray",
"brown",
"red",
"orange",
"yellow",
"green",
"blue",
"purple",
"pink"
], Ln = (e) => {
let t = g(), r = n();
return /* @__PURE__ */ X(J, { children: [/* @__PURE__ */ Y(() => e.text ? /* @__PURE__ */ X(J, { children: [/* @__PURE__ */ Y(t.Generic.Menu.Label, { children: r.color_picker.text_title }), In.map((n) => /* @__PURE__ */ Y(t.Generic.Menu.Item, {
onClick: () => {
e.onClick?.(), e.text.setColor(n);
},
"data-test": "text-color-" + n,
icon: /* @__PURE__ */ Y(Fn, {
textColor: n,
size: e.iconSize
}),
checked: e.text.color === n,
children: r.color_picker.colors[n]
}, "text-color-" + n))] }) : null, {}), /* @__PURE__ */ Y(() => e.background ? /* @__PURE__ */ X(J, { children: [/* @__PURE__ */ Y(t.Generic.Menu.Label, { children: r.color_picker.background_title }), In.map((n) => /* @__PURE__ */ Y(t.Generic.Menu.Item, {
onClick: () => {
e.onClick?.(), e.background.setColor(n);
},
"data-test": "background-color-" + n,
icon: /* @__PURE__ */ Y(Fn, {
backgroundColor: n,
size: e.iconSize
}),
checked: e.background.color === n,
children: r.color_picker.colors[n]
}, "background-color-" + n))] }) : null, {})] });
};
//#endregion
//#region src/components/FormattingToolbar/DefaultButtons/ColorStyleButton.tsx
function Rn(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 zn = () => {
let t = g(), r = n(), i = e(), a = Rn("text", i), o = Rn("background", i), s = m({
editor: i,
selector: ({ editor: e }) => {
if (!e.isEditable || !(e.getSelection()?.blocks || [e.getTextCursorPosition().block]).find((e) => e.content !== void 0)) return;
let t = Rn("text", e), n = Rn("background", e);
if (!(!t && !n)) return {
textColor: t ? e.getActiveStyles().textColor || "default" : void 0,
backgroundColor: n ? e.getActiveStyles().backgroundColor || "default" : void 0
};
}
}), c = T((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 }), setTimeout(() => {
i.focus();
});
}, [i, a]), l = T((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 }), setTimeout(() => {
i.focus();
});
}, [o, i]);
return s === void 0 ? null : /* @__PURE__ */ X(t.Generic.Menu.Root, { children: [/* @__PURE__ */ Y(t.Generic.Menu.Trigger, { children: /* @__PURE__ */ Y(t.FormattingToolbar.Button, {
className: "bn-button",
"data-test": "colors",
label: r.formatting_toolbar.colors.tooltip,
mainTooltip: r.formatting_toolbar.colors.tooltip,
icon: /* @__PURE__ */ Y(Fn, {
textColor: s.textColor,
backgroundColor: s.backgroundColor,
size: 20
})
}) }), /* @__PURE__ */ Y(t.Generic.Menu.Dropdown, {
className: "bn-menu-dropdown bn-color-picker-dropdown",
children: /* @__PURE__ */ Y(Ln, {
text: s.textColor ? {
color: s.textColor,
setColor: c
} : void 0,
background: s.backgroundColor ? {
color: s.backgroundColor,
setColor: l
} : void 0
})
})] });
}, Bn = (e) => {
for (let t of ae) if (e.startsWith(t)) return e;
return `${ne}://${e}`;
}, Vn = (e) => {
let t = g(), r = n(), { editLink: i } = f(re), { url: a, text: o, showTextField: s } = e, [c, l] = j(a), [u, d] = j(o);
D(() => {
l(a), d(o);
}, [o, a]);
let p = T((t) => {
t.key === "Enter" && !t.nativeEvent.isComposing && (t.preventDefault(), i(Bn(c), u, e.range.from), e.setToolbarOpen?.(!1), e.setToolbarPositionFrozen?.(!1));
}, [
i,
c,
u,
e
]), m = T((e) => l(e.currentTarget.value), []), h = T((e) => d(e.currentTarget.value), []), _ = T(() => {
i(Bn(c), u, e.range.from), e.setToolbarOpen?.(!1), e.setToolbarPositionFrozen?.(!1);
}, [
i,
c,
u,
e
]);
return /* @__PURE__ */ X(t.Generic.Form.Root, { children: [/* @__PURE__ */ Y(t.Generic.Form.TextInput, {
className: "bn-text-input",
name: "url",
icon: /* @__PURE__ */ Y(on, {}),
autoFocus: !0,
placeholder: r.link_toolbar.form.url_placeholder,
value: c,
onKeyDown: p,
onChange: m,
onSubmit: _
}), s !== !1 && /* @__PURE__ */ Y(t.Generic.Form.TextInput, {
className: "bn-text-input",
name: "title",
icon: /* @__PURE__ */ Y(Xt, {}),
placeholder: r.link_toolbar.form.title_placeholder,
value: u,
onKeyDown: p,
onChange: h,
onSubmit: _
})] });
};
//#endregion
//#region src/components/FormattingToolbar/DefaultButtons/CreateLinkButton.tsx
function Hn(e) {
return "link" in e.schema.inlineContentSchema && e.schema.inlineContentSchema.link === "link";
}
var Un = () => {
let t = e(), r = d(), i = g(), a = n(), o = f(I), { showSelection: s } = f(ie), [c, l] = j(!1);
D(() => (s(c, "createLinkButton"), () => s(!1, "createLinkButton")), [c, s]);
let u = m({
editor: t,
selector: ({ editor: e }) => {
if (!(!e.isEditable || !Hn(e) || Ke(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 D(() => {
l(!1);
}, [u]), D(() => {
let e = (e) => {
(e.ctrlKey || e.metaKey) && e.key === "k" && (l(!0), e.preventDefault());
};
return r?.addEventListener("keydown", e), () => {
r?.removeEventListener("keydown", e);
};
}, [r]), u === void 0 ? null : /* @__PURE__ */ X(i.Generic.Popover.Root, {
open: c,
onOpenChange: l,
children: [/* @__PURE__ */ Y(i.Generic.Popover.Trigger, { children: /* @__PURE__ */ Y(i.FormattingToolbar.Button, {
className: "bn-button",
"data-test": "createLink",
label: a.formatting_toolbar.link.tooltip,
mainTooltip: a.formatting_toolbar.link.tooltip,
secondaryTooltip: Fe(a.formatting_toolbar.link.secondary_tooltip, a.generic.ctrl_shortcut),
icon: /* @__PURE__ */ Y(on, {}),
onClick: () => l((e) => !e)
}) }), /* @__PURE__ */ Y(i.Generic.Popover.Content, {
className: "bn-popover-content bn-form-popover",
variant: "form-popover",
children: /* @__PURE__ */ Y(Vn, {
url: u.url || "",
text: u.text,
range: u.range,
showTextField: !1,
setToolbarOpen: (e) => o.store.setState(e)
})
})]
});
}, Wn = () => {
let t = n(), r = g(), i = e(), a = m({
editor: i,
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 (G(n, e, n.type, {
url: "string",
caption: "string"
})) return n;
}
}), [o, s] = j(!1), c = T((e) => {
a !== void 0 && K(i, a.type, { caption: "string" }) && i.updateBlock(a.id, { props: { caption: e.currentTarget.value } });
}, [a, i]), l = T((e) => {
e.key === "Enter" && !e.nativeEvent.isComposing && (e.preventDefault(), s(!1));
}, []);
return a === void 0 ? null : /* @__PURE__ */ X(r.Generic.Popover.Root, {
open: o,
onOpenChange: s,
children: [/* @__PURE__ */ Y(r.Generic.Popover.Trigger, { children: /* @__PURE__ */ Y(r.FormattingToolbar.Button, {
className: "bn-button",
label: t.formatting_toolbar.file_caption.tooltip,
mainTooltip: t.formatting_toolbar.file_caption.tooltip,
icon: /* @__PURE__ */ Y(ln, {}),
onClick: () => s((e) => !e)
}) }), /* @__PURE__ */ Y(r.Generic.Popover.Content, {
className: "bn-popover-content bn-form-popover",
variant: "form-popover",
children: /* @__PURE__ */ Y(r.Generic.Form.Root, { children: /* @__PURE__ */ Y(r.Generic.Form.TextInput, {
name: "file-caption",
icon: /* @__PURE__ */ Y(ln, {}),
value: a.props.caption,
autoFocus: !0,
placeholder: t.formatting_toolbar.file_caption.input_placeholder,
onKeyDown: l,
onChange: c
}) })
})]
});
}, Gn = () => {
let t = n(), r = g(), i = e(), a = m({
editor: i,
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 (G(n, e, n.type, { url: "string" })) return n;
}
}), o = T(() => {
a !== void 0 && (i.focus(), i.removeBlocks([a.id]));
}, [a, i]);
return a === void 0 ? null : /* @__PURE__ */ Y(r.FormattingToolbar.Button, {
className: "bn-button",
label: t.formatting_toolbar.file_delete.tooltip[a.type] || t.formatting_toolbar.file_delete.tooltip.file,
mainTooltip: t.formatting_toolbar.file_delete.tooltip[a.type] || t.formatting_toolbar.file_delete.tooltip.file,
icon: /* @__PURE__ */ Y(Rt, {}),
onClick: o
});
}, Kn = () => {
let t = n(), r = g(), i = e(), a = m({
editor: i,
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 (G(n, e, n.type, {
url: "string",
name: "string"
})) return n;
}
}), [o, s] = j(!1), c = T((e) => {
a !== void 0 && K(i, a.type, { name: "string" }) && i.updateBlock(a.id, { props: { name: e.currentTarget.value } });
}, [a, i]), l = T((e) => {
e.key === "Enter" && !e.nativeEvent.isComposing && (e.preventDefault(), s(!1));
}, []);
return a === void 0 ? null : /* @__PURE__ */ X(r.Generic.Popover.Root, {
open: o,
onOpenChange: s,
children: [/* @__PURE__ */ Y(r.Generic.Popover.Trigger, { children: /* @__PURE__ */ Y(r.FormattingToolbar.Button, {
className: "bn-button",
label: t.formatting_toolbar.file_rename.tooltip[a.type] || t.formatting_toolbar.file_rename.tooltip.file,
mainTooltip: t.formatting_toolbar.file_rename.tooltip[a.type] || t.formatting_toolbar.file_rename.tooltip.file,
icon: /* @__PURE__ */ Y(vn, {}),
onClick: () => s((e) => !e)
}) }), /* @__PURE__ */ Y(r.Generic.Popover.Content, {
className: "bn-popover-content bn-form-popover",
variant: "form-popover",
children: /* @__PURE__ */ Y(r.Generic.Form.Root, { children: /* @__PURE__ */ Y(r.Generic.Form.TextInput, {
name: "file-name",
icon: /* @__PURE__ */ Y(vn, {}),
value: a.props.name,
autoFocus: !0,
placeholder: t.formatting_toolbar.file_rename.input_placeholder[a.type] || t.formatting_toolbar.file_rename.input_placeholder.file,
onKeyDown: l,
onChange: c
}) })
})]
});
}, qn = () => {
let t = n(), r = g(), i = e(), a = m({
editor: i,
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 (G(n, e, n.type, { url: "string" })) return n;
}
});
return a === void 0 ? null : /* @__PURE__ */ X(r.Generic.Popover.Root, {
position: "bottom",
children: [/* @__PURE__ */ Y(r.Generic.Popover.Trigger, { children: /* @__PURE__ */ Y(r.FormattingToolbar.Button, {
className: "bn-button",
mainTooltip: t.formatting_toolbar.file_replace.tooltip[a.type] || t.formatting_toolbar.file_replace.tooltip.file,
label: t.formatting_toolbar.file_replace.tooltip[a.type] || t.formatting_toolbar.file_replace.tooltip.file,
icon: /* @__PURE__ */ Y(Gt, {})
}) }), /* @__PURE__ */ Y(r.Generic.Popover.Content, {
className: "bn-popover-content bn-panel-popover",
variant: "panel-popover",
children: /* @__PURE__ */ Y(ht, { blockId: a.id })
})]
});
}, Jn = () => {
let t = n(), r = g(), i = e(), a = m({
editor: i,
selector: ({ editor: e }) => {
if (!(!e.isEditable || !(e.getSelection()?.blocks || [e.getTextCursorPosition().block]).find((e) => e.content !== void 0))) return { canNestBlock: e.canNestBlock() };
}
}), o = T(() => {
a !== void 0 && a.canNestBlock && (i.focus(), i.nestBlock());
}, [i, a]);
return a === void 0 ? null : /* @__PURE__ */ Y(r.FormattingToolbar.Button, {
className: "bn-button",
"data-test": "nestBlock",
onClick: o,
isDisabled: !a.canNestBlock,
label: t.formatting_toolbar.nest.tooltip,
mainTooltip: t.formatting_toolbar.nest.tooltip,
secondaryTooltip: Fe(t.formatting_toolbar.nest.secondary_tooltip, t.generic.ctrl_shortcut),
icon: /* @__PURE__ */ Y(un, {})
});
}, Yn = () => {
let t = n(), r = g(), i = e(), a = m({
editor: i,
selector: ({ editor: e }) => {
if (!(!e.isEditable || !(e.getSelection()?.blocks || [e.getTextCursorPosition().block]).find((e) => e.content !== void 0))) return { canUnnestBlock: e.canUnnestBlock() };
}
}), o = T(() => {
a !== void 0 && a.canUnnestBlock && (i.focus(), i.unnestBlock());
}, [i, a]);
return a === void 0 ? null : /* @__PURE__ */ Y(r.FormattingToolbar.Button, {
className: "bn-button",
"data-test": "unnestBlock",
onClick: o,
isDisabled: !a.canUnnestBlock,
label: t.formatting_toolbar.unnest.tooltip,
mainTooltip: t.formatting_toolbar.unnest.tooltip,
secondaryTooltip: Fe(t.formatting_toolbar.unnest.secondary_tooltip, t.generic.ctrl_shortcut),
icon: /* @__PURE__ */ Y(dn, {})
});
}, Xn = (e) => [
{
name: e.slash_menu.paragraph.title,
type: "paragraph",
icon: Xt
},
{
name: e.slash_menu.heading.title,
type: "heading",
props: {
level: 1,
isToggleable: !1
},
icon: _n
},
{
name: e.slash_menu.heading_2.title,
type: "heading",
props: {
level: 2,
isToggleable: !1
},
icon: gn
},
{
name: e.slash_menu.heading_3.title,
type: "heading",
props: {
level: 3,
isToggleable: !1
},
icon: hn
},
{
name: e.slash_menu.heading_4.title,
type: "heading",
props: {
level: 4,
isToggleable: !1
},
icon: mn
},
{
name: e.slash_menu.heading_5.title,
type: "heading",
props: {
level: 5,
isToggleable: !1
},
icon: pn
},
{
name: e.slash_menu.heading_6.title,
type: "heading",
props: {
level: 6,
isToggleable: !1
},
icon: fn
},
{
name: e.slash_menu.toggle_heading.title,
type: "heading",
props: {
level: 1,
isToggleable: !0
},
icon: _n
},
{
name: e.slash_menu.toggle_heading_2.title,
type: "heading",
props: {
level: 2,
isToggleable: !0
},
icon: gn
},
{
name: e.slash_menu.toggle_heading_3.title,
type: "heading",
props: {
level: 3,
isToggleable: !0
},
icon: hn
},
{
name: e.slash_menu.quote.title,
type: "quote",
icon: $t
},
{
name: e.slash_menu.toggle_list.title,
type: "toggleListItem",
icon: Wt
},
{
name: e.slash_menu.bullet_list.title,
type: "bulletListItem",
icon: nn
},
{
name: e.slash_menu.numbered_list.title,
type: "numberedListItem",
icon: rn
},
{
name: e.slash_menu.check_list.title,
type: "checkListItem",
icon: an
}
], Zn = (t) => {
let n = g(), r = e(), i = m({
editor: r,
selector: ({ editor: e }) => e.getSelection()?.blocks || [e.getTextCursorPosition().block]
}), a = i[0], o = k(() => (t.items || Xn(r.dictionary)).filter((e) => K(r, e.type, Object.fromEntries(Object.entries(e.props || {}).map(([e, t]) => [e, typeof t])))), [r, t.items]), s = k(() => o.map((e) => {
let t = e.icon, n = e.type === a.type, o = Object.entries(e.props || {}).filter(([e, t]) => t !== a.props[e]).length === 0;
return {
text: e.name,
icon: /* @__PURE__ */ Y(t, { size: 16 }),
onClick: () => {
r.focus(), r.transact(() => {
for (let t of i) r.updateBlock(t, {
type: e.type,
props: e.props
});
});
},
isSelected: n && o
};
}), [
r,
o,
a.props,
a.type,
i
]);
return !k(() => s.find((e) => e.isSelected) !== void 0, [s]) || !r.isEditable ? null : /* @__PURE__ */ Y(n.FormattingToolbar.Select, {
className: "bn-select",
items: s
});
}, Qn = () => {
let e = n(), t = g(), r = f("comments"), { store: i } = f(I), a = T(() => {
r.startPendingComment(), i.setState(!1);
}, [r, i]);
return /* @__PURE__ */ Y(t.FormattingToolbar.Button, {
className: "bn-button",
label: e.formatting_toolbar.comment.tooltip,
mainTooltip: e.formatting_toolbar.comment.tooltip,
icon: /* @__PURE__ */ Y(On, {}),
onClick: a
});
}, $n = () => e().getExtension("comments") ? /* @__PURE__ */ Y(Qn, {}) : null, er = () => {
let t = n(), r = g(), i = e(), a = T(() => {
i._tiptapEditor.chain().focus().addPendingComment().run();
}, [i]);
return !i._tiptapEditor.commands.addPendingComment || !i.isEditable ? null : /* @__PURE__ */ Y(r.FormattingToolbar.Button, {
className: "bn-button",
label: t.formatting_toolbar.comment.tooltip,
mainTooltip: t.formatting_toolbar.comment.tooltip,
icon: /* @__PURE__ */ Y(On, {}),
onClick: a
});
};
//#endregion
//#region src/util/sanitizeUrl.ts
function tr(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 nr = () => {
let t = n(), r = g(), i = e(), a = m({
editor: i,
selector: ({ editor: e }) => {
let t = e.getSelection()?.blocks || [e.getTextCursorPosition().block];
if (t.length !== 1) return;
let n = t[0];
if (G(n, e, n.type, { url: "string" })) return n;
}
}), o = T(() => {
a !== void 0 && (i.focus(), i.resolveFileUrl ? i.resolveFileUrl(a.props.url).then((e) => window.open(tr(e, window.location.href))) : window.open(tr(a.props.url, window.location.href)));
}, [a, i]);
return a === void 0 ? null : /* @__PURE__ */ Y(r.FormattingToolbar.Button, {
className: "bn-button",
label: t.formatting_toolbar.file_download.tooltip[a.type] || t.formatting_toolbar.file_download.tooltip.file,
mainTooltip: t.formatting_toolbar.file_download.tooltip[a.type] || t.formatting_toolbar.file_download.tooltip.file,
icon: /* @__PURE__ */ Y(Ft, {}),
onClick: o
});
}, rr = () => {
let t = n(), r = g(), i = e(), a = m({
editor: i,
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 (G(n, e, n.type, {
url: "string",
showPreview: "boolean"
})) return n;
}
}), o = T(() => {
a !== void 0 && K(i, a.type, { showPreview: "boolean" }) && i.updateBlock(a.id, { props: { showPreview: !a.props.showPreview } });
}, [a, i]);
return a === void 0 ? null : /* @__PURE__ */ Y(r.FormattingToolbar.Button, {
className: "bn-button",
label: "Toggle preview",
mainTooltip: t.formatting_toolbar.file_preview_toggle.tooltip,
icon: /* @__PURE__ */ Y(Kt, {}),
isSelected: a.props.showPreview,
onClick: o
});
}, ir = () => {
let t = n(), r = g(), i = e(), a = f(z), o = m({
editor: i,
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: a.getMergeDirection(n) };
}
}), s = T(() => {
a?.mergeCells();
}, [a]);
return o === void 0 ? null : /* @__PURE__ */ Y(r.FormattingToolbar.Button, {
className: "bn-button",
label: t.formatting_toolbar.table_cell_merge.tooltip,
mainTooltip: t.formatting_toolbar.table_cell_merge.tooltip,
icon: o.mergeDirection === "horizontal" ? /* @__PURE__ */ Y(tn, {}) : /* @__PURE__ */ Y(en, {}),
onClick: s
});
}, ar = () => e().getExtension(z) ? /* @__PURE__ */ Y(ir, {}) : null, or = {
left: Sn,
center: wn,
right: xn,
justify: Cn
}, sr = (t) => {
let r = g(), i = n(), a = e(), o = m({
editor: a,
selector: ({ editor: e }) => {
if (!e.isEditable) return;
let t = e.getSelection()?.blocks || [e.getTextCursorPosition().block], n = t[0];
if (G(n, e, n.type, { textAlignment: je.textAlignment })) return {
textAlignment: n.props.textAlignment,
blocks: t
};
if (t.length === 1 && G(n, e, "table")) return e.getExtension(z)?.getCellSelection() ? {
textAlignment: qe(n.content.rows[0].cells[0]).props.textAlignment,
blocks: [n]
} : void 0;
}
}), s = T((e) => {
if (o !== void 0) {
a.focus();
for (let t of o.blocks) if (G(t, a, t.type, { textAlignment: je.textAlignment }) && K(a, t.type, { textAlignment: je.textAlignment })) a.updateBlock(t, { props: { textAlignment: e } });
else if (t.type === "table") {
let n = a.getExtension(z)?.getCellSelection();
if (!n) continue;
let r = t.content.rows.map((e) => ({
...e,
cells: e.cells.map((e) => qe(e))
}));
n.cells.forEach(({ row: t, col: n }) => {
r[t].cells[n].props.textAlignment = e;
}), a.updateBlock(t, {
type: "table",
content: {
...t.content,
type: "tableContent",
rows: r
}
}), a.setTextCursorPosition(t);
}
}
}, [a, o]);
if (o === void 0) return null;
let c = or[t.textAlignment];
return /* @__PURE__ */ Y(r.FormattingToolbar.Button, {
className: "bn-button",
"data-test": `alignText${t.textAlignment.slice(0, 1).toUpperCase() + t.textAlignment.slice(1)}`,
onClick: () => s(t.textAlignment),
isSelected: o.textAlignment === t.textAlignment,
label: i.formatting_toolbar[`align_${t.textAlignment}`].tooltip,
mainTooltip: i.formatting_toolbar[`align_${t.textAlignment}`].tooltip,
icon: /* @__PURE__ */ Y(c, {})
});
}, cr = (e) => [
/* @__PURE__ */ Y(Zn, { items: e }, "blockTypeSelect"),
/* @__PURE__ */ Y(ar, {}, "tableCellMergeButton"),
/* @__PURE__ */ Y(Wn, {}, "fileCaptionButton"),
/* @__PURE__ */ Y(qn, {}, "replaceFileButton"),
/* @__PURE__ */ Y(Kn, {}, "fileRenameButton"),
/* @__PURE__ */ Y(Gn, {}, "fileDeleteButton"),
/* @__PURE__ */ Y(nr, {}, "fileDownloadButton"),
/* @__PURE__ */ Y(rr, {}, "filePreviewButton"),
/* @__PURE__ */ Y(Pn, { basicTextStyle: "bold" }, "boldStyleButton"),
/* @__PURE__ */ Y(Pn, { basicTextStyle: "italic" }, "italicStyleButton"),
/* @__PURE__ */ Y(Pn, { basicTextStyle: "underline" }, "underlineStyleButton"),
/* @__PURE__ */ Y(Pn, { basicTextStyle: "strike" }, "strikeStyleButton"),
/* @__PURE__ */ Y(sr, { textAlignment: "left" }, "textAlignLeftButton"),
/* @__PURE__ */ Y(sr, { textAlignment: "center" }, "textAlignCenterButton"),
/* @__PURE__ */ Y(sr, { textAlignment: "right" }, "textAlignRightButton"),
/* @__PURE__ */ Y(zn, {}, "colorStyleButton"),
/* @__PURE__ */ Y(Jn, {}, "nestBlockButton"),
/* @__PURE__ */ Y(Yn, {}, "unnestBlockButton"),
/* @__PURE__ */ Y(Un, {}, "createLinkButton"),
/* @__PURE__ */ Y($n, {}, "addCommentButton"),
/* @__PURE__ */ Y(er, {}, "addTiptapCommentButton")
], lr = (e) => {
let t = g();
return /* @__PURE__ */ Y(t.FormattingToolbar.Root, {
className: "bn-toolbar bn-formatting-toolbar",
children: e.children || cr(e.blockTypeSelectItems)
});
}, ur = (e) => {
switch (e) {
case "left": return "top-start";
case "center": return "top";
case "right": return "top-end";
default: return "top-start";
}
}, dr = (n) => {
let r = e(), i = f(I, { editor: r }), a = l(I, { editor: r }), o = m({
editor: r,
selector: ({ editor: e }) => i.store.state ? {
from: e.prosemirrorState.selection.from,
to: e.prosemirrorState.selection.to
} : void 0
}), s = m({
editor: r,
selector: ({ editor: e }) => {
let t = e.getTextCursorPosition().block;
return G(t, e, t.type, { textAlignment: je.textAlignment }) ? ur(t.props.textAlignment) : "top-start";
}
}), c = k(() => ({
...n.floatingUIOptions,
useFloatingOptions: {
open: a,
onOpenChange: (e, t, n) => {
i.store.setState(e), n === "escape-key" && r.focus();
},
placement: s,
middleware: [
H(10),
U(),
V()
],
...n.floatingUIOptions?.useFloatingOptions
},
focusManagerProps: {
disabled: !0,
...n.floatingUIOptions?.focusManagerProps
},
elementProps: {
style: { zIndex: 40 },
...n.floatingUIOptions?.elementProps
}
}), [
a,
s,
n.floatingUIOptions,
i.store,
r
]), u = n.formattingToolbar || lr;
return /* @__PURE__ */ Y(t, {
position: o,
portalElement: n.portalElement,
...c,
children: a && /* @__PURE__ */ Y(u, {})
});
}, fr = (e) => {
let t = g(), r = n(), { deleteLink: i } = f(re);
return /* @__PURE__ */ Y(t.LinkToolbar.Button, {
className: "bn-button",
label: r.link_toolbar.delete.tooltip,
mainTooltip: r.link_toolbar.delete.tooltip,
isSelected: !1,
onClick: () => {
i(e.range.from), e.setToolbarOpen?.(!1);
},
icon: /* @__PURE__ */ Y(sn, {})
});
}, pr = (e) => {
let t = g(), r = n();
return /* @__PURE__ */ X(t.Generic.Popover.Root, {
onOpenChange: e.setToolbarPositionFrozen,
children: [/* @__PURE__ */ Y(t.Generic.Popover.Trigger, { children: /* @__PURE__ */ Y(t.LinkToolbar.Button, {
className: "bn-button",
mainTooltip: r.link_toolbar.edit.tooltip,
isSelected: !1,
children: r.link_toolbar.edit.text
}) }), /* @__PURE__ */ Y(t.Generic.Popover.Content, {
className: "bn-popover-content bn-form-popover",
variant: "form-popover",
children: /* @__PURE__ */ Y(Vn, {
url: e.url,
text: e.text,
range: e.range,
setToolbarOpen: e.setToolbarOpen,
setToolbarPositionFrozen: e.setToolbarPositionFrozen
})
})]
});
}, mr = (e) => {
let t = g(), r = n();
return /* @__PURE__ */ Y(t.LinkToolbar.Button, {
className: "bn-button",
mainTooltip: r.link_toolbar.open.tooltip,
label: r.link_toolbar.open.tooltip,
isSelected: !1,
onClick: () => {
window.open(tr(e.url, window.location.href), "_blank");
},
icon: /* @__PURE__ */ Y(Pt, {})
});
}, hr = (e) => {
let t = g();
return /* @__PURE__ */ Y(t.LinkToolbar.Root, {
className: "bn-toolbar bn-link-toolbar",
children: e.children || /* @__PURE__ */ X(J, { children: [
/* @__PURE__ */ Y(pr, {
url: e.url,
text: e.text,
range: e.range,
setToolbarOpen: e.setToolbarOpen,
setToolbarPositionFrozen: e.setToolbarPositionFrozen
}),
/* @__PURE__ */ Y(mr, { url: e.url }),
/* @__PURE__ */ Y(fr, {
range: e.range,
setToolbarOpen: e.setToolbarOpen
})
] })
});
}, gr = (t) => {
let n = e(), [i, a] = j(!1), [o, s] = j(!1), c = d(), l = f(re), [u, p] = j(void 0);
D(() => {
let e = () => {
let e = l.getLinkAtSelection();
if (!e) {
p(void 0), o || a(!1);
return;
}
p({
cursorType: "text",
url: e.mark.attrs.href,
text: e.text,
range: e.range,
element: l.getLinkElementAtPos(e.range.from)
}), o || a(!0);
}, t = (e) => {
if (u !== void 0 && u.cursorType === "text" || !(e.target instanceof HTMLElement)) return;
let t = l.getLinkAtElement(e.target);
t && p({
cursorType: "mouse",
url: t.mark.attrs.href,
text: t.text,
range: t.range,
element: l.getLinkElementAtPos(t.range.from)
});
}, r = n.onChange(e), i = n.onSelectionChange(e);
return c?.addEventListener("mouseover", t), () => {
r(), i(), c?.removeEventListener("mouseover", t);
};
}, [
n,
c,
l,
u,
o
]);
let m = k(() => ({
...t.floatingUIOptions,
useFloatingOptions: {
open: i,
onOpenChange: (e, t, r) => {
o || (u === void 0 || u.cursorType !== "text" || r !== "hover") && (r === "escape-key" && n.focus(), a(e));
},
placement: "top-start",
middleware: [H(10), V()],
...t.floatingUIOptions?.useFloatingOptions
},
useHoverProps: {
enabled: u !== void 0 && u.cursorType === "mouse",
delay: {
open: 250,
close: 250
},
handleClose: fe(),
...t.floatingUIOptions?.useHoverProps
},
focusManagerProps: {
disabled: !0,
...t.floatingUIOptions?.focusManagerProps
},
elementProps: {
style: { zIndex: 50 },
...t.floatingUIOptions?.elementProps
}
}), [
n,
u,
t.floatingUIOptions,
i,
o
]), h = k(() => u?.element ? { element: u.element } : void 0, [u?.element]);
if (!n.isEditable) return null;
let g = t.linkToolbar || hr;
return /* @__PURE__ */ Y(r, {
reference: h,
portalElement: t.portalElement,
...m,
children: u && /* @__PURE__ */ Y(g, {
url: u.url,
text: u.text,
range: u.range,
setToolbarOpen: a,
setToolbarPositionFrozen: s
})
});
};
//#endregion
//#region ../../node_modules/.pnpm/react-icons@5.6.0_react@19.2.5/node_modules/react-icons/ai/index.mjs
function _r(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 vr = () => {
let t = g(), r = n(), i = e(), a = f(R), o = l(L, {
editor: i,
selector: (e) => e?.block
}), s = T(() => {
if (o === void 0) return;
let e = o.content;
if (e !== void 0 && Array.isArray(e) && e.length === 0) i.setTextCursorPosition(o), a.openSuggestionMenu("/");
else {
let e = i.insertBlocks([{ type: "paragraph" }], o, "after")[0];
i.setTextCursorPosition(e), a.openSuggestionMenu("/");
}
}, [
o,
i,
a
]);
return o === void 0 ? null : /* @__PURE__ */ Y(t.SideMenu.Button, {
className: "bn-button",
label: r.side_menu.add_block_label,
icon: /* @__PURE__ */ Y(_r, {
size: 24,
onClick: s,
"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 yr(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 br(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 xr(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 Sr(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 Cr = (t) => {
let n = g(), r = e(), i = l(L, {
editor: r,
selector: (e) => e?.block
});
return i === void 0 || !G(i, r, i.type, { textColor: "string" }) && !G(i, r, i.type, { backgroundColor: "string" }) ? null : /* @__PURE__ */ X(n.Generic.Menu.Root, {
position: "right",
sub: !0,
children: [/* @__PURE__ */ Y(n.Generic.Menu.Trigger, {
sub: !0,
children: /* @__PURE__ */ Y(n.Generic.Menu.Item, {
className: "bn-menu-item",
subTrigger: !0,
children: t.children
})
}), /* @__PURE__ */ Y(n.Generic.Menu.Dropdown, {
sub: !0,
className: "bn-menu-dropdown bn-color-picker-dropdown",
children: /* @__PURE__ */ Y(Ln, {
iconSize: 18,
text: G(i, r, i.type, { textColor: "string" }) && K(r, i.type, { textColor: "string" }) ? {
color: i.props.textColor,
setColor: (e) => r.updateBlock(i, {
type: i.type,
props: { textColor: e }
})
} : void 0,
background: G(i, r, i.type, { backgroundColor: "string" }) && K(r, i.type, { backgroundColor: "string" }) ? {
color: i.props.backgroundColor,
setColor: (e) => r.updateBlock(i, { props: { backgroundColor: e } })
} : void 0
})
})]
});
}, wr = (t) => {
let n = g(), r = e(), i = l(L, {
editor: r,
selector: (e) => e?.block
});
return i === void 0 ? null : /* @__PURE__ */ Y(n.Generic.Menu.Item, {
className: "bn-menu-item",
onClick: () => {
let e = r.getSelection()?.blocks, t = e && e.some((e) => e.id === i.id) ? e : [i];
r.removeBlocks(t);
},
children: t.children
});
}, Tr = (t) => {
let n = g(), r = e(), i = l(L, {
editor: r,
selector: (e) => e?.block
});
if (i === void 0 || i.type !== "table" || !r.settings.tables.headers) return null;
let a = !!i.content.headerRows;
return /* @__PURE__ */ Y(n.Generic.Menu.Item, {
className: "bn-menu-item",
checked: a,
onClick: () => {
r.updateBlock(i, { content: {
...i.content,
headerRows: a ? void 0 : 1
} });
},
children: t.children
});
}, Er = (t) => {
let n = g(), r = e(), i = l(L, {
editor: r,
selector: (e) => e?.block
});
if (i === void 0 || i.type !== "table" || !r.settings.tables.headers) return null;
let a = !!i.content.headerCols;
return /* @__PURE__ */ Y(n.Generic.Menu.Item, {
className: "bn-menu-item",
checked: a,
onClick: () => {
r.updateBlock(i, { content: {
...i.content,
headerCols: a ? void 0 : 1
} });
},
children: t.children
});
}, Dr = (e) => {
let t = g(), r = n();
return /* @__PURE__ */ Y(t.Generic.Menu.Dropdown, {
className: "bn-menu-dropdown bn-drag-handle-menu",
children: e.children || /* @__PURE__ */ X(J, { children: [
/* @__PURE__ */ Y(wr, { children: r.drag_handle.delete_menuitem }),
/* @__PURE__ */ Y(Cr, { children: r.drag_handle.colors_menuitem }),
/* @__PURE__ */ Y(Tr, { children: r.drag_handle.header_row_menuitem }),
/* @__PURE__ */ Y(Er, { children: r.drag_handle.header_column_menuitem })
] })
});
}, Or = (e) => {
let t = g(), r = n(), i = f(L), a = l(L, { selector: (e) => e?.block });
if (a === void 0) return null;
let o = e.dragHandleMenu || Dr;
return /* @__PURE__ */ X(t.Generic.Menu.Root, {
onOpenChange: (e) => {
e ? i.freezeMenu() : i.unfreezeMenu();
},
position: "left",
children: [/* @__PURE__ */ Y(t.Generic.Menu.Trigger, { children: /* @__PURE__ */ Y(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__ */ Y(Sr, {
size: 24,
"data-test": "dragHandle"
})
}) }), /* @__PURE__ */ Y(o, { children: e.children })]
});
}, kr = (e) => {
let t = g();
return /* @__PURE__ */ Y(t.SideMenu.Root, {
className: "bn-side-menu",
children: e.children || /* @__PURE__ */ X(J, { children: [/* @__PURE__ */ Y(vr, {}), /* @__PURE__ */ Y(Or, { dragHandleMenu: e.dragHandleMenu })] })
});
};
//#endregion
//#region src/components/SideMenu/SideMenuController.tsx
function Ar(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 jr = (t) => {
let n = e(), { show: r, block: i } = l(L, { selector: (e) => e === void 0 ? void 0 : {
show: e.show,
block: e.block
} }) || {}, a = T((e, t, r) => {
let i = !1;
return ue(e, t, () => {
if (!i) {
i = !0;
return;
}
n.getExtension(L)?.hideMenuIfNotFrozen();
}, {
ancestorScroll: !0,
ancestorResize: !1,
elementResize: !1,
layoutShift: !1
});
}, [n]), o = k(() => ({
...t.floatingUIOptions,
useFloatingOptions: {
open: r,
placement: "left-start",
middleware: [H({ crossAxis: i ? Ar(n, i) : 0 })],
whileElementsMounted: a,
...t.floatingUIOptions?.useFloatingOptions
},
useDismissProps: {
enabled: !1,
...t.floatingUIOptions?.useDismissProps
},
focusManagerProps: {
disabled: !0,
...t.floatingUIOptions?.focusManagerProps
},
elementProps: {
style: { zIndex: 20 },
...t.floatingUIOptions?.elementProps
}
}), [
t.floatingUIOptions,
r,
i,
n,
a
]), s = t.sideMenu || kr;
return /* @__PURE__ */ Y(ft, {
blockId: r ? i?.id : void 0,
portalElement: t.portalElement,
...o,
children: i?.id && /* @__PURE__ */ Y(s, {})
});
}, Mr = ({ 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(", ");
}, Nr = (e) => {
let t = g(), r = n(), i = k(() => {
let t = r.suggestion_changes, n = e.formatChangeLabel ?? Mr, 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 ? n({
format: e.format,
dictionary: r
}) : "";
return t.formatting_change_by(a, i);
}, [
r,
e.formatChangeLabel,
e.users,
e.modificationType,
e.format
]);
return /* @__PURE__ */ Y(t.AttributionTooltip.Root, {
className: "bn-suggestion-tooltip",
markClassName: e.className,
backgroundColor: e.className ? void 0 : e.color,
children: i
});
}, Pr = (e) => {
let t = l("attribution", { selector: (e) => e }), n = k(() => 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]), i = k(() => ({
...e.floatingUIOptions,
useFloatingOptions: {
open: !!t,
placement: "top-start",
middleware: [
de(),
H(4),
V(),
U({ padding: 4 })
],
...e.floatingUIOptions?.useFloatingOptions
},
focusManagerProps: {
disabled: !0,
...e.floatingUIOptions?.focusManagerProps
},
elementProps: {
style: {
zIndex: 1e4,
pointerEvents: "none"
},
...e.floatingUIOptions?.elementProps
}
}), [e.floatingUIOptions, t]), a = e.attributionTooltip || Nr, o = k(() => 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__ */ Y(r, {
reference: n,
portalElement: e.portalElement,
...i,
children: o && /* @__PURE__ */ Y(a, { ...o })
});
};
//#endregion
//#region src/components/SuggestionMenu/GridSuggestionMenu/getDefaultReactEmojiPickerItems.tsx
async function Fr(e, t) {
return (await se(e, t)).map(({ id: e, onItemClick: t }) => ({
id: e,
onItemClick: t,
icon: e
}));
}
//#endregion
//#region src/components/SuggestionMenu/GridSuggestionMenu/GridSuggestionMenu.tsx
function Ir(e) {
let t = g(), r = n(), { items: i, loadingState: a, selectedIndex: o, onItemClick: s, columns: c } = e, l = a === "loading-initial" || a === "loading" ? /* @__PURE__ */ Y(t.GridSuggestionMenu.Loader, {
className: "bn-grid-suggestion-menu-loader",
columns: c
}) : null, u = k(() => {
let e = [];
for (let n = 0; n < i.length; n++) {
let r = i[n];
e.push(/* @__PURE__ */ Y(t.GridSuggestionMenu.Item, {
className: "bn-grid-suggestion-menu-item",
item: r,
id: `bn-grid-suggestion-menu-item-${n}`,
isSelected: n === o,
onClick: () => s?.(r)
}, r.id));
}
return e;
}, [
t,
i,
s,
o
]);
return /* @__PURE__ */ X(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__ */ Y(t.GridSuggestionMenu.EmptyItem, {
className: "bn-grid-suggestion-menu-empty-item",
columns: c,
children: r.suggestion_menu.no_items_title
})
]
});
}
//#endregion
//#region src/components/SuggestionMenu/getSuggestionMenuItemId.ts
function Lr(e) {
return e === void 0 ? void 0 : "bn-suggestion-menu-item-" + e;
}
//#endregion
//#region src/components/SuggestionMenu/hooks/useCloseSuggestionMenuNoItems.ts
function Rr(e, t, n, r = 3) {
let i = A(0);
D(() => {
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 zr(e, t) {
let [n, r] = j([]), [i, a] = j(!1), o = A(void 0), s = A(void 0);
return D(() => {
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 Br(e, t, n, r, i) {
let a = d(e), [o, s] = j(0);
return D(() => {
let e = (e) => (e.key === "ArrowLeft" && (e.preventDefault(), n.length && s((o - 1 + n.length) % n.length)), e.key === "ArrowRight" && (e.preventDefault(), n.length && s((o + 1 + n.length) % n.length)), e.key === "ArrowUp" ? (e.preventDefault(), n.length && s((o - r + n.length) % n.length), !0) : e.key === "ArrowDown" ? (e.preventDefault(), n.length && s((o + r) % n.length), !0) : e.key === "Enter" && !e.isComposing && (e.stopPropagation(), e.preventDefault(), n.length && i?.(n[o]), !0));
return a?.addEventListener("keydown", e, !0), () => {
a?.removeEventListener("keydown", e, !0);
};
}, [
a,
n,
o,
i,
r,
r !== void 0 && r > 1
]), D(() => {
s(0);
}, [t]), { selectedIndex: n.length === 0 ? void 0 : o };
}
//#endregion
//#region src/components/SuggestionMenu/GridSuggestionMenu/GridSuggestionMenuWrapper.tsx
function Vr(t) {
let n = v().setContentEditableProps, r = e(), { getItems: i, gridSuggestionMenuComponent: a, query: o, clearQuery: s, closeMenu: c, onItemClick: l, columns: u } = t, d = T((e) => {
c(), s(), l?.(e);
}, [
l,
c,
s
]), { items: f, usedQuery: p, loadingState: m } = zr(o, i);
Rr(f, p, c);
let { selectedIndex: h } = Br(r, o, f, u, d);
return D(() => (n((e) => ({
...e,
"aria-expanded": !0,
"aria-controls": "bn-suggestion-menu"
})), () => {
n((e) => ({
...e,
"aria-expanded": !1,
"aria-controls": void 0
}));
}), [n]), D(() => (n((e) => ({
...e,
"aria-activedescendant": Lr(h)
})), () => {
n((e) => ({
...e,
"aria-activedescendant": void 0
}));
}), [n, h]), /* @__PURE__ */ Y(a, {
items: f,
onItemClick: d,
loadingState: m,
selectedIndex: h,
columns: u
});
}
//#endregion
//#region src/components/SuggestionMenu/GridSuggestionMenu/GridSuggestionMenuController.tsx
function Hr(t) {
let n = e(), i = d(), { triggerCharacter: a, gridSuggestionMenuComponent: o, columns: s, shouldOpen: c, minQueryLength: u, onItemClick: p, getItems: m } = t, h = k(() => p || ((e) => {
e.onItemClick(n);
}), [n, p]), g = k(() => m || (async (e) => await Fr(n, e)), [n, m]), _ = f(R);
D(() => {
_.addSuggestionMenu({
triggerCharacter: a,
shouldOpen: c
});
}, [
_,
a,
c
]);
let v = l(R), y = l(R, { selector: (e) => ({
element: i?.firstChild || void 0,
getBoundingClientRect: () => e?.referencePos || new DOMRect()
}) }), b = k(() => ({
...t.floatingUIOptions,
useFloatingOptions: {
open: v?.show && v?.triggerCharacter === a,
onOpenChange: (e) => {
e || _.closeMenu();
},
placement: "bottom-start",
middleware: [
H(10),
le({
allowedPlacements: ["bottom-start", "top-start"],
padding: 10
}),
U(),
W({
apply({ elements: e, availableHeight: t }) {
e.floating.style.maxHeight = `${Math.max(0, t)}px`;
},
padding: 10
})
],
...t.floatingUIOptions?.useFloatingOptions
},
focusManagerProps: {
disabled: !0,
...t.floatingUIOptions?.focusManagerProps
},
elementProps: {
onMouseDownCapture: (e) => e.preventDefault(),
style: { zIndex: 70 },
...t.floatingUIOptions?.elementProps
}
}), [
t.floatingUIOptions,
v?.show,
v?.triggerCharacter,
_,
a
]);
return !v || !v.ignoreQueryLength && u && (v.query.startsWith(" ") || v.query.length < u) ? null : /* @__PURE__ */ Y(r, {
reference: y,
portalElement: t.portalElement,
...b,
children: a && /* @__PURE__ */ Y(Vr, {
query: v.query,
closeMenu: _.closeMenu,
clearQuery: _.clearQuery,
getItems: g,
columns: s,
gridSuggestionMenuComponent: o || Ir,
onItemClick: h
})
});
}
//#endregion
//#region src/components/SuggestionMenu/SuggestionMenu.tsx
function Ur(e) {
let t = g(), r = n(), { items: i, loadingState: a, selectedIndex: o, onItemClick: s } = e, c = a === "loading-initial" || a === "loading" ? /* @__PURE__ */ Y(t.SuggestionMenu.Loader, { className: "bn-suggestion-menu-loader" }) : null, l = k(() => {
let e, n = [];
for (let r = 0; r < i.length; r++) {
let a = i[r];
a.group !== e && (e = a.group, n.push(/* @__PURE__ */ Y(t.SuggestionMenu.Label, {
className: "bn-suggestion-menu-label",
children: e
}, e))), n.push(/* @__PURE__ */ Y(t.SuggestionMenu.Item, {
className: q("bn-suggestion-menu-item", a.size === "small" ? "bn-suggestion-menu-item-small" : ""),
item: a,
id: `bn-suggestion-menu-item-${r}`,
isSelected: r === o,
onClick: () => s?.(a)
}, a.title));
}
return n;
}, [
t,
i,
s,
o
]);
return /* @__PURE__ */ X(t.SuggestionMenu.Root, {
id: "bn-suggestion-menu",
className: "bn-suggestion-menu",
children: [
l,
l.length === 0 && (e.loadingState === "loading" || e.loadingState === "loaded") && /* @__PURE__ */ Y(t.SuggestionMenu.EmptyItem, {
className: "bn-suggestion-menu-item",
children: r.suggestion_menu.no_items_title
}),
c
]
});
}
//#endregion
//#region src/components/SuggestionMenu/hooks/useSuggestionMenuKeyboardHandler.ts
function Wr(e, t) {
let [n, r] = j(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 = Gr(i) ? i.nativeEvent.isComposing : i.isComposing;
return i.key === "Enter" && !a && (i.preventDefault(), i.stopPropagation(), e.length && t?.(e[n]), !0);
}
};
}
function Gr(e) {
return e.nativeEvent !== void 0;
}
//#endregion
//#region src/components/SuggestionMenu/hooks/useSuggestionMenuKeyboardNavigation.ts
function Kr(e, t, n, r, i) {
let a = d(), { selectedIndex: o, setSelectedIndex: s, handler: c } = Wr(n, r);
return D(() => {
let e = i || a;
return e?.addEventListener("keydown", c, !0), () => {
e?.removeEventListener("keydown", c, !0);
};
}, [
a,
n,
o,
r,
i,
c
]), D(() => {
s(0);
}, [t, s]), { selectedIndex: n.length === 0 ? void 0 : o };
}
//#endregion
//#region src/components/SuggestionMenu/SuggestionMenuWrapper.tsx
function qr(t) {
let n = v().setContentEditableProps, r = e(), { getItems: i, suggestionMenuComponent: a, query: o, clearQuery: s, closeMenu: c, onItemClick: l } = t, u = T((e) => {
c(), s(), l?.(e);
}, [
l,
c,
s
]), { items: d, usedQuery: f, loadingState: p } = zr(o, i);
Rr(d, f, c);
let { selectedIndex: m } = Kr(r, o, d, u);
return D(() => (n((e) => ({
...e,
"aria-expanded": !0,
"aria-controls": "bn-suggestion-menu"
})), () => {
n((e) => ({
...e,
"aria-expanded": !1,
"aria-controls": void 0
}));
}), [n]), D(() => (n((e) => ({
...e,
"aria-activedescendant": Lr(m)
})), () => {
n((e) => ({
...e,
"aria-activedescendant": void 0
}));
}), [n, m]), /* @__PURE__ */ Y(a, {
items: d,
onItemClick: u,
loadingState: p,
selectedIndex: m
});
}
//#endregion
//#region src/components/SuggestionMenu/getDefaultReactSlashMenuItems.tsx
var Jr = {
heading: _n,
heading_2: gn,
heading_3: hn,
heading_4: mn,
heading_5: pn,
heading_6: fn,
toggle_heading: _n,
toggle_heading_2: gn,
toggle_heading_3: hn,
quote: $t,
toggle_list: Wt,
numbered_list: rn,
bullet_list: nn,
check_list: an,
paragraph: Xt,
table: Zt,
image: qt,
video: Jt,
audio: Ht,
file: En,
emoji: jt,
code_block: yn,
divider: Mt
};
function Yr(e) {
return ce(e).map((e) => {
let t = Jr[e.key];
return {
...e,
icon: /* @__PURE__ */ Y(t, { size: 18 })
};
});
}
//#endregion
//#region src/components/SuggestionMenu/SuggestionMenuController.tsx
function Xr(t) {
let n = e(), i = d(), { triggerCharacter: a, suggestionMenuComponent: o, shouldOpen: s, minQueryLength: c, onItemClick: u, getItems: p } = t, m = k(() => u || ((e) => {
e.onItemClick(n);
}), [n, u]), h = k(() => p || (async (e) => oe(Yr(n), e)), [n, p]), g = f(R);
D(() => {
g.addSuggestionMenu({
triggerCharacter: a,
shouldOpen: s
});
}, [
g,
a,
s
]);
let _ = l(R), v = l(R, { selector: (e) => ({
element: i?.firstChild || void 0,
getBoundingClientRect: () => e?.referencePos || new DOMRect()
}) }), y = k(() => ({
...t.floatingUIOptions,
useFloatingOptions: {
open: _?.show && _?.triggerCharacter === a,
onOpenChange: (e) => {
e || g.closeMenu();
},
placement: "bottom-start",
middleware: [
H(10),
le({
allowedPlacements: ["bottom-start", "top-start"],
padding: 10
}),
U(),
W({
apply({ elements: e, availableHeight: t }) {
e.floating.style.maxHeight = `${Math.max(0, t)}px`;
},
padding: 10
})
],
...t.floatingUIOptions?.useFloatingOptions
},
focusManagerProps: {
disabled: !0,
...t.floatingUIOptions?.focusManagerProps
},
elementProps: {
onMouseDownCapture: (e) => e.preventDefault(),
style: { zIndex: 80 },
...t.floatingUIOptions?.elementProps
}
}), [
t.floatingUIOptions,
_?.show,
_?.triggerCharacter,
g,
a
]);
return !_ || !_.ignoreQueryLength && c && (_.query.startsWith(" ") || _.query.length < c) ? null : /* @__PURE__ */ Y(r, {
reference: v,
portalElement: t.portalElement,
...y,
children: a && /* @__PURE__ */ Y(qr, {
query: _.query,
closeMenu: g.closeMenu,
clearQuery: g.clearQuery,
getItems: h,
suggestionMenuComponent: o || Ur,
onItemClick: m
})
});
}
//#endregion
//#region src/components/TableHandles/ExtendButton/ExtendButton.tsx
var Zr = (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);
}, Qr = (t) => {
let n = g(), r = e(), i = f(z), a = l(z, { selector: (e) => e?.block }), o = A(!1), [s, c] = j(), u = T((e) => {
i.freezeHandles(), t.hideOtherElements(!0), a && (c({
originalContent: a.content,
originalCroppedContent: { rows: i.cropEmptyRowsOrColumns(a, t.orientation === "addOrRemoveColumns" ? "columns" : "rows") },
startPos: t.orientation === "addOrRemoveColumns" ? e.clientX : e.clientY
}), o.current = !1, e.preventDefault());
}, [
a,
t,
i
]), d = T(() => {
!a || o.current || r.updateBlock(a, {
type: "table",
content: {
...a.content,
rows: t.orientation === "addOrRemoveColumns" ? i.addRowsOrColumns(a, "columns", 1) : i.addRowsOrColumns(a, "rows", 1)
}
});
}, [
a,
r,
t.orientation,
i
]);
return D(() => {
let e = (e) => {
if (!a) return;
if (!s) throw Error("editingState is undefined");
o.current = !0;
let n = (t.orientation === "addOrRemoveColumns" ? e.clientX : e.clientY) - s.startPos, c = t.orientation === "addOrRemoveColumns" ? s.originalCroppedContent.rows[0]?.cells.length ?? 0 : s.originalCroppedContent.rows.length, l = t.orientation === "addOrRemoveColumns" ? s.originalContent.rows[0]?.cells.length ?? 0 : s.originalContent.rows.length, u = t.orientation === "addOrRemoveColumns" ? a.content.rows[0].cells.length : a.content.rows.length, d = l + Zr(n / (t.orientation === "addOrRemoveColumns" ? ge : he), .3);
d >= c && d > 0 && d !== u && (r.updateBlock(a, {
type: "table",
content: {
...a.content,
rows: t.orientation === "addOrRemoveColumns" ? i.addRowsOrColumns({
type: "table",
content: s.originalCroppedContent
}, "columns", d - c) : i.addRowsOrColumns({
type: "table",
content: s.originalCroppedContent
}, "rows", d - c)
}
}), a.content && r.setTextCursorPosition(a));
};
return s && window.addEventListener("mousemove", e), () => {
window.removeEventListener("mousemove", e);
};
}, [
a,
s,
r,
t.orientation,
i
]), D(() => {
let e = () => {
t.hideOtherElements(!1), i.unfreezeHandles(), c(void 0);
};
return s && window.addEventListener("mouseup", e), () => {
window.removeEventListener("mouseup", e);
};
}, [
s,
t,
i
]), r.isEditable ? /* @__PURE__ */ Y(n.TableHandle.ExtendButton, {
className: q("bn-extend-button", t.orientation === "addOrRemoveColumns" ? "bn-extend-button-add-remove-columns" : "bn-extend-button-add-remove-rows", s === null ? "" : "bn-extend-button-editing"),
onClick: d,
onMouseDown: u,
children: t.children || /* @__PURE__ */ Y(Vt, {
size: 18,
"data-test": "extendButton"
})
}) : null;
}, $r = (t) => {
let r = g(), i = n(), a = e(), { block: o, colIndex: s, rowIndex: c } = l(z, { selector: (e) => ({
block: e?.block,
colIndex: e?.colIndex,
rowIndex: e?.rowIndex
}) }), u = (e, t) => {
if (o === void 0 || s === void 0 || c === void 0) return;
let n = o.content.rows.map((e) => ({
...e,
cells: e.cells.map((e) => qe(e))
}));
t === "text" ? n[c].cells[s].props.textColor = e : n[c].cells[s].props.backgroundColor = e, a.updateBlock(o, {
type: "table",
content: {
...o.content,
rows: n
}
}), a.setTextCursorPosition(o);
};
if (o === void 0 || s === void 0 || c === void 0) return null;
let d = o.content.rows[c]?.cells?.[s];
return !d || a.settings.tables.cellTextColor === !1 && a.settings.tables.cellBackgroundColor === !1 ? null : /* @__PURE__ */ X(r.Generic.Menu.Root, {
position: "right",
sub: !0,
children: [/* @__PURE__ */ Y(r.Generic.Menu.Trigger, {
sub: !0,
children: /* @__PURE__ */ Y(r.Generic.Menu.Item, {
className: "bn-menu-item",
subTrigger: !0,
children: t.children || i.drag_handle.colors_menuitem
})
}), /* @__PURE__ */ Y(r.Generic.Menu.Dropdown, {
sub: !0,
className: "bn-menu-dropdown bn-color-picker-dropdown",
children: /* @__PURE__ */ Y(Ln, {
iconSize: 18,
text: a.settings.tables.cellTextColor ? {
color: Ge(d) ? d.props.textColor : "default",
setColor: (e) => u(e, "text")
} : void 0,
background: a.settings.tables.cellBackgroundColor ? {
color: Ge(d) ? d.props.backgroundColor : "default",
setColor: (e) => u(e, "background")
} : void 0
})
})]
});
}, ei = () => {
let t = g(), r = n(), i = e(), a = f(z), { block: o, colIndex: s, rowIndex: c } = l(z, { selector: (e) => ({
block: e?.block,
colIndex: e?.colIndex,
rowIndex: e?.rowIndex
}) });
if (o === void 0 || s === void 0 || c === void 0) return null;
let u = o.content.rows[c]?.cells?.[s];
return !u || !Ge(u) || Ve(u) === 1 && Le(u) === 1 || !i.settings.tables.splitCells ? null : /* @__PURE__ */ Y(t.Generic.Menu.Item, {
onClick: () => {
a.splitCell({
row: c,
col: s
});
},
children: r.table_handle.split_cell_menuitem
});
}, ti = (e) => {
let t = g();
return /* @__PURE__ */ Y(t.Generic.Menu.Dropdown, {
className: "bn-menu-dropdown bn-table-handle-menu",
children: e.children || /* @__PURE__ */ X(J, { children: [/* @__PURE__ */ Y(ei, {}), /* @__PURE__ */ Y($r, {})] })
});
}, ni = (t) => {
let n = g(), r = e(), i = f(z), a = t.tableCellMenu || ti;
return !r.settings.tables.splitCells && !r.settings.tables.cellBackgroundColor && !r.settings.tables.cellTextColor ? null : /* @__PURE__ */ X(n.Generic.Menu.Root, {
onOpenChange: (e) => {
e ? (i.freezeHandles(), t.hideOtherElements(!0)) : (i.unfreezeHandles(), t.hideOtherElements(!1), r.focus());
},
position: "right",
children: [/* @__PURE__ */ Y(n.Generic.Menu.Trigger, { children: /* @__PURE__ */ Y(n.Generic.Menu.Button, {
className: "bn-table-cell-handle",
children: t.children || /* @__PURE__ */ Y(yr, {
size: 12,
"data-test": "tableCellHandle"
})
}) }), /* @__PURE__ */ Y(a, {})]
});
}, ri = (e) => {
let t = g(), r = n(), i = f(z), a = l(z, { selector: (t) => e.orientation === "column" ? t?.colIndex : t?.rowIndex });
return i === void 0 || a === void 0 ? null : /* @__PURE__ */ Y(t.Generic.Menu.Item, {
onClick: () => {
i.addRowOrColumn(a, e.orientation === "row" ? {
orientation: "row",
side: e.side
} : {
orientation: "column",
side: e.side
});
},
children: r.table_handle[`add_${e.side}_menuitem`]
});
}, ii = (e) => {
let t = g(), r = n(), i = f(z), a = l(z, { selector: (t) => e.orientation === "column" ? t?.colIndex : t?.rowIndex });
return i === void 0 || a === void 0 ? null : /* @__PURE__ */ Y(t.Generic.Menu.Item, {
onClick: () => i.removeRowOrColumn(a, e.orientation),
children: e.orientation === "row" ? r.table_handle.delete_row_menuitem : r.table_handle.delete_column_menuitem
});
}, ai = (t) => {
let r = g(), i = n(), a = e(), o = f(z), { block: s, index: c } = l(z, { selector: (e) => ({
block: e?.block,
index: t.orientation === "column" ? e?.colIndex : e?.rowIndex
}) }), u = k(() => o === void 0 || s === void 0 || c === void 0 ? [] : t.orientation === "row" ? o.getCellsAtRowHandle(s, c) : o.getCellsAtColumnHandle(s, c), [
s,
c,
t.orientation,
o
]), d = (e, t) => {
if (s === void 0) return;
let n = s.content.rows.map((e) => ({
...e,
cells: e.cells.map((e) => qe(e))
}));
u.forEach(({ row: r, col: i }) => {
t === "text" ? n[r].cells[i].props.textColor = e : n[r].cells[i].props.backgroundColor = e;
}), a.updateBlock(s, {
type: "table",
content: {
...s.content,
rows: n
}
}), a.setTextCursorPosition(s);
};
if (!u || !u[0] || !o || a.settings.tables.cellTextColor === !1 && a.settings.tables.cellBackgroundColor === !1) return null;
let p = qe(u[0].cell);
return /* @__PURE__ */ X(r.Generic.Menu.Root, {
position: "right",
sub: !0,
children: [/* @__PURE__ */ Y(r.Generic.Menu.Trigger, {
sub: !0,
children: /* @__PURE__ */ Y(r.Generic.Menu.Item, {
className: "bn-menu-item",
subTrigger: !0,
children: t.children || i.drag_handle.colors_menuitem
})
}), /* @__PURE__ */ Y(r.Generic.Menu.Dropdown, {
sub: !0,
className: "bn-menu-dropdown bn-color-picker-dropdown",
children: /* @__PURE__ */ Y(Ln, {
iconSize: 18,
text: a.settings.tables.cellTextColor ? {
color: u.every(({ cell: e }) => Ge(e) && e.props.textColor === p.props.textColor) ? p.props.textColor : "default",
setColor: (e) => {
d(e, "text");
}
} : void 0,
background: a.settings.tables.cellBackgroundColor ? {
color: u.every(({ cell: e }) => Ge(e) && e.props.backgroundColor === p.props.backgroundColor) ? p.props.backgroundColor : "default",
setColor: (e) => d(e, "background")
} : void 0
})
})]
});
}, oi = (t) => {
let r = g(), i = n(), a = e(), o = f(z), { block: s, index: c } = l(z, { selector: (e) => ({
block: e?.block,
index: t.orientation === "column" ? e?.colIndex : e?.rowIndex
}) });
if (o === void 0 || s === void 0 || c !== 0 || t.orientation !== "row" || !a.settings.tables.headers) return null;
let u = !!s.content.headerRows;
return /* @__PURE__ */ Y(r.Generic.Menu.Item, {
className: "bn-menu-item",
checked: u,
onClick: () => {
a.updateBlock(s, {
...s,
content: {
...s.content,
headerRows: u ? void 0 : 1
}
});
},
children: i.drag_handle.header_row_menuitem
});
}, si = (t) => {
let r = g(), i = n(), a = e(), o = f(z), s = l(z, { selector: (e) => e?.block }), c = l(z, { selector: (e) => t.orientation === "column" ? e?.colIndex : e?.rowIndex });
if (!o || c !== 0 || !s || t.orientation !== "column" || !a.settings.tables.headers) return null;
let u = !!s.content.headerCols;
return /* @__PURE__ */ Y(r.Generic.Menu.Item, {
className: "bn-menu-item",
checked: u,
onClick: () => {
a.updateBlock(s, {
...s,
content: {
...s.content,
headerCols: u ? void 0 : 1
}
});
},
children: i.drag_handle.header_column_menuitem
});
}, ci = (e) => {
let t = g();
return /* @__PURE__ */ Y(t.Generic.Menu.Dropdown, {
className: "bn-table-handle-menu",
children: e.children || /* @__PURE__ */ X(J, { children: [
/* @__PURE__ */ Y(ii, { orientation: e.orientation }),
/* @__PURE__ */ Y(ri, {
orientation: e.orientation,
side: e.orientation === "row" ? "above" : "left"
}),
/* @__PURE__ */ Y(ri, {
orientation: e.orientation,
side: e.orientation === "row" ? "below" : "right"
}),
/* @__PURE__ */ Y(oi, { orientation: e.orientation }),
/* @__PURE__ */ Y(si, { orientation: e.orientation }),
/* @__PURE__ */ Y(ai, { orientation: e.orientation })
] })
});
}, li = (t) => {
let n = e(), r = g(), [i, a] = j(!1), o = t.tableHandleMenu || ci, s = f(z), c = l(z), u = k(() => !s || !c || !c.block || c.block.type !== "table" ? !1 : t.orientation === "column" ? s.getCellsAtColumnHandle(c.block, c.colIndex).every(({ cell: e }) => Le(e) === 1) : s.getCellsAtRowHandle(c.block, c.rowIndex).every(({ cell: e }) => Ve(e) === 1), [
t.orientation,
c,
s
]);
return c ? /* @__PURE__ */ X(r.Generic.Menu.Root, {
onOpenChange: (e) => {
e ? (s.freezeHandles(), t.hideOtherElements(!0)) : (s.unfreezeHandles(), t.hideOtherElements(!1), n.focus());
},
position: "right",
children: [/* @__PURE__ */ Y(r.Generic.Menu.Trigger, { children: /* @__PURE__ */ Y(r.TableHandle.Root, {
className: q("bn-table-handle", i ? "bn-table-handle-dragging" : "", u ? "" : "bn-table-handle-not-draggable"),
draggable: u,
onDragStart: (e) => {
a(!0), t.hideOtherElements(!0), t.orientation === "column" ? s.colDragStart(e) : s.rowDragStart(e);
},
onDragEnd: () => {
s.dragEnd(), t.hideOtherElements(!1), a(!1);
},
style: t.orientation === "column" ? { transform: "rotate(0.25turn)" } : void 0,
children: t.children || /* @__PURE__ */ Y(Sr, {
size: 24,
"data-test": "tableHandle"
})
}) }), /* @__PURE__ */ Y(o, { orientation: t.orientation })]
}) : null;
}, ui = (t) => {
let n = e(), [i, a] = j(), o = l(z), s = k(() => {
let e = {};
if (o === void 0) return {};
let t = ze(o.block.id, n.prosemirrorState.doc);
if (!t) return {};
let r = t.posBeforeNode + 1, i = n.prosemirrorView.domAtPos(r + 1).node;
if (!(i instanceof Element)) return {};
if (e.tableReference = { element: i }, o.rowIndex === void 0 || o.colIndex === void 0) return e;
let a = n.prosemirrorState.doc.resolve(r + 1).posAtIndex(o.rowIndex), s = n.prosemirrorState.doc.resolve(a + 1).posAtIndex(o.colIndex), c = n.prosemirrorView.domAtPos(s + 1).node;
return c instanceof Element ? (e.cellReference = { element: c }, e.rowReference = {
element: i,
getBoundingClientRect: () => {
let e = i.getBoundingClientRect(), t = c.getBoundingClientRect();
return new DOMRect(e.x, o.draggingState && o.draggingState.draggedCellOrientation === "row" ? o.draggingState.mousePos - t.height / 2 : t.y, e.width, t.height);
}
}, e.columnReference = {
element: i,
getBoundingClientRect: () => {
let e = i.getBoundingClientRect(), t = c.getBoundingClientRect();
return new DOMRect(o.draggingState && o.draggingState.draggedCellOrientation === "col" ? o.draggingState.mousePos - t.width / 2 : t.x, e.y, t.width, e.height);
}
}, e) : {};
}, [n, o]), c = T((e, t, r) => {
let i = !1;
return ue(e, t, () => {
if (!i) {
i = !0;
return;
}
n.getExtension(z)?.hideHandlesIfNotFrozen();
}, {
ancestorScroll: !0,
ancestorResize: !1,
elementResize: !1,
layoutShift: !1
});
}, [n]), u = k(() => o === void 0 ? void 0 : {
rowTableHandle: {
useFloatingOptions: {
open: o.show && o.rowIndex !== void 0 && (!i || i === "rowTableHandle"),
placement: "left",
middleware: [H(-10)],
whileElementsMounted: c
},
focusManagerProps: { disabled: !0 },
elementProps: { style: { zIndex: 10 } }
},
columnTableHandle: {
useFloatingOptions: {
open: o.show && o.colIndex !== void 0 && (!i || i === "columnTableHandle"),
placement: "top",
middleware: [H(-12)],
whileElementsMounted: c
},
focusManagerProps: { disabled: !0 },
elementProps: { style: { zIndex: 10 } }
},
tableCellHandle: {
useFloatingOptions: {
open: o.show && o.rowIndex !== void 0 && o.colIndex !== void 0 && (!i || i === "tableCellHandle"),
placement: "top-end",
middleware: [H({
mainAxis: -15,
crossAxis: -1
})],
whileElementsMounted: c
},
focusManagerProps: { disabled: !0 },
elementProps: { style: { zIndex: 10 } }
},
extendRowsButton: {
useFloatingOptions: {
open: o.show && o.showAddOrRemoveRowsButton && (!i || i === "extendRowsButton"),
placement: "bottom",
whileElementsMounted: c,
middleware: [W({ 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: o.show && o.showAddOrRemoveColumnsButton && (!i || i === "extendColumnsButton"),
placement: "right",
whileElementsMounted: c,
middleware: [W({ apply({ rects: e, elements: t }) {
Object.assign(t.floating.style, { height: `${e.reference.height}px` });
} })]
},
focusManagerProps: { disabled: !0 },
elementProps: { style: { zIndex: 10 } }
}
}, [
i,
o,
c
]);
if (!o) return null;
let d = t.tableHandle || li, f = t.extendButton || Qr, p = t.tableCellHandle || ni;
return /* @__PURE__ */ X(J, { children: [
/* @__PURE__ */ Y(r, {
reference: s?.rowReference,
portalElement: t.portalElement,
...u?.rowTableHandle,
children: o.show && o.rowIndex !== void 0 && (!i || i === "rowTableHandle") && /* @__PURE__ */ Y(d, {
orientation: "row",
hideOtherElements: (e) => a(e ? "rowTableHandle" : void 0)
})
}),
/* @__PURE__ */ Y(r, {
reference: s?.columnReference,
portalElement: t.portalElement,
...u?.columnTableHandle,
children: o.show && o.colIndex !== void 0 && (!i || i === "columnTableHandle") && /* @__PURE__ */ Y(d, {
orientation: "column",
hideOtherElements: (e) => a(e ? "columnTableHandle" : void 0)
})
}),
/* @__PURE__ */ Y(r, {
reference: s?.cellReference,
portalElement: t.portalElement,
...u?.tableCellHandle,
children: o.show && o.rowIndex !== void 0 && o.colIndex !== void 0 && (!i || i === "tableCellHandle") && /* @__PURE__ */ Y(p, { hideOtherElements: (e) => a(e ? "tableCellHandle" : void 0) })
}),
/* @__PURE__ */ Y(r, {
reference: s?.tableReference,
portalElement: t.portalElement,
...u?.extendRowsButton,
children: o.show && o.showAddOrRemoveRowsButton && (!i || i === "extendRowsButton") && /* @__PURE__ */ Y(f, {
orientation: "addOrRemoveRows",
hideOtherElements: (e) => a(e ? "extendRowsButton" : void 0)
})
}),
/* @__PURE__ */ Y(r, {
reference: s?.tableReference,
portalElement: t.portalElement,
...u?.extendColumnsButton,
children: o.show && o.showAddOrRemoveColumnsButton && (!i || i === "extendColumnsButton") && /* @__PURE__ */ Y(f, {
orientation: "addOrRemoveColumns",
hideOtherElements: (e) => a(e ? "extendColumnsButton" : void 0)
})
})
] });
};
//#endregion
//#region src/editor/portalElements.ts
function Q(e) {
if (e !== void 0) {
if (e === null) return typeof document < "u" ? document.body : 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 di = C(() => Promise.resolve().then(() => Ma)), fi = C(() => Promise.resolve().then(() => La));
function pi(t) {
let n = e();
if (!n) throw Error("BlockNoteDefaultUI must be used within a BlockNoteContext.Provider");
let r = t.portalElements, i = Q(r?.formattingToolbar), a = Q(r?.linkToolbar), o = Q(r?.slashMenu), s = Q(r?.emojiPicker), c = Q(r?.sideMenu), l = Q(r?.filePanel), u = Q(r?.tableHandles), d = Q(r?.comments), f = Q(r?.attributionTooltip);
return /* @__PURE__ */ X(J, { children: [
n.getExtension(I) && t.formattingToolbar !== !1 && /* @__PURE__ */ Y(dr, { portalElement: i }),
n.getExtension(re) && t.linkToolbar !== !1 && /* @__PURE__ */ Y(gr, { portalElement: a }),
n.getExtension(R) && t.slashMenu !== !1 && /* @__PURE__ */ Y(Xr, {
triggerCharacter: "/",
shouldOpen: (e) => !e.selection.$from.parent.type.isInGroup("tableContent"),
portalElement: o
}),
n.getExtension(R) && t.emojiPicker !== !1 && /* @__PURE__ */ Y(Hr, {
triggerCharacter: ":",
columns: 10,
minQueryLength: 2,
portalElement: s
}),
n.getExtension(L) && t.sideMenu !== !1 && /* @__PURE__ */ Y(jr, { portalElement: c }),
n.getExtension(F) && t.filePanel !== !1 && /* @__PURE__ */ Y(gt, { portalElement: l }),
n.getExtension(z) && t.tableHandles !== !1 && /* @__PURE__ */ Y(ui, { portalElement: u }),
n.getExtension(N) && t.comments !== !1 && /* @__PURE__ */ X(b, { children: [/* @__PURE__ */ Y(di, { portalElement: d }), /* @__PURE__ */ Y(fi, { portalElement: d })] }),
n.getExtension("attribution") && t.attributionTooltip !== !1 && /* @__PURE__ */ Y(Pr, { portalElement: f })
] });
}
//#endregion
//#region src/hooks/useEditorChange.ts
function mi(e, t) {
let n = v();
t ||= n?.editor, D(() => {
if (!t) throw Error("'editor' is required, either from BlockNoteContext or as a function argument");
return t.onChange(e);
}, [e, t]);
}
//#endregion
//#region src/hooks/useEditorSelectionChange.ts
function hi(e, t, n) {
let r = v();
t ||= r?.editor, D(() => {
if (!t) throw Error("'editor' is required, either from BlockNoteContext or as a function argument");
return t.onSelectionChange(e, n);
}, [
e,
t,
n
]);
}
//#endregion
//#region src/hooks/usePrefersColorScheme.ts
var gi = () => {
let e = k(() => window.matchMedia?.("(prefers-color-scheme: dark)"), []), t = k(() => window.matchMedia?.("(prefers-color-scheme: light)"), []), n = e?.matches, r = t?.matches, [i, a] = j(n ? "dark" : r ? "light" : "no-preference");
return D(() => {
a(n ? "dark" : r ? "light" : "no-preference");
}, [n, r]), D(() => {
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;
}, _i = x(void 0);
function vi() {
return E(_i);
}
//#endregion
//#region src/editor/EditorContent.tsx
function yi() {
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]: et(r.reactElement, r.element, n)
}, e.forEach((e) => e());
},
removeRenderer(n) {
let r = { ...t };
delete r[n], t = r, e.forEach((e) => e());
}
};
}
var bi = ({ contentComponent: e }) => {
let t = M(e.subscribe, e.getSnapshot, e.getServerSnapshot);
return /* @__PURE__ */ Y(J, { children: Object.values(t) });
}, xi = S((e, t) => {
let [n, r] = j();
return O(t, () => (e, t) => {
tt(() => {
r({
node: e,
container: t
});
}), r(void 0);
}, []), /* @__PURE__ */ Y(J, { children: n && et(n.node, n.container) });
}), Si = () => {};
function Ci(e, t) {
let { editor: n, className: r, theme: i, children: a, editable: o, onSelectionChange: s, onChange: c, formattingToolbar: l, linkToolbar: u, slashMenu: d, emojiPicker: f, sideMenu: p, filePanel: m, tableHandles: h, comments: y, portalElements: b, autoFocus: x, renderEditor: S = !0, ...C } = e, w = k(() => Q(b?.default) ?? null, [b?.default]), [E, ee] = j(), O = v(), te = gi(), A = O?.colorSchemePreference || te, M = i || (A === "dark" ? "dark" : "light"), N = g(), P = k(() => ({
formattingToolbar: N ? l : !1,
linkToolbar: N ? u : !1,
sideMenu: N ? p : !1,
slashMenu: N ? d : !1,
filePanel: N ? m : !1,
tableHandles: N ? h : !1,
emojiPicker: N ? f : !1,
comments: N ? y : !1,
portalElements: b
}), [
y,
N,
f,
m,
l,
u,
p,
d,
h,
b
]);
mi(c || Si, n), hi(s || Si, n);
let ne = T((e) => {
n.elementRenderer = e;
}, [n]);
D(() => {
if (!n.portalElement) throw Error("Portal element not found");
n.portalElement.className = q("bn-root", M, r || ""), n.portalElement.setAttribute("data-color-scheme", M);
}, [
n,
M,
r
]);
let F = k(() => ({
...O,
editor: n,
setContentEditableProps: ee,
colorSchemePreference: M
}), [
O,
n,
M
]), I = k(() => ({
editorProps: {
autoFocus: x,
contentEditableProps: E,
editable: o,
portalTarget: w
},
defaultUIProps: P
}), [
x,
E,
o,
P,
w
]);
return /* @__PURE__ */ Y(_.Provider, {
value: F,
children: /* @__PURE__ */ X(_i.Provider, {
value: I,
children: [/* @__PURE__ */ Y(xi, { ref: ne }), /* @__PURE__ */ Y(wi, {
className: r,
renderEditor: S,
editorColorScheme: M,
ref: t,
...C,
children: a
})]
})
});
}
var wi = y.forwardRef(({ className: e, renderEditor: t, editorColorScheme: n, children: r, ...i }, a) => /* @__PURE__ */ Y("div", {
className: q("bn-root", "bn-container", n, e),
"data-color-scheme": n,
...i,
ref: a,
children: t ? /* @__PURE__ */ Y(Ei, { children: r }) : r
})), Ti = y.forwardRef(Ci), Ei = (t) => {
let n = vi(), r = e(), i = k(() => yi(), []), a = n.editorProps.portalTarget, o = T((e) => {
r.isEditable = n.editorProps.editable !== !1, r._tiptapEditor.contentComponent = i, e ? r.mount(e, { portalTarget: a }) : r.unmount();
}, [
n.editorProps.editable,
r,
i,
a
]);
return /* @__PURE__ */ X(J, { children: [
/* @__PURE__ */ Y(bi, { contentComponent: i }),
/* @__PURE__ */ Y(Di, {
...n.editorProps,
...t,
mount: o
}),
/* @__PURE__ */ Y(pi, { ...n.defaultUIProps }),
t.children
] });
}, Di = (e) => {
let { autoFocus: t, mount: n, contentEditableProps: r } = e;
return /* @__PURE__ */ Y("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 = ct(r), tt(() => {
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 Oi(e, t) {
let n = A(t), r = e.view.state.doc;
try {
n.current = Ie(e.getPos, r);
} catch {}
return n.current;
}
//#endregion
//#region src/schema/ReactBlockSpec.tsx
function ki(e) {
return /* @__PURE__ */ Y(rt, {
onDragOver: (e) => e.preventDefault(),
...Object.fromEntries(Object.entries(e.domAttributes || {}).filter(([e]) => e !== "class")),
className: q("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]) => [we(e), t])),
"data-file-block": e.isFileBlock === !0 || void 0,
children: e.children
});
}
function Ai(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__ */ Y(ki, {
blockType: e.type,
blockProps: e.props,
propSchema: i.propSchema,
domAttributes: this.blockContentDOMAttributes,
isFileBlock: a.meta?.fileBlockAccept !== void 0,
children: /* @__PURE__ */ Y(r, {
block: e,
editor: t,
contentRef: (e) => {
o(e), e && (e.className = q("bn-inline-content", e.className));
},
context: n
})
}), t);
},
render(e, t) {
if (this.renderType === "nodeView") {
let n = e;
return ot((e) => {
let r = Oi(e, n), o = st().nodeViewContentRef;
if (!o) throw Error("nodeViewContentRef is not set");
let s = a.render;
return /* @__PURE__ */ Y(ki, {
blockType: r.type,
blockProps: r.props,
propSchema: i.propSchema,
isFileBlock: !!a.meta?.fileBlockAccept,
domAttributes: this.blockContentDOMAttributes,
children: /* @__PURE__ */ Y(s, {
block: r,
editor: t,
contentRef: (e) => {
o(e), e && (e.className = q("bn-inline-content", e.className), e.dataset.nodeViewContent = "");
}
})
});
}, { className: "bn-react-node-view-renderer" })(this.props);
}
{
let n = a.render;
return $((r) => /* @__PURE__ */ Y(ki, {
blockType: e.type,
blockProps: e.props,
propSchema: i.propSchema,
domAttributes: this.blockContentDOMAttributes,
children: /* @__PURE__ */ Y(n, {
block: e,
editor: t,
contentRef: (e) => {
r(e), e && (e.className = q("bn-inline-content", e.className));
}
})
}), t);
}
}
},
extensions: o
};
};
}
//#endregion
//#region src/blocks/File/useResolveUrl.tsx
function ji(t) {
let n = e(), [r, i] = j("loading"), [a, o] = j();
if (D(() => {
let e = !0;
return (async () => {
let r = "";
i("loading");
try {
r = n.resolveFileUrl ? await n.resolveFileUrl(t) : t;
} catch {
i("error");
return;
}
e && (i("loaded"), o(r));
})(), () => {
e = !1;
};
}, [n, t]), r !== "loaded") return { loadingState: r };
if (!a) throw Error("Finished fetching file but did not get download URL.");
return {
loadingState: r,
downloadUrl: a
};
}
//#endregion
//#region src/blocks/File/helpers/toExternalHTML/FigureWithCaption.tsx
var Mi = (e) => /* @__PURE__ */ X("figure", { children: [e.children, /* @__PURE__ */ Y("figcaption", { children: e.caption })] });
//#endregion
//#region src/hooks/useOnUploadEnd.ts
function Ni(t) {
let n = e();
D(() => n.onUploadEnd(t), [t, n]);
}
//#endregion
//#region src/hooks/useOnUploadStart.ts
function Pi(t) {
let n = e();
D(() => n.onUploadStart(t), [t, n]);
}
//#endregion
//#region src/hooks/useUploadLoading.ts
function Fi(e) {
let [t, n] = j(!1);
return Pi((t) => {
t === e && n(!0);
}), Ni((t) => {
t === e && n(!1);
}), t;
}
//#endregion
//#region src/blocks/File/helpers/render/AddFileButton.tsx
var Ii = (t) => {
let r = e(), i = n(), a = f(F), o = T((e) => {
e.preventDefault();
}, []), s = T(() => {
r.isEditable && t.editor.transact(() => a.showMenu(t.block.id));
}, [
r.isEditable,
a,
t.block.id,
t.editor
]);
return /* @__PURE__ */ X("div", {
className: "bn-add-file-button",
onMouseDown: o,
onClick: s,
children: [/* @__PURE__ */ Y("div", {
className: "bn-add-file-button-icon",
children: t.buttonIcon || /* @__PURE__ */ Y(En, { size: 24 })
}), /* @__PURE__ */ Y("div", {
className: "bn-add-file-button-text",
children: t.block.type in i.file_blocks.add_button_text ? i.file_blocks.add_button_text[t.block.type] : i.file_blocks.add_button_text.file
})]
});
}, Li = (e) => /* @__PURE__ */ X("div", {
className: "bn-file-name-with-icon",
contentEditable: !1,
draggable: !1,
children: [/* @__PURE__ */ Y("div", {
className: "bn-file-icon",
children: /* @__PURE__ */ Y(En, { size: 24 })
}), /* @__PURE__ */ Y("p", {
className: "bn-file-name",
children: e.block.props.name
})]
}), Ri = (e) => {
let t = Fi(e.block.id), n = e.block.props.url !== "" && e.block.props.caption && !t ? "figure" : "div";
return /* @__PURE__ */ Y(n, {
className: "bn-file-block-content-wrapper",
onMouseEnter: e.onMouseEnter,
onMouseLeave: e.onMouseLeave,
style: e.style,
children: t ? /* @__PURE__ */ Y("div", {
className: "bn-file-loading-preview",
children: "Loading..."
}) : e.block.props.url === "" ? /* @__PURE__ */ Y(Ii, { ...e }) : /* @__PURE__ */ X(J, { children: [e.block.props.showPreview === !1 || !e.children ? /* @__PURE__ */ Y(Li, { ...e }) : e.children, e.block.props.caption && /* @__PURE__ */ Y("figcaption", {
className: "bn-file-caption",
children: e.block.props.caption
})] })
});
}, zi = (e) => /* @__PURE__ */ X("div", { children: [e.children, /* @__PURE__ */ Y("p", { children: e.caption })] }), Bi = (e) => {
let t = ji(e.block.props.url);
return /* @__PURE__ */ Y("audio", {
className: "bn-audio",
src: t.loadingState === "loading" ? e.block.props.url : t.downloadUrl,
controls: !0,
contentEditable: !1,
draggable: !1
});
}, Vi = (e) => {
if (!e.block.props.url) return /* @__PURE__ */ Y("p", { children: "Add audio" });
let t = e.block.props.showPreview ? /* @__PURE__ */ Y("audio", { src: e.block.props.url }) : /* @__PURE__ */ Y("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__ */ Y(Mi, {
caption: e.block.props.caption,
children: t
}) : /* @__PURE__ */ Y(zi, {
caption: e.block.props.caption,
children: t
}) : t;
}, Hi = (e) => /* @__PURE__ */ Y(Ri, {
...e,
buttonIcon: /* @__PURE__ */ Y(Ht, { size: 24 }),
children: /* @__PURE__ */ Y(Bi, { ...e })
}), Ui = Ai(Te, (e) => ({
meta: { fileBlockAccept: ["audio/*"] },
render: Hi,
parse: Ce(e),
toExternalHTML: Vi,
runsBefore: ["file"]
})), Wi = Ai(Ee, {
render: (e) => /* @__PURE__ */ Y(Ri, { ...e }),
parse: Ne(),
toExternalHTML: (e) => {
if (!e.block.props.url) return /* @__PURE__ */ Y("p", { children: "Add file" });
let t = /* @__PURE__ */ Y("a", {
href: e.block.props.url,
children: e.block.props.name || e.block.props.url
});
return e.block.props.caption ? /* @__PURE__ */ Y(zi, {
caption: e.block.props.caption,
children: t
}) : t;
}
}), Gi = (e) => {
let [t, n] = j(void 0), [r, i] = j(e.block.props.previewWidth), [a, o] = j(!1), s = A(null);
D(() => {
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 = T(() => {
e.editor.isEditable && o(!0);
}, [e.editor.isEditable]), l = T(() => {
o(!1);
}, []), u = T((e) => {
e.preventDefault();
let t = "touches" in e ? e.touches[0].clientX : e.clientX;
n({
handleUsed: "left",
initialWidth: s.current.clientWidth,
initialClientX: t
});
}, []), d = T((e) => {
e.preventDefault();
let t = "touches" in e ? e.touches[0].clientX : e.clientX;
n({
handleUsed: "right",
initialWidth: s.current.clientWidth,
initialClientX: t
});
}, []), f = Fi(e.block.id);
return /* @__PURE__ */ Y(Ri, {
...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__ */ X("div", {
className: "bn-visual-media-wrapper",
style: { position: "relative" },
ref: s,
children: [
e.children,
/* @__PURE__ */ Y("div", {
className: "bn-resize-handle",
style: {
left: "4px",
display: a || t ? "initial" : "none"
},
onMouseDown: u,
onTouchStart: u
}),
/* @__PURE__ */ Y("div", {
className: "bn-resize-handle",
style: {
right: "4px",
display: a || t ? "initial" : "none"
},
onMouseDown: d,
onTouchStart: d
}),
t && /* @__PURE__ */ Y("div", { style: {
position: "absolute",
height: "100%",
width: "100%"
} })
]
})
});
}, Ki = (e) => {
let t = ji(e.block.props.url), n = e.block.props.name || "";
return /* @__PURE__ */ Y("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
});
}, qi = (e) => {
if (!e.block.props.url) return /* @__PURE__ */ Y("p", { children: "Add image" });
let t = e.block.props.name || "", n = e.block.props.showPreview ? /* @__PURE__ */ Y("img", {
src: e.block.props.url,
alt: t,
width: e.block.props.previewWidth
}) : /* @__PURE__ */ Y("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__ */ Y(Mi, {
caption: e.block.props.caption,
children: n
}) : /* @__PURE__ */ Y(zi, {
caption: e.block.props.caption,
children: n
}) : n;
}, Ji = (e) => /* @__PURE__ */ Y(Gi, {
...e,
buttonIcon: /* @__PURE__ */ Y(qt, { size: 24 }),
children: /* @__PURE__ */ Y(Ki, { ...e })
}), Yi = Ai(De, (e) => ({
meta: { fileBlockAccept: ["image/*"] },
render: Ji,
parse: Ue(e),
toExternalHTML: qi,
runsBefore: ["file"]
}));
//#endregion
//#region ../../node_modules/.pnpm/react-icons@5.6.0_react@19.2.5/node_modules/react-icons/tb/index.mjs
function Xi(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 Zi = { page_break: Xi };
function Qi(e) {
return Be(e).map((e) => {
let t = Zi[e.key];
return {
...e,
icon: /* @__PURE__ */ Y(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 $i(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 ea = (e) => /* @__PURE__ */ X("div", {
className: "bn-preview-placeholder" + (e.error ? " bn-preview-placeholder-error" : ""),
contentEditable: !1,
children: [/* @__PURE__ */ Y("div", {
className: "bn-preview-placeholder-icon",
"aria-hidden": "true",
children: e.icon ?? (e.error ? /* @__PURE__ */ Y(xr, {}) : /* @__PURE__ */ Y($i, {}))
}), /* @__PURE__ */ Y("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 = A(!1);
c == null ? f.current = !1 : n.isOpen || (f.current = !0);
let p = l == null || typeof l == "string" ? /* @__PURE__ */ Y(ea, { text: l ?? t.dictionary.code_block.add_source_button_text }) : l, m = u == null || typeof u == "string" ? /* @__PURE__ */ Y(ea, {
error: !0,
text: u ?? "Error"
}) : u, h = ee(), 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__ */ X(b, {
className: "bn-preview-with-source-popup" + (n.isSelected ? " ProseMirror-selectednode" : ""),
"data-open": n.isOpen ? "true" : "false",
children: [/* @__PURE__ */ Y(x, {
className: "bn-preview-container",
contentEditable: !1,
role: _ ? "button" : void 0,
onClick: v,
children: g
}), /* @__PURE__ */ X("div", {
className: "bn-source-block-popup",
children: [/* @__PURE__ */ X("div", {
className: "bn-code-block-source-popup-body",
children: [/* @__PURE__ */ X("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__ */ Y("code", {
ref: a,
"aria-label": d,
"aria-invalid": c ? !0 : void 0,
"aria-describedby": c ? h : void 0
}), r && o.length === 0 && /* @__PURE__ */ Y("br", {
"aria-hidden": "true",
contentEditable: !1
})]
}), /* @__PURE__ */ Y("div", {
className: "bn-code-block-source-popup-ok-button-wrapper",
contentEditable: !1,
inert: !n.isOpen,
children: /* @__PURE__ */ X("button", {
type: "button",
className: "bn-code-block-source-popup-ok-button",
onClick: y,
children: [t.dictionary.code_block.ok_button_text, i && /* @__PURE__ */ Y(br, {
className: "bn-code-block-source-popup-ok-button-icon",
"aria-hidden": "true"
})]
})
})]
}), /* @__PURE__ */ Y("div", {
id: h,
className: "bn-code-block-source-error",
contentEditable: !1,
style: { display: c ? "block" : "none" },
role: "alert",
inert: !n.isOpen,
children: c
})]
})]
});
}, na = (e) => {
let { editor: t, block: n } = e, { store: r } = f(_e, { editor: t });
return {
isOpen: l(_e, {
editor: t,
selector: (e) => e.popupOpen === n.id
}),
isSelected: l(_e, {
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();
}
};
}, ra = (e) => {
let { block: t, editor: n, ...r } = e, i = na({
editor: n,
block: t
}), a = n.schema.blockSpecs[t.type]?.implementation?.meta?.hardBreakShortcut !== "enter";
return /* @__PURE__ */ Y(ta, {
editor: n,
popup: i,
enterSubmits: a,
...r
});
}, ia = (e) => {
let { editor: t, node: n, getPos: r } = e, { store: i } = f(ve, { editor: t }), a = l(ve, {
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(lt.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(lt.create(i.state.tr.doc, e + n.nodeSize))), t.focus();
}
};
}, aa = (e) => {
let { editor: t, node: n, getPos: r, ...i } = e, a = ia({
editor: t,
node: n,
getPos: r
});
return /* @__PURE__ */ Y(ta, {
inline: !0,
editor: t,
popup: a,
...i
});
}, oa = (e) => {
let t = ji(e.block.props.url);
return /* @__PURE__ */ Y("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
});
}, sa = (e) => {
if (!e.block.props.url) return /* @__PURE__ */ Y("p", { children: "Add video" });
let t = e.block.props.showPreview ? /* @__PURE__ */ Y("video", {
src: e.block.props.url,
width: e.block.props.previewWidth || void 0
}) : /* @__PURE__ */ Y("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__ */ Y(Mi, {
caption: e.block.props.caption,
children: t
}) : /* @__PURE__ */ Y(zi, {
caption: e.block.props.caption,
children: t
}) : t;
}, ca = (e) => /* @__PURE__ */ Y(Gi, {
...e,
buttonIcon: /* @__PURE__ */ Y(Ut, { size: 24 }),
children: /* @__PURE__ */ Y(oa, { ...e })
}), la = Ai(Ae, (e) => ({
meta: { fileBlockAccept: ["video/*"] },
render: ca,
parse: Qe(e),
toExternalHTML: sa,
runsBefore: ["file"]
})), ua = (e, t) => {
if (t.type === "toggled") return !e;
if (t.type === "childAdded") return !0;
if (t.type === "lastChildRemoved") return !1;
throw new ye(t);
}, da = (e) => {
let { block: t, editor: n, children: r, toggledState: i } = e, [a, o] = te(ua, (i || Me).get(t)), s = (e) => {
let t = n.getBlock(e);
t && ((i || Me).set(t, !a), o({ type: "toggled" }));
}, c = (e) => {
(i || Me).set(e, !0), o({ type: "childAdded" });
}, l = (e) => {
(i || Me).set(e, !1), o({ type: "lastChildRemoved" });
}, u = m({
editor: n,
selector: ({ editor: e }) => {
if (!G(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__ */ X("div", { children: [/* @__PURE__ */ X("div", {
className: "bn-toggle-wrapper",
"data-show-children": a,
children: [/* @__PURE__ */ Y("button", {
className: "bn-toggle-button",
type: "button",
onMouseDown: (e) => e.preventDefault(),
onClick: () => s(t),
children: /* @__PURE__ */ Y("svg", {
xmlns: "http://www.w3.org/2000/svg",
height: "1em",
viewBox: "0 -960 960 960",
width: "1em",
fill: "currentcolor",
children: /* @__PURE__ */ Y("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__ */ Y("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
})] });
}, fa = (t) => {
let n = A(null), r = e(), i = l(I, { editor: r });
if (D(() => {
let e = n.current;
if (!e) return;
let t = (t) => {
e.style.setProperty("--bn-mobile-keyboard-offset", t > 0 ? `${t}px` : "0px");
}, r, i = () => {
let t = window.getSelection();
if (!t || t.rangeCount === 0) return;
let n = t.getRangeAt(0).getBoundingClientRect(), r = window.visualViewport;
if (!r) return;
let i = e.getBoundingClientRect().height || 44, a = r.offsetTop + r.height - i;
n.bottom > a ? window.scrollBy({
top: n.bottom - a + 16,
behavior: "smooth"
}) : n.top < r.offsetTop && window.scrollBy({
top: n.top - r.offsetTop - 16,
behavior: "smooth"
});
}, a = navigator.virtualKeyboard;
if (a) {
a.overlaysContent = !0;
let e = () => {
t(a.boundingRect.height), clearTimeout(r), r = setTimeout(i, 100);
};
a.addEventListener("geometrychange", e);
let n = () => i();
return document.addEventListener("selectionchange", n), () => {
a.removeEventListener("geometrychange", e), document.removeEventListener("selectionchange", n), clearTimeout(r);
};
}
let o = window.visualViewport;
if (!o) return;
let s = 0, c = () => {
let e = document.documentElement.clientHeight - o.height - o.offsetTop;
e > 50 && (s = e), t(e), clearTimeout(r), r = setTimeout(i, 100);
}, l = (e) => {
let n = e.target;
(n.isContentEditable || n.tagName === "INPUT" || n.tagName === "TEXTAREA") && s > 0 && t(s);
}, u = () => {
t(0);
}, d = () => i();
return o.addEventListener("resize", c), o.addEventListener("scroll", c), document.addEventListener("focusin", l), document.addEventListener("focusout", u), document.addEventListener("selectionchange", d), () => {
o.removeEventListener("resize", c), o.removeEventListener("scroll", c), document.removeEventListener("focusin", l), document.removeEventListener("focusout", u), document.removeEventListener("selectionchange", d), clearTimeout(r);
};
}, []), !i && n.current) return /* @__PURE__ */ Y("div", {
ref: n,
className: "bn-mobile-formatting-toolbar",
dangerouslySetInnerHTML: { __html: n.current.innerHTML }
});
let a = t.formattingToolbar || lr;
return /* @__PURE__ */ Y("div", {
ref: n,
className: "bn-mobile-formatting-toolbar",
children: /* @__PURE__ */ Y(a, {})
});
};
//#endregion
//#region src/components/TableHandles/hooks/useExtendButtonsPositioning.ts
function pa(e, t, n) {
let { refs: r, update: i, context: a, floatingStyles: o } = pe({
open: t,
placement: e === "addOrRemoveColumns" ? "right" : "bottom",
middleware: [W({ 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 } = me(a);
return D(() => {
i();
}, [n, i]), D(() => {
n !== null && r.setReference({ getBoundingClientRect: () => n });
}, [
e,
n,
r
]), k(() => ({
isMounted: s,
ref: r.setFloating,
style: {
display: "flex",
...c,
...o
}
}), [
o,
s,
r.setFloating,
c
]);
}
function ma(e, t, n) {
let r = pa("addOrRemoveRows", t, n), i = pa("addOrRemoveColumns", e, n);
return k(() => ({
addOrRemoveRowsButton: r,
addOrRemoveColumnsButton: i
}), [i, r]);
}
//#endregion
//#region src/components/TableHandles/hooks/useTableHandlesPositioning.ts
function ha(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 ga(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 _a(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 } = pe({
open: t,
placement: e === "row" ? "left" : e === "col" ? "top" : "bottom-end",
middleware: [H(e === "row" ? -10 : e === "col" ? -12 : {
mainAxis: 1,
crossAxis: -1
})]
}), { isMounted: l, styles: u } = me(s);
return D(() => {
o();
}, [
n,
r,
o
]), D(() => {
n === null || r === null || i && e === "cell" || a.setReference({ getBoundingClientRect: () => (e === "row" ? ha : e === "col" ? ga : _a)(n, r, i) });
}, [
i,
e,
n,
r,
a
]), k(() => ({
isMounted: l,
ref: a.setFloating,
style: {
display: "flex",
...u,
...c
}
}), [
c,
l,
a.setFloating,
u
]);
}
function ya(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 k(() => ({
rowHandle: i,
colHandle: a,
cellHandle: o
}), [
a,
i,
o
]);
}
//#endregion
//#region src/components/Comments/EmojiMartPicker.tsx
var ba;
async function xa() {
return ba || (ba = (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
};
})(), ba);
}
function Sa(e) {
let t = A(null), n = A(null);
return n.current && n.current.update(e), D(() => ((async () => {
let { emojiMart: r } = await xa();
n.current = new r.Picker({
...e,
ref: t
});
})(), () => {
n.current = null;
}), []), y.createElement("div", { ref: t });
}
//#endregion
//#region src/components/Comments/EmojiPicker.tsx
var Ca = (e) => {
let [t, n] = j(!1), r = g(), i = v(), a = i.editor?.portalElement;
if (!a) throw Error("Portal root not found");
return /* @__PURE__ */ X(r.Generic.Popover.Root, {
open: t,
portalRoot: a,
children: [/* @__PURE__ */ Y(r.Generic.Popover.Trigger, { children: /* @__PURE__ */ Y("div", {
onClick: (r) => {
r.preventDefault(), r.stopPropagation(), n(!t), e.onOpenChange?.(!t);
},
style: {
display: "flex",
justifyContent: "center",
alignItems: "center"
},
children: e.children
}) }), /* @__PURE__ */ Y(r.Generic.Popover.Content, {
className: "bn-emoji-picker-popover",
variant: "panel-popover",
children: /* @__PURE__ */ Y(Sa, {
perLine: 7,
onClickOutside: () => {
n(!1), e.onOpenChange?.(!1);
},
onEmojiSelect: (t) => {
e.onEmojiSelect(t), n(!1), e.onOpenChange?.(!1);
},
theme: i?.colorSchemePreference
})
})]
});
};
//#endregion
//#region src/components/Comments/useCommentUsers.ts
function wa(e) {
let { userStore: t } = f(N), n = e.join(",");
return D(() => {
t.loadUsers(e);
}, [t, n]), a(t.store, (t) => {
let n = /* @__PURE__ */ new Map();
for (let r of e) {
let e = t.get(r);
e && n.set(r, e);
}
return n;
});
}
function Ta(e) {
return wa([e]).get(e);
}
//#endregion
//#region src/components/Comments/ReactionBadge.tsx
var Ea = (e) => {
let t = g(), r = n(), i = f(N), a = e.comment.reactions.find((t) => t.emoji === e.emoji);
if (!a) throw Error("Trying to render reaction badge for non-existing reaction");
let [o, s] = j([]), c = wa(o);
return /* @__PURE__ */ Y(t.Generic.Badge.Root, {
className: q("bn-badge", "bn-comment-reaction"),
text: a.userIds.length.toString(),
icon: a.emoji,
isSelected: i.threadStore.auth.canDeleteReaction(e.comment, a.emoji),
onClick: () => e.onReactionSelect(a.emoji),
onMouseEnter: () => s(a.userIds),
mainTooltip: r.comments.reactions.reacted_by,
secondaryTooltip: `${Array.from(c.values()).map((e) => e.username).join("\n")}`
}, a.emoji);
}, Da = w(({ 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__ */ X(J, { children: [t.reactions.length > 0 && !n && /* @__PURE__ */ X(c.Generic.Badge.Group, {
className: q("bn-badge-group", "bn-comment-reactions"),
children: [t.reactions.map((e) => /* @__PURE__ */ Y(Ea, {
comment: t,
emoji: e.emoji,
onReactionSelect: i
}, e.emoji)), u && /* @__PURE__ */ Y(Ca, {
onEmojiSelect: (e) => i(e.native),
onOpenChange: s,
children: /* @__PURE__ */ Y(c.Generic.Badge.Root, {
className: q("bn-badge", "bn-comment-add-reaction"),
text: "+",
icon: /* @__PURE__ */ Y(At, { size: 16 }),
mainTooltip: l.comments.actions.add_reaction
})
})]
}), n && /* @__PURE__ */ X(c.Generic.Toolbar.Root, {
variant: "action-toolbar",
className: q("bn-action-toolbar", "bn-comment-actions"),
children: [/* @__PURE__ */ Y(c.Generic.Toolbar.Button, {
mainTooltip: l.comments.save_button_text,
variant: "compact",
onClick: a,
isDisabled: e,
children: l.comments.save_button_text
}), /* @__PURE__ */ Y(c.Generic.Toolbar.Button, {
className: "bn-button",
mainTooltip: l.comments.cancel_button_text,
variant: "compact",
onClick: o,
children: l.comments.cancel_button_text
})]
})] });
}), Oa = ({ comment: e, thread: t, showResolveButton: r }) => {
let i = f(N), a = n(), o = s({
initialContent: e.body,
trailingBlock: !1,
dictionary: {
...a,
placeholders: { emptyDocument: a.placeholders.edit_comment }
},
schema: i.commentEditorSchema || u
}), c = g(), [l, d] = j(!1), [m, h] = j(!1), _ = i.threadStore, v = T(() => {
d(!0);
}, []), y = T(() => {
o.replaceBlocks(o.document, e.body), d(!1);
}, [o, e.body]), b = T(async (n) => {
await _.updateComment({
commentId: e.id,
comment: { body: o.document },
threadId: t.id
}), d(!1);
}, [
e,
t.id,
o,
_
]), x = T(async () => {
await _.deleteComment({
commentId: e.id,
threadId: t.id
});
}, [
e,
t.id,
_
]), S = T(async (n) => {
_.auth.canAddReaction(e, n) ? await _.addReaction({
threadId: t.id,
commentId: e.id,
emoji: n
}) : _.auth.canDeleteReaction(e, n) && await _.deleteReaction({
threadId: t.id,
commentId: e.id,
emoji: n
});
}, [
_,
e,
t.id
]), C = T(async () => {
await _.resolveThread({ threadId: t.id });
}, [t.id, _]), w = T(async () => {
await _.unresolveThread({ threadId: t.id });
}, [t.id, _]), E = Ta(e.userId);
if (!e.body) return null;
let D, ee = _.auth.canAddReaction(e), O = _.auth.canDeleteComment(e), k = _.auth.canUpdateComment(e), te = r && (t.resolved ? _.auth.canUnresolveThread(t) : _.auth.canResolveThread(t));
l || (D = /* @__PURE__ */ X(c.Generic.Toolbar.Root, {
className: q("bn-action-toolbar", "bn-comment-actions"),
variant: "action-toolbar",
children: [
ee && /* @__PURE__ */ Y(Ca, {
onEmojiSelect: (e) => S(e.native),
onOpenChange: h,
children: /* @__PURE__ */ Y(c.Generic.Toolbar.Button, {
mainTooltip: a.comments.actions.add_reaction,
variant: "compact",
children: /* @__PURE__ */ Y(At, { size: 16 })
}, "add-reaction")
}),
te && (t.resolved ? /* @__PURE__ */ Y(c.Generic.Toolbar.Button, {
mainTooltip: a.comments.actions.reopen,
variant: "compact",
onClick: w,
children: /* @__PURE__ */ Y(jn, { size: 16 })
}, "reopen") : /* @__PURE__ */ Y(c.Generic.Toolbar.Button, {
mainTooltip: a.comments.actions.resolve,
variant: "compact",
onClick: C,
children: /* @__PURE__ */ Y(Bt, { size: 16 })
}, "resolve")),
(O || k) && /* @__PURE__ */ X(c.Generic.Menu.Root, {
position: "bottom-start",
children: [/* @__PURE__ */ Y(c.Generic.Menu.Trigger, { children: /* @__PURE__ */ Y(c.Generic.Toolbar.Button, {
mainTooltip: a.comments.actions.more_actions,
variant: "compact",
children: /* @__PURE__ */ Y(Nt, { size: 16 })
}, "more-actions") }), /* @__PURE__ */ X(c.Generic.Menu.Dropdown, {
className: "bn-menu-dropdown",
children: [k && /* @__PURE__ */ Y(c.Generic.Menu.Item, {
icon: /* @__PURE__ */ Y(kn, {}),
onClick: v,
children: a.comments.actions.edit_comment
}, "edit-comment"), O && /* @__PURE__ */ Y(c.Generic.Menu.Item, {
icon: /* @__PURE__ */ Y(Lt, {}),
onClick: x,
children: a.comments.actions.delete_comment
}, "delete-comment")]
})]
})
]
}));
let A = e.createdAt.toLocaleDateString(void 0, {
month: "short",
day: "numeric"
});
if (!e.body) throw Error("soft deletes are not yet supported");
return /* @__PURE__ */ Y(c.Comments.Comment, {
authorInfo: E ?? "loading",
timeString: A,
edited: e.updatedAt.getTime() !== e.createdAt.getTime(),
showActions: "hover",
actions: D,
className: "bn-thread-comment",
emojiPickerOpen: m,
children: /* @__PURE__ */ Y(p, {
autoFocus: l,
editor: o,
editable: l,
actions: e.reactions.length > 0 || l ? ({ isFocused: t, isEmpty: n }) => /* @__PURE__ */ Y(Da, {
isFocused: t,
isEmpty: n,
comment: e,
isEditing: l,
threadStore: _,
onReactionSelect: S,
onEditSubmit: b,
onEditCancel: y,
onEmojiPickerOpenChange: h,
Components: c,
dict: a
}) : void 0
})
});
}, ka = ({ thread: e, maxCommentsBeforeCollapse: t }) => {
let r = g(), i = n(), a = wa(e.resolvedBy ? [e.resolvedBy] : []), o = e.comments.map((t, n) => /* @__PURE__ */ Y(Oa, {
thread: e,
comment: t,
showResolveButton: n === 0
}, t.id + JSON.stringify(t.body || "{}")));
if (e.resolved && e.resolvedUpdatedAt && e.resolvedBy) {
if (!a.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;
o.splice(t, 0, /* @__PURE__ */ Y(r.Comments.Comment, {
className: "bn-thread-comment",
authorInfo: e.resolvedBy && a.get(e.resolvedBy) || "loading",
timeString: e.resolvedUpdatedAt.toLocaleDateString(void 0, {
month: "short",
day: "numeric"
}),
edited: !1,
showActions: !1,
children: /* @__PURE__ */ Y("div", {
className: "bn-resolved-text",
children: i.comments.sidebar.marked_as_resolved
})
}, "resolved-comment"));
}
return t && o.length > t && o.splice(1, o.length - 2, /* @__PURE__ */ Y(r.Comments.ExpandSectionsPrompt, {
className: "bn-thread-expand-prompt",
children: i.comments.sidebar.more_replies(e.comments.length - 2)
}, "expand-prompt")), o;
}, Aa = w(({ isEmpty: e, onSave: t, Components: n, dict: r }) => /* @__PURE__ */ Y(n.Generic.Toolbar.Root, {
className: q("bn-action-toolbar", "bn-comment-actions"),
variant: "action-toolbar",
children: /* @__PURE__ */ Y(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 ja(t) {
let r = e(), i = t.newCommentEditor, a = f(N), o = g(), s = n(), c = T(async () => {
await a.createThread({ initialComment: { body: i.document } }), a.stopPendingComment(), r.transact((e) => {
e.setSelection(lt.create(e.doc, e.selection.to));
}), r.focus();
}, [
a,
i,
r
]);
return /* @__PURE__ */ Y(o.Comments.Card, {
className: "bn-thread",
children: /* @__PURE__ */ Y(p, {
autoFocus: !0,
editable: !0,
editor: i,
actions: ({ isFocused: e, isEmpty: t }) => /* @__PURE__ */ Y(Aa, {
isFocused: e,
isEmpty: t,
onSave: c,
Components: o,
dict: s
})
})
});
}
//#endregion
//#region src/components/Comments/FloatingComposerController.tsx
var Ma = /* @__PURE__ */ dt({ default: () => Na });
function Na(r) {
let i = e(), a = n(), o = f(N), c = l(N, {
editor: i,
selector: (e) => e.pendingComment
}), d = s({
trailingBlock: !1,
dictionary: {
...a,
placeholders: { emptyDocument: a.placeholders.new_comment }
},
schema: o.commentEditorSchema || u
}, [c]), p = m({
editor: i,
selector: ({ editor: e }) => c ? {
from: e.prosemirrorState.selection.from,
to: e.prosemirrorState.selection.to
} : void 0
}), g = k(() => ({
...r.floatingUIOptions,
useFloatingOptions: {
open: !!c,
onOpenChange: (e) => {
if (!e) {
if (!h({
hasUnsavedContent: !d.isEmpty,
confirmBeforeDiscard: o.confirmBeforeDiscard,
message: a.comments.discard_pending_comment
})) return;
o.stopPendingComment(), i.focus();
}
},
placement: "bottom",
middleware: [
H(10),
U(),
V()
],
...r.floatingUIOptions?.useFloatingOptions
},
focusManagerProps: { disabled: !1 },
elementProps: {
style: { zIndex: 60 },
...r.floatingUIOptions?.elementProps
}
}), [
o,
a,
i,
d,
c,
r.floatingUIOptions
]), _ = r.floatingComposer || ja;
return /* @__PURE__ */ Y(t, {
position: p,
portalElement: r.portalElement,
...g,
children: /* @__PURE__ */ Y(_, { newCommentEditor: d })
});
}
//#endregion
//#region src/components/Comments/Thread.tsx
var Pa = w(({ isEmpty: e, onNewCommentSave: t, Components: n, dict: r }) => e ? null : /* @__PURE__ */ Y(n.Generic.Toolbar.Root, {
variant: "action-toolbar",
className: q("bn-action-toolbar", "bn-comment-actions"),
children: /* @__PURE__ */ Y(n.Generic.Toolbar.Button, {
mainTooltip: r.comments.save_button_text,
variant: "compact",
isDisabled: e,
onClick: t,
children: r.comments.save_button_text
})
})), Fa = ({ thread: e, selected: t, orphaned: r, referenceText: i, maxCommentsBeforeCollapse: a, onFocus: o, onBlur: c, tabIndex: l, newCommentEditor: d }) => {
let m = g(), h = n(), _ = f(N), v = s({
trailingBlock: !1,
dictionary: {
...h,
placeholders: { emptyDocument: h.placeholders.comment_reply }
},
schema: _.commentEditorSchema || u
}), y = d ?? v, b = T(async () => {
await _.threadStore.addComment({
comment: { body: y.document },
threadId: e.id
}), y.removeBlocks(y.document);
}, [
_,
y,
e.id
]);
return /* @__PURE__ */ X(m.Comments.Card, {
className: q("bn-thread", r && "bn-thread-orphaned"),
headerText: i,
onFocus: o,
onBlur: c,
selected: t,
tabIndex: l,
children: [/* @__PURE__ */ Y(m.Comments.CardSection, {
className: "bn-thread-comments",
children: /* @__PURE__ */ Y(ka, {
thread: e,
maxCommentsBeforeCollapse: t ? void 0 : a || 5
})
}), t && /* @__PURE__ */ Y(m.Comments.CardSection, {
className: "bn-thread-composer",
children: /* @__PURE__ */ Y(p, {
autoFocus: !1,
editable: !0,
editor: y,
actions: ({ isFocused: e, isEmpty: t }) => /* @__PURE__ */ Y(Pa, {
isFocused: e,
isEmpty: t,
onNewCommentSave: b,
Components: m,
dict: h
})
})
})]
});
};
//#endregion
//#region src/components/Comments/useThreads.ts
function Ia() {
let e = f(N).threadStore, t = A(void 0);
t.current ||= e.getThreads();
let n = T((n) => e.subscribe((e) => {
t.current = e, n();
}), [e]);
return M(n, () => t.current);
}
//#endregion
//#region src/components/Comments/FloatingThreadController.tsx
var La = /* @__PURE__ */ dt({ default: () => Ra });
function Ra(r) {
let i = e(), a = n(), o = f(N), c = l(N, {
editor: i,
selector: (e) => e.selectedThreadId ? {
id: e.selectedThreadId,
position: e.threadPositions.get(e.selectedThreadId)
} : void 0
}), d = s({
trailingBlock: !1,
dictionary: {
...a,
placeholders: { emptyDocument: a.placeholders.comment_reply }
},
schema: o.commentEditorSchema || u
}, [c?.id]), p = Ia(), m = k(() => c ? p.get(c.id) : void 0, [c, p]), g = k(() => ({
...r.floatingUIOptions,
useFloatingOptions: {
open: !!c,
onOpenChange: (e, t, n) => {
if (!e) {
if (!h({
hasUnsavedContent: !d.isEmpty,
confirmBeforeDiscard: o.confirmBeforeDiscard,
message: a.comments.discard_pending_comment
})) return;
n === "escape-key" && i.focus(), o.selectThread(void 0);
}
},
placement: "bottom",
middleware: [
H(10),
U(),
V()
],
...r.floatingUIOptions?.useFloatingOptions
},
focusManagerProps: {
disabled: !0,
...r.floatingUIOptions?.focusManagerProps
},
elementProps: {
style: { zIndex: 30 },
...r.floatingUIOptions?.elementProps
}
}), [
o,
a,
i,
d,
r.floatingUIOptions,
c
]), _ = r.floatingThread || Fa;
return /* @__PURE__ */ Y(t, {
position: c?.position,
portalElement: r.portalElement,
...g,
children: m && /* @__PURE__ */ Y(_, {
thread: m,
selected: !0,
newCommentEditor: d
})
});
}
//#endregion
//#region src/components/Comments/ThreadsSidebar.tsx
var za = y.memo(({ thread: e, selectedThreadId: t, maxCommentsBeforeCollapse: n, referenceText: r, orphaned: i }) => {
let a = f(N), o = T((t) => {
t.target.closest(".bn-action-toolbar") || a.selectThread(e.id);
}, [a, e.id]), s = T((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__ */ Y(Fa, {
thread: e,
selected: e.id === t,
orphaned: i,
referenceText: r,
maxCommentsBeforeCollapse: n,
onFocus: o,
onBlur: s,
tabIndex: 0
});
});
function Ba(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 ye(t);
}
function Va(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 Ha(t) {
let n = e(), { selectedThreadId: r, threadPositions: i } = l(N), a = Ia(), o = k(() => {
let e = Ba(Array.from(a.values()), t.sort || "position", i), r = [];
for (let a of e) {
let e = i.get(a.id), o = e === void 0;
a.resolved ? (t.filter === "resolved" || t.filter === "all") && r.push({
thread: a,
referenceText: Va(n, e),
orphaned: o
}) : (t.filter === "open" || t.filter === "all") && r.push({
thread: a,
referenceText: Va(n, e),
orphaned: o
});
}
return r;
}, [
a,
t.sort,
t.filter,
i,
n
]);
return /* @__PURE__ */ Y("div", {
className: "bn-threads-sidebar",
children: o.map((e) => /* @__PURE__ */ Y(za, {
thread: e.thread,
selectedThreadId: r,
editor: n,
referenceText: e.referenceText,
orphaned: e.orphaned,
maxCommentsBeforeCollapse: t.maxCommentsBeforeCollapse
}, e.thread.id))
});
}
//#endregion
//#region src/components/Versioning/useVersionUsers.ts
function Ua(e) {
let { userStore: t } = f(B), n = e.join(",");
return D(() => {
t.loadUsers(e);
}, [t, n]), a(t.store, (t) => {
let n = /* @__PURE__ */ new Map();
for (let r of e) {
let e = t.get(r);
e && n.set(r, e);
}
return n;
});
}
function Wa(e) {
let t = e?.by === void 0 ? [] : Array.isArray(e.by) ? e.by : [e.by], n = Ua(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 Ga = (e) => `${e.toLocaleDateString(void 0, {
day: "numeric",
month: "long",
year: "numeric"
})}, ${e.toLocaleTimeString(void 0, {
hour: "numeric",
minute: "2-digit"
})}`, Ka = x(void 0), qa = (e) => {
let { canCompare: t } = f(B), [n, r] = j(!0), [i, a] = j("history"), o = t, s = e.filter === void 0 ? void 0 : e.filter === "named" ? "named" : "history", c = s === void 0, l = s ?? i, u = k(() => ({
comparisonEnabled: o,
comparisonMode: o && n,
setComparisonMode: r,
activeTab: l,
setActiveTab: a,
showTabs: c
}), [
o,
n,
l,
c
]);
return /* @__PURE__ */ Y(Ka.Provider, {
value: u,
children: e.children
});
}, Ja = () => {
let e = E(Ka);
if (!e) throw Error("useVersioningSidebar must be used within a VersioningSidebarProvider");
return e;
}, Ya = ({ snapshot: e, previousSnapshot: t }) => {
let n = g(), { canPreviewCurrent: r, previewCurrentVersion: i, exitPreview: a } = f(B), o = l(B, { selector: (e) => e.previewedSnapshotId === P }), s = l(B, { selector: (e) => e.snapshots.filter((e) => e.id !== P) }), { comparisonEnabled: c, comparisonMode: u, setComparisonMode: d } = Ja(), p = Wa(e), m = () => {
u && i && t ? i({ compareTo: t.id }) : a();
}, h = s[s.length - 1], _ = c && r && i && h ? /* @__PURE__ */ Y(n.Generic.Toolbar.Root, {
variant: "action-toolbar",
className: "bn-action-toolbar",
children: /* @__PURE__ */ X(n.Generic.Menu.Root, {
position: "bottom-start",
children: [/* @__PURE__ */ Y(n.Generic.Menu.Trigger, { children: /* @__PURE__ */ Y(n.Generic.Toolbar.Button, {
className: "bn-snapshot-menu-trigger",
mainTooltip: "More",
variant: "compact",
onClick: (e) => {
e.preventDefault(), e.stopPropagation();
},
children: /* @__PURE__ */ Y(Nt, { size: 16 })
}) }), /* @__PURE__ */ Y(n.Generic.Menu.Dropdown, {
className: "bn-menu-dropdown",
children: /* @__PURE__ */ Y(n.Generic.Menu.Item, {
icon: /* @__PURE__ */ Y(An, {}),
onClick: () => {
d(!0), i({ compareTo: h.id });
},
children: "Compare since beginning"
})
})]
})
}) : void 0;
return /* @__PURE__ */ Y(n.Versioning.Snapshot, {
className: "bn-snapshot",
selected: o,
onClick: m,
actions: _,
children: /* @__PURE__ */ X("div", {
className: "bn-snapshot-body",
children: [
/* @__PURE__ */ Y("div", {
className: "bn-snapshot-name",
children: "Current version"
}),
p !== void 0 && /* @__PURE__ */ Y("div", {
className: "bn-snapshot-date",
children: Ga(new Date(e.createdAt))
}),
p !== void 0 && /* @__PURE__ */ Y("div", {
className: "bn-snapshot-secondary-label",
children: p
})
]
})
});
}, Xa = ({ snapshot: e, previousSnapshot: t }) => {
let n = g(), { canRestore: r, restore: i, canRename: a, rename: o, canRemove: s, remove: c, previewSnapshot: u, previewCurrentVersion: d } = f(B), p = l(B, { selector: (t) => t.previewedSnapshotId === e.id }), m = l(B, { selector: (e) => e.previewedSnapshotId }), h = l(B, { selector: (e) => e.compareToSnapshotId }), _ = l(B, { selector: (t) => e?.restoredFromSnapshotId === void 0 ? void 0 : t.snapshots.find((t) => t.id === e.restoredFromSnapshotId) }), { comparisonEnabled: v, comparisonMode: y, setComparisonMode: b } = Ja(), x = Wa(e), S = Ga(new Date(e?.createdAt || 0)), [C, w] = j(e?.name || S);
if (e === void 0) return null;
let T = h === e.id && !p, E = () => {
if (!y) {
u(e.id);
return;
}
u(e.id, { compareTo: t?.id });
}, D = v || r || s ? /* @__PURE__ */ Y(n.Generic.Toolbar.Root, {
variant: "action-toolbar",
className: "bn-action-toolbar",
children: /* @__PURE__ */ X(n.Generic.Menu.Root, {
position: "bottom-start",
children: [/* @__PURE__ */ Y(n.Generic.Menu.Trigger, { children: /* @__PURE__ */ Y(n.Generic.Toolbar.Button, {
className: "bn-snapshot-menu-trigger",
mainTooltip: "More",
variant: "compact",
onClick: (e) => {
e.preventDefault(), e.stopPropagation();
},
children: /* @__PURE__ */ Y(Nt, { size: 16 })
}) }), /* @__PURE__ */ X(n.Generic.Menu.Dropdown, {
className: "bn-menu-dropdown",
children: [
v && /* @__PURE__ */ Y(n.Generic.Menu.Item, {
icon: /* @__PURE__ */ Y(An, {}),
onClick: () => {
b(!0), m !== void 0 && m !== P && m !== e.id ? u(m, { compareTo: e.id }) : d && d({ compareTo: e.id });
},
children: "Compare with this version"
}),
r && /* @__PURE__ */ Y(n.Generic.Menu.Item, {
icon: /* @__PURE__ */ Y(jn, {}),
onClick: () => {
i?.(e.id);
},
children: "Restore"
}),
s && /* @__PURE__ */ Y(n.Generic.Menu.Item, {
icon: /* @__PURE__ */ Y(It, {}),
onClick: () => {
c?.(e.id);
},
children: "Delete"
})
]
})]
})
}) : void 0;
return /* @__PURE__ */ X(n.Versioning.Snapshot, {
className: "bn-snapshot",
selected: p,
comparing: T,
onClick: E,
actions: D,
children: [T && /* @__PURE__ */ X("div", {
className: "bn-snapshot-comparing-to",
children: [/* @__PURE__ */ Y(An, { size: 14 }), /* @__PURE__ */ Y("span", { children: "Comparing to" })]
}), /* @__PURE__ */ X("div", {
className: "bn-snapshot-body",
children: [
a ? /* @__PURE__ */ Y("input", {
className: "bn-snapshot-name",
type: "text",
value: C,
readOnly: !p,
style: { cursor: p ? "text" : "pointer" },
onChange: (e) => w(e.target.value),
onMouseDown: (e) => {
p || e.preventDefault();
},
onClick: (e) => {
p && e.stopPropagation();
},
onBlur: () => o?.(e.id, C === S ? void 0 : C)
}) : /* @__PURE__ */ Y("div", {
className: "bn-snapshot-name",
children: C
}),
e.name && e.name !== S && /* @__PURE__ */ Y("div", {
className: "bn-snapshot-date",
children: S
}),
_ && /* @__PURE__ */ Y("div", {
className: "bn-snapshot-original-date",
children: `Restored from ${Ga(new Date(_.createdAt))}`
}),
x !== void 0 && /* @__PURE__ */ Y("div", {
className: "bn-snapshot-secondary-label",
children: x
})
]
})]
});
}, Za = (e) => {
let t = g(), { exitPreview: n, previewSnapshot: r, previewCurrentVersion: i, create: a, canCreate: o } = f(B), s = l(B, { selector: (e) => e.previewedSnapshotId }), c = l(B, { selector: (e) => e.snapshots }), { comparisonEnabled: u, comparisonMode: d, setComparisonMode: p } = Ja();
return /* @__PURE__ */ X("div", {
className: "bn-versioning-sidebar-header",
children: [/* @__PURE__ */ X("div", {
className: "bn-versioning-sidebar-header-title",
children: [/* @__PURE__ */ Y("h2", {
className: "bn-versioning-sidebar-title",
children: "History"
}), /* @__PURE__ */ X(t.Generic.Toolbar.Root, {
variant: "action-toolbar",
className: "bn-action-toolbar bn-versioning-sidebar-header-actions",
children: [o && /* @__PURE__ */ Y(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__ */ Y(Dn, { size: 16 })
}), u && /* @__PURE__ */ Y(t.Generic.Toolbar.Button, {
mainTooltip: d ? "Turn off comparison" : "Turn on comparison",
isSelected: d,
onClick: () => {
let e = d;
p((e) => !e);
let t = s !== void 0 && s !== P;
if (e) {
t ? r(s) : s === P && n();
return;
}
if (t) {
let e = c.findIndex((e) => e.id === s), t = e >= 0 ? c[e + 1] : void 0;
r(s, { compareTo: t?.id });
} else {
let e = c.find((e) => e.id !== P);
i && e && i({ compareTo: e.id });
}
},
children: /* @__PURE__ */ Y(An, { size: 16 })
})]
})]
}), e.onClose && /* @__PURE__ */ Y(t.Generic.Toolbar.Root, {
variant: "action-toolbar",
className: "bn-action-toolbar bn-versioning-sidebar-header-actions",
children: /* @__PURE__ */ Y(t.Generic.Toolbar.Button, {
mainTooltip: "Close",
onClick: () => {
n(), e.onClose?.();
},
children: /* @__PURE__ */ Y(zt, { size: 16 })
})
})]
});
}, Qa = (e) => {
let t = g(), { list: n } = f(B), { snapshots: r } = l(B), { activeTab: i, setActiveTab: a, showTabs: o } = Ja();
return D(() => {
n();
}, [n]), /* @__PURE__ */ X(t.Versioning.Sidebar, {
className: "bn-versioning-sidebar",
children: [
/* @__PURE__ */ Y(Za, { onClose: e.onClose }),
o && /* @__PURE__ */ X("div", {
className: "bn-versioning-sidebar-tabs",
role: "tablist",
children: [/* @__PURE__ */ Y("button", {
type: "button",
role: "tab",
className: "bn-versioning-sidebar-tab",
"aria-selected": i === "history",
onClick: () => a("history"),
children: "Version History"
}), /* @__PURE__ */ Y("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 === P || i !== "named" || typeof e.id == "string" && !e.id.startsWith("history-") && e.name !== void 0).map((e, t, n) => e.id === P ? /* @__PURE__ */ Y(Ya, {
snapshot: e,
previousSnapshot: n[t + 1]
}, "current-version") : /* @__PURE__ */ Y(Xa, {
snapshot: e,
previousSnapshot: n[t + 1]
}, e.id))
]
});
}, $a = (e) => /* @__PURE__ */ Y(qa, {
filter: e.filter,
children: /* @__PURE__ */ Y(Qa, { onClose: e.onClose })
});
//#endregion
//#region src/hooks/useActiveStyles.ts
function eo(e) {
let t = v();
if (e ||= t?.editor, !e) throw Error("'editor' is required, either from BlockNoteContext or as a function argument");
return m({
editor: e,
selector: ({ editor: e }) => e.getActiveStyles()
});
}
//#endregion
//#region src/hooks/useEditorSelectionBoundingBox.ts
function to(e, t) {
return m({
editor: t,
selector: ({ editor: t }) => e ? t.getSelectionBoundingBox() : void 0
});
}
//#endregion
//#region src/hooks/useFocusWithin.ts
function no(e) {
return e.currentTarget instanceof HTMLElement && e.relatedTarget instanceof HTMLElement && e.currentTarget.contains(e.relatedTarget);
}
function ro({ onBlur: e, onFocus: t } = {}) {
let n = A(null), [r, i] = j(!1), a = A(!1), o = (e) => {
i(e), a.current = e;
}, s = T((e) => {
a.current || (o(!0), t?.(e));
}, [t]), c = T((t) => {
a.current && !no(t) && (o(!1), e?.(t));
}, [e]);
return D(() => {
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 io(e) {
return m({
editor: e,
selector: ({ editor: e }) => e.getSelection()?.blocks || [e.getTextCursorPosition().block]
});
}
//#endregion
//#region src/schema/ReactInlineContentSpec.tsx
function ao(e) {
return /* @__PURE__ */ Y(rt, {
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]) => [we(e), t])),
children: e.children
});
}
function oo(e, t, n) {
let r = $e.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" ? Ye(this.editor) : void 0;
},
addAttributes() {
return Xe(e.propSchema);
},
addKeyboardShortcuts() {
return xe(e);
},
parseHTML() {
return Re(e, t.parse, t.parseContent);
},
renderHTML({ node: n }) {
let r = this.options.editor, i = Je(n, r.schema.inlineContentSchema, r.schema.styleSchema), a = t.toExternalHTML || t.render, o = $((e) => /* @__PURE__ */ Y(a, {
contentRef: (t) => {
e(t), t && (t.dataset.editable = "");
},
inlineContent: i,
updateInlineContent: () => {},
editor: r,
node: n,
getPos: () => void 0
}), r);
return be(o, e.type, n.attrs, e.propSchema);
},
addNodeView() {
let n = this.options.editor;
return (r) => ot((r) => {
let i = st().nodeViewContentRef;
if (!i) throw Error("nodeViewContentRef is not set");
let a = t.render;
return /* @__PURE__ */ Y(ao, {
inlineContentProps: r.node.attrs,
inlineContentType: e.type,
propSchema: e.propSchema,
children: /* @__PURE__ */ Y(a, {
contentRef: (e) => {
i(e), e && (e.dataset.editable = "");
},
editor: n,
node: r.node,
getPos: r.getPos,
inlineContent: Je(r.node, n.schema.inlineContentSchema, n.schema.styleSchema),
updateInlineContent: (e) => {
let t = We([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 Oe(e, {
...t,
node: r,
render(n, r, i) {
let a = t.render, o = We([n], i.pmSchema)[0];
return $((t) => /* @__PURE__ */ Y(ao, {
inlineContentProps: n.props,
inlineContentType: e.type,
propSchema: e.propSchema,
children: /* @__PURE__ */ Y(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 = We([n], r.pmSchema)[0];
return $((t) => /* @__PURE__ */ Y(ao, {
inlineContentProps: n.props,
inlineContentType: e.type,
propSchema: e.propSchema,
children: /* @__PURE__ */ Y(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 so(e, t) {
let n = nt.create({
name: e.type,
addAttributes() {
return Ze(e.propSchema);
},
parseHTML() {
return He(e);
},
renderHTML({ mark: n }) {
let r = t.render, i = $((t) => /* @__PURE__ */ Y(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 Se(i, e.type, n.attrs.stringValue, e.propSchema);
},
addMarkView() {
let n = this.options.editor;
return (r) => {
let i = at((r) => {
let i = E(it).markViewContentRef;
if (!i) throw Error("markViewContentRef is not set");
let a = t.render;
return /* @__PURE__ */ Y(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 ke(e, {
...t,
mark: n,
render(n, r) {
let i = t.render, a = $((e) => /* @__PURE__ */ Y(i, {
editor: r,
value: n,
contentRef: (t) => {
e(t), t && (t.dataset.editable = "");
}
}), r);
return Se(a, e.type, n, e.propSchema);
},
toExternalHTML(n, r) {
let i = t.render, a = $((e) => /* @__PURE__ */ Y(i, {
editor: r,
value: n,
contentRef: (t) => {
e(t), t && (t.dataset.editable = "");
}
}), r);
return Se(a, e.type, n, e.propSchema);
}
});
}
//#endregion
//#region src/util/elementOverflow.ts
function co(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 lo(e) {
return (t) => {
e.forEach((e) => {
typeof e == "function" ? e(t) : e != null && (e.current = t);
});
};
}
//#endregion
export { vr as AddBlockButton, ri as AddButton, $n as AddCommentButton, Qn as AddCommentButtonInner, Ii as AddFileButton, er as AddTiptapCommentButton, Nr as AttributionTooltip, Pr as AttributionTooltipController, Hi as AudioBlock, Bi as AudioPreview, Vi as AudioToExternalHTML, Pn as BasicTextStyleButton, Cr as BlockColorsItem, ki as BlockContentWrapper, _ as BlockNoteContext, pi as BlockNoteDefaultUI, Ei as BlockNoteViewEditor, Ti as BlockNoteViewRaw, ft as BlockPopover, Zn as BlockTypeSelect, $r as ColorPickerButton, zn as ColorStyleButton, Oa as Comment, ka as Comments, c as ComponentsContext, Un as CreateLinkButton, ii as DeleteButton, fr as DeleteLinkButton, Or as DragHandleButton, Dr as DragHandleMenu, pr as EditLinkButton, Vn as EditLinkMenuItems, pt as EmbedTab, fa as ExperimentalMobileFormattingToolbarController, Qr as ExtendButton, Mi as FigureWithCaption, Ri as FileBlockWrapper, Wn as FileCaptionButton, Gn as FileDeleteButton, nr as FileDownloadButton, Li as FileNameWithIcon, ht as FilePanel, gt as FilePanelController, rr as FilePreviewButton, Kn as FileRenameButton, qn as FileReplaceButton, ja as FloatingComposer, Na as FloatingComposerController, Ra as FloatingThreadController, lr as FormattingToolbar, dr as FormattingToolbarController, r as GenericPopover, Hr as GridSuggestionMenuController, Vr as GridSuggestionMenuWrapper, Ji as ImageBlock, Ki as ImagePreview, qi as ImageToExternalHTML, ao as InlineContentWrapper, hr as LinkToolbar, gr as LinkToolbarController, zi as LinkWithCaption, Jn as NestBlockButton, mr as OpenLinkButton, t as PositionPopover, ea as PreviewPlaceholder, Ui as ReactAudioBlock, Wi as ReactFileBlock, Yi as ReactImageBlock, la as ReactVideoBlock, wr as RemoveBlockItem, Gi as ResizableFileBlockWrapper, kr as SideMenu, jr as SideMenuController, ra as SourceBlockWithPreview, aa as SourceInlineContentWithPreview, ta as SourceWithPreview, ei as SplitButton, Xr as SuggestionMenuController, qr as SuggestionMenuWrapper, ni as TableCellButton, ti as TableCellMenu, ar as TableCellMergeButton, Er as TableColumnHeaderItem, li as TableHandle, ci as TableHandleMenu, ui as TableHandlesController, Tr as TableRowHeaderItem, sr as TextAlignButton, Fa as Thread, Ha as ThreadsSidebar, da as ToggleWrapper, Yn as UnnestBlockButton, mt as UploadTab, $a as VersioningSidebar, ca as VideoBlock, oa as VideoPreview, sa as VideoToExternalHTML, Xn as blockTypeSelectItems, Ai as createReactBlockSpec, oo as createReactInlineContentSpec, so as createReactStyleSpec, Mr as defaultFormatChangeLabel, co as elementOverflow, Fr as getDefaultReactEmojiPickerItems, Yr as getDefaultReactSlashMenuItems, cr as getFormattingToolbarItems, i as getMountedBoundingClientRectCache, Qi as getPageBreakReactSlashMenuItems, Va as getReferenceText, lo as mergeRefs, o as shallow, eo as useActiveStyles, v as useBlockNoteContext, e as useBlockNoteEditor, Rr as useCloseSuggestionMenuNoItems, g as useComponentsContext, s as useCreateBlockNote, n as useDictionary, mi as useEditorChange, d as useEditorDOMElement, to as useEditorSelectionBoundingBox, hi as useEditorSelectionChange, m as useEditorState, ma as useExtendButtonsPositioning, f as useExtension, l as useExtensionState, ro as useFocusWithin, Br as useGridSuggestionMenuKeyboardNavigation, zr as useLoadSuggestionMenuItems, Oi as useNodeViewBlock, Ni as useOnUploadEnd, Pi as useOnUploadStart, gi as usePrefersColorScheme, ji as useResolveUrl, io as useSelectedBlocks, Wa as useSnapshotLabel, na as useSourceBlockPreviewPopup, ia as useSourceInlineContentPreviewPopup, a as useStore, Wr as useSuggestionMenuKeyboardHandler, Kr as useSuggestionMenuKeyboardNavigation, ya as useTableHandlesPositioning, Ia as useThreads, Fi as useUploadLoading, Ua as useVersionUsers };
//# sourceMappingURL=blocknote-react.js.map