@payloadcms/richtext-lexical 3.57.0-canary.0 → 3.57.0-canary.1

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.
Files changed (54) hide show
  1. package/dist/exports/client/Field-PKJPWZJL.js +2 -0
  2. package/dist/exports/client/{Field-SOED2PIU.js.map → Field-PKJPWZJL.js.map} +2 -2
  3. package/dist/exports/client/chunk-CYLMY5ZJ.js +2 -0
  4. package/dist/exports/client/{chunk-FSKAVN4P.js.map → chunk-CYLMY5ZJ.js.map} +2 -2
  5. package/dist/exports/client/chunk-YCH4JNUH.js +12 -0
  6. package/dist/exports/client/{chunk-KZKGNMS3.js.map → chunk-YCH4JNUH.js.map} +2 -2
  7. package/dist/exports/client/{component-M3U253XK.js → component-3PENNOM3.js} +2 -2
  8. package/dist/exports/client/index.d.ts +2 -0
  9. package/dist/exports/client/index.d.ts.map +1 -1
  10. package/dist/exports/client/index.js +10 -10
  11. package/dist/exports/client/index.js.map +4 -4
  12. package/dist/features/blocks/client/component/BlockContent.js +8 -10
  13. package/dist/features/blocks/client/component/BlockContent.js.map +1 -1
  14. package/dist/features/experimental_table/client/plugins/TableCellResizerPlugin/index.js +3 -5
  15. package/dist/features/experimental_table/client/plugins/TableCellResizerPlugin/index.js.map +1 -1
  16. package/dist/features/relationship/client/plugins/index.js +20 -37
  17. package/dist/features/relationship/client/plugins/index.js.map +1 -1
  18. package/dist/features/relationship/client/utils/EnabledRelationshipsCondition.js +28 -53
  19. package/dist/features/relationship/client/utils/EnabledRelationshipsCondition.js.map +1 -1
  20. package/dist/features/toolbars/shared/ToolbarButton/index.js +35 -37
  21. package/dist/features/toolbars/shared/ToolbarButton/index.js.map +1 -1
  22. package/dist/features/toolbars/shared/ToolbarDropdown/index.js +20 -30
  23. package/dist/features/toolbars/shared/ToolbarDropdown/index.js.map +1 -1
  24. package/dist/field/RenderLexical/index.d.ts +23 -0
  25. package/dist/field/RenderLexical/index.d.ts.map +1 -0
  26. package/dist/field/RenderLexical/index.js +130 -0
  27. package/dist/field/RenderLexical/index.js.map +1 -0
  28. package/dist/index.d.ts +1 -0
  29. package/dist/index.d.ts.map +1 -1
  30. package/dist/index.js +3 -1
  31. package/dist/index.js.map +1 -1
  32. package/dist/lexical/LexicalEditor.js +22 -35
  33. package/dist/lexical/LexicalEditor.js.map +1 -1
  34. package/dist/lexical/plugins/InsertParagraphAtEnd/index.js +7 -15
  35. package/dist/lexical/plugins/InsertParagraphAtEnd/index.js.map +1 -1
  36. package/dist/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/LexicalMenu.js +7 -15
  37. package/dist/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/LexicalMenu.js.map +1 -1
  38. package/dist/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/index.js +75 -141
  39. package/dist/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/index.js.map +1 -1
  40. package/dist/lexical/ui/ContentEditable.js +2 -11
  41. package/dist/lexical/ui/ContentEditable.js.map +1 -1
  42. package/dist/nodeTypes.d.ts +13 -1
  43. package/dist/nodeTypes.d.ts.map +1 -1
  44. package/dist/nodeTypes.js +4 -1
  45. package/dist/nodeTypes.js.map +1 -1
  46. package/dist/utilities/buildEditorState.d.ts +11 -0
  47. package/dist/utilities/buildEditorState.d.ts.map +1 -0
  48. package/dist/utilities/buildEditorState.js +76 -0
  49. package/dist/utilities/buildEditorState.js.map +1 -0
  50. package/package.json +10 -10
  51. package/dist/exports/client/Field-SOED2PIU.js +0 -2
  52. package/dist/exports/client/chunk-FSKAVN4P.js +0 -2
  53. package/dist/exports/client/chunk-KZKGNMS3.js +0 -12
  54. /package/dist/exports/client/{component-M3U253XK.js.map → component-3PENNOM3.js.map} +0 -0
@@ -0,0 +1,11 @@
1
+ import type { SerializedLexicalNode } from 'lexical';
2
+ import type { DefaultTypedEditorState, TypedEditorState } from '../nodeTypes.js';
3
+ export declare function buildEditorState(args: {
4
+ nodes?: DefaultTypedEditorState['root']['children'];
5
+ text?: string;
6
+ }): DefaultTypedEditorState;
7
+ export declare function buildEditorState<T extends SerializedLexicalNode>(args: {
8
+ nodes?: TypedEditorState<T>['root']['children'];
9
+ text?: string;
10
+ }): TypedEditorState<T>;
11
+ //# sourceMappingURL=buildEditorState.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"buildEditorState.d.ts","sourceRoot":"","sources":["../../src/utilities/buildEditorState.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAA;AAEpD,OAAO,KAAK,EAAE,uBAAuB,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAA;AAEhF,wBAAgB,gBAAgB,CAAC,IAAI,EAAE;IACrC,KAAK,CAAC,EAAE,uBAAuB,CAAC,MAAM,CAAC,CAAC,UAAU,CAAC,CAAA;IACnD,IAAI,CAAC,EAAE,MAAM,CAAA;CACd,GAAG,uBAAuB,CAAA;AAE3B,wBAAgB,gBAAgB,CAAC,CAAC,SAAS,qBAAqB,EAAE,IAAI,EAAE;IAEtE,KAAK,CAAC,EAAE,gBAAgB,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,UAAU,CAAC,CAAA;IAC/C,IAAI,CAAC,EAAE,MAAM,CAAA;CACd,GAAG,gBAAgB,CAAC,CAAC,CAAC,CAAA"}
@@ -0,0 +1,76 @@
1
+ /**
2
+ * Helper to build lexical editor state JSON from text and/or nodes.
3
+ *
4
+ * @param nodes - The nodes to include in the editor state. If you pass the `text` argument, this will append your nodes after the first paragraph node.
5
+ * @param text - The text content to include in the editor state. This will create a paragraph node with a text node for you and set that as the first node.
6
+ * @returns The constructed editor state JSON.
7
+ *
8
+ * @example
9
+ *
10
+ * just passing text:
11
+ *
12
+ * ```ts
13
+ * const editorState = buildEditorState({ text: 'Hello world' }) // result typed as DefaultTypedEditorState
14
+ * ```
15
+ *
16
+ * @example
17
+ *
18
+ * passing nodes:
19
+ *
20
+ * ```ts
21
+ * const editorState = // result typed as TypedEditorState<DefaultNodeTypes | SerializedBlockNode> (or TypedEditorState<SerializedBlockNode>)
22
+ * buildEditorState<DefaultNodeTypes | SerializedBlockNode>({ // or just buildEditorState<SerializedBlockNode> if you *only* want to allow block nodes
23
+ * nodes: [
24
+ * {
25
+ * type: 'block',
26
+ * fields: {
27
+ * id: 'id',
28
+ * blockName: 'Cool block',
29
+ * blockType: 'myBlock',
30
+ * },
31
+ * format: 'left',
32
+ * version: 1,
33
+ * }
34
+ * ],
35
+ * })
36
+ * ```
37
+ */export function buildEditorState({
38
+ nodes,
39
+ text
40
+ }) {
41
+ const editorJSON = {
42
+ root: {
43
+ type: 'root',
44
+ children: [],
45
+ direction: 'ltr',
46
+ format: '',
47
+ indent: 0,
48
+ version: 1
49
+ }
50
+ };
51
+ if (text) {
52
+ editorJSON.root.children.push({
53
+ type: 'paragraph',
54
+ children: [{
55
+ type: 'text',
56
+ detail: 0,
57
+ format: 0,
58
+ mode: 'normal',
59
+ style: '',
60
+ text,
61
+ version: 1
62
+ }],
63
+ direction: 'ltr',
64
+ format: '',
65
+ indent: 0,
66
+ textFormat: 0,
67
+ textStyle: '',
68
+ version: 1
69
+ });
70
+ }
71
+ if (nodes?.length) {
72
+ editorJSON.root.children.push(...nodes);
73
+ }
74
+ return editorJSON;
75
+ }
76
+ //# sourceMappingURL=buildEditorState.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"buildEditorState.js","names":["buildEditorState","nodes","text","editorJSON","root","type","children","direction","format","indent","version","push","detail","mode","style","textFormat","textStyle","length"],"sources":["../../src/utilities/buildEditorState.ts"],"sourcesContent":["import type { SerializedLexicalNode } from 'lexical'\n\nimport type { DefaultTypedEditorState, TypedEditorState } from '../nodeTypes.js'\n\nexport function buildEditorState(args: {\n nodes?: DefaultTypedEditorState['root']['children']\n text?: string\n}): DefaultTypedEditorState\n\nexport function buildEditorState<T extends SerializedLexicalNode>(args: {\n // If you pass children typed for a specific schema T, the return is TypedEditorState<T>\n nodes?: TypedEditorState<T>['root']['children']\n text?: string\n}): TypedEditorState<T>\n\n/**\n * Helper to build lexical editor state JSON from text and/or nodes.\n *\n * @param nodes - The nodes to include in the editor state. If you pass the `text` argument, this will append your nodes after the first paragraph node.\n * @param text - The text content to include in the editor state. This will create a paragraph node with a text node for you and set that as the first node.\n * @returns The constructed editor state JSON.\n *\n * @example\n *\n * just passing text:\n *\n * ```ts\n * const editorState = buildEditorState({ text: 'Hello world' }) // result typed as DefaultTypedEditorState\n * ```\n *\n * @example\n *\n * passing nodes:\n *\n * ```ts\n * const editorState = // result typed as TypedEditorState<DefaultNodeTypes | SerializedBlockNode> (or TypedEditorState<SerializedBlockNode>)\n * buildEditorState<DefaultNodeTypes | SerializedBlockNode>({ // or just buildEditorState<SerializedBlockNode> if you *only* want to allow block nodes\n * nodes: [\n * {\n * type: 'block',\n * fields: {\n * id: 'id',\n * blockName: 'Cool block',\n * blockType: 'myBlock',\n * },\n * format: 'left',\n * version: 1,\n * }\n * ],\n * })\n * ```\n */\nexport function buildEditorState<T extends SerializedLexicalNode>({\n nodes,\n text,\n}: {\n nodes?: DefaultTypedEditorState['root']['children'] | TypedEditorState<T>['root']['children']\n text?: string\n}): DefaultTypedEditorState | TypedEditorState<T> {\n const editorJSON: DefaultTypedEditorState = {\n root: {\n type: 'root',\n children: [],\n direction: 'ltr',\n format: '',\n indent: 0,\n version: 1,\n },\n }\n\n if (text) {\n editorJSON.root.children.push({\n type: 'paragraph',\n children: [\n {\n type: 'text',\n detail: 0,\n format: 0,\n mode: 'normal',\n style: '',\n text,\n version: 1,\n },\n ],\n direction: 'ltr',\n format: '',\n indent: 0,\n textFormat: 0,\n textStyle: '',\n version: 1,\n })\n }\n\n if (nodes?.length) {\n editorJSON.root.children.push(...(nodes as any))\n }\n\n return editorJSON\n}\n"],"mappings":"AAeA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCA,OAAO,SAASA,iBAAkD;EAChEC,KAAK;EACLC;AAAI,CAIL;EACC,MAAMC,UAAA,GAAsC;IAC1CC,IAAA,EAAM;MACJC,IAAA,EAAM;MACNC,QAAA,EAAU,EAAE;MACZC,SAAA,EAAW;MACXC,MAAA,EAAQ;MACRC,MAAA,EAAQ;MACRC,OAAA,EAAS;IACX;EACF;EAEA,IAAIR,IAAA,EAAM;IACRC,UAAA,CAAWC,IAAI,CAACE,QAAQ,CAACK,IAAI,CAAC;MAC5BN,IAAA,EAAM;MACNC,QAAA,EAAU,CACR;QACED,IAAA,EAAM;QACNO,MAAA,EAAQ;QACRJ,MAAA,EAAQ;QACRK,IAAA,EAAM;QACNC,KAAA,EAAO;QACPZ,IAAA;QACAQ,OAAA,EAAS;MACX,EACD;MACDH,SAAA,EAAW;MACXC,MAAA,EAAQ;MACRC,MAAA,EAAQ;MACRM,UAAA,EAAY;MACZC,SAAA,EAAW;MACXN,OAAA,EAAS;IACX;EACF;EAEA,IAAIT,KAAA,EAAOgB,MAAA,EAAQ;IACjBd,UAAA,CAAWC,IAAI,CAACE,QAAQ,CAACK,IAAI,IAAKV,KAAA;EACpC;EAEA,OAAOE,UAAA;AACT","ignoreList":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@payloadcms/richtext-lexical",
3
- "version": "3.57.0-canary.0",
3
+ "version": "3.57.0-canary.1",
4
4
  "description": "The officially supported Lexical richtext adapter for Payload",
5
5
  "homepage": "https://payloadcms.com",
