@payloadcms/richtext-lexical 3.0.0-beta.20 → 3.0.0-beta.21

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 (92) hide show
  1. package/dist/field/features/blocks/feature.server.d.ts.map +1 -1
  2. package/dist/field/features/blocks/feature.server.js +28 -68
  3. package/dist/field/features/blocks/feature.server.js.map +1 -1
  4. package/dist/field/features/blocks/populationPromise.d.ts.map +1 -1
  5. package/dist/field/features/blocks/populationPromise.js +0 -13
  6. package/dist/field/features/blocks/populationPromise.js.map +1 -1
  7. package/dist/field/features/blocks/validate.d.ts.map +1 -1
  8. package/dist/field/features/blocks/validate.js +2 -14
  9. package/dist/field/features/blocks/validate.js.map +1 -1
  10. package/dist/field/features/link/drawer/baseFields.d.ts +3 -3
  11. package/dist/field/features/link/drawer/baseFields.d.ts.map +1 -1
  12. package/dist/field/features/link/drawer/baseFields.js +28 -42
  13. package/dist/field/features/link/drawer/baseFields.js.map +1 -1
  14. package/dist/field/features/link/drawer/types.d.ts +4 -2
  15. package/dist/field/features/link/drawer/types.d.ts.map +1 -1
  16. package/dist/field/features/link/drawer/types.js.map +1 -1
  17. package/dist/field/features/link/feature.server.d.ts +0 -2
  18. package/dist/field/features/link/feature.server.d.ts.map +1 -1
  19. package/dist/field/features/link/feature.server.js +22 -6
  20. package/dist/field/features/link/feature.server.js.map +1 -1
  21. package/dist/field/features/link/plugins/floatingLinkEditor/LinkEditor/index.d.ts.map +1 -1
  22. package/dist/field/features/link/plugins/floatingLinkEditor/LinkEditor/index.js +38 -24
  23. package/dist/field/features/link/plugins/floatingLinkEditor/LinkEditor/index.js.map +1 -1
  24. package/dist/field/features/link/plugins/floatingLinkEditor/index.scss +9 -1
  25. package/dist/field/features/link/plugins/floatingLinkEditor/utilities.d.ts +3 -5
  26. package/dist/field/features/link/plugins/floatingLinkEditor/utilities.d.ts.map +1 -1
  27. package/dist/field/features/link/plugins/floatingLinkEditor/utilities.js +11 -29
  28. package/dist/field/features/link/plugins/floatingLinkEditor/utilities.js.map +1 -1
  29. package/dist/field/features/link/plugins/link/index.d.ts.map +1 -1
  30. package/dist/field/features/link/plugins/link/index.js +0 -6
  31. package/dist/field/features/link/plugins/link/index.js.map +1 -1
  32. package/dist/field/features/link/populationPromise.d.ts.map +1 -1
  33. package/dist/field/features/link/populationPromise.js +5 -23
  34. package/dist/field/features/link/populationPromise.js.map +1 -1
  35. package/dist/field/features/link/validate.d.ts +5 -0
  36. package/dist/field/features/link/validate.d.ts.map +1 -0
  37. package/dist/field/features/link/validate.js +32 -0
  38. package/dist/field/features/link/validate.js.map +1 -0
  39. package/dist/field/features/relationship/nodes/components/RelationshipComponent.d.ts.map +1 -1
  40. package/dist/field/features/relationship/nodes/components/RelationshipComponent.js +51 -2
  41. package/dist/field/features/relationship/nodes/components/RelationshipComponent.js.map +1 -1
  42. package/dist/field/features/types.d.ts +5 -1
  43. package/dist/field/features/types.d.ts.map +1 -1
  44. package/dist/field/features/types.js.map +1 -1
  45. package/dist/field/features/upload/feature.server.d.ts.map +1 -1
  46. package/dist/field/features/upload/feature.server.js +14 -2
  47. package/dist/field/features/upload/feature.server.js.map +1 -1
  48. package/dist/field/features/upload/populationPromise.d.ts.map +1 -1
  49. package/dist/field/features/upload/populationPromise.js +2 -12
  50. package/dist/field/features/upload/populationPromise.js.map +1 -1
  51. package/dist/field/features/upload/validate.d.ts +2 -1
  52. package/dist/field/features/upload/validate.d.ts.map +1 -1
  53. package/dist/field/features/upload/validate.js +33 -11
  54. package/dist/field/features/upload/validate.js.map +1 -1
  55. package/dist/field/lexical/LexicalEditor.js +1 -1
  56. package/dist/field/lexical/LexicalEditor.js.map +1 -1
  57. package/dist/field/lexical/config/server/default.d.ts +1 -2
  58. package/dist/field/lexical/config/server/default.d.ts.map +1 -1
  59. package/dist/field/lexical/config/server/default.js +0 -2
  60. package/dist/field/lexical/config/server/default.js.map +1 -1
  61. package/dist/field/lexical/config/server/loader.d.ts +4 -2
  62. package/dist/field/lexical/config/server/loader.d.ts.map +1 -1
  63. package/dist/field/lexical/config/server/loader.js +3 -2
  64. package/dist/field/lexical/config/server/loader.js.map +1 -1
  65. package/dist/field/lexical/config/server/sanitize.d.ts +2 -1
  66. package/dist/field/lexical/config/server/sanitize.d.ts.map +1 -1
  67. package/dist/field/lexical/config/server/sanitize.js +3 -2
  68. package/dist/field/lexical/config/server/sanitize.js.map +1 -1
  69. package/dist/field/lexical/plugins/FloatingSelectToolbar/index.d.ts.map +1 -1
  70. package/dist/field/lexical/plugins/FloatingSelectToolbar/index.js +24 -23
  71. package/dist/field/lexical/plugins/FloatingSelectToolbar/index.js.map +1 -1
  72. package/dist/field/lexical/utils/setFloatingElemPosition.d.ts +1 -1
  73. package/dist/field/lexical/utils/setFloatingElemPosition.d.ts.map +1 -1
  74. package/dist/field/lexical/utils/setFloatingElemPosition.js +15 -13
  75. package/dist/field/lexical/utils/setFloatingElemPosition.js.map +1 -1
  76. package/dist/field/lexical/utils/url.d.ts.map +1 -1
  77. package/dist/field/lexical/utils/url.js +2 -0
  78. package/dist/field/lexical/utils/url.js.map +1 -1
  79. package/dist/generateComponentMap.d.ts.map +1 -1
  80. package/dist/generateComponentMap.js +1 -10
  81. package/dist/generateComponentMap.js.map +1 -1
  82. package/dist/generateSchemaMap.d.ts.map +1 -1
  83. package/dist/generateSchemaMap.js +1 -10
  84. package/dist/generateSchemaMap.js.map +1 -1
  85. package/dist/index.d.ts +3 -3
  86. package/dist/index.d.ts.map +1 -1
  87. package/dist/index.js +241 -234
  88. package/dist/index.js.map +1 -1
  89. package/dist/types.d.ts +8 -1
  90. package/dist/types.d.ts.map +1 -1
  91. package/dist/types.js.map +1 -1
  92. package/package.json +9 -9
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/field/lexical/LexicalEditor.tsx"],"sourcesContent":["'use client'\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext.js'\nimport LexicalErrorBoundary from '@lexical/react/LexicalErrorBoundary.js'\nimport { HistoryPlugin } from '@lexical/react/LexicalHistoryPlugin.js'\nimport { OnChangePlugin } from '@lexical/react/LexicalOnChangePlugin.js'\nimport { RichTextPlugin } from '@lexical/react/LexicalRichTextPlugin.js'\nimport { TabIndentationPlugin } from '@lexical/react/LexicalTabIndentationPlugin.js'\nimport * as React from 'react'\nimport { useEffect, useState } from 'react'\n\nimport type { LexicalProviderProps } from './LexicalProvider.js'\n\nimport { EditorPlugin } from './EditorPlugin.js'\nimport './LexicalEditor.scss'\nimport { FloatingSelectToolbarPlugin } from './plugins/FloatingSelectToolbar/index.js'\nimport { MarkdownShortcutPlugin } from './plugins/MarkdownShortcut/index.js'\nimport { SlashMenuPlugin } from './plugins/SlashMenu/index.js'\nimport { AddBlockHandlePlugin } from './plugins/handles/AddBlockHandlePlugin/index.js'\nimport { DraggableBlockPlugin } from './plugins/handles/DraggableBlockPlugin/index.js'\nimport { LexicalContentEditable } from './ui/ContentEditable.js'\n\nexport const LexicalEditor: React.FC<Pick<LexicalProviderProps, 'editorConfig' | 'onChange'>> = (\n props,\n) => {\n const { editorConfig, onChange } = props\n const [editor] = useLexicalComposerContext()\n\n const [floatingAnchorElem, setFloatingAnchorElem] = useState<HTMLDivElement | null>(null)\n const onRef = (_floatingAnchorElem: HTMLDivElement) => {\n if (_floatingAnchorElem !== null) {\n setFloatingAnchorElem(_floatingAnchorElem)\n }\n }\n\n const [isSmallWidthViewport, setIsSmallWidthViewport] = useState<boolean>(false)\n\n useEffect(() => {\n const updateViewPortWidth = () => {\n const isNextSmallWidthViewport = window.matchMedia('(max-width: 1025px)').matches\n\n if (isNextSmallWidthViewport !== isSmallWidthViewport) {\n setIsSmallWidthViewport(isNextSmallWidthViewport)\n }\n }\n updateViewPortWidth()\n window.addEventListener('resize', updateViewPortWidth)\n\n return () => {\n window.removeEventListener('resize', updateViewPortWidth)\n }\n }, [isSmallWidthViewport])\n\n const ErrorBoundaryComponent = LexicalErrorBoundary.default || LexicalErrorBoundary\n\n return (\n <React.Fragment>\n {editorConfig.features.plugins.map((plugin) => {\n if (plugin.position === 'top') {\n return <EditorPlugin key={plugin.key} plugin={plugin} />\n }\n })}\n <RichTextPlugin\n //@ts-expect-error ts being dumb\n ErrorBoundary={ErrorBoundaryComponent}\n contentEditable={\n <div className=\"editor-scroller\">\n <div className=\"editor\" ref={onRef}>\n <LexicalContentEditable />\n </div>\n </div>\n }\n placeholder={\n <p className=\"editor-placeholder\">Start typing, or press '/' for commands...</p>\n }\n />\n <OnChangePlugin\n // Selection changes can be ignored here, reducing the\n // frequency that the FieldComponent and Payload receive updates.\n // Selection changes are only needed if you are saving selection state\n ignoreSelectionChange\n onChange={(editorState, editor, tags) => {\n // Ignore any onChange event triggered by focus only\n if (!tags.has('focus') || tags.size > 1) {\n if (onChange != null) onChange(editorState, editor, tags)\n }\n }}\n />\n {floatingAnchorElem && (\n <React.Fragment>\n {!isSmallWidthViewport && editor.isEditable() && (\n <React.Fragment>\n <DraggableBlockPlugin anchorElem={floatingAnchorElem} />\n <AddBlockHandlePlugin anchorElem={floatingAnchorElem} />\n </React.Fragment>\n )}\n {editorConfig.features.plugins.map((plugin) => {\n if (\n plugin.position === 'floatingAnchorElem' &&\n !(plugin.desktopOnly === true && isSmallWidthViewport)\n ) {\n return (\n <EditorPlugin anchorElem={floatingAnchorElem} key={plugin.key} plugin={plugin} />\n )\n }\n })}\n {editor.isEditable() && (\n <React.Fragment>\n <FloatingSelectToolbarPlugin anchorElem={floatingAnchorElem} />\n <SlashMenuPlugin anchorElem={floatingAnchorElem} />\n </React.Fragment>\n )}\n </React.Fragment>\n )}\n {editor.isEditable() && (\n <React.Fragment>\n <HistoryPlugin />\n {editorConfig?.features?.markdownTransformers?.length > 0 && <MarkdownShortcutPlugin />}\n </React.Fragment>\n )}\n\n <TabIndentationPlugin />\n {editorConfig.features.plugins.map((plugin) => {\n if (plugin.position === 'normal') {\n return <EditorPlugin key={plugin.key} plugin={plugin} />\n }\n })}\n {editorConfig.features.plugins.map((plugin) => {\n if (plugin.position === 'bottom') {\n return <EditorPlugin key={plugin.key} plugin={plugin} />\n }\n })}\n </React.Fragment>\n )\n}\n"],"names":["useLexicalComposerContext","LexicalErrorBoundary","HistoryPlugin","OnChangePlugin","RichTextPlugin","TabIndentationPlugin","React","useEffect","useState","EditorPlugin","FloatingSelectToolbarPlugin","MarkdownShortcutPlugin","SlashMenuPlugin","AddBlockHandlePlugin","DraggableBlockPlugin","LexicalContentEditable","LexicalEditor","props","editorConfig","onChange","editor","floatingAnchorElem","setFloatingAnchorElem","onRef","_floatingAnchorElem","isSmallWidthViewport","setIsSmallWidthViewport","updateViewPortWidth","isNextSmallWidthViewport","window","matchMedia","matches","addEventListener","removeEventListener","ErrorBoundaryComponent","default","Fragment","features","plugins","map","plugin","position","key","ErrorBoundary","contentEditable","div","className","ref","placeholder","p","ignoreSelectionChange","editorState","tags","has","size","isEditable","anchorElem","desktopOnly","markdownTransformers","length"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA;AACA,SAASA,yBAAyB,QAAQ,2CAA0C;AACpF,OAAOC,0BAA0B,yCAAwC;AACzE,SAASC,aAAa,QAAQ,yCAAwC;AACtE,SAASC,cAAc,QAAQ,0CAAyC;AACxE,SAASC,cAAc,QAAQ,0CAAyC;AACxE,SAASC,oBAAoB,QAAQ,gDAA+C;AACpF,YAAYC,WAAW,QAAO;AAC9B,SAASC,SAAS,EAAEC,QAAQ,QAAQ,QAAO;AAI3C,SAASC,YAAY,QAAQ,oBAAmB;AAChD,OAAO,uBAAsB;AAC7B,SAASC,2BAA2B,QAAQ,2CAA0C;AACtF,SAASC,sBAAsB,QAAQ,sCAAqC;AAC5E,SAASC,eAAe,QAAQ,+BAA8B;AAC9D,SAASC,oBAAoB,QAAQ,kDAAiD;AACtF,SAASC,oBAAoB,QAAQ,kDAA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AYD,KAAKE,IAAI,GAAG,GAAG;gBACvC,IAAInC,YAAY,MAAMA,SAASgC,aAAa/B,QAAQgC;YACtD;QACF;QAED/B,oCACC,oBAACf,MAAM8B,QAAQ,QACZ,CAACX,wBAAwBL,OAAOmC,UAAU,oBACzC,oBAACjD,MAAM8B,QAAQ,sBACb,oBAACtB;QAAqB0C,YAAYnC;sBAClC,oBAACR;QAAqB2C,YAAYnC;SAGrCH,aAAamB,QAAQ,CAACC,OAAO,CAACC,GAAG,CAAC,CAACC;QAClC,IACEA,OAAOC,QAAQ,KAAK,wBACpB,CAAED,CAAAA,OAAOiB,WAAW,KAAK,QAAQhC,oBAAmB,GACpD;YACA,qBACE,oBAAChB;gBAAa+C,YAAYnC;gBAAoBqB,KAAKF,OAAOE,GAAG;gBAAEF,QAAQA;;QAE3E;IACF,IACCpB,OAAOmC,UAAU,oBAChB,oBAACjD,MAAM8B,QAAQ,sBACb,oBAAC1B;QAA4B8C,YAAYnC;sBACzC,oBAACT;QAAgB4C,YAAYnC;UAKpCD,OAAOmC,UAAU,oBAChB,oBAACjD,MAAM8B,QAAQ,sBACb,oBAAClC,sBACAgB,cAAcmB,UAAUqB,sBAAsBC,SAAS,mBAAK,oBAAChD,8CAIlE,oBAACN,6BACAa,aAAamB,QAAQ,CAACC,OAAO,CAACC,GAAG,CAAC,CAACC;QAClC,IAAIA,OAAOC,QAAQ,KAAK,UAAU;YAChC,qBAAO,oBAAChC;gBAAaiC,KAAKF,OAAOE,GAAG;gBAAEF,QAAQA;;QAChD;IACF,IACCtB,aAAamB,QAAQ,CAACC,OAAO,CAACC,GAAG,CAAC,CAACC;QAClC,IAAIA,OAAOC,QAAQ,KAAK,UAAU;YAChC,qBAAO,oBAAChC;gBAAaiC,KAAKF,OAAOE,GAAG;gBAAEF,QAAQA;;QAChD;IACF;AAGN,EAAC"}
1
+ {"version":3,"sources":["../../../src/field/lexical/LexicalEditor.tsx"],"sourcesContent":["'use client'\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext.js'\nimport LexicalErrorBoundary from '@lexical/react/LexicalErrorBoundary.js'\nimport { HistoryPlugin } from '@lexical/react/LexicalHistoryPlugin.js'\nimport { OnChangePlugin } from '@lexical/react/LexicalOnChangePlugin.js'\nimport { RichTextPlugin } from '@lexical/react/LexicalRichTextPlugin.js'\nimport { TabIndentationPlugin } from '@lexical/react/LexicalTabIndentationPlugin.js'\nimport * as React from 'react'\nimport { useEffect, useState } from 'react'\n\nimport type { LexicalProviderProps } from './LexicalProvider.js'\n\nimport { EditorPlugin } from './EditorPlugin.js'\nimport './LexicalEditor.scss'\nimport { FloatingSelectToolbarPlugin } from './plugins/FloatingSelectToolbar/index.js'\nimport { MarkdownShortcutPlugin } from './plugins/MarkdownShortcut/index.js'\nimport { SlashMenuPlugin } from './plugins/SlashMenu/index.js'\nimport { AddBlockHandlePlugin } from './plugins/handles/AddBlockHandlePlugin/index.js'\nimport { DraggableBlockPlugin } from './plugins/handles/DraggableBlockPlugin/index.js'\nimport { LexicalContentEditable } from './ui/ContentEditable.js'\n\nexport const LexicalEditor: React.FC<Pick<LexicalProviderProps, 'editorConfig' | 'onChange'>> = (\n props,\n) => {\n const { editorConfig, onChange } = props\n const [editor] = useLexicalComposerContext()\n\n const [floatingAnchorElem, setFloatingAnchorElem] = useState<HTMLDivElement | null>(null)\n const onRef = (_floatingAnchorElem: HTMLDivElement) => {\n if (_floatingAnchorElem !== null) {\n setFloatingAnchorElem(_floatingAnchorElem)\n }\n }\n\n const [isSmallWidthViewport, setIsSmallWidthViewport] = useState<boolean>(false)\n\n useEffect(() => {\n const updateViewPortWidth = () => {\n const isNextSmallWidthViewport = window.matchMedia('(max-width: 768px)').matches\n\n if (isNextSmallWidthViewport !== isSmallWidthViewport) {\n setIsSmallWidthViewport(isNextSmallWidthViewport)\n }\n }\n updateViewPortWidth()\n window.addEventListener('resize', updateViewPortWidth)\n\n return () => {\n window.removeEventListener('resize', updateViewPortWidth)\n }\n }, [isSmallWidthViewport])\n\n const ErrorBoundaryComponent = LexicalErrorBoundary.default || LexicalErrorBoundary\n\n return (\n <React.Fragment>\n {editorConfig.features.plugins.map((plugin) => {\n if (plugin.position === 'top') {\n return <EditorPlugin key={plugin.key} plugin={plugin} />\n }\n })}\n <RichTextPlugin\n //@ts-expect-error ts being dumb\n ErrorBoundary={ErrorBoundaryComponent}\n contentEditable={\n <div className=\"editor-scroller\">\n <div className=\"editor\" ref={onRef}>\n <LexicalContentEditable />\n </div>\n </div>\n }\n placeholder={\n <p className=\"editor-placeholder\">Start typing, or press '/' for commands...</p>\n }\n />\n <OnChangePlugin\n // Selection changes can be ignored here, reducing the\n // frequency that the FieldComponent and Payload receive updates.\n // Selection changes are only needed if you are saving selection state\n ignoreSelectionChange\n onChange={(editorState, editor, tags) => {\n // Ignore any onChange event triggered by focus only\n if (!tags.has('focus') || tags.size > 1) {\n if (onChange != null) onChange(editorState, editor, tags)\n }\n }}\n />\n {floatingAnchorElem && (\n <React.Fragment>\n {!isSmallWidthViewport && editor.isEditable() && (\n <React.Fragment>\n <DraggableBlockPlugin anchorElem={floatingAnchorElem} />\n <AddBlockHandlePlugin anchorElem={floatingAnchorElem} />\n </React.Fragment>\n )}\n {editorConfig.features.plugins.map((plugin) => {\n if (\n plugin.position === 'floatingAnchorElem' &&\n !(plugin.desktopOnly === true && isSmallWidthViewport)\n ) {\n return (\n <EditorPlugin anchorElem={floatingAnchorElem} key={plugin.key} plugin={plugin} />\n )\n }\n })}\n {editor.isEditable() && (\n <React.Fragment>\n <FloatingSelectToolbarPlugin anchorElem={floatingAnchorElem} />\n <SlashMenuPlugin anchorElem={floatingAnchorElem} />\n </React.Fragment>\n )}\n </React.Fragment>\n )}\n {editor.isEditable() && (\n <React.Fragment>\n <HistoryPlugin />\n {editorConfig?.features?.markdownTransformers?.length > 0 && <MarkdownShortcutPlugin />}\n </React.Fragment>\n )}\n\n <TabIndentationPlugin />\n {editorConfig.features.plugins.map((plugin) => {\n if (plugin.position === 'normal') {\n return <EditorPlugin key={plugin.key} plugin={plugin} />\n }\n })}\n {editorConfig.features.plugins.map((plugin) => {\n if (plugin.position === 'bottom') {\n return <EditorPlugin key={plugin.key} plugin={plugin} />\n }\n })}\n </React.Fragment>\n )\n}\n"],"names":["useLexicalComposerContext","LexicalErrorBoundary","HistoryPlugin","OnChangePlugin","RichTextPlugin","TabIndentationPlugin","React","useEffect","useState","EditorPlugin","FloatingSelectToolbarPlugin","MarkdownShortcutPlugin","SlashMenuPlugin","AddBlockHandlePlugin","DraggableBlockPlugin","LexicalContentEditable","LexicalEditor","props","editorConfig","onChange","editor","floatingAnchorElem","setFloatingAnchorElem","onRef","_floatingAnchorElem","isSmallWidthViewport","setIsSmallWidthViewport","updateViewPortWidth","isNextSmallWidthViewport","window","matchMedia","matches","addEventListener","removeEventListener","ErrorBoundaryComponent","default","Fragment","features","plugins","map","plugin","position","key","ErrorBoundary","contentEditable","div","className","ref","placeholder","p","ignoreSelectionChange","editorState","tags","has","size","isEditable","anchorElem","desktopOnly","markdownTransformers","length"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA;AACA,SAASA,yBAAyB,QAAQ,2CAA0C;AACpF,OAAOC,0BAA0B,yCAAwC;AACzE,SAASC,aAAa,QAAQ,yCAAwC;AACtE,SAASC,cAAc,QAAQ,0CAAyC;AACxE,SAASC,cAAc,QAAQ,0CAAyC;AACxE,SAASC,oBAAoB,QAAQ,gDAA+C;AACpF,YAAYC,WAAW,QAAO;AAC9B,SAASC,SAAS,EAAEC,QAAQ,QAAQ,QAAO;AAI3C,SAASC,YAAY,QAAQ,oBAAmB;AAChD,OAAO,uBAAsB;AAC7B,SAASC,2BAA2B,QAAQ,2CAA0C;AACtF,SAASC,sBAAsB,QAAQ,sCAAqC;AAC5E,SAASC,eAAe,QAAQ,+BAA8B;AAC9D,SA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ditorConfig as LexicalEditorConfig } from 'lexical';
2
2
  import type { FeatureProviderServer } from '../../../features/types.js';
3
- import type { SanitizedServerEditorConfig, ServerEditorConfig } from '../types.js';
3
+ import type { ServerEditorConfig } from '../types.js';
4
4
  export declare const defaultEditorLexicalConfig: LexicalEditorConfig;
5
5
  export declare const defaultEditorFeatures: FeatureProviderServer<unknown, unknown>[];
6
6
  export declare const defaultEditorConfig: ServerEditorConfig;
7
- export declare const defaultSanitizedServerEditorConfig: SanitizedServerEditorConfig;
8
7
  //# sourceMappingURL=default.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"default.d.ts","sourceRoot":"","sources":["../../../../../src/field/lexical/config/server/default.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,IAAI,mBAAmB,EAAE,MAAM,SAAS,CAAA;AAElE,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAA;AACvE,OAAO,KAAK,EAAE,2BAA2B,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAA;AAwBlF,eAAO,MAAM,0BAA0B,EAAE,mBAGxC,CAAA;AAED,eAAO,MAAM,qBAAqB,EAAE,qBAAqB,CAAC,OAAO,EAAE,OAAO,CAAC,EAoB1E,CAAA;AAED,eAAO,MAAM,mBAAmB,EAAE,kBAGjC,CAAA;AAED,eAAO,MAAM,kCAAkC,EAAE,2BACA,CAAA"}
1
+ {"version":3,"file":"default.d.ts","sourceRoot":"","sources":["../../../../../src/field/lexical/config/server/default.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,IAAI,mBAAmB,EAAE,MAAM,SAAS,CAAA;AAElE,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAA;AACvE,OAAO,KAAK,EAA+B,kBAAkB,EAAE,MAAM,aAAa,CAAA;AAuBlF,eAAO,MAAM,0BAA0B,EAAE,mBAGxC,CAAA;AAED,eAAO,MAAM,qBAAqB,EAAE,qBAAqB,CAAC,OAAO,EAAE,OAAO,CAAC,EAoB1E,CAAA;AAED,eAAO,MAAM,mBAAmB,EAAE,kBAGjC,CAAA"}
@@ -18,7 +18,6 @@ import { ParagraphFeature } from '../../../features/paragraph/feature.server.js'
18
18
  import { RelationshipFeature } from '../../../features/relationship/feature.server.js';
19
19
  import { UploadFeature } from '../../../features/upload/feature.server.js';
20
20
  import { LexicalEditorTheme } from '../../theme/EditorTheme.js';
21
- import { sanitizeServerEditorConfig } from './sanitize.js';
22
21
  export const defaultEditorLexicalConfig = {
23
22
  namespace: 'lexical',
24
23
  theme: LexicalEditorTheme
@@ -48,6 +47,5 @@ export const defaultEditorConfig = {
48
47
  features: defaultEditorFeatures,
49
48
  lexical: defaultEditorLexicalConfig
50
49
  };
51
- export const defaultSanitizedServerEditorConfig = sanitizeServerEditorConfig(defaultEditorConfig);
52
50
 
53
51
  //# sourceMappingURL=default.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../src/field/lexical/config/server/default.ts"],"sourcesContent":["import type { EditorConfig as LexicalEditorConfig } from 'lexical'\n\nimport type { FeatureProviderServer } from '../../../features/types.js'\nimport type { SanitizedServerEditorConfig, ServerEditorConfig } from '../types.js'\n\nimport { AlignFeature } from '../../../features/align/feature.server.js'\nimport { BlockQuoteFeature } from '../../../features/blockquote/feature.server.js'\nimport { BoldFeature } from '../../../features/format/bold/feature.server.js'\nimport { InlineCodeFeature } from '../../../features/format/inlinecode/feature.server.js'\nimport { ItalicFeature } from '../../../features/format/italic/feature.server.js'\nimport { StrikethroughFeature } from '../../../features/format/strikethrough/feature.server.js'\nimport { SubscriptFeature } from '../../../features/format/subscript/feature.server.js'\nimport { SuperscriptFeature } from '../../../features/format/superscript/feature.server.js'\nimport { UnderlineFeature } from '../../../features/format/underline/feature.server.js'\nimport { HeadingFeature } from '../../../features/heading/feature.server.js'\nimport { HorizontalRuleFeature } from '../../../features/horizontalrule/feature.server.js'\nimport { IndentFeature } from '../../../features/indent/feature.server.js'\nimport { LinkFeature } from '../../../features/link/feature.server.js'\nimport { CheckListFeature } from '../../../features/lists/checklist/feature.server.js'\nimport { OrderedListFeature } from '../../../features/lists/orderedlist/feature.server.js'\nimport { UnorderedListFeature } from '../../../features/lists/unorderedlist/feature.server.js'\nimport { ParagraphFeature } from '../../../features/paragraph/feature.server.js'\nimport { RelationshipFeature } from '../../../features/relationship/feature.server.js'\nimport { UploadFeature } from '../../../features/upload/feature.server.js'\nimport { LexicalEditorTheme } from '../../theme/EditorTheme.js'\nimport { sanitizeServerEditorConfig } from './sanitize.js'\n\nexport const defaultEditorLexicalConfig: LexicalEditorConfig = {\n namespace: 'lexical',\n theme: LexicalEditorTheme,\n}\n\nexport const defaultEditorFeatures: FeatureProviderServer<unknown, unknown>[] = [\n BoldFeature(),\n ItalicFeature(),\n UnderlineFeature(),\n StrikethroughFeature(),\n SubscriptFeature(),\n SuperscriptFeature(),\n InlineCodeFeature(),\n ParagraphFeature(),\n HeadingFeature(),\n AlignFeature(),\n IndentFeature(),\n UnorderedListFeature(),\n OrderedListFeature(),\n CheckListFeature(),\n LinkFeature(),\n RelationshipFeature(),\n BlockQuoteFeature(),\n UploadFeature(),\n HorizontalRuleFeature(),\n]\n\nexport const defaultEditorConfig: ServerEditorConfig = {\n features: defaultEditorFeatures,\n lexical: defaultEditorLexicalConfig,\n}\n\nexport const defaultSanitizedServerEditorConfig: SanitizedServerEditorConfig =\n sanitizeServerEditorConfig(defaultEditorConfig)\n"],"names":["AlignFeature","BlockQuoteFeature","BoldFeature","InlineCodeFeature","ItalicFeature","StrikethroughFeature","SubscriptFeature","SuperscriptFeature","UnderlineFeature","HeadingFeature","HorizontalRuleFeature","IndentFeature","LinkFeature","CheckListFeature","OrderedListFeature","UnorderedListFeature","ParagraphFeature","RelationshipFeature","UploadFeature","LexicalEditorTheme","sanitizeServerEditorConfig","defaultEditorLexicalConfig","namespace","theme","defaultEditorFeatures","defaultEditorConfig","features","lexical","defaultSanitizedServerEditorConfig"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAKA,SAASA,YAAY,QAAQ,4CAA2C;AACxE,SAASC,iBAAiB,QAAQ,iDAAgD;AAClF,SAASC,WAAW,QAAQ,kDAAiD;AAC7E,SAASC,iBAAiB,QAAQ,wDAAuD;AACzF,SAASC,aAAa,QAAQ,oDAAmD;AACjF,SAASC,oBAAoB,QAAQ,2DAA0D;AAC/F,SAASC,gBAAgB,QAAQ,uDAAsD;AACvF,SAASC,kBAAkB,QAAQ,yDAAwD;AAC3F,SAASC,gBAAgB,QAAQ,uDAAsD;AACvF,SAASC,cAAc,QAAQ,8CAA6C;AAC5E,SAASC,qBAAqB,QAAQ,qDAAoD;AAC1F,SAASC,aAAa,QAAQ,6CAA4C;AAC1E,SAASC,WAAW,QAAQ,2CAA0C;AACtE,SAASC,gBAAgB,QAAQ,sDAAqD;AACtF,SAASC,kBAAkB,QAAQ,wDAAuD;AAC1F,SAASC,oBAAoB,QAAQ,0DAAyD;AAC9F,SAASC,gBAAgB,QAAQ,gDAA+C;AAChF,SAASC,mBAAmB,QAAQ,mDAAkD;AACtF,SAASC,aAAa,QAAQ,6CAA4C;AAC1E,SAASC,kBAAkB,QAAQ,6BAA4B;AAC/D,SAASC,0BAA0B,QAAQ,gBAAe;AAE1D,OAAO,MAAMC,6BAAkD;IAC7DC,WAAW;IACXC,OAAOJ;AACT,EAAC;AAED,OAAO,MAAMK,wBAAmE;IAC9EtB;IACAE;IACAI;IACAH;IACAC;IACAC;IACAJ;IACAa;IACAP;IACAT;IACAW;IACAI;IACAD;IACAD;IACAD;IACAK;IACAhB;IACAiB;IACAR;CACD,CAAA;AAED,OAAO,MAAMe,sBAA0C;IACrDC,UAAUF;IACVG,SAASN;AACX,EAAC;AAED,OAAO,MAAMO,qCACXR,2BAA2BK,qBAAoB"}
1
+ {"version":3,"sources":["../../../../../src/field/lexical/config/server/default.ts"],"sourcesContent":["import type { EditorConfig as LexicalEditorConfig } from 'lexical'\n\nimport type { FeatureProviderServer } from '../../../features/types.js'\nimport type { SanitizedServerEditorConfig, ServerEditorConfig } from '../types.js'\n\nimport { AlignFeature } from '../../../features/align/feature.server.js'\nimport { BlockQuoteFeature } from '../../../features/blockquote/feature.server.js'\nimport { BoldFeature } from '../../../features/format/bold/feature.server.js'\nimport { InlineCodeFeature } from '../../../features/format/inlinecode/feature.server.js'\nimport { ItalicFeature } from '../../../features/format/italic/feature.server.js'\nimport { StrikethroughFeature } from '../../../features/format/strikethrough/feature.server.js'\nimport { SubscriptFeature } from '../../../features/format/subscript/feature.server.js'\nimport { SuperscriptFeature } from '../../../features/format/superscript/feature.server.js'\nimport { UnderlineFeature } from '../../../features/format/underline/feature.server.js'\nimport { HeadingFeature } from '../../../features/heading/feature.server.js'\nimport { HorizontalRuleFeature } from '../../../features/horizontalrule/feature.server.js'\nimport { IndentFeature } from '../../../features/indent/feature.server.js'\nimport { LinkFeature } from '../../../features/link/feature.server.js'\nimport { CheckListFeature } from '../../../features/lists/checklist/feature.server.js'\nimport { OrderedListFeature } from '../../../features/lists/orderedlist/feature.server.js'\nimport { UnorderedListFeature } from '../../../features/lists/unorderedlist/feature.server.js'\nimport { ParagraphFeature } from '../../../features/paragraph/feature.server.js'\nimport { RelationshipFeature } from '../../../features/relationship/feature.server.js'\nimport { UploadFeature } from '../../../features/upload/feature.server.js'\nimport { LexicalEditorTheme } from '../../theme/EditorTheme.js'\n\nexport const defaultEditorLexicalConfig: LexicalEditorConfig = {\n namespace: 'lexical',\n theme: LexicalEditorTheme,\n}\n\nexport const defaultEditorFeatures: FeatureProviderServer<unknown, unknown>[] = [\n BoldFeature(),\n ItalicFeature(),\n UnderlineFeature(),\n StrikethroughFeature(),\n SubscriptFeature(),\n SuperscriptFeature(),\n InlineCodeFeature(),\n ParagraphFeature(),\n HeadingFeature(),\n AlignFeature(),\n IndentFeature(),\n UnorderedListFeature(),\n OrderedListFeature(),\n CheckListFeature(),\n LinkFeature(),\n RelationshipFeature(),\n BlockQuoteFeature(),\n UploadFeature(),\n HorizontalRuleFeature(),\n]\n\nexport const defaultEditorConfig: ServerEditorConfig = {\n features: defaultEditorFeatures,\n lexical: defaultEditorLexicalConfig,\n}\n"],"names":["AlignFeature","BlockQuoteFeature","BoldFeature","InlineCodeFeature","ItalicFeature","StrikethroughFeature","SubscriptFeature","SuperscriptFeature","UnderlineFeature","HeadingFeature","HorizontalRuleFeature","IndentFeature","LinkFeature","CheckListFeature","OrderedListFeature","UnorderedListFeature","ParagraphFeature","RelationshipFeature","UploadFeature","LexicalEditorTheme","defaultEditorLexicalConfig","namespace","theme","defaultEditorFeatures","defaultEditorConfig","features","lexical"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAKA,SAASA,YAAY,QAAQ,4CAA2C;AACxE,SAASC,iBAAiB,QAAQ,iDAAgD;AAClF,SAASC,WAAW,QAAQ,kDAAiD;AAC7E,SAASC,iBAAiB,QAAQ,wDAAuD;AACzF,SAASC,aAAa,QAAQ,oDAAmD;AACjF,SAASC,oBAAoB,QAAQ,2DAA0D;AAC/F,SAASC,gBAAgB,QAAQ,uDAAsD;AACvF,SAASC,kBAAkB,QAAQ,yDAAwD;AAC3F,SAASC,gBAAgB,QAAQ,uDAAsD;AACvF,SAASC,cAAc,QAAQ,8CAA6C;AAC5E,SAASC,qBAAqB,QAAQ,qDAAoD;AAC1F,SAASC,aAAa,QAAQ,6CAA4C;AAC1E,SAASC,WAAW,QAAQ,2CAA0C;AACtE,SAASC,gBAAgB,QAAQ,sDAAqD;AACtF,SAASC,kBAAkB,QAAQ,wDAAuD;AAC1F,SAASC,oBAAoB,QAAQ,0DAAyD;AAC9F,SAASC,gBAAgB,QAAQ,gDAA+C;AAChF,SAASC,mBAAmB,QAAQ,mDAAkD;AACtF,SAASC,aAAa,QAAQ,6CAA4C;AAC1E,SAASC,kBAAkB,QAAQ,6BAA4B;AAE/D,OAAO,MAAMC,6BAAkD;IAC7DC,WAAW;IACXC,OAAOH;AACT,EAAC;AAED,OAAO,MAAMI,wBAAmE;IAC9ErB;IACAE;IACAI;IACAH;IACAC;IACAC;IACAJ;IACAa;IACAP;IACAT;IACAW;IACAI;IACAD;IACAD;IACAD;IACAK;IACAhB;IACAiB;IACAR;CACD,CAAA;AAED,OAAO,MAAMc,sBAA0C;IACrDC,UAAUF;IACVG,SAASN;AACX,EAAC"}
@@ -1,7 +1,9 @@
1
+ import type { SanitizedConfig } from 'payload/config';
1
2
  import type { FeatureProviderServer, ResolvedServerFeatureMap } from '../../../features/types.js';
2
3
  import type { ServerEditorConfig } from '../types.js';
3
4
  export declare function sortFeaturesForOptimalLoading(featureProviders: FeatureProviderServer<unknown, unknown>[]): FeatureProviderServer<unknown, unknown>[];
4
- export declare function loadFeatures({ unSanitizedEditorConfig, }: {
5
+ export declare function loadFeatures({ config, unSanitizedEditorConfig, }: {
6
+ config: SanitizedConfig;
5
7
  unSanitizedEditorConfig: ServerEditorConfig;
6
- }): ResolvedServerFeatureMap;
8
+ }): Promise<ResolvedServerFeatureMap>;
7
9
  //# sourceMappingURL=loader.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"loader.d.ts","sourceRoot":"","sources":["../../../../../src/field/lexical/config/server/loader.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,qBAAqB,EACrB,wBAAwB,EAEzB,MAAM,4BAA4B,CAAA;AACnC,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAA;AA8FrD,wBAAgB,6BAA6B,CAC3C,gBAAgB,EAAE,qBAAqB,CAAC,OAAO,EAAE,OAAO,CAAC,EAAE,GAC1D,qBAAqB,CAAC,OAAO,EAAE,OAAO,CAAC,EAAE,CAE3C;AAED,wBAAgB,YAAY,CAAC,EAC3B,uBAAuB,GACxB,EAAE;IACD,uBAAuB,EAAE,kBAAkB,CAAA;CAC5C,GAAG,wBAAwB,CA8E3B"}
1
+ {"version":3,"file":"loader.d.ts","sourceRoot":"","sources":["../../../../../src/field/lexical/config/server/loader.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAU,eAAe,EAAE,MAAM,gBAAgB,CAAA;AAE7D,OAAO,KAAK,EACV,qBAAqB,EACrB,wBAAwB,EAEzB,MAAM,4BAA4B,CAAA;AACnC,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAA;AA8FrD,wBAAgB,6BAA6B,CAC3C,gBAAgB,EAAE,qBAAqB,CAAC,OAAO,EAAE,OAAO,CAAC,EAAE,GAC1D,qBAAqB,CAAC,OAAO,EAAE,OAAO,CAAC,EAAE,CAE3C;AAED,wBAAsB,YAAY,CAAC,EACjC,MAAM,EACN,uBAAuB,GACxB,EAAE;IACD,MAAM,EAAE,eAAe,CAAA;IACvB,uBAAuB,EAAE,kBAAkB,CAAA;CAC5C,GAAG,OAAO,CAAC,wBAAwB,CAAC,CA+EpC"}
@@ -57,7 +57,7 @@ function visit(graph, key, visited, stack, currentPath = []) {
57
57
  export function sortFeaturesForOptimalLoading(featureProviders) {
58
58
  return topologicallySortFeatures(featureProviders);
59
59
  }
60
- export function loadFeatures({ unSanitizedEditorConfig }) {
60
+ export async function loadFeatures({ config, unSanitizedEditorConfig }) {
61
61
  // First remove all duplicate features. The LAST feature with a given key wins.
62
62
  unSanitizedEditorConfig.features = unSanitizedEditorConfig.features.reverse().filter((f, i, arr)=>{
63
63
  const firstIndex = arr.findIndex((f2)=>f2.key === f.key);
@@ -97,7 +97,8 @@ export function loadFeatures({ unSanitizedEditorConfig }) {
97
97
  }
98
98
  }
99
99
  }
100
- const feature = featureProvider.feature({
100
+ const feature = await featureProvider.feature({
101
+ config,
101
102
  featureProviderMap,
102
103
  resolvedFeatures,
103
104
  unSanitizedEditorConfig
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../src/field/lexical/config/server/loader.ts"],"sourcesContent":["import type {\n FeatureProviderServer,\n ResolvedServerFeatureMap,\n ServerFeatureProviderMap,\n} from '../../../features/types.js'\nimport type { ServerEditorConfig } from '../types.js'\n\ntype DependencyGraph = {\n [key: string]: {\n dependencies: string[]\n dependenciesPriority: string[]\n dependenciesSoft: string[]\n featureProvider: FeatureProviderServer<unknown, unknown>\n }\n}\n\nfunction createDependencyGraph(\n featureProviders: FeatureProviderServer<unknown, unknown>[],\n): DependencyGraph {\n const graph: DependencyGraph = {}\n for (const fp of featureProviders) {\n graph[fp.key] = {\n dependencies: fp.dependencies || [],\n dependenciesPriority: fp.dependenciesPriority || [],\n dependenciesSoft: fp.dependenciesSoft || [],\n featureProvider: fp,\n }\n }\n return graph\n}\n\nfunction topologicallySortFeatures(\n featureProviders: FeatureProviderServer<unknown, unknown>[],\n): FeatureProviderServer<unknown, unknown>[] {\n const graph = createDependencyGraph(featureProviders)\n const visited: { [key: string]: boolean } = {}\n const stack: FeatureProviderServer<unknown, unknown>[] = []\n\n for (const key in graph) {\n if (!visited[key]) {\n visit(graph, key, visited, stack)\n }\n }\n\n return stack.reverse()\n}\n\nfunction visit(\n graph: DependencyGraph,\n key: string,\n visited: { [key: string]: boolean },\n stack: FeatureProviderServer<unknown, unknown>[],\n currentPath: string[] = [],\n) {\n if (!graph[key]) {\n throw new Error(`Feature key ${key} is not present in the dependency graph.`)\n }\n\n if (currentPath.includes(key)) {\n throw new Error(`Circular dependency detected: ${currentPath.join(' -> ')} -> ${key}`)\n }\n\n if (visited[key]) {\n return\n }\n\n visited[key] = true\n currentPath.push(key)\n\n // First process the hard priority dependencies\n for (const dep of graph[key].dependenciesPriority) {\n if (!visited[dep]) {\n visit(graph, dep, visited, stack, currentPath)\n }\n }\n\n // Then process the normal dependencies, but make sure to not violate hard dependencies\n for (const dep of graph[key].dependencies) {\n if (!visited[dep] && !graph[key].dependenciesPriority.includes(dep)) {\n visit(graph, dep, visited, stack, currentPath)\n }\n }\n\n // Then process the soft dependencies. Make sure to not violate hard and normal dependencies.\n for (const dep of graph[key].dependenciesSoft) {\n if (\n graph[dep] &&\n !visited[dep] &&\n !graph[key].dependenciesPriority.includes(dep) &&\n !graph[key].dependencies.includes(dep)\n ) {\n visit(graph, dep, visited, stack, currentPath)\n }\n }\n\n stack.push(graph[key].featureProvider)\n currentPath.pop()\n}\n\nexport function sortFeaturesForOptimalLoading(\n featureProviders: FeatureProviderServer<unknown, unknown>[],\n): FeatureProviderServer<unknown, unknown>[] {\n return topologicallySortFeatures(featureProviders)\n}\n\nexport function loadFeatures({\n unSanitizedEditorConfig,\n}: {\n unSanitizedEditorConfig: ServerEditorConfig\n}): ResolvedServerFeatureMap {\n // First remove all duplicate features. The LAST feature with a given key wins.\n unSanitizedEditorConfig.features = unSanitizedEditorConfig.features\n .reverse()\n .filter((f, i, arr) => {\n const firstIndex = arr.findIndex((f2) => f2.key === f.key)\n return firstIndex === i\n })\n .reverse()\n\n unSanitizedEditorConfig.features = sortFeaturesForOptimalLoading(unSanitizedEditorConfig.features)\n\n const featureProviderMap: ServerFeatureProviderMap = new Map(\n unSanitizedEditorConfig.features.map(\n (f) => [f.key, f] as [string, FeatureProviderServer<unknown, unknown>],\n ),\n )\n\n const resolvedFeatures: ResolvedServerFeatureMap = new Map()\n\n // Make sure all dependencies declared in the respective features exist\n let loaded = 0\n for (const featureProvider of unSanitizedEditorConfig.features) {\n if (!featureProvider.key) {\n throw new Error(\n `A Feature you've added does not have a key. Please add a key to the feature. This is used to uniquely identify the feature.`,\n )\n }\n if (featureProvider.dependencies?.length) {\n for (const dependencyKey of featureProvider.dependencies) {\n const found = unSanitizedEditorConfig.features.find((f) => f.key === dependencyKey)\n if (!found) {\n throw new Error(\n `Feature ${featureProvider.key} has a dependency ${dependencyKey} which does not exist.`,\n )\n }\n }\n }\n\n if (featureProvider.dependenciesPriority?.length) {\n for (const priorityDependencyKey of featureProvider.dependenciesPriority) {\n // look in the resolved features instead of the editorConfig.features, as a dependency requires the feature to be loaded before it, contrary to a soft-dependency\n const found = resolvedFeatures.get(priorityDependencyKey)\n if (!found) {\n const existsInEditorConfig = unSanitizedEditorConfig.features.find(\n (f) => f.key === priorityDependencyKey,\n )\n if (!existsInEditorConfig) {\n throw new Error(\n `Feature ${featureProvider.key} has a priority dependency ${priorityDependencyKey} which does not exist.`,\n )\n } else {\n throw new Error(\n `Feature ${featureProvider.key} has a priority dependency ${priorityDependencyKey} which is not loaded before it.`,\n )\n }\n }\n }\n }\n\n const feature = featureProvider.feature({\n featureProviderMap,\n resolvedFeatures,\n unSanitizedEditorConfig,\n })\n resolvedFeatures.set(featureProvider.key, {\n ...feature,\n dependencies: featureProvider.dependencies,\n dependenciesPriority: featureProvider.dependenciesPriority,\n dependenciesSoft: featureProvider.dependenciesSoft,\n key: featureProvider.key,\n order: loaded,\n })\n\n loaded++\n }\n\n return resolvedFeatures\n}\n"],"names":["createDependencyGraph","featureProviders","graph","fp","key","dependencies","dependenciesPriority","dependenciesSoft","featureProvider","topologicallySortFeatures","visited","stack","visit","reverse","currentPath","Error","includes","join","push","dep","pop","sortFeaturesForOptimalLoading","loadFeatures","unSanitizedEditorConfig","features","filter","f","i","arr","firstIndex","findIndex","f2","featureProviderMap","Map","map","resolvedFeatures","loaded","length","dependencyKey","found","find","priorityDependencyKey","get","existsInEditorConfig","feature","set","order"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAgBA,SAASA,sBACPC,gBAA2D;IAE3D,MAAMC,QAAyB,CAAC;IAChC,KAAK,MAAMC,MAAMF,iBAAkB;QACjCC,KAAK,CAACC,GAAGC,GAAG,CAAC,GAAG;YACdC,cAAcF,GAAGE,YAAY,IAAI,EAAE;YACnCC,sBAAsBH,GAAGG,oBAAoB,IAAI,EAAE;YACnDC,kBAAkBJ,GAAGI,gBAAgB,IAAI,EAAE;YAC3CC,iBAAiBL;QACnB;IACF;IACA,OAAOD;AACT;AAEA,SAASO,0BACPR,gBAA2D;IAE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BACrE,IAAI,CAACC,OAAO;oBACV,MAAM,IAAIxB,MACR,CAAC,QAAQ,EAAEP,gBAAgBJ,GAAG,CAAC,kBAAkB,EAAEkC,cAAc,sBAAsB,CAAC;gBAE5F;YACF;QACF;QAEA,IAAI9B,gBAAgBF,oBAAoB,EAAE+B,QAAQ;YAChD,KAAK,MAAMI,yBAAyBjC,gBAAgBF,oBAAoB,CAAE;gBACxE,iKAAiK;gBACjK,MAAMiC,QAAQJ,iBAAiBO,GAAG,CAACD;gBACnC,IAAI,CAACF,OAAO;oBACV,MAAMI,uBAAuBpB,wBAAwBC,QAAQ,CAACgB,IAAI,CAChE,CAACd,IAAMA,EAAEtB,GAAG,KAAKqC;oBAEnB,IAAI,CAACE,sBAAsB;wBACzB,MAAM,IAAI5B,MACR,CAAC,QAAQ,EAAEP,gBAAgBJ,GAAG,CAAC,2BAA2B,EAAEqC,sBAAsB,sBAAsB,CAAC;oBAE7G,OAAO;wBACL,MAAM,IAAI1B,MACR,CAAC,QAAQ,EAAEP,gBAAgBJ,GAAG,CAAC,2BAA2B,EAAEqC,sBAAsB,+BAA+B,CAAC;oBAEtH;gBACF;YACF;QACF;QAEA,MAAMG,UAAUpC,gBAAgBoC,OAAO,CAAC;YACtCZ;YACAG;YACAZ;QACF;QACAY,iBAAiBU,GAAG,CAACrC,gBAAgBJ,GAAG,EAAE;YACxC,GAAGwC,OAAO;YACVvC,cAAcG,gBAAgBH,YAAY;YAC1CC,sBAAsBE,gBAAgBF,oBAAoB;YAC1DC,kBAAkBC,gBAAgBD,gBAAgB;YAClDH,KAAKI,gBAAgBJ,GAAG;YACxB0C,OAAOV;QACT;QAEAA;IACF;IAEA,OAAOD;AACT"}
1
+ {"version":3,"sources":["../../../../../src/field/lexical/config/server/loader.ts"],"sourcesContent":["import type { Config, SanitizedConfig } from 'payload/config'\n\nimport type {\n FeatureProviderServer,\n ResolvedServerFeatureMap,\n ServerFeatureProviderMap,\n} from '../../../features/types.js'\nimport type { ServerEditorConfig } from '../types.js'\n\ntype DependencyGraph = {\n [key: string]: {\n dependencies: string[]\n dependenciesPriority: string[]\n dependenciesSoft: string[]\n featureProvider: FeatureProviderServer<unknown, unknown>\n }\n}\n\nfunction createDependencyGraph(\n featureProviders: FeatureProviderServer<unknown, unknown>[],\n): DependencyGraph {\n const graph: DependencyGraph = {}\n for (const fp of featureProviders) {\n graph[fp.key] = {\n dependencies: fp.dependencies || [],\n dependenciesPriority: fp.dependenciesPriority || [],\n dependenciesSoft: fp.dependenciesSoft || [],\n featureProvider: fp,\n }\n }\n return graph\n}\n\nfunction topologicallySortFeatures(\n featureProviders: FeatureProviderServer<unknown, unknown>[],\n): FeatureProviderServer<unknown, unknown>[] {\n const graph = createDependencyGraph(featureProviders)\n const visited: { [key: string]: boolean } = {}\n const stack: FeatureProviderServer<unknown, unknown>[] = []\n\n for (const key in graph) {\n if (!visited[key]) {\n visit(graph, key, visited, stack)\n }\n }\n\n return stack.reverse()\n}\n\nfunction visit(\n graph: DependencyGraph,\n key: string,\n visited: { [key: string]: boolean },\n stack: FeatureProviderServer<unknown, unknown>[],\n currentPath: string[] = [],\n) {\n if (!graph[key]) {\n throw new Error(`Feature key ${key} is not present in the dependency graph.`)\n }\n\n if (currentPath.includes(key)) {\n throw new Error(`Circular dependency detected: ${currentPath.join(' -> ')} -> ${key}`)\n }\n\n if (visited[key]) {\n return\n }\n\n visited[key] = true\n currentPath.push(key)\n\n // First process the hard priority dependencies\n for (const dep of graph[key].dependenciesPriority) {\n if (!visited[dep]) {\n visit(graph, dep, visited, stack, currentPath)\n }\n }\n\n // Then process the normal dependencies, but make sure to not violate hard dependencies\n for (const dep of graph[key].dependencies) {\n if (!visited[dep] && !graph[key].dependenciesPriority.includes(dep)) {\n visit(graph, dep, visited, stack, currentPath)\n }\n }\n\n // Then process the soft dependencies. Make sure to not violate hard and normal dependencies.\n for (const dep of graph[key].dependenciesSoft) {\n if (\n graph[dep] &&\n !visited[dep] &&\n !graph[key].dependenciesPriority.includes(dep) &&\n !graph[key].dependencies.includes(dep)\n ) {\n visit(graph, dep, visited, stack, currentPath)\n }\n }\n\n stack.push(graph[key].featureProvider)\n currentPath.pop()\n}\n\nexport function sortFeaturesForOptimalLoading(\n featureProviders: FeatureProviderServer<unknown, unknown>[],\n): FeatureProviderServer<unknown, unknown>[] {\n return topologicallySortFeatures(featureProviders)\n}\n\nexport async function loadFeatures({\n config,\n unSanitizedEditorConfig,\n}: {\n config: SanitizedConfig\n unSanitizedEditorConfig: ServerEditorConfig\n}): Promise<ResolvedServerFeatureMap> {\n // First remove all duplicate features. The LAST feature with a given key wins.\n unSanitizedEditorConfig.features = unSanitizedEditorConfig.features\n .reverse()\n .filter((f, i, arr) => {\n const firstIndex = arr.findIndex((f2) => f2.key === f.key)\n return firstIndex === i\n })\n .reverse()\n\n unSanitizedEditorConfig.features = sortFeaturesForOptimalLoading(unSanitizedEditorConfig.features)\n\n const featureProviderMap: ServerFeatureProviderMap = new Map(\n unSanitizedEditorConfig.features.map(\n (f) => [f.key, f] as [string, FeatureProviderServer<unknown, unknown>],\n ),\n )\n\n const resolvedFeatures: ResolvedServerFeatureMap = new Map()\n\n // Make sure all dependencies declared in the respective features exist\n let loaded = 0\n for (const featureProvider of unSanitizedEditorConfig.features) {\n if (!featureProvider.key) {\n throw new Error(\n `A Feature you've added does not have a key. Please add a key to the feature. This is used to uniquely identify the feature.`,\n )\n }\n if (featureProvider.dependencies?.length) {\n for (const dependencyKey of featureProvider.dependencies) {\n const found = unSanitizedEditorConfig.features.find((f) => f.key === dependencyKey)\n if (!found) {\n throw new Error(\n `Feature ${featureProvider.key} has a dependency ${dependencyKey} which does not exist.`,\n )\n }\n }\n }\n\n if (featureProvider.dependenciesPriority?.length) {\n for (const priorityDependencyKey of featureProvider.dependenciesPriority) {\n // look in the resolved features instead of the editorConfig.features, as a dependency requires the feature to be loaded before it, contrary to a soft-dependency\n const found = resolvedFeatures.get(priorityDependencyKey)\n if (!found) {\n const existsInEditorConfig = unSanitizedEditorConfig.features.find(\n (f) => f.key === priorityDependencyKey,\n )\n if (!existsInEditorConfig) {\n throw new Error(\n `Feature ${featureProvider.key} has a priority dependency ${priorityDependencyKey} which does not exist.`,\n )\n } else {\n throw new Error(\n `Feature ${featureProvider.key} has a priority dependency ${priorityDependencyKey} which is not loaded before it.`,\n )\n }\n }\n }\n }\n\n const feature = await featureProvider.feature({\n config,\n featureProviderMap,\n resolvedFeatures,\n unSanitizedEditorConfig,\n })\n resolvedFeatures.set(featureProvider.key, {\n ...feature,\n dependencies: featureProvider.dependencies,\n dependenciesPriority: featureProvider.dependenciesPriority,\n dependenciesSoft: featureProvider.dependenciesSoft,\n key: featureProvider.key,\n order: loaded,\n })\n\n loaded++\n }\n\n return resolvedFeatures\n}\n"],"names":["createDependencyGraph","featureProviders","graph","fp","key","dependencies","dependenciesPriority","dependenciesSoft","featureProvider","topologicallySortFeatures","visited","stack","visit","reverse","currentPath","Error","includes","join","push","dep","pop","sortFeaturesForOptimalLoading","loadFeatures","config","unSanitizedEditorConfig","features","filter","f","i","arr","firstIndex","findIndex","f2","featureProviderMap","Map","map","resolvedFeatures","loaded","length","dependencyKey","found","find","priorityDependencyKey","get","existsInEditorConfig","feature","set","order"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAkBA,SAASA,sBACPC,gBAA2D;IAE3D,MAAMC,QAAyB,CAAC;IAChC,KAAK,MAAMC,MAAMF,iBAAkB;QACjCC,KAAK,CAACC,GAAGC,GAAG,CAAC,GAAG;YACdC,cAAcF,GAAGE,YAAY,IAAI,EAAE;YACnCC,sBAAsBH,GAAGG,oBAAoB,IAAI,EAAE;YACnDC,kBAAkBJ,GAAGI,gBAAgB,IAAI,EAAE;YAC3CC,iBAAiBL;QACnB;IACF;IACA,OAAOD;AACT;AAEA,SAASO,0BACPR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AMA,EAAEvB,GAAG,KAAKmC;gBACrE,IAAI,CAACC,OAAO;oBACV,MAAM,IAAIzB,MACR,CAAC,QAAQ,EAAEP,gBAAgBJ,GAAG,CAAC,kBAAkB,EAAEmC,cAAc,sBAAsB,CAAC;gBAE5F;YACF;QACF;QAEA,IAAI/B,gBAAgBF,oBAAoB,EAAEgC,QAAQ;YAChD,KAAK,MAAMI,yBAAyBlC,gBAAgBF,oBAAoB,CAAE;gBACxE,iKAAiK;gBACjK,MAAMkC,QAAQJ,iBAAiBO,GAAG,CAACD;gBACnC,IAAI,CAACF,OAAO;oBACV,MAAMI,uBAAuBpB,wBAAwBC,QAAQ,CAACgB,IAAI,CAChE,CAACd,IAAMA,EAAEvB,GAAG,KAAKsC;oBAEnB,IAAI,CAACE,sBAAsB;wBACzB,MAAM,IAAI7B,MACR,CAAC,QAAQ,EAAEP,gBAAgBJ,GAAG,CAAC,2BAA2B,EAAEsC,sBAAsB,sBAAsB,CAAC;oBAE7G,OAAO;wBACL,MAAM,IAAI3B,MACR,CAAC,QAAQ,EAAEP,gBAAgBJ,GAAG,CAAC,2BAA2B,EAAEsC,sBAAsB,+BAA+B,CAAC;oBAEtH;gBACF;YACF;QACF;QAEA,MAAMG,UAAU,MAAMrC,gBAAgBqC,OAAO,CAAC;YAC5CtB;YACAU;YACAG;YACAZ;QACF;QACAY,iBAAiBU,GAAG,CAACtC,gBAAgBJ,GAAG,EAAE;YACxC,GAAGyC,OAAO;YACVxC,cAAcG,gBAAgBH,YAAY;YAC1CC,sBAAsBE,gBAAgBF,oBAAoB;YAC1DC,kBAAkBC,gBAAgBD,gBAAgB;YAClDH,KAAKI,gBAAgBJ,GAAG;YACxB2C,OAAOV;QACT;QAEAA;IACF;IAEA,OAAOD;AACT"}
@@ -1,5 +1,6 @@
1
+ import type { SanitizedConfig } from 'payload/config';
1
2
  import type { ResolvedServerFeatureMap, SanitizedServerFeatures } from '../../../features/types.js';
2
3
  import type { SanitizedServerEditorConfig, ServerEditorConfig } from '../types.js';
3
4
  export declare const sanitizeServerFeatures: (features: ResolvedServerFeatureMap) => SanitizedServerFeatures;
4
- export declare function sanitizeServerEditorConfig(editorConfig: ServerEditorConfig): SanitizedServerEditorConfig;
5
+ export declare function sanitizeServerEditorConfig(editorConfig: ServerEditorConfig, config: SanitizedConfig): Promise<SanitizedServerEditorConfig>;
5
6
  //# sourceMappingURL=sanitize.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"sanitize.d.ts","sourceRoot":"","sources":["../../../../../src/field/lexical/config/server/sanitize.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,wBAAwB,EAAE,uBAAuB,EAAE,MAAM,4BAA4B,CAAA;AACnG,OAAO,KAAK,EAAE,2BAA2B,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAA;AAIlF,eAAO,MAAM,sBAAsB,0CAEhC,uBA0EF,CAAA;AAED,wBAAgB,0BAA0B,CACxC,YAAY,EAAE,kBAAkB,GAC/B,2BAA2B,CAU7B"}
1
+ {"version":3,"file":"sanitize.d.ts","sourceRoot":"","sources":["../../../../../src/field/lexical/config/server/sanitize.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAU,eAAe,EAAE,MAAM,gBAAgB,CAAA;AAE7D,OAAO,KAAK,EAAE,wBAAwB,EAAE,uBAAuB,EAAE,MAAM,4BAA4B,CAAA;AACnG,OAAO,KAAK,EAAE,2BAA2B,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAA;AAIlF,eAAO,MAAM,sBAAsB,0CAEhC,uBA0EF,CAAA;AAED,wBAAsB,0BAA0B,CAC9C,YAAY,EAAE,kBAAkB,EAChC,MAAM,EAAE,eAAe,GACtB,OAAO,CAAC,2BAA2B,CAAC,CAWtC"}
@@ -65,8 +65,9 @@ export const sanitizeServerFeatures = (features)=>{
65
65
  });
66
66
  return sanitized;
67
67
  };
68
- export function sanitizeServerEditorConfig(editorConfig) {
69
- const resolvedFeatureMap = loadFeatures({
68
+ export async function sanitizeServerEditorConfig(editorConfig, config) {
69
+ const resolvedFeatureMap = await loadFeatures({
70
+ config,
70
71
  unSanitizedEditorConfig: editorConfig
71
72
  });
72
73
  return {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../src/field/lexical/config/server/sanitize.ts"],"sourcesContent":["import type { ResolvedServerFeatureMap, SanitizedServerFeatures } from '../../../features/types.js'\nimport type { SanitizedServerEditorConfig, ServerEditorConfig } from '../types.js'\n\nimport { loadFeatures } from './loader.js'\n\nexport const sanitizeServerFeatures = (\n features: ResolvedServerFeatureMap,\n): SanitizedServerFeatures => {\n const sanitized: SanitizedServerFeatures = {\n converters: {\n html: [],\n },\n enabledFeatures: [],\n\n generatedTypes: {\n modifyOutputSchemas: [],\n },\n hooks: {\n afterChange: new Map(),\n afterRead: new Map(),\n beforeChange: new Map(),\n beforeDuplicate: new Map(),\n beforeValidate: new Map(),\n },\n markdownTransformers: [],\n nodes: [],\n populationPromises: new Map(),\n\n validations: new Map(),\n }\n\n if (!features?.size) {\n return sanitized\n }\n\n features.forEach((feature) => {\n if (feature?.generatedTypes?.modifyOutputSchema) {\n sanitized.generatedTypes.modifyOutputSchemas.push(feature.generatedTypes.modifyOutputSchema)\n }\n\n if (feature.nodes?.length) {\n sanitized.nodes = sanitized.nodes.concat(feature.nodes)\n feature.nodes.forEach((node) => {\n const nodeType = 'with' in node.node ? node.node.replace.getType() : node.node.getType() // TODO: Idk if this works for node replacements\n if (node?.populationPromises?.length) {\n sanitized.populationPromises.set(nodeType, node.populationPromises)\n }\n if (node?.validations?.length) {\n sanitized.validations.set(nodeType, node.validations)\n }\n if (node?.converters?.html) {\n sanitized.converters.html.push(node.converters.html)\n }\n if (node?.hooks?.afterChange) {\n sanitized.hooks.afterChange.set(nodeType, node.hooks.afterChange)\n }\n if (node?.hooks?.afterRead) {\n sanitized.hooks.afterRead.set(nodeType, node.hooks.afterRead)\n }\n if (node?.hooks?.beforeChange) {\n sanitized.hooks.beforeChange.set(nodeType, node.hooks.beforeChange)\n }\n if (node?.hooks?.beforeDuplicate) {\n sanitized.hooks.beforeDuplicate.set(nodeType, node.hooks.beforeDuplicate)\n }\n if (node?.hooks?.beforeValidate) {\n sanitized.hooks.beforeValidate.set(nodeType, node.hooks.beforeValidate)\n }\n })\n }\n\n if (feature.markdownTransformers?.length) {\n sanitized.markdownTransformers = sanitized.markdownTransformers.concat(\n feature.markdownTransformers,\n )\n }\n\n sanitized.enabledFeatures.push(feature.key)\n })\n\n return sanitized\n}\n\nexport function sanitizeServerEditorConfig(\n editorConfig: ServerEditorConfig,\n): SanitizedServerEditorConfig {\n const resolvedFeatureMap = loadFeatures({\n unSanitizedEditorConfig: editorConfig,\n })\n\n return {\n features: sanitizeServerFeatures(resolvedFeatureMap),\n lexical: editorConfig.lexical,\n resolvedFeatureMap,\n }\n}\n"],"names":["loadFeatures","sanitizeServerFeatures","features","sanitized","converters","html","enabledFeatures","generatedTypes","modifyOutputSchemas","hooks","afterChange","Map","afterRead","beforeChange","beforeDuplicate","beforeValidate","markdownTransformers","nodes","populationPromises","validations","size","forEach","feature","modifyOutputSchema","push","length","concat","node","nodeType","replace","getType","set","key","sanitizeServerEditorConfig","editorConfig","resolvedFeatureMap","unSanitizedEditorConfig","lexical"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAGA,SAASA,YAAY,QAAQ,cAAa;AAE1C,OAAO,MAAMC,yBAAyB,CACpCC;IAEA,MAAMC,YAAqC;QACzCC,YAAY;YACVC,MAAM,EAAE;QACV;QACAC,iBAAiB,EAAE;QAEnBC,gBAAgB;YACdC,qBAAqB,EAAE;QACzB;QACAC,OAAO;YACLC,aAAa,IAAIC;YACjBC,WAAW,IAAID;YACfE,cAAc,IAAIF;YAClBG,iBAAiB,IAAIH;YACrBI,gBAAgB,IAAIJ;QACtB;QACAK,sBAAsB,EAAE;QACxBC,OAAO,EAAE;QACTC,oBA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AAG,CAACH,UAAUD,KAAKlB,KAAK,CAACI,YAAY;gBACpE;gBACA,IAAIc,MAAMlB,OAAOK,iBAAiB;oBAChCX,UAAUM,KAAK,CAACK,eAAe,CAACiB,GAAG,CAACH,UAAUD,KAAKlB,KAAK,CAACK,eAAe;gBAC1E;gBACA,IAAIa,MAAMlB,OAAOM,gBAAgB;oBAC/BZ,UAAUM,KAAK,CAACM,cAAc,CAACgB,GAAG,CAACH,UAAUD,KAAKlB,KAAK,CAACM,cAAc;gBACxE;YACF;QACF;QAEA,IAAIO,QAAQN,oBAAoB,EAAES,QAAQ;YACxCtB,UAAUa,oBAAoB,GAAGb,UAAUa,oBAAoB,CAACU,MAAM,CACpEJ,QAAQN,oBAAoB;QAEhC;QAEAb,UAAUG,eAAe,CAACkB,IAAI,CAACF,QAAQU,GAAG;IAC5C;IAEA,OAAO7B;AACT,EAAC;AAED,OAAO,SAAS8B,2BACdC,YAAgC;IAEhC,MAAMC,qBAAqBnC,aAAa;QACtCoC,yBAAyBF;IAC3B;IAEA,OAAO;QACLhC,UAAUD,uBAAuBkC;QACjCE,SAASH,aAAaG,OAAO;QAC7BF;IACF;AACF"}
1
+ {"version":3,"sources":["../../../../../src/field/lexical/config/server/sanitize.ts"],"sourcesContent":["import type { Config, SanitizedConfig } from 'payload/config'\n\nimport type { ResolvedServerFeatureMap, SanitizedServerFeatures } from '../../../features/types.js'\nimport type { SanitizedServerEditorConfig, ServerEditorConfig } from '../types.js'\n\nimport { loadFeatures } from './loader.js'\n\nexport const sanitizeServerFeatures = (\n features: ResolvedServerFeatureMap,\n): SanitizedServerFeatures => {\n const sanitized: SanitizedServerFeatures = {\n converters: {\n html: [],\n },\n enabledFeatures: [],\n\n generatedTypes: {\n modifyOutputSchemas: [],\n },\n hooks: {\n afterChange: new Map(),\n afterRead: new Map(),\n beforeChange: new Map(),\n beforeDuplicate: new Map(),\n beforeValidate: new Map(),\n },\n markdownTransformers: [],\n nodes: [],\n populationPromises: new Map(),\n\n validations: new Map(),\n }\n\n if (!features?.size) {\n return sanitized\n }\n\n features.forEach((feature) => {\n if (feature?.generatedTypes?.modifyOutputSchema) {\n sanitized.generatedTypes.modifyOutputSchemas.push(feature.generatedTypes.modifyOutputSchema)\n }\n\n if (feature.nodes?.length) {\n sanitized.nodes = sanitized.nodes.concat(feature.nodes)\n feature.nodes.forEach((node) => {\n const nodeType = 'with' in node.node ? node.node.replace.getType() : node.node.getType() // TODO: Idk if this works for node replacements\n if (node?.populationPromises?.length) {\n sanitized.populationPromises.set(nodeType, node.populationPromises)\n }\n if (node?.validations?.length) {\n sanitized.validations.set(nodeType, node.validations)\n }\n if (node?.converters?.html) {\n sanitized.converters.html.push(node.converters.html)\n }\n if (node?.hooks?.afterChange) {\n sanitized.hooks.afterChange.set(nodeType, node.hooks.afterChange)\n }\n if (node?.hooks?.afterRead) {\n sanitized.hooks.afterRead.set(nodeType, node.hooks.afterRead)\n }\n if (node?.hooks?.beforeChange) {\n sanitized.hooks.beforeChange.set(nodeType, node.hooks.beforeChange)\n }\n if (node?.hooks?.beforeDuplicate) {\n sanitized.hooks.beforeDuplicate.set(nodeType, node.hooks.beforeDuplicate)\n }\n if (node?.hooks?.beforeValidate) {\n sanitized.hooks.beforeValidate.set(nodeType, node.hooks.beforeValidate)\n }\n })\n }\n\n if (feature.markdownTransformers?.length) {\n sanitized.markdownTransformers = sanitized.markdownTransformers.concat(\n feature.markdownTransformers,\n )\n }\n\n sanitized.enabledFeatures.push(feature.key)\n })\n\n return sanitized\n}\n\nexport async function sanitizeServerEditorConfig(\n editorConfig: ServerEditorConfig,\n config: SanitizedConfig,\n): Promise<SanitizedServerEditorConfig> {\n const resolvedFeatureMap = await loadFeatures({\n config,\n unSanitizedEditorConfig: editorConfig,\n })\n\n return {\n features: sanitizeServerFeatures(resolvedFeatureMap),\n lexical: editorConfig.lexical,\n resolvedFeatureMap,\n }\n}\n"],"names":["loadFeatures","sanitizeServerFeatures","features","sanitized","converters","html","enabledFeatures","generatedTypes","modifyOutputSchemas","hooks","afterChange","Map","afterRead","beforeChange","beforeDuplicate","beforeValidate","markdownTransformers","nodes","populationPromises","validations","size","forEach","feature","modifyOutputSchema","push","length","concat","node","nodeType","replace","getType","set","key","sanitizeServerEditorConfig","editorConfig","config","resolvedFeatureMap","unSanitizedEditorConfig","lexical"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAKA,SAASA,YAAY,QAAQ,cAAa;AAE1C,OAAO,MAAMC,yBAAyB,CACpCC;IAEA,MAAMC,YAAqC;QACzCC,YAAY;YACVC,MAAM,EAAE;QACV;QACAC,iBAAiB,EAAE;QAEnBC,gBAAgB;YACdC,qBAAqB,EAAE;QACzB;QACAC,OAAO;YACLC,aAAa,IAAIC;YACjBC,WAAW,IAAID;YACfE,cAAc,IAAIF;YAClBG,iBAAiB,IAAIH;YACrBI,gBAAgB,IAAIJ;QACtB;QACAK,sBAAsB,EAAE;QACxBC,OAAO,EAAE;QACTC,oBAAoB,IAAIP;QAExBQ,aAAa,IAAIR;IACnB;IAEA,IAAI,CAACT,UAAUkB,MAAM;QACnB,OAAOjB;IACT;IAEAD,SAASmB,OAAO,CAAC,CAACC;QAChB,IAAIA,SAASf,gBAAgBgB,oBAAoB;YAC/CpB,UAAUI,cAAc,CAACC,mBAAmB,CAACgB,IAAI,CAACF,QAAQf,cAAc,CAACgB,kBAAkB;QAC7F;QAEA,IAAID,QAAQL,KAAK,EAAEQ,QAAQ;YACzBtB,UAAUc,KAAK,GAAGd,UAAUc,KAAK,CAACS,MAAM,CAACJ,QAAQL,KAAK;YACtDK,QAAQL,KAAK,CAACI,OAAO,CAAC,CAACM;gBACrB,MAAMC,WAAW,UAAUD,KAAKA,IAAI,GAAGA,KAAKA,IAAI,CAACE,OAAO,CAACC,OAAO,KAAKH,KAAKA,IAAI,CAACG,OAAO,GAAG,gDAAgD;;gBACzI,IAAIH,MAA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ACpBC,YAAgC,EAChCC,MAAuB;IAEvB,MAAMC,qBAAqB,MAAMpC,aAAa;QAC5CmC;QACAE,yBAAyBH;IAC3B;IAEA,OAAO;QACLhC,UAAUD,uBAAuBmC;QACjCE,SAASJ,aAAaI,OAAO;QAC7BF;IACF;AACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/field/lexical/plugins/FloatingSelectToolbar/index.tsx"],"names":[],"mappings":";AAuBA,OAAO,cAAc,CAAA;AAoVrB,wBAAgB,2BAA2B,CAAC,EAC1C,UAA0B,GAC3B,EAAE;IACD,UAAU,CAAC,EAAE,WAAW,CAAA;CACzB,GAAG,GAAG,CAAC,OAAO,GAAG,IAAI,CAGrB"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/field/lexical/plugins/FloatingSelectToolbar/index.tsx"],"names":[],"mappings":";AAuBA,OAAO,cAAc,CAAA;AA2VrB,wBAAgB,2BAA2B,CAAC,EAC1C,UAA0B,GAC3B,EAAE;IACD,UAAU,CAAC,EAAE,WAAW,CAAA;CACzB,GAAG,GAAG,CAAC,OAAO,GAAG,IAAI,CAGrB"}
@@ -54,33 +54,33 @@ function ToolbarSection({ anchorElem, editor, index, section }) {
54
54
  }));
55
55
  }
56
56
  function FloatingSelectToolbar({ anchorElem, editor }) {
57
- const popupCharStylesEditorRef = useRef(null);
57
+ const floatingToolbarRef = useRef(null);
58
58
  const caretRef = useRef(null);
59
59
  const { editorConfig } = useEditorConfigContext();
60
60
  const closeFloatingToolbar = useCallback(()=>{
61
- if (popupCharStylesEditorRef?.current) {
62
- const isOpacityZero = popupCharStylesEditorRef.current.style.opacity === '0';
63
- const isPointerEventsNone = popupCharStylesEditorRef.current.style.pointerEvents === 'none';
61
+ if (floatingToolbarRef?.current) {
62
+ const isOpacityZero = floatingToolbarRef.current.style.opacity === '0';
63
+ const isPointerEventsNone = floatingToolbarRef.current.style.pointerEvents === 'none';
64
64
  if (!isOpacityZero) {
65
- popupCharStylesEditorRef.current.style.opacity = '0';
65
+ floatingToolbarRef.current.style.opacity = '0';
66
66
  }
67
67
  if (!isPointerEventsNone) {
68
- popupCharStylesEditorRef.current.style.pointerEvents = 'none';
68
+ floatingToolbarRef.current.style.pointerEvents = 'none';
69
69
  }
70
70
  }
71
71
  }, [
72
- popupCharStylesEditorRef
72
+ floatingToolbarRef
73
73
  ]);
74
74
  const mouseMoveListener = useCallback((e)=>{
75
- if (popupCharStylesEditorRef?.current && (e.buttons === 1 || e.buttons === 3)) {
76
- const isOpacityZero = popupCharStylesEditorRef.current.style.opacity === '0';
77
- const isPointerEventsNone = popupCharStylesEditorRef.current.style.pointerEvents === 'none';
75
+ if (floatingToolbarRef?.current && (e.buttons === 1 || e.buttons === 3)) {
76
+ const isOpacityZero = floatingToolbarRef.current.style.opacity === '0';
77
+ const isPointerEventsNone = floatingToolbarRef.current.style.pointerEvents === 'none';
78
78
  if (!isOpacityZero || !isPointerEventsNone) {
79
79
  // Check if the mouse is not over the popup
80
80
  const x = e.clientX;
81
81
  const y = e.clientY;
82
82
  const elementUnderMouse = document.elementFromPoint(x, y);
83
- if (!popupCharStylesEditorRef.current.contains(elementUnderMouse)) {
83
+ if (!floatingToolbarRef.current.contains(elementUnderMouse)) {
84
84
  // Mouse is not over the target element => not a normal click, but probably a drag
85
85
  closeFloatingToolbar();
86
86
  }
@@ -90,16 +90,16 @@ function FloatingSelectToolbar({ anchorElem, editor }) {
90
90
  closeFloatingToolbar
91
91
  ]);
92
92
  const mouseUpListener = useCallback(()=>{
93
- if (popupCharStylesEditorRef?.current) {
94
- if (popupCharStylesEditorRef.current.style.opacity !== '1') {
95
- popupCharStylesEditorRef.current.style.opacity = '1';
93
+ if (floatingToolbarRef?.current) {
94
+ if (floatingToolbarRef.current.style.opacity !== '1') {
95
+ floatingToolbarRef.current.style.opacity = '1';
96
96
  }
97
- if (popupCharStylesEditorRef.current.style.pointerEvents !== 'auto') {
98
- popupCharStylesEditorRef.current.style.pointerEvents = 'auto';
97
+ if (floatingToolbarRef.current.style.pointerEvents !== 'auto') {
98
+ floatingToolbarRef.current.style.pointerEvents = 'auto';
99
99
  }
100
100
  }
101
101
  }, [
102
- popupCharStylesEditorRef
102
+ floatingToolbarRef
103
103
  ]);
104
104
  useEffect(()=>{
105
105
  document.addEventListener('mousemove', mouseMoveListener);
@@ -109,23 +109,24 @@ function FloatingSelectToolbar({ anchorElem, editor }) {
109
109
  document.removeEventListener('mouseup', mouseUpListener);
110
110
  };
111
111
  }, [
112
- popupCharStylesEditorRef,
112
+ floatingToolbarRef,
113
113
  mouseMoveListener,
114
114
  mouseUpListener
115
115
  ]);
116
116
  const updateTextFormatFloatingToolbar = useCallback(()=>{
117
117
  const selection = $getSelection();
118
- const popupCharStylesEditorElem = popupCharStylesEditorRef.current;
119
118
  const nativeSelection = window.getSelection();
120
- if (popupCharStylesEditorElem === null) {
119
+ if (floatingToolbarRef.current === null) {
121
120
  return;
122
121
  }
123
122
  const rootElement = editor.getRootElement();
124
123
  if (selection !== null && nativeSelection !== null && !nativeSelection.isCollapsed && rootElement !== null && rootElement.contains(nativeSelection.anchorNode)) {
125
124
  const rangeRect = getDOMRangeRect(nativeSelection, rootElement);
126
- setFloatingElemPosition(rangeRect, popupCharStylesEditorElem, anchorElem, 'center');
125
+ // Position floating toolbar
126
+ const offsetIfFlipped = setFloatingElemPosition(rangeRect, floatingToolbarRef.current, anchorElem, 'center');
127
+ // Position caret
127
128
  if (caretRef.current) {
128
- setFloatingElemPosition(rangeRect, caretRef.current, popupCharStylesEditorElem, 'center', 10, 5, true);
129
+ setFloatingElemPosition(rangeRect, caretRef.current, floatingToolbarRef.current, 'center', 10, 5, true, offsetIfFlipped);
129
130
  }
130
131
  }
131
132
  }, [
@@ -172,7 +173,7 @@ function FloatingSelectToolbar({ anchorElem, editor }) {
172
173
  ]);
173
174
  return /*#__PURE__*/ React.createElement("div", {
174
175
  className: "floating-select-toolbar-popup",
175
- ref: popupCharStylesEditorRef
176
+ ref: floatingToolbarRef
176
177
  }, /*#__PURE__*/ React.createElement("div", {
177
178
  className: "caret",
178
179
  ref: caretRef
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../src/field/lexical/plugins/FloatingSelectToolbar/index.tsx"],"sourcesContent":["'use client'\nimport type { LexicalEditor } from 'lexical'\n\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext.js'\nimport { mergeRegister } from '@lexical/utils'\nimport {\n $getSelection,\n $isRangeSelection,\n $isTextNode,\n COMMAND_PRIORITY_LOW,\n SELECTION_CHANGE_COMMAND,\n} from 'lexical'\nimport { useCallback, useEffect, useRef, useState } from 'react'\nimport * as React from 'react'\nimport { createPortal } from 'react-dom'\n\nimport type { FloatingToolbarSection, FloatingToolbarSectionEntry } from './types.js'\n\nimport { useEditorConfigContext } from '../../config/client/EditorConfigProvider.js'\nimport { getDOMRangeRect } from '../../utils/getDOMRangeRect.js'\nimport { setFloatingElemPosition } from '../../utils/setFloatingElemPosition.js'\nimport { ToolbarButton } from './ToolbarButton/index.js'\nimport { ToolbarDropdown } from './ToolbarDropdown/index.js'\nimport './index.scss'\n\nfunction ButtonSectionEntry({\n anchorElem,\n editor,\n entry,\n}: {\n anchorElem: HTMLElement\n editor: LexicalEditor\n entry: FloatingToolbarSectionEntry\n}): React.ReactNode {\n if (entry.Component) {\n return (\n entry?.Component && (\n <entry.Component anchorElem={anchorElem} editor={editor} entry={entry} key={entry.key} />\n )\n )\n }\n\n return (\n <ToolbarButton entry={entry} key={entry.key}>\n {entry?.ChildComponent && <entry.ChildComponent />}\n </ToolbarButton>\n )\n}\n\nfunction ToolbarSection({\n anchorElem,\n editor,\n index,\n section,\n}: {\n anchorElem: HTMLElement\n editor: LexicalEditor\n index: number\n section: FloatingToolbarSection\n}): React.ReactNode {\n const { editorConfig } = useEditorConfigContext()\n\n const Icon =\n section?.type === 'dropdown' && section.entries.length && section.ChildComponent\n ? section.ChildComponent\n : null\n\n return (\n <div\n className={`floating-select-toolbar-popup__section floating-select-toolbar-popup__section-${section.key}`}\n key={section.key}\n >\n {section.type === 'dropdown' &&\n section.entries.length &&\n (Icon ? (\n <ToolbarDropdown\n Icon={Icon}\n anchorElem={anchorElem}\n editor={editor}\n entries={section.entries}\n sectionKey={section.key}\n />\n ) : (\n <ToolbarDropdown\n anchorElem={anchorElem}\n editor={editor}\n entries={section.entries}\n sectionKey={section.key}\n />\n ))}\n {section.type === 'buttons' &&\n section.entries.length &&\n section.entries.map((entry) => {\n return (\n <ButtonSectionEntry\n anchorElem={anchorElem}\n editor={editor}\n entry={entry}\n key={entry.key}\n />\n )\n })}\n {index < editorConfig.features.floatingSelectToolbar?.sections.length - 1 && (\n <div className=\"divider\" />\n )}\n </div>\n )\n}\n\nfunction FloatingSelectToolbar({\n anchorElem,\n editor,\n}: {\n anchorElem: HTMLElement\n editor: LexicalEditor\n}): React.ReactNode {\n const popupCharStylesEditorRef = useRef<HTMLDivElement | null>(null)\n const caretRef = useRef<HTMLDivElement | null>(null)\n\n const { editorConfig } = useEditorConfigContext()\n\n const closeFloatingToolbar = useCallback(() => {\n if (popupCharStylesEditorRef?.current) {\n const isOpacityZero = popupCharStylesEditorRef.current.style.opacity === '0'\n const isPointerEventsNone = popupCharStylesEditorRef.current.style.pointerEvents === 'none'\n\n if (!isOpacityZero) {\n popupCharStylesEditorRef.current.style.opacity = '0'\n }\n if (!isPointerEventsNone) {\n popupCharStylesEditorRef.current.style.pointerEvents = 'none'\n }\n }\n }, [popupCharStylesEditorRef])\n\n const mouseMoveListener = useCallback(\n (e: MouseEvent) => {\n if (popupCharStylesEditorRef?.current && (e.buttons === 1 || e.buttons === 3)) {\n const isOpacityZero = popupCharStylesEditorRef.current.style.opacity === '0'\n const isPointerEventsNone = popupCharStylesEditorRef.current.style.pointerEvents === 'none'\n if (!isOpacityZero || !isPointerEventsNone) {\n // Check if the mouse is not over the popup\n const x = e.clientX\n const y = e.clientY\n const elementUnderMouse = document.elementFromPoint(x, y)\n if (!popupCharStylesEditorRef.current.contains(elementUnderMouse)) {\n // Mouse is not over the target element => not a normal click, but probably a drag\n closeFloatingToolbar()\n }\n }\n }\n },\n [closeFloatingToolbar],\n )\n\n const mouseUpListener = useCallback(() => {\n if (popupCharStylesEditorRef?.current) {\n if (popupCharStylesEditorRef.current.style.opacity !== '1') {\n popupCharStylesEditorRef.current.style.opacity = '1'\n }\n if (popupCharStylesEditorRef.current.style.pointerEvents !== 'auto') {\n popupCharStylesEditorRef.current.style.pointerEvents = 'auto'\n }\n }\n }, [popupCharStylesEditorRef])\n\n useEffect(() => {\n document.addEventListener('mousemove', mouseMoveListener)\n document.addEventListener('mouseup', mouseUpListener)\n\n return () => {\n document.removeEventListener('mousemove', mouseMoveListener)\n document.removeEventListener('mouseup', mouseUpListener)\n }\n }, [popupCharStylesEditorRef, mouseMoveListener, mouseUpListener])\n\n const updateTextFormatFloatingToolbar = useCallback(() => {\n const selection = $getSelection()\n\n const popupCharStylesEditorElem = popupCharStylesEditorRef.current\n const nativeSelection = window.getSelection()\n\n if (popupCharStylesEditorElem === null) {\n return\n }\n\n const rootElement = editor.getRootElement()\n if (\n selection !== null &&\n nativeSelection !== null &&\n !nativeSelection.isCollapsed &&\n rootElement !== null &&\n rootElement.contains(nativeSelection.anchorNode)\n ) {\n const rangeRect = getDOMRangeRect(nativeSelection, rootElement)\n\n setFloatingElemPosition(rangeRect, popupCharStylesEditorElem, anchorElem, 'center')\n\n if (caretRef.current) {\n setFloatingElemPosition(\n rangeRect, // selection to position around\n caretRef.current, // what to position\n popupCharStylesEditorElem, // anchor elem\n 'center',\n 10,\n 5,\n true,\n )\n }\n }\n }, [editor, anchorElem])\n\n useEffect(() => {\n const scrollerElem = anchorElem.parentElement\n\n const update = () => {\n editor.getEditorState().read(() => {\n updateTextFormatFloatingToolbar()\n })\n }\n\n window.addEventListener('resize', update)\n if (scrollerElem) {\n scrollerElem.addEventListener('scroll', update)\n }\n\n return () => {\n window.removeEventListener('resize', update)\n if (scrollerElem) {\n scrollerElem.removeEventListener('scroll', update)\n }\n }\n }, [editor, updateTextFormatFloatingToolbar, anchorElem])\n\n useEffect(() => {\n editor.getEditorState().read(() => {\n updateTextFormatFloatingToolbar()\n })\n return mergeRegister(\n editor.registerUpdateListener(({ editorState }) => {\n editorState.read(() => {\n updateTextFormatFloatingToolbar()\n })\n }),\n\n editor.registerCommand(\n SELECTION_CHANGE_COMMAND,\n () => {\n updateTextFormatFloatingToolbar()\n return false\n },\n COMMAND_PRIORITY_LOW,\n ),\n )\n }, [editor, updateTextFormatFloatingToolbar])\n\n return (\n <div className=\"floating-select-toolbar-popup\" ref={popupCharStylesEditorRef}>\n <div className=\"caret\" ref={caretRef} />\n {editor.isEditable() && (\n <React.Fragment>\n {editorConfig?.features &&\n editorConfig.features?.floatingSelectToolbar?.sections.map((section, i) => {\n return (\n <ToolbarSection\n anchorElem={anchorElem}\n editor={editor}\n index={i}\n key={section.key}\n section={section}\n />\n )\n })}\n </React.Fragment>\n )}\n </div>\n )\n}\n\nfunction useFloatingTextFormatToolbar(\n editor: LexicalEditor,\n anchorElem: HTMLElement,\n): JSX.Element | null {\n const [isText, setIsText] = useState(false)\n\n const updatePopup = useCallback(() => {\n editor.getEditorState().read(() => {\n // Should not to pop up the floating toolbar when using IME input\n if (editor.isComposing()) {\n return\n }\n const selection = $getSelection()\n const nativeSelection = window.getSelection()\n const rootElement = editor.getRootElement()\n\n if (\n nativeSelection !== null &&\n (!$isRangeSelection(selection) ||\n rootElement === null ||\n !rootElement.contains(nativeSelection.anchorNode))\n ) {\n setIsText(false)\n return\n }\n\n if (!$isRangeSelection(selection)) {\n return\n }\n\n if (selection.getTextContent() !== '') {\n const nodes = selection.getNodes()\n let foundNodeWithText = false\n for (const node of nodes) {\n if ($isTextNode(node)) {\n setIsText(true)\n foundNodeWithText = true\n break\n }\n }\n if (!foundNodeWithText) {\n setIsText(false)\n }\n } else {\n setIsText(false)\n }\n\n const rawTextContent = selection.getTextContent().replace(/\\n/g, '')\n if (!selection.isCollapsed() && rawTextContent === '') {\n setIsText(false)\n return\n }\n })\n }, [editor])\n\n useEffect(() => {\n document.addEventListener('selectionchange', updatePopup)\n document.addEventListener('mouseup', updatePopup)\n return () => {\n document.removeEventListener('selectionchange', updatePopup)\n document.removeEventListener('mouseup', updatePopup)\n }\n }, [updatePopup])\n\n useEffect(() => {\n return mergeRegister(\n editor.registerUpdateListener(() => {\n updatePopup()\n }),\n editor.registerRootListener(() => {\n if (editor.getRootElement() === null) {\n setIsText(false)\n }\n }),\n )\n }, [editor, updatePopup])\n\n if (!isText) {\n return null\n }\n\n return createPortal(<FloatingSelectToolbar anchorElem={anchorElem} editor={editor} />, anchorElem)\n}\n\nexport function FloatingSelectToolbarPlugin({\n anchorElem = document.body,\n}: {\n anchorElem?: HTMLElement\n}): JSX.Element | null {\n const [editor] = useLexicalComposerContext()\n return useFloatingTextFormatToolbar(editor, anchorElem)\n}\n"],"names":["useLexicalComposerContext","mergeRegister","$getSelection","$isRangeSelection","$isTextNode","COMMAND_PRIORITY_LOW","SELECTION_CHANGE_COMMAND","useCallback","useEffect","useRef","useState","React","createPortal","useEditorConfigContext","getDOMRangeRect","setFloatingElemPosition","ToolbarButton","ToolbarDropdown","ButtonSectionEntry","anchorElem","editor","entry","Component","key","ChildComponent","ToolbarSection","index","section","editorConfig","Icon","type","entries","length","div","className","sectionKey","map","features","floatingSelectToolbar","sections","FloatingSelectToolbar","popupCharStylesEditorRef","caretRef","closeFloatingToolbar","current","isOpacityZero","style","opacity","isPointerEventsNone","pointerEvents","mouseMoveListener","e","buttons","x","clientX","y","clientY","elementUnderMouse","document","elementFromPoint","contains","mouseUpListener","addEventListener","removeEventListener","updateTextFormatFloatingToolbar","selection","popupCharStylesEditorElem","nativeSelection","window","getSelection","rootElement","getRootElement","isCollapsed","anchorNode","rangeRect","scrollerElem","parentElement","update","getEditorState","read","registerUpdateListener","editorState","registerCommand","ref","isEditable","Fragment","i","useFloatingTextFormatToolbar","isText","setIsText","updatePopup","isComposing","getTextContent","nodes","getNodes","foundNodeWithText","node","rawTextContent","replace","registerRootListener","FloatingSelectToolbarPlugin","body"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA;AAGA,SAASA,yBAAyB,QAAQ,2CAA0C;AACpF,SAASC,aAAa,QAAQ,iBAAgB;AAC9C,SACEC,aAAa,EACbC,iBAAiB,EACjBC,WAAW,EACXC,oBAAoB,EACpBC,wBAAwB,QACnB,UAAS;AAChB,SAASC,WAAW,EAAEC,SAAS,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,QAAO;AAChE,YAAYC,WAAW,QAAO;AAC9B,SAASC,YAAY,QAAQ,YAAW;AAIxC,SAASC,sBAAsB,QAAQ,8CAA6C;AACpF,SAASC,eAAe,QAAQ,iCAAgC;AAChE,SAASC,uBAAuB,QAAQ,yCAAwC;AAChF,SAASC,aAAa,QAAQ,2BAA0B;AACxD,SAASC,eAAe,QAAQ,6BAA4B;AAC5D,OAAO,eAAc;AAErB,SAASC,mBAAmB,EAC1BC,UAAU,EACVC,MAAM,EACNC,KAAK,EAKN;IACC,IAAIA,MAAMC,SAAS,EAAE;QACnB,OACED,OAAOC,2BACL,oBAACD,MAAMC,SAAS;YAACH,YAAYA;YAAYC,QAAQA;YAAQC,OAAOA;YAAOE,KAAKF,MAAME,GAAG;;IAG3F;IAEA,qBACE,oBAACP;QAAcK,OAAOA;QAAOE,KAAKF,MAAME,GAAG;OACxCF,OAAOG,gCAAkB,oBAACH,MAAMG,cAAc;AAGrD;AAEA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;gBACF;gBACA,IAAI,CAACA,mBAAmB;oBACtBN,UAAU;gBACZ;YACF,OAAO;gBACLA,UAAU;YACZ;YAEA,MAAMQ,iBAAiBhC,UAAU2B,cAAc,GAAGM,OAAO,CAAC,OAAO;YACjE,IAAI,CAACjC,UAAUO,WAAW,MAAMyB,mBAAmB,IAAI;gBACrDR,UAAU;gBACV;YACF;QACF;IACF,GAAG;QAACrE;KAAO;IAEXZ,UAAU;QACRkD,SAASI,gBAAgB,CAAC,mBAAmB4B;QAC7ChC,SAASI,gBAAgB,CAAC,WAAW4B;QACrC,OAAO;YACLhC,SAASK,mBAAmB,CAAC,mBAAmB2B;YAChDhC,SAASK,mBAAmB,CAAC,WAAW2B;QAC1C;IACF,GAAG;QAACA;KAAY;IAEhBlF,UAAU;QACR,OAAOP,cACLmB,OAAO4D,sBAAsB,CAAC;YAC5BU;QACF,IACAtE,OAAO+E,oBAAoB,CAAC;YAC1B,IAAI/E,OAAOmD,cAAc,OAAO,MAAM;gBACpCkB,UAAU;YACZ;QACF;IAEJ,GAAG;QAACrE;QAAQsE;KAAY;IAExB,IAAI,CAACF,QAAQ;QACX,OAAO;IACT;IAEA,qBAAO5E,2BAAa,oBAAC4B;QAAsBrB,YAAYA;QAAYC,QAAQA;QAAYD;AACzF;AAEA,OAAO,SAASiF,4BAA4B,EAC1CjF,aAAauC,SAAS2C,IAAI,EAG3B;IACC,MAAM,CAACjF,OAAO,GAAGpB;IACjB,OAAOuF,6BAA6BnE,QAAQD;AAC9C"}
1
+ {"version":3,"sources":["../../../../../src/field/lexical/plugins/FloatingSelectToolbar/index.tsx"],"sourcesContent":["'use client'\nimport type { LexicalEditor } from 'lexical'\n\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext.js'\nimport { mergeRegister } from '@lexical/utils'\nimport {\n $getSelection,\n $isRangeSelection,\n $isTextNode,\n COMMAND_PRIORITY_LOW,\n SELECTION_CHANGE_COMMAND,\n} from 'lexical'\nimport { useCallback, useEffect, useRef, useState } from 'react'\nimport * as React from 'react'\nimport { createPortal } from 'react-dom'\n\nimport type { FloatingToolbarSection, FloatingToolbarSectionEntry } from './types.js'\n\nimport { useEditorConfigContext } from '../../config/client/EditorConfigProvider.js'\nimport { getDOMRangeRect } from '../../utils/getDOMRangeRect.js'\nimport { setFloatingElemPosition } from '../../utils/setFloatingElemPosition.js'\nimport { ToolbarButton } from './ToolbarButton/index.js'\nimport { ToolbarDropdown } from './ToolbarDropdown/index.js'\nimport './index.scss'\n\nfunction ButtonSectionEntry({\n anchorElem,\n editor,\n entry,\n}: {\n anchorElem: HTMLElement\n editor: LexicalEditor\n entry: FloatingToolbarSectionEntry\n}): React.ReactNode {\n if (entry.Component) {\n return (\n entry?.Component && (\n <entry.Component anchorElem={anchorElem} editor={editor} entry={entry} key={entry.key} />\n )\n )\n }\n\n return (\n <ToolbarButton entry={entry} key={entry.key}>\n {entry?.ChildComponent && <entry.ChildComponent />}\n </ToolbarButton>\n )\n}\n\nfunction ToolbarSection({\n anchorElem,\n editor,\n index,\n section,\n}: {\n anchorElem: HTMLElement\n editor: LexicalEditor\n index: number\n section: FloatingToolbarSection\n}): React.ReactNode {\n const { editorConfig } = useEditorConfigContext()\n\n const Icon =\n section?.type === 'dropdown' && section.entries.length && section.ChildComponent\n ? section.ChildComponent\n : null\n\n return (\n <div\n className={`floating-select-toolbar-popup__section floating-select-toolbar-popup__section-${section.key}`}\n key={section.key}\n >\n {section.type === 'dropdown' &&\n section.entries.length &&\n (Icon ? (\n <ToolbarDropdown\n Icon={Icon}\n anchorElem={anchorElem}\n editor={editor}\n entries={section.entries}\n sectionKey={section.key}\n />\n ) : (\n <ToolbarDropdown\n anchorElem={anchorElem}\n editor={editor}\n entries={section.entries}\n sectionKey={section.key}\n />\n ))}\n {section.type === 'buttons' &&\n section.entries.length &&\n section.entries.map((entry) => {\n return (\n <ButtonSectionEntry\n anchorElem={anchorElem}\n editor={editor}\n entry={entry}\n key={entry.key}\n />\n )\n })}\n {index < editorConfig.features.floatingSelectToolbar?.sections.length - 1 && (\n <div className=\"divider\" />\n )}\n </div>\n )\n}\n\nfunction FloatingSelectToolbar({\n anchorElem,\n editor,\n}: {\n anchorElem: HTMLElement\n editor: LexicalEditor\n}): React.ReactNode {\n const floatingToolbarRef = useRef<HTMLDivElement | null>(null)\n const caretRef = useRef<HTMLDivElement | null>(null)\n\n const { editorConfig } = useEditorConfigContext()\n\n const closeFloatingToolbar = useCallback(() => {\n if (floatingToolbarRef?.current) {\n const isOpacityZero = floatingToolbarRef.current.style.opacity === '0'\n const isPointerEventsNone = floatingToolbarRef.current.style.pointerEvents === 'none'\n\n if (!isOpacityZero) {\n floatingToolbarRef.current.style.opacity = '0'\n }\n if (!isPointerEventsNone) {\n floatingToolbarRef.current.style.pointerEvents = 'none'\n }\n }\n }, [floatingToolbarRef])\n\n const mouseMoveListener = useCallback(\n (e: MouseEvent) => {\n if (floatingToolbarRef?.current && (e.buttons === 1 || e.buttons === 3)) {\n const isOpacityZero = floatingToolbarRef.current.style.opacity === '0'\n const isPointerEventsNone = floatingToolbarRef.current.style.pointerEvents === 'none'\n if (!isOpacityZero || !isPointerEventsNone) {\n // Check if the mouse is not over the popup\n const x = e.clientX\n const y = e.clientY\n const elementUnderMouse = document.elementFromPoint(x, y)\n if (!floatingToolbarRef.current.contains(elementUnderMouse)) {\n // Mouse is not over the target element => not a normal click, but probably a drag\n closeFloatingToolbar()\n }\n }\n }\n },\n [closeFloatingToolbar],\n )\n\n const mouseUpListener = useCallback(() => {\n if (floatingToolbarRef?.current) {\n if (floatingToolbarRef.current.style.opacity !== '1') {\n floatingToolbarRef.current.style.opacity = '1'\n }\n if (floatingToolbarRef.current.style.pointerEvents !== 'auto') {\n floatingToolbarRef.current.style.pointerEvents = 'auto'\n }\n }\n }, [floatingToolbarRef])\n\n useEffect(() => {\n document.addEventListener('mousemove', mouseMoveListener)\n document.addEventListener('mouseup', mouseUpListener)\n\n return () => {\n document.removeEventListener('mousemove', mouseMoveListener)\n document.removeEventListener('mouseup', mouseUpListener)\n }\n }, [floatingToolbarRef, mouseMoveListener, mouseUpListener])\n\n const updateTextFormatFloatingToolbar = useCallback(() => {\n const selection = $getSelection()\n\n const nativeSelection = window.getSelection()\n\n if (floatingToolbarRef.current === null) {\n return\n }\n\n const rootElement = editor.getRootElement()\n if (\n selection !== null &&\n nativeSelection !== null &&\n !nativeSelection.isCollapsed &&\n rootElement !== null &&\n rootElement.contains(nativeSelection.anchorNode)\n ) {\n const rangeRect = getDOMRangeRect(nativeSelection, rootElement)\n\n // Position floating toolbar\n const offsetIfFlipped = setFloatingElemPosition(\n rangeRect, // selection to position around\n floatingToolbarRef.current, // what to position\n anchorElem, // anchor elem\n 'center',\n )\n\n // Position caret\n if (caretRef.current) {\n setFloatingElemPosition(\n rangeRect, // selection to position around\n caretRef.current, // what to position\n floatingToolbarRef.current, // anchor elem\n 'center',\n 10,\n 5,\n true,\n offsetIfFlipped,\n )\n }\n }\n }, [editor, anchorElem])\n\n useEffect(() => {\n const scrollerElem = anchorElem.parentElement\n\n const update = () => {\n editor.getEditorState().read(() => {\n updateTextFormatFloatingToolbar()\n })\n }\n\n window.addEventListener('resize', update)\n if (scrollerElem) {\n scrollerElem.addEventListener('scroll', update)\n }\n\n return () => {\n window.removeEventListener('resize', update)\n if (scrollerElem) {\n scrollerElem.removeEventListener('scroll', update)\n }\n }\n }, [editor, updateTextFormatFloatingToolbar, anchorElem])\n\n useEffect(() => {\n editor.getEditorState().read(() => {\n updateTextFormatFloatingToolbar()\n })\n return mergeRegister(\n editor.registerUpdateListener(({ editorState }) => {\n editorState.read(() => {\n updateTextFormatFloatingToolbar()\n })\n }),\n\n editor.registerCommand(\n SELECTION_CHANGE_COMMAND,\n () => {\n updateTextFormatFloatingToolbar()\n return false\n },\n COMMAND_PRIORITY_LOW,\n ),\n )\n }, [editor, updateTextFormatFloatingToolbar])\n\n return (\n <div className=\"floating-select-toolbar-popup\" ref={floatingToolbarRef}>\n <div className=\"caret\" ref={caretRef} />\n {editor.isEditable() && (\n <React.Fragment>\n {editorConfig?.features &&\n editorConfig.features?.floatingSelectToolbar?.sections.map((section, i) => {\n return (\n <ToolbarSection\n anchorElem={anchorElem}\n editor={editor}\n index={i}\n key={section.key}\n section={section}\n />\n )\n })}\n </React.Fragment>\n )}\n </div>\n )\n}\n\nfunction useFloatingTextFormatToolbar(\n editor: LexicalEditor,\n anchorElem: HTMLElement,\n): JSX.Element | null {\n const [isText, setIsText] = useState(false)\n\n const updatePopup = useCallback(() => {\n editor.getEditorState().read(() => {\n // Should not to pop up the floating toolbar when using IME input\n if (editor.isComposing()) {\n return\n }\n const selection = $getSelection()\n const nativeSelection = window.getSelection()\n const rootElement = editor.getRootElement()\n\n if (\n nativeSelection !== null &&\n (!$isRangeSelection(selection) ||\n rootElement === null ||\n !rootElement.contains(nativeSelection.anchorNode))\n ) {\n setIsText(false)\n return\n }\n\n if (!$isRangeSelection(selection)) {\n return\n }\n\n if (selection.getTextContent() !== '') {\n const nodes = selection.getNodes()\n let foundNodeWithText = false\n for (const node of nodes) {\n if ($isTextNode(node)) {\n setIsText(true)\n foundNodeWithText = true\n break\n }\n }\n if (!foundNodeWithText) {\n setIsText(false)\n }\n } else {\n setIsText(false)\n }\n\n const rawTextContent = selection.getTextContent().replace(/\\n/g, '')\n if (!selection.isCollapsed() && rawTextContent === '') {\n setIsText(false)\n return\n }\n })\n }, [editor])\n\n useEffect(() => {\n document.addEventListener('selectionchange', updatePopup)\n document.addEventListener('mouseup', updatePopup)\n return () => {\n document.removeEventListener('selectionchange', updatePopup)\n document.removeEventListener('mouseup', updatePopup)\n }\n }, [updatePopup])\n\n useEffect(() => {\n return mergeRegister(\n editor.registerUpdateListener(() => {\n updatePopup()\n }),\n editor.registerRootListener(() => {\n if (editor.getRootElement() === null) {\n setIsText(false)\n }\n }),\n )\n }, [editor, updatePopup])\n\n if (!isText) {\n return null\n }\n\n return createPortal(<FloatingSelectToolbar anchorElem={anchorElem} editor={editor} />, anchorElem)\n}\n\nexport function FloatingSelectToolbarPlugin({\n anchorElem = document.body,\n}: {\n anchorElem?: HTMLElement\n}): JSX.Element | null {\n const [editor] = useLexicalComposerContext()\n return useFloatingTextFormatToolbar(editor, anchorElem)\n}\n"],"names":["useLexicalComposerContext","mergeRegister","$getSelection","$isRangeSelection","$isTextNode","COMMAND_PRIORITY_LOW","SELECTION_CHANGE_COMMAND","useCallback","useEffect","useRef","useState","React","createPortal","useEditorConfigContext","getDOMRangeRect","setFloatingElemPosition","ToolbarButton","ToolbarDropdown","ButtonSectionEntry","anchorElem","editor","entry","Component","key","ChildComponent","ToolbarSection","index","section","editorConfig","Icon","type","entries","length","div","className","sectionKey","map","features","floatingSelectToolbar","sections","FloatingSelectToolbar","floatingToolbarRef","caretRef","closeFloatingToolbar","current","isOpacityZero","style","opacity","isPointerEventsNone","pointerEvents","mouseMoveListener","e","buttons","x","clientX","y","clientY","elementUnderMouse","document","elementFromPoint","contains","mouseUpListener","addEventListener","removeEventListener","updateTextFormatFloatingToolbar","selection","nativeSelection","window","getSelection","rootElement","getRootElement","isCollapsed","anchorNode","rangeRect","offsetIfFlipped","scrollerElem","parentElement","update","getEditorState","read","registerUpdateListener","editorState","registerCommand","ref","isEditable","Fragment","i","useFloatingTextFormatToolbar","isText","setIsText","updatePopup","isComposing","getTextContent","nodes","getNodes","foundNodeWithText","node","rawTextContent","replace","registerRootListener","FloatingSelectToolbarPlugin","body"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA;AAGA,SAASA,yBAA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hC,SAASK,mBAAmB,CAAC,mBAAmB2B;YAChDhC,SAASK,mBAAmB,CAAC,WAAW2B;QAC1C;IACF,GAAG;QAACA;KAAY;IAEhBlF,UAAU;QACR,OAAOP,cACLmB,OAAO4D,sBAAsB,CAAC;YAC5BU;QACF,IACAtE,OAAO+E,oBAAoB,CAAC;YAC1B,IAAI/E,OAAOkD,cAAc,OAAO,MAAM;gBACpCmB,UAAU;YACZ;QACF;IAEJ,GAAG;QAACrE;QAAQsE;KAAY;IAExB,IAAI,CAACF,QAAQ;QACX,OAAO;IACT;IAEA,qBAAO5E,2BAAa,oBAAC4B;QAAsBrB,YAAYA;QAAYC,QAAQA;QAAYD;AACzF;AAEA,OAAO,SAASiF,4BAA4B,EAC1CjF,aAAauC,SAAS2C,IAAI,EAG3B;IACC,MAAM,CAACjF,OAAO,GAAGpB;IACjB,OAAOuF,6BAA6BnE,QAAQD;AAC9C"}
@@ -1,2 +1,2 @@
1
- export declare function setFloatingElemPosition(targetRect: ClientRect | null, floatingElem: HTMLElement, anchorElem: HTMLElement, horizontalPosition?: 'center' | 'left', verticalGap?: number, horizontalOffset?: number, specialHandlingForCaret?: boolean): void;
1
+ export declare function setFloatingElemPosition(targetRect: ClientRect | null, floatingElem: HTMLElement, anchorElem: HTMLElement, horizontalPosition?: 'center' | 'left', verticalGap?: number, horizontalOffset?: number, specialHandlingForCaret?: boolean, anchorFlippedOffset?: number): number;
2
2
  //# sourceMappingURL=setFloatingElemPosition.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"setFloatingElemPosition.d.ts","sourceRoot":"","sources":["../../../../src/field/lexical/utils/setFloatingElemPosition.ts"],"names":[],"mappings":"AAMA,wBAAgB,uBAAuB,CACrC,UAAU,EAAE,UAAU,GAAG,IAAI,EAC7B,YAAY,EAAE,WAAW,EACzB,UAAU,EAAE,WAAW,EACvB,kBAAkB,GAAE,QAAQ,GAAG,MAAe,EAC9C,WAAW,GAAE,MAAqB,EAClC,gBAAgB,GAAE,MAA0B,EAC5C,uBAAuB,UAAQ,GAC9B,IAAI,CAuDN"}
1
+ {"version":3,"file":"setFloatingElemPosition.d.ts","sourceRoot":"","sources":["../../../../src/field/lexical/utils/setFloatingElemPosition.ts"],"names":[],"mappings":"AAOA,wBAAgB,uBAAuB,CACrC,UAAU,EAAE,UAAU,GAAG,IAAI,EAC7B,YAAY,EAAE,WAAW,EACzB,UAAU,EAAE,WAAW,EACvB,kBAAkB,GAAE,QAAQ,GAAG,MAAe,EAC9C,WAAW,GAAE,MAAqB,EAClC,gBAAgB,GAAE,MAA0B,EAC5C,uBAAuB,UAAQ,EAC/B,mBAAmB,SAAI,GACtB,MAAM,CA0DR"}
@@ -1,9 +1,11 @@
1
1
  const VERTICAL_GAP = 10;
2
2
  const HORIZONTAL_OFFSET = 5;
3
- // TODO: This works fine with some dirty fixes (looking at you, specialHandlingForCaret). But this definitely needs refactoring and documentation, to be easier to understand and maintain.
3
+ // TODO: needs refactoring
4
4
  // This is supposed to position the floatingElem based on the parent (anchorElem) and the target (targetRect) which is usually the selected text.
5
5
  // So basically, it positions the floatingElem either below or above the target (targetRect) and aligns it to the left or center of the target (targetRect).
6
- export function setFloatingElemPosition(targetRect, floatingElem, anchorElem, horizontalPosition = 'left', verticalGap = VERTICAL_GAP, horizontalOffset = HORIZONTAL_OFFSET, specialHandlingForCaret = false) {
6
+ // This is used for positioning the floating toolbar (anchor: richtext editor) and its caret (anchor: floating toolbar)
7
+ export function setFloatingElemPosition(targetRect, floatingElem, anchorElem, horizontalPosition = 'left', verticalGap = VERTICAL_GAP, horizontalOffset = HORIZONTAL_OFFSET, specialHandlingForCaret = false, anchorFlippedOffset = 0) {
8
+ // Returns the top offset if the target was flipped
7
9
  const scrollerElem = anchorElem.parentElement;
8
10
  if (targetRect === null || scrollerElem == null) {
9
11
  floatingElem.style.opacity = '0';
@@ -19,8 +21,10 @@ export function setFloatingElemPosition(targetRect, floatingElem, anchorElem, ho
19
21
  // Calculate left to position floatingElem to the horizontal middle of targetRect
20
22
  left = targetRect.left + targetRect.width / 2 - floatingElemRect.width / 2;
21
23
  }
22
- if (top < editorScrollerRect.top) {
23
- top += floatingElemRect.height + targetRect.height + verticalGap * 2;
24
+ let addedToTop = 0;
25
+ if (top < editorScrollerRect.top && !specialHandlingForCaret) {
26
+ addedToTop = floatingElemRect.height + targetRect.height + verticalGap * 2;
27
+ top += addedToTop;
24
28
  }
25
29
  if (horizontalPosition === 'center') {
26
30
  if (left + floatingElemRect.width > editorScrollerRect.right) {
@@ -33,21 +37,19 @@ export function setFloatingElemPosition(targetRect, floatingElem, anchorElem, ho
33
37
  left = editorScrollerRect.right - floatingElemRect.width - horizontalOffset;
34
38
  }
35
39
  }
36
- top -= anchorElementRect.top;
37
40
  left -= anchorElementRect.left;
38
41
  floatingElem.style.opacity = '1';
39
- if (specialHandlingForCaret && top == 0 /* 0 Happens when selecting 1st line */ ) {
40
- top -= 44 // Especially this arbitrary number needs refactoring (this is for the caret)
41
- ;
42
- // rotate too
43
- floatingElem.style.transform = `translate(${left}px, ${top}px) rotate(180deg)`;
44
- } else if (specialHandlingForCaret && top === -63 /* -63 Happens when selecting 2nd line in multi-line paragraph */ ) {
45
- top += 18 // Especially this arbitrary number needs refactoring (this is for the caret)
46
- ;
42
+ if (specialHandlingForCaret && anchorFlippedOffset !== 0) {
43
+ // Floating select toolbar was flipped (positioned below text rather than above). Thus, the caret now needs to be positioned
44
+ // on the other side and rotated.
45
+ top -= anchorElementRect.bottom - anchorFlippedOffset + floatingElemRect.height - 3;
46
+ // top += anchorFlippedOffset - anchorElementRect.height - floatingElemRect.height + 2
47
47
  floatingElem.style.transform = `translate(${left}px, ${top}px) rotate(180deg)`;
48
48
  } else {
49
+ top -= anchorElementRect.top;
49
50
  floatingElem.style.transform = `translate(${left}px, ${top}px)`;
50
51
  }
52
+ return addedToTop;
51
53
  }
52
54
 
53
55
  //# sourceMappingURL=setFloatingElemPosition.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/field/lexical/utils/setFloatingElemPosition.ts"],"sourcesContent":["const VERTICAL_GAP = 10\nconst HORIZONTAL_OFFSET = 5\n\n// TODO: This works fine with some dirty fixes (looking at you, specialHandlingForCaret). But this definitely needs refactoring and documentation, to be easier to understand and maintain.\n// This is supposed to position the floatingElem based on the parent (anchorElem) and the target (targetRect) which is usually the selected text.\n// So basically, it positions the floatingElem either below or above the target (targetRect) and aligns it to the left or center of the target (targetRect).\nexport function setFloatingElemPosition(\n targetRect: ClientRect | null,\n floatingElem: HTMLElement,\n anchorElem: HTMLElement,\n horizontalPosition: 'center' | 'left' = 'left',\n verticalGap: number = VERTICAL_GAP,\n horizontalOffset: number = HORIZONTAL_OFFSET,\n specialHandlingForCaret = false,\n): void {\n const scrollerElem = anchorElem.parentElement\n\n if (targetRect === null || scrollerElem == null) {\n floatingElem.style.opacity = '0'\n floatingElem.style.transform = 'translate(-10000px, -10000px)'\n return\n }\n\n const floatingElemRect = floatingElem.getBoundingClientRect()\n const anchorElementRect = anchorElem.getBoundingClientRect()\n const editorScrollerRect = scrollerElem.getBoundingClientRect()\n\n let top = targetRect.top - floatingElemRect.height - verticalGap\n let left = targetRect.left - horizontalOffset\n\n if (horizontalPosition === 'center') {\n // Calculate left to position floatingElem to the horizontal middle of targetRect\n left = targetRect.left + targetRect.width / 2 - floatingElemRect.width / 2\n }\n\n if (top < editorScrollerRect.top) {\n top += floatingElemRect.height + targetRect.height + verticalGap * 2\n }\n\n if (horizontalPosition === 'center') {\n if (left + floatingElemRect.width > editorScrollerRect.right) {\n left = editorScrollerRect.right - floatingElemRect.width - horizontalOffset\n } else if (left < editorScrollerRect.left) {\n left = editorScrollerRect.left + horizontalOffset\n }\n } else {\n if (left + floatingElemRect.width > editorScrollerRect.right) {\n left = editorScrollerRect.right - floatingElemRect.width - horizontalOffset\n }\n }\n\n top -= anchorElementRect.top\n left -= anchorElementRect.left\n\n floatingElem.style.opacity = '1'\n\n if (specialHandlingForCaret && top == 0 /* 0 Happens when selecting 1st line */) {\n top -= 44 // Especially this arbitrary number needs refactoring (this is for the caret)\n // rotate too\n floatingElem.style.transform = `translate(${left}px, ${top}px) rotate(180deg)`\n } else if (\n specialHandlingForCaret &&\n top === -63 /* -63 Happens when selecting 2nd line in multi-line paragraph */\n ) {\n top += 18 // Especially this arbitrary number needs refactoring (this is for the caret)\n floatingElem.style.transform = `translate(${left}px, ${top}px) rotate(180deg)`\n } else {\n floatingElem.style.transform = `translate(${left}px, ${top}px)`\n }\n}\n"],"names":["VERTICAL_GAP","HORIZONTAL_OFFSET","setFloatingElemPosition","targetRect","floatingElem","anchorElem","horizontalPosition","verticalGap","horizontalOffset","specialHandlingForCaret","scrollerElem","parentElement","style","opacity","transform","floatingElemRect","getBoundingClientRect","anchorElementRect","editorScrollerRect","top","height","left","width","right"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,MAAMA,eAAe;AACrB,MAAMC,oBAAoB;AAE1B,2LAA2L;AAC3L,iJAAiJ;AACjJ,4JAA4J;AAC5J,OAAO,SAASC,wBACdC,UAA6B,EAC7BC,YAAyB,EACzBC,UAAuB,EACvBC,qBAAwC,MAAM,EAC9CC,cAAsBP,YAAY,EAClCQ,mBAA2BP,iBAAiB,EAC5CQ,0BAA0B,KAAK;IAE/B,MAAMC,eAAeL,WAAWM,aAAa;IAE7C,IAAIR,eAAe,QAAQO,gBAAgB,MAAM;QAC/CN,aAAaQ,KAAK,CAACC,OAAO,GAAG;QAC7BT,aAAaQ,KAAK,CAACE,SAAS,GAAG;QAC/B;IACF;IAEA,MAAMC,mBAAmBX,aAAaY,qBAAqB;IAC3D,MAAMC,oBAAoBZ,WAAWW,qBAAqB;IAC1D,MAAME,qBAAqBR,aAAaM,qBAAqB;IAE7D,IAAIG,MAAMhB,WAAWgB,GAAG,GAAGJ,iBAAiBK,MAAM,GAAGb;IACrD,IAAIc,OAAOlB,WAAWkB,IAAI,GAAGb;IAE7B,IAAIF,uB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
1
+ {"version":3,"sources":["../../../../src/field/lexical/utils/setFloatingElemPosition.ts"],"sourcesContent":["const VERTICAL_GAP = 10\nconst HORIZONTAL_OFFSET = 5\n\n// TODO: needs refactoring\n// This is supposed to position the floatingElem based on the parent (anchorElem) and the target (targetRect) which is usually the selected text.\n// So basically, it positions the floatingElem either below or above the target (targetRect) and aligns it to the left or center of the target (targetRect).\n// This is used for positioning the floating toolbar (anchor: richtext editor) and its caret (anchor: floating toolbar)\nexport function setFloatingElemPosition(\n targetRect: ClientRect | null,\n floatingElem: HTMLElement,\n anchorElem: HTMLElement,\n horizontalPosition: 'center' | 'left' = 'left',\n verticalGap: number = VERTICAL_GAP,\n horizontalOffset: number = HORIZONTAL_OFFSET,\n specialHandlingForCaret = false,\n anchorFlippedOffset = 0, // Offset which was added to the anchor (for caret, floating toolbar) if it was flipped\n): number {\n // Returns the top offset if the target was flipped\n const scrollerElem = anchorElem.parentElement\n\n if (targetRect === null || scrollerElem == null) {\n floatingElem.style.opacity = '0'\n floatingElem.style.transform = 'translate(-10000px, -10000px)'\n return\n }\n\n const floatingElemRect = floatingElem.getBoundingClientRect()\n const anchorElementRect = anchorElem.getBoundingClientRect()\n const editorScrollerRect = scrollerElem.getBoundingClientRect()\n\n let top = targetRect.top - floatingElemRect.height - verticalGap\n let left = targetRect.left - horizontalOffset\n\n if (horizontalPosition === 'center') {\n // Calculate left to position floatingElem to the horizontal middle of targetRect\n left = targetRect.left + targetRect.width / 2 - floatingElemRect.width / 2\n }\n\n let addedToTop = 0\n if (top < editorScrollerRect.top && !specialHandlingForCaret) {\n addedToTop = floatingElemRect.height + targetRect.height + verticalGap * 2\n\n top += addedToTop\n }\n\n if (horizontalPosition === 'center') {\n if (left + floatingElemRect.width > editorScrollerRect.right) {\n left = editorScrollerRect.right - floatingElemRect.width - horizontalOffset\n } else if (left < editorScrollerRect.left) {\n left = editorScrollerRect.left + horizontalOffset\n }\n } else {\n if (left + floatingElemRect.width > editorScrollerRect.right) {\n left = editorScrollerRect.right - floatingElemRect.width - horizontalOffset\n }\n }\n\n left -= anchorElementRect.left\n\n floatingElem.style.opacity = '1'\n\n if (specialHandlingForCaret && anchorFlippedOffset !== 0) {\n // Floating select toolbar was flipped (positioned below text rather than above). Thus, the caret now needs to be positioned\n // on the other side and rotated.\n top -= anchorElementRect.bottom - anchorFlippedOffset + floatingElemRect.height - 3\n // top += anchorFlippedOffset - anchorElementRect.height - floatingElemRect.height + 2\n floatingElem.style.transform = `translate(${left}px, ${top}px) rotate(180deg)`\n } else {\n top -= anchorElementRect.top\n\n floatingElem.style.transform = `translate(${left}px, ${top}px)`\n }\n\n return addedToTop\n}\n"],"names":["VERTICAL_GAP","HORIZONTAL_OFFSET","setFloatingElemPosition","targetRect","floatingElem","anchorElem","horizontalPosition","verticalGap","horizontalOffset","specialHandlingForCaret","anchorFlippedOffset","scrollerElem","parentElement","style","opacity","transform","floatingElemRect","getBoundingClientRect","anchorElementRect","editorScrollerRect","top","height","left","width","addedToTop","right","bottom"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,MAAMA,eAAe;AACrB,MAAMC,oBAAoB;AAE1B,0BAA0B;AAC1B,iJAAiJ;AACjJ,4JAA4J;AAC5J,uHAAuH;AACvH,OAAO,SAASC,wBACdC,UAA6B,EAC7BC,YAAyB,EACzBC,UAAuB,EACvBC,qBAAwC,MAAM,EAC9CC,cAAsBP,YAAY,EAClCQ,mBAA2BP,iBAAiB,EAC5CQ,0BAA0B,KAAK,EAC/BC,sBAAsB,CAAC;IAEvB,mDAAmD;IACnD,MAAMC,eAAeN,WAAWO,aAAa;IAE7C,IAAIT,eAAe,QAAQQ,gBAAgB,MAAM;QAC/CP,aAAaS,KAAK,CAACC,OAAO,GAAG;QAC7BV,aAAaS,KAAK,CAACE,SAAS,GAAG;QAC/B;IACF;IAEA,MAAMC,mBAAmBZ,aAAaa,qBAAqB;IAC3D,MAAMC,oBAAoBb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;QAE5BhB,aAAaS,KAAK,CAACE,SAAS,GAAG,CAAC,UAAU,EAAEO,KAAK,IAAI,EAAEF,IAAI,GAAG,CAAC;IACjE;IAEA,OAAOI;AACT"}
@@ -1 +1 @@
1
- {"version":3,"file":"url.d.ts","sourceRoot":"","sources":["../../../../src/field/lexical/utils/url.ts"],"names":[],"mappings":"AAAA,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAa/C;AAMD,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAoBhD"}
1
+ {"version":3,"file":"url.d.ts","sourceRoot":"","sources":["../../../../src/field/lexical/utils/url.ts"],"names":[],"mappings":"AAAA,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAa/C;AAQD,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAoBhD"}