UNPKG

@blocknote/react

Version:

A "Notion-style" block-based extensible text editor built on top of Prosemirror and Tiptap.

27 lines (24 loc) 68.6 kB
(function(g,c){typeof exports=="object"&&typeof module<"u"?c(exports,require("react"),require("@blocknote/core"),require("@floating-ui/react"),require("@mantine/core"),require("use-prefers-color-scheme"),require("react-dom"),require("@tiptap/react")):typeof define=="function"&&define.amd?define(["exports","react","@blocknote/core","@floating-ui/react","@mantine/core","use-prefers-color-scheme","react-dom","@tiptap/react"],c):(g=typeof globalThis<"u"?globalThis:g||self,c(g["blocknote-react"]={},g.React,g.core$1,g.react,g.core,g.usePrefersColorScheme,g.ReactDOM,g.react$1))})(this,function(g,c,v,P,b,Rn,ee,U){"use strict";const ye=e=>e&&typeof e=="object"&&"default"in e?e:{default:e},O=ye(c),Fn=ye(Rn),Nn=ye(ee),pe=c.createContext(void 0);function W(e){return c.useContext(pe)}var Se={exports:{}},te={};/** * @license React * react-jsx-runtime.production.min.js * * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */var $e;function Zn(){if($e)return te;$e=1;var e=O.default,t=Symbol.for("react.element"),n=Symbol.for("react.fragment"),o=Object.prototype.hasOwnProperty,i=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,l={key:!0,ref:!0,__self:!0,__source:!0};function u(s,f,h){var k,C={},H=null,L=null;h!==void 0&&(H=""+h),f.key!==void 0&&(H=""+f.key),f.ref!==void 0&&(L=f.ref);for(k in f)o.call(f,k)&&!l.hasOwnProperty(k)&&(C[k]=f[k]);if(s&&s.defaultProps)for(k in f=s.defaultProps,f)C[k]===void 0&&(C[k]=f[k]);return{$$typeof:t,type:s,key:H,ref:L,props:C,_owner:i.current}}return te.Fragment=n,te.jsx=u,te.jsxs=u,te}var ne={};/** * @license React * react-jsx-runtime.development.js * * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */var et;function zn(){return et||(et=1,process.env.NODE_ENV!=="production"&&function(){var e=O.default,t=Symbol.for("react.element"),n=Symbol.for("react.portal"),o=Symbol.for("react.fragment"),i=Symbol.for("react.strict_mode"),l=Symbol.for("react.profiler"),u=Symbol.for("react.provider"),s=Symbol.for("react.context"),f=Symbol.for("react.forward_ref"),h=Symbol.for("react.suspense"),k=Symbol.for("react.suspense_list"),C=Symbol.for("react.memo"),H=Symbol.for("react.lazy"),L=Symbol.for("react.offscreen"),q=Symbol.iterator,Fe="@@iterator";function Y(a){if(a===null||typeof a!="object")return null;var d=q&&a[q]||a[Fe];return typeof d=="function"?d:null}var z=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function B(a){{for(var d=arguments.length,m=new Array(d>1?d-1:0),x=1;x<d;x++)m[x-1]=arguments[x];Ne("error",a,m)}}function Ne(a,d,m){{var x=z.ReactDebugCurrentFrame,T=x.getStackAddendum();T!==""&&(d+="%s",m=m.concat([T]));var M=m.map(function(p){return String(p)});M.unshift("Warning: "+d),Function.prototype.apply.call(console[a],console,M)}}var K=!1,me=!1,Ze=!1,ze=!1,Ue=!1,G;G=Symbol.for("react.module.reference");function Ao(a){return!!(typeof a=="string"||typeof a=="function"||a===o||a===l||Ue||a===i||a===h||a===k||ze||a===L||K||me||Ze||typeof a=="object"&&a!==null&&(a.$$typeof===H||a.$$typeof===C||a.$$typeof===u||a.$$typeof===s||a.$$typeof===f||a.$$typeof===G||a.getModuleId!==void 0))}function Ro(a,d,m){var x=a.displayName;if(x)return x;var T=d.displayName||d.name||"";return T!==""?m+"("+T+")":m}function bn(a){return a.displayName||"Context"}function F(a){if(a==null)return null;if(typeof a.tag=="number"&&B("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),typeof a=="function")return a.displayName||a.name||null;if(typeof a=="string")return a;switch(a){case o:return"Fragment";case n:return"Portal";case l:return"Profiler";case i:return"StrictMode";case h:return"Suspense";case k:return"SuspenseList"}if(typeof a=="object")switch(a.$$typeof){case s:var d=a;return bn(d)+".Consumer";case u:var m=a;return bn(m._context)+".Provider";case f:return Ro(a,a.render,"ForwardRef");case C:var x=a.displayName||null;return x!==null?x:F(a.type)||"Memo";case H:{var T=a,M=T._payload,p=T._init;try{return F(p(M))}catch{return null}}}return null}var J=Object.assign,le=0,kn,vn,xn,Cn,yn,pn,Sn;function Tn(){}Tn.__reactDisabledLog=!0;function Fo(){{if(le===0){kn=console.log,vn=console.info,xn=console.warn,Cn=console.error,yn=console.group,pn=console.groupCollapsed,Sn=console.groupEnd;var a={configurable:!0,enumerable:!0,value:Tn,writable:!0};Object.defineProperties(console,{info:a,log:a,warn:a,error:a,group:a,groupCollapsed:a,groupEnd:a})}le++}}function No(){{if(le--,le===0){var a={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:J({},a,{value:kn}),info:J({},a,{value:vn}),warn:J({},a,{value:xn}),error:J({},a,{value:Cn}),group:J({},a,{value:yn}),groupCollapsed:J({},a,{value:pn}),groupEnd:J({},a,{value:Sn})})}le<0&&B("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var We=z.ReactCurrentDispatcher,qe;function be(a,d,m){{if(qe===void 0)try{throw Error()}catch(T){var x=T.stack.trim().match(/\n( *(at )?)/);qe=x&&x[1]||""}return` `+qe+a}}var Ye=!1,ke;{var Zo=typeof WeakMap=="function"?WeakMap:Map;ke=new Zo}function jn(a,d){if(!a||Ye)return"";{var m=ke.get(a);if(m!==void 0)return m}var x;Ye=!0;var T=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var M;M=We.current,We.current=null,Fo();try{if(d){var p=function(){throw Error()};if(Object.defineProperty(p.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(p,[])}catch(N){x=N}Reflect.construct(a,[],p)}else{try{p.call()}catch(N){x=N}a.call(p.prototype)}}else{try{throw Error()}catch(N){x=N}a()}}catch(N){if(N&&x&&typeof N.stack=="string"){for(var y=N.stack.split(` `),I=x.stack.split(` `),E=y.length-1,V=I.length-1;E>=1&&V>=0&&y[E]!==I[V];)V--;for(;E>=1&&V>=0;E--,V--)if(y[E]!==I[V]){if(E!==1||V!==1)do if(E--,V--,V<0||y[E]!==I[V]){var _=` `+y[E].replace(" at new "," at ");return a.displayName&&_.includes("<anonymous>")&&(_=_.replace("<anonymous>",a.displayName)),typeof a=="function"&&ke.set(a,_),_}while(E>=1&&V>=0);break}}}finally{Ye=!1,We.current=M,No(),Error.prepareStackTrace=T}var $=a?a.displayName||a.name:"",An=$?be($):"";return typeof a=="function"&&ke.set(a,An),An}function zo(a,d,m){return jn(a,!1)}function Uo(a){var d=a.prototype;return!!(d&&d.isReactComponent)}function ve(a,d,m){if(a==null)return"";if(typeof a=="function")return jn(a,Uo(a));if(typeof a=="string")return be(a);switch(a){case h:return be("Suspense");case k:return be("SuspenseList")}if(typeof a=="object")switch(a.$$typeof){case f:return zo(a.render);case C:return ve(a.type,d,m);case H:{var x=a,T=x._payload,M=x._init;try{return ve(M(T),d,m)}catch{}}}return""}var xe=Object.prototype.hasOwnProperty,wn={},Mn=z.ReactDebugCurrentFrame;function Ce(a){if(a){var d=a._owner,m=ve(a.type,a._source,d?d.type:null);Mn.setExtraStackFrame(m)}else Mn.setExtraStackFrame(null)}function Wo(a,d,m,x,T){{var M=Function.call.bind(xe);for(var p in a)if(M(a,p)){var y=void 0;try{if(typeof a[p]!="function"){var I=Error((x||"React class")+": "+m+" type `"+p+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof a[p]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw I.name="Invariant Violation",I}y=a[p](d,p,x,m,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(E){y=E}y&&!(y instanceof Error)&&(Ce(T),B("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",x||"React class",m,p,typeof y),Ce(null)),y instanceof Error&&!(y.message in wn)&&(wn[y.message]=!0,Ce(T),B("Failed %s type: %s",m,y.message),Ce(null))}}}var qo=Array.isArray;function Ke(a){return qo(a)}function Yo(a){{var d=typeof Symbol=="function"&&Symbol.toStringTag,m=d&&a[Symbol.toStringTag]||a.constructor.name||"Object";return m}}function Ko(a){try{return Hn(a),!1}catch{return!0}}function Hn(a){return""+a}function En(a){if(Ko(a))return B("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",Yo(a)),Hn(a)}var se=z.ReactCurrentOwner,Go={key:!0,ref:!0,__self:!0,__source:!0},Bn,Vn,Ge;Ge={};function Jo(a){if(xe.call(a,"ref")){var d=Object.getOwnPropertyDescriptor(a,"ref").get;if(d&&d.isReactWarning)return!1}return a.ref!==void 0}function Qo(a){if(xe.call(a,"key")){var d=Object.getOwnPropertyDescriptor(a,"key").get;if(d&&d.isReactWarning)return!1}return a.key!==void 0}function Xo(a,d){if(typeof a.ref=="string"&&se.current&&d&&se.current.stateNode!==d){var m=F(se.current.type);Ge[m]||(B('Component "%s" contains the string ref "%s". Support for string refs will be removed in a future major release. This case cannot be automatically converted to an arrow function. We ask you to manually fix this case by using useRef() or createRef() instead. Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref',F(se.current.type),a.ref),Ge[m]=!0)}}function $o(a,d){{var m=function(){Bn||(Bn=!0,B("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",d))};m.isReactWarning=!0,Object.defineProperty(a,"key",{get:m,configurable:!0})}}function er(a,d){{var m=function(){Vn||(Vn=!0,B("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",d))};m.isReactWarning=!0,Object.defineProperty(a,"ref",{get:m,configurable:!0})}}var tr=function(a,d,m,x,T,M,p){var y={$$typeof:t,type:a,key:d,ref:m,props:p,_owner:M};return y._store={},Object.defineProperty(y._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(y,"_self",{configurable:!1,enumerable:!1,writable:!1,value:x}),Object.defineProperty(y,"_source",{configurable:!1,enumerable:!1,writable:!1,value:T}),Object.freeze&&(Object.freeze(y.props),Object.freeze(y)),y};function nr(a,d,m,x,T){{var M,p={},y=null,I=null;m!==void 0&&(En(m),y=""+m),Qo(d)&&(En(d.key),y=""+d.key),Jo(d)&&(I=d.ref,Xo(d,T));for(M in d)xe.call(d,M)&&!Go.hasOwnProperty(M)&&(p[M]=d[M]);if(a&&a.defaultProps){var E=a.defaultProps;for(M in E)p[M]===void 0&&(p[M]=E[M])}if(y||I){var V=typeof a=="function"?a.displayName||a.name||"Unknown":a;y&&$o(p,V),I&&er(p,V)}return tr(a,y,I,T,x,se.current,p)}}var Je=z.ReactCurrentOwner,Ln=z.ReactDebugCurrentFrame;function X(a){if(a){var d=a._owner,m=ve(a.type,a._source,d?d.type:null);Ln.setExtraStackFrame(m)}else Ln.setExtraStackFrame(null)}var Qe;Qe=!1;function Xe(a){return typeof a=="object"&&a!==null&&a.$$typeof===t}function In(){{if(Je.current){var a=F(Je.current.type);if(a)return` Check the render method of \``+a+"`."}return""}}function or(a){{if(a!==void 0){var d=a.fileName.replace(/^.*[\\\/]/,""),m=a.lineNumber;return` Check your code at `+d+":"+m+"."}return""}}var Pn={};function rr(a){{var d=In();if(!d){var m=typeof a=="string"?a:a.displayName||a.name;m&&(d=` Check the top-level render call using <`+m+">.")}return d}}function Dn(a,d){{if(!a._store||a._store.validated||a.key!=null)return;a._store.validated=!0;var m=rr(d);if(Pn[m])return;Pn[m]=!0;var x="";a&&a._owner&&a._owner!==Je.current&&(x=" It was passed a child from "+F(a._owner.type)+"."),X(a),B('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',m,x),X(null)}}function _n(a,d){{if(typeof a!="object")return;if(Ke(a))for(var m=0;m<a.length;m++){var x=a[m];Xe(x)&&Dn(x,d)}else if(Xe(a))a._store&&(a._store.validated=!0);else if(a){var T=Y(a);if(typeof T=="function"&&T!==a.entries)for(var M=T.call(a),p;!(p=M.next()).done;)Xe(p.value)&&Dn(p.value,d)}}}function ar(a){{var d=a.type;if(d==null||typeof d=="string")return;var m;if(typeof d=="function")m=d.propTypes;else if(typeof d=="object"&&(d.$$typeof===f||d.$$typeof===C))m=d.propTypes;else return;if(m){var x=F(d);Wo(m,a.props,"prop",x,a)}else if(d.PropTypes!==void 0&&!Qe){Qe=!0;var T=F(d);B("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",T||"Unknown")}typeof d.getDefaultProps=="function"&&!d.getDefaultProps.isReactClassApproved&&B("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function ir(a){{for(var d=Object.keys(a.props),m=0;m<d.length;m++){var x=d[m];if(x!=="children"&&x!=="key"){X(a),B("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",x),X(null);break}}a.ref!==null&&(X(a),B("Invalid attribute `ref` supplied to `React.Fragment`."),X(null))}}function On(a,d,m,x,T,M){{var p=Ao(a);if(!p){var y="";(a===void 0||typeof a=="object"&&a!==null&&Object.keys(a).length===0)&&(y+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");var I=or(T);I?y+=I:y+=In();var E;a===null?E="null":Ke(a)?E="array":a!==void 0&&a.$$typeof===t?(E="<"+(F(a.type)||"Unknown")+" />",y=" Did you accidentally export a JSX literal instead of a component?"):E=typeof a,B("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",E,y)}var V=nr(a,d,m,T,M);if(V==null)return V;if(p){var _=d.children;if(_!==void 0)if(x)if(Ke(_)){for(var $=0;$<_.length;$++)_n(_[$],a);Object.freeze&&Object.freeze(_)}else B("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else _n(_,a)}return a===o?ir(V):ar(V),V}}function lr(a,d,m){return On(a,d,m,!0)}function sr(a,d,m){return On(a,d,m,!1)}var cr=sr,ur=lr;ne.Fragment=o,ne.jsx=cr,ne.jsxs=ur}()),ne}process.env.NODE_ENV==="production"?Se.exports=Zn():Se.exports=zn();var r=Se.exports;function w(e){const t=W();if(!(t!=null&&t.editor))throw new Error("useBlockNoteEditor was called outside of a BlockNoteContext provider or BlockNoteView component");return t.editor}function ce(e,t){const n=W();t||(t=n==null?void 0:n.editor),c.useEffect(()=>{if(!t)throw new Error("'editor' is required, either from BlockNoteContext or as a function argument");return t.onChange(e)},[e,t])}function ue(e,t){const n=W();t||(t=n==null?void 0:n.editor),c.useEffect(()=>{if(!t)throw new Error("'editor' is required, either from BlockNoteContext or as a function argument");return t.onSelectionChange(e)},[e,t])}function R(e,t){ce(e,t),ue(e,t)}function oe(e,t,n,o){const{refs:i,update:l,context:u,floatingStyles:s}=P.useFloating({open:e,...o}),{isMounted:f,styles:h}=P.useTransitionStyles(u);return c.useEffect(()=>{l()},[t,l]),c.useEffect(()=>{t!==null&&i.setReference({getBoundingClientRect:()=>t})},[t,i]),c.useMemo(()=>({isMounted:f,ref:i.setFloating,style:{display:"flex",...h,...s,zIndex:n}}),[s,f,i.setFloating,h,n])}function Q(e){const[t,n]=c.useState();return c.useEffect(()=>e(o=>{n({...o})}),[e]),t}function tt(e){return t=>{e.forEach(n=>{typeof n=="function"?n(t):n!=null&&(n.current=t)})}}const Te=c.forwardRef((e,t)=>{const{className:n,children:o,...i}=e;return r.jsx(b.Group,{className:v.mergeCSSClasses("bn-toolbar",n||""),ref:t,...i,children:o})});var nt={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},ot=O.default.createContext&&O.default.createContext(nt),Z=globalThis&&globalThis.__assign||function(){return Z=Object.assign||function(e){for(var t,n=1,o=arguments.length;n<o;n++){t=arguments[n];for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i])}return e},Z.apply(this,arguments)},Un=globalThis&&globalThis.__rest||function(e,t){var n={};for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&t.indexOf(o)<0&&(n[o]=e[o]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,o=Object.getOwnPropertySymbols(e);i<o.length;i++)t.indexOf(o[i])<0&&Object.prototype.propertyIsEnumerable.call(e,o[i])&&(n[o[i]]=e[o[i]]);return n};function rt(e){return e&&e.map(function(t,n){return O.default.createElement(t.tag,Z({key:n},t.attr),rt(t.child))})}function j(e){return function(t){return O.default.createElement(Wn,Z({attr:Z({},e.attr)},t),rt(e.child))}}function Wn(e){var t=function(n){var o=e.attr,i=e.size,l=e.title,u=Un(e,["attr","size","title"]),s=i||n.size||"1em",f;return n.className&&(f=n.className),e.className&&(f=(f?f+" ":"")+e.className),O.default.createElement("svg",Z({stroke:"currentColor",fill:"currentColor",strokeWidth:"0"},n.attr,o,u,{className:f,style:Z(Z({color:e.color||n.color},n.style),e.style),height:s,width:s,xmlns:"http://www.w3.org/2000/svg"}),l&&O.default.createElement("title",null,l),e.children)};return ot!==void 0?O.default.createElement(ot.Consumer,null,function(n){return t(n)}):t(nt)}function qn(e){return j({tag:"svg",attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{d:"M23 11.9998L15.9289 19.0708L14.5147 17.6566L20.1716 11.9998L14.5147 6.34292L15.9289 4.92871L23 11.9998ZM3.82843 11.9998L9.48528 17.6566L8.07107 19.0708L1 11.9998L8.07107 4.92871L9.48528 6.34292L3.82843 11.9998Z"}}]})(e)}function Yn(e){return j({tag:"svg",attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{d:"M3 4H21V6H3V4ZM5 19H19V21H5V19ZM3 14H21V16H3V14ZM5 9H19V11H5V9Z"}}]})(e)}function Kn(e){return j({tag:"svg",attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{d:"M3 4H21V6H3V4ZM3 19H21V21H3V19ZM3 14H21V16H3V14ZM3 9H21V11H3V9Z"}}]})(e)}function Gn(e){return j({tag:"svg",attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{d:"M3 4H21V6H3V4ZM3 19H17V21H3V19ZM3 14H21V16H3V14ZM3 9H17V11H3V9Z"}}]})(e)}function Jn(e){return j({tag:"svg",attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{d:"M3 4H21V6H3V4ZM7 19H21V21H7V19ZM3 14H21V16H3V14ZM7 9H21V11H7V9Z"}}]})(e)}function Qn(e){return j({tag:"svg",attr:{viewBox:"0 0 24 24"},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"}}]})(e)}function at(e){return j({tag:"svg",attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{d:"M13 20H11V13H4V20H2V4H4V11H11V4H13V20ZM21.0005 8V20H19.0005L19 10.204L17 10.74V8.67L19.5005 8H21.0005Z"}}]})(e)}function it(e){return j({tag:"svg",attr:{viewBox:"0 0 24 24"},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"}}]})(e)}function lt(e){return j({tag:"svg",attr:{viewBox:"0 0 24 24"},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"}}]})(e)}function Xn(e){return j({tag:"svg",attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{d:"M3 4H21V6H3V4ZM3 19H21V21H3V19ZM11 14H21V16H11V14ZM11 9H21V11H11V9ZM3 12.5L7 9V16L3 12.5Z"}}]})(e)}function $n(e){return j({tag:"svg",attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{d:"M3 4H21V6H3V4ZM3 19H21V21H3V19ZM11 14H21V16H11V14ZM11 9H21V11H11V9ZM7 12.5L3 16V9L7 12.5Z"}}]})(e)}function eo(e){return j({tag:"svg",attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{d:"M15 20H7V18H9.92661L12.0425 6H9V4H17V6H14.0734L11.9575 18H15V20Z"}}]})(e)}function to(e){return j({tag:"svg",attr:{viewBox:"0 0 24 24"},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"}}]})(e)}function st(e){return j({tag:"svg",attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{d:"M18.3643 15.5353L16.95 14.1211L18.3643 12.7069C20.3169 10.7543 20.3169 7.58847 18.3643 5.63585C16.4116 3.68323 13.2458 3.68323 11.2932 5.63585L9.87898 7.05007L8.46477 5.63585L9.87898 4.22164C12.6127 1.48797 17.0448 1.48797 19.7785 4.22164C22.5121 6.95531 22.5121 11.3875 19.7785 14.1211L18.3643 15.5353ZM15.5358 18.3638L14.1216 19.778C11.388 22.5117 6.9558 22.5117 4.22213 19.778C1.48846 17.0443 1.48846 12.6122 4.22213 9.87849L5.63634 8.46428L7.05055 9.87849L5.63634 11.2927C3.68372 13.2453 3.68372 16.4112 5.63634 18.3638C7.58896 20.3164 10.7548 20.3164 12.7074 18.3638L14.1216 16.9496L15.5358 18.3638ZM14.8287 7.75717L16.2429 9.17139L9.17187 16.2425L7.75766 14.8282L14.8287 7.75717Z"}}]})(e)}function ct(e){return j({tag:"svg",attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{d:"M8 4H21V6H8V4ZM5 3V6H6V7H3V6H4V4H3V3H5ZM3 14V11.5H5V11H3V10H6V12.5H4V13H6V14H3ZM5 19.5H3V18.5H5V18H3V17H6V21H3V20H5V19.5ZM8 11H21V13H8V11ZM8 18H21V20H8V18Z"}}]})(e)}function ut(e){return j({tag:"svg",attr:{viewBox:"0 0 24 24"},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"}}]})(e)}function no(e){return j({tag:"svg",attr:{viewBox:"0 0 24 24"},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"}}]})(e)}function oo(e){return j({tag:"svg",attr:{viewBox:"0 0 24 24"},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"}}]})(e)}function re(e){return j({tag:"svg",attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{d:"M13 6V21H11V6H5V4H19V6H13Z"}}]})(e)}function ro(e){return j({tag:"svg",attr:{viewBox:"0 0 24 24"},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"}}]})(e)}function ao(e){return j({tag:"svg",attr:{viewBox:"0 0 24 24"},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"}}]})(e)}function io(e){return j({tag:"svg",attr:{viewBox:"0 0 24 24"},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"}}]})(e)}function lo(e){return j({tag:"svg",attr:{viewBox:"0 0 24 24"},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"}}]})(e)}function A(e){const t=W();if(e||(e=t==null?void 0:t.editor),!e)throw new Error("'editor' is required, either from BlockNoteContext or as a function argument");const n=e,[o,i]=c.useState(()=>{var l;return((l=n.getSelection())==null?void 0:l.blocks)||[n.getTextCursorPosition().block]});return R(()=>{var l;return i(((l=n.getSelection())==null?void 0:l.blocks)||[n.getTextCursorPosition().block])},n),o}const so=e=>r.jsxs(b.Stack,{gap:0,className:"bn-tooltip",children:[r.jsx(b.Text,{size:"sm",children:e.mainTooltip}),e.secondaryTooltip&&r.jsx(b.Text,{size:"xs",children:e.secondaryTooltip})]}),D=c.forwardRef((e,t)=>{const n=e.icon;return r.jsx(b.Tooltip,{withinPortal:!1,label:r.jsx(so,{mainTooltip:e.mainTooltip,secondaryTooltip:e.secondaryTooltip}),children:e.children?r.jsxs(b.Button,{onMouseDown:o=>{v.isSafari()&&o.currentTarget.focus()},onClick:e.onClick,"data-selected":e.isSelected?"true":void 0,"data-test":e.mainTooltip.slice(0,1).toLowerCase()+e.mainTooltip.replace(/\s+/g,"").slice(1),size:"xs",disabled:e.isDisabled||!1,ref:t,children:[n&&r.jsx(n,{}),e.children]}):r.jsx(b.ActionIcon,{onMouseDown:o=>{v.isSafari()&&o.currentTarget.focus()},onClick:e.onClick,"data-selected":e.isSelected?"true":void 0,"data-test":e.mainTooltip.slice(0,1).toLowerCase()+e.mainTooltip.replace(/\s+/g,"").slice(1),size:30,disabled:e.isDisabled||!1,ref:t,children:n&&r.jsx(n,{})})})}),co={bold:Qn,italic:eo,underline:ro,strike:no,code:qn},uo={bold:"Mod+B",italic:"Mod+I",underline:"Mod+U",strike:"Mod+Shift+X",code:""};function fo(e,t){return e in t.schema.styleSchema&&t.schema.styleSchema[e].type===e&&t.schema.styleSchema[e].propSchema==="boolean"}const ae=e=>{const t=w(),n=fo(e.basicTextStyle,t),o=A(t),[i,l]=c.useState(e.basicTextStyle in t.getActiveStyles());R(()=>{n&&l(e.basicTextStyle in t.getActiveStyles())},t);const u=f=>{if(n){if(t.focus(),t.schema.styleSchema[f].propSchema!=="boolean")throw new Error("can only toggle boolean styles");t.toggleStyles({[f]:!0})}};return c.useMemo(()=>n?!!o.find(f=>f.content!==void 0):!1,[n,o])?r.jsx(D,{onClick:()=>u(e.basicTextStyle),isSelected:i,mainTooltip:e.basicTextStyle.slice(0,1).toUpperCase()+e.basicTextStyle.slice(1),secondaryTooltip:v.formatKeyboardShortcut(uo[e.basicTextStyle]),icon:co[e.basicTextStyle]}):null};function je(){const e=c.useRef(null);return{ref:e,updateMaxHeight:()=>{setTimeout(()=>{if(e.current&&e.current.childElementCount>0){e.current.firstElementChild.style.maxHeight="none";const t=e.current.firstElementChild.getBoundingClientRect();e.current.firstElementChild.style.maxHeight=`${Math.min(t.top>=0?window.innerHeight-t.top-20:t.bottom-20)}px`}},10)}}}const we=e=>{const t=e.textColor||"default",n=e.backgroundColor||"default",o=e.size||16,i=c.useMemo(()=>({pointerEvents:"none",fontSize:(o*.75).toString()+"px",height:o.toString()+"px",lineHeight:o.toString()+"px",textAlign:"center",width:o.toString()+"px"}),[o]);return r.jsx(b.Box,{className:"bn-color-icon","data-background-color":n,"data-text-color":t,style:i,children:"A"})};function Me(e){return j({tag:"svg",attr:{version:"1.2",baseProfile:"tiny",viewBox:"0 0 24 24"},child:[{tag:"path",attr:{d:"M16.972 6.251c-.967-.538-2.185-.188-2.72.777l-3.713 6.682-2.125-2.125c-.781-.781-2.047-.781-2.828 0-.781.781-.781 2.047 0 2.828l4 4c.378.379.888.587 1.414.587l.277-.02c.621-.087 1.166-.46 1.471-1.009l5-9c.537-.966.189-2.183-.776-2.72z"}}]})(e)}const dt=e=>{const t=()=>e.text?r.jsxs(r.Fragment,{children:[r.jsx(b.Menu.Label,{children:"Text"}),["default","gray","brown","red","orange","yellow","green","blue","purple","pink"].map(o=>r.jsx(b.Menu.Item,{onClick:()=>{e.onClick&&e.onClick(),e.text.setColor(o)},component:"div","data-test":"text-color-"+o,leftSection:r.jsx(we,{textColor:o,size:e.iconSize}),rightSection:e.text.color===o?r.jsx(Me,{size:20,className:"bn-tick-icon"}):r.jsx("div",{className:"bn-tick-space"}),children:o.charAt(0).toUpperCase()+o.slice(1)},"text-color-"+o))]}):null,n=()=>e.background?r.jsxs(r.Fragment,{children:[r.jsx(b.Menu.Label,{children:"Background"}),["default","gray","brown","red","orange","yellow","green","blue","purple","pink"].map(o=>r.jsx(b.Menu.Item,{onClick:()=>{e.onClick&&e.onClick(),e.background.setColor(o)},component:"div","data-test":"background-color-"+o,leftSection:r.jsx(we,{backgroundColor:o,size:e.iconSize}),rightSection:e.background.color===o?r.jsx(Me,{size:20,className:"bn-tick-icon"}):r.jsx("div",{className:"bn-tick-space"}),children:o.charAt(0).toUpperCase()+o.slice(1)},"background-color-"+o))]}):null;return r.jsxs(r.Fragment,{children:[r.jsx(t,{}),r.jsx(n,{})]})};function ft(e,t){return`${e}Color`in t.schema.styleSchema&&t.schema.styleSchema[`${e}Color`].type===`${e}Color`&&t.schema.styleSchema[`${e}Color`].propSchema==="string"}const gt=()=>{const e=w(),t=ft("text",e),n=ft("background",e),o=A(e),[i,l]=c.useState(t&&e.getActiveStyles().textColor||"default"),[u,s]=c.useState(n&&e.getActiveStyles().backgroundColor||"default");R(()=>{t&&l(e.getActiveStyles().textColor||"default"),n&&s(e.getActiveStyles().backgroundColor||"default")},e);const{ref:f,updateMaxHeight:h}=je(),k=c.useCallback(L=>{if(!t)throw Error("Tried to set text color, but style does not exist in editor schema.");e.focus(),L==="default"?e.removeStyles({textColor:L}):e.addStyles({textColor:L})},[e,t]),C=c.useCallback(L=>{if(!n)throw Error("Tried to set background color, but style does not exist in editor schema.");e.focus(),L==="default"?e.removeStyles({backgroundColor:L}):e.addStyles({backgroundColor:L})},[n,e]);return c.useMemo(()=>{if(!t&&!n)return!1;for(const L of o)if(L.content!==void 0)return!0;return!1},[n,o,t])?r.jsxs(b.Menu,{withinPortal:!1,onOpen:h,children:[r.jsx(b.Menu.Target,{children:r.jsx(D,{mainTooltip:"Colors",icon:()=>r.jsx(we,{textColor:i,backgroundColor:u,size:20})})}),r.jsx("div",{ref:f,children:r.jsx(b.Menu.Dropdown,{children:r.jsx(dt,{text:t?{color:i,setColor:k}:void 0,background:n?{color:u,setColor:C}:void 0})})})]}):null},He=e=>r.jsxs(b.Popover,{withinPortal:!1,zIndex:1e4,children:[r.jsx(b.Popover.Target,{children:e.button}),r.jsx(b.Popover.Dropdown,{children:r.jsx(b.Stack,{className:"bn-toolbar-input-dropdown",children:e.dropdownItems})})]}),go={text:b.TextInput,file:b.FileInput},Ee=e=>{const{type:t,icon:n,...o}=e,i=go[e.type],l=e.icon;return r.jsx(b.Group,{children:r.jsx(i,{size:"xs",icon:r.jsx(l,{}),...o})})},Be=e=>{const{url:t,text:n,editLink:o}=e,[i,l]=c.useState(t),[u,s]=c.useState(n);c.useEffect(()=>{l(t),s(n)},[n,t]);const f=c.useCallback(H=>{H.key==="Enter"&&(H.preventDefault(),o(i,u))},[o,i,u]),h=c.useCallback(H=>l(H.currentTarget.value),[]),k=c.useCallback(H=>s(H.currentTarget.value),[]),C=c.useCallback(()=>o(i,u),[o,i,u]);return r.jsxs(r.Fragment,{children:[r.jsx(Ee,{type:"text",icon:st,autoFocus:!0,placeholder:"Edit URL",value:i,onKeyDown:f,onChange:h,onSubmit:C}),r.jsx(Ee,{type:"text",icon:re,placeholder:"Edit Title",value:u,onKeyDown:f,onChange:k,onSubmit:C})]})};function ho(e){return"link"in e.schema.inlineContentSchema&&e.schema.inlineContentSchema.link==="link"}const ht=()=>{const e=w(),t=ho(e),n=A(e),[o,i]=c.useState(e.getSelectedLinkUrl()||""),[l,u]=c.useState(e.getSelectedText());R(()=>{u(e.getSelectedText()||""),i(e.getSelectedLinkUrl()||"")},e);const s=c.useCallback((h,k)=>{e.createLink(h,k),e.focus()},[e]);return c.useMemo(()=>{if(!t)return!1;for(const h of n)if(h.content===void 0)return!1;return!0},[t,n])?r.jsx(He,{button:r.jsx(D,{mainTooltip:"Create Link",secondaryTooltip:v.formatKeyboardShortcut("Mod+K"),icon:st}),dropdownItems:r.jsx(Be,{url:o,text:l,editLink:s})}):null},mt=()=>{const e=w(),[t,n]=c.useState(),o=A(e),i=c.useMemo(()=>{if(o.length!==1)return;const s=o[0];if(v.checkBlockIsDefaultType("image",s,e))return s},[e,o]),l=c.useCallback(s=>{i&&v.checkDefaultBlockTypeInSchema("image",e)&&s.key==="Enter"&&(s.preventDefault(),e.updateBlock(i,{type:"image",props:{caption:t}}))},[t,e,i]),u=c.useCallback(s=>n(s.currentTarget.value),[]);return i?r.jsx(He,{button:r.jsx(D,{mainTooltip:"Edit Caption",icon:re,isSelected:i.props.caption!==""}),dropdownItems:r.jsx(Ee,{type:"text",icon:re,value:t,autoFocus:!0,placeholder:"Edit Caption",onKeyDown:l,defaultValue:i.props.caption,onChange:u})}):null},bt=()=>{const e=w(),t=A(e),[n,o]=c.useState(()=>e.canNestBlock());R(()=>{o(e.canNestBlock())},e);const i=c.useCallback(()=>{e.focus(),e.nestBlock()},[e]);return c.useMemo(()=>!t.find(u=>e.schema.blockSchema[u.type].content!=="inline"),[e.schema.blockSchema,t])?r.jsx(D,{onClick:i,isDisabled:!n,mainTooltip:"Nest Block",secondaryTooltip:v.formatKeyboardShortcut("Tab"),icon:$n}):null},kt=()=>{const e=w(),t=A(e),[n,o]=c.useState(()=>e.canUnnestBlock());R(()=>{o(e.canUnnestBlock())},e);const i=c.useCallback(()=>{e.focus(),e.unnestBlock()},[e]);return c.useMemo(()=>!t.find(u=>e.schema.blockSchema[u.type].content!=="inline"),[e.schema.blockSchema,t])?r.jsx(D,{onClick:i,isDisabled:!n,mainTooltip:"Unnest Block",secondaryTooltip:v.formatKeyboardShortcut("Shift+Tab"),icon:Xn}):null},Ve=c.forwardRef((e,t)=>{const{className:n,children:o,...i}=e;return r.jsx("div",{className:v.mergeCSSClasses("bn-image-panel-tab",n||""),...i,ref:t,children:o})}),vt=c.forwardRef((e,t)=>r.jsx(b.FileInput,{size:"xs",...e,ref:t,"data-test":"upload-input"})),xt=e=>{const{block:t,setLoading:n}=e,o=w(),[i,l]=c.useState(!1);c.useEffect(()=>{i&&setTimeout(()=>{l(!1)},3e3)},[i]);const u=c.useCallback(s=>{if(s===null)return;async function f(h){if(n(!0),o.uploadFile!==void 0)try{const k=await o.uploadFile(h);o.updateBlock(t,{type:"image",props:{url:k}})}catch{l(!0)}finally{n(!1)}}f(s)},[t,o,n]);return o.uploadFile!==void 0?r.jsxs(Ve,{children:[r.jsx(vt,{placeholder:"Upload Image",value:null,onChange:u}),i&&r.jsx(b.Text,{c:"red",size:"12px",children:"Error: Upload failed"})]}):null},Ct=c.forwardRef((e,t)=>r.jsx(b.TextInput,{size:"xs",...e,ref:t,"data-test":"embed-input"})),yt=c.forwardRef((e,t)=>r.jsx(b.Button,{size:"xs",...e,ref:t,"data-test":"embed-input-button",children:"Embed Image"})),pt=e=>{const{block:t}=e,n=w(),[o,i]=c.useState(""),l=c.useCallback(f=>{i(f.currentTarget.value)},[]),u=c.useCallback(f=>{f.key==="Enter"&&(f.preventDefault(),n.updateBlock(t,{type:"image",props:{url:o}}))},[n,t,o]),s=c.useCallback(()=>{n.updateBlock(t,{type:"image",props:{url:o}})},[n,t,o]);return r.jsxs(Ve,{children:[r.jsx(Ct,{placeholder:"Enter URL",value:o,onChange:l,onKeyDown:u,"data-test":"embed-input"}),r.jsx(yt,{className:"bn-image-panel-button",onClick:s,"data-test":"embed-input-button",children:"Embed Image"})]})},Le=e=>{const t=w(),[n,o]=c.useState("default"),[i,l]=c.useState(!1);return r.jsx(b.Group,{className:"bn-image-panel",children:e.children!==void 0?e.children:r.jsxs(b.Tabs,{value:n,onChange:o,children:[i&&r.jsx(b.LoadingOverlay,{visible:i}),r.jsxs(b.Tabs.List,{children:[t.uploadFile!==void 0&&r.jsx(b.Tabs.Tab,{value:"default","data-test":"upload-tab",children:"Upload"}),r.jsx(b.Tabs.Tab,{value:t.uploadFile===void 0?"default":"embed","data-test":"embed-tab",children:"Embed"})]}),t.uploadFile!==void 0&&r.jsx(b.Tabs.Panel,{className:"bn-upload-image-panel",value:"default",children:r.jsx(xt,{block:e.block,setLoading:l})}),r.jsx(b.Tabs.Panel,{className:"bn-embed-image-panel",value:t.uploadFile===void 0?"default":"embed",children:r.jsx(pt,{block:e.block})})]})})},St=()=>{const e=w(),t=A(e),[n,o]=c.useState(!1);c.useEffect(()=>{o(!1)},[t]);const i=t.length===1?t[0]:void 0;return i===void 0||i.type!=="image"||!v.checkBlockIsDefaultType("image",i,e)?null:r.jsxs(b.Popover,{withinPortal:!1,opened:n,position:"bottom",children:[r.jsx(b.Popover.Target,{children:r.jsx(D,{onClick:()=>o(!n),isSelected:n,mainTooltip:"Replace Image",icon:io})}),r.jsx(b.Popover.Dropdown,{children:r.jsx(Le,{block:i})})]})},mo={left:Gn,center:Yn,right:Jn,justify:Kn},de=e=>{const t=w(),n=A(t),o=c.useMemo(()=>{const u=n[0];if(v.checkBlockHasDefaultProp("textAlignment",u,t))return u.props.textAlignment},[t,n]),i=c.useCallback(u=>{t.focus();for(const s of n)v.checkBlockTypeHasDefaultProp("textAlignment",s.type,t)&&t.updateBlock(s,{props:{textAlignment:u}})},[t,n]);return c.useMemo(()=>!!n.find(u=>"textAlignment"in u.props),[n])?r.jsx(D,{onClick:()=>i(e.textAlignment),isSelected:o===e.textAlignment,mainTooltip:e.textAlignment==="justify"?"Justify Text":"Align Text "+e.textAlignment.slice(0,1).toUpperCase()+e.textAlignment.slice(1),icon:mo[e.textAlignment]}):null};function bo(e){const t=e.icon;return r.jsx(b.Menu.Item,{onClick:e.onClick,leftSection:t&&r.jsx(t,{size:16}),rightSection:e.isSelected?r.jsx(Me,{size:20,className:"bn-tick-icon"}):r.jsx("div",{className:"bn-tick-space"}),disabled:e.isDisabled,children:e.text},e.text)}function ko(e){return j({tag:"svg",attr:{viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true"},child:[{tag:"path",attr:{fillRule:"evenodd",d:"M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z",clipRule:"evenodd"}}]})(e)}function vo(e){return j({tag:"svg",attr:{viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true"},child:[{tag:"path",attr:{fillRule:"evenodd",d:"M7.293 14.707a1 1 0 010-1.414L10.586 10 7.293 6.707a1 1 0 011.414-1.414l4 4a1 1 0 010 1.414l-4 4a1 1 0 01-1.414 0z",clipRule:"evenodd"}}]})(e)}function Tt(e){const t=e.items.filter(l=>l.isSelected)[0],{ref:n,updateMaxHeight:o}=je();if(!t)return null;const i=t.icon;return r.jsxs(b.Menu,{withinPortal:!1,transitionProps:{exitDuration:0},disabled:e.isDisabled,onOpen:o,children:[r.jsx(b.Menu.Target,{children:r.jsx(b.Button,{onMouseDown:l=>{v.isSafari()&&l.currentTarget.focus()},leftSection:i&&r.jsx(i,{size:16}),rightSection:r.jsx(ko,{}),size:"xs",variant:"subtle",disabled:e.isDisabled,children:t.text})}),r.jsx("div",{ref:n,children:r.jsx(b.Menu.Dropdown,{children:e.items.map(l=>r.jsx(bo,{...l},l.text))})})]})}const jt=[{name:"Paragraph",type:"paragraph",icon:re,isSelected:e=>e.type==="paragraph"},{name:"Heading 1",type:"heading",props:{level:1},icon:at,isSelected:e=>e.type==="heading"&&"level"in e.props&&e.props.level===1},{name:"Heading 2",type:"heading",props:{level:2},icon:it,isSelected:e=>e.type==="heading"&&"level"in e.props&&e.props.level===2},{name:"Heading 3",type:"heading",props:{level:3},icon:lt,isSelected:e=>e.type==="heading"&&"level"in e.props&&e.props.level===3},{name:"Bullet List",type:"bulletListItem",icon:ut,isSelected:e=>e.type==="bulletListItem"},{name:"Numbered List",type:"numberedListItem",icon:ct,isSelected:e=>e.type==="numberedListItem"}],wt=e=>{const t=w(),n=A(t),[o,i]=c.useState(t.getTextCursorPosition().block),l=c.useMemo(()=>(e.items||jt).filter(f=>v.checkDefaultBlockTypeInSchema(f.type,t)),[t,e.items]),u=c.useMemo(()=>l.find(f=>f.type===o.type)!==void 0,[o.type,l]),s=c.useMemo(()=>{const f=h=>{t.focus();for(const k of n)t.updateBlock(k,{type:h.type,props:h.props})};return l.map(h=>({text:h.name,icon:h.icon,onClick:()=>f(h),isSelected:h.isSelected(o)}))},[o,l,t,n]);return R(()=>{i(t.getTextCursorPosition().block)},t),u?r.jsx(Tt,{items:s}):null},Mt=e=>[r.jsx(wt,{items:e},"blockTypeSelect"),r.jsx(mt,{},"imageCaptionButton"),r.jsx(St,{},"replaceImageButton"),r.jsx(ae,{basicTextStyle:"bold"},"boldStyleButton"),r.jsx(ae,{basicTextStyle:"italic"},"italicStyleButton"),r.jsx(ae,{basicTextStyle:"underline"},"underlineStyleButton"),r.jsx(ae,{basicTextStyle:"strike"},"strikeStyleButton"),r.jsx(de,{textAlignment:"left"},"textAlignLeftButton"),r.jsx(de,{textAlignment:"center"},"textAlignCenterButton"),r.jsx(de,{textAlignment:"right"},"textAlignRightButton"),r.jsx(gt,{},"colorStyleButton"),r.jsx(bt,{},"nestBlockButton"),r.jsx(kt,{},"unnestBlockButton"),r.jsx(ht,{},"createLinkButton")],Ht=e=>r.jsx(Te,{children:e.children||Mt(e.blockTypeSelectItems)}),Et=e=>{switch(e){case"left":return"top-start";case"center":return"top";case"right":return"top-end";default:return"top-start"}},Bt=e=>{const t=c.useRef(null),n=w(),[o,i]=c.useState(()=>{const C=n.getTextCursorPosition().block;return"textAlignment"in C.props?Et(C.props.textAlignment):"top-start"});R(()=>{const C=n.getTextCursorPosition().block;"textAlignment"in C.props?i(Et(C.props.textAlignment)):i("top-start")},n);const l=Q(n.formattingToolbar.onUpdate.bind(n.formattingToolbar)),{isMounted:u,ref:s,style:f}=oe((l==null?void 0:l.show)||!1,(l==null?void 0:l.referencePos)||null,3e3,{placement:o,middleware:[P.offset(10),P.flip()]}),h=c.useMemo(()=>tt([t,s]),[t,s]);if(!u||!l)return null;if(!l.show&&t.current)return r.jsx("div",{ref:h,style:f,dangerouslySetInnerHTML:{__html:t.current.innerHTML}});const k=e.formattingToolbar||Ht;return r.jsx("div",{ref:h,style:f,children:r.jsx(k,{})})},Vt=e=>r.jsx(He,{button:r.jsx(D,{mainTooltip:"Edit",isSelected:!1,children:"Edit Link"}),dropdownItems:r.jsx(Be,{...e})}),Lt=e=>r.jsx(D,{mainTooltip:"Open in new tab",isSelected:!1,onClick:()=>{window.open(e.url,"_blank")},icon:lo}),It=e=>r.jsx(D,{mainTooltip:"Remove link",isSelected:!1,onClick:e.deleteLink,icon:to}),Pt=e=>e.children?r.jsx(Te,{children:e.children}):r.jsxs(Te,{onMouseEnter:e.stopHideTimer,onMouseLeave:e.startHideTimer,children:[r.jsx(Vt,{url:e.url,text:e.text,editLink:e.editLink}),r.jsx(Lt,{url:e.url}),r.jsx(It,{deleteLink:e.deleteLink})]}),Dt=e=>{const t=w(),n={deleteLink:t.linkToolbar.deleteLink,editLink:t.linkToolbar.editLink,startHideTimer:t.linkToolbar.startHideTimer,stopHideTimer:t.linkToolbar.stopHideTimer},o=Q(t.linkToolbar.onUpdate.bind(t.linkToolbar)),{isMounted:i,ref:l,style:u}=oe((o==null?void 0:o.show)||!1,(o==null?void 0:o.referencePos)||null,4e3,{placement:"top-start",middleware:[P.offset(10),P.flip()]});if(!i||!o)return null;const{show:s,referencePos:f,...h}=o,k=e.linkToolbar||Pt;return r.jsx("div",{ref:l,style:u,children:r.jsx(k,{...h,...n})})},_t=e=>{const t=w();if(!t.imagePanel)throw new Error("ImageToolbarController can only be used when BlockNote editor schema contains image block");const n=Q(t.imagePanel.onUpdate.bind(t.imagePanel)),{isMounted:o,ref:i,style:l}=oe((n==null?void 0:n.show)||!1,(n==null?void 0:n.referencePos)||null,5e3,{placement:"bottom",middleware:[P.offset(10),P.flip()]});if(!o||!n)return null;const{show:u,referencePos:s,...f}=n,h=e.imageToolbar||Le;return r.jsx("div",{ref:i,style:l,children:r.jsx(h,{...f})})};function xo(e){return j({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"}},{tag:"path",attr:{d:"M192 474h672q8 0 8 8v60q0 8-8 8H160q-8 0-8-8v-60q0-8 8-8Z"}}]})(e)}const Ie=e=>r.jsx(b.ActionIcon,{size:24,children:e.children}),Ot=e=>r.jsx(Ie,{children:r.jsx(xo,{size:24,onClick:e.addBlock,"data-test":"dragHandleAdd"})});function At(e){return j({tag:"svg",attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{fill:"none",d:"M0 0h24v24H0V0z"}},{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"}}]})(e)}const Pe=e=>{const{children:t,...n}=e;return r.jsx(b.Menu.Item,{...n,children:t})},Rt=e=>{const t=w(),[n,o]=c.useState(!1),{ref:i,updateMaxHeight:l}=je(),u=c.useRef(),s=c.useCallback(()=>{u.current&&clearTimeout(u.current),u.current=setTimeout(()=>{o(!1)},250)},[]),f=c.useCallback(()=>{u.current&&clearTimeout(u.current),n||l(),o(!0)},[n,l]);return!v.checkBlockTypeHasDefaultProp("textColor",e.block.type,t)&&!v.checkBlockTypeHasDefaultProp("backgroundColor",e.block.type,t)?null:r.jsx(Pe,{onMouseLeave:s,onMouseOver:f,children:r.jsxs(b.Menu,{withinPortal:!1,opened:n,position:"right",children:[r.jsx(b.Menu.Target,{children:r.jsxs("div",{style:{display:"flex",alignItems:"center"},children:[r.jsx("div",{style:{flex:1},children:e.children}),r.jsx(b.Box,{style:{display:"flex",alignItems:"center"},children:r.jsx(vo,{size:15})})]})}),r.jsx("div",{ref:i,children:r.jsx(b.Menu.Dropdown,{onMouseLeave:s,onMouseOver:f,style:{marginLeft:"5px"},children:r.jsx(dt,{iconSize:18,text:v.checkBlockTypeHasDefaultProp("textColor",e.block.type,t)&&v.checkBlockHasDefaultProp("textColor",e.block,t)?{color:e.block.props.textColor,setColor:h=>t.updateBlock(e.block,{type:e.block.type,props:{textColor:h}})}:void 0,background:v.checkBlockTypeHasDefaultProp("backgroundColor",e.block.type,t)&&v.checkBlockHasDefaultProp("backgroundColor",e.block,t)?{color:e.block.props.backgroundColor,setColor:h=>t.updateBlock(e.block,{props:{backgroundColor:h}})}:void 0})})})]})})},Ft=e=>{const t=w();return r.jsx(Pe,{onClick:()=>t.removeBlocks([e.block]),children:e.children})},Nt=e=>r.jsx(b.Menu.Dropdown,{className:"bn-drag-handle-menu",children:e.children||r.jsxs(r.Fragment,{children:[r.jsx(Ft,{...e,children:"Delete"}),r.jsx(Rt,{...e,children:"Colors"})]})}),Zt=e=>{const t=e.dragHandleMenu||Nt;return r.jsxs(b.Menu,{withinPortal:!1,trigger:"click",onOpen:e.freezeMenu,onClose:e.unfreezeMenu,width:100,position:"left",children:[r.jsx(b.Menu.Target,{children:r.jsx("div",{className:"bn-drag-handle",draggable:"true",onDragStart:e.blockDragStart,onDragEnd:e.blockDragEnd,children:r.jsx(Ie,{children:r.jsx(At,{size:24,"data-test":"dragHandle"})})})}),r.jsx(t,{block:e.block})]})},zt=e=>{const{addBlock:t,...n}=e;return r.jsx(b.Group,{className:"bn-side-menu",gap:0,children:e.children||r.jsxs(r.Fragment,{children:[r.jsx(Ot,{addBlock:t}),r.jsx(Zt,{...n})]})})},Ut=e=>{const t=w(),n={addBlock:t.sideMenu.addBlock,blockDragStart:t.sideMenu.blockDragStart,blockDragEnd:t.sideMenu.blockDragEnd,freezeMenu:t.sideMenu.freezeMenu,unfreezeMenu:t.sideMenu.unfreezeMenu},o=Q(t.sideMenu.onUpdate.bind(t.sideMenu)),{isMounted:i,ref:l,style:u}=oe((o==null?void 0:o.show)||!1,(o==null?void 0:o.referencePos)||null,1e3,{placement:"left"});if(!i||!o)return null;const{show:s,referencePos:f,...h}=o,k=e.sideMenu||zt;return r.jsx("div",{ref:l,style:u,children:r.jsx(k,{...h,...n})})},Co={"Heading 1":at,"Heading 2":it,"Heading 3":lt,"Numbered List":ct,"Bullet List":ut,Paragraph:re,Table:oo,Image:ao};function De(e){return v.getDefaultSlashMenuItems(e).map(t=>{const n=Co[t.title];return{...t,icon:r.jsx(n,{size:18})}})}function Wt(e,t,n,o=3){const i=c.useRef(0);c.useEffect(()=>{t!==void 0&&(e.length>0?i.current=t.length:t.length-i.current>o&&n())},[n,o,e.length,t])}function qt(e,t){const[n,o]=c.useState([]),[i,l]=c.useState(!1),u=c.useRef(),s=c.useRef();return c.useEffect(()=>{const f=e;u.current=e,l(!0),t(e).then(h=>{u.current===f&&(o(h),l(!1),s.current=f)})},[e,t]),{items:n||[],usedQuery:s.current,loadingState:s.current===void 0?"loading-initial":i?"loading":"loaded"}}function Yt(e,t,n,o){const[i,l]=c.useState(0);return c.useEffect(()=>{const u=s=>s.key==="ArrowUp"?(s.preventDefault(),t.length&&l((i-1+t.length)%t.length),!0):s.key==="ArrowDown"?(s.preventDefault(),t.length&&l((i+1)%t.length),!0):s.key==="Enter"?(s.preventDefault(),t.length&&(o==null||o(t[i])),!0):s.key==="Escape"?(s.preventDefault(),n(),!0):!1;return e.domElement.addEventListener("keydown",u,!0),()=>{e.domElement.removeEventListener("keydown",u,!0)}},[n,e.domElement,t,i,o]),i}function Kt(e){const t=w(),{getItems:n,suggestionMenuComponent:o,query:i,clearQuery:l,closeMenu:u,onItemClick:s}=e,f=c.useCallback(q=>{u(),l(),s==null||s(q)},[s,u,l]),{items:h,usedQuery:k,loadingState:C}=qt(i,n);Wt(h,k,u);const H=Yt(t,h,u,f),L=o;return r.jsx(L,{items:h,onItemClick:f,loadingState:C,selectedIndex:H})}const yo=5;function Gt(e){const t=c.useRef(null);function n(){var u;const i=e.isSelected,l=(u=t.current)==null?void 0:u.matches(":hover");return i||l}function o(){var i,l;n()?(i=t.current)==null||i.setAttribute("data-hovered","true"):(l=t.current)==null||l.removeAttribute("data-hovered")}return c.useEffect(()=>{o(),n()&&t.current&&t.current.getBoundingClientRect().left>yo&&t.current.scrollIntoView({behavior:"smooth",block:"nearest"})}),r.jsx(b.Menu.Item,{className:"bn-slash-menu-item",onClick:e.onClick,closeMenuOnClick:!1,onMouseLeave:()=>{setTimeout(()=>{o()},1)},leftSection:e.icon,rightSection:e.badge&&r.jsx(b.Badge,{size:"xs",children:e.badge}),ref:t,children:r.jsxs(b.Stack,{children:[r.jsx(b.Text,{lh:"20px",size:"14px",fw:500,children:e.title}),r.jsx(b.Text,{lh:"16px",size:"10px",children:e.subtext})]})})}function Jt(e){const{items:t,loadingState:n,selectedIndex:o,onItemClick:i}=e,l=n==="loading-initial"||n==="loading"?r.jsx(b.Loader,{className:"bn-slash-menu-loader",type:"dots"}):null,u=c.useMemo(()=>{let s;const f=[];for(le