6
6
  "repository": {
@@ -373,8 +373,8 @@
373
373
  "react-error-boundary": "4.1.2",
374
374
  "ts-essentials": "10.0.3",
375
375
  "uuid": "10.0.0",
376
- "@payloadcms/translations": "3.57.0-canary.0",
377
- "@payloadcms/ui": "3.57.0-canary.0"
376
+ "@payloadcms/translations": "3.57.0-canary.1",
377
+ "@payloadcms/ui": "3.57.0-canary.1"
378
378
  },
379
379
  "devDependencies": {
380
380
  "@babel/cli": "7.27.2",
@@ -386,23 +386,23 @@
386
386
  "@types/escape-html": "1.0.4",
387
387
  "@types/json-schema": "7.0.15",
388
388
  "@types/node": "22.15.30",
389
- "@types/react": "19.1.8",
390
- "@types/react-dom": "19.1.6",
391
- "babel-plugin-react-compiler": "19.1.0-rc.2",
389
+ "@types/react": "19.1.12",
390
+ "@types/react-dom": "19.1.9",
391
+ "babel-plugin-react-compiler": "19.1.0-rc.3",
392
392
  "babel-plugin-transform-remove-imports": "^1.8.0",
393
393
  "esbuild": "0.25.5",
394
394
  "esbuild-sass-plugin": "3.3.1",
395
395
  "swc-plugin-transform-remove-imports": "4.0.4",
396
- "payload": "3.57.0-canary.0",
397
- "@payloadcms/eslint-config": "3.28.0"
396
+ "@payloadcms/eslint-config": "3.28.0",
397
+ "payload": "3.57.0-canary.1"
398
398
  },
399
399
  "peerDependencies": {
400
400
  "@faceless-ui/modal": "3.0.0",
401
401
  "@faceless-ui/scroll-info": "2.0.0",
402
402
  "react": "^19.0.0 || ^19.0.0-rc-65a56d0e-20241020",
403
403
  "react-dom": "^19.0.0 || ^19.0.0-rc-65a56d0e-20241020",
404
- "@payloadcms/next": "3.57.0-canary.0",
405
- "payload": "3.57.0-canary.0"
404
+ "@payloadcms/next": "3.57.0-canary.1",
405
+ "payload": "3.57.0-canary.1"
406
406
  },
