@innoviatech/lexical-text-editor 0.0.4 → 0.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/AlignmentSelectionList.d.ts +9 -0
- package/dist/components/ColorPicker.d.ts +7 -0
- package/dist/components/ContentPreview.d.ts +10 -0
- package/dist/components/DropdownList.d.ts +9 -0
- package/dist/components/HeadingSelectionList.d.ts +9 -0
- package/dist/components/ImageComponent.d.ts +11 -0
- package/dist/components/InsertDropdownList.d.ts +1 -0
- package/dist/components/LexicalTextEditor.d.ts +9 -0
- package/dist/components/LinkModal.d.ts +9 -0
- package/dist/components/Separator.d.ts +1 -0
- package/dist/components/ui/button.d.ts +14 -0
- package/dist/components/ui/command.d.ts +18 -0
- package/dist/components/ui/dialog.d.ts +15 -0
- package/dist/components/ui/input.d.ts +3 -0
- package/dist/components/ui/popover.d.ts +7 -0
- package/dist/components/ui/scroll-area.d.ts +5 -0
- package/dist/components/ui/tooltip.d.ts +7 -0
- package/dist/constants/index.d.ts +71 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.esm.js +2 -0
- package/dist/index.esm.js.map +1 -0
- package/dist/index.js +1 -26
- package/dist/index.js.map +1 -1
- package/dist/lib/utils.d.ts +1 -0
- package/dist/nodes/ImageNode.d.ts +43 -0
- package/dist/nodes/VideoNode.d.ts +30 -0
- package/dist/nodes/YoutubeNode.d.ts +25 -0
- package/dist/plugins/ColorPlugin.d.ts +1 -0
- package/dist/plugins/CustomOnChangePlugin.d.ts +6 -0
- package/dist/plugins/ImagePlugin.d.ts +1 -0
- package/dist/plugins/ListPlugin.d.ts +5 -0
- package/dist/plugins/ToolbarPlugin.d.ts +3 -0
- package/dist/plugins/VideoPlugin.d.ts +1 -0
- package/dist/style.css +2 -0
- package/innoviatech-lexical-text-editor-0.0.5.tgz +0 -0
- package/package.json +30 -38
- package/postcss.config.js +6 -0
- package/rollup.config.js +41 -25
- package/src/components/ColorPicker.tsx +0 -1
- package/src/components/ContentPreview.tsx +0 -1
- package/src/components/ImageComponent.tsx +5 -5
- package/src/components/LexicalTextEditor.tsx +5 -18
- package/src/components/ui/button.tsx +27 -29
- package/src/index.ts +5 -3
- package/src/lib/utils.ts +5 -5
- package/src/nodes/ImageNode.tsx +1 -152
- package/src/plugins/ImagePlugin.tsx +0 -1
- package/src/plugins/ListPlugin.tsx +0 -1
- package/src/styles/lexical-editor.css +63 -30
- package/src/types/global.d.ts +34 -0
- package/src/types/other.d.ts +11 -0
- package/src/types/react-icons.d.ts +11 -0
- package/tailwind.config.js +10 -0
- package/tsconfig.json +23 -10
- package/dist/index.css +0 -111
- package/dist/index.mjs +0 -27
- package/dist/index.mjs.map +0 -1
package/dist/index.mjs
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import{jsx as e,jsxs as t,Fragment as n}from"react/jsx-runtime";import{LexicalComposer as r}from"@lexical/react/LexicalComposer";import*as i from"react";import o,{useState as a,forwardRef as l,createElement as c,useRef as s,useEffect as d,useCallback as u,useMemo as f}from"react";import{$isHeadingNode as p,$isQuoteNode as h,$createQuoteNode as m,$createHeadingNode as g,HeadingNode as v,QuoteNode as b}from"@lexical/rich-text";import{CodeHighlightNode as y,CodeNode as x}from"@lexical/code";import{RichTextPlugin as w}from"@lexical/react/LexicalRichTextPlugin";import{ContentEditable as C}from"@lexical/react/LexicalContentEditable";import{LexicalErrorBoundary as N}from"@lexical/react/LexicalErrorBoundary";import{HistoryPlugin as k}from"@lexical/react/LexicalHistoryPlugin";import{ListPlugin as _}from"@lexical/react/LexicalListPlugin";import{REMOVE_LIST_COMMAND as A,INSERT_ORDERED_LIST_COMMAND as S,INSERT_UNORDERED_LIST_COMMAND as z,$isListNode as L,ListNode as O,ListItemNode as T}from"@lexical/list";import{RxLetterCaseLowercase as E,RxLetterCaseUppercase as D,RxLetterCaseCapitalize as M}from"react-icons/rx";import{TbBold as P,TbItalic as R,TbUnderline as U}from"react-icons/tb";import{BsSuperscript as F,BsSubscript as H,BsChatSquareQuote as I,BsArrowCounterclockwise as j,BsArrowClockwise as W,BsJustifyLeft as K,BsTextCenter as B,BsJustifyRight as J,BsJustify as $,BsTextParagraph as Q,BsTypeH1 as V,BsTypeH2 as q,BsTypeH3 as Z,BsTypeH4 as Y,BsTypeH5 as X,BsTypeH6 as G,BsListOl as ee,BsListUl as te}from"react-icons/bs";import{AiOutlineStrikethrough as ne,AiOutlineFontColors as re,AiOutlineBgColors as ie}from"react-icons/ai";import{IoCodeSlashOutline as oe,IoImageOutline as ae}from"react-icons/io5";import{PiHighlighterLight as le}from"react-icons/pi";import{useLexicalComposerContext as ce}from"@lexical/react/LexicalComposerContext";import{$createRangeSelection as se,$findMatchingParent as de,INTERNAL_$isBlock as ue,$isElementNode as fe,$getSelection as pe,$setSelection as he,$isRootOrShadowRoot as me,$hasAncestor as ge,$isRangeSelection as ve,$isTextNode as be,$isTokenOrSegmented as ye,$getCharacterOffsets as xe,$isLeafNode as we,$getPreviousSelection as Ce,$caretRangeFromSelection as Ne,SELECTION_CHANGE_COMMAND as ke,$getNodeByKey as _e,DecoratorNode as Ae,$applyNodeReplacement as Se,$insertNodes as ze,CAN_REDO_COMMAND as Le,CAN_UNDO_COMMAND as Oe,REDO_COMMAND as Te,UNDO_COMMAND as Ee,FORMAT_ELEMENT_COMMAND as De,FORMAT_TEXT_COMMAND as Me,$createParagraphNode as Pe,$getRoot as Re,isDOMDocumentNode as Ue,ArtificialNode__DO_NOT_USE as Fe,$createLineBreakNode as He,$cloneWithProperties as Ie,getRegisteredNode as je,isHTMLElement as We,isDocumentFragment as Ke,$isBlockElementNode as Be,isBlockDomNode as Je,isInlineDomNode as $e}from"lexical";import{TOGGLE_LINK_COMMAND as Qe,$isLinkNode as Ve,LinkNode as qe}from"@lexical/link";import{cva as Ze}from"class-variance-authority";import{clsx as Ye}from"clsx";import{twMerge as Xe}from"tailwind-merge";import*as Ge from"@radix-ui/react-tooltip";import*as et from"@radix-ui/react-popover";import{HiChevronDown as tt}from"react-icons/hi2";import{IoIosLink as nt}from"react-icons/io";import{TiDeleteOutline as rt}from"react-icons/ti";import{SketchPicker as it}from"react-color";import{createPortal as ot}from"react-dom";import*as at from"@radix-ui/react-dialog";import{FaYoutube as lt}from"react-icons/fa";import{VscPreview as ct}from"react-icons/vsc";import{LinkPlugin as st}from"@lexical/react/LexicalLinkPlugin";import{OnChangePlugin as dt}from"@lexical/react/LexicalOnChangePlugin";var ut=function(e,t){return ut=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},ut(e,t)};function ft(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function n(){this.constructor=e}ut(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}var pt,ht,mt=function(){return mt=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},mt.apply(this,arguments)};function gt(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(r=Object.getOwnPropertySymbols(e);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]])}return n}"function"==typeof SuppressedError&&SuppressedError,function(e){e.Bold="bold",e.Italics="italics",e.Underline="underline",e.Quote="quote",e.Lowercase="lowercase",e.Uppercase="uppercase",e.Capitalize="capitalize",e.Strikethrough="strikethrough",e.Superscript="superscript",e.Subscript="subscript",e.Highlight="highlight",e.Code="code",e.Link="link",e.LeftAlign="leftAlign",e.CenterAlign="centerAlign",e.RightAlign="rightAlign",e.JustifyAlign="justifyAlign",e.Divider="divider",e.Undo="undo",e.Redo="redo"}(pt||(pt={})),function(e){e.Normal="normal",e.H1="h1",e.H2="h2",e.H3="h3",e.H4="h4",e.H5="h5",e.H6="h6"}(ht||(ht={}));var vt=[{id:pt.Lowercase,icon:e(E,{}),label:"Lowercase"},{id:pt.Uppercase,icon:e(D,{}),label:"Uppercase"},{id:pt.Capitalize,icon:e(M,{}),label:"Capitalize"},{id:pt.Strikethrough,icon:e(ne,{}),label:"Strikethrough"},{id:pt.Highlight,icon:e(le,{}),label:"Highlight",fontSize:10},{id:pt.Superscript,icon:e(F,{}),label:"Superscript"},{id:pt.Subscript,icon:e(H,{}),label:"Subscript"}],bt=[{id:pt.Bold,icon:e(P,{}),label:"Bold"},{id:pt.Italics,icon:e(R,{}),label:"Italics"},{id:pt.Underline,icon:e(U,{}),label:"Underline"},{id:pt.Divider},{id:pt.Quote,icon:e(I,{}),label:"Quote"},{id:pt.Code,icon:e(oe,{}),label:"Code"}],yt=[{id:pt.Undo,icon:e(j,{}),label:"Undo"},{id:pt.Redo,icon:e(W,{}),label:"Redo"},{id:pt.Divider}],xt=[{id:pt.LeftAlign,icon:e(K,{}),label:"Left Align"},{id:pt.CenterAlign,icon:e(B,{}),label:"Center Align"},{id:pt.RightAlign,icon:e(J,{}),label:"Right Align"},{id:pt.JustifyAlign,icon:e($,{}),label:"Justify Align"}],wt=[{id:"normal",label:"Normal",icon:e(Q,{})},{id:"h1",label:"Heading 1",icon:e(V,{})},{id:"h2",label:"Heading 2",icon:e(q,{})},{id:"h3",label:"Heading 3",icon:e(Z,{})},{id:"h4",label:"Heading 4",icon:e(Y,{})},{id:"h5",label:"Heading 5",icon:e(X,{})},{id:"h6",label:"Heading 6",icon:e(G,{})}];function Ct(e,...t){const n=new URL("https://lexical.dev/docs/error"),r=new URLSearchParams;r.append("code",e);for(const e of t)r.append("v",e);throw n.search=r.toString(),Error(`Minified Lexical error #${e}; visit ${n.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}const Nt=new Map;function kt(e){let t=Nt.get(e);return void 0===t&&(t=function(e){const t={};if(!e)return t;const n=e.split(";");for(const e of n)if(""!==e){const[n,r]=e.split(/:([^]+)/);n&&r&&(t[n.trim()]=r.trim())}return t}(e),Nt.set(e,t)),t}function _t(e,t){(ve(e)?e.isCollapsed():be(e)||fe(e))||Ct(280);const n=kt(ve(e)?e.style:be(e)?e.getStyle():e.getTextStyle()),r=Object.entries(t).reduce((t,[r,i])=>("function"==typeof i?t[r]=i(n[r],e):null===i?delete t[r]:t[r]=i,t),{...n}),i=function(e){let t="";for(const n in e)n&&(t+=`${n}: ${e[n]};`);return t}(r);ve(e)||be(e)?e.setStyle(i):e.setTextStyle(i),Nt.set(i,r)}function At(e,t){if(ve(e)&&e.isCollapsed()){_t(e,t);const n=e.anchor.getNode();fe(n)&&n.isEmpty()&&_t(n,t)}!function(e){const t=pe();if(!t)return;const n=new Map,r=e=>n.get(e.getKey())||[0,e.getTextContentSize()];if(ve(t))for(const e of Ne(t).getTextSlices())e&&n.set(e.caret.origin.getKey(),e.getSliceIndices());const i=t.getNodes();for(const t of i){if(!be(t)||!t.canHaveFormat())continue;const[n,i]=r(t);i!==n&&(ye(t)||0===n&&i===t.getTextContentSize()?e(t):e(t.splitText(n,i)[0===n?0:1]))}ve(t)&&"text"===t.anchor.type&&"text"===t.focus.type&&t.anchor.key===t.focus.key&&function(e){if(e.isBackward()){const{anchor:t,focus:n}=e,{key:r,offset:i,type:o}=t;t.set(n.key,n.offset,n.type),n.set(r,i,o)}}(t)}(e=>{_t(e,t)})}function St(e,t){const n=e.getFormatType(),r=e.getIndent();n!==t.getFormatType()&&t.setFormat(n),r!==t.getIndent()&&t.setIndent(r)}function zt(e){return e.getNode().isAttached()}function Lt(e){let t=e;for(;null!==t&&!me(t);){const e=t.getLatest(),n=t.getParent();0===e.getChildrenSize()&&t.remove(!0),t=n}}function Ot(e,t,n=null){const r=e.getStartEndPoints(),i=r?r[0]:null,o=e.getNodes(),a=o.length;if(null!==i&&(0===a||1===a&&"element"===i.type&&0===i.getNode().getChildrenSize())){const e="text"===i.type?i.getNode().getParentOrThrow():i.getNode(),r=e.getChildren();let o=t();return o.setFormat(e.getFormatType()),o.setIndent(e.getIndent()),r.forEach(e=>o.append(e)),n&&(o=n.append(o)),void e.replace(o)}let l=null,c=[];for(let r=0;r<a;r++){const i=o[r];me(i)?(Tt(e,c,c.length,t,n),c=[],l=i):null===l||null!==l&&ge(i,l)?c.push(i):(Tt(e,c,c.length,t,n),c=[i])}Tt(e,c,c.length,t,n)}function Tt(e,t,n,r,i=null){if(0===t.length)return;const o=t[0],a=new Map,l=[];let c=fe(o)?o:o.getParentOrThrow();c.isInline()&&(c=c.getParentOrThrow());let s=!1;for(;null!==c;){const e=c.getPreviousSibling();if(null!==e){c=e,s=!0;break}if(c=c.getParentOrThrow(),me(c))break}const d=new Set;for(let e=0;e<n;e++){const n=t[e];fe(n)&&0===n.getChildrenSize()&&d.add(n.getKey())}const u=new Set;for(let e=0;e<n;e++){const n=t[e];let i=n.getParent();if(null!==i&&i.isInline()&&(i=i.getParent()),null!==i&&we(n)&&!u.has(n.getKey())){const e=i.getKey();if(void 0===a.get(e)){const t=r();t.setFormat(i.getFormatType()),t.setIndent(i.getIndent()),l.push(t),a.set(e,t),i.getChildren().forEach(e=>{t.append(e),u.add(e.getKey()),fe(e)&&e.getChildrenKeys().forEach(e=>u.add(e))}),Lt(i)}}else if(d.has(n.getKey())){fe(n)||Ct(179);const e=r();e.setFormat(n.getFormatType()),e.setIndent(n.getIndent()),l.push(e),n.remove(!0)}}if(null!==i)for(let e=0;e<l.length;e++){const t=l[e];i.append(t)}let f=null;if(me(c))if(s)if(null!==i)c.insertAfter(i);else for(let e=l.length-1;e>=0;e--){const t=l[e];c.insertAfter(t)}else{const e=c.getFirstChild();if(fe(e)&&(c=e),null===e)if(i)c.append(i);else for(let e=0;e<l.length;e++){const t=l[e];c.append(t),f=t}else if(null!==i)e.insertBefore(i);else for(let t=0;t<l.length;t++){const n=l[t];e.insertBefore(n),f=n}}else if(i)c.insertAfter(i);else for(let e=l.length-1;e>=0;e--){const t=l[e];c.insertAfter(t),f=t}const p=Ce();ve(p)&&zt(p.anchor)&&zt(p.focus)?he(p.clone()):null!==f?f.selectEnd():e.dirty=!0}function Et(e,t,n){const r=kt(e.getStyle());return null!==r&&r[t]||n}function Dt(e,t,n=""){let r=null;const i=e.getNodes(),o=e.anchor,a=e.focus,l=e.isBackward(),c=l?a.offset:o.offset,s=l?a.getNode():o.getNode();if(ve(e)&&e.isCollapsed()&&""!==e.style){const n=kt(e.style);if(null!==n&&t in n)return n[t]}for(let e=0;e<i.length;e++){const o=i[e];if((0===e||0!==c||!o.is(s))&&be(o)){const e=Et(o,t,n);if(null===r)r=e;else if(r!==e){r="";break}}}return null===r?n:r}const Mt="undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement,Pt=Mt&&"documentMode"in document?document.documentMode:null;function Rt(...e){return()=>{for(let t=e.length-1;t>=0;t--)e[t]();e.length=0}}function Ut(e,t){if("function"==typeof e)return e(t);null!=e&&(e.current=t)}function Ft(t){const n=It(t),r=i.forwardRef((t,r)=>{const{children:o,...a}=t,l=i.Children.toArray(o),c=l.find(Wt);if(c){const t=c.props.children,o=l.map(e=>e===c?i.Children.count(t)>1?i.Children.only(null):i.isValidElement(t)?t.props.children:null:e);return e(n,{...a,ref:r,children:i.isValidElement(t)?i.cloneElement(t,void 0,o):null})}return e(n,{...a,ref:r,children:o})});return r.displayName=`${t}.Slot`,r}Mt&&"InputEvent"in window&&!Pt&&new window.InputEvent("input");var Ht=Ft("Slot");function It(e){const t=i.forwardRef((e,t)=>{const{children:n,...r}=e;if(i.isValidElement(n)){const e=function(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning;if(n)return e.ref;if(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n)return e.props.ref;return e.props.ref||e.ref}(n),o=function(e,t){const n={...t};for(const r in t){const i=e[r],o=t[r];/^on[A-Z]/.test(r)?i&&o?n[r]=(...e)=>{const t=o(...e);return i(...e),t}:i&&(n[r]=i):"style"===r?n[r]={...i,...o}:"className"===r&&(n[r]=[i,o].filter(Boolean).join(" "))}return{...e,...n}}(r,n.props);return n.type!==i.Fragment&&(o.ref=t?function(...e){return t=>{let n=!1;const r=e.map(e=>{const r=Ut(e,t);return n||"function"!=typeof r||(n=!0),r});if(n)return()=>{for(let t=0;t<r.length;t++){const n=r[t];"function"==typeof n?n():Ut(e[t],null)}}}}(t,e):e),i.cloneElement(n,o)}return i.Children.count(n)>1?i.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var jt=Symbol("radix.slottable");function Wt(e){return i.isValidElement(e)&&"function"==typeof e.type&&"__radixId"in e.type&&e.type.__radixId===jt}function Kt(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return Xe(Ye(e))}var Bt=Ze("cursor-pointer inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-all disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 [&_svg]:shrink-0 outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/90",toolbar:"bg-transparent hover:bg-slate-100/80 text-gray-600",toolbarActive:"bg-slate-100 text-gray-900 ",destructive:"bg-destructive text-white hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",outline:"border bg-background shadow-xs hover:bg-accent hover:text-accent-foreground dark:bg-input/30 dark:border-input dark:hover:bg-input/50",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-9 px-4 py-2 has-[>svg]:px-2",sm:"h-8 rounded-md gap-1.5 px-3 has-[>svg]:px-2.5",lg:"h-10 rounded-md px-6 has-[>svg]:px-4",icon:"size-9"}},defaultVariants:{variant:"default",size:"default"}});function Jt(t){var n=t.className,r=t.variant,i=t.size,o=t.asChild,a=void 0!==o&&o,l=gt(t,["className","variant","size","asChild"]);return e(a?Ht:"button",mt({"data-slot":"button",className:Kt(Bt({variant:r,size:i,className:n}))},l))}function $t(t){var n=t.delayDuration,r=void 0===n?0:n,i=gt(t,["delayDuration"]);return e(Ge.Provider,mt({"data-slot":"tooltip-provider",delayDuration:r},i))}function Qt(t){var n=gt(t,[]);return e($t,{children:e(Ge.Root,mt({"data-slot":"tooltip"},n))})}function Vt(t){var n=gt(t,[]);return e(Ge.Trigger,mt({"data-slot":"tooltip-trigger"},n))}function qt(n){var r=n.className,i=n.sideOffset,o=void 0===i?0:i,a=n.children,l=gt(n,["className","sideOffset","children"]);return e(Ge.Portal,{children:t(Ge.Content,mt({"data-slot":"tooltip-content",sideOffset:o,className:Kt("bg-foreground text-background animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 w-fit origin-(--radix-tooltip-content-transform-origin) rounded-md px-3 py-1.5 text-xs text-balance",r)},l,{children:[a,e(Ge.Arrow,{className:"bg-foreground fill-foreground z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px]"})]}))})}function Zt(t){var n=gt(t,[]);return e(et.Root,mt({"data-slot":"popover"},n))}function Yt(t){var n=gt(t,[]);return e(et.Trigger,mt({"data-slot":"popover-trigger"},n))}function Xt(t){var n=t.className,r=t.align,i=void 0===r?"center":r,o=t.sideOffset,a=void 0===o?4:o,l=gt(t,["className","align","sideOffset"]);return e(et.Portal,{children:e(et.Content,mt({"data-slot":"popover-content",align:i,sideOffset:a,className:Kt("bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 w-72 origin-(--radix-popover-content-transform-origin) rounded-md border p-4 shadow-md outline-hidden",n)},l))})}function Gt(n){var r=n.onAction,i=n.selectionMap,o=a(!1),l=o[0],c=o[1];return t(Zt,{open:l,onOpenChange:function(e){return c(e)},children:[e(Yt,{asChild:!0,children:t(Jt,{variant:l?"toolbarActive":"toolbar",onClick:function(){return c(!l)},size:"icon",className:"size-8 w-fit p-2 select-none border-[1px] border-gray-100",children:[e("span",{children:"Aa"})," ",e(tt,{className:" transition-normal duration-100 ".concat(l?"rotate-180":"rotate-0")})]})}),e(Xt,{className:"p-2 w-fit flex flex-col items-start gap-1",children:vt.map(function(n){var o=n.id,a=n.label,l=n.icon;return t(Jt,{variant:i[o]?"toolbarActive":"toolbar",onClick:function(){return r(o)},size:"icon",className:"size-8 w-full flex justify-start py-2 px-3 select-none",children:[l," ",e("span",{className:"ml-2",children:a})]},o)})})]})}function en(){return e("div",{className:"w-[1px] h-[20px] mx-[2px] bg-gray-300 shrink-0"})}function tn(n){var r=n.updateHeading,i=n.headingSelectionMap,o=wt.find(function(e){return i[e.id]}),l=a(!1),c=l[0],s=l[1];return t(Zt,{open:c,onOpenChange:function(e){return s(e)},children:[e(Yt,{asChild:!0,children:t(Jt,{variant:c?"toolbarActive":"toolbar",onClick:function(){return s(!c)},size:"icon",className:"size-8 w-fit p-2 select-none min-w-[130px] border-[1px] border-gray-100",children:[null==o?void 0:o.icon,e("span",{children:null==o?void 0:o.label})," ",e(tt,{className:" transition-normal duration-100 ".concat(c?"rotate-180":"rotate-0")})]})}),e(Xt,{align:"start",className:"p-2 w-fit flex flex-col items-start gap-1",children:wt.map(function(n){var o=n.id,a=n.label,l=n.icon;return t(Jt,{variant:i[o]?"toolbarActive":"toolbar",onClick:function(){return r(o)},size:"icon",className:"size-8 w-full flex justify-start py-2 px-3 select-none",children:[l," ",e("span",{className:"ml-2",children:a})]},o)})})]})}function nn(t){var n=t.className,r=t.type,i=gt(t,["className","type"]);return e("input",mt({type:r,"data-slot":"input",className:Kt("file:text-foreground placeholder:text-muted-foreground selection:bg-primary selection:text-primary-foreground dark:bg-input/30 border-input h-9 w-full min-w-0 rounded-md border bg-transparent px-3 py-1 text-base shadow-xs transition-[color,box-shadow] outline-none file:inline-flex file:h-7 file:border-0 file:bg-transparent file:text-sm file:font-medium disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 md:text-sm","focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px]","aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",n)},i))}
|
|
2
|
-
/**
|
|
3
|
-
* @license lucide-react v0.546.0 - ISC
|
|
4
|
-
*
|
|
5
|
-
* This source code is licensed under the ISC license.
|
|
6
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
7
|
-
*/const rn=e=>{const t=(e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,t,n)=>n?n.toUpperCase():t.toLowerCase()))(e);return t.charAt(0).toUpperCase()+t.slice(1)},on=(...e)=>e.filter((e,t,n)=>Boolean(e)&&""!==e.trim()&&n.indexOf(e)===t).join(" ").trim(),an=e=>{for(const t in e)if(t.startsWith("aria-")||"role"===t||"title"===t)return!0};
|
|
8
|
-
/**
|
|
9
|
-
* @license lucide-react v0.546.0 - ISC
|
|
10
|
-
*
|
|
11
|
-
* This source code is licensed under the ISC license.
|
|
12
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
13
|
-
*/
|
|
14
|
-
var ln={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};
|
|
15
|
-
/**
|
|
16
|
-
* @license lucide-react v0.546.0 - ISC
|
|
17
|
-
*
|
|
18
|
-
* This source code is licensed under the ISC license.
|
|
19
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
20
|
-
*/const cn=l(({color:e="currentColor",size:t=24,strokeWidth:n=2,absoluteStrokeWidth:r,className:i="",children:o,iconNode:a,...l},s)=>c("svg",{ref:s,...ln,width:t,height:t,stroke:e,strokeWidth:r?24*Number(n)/Number(t):n,className:on("lucide",i),...!o&&!an(l)&&{"aria-hidden":"true"},...l},[...a.map(([e,t])=>c(e,t)),...Array.isArray(o)?o:[o]])),sn=(e,t)=>{const n=l(({className:n,...r},i)=>{return c(cn,{ref:i,iconNode:t,className:on(`lucide-${o=rn(e),o.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase()}`,`lucide-${e}`,n),...r});var o});return n.displayName=rn(e),n},dn=sn("check",[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]]),un=sn("pencil",[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]]),fn=sn("upload",[["path",{d:"M12 3v12",key:"1x0j5s"}],["path",{d:"m17 8-5-5-5 5",key:"7q97r8"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}]]),pn=sn("x",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]);
|
|
21
|
-
/**
|
|
22
|
-
* @license lucide-react v0.546.0 - ISC
|
|
23
|
-
*
|
|
24
|
-
* This source code is licensed under the ISC license.
|
|
25
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
26
|
-
*/function hn(n){var r=n.linkUrl,i=n.setLinkUrl,o=n.onConfirm,l=n.onCancel,c=n.removeLink,u=a(!1),f=u[0],p=u[1],h=s(null),m=s(null);return d(function(){"https://"===r&&p(!0)},[r]),d(function(){var e;f&&(null===(e=m.current)||void 0===e||e.focus())},[f]),d(function(){var e=function(e){h.current&&!h.current.contains(e.target)&&l()};return document.addEventListener("mousedown",e),function(){document.removeEventListener("mousedown",e)}},[l]),t("div",{ref:h,className:Kt("absolute z-[9999] top-[100px] right-[20px]","bg-white shadow-lg rounded-xl px-1.5 py-1 sm:px-3 sm:py-2 flex items-center space-x-2","border border-gray-200"),children:[e("div",{className:"flex-1 min-w-[200px]",children:f?e(nn,{ref:m,className:"h-8 text-sm",value:r,onChange:function(e){return i(e.target.value)},onKeyDown:function(e){"Enter"===e.key?(e.preventDefault(),o(r),p(!1)):"Escape"===e.key&&(e.preventDefault(),p(!1),l())}}):e("a",{href:r,target:"_blank",rel:"noopener noreferrer",className:"text-blue-600 text-sm underline truncate block max-w-full text-start",children:r})}),t("div",{children:[e(Jt,{variant:"ghost",size:"icon",onMouseDown:function(e){return e.preventDefault()},onClick:function(){f?(o(r),p(!1)):p(!0)},className:"h-8 w-8",children:e(f?dn:un,{className:"h-4 w-4"})}),e(Jt,{variant:"ghost",size:"icon",onMouseDown:function(e){return e.preventDefault()},onClick:c,className:"h-8 w-8",children:e(rt,{className:"h-4 w-4"})})]})]})}function mn(n){var r=n.onAction,i=n.alignmentSelectionMap,o=xt.find(function(e){return i[e.id]}),l=a(!1),c=l[0],s=l[1];return t(Zt,{open:c,onOpenChange:function(e){return s(e)},children:[e(Yt,{asChild:!0,children:t(Jt,{variant:c?"toolbarActive":"toolbar",onClick:function(){return s(!c)},size:"icon",className:"size-8 w-fit p-2 select-none min-w-[145px] border-[1px] border-gray-100",children:[null==o?void 0:o.icon,e("span",{children:null==o?void 0:o.label})," ",e(tt,{className:" transition-normal duration-100 ".concat(c?"rotate-180":"rotate-0")})]})}),e(Xt,{align:"start",className:"p-2 w-fit flex flex-col items-start gap-1",children:xt.map(function(n){var o=n.id,a=n.label,l=n.icon;return t(Jt,{variant:i[o]?"toolbarActive":"toolbar",onClick:function(){return r(o)},size:"icon",className:"size-8 w-full flex justify-start py-2 px-3 select-none",children:[l," ",e("span",{className:"ml-2",children:a})]},o)})})]})}function gn(n){var r,i,o=n.color,l=n.onChange,c=n.icon,u=a(!1),f=u[0],p=u[1],h=s(null),m=s(null);d(function(){var e=function(e){m.current&&!m.current.contains(e.target)&&h.current&&!h.current.contains(e.target)&&p(!1)};return document.addEventListener("mousedown",e),function(){return document.removeEventListener("mousedown",e)}},[]);return t("div",{className:"relative inline-block",children:[e(Jt,{ref:h,variant:"ghost",size:"icon",className:"rounded-md text-gray-700 hover:bg-gray-200","aria-label":"Change Color",onClick:function(){return p(function(e){return!e})},children:c}),f&&ot(e("div",{ref:m,className:"\n absolute z-50 p-2 bg-transparent rounded-md select-none\n transition-all duration-200\n origin-top-left w-fit\n ".concat(f?"opacity-100 scale-100 translate-y-0":"opacity-0 scale-95 -translate-y-2 pointer-events-none"),style:{top:null===(r=h.current)||void 0===r?void 0:r.getBoundingClientRect().bottom,left:null===(i=h.current)||void 0===i?void 0:i.getBoundingClientRect().left,position:"absolute"},onMouseDown:function(e){return e.preventDefault()},children:e(it,{color:o,onChangeComplete:function(e){l(e.hex)}})}),document.body)]})}function vn(){var r=ce()[0],i=a({color:"#000",bgColor:"#fff"}),o=i[0],l=o.color,c=o.bgColor,s=i[1],u=function(){var e=pe();if(ve(e)){var t=Dt(e,"color","#000"),n=Dt(e,"background","#fff");s({color:t,bgColor:n})}};d(function(){return Rt(r.registerUpdateListener(function(e){e.editorState.read(function(){u()})}),r.registerCommand(ke,function(){return u(),!1},1))},[r]);var f=function(e){var t=e.property,n=e.color;r.update(function(){var e,r=pe();r&&At(r,((e={})[t]=n,e))})};return t(n,{children:[e(gn,{color:l,onChange:function(e){f({property:"color",color:e})},icon:e(re,{})}),e(gn,{color:c,onChange:function(e){f({property:"background",color:e})},icon:e(ie,{})})]})}function bn(r){var i=r.blockType,o=ce()[0];return t(n,{children:[t(Qt,{delayDuration:700,children:[e(Vt,{asChild:!0,children:e(Jt,{variant:"ol"===i?"toolbarActive":"toolbar",size:"icon",className:"size-8","aria-label":"Add ordered list",onClick:function(){"ol"===i?o.dispatchCommand(A,void 0):o.dispatchCommand(S,void 0)},children:e(ee,{})})}),e(qt,{side:"bottom",children:"Ordered list"})]}),t(Qt,{delayDuration:700,children:[e(Vt,{asChild:!0,children:e(Jt,{variant:"ul"===i?"toolbarActive":"toolbar",size:"icon",className:"size-8","aria-label":"Add unordered list",onClick:function(){"ul"===i?o.dispatchCommand(A,void 0):o.dispatchCommand(z,void 0)},children:e(te,{})})}),e(qt,{side:"bottom",children:"Unordered list"})]})]})}var yn=function(n){var r=n.src,i=n.altText,o=n.nodeKey,l=n.width,c=n.height,d=n.maxWidth,u=ce()[0],f=a({width:"number"==typeof l?l:d,height:"number"==typeof c?c:"auto"}),p=f[0],h=f[1],m=s(null),g=s(null),v=function(e){if(g.current){var t=e.clientX-g.current.x,n=Math.min(d,Math.max(50,g.current.width+t)),r=n/g.current.width*g.current.height||"auto";h({width:n,height:r})}},b=function(){g.current&&(u.update(function(){var e=_e(o);e&&e instanceof Cn&&e.updateDimensions(p.width,p.height)}),window.removeEventListener("mousemove",v),window.removeEventListener("mouseup",b))};return t("div",{ref:m,style:{display:"inline-block",position:"relative",maxWidth:d},children:[e("img",{src:r,alt:i,style:{width:p.width,height:p.height,maxWidth:"100%",display:"block"}}),e("div",{onMouseDown:function(e){var t,n;e.preventDefault(),e.stopPropagation(),g.current={x:e.clientX,y:e.clientY,width:p.width,height:null!==(n=null===(t=m.current)||void 0===t?void 0:t.offsetHeight)&&void 0!==n?n:0},window.addEventListener("mousemove",v),window.addEventListener("mouseup",b)},style:{position:"absolute",bottom:0,right:0,width:14,height:14,background:"white",border:"1px solid #999",cursor:"nwse-resize",borderRadius:2}})]})},xn=function(e){return Se(new Cn(e))},wn=function(e){if(e instanceof HTMLImageElement){var t=e.src,n=e.alt;return{node:xn({src:t,altText:n})}}return null},Cn=function(t){function n(e){var n=void 0===e?{}:e,r=n.src,i=void 0===r?"":r,o=n.altText,a=void 0===o?"":o,l=n.maxWidth,c=void 0===l?1080:l,s=n.width,d=n.height,u=n.key,f=t.call(this,u)||this;return f.__altText=a,f.__src=i,f.__maxWidth=c,f.__height=d,f.__width=s,f}return ft(n,t),n.getType=function(){return"image"},n.clone=function(e){return new n({altText:e.__altText,src:e.__src,height:e.__height,width:e.__width,maxWidth:e.__maxWidth,key:e.getKey()})},n.prototype.createDOM=function(){return document.createElement("span")},n.prototype.exportDOM=function(){var e=document.createElement("img");return e.setAttribute("src",this.__src),e.setAttribute("alt",this.__altText),this.__width&&"inherit"!==this.__width&&e.setAttribute("width",String(this.__width)),this.__height&&"inherit"!==this.__height&&e.setAttribute("height",String(this.__height)),{element:e}},n.importDOM=function(){return{img:function(){return{conversion:wn,priority:0}}}},n.prototype.exportJSON=function(){return{type:"image",version:1,src:this.__src,altText:this.__altText,maxWidth:this.__maxWidth,width:this.__width,height:this.__height}},n.importJSON=function(e){return new n({src:e.src,altText:e.altText,maxWidth:e.maxWidth,width:e.width,height:e.height})},n.prototype.updateDimensions=function(e,t){var n=this.getWritable();n.__width=e,n.__height=t},n.prototype.updateDOM=function(){return!1},n.prototype.decorate=function(){return e(yn,{src:this.__src,altText:this.__altText,nodeKey:this.getKey(),width:this.__width,height:this.__height,maxWidth:this.__maxWidth})},n}(Ae);function Nn(t){var n=gt(t,[]);return e(at.Root,mt({"data-slot":"dialog"},n))}function kn(t){var n=gt(t,[]);return e(at.Trigger,mt({"data-slot":"dialog-trigger"},n))}function _n(t){var n=gt(t,[]);return e(at.Portal,mt({"data-slot":"dialog-portal"},n))}function An(t){var n=t.className,r=gt(t,["className"]);return e(at.Overlay,mt({"data-slot":"dialog-overlay",className:Kt("data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/50",n)},r))}function Sn(n){var r=n.className,i=n.children,o=n.showCloseButton,a=void 0===o||o,l=gt(n,["className","children","showCloseButton"]);return t(_n,{"data-slot":"dialog-portal",children:[e(An,{}),t(at.Content,mt({"data-slot":"dialog-content","aria-describedby":"",className:Kt("bg-background data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border p-6 shadow-lg duration-200 sm:max-w-lg",r)},l,{children:[i,a&&t(at.Close,{"data-slot":"dialog-close",className:"ring-offset-background focus:ring-ring data-[state=open]:bg-accent data-[state=open]:text-muted-foreground absolute top-4 right-4 rounded-xs opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",children:[e(pn,{}),e("span",{className:"sr-only",children:"Close"})]})]}))]})}function zn(t){var n=t.className,r=gt(t,["className"]);return e("div",mt({"data-slot":"dialog-header",className:Kt("flex flex-col gap-2 text-center sm:text-left",n)},r))}function Ln(t){var n=t.className,r=gt(t,["className"]);return e("div",mt({"data-slot":"dialog-footer",className:Kt("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",n)},r))}function On(t){var n=t.className,r=gt(t,["className"]);return e(at.Title,mt({"data-slot":"dialog-title",className:Kt("text-lg leading-none font-semibold",n)},r))}function Tn(){var n=a(!1),r=n[0],i=n[1],o=a(""),l=o[0],c=o[1],d=a(""),u=d[0],f=d[1],p=a(),h=p[0],m=p[1],g=s(null),v=ce()[0];return t("div",{children:[e("input",{type:"file",ref:g,accept:"image/*",className:"hidden",onChange:function(e){var t,n=null===(t=e.target.files)||void 0===t?void 0:t[0];n&&m(n),e.target.value=""}}),t(Nn,{open:r,onOpenChange:i,children:[e(kn,{asChild:!0,children:e(Jt,{size:"icon",variant:"ghost",className:"rounded-md text-gray-700 hover:bg-gray-200",children:e(ae,{})})}),t(Sn,{className:"sm:max-w-md",children:[e(zn,{children:e(On,{className:"!text-lg text-gray-800",children:"Add Image"})}),e("div",{className:"flex flex-col gap-4 py-2",children:t("div",{className:"flex flex-col items-center gap-4",children:[e(nn,{value:u,onChange:function(e){return f(e.target.value)},placeholder:"Alt text"}),e(nn,{value:l,onChange:function(e){return c(e.target.value)},placeholder:"Add Image by URL"}),t("div",{className:"flex items-center w-full text-gray-500 text-sm",children:[e("div",{className:"flex-grow border-t border-gray-300"}),e("span",{className:"mx-2",children:"or"}),e("div",{className:"flex-grow border-t border-gray-300"})]}),t("div",{className:"flex flex-col gap-2 w-fit",children:[t(Jt,{variant:"outline",className:"flex items-center gap-2 bg-gray-50 hover:bg-gray-100",onClick:function(){var e;return null===(e=g.current)||void 0===e?void 0:e.click()},children:[e(fn,{className:"h-4 w-4"})," Upload Image"]}),h&&e("span",{className:"text-sm text-gray-600",children:h.name})]})]})}),e(Ln,{children:e(Jt,{onClick:function(){var e="";l&&(e=l),h&&(e=URL.createObjectURL(h)),v.update(function(){var t=xn({src:e,altText:u});ze([t])}),m(void 0),f(""),c(""),i(!1)},disabled:!l&&!h,className:"!bg-blue-600 text-white hover:bg-blue-700 disabled:opacity-50",children:"Add Image"})})]})]})]})}var En=function(e){var t=e.id,n=e.provider;return new Hn({id:t,provider:n})},Dn="data-lexical-video",Mn="data-provider",Pn="315px",Rn="560px",Un=function(e,t){return"drive"===t?"https://drive.google.com/file/d/".concat(e,"/preview"):"https://www.youtube-nocookie.com/embed/".concat(e)},Fn=function(e){var t,n=null==e?void 0:e.getAttribute(Dn),r=null!==(t=null==e?void 0:e.getAttribute(Mn))&&void 0!==t?t:"youtube";return n?{node:En({id:n,provider:r})}:null},Hn=function(t){function n(e){var n=e.id,r=e.provider,i=e.key,o=t.call(this,i)||this;return o.__id=n,o.__provider=r,o}return ft(n,t),n.getType=function(){return"video"},n.clone=function(e){return new n({id:e.__id,provider:e.__provider,key:e.getKey()})},n.importJSON=function(e){return En({id:e.id,provider:e.provider})},n.prototype.exportJSON=function(){return{id:this.__id,provider:this.__provider,type:"video",version:1}},n.prototype.updateDOM=function(){return!1},n.prototype.decorate=function(){return e("iframe",{height:Pn,width:Rn,src:Un(this.__id,this.__provider),frameBorder:"0",allowFullScreen:!0})},n.prototype.createDOM=function(){return document.createElement("div")},n.prototype.exportDOM=function(){var e=document.createElement("iframe");return e.setAttribute(Dn,this.__id),e.setAttribute(Mn,this.__provider),e.setAttribute("height",Pn),e.setAttribute("width",Rn),e.setAttribute("src",Un(this.__id,this.__provider)),{element:e}},n.importDOM=function(){return{iframe:function(){return{conversion:Fn,priority:0}}}},n}(Ae);function In(){var n=a(!1),r=n[0],i=n[1],o=a(!1),l=o[0],c=o[1],s=a(""),u=s[0],f=s[1],p=ce()[0];return d(function(){r||(f(""),c(!1))},[r]),e("div",{children:t(Nn,{open:r,onOpenChange:i,children:[e(kn,{asChild:!0,children:e(Jt,{size:"icon",variant:"ghost",className:"rounded-md text-gray-700 hover:bg-gray-200",children:e(lt,{})})}),t(Sn,{className:"sm:max-w-md",children:[e(zn,{children:e(On,{className:"!text-lg text-gray-800",children:"Embed Video"})}),t("div",{className:"py-2",children:[e(nn,{value:u,onChange:function(e){return f(e.target.value)},placeholder:"Add YouTube or Google Drive URL"}),l&&e("p",{className:"mt-1.5 text-red-800/80 text-[0.8rem]",children:"It's not a valid youtube or google drive URL"})]}),e(Ln,{children:e(Jt,{onClick:function(){var e;if(u){var t=null,n=null,r=/^.*(youtu\.be\/|v\/|u\/\w\/|embed\/|watch\?v=|&v=)([^#&?]*).*/.exec(u);r&&11===(null===(e=r[2])||void 0===e?void 0:e.length)&&(t="youtube",n=r[2]);var o=/drive\.google\.com\/file\/d\/([a-zA-Z0-9_-]+)\//.exec(u);o&&o[1]&&(t="drive",n=o[1]),n&&t?(p.update(function(){var e=En({id:n,provider:t});ze([e])}),f(""),c(!1),i(!1)):c(!0)}},disabled:!u,className:"bg-blue-600 text-white hover:bg-blue-700 disabled:opacity-50",children:"Embed"})})]})]})})}function jn(t){var n=t.value;return e("div",{className:"prose max-w-none",dangerouslySetInnerHTML:{__html:n}})}function Wn(n){var r=n.value,i=n.triggerLabel,o=void 0===i?"Preview":i,l=a(!1),c=l[0],s=l[1];return t(Nn,{open:c,onOpenChange:s,children:[e(kn,{asChild:!0,children:t(Jt,{variant:c?"toolbarActive":"toolbar",size:"icon",className:"size-8 w-fit p-2 select-none border-[1px] border-gray-100",children:[e(ct,{})," ",o]})}),t(Sn,{className:"w-[90vw] md:w-[80vw] lg:w-[70vw] max-w-4xl max-h-[90vh] sm:max-w-[1000px] overflow-y-auto bg-white",children:[e(zn,{children:e(On,{className:"!text-xl",children:"Content Preview"})}),t("div",{className:" p-[2vw] rounded-lg border min-h-[400px] w-full text-start bg-white",children:[e("div",{className:"py-1 border-b-2 mb-4 font-medium",children:"CONTENT"}),e(jn,{value:r})]})]})]})}var Kn=function(n){var r,i,o,l=n.value,c=ce()[0],s=a(((r={})[pt.Undo]=!0,r[pt.Redo]=!0,r)),f=s[0],v=s[1],b=a(!1),y=b[0],x=b[1],w=a(((i={})[pt.LeftAlign]=!0,i)),C=w[0],N=w[1],k=a(((o={})[ht.Normal]=!0,o)),_=k[0],A=k[1],S=a("paragraph"),z=S[0],T=S[1],E=a("https://"),D=E[0],M=E[1],P=!0,R=function(){var e,t;if(P){var n=c.getRootElement();n&&(n.scrollTop=0,P=!1)}var r=pe();if(ve(r)){var i=((e={})[pt.Bold]=r.hasFormat("bold"),e[pt.Italics]=r.hasFormat("italic"),e[pt.Underline]=r.hasFormat("underline"),e[pt.Uppercase]=r.hasFormat("uppercase"),e[pt.Lowercase]=r.hasFormat("lowercase"),e[pt.Capitalize]=r.hasFormat("capitalize"),e[pt.Strikethrough]=r.hasFormat("strikethrough"),e[pt.Superscript]=r.hasFormat("superscript"),e[pt.Subscript]=r.hasFormat("subscript"),e[pt.Code]=r.hasFormat("code"),e[pt.Highlight]=r.hasFormat("highlight"),e);N(i);var o=r.anchor.getNode(),a="root"===o.getKey()?o:o.getTopLevelElementOrThrow(),l=a.getKey();if(!c.getElementByKey(l))return;if(L(a)){var s=function(e,t){let n=e;for(;null!=n;){if(n instanceof t)return n;n=n.getParent()}return null}(o,O),d=s?s.getTag():a.getTag();T(d)}else if("paragraph"===a.getType()||p(a)){var u=null;p(a)&&(u=a.getTag());var f=((t={})[ht.H1]="h1"===u,t[ht.H2]="h2"===u,t[ht.H3]="h3"===u,t[ht.H4]="h4"===u,t[ht.H5]="h5"===u,t[ht.H6]="h6"===u,t[ht.Normal]="paragraph"===a.getType(),t);A(f)}else T(a.getType());var h=(fe(o)?o:a).getFormat();N(function(e){var t;return mt(mt({},e),((t={})[pt.LeftAlign]=0===h||1===h,t[pt.CenterAlign]=2===h,t[pt.RightAlign]=3===h,t[pt.JustifyAlign]=4===h,t))}),"quote"===a.getType()?N(function(e){var t;return mt(mt({},e),((t={})[pt.Quote]=!0,t))}):N(function(e){var t;return mt(mt({},e),((t={})[pt.Quote]=!1,t))});var m=r.anchor.getNode(),g=m.getParent();Ve(g)?(N(function(e){var t;return mt(mt({},e),((t={})[pt.Link]=!0,t))}),M(g.getURL()),x(!0)):Ve(m)?(N(function(e){var t;return mt(mt({},e),((t={})[pt.Link]=!0,t))}),M(m.getURL()),x(!0)):(N(function(e){var t;return mt(mt({},e),((t={})[pt.Link]=!1,t))}),M("https://"),x(!1))}};d(function(){return Rt(c.registerUpdateListener(function(e){e.editorState.read(function(){R()})}),c.registerCommand(ke,function(){return R(),!1},1),c.registerCommand(Oe,function(e){return v(function(t){return mt(mt({},t),{undo:!e})}),!1},1),c.registerCommand(Le,function(e){return v(function(t){return mt(mt({},t),{redo:!e})}),!1},1))},[]);var U=function(e){switch(e){case pt.Bold:c.dispatchCommand(Me,"bold");break;case pt.Italics:c.dispatchCommand(Me,"italic");break;case pt.Underline:c.dispatchCommand(Me,"underline");break;case pt.Lowercase:c.dispatchCommand(Me,"lowercase");break;case pt.Uppercase:c.dispatchCommand(Me,"uppercase");break;case pt.Capitalize:c.dispatchCommand(Me,"capitalize");break;case pt.Strikethrough:c.dispatchCommand(Me,"strikethrough");break;case pt.Superscript:c.dispatchCommand(Me,"superscript");break;case pt.Subscript:c.dispatchCommand(Me,"subscript");break;case pt.Highlight:c.dispatchCommand(Me,"highlight");break;case pt.Code:c.dispatchCommand(Me,"code");break;case pt.Quote:c.update(function(){var e=pe();if(ve(e)){var t=e.anchor.getNode().getParent();t&&h(t)?function(e,t,n=St){if(null===e)return;const r=e.getStartEndPoints(),i=new Map;let o=null;if(r){const[e,t]=r;o=se(),o.anchor.set(e.key,e.offset,e.type),o.focus.set(t.key,t.offset,t.type);const n=de(e.getNode(),ue),a=de(t.getNode(),ue);fe(n)&&i.set(n.getKey(),n),fe(a)&&i.set(a.getKey(),a)}for(const t of e.getNodes())if(fe(t)&&ue(t))i.set(t.getKey(),t);else if(null===r){const e=de(t,ue);fe(e)&&i.set(e.getKey(),e)}for(const[e,r]of i){const i=t();n(r,i),r.replace(i,!0),o&&(e===o.anchor.key&&o.anchor.set(i.getKey(),o.anchor.offset,o.anchor.type),e===o.focus.key&&o.focus.set(i.getKey(),o.focus.offset,o.focus.type))}o&&e.is(pe())&&he(o)}(e,function(){return Pe()}):Ot(e,function(){return m()})}});break;case pt.Link:F(),x(!0);break;case pt.LeftAlign:c.dispatchCommand(De,"left");break;case pt.RightAlign:c.dispatchCommand(De,"right");break;case pt.CenterAlign:c.dispatchCommand(De,"center");break;case pt.JustifyAlign:c.dispatchCommand(De,"justify");break;case pt.Undo:c.dispatchCommand(Ee,void 0);break;case pt.Redo:c.dispatchCommand(Te,void 0)}},F=u(function(){console.log("insertlink"),y?c.dispatchCommand(Qe,null):""!==D&&c.dispatchCommand(Qe,D)},[c,y]),H=u(function(){M(""),c.dispatchCommand(Qe,null),x(!1)},[c]);return t("div",{className:"relative flex gap-1.5 flex-wrap justify-center items-center p-1.5 pb-2 mb-1 border-b-[1px]",children:[yt.map(function(n){var r=n.id,i=n.label,o=n.icon;return r===pt.Divider?e(en,{},r):t(Qt,{delayDuration:700,children:[e(Vt,{asChild:!0,children:e(Jt,{variant:C[r]?"toolbarActive":"toolbar",size:"icon",className:"size-8",onClick:function(){return U(r)},disabled:!!f[r],children:o})}),e(qt,{side:"bottom",children:i})]},r)}),t("div",{className:"flex gap-1.5 justify-start items-center",children:[e(tn,{updateHeading:function(e){c.update(function(){var t=pe();ve(t)&&Ot(t,"normal"===e?function(){return Pe()}:function(){return g(e)})})},headingSelectionMap:_}),e(en,{})]}),bt.map(function(n){var r=n.id,i=n.label,o=n.icon;return r===pt.Divider?e(en,{},r):t(Qt,{delayDuration:700,children:[e(Vt,{asChild:!0,children:e(Jt,{variant:C[r]?"toolbarActive":"toolbar",size:"icon",className:"size-8",onClick:function(){return U(r)},disabled:!!f[r],children:o})}),e(qt,{side:"bottom",children:i})]},r)}),t("div",{className:"flex gap-1.5 justify-start items-center",children:[e(bn,{blockType:z}),e(en,{})]}),e(vn,{}),e(Gt,{onAction:U,selectionMap:C}),t("div",{className:"flex gap-1.5 justify-start items-center",children:[e(mn,{onAction:U,alignmentSelectionMap:C}),e(en,{})]}),t(Qt,{delayDuration:700,children:[e(Vt,{asChild:!0,children:e(Jt,{variant:C[pt.Link]?"toolbarActive":"toolbar",size:"icon",className:"size-8",onClick:function(){return U(pt.Link)},disabled:!!f[pt.Link],children:e(nt,{})})}),e(qt,{side:"bottom",children:"Link"})]}),y&&e(hn,{linkUrl:D,setLinkUrl:M,removeLink:H,onConfirm:function(e){c.dispatchCommand(Qe,{url:e,target:"_blank"}),M(e),x(!1)},onCancel:function(){M(""),x(!1)}}),e(Tn,{}),e(In,{}),e(Wn,{value:l})]})};function Bn(e,t){if("undefined"==typeof document||"undefined"==typeof window&&void 0===global.window)throw new Error("To use $generateHtmlFromNodes in headless mode please initialize a headless browser implementation such as JSDom before calling this function.");const n=document.createElement("div"),r=Re().getChildren();for(let i=0;i<r.length;i++)Jn(e,r[i],n,t);return n.innerHTML}function Jn(e,t,n,r=null){let i=null===r||t.isSelected(r);const o=fe(t)&&t.excludeFromCopy("html");let a=t;if(null!==r){let e=Ie(t);e=be(e)&&null!==r?function(e,t){const n=e.getStartEndPoints();if(t.isSelected(e)&&!ye(t)&&null!==n){const[r,i]=n,o=e.isBackward(),a=r.getNode(),l=i.getNode(),c=t.is(a),s=t.is(l);if(c||s){const[n,r]=xe(e),i=a.is(l),c=t.is(o?l:a),s=t.is(o?a:l);let d,u=0;i?(u=n>r?r:n,d=n>r?n:r):c?(u=o?r:n,d=void 0):s&&(u=0,d=o?n:r),t.__text=t.__text.slice(u,d)}}return t}(r,e):e,a=e}const l=fe(a)?a.getChildren():[],c=je(e,a.getType());let s;s=c&&void 0!==c.exportDOM?c.exportDOM(e,a):a.exportDOM(e);const{element:d,after:u}=s;if(!d)return!1;const f=document.createDocumentFragment();for(let n=0;n<l.length;n++){const o=l[n],a=Jn(e,o,f,r);!i&&fe(t)&&a&&t.extractWithChild(o,r,"html")&&(i=!0)}if(i&&!o){if((We(d)||Ke(d))&&d.append(f),n.append(d),u){const e=u.call(a,d);e&&(Ke(d)?d.replaceChildren(e):d.replaceWith(e))}}else n.append(f);return i}const $n=new Set(["STYLE","SCRIPT"]);function Qn(e,t,n,r,i=new Map,o){let a=[];if($n.has(e.nodeName))return a;let l=null;const c=function(e,t){const{nodeName:n}=e,r=t._htmlConversions.get(n.toLowerCase());let i=null;if(void 0!==r)for(const t of r){const n=t(e);null!==n&&(null===i||(i.priority||0)<=(n.priority||0))&&(i=n)}return null!==i?i.conversion:null}(e,t),s=c?c(e):null;let d=null;if(null!==s){d=s.after;const t=s.node;if(l=Array.isArray(t)?t[t.length-1]:t,null!==l){for(const[,e]of i)if(l=e(l,o),!l)break;l&&a.push(...Array.isArray(t)?t:[l])}null!=s.forChild&&i.set(e.nodeName,s.forChild)}const u=e.childNodes;let f=[];const p=(null==l||!me(l))&&(null!=l&&Be(l)||r);for(let e=0;e<u.length;e++)f.push(...Qn(u[e],t,n,p,new Map(i),l));return null!=d&&(f=d(f)),Je(e)&&(f=function(e,t,n){const r=e.style.textAlign,i=[];let o=[];for(let e=0;e<t.length;e++){const a=t[e];if(Be(a))r&&!a.getFormat()&&a.setFormat(r),i.push(a);else if(o.push(a),e===t.length-1||e<t.length-1&&Be(t[e+1])){const e=n();e.setFormat(r),e.append(...o),i.push(e),o=[]}}return i}(e,f,p?()=>{const e=new Fe;return n.push(e),e}:Pe)),null==l?f.length>0?a=a.concat(f):Je(e)&&function(e){return null!=e.nextSibling&&null!=e.previousSibling&&($e(e.nextSibling)&&$e(e.previousSibling))}(e)&&(a=a.concat(He())):fe(l)&&l.append(...f),a}function Vn(t){var n=t.value,r=t.onChange,i=ce()[0],o=a(!0),l=o[0],c=o[1];return d(function(){n&&l&&(c(!1),i.update(function(){if(Bn(i)!==n){Re().clear();var e=(new DOMParser).parseFromString(n,"text/html"),t=function(e,t){const n=Ue(t)?t.body.childNodes:t.childNodes;let r=[];const i=[];for(const t of n)if(!$n.has(t.nodeName)){const n=Qn(t,e,i,!1);null!==n&&(r=r.concat(n))}return function(e){for(const t of e)t.getNextSibling()instanceof Fe&&t.insertAfter(He());for(const t of e){const e=t.getChildren();for(const n of e)t.insertBefore(n);t.remove()}}(i),r}(i,e);ze(t)}}))},[i,n,l]),d(function(){c(!0)},[n]),e(dt,{onChange:function(e){e.read(function(){r(Bn(i))})}})}var qn=function(e){var t=e.id;return new tr({id:t})},Zn="data-lexical-youtube",Yn="315px",Xn="560px",Gn=function(e){return"https://www.youtube-nocookie.com/embed/".concat(e)},er=function(e){var t=null==e?void 0:e.getAttribute(Zn);return t?{node:qn({id:t})}:null},tr=function(t){function n(e){var n=e.id,r=e.key,i=t.call(this,r)||this;return i.__id=n,i}return ft(n,t),n.getType=function(){return"youtube"},n.clone=function(e){return new n({id:e.__id,key:e.getKey()})},n.importJSON=function(e){return qn({id:e.id})},n.prototype.exportJSON=function(){return{id:this.__id,type:"youtube",version:1}},n.prototype.decorate=function(){return e("iframe",{height:Yn,width:Xn,src:Gn(this.__id),frameBorder:"0",allowFullScreen:!0})},n.prototype.createDOM=function(){return document.createElement("div")},n.prototype.exportDOM=function(){var e=document.createElement("iframe");return e.setAttribute(Zn,this.__id),e.setAttribute("height",Yn),e.setAttribute("width",Xn),e.setAttribute("src",Gn(this.__id)),{element:e}},n.importDOM=function(){return{iframe:function(){return{conversion:er,priority:0}}}},n}(Ae),nr={text:{bold:"font-bold",underline:"underline",italic:"italic",strikethrough:"line-through",underlineStrikethrough:"underline line-through",uppercase:"uppercase",lowercase:"lowercase",capitalize:"capitalize",code:"bg-gray-100 border border-gray-300 px-1 rounded text-sm font-mono text-black"},paragraph:"mb-2",list:{ul:"list-disc list-inside pl-6",ol:"list-decimal list-inside pl-6",listitem:"mb-1"},quote:"border-l-4 border-gray-400 pl-4 italic text-gray-800 bg-gray-50 py-2 rounded-r",link:"text-blue-600 underline hover:text-blue-800"},rr=o.memo(function(n){var i=n.name,o=n.value,a=n.onChange,l=n.placeholder,c=f(function(){return{namespace:i,theme:nr,onError:function(e){console.error("Lexical error:",e)},nodes:[v,y,x,O,T,b,qe,Cn,tr,Hn]}},[i]);return e("div",{className:"border-[1px] rounded-lg w-full max-w-[900px] pb-2 scrollbar-thin",children:t(r,{initialConfig:c,children:[e("div",{className:"px-2",children:e(Kn,{value:o})}),e("div",{className:"relative",children:e(w,{contentEditable:e(C,{className:"h-[400px] text-start w-full text-[14px] p-[8px] overflow-auto outline-0"}),placeholder:e("div",{className:"absolute text-[#999] top-[8px] left-[10px] text-[14px]",children:l||"Some Text"}),ErrorBoundary:N})}),e(k,{}),e(_,{}),e(st,{}),e(Vn,{value:o,onChange:a})]})})});export{rr as default};
|
|
27
|
-
//# sourceMappingURL=index.mjs.map
|