@payloadcms/richtext-lexical 3.0.0-alpha.59 → 3.0.0-alpha.61
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cell/index.js.map +1 -1
- package/dist/exports/components.js.map +1 -1
- package/dist/field/Field.js.map +1 -1
- package/dist/field/features/align/feature.client.js.map +1 -1
- package/dist/field/features/align/feature.server.js.map +1 -1
- package/dist/field/features/align/floatingSelectToolbarAlignDropdownSection.js.map +1 -1
- package/dist/field/features/blockquote/feature.client.js.map +1 -1
- package/dist/field/features/blockquote/feature.server.js.map +1 -1
- package/dist/field/features/blockquote/markdownTransformer.js.map +1 -1
- package/dist/field/features/blocks/component/BlockContent.js.map +1 -1
- package/dist/field/features/blocks/component/FormSavePlugin.js.map +1 -1
- package/dist/field/features/blocks/component/index.js.map +1 -1
- package/dist/field/features/blocks/component/removeEmptyArrayValues.js.map +1 -1
- package/dist/field/features/blocks/drawer/index.js.map +1 -1
- package/dist/field/features/blocks/feature.client.js.map +1 -1
- package/dist/field/features/blocks/feature.server.js.map +1 -1
- package/dist/field/features/blocks/nodes/BlocksNode.js.map +1 -1
- package/dist/field/features/blocks/plugin/commands.js.map +1 -1
- package/dist/field/features/blocks/plugin/index.js.map +1 -1
- package/dist/field/features/blocks/populationPromise.js.map +1 -1
- package/dist/field/features/blocks/validate.js.map +1 -1
- package/dist/field/features/common/floatingSelectToolbarFeaturesButtonsSection/index.js.map +1 -1
- package/dist/field/features/common/floatingSelectToolbarTextDropdownSection/index.js.map +1 -1
- package/dist/field/features/converters/html/converter/converters/linebreak.js.map +1 -1
- package/dist/field/features/converters/html/converter/converters/paragraph.js.map +1 -1
- package/dist/field/features/converters/html/converter/converters/text.js.map +1 -1
- package/dist/field/features/converters/html/converter/defaultConverters.js.map +1 -1
- package/dist/field/features/converters/html/converter/index.js.map +1 -1
- package/dist/field/features/converters/html/converter/types.js.map +1 -1
- package/dist/field/features/converters/html/feature.server.js.map +1 -1
- package/dist/field/features/converters/html/field/index.js.map +1 -1
- package/dist/field/features/createClientComponent.js.map +1 -1
- package/dist/field/features/createFeaturePropComponent.js.map +1 -1
- package/dist/field/features/debug/testrecorder/feature.client.js.map +1 -1
- package/dist/field/features/debug/testrecorder/feature.server.js.map +1 -1
- package/dist/field/features/debug/testrecorder/plugin/index.js.map +1 -1
- package/dist/field/features/debug/treeview/feature.client.js.map +1 -1
- package/dist/field/features/debug/treeview/feature.server.js.map +1 -1
- package/dist/field/features/debug/treeview/plugin/index.js.map +1 -1
- package/dist/field/features/format/bold/feature.client.js.map +1 -1
- package/dist/field/features/format/bold/feature.server.js.map +1 -1
- package/dist/field/features/format/bold/markdownTransformers.js.map +1 -1
- package/dist/field/features/format/common/floatingSelectToolbarSection.js.map +1 -1
- package/dist/field/features/format/inlinecode/feature.client.js.map +1 -1
- package/dist/field/features/format/inlinecode/feature.server.js.map +1 -1
- package/dist/field/features/format/inlinecode/markdownTransformers.js.map +1 -1
- package/dist/field/features/format/italic/feature.client.js.map +1 -1
- package/dist/field/features/format/italic/feature.server.js.map +1 -1
- package/dist/field/features/format/italic/markdownTransformers.js.map +1 -1
- package/dist/field/features/format/strikethrough/feature.client.js.map +1 -1
- package/dist/field/features/format/strikethrough/feature.server.js.map +1 -1
- package/dist/field/features/format/strikethrough/markdownTransformers.js.map +1 -1
- package/dist/field/features/format/subscript/feature.client.js.map +1 -1
- package/dist/field/features/format/subscript/feature.server.js.map +1 -1
- package/dist/field/features/format/superscript/feature.client.js.map +1 -1
- package/dist/field/features/format/superscript/feature.server.js.map +1 -1
- package/dist/field/features/format/underline/feature.client.js.map +1 -1
- package/dist/field/features/format/underline/feature.server.js.map +1 -1
- package/dist/field/features/heading/feature.client.js.map +1 -1
- package/dist/field/features/heading/feature.server.js.map +1 -1
- package/dist/field/features/heading/markdownTransformer.js.map +1 -1
- package/dist/field/features/indent/feature.client.js.map +1 -1
- package/dist/field/features/indent/feature.server.js.map +1 -1
- package/dist/field/features/indent/floatingSelectToolbarIndentSection.js.map +1 -1
- package/dist/field/features/link/drawer/baseFields.d.ts.map +1 -1
- package/dist/field/features/link/drawer/baseFields.js +8 -19
- package/dist/field/features/link/drawer/baseFields.js.map +1 -1
- package/dist/field/features/link/drawer/index.js.map +1 -1
- package/dist/field/features/link/drawer/types.js.map +1 -1
- package/dist/field/features/link/feature.client.js.map +1 -1
- package/dist/field/features/link/feature.server.d.ts.map +1 -1
- package/dist/field/features/link/feature.server.js +1 -8
- package/dist/field/features/link/feature.server.js.map +1 -1
- package/dist/field/features/link/nodes/AutoLinkNode.js.map +1 -1
- package/dist/field/features/link/nodes/LinkNode.js +2 -2
- package/dist/field/features/link/nodes/LinkNode.js.map +1 -1
- package/dist/field/features/link/nodes/types.js.map +1 -1
- package/dist/field/features/link/plugins/autoLink/index.js.map +1 -1
- package/dist/field/features/link/plugins/clickableLink/index.js.map +1 -1
- package/dist/field/features/link/plugins/floatingLinkEditor/LinkEditor/commands.js.map +1 -1
- package/dist/field/features/link/plugins/floatingLinkEditor/LinkEditor/index.d.ts.map +1 -1
- package/dist/field/features/link/plugins/floatingLinkEditor/LinkEditor/index.js +15 -6
- package/dist/field/features/link/plugins/floatingLinkEditor/LinkEditor/index.js.map +1 -1
- package/dist/field/features/link/plugins/floatingLinkEditor/index.js.map +1 -1
- package/dist/field/features/link/plugins/floatingLinkEditor/types.d.ts +2 -0
- package/dist/field/features/link/plugins/floatingLinkEditor/types.d.ts.map +1 -1
- package/dist/field/features/link/plugins/floatingLinkEditor/types.js.map +1 -1
- package/dist/field/features/link/plugins/floatingLinkEditor/utilities.d.ts.map +1 -1
- package/dist/field/features/link/plugins/floatingLinkEditor/utilities.js +2 -1
- package/dist/field/features/link/plugins/floatingLinkEditor/utilities.js.map +1 -1
- package/dist/field/features/link/plugins/link/index.js.map +1 -1
- package/dist/field/features/link/populationPromise.js.map +1 -1
- package/dist/field/features/lists/checklist/feature.client.js.map +1 -1
- package/dist/field/features/lists/checklist/feature.server.js.map +1 -1
- package/dist/field/features/lists/checklist/markdownTransformers.js.map +1 -1
- package/dist/field/features/lists/checklist/plugin/index.js.map +1 -1
- package/dist/field/features/lists/common/markdown.js.map +1 -1
- package/dist/field/features/lists/htmlConverter.js.map +1 -1
- package/dist/field/features/lists/orderedlist/feature.client.js.map +1 -1
- package/dist/field/features/lists/orderedlist/feature.server.js.map +1 -1
- package/dist/field/features/lists/orderedlist/markdownTransformer.js.map +1 -1
- package/dist/field/features/lists/plugin/index.js.map +1 -1
- package/dist/field/features/lists/unorderedlist/feature.client.js.map +1 -1
- package/dist/field/features/lists/unorderedlist/feature.server.js.map +1 -1
- package/dist/field/features/lists/unorderedlist/markdownTransformer.js.map +1 -1
- package/dist/field/features/migrations/lexicalPluginToLexical/converter/converters/heading/client.js.map +1 -1
- package/dist/field/features/migrations/lexicalPluginToLexical/converter/converters/heading/converter.js.map +1 -1
- package/dist/field/features/migrations/lexicalPluginToLexical/converter/converters/heading/index.js.map +1 -1
- package/dist/field/features/migrations/lexicalPluginToLexical/converter/converters/link/client.js.map +1 -1
- package/dist/field/features/migrations/lexicalPluginToLexical/converter/converters/link/converter.js.map +1 -1
- package/dist/field/features/migrations/lexicalPluginToLexical/converter/converters/link/index.js.map +1 -1
- package/dist/field/features/migrations/lexicalPluginToLexical/converter/converters/list/client.js.map +1 -1
- package/dist/field/features/migrations/lexicalPluginToLexical/converter/converters/list/converter.js.map +1 -1
- package/dist/field/features/migrations/lexicalPluginToLexical/converter/converters/list/index.js.map +1 -1
- package/dist/field/features/migrations/lexicalPluginToLexical/converter/converters/listItem/client.js.map +1 -1
- package/dist/field/features/migrations/lexicalPluginToLexical/converter/converters/listItem/converter.js.map +1 -1
- package/dist/field/features/migrations/lexicalPluginToLexical/converter/converters/listItem/index.js.map +1 -1
- package/dist/field/features/migrations/lexicalPluginToLexical/converter/converters/quote/client.js.map +1 -1
- package/dist/field/features/migrations/lexicalPluginToLexical/converter/converters/quote/converter.js.map +1 -1
- package/dist/field/features/migrations/lexicalPluginToLexical/converter/converters/quote/index.js.map +1 -1
- package/dist/field/features/migrations/lexicalPluginToLexical/converter/converters/unknown/client.js.map +1 -1
- package/dist/field/features/migrations/lexicalPluginToLexical/converter/converters/unknown/converter.js.map +1 -1
- package/dist/field/features/migrations/lexicalPluginToLexical/converter/converters/unknown/index.js.map +1 -1
- package/dist/field/features/migrations/lexicalPluginToLexical/converter/converters/upload/client.js.map +1 -1
- package/dist/field/features/migrations/lexicalPluginToLexical/converter/converters/upload/converter.js.map +1 -1
- package/dist/field/features/migrations/lexicalPluginToLexical/converter/converters/upload/index.js.map +1 -1
- package/dist/field/features/migrations/lexicalPluginToLexical/converter/defaultConverters.js.map +1 -1
- package/dist/field/features/migrations/lexicalPluginToLexical/converter/index.js.map +1 -1
- package/dist/field/features/migrations/lexicalPluginToLexical/converter/types.js.map +1 -1
- package/dist/field/features/migrations/lexicalPluginToLexical/feature.client.js.map +1 -1
- package/dist/field/features/migrations/lexicalPluginToLexical/feature.server.js.map +1 -1
- package/dist/field/features/migrations/lexicalPluginToLexical/nodes/unknownConvertedNode/Component.js.map +1 -1
- package/dist/field/features/migrations/lexicalPluginToLexical/nodes/unknownConvertedNode/index.js.map +1 -1
- package/dist/field/features/migrations/slateToLexical/converter/converters/blockquote/client.js.map +1 -1
- package/dist/field/features/migrations/slateToLexical/converter/converters/blockquote/converter.js.map +1 -1
- package/dist/field/features/migrations/slateToLexical/converter/converters/blockquote/index.js.map +1 -1
- package/dist/field/features/migrations/slateToLexical/converter/converters/heading/client.js.map +1 -1
- package/dist/field/features/migrations/slateToLexical/converter/converters/heading/converter.js.map +1 -1
- package/dist/field/features/migrations/slateToLexical/converter/converters/heading/index.js.map +1 -1
- package/dist/field/features/migrations/slateToLexical/converter/converters/indent/client.js.map +1 -1
- package/dist/field/features/migrations/slateToLexical/converter/converters/indent/converter.js.map +1 -1
- package/dist/field/features/migrations/slateToLexical/converter/converters/indent/index.js.map +1 -1
- package/dist/field/features/migrations/slateToLexical/converter/converters/link/client.js.map +1 -1
- package/dist/field/features/migrations/slateToLexical/converter/converters/link/converter.js.map +1 -1
- package/dist/field/features/migrations/slateToLexical/converter/converters/link/index.js.map +1 -1
- package/dist/field/features/migrations/slateToLexical/converter/converters/listItem/client.js.map +1 -1
- package/dist/field/features/migrations/slateToLexical/converter/converters/listItem/converter.js.map +1 -1
- package/dist/field/features/migrations/slateToLexical/converter/converters/listItem/index.js.map +1 -1
- package/dist/field/features/migrations/slateToLexical/converter/converters/orderedList/client.js.map +1 -1
- package/dist/field/features/migrations/slateToLexical/converter/converters/orderedList/converter.js.map +1 -1
- package/dist/field/features/migrations/slateToLexical/converter/converters/orderedList/index.js.map +1 -1
- package/dist/field/features/migrations/slateToLexical/converter/converters/relationship/client.js.map +1 -1
- package/dist/field/features/migrations/slateToLexical/converter/converters/relationship/converter.js.map +1 -1
- package/dist/field/features/migrations/slateToLexical/converter/converters/relationship/index.js.map +1 -1
- package/dist/field/features/migrations/slateToLexical/converter/converters/unknown/client.js.map +1 -1
- package/dist/field/features/migrations/slateToLexical/converter/converters/unknown/converter.js.map +1 -1
- package/dist/field/features/migrations/slateToLexical/converter/converters/unknown/index.js.map +1 -1
- package/dist/field/features/migrations/slateToLexical/converter/converters/unorderedList/client.js.map +1 -1
- package/dist/field/features/migrations/slateToLexical/converter/converters/unorderedList/converter.js.map +1 -1
- package/dist/field/features/migrations/slateToLexical/converter/converters/unorderedList/index.js.map +1 -1
- package/dist/field/features/migrations/slateToLexical/converter/converters/upload/client.js.map +1 -1
- package/dist/field/features/migrations/slateToLexical/converter/converters/upload/converter.js.map +1 -1
- package/dist/field/features/migrations/slateToLexical/converter/converters/upload/index.js.map +1 -1
- package/dist/field/features/migrations/slateToLexical/converter/defaultConverters.js.map +1 -1
- package/dist/field/features/migrations/slateToLexical/converter/index.js.map +1 -1
- package/dist/field/features/migrations/slateToLexical/converter/types.js.map +1 -1
- package/dist/field/features/migrations/slateToLexical/feature.client.js.map +1 -1
- package/dist/field/features/migrations/slateToLexical/feature.server.js.map +1 -1
- package/dist/field/features/migrations/slateToLexical/nodes/unknownConvertedNode/Component.js.map +1 -1
- package/dist/field/features/migrations/slateToLexical/nodes/unknownConvertedNode/index.js.map +1 -1
- package/dist/field/features/paragraph/feature.client.js.map +1 -1
- package/dist/field/features/paragraph/feature.server.js.map +1 -1
- package/dist/field/features/relationship/drawer/commands.js.map +1 -1
- package/dist/field/features/relationship/drawer/index.js.map +1 -1
- package/dist/field/features/relationship/feature.client.js.map +1 -1
- package/dist/field/features/relationship/feature.server.js.map +1 -1
- package/dist/field/features/relationship/nodes/RelationshipNode.js.map +1 -1
- package/dist/field/features/relationship/nodes/components/RelationshipComponent.js.map +1 -1
- package/dist/field/features/relationship/plugins/index.js.map +1 -1
- package/dist/field/features/relationship/populationPromise.js.map +1 -1
- package/dist/field/features/relationship/utils/EnabledRelationshipsCondition.js +1 -1
- package/dist/field/features/relationship/utils/EnabledRelationshipsCondition.js.map +1 -1
- package/dist/field/features/types.d.ts +6 -1
- package/dist/field/features/types.d.ts.map +1 -1
- package/dist/field/features/types.js.map +1 -1
- package/dist/field/features/upload/component/ExtraFieldsDrawer/index.js.map +1 -1
- package/dist/field/features/upload/component/index.js.map +1 -1
- package/dist/field/features/upload/drawer/commands.js.map +1 -1
- package/dist/field/features/upload/drawer/index.js.map +1 -1
- package/dist/field/features/upload/feature.client.js.map +1 -1
- package/dist/field/features/upload/feature.server.js.map +1 -1
- package/dist/field/features/upload/nodes/UploadNode.js.map +1 -1
- package/dist/field/features/upload/plugin/index.js.map +1 -1
- package/dist/field/features/upload/populationPromise.js.map +1 -1
- package/dist/field/features/upload/validate.js.map +1 -1
- package/dist/field/index.js.map +1 -1
- package/dist/field/lexical/EditorPlugin.js.map +1 -1
- package/dist/field/lexical/LexicalEditor.js.map +1 -1
- package/dist/field/lexical/LexicalProvider.js.map +1 -1
- package/dist/field/lexical/config/client/EditorConfigProvider.js.map +1 -1
- package/dist/field/lexical/config/client/default.js.map +1 -1
- package/dist/field/lexical/config/client/loader.js.map +1 -1
- package/dist/field/lexical/config/client/sanitize.js.map +1 -1
- package/dist/field/lexical/config/server/default.js.map +1 -1
- package/dist/field/lexical/config/server/loader.js.map +1 -1
- package/dist/field/lexical/config/server/sanitize.js.map +1 -1
- package/dist/field/lexical/config/types.js.map +1 -1
- package/dist/field/lexical/nodes/index.js.map +1 -1
- package/dist/field/lexical/plugins/FloatingSelectToolbar/ToolbarButton/index.js.map +1 -1
- package/dist/field/lexical/plugins/FloatingSelectToolbar/ToolbarDropdown/DropDown.js.map +1 -1
- package/dist/field/lexical/plugins/FloatingSelectToolbar/ToolbarDropdown/index.js.map +1 -1
- package/dist/field/lexical/plugins/FloatingSelectToolbar/index.js.map +1 -1
- package/dist/field/lexical/plugins/FloatingSelectToolbar/types.js.map +1 -1
- package/dist/field/lexical/plugins/MarkdownShortcut/index.js.map +1 -1
- package/dist/field/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/LexicalMenu.js.map +1 -1
- package/dist/field/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/index.js.map +1 -1
- package/dist/field/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/types.js.map +1 -1
- package/dist/field/lexical/plugins/SlashMenu/index.js.map +1 -1
- package/dist/field/lexical/plugins/SlashMenu/useMenuTriggerMatch.js.map +1 -1
- package/dist/field/lexical/plugins/handles/AddBlockHandlePlugin/index.js.map +1 -1
- package/dist/field/lexical/plugins/handles/DraggableBlockPlugin/debounce.js.map +1 -1
- package/dist/field/lexical/plugins/handles/DraggableBlockPlugin/getBoundingRectWithoutTransform.js.map +1 -1
- package/dist/field/lexical/plugins/handles/DraggableBlockPlugin/getNodeCloseToPoint.js.map +1 -1
- package/dist/field/lexical/plugins/handles/DraggableBlockPlugin/highlightElemOriginalPosition.js.map +1 -1
- package/dist/field/lexical/plugins/handles/DraggableBlockPlugin/index.js.map +1 -1
- package/dist/field/lexical/plugins/handles/DraggableBlockPlugin/setTargetLine.js.map +1 -1
- package/dist/field/lexical/plugins/handles/utils/getCollapsedMargins.js.map +1 -1
- package/dist/field/lexical/plugins/handles/utils/getTopLevelNodeKeys.js.map +1 -1
- package/dist/field/lexical/plugins/handles/utils/isOnHandleElement.js.map +1 -1
- package/dist/field/lexical/plugins/handles/utils/setHandlePosition.js.map +1 -1
- package/dist/field/lexical/theme/EditorTheme.js.map +1 -1
- package/dist/field/lexical/ui/ContentEditable.js.map +1 -1
- package/dist/field/lexical/ui/icons/AI/index.js.map +1 -1
- package/dist/field/lexical/ui/icons/AlignCenter/index.js.map +1 -1
- package/dist/field/lexical/ui/icons/AlignJustify/index.js.map +1 -1
- package/dist/field/lexical/ui/icons/AlignLeft/index.js.map +1 -1
- package/dist/field/lexical/ui/icons/AlignRight/index.js.map +1 -1
- package/dist/field/lexical/ui/icons/Block/index.js.map +1 -1
- package/dist/field/lexical/ui/icons/Blockquote/index.js.map +1 -1
- package/dist/field/lexical/ui/icons/Bold/index.js.map +1 -1
- package/dist/field/lexical/ui/icons/Checklist/index.js.map +1 -1
- package/dist/field/lexical/ui/icons/Code/index.js.map +1 -1
- package/dist/field/lexical/ui/icons/CodeBlock/index.js.map +1 -1
- package/dist/field/lexical/ui/icons/H1/index.js.map +1 -1
- package/dist/field/lexical/ui/icons/H2/index.js.map +1 -1
- package/dist/field/lexical/ui/icons/H3/index.js.map +1 -1
- package/dist/field/lexical/ui/icons/H4/index.js.map +1 -1
- package/dist/field/lexical/ui/icons/H5/index.js.map +1 -1
- package/dist/field/lexical/ui/icons/H6/index.js.map +1 -1
- package/dist/field/lexical/ui/icons/IndentDecrease/index.js.map +1 -1
- package/dist/field/lexical/ui/icons/IndentIncrease/index.js.map +1 -1
- package/dist/field/lexical/ui/icons/Italic/index.js.map +1 -1
- package/dist/field/lexical/ui/icons/Link/index.js.map +1 -1
- package/dist/field/lexical/ui/icons/OrderedList/index.js.map +1 -1
- package/dist/field/lexical/ui/icons/Relationship/index.js.map +1 -1
- package/dist/field/lexical/ui/icons/Strikethrough/index.js.map +1 -1
- package/dist/field/lexical/ui/icons/Subscript/index.js.map +1 -1
- package/dist/field/lexical/ui/icons/Superscript/index.js.map +1 -1
- package/dist/field/lexical/ui/icons/Text/index.js.map +1 -1
- package/dist/field/lexical/ui/icons/Underline/index.js.map +1 -1
- package/dist/field/lexical/ui/icons/UnorderedList/index.js.map +1 -1
- package/dist/field/lexical/ui/icons/Upload/index.js.map +1 -1
- package/dist/field/lexical/utils/canUseDOM.js.map +1 -1
- package/dist/field/lexical/utils/cloneDeep.js.map +1 -1
- package/dist/field/lexical/utils/environment.js.map +1 -1
- package/dist/field/lexical/utils/getDOMRangeRect.js.map +1 -1
- package/dist/field/lexical/utils/getSelectedNode.js.map +1 -1
- package/dist/field/lexical/utils/guard.js.map +1 -1
- package/dist/field/lexical/utils/invariant.js.map +1 -1
- package/dist/field/lexical/utils/joinClasses.js.map +1 -1
- package/dist/field/lexical/utils/markdown/createBlockNode.js.map +1 -1
- package/dist/field/lexical/utils/nodeFormat.js.map +1 -1
- package/dist/field/lexical/utils/point.js.map +1 -1
- package/dist/field/lexical/utils/rect.js.map +1 -1
- package/dist/field/lexical/utils/setFloatingElemPosition.js.map +1 -1
- package/dist/field/lexical/utils/setFloatingElemPositionForLinkEditor.js.map +1 -1
- package/dist/field/lexical/utils/swipe.js.map +1 -1
- package/dist/field/lexical/utils/url.js.map +1 -1
- package/dist/generateComponentMap.d.ts.map +1 -1
- package/dist/generateComponentMap.js +4 -1
- package/dist/generateComponentMap.js.map +1 -1
- package/dist/generateSchemaMap.d.ts.map +1 -1
- package/dist/generateSchemaMap.js +2 -1
- package/dist/generateSchemaMap.js.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/populate/defaultValue.js.map +1 -1
- package/dist/populate/populate.js.map +1 -1
- package/dist/populate/recurseNestedFields.js.map +1 -1
- package/dist/populate/richTextRelationshipPromise.js.map +1 -1
- package/dist/types.js.map +1 -1
- package/dist/useLexicalFeature.js.map +1 -1
- package/dist/validate/index.js.map +1 -1
- package/dist/validate/validateNodes.js.map +1 -1
- package/package.json +9 -9
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/field/features/upload/validate.ts"],"sourcesContent":["import { fieldAffectsData } from 'payload/types'\nimport { getIDType, isValidID } from 'payload/utilities'\n\nimport type { NodeValidation } from '../types.js'\nimport type { SerializedUploadNode } from './nodes/UploadNode.js'\n\nimport { CAN_USE_DOM } from '../../lexical/utils/canUseDOM.js'\n\nexport const uploadValidation = (): NodeValidation<SerializedUploadNode> => {\n const uploadValidation: NodeValidation<SerializedUploadNode> = ({\n node,\n validation: {\n options: {\n req: {\n payload: { config, db },\n t,\n },\n },\n },\n }) => {\n if (!CAN_USE_DOM) {\n const idField = config.collections\n .find(({ slug }) => slug === node.relationTo)\n .fields.find((field) => fieldAffectsData(field) && field.name === 'id')\n\n const type = getIDType(idField, db?.defaultIDType)\n\n if (!isValidID(node.value?.id, type)) {\n return t('validation:validUploadID')\n }\n }\n\n // TODO: validate upload collection fields\n\n return true\n }\n\n return uploadValidation\n}\n"],"names":["fieldAffectsData","getIDType","isValidID","CAN_USE_DOM","uploadValidation","node","validation","options","req","payload","config","db","t","idField","collections","find","slug","relationTo","fields","field","name","type","defaultIDType","value","id"],"mappings":"AAAA,SAASA,gBAAgB,QAAQ,gBAAe;AAChD,SAASC,SAAS,EAAEC,SAAS,QAAQ,oBAAmB;AAKxD,SAASC,WAAW,QAAQ,mCAAkC;AAE9D,OAAO,MAAMC,mBAAmB;IAC9B,MAAMA,mBAAyD,CAAC,EAC9DC,IAAI,EACJC,YAAY,EACVC,SAAS,EACPC,KAAK,EACHC,SAAS,EAAEC,MAAM,EAAEC,EAAE,EAAE,EACvBC,CAAC,EACF,EACF,EACF,EACF;QACC,IAAI,CAACT,aAAa;YAChB,MAAMU,UAAUH,OAAOI,WAAW,CAC/BC,IAAI,CAAC,CAAC,EAAEC,IAAI,EAAE,GAAKA,SAASX,KAAKY,UAAU,EAC3CC,MAAM,CAACH,IAAI,CAAC,CAACI,QAAUnB,iBAAiBmB,UAAUA,MAAMC,IAAI,KAAK;YAEpE,MAAMC,OAAOpB,UAAUY,SAASF,IAAIW;YAEpC,IAAI,CAACpB,UAAUG,KAAKkB,KAAK,EAAEC,IAAIH,OAAO;gBACpC,OAAOT,EAAE;YACX;QACF;QAEA,0CAA0C;QAE1C,OAAO;IACT;IAEA,OAAOR;AACT,EAAC"}
|
|
1
|
+
{"version":3,"sources":["../../../../src/field/features/upload/validate.ts"],"sourcesContent":["import { fieldAffectsData } from 'payload/types'\nimport { getIDType, isValidID } from 'payload/utilities'\n\nimport type { NodeValidation } from '../types.js'\nimport type { SerializedUploadNode } from './nodes/UploadNode.js'\n\nimport { CAN_USE_DOM } from '../../lexical/utils/canUseDOM.js'\n\nexport const uploadValidation = (): NodeValidation<SerializedUploadNode> => {\n const uploadValidation: NodeValidation<SerializedUploadNode> = ({\n node,\n validation: {\n options: {\n req: {\n payload: { config, db },\n t,\n },\n },\n },\n }) => {\n if (!CAN_USE_DOM) {\n const idField = config.collections\n .find(({ slug }) => slug === node.relationTo)\n .fields.find((field) => fieldAffectsData(field) && field.name === 'id')\n\n const type = getIDType(idField, db?.defaultIDType)\n\n if (!isValidID(node.value?.id, type)) {\n return t('validation:validUploadID')\n }\n }\n\n // TODO: validate upload collection fields\n\n return true\n }\n\n return uploadValidation\n}\n"],"names":["fieldAffectsData","getIDType","isValidID","CAN_USE_DOM","uploadValidation","node","validation","options","req","payload","config","db","t","idField","collections","find","slug","relationTo","fields","field","name","type","defaultIDType","value","id"],"rangeMappings":";;;;;;;;;;;;;;;;","mappings":"AAAA,SAASA,gBAAgB,QAAQ,gBAAe;AAChD,SAASC,SAAS,EAAEC,SAAS,QAAQ,oBAAmB;AAKxD,SAASC,WAAW,QAAQ,mCAAkC;AAE9D,OAAO,MAAMC,mBAAmB;IAC9B,MAAMA,mBAAyD,CAAC,EAC9DC,IAAI,EACJC,YAAY,EACVC,SAAS,EACPC,KAAK,EACHC,SAAS,EAAEC,MAAM,EAAEC,EAAE,EAAE,EACvBC,CAAC,EACF,EACF,EACF,EACF;QACC,IAAI,CAACT,aAAa;YAChB,MAAMU,UAAUH,OAAOI,WAAW,CAC/BC,IAAI,CAAC,CAAC,EAAEC,IAAI,EAAE,GAAKA,SAASX,KAAKY,UAAU,EAC3CC,MAAM,CAACH,IAAI,CAAC,CAACI,QAAUnB,iBAAiBmB,UAAUA,MAAMC,IAAI,KAAK;YAEpE,MAAMC,OAAOpB,UAAUY,SAASF,IAAIW;YAEpC,IAAI,CAACpB,UAAUG,KAAKkB,KAAK,EAAEC,IAAIH,OAAO;gBACpC,OAAOT,EAAE;YACX;QACF;QAEA,0CAA0C;QAE1C,OAAO;IACT;IAEA,OAAOR;AACT,EAAC"}
|
package/dist/field/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/field/index.tsx"],"sourcesContent":["'use client'\nimport type { FormFieldBase } from '@payloadcms/ui/fields/shared'\nimport type { EditorConfig as LexicalEditorConfig } from 'lexical/LexicalEditor.js'\n\nimport { ShimmerEffect } from '@payloadcms/ui/elements/ShimmerEffect'\nimport { useFieldProps } from '@payloadcms/ui/forms/FieldPropsProvider'\nimport { useClientFunctions } from '@payloadcms/ui/providers/ClientFunction'\nimport React, { Suspense, lazy, useEffect, useState } from 'react'\n\nimport type { GeneratedFeatureProviderComponent } from '../types.js'\nimport type { FeatureProviderClient } from './features/types.js'\nimport type { SanitizedClientEditorConfig } from './lexical/config/types.js'\n\nimport { defaultEditorLexicalConfig } from './lexical/config/client/default.js'\nimport { loadClientFeatures } from './lexical/config/client/loader.js'\nimport { sanitizeClientEditorConfig } from './lexical/config/client/sanitize.js'\n\nconst RichTextEditor = lazy(() =>\n import('./Field.js').then((module) => ({ default: module.RichText })),\n)\n\nexport const RichTextField: React.FC<\n FormFieldBase & {\n lexicalEditorConfig: LexicalEditorConfig\n name: string\n richTextComponentMap: Map<string, React.ReactNode>\n }\n> = (props) => {\n const { lexicalEditorConfig, richTextComponentMap } = props\n const { schemaPath } = useFieldProps()\n const clientFunctions = useClientFunctions()\n const [hasLoadedFeatures, setHasLoadedFeatures] = useState(false)\n\n const [featureProviders, setFeatureProviders] = useState<FeatureProviderClient<unknown>[]>([])\n\n const [finalSanitizedEditorConfig, setFinalSanitizedEditorConfig] =\n useState<SanitizedClientEditorConfig>(null)\n\n let featureProviderComponents: GeneratedFeatureProviderComponent[] = richTextComponentMap.get(\n 'features',\n ) as GeneratedFeatureProviderComponent[] // TODO: Type better\n // order by order\n featureProviderComponents = featureProviderComponents.sort((a, b) => a.order - b.order)\n\n const featureComponentsWithFeaturesLength =\n Array.from(richTextComponentMap.keys()).filter(\n (key) => key.startsWith(`feature.`) && !key.includes('.fields.'),\n ).length + featureProviderComponents.length\n\n useEffect(() => {\n if (!hasLoadedFeatures) {\n const featureProvidersLocal: FeatureProviderClient<unknown>[] = []\n let featureProvidersAndComponentsLoaded = 0\n\n Object.entries(clientFunctions).forEach(([key, plugin]) => {\n if (key.startsWith(`lexicalFeature.${schemaPath}.`)) {\n if (!key.includes('.components.')) {\n featureProvidersLocal.push(plugin)\n }\n featureProvidersAndComponentsLoaded++\n }\n })\n\n if (featureProvidersAndComponentsLoaded === featureComponentsWithFeaturesLength) {\n setFeatureProviders(featureProvidersLocal)\n setHasLoadedFeatures(true)\n\n /**\n * Loaded feature provided => create the final sanitized editor config\n */\n\n const resolvedClientFeatures = loadClientFeatures({\n clientFunctions,\n schemaPath,\n unSanitizedEditorConfig: {\n features: featureProvidersLocal,\n lexical: lexicalEditorConfig,\n },\n })\n\n setFinalSanitizedEditorConfig(\n sanitizeClientEditorConfig(\n lexicalEditorConfig ? lexicalEditorConfig : defaultEditorLexicalConfig,\n resolvedClientFeatures,\n ),\n )\n }\n }\n }, [\n hasLoadedFeatures,\n clientFunctions,\n schemaPath,\n featureProviderComponents.length,\n featureProviders,\n finalSanitizedEditorConfig,\n lexicalEditorConfig,\n featureComponentsWithFeaturesLength,\n ])\n\n if (!hasLoadedFeatures) {\n return (\n <React.Fragment>\n {Array.isArray(featureProviderComponents) &&\n featureProviderComponents.map((featureProvider) => {\n // get all components starting with key feature.${FeatureProvider.key}.components.{featureComponentKey}\n const featureComponentKeys = Array.from(richTextComponentMap.keys()).filter((key) =>\n key.startsWith(`feature.${featureProvider.key}.components.`),\n )\n const featureComponents: React.ReactNode[] = featureComponentKeys.map((key) => {\n return richTextComponentMap.get(key)\n }) // TODO: Type better\n\n return (\n <React.Fragment key={featureProvider.key}>\n {featureComponents?.length\n ? featureComponents.map((FeatureComponent) => {\n return FeatureComponent\n })\n : null}\n {featureProvider.ClientComponent}\n </React.Fragment>\n )\n })}\n </React.Fragment>\n )\n }\n\n return (\n <Suspense fallback={<ShimmerEffect height=\"35vh\" />}>\n {finalSanitizedEditorConfig && (\n <RichTextEditor {...props} editorConfig={finalSanitizedEditorConfig} />\n )}\n </Suspense>\n )\n}\n"],"names":["ShimmerEffect","useFieldProps","useClientFunctions","React","Suspense","lazy","useEffect","useState","defaultEditorLexicalConfig","loadClientFeatures","sanitizeClientEditorConfig","RichTextEditor","then","module","default","RichText","RichTextField","props","lexicalEditorConfig","richTextComponentMap","schemaPath","clientFunctions","hasLoadedFeatures","setHasLoadedFeatures","featureProviders","setFeatureProviders","finalSanitizedEditorConfig","setFinalSanitizedEditorConfig","featureProviderComponents","get","sort","a","b","order","featureComponentsWithFeaturesLength","Array","from","keys","filter","key","startsWith","includes","length","featureProvidersLocal","featureProvidersAndComponentsLoaded","Object","entries","forEach","plugin","push","resolvedClientFeatures","unSanitizedEditorConfig","features","lexical","Fragment","isArray","map","featureProvider","featureComponentKeys","featureComponents","FeatureComponent","ClientComponent","fallback","height","editorConfig"],"mappings":"AAAA;AAIA,SAASA,aAAa,QAAQ,wCAAuC;AACrE,SAASC,aAAa,QAAQ,0CAAyC;AACvE,SAASC,kBAAkB,QAAQ,0CAAyC;AAC5E,OAAOC,SAASC,QAAQ,EAAEC,IAAI,EAA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use client'\nimport type { FormFieldBase } from '@payloadcms/ui/fields/shared'\nimport type { EditorConfig as LexicalEditorConfig } from 'lexical/LexicalEditor.js'\n\nimport { ShimmerEffect } from '@payloadcms/ui/elements/ShimmerEffect'\nimport { useFieldProps } from '@payloadcms/ui/forms/FieldPropsProvider'\nimport { useClientFunctions } from '@payloadcms/ui/providers/ClientFunction'\nimport React, { Suspense, lazy, useEffect, useState } from 'react'\n\nimport type { GeneratedFeatureProviderComponent } from '../types.js'\nimport type { FeatureProviderClient } from './features/types.js'\nimport type { SanitizedClientEditorConfig } from './lexical/config/types.js'\n\nimport { defaultEditorLexicalConfig } from './lexical/config/client/default.js'\nimport { loadClientFeatures } from './lexical/config/client/loader.js'\nimport { sanitizeClientEditorConfig } from './lexical/config/client/sanitize.js'\n\nconst RichTextEditor = lazy(() =>\n import('./Field.js').then((module) => ({ default: module.RichText })),\n)\n\nexport const RichTextField: React.FC<\n FormFieldBase & {\n lexicalEditorConfig: LexicalEditorConfig\n name: string\n richTextComponentMap: Map<string, React.ReactNode>\n }\n> = (props) => {\n const { lexicalEditorConfig, richTextComponentMap } = props\n const { schemaPath } = useFieldProps()\n const clientFunctions = useClientFunctions()\n const [hasLoadedFeatures, setHasLoadedFeatures] = useState(false)\n\n const [featureProviders, setFeatureProviders] = useState<FeatureProviderClient<unknown>[]>([])\n\n const [finalSanitizedEditorConfig, setFinalSanitizedEditorConfig] =\n useState<SanitizedClientEditorConfig>(null)\n\n let featureProviderComponents: GeneratedFeatureProviderComponent[] = richTextComponentMap.get(\n 'features',\n ) as GeneratedFeatureProviderComponent[] // TODO: Type better\n // order by order\n featureProviderComponents = featureProviderComponents.sort((a, b) => a.order - b.order)\n\n const featureComponentsWithFeaturesLength =\n Array.from(richTextComponentMap.keys()).filter(\n (key) => key.startsWith(`feature.`) && !key.includes('.fields.'),\n ).length + featureProviderComponents.length\n\n useEffect(() => {\n if (!hasLoadedFeatures) {\n const featureProvidersLocal: FeatureProviderClient<unknown>[] = []\n let featureProvidersAndComponentsLoaded = 0\n\n Object.entries(clientFunctions).forEach(([key, plugin]) => {\n if (key.startsWith(`lexicalFeature.${schemaPath}.`)) {\n if (!key.includes('.components.')) {\n featureProvidersLocal.push(plugin)\n }\n featureProvidersAndComponentsLoaded++\n }\n })\n\n if (featureProvidersAndComponentsLoaded === featureComponentsWithFeaturesLength) {\n setFeatureProviders(featureProvidersLocal)\n setHasLoadedFeatures(true)\n\n /**\n * Loaded feature provided => create the final sanitized editor config\n */\n\n const resolvedClientFeatures = loadClientFeatures({\n clientFunctions,\n schemaPath,\n unSanitizedEditorConfig: {\n features: featureProvidersLocal,\n lexical: lexicalEditorConfig,\n },\n })\n\n setFinalSanitizedEditorConfig(\n sanitizeClientEditorConfig(\n lexicalEditorConfig ? lexicalEditorConfig : defaultEditorLexicalConfig,\n resolvedClientFeatures,\n ),\n )\n }\n }\n }, [\n hasLoadedFeatures,\n clientFunctions,\n schemaPath,\n featureProviderComponents.length,\n featureProviders,\n finalSanitizedEditorConfig,\n lexicalEditorConfig,\n featureComponentsWithFeaturesLength,\n ])\n\n if (!hasLoadedFeatures) {\n return (\n <React.Fragment>\n {Array.isArray(featureProviderComponents) &&\n featureProviderComponents.map((featureProvider) => {\n // get all components starting with key feature.${FeatureProvider.key}.components.{featureComponentKey}\n const featureComponentKeys = Array.from(richTextComponentMap.keys()).filter((key) =>\n key.startsWith(`feature.${featureProvider.key}.components.`),\n )\n const featureComponents: React.ReactNode[] = featureComponentKeys.map((key) => {\n return richTextComponentMap.get(key)\n }) // TODO: Type better\n\n return (\n <React.Fragment key={featureProvider.key}>\n {featureComponents?.length\n ? featureComponents.map((FeatureComponent) => {\n return FeatureComponent\n })\n : null}\n {featureProvider.ClientComponent}\n </React.Fragment>\n )\n })}\n </React.Fragment>\n )\n }\n\n return (\n <Suspense fallback={<ShimmerEffect height=\"35vh\" />}>\n {finalSanitizedEditorConfig && (\n <RichTextEditor {...props} editorConfig={finalSanitizedEditorConfig} />\n )}\n </Suspense>\n )\n}\n"],"names":["ShimmerEffect","useFieldProps","useClientFunctions","React","Suspense","lazy","useEffect","useState","defaultEditorLexicalConfig","loadClientFeatures","sanitizeClientEditorConfig","RichTextEditor","then","module","default","RichText","RichTextField","props","lexicalEditorConfig","richTextComponentMap","schemaPath","clientFunctions","hasLoadedFeatures","setHasLoadedFeatures","featureProviders","setFeatureProviders","finalSanitizedEditorConfig","setFinalSanitizedEditorConfig","featureProviderComponents","get","sort","a","b","order","featureComponentsWithFeaturesLength","Array","from","keys","filter","key","startsWith","includes","length","featureProvidersLocal","featureProvidersAndComponentsLoaded","Object","entries","forEach","plugin","push","resolvedClientFeatures","unSanitizedEditorConfig","features","lexical","Fragment","isArray","map","featureProvider","featureComponentKeys","featureComponents","FeatureComponent","ClientComponent","fallback","height","editorConfig"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA;AAIA,SAASA,aAAa,QAAQ,wCAAuC;AACrE,SAASC,aAAa,QAAQ,0CAAyC;AACvE,SAASC,kBAAkB,QAAQ,0CAAyC;AAC5E,OAAOC,SAASC,QAAQ,EAAEC,IAAI,EAAEC,SAAS,EAAEC,QAAQ,QAAQ,QAAO;AAMlE,SAASC,0BAA0B,QAAQ,qCAAoC;AAC/E,SAASC,kBAAkB,QAAQ,oCAAmC;AACtE,SAASC,0BAA0B,QAAQ,sCAAqC;AAEhF,MAAMC,+BAAiBN,KAAK,IAC1B,MAAM,CAAC,cAAcO,IAAI,CAAC,CAACC,SAAY,CAAA;YAAEC,SAASD,OAAOE,QAAQ;QAAC,CAAA;AAGpE,OAAO,MAAMC,gBAMT,CAACC;IACH,MAAM,EAAEC,mBAAmB,EAAEC,oBAAoB,EAAE,GAAGF;IACtD,MAAM,EAAEG,UAAU,EAAE,GAAGnB;IACvB,MAAMoB,kBAAkBnB;IACxB,MAAM,CAACoB,mBAAmBC,qBAAqB,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BACE,oBAACnB,MAAMmD,QAAQ,QACZnB,MAAMoB,OAAO,CAAC3B,8BACbA,0BAA0B4B,GAAG,CAAC,CAACC;YAC7B,uGAAuG;YACvG,MAAMC,uBAAuBvB,MAAMC,IAAI,CAACjB,qBAAqBkB,IAAI,IAAIC,MAAM,CAAC,CAACC,MAC3EA,IAAIC,UAAU,CAAC,CAAC,QAAQ,EAAEiB,gBAAgBlB,GAAG,CAAC,YAAY,CAAC;YAE7D,MAAMoB,oBAAuCD,qBAAqBF,GAAG,CAAC,CAACjB;gBACrE,OAAOpB,qBAAqBU,GAAG,CAACU;YAClC,GAAG,oBAAoB;;YAEvB,qBACE,oBAACpC,MAAMmD,QAAQ;gBAACf,KAAKkB,gBAAgBlB,GAAG;eACrCoB,mBAAmBjB,SAChBiB,kBAAkBH,GAAG,CAAC,CAACI;gBACrB,OAAOA;YACT,KACA,MACHH,gBAAgBI,eAAe;QAGtC;IAGR;IAEA,qBACE,oBAACzD;QAAS0D,wBAAU,oBAAC9D;YAAc+D,QAAO;;OACvCrC,4CACC,oBAACf;QAAgB,GAAGM,KAAK;QAAE+C,cAActC;;AAIjD,EAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/field/lexical/EditorPlugin.tsx"],"sourcesContent":["import * as React from 'react'\n\nimport type { SanitizedPlugin } from '../features/types.js'\n\nexport const EditorPlugin: React.FC<{\n anchorElem?: HTMLDivElement\n plugin: SanitizedPlugin\n}> = ({ anchorElem, plugin }) => {\n if (plugin.position === 'floatingAnchorElem') {\n return plugin.Component && <plugin.Component anchorElem={anchorElem} />\n }\n\n return plugin.Component && <plugin.Component />\n}\n"],"names":["React","EditorPlugin","anchorElem","plugin","position","Component"],"mappings":"AAAA,YAAYA,WAAW,QAAO;AAI9B,OAAO,MAAMC,eAGR,CAAC,EAAEC,UAAU,EAAEC,MAAM,EAAE;IAC1B,IAAIA,OAAOC,QAAQ,KAAK,sBAAsB;QAC5C,OAAOD,OAAOE,SAAS,kBAAI,oBAACF,OAAOE,SAAS;YAACH,YAAYA;;IAC3D;IAEA,OAAOC,OAAOE,SAAS,kBAAI,oBAACF,OAAOE,SAAS;AAC9C,EAAC"}
|
|
1
|
+
{"version":3,"sources":["../../../src/field/lexical/EditorPlugin.tsx"],"sourcesContent":["import * as React from 'react'\n\nimport type { SanitizedPlugin } from '../features/types.js'\n\nexport const EditorPlugin: React.FC<{\n anchorElem?: HTMLDivElement\n plugin: SanitizedPlugin\n}> = ({ anchorElem, plugin }) => {\n if (plugin.position === 'floatingAnchorElem') {\n return plugin.Component && <plugin.Component anchorElem={anchorElem} />\n }\n\n return plugin.Component && <plugin.Component />\n}\n"],"names":["React","EditorPlugin","anchorElem","plugin","position","Component"],"rangeMappings":";;;;;;;;","mappings":"AAAA,YAAYA,WAAW,QAAO;AAI9B,OAAO,MAAMC,eAGR,CAAC,EAAEC,UAAU,EAAEC,MAAM,EAAE;IAC1B,IAAIA,OAAOC,QAAQ,KAAK,sBAAsB;QAC5C,OAAOD,OAAOE,SAAS,kBAAI,oBAACF,OAAOE,SAAS;YAACH,YAAYA;;IAC3D;IAEA,OAAOC,OAAOE,SAAS,kBAAI,oBAACF,OAAOE,SAAS;AAC9C,EAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/field/lexical/LexicalEditor.tsx"],"sourcesContent":["'use client'\nimport lexicalComposerContextImport from '@lexical/react/LexicalComposerContext.js'\nconst { useLexicalComposerContext } = lexicalComposerContextImport\n\nimport LexicalErrorBoundary from '@lexical/react/LexicalErrorBoundary.js'\nimport lexicalHistoryPluginImport from '@lexical/react/LexicalHistoryPlugin.js'\nconst { HistoryPlugin } = lexicalHistoryPluginImport\n\nimport lexicalOnChangePluginImport from '@lexical/react/LexicalOnChangePlugin.js'\nconst { OnChangePlugin } = lexicalOnChangePluginImport\n\nimport lexicalRichTextPluginImport from '@lexical/react/LexicalRichTextPlugin.js'\nconst { RichTextPlugin } = lexicalRichTextPluginImport\n\nimport lexicalTabIndentationPluginImport from '@lexical/react/LexicalTabIndentationPlugin.js'\nconst { TabIndentationPlugin } = lexicalTabIndentationPluginImport\n\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":["lexicalComposerContextImport","useLexicalComposerContext","LexicalErrorBoundary","lexicalHistoryPluginImport","HistoryPlugin","lexicalOnChangePluginImport","OnChangePlugin","lexicalRichTextPluginImport","RichTextPlugin","lexicalTabIndentationPluginImport","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"],"mappings":"AAAA;AACA,OAAOA,kCAAkC,2CAA0C;AACnF,MAAM,EAAEC,yBAAyB,EAAE,GAAGD;AAEtC,OAAOE,0BAA0B,yCAAwC;AACzE,OAAOC,gCAAgC,yCAAwC;AAC/E,MAAM,EAAEC,aAAa,EAAE,GAAGD;AAE1B,OAAOE,iCAAiC,0CAAyC;AACjF,MAAM,EAAEC,cAAc,EAAE,GAAGD;AAE3B,OAAOE,iCAAiC,0CAAyC;AACjF,MAAM,EAAEC,cAAc,EAAE,GAAGD;AAE3B,OAAOE,uCAAuC,gDAA+C;AAC7F,MAAM,EAAEC,oBAAoB,EAAE,GAAGD;AAEjC,YAAYE,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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tsx"],"sourcesContent":["'use client'\nimport lexicalComposerContextImport from '@lexical/react/LexicalComposerContext.js'\nconst { useLexicalComposerContext } = lexicalComposerContextImport\n\nimport LexicalErrorBoundary from '@lexical/react/LexicalErrorBoundary.js'\nimport lexicalHistoryPluginImport from '@lexical/react/LexicalHistoryPlugin.js'\nconst { HistoryPlugin } = lexicalHistoryPluginImport\n\nimport lexicalOnChangePluginImport from '@lexical/react/LexicalOnChangePlugin.js'\nconst { OnChangePlugin } = lexicalOnChangePluginImport\n\nimport lexicalRichTextPluginImport from '@lexical/react/LexicalRichTextPlugin.js'\nconst { RichTextPlugin } = lexicalRichTextPluginImport\n\nimport lexicalTabIndentationPluginImport from '@lexical/react/LexicalTabIndentationPlugin.js'\nconst { TabIndentationPlugin } = lexicalTabIndentationPluginImport\n\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":["lexicalComposerContextImport","useLexicalComposerContext","LexicalErrorBoundary","lexicalHistoryPluginImport","HistoryPlugin","lexicalOnChangePluginImport","OnChangePlugin","lexicalRichTextPluginImport","RichTextPlugin","lexicalTabIndentationPluginImport","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,OAAOA,kCAAkC,2CAA0C;AACnF,MAAM,EAAEC,yBAAyB,EAAE,GAAGD;AAEtC,OAAOE,0BAA0B,yCAAwC;AACzE,O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AAU,oBAChB,oBAACjD,MAAM8B,QAAQ,sBACb,oBAACrC,sBACAmB,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 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/field/lexical/LexicalProvider.tsx"],"sourcesContent":["'use client'\nimport type { EditorState, SerializedEditorState } from 'lexical'\nimport type { LexicalEditor } from 'lexical'\n\nimport lexicalComposerImport from '@lexical/react/LexicalComposer.js'\nconst { LexicalComposer } = lexicalComposerImport\n\nimport type { InitialConfigType } from '@lexical/react/LexicalComposer.js'\nimport type { FormFieldBase } from '@payloadcms/ui/fields/shared'\n\nimport * as React from 'react'\n\nimport type { SanitizedClientEditorConfig } from './config/types.js'\n\nimport { LexicalEditor as LexicalEditorComponent } from './LexicalEditor.js'\nimport { EditorConfigProvider } from './config/client/EditorConfigProvider.js'\nimport { getEnabledNodes } from './nodes/index.js'\n\nexport type LexicalProviderProps = {\n editorConfig: SanitizedClientEditorConfig\n fieldProps: FormFieldBase & {\n editorConfig: SanitizedClientEditorConfig // With rendered features n stuff\n name: string\n richTextComponentMap: Map<string, React.ReactNode>\n }\n onChange: (editorState: EditorState, editor: LexicalEditor, tags: Set<string>) => void\n path: string\n readOnly: boolean\n value: SerializedEditorState\n}\nexport const LexicalProvider: React.FC<LexicalProviderProps> = (props) => {\n const { editorConfig, fieldProps, onChange, path, readOnly } = props\n let { value } = props\n\n const [initialConfig, setInitialConfig] = React.useState<InitialConfigType | null>(null)\n\n // set lexical config in useEffect: // TODO: Is this the most performant way to do this? Prob not\n React.useEffect(() => {\n const newInitialConfig: InitialConfigType = {\n editable: readOnly !== true,\n editorState: value != null ? JSON.stringify(value) : undefined,\n namespace: editorConfig.lexical.namespace,\n nodes: [...getEnabledNodes({ editorConfig })],\n onError: (error: Error) => {\n throw error\n },\n theme: editorConfig.lexical.theme,\n }\n setInitialConfig(newInitialConfig)\n }, [editorConfig, readOnly, value])\n\n if (editorConfig?.features?.hooks?.load?.length) {\n editorConfig.features.hooks.load.forEach((hook) => {\n value = hook({ incomingEditorState: value })\n })\n }\n\n if (value && typeof value !== 'object') {\n throw new Error(\n 'The value passed to the Lexical editor is not an object. This is not supported. Please remove the data from the field and start again. This is the value that was passed in: ' +\n JSON.stringify(value),\n )\n }\n\n if (value && Array.isArray(value) && !('root' in value)) {\n throw new Error(\n 'You have tried to pass in data from the old, Slate editor, to the new, Lexical editor. This is not supported. There is no automatic conversion from Slate to Lexical data available yet (coming soon). Please remove the data from the field and start again.',\n )\n }\n\n if (value && 'jsonContent' in value) {\n throw new Error(\n 'You have tried to pass in data from payload-plugin-lexical. This is not supported. The data structure has changed in this editor, compared to the plugin, and there is no automatic conversion available yet (coming soon). Please remove the data from the field and start again.',\n )\n }\n\n if (!initialConfig) {\n return <p>Loading...</p>\n }\n\n return (\n <LexicalComposer initialConfig={initialConfig} key={path}>\n <EditorConfigProvider editorConfig={editorConfig} fieldProps={fieldProps}>\n <div className=\"editor-shell\">\n <LexicalEditorComponent editorConfig={editorConfig} onChange={onChange} />\n </div>\n </EditorConfigProvider>\n </LexicalComposer>\n )\n}\n"],"names":["lexicalComposerImport","LexicalComposer","React","LexicalEditor","LexicalEditorComponent","EditorConfigProvider","getEnabledNodes","LexicalProvider","props","editorConfig","fieldProps","onChange","path","readOnly","value","initialConfig","setInitialConfig","useState","useEffect","newInitialConfig","editable","editorState","JSON","stringify","undefined","namespace","lexical","nodes","onError","error","theme","features","hooks","load","length","forEach","hook","incomingEditorState","Error","Array","isArray","p","key","div","className"],"mappings":"AAAA;AAIA,OAAOA,2BAA2B,oCAAmC;AACrE,MAAM,EAAEC,eAAe,EAAE,GAAGD;AAK5B,YAAYE,WAAW,QAAO;AAI9B,SAASC,iBAAiBC,sBAAsB,QAAQ,qBAAoB;AAC5E,SAASC,oBAAoB,QAAQ,0CAAyC;AAC9E,SAASC,eAAe,QAAQ,mBAAkB;AAclD,OAAO,MAAMC,kBAAkD,CAACC;IAC9D,MAAM,EAAEC,YAAY,EAAEC,UAAU,EAAEC,QAAQ,EAAEC,IAAI,EAAEC,QAAQ,EAAE,GAAGL;IAC/D,IAAI,EAAEM,KAAK,EAAE,GAAGN;IAEhB,MAAM,CAACO,eAAeC,iBAAiB,GAAGd,MAAMe,QAAQ,CAA2B;IAEnF,iGAAiG;IACjGf,MAAMgB,SAAS,CAAC;QACd,MAAMC,mBAAsC;YAC1CC,UAAUP,aAAa;YACvBQ,aAAaP,SAAS,OAAOQ,KAAKC,SAAS,CAACT,SAASU;YACrDC,WAAWhB,aAAaiB,OAAO,CAACD,SAAS;YACzCE,OAAO;mBAAIrB,gBAAgB;oBAAEG;gBAAa;aAAG;YAC7CmB,SAAS,CAACC;gBACR,MAAMA;YACR;YACAC,OAAOrB,aAAaiB,OAAO,CAACI,KAAK;QACnC;QACAd,iBAAiBG;IACnB,GAAG;QAACV;QAAcI;QAAUC;KAAM;IAElC,IAAIL,cAAcsB,UAAUC,OAAOC,MAAMC,QAAQ;QAC/CzB,aAAasB,QAAQ,CAACC,KAAK,CAACC,IAAI,CAACE,OAAO,CAAC,CAACC;YACxCtB,QAAQsB,KAAK;gBAAEC,qBAAqBvB;YAAM;QAC5C;IACF;IAEA,IAAIA,SAAS,OAAOA,UAAU,UAAU;QACtC,MAAM,IAAIwB,MACR,kLACEhB,KAAKC,SAAS,CAACT;IAErB;IAEA,IAAIA,SAASyB,MAAMC,OAAO,CAAC1B,UAAU,CAAE,CAAA,UAAUA,KAAI,GAAI;QACvD,MAAM,IAAIwB,MACR;IAEJ;IAEA,IAAIxB,SAAS,iBAAiBA,OAAO;QACnC,MAAM,IAAIwB,MACR;IAEJ;IAEA,IAAI,CAACvB,eAAe;QAClB,qBAAO,oBAAC0B,WAAE;IACZ;IAEA,qBACE,oBAACxC;QAAgBc,eAAeA;QAAe2B,KAAK9B;qBAClD,oBAACP;QAAqBI,cAAcA;QAAcC,YAAYA;qBAC5D,oBAACiC;QAAIC,WAAU;qBACb,oBAACxC;QAAuBK,cAAcA;QAAcE,UAAUA;;AAKxE,EAAC"}
|
|
1
|
+
{"version":3,"sources":["../../../src/field/lexical/LexicalProvider.tsx"],"sourcesContent":["'use client'\nimport type { EditorState, SerializedEditorState } from 'lexical'\nimport type { LexicalEditor } from 'lexical'\n\nimport lexicalComposerImport from '@lexical/react/LexicalComposer.js'\nconst { LexicalComposer } = lexicalComposerImport\n\nimport type { InitialConfigType } from '@lexical/react/LexicalComposer.js'\nimport type { FormFieldBase } from '@payloadcms/ui/fields/shared'\n\nimport * as React from 'react'\n\nimport type { SanitizedClientEditorConfig } from './config/types.js'\n\nimport { LexicalEditor as LexicalEditorComponent } from './LexicalEditor.js'\nimport { EditorConfigProvider } from './config/client/EditorConfigProvider.js'\nimport { getEnabledNodes } from './nodes/index.js'\n\nexport type LexicalProviderProps = {\n editorConfig: SanitizedClientEditorConfig\n fieldProps: FormFieldBase & {\n editorConfig: SanitizedClientEditorConfig // With rendered features n stuff\n name: string\n richTextComponentMap: Map<string, React.ReactNode>\n }\n onChange: (editorState: EditorState, editor: LexicalEditor, tags: Set<string>) => void\n path: string\n readOnly: boolean\n value: SerializedEditorState\n}\nexport const LexicalProvider: React.FC<LexicalProviderProps> = (props) => {\n const { editorConfig, fieldProps, onChange, path, readOnly } = props\n let { value } = props\n\n const [initialConfig, setInitialConfig] = React.useState<InitialConfigType | null>(null)\n\n // set lexical config in useEffect: // TODO: Is this the most performant way to do this? Prob not\n React.useEffect(() => {\n const newInitialConfig: InitialConfigType = {\n editable: readOnly !== true,\n editorState: value != null ? JSON.stringify(value) : undefined,\n namespace: editorConfig.lexical.namespace,\n nodes: [...getEnabledNodes({ editorConfig })],\n onError: (error: Error) => {\n throw error\n },\n theme: editorConfig.lexical.theme,\n }\n setInitialConfig(newInitialConfig)\n }, [editorConfig, readOnly, value])\n\n if (editorConfig?.features?.hooks?.load?.length) {\n editorConfig.features.hooks.load.forEach((hook) => {\n value = hook({ incomingEditorState: value })\n })\n }\n\n if (value && typeof value !== 'object') {\n throw new Error(\n 'The value passed to the Lexical editor is not an object. This is not supported. Please remove the data from the field and start again. This is the value that was passed in: ' +\n JSON.stringify(value),\n )\n }\n\n if (value && Array.isArray(value) && !('root' in value)) {\n throw new Error(\n 'You have tried to pass in data from the old, Slate editor, to the new, Lexical editor. This is not supported. There is no automatic conversion from Slate to Lexical data available yet (coming soon). Please remove the data from the field and start again.',\n )\n }\n\n if (value && 'jsonContent' in value) {\n throw new Error(\n 'You have tried to pass in data from payload-plugin-lexical. This is not supported. The data structure has changed in this editor, compared to the plugin, and there is no automatic conversion available yet (coming soon). Please remove the data from the field and start again.',\n )\n }\n\n if (!initialConfig) {\n return <p>Loading...</p>\n }\n\n return (\n <LexicalComposer initialConfig={initialConfig} key={path}>\n <EditorConfigProvider editorConfig={editorConfig} fieldProps={fieldProps}>\n <div className=\"editor-shell\">\n <LexicalEditorComponent editorConfig={editorConfig} onChange={onChange} />\n </div>\n </EditorConfigProvider>\n </LexicalComposer>\n )\n}\n"],"names":["lexicalComposerImport","LexicalComposer","React","LexicalEditor","LexicalEditorComponent","EditorConfigProvider","getEnabledNodes","LexicalProvider","props","editorConfig","fieldProps","onChange","path","readOnly","value","initialConfig","setInitialConfig","useState","useEffect","newInitialConfig","editable","editorState","JSON","stringify","undefined","namespace","lexical","nodes","onError","error","theme","features","hooks","load","length","forEach","hook","incomingEditorState","Error","Array","isAr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ASyB,MAAMC,OAAO,CAAC1B,UAAU,CAAE,CAAA,UAAUA,KAAI,GAAI;QACvD,MAAM,IAAIwB,MACR;IAEJ;IAEA,IAAIxB,SAAS,iBAAiBA,OAAO;QACnC,MAAM,IAAIwB,MACR;IAEJ;IAEA,IAAI,CAACvB,eAAe;QAClB,qBAAO,oBAAC0B,WAAE;IACZ;IAEA,qBACE,oBAACxC;QAAgBc,eAAeA;QAAe2B,KAAK9B;qBAClD,oBAACP;QAAqBI,cAAcA;QAAcC,YAAYA;qBAC5D,oBAACiC;QAAIC,WAAU;qBACb,oBAACxC;QAAuBK,cAAcA;QAAcE,UAAUA;;AAKxE,EAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/field/lexical/config/client/EditorConfigProvider.tsx"],"sourcesContent":["'use client'\n\nimport type { FormFieldBase } from '@payloadcms/ui/fields/shared'\n\nimport * as React from 'react'\nimport { createContext, useContext, useEffect, useMemo, useState } from 'react'\n\nimport type { SanitizedClientEditorConfig } from '../types.js'\n\n// Should always produce a 20 character pseudo-random string\nfunction generateQuickGuid(): string {\n return Math.random().toString(36).substring(2, 12) + Math.random().toString(36).substring(2, 12)\n}\ninterface ContextType {\n editorConfig: SanitizedClientEditorConfig\n field: FormFieldBase & {\n editorConfig: SanitizedClientEditorConfig // With rendered features n stuff\n name: string\n richTextComponentMap: Map<string, React.ReactNode>\n }\n uuid: string\n}\n\nconst Context: React.Context<ContextType> = createContext({\n editorConfig: null,\n field: null,\n uuid: generateQuickGuid(),\n})\n\nexport const EditorConfigProvider = ({\n children,\n editorConfig,\n fieldProps,\n}: {\n children: React.ReactNode\n editorConfig: SanitizedClientEditorConfig\n fieldProps: FormFieldBase & {\n editorConfig: SanitizedClientEditorConfig // With rendered features n stuff\n name: string\n richTextComponentMap: Map<string, React.ReactNode>\n }\n}): React.ReactNode => {\n // State to store the UUID\n const [uuid, setUuid] = useState(generateQuickGuid())\n\n // When the component mounts, generate a new UUID only once\n useEffect(() => {\n setUuid(generateQuickGuid())\n }, [])\n\n const editorContext = useMemo(\n () => ({ editorConfig, field: fieldProps, uuid }),\n [editorConfig, fieldProps, uuid],\n )\n\n return <Context.Provider value={editorContext}>{children}</Context.Provider>\n}\n\nexport const useEditorConfigContext = (): ContextType => {\n const context = useContext(Context)\n if (context === undefined) {\n throw new Error('useEditorConfigContext must be used within an EditorConfigProvider')\n }\n return context\n}\n"],"names":["React","createContext","useContext","useEffect","useMemo","useState","generateQuickGuid","Math","random","toString","substring","Context","editorConfig","field","uuid","EditorConfigProvider","children","fieldProps","setUuid","editorContext","Provider","value","useEditorConfigContext","context","undefined","Error"],"mappings":"AAAA;AAIA,YAAYA,WAAW,QAAO;AAC9B,SAASC,aAAa,EAAEC,UAAU,EAAEC,SAAS,EAAEC,OAAO,EAAEC,QAAQ,QAAQ,QAAO;AAI/E,4DAA4D;AAC5D,SAASC;IACP,OAAOC,KAAKC,MAAM,GAAGC,QAAQ,CAAC,IAAIC,SAAS,CAAC,GAAG,MAAMH,KAAKC,MAAM,GAAGC,QAAQ,CAAC,IAAIC,SAAS,CAAC,GAAG;AAC/F;AAWA,MAAMC,wBAAsCV,cAAc;IACxDW,cAAc;IACdC,OAAO;IACPC,MAAMR;AACR;AAEA,OAAO,MAAMS,uBAAuB,CAAC,EACnCC,QAAQ,EACRJ,YAAY,EACZK,UAAU,EASX;IACC,0BAA0B;IAC1B,MAAM,CAACH,MAAMI,QAAQ,GAAGb,SAASC;IAEjC,2DAA2D;IAC3DH,UAAU;QACRe,QAAQZ;IACV,GAAG,EAAE;IAEL,MAAMa,gBAAgBf,QACpB,IAAO,CAAA;YAAEQ;YAAcC,OAAOI;YAAYH;QAAK,CAAA,GAC/C;QAACF;QAAcK;QAAYH;KAAK;IAGlC,qBAAO,oBAACH,QAAQS,QAAQ;QAACC,OAAOF;OAAgBH;AAClD,EAAC;AAED,OAAO,MAAMM,yBAAyB;IACpC,MAAMC,UAAUrB,WAAWS;IAC3B,IAAIY,YAAYC,WAAW;QACzB,MAAM,IAAIC,MAAM;IAClB;IACA,OAAOF;AACT,EAAC"}
|
|
1
|
+
{"version":3,"sources":["../../../../../src/field/lexical/config/client/EditorConfigProvider.tsx"],"sourcesContent":["'use client'\n\nimport type { FormFieldBase } from '@payloadcms/ui/fields/shared'\n\nimport * as React from 'react'\nimport { createContext, useContext, useEffect, useMemo, useState } from 'react'\n\nimport type { SanitizedClientEditorConfig } from '../types.js'\n\n// Should always produce a 20 character pseudo-random string\nfunction generateQuickGuid(): string {\n return Math.random().toString(36).substring(2, 12) + Math.random().toString(36).substring(2, 12)\n}\ninterface ContextType {\n editorConfig: SanitizedClientEditorConfig\n field: FormFieldBase & {\n editorConfig: SanitizedClientEditorConfig // With rendered features n stuff\n name: string\n richTextComponentMap: Map<string, React.ReactNode>\n }\n uuid: string\n}\n\nconst Context: React.Context<ContextType> = createContext({\n editorConfig: null,\n field: null,\n uuid: generateQuickGuid(),\n})\n\nexport const EditorConfigProvider = ({\n children,\n editorConfig,\n fieldProps,\n}: {\n children: React.ReactNode\n editorConfig: SanitizedClientEditorConfig\n fieldProps: FormFieldBase & {\n editorConfig: SanitizedClientEditorConfig // With rendered features n stuff\n name: string\n richTextComponentMap: Map<string, React.ReactNode>\n }\n}): React.ReactNode => {\n // State to store the UUID\n const [uuid, setUuid] = useState(generateQuickGuid())\n\n // When the component mounts, generate a new UUID only once\n useEffect(() => {\n setUuid(generateQuickGuid())\n }, [])\n\n const editorContext = useMemo(\n () => ({ editorConfig, field: fieldProps, uuid }),\n [editorConfig, fieldProps, uuid],\n )\n\n return <Context.Provider value={editorContext}>{children}</Context.Provider>\n}\n\nexport const useEditorConfigContext = (): ContextType => {\n const context = useContext(Context)\n if (context === undefined) {\n throw new Error('useEditorConfigContext must be used within an EditorConfigProvider')\n }\n return context\n}\n"],"names":["React","createContext","useContext","useEffect","useMemo","useState","generateQuickGuid","Math","random","toString","substring","Context","editorConfig","field","uuid","EditorConfigProvider","children","fieldProps","setUuid","editorContext","Provider","value","useEditorConfigContext","context","undefined","Error"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA;AAIA,YAAYA,WAAW,QAAO;AAC9B,SAASC,aAAa,EAAEC,UAAU,EAAEC,SAAS,EAAEC,OAAO,EAAEC,QAAQ,QAAQ,QAAO;AAI/E,4DAA4D;AAC5D,SAASC;IACP,OAAOC,KAAKC,MAAM,GAAGC,QAAQ,CAAC,IAAIC,SAAS,CAAC,GAAG,MAAMH,KAAKC,MAAM,GAAGC,QAAQ,CAAC,IAAIC,SAAS,CAAC,GAAG;AAC/F;AAWA,MAAMC,wBAAsCV,cAAc;IACxDW,cAAc;IACdC,OAAO;IACPC,MAAMR;AACR;AAEA,OAAO,MAAMS,uBAAuB,CAAC,EACnCC,QAAQ,EACRJ,YAAY,EACZK,UAAU,EASX;IACC,0BAA0B;IAC1B,MAAM,CAACH,MAAMI,QAAQ,GAAGb,SAASC;IAEjC,2DAA2D;IAC3DH,UAAU;QACRe,QAAQZ;IACV,GAAG,EAAE;IAEL,MAAMa,gBAAgBf,QACpB,IAAO,CAAA;YAAEQ;YAAcC,OAAOI;YAAYH;QAAK,CAAA,GAC/C;QAACF;QAAcK;QAAYH;KAAK;IAGlC,qBAAO,oBAACH,QAAQS,QAAQ;QAACC,OAAOF;OAAgBH;AAClD,EAAC;AAED,OAAO,MAAMM,yBAAyB;IACpC,MAAMC,UAAUrB,WAAWS;IAC3B,IAAIY,YAAYC,WAAW;QACzB,MAAM,IAAIC,MAAM;IAClB;IACA,OAAOF;AACT,EAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/field/lexical/config/client/default.ts"],"sourcesContent":["'use client'\nimport type { EditorConfig as LexicalEditorConfig } from 'lexical/LexicalEditor.js'\n\nimport { LexicalEditorTheme } from '../../theme/EditorTheme.js'\n\nexport const defaultEditorLexicalConfig: LexicalEditorConfig = {\n namespace: 'lexical',\n theme: LexicalEditorTheme,\n}\n"],"names":["LexicalEditorTheme","defaultEditorLexicalConfig","namespace","theme"],"mappings":"AAAA;AAGA,SAASA,kBAAkB,QAAQ,6BAA4B;AAE/D,OAAO,MAAMC,6BAAkD;IAC7DC,WAAW;IACXC,OAAOH;AACT,EAAC"}
|
|
1
|
+
{"version":3,"sources":["../../../../../src/field/lexical/config/client/default.ts"],"sourcesContent":["'use client'\nimport type { EditorConfig as LexicalEditorConfig } from 'lexical/LexicalEditor.js'\n\nimport { LexicalEditorTheme } from '../../theme/EditorTheme.js'\n\nexport const defaultEditorLexicalConfig: LexicalEditorConfig = {\n namespace: 'lexical',\n theme: LexicalEditorTheme,\n}\n"],"names":["LexicalEditorTheme","defaultEditorLexicalConfig","namespace","theme"],"rangeMappings":";;;;;","mappings":"AAAA;AAGA,SAASA,kBAAkB,QAAQ,6BAA4B;AAE/D,OAAO,MAAMC,6BAAkD;IAC7DC,WAAW;IACXC,OAAOH;AACT,EAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/field/lexical/config/client/loader.ts"],"sourcesContent":["'use client'\n\nimport type {\n ClientFeatureProviderMap,\n FeatureProviderClient,\n ResolvedClientFeatureMap,\n} from '../../../features/types.js'\nimport type { ClientEditorConfig } from '../types.js'\n\n/**\n * This function expects client functions to ALREADY be ordered & dependencies checked on the server\n * @param unSanitizedEditorConfig\n */\nexport function loadClientFeatures({\n clientFunctions,\n schemaPath,\n unSanitizedEditorConfig,\n}: {\n clientFunctions?: Record<string, any>\n schemaPath: string\n unSanitizedEditorConfig: ClientEditorConfig\n}): ResolvedClientFeatureMap {\n for (const featureProvider of unSanitizedEditorConfig.features) {\n if (\n !featureProvider?.clientFeatureProps?.featureKey ||\n featureProvider?.clientFeatureProps?.order === undefined ||\n featureProvider?.clientFeatureProps?.order === null\n ) {\n throw new Error(\n 'A Feature you have installed does not return the client props as clientFeatureProps. Please make sure to always return those props, even if they are null, as other important props like order and featureKey are later on injected.',\n )\n }\n }\n\n // sort unSanitizedEditorConfig.features by order\n unSanitizedEditorConfig.features = unSanitizedEditorConfig.features.sort(\n (a, b) => a.clientFeatureProps.order - b.clientFeatureProps.order,\n )\n\n const featureProviderMap: ClientFeatureProviderMap = new Map(\n unSanitizedEditorConfig.features.map(\n (f) => [f.clientFeatureProps.featureKey, f] as [string, FeatureProviderClient<unknown>],\n ),\n )\n\n const resolvedFeatures: ResolvedClientFeatureMap = 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 /**\n * Load relevant clientFunctions scoped to this feature and then pass them to the client feature\n */\n const relevantClientFunctions: Record<string, any> = {}\n Object.entries(clientFunctions).forEach(([key, plugin]) => {\n if (\n key.startsWith(\n `lexicalFeature.${schemaPath}.${featureProvider.clientFeatureProps.featureKey}.components.`,\n )\n ) {\n const featureComponentKey = key.split(\n `${schemaPath}.${featureProvider.clientFeatureProps.featureKey}.components.`,\n )[1]\n relevantClientFunctions[featureComponentKey] = plugin\n }\n })\n\n const feature = featureProvider.feature({\n clientFunctions: relevantClientFunctions,\n featureProviderMap,\n resolvedFeatures,\n unSanitizedEditorConfig,\n })\n resolvedFeatures.set(featureProvider.clientFeatureProps.featureKey, {\n ...feature,\n key: featureProvider.clientFeatureProps.featureKey,\n order: loaded,\n })\n\n loaded++\n }\n\n return resolvedFeatures\n}\n"],"names":["loadClientFeatures","clientFunctions","schemaPath","unSanitizedEditorConfig","featureProvider","features","clientFeatureProps","featureKey","order","undefined","Error","sort","a","b","featureProviderMap","Map","map","f","resolvedFeatures","loaded","relevantClientFunctions","Object","entries","forEach","key","plugin","startsWith","featureComponentKey","split","feature","set"],"mappings":"AAAA;AASA;;;CAGC,GACD,OAAO,SAASA,mBAAmB,EACjCC,eAAe,EACfC,UAAU,EACVC,uBAAuB,EAKxB;IACC,KAAK,MAAMC,mBAAmBD,wBAAwBE,QAAQ,CAAE;QAC9D,IACE,CAACD,iBAAiBE,oBAAoBC,c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{"version":3,"sources":["../../../../../src/field/lexical/config/client/loader.ts"],"sourcesContent":["'use client'\n\nimport type {\n ClientFeatureProviderMap,\n FeatureProviderClient,\n ResolvedClientFeatureMap,\n} from '../../../features/types.js'\nimport type { ClientEditorConfig } from '../types.js'\n\n/**\n * This function expects client functions to ALREADY be ordered & dependencies checked on the server\n * @param unSanitizedEditorConfig\n */\nexport function loadClientFeatures({\n clientFunctions,\n schemaPath,\n unSanitizedEditorConfig,\n}: {\n clientFunctions?: Record<string, any>\n schemaPath: string\n unSanitizedEditorConfig: ClientEditorConfig\n}): ResolvedClientFeatureMap {\n for (const featureProvider of unSanitizedEditorConfig.features) {\n if (\n !featureProvider?.clientFeatureProps?.featureKey ||\n featureProvider?.clientFeatureProps?.order === undefined ||\n featureProvider?.clientFeatureProps?.order === null\n ) {\n throw new Error(\n 'A Feature you have installed does not return the client props as clientFeatureProps. Please make sure to always return those props, even if they are null, as other important props like order and featureKey are later on injected.',\n )\n }\n }\n\n // sort unSanitizedEditorConfig.features by order\n unSanitizedEditorConfig.features = unSanitizedEditorConfig.features.sort(\n (a, b) => a.clientFeatureProps.order - b.clientFeatureProps.order,\n )\n\n const featureProviderMap: ClientFeatureProviderMap = new Map(\n unSanitizedEditorConfig.features.map(\n (f) => [f.clientFeatureProps.featureKey, f] as [string, FeatureProviderClient<unknown>],\n ),\n )\n\n const resolvedFeatures: ResolvedClientFeatureMap = 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 /**\n * Load relevant clientFunctions scoped to this feature and then pass them to the client feature\n */\n const relevantClientFunctions: Record<string, any> = {}\n Object.entries(clientFunctions).forEach(([key, plugin]) => {\n if (\n key.startsWith(\n `lexicalFeature.${schemaPath}.${featureProvider.clientFeatureProps.featureKey}.components.`,\n )\n ) {\n const featureComponentKey = key.split(\n `${schemaPath}.${featureProvider.clientFeatureProps.featureKey}.components.`,\n )[1]\n relevantClientFunctions[featureComponentKey] = plugin\n }\n })\n\n const feature = featureProvider.feature({\n clientFunctions: relevantClientFunctions,\n featureProviderMap,\n resolvedFeatures,\n unSanitizedEditorConfig,\n })\n resolvedFeatures.set(featureProvider.clientFeatureProps.featureKey, {\n ...feature,\n key: featureProvider.clientFeatureProps.featureKey,\n order: loaded,\n })\n\n loaded++\n }\n\n return resolvedFeatures\n}\n"],"names":["loadClientFeatures","clientFunctions","schemaPath","unSanitizedEditorConfig","featureProvider","features","clientFeatureProps","featureKey","order","undefined","Error","sort","a","b","featureProviderMap","Map","map","f","resolvedFeatures","loaded","relevantClientFunctions","Object","entries","forEach","key","plugin","startsWith","featureComponentKey","split","feature","set"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA;AASA;;;CAGC,GACD,OAAO,SAASA,mBAAmB,EACjCC,eAAe,EACfC,UAAU,EACVC,uBAAuB,EAKxB;IACC,KAAK,MAAMC,mBAAmBD,wBAAwBE,QAAQ,CAAE;QAC9D,IACE,CAACD,iBAAiBE,oBAAoBC,cACtCH,iBAAiBE,oBAAoBE,UAAUC,aAC/CL,iBAAiBE,oBAAoBE,UAAU,MAC/C;YACA,MAAM,IAAIE,MACR;QAEJ;IACF;IAEA,iDAAiD;IACjDP,wBAAwBE,QAAQ,GAAGF,wBAAwBE,QAAQ,CAACM,IAAI,CACtE,CAACC,GAAGC,IAAMD,EAAEN,kBAAkB,CAACE,KAAK,GAAGK,EAAEP,kBAAkB,CAACE,KAAK;IAGnE,MAAMM,qBAA+C,IAAIC,IACvDZ,wBAAwBE,QAAQ,CAACW,GAAG,CAClC,CAACC,IAAM;YAACA,EAAEX,kBAAkB,CAACC,UAAU;YAAEU;SAAE;IAI/C,MAAMC,mBAA6C,IAAIH;IAEvD,uEAAuE;IACvE,IAAII,SAAS;IACb,KAAK,MAAMf,mBAAmBD,wBAAwBE,QAAQ,CAAE;QAC9D;;KAEC,GACD,MAAMe,0BAA+C,CAAC;QACtDC,OAAOC,OAAO,CAACrB,iBAAiBsB,OAAO,CAAC,CAAC,CAACC,KAAKC,OAAO;YACpD,IACED,IAAIE,UAAU,CACZ,CAAC,eAAe,EAAExB,WAAW,CAAC,EAAEE,gBAAgBE,kBAAkB,CAACC,UAAU,CAAC,YAAY,CAAC,GAE7F;gBACA,MAAMoB,sBAAsBH,IAAII,KAAK,CACnC,CAAC,EAAE1B,WAAW,CAAC,EAAEE,gBAAgBE,kBAAkB,CAACC,UAAU,CAAC,YAAY,CAAC,CAC7E,CAAC,EAAE;gBACJa,uBAAuB,CAACO,oBAAoB,GAAGF;YACjD;QACF;QAEA,MAAMI,UAAUzB,gBAAgByB,OAAO,CAAC;YACtC5B,iBAAiBmB;YACjBN;YACAI;YACAf;QACF;QACAe,iBAAiBY,GAAG,CAAC1B,gBAAgBE,kBAAkB,CAACC,UAAU,EAAE;YAClE,GAAGsB,OAAO;YACVL,KAAKpB,gBAAgBE,kBAAkB,CAACC,UAAU;YAClDC,OAAOW;QACT;QAEAA;IACF;IAEA,OAAOD;AACT"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/field/lexical/config/client/sanitize.ts"],"sourcesContent":["'use client'\n\nimport type { EditorConfig as LexicalEditorConfig } from 'lexical/LexicalEditor.js'\n\nimport type { ResolvedClientFeatureMap, SanitizedClientFeatures } from '../../../features/types.js'\nimport type { SanitizedClientEditorConfig } from '../types.js'\n\nexport const sanitizeClientFeatures = (\n features: ResolvedClientFeatureMap,\n): SanitizedClientFeatures => {\n const sanitized: SanitizedClientFeatures = {\n enabledFeatures: [],\n floatingSelectToolbar: {\n sections: [],\n },\n hooks: {\n load: [],\n save: [],\n },\n markdownTransformers: [],\n nodes: [],\n plugins: [],\n slashMenu: {\n dynamicOptions: [],\n groupsWithOptions: [],\n },\n }\n\n if (!features?.size) {\n return sanitized\n }\n\n features.forEach((feature) => {\n if (feature.hooks) {\n if (feature.hooks?.load?.length) {\n sanitized.hooks.load = sanitized.hooks.load.concat(feature.hooks.load)\n }\n if (feature.hooks?.save?.length) {\n sanitized.hooks.save = sanitized.hooks.save.concat(feature.hooks.save)\n }\n }\n\n if (feature.nodes?.length) {\n sanitized.nodes = sanitized.nodes.concat(feature.nodes)\n }\n if (feature.plugins?.length) {\n feature.plugins.forEach((plugin, i) => {\n sanitized.plugins.push({\n Component: plugin.Component,\n key: feature.key + i,\n position: plugin.position,\n })\n })\n }\n\n if (feature.floatingSelectToolbar?.sections?.length) {\n for (const section of feature.floatingSelectToolbar.sections) {\n // 1. find the section with the same key or create new one\n let foundSection = sanitized.floatingSelectToolbar.sections.find(\n (sanitizedSection) => sanitizedSection.key === section.key,\n )\n if (!foundSection) {\n foundSection = {\n ...section,\n entries: [],\n }\n } else {\n sanitized.floatingSelectToolbar.sections =\n sanitized.floatingSelectToolbar.sections.filter(\n (sanitizedSection) => sanitizedSection.key !== section.key,\n )\n }\n\n // 2. Add options to group options array and add to sanitized.slashMenu.groupsWithOptions\n if (section?.entries?.length) {\n foundSection.entries = foundSection.entries.concat(section.entries)\n }\n sanitized.floatingSelectToolbar?.sections.push(foundSection)\n }\n }\n\n if (feature.slashMenu?.options) {\n if (feature.slashMenu.dynamicOptions?.length) {\n sanitized.slashMenu.dynamicOptions = sanitized.slashMenu.dynamicOptions.concat(\n feature.slashMenu.dynamicOptions,\n )\n }\n\n for (const optionGroup of feature.slashMenu.options) {\n // 1. find the group with the same name or create new one\n let group = sanitized.slashMenu.groupsWithOptions.find(\n (group) => group.key === optionGroup.key,\n )\n if (!group) {\n group = {\n ...optionGroup,\n options: [],\n }\n } else {\n sanitized.slashMenu.groupsWithOptions = sanitized.slashMenu.groupsWithOptions.filter(\n (group) => group.key !== optionGroup.key,\n )\n }\n\n // 2. Add options to group options array and add to sanitized.slashMenu.groupsWithOptions\n if (optionGroup?.options?.length) {\n group.options = group.options.concat(optionGroup.options)\n }\n sanitized.slashMenu.groupsWithOptions.push(group)\n }\n }\n\n if (feature.markdownTransformers?.length) {\n sanitized.markdownTransformers = sanitized.markdownTransformers.concat(\n feature.markdownTransformers,\n )\n }\n sanitized.enabledFeatures.push(feature.key)\n })\n\n // Sort sanitized.floatingSelectToolbar.sections by order property\n sanitized.floatingSelectToolbar.sections.sort((a, b) => {\n if (a.order && b.order) {\n return a.order - b.order\n } else if (a.order) {\n return -1\n } else if (b.order) {\n return 1\n } else {\n return 0\n }\n })\n\n // Sort sanitized.floatingSelectToolbar.sections.[section].entries by order property\n for (const section of sanitized.floatingSelectToolbar.sections) {\n section.entries.sort((a, b) => {\n if (a.order && b.order) {\n return a.order - b.order\n } else if (a.order) {\n return -1\n } else if (b.order) {\n return 1\n } else {\n return 0\n }\n })\n }\n\n return sanitized\n}\n\nexport function sanitizeClientEditorConfig(\n lexical: LexicalEditorConfig,\n resolvedClientFeatureMap: ResolvedClientFeatureMap,\n): SanitizedClientEditorConfig {\n return {\n features: sanitizeClientFeatures(resolvedClientFeatureMap),\n lexical,\n resolvedFeatureMap: resolvedClientFeatureMap,\n }\n}\n"],"names":["sanitizeClientFeatures","features","sanitized","enabledFeatures","floatingSelectToolbar","sections","hooks","load","save","markdownTransformers","nodes","plugins","slashMenu","dynamicOptions","groupsWithOptions","size","forEach","feature","length","concat","plugin","i","push","Component","key","position","section","foundSection","find","sanitizedSection","entries","filter","options","optionGroup","group","sort","a","b","order","sanitizeClientEditorConfig","lexical","resolvedClientFeatureMap","resolvedFeatureMap"],"mappings":"AAAA;AAOA,OAAO,MAAMA,yBAAyB,CACpCC;IAEA,MAAMC,YAAqC;QACzCC,iBAAiB,EAAE;QACnBC,uBAAuB;YACrBC,UAAU,EAAE;QACd;QACAC,OAAO;YACLC,MAAM,EAAE;YACRC,MAAM,EAAE;QACV;QACAC,sBAAsB,EAAE;QACxBC,OAAO,EAAE;QACTC,SAAS,EAAE;QACXC,WAAW;YACTC,gBAAgB,EAAE;YAClBC,mBAAmB,EAAE;QACvB;IACF;IAEA,IAAI,CAACb,UAAUc,MAAM;QACnB,OAAOb;IACT;IA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eAAe,CAACmB,IAAI,CAACL,QAAQO,GAAG;IAC5C;IAEA,kEAAkE;IAClEtB,UAAUE,qBAAqB,CAACC,QAAQ,CAAC8B,IAAI,CAAC,CAACC,GAAGC;QAChD,IAAID,EAAEE,KAAK,IAAID,EAAEC,KAAK,EAAE;YACtB,OAAOF,EAAEE,KAAK,GAAGD,EAAEC,KAAK;QAC1B,OAAO,IAAIF,EAAEE,KAAK,EAAE;YAClB,OAAO,CAAC;QACV,OAAO,IAAID,EAAEC,KAAK,EAAE;YAClB,OAAO;QACT,OAAO;YACL,OAAO;QACT;IACF;IAEA,oFAAoF;IACpF,KAAK,MAAMZ,WAAWxB,UAAUE,qBAAqB,CAACC,QAAQ,CAAE;QAC9DqB,QAAQI,OAAO,CAACK,IAAI,CAAC,CAACC,GAAGC;YACvB,IAAID,EAAEE,KAAK,IAAID,EAAEC,KAAK,EAAE;gBACtB,OAAOF,EAAEE,KAAK,GAAGD,EAAEC,KAAK;YAC1B,OAAO,IAAIF,EAAEE,KAAK,EAAE;gBAClB,OAAO,CAAC;YACV,OAAO,IAAID,EAAEC,KAAK,EAAE;gBAClB,OAAO;YACT,OAAO;gBACL,OAAO;YACT;QACF;IACF;IAEA,OAAOpC;AACT,EAAC;AAED,OAAO,SAASqC,2BACdC,OAA4B,EAC5BC,wBAAkD;IAElD,OAAO;QACLxC,UAAUD,uBAAuByC;QACjCD;QACAE,oBAAoBD;IACtB;AACF"}
|
|
1
|
+
{"version":3,"sources":["../../../../../src/field/lexical/config/client/sanitize.ts"],"sourcesContent":["'use client'\n\nimport type { EditorConfig as LexicalEditorConfig } from 'lexical/LexicalEditor.js'\n\nimport type { ResolvedClientFeatureMap, SanitizedClientFeatures } from '../../../features/types.js'\nimport type { SanitizedClientEditorConfig } from '../types.js'\n\nexport const sanitizeClientFeatures = (\n features: ResolvedClientFeatureMap,\n): SanitizedClientFeatures => {\n const sanitized: SanitizedClientFeatures = {\n enabledFeatures: [],\n floatingSelectToolbar: {\n sections: [],\n },\n hooks: {\n load: [],\n save: [],\n },\n markdownTransformers: [],\n nodes: [],\n plugins: [],\n slashMenu: {\n dynamicOptions: [],\n groupsWithOptions: [],\n },\n }\n\n if (!features?.size) {\n return sanitized\n }\n\n features.forEach((feature) => {\n if (feature.hooks) {\n if (feature.hooks?.load?.length) {\n sanitized.hooks.load = sanitized.hooks.load.concat(feature.hooks.load)\n }\n if (feature.hooks?.save?.length) {\n sanitized.hooks.save = sanitized.hooks.save.concat(feature.hooks.save)\n }\n }\n\n if (feature.nodes?.length) {\n sanitized.nodes = sanitized.nodes.concat(feature.nodes)\n }\n if (feature.plugins?.length) {\n feature.plugins.forEach((plugin, i) => {\n sanitized.plugins.push({\n Component: plugin.Component,\n key: feature.key + i,\n position: plugin.position,\n })\n })\n }\n\n if (feature.floatingSelectToolbar?.sections?.length) {\n for (const section of feature.floatingSelectToolbar.sections) {\n // 1. find the section with the same key or create new one\n let foundSection = sanitized.floatingSelectToolbar.sections.find(\n (sanitizedSection) => sanitizedSection.key === section.key,\n )\n if (!foundSection) {\n foundSection = {\n ...section,\n entries: [],\n }\n } else {\n sanitized.floatingSelectToolbar.sections =\n sanitized.floatingSelectToolbar.sections.filter(\n (sanitizedSection) => sanitizedSection.key !== section.key,\n )\n }\n\n // 2. Add options to group options array and add to sanitized.slashMenu.groupsWithOptions\n if (section?.entries?.length) {\n foundSection.entries = foundSection.entries.concat(section.entries)\n }\n sanitized.floatingSelectToolbar?.sections.push(foundSection)\n }\n }\n\n if (feature.slashMenu?.options) {\n if (feature.slashMenu.dynamicOptions?.length) {\n sanitized.slashMenu.dynamicOptions = sanitized.slashMenu.dynamicOptions.concat(\n feature.slashMenu.dynamicOptions,\n )\n }\n\n for (const optionGroup of feature.slashMenu.options) {\n // 1. find the group with the same name or create new one\n let group = sanitized.slashMenu.groupsWithOptions.find(\n (group) => group.key === optionGroup.key,\n )\n if (!group) {\n group = {\n ...optionGroup,\n options: [],\n }\n } else {\n sanitized.slashMenu.groupsWithOptions = sanitized.slashMenu.groupsWithOptions.filter(\n (group) => group.key !== optionGroup.key,\n )\n }\n\n // 2. Add options to group options array and add to sanitized.slashMenu.groupsWithOptions\n if (optionGroup?.options?.length) {\n group.options = group.options.concat(optionGroup.options)\n }\n sanitized.slashMenu.groupsWithOptions.push(group)\n }\n }\n\n if (feature.markdownTransformers?.length) {\n sanitized.markdownTransformers = sanitized.markdownTransformers.concat(\n feature.markdownTransformers,\n )\n }\n sanitized.enabledFeatures.push(feature.key)\n })\n\n // Sort sanitized.floatingSelectToolbar.sections by order property\n sanitized.floatingSelectToolbar.sections.sort((a, b) => {\n if (a.order && b.order) {\n return a.order - b.order\n } else if (a.order) {\n return -1\n } else if (b.order) {\n return 1\n } else {\n return 0\n }\n })\n\n // Sort sanitized.floatingSelectToolbar.sections.[section].entries by order property\n for (const section of sanitized.floatingSelectToolbar.sections) {\n section.entries.sort((a, b) => {\n if (a.order && b.order) {\n return a.order - b.order\n } else if (a.order) {\n return -1\n } else if (b.order) {\n return 1\n } else {\n return 0\n }\n })\n }\n\n return sanitized\n}\n\nexport function sanitizeClientEditorConfig(\n lexical: LexicalEditorConfig,\n resolvedClientFeatureMap: ResolvedClientFeatureMap,\n): SanitizedClientEditorConfig {\n return {\n features: sanitizeClientFeatures(resolvedClientFeatureMap),\n lexical,\n resolvedFeatureMap: resolvedClientFeatureMap,\n }\n}\n"],"names":["sanitizeClientFeatures","features","sanitized","enabledFeatures","floatingSelectToolbar","sections","hooks","load","save","markdownTransformers","nodes","plugins","slashMenu","dynamicOptions","groupsWithOptions","size","forEach","feature","length","concat","plugin","i","push","Component","key","position","section","foundSection","find","sanitizedSection","entries","filter","options","optionGroup","group","sort","a","b","order","sanitizeClientEditorConfig","lexical","resolvedClientFeatureMap","resolvedFeatureMap"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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ACjCD;QACAE,oBAAoBD;IACtB;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/field/lexical/config/server/default.ts"],"sourcesContent":["import type { EditorConfig as LexicalEditorConfig } from 'lexical/LexicalEditor.js'\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 { 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]\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","IndentFeature","LinkFeature","CheckListFeature","OrderedListFeature","UnorderedListFeature","ParagraphFeature","RelationshipFeature","UploadFeature","LexicalEditorTheme","sanitizeServerEditorConfig","defaultEditorLexicalConfig","namespace","theme","defaultEditorFeatures","defaultEditorConfig","features","lexical","defaultSanitizedServerEditorConfig"],"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,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;IAC9ErB;IACAE;IACAI;IACAH;IACAC;IACAC;IACAJ;IACAY;IACAN;IACAT;IACAU;IACAI;IACAD;IACAD;IACAD;IACAK;IACAf;IACAgB;CACD,CAAA;AAED,OAAO,MAAMO,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/LexicalEditor.js'\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 { 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]\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","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,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;IAC9ErB;IACAE;IACAI;IACAH;IACAC;IACAC;IACAJ;IACAY;IACAN;IACAT;IACAU;IACAI;IACAD;IACAD;IACAD;IACAK;IACAf;IACAgB;CACD,CAAA;AAED,OAAO,MAAMO,sBAA0C;IACrDC,UAAUF;IACVG,SAASN;AACX,EAAC;AAED,OAAO,MAAMO,qCACXR,2BAA2BK,qBAAoB"}
|
|
@@ -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"],"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;IAE3D,MAAMC,QAAQF,sBAAsBC;IACpC,MAAMS,UAAsC,CAAC;IAC7C,MAAMC,QAAmD,EAAE;IAE3D,IAAK,MAAMP,OAAOF,MAAO;QACvB,IAAI,CAACQ,OAAO,CAACN,IAAI,EAAE;YACjBQ,MAAMV,OAAOE,KAAKM,SAASC;QAC7B;IACF;IAEA,OAAOA,MAAME,OAAO;AACtB;AAEA,SAASD,MACPV,KAAsB,EACtBE,GAAW,EACXM,OAA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J,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 {\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;IAE3D,MAAMC,QAAQF,sBAAsBC;IACpC,MAAMS,UAAsC,CAAC;IAC7C,MAAMC,QAAmD,EAAE;IAE3D,IAAK,MAAMP,OAAOF,MAAO;QACvB,IAAI,CAACQ,OAAO,CAACN,IAAI,EAAE;YACjBQ,MAAMV,OAAOE,KAAKM,SAASC;QAC7B;IACF;IAEA,OAAOA,MAAME,OAAO;AACtB;AAEA,SAASD,MACPV,KAAsB,EACtBE,GAAW,EACXM,OAAmC,EACnCC,KAAgD,EAChDG,cAAwB,EAAE;IAE1B,IAA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;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 +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 afterReadPromises: [],\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 if (feature.hooks) {\n if (feature.hooks.afterReadPromise) {\n sanitized.hooks.afterReadPromises = sanitized.hooks.afterReadPromises.concat(\n feature.hooks.afterReadPromise,\n )\n }\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 })\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","afterReadPromises","markdownTransformers","nodes","populationPromises","Map","validations","size","forEach","feature","modifyOutputSchema","push","afterReadPromise","concat","length","node","nodeType","replace","getType","set","key","sanitizeServerEditorConfig","editorConfig","resolvedFeatureMap","unSanitizedEditorConfig","lexical"],"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;YACd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AoB,EAAEY,QAAQ;YACxCpB,UAAUQ,oBAAoB,GAAGR,UAAUQ,oBAAoB,CAACW,MAAM,CACpEJ,QAAQP,oBAAoB;QAEhC;QAEAR,UAAUG,eAAe,CAACc,IAAI,CAACF,QAAQW,GAAG;IAC5C;IAEA,OAAO1B;AACT,EAAC;AAED,OAAO,SAAS2B,2BACdC,YAAgC;IAEhC,MAAMC,qBAAqBhC,aAAa;QACtCiC,yBAAyBF;IAC3B;IAEA,OAAO;QACL7B,UAAUD,uBAAuB+B;QACjCE,SAASH,aAAaG,OAAO;QAC7BF;IACF;AACF"}
|
|
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 afterReadPromises: [],\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 if (feature.hooks) {\n if (feature.hooks.afterReadPromise) {\n sanitized.hooks.afterReadPromises = sanitized.hooks.afterReadPromises.concat(\n feature.hooks.afterReadPromise,\n )\n }\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 })\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","afterReadPromises","markdownTransformers","nodes","populationPromises","Map","validations","size","forEach","feature","modifyOutputSchema","push","afterReadPromise","concat","length","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,mBAAmB,EAAE;QACvB;QACAC,sBAAsB,EAAE;QACxBC,OAAO,EAAE;QACTC,oBAAoB,IAAIC;QAExBC,aAAa,IAAID;IACnB;IAEA,IAAI,CAACZ,UAAUc,MAAM;QACnB,OAAOb;IACT;IAEAD,SAASe,OAAO,CAAC,CAACC;QAChB,IAAIA,SAASX,gBAAgBY,oBAAoB;YAC/ChB,UA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IAC3B;IAEA,OAAO;QACL7B,UAAUD,uBAAuB+B;QACjCE,SAASH,aAAaG,OAAO;QAC7BF;IACF;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/field/lexical/config/types.ts"],"sourcesContent":["import type { EditorConfig as LexicalEditorConfig } from 'lexical/LexicalEditor.js'\n\nimport type {\n FeatureProviderClient,\n FeatureProviderServer,\n ResolvedClientFeatureMap,\n ResolvedServerFeatureMap,\n SanitizedClientFeatures,\n SanitizedServerFeatures,\n} from '../../features/types.js'\n\nexport type ServerEditorConfig = {\n features: FeatureProviderServer<unknown, unknown>[]\n lexical?: LexicalEditorConfig\n}\n\nexport type SanitizedServerEditorConfig = {\n features: SanitizedServerFeatures\n lexical: LexicalEditorConfig\n resolvedFeatureMap: ResolvedServerFeatureMap\n}\n\nexport type ClientEditorConfig = {\n features: FeatureProviderClient<unknown>[]\n lexical?: LexicalEditorConfig\n}\n\nexport type SanitizedClientEditorConfig = {\n features: SanitizedClientFeatures\n lexical: LexicalEditorConfig\n resolvedFeatureMap: ResolvedClientFeatureMap\n}\n"],"names":[],"mappings":"AA2BA,WAIC"}
|
|
1
|
+
{"version":3,"sources":["../../../../src/field/lexical/config/types.ts"],"sourcesContent":["import type { EditorConfig as LexicalEditorConfig } from 'lexical/LexicalEditor.js'\n\nimport type {\n FeatureProviderClient,\n FeatureProviderServer,\n ResolvedClientFeatureMap,\n ResolvedServerFeatureMap,\n SanitizedClientFeatures,\n SanitizedServerFeatures,\n} from '../../features/types.js'\n\nexport type ServerEditorConfig = {\n features: FeatureProviderServer<unknown, unknown>[]\n lexical?: LexicalEditorConfig\n}\n\nexport type SanitizedServerEditorConfig = {\n features: SanitizedServerFeatures\n lexical: LexicalEditorConfig\n resolvedFeatureMap: ResolvedServerFeatureMap\n}\n\nexport type ClientEditorConfig = {\n features: FeatureProviderClient<unknown>[]\n lexical?: LexicalEditorConfig\n}\n\nexport type SanitizedClientEditorConfig = {\n features: SanitizedClientFeatures\n lexical: LexicalEditorConfig\n resolvedFeatureMap: ResolvedClientFeatureMap\n}\n"],"names":[],"rangeMappings":"","mappings":"AA2BA,WAIC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/field/lexical/nodes/index.ts"],"sourcesContent":["import type { Klass, LexicalNode } from 'lexical'\nimport type { LexicalNodeReplacement } from 'lexical'\n\nimport type { SanitizedClientEditorConfig, SanitizedServerEditorConfig } from '../config/types.js'\n\nexport function getEnabledNodes({\n editorConfig,\n}: {\n editorConfig: SanitizedClientEditorConfig | SanitizedServerEditorConfig\n}): Array<Klass<LexicalNode> | LexicalNodeReplacement> {\n return editorConfig.features.nodes.map((node) => {\n if ('node' in node) {\n return node.node\n }\n return node\n })\n}\n"],"names":["getEnabledNodes","editorConfig","features","nodes","map","node"],"mappings":"AAKA,OAAO,SAASA,gBAAgB,EAC9BC,YAAY,EAGb;IACC,OAAOA,aAAaC,QAAQ,CAACC,KAAK,CAACC,GAAG,CAAC,CAACC;QACtC,IAAI,UAAUA,MAAM;YAClB,OAAOA,KAAKA,IAAI;QAClB;QACA,OAAOA;IACT;AACF"}
|
|
1
|
+
{"version":3,"sources":["../../../../src/field/lexical/nodes/index.ts"],"sourcesContent":["import type { Klass, LexicalNode } from 'lexical'\nimport type { LexicalNodeReplacement } from 'lexical'\n\nimport type { SanitizedClientEditorConfig, SanitizedServerEditorConfig } from '../config/types.js'\n\nexport function getEnabledNodes({\n editorConfig,\n}: {\n editorConfig: SanitizedClientEditorConfig | SanitizedServerEditorConfig\n}): Array<Klass<LexicalNode> | LexicalNodeReplacement> {\n return editorConfig.features.nodes.map((node) => {\n if ('node' in node) {\n return node.node\n }\n return node\n })\n}\n"],"names":["getEnabledNodes","editorConfig","features","nodes","map","node"],"rangeMappings":";;;;;;;","mappings":"AAKA,OAAO,SAASA,gBAAgB,EAC9BC,YAAY,EAGb;IACC,OAAOA,aAAaC,QAAQ,CAACC,KAAK,CAACC,GAAG,CAAC,CAACC;QACtC,IAAI,UAAUA,MAAM;YAClB,OAAOA,KAAKA,IAAI;QAClB;QACA,OAAOA;IACT;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../src/field/lexical/plugins/FloatingSelectToolbar/ToolbarButton/index.tsx"],"sourcesContent":["'use client'\nimport lexicalComposerContextImport from '@lexical/react/LexicalComposerContext.js'\nconst { useLexicalComposerContext } = lexicalComposerContextImport\nimport lexicalUtilsImport from '@lexical/utils'\nconst { mergeRegister } = lexicalUtilsImport\n\nimport lexicalImport from 'lexical'\nconst { $getSelection } = lexicalImport\n\nimport React, { useCallback, useEffect, useState } from 'react'\n\nimport type { FloatingToolbarSectionEntry } from '../types.js'\n\nimport './index.scss'\n\nconst baseClass = 'floating-select-toolbar-popup__button'\n\nexport const ToolbarButton = ({\n children,\n entry,\n}: {\n children: React.JSX.Element\n entry: FloatingToolbarSectionEntry\n}) => {\n const [editor] = useLexicalComposerContext()\n const [enabled, setEnabled] = useState<boolean>(true)\n const [active, setActive] = useState<boolean>(false)\n const [className, setClassName] = useState<string>(baseClass)\n\n const updateStates = useCallback(() => {\n editor.getEditorState().read(() => {\n const selection = $getSelection()\n if (entry.isActive) {\n const isActive = entry.isActive({ editor, selection })\n if (active !== isActive) {\n setActive(isActive)\n }\n }\n if (entry.isEnabled) {\n const isEnabled = entry.isEnabled({ editor, selection })\n if (enabled !== isEnabled) {\n setEnabled(isEnabled)\n }\n }\n })\n }, [active, editor, enabled, entry])\n\n useEffect(() => {\n updateStates()\n }, [updateStates])\n\n useEffect(() => {\n document.addEventListener('mouseup', updateStates)\n return () => {\n document.removeEventListener('mouseup', updateStates)\n }\n }, [updateStates])\n\n useEffect(() => {\n return mergeRegister(\n editor.registerUpdateListener(() => {\n updateStates()\n }),\n )\n }, [editor, updateStates])\n\n useEffect(() => {\n setClassName(\n [\n baseClass,\n enabled === false ? 'disabled' : '',\n active ? 'active' : '',\n entry?.key ? `${baseClass}-` + entry.key : '',\n ]\n .filter(Boolean)\n .join(' '),\n )\n }, [enabled, active, className])\n\n return (\n <button\n className={className}\n onClick={() => {\n if (enabled !== false) {\n entry.onClick({\n editor,\n isActive: active,\n })\n }\n }}\n onMouseDown={(e) => {\n // This fixes a bug where you are unable to click the button if you are in a NESTED editor (editor in blocks field in editor).\n // Thus only happens if you click on the SVG of the button. Clicking on the outside works. Related issue: https://github.com/payloadcms/payload/issues/4025\n // TODO: Find out why exactly it happens and why e.preventDefault() on the mouseDown fixes it. Write that down here, or potentially fix a root cause, if there is any.\n e.preventDefault()\n }}\n type=\"button\"\n >\n {children}\n </button>\n )\n}\n"],"names":["lexicalComposerContextImport","useLexicalComposerContext","lexicalUtilsImport","mergeRegister","lexicalImport","$getSelection","React","useCallback","useEffect","useState","baseClass","ToolbarButton","children","entry","editor","enabled","setEnabled","active","setActive","className","setClassName","updateStates","getEditorState","read","selection","isActive","isEnabled","document","addEventListener","removeEventListener","registerUpdateListener","key","filter","Boolean","join","button","onClick","onMouseDown","e","preventDefault","type"],"mappings":"AAAA;AACA,OAAOA,kCAAkC,2CAA0C;AACnF,MAAM,EAAEC,yBAAyB,EAAE,GAAGD;AACtC,OAAOE,wBAAwB,iBAAgB;AAC/C,MAAM,EAAEC,aAAa,EAAE,GAAGD;AAE1B,OAAOE,mBAAmB,UAAS;AACnC,MAAM,EAAEC,aAAa,EAAE,GAAGD;AAE1B,OAAOE,SAASC,WAAW,EAAEC,SAAS,EAAEC,QAAQ,QAAQ,QAAO;AAI/D,OAAO,eAAc;AAErB,MAAMC,YAAY;AAElB,OAAO,MAAMC,gBAAgB,CAAC,EAC5BC,QAAQ,EACRC,KAAK,EAIN;IACC,MAAM,CAACC,OAAO,GAAGb;IACjB,MAAM,CAACc,SAASC,WAAW,GAAGP,SAAkB;IAChD,MAAM,CAACQ,QAAQC,UAAU,GAAGT,SAAkB;IAC9C,MAAM,CAACU,WAAWC,aAAa,GAAGX,SAAiBC;IAEnD,MAAMW,eAAed,YAAY;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../../../../src/field/lexical/plugins/FloatingSelectToolbar/ToolbarButton/index.tsx"],"sourcesContent":["'use client'\nimport lexicalComposerContextImport from '@lexical/react/LexicalComposerContext.js'\nconst { useLexicalComposerContext } = lexicalComposerContextImport\nimport lexicalUtilsImport from '@lexical/utils'\nconst { mergeRegister } = lexicalUtilsImport\n\nimport lexicalImport from 'lexical'\nconst { $getSelection } = lexicalImport\n\nimport React, { useCallback, useEffect, useState } from 'react'\n\nimport type { FloatingToolbarSectionEntry } from '../types.js'\n\nimport './index.scss'\n\nconst baseClass = 'floating-select-toolbar-popup__button'\n\nexport const ToolbarButton = ({\n children,\n entry,\n}: {\n children: React.JSX.Element\n entry: FloatingToolbarSectionEntry\n}) => {\n const [editor] = useLexicalComposerContext()\n const [enabled, setEnabled] = useState<boolean>(true)\n const [active, setActive] = useState<boolean>(false)\n const [className, setClassName] = useState<string>(baseClass)\n\n const updateStates = useCallback(() => {\n editor.getEditorState().read(() => {\n const selection = $getSelection()\n if (entry.isActive) {\n const isActive = entry.isActive({ editor, selection })\n if (active !== isActive) {\n setActive(isActive)\n }\n }\n if (entry.isEnabled) {\n const isEnabled = entry.isEnabled({ editor, selection })\n if (enabled !== isEnabled) {\n setEnabled(isEnabled)\n }\n }\n })\n }, [active, editor, enabled, entry])\n\n useEffect(() => {\n updateStates()\n }, [updateStates])\n\n useEffect(() => {\n document.addEventListener('mouseup', updateStates)\n return () => {\n document.removeEventListener('mouseup', updateStates)\n }\n }, [updateStates])\n\n useEffect(() => {\n return mergeRegister(\n editor.registerUpdateListener(() => {\n updateStates()\n }),\n )\n }, [editor, updateStates])\n\n useEffect(() => {\n setClassName(\n [\n baseClass,\n enabled === false ? 'disabled' : '',\n active ? 'active' : '',\n entry?.key ? `${baseClass}-` + entry.key : '',\n ]\n .filter(Boolean)\n .join(' '),\n )\n }, [enabled, active, className])\n\n return (\n <button\n className={className}\n onClick={() => {\n if (enabled !== false) {\n entry.onClick({\n editor,\n isActive: active,\n })\n }\n }}\n onMouseDown={(e) => {\n // This fixes a bug where you are unable to click the button if you are in a NESTED editor (editor in blocks field in editor).\n // Thus only happens if you click on the SVG of the button. Clicking on the outside works. Related issue: https://github.com/payloadcms/payload/issues/4025\n // TODO: Find out why exactly it happens and why e.preventDefault() on the mouseDown fixes it. Write that down here, or potentially fix a root cause, if there is any.\n e.preventDefault()\n }}\n type=\"button\"\n >\n {children}\n </button>\n )\n}\n"],"names":["lexicalComposerContextImport","useLexicalComposerContext","lexicalUtilsImport","mergeRegister","lexicalImport","$getSelection","React","useCallback","useEffect","useState","baseClass","ToolbarButton","children","entry","editor","enabled","setEnabled","active","setActive","className","setClassName","updateStates","getEditorState","read","selection","isActive","isEnabled","document","addEventListener","removeEventListener","registerUpdateListener","key","filter","Boolean","join","button","onClick","onMouseDown","e","preventDefault","type"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA;AACA,OAAOA,kCAAkC,2CAA0C;AACnF,MAAM,EAAEC,yBAAyB,EAAE,GAAGD;AACtC,OAAOE,wBAAwB,iBAAgB;AAC/C,MAAM,EAAEC,aAAa,EAAE,GAAGD;AAE1B,OAAOE,mBAAmB,UAAS;AACnC,MAAM,EAAEC,aAAa,EAAE,GAAGD;AAE1B,OAAOE,SAASC,WAAW,EAAEC,SAAS,EAAEC,QAAQ,QAAQ,QAAO;AAI/D,OAAO,eAAc;AAErB,MAAMC,YAAY;AAElB,OAAO,MAAMC,gBAAgB,CAAC,EAC5BC,QAAQ,EACRC,KAAK,EAIN;IACC,MAAM,CAACC,OAAO,GAAGb;IACjB,MAAM,CAACc,SAASC,WAAW,GAAGP,SAAkB;IAChD,MAAM,CAACQ,QAAQC,UAAU,GAAGT,SAAkB;IAC9C,MAAM,CAACU,WAAWC,aAAa,GAAGX,SAAiBC;IAEnD,MAAMW,eAAed,YAAY;QAC/BO,OAAOQ,c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["../../../../../../src/field/lexical/plugins/FloatingSelectToolbar/ToolbarDropdown/DropDown.tsx"],"sourcesContent":["'use client'\nimport lexicalComposerContextImport from '@lexical/react/LexicalComposerContext.js'\nconst { useLexicalComposerContext } = lexicalComposerContextImport\n\nimport lexicalUtilsImport from '@lexical/utils'\nconst { mergeRegister } = lexicalUtilsImport\n\nimport lexicalImport from 'lexical'\nconst { $getSelection } = lexicalImport\n\nimport { type ReactNode, useCallback, useEffect, useMemo, useRef, useState } from 'react'\nimport React from 'react'\nimport { createPortal } from 'react-dom'\n\nimport type { FloatingToolbarSectionEntry } from '../types.js'\n\nconst baseClass = 'floating-select-toolbar-popup__dropdown-item'\n\ninterface DropDownContextType {\n registerItem: (ref: React.RefObject<HTMLButtonElement>) => void\n}\n\nconst DropDownContext = React.createContext<DropDownContextType | null>(null)\n\nexport function DropDownItem({\n children,\n entry,\n title,\n}: {\n children: React.ReactNode\n entry: FloatingToolbarSectionEntry\n title?: string\n}): React.ReactNode {\n const [editor] = useLexicalComposerContext()\n const [enabled, setEnabled] = useState<boolean>(true)\n const [active, setActive] = useState<boolean>(false)\n const [className, setClassName] = useState<string>(baseClass)\n\n const updateStates = useCallback(() => {\n editor.getEditorState().read(() => {\n const selection = $getSelection()\n if (entry.isActive) {\n const isActive = entry.isActive({ editor, selection })\n if (active !== isActive) {\n setActive(isActive)\n }\n }\n if (entry.isEnabled) {\n const isEnabled = entry.isEnabled({ editor, selection })\n if (enabled !== isEnabled) {\n setEnabled(isEnabled)\n }\n }\n })\n }, [active, editor, enabled, entry])\n\n useEffect(() => {\n updateStates()\n }, [updateStates])\n\n useEffect(() => {\n document.addEventListener('mouseup', updateStates)\n return () => {\n document.removeEventListener('mouseup', updateStates)\n }\n }, [updateStates])\n\n useEffect(() => {\n return mergeRegister(\n editor.registerUpdateListener(() => {\n updateStates()\n }),\n )\n }, [editor, updateStates])\n\n useEffect(() => {\n setClassName(\n [\n baseClass,\n enabled === false ? 'disabled' : '',\n active ? 'active' : '',\n entry?.key ? `${baseClass}-${entry.key}` : '',\n ]\n .filter(Boolean)\n .join(' '),\n )\n }, [enabled, active, className, entry.key])\n\n const ref = useRef<HTMLButtonElement>(null)\n\n const dropDownContext = React.useContext(DropDownContext)\n\n if (dropDownContext === null) {\n throw new Error('DropDownItem must be used within a DropDown')\n }\n\n const { registerItem } = dropDownContext\n\n useEffect(() => {\n if (ref?.current != null) {\n registerItem(ref)\n }\n }, [ref, registerItem])\n\n return (\n <button\n className={className}\n onClick={() => {\n if (enabled !== false) {\n entry.onClick({\n editor,\n isActive: active,\n })\n }\n }}\n onMouseDown={(e) => {\n // This is required for Firefox compatibility. Without it, the dropdown will disappear without the onClick being called.\n // This only happens in Firefox. Must be something about how Firefox handles focus events differently.\n e.preventDefault()\n }}\n ref={ref}\n title={title}\n type=\"button\"\n >\n {children}\n </button>\n )\n}\n\nfunction DropDownItems({\n children,\n dropDownRef,\n onClose,\n}: {\n children: React.ReactNode\n dropDownRef: React.Ref<HTMLDivElement>\n onClose: () => void\n}): JSX.Element {\n const [items, setItems] = useState<Array<React.RefObject<HTMLButtonElement>>>()\n const [highlightedItem, setHighlightedItem] = useState<React.RefObject<HTMLButtonElement>>()\n\n const registerItem = useCallback(\n (itemRef: React.RefObject<HTMLButtonElement>) => {\n setItems((prev) => (prev != null ? [...prev, itemRef] : [itemRef]))\n },\n [setItems],\n )\n\n const handleKeyDown = (event: React.KeyboardEvent<HTMLDivElement>): void => {\n if (items == null) return\n\n const { key } = event\n\n if (['ArrowDown', 'ArrowUp', 'Escape', 'Tab'].includes(key)) {\n event.preventDefault()\n }\n\n if (key === 'Escape' || key === 'Tab') {\n onClose()\n } else if (key === 'ArrowUp') {\n setHighlightedItem((prev) => {\n if (prev == null) return items[0]\n const index = items.indexOf(prev) - 1\n return items[index === -1 ? items.length - 1 : index]\n })\n } else if (key === 'ArrowDown') {\n setHighlightedItem((prev) => {\n if (prev == null) return items[0]\n return items[items.indexOf(prev) + 1]\n })\n }\n }\n\n const contextValue = useMemo(\n () => ({\n registerItem,\n }),\n [registerItem],\n )\n\n useEffect(() => {\n if (items != null && highlightedItem == null) {\n setHighlightedItem(items[0])\n }\n\n if (highlightedItem?.current != null) {\n highlightedItem.current.focus()\n }\n }, [items, highlightedItem])\n\n return (\n <DropDownContext.Provider value={contextValue}>\n <div\n className=\"floating-select-toolbar-popup__dropdown-items\"\n onKeyDown={handleKeyDown}\n ref={dropDownRef}\n >\n {children}\n </div>\n </DropDownContext.Provider>\n )\n}\n\nexport function DropDown({\n Icon,\n buttonAriaLabel,\n buttonClassName,\n children,\n disabled = false,\n stopCloseOnClickSelf,\n}: {\n Icon?: React.FC\n buttonAriaLabel?: string\n buttonClassName: string\n children: ReactNode\n disabled?: boolean\n stopCloseOnClickSelf?: boolean\n}): React.ReactNode {\n const dropDownRef = useRef<HTMLDivElement>(null)\n const buttonRef = useRef<HTMLButtonElement>(null)\n const [showDropDown, setShowDropDown] = useState(false)\n\n const handleClose = (): void => {\n setShowDropDown(false)\n if (buttonRef?.current != null) {\n buttonRef.current.focus()\n }\n }\n\n useEffect(() => {\n const button = buttonRef.current\n const dropDown = dropDownRef.current\n\n if (showDropDown && button !== null && dropDown !== null) {\n const { left, top } = button.getBoundingClientRect()\n const scrollTopOffset = window.pageYOffset || document.documentElement.scrollTop\n dropDown.style.top = `${top + scrollTopOffset + button.offsetHeight + 5}px`\n dropDown.style.left = `${Math.min(left - 5, window.innerWidth - dropDown.offsetWidth - 20)}px`\n }\n }, [dropDownRef, buttonRef, showDropDown])\n\n useEffect(() => {\n const button = buttonRef.current\n\n if (button !== null && showDropDown) {\n const handle = (event: MouseEvent): void => {\n const { target } = event\n if (stopCloseOnClickSelf != null) {\n // eslint-disable-next-line @typescript-eslint/prefer-optional-chain\n if (dropDownRef.current != null && dropDownRef.current.contains(target as Node)) {\n return\n }\n }\n if (!button.contains(target as Node)) {\n setShowDropDown(false)\n }\n }\n document.addEventListener('click', handle)\n\n return () => {\n document.removeEventListener('click', handle)\n }\n }\n }, [dropDownRef, buttonRef, showDropDown, stopCloseOnClickSelf])\n\n return (\n <React.Fragment>\n <button\n aria-label={buttonAriaLabel}\n className={buttonClassName + (showDropDown ? ' active' : '')}\n disabled={disabled}\n onClick={(event) => {\n event.preventDefault()\n setShowDropDown(!showDropDown)\n }}\n onMouseDown={(e) => {\n // This fixes a bug where you are unable to click the button if you are in a NESTED editor (editor in blocks field in editor).\n // Thus only happens if you click on the SVG of the button. Clicking on the outside works. Related issue: https://github.com/payloadcms/payload/issues/4025\n // TODO: Find out why exactly it happens and why e.preventDefault() on the mouseDown fixes it. Write that down here, or potentially fix a root cause, if there is any.\n e.preventDefault()\n }}\n ref={buttonRef}\n type=\"button\"\n >\n <Icon />\n <i className=\"floating-select-toolbar-popup__dropdown-caret\" />\n </button>\n\n {showDropDown &&\n createPortal(\n <DropDownItems dropDownRef={dropDownRef} onClose={handleClose}>\n {children}\n </DropDownItems>,\n document.body,\n )}\n </React.Fragment>\n )\n}\n"],"names":["lexicalComposerContextImport","useLexicalComposerContext","lexicalUtilsImport","mergeRegister","lexicalImport","$getSelection","useCallback","useEffect","useMemo","useRef","useState","React","createPortal","baseClass","DropDownContext","createContext","DropDownItem","children","entry","title","editor","enabled","setEnabled","active","setActive","className","setClassName","updateStates","getEditorState","read","selection","isActive","isEnabled","document","addEventListener","removeEventListener","registerUpdateListener","key","filter","Boolean","join","ref","dropDownContext","useContext","Error","registerItem","current","button","onClick","onMouseDown","e","preventDefault","type","DropDownItems","dropDownRef","onClose","items","setItems","highlightedItem","setHighlightedItem","itemRef","prev","handleKeyDown","event","includes","index","indexOf","length","contextValue","focus","Provider","value","div","onKeyDown","DropDown","Icon","buttonAriaLabel","buttonClassName","disabled","stopCloseOnClickSelf","buttonRef","showDropDown","setShowDropDown","handleClose","dropDown","left","top","getBoundingClientRect","scrollTopOffset","window","pageYOffset","documentElement","scrollTop","style","offsetHeight","Math","min","innerWidth","offsetWidth","handle","target","contains","Fragment","aria-label","i","body"],"mappings":"AAAA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AEnC,OAAO;gBACLlE,SAASE,mBAAmB,CAAC,SAASgE;YACxC;QACF;IACF,GAAG;QAAC7C;QAAa0B;QAAWC;QAAcF;KAAqB;IAE/D,qBACE,oBAACpE,MAAM2F,QAAQ,sBACb,oBAACvD;QACCwD,cAAY3B;QACZnD,WAAWoD,kBAAmBI,CAAAA,eAAe,YAAY,EAAC;QAC1DH,UAAUA;QACV9B,SAAS,CAACe;YACRA,MAAMZ,cAAc;YACpB+B,gBAAgB,CAACD;QACnB;QACAhC,aAAa,CAACC;YACZ,8HAA8H;YAC9H,2JAA2J;YAC3J,sKAAsK;YACtKA,EAAEC,cAAc;QAClB;QACAV,KAAKuC;QACL5B,MAAK;qBAEL,oBAACuB,2BACD,oBAAC6B;QAAE/E,WAAU;SAGdwD,8BACCrE,2BACE,oBAACyC;QAAcC,aAAaA;QAAaC,SAAS4B;OAC/ClE,WAEHgB,SAASwE,IAAI;AAIvB"}
|
|
1
|
+
{"version":3,"sources":["../../../../../../src/field/lexical/plugins/FloatingSelectToolbar/ToolbarDropdown/DropDown.tsx"],"sourcesContent":["'use client'\nimport lexicalComposerContextImport from '@lexical/react/LexicalComposerContext.js'\nconst { useLexicalComposerContext } = lexicalComposerContextImport\n\nimport lexicalUtilsImport from '@lexical/utils'\nconst { mergeRegister } = lexicalUtilsImport\n\nimport lexicalImport from 'lexical'\nconst { $getSelection } = lexicalImport\n\nimport { type ReactNode, useCallback, useEffect, useMemo, useRef, useState } from 'react'\nimport React from 'react'\nimport { createPortal } from 'react-dom'\n\nimport type { FloatingToolbarSectionEntry } from '../types.js'\n\nconst baseClass = 'floating-select-toolbar-popup__dropdown-item'\n\ninterface DropDownContextType {\n registerItem: (ref: React.RefObject<HTMLButtonElement>) => void\n}\n\nconst DropDownContext = React.createContext<DropDownContextType | null>(null)\n\nexport function DropDownItem({\n children,\n entry,\n title,\n}: {\n children: React.ReactNode\n entry: FloatingToolbarSectionEntry\n title?: string\n}): React.ReactNode {\n const [editor] = useLexicalComposerContext()\n const [enabled, setEnabled] = useState<boolean>(true)\n const [active, setActive] = useState<boolean>(false)\n const [className, setClassName] = useState<string>(baseClass)\n\n const updateStates = useCallback(() => {\n editor.getEditorState().read(() => {\n const selection = $getSelection()\n if (entry.isActive) {\n const isActive = entry.isActive({ editor, selection })\n if (active !== isActive) {\n setActive(isActive)\n }\n }\n if (entry.isEnabled) {\n const isEnabled = entry.isEnabled({ editor, selection })\n if (enabled !== isEnabled) {\n setEnabled(isEnabled)\n }\n }\n })\n }, [active, editor, enabled, entry])\n\n useEffect(() => {\n updateStates()\n }, [updateStates])\n\n useEffect(() => {\n document.addEventListener('mouseup', updateStates)\n return () => {\n document.removeEventListener('mouseup', updateStates)\n }\n }, [updateStates])\n\n useEffect(() => {\n return mergeRegister(\n editor.registerUpdateListener(() => {\n updateStates()\n }),\n )\n }, [editor, updateStates])\n\n useEffect(() => {\n setClassName(\n [\n baseClass,\n enabled === false ? 'disabled' : '',\n active ? 'active' : '',\n entry?.key ? `${baseClass}-${entry.key}` : '',\n ]\n .filter(Boolean)\n .join(' '),\n )\n }, [enabled, active, className, entry.key])\n\n const ref = useRef<HTMLButtonElement>(null)\n\n const dropDownContext = React.useContext(DropDownContext)\n\n if (dropDownContext === null) {\n throw new Error('DropDownItem must be used within a DropDown')\n }\n\n const { registerItem } = dropDownContext\n\n useEffect(() => {\n if (ref?.current != null) {\n registerItem(ref)\n }\n }, [ref, registerItem])\n\n return (\n <button\n className={className}\n onClick={() => {\n if (enabled !== false) {\n entry.onClick({\n editor,\n isActive: active,\n })\n }\n }}\n onMouseDown={(e) => {\n // This is required for Firefox compatibility. Without it, the dropdown will disappear without the onClick being called.\n // This only happens in Firefox. Must be something about how Firefox handles focus events differently.\n e.preventDefault()\n }}\n ref={ref}\n title={title}\n type=\"button\"\n >\n {children}\n </button>\n )\n}\n\nfunction DropDownItems({\n children,\n dropDownRef,\n onClose,\n}: {\n children: React.ReactNode\n dropDownRef: React.Ref<HTMLDivElement>\n onClose: () => void\n}): JSX.Element {\n const [items, setItems] = useState<Array<React.RefObject<HTMLButtonElement>>>()\n const [highlightedItem, setHighlightedItem] = useState<React.RefObject<HTMLButtonElement>>()\n\n const registerItem = useCallback(\n (itemRef: React.RefObject<HTMLButtonElement>) => {\n setItems((prev) => (prev != null ? [...prev, itemRef] : [itemRef]))\n },\n [setItems],\n )\n\n const handleKeyDown = (event: React.KeyboardEvent<HTMLDivElement>): void => {\n if (items == null) return\n\n const { key } = event\n\n if (['ArrowDown', 'ArrowUp', 'Escape', 'Tab'].includes(key)) {\n event.preventDefault()\n }\n\n if (key === 'Escape' || key === 'Tab') {\n onClose()\n } else if (key === 'ArrowUp') {\n setHighlightedItem((prev) => {\n if (prev == null) return items[0]\n const index = items.indexOf(prev) - 1\n return items[index === -1 ? items.length - 1 : index]\n })\n } else if (key === 'ArrowDown') {\n setHighlightedItem((prev) => {\n if (prev == null) return items[0]\n return items[items.indexOf(prev) + 1]\n })\n }\n }\n\n const contextValue = useMemo(\n () => ({\n registerItem,\n }),\n [registerItem],\n )\n\n useEffect(() => {\n if (items != null && highlightedItem == null) {\n setHighlightedItem(items[0])\n }\n\n if (highlightedItem?.current != null) {\n highlightedItem.current.focus()\n }\n }, [items, highlightedItem])\n\n return (\n <DropDownContext.Provider value={contextValue}>\n <div\n className=\"floating-select-toolbar-popup__dropdown-items\"\n onKeyDown={handleKeyDown}\n ref={dropDownRef}\n >\n {children}\n </div>\n </DropDownContext.Provider>\n )\n}\n\nexport function DropDown({\n Icon,\n buttonAriaLabel,\n buttonClassName,\n children,\n disabled = false,\n stopCloseOnClickSelf,\n}: {\n Icon?: React.FC\n buttonAriaLabel?: string\n buttonClassName: string\n children: ReactNode\n disabled?: boolean\n stopCloseOnClickSelf?: boolean\n}): React.ReactNode {\n const dropDownRef = useRef<HTMLDivElement>(null)\n const buttonRef = useRef<HTMLButtonElement>(null)\n const [showDropDown, setShowDropDown] = useState(false)\n\n const handleClose = (): void => {\n setShowDropDown(false)\n if (buttonRef?.current != null) {\n buttonRef.current.focus()\n }\n }\n\n useEffect(() => {\n const button = buttonRef.current\n const dropDown = dropDownRef.current\n\n if (showDropDown && button !== null && dropDown !== null) {\n const { left, top } = button.getBoundingClientRect()\n const scrollTopOffset = window.pageYOffset || document.documentElement.scrollTop\n dropDown.style.top = `${top + scrollTopOffset + button.offsetHeight + 5}px`\n dropDown.style.left = `${Math.min(left - 5, window.innerWidth - dropDown.offsetWidth - 20)}px`\n }\n }, [dropDownRef, buttonRef, showDropDown])\n\n useEffect(() => {\n const button = buttonRef.current\n\n if (button !== null && showDropDown) {\n const handle = (event: MouseEvent): void => {\n const { target } = event\n if (stopCloseOnClickSelf != null) {\n // eslint-disable-next-line @typescript-eslint/prefer-optional-chain\n if (dropDownRef.current != null && dropDownRef.current.contains(target as Node)) {\n return\n }\n }\n if (!button.contains(target as Node)) {\n setShowDropDown(false)\n }\n }\n document.addEventListener('click', handle)\n\n return () => {\n document.removeEventListener('click', handle)\n }\n }\n }, [dropDownRef, buttonRef, showDropDown, stopCloseOnClickSelf])\n\n return (\n <React.Fragment>\n <button\n aria-label={buttonAriaLabel}\n className={buttonClassName + (showDropDown ? ' active' : '')}\n disabled={disabled}\n onClick={(event) => {\n event.preventDefault()\n setShowDropDown(!showDropDown)\n }}\n onMouseDown={(e) => {\n // This fixes a bug where you are unable to click the button if you are in a NESTED editor (editor in blocks field in editor).\n // Thus only happens if you click on the SVG of the button. Clicking on the outside works. Related issue: https://github.com/payloadcms/payload/issues/4025\n // TODO: Find out why exactly it happens and why e.preventDefault() on the mouseDown fixes it. Write that down here, or potentially fix a root cause, if there is any.\n e.preventDefault()\n }}\n ref={buttonRef}\n type=\"button\"\n >\n <Icon />\n <i className=\"floating-select-toolbar-popup__dropdown-caret\" />\n </button>\n\n {showDropDown &&\n createPortal(\n <DropDownItems dropDownRef={dropDownRef} onClose={handleClose}>\n {children}\n </DropDownItems>,\n document.body,\n )}\n </React.Fragment>\n )\n}\n"],"names":["lexicalComposerContextImport","useLexicalComposerContext","lexicalUtilsImport","mergeRegister","lexicalImport","$getSelection","useCallback","useEffect","useMemo","useRef","useState","React","createPortal","baseClass","DropDownContext","createContext","DropDownItem","children","entry","title","editor","enabled","setEnabled","active","setActive","className","setClassName","updateStates","getEditorState","read","selection","isActive","isEnabled","document","addEventListener","removeEventListener","registerUpdateListener","key","filter","Boolean","join","ref","dropDownContext","useContext","Error","registerItem","current","button","onClick","onMouseDown","e","preventDefault","type","DropDownItems","dropDownRef","onClose","items","setItems","highlightedItem","setHighlightedItem","itemRef","prev","handleKeyDown","event","includes","index","indexOf","length","contextValue","focus","Provider","value","div","onKeyDown","DropDown","Icon","buttonAriaLabel","buttonClassName","disabled","stopCloseOnClickSelf","buttonRef","showDropDown","setShowDropDown","handleClose","dropDown","left","top","getBoundingClientRect","scrollTopOffset","window","pageYOffset","documentElement","scrollTop","style","offsetHeight","Math","min","innerWidth","offsetWidth","handle","target","contains","Fragment","aria-label","i","body"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA;AACA,OAAOA,kCAAkC,2CAA0C;AACnF,MAAM,EAAEC,yBAAyB,EAAE,GAAGD;AAEtC,OAAOE,wBAAwB,iBAAgB;AAC/C,MAAM,EAAEC,aAAa,EAAE,GAAGD;AAE1B,OAAOE,mBAAmB,UAAS;AACnC,MAAM,EAAEC,aAAa,EAAE,GAAGD;AAE1B,SAAyBE,WAAW,EAAEC,SAAS,EAAEC,OAAO,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,QAAO;AACzF,OAAOC,WAAW,QAAO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,CAACC;YACZ,8HAA8H;YAC9H,2JAA2J;YAC3J,sKAAsK;YACtKA,EAAEC,cAAc;QAClB;QACAV,KAAKuC;QACL5B,MAAK;qBAEL,oBAACuB,2BACD,oBAAC6B;QAAE/E,WAAU;SAGdwD,8BACCrE,2BACE,oBAACyC;QAAcC,aAAaA;QAAaC,SAAS4B;OAC/ClE,WAEHgB,SAASwE,IAAI;AAIvB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../src/field/lexical/plugins/FloatingSelectToolbar/ToolbarDropdown/index.tsx"],"sourcesContent":["'use client'\nimport React from 'react'\n\nconst baseClass = 'floating-select-toolbar-popup__dropdown'\n\nimport type { LexicalEditor } from 'lexical'\n\nimport type { FloatingToolbarSectionEntry } from '../types.js'\n\nimport { DropDown, DropDownItem } from './DropDown.js'\nimport './index.scss'\n\nexport const ToolbarEntry = ({\n anchorElem,\n editor,\n entry,\n}: {\n anchorElem: HTMLElement\n editor: LexicalEditor\n entry: FloatingToolbarSectionEntry\n}) => {\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 <DropDownItem entry={entry} key={entry.key}>\n {entry?.ChildComponent && <entry.ChildComponent />}\n <span className=\"text\">{entry.label}</span>\n </DropDownItem>\n )\n}\n\nexport const ToolbarDropdown = ({\n Icon,\n anchorElem,\n classNames,\n editor,\n entries,\n sectionKey,\n}: {\n Icon?: React.FC\n anchorElem: HTMLElement\n classNames?: string[]\n editor: LexicalEditor\n entries: FloatingToolbarSectionEntry[]\n sectionKey: string\n}) => {\n return (\n <DropDown\n Icon={Icon}\n buttonAriaLabel={`${sectionKey} dropdown`}\n buttonClassName={[baseClass, `${baseClass}-${sectionKey}`, ...(classNames || [])]\n .filter(Boolean)\n .join(' ')}\n key={sectionKey}\n >\n {entries.length &&\n entries.map((entry) => {\n return (\n <ToolbarEntry anchorElem={anchorElem} editor={editor} entry={entry} key={entry.key} />\n )\n })}\n </DropDown>\n )\n}\n"],"names":["React","baseClass","DropDown","DropDownItem","ToolbarEntry","anchorElem","editor","entry","Component","key","ChildComponent","span","className","label","ToolbarDropdown","Icon","classNames","entries","sectionKey","buttonAriaLabel","buttonClassName","filter","Boolean","join","length","map"],"mappings":"AAAA;AACA,OAAOA,WAAW,QAAO;AAEzB,MAAMC,YAAY;AAMlB,SAASC,QAAQ,EAAEC,YAAY,QAAQ,gBAAe;AACtD,OAAO,eAAc;AAErB,OAAO,MAAMC,eAAe,CAAC,EAC3BC,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,oBAACN;QAAaI,OAAOA;QAAOE,KAAKF,MAAME,GAAG;OACvCF,OAAOG,gCAAkB,oBAACH,MAAMG,cAAc,uBAC/C,oBAACC;QAAKC,WAAU;OAAQL,MAAMM,KAAK;AAGzC,EAAC;AAED,OAAO,MAAMC,kBAAkB,CAAC,EAC9BC,IAAI,EACJV,UAAU,EACVW,UAAU,EACVV,MAAM,EACNW,OAAO,EACPC,UAAU,EAQX;IACC,qBACE,oBAAChB;QACCa,MAAMA;QACNI,iBAAiB,CAAC,EAAED,WAAW,SAAS,CAAC;QACzCE,iBAAiB;YAACnB;YAAW,CAAC,EAAEA,UAAU,CAAC,EAAEiB,WAAW,CAAC;eAAMF,cAAc,EAAE;SAAE,CAC9EK,MAAM,CAACC,SACPC,IAAI,CAAC;QACRd,KAAKS;OAEJD,QAAQO,MAAM,IACbP,QAAQQ,GAAG,CAAC,CAAClB;QACX,qBACE,oBAACH;YAAaC,YAAYA;YAAYC,QAAQA;YAAQC,OAAOA;YAAOE,KAAKF,MAAME,GAAG;;IAEtF;AAGR,EAAC"}
|
|
1
|
+
{"version":3,"sources":["../../../../../../src/field/lexical/plugins/FloatingSelectToolbar/ToolbarDropdown/index.tsx"],"sourcesContent":["'use client'\nimport React from 'react'\n\nconst baseClass = 'floating-select-toolbar-popup__dropdown'\n\nimport type { LexicalEditor } from 'lexical'\n\nimport type { FloatingToolbarSectionEntry } from '../types.js'\n\nimport { DropDown, DropDownItem } from './DropDown.js'\nimport './index.scss'\n\nexport const ToolbarEntry = ({\n anchorElem,\n editor,\n entry,\n}: {\n anchorElem: HTMLElement\n editor: LexicalEditor\n entry: FloatingToolbarSectionEntry\n}) => {\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 <DropDownItem entry={entry} key={entry.key}>\n {entry?.ChildComponent && <entry.ChildComponent />}\n <span className=\"text\">{entry.label}</span>\n </DropDownItem>\n )\n}\n\nexport const ToolbarDropdown = ({\n Icon,\n anchorElem,\n classNames,\n editor,\n entries,\n sectionKey,\n}: {\n Icon?: React.FC\n anchorElem: HTMLElement\n classNames?: string[]\n editor: LexicalEditor\n entries: FloatingToolbarSectionEntry[]\n sectionKey: string\n}) => {\n return (\n <DropDown\n Icon={Icon}\n buttonAriaLabel={`${sectionKey} dropdown`}\n buttonClassName={[baseClass, `${baseClass}-${sectionKey}`, ...(classNames || [])]\n .filter(Boolean)\n .join(' ')}\n key={sectionKey}\n >\n {entries.length &&\n entries.map((entry) => {\n return (\n <ToolbarEntry anchorElem={anchorElem} editor={editor} entry={entry} key={entry.key} />\n )\n })}\n </DropDown>\n )\n}\n"],"names":["React","baseClass","DropDown","DropDownItem","ToolbarEntry","anchorElem","editor","entry","Component","key","ChildComponent","span","className","label","ToolbarDropdown","Icon","classNames","entries","sectionKey","buttonAriaLabel","buttonClassName","filter","Boolean","join","length","map"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA;AACA,OAAOA,WAAW,QAAO;AAEzB,MAAMC,YAAY;AAMlB,SAASC,QAAQ,EAAEC,YAAY,QAAQ,gBAAe;AACtD,OAAO,eAAc;AAErB,OAAO,MAAMC,eAAe,CAAC,EAC3BC,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,oBAACN;QAAaI,OAAOA;QAAOE,KAAKF,MAAME,GAAG;OACvCF,OAAOG,gCAAkB,oBAACH,MAAMG,cAAc,uBAC/C,oBAACC;QAAKC,WAAU;OAAQL,MAAMM,KAAK;AAGzC,EAAC;AAED,OAAO,MAAMC,kBAAkB,CAAC,EAC9BC,IAAI,EACJV,UAAU,EACVW,UAAU,EACVV,MAAM,EACNW,OAAO,EACPC,UAAU,EAQX;IACC,qBACE,oBAAChB;QACCa,MAAMA;QACNI,iBAAiB,CAAC,EAAED,WAAW,SAAS,CAAC;QACzCE,iBAAiB;YAACnB;YAAW,CAAC,EAAEA,UAAU,CAAC,EAAEiB,WAAW,CAAC;eAAMF,cAAc,EAAE;SAAE,CAC9EK,MAAM,CAACC,SACPC,IAAI,CAAC;QACRd,KAAKS;OAEJD,QAAQO,MAAM,IACbP,QAAQQ,GAAG,CAAC,CAAClB;QACX,qBACE,oBAACH;YAAaC,YAAYA;YAAYC,QAAQA;YAAQC,OAAOA;YAAOE,KAAKF,MAAME,GAAG;;IAEtF;AAGR,EAAC"}
|