407
407
  "engines": {
408
408
  "node": "^18.20.2 || >=20.9.0"
@@ -1,2 +0,0 @@
1
- "use client";import{b as ke,c as we,f as _,h as ve,i as Te,j as De,k as Be,l as Le}from"./chunk-KZKGNMS3.js";import{a as Re,b as R}from"./chunk-BZZVLW4U.js";import{jsx as F,jsxs as ge}from"react/jsx-runtime";import{FieldDescription as En,FieldError as xn,FieldLabel as bn,RenderCustomComponent as xt,useEditDepth as Cn,useEffectEvent as Nn,useField as Pn}from"@payloadcms/ui";import{mergeFieldStyles as Sn}from"@payloadcms/ui/shared";import bt,{useCallback as Ct,useEffect as Nt,useMemo as Rn,useState as Pt}from"react";import{ErrorBoundary as kn}from"react-error-boundary";import"./bundled.css";import{jsx as O}from"react/jsx-runtime";import{LexicalComposer as gn}from"@lexical/react/LexicalComposer.js";import{useEditDepth as hn}from"@payloadcms/ui";import*as ht from"react";import{useMemo as yn}from"react";import{c as Zo}from"react/compiler-runtime";import{jsx as b,jsxs as te}from"react/jsx-runtime";import{useLexicalComposerContext as en}from"@lexical/react/LexicalComposerContext.js";import{LexicalErrorBoundary as tn}from"@lexical/react/LexicalErrorBoundary.js";import{HistoryPlugin as on}from"@lexical/react/LexicalHistoryPlugin.js";import{OnChangePlugin as nn}from"@lexical/react/LexicalOnChangePlugin.js";import{RichTextPlugin as rn}from"@lexical/react/LexicalRichTextPlugin.js";import{BLUR_COMMAND as sn,COMMAND_PRIORITY_LOW as pt,FOCUS_COMMAND as ln}from"lexical";import*as q from"react";import{useEffect as an,useState as cn}from"react";import{jsx as Me}from"react/jsx-runtime";import"react";var $=({anchorElem:t,clientProps:e,plugin:o})=>o.position==="floatingAnchorElem"&&t?o.Component&&Me(o.Component,{anchorElem:t,clientProps:e}):o.Component&&Me(o.Component,{clientProps:e});import{c as kt}from"react/compiler-runtime";import{useLexicalComposerContext as wt}from"@lexical/react/LexicalComposerContext";import{$findMatchingParent as ne,mergeRegister as vt}from"@lexical/utils";import{$createNodeSelection as Tt,$getEditor as X,$getNearestNodeFromDOMNode as Dt,$getSelection as re,$isDecoratorNode as K,$isElementNode as Ee,$isLineBreakNode as Bt,$isNodeSelection as ie,$isRangeSelection as Ae,$isRootOrShadowRoot as Lt,$isTextNode as Mt,$setSelection as Ie,CLICK_COMMAND as At,COMMAND_PRIORITY_LOW as W,KEY_ARROW_DOWN_COMMAND as It,KEY_ARROW_UP_COMMAND as _t,KEY_BACKSPACE_COMMAND as Ot,KEY_DELETE_COMMAND as Ft,SELECTION_CHANGE_COMMAND as $t}from"lexical";import{useEffect as Kt}from"react";function _e(){let t=kt(3),[e]=wt(),o=Gt,r,n;return t[0]!==e?(r=()=>vt(e.registerCommand(At,Vt,W),e.registerCommand(Ft,o,W),e.registerCommand(Ot,o,W),e.registerCommand($t,Yt,W),e.registerCommand(_t,zt,W),e.registerCommand(It,Ht,W)),n=[e],t[0]=e,t[1]=r,t[2]=n):(r=t[1],n=t[2]),Kt(r,n),null}function Ht(t){let e=re();if(ie(e)){t.preventDefault();let i=e.getNodes()[0]?.getNextSibling();if(K(i)){let y=X().getElementByKey(i.getKey());return y&&Z({element:y,node:i}),!0}if(!Ee(i))return!0;let s=i.getFirstDescendant()??i;return s&&(ne(s,se)?.selectEnd(),t.preventDefault()),!0}if(!Ae(e))return!1;let r=(e.isBackward()?e.anchor:e.focus).getNode(),n=ne(r,jt),c=n?.getNextSibling();if(!n||c!==Oe(n))return!1;if(K(c)){let i=X().getElementByKey(c.getKey());if(i)return Z({element:i,node:c}),t.preventDefault(),!0}return!1}function jt(t){return Oe(t)!==null}function zt(t){let e=re();if(ie(e)){let i=e.getNodes()[0]?.getPreviousSibling();if(K(i)){let y=X().getElementByKey(i.getKey());return y?(Z({element:y,node:i}),t.preventDefault(),!0):!1}if(!Ee(i))return!1;let s=i.getLastDescendant()??i;return s?(ne(s,se)?.selectStart(),t.preventDefault(),!0):!1}if(!Ae(e))return!1;let r=(e.isBackward()?e.anchor:e.focus).getNode(),n=ne(r,Wt),c=n?.getPreviousSibling();if(!n||c!==Fe(n))return!1;if(K(c)){let i=X().getElementByKey(c.getKey());if(i)return Z({element:i,node:c}),t.preventDefault(),!0}return!1}function Wt(t){return Fe(t)!==null}function Yt(){let t=Jt();return document.querySelector(".decorator-selected")?.classList.remove("decorator-selected"),t?(t.element?.classList.add("decorator-selected"),!0):!1}function Vt(t){document.querySelector(".decorator-selected")?.classList.remove("decorator-selected");let e=qt(t);if(!e)return!0;let{target:o}=t;return!(o instanceof HTMLElement)||o.isContentEditable||o.closest('button, textarea, input, .react-select, .code-editor, .no-select-decorator, [role="button"]')?Ie(null):Z(e),!0}function Gt(t){let e=re();return ie(e)?(t.preventDefault(),e.getNodes().forEach(Ut),!0):!1}function Ut(t){t.remove()}function qt(t){if(!(t.target instanceof HTMLElement))return;let e=t.target.closest('[data-lexical-decorator="true"]');if(!(e instanceof HTMLElement))return;let o=Dt(e);return K(o)?{element:e,node:o}:void 0}function Jt(){let t=re();if(!ie(t))return;let e=t.getNodes();if(e.length!==1)return;let o=e[0];return K(o)?{decorator:o,element:X().getElementByKey(o.getKey())}:void 0}function Z({element:t,node:e}){document.querySelector(".decorator-selected")?.classList.remove("decorator-selected");let o=Tt();o.add(e.getKey()),Ie(o),t.scrollIntoView({behavior:"smooth",block:"nearest"}),t.classList.add("decorator-selected")}function se(t){if(K(t)&&!t.isInline())return!0;if(!Ee(t)||Lt(t))return!1;let e=t.getFirstChild(),o=e===null||Bt(e)||Mt(e)||e.isInline();return!t.isInline()&&t.canBeEmpty()!==!1&&o}function Oe(t){let e=t.getNextSibling();for(;e!==null;){if(se(e))return e;e=e.getNextSibling()}return null}function Fe(t){let e=t.getPreviousSibling();for(;e!==null;){if(se(e))return e;e=e.getPreviousSibling()}return null}import{jsx as xe}from"react/jsx-runtime";import{useLexicalComposerContext as oo}from"@lexical/react/LexicalComposerContext.js";import{$createParagraphNode as no,isHTMLElement as ro}from"lexical";import*as je from"react";import{useCallback as io,useEffect as He,useRef as so,useState as lo}from"react";import{createPortal as ao}from"react-dom";var Y=(t,e,o,r,n=50,c=25)=>{let i=0;if(t&&!t.contains(r)){let{bottom:s,left:d,right:y,top:g}=t.getBoundingClientRect(),a=g+window.scrollY,l=s+window.scrollY;if(o<a-c||o>l+c||e<d-n||e>y+n)return-1;(e<d||e>y)&&(i=e<d?e-d:e-y)}return i};import{$getNodeByKey as ae}from"lexical";function V(t){let e=t.getBoundingClientRect(),o=getComputedStyle(t).getPropertyValue("transform");if(!o||o==="none")return e;let r=o.split(",").pop();return e.y=e.y-Number(r?.replace(")","")),e}function le(t){let e=(d,y)=>d?parseFloat(window.getComputedStyle(d)[y]):0,{marginBottom:o,marginTop:r}=window.getComputedStyle(t),n=e(t.previousElementSibling,"marginBottom"),c=e(t.nextElementSibling,"marginTop"),i=Math.max(parseFloat(r),n);return{marginBottom:Math.max(parseFloat(o),c),marginTop:i}}import{$getRoot as Qt}from"lexical";function H(t){return t.getEditorState().read(()=>Qt().getChildrenKeys())}var Xt=1,Zt=-1,$e=0,M={props:null,result:null};function eo(t,e,o=20){let r=t.x-e.x,n=t.y-e.y;return r*r+n*n<=o*o}function G(t){let{anchorElem:e,cache_threshold:o=20,editor:r,fuzzy:n=!1,horizontalOffset:c=0,point:{x:i,y:s},startIndex:d=0,useEdgeAsDefault:y=!1}=t;if(o>0&&M.props&&M.result&&M.props.fuzzy===t.fuzzy&&M.props.horizontalOffset===t.horizontalOffset&&M.props.useEdgeAsDefault===t.useEdgeAsDefault&&eo(M.props.point,t.point,o))return M.result;let g=e.getBoundingClientRect(),a=H(r),l={blockElem:null,blockNode:null,distance:1/0,foundAtIndex:-1,isFoundNodeEmptyParagraph:!1};return r.getEditorState().read(()=>{if(y){let m=r.getElementByKey(a[0]),h=r.getElementByKey(a[a.length-1]);if(m&&h){let[u,f]=[V(m),V(h)];if(s<u.top?(l.blockElem=m,l.distance=u.top-s,l.blockNode=ae(a[0]),l.foundAtIndex=0):s>f.bottom&&(l.distance=s-f.bottom,l.blockNode=ae(a[a.length-1]),l.blockElem=h,l.foundAtIndex=a.length-1),l?.blockElem)return{blockElem:null,isFoundNodeEmptyParagraph:!1}}}let p=d,E=$e;for(;p>=0&&p<a.length;){let m=a[p],h=r.getElementByKey(m);if(h===null)break;let u=new _(i+c,s),f=Be.fromDOMRect(V(h)),{marginBottom:x,marginTop:w}=le(h),S=f.generateNewRect({bottom:f.bottom+x,left:g.left,right:g.right,top:f.top-w}),{distance:C,isOnBottomSide:k,isOnTopSide:N}=S.distanceFromPoint(u);if(C===0){l.blockElem=h,l.blockNode=ae(m),l.foundAtIndex=p,l.distance=C,l.blockNode&&l.blockNode.getType()==="paragraph"&&l.blockNode.getTextContent()===""&&(!n&&!t.returnEmptyParagraphs&&(l.blockElem=null,l.blockNode=null),l.isFoundNodeEmptyParagraph=!0);break}else n&&C<l.distance&&(l.blockElem=h,l.blockNode=ae(m),l.distance=C,l.foundAtIndex=p);E===$e&&(N?E=Zt:k?E=Xt:E=1/0),p+=E}}),M.props=t,M.result={blockElem:l.blockElem,blockNode:l.blockNode,foundAtIndex:l.foundAtIndex,isFoundNodeEmptyParagraph:l.isFoundNodeEmptyParagraph},{blockElem:l.blockElem,blockNode:l.blockNode,foundAtIndex:l.foundAtIndex,isFoundNodeEmptyParagraph:l.isFoundNodeEmptyParagraph}}function ce(t,e){return!!t.closest(`.${e}`)}var to=["IMG","INPUT","TEXTAREA","SELECT","BUTTON","VIDEO","OBJECT","EMBED","IFRAME","HR"];function Ke(t){if(!t||to.includes(t.tagName)||t.offsetHeight===0||t.offsetWidth===0)return!1;let e=window.getComputedStyle(t);return!(e.display==="table-cell"||e.position==="absolute"||e.visibility==="hidden"||e.opacity==="0")}function de(t,e,o,r=0){if(!t){e.style.opacity="0",e.style.transform="translate(-10000px, -10000px)";return}let n=t.getBoundingClientRect(),c=window.getComputedStyle(t),i=e.getBoundingClientRect(),s=o.getBoundingClientRect(),d;if(["lexical-block","lexical-upload","lexical-relationship"].some(a=>t.firstElementChild?.classList.contains(a)))d=n.top+8-s.top;else{let a=Ke(t)?parseInt(c.lineHeight,10):0;d=n.top+(a-i.height)/2-s.top}let g=r;e.style.opacity="1",e.style.transform=`translate(${g}px, ${d}px)`}var co="add-block-menu",ue=1/0;function uo(t){return t===0?1/0:ue>=0&&ue<t?ue:Math.floor(t/2)}function mo(t,e,o){let r=e.parentElement,{editorConfig:n}=R(),c=n?.admin?.hideGutter?-24:12,i=so(null),[s,d]=lo(null);He(()=>{function g(a){let l=a.target;if(!ro(l))return;let p=Y(r,a.pageX,a.pageY,l);if(p===-1){d(null);return}if(ce(l,co))return;let E=H(t),{blockElem:m,blockNode:h,foundAtIndex:u}=G({anchorElem:e,cache_threshold:0,editor:t,horizontalOffset:-p,point:new _(a.x,a.y),returnEmptyParagraphs:!0,startIndex:uo(E.length),useEdgeAsDefault:!1});ue=u,m&&h&&(s?.node!==h||s?.elem!==m)&&d({elem:m,node:h})}return document?.addEventListener("mousemove",g),()=>{document?.removeEventListener("mousemove",g)}},[r,e,t,s]),He(()=>{i.current&&s?.node&&de(s?.elem,i.current,e,c)},[e,s,c]);let y=io(g=>{let a=s;a?.node&&(t.update(()=>{let l=!0;if((a?.node.getType()!=="paragraph"||a.node.getTextContent()!=="")&&(l=!1),!l){let p=no();a?.node.insertAfter(p),setTimeout(()=>{a={elem:t.getElementByKey(p.getKey()),node:p},d(a)},0)}}),setTimeout(()=>{t.update(()=>{t.focus(),a?.node&&"select"in a.node&&typeof a.node.select=="function"&&a.node.select()})},1),setTimeout(()=>{t.dispatchCommand(Te,{node:a?.node})},2),g.stopPropagation(),g.preventDefault())},[t,s]);return ao(xe(je.Fragment,{children:xe("button",{"aria-label":"Add block",className:"icon add-block-menu",onClick:g=>{y(g)},ref:i,type:"button",children:xe("div",{className:o?"icon":""})})}),e)}function ze(t){let{anchorElem:e}=t,o=e===void 0?document.body:e,[r]=oo();return mo(r,o,r._editable)}import{jsx as me,jsxs as po}from"react/jsx-runtime";import{useLexicalComposerContext as go}from"@lexical/react/LexicalComposerContext.js";import{eventFiles as Ve}from"@lexical/rich-text";import{$getNearestNodeFromDOMNode as Ge,$getNodeByKey as ho,isHTMLElement as be}from"lexical";import*as Xe from"react";import{useEffect as Ce,useRef as fe,useState as Ue}from"react";import{createPortal as yo}from"react-dom";var We=0,fo=-24;var j=0;function Ye(t,e,o,r,n,c,i,s,d,y=!1){let{height:g,top:a}=r.getBoundingClientRect(),{top:l,width:p}=i.getBoundingClientRect(),{marginBottom:E,marginTop:m}=le(r),h=a,u=c>=a+g/2+window.scrollY,f=!1;if(n?.elem)if(r!==n?.elem)(u&&n?.elem&&n?.elem===r.nextElementSibling||!u&&n?.elem&&n?.elem===r.previousElementSibling)&&(j++,j<200&&(f=!0));else{j++;let C=n?.boundingBox?.y,k=r.getBoundingClientRect().y;(u===n?.isBelow&&C===k||j<200)&&(f=!1)}if(f)return{isBelow:u,willStayInSamePosition:f};y?h+=g/2:u?h+=g+E/2:h-=m/2;let x=0;y||(u?x=-We:x=We);let w=h-l+x,S=fo-e;return o.style.width=`calc(${p}px - ${t})`,o.style.opacity=".8",o.style.transform=`translate(${S}px, calc(${w}px - 2px))`,n?.elem&&(n.elem.style.opacity="",n?.elem===r?u?n.elem.style.marginTop="":n.elem.style.marginBottom="":(n.elem.style.marginBottom="",n.elem.style.marginTop="")),j=0,{isBelow:u,willStayInSamePosition:f}}var Eo="draggable-block-menu",qe="application/x-lexical-drag-block",ee=1/0;function Je(t){return t===0?1/0:ee>=0&&ee<t?ee:Math.floor(t/2)}function xo(t,e){let{transform:o}=e.style;t.setDragImage(e,0,0),setTimeout(()=>{e.style.transform=o})}function Qe(t,e){t&&(t.style.opacity="0"),e&&(e.style.opacity="",e.style.marginBottom="",e.style.marginTop="")}function bo(t,e,o){let r=e.parentElement,n=fe(null),c=fe(null),i=fe(null),s=fe(!1),[d,y]=Ue(null),[g,a]=Ue(null),{editorConfig:l}=R(),p=l?.admin?.hideGutter?-44:-8;Ce(()=>{function h(u){let f=u.target;if(!be(f))return;let x=Y(r,u.pageX,u.pageY,f);if(x===-1){y(null);return}if(ce(f,Eo))return;let w=H(t),{blockElem:S,foundAtIndex:C,isFoundNodeEmptyParagraph:k}=G({anchorElem:e,cache_threshold:0,editor:t,horizontalOffset:-x,point:new _(u.x,u.y),startIndex:Je(w.length),useEdgeAsDefault:!1,verbose:!1});ee=C,!(!S&&!k)&&d!==S&&y(S)}return document?.addEventListener("mousemove",h),()=>{document?.removeEventListener("mousemove",h)}},[r,e,t,d]),Ce(()=>{n.current&&de(d,n.current,e,p)},[e,d,p]),Ce(()=>{function h(f){if(!s.current)return!1;let[x]=Ve(f);if(x)return!1;let{pageY:w,target:S}=f;if(!be(S))return!1;let C=Y(r,f.pageX,f.pageY,S,100,50),k=H(t),{blockElem:N,foundAtIndex:B,isFoundNodeEmptyParagraph:I}=G({anchorElem:e,editor:t,fuzzy:!0,horizontalOffset:-C,point:new _(f.x,f.y),startIndex:Je(k.length),useEdgeAsDefault:!0,verbose:!0});ee=B;let v=c.current;if(N===null||v===null)return!1;if(d!==N){let{isBelow:T,willStayInSamePosition:J}=Ye(l?.admin?.hideGutter?"0px":"3rem",p+(l?.admin?.hideGutter?n?.current?.getBoundingClientRect()?.width??0:-(n?.current?.getBoundingClientRect()?.width??0)),v,N,g,w,e,f,i,I);f.preventDefault(),J||a({boundingBox:N.getBoundingClientRect(),elem:N,isBelow:T})}else g?.elem&&(Qe(v,g.elem),a({boundingBox:N.getBoundingClientRect(),elem:N,isBelow:!1}));return!0}function u(f){if(!s.current)return!1;let[x]=Ve(f);if(x)return!1;let{dataTransfer:w,pageY:S,target:C}=f,k=w?.getData(qe)||"";return t.update(()=>{let N=ho(k);if(!N||!be(C))return!1;let B=Y(r,f.pageX,f.pageY,C,100,50),{blockElem:I,isFoundNodeEmptyParagraph:v}=G({anchorElem:e,editor:t,fuzzy:!0,horizontalOffset:-B,point:new _(f.x,f.y),useEdgeAsDefault:!0});if(!I)return!1;let T=Ge(I);if(!T)return!1;if(T===N)return!0;let{height:J,top:he}=V(I),z=S>=he+J/2+window.scrollY;v?(T.insertBefore(N),T.remove()):z?T.insertAfter(N):T.insertBefore(N),d!==null&&y(null),document.querySelectorAll(".lexical-block-highlighter").forEach(D=>{D.remove()});let oe=t.getElementByKey(N.getKey());setTimeout(()=>{let D=oe?.getBoundingClientRect();if(!D)return;let P=document.createElement("div");P.className="lexical-block-highlighter",P.style.backgroundColor="var(--theme-elevation-1000",P.style.transition="opacity 0.5s ease-in-out",P.style.zIndex="1",P.style.pointerEvents="none",P.style.boxSizing="border-box",P.style.borderRadius="4px",P.style.position="absolute",document.body.appendChild(P),P.style.opacity="0.1",P.style.height=`${D.height+8}px`,P.style.width=`${D.width+8}px`,P.style.top=`${D.top+window.scrollY-4}px`,P.style.left=`${D.left-4}px`,setTimeout(()=>{P.style.opacity="0",setTimeout(()=>{P.remove()},500)},1e3)},120)}),!0}return document.addEventListener("dragover",h),document.addEventListener("drop",u),()=>{document.removeEventListener("dragover",h),document.removeEventListener("drop",u)}},[r,p,e,t,g,d,l?.admin?.hideGutter]);function E(h){let u=h.dataTransfer;if(!u||!d)return;xo(u,d);let f="";t.update(()=>{let x=Ge(d);x&&(f=x.getKey())}),s.current=!0,u.setData(qe,f)}function m(){s.current=!1,g?.elem&&Qe(c.current,g?.elem)}return yo(po(Xe.Fragment,{children:[me("button",{"aria-label":"Drag to move",className:"icon draggable-block-menu",draggable:!0,onDragEnd:m,onDragStart:E,ref:n,type:"button",children:me("div",{className:o?"icon":""})}),me("div",{className:"draggable-block-target-line",ref:c}),me("div",{className:"debug-highlight",ref:i})]}),e)}function Ze(t){let{anchorElem:e}=t,o=e===void 0?document.body:e,[r]=go();return bo(r,o,r._editable)}import{c as Co}from"react/compiler-runtime";import{jsx as Ne}from"react/jsx-runtime";import{useLexicalComposerContext as No}from"@lexical/react/LexicalComposerContext";import{$createParagraphNode as Po,$getRoot as So}from"lexical";import"react";var et="insert-paragraph-at-end",tt=()=>{let t=Co(4),[e]=No(),{editorConfig:o}=R();if(o?.admin?.hideInsertParagraphAtEnd)return null;let r;t[0]!==e?(r=()=>{e.update(Ro)},t[0]=e,t[1]=r):r=t[1];let n=r,c;return t[2]!==n?(c=Ne("div",{"aria-label":"Insert Paragraph",className:et,onClick:n,role:"button",tabIndex:0,children:Ne("div",{className:`${et}-inside`,children:Ne("span",{children:"+"})})}),t[2]=n,t[3]=c):c=t[3],c};function Ro(){let t=Po();So().append(t),t.select()}import{c as ko}from"react/compiler-runtime";import{useLexicalComposerContext as wo}from"@lexical/react/LexicalComposerContext";import*as ot from"react";var nt=()=>{let t=ko(4),{editorConfig:e}=R(),[o]=wo(),r,n;return t[0]!==o||t[1]!==e.features.markdownTransformers?(r=()=>we(o,e.features.markdownTransformers??[]),n=[o,e.features.markdownTransformers],t[0]=o,t[1]=e.features.markdownTransformers,t[2]=r,t[3]=n):(r=t[2],n=t[3]),ot.useEffect(r,n),null};import{useLexicalComposerContext as vo}from"@lexical/react/LexicalComposerContext";import{$getSelection as To,$isRangeSelection as Do,RootNode as Bo}from"lexical";import{useEffect as Lo}from"react";function rt(){let[t]=vo();return Lo(()=>t.registerNodeTransform(Bo,e=>{let o=To();if(Do(o)){let r=o.anchor.getNode(),n=o.focus.getNode();(!r.isAttached()||!n.isAttached())&&(e.selectEnd(),console.warn("updateEditor: selection has been moved to the end of the editor because the previously selected nodes have been removed and selection wasn't moved to another node. Ensure selection changes after removing/replacing a selected node."))}return!1}),[t]),null}import{useLexicalComposerContext as Mo}from"@lexical/react/LexicalComposerContext";import{$getSelection as Ao,COMMAND_PRIORITY_LOW as Io,SELECT_ALL_COMMAND as _o}from"lexical";import{useEffect as Oo}from"react";function it(){let[t]=Mo();return Oo(()=>t.registerCommand(_o,()=>{if(Ao())return!1;let o=document.activeElement;return o instanceof HTMLInputElement&&o.select(),!0},Io),[t]),null}import{jsx as U,jsxs as lt}from"react/jsx-runtime";import{useLexicalComposerContext as $o}from"@lexical/react/LexicalComposerContext.js";import{useTranslation as at}from"@payloadcms/ui";import{useCallback as Ko,useMemo as Ho,useState as jo}from"react";import"react";import*as ct from"react-dom";import{c as Fo}from"react/compiler-runtime";import"react";function st(t,e){let o=Fo(4),{maxLength:r,minLength:n}=e,c=r===void 0?75:r,i=n===void 0?1:n,s;return o[0]!==c||o[1]!==i||o[2]!==t?(s=d=>{let{query:y}=d,g="[^"+t+ve+"\\s]",l=new RegExp("(^|\\s|\\()(["+t+"]((?:"+g+"){0,"+c+"}))$").exec(y);if(l!==null){let p=l[1],E=l[3];if(E.length>=i)return{leadOffset:l.index+p.length,matchingString:E,replaceableString:l[2]}}return null},o[0]=c,o[1]=i,o[2]=t,o[3]=s):s=o[3],s}var A="slash-menu-popup";function zo({isSelected:t,item:e,onClick:o,onMouseEnter:r,ref:n}){let{fieldProps:{featureClientSchemaMap:c,schemaPath:i}}=R(),{i18n:s}=at(),d=`${A}__item ${A}__item-${e.key}`;t&&(d+=` ${A}__item--selected`);let y=e.key;return e.label&&(y=typeof e.label=="function"?e.label({featureClientSchemaMap:c,i18n:s,schemaPath:i}):e.label),y.length>25&&(y=y.substring(0,25)+"..."),lt("button",{"aria-selected":t,className:d,id:A+"__item-"+e.key,onClick:o,onMouseEnter:r,ref:n,role:"option",tabIndex:-1,type:"button",children:[e?.Icon&&U(e.Icon,{}),U("span",{className:`${A}__item-text`,children:y})]},e.key)}function dt({anchorElem:t=document.body}){let[e]=$o(),[o,r]=jo(null),{editorConfig:n}=R(),{i18n:c}=at(),{fieldProps:{featureClientSchemaMap:i,schemaPath:s}}=R(),d=st("/",{minLength:0}),y=Ko(()=>{let a=[];for(let l of n.features.slashMenu.dynamicGroups)if(o){let p=l({editor:e,queryString:o});a=a.concat(p)}return a},[e,o,n?.features]),g=Ho(()=>{let a=[];for(let l of n?.features.slashMenu.groups??[])a.push(l);if(o){a=a.map(p=>{let E=p.items.filter(m=>{let h=m.key;return m.label&&(h=typeof m.label=="function"?m.label({featureClientSchemaMap:i,i18n:c,schemaPath:s}):m.label),new RegExp(o,"gi").exec(h)?!0:m.keywords!=null?m.keywords.some(u=>new RegExp(o,"gi").exec(u)):!1});return E.length?{...p,items:E}:null}),a=a.filter(p=>p!=null);let l=y();for(let p of l){let E=a.find(m=>m.key===p.key);E?a=a.filter(m=>m.key!==p.key):E={...p,items:[]},E?.items?.length&&(E.items=E.items.concat(E.items)),a.push(E)}}return a},[o,n?.features.slashMenu.groups,y,i,c,s]);return U(De,{anchorElem:t,groups:g,menuRenderFn:(a,{selectedItemKey:l,selectItemAndCleanUp:p,setSelectedItemKey:E})=>a.current&&g.length?ct.createPortal(U("div",{className:A,children:g.map(m=>{let h=m.key;return m.label&&i&&(h=typeof m.label=="function"?m.label({featureClientSchemaMap:i,i18n:c,schemaPath:s}):m.label),lt("div",{className:`${A}__group ${A}__group-${m.key}`,children:[U("div",{className:`${A}__group-title`,children:h}),m.items.map((u,f)=>U(zo,{index:f,isSelected:l===u.key,item:u,onClick:()=>{E(u.key),p(u)},onMouseEnter:()=>{E(u.key)},ref:x=>{u.ref={current:x}}},u.key))]},m.key)})}),a.current):null,onQueryChange:r,triggerFn:d})}import{c as Wo}from"react/compiler-runtime";import{useLexicalComposerContext as Yo}from"@lexical/react/LexicalComposerContext";import{TEXT_TYPE_TO_FORMAT as Vo,TextNode as Go}from"lexical";import{useEffect as Uo}from"react";function ut(t){let e=Wo(6),{features:o}=t,[r]=Yo(),n;e[0]!==r||e[1]!==o.enabledFormats?(n=()=>{let i=qo(o.enabledFormats);if(i.length!==0)return r.registerNodeTransform(Go,s=>{i.forEach(d=>{s.hasFormat(d)&&s.toggleFormat(d)})})},e[0]=r,e[1]=o.enabledFormats,e[2]=n):n=e[2];let c;return e[3]!==r||e[4]!==o?(c=[r,o],e[3]=r,e[4]=o,e[5]=c):c=e[5],Uo(n,c),null}function qo(t){let e=Object.keys(Vo),o=new Set(t);return e.filter(r=>!o.has(r))}import{c as Jo}from"react/compiler-runtime";import{jsx as mt}from"react/jsx-runtime";import{ContentEditable as Qo}from"@lexical/react/LexicalContentEditable.js";import{useTranslation as Xo}from"@payloadcms/ui";import"react";function ft(t){let e=Jo(7),{className:o,editorConfig:r}=t,{t:n}=Xo(),c;if(e[0]!==o||e[1]!==r?.admin?.placeholder||e[2]!==n){let i;e[4]!==r?.admin?.placeholder||e[5]!==n?(i=r?.admin?.placeholder??n("lexical:general:placeholder"),e[4]=r?.admin?.placeholder,e[5]=n,e[6]=i):i=e[6],c=mt(Qo,{"aria-placeholder":n("lexical:general:placeholder"),className:o??"ContentEditable__root",placeholder:mt("p",{className:"editor-placeholder",children:i})}),e[0]=o,e[1]=r?.admin?.placeholder,e[2]=n,e[3]=c}else c=e[3];return c}var gt=t=>{let e=Zo(21),{editorConfig:o,editorContainerRef:r,isSmallWidthViewport:n,onChange:c}=t,i=R(),[s]=en(),[d,y]=cn(null),g;e[0]===Symbol.for("react.memo_cache_sentinel")?(g=m=>{m!==null&&y(m)},e[0]=g):g=e[0];let a=g,l,p;e[1]!==s||e[2]!==i?(l=()=>{if(!i?.uuid){console.error("Lexical Editor must be used within an EditorConfigProvider");return}i?.parentEditor?.uuid&&i.parentEditor?.registerChild(i.uuid,i);let m=()=>{i.focusEditor(i)},h=()=>{i.blurEditor(i)},u=s.registerCommand(ln,()=>(m(),!0),pt),f=s.registerCommand(sn,()=>(h(),!0),pt);return()=>{u(),f(),i.parentEditor?.unregisterChild?.(i.uuid)}},p=[s,i],e[1]=s,e[2]=i,e[3]=l,e[4]=p):(l=e[3],p=e[4]),an(l,p);let E;if(e[5]!==s||e[6]!==o||e[7]!==r||e[8]!==d||e[9]!==n||e[10]!==c){let m;e[12]!==c?(m=(u,f,x)=>{(!x.has("focus")||x.size>1)&&c?.(u,f,x)},e[12]=c,e[13]=m):m=e[13];let h;e[14]!==s||e[15]!==o.admin?.hideAddBlockButton||e[16]!==o.admin?.hideDraggableBlockElement||e[17]!==o.features.plugins||e[18]!==d||e[19]!==n?(h=d&&te(q.Fragment,{children:[!n&&s.isEditable()&&te(q.Fragment,{children:[o.admin?.hideDraggableBlockElement?null:b(Ze,{anchorElem:d}),o.admin?.hideAddBlockButton?null:b(ze,{anchorElem:d})]}),o.features.plugins?.map(u=>{if(u.position==="floatingAnchorElem"&&!(u.desktopOnly===!0&&n))return b($,{anchorElem:d,clientProps:u.clientProps,plugin:u},u.key)}),s.isEditable()&&b(q.Fragment,{children:b(dt,{anchorElem:d})})]}),e[14]=s,e[15]=o.admin?.hideAddBlockButton,e[16]=o.admin?.hideDraggableBlockElement,e[17]=o.features.plugins,e[18]=d,e[19]=n,e[20]=h):h=e[20],E=te(q.Fragment,{children:[o.features.plugins?.map(dn),te("div",{className:"editor-container",ref:r,children:[o.features.plugins?.map(un),b(rn,{contentEditable:b("div",{className:"editor-scroller",children:b("div",{className:"editor",ref:a,children:b(ft,{editorConfig:o})})}),ErrorBoundary:tn}),b(rt,{}),b(tt,{}),b(_e,{}),b(ut,{features:o.features}),b(it,{}),b(nn,{ignoreSelectionChange:!0,onChange:m}),h,s.isEditable()&&te(q.Fragment,{children:[b(on,{}),o?.features?.markdownTransformers?.length>0&&b(nt,{})]}),o.features.plugins?.map(mn),o.features.plugins?.map(fn)]}),o.features.plugins?.map(pn)]}),e[5]=s,e[6]=o,e[7]=r,e[8]=d,e[9]=n,e[10]=c,e[11]=E}else E=e[11];return E};function dn(t){if(t.position==="aboveContainer")return b($,{clientProps:t.clientProps,plugin:t},t.key)}function un(t){if(t.position==="top")return b($,{clientProps:t.clientProps,plugin:t},t.key)}function mn(t){if(t.position==="normal")return b($,{clientProps:t.clientProps,plugin:t},t.key)}function fn(t){if(t.position==="bottom")return b($,{clientProps:t.clientProps,plugin:t},t.key)}function pn(t){if(t.position==="belowContainer")return b($,{clientProps:t.clientProps,plugin:t},t.key)}var yt=({children:t,providers:e})=>{if(!e?.length)return t;let o=e[0];return e.length>1?O(o,{children:O(yt,{providers:e.slice(1),children:t})}):O(o,{children:t})},Et=t=>{let{composerKey:e,editorConfig:o,fieldProps:r,isSmallWidthViewport:n,onChange:c,readOnly:i,value:s}=t,d=R(),y=hn(),g=ht.useRef(null),a=yn(()=>{if(s&&typeof s!="object")throw new Error("The value passed to the Lexical editor is not an object. This is not supported. Please remove the data from the field and start again. This is the value that was passed in: "+JSON.stringify(s));if(s&&Array.isArray(s)&&!("root"in s))throw new Error("You have tried to pass in data from the old Slate editor to the new Lexical editor. The data structure is different, thus you will have to migrate your data. We offer a one-line migration script which migrates all your rich text fields: https://payloadcms.com/docs/lexical/migration#migration-via-migration-script-recommended");if(s&&"jsonContent"in s)throw new Error("You have tried to pass in data from payload-plugin-lexical. The data structure is different, thus you will have to migrate your data. Migration guide: https://payloadcms.com/docs/lexical/migration#migrating-from-payload-plugin-lexical");return{editable:i!==!0,editorState:s!=null?JSON.stringify(s):void 0,namespace:o.lexical.namespace,nodes:Le({editorConfig:o}),onError:l=>{throw l},theme:o.lexical.theme}},[o]);return a?O(gn,{initialConfig:a,children:O(Re,{editorConfig:o,editorContainerRef:g,fieldProps:r,parentContext:d?.editDepth===y?d:void 0,children:O(yt,{providers:o.features.providers,children:O(gt,{editorConfig:o,editorContainerRef:g,isSmallWidthViewport:n,onChange:c})})})},e+a.editable):O("p",{children:"Loading..."})};var pe="rich-text-lexical",wn=t=>{let{editorConfig:e,field:o,field:{admin:{className:r,description:n,readOnly:c}={},label:i,localized:s,required:d},path:y,readOnly:g,validate:a}=t,l=g||c,p=Cn(),E=Ct((L,Q)=>typeof a=="function"?a(L,{...Q,required:d}):!0,[a,d]),{customComponents:{AfterInput:m,BeforeInput:h,Description:u,Error:f,Label:x}={},disabled:w,initialValue:S,path:C,setValue:k,showError:N,value:B}=Pn({potentiallyStalePath:y,validate:E}),I=l||w,[v,T]=Pt(!1),[J,he]=Pt(),ye=bt.useRef(S),z=bt.useRef(B);Nt(()=>{let L=()=>{let Q=window.matchMedia("(max-width: 768px)").matches;Q!==v&&T(Q)};return L(),window.addEventListener("resize",L),()=>{window.removeEventListener("resize",L)}},[v]);let Pe=[pe,"field-type",r,N&&"error",I&&`${pe}--read-only`,e?.admin?.hideGutter!==!0&&!v?`${pe}--show-gutter`:null].filter(Boolean).join(" "),oe=`${C}.${p}`,D=ke(),P=Ct(L=>{D(()=>{let Se=L.toJSON();z.current=Se,k(Se)})},[k,D]),St=Rn(()=>Sn(o),[o]),Rt=Nn(L=>{z.current!==B&&JSON.stringify(z.current)!==JSON.stringify(B)&&(ye.current=L,z.current=B,he(new Date))});return Nt(()=>{Object.is(S,ye.current)||Rt(S)},[S]),ge("div",{className:Pe,style:St,children:[F(xt,{CustomComponent:f,Fallback:F(xn,{path:C,showError:N})}),x||F(bn,{label:i,localized:s,path:C,required:d}),ge("div",{className:`${pe}__wrap`,children:[ge(kn,{fallbackRender:vn,onReset:()=>{},children:[h,F(Et,{composerKey:oe,editorConfig:e,fieldProps:t,isSmallWidthViewport:v,onChange:P,readOnly:I,value:B},JSON.stringify({path:C,rerenderProviderKey:J})),m]}),u,F(xt,{CustomComponent:u,Fallback:F(En,{description:n,path:C})})]})]},oe)};function vn({error:t}){return ge("div",{className:"errorBoundary",role:"alert",children:[F("p",{children:"Something went wrong:"}),F("pre",{style:{color:"red"},children:t.message})]})}var cs=wn;export{cs as RichText};
2
- //# sourceMappingURL=Field-SOED2PIU.js.map
@@ -1,2 +0,0 @@
1
- import{b as F}from"./chunk-BZZVLW4U.js";import{c as V}from"react/compiler-runtime";import{jsx as R}from"react/jsx-runtime";import{Drawer as q,EditDepthProvider as z,useModal as G}from"@payloadcms/ui";import"react";import{jsx as E,jsxs as O}from"react/jsx-runtime";import{Form as M,FormSubmit as v,RenderFields as T,useDocumentForm as $,useDocumentInfo as N,useServerFunctions as W,useTranslation as k}from"@payloadcms/ui";import{abortAndIgnore as P}from"@payloadcms/ui/shared";import{deepCopyObjectSimpleWithoutReactComponents as y}from"payload/shared";import{useCallback as B,useEffect as I,useRef as H,useState as L}from"react";import{v4 as U}from"uuid";var j=({data:i,featureKey:e,fieldMapOverride:o,handleDrawerSubmit:n,schemaFieldsPathOverride:t,schemaPath:d,schemaPathSuffix:f})=>{let{t:p}=k(),{id:l,collectionSlug:c,getDocPreferences:u,globalSlug:a}=N(),{fields:s}=$(),m=H(new AbortController),[r,h]=L(!1),{fieldProps:{featureClientSchemaMap:w}}=F(),{getFormState:S}=W(),C=t??`${d}.lexical_internal_feature.${e}${f?`.${f}`:""}`,b=o??w[e]?.[C];I(()=>{let g=new AbortController;return(async()=>{let{state:_}=await S({id:l,collectionSlug:c,data:i??{},docPermissions:{fields:!0},docPreferences:await u(),documentFormState:y(s),globalSlug:a,initialBlockData:i,operation:"update",renderAllFields:!0,schemaPath:C,signal:g.signal});h(_)})(),()=>{P(g)}},[C,l,i,S,c,a,u,s]);let x=B(async({formState:g})=>{P(m.current);let A=new AbortController;m.current=A;let{state:_}=await S({id:l,collectionSlug:c,docPermissions:{fields:!0},docPreferences:await u(),documentFormState:y(s),formState:g,globalSlug:a,initialBlockFormState:g,operation:"update",schemaPath:C,signal:A.signal});return _||g},[S,l,c,u,s,a,C]);return I(()=>()=>{P(m.current)},[]),r===!1?null:O(M,{beforeSubmit:[x],disableValidationOnSubmit:!0,fields:Array.isArray(b)?b:[],initialState:r,onChange:[x],onSubmit:n,uuid:U(),children:[E(T,{fields:Array.isArray(b)?b:[],forceRender:!0,parentIndexPath:"",parentPath:"",parentSchemaPath:C,permissions:!0,readOnly:!1}),E(v,{children:p("fields:saveChanges")})]})};var Ce=i=>{let e=V(15),{className:o,data:n,drawerSlug:t,drawerTitle:d,featureKey:f,fieldMapOverride:p,handleDrawerSubmit:l,schemaFieldsPathOverride:c,schemaPath:u,schemaPathSuffix:a}=i,{closeModal:s}=G(),m=d??"",r;e[0]!==s||e[1]!==t||e[2]!==l?(r=(w,S)=>{s(t),setTimeout(()=>{l(w,S)},1)},e[0]=s,e[1]=t,e[2]=l,e[3]=r):r=e[3];let h;return e[4]!==o||e[5]!==n||e[6]!==t||e[7]!==f||e[8]!==p||e[9]!==c||e[10]!==u||e[11]!==a||e[12]!==m||e[13]!==r?(h=R(z,{children:R(q,{className:o,slug:t,title:m,children:R(j,{data:n,featureKey:f,fieldMapOverride:p,handleDrawerSubmit:r,schemaFieldsPathOverride:c,schemaPath:u,schemaPathSuffix:a})})}),e[4]=o,e[5]=n,e[6]=t,e[7]=f,e[8]=p,e[9]=c,e[10]=u,e[11]=a,e[12]=m,e[13]=r,e[14]=h):h=e[14],h};import{c as J}from"react/compiler-runtime";import{jsx as K}from"react/jsx-runtime";import{useAuth as Q,useConfig as X,useEntityVisibility as Y}from"@payloadcms/ui";import*as D from"react";var Z=(i,e)=>i.filter(({slug:o,admin:{enableRichTextRelationship:n},upload:t})=>e?.visibleEntities?.collections.includes(o)?e?.uploads?n&&!!t:t?!1:n:!1),we=i=>{let e=J(20),o,n,t,d;e[0]!==i?({children:n,FallbackComponent:o,uploads:d,...t}=i,e[0]=i,e[1]=o,e[2]=n,e[3]=t,e[4]=d):(o=e[1],n=e[2],t=e[3],d=e[4]);let f=d===void 0?!1:d,{config:p}=X(),{collections:l}=p,{user:c}=Q(),{visibleEntities:u}=Y(),a;e[5]!==l||e[6]!==f||e[7]!==c||e[8]!==u?(a=()=>Z(l,{uploads:f,user:c,visibleEntities:u}).map(ee),e[5]=l,e[6]=f,e[7]=c,e[8]=u,e[9]=a):a=e[9];let[s]=D.useState(a);if(!s.length){let r;return e[10]!==o||e[11]!==t?(r=o?K(o,{...t}):null,e[10]=o,e[11]=t,e[12]=r):r=e[12],r}let m;if(e[13]!==n||e[14]!==s||e[15]!==t){let r;e[17]!==s||e[18]!==t?(r={...t,enabledCollectionSlugs:s},e[17]=s,e[18]=t,e[19]=r):r=e[19],m=D.cloneElement(n,r),e[13]=n,e[14]=s,e[15]=t,e[16]=m}else m=e[16];return m};function ee(i){let{slug:e}=i;return e}import{createCommand as te}from"lexical";var Re=te("INSERT_UPLOAD_WITH_DRAWER_COMMAND");export{Ce as a,we as b,Re as c};
2
- //# sourceMappingURL=chunk-FSKAVN4P.js.map
@@ -1,12 +0,0 @@
1
- var st=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";import{c as ae}from"react/compiler-runtime";import{useRef as le}from"react";function Xn(o){let t=ae(2),e=o===void 0?500:o,r=le(void 0),n;return t[0]!==e?(n=s=>new Promise(i=>{let a=()=>{s(),i()};"requestIdleCallback"in window?("cancelIdleCallback"in window&&r.current!==void 0&&cancelIdleCallback(r.current),r.current=requestIdleCallback(a,{timeout:e})):fe().then(a)}),t[0]=e,t[1]=n):n=t[1],n}function fe(){return new Promise(o=>{setTimeout(o,100),requestAnimationFrame(()=>{setTimeout(o,0)})})}var Q=class{_x;_y;constructor(t,e){this._x=t,this._y=e}calcDeltaXTo({x:t}){return this.x-t}calcDeltaYTo({y:t}){return this.y-t}calcDistanceTo(t){return Math.sqrt(Math.pow(this.calcDeltaXTo(t),2)+Math.pow(this.calcDeltaYTo(t),2))}calcHorizontalDistanceTo(t){return Math.abs(this.calcDeltaXTo(t))}calcVerticalDistance(t){return Math.abs(this.calcDeltaYTo(t))}equals({x:t,y:e}){return this.x===t&&this.y===e}get x(){return this._x}get y(){return this._y}};function ct(o){return o instanceof Q}import{c as be}from"react/compiler-runtime";import{jsx as Oe}from"react/jsx-runtime";import{useLexicalComposerContext as ke}from"@lexical/react/LexicalComposerContext.js";import{mergeRegister as Ae}from"@lexical/utils";import{$getSelection as V,$isRangeSelection as Z,$isTextNode as Me,COMMAND_PRIORITY_LOW as $e,createCommand as Le,getDOMSelection as De}from"lexical";import{useEffect as xt,useState as Be}from"react";import*as j from"react";import{c as dt}from"react/compiler-runtime";import{useLexicalComposerContext as mt}from"@lexical/react/LexicalComposerContext.js";import{mergeRegister as at}from"@lexical/utils";import{$getSelection as gt,$isRangeSelection as ue,$setSelection as de,COMMAND_PRIORITY_LOW as A,createCommand as me,KEY_ARROW_DOWN_COMMAND as ge,KEY_ARROW_UP_COMMAND as pe,KEY_ENTER_COMMAND as he,KEY_ESCAPE_COMMAND as xe,KEY_TAB_COMMAND as Ee}from"lexical";import{useCallback as q,useEffect as M,useLayoutEffect as _e,useMemo as Te,useRef as Se,useState as we}from"react";var Ce="slash-menu-popup",lt=o=>{let t=document.getElementById("slash-menu");if(!t)return;let e=t.getBoundingClientRect();e.top+e.height>window.innerHeight&&t.scrollIntoView({block:"center"}),e.top<0&&t.scrollIntoView({block:"center"}),o.scrollIntoView({block:"nearest"})};function Re(o,t,e){let r=e;for(let n=r;n<=t.length;n++)o.substring(o.length-n)===t.substring(0,n)&&(r=n);return r}function Fe(o){let t=gt();if(!ue(t)||!t.isCollapsed())return;let e=t.anchor;if(e.type!=="text")return;let r=e.getNode();if(!r.isSimpleText())return;let n=e.offset,c=r.getTextContent().slice(0,n),s=o.replaceableString.length,i=Re(c,o.matchingString,s),a=n-i;if(a<0)return;let f;return a===0?[f]=r.splitText(n):[,f]=r.splitText(a,n),f}function Ie(o,t){let e=getComputedStyle(o),r=e.position==="absolute",n=t?/(auto|scroll|hidden)/:/(auto|scroll)/;if(e.position==="fixed")return document.body;for(let c=o;c=c.parentElement;)if(e=getComputedStyle(c),!(r&&e.position==="static")&&n.test(e.overflow+e.overflowY+e.overflowX))return c;return document.body}function ft(o,t){let e=o.getBoundingClientRect(),r=t.getBoundingClientRect();return e.top>r.top&&e.top<r.bottom}function Ne(o,t,e,r){let n=dt(12),[c]=mt(),s;n[0]!==c||n[1]!==e||n[2]!==r||n[3]!==o||n[4]!==t.current?(s=()=>{let a=t.current;if(a!=null&&o!=null){let f=c.getRootElement(),l=f!=null?Ie(f,!1):document.body,m=!1,g=ft(a,l),p=function(){m||(window.requestAnimationFrame(function(){e(),m=!1}),m=!0);let u=ft(a,l);u!==g&&(g=u,r?.(u))},d=new ResizeObserver(e);return window.addEventListener("resize",e),document.addEventListener("scroll",p,{capture:!0,passive:!0}),d.observe(a),()=>{d.disconnect(),window.removeEventListener("resize",e),document.removeEventListener("scroll",p,!0)}}},n[0]=c,n[1]=e,n[2]=r,n[3]=o,n[4]=t.current,n[5]=s):s=n[5];let i;n[6]!==c||n[7]!==e||n[8]!==r||n[9]!==o||n[10]!==t?(i=[c,r,e,o,t],n[6]=c,n[7]=e,n[8]=r,n[9]=o,n[10]=t,n[11]=i):i=n[11],M(s,i)}var ut=me("SCROLL_TYPEAHEAD_OPTION_INTO_VIEW_COMMAND");function pt({anchorElementRef:o,close:t,editor:e,groups:r,menuRenderFn:n,resolution:c,shouldSplitNodeWithQuery:s=!1}){let[i,a]=we(null),f=c.match&&c.match.matchingString||"",l=q(d=>{let u=e.getRootElement();u!==null&&(u.setAttribute("aria-activedescendant",`${Ce}__item-${d.key}`),a(d.key))},[e]),m=q(()=>{if(r!==null&&f!=null){let d=r.flatMap(u=>u.items);if(d.length){let u=d[0];l(u)}}},[r,l,f]);M(()=>{m()},[f,m]);let g=q(d=>{t(),e.update(()=>{let u=c.match!=null&&s?Fe(c.match):null;u&&u.remove()}),setTimeout(()=>{let u;e.read(()=>{u=gt()?.clone()}),e.update(()=>{u&&de(u)}),d.onSelect({editor:e,queryString:c.match?c.match.matchingString:""})},0)},[e,s,c.match,t]);M(()=>()=>{let d=e.getRootElement();d!==null&&d.removeAttribute("aria-activedescendant")},[e]),_e(()=>{r===null?a(null):i===null&&m()},[r,i,l,m]),M(()=>at(e.registerCommand(ut,({item:d})=>d.ref&&d.ref.current!=null?(lt(d.ref.current),!0):!1,A)),[e,l]),M(()=>at(e.registerCommand(ge,d=>{let u=d;if(r!==null&&r.length&&i!==null){let x=r.flatMap(T=>T.items),h=x.findIndex(T=>T.key===i),E=h!==x.length-1?h+1:0,_=x[E];if(!_)return!1;l(_),_.ref!=null&&_.ref.current&&e.dispatchCommand(ut,{index:E,item:_}),u.preventDefault(),u.stopImmediatePropagation()}return!0},A),e.registerCommand(pe,d=>{let u=d;if(r!==null&&r.length&&i!==null){let x=r.flatMap(T=>T.items),h=x.findIndex(T=>T.key===i),E=h!==0?h-1:x.length-1,_=x[E];if(!_)return!1;l(_),_.ref!=null&&_.ref.current&&lt(_.ref.current),u.preventDefault(),u.stopImmediatePropagation()}return!0},A),e.registerCommand(xe,d=>{let u=d;return u.preventDefault(),u.stopImmediatePropagation(),t(),!0},A),e.registerCommand(Ee,d=>{let u=d;if(r===null||i===null)return!1;let h=r.flatMap(E=>E.items).find(E=>E.key===i);return h?(u.preventDefault(),u.stopImmediatePropagation(),g(h),!0):!1},A),e.registerCommand(he,d=>{if(r===null||i===null)return!1;let x=r.flatMap(h=>h.items).find(h=>h.key===i);return x?(d!==null&&(d.preventDefault(),d.stopImmediatePropagation()),g(x),!0):!1},A)),[g,t,e,r,i,l]);let p=Te(()=>({groups:r,selectedItemKey:i,selectItemAndCleanUp:g,setSelectedItemKey:a}),[g,i,r]);return n(o,p,c.match?c.match.matchingString:"")}function ye(o,t){t!=null&&(o.className=t),o.setAttribute("aria-label","Slash menu"),o.setAttribute("role","listbox"),o.style.display="block",o.style.position="absolute"}function ht(o,t,e,r){let n=dt(14),[c]=mt(),s;n[0]===Symbol.for("react.memo_cache_sentinel")?(s=st?document.createElement("div"):null,n[0]=s):s=n[0];let i=Se(s),a;n[1]!==o||n[2]!==r||n[3]!==c||n[4]!==t?(a=()=>{if(i.current===null||parent===void 0)return;let d=c.getRootElement(),u=i.current,x=u.firstChild;if(d!==null&&t!==null){let{height:h,width:E}=t.getRect(),{left:_,top:T}=t.getRect(),I=T;if(T=T-(o.getBoundingClientRect().top+window.scrollY),_=_-(o.getBoundingClientRect().left+window.scrollX),u.style.left=`${_+window.scrollX}px`,u.style.height=`${h}px`,u.style.width=`${E}px`,x!==null){let S=x.getBoundingClientRect(),F=S.height,w=S.width,N=d.getBoundingClientRect();_+w>N.right&&(u.style.left=`${N.right-w+window.scrollX}px`);let y=I+F+32>window.innerHeight,O=I<0;y&&!O?u.style.top=`${T+32-F+window.scrollY-(h+24)}px`:u.style.top=`${T+window.scrollY+32}px`}u.isConnected||(ye(u,r),o.append(u)),u.setAttribute("id","slash-menu"),i.current=u,d.setAttribute("aria-controls","slash-menu")}},n[1]=o,n[2]=r,n[3]=c,n[4]=t,n[5]=a):a=n[5];let f=a,l,m;n[6]!==c||n[7]!==f||n[8]!==t?(l=()=>{let d=c.getRootElement();if(t!==null)return f(),()=>{d!==null&&d.removeAttribute("aria-controls");let u=i.current;u!==null&&u.isConnected&&(u.remove(),u.removeAttribute("id"))}},m=[c,f,t],n[6]=c,n[7]=f,n[8]=t,n[9]=l,n[10]=m):(l=n[9],m=n[10]),M(l,m);let g;return n[11]!==t||n[12]!==e?(g=d=>{t!==null&&(d||e(null))},n[11]=t,n[12]=e,n[13]=g):g=n[13],Ne(t,i,f,g),i}var lo=`\\.,\\+\\*\\?\\$\\@\\|#{}\\(\\)\\^\\-\\[\\]\\\\/!%'"~=<>_:;`;function Pe(o){let t=o.anchor;if(t.type!=="text")return null;let e=t.getNode();if(!e.isSimpleText())return null;let r=t.offset;return e.getTextContent().slice(0,r)}function Et(o,t,e){let r=De(e);if(r===null||!r.isCollapsed)return!1;let n=r.anchorNode,c=o,s=r.anchorOffset;if(n==null||s==null)return!1;try{t.setStart(n,c),t.setEnd(n,s>1?s:1)}catch{return!1}return!0}function ve(o){let t;return o.getEditorState().read(()=>{let e=V();Z(e)&&(t=Pe(e))}),t}function _t(o,t){return t!==0?!1:o.getEditorState().read(()=>{let e=V();if(Z(e)){let c=e.anchor.getNode().getPreviousSibling();return Me(c)&&c.isTextEntity()}return!1})}function Tt(o){j.startTransition?j.startTransition(o):o()}var He=Le("ENABLE_SLASH_MENU_COMMAND");function fo(o){let t=be(30),{anchorClassName:e,anchorElem:r,groups:n,menuRenderFn:c,onClose:s,onOpen:i,onQueryChange:a,triggerFn:f}=o,[l]=ke(),[m,g]=Be(null),p=ht(r,m,g,e),d;t[0]!==s||t[1]!==m?(d=()=>{g(null),s!=null&&m!==null&&s()},t[0]=s,t[1]=m,t[2]=d):d=t[2];let u=d,x;t[3]!==i||t[4]!==m?(x=F=>{g(F),i!=null&&m===null&&i(F)},t[3]=i,t[4]=m,t[5]=x):x=t[5];let h=x,E,_;t[6]!==l||t[7]!==h?(E=()=>Ae(l.registerCommand(He,F=>{let{node:w}=F;return l.getEditorState().read(()=>{let N={leadOffset:0,matchingString:"",replaceableString:""};if(!_t(l,N.leadOffset)&&w!==null){let y=l._window??window,O=y.document.createRange();Et(N.leadOffset,O,y)!==null&&Tt(()=>h({getRect:()=>O.getBoundingClientRect(),match:N}));return}}),!0},$e)),_=[l,h],t[6]=l,t[7]=h,t[8]=E,t[9]=_):(E=t[8],_=t[9]),xt(E,_);let T;t[10]!==u||t[11]!==l||t[12]!==a||t[13]!==h||t[14]!==f?(T=()=>{let F=()=>{l.getEditorState().read(()=>{let N=l._window??window,y=N.document.createRange(),O=V(),W=ve(l);if(!Z(O)||!O.isCollapsed()||W===void 0||y===null){u();return}let k=f({editor:l,query:W});if(a(k?k.matchingString:null),k!==null&&!_t(l,k.leadOffset)&&Et(k.leadOffset,y,N)!==null){Tt(()=>h({getRect:()=>y.getBoundingClientRect(),match:k}));return}u()})},w=l.registerUpdateListener(F);return()=>{w()}},t[10]=u,t[11]=l,t[12]=a,t[13]=h,t[14]=f,t[15]=T):T=t[15];let I;t[16]!==u||t[17]!==l||t[18]!==a||t[19]!==h||t[20]!==m||t[21]!==f?(I=[l,f,a,m,u,h],t[16]=u,t[17]=l,t[18]=a,t[19]=h,t[20]=m,t[21]=f,t[22]=I):I=t[22],xt(T,I);let S;return t[23]!==p||t[24]!==u||t[25]!==l||t[26]!==n||t[27]!==c||t[28]!==m?(S=p.current===null||m===null||l===null?null:Oe(pt,{anchorElementRef:p,close:u,editor:l,groups:n,menuRenderFn:c,resolution:m,shouldSplitNodeWithQuery:!0}),t[23]=p,t[24]=u,t[25]=l,t[26]=n,t[27]=c,t[28]=m,t[29]=S):S=t[29],S}var St=class o{_bottom;_left;_right;_top;constructor(t,e,r,n){let[c,s]=e<=n?[e,n]:[n,e],[i,a]=t<=r?[t,r]:[r,t];this._top=c,this._right=a,this._left=i,this._bottom=s}static fromDOM(t){let{height:e,left:r,top:n,width:c}=t.getBoundingClientRect();return o.fromLWTH(r,c,n,e)}static fromDOMRect(t){let{height:e,left:r,top:n,width:c}=t;return o.fromLWTH(r,c,n,e)}static fromLTRB(t,e,r,n){return new o(t,e,r,n)}static fromLWTH(t,e,r,n){return new o(t,r,t+e,r+n)}static fromPoints(t,e){let{x:r,y:n}=t,{x:c,y:s}=e;return o.fromLTRB(r,n,c,s)}contains(t){if(ct(t)){let{x:s,y:i}=t,a=i<this._top,f=i>this._bottom,l=s<this._left,m=s>this._right;return{reason:{isOnBottomSide:f,isOnLeftSide:l,isOnRightSide:m,isOnTopSide:a},result:!a&&!f&&!l&&!m}}let{bottom:e,left:r,right:n,top:c}=t;return c>=this._top&&c<=this._bottom&&e>=this._top&&e<=this._bottom&&r>=this._left&&r<=this._right&&n>=this._left&&n<=this._right}distanceFromPoint(t){let e=this.contains(t);if(e.result)return{distance:0,isOnBottomSide:e.reason.isOnBottomSide,isOnLeftSide:e.reason.isOnLeftSide,isOnRightSide:e.reason.isOnRightSide,isOnTopSide:e.reason.isOnTopSide};let r=0,n=0;return t.x<this._left?r=this._left-t.x:t.x>this._right&&(r=t.x-this._right),t.y<this._top?n=this._top-t.y:t.y>this._bottom&&(n=t.y-this._bottom),{distance:Math.sqrt(r*r+n*n),isOnBottomSide:t.y>this._bottom,isOnLeftSide:t.x<this._left,isOnRightSide:t.x>this._right,isOnTopSide:t.y<this._top}}equals({bottom:t,left:e,right:r,top:n}){return n===this._top&&t===this._bottom&&e===this._left&&r===this._right}generateNewRect({bottom:t=this.bottom,left:e=this.left,right:r=this.right,top:n=this.top}){return new o(e,n,r,t)}intersectsWith(t){let{height:e,left:r,top:n,width:c}=t,{height:s,left:i,top:a,width:f}=this,l=r+c>=i+f?r+c:i+f,m=n+e>=a+s?n+e:a+s,g=r<=i?r:i,p=n<=a?n:a;return l-g<=c+f&&m-p<=e+s}get bottom(){return this._bottom}get height(){return Math.abs(this._bottom-this._top)}get left(){return this._left}get right(){return this._right}get top(){return this._top}get width(){return Math.abs(this._left-this._right)}};function po({editorConfig:o}){return Ke({nodes:o.features.nodes})}function Ke({nodes:o}){return o.map(t=>"node"in t?t.node:t)}import{$getRoot as je,$isDecoratorNode as It,$isElementNode as U,$isLineBreakNode as Ve,$isTextNode as G}from"lexical";import{$isListItemNode as Ue,$isListNode as wt}from"@lexical/list";import{$isHeadingNode as Ge,$isQuoteNode as ze}from"@lexical/rich-text";import{$isParagraphNode as Xe,$isTextNode as Ye}from"lexical";var C={markdownFormatKind:null,regEx:/(?:)/,regExForAutoFormatting:/(?:)/,requiresParagraphStart:!1},R={...C,requiresParagraphStart:!0},To={...R,export:$(1),markdownFormatKind:"paragraphH1",regEx:/^# /,regExForAutoFormatting:/^# /},So={...R,export:$(2),markdownFormatKind:"paragraphH2",regEx:/^## /,regExForAutoFormatting:/^## /},wo={...R,export:$(3),markdownFormatKind:"paragraphH3",regEx:/^### /,regExForAutoFormatting:/^### /},Co={...R,export:$(4),markdownFormatKind:"paragraphH4",regEx:/^#### /,regExForAutoFormatting:/^#### /},Ro={...R,export:$(5),markdownFormatKind:"paragraphH5",regEx:/^##### /,regExForAutoFormatting:/^##### /},Fo={...R,export:$(6),markdownFormatKind:"paragraphH6",regEx:/^###### /,regExForAutoFormatting:/^###### /},Io={...R,export:Qe,markdownFormatKind:"paragraphBlockQuote",regEx:/^> /,regExForAutoFormatting:/^> /},No={...R,export:J,markdownFormatKind:"paragraphUnorderedList",regEx:/^(\s{0,10})- /,regExForAutoFormatting:/^(\s{0,10})- /},yo={...R,export:J,markdownFormatKind:"paragraphUnorderedList",regEx:/^(\s{0,10})\* /,regExForAutoFormatting:/^(\s{0,10})\* /},bo={...R,export:J,markdownFormatKind:"paragraphOrderedList",regEx:/^(\s{0,10})(\d+)\.\s/,regExForAutoFormatting:/^(\s{0,10})(\d+)\.\s/},Oo={...R,markdownFormatKind:"horizontalRule",regEx:/^\*\*\*$/,regExForAutoFormatting:/^\*\*\* /},ko={...R,markdownFormatKind:"horizontalRule",regEx:/^---$/,regExForAutoFormatting:/^--- /},Ao={...C,exportFormat:"code",exportTag:"`",markdownFormatKind:"code",regEx:/(`)(\s*)([^`]*)(\s*)(`)()/,regExForAutoFormatting:/(`)(\s*\b)([^`]*)(\b\s*)(`)(\s)$/},Mo={...C,exportFormat:"bold",exportTag:"**",markdownFormatKind:"bold",regEx:/(\*\*)(\s*)([^*]*)(\s*)(\*\*)()/,regExForAutoFormatting:/(\*\*)(\s*\b)([^*]*)(\b\s*)(\*\*)(\s)$/},$o={...C,exportFormat:"italic",exportTag:"*",markdownFormatKind:"italic",regEx:/(\*)(\s*)([^*]*)(\s*)(\*)()/,regExForAutoFormatting:/(\*)(\s*\b)([^*]*)(\b\s*)(\*)(\s)$/},Lo={...C,exportFormat:"bold",exportTag:"_",markdownFormatKind:"bold",regEx:/(__)(\s*)([^_]*)(\s*)(__)()/,regExForAutoFormatting:/(__)(\s*)([^_]*)(\s*)(__)(\s)$/},Do={...C,exportFormat:"italic",exportTag:"_",markdownFormatKind:"italic",regEx:/(_)()([^_]*)()(_)()/,regExForAutoFormatting:/(_)()([^_]*)()(_)(\s)$/},Bo={...C,exportFormat:"underline",exportTag:"<u>",exportTagClose:"</u>",markdownFormatKind:"underline",regEx:/(<u>)(\s*)([^<]*)(\s*)(<\/u>)()/,regExForAutoFormatting:/(<u>)(\s*\b)([^<]*)(\b\s*)(<\/u>)(\s)$/},Po={...C,exportFormat:"strikethrough",exportTag:"~~",markdownFormatKind:"strikethrough",regEx:/(~~)(\s*)([^~]*)(\s*)(~~)()/,regExForAutoFormatting:/(~~)(\s*\b)([^~]*)(\b\s*)(~~)(\s)$/},vo={...C,markdownFormatKind:"strikethrough_italic_bold",regEx:/(~~_\*\*)(\s*\b)([^*_~]+)(\b\s*)(\*\*_~~)()/,regExForAutoFormatting:/(~~_\*\*)(\s*\b)([^*_~]+)(\b\s*)(\*\*_~~)(\s)$/},Ho={...C,markdownFormatKind:"italic_bold",regEx:/(_\*\*)(\s*\b)([^*_]+)(\b\s*)(\*\*_)/,regExForAutoFormatting:/(_\*\*)(\s*\b)([^*_]+)(\b\s*)(\*\*_)(\s)$/},Ko={...C,markdownFormatKind:"strikethrough_italic",regEx:/(~~_)(\s*)([^_~]+)(\s*)(_~~)/,regExForAutoFormatting:/(~~_)(\s*)([^_~]+)(\s*)(_~~)(\s)$/},Uo={...C,markdownFormatKind:"strikethrough_bold",regEx:/(~~\*\*)(\s*\b)([^*~]+)(\b\s*)(\*\*~~)/,regExForAutoFormatting:/(~~\*\*)(\s*\b)([^*~]+)(\b\s*)(\*\*~~)(\s)$/},Go={...C,markdownFormatKind:"link",regEx:/(\[)([^\]]*)(\]\()([^)]*)(\)*)()/,regExForAutoFormatting:/(\[)([^\]]*)(\]\()([^)]*)(\)*)(\s)$/};function $(o){return(t,e)=>Ge(t)&&t.getTag()==="h"+o?"#".repeat(o)+" "+e(t):null}function J(o,t){return wt(o)?Ct(o,t,0):null}var We=4;function Ct(o,t,e){let r=[],n=o.getChildren(),c=0;for(let s of n)if(Ue(s)){if(s.getChildrenSize()===1){let f=s.getFirstChild();if(wt(f)){r.push(Ct(f,t,e+1));continue}}let i=" ".repeat(e*We),a=o.getListType()==="bullet"?"- ":`${o.getStart()+c}. `;r.push(i+a+t(s)),c++}return r.join(`
2
- `)}function Qe(o,t){return ze(o)?"> "+t(o):null}function H(o,t){let e={};for(let r of o){let n=t(r);n&&(e[n]?e[n].push(r):e[n]=[r])}return e}function L(o){let t=H(o,e=>e.type);return{element:t.element||[],multilineElement:t["multiline-element"]||[],textFormat:t["text-format"]||[],textMatch:t["text-match"]||[]}}var D=/[!-/:-@[-`{-~\s]/,qe=/^\s{0,3}$/;function v(o){if(!Xe(o))return!1;let t=o.getFirstChild();return t==null||o.getChildrenSize()===1&&Ye(t)&&qe.test(t.getTextContent())}function Nt(o,t=!1){let e=L(o),r=[...e.multilineElement,...e.element],n=!t,c=e.textFormat.filter(s=>s.format.length===1).sort((s,i)=>s.format.includes("code")&&!i.format.includes("code")?1:!s.format.includes("code")&&i.format.includes("code")?-1:0);return s=>{let i=[],a=(s||je()).getChildren();return a.forEach((f,l)=>{let m=Ze(f,r,c,e.textMatch);m!=null&&i.push(n&&l>0&&!v(f)&&!v(a[l-1])?`
3
- `.concat(m):m)}),i.join(`
4
- `)}}function Ze(o,t,e,r){for(let n of t){if(!n.export)continue;let c=n.export(o,s=>z(s,e,r));if(c!=null)return c}return U(o)?z(o,e,r):It(o)?o.getTextContent():null}function z(o,t,e,r,n){let c=[],s=o.getChildren();r||(r=[]),n||(n=[]);t:for(let i of s){for(let a of e){if(!a.export)continue;let f=a.export(i,l=>z(l,t,e,r,[...n,...r]),(l,m)=>Rt(l,m,t,r,n));if(f!=null){c.push(f);continue t}}Ve(i)?c.push(`
5
- `):G(i)?c.push(Rt(i,i.getTextContent(),t,r,n)):U(i)?c.push(z(i,t,e,r,n)):It(i)&&c.push(i.getTextContent())}return c.join("")}function Rt(o,t,e,r,n){let c=t.trim(),s=c;o.hasFormat("code")||(s=s.replace(/([*_`~\\])/g,"\\$1"));let i="",a="",f="",l=Ft(o,!0),m=Ft(o,!1),g=new Set;for(let p of e){let d=p.format[0],u=p.tag;K(o,d)&&!g.has(d)&&(g.add(d),(!K(l,d)||!r.find(x=>x.tag===u))&&(r.push({format:d,tag:u}),i+=u))}for(let p=0;p<r.length;p++){let d=r[p],u=K(o,d.format),x=K(m,d.format);if(u&&x)continue;let h=[...r];for(;h.length>p;){let E=h.pop();n&&E&&n.find(_=>_.tag===E.tag)||(E&&typeof E.tag=="string"&&(u?x||(f+=E.tag):a+=E.tag),r.pop())}break}return s=i+s+f,a+t.replace(c,()=>s)}function Ft(o,t){let e=t?o.getPreviousSibling():o.getNextSibling();if(!e){let r=o.getParentOrThrow();r.isInline()&&(e=t?r.getPreviousSibling():r.getNextSibling())}for(;e;){if(U(e)){if(!e.isInline())break;let r=t?e.getLastDescendant():e.getFirstDescendant();if(G(r))return r;e=t?e.getPreviousSibling():e.getNextSibling()}if(G(e))return e;if(!U(e))return null}return null}function K(o,t){return G(o)&&o.hasFormat(t)}import{$isListItemNode as tn,$isListNode as At}from"@lexical/list";import{$isQuoteNode as en}from"@lexical/rich-text";import{$findMatchingParent as nn}from"@lexical/utils";import{$createLineBreakNode as on,$createParagraphNode as rn,$createTextNode as sn,$getRoot as cn,$getSelection as an,$isParagraphNode as ln}from"lexical";import{$isTextNode as B}from"lexical";function yt(o,t){let e=o.getTextContent(),r=Je(e,t);if(!r)return null;let n=r.index||0,c=n+r[0].length,s=t.transformersByTag[r[1]];return{endIndex:c,match:r,startIndex:n,transformer:s}}function Je(o,t){let e=o.match(t.openTagsRegExp);if(e==null)return null;for(let r of e){let n=r.replace(/^\s/,""),c=t.fullMatchRegExpByTag[n];if(c==null)continue;let s=o.match(c),i=t.transformersByTag[n];if(s!=null&&i!=null){if(i.intraword!==!1)return s;let{index:a=0}=s,f=o[a-1],l=o[a+s[0].length];if((!f||D.test(f))&&(!l||D.test(l)))return s}}return null}function bt(o,t,e,r,n){let c=o.getTextContent(),s,i,a;if(n[0]===c?a=o:t===0?[a,s]=o.splitText(e):[i,a,s]=o.splitText(t,e),a.setTextContent(n[2]),r)for(let f of r.format)a.hasFormat(f)||a.toggleFormat(f);return{nodeAfter:s,nodeBefore:i,transformedNode:a}}function Ot(o,t){let e=o,r,n,c,s;for(let i of t){if(!i.replace||!i.importRegExp)continue;let a=e.getTextContent().match(i.importRegExp);if(!a)continue;let f=a.index||0,l=i.getEndIndex?i.getEndIndex(e,a):f+a[0].length;l!==!1&&(r===void 0||n===void 0||f<r&&l>n)&&(r=f,n=l,c=i,s=a)}return r===void 0||n===void 0||c===void 0||s===void 0?null:{endIndex:n,match:s,startIndex:r,transformer:c}}function kt(o,t,e,r,n){let c,s,i;if(t===0?[i,c]=o.splitText(e):[s,i,c]=o.splitText(t,e),!r.replace)return null;let a=i?r.replace(i,n):void 0;return{nodeAfter:c,nodeBefore:s,transformedNode:a||void 0}}function b(o,t,e){let r=yt(o,t),n=Ot(o,e);if(r&&n&&(r.startIndex<=n.startIndex&&r.endIndex>=n.endIndex?n=null:r=null),r){let i=bt(o,r.startIndex,r.endIndex,r.transformer,r.match);i.nodeAfter&&B(i.nodeAfter)&&!i.nodeAfter.hasFormat("code")&&b(i.nodeAfter,t,e),i.nodeBefore&&B(i.nodeBefore)&&!i.nodeBefore.hasFormat("code")&&b(i.nodeBefore,t,e),i.transformedNode&&B(i.transformedNode)&&!i.transformedNode.hasFormat("code")&&b(i.transformedNode,t,e)}else if(n){let i=kt(o,n.startIndex,n.endIndex,n.transformer,n.match);if(!i)return;i.nodeAfter&&B(i.nodeAfter)&&!i.nodeAfter.hasFormat("code")&&b(i.nodeAfter,t,e),i.nodeBefore&&B(i.nodeBefore)&&!i.nodeBefore.hasFormat("code")&&b(i.nodeBefore,t,e),i.transformedNode&&B(i.transformedNode)&&!i.transformedNode.hasFormat("code")&&b(i.transformedNode,t,e)}let s=o.getTextContent().replace(/\\([*_`~])/g,"$1");o.setTextContent(s)}function Mt(o,t=!1){let e=L(o),r=dn(e.textFormat);return(n,c)=>{let s=n.split(`
6
- `),i=s.length,a=c||cn();a.clear();for(let l=0;l<i;l++){let m=s[l],[g,p]=fn(s,l,e.multilineElement,a);if(g){l=p;continue}un(m,a,e.element,r,e.textMatch)}let f=a.getChildren();for(let l of f)!t&&v(l)&&a.getChildrenSize()>1&&l.remove();an()!==null&&a.selectStart()}}function fn(o,t,e,r){for(let n of e){let{handleImportAfterStartMatch:c,regExpEnd:s,regExpStart:i,replace:a}=n,f=o[t]?.match(i);if(!f)continue;if(c){let d=c({lines:o,rootNode:r,startLineIndex:t,startMatch:f,transformer:n});if(d===null)continue;if(d)return d}let l=typeof s=="object"&&"regExp"in s?s.regExp:s,m=s&&typeof s=="object"&&"optional"in s?s.optional:!s,g=t,p=o.length;for(;g<p;){let d=l?o[g]?.match(l):null;if(!d&&(!m||m&&g<p-1)){g++;continue}if(d&&t===g&&d.index===f.index){g++;continue}let u=[];if(d&&t===g)u.push(o[t].slice(f[0].length,-d[0].length));else for(let x=t;x<=g;x++){let h=o[x];if(x===t){let E=h.slice(f[0].length);u.push(E)}else if(x===g&&d){let E=h.slice(0,-d[0].length);u.push(E)}else u.push(h)}if(a(r,null,f,d,u,!0)!==!1)return[!0,g];break}}return[!1,t]}function un(o,t,e,r,n){let c=sn(o),s=rn();s.append(c),t.append(s);for(let{regExp:i,replace:a}of e){let f=o.match(i);if(f&&(c.setTextContent(o.slice(f[0].length)),a(s,[c],f,!0)!==!1))break}if(b(c,r,n),s.isAttached()&&o.length>0){let i=s.getPreviousSibling();if(ln(i)||en(i)||At(i)){let a=i;if(At(i)){let f=i.getLastDescendant();f==null?a=null:a=nn(f,tn)}a!=null&&a.getTextContentSize()>0&&(a.splice(a.getChildrenSize(),0,[on(),...s.getChildren()]),s.remove())}}}function dn(o){let t={},e={},r=[],n="(?<![\\\\])";for(let c of o){let{tag:s}=c;t[s]=c;let i=s.replace(/([*^+])/g,"\\$1");r.push(i),s.length===1?e[s]=new RegExp(`(?<![\\\\${i}])(${i})((\\\\${i})?.*?[^${i}\\s](\\\\${i})?)((?<!\\\\)|(?<=\\\\\\\\))(${i})(?![\\\\${i}])`):e[s]=new RegExp(`(?<!\\\\)(${i})((\\\\${i})?.*?[^\\s](\\\\${i})?)((?<!\\\\)|(?<=\\\\\\\\))(${i})(?!\\\\)`)}return{fullMatchRegExpByTag:e,openTagsRegExp:new RegExp(`${n}(${r.join("|")})`,"g"),transformersByTag:t}}import{$createRangeSelection as mn,$getSelection as tt,$isLineBreakNode as gn,$isRangeSelection as et,$isRootOrShadowRoot as Lt,$isTextNode as Dt,$setSelection as pn}from"lexical";function hn(o,t,e,r){let n=o.getParent();if(!Lt(n)||o.getFirstChild()!==t)return!1;let c=t.getTextContent();if(c[e-1]!==" ")return!1;for(let{regExp:s,replace:i}of r){let a=c.match(s);if(a&&a[0].length===(a[0].endsWith(" ")?e:e-1)){let f=t.getNextSiblings(),[l,m]=t.splitText(e);l?.remove();let g=m?[m,...f]:f;if(i(o,g,a,!1)!==!1)return!0}}return!1}function xn(o,t,e,r){let n=o.getParent();if(!Lt(n)||o.getFirstChild()!==t)return!1;let c=t.getTextContent();if(c[e-1]!==" ")return!1;for(let{regExpEnd:s,regExpStart:i,replace:a}of r){if(s&&!("optional"in s)||s&&"optional"in s&&!s.optional)continue;let f=c.match(i);if(f&&f[0].length===(f[0].endsWith(" ")?e:e-1)){let l=t.getNextSiblings(),[m,g]=t.splitText(e);m?.remove();let p=g?[g,...l]:l;if(a(o,p,f,null,null,!1)!==!1)return!0}}return!1}function En(o,t,e){let r=o.getTextContent(),n=r[t-1],c=e[n];if(c==null)return!1;t<r.length&&(r=r.slice(0,t));for(let s of c){if(!s.replace||!s.regExp)continue;let i=r.match(s.regExp);if(i===null)continue;let a=i.index||0,f=a+i[0].length,l;return a===0?[l]=o.splitText(f):[,l]=o.splitText(a,f),l&&(l.selectNext(0,0),s.replace(l,i)),!0}return!1}function _n(o,t,e){let r=o.getTextContent(),n=t-1,c=r[n],s=e[c];if(!s)return!1;for(let i of s){let{tag:a}=i,f=a.length,l=n-f+1;if(f>1&&!Bt(r,l,a,0,f)||r[l-1]===" ")continue;let m=r[n+1];if(i.intraword===!1&&m&&!D.test(m))continue;let g=o,p=g,d=$t(r,l,a),u=p;for(;d<0&&(u=u.getPreviousSibling())&&!gn(u);)if(Dt(u)){let w=u.getTextContent();p=u,d=$t(w,w.length,a)}if(d<0||p===g&&d+f===l)continue;let x=p.getTextContent();if(d>0&&x[d-1]===c)continue;let h=x[d-1];if(i.intraword===!1&&h&&!D.test(h))continue;let E=g.getTextContent(),_=E.slice(0,l)+E.slice(n+1);g.setTextContent(_);let T=p===g?_:x;p.setTextContent(T.slice(0,d)+T.slice(d+f));let I=tt(),S=mn();pn(S);let F=n-f*(p===g?2:1)+1;S.anchor.set(p.__key,d,"text"),S.focus.set(g.__key,F,"text");for(let w of i.format)S.hasFormat(w)||S.formatText(w);S.anchor.set(S.focus.key,S.focus.offset,S.focus.type);for(let w of i.format)S.hasFormat(w)&&S.toggleFormat(w);return et(I)&&(S.format=I.format),!0}return!1}function $t(o,t,e){let r=e.length;for(let n=t;n>=r;n--){let c=n-r;if(Bt(o,c,e,0,r)&&o[c+r]!==" ")return c}return-1}function Bt(o,t,e,r,n){for(let c=0;c<n;c++)if(o[t+c]!==e[r+c])return!1;return!0}function ur(o,t=X){let e=L(t),r=H(e.textFormat,({tag:s})=>s[s.length-1]),n=H(e.textMatch,({trigger:s})=>s);for(let s of t){let i=s.type;if(i==="element"||i==="text-match"||i==="multiline-element"){let a=s.dependencies;for(let f of a)if(!o.hasNode(f))throw new Error("MarkdownShortcuts: missing dependency %s for transformer. Ensure node dependency is included in editor initial config."+f.getType())}}let c=(s,i,a)=>{hn(s,i,a,e.element)||xn(s,i,a,e.multilineElement)||En(i,a,n)||_n(i,a,r)};return o.registerUpdateListener(({dirtyLeaves:s,editorState:i,prevEditorState:a,tags:f})=>{if(f.has("collaboration")||f.has("historic")||o.isComposing())return;let l=i.read(tt),m=a.read(tt);if(!et(m)||!et(l)||!l.isCollapsed()||l.is(m))return;let g=l.anchor.key,p=l.anchor.offset,d=i._nodeMap.get(g);!Dt(d)||!s.has(g)||p!==1&&p>m.anchor.offset+1||o.update(()=>{if(d.hasFormat("code"))return;let u=d.getParent();u!==null&&c(u,d,l.anchor.offset)})})}import{$createListItemNode as Tn,$createListNode as Sn,$isListItemNode as wn,$isListNode as P,ListItemNode as ot,ListNode as rt}from"@lexical/list";import{$createHeadingNode as Cn,$createQuoteNode as Rn,$isHeadingNode as Fn,$isQuoteNode as Pt,HeadingNode as In,QuoteNode as Nn}from"@lexical/rich-text";import{$createLineBreakNode as yn}from"lexical";var vt=/^[\t ]*$/,Gt=/^(\s*)(\d+)\.\s/,zt=/^(\s*)[-*+]\s/,Xt=/^(\s*)(?:-\s)?\s?(\[(\s|x)?\])\s/i,nt=/^(#{1,6})\s/,Yt=/^>\s/,bn=/^[ \t]*(\\`\\`\\`|```)(\w+)?/,Ht=/[ \t]*(\\`\\`\\`|```)$/,On=/^[ \t]*```[^`]+(?:(?:`{1,2}|`{4,})[^`]+)*```(?:[^`]|$)/,kn=/^\|(.+)\|\s?$/,An=/^(\| ?:?-*:? ?)+\|\s?$/,Kt=/^[ \t]*<[a-z_][\w-]*(?:\s[^<>]*)?\/?>/i,Ut=/^[ \t]*<\/[a-z_][\w-]*\s*>/i,Mn=o=>(t,e,r)=>{let n=o(r);n.append(...e),t.replace(n),n.select(0,0)},Wt=4;function $n(o){let t=o.match(/\t/g),e=o.match(/ /g),r=0;return t&&(r+=t.length),e&&(r+=Math.floor(e.length/Wt)),r}var it=o=>(t,e,r)=>{let n=t.getPreviousSibling(),c=t.getNextSibling(),s=Tn(o==="check"?r[3]==="x":void 0);if(P(c)&&c.getListType()===o){let a=c.getFirstChild();a!==null?a.insertBefore(s):c.append(s),t.remove()}else if(P(n)&&n.getListType()===o)n.append(s),t.remove();else{let a=Sn(o,o==="number"?Number(r[2]):void 0);a.append(s),t.replace(a)}s.append(...e),s.select(0,0);let i=$n(r[1]);i&&s.setIndent(i)},Y=(o,t,e)=>{let r=[],n=o.getChildren(),c=0;for(let s of n)if(wn(s)){if(s.getChildrenSize()===1){let l=s.getFirstChild();if(P(l)){r.push(Y(l,t,e+1));continue}}let i=" ".repeat(e*Wt),a=o.getListType(),f=a==="number"?`${o.getStart()+c}. `:a==="check"?`- [${s.getChecked()?"x":" "}] `:"- ";r.push(i+f+t(s)),c++}return r.join(`
7
- `)},Qt={type:"element",dependencies:[In],export:(o,t)=>{if(!Fn(o))return null;let e=Number(o.getTag().slice(1));return"#".repeat(e)+" "+t(o)},regExp:nt,replace:Mn(o=>{let t="h"+o[1].length;return Cn(t)})},qt={type:"element",dependencies:[Nn],export:(o,t)=>{if(!Pt(o))return null;let e=t(o).split(`
8
- `),r=[];for(let n of e)r.push("> "+n);return r.join(`
9
- `)},regExp:Yt,replace:(o,t,e,r)=>{if(r){let c=o.getPreviousSibling();if(Pt(c)){c.splice(c.getChildrenSize(),0,[yn(),...t]),c.select(0,0),o.remove();return}}let n=Rn();n.append(...t),o.replace(n),n.select(0,0)}},jt={type:"element",dependencies:[rt,ot],export:(o,t)=>P(o)?Y(o,t,0):null,regExp:zt,replace:it("bullet")},Ln={type:"element",dependencies:[rt,ot],export:(o,t)=>P(o)?Y(o,t,0):null,regExp:Xt,replace:it("check")},Vt={type:"element",dependencies:[rt,ot],export:(o,t)=>P(o)?Y(o,t,0):null,regExp:Gt,replace:it("number")},Zt={type:"text-format",format:["code"],tag:"`"},Jt={type:"text-format",format:["highlight"],tag:"=="},te={type:"text-format",format:["bold","italic"],tag:"***"},ee={type:"text-format",format:["bold","italic"],intraword:!1,tag:"___"},ne={type:"text-format",format:["bold"],tag:"**"},oe={type:"text-format",format:["bold"],intraword:!1,tag:"__"},re={type:"text-format",format:["strikethrough"],tag:"~~"},ie={type:"text-format",format:["italic"],tag:"*"},se={type:"text-format",format:["italic"],intraword:!1,tag:"_"};function ce(o,t){let e=o.split(`
10
- `),r=!1,n=[],c=0;for(let s=0;s<e.length;s++){let i=e[s],a=n[n.length-1];if(On.test(i)){n.push(i);continue}if(Ht.test(i)){c===0&&(r=!0),c===1&&(r=!1),c>0&&c--,n.push(i);continue}if(bn.test(i)){r=!0,c++,n.push(i);continue}if(r){n.push(i);continue}vt.test(i)||vt.test(a)||!a||nt.test(a)||nt.test(i)||Yt.test(i)||Gt.test(i)||zt.test(i)||Xt.test(i)||kn.test(i)||An.test(i)||!t||Kt.test(i)||Ut.test(i)||Kt.test(a)||Ut.test(a)||Ht.test(a)?n.push(i):n[n.length-1]=a+" "+i.trim()}return n.join(`
11
- `)}var Dn=[Qt,qt,jt,Vt],Bn=[],Pn=[Zt,te,ee,ne,oe,Jt,ie,se,re],vn=[],X=[...Dn,...Bn,...Pn,...vn];function Tr(o,t=X,e,r=!1,n=!0){let c=r?o:ce(o,n);return Mt(t,r)(c,e)}function Sr(o=X,t,e=!1){return Nt(o,e)(t)}export{st as a,Xn as b,ur as c,Tr as d,Sr as e,Q as f,ct as g,lo as h,He as i,fo as j,St as k,po as l};
12
- //# sourceMappingURL=chunk-KZKGNMS3.js.map