@payloadcms/richtext-lexical 3.0.0-beta.134 → 3.0.0-beta.135
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/exports/client/Field-KKSJXHR7.js +2 -0
- package/dist/exports/client/Field-KKSJXHR7.js.map +7 -0
- package/dist/exports/client/bundled.css +1 -1
- package/dist/exports/client/chunk-QPPOQTHD.js +2 -0
- package/dist/exports/client/{chunk-OOBB5GCO.js.map → chunk-QPPOQTHD.js.map} +3 -3
- package/dist/exports/client/index.js +15 -13
- package/dist/exports/client/index.js.map +4 -4
- package/dist/exports/server/ast/mdx.d.ts +7 -0
- package/dist/exports/server/ast/mdx.d.ts.map +1 -0
- package/dist/exports/server/ast/mdx.js +37 -0
- package/dist/exports/server/ast/mdx.js.map +1 -0
- package/dist/exports/shared.d.ts +4 -0
- package/dist/exports/shared.d.ts.map +1 -0
- package/dist/exports/shared.js +4 -0
- package/dist/exports/shared.js.map +1 -0
- package/dist/features/blocks/client/index.d.ts +1 -5
- package/dist/features/blocks/client/index.d.ts.map +1 -1
- package/dist/features/blocks/client/index.js +138 -154
- package/dist/features/blocks/client/index.js.map +1 -1
- package/dist/features/blocks/client/markdownTransformer.d.ts +16 -0
- package/dist/features/blocks/client/markdownTransformer.d.ts.map +1 -0
- package/dist/features/blocks/client/markdownTransformer.js +144 -0
- package/dist/features/blocks/client/markdownTransformer.js.map +1 -0
- package/dist/features/blocks/client/plugin/index.d.ts +1 -2
- package/dist/features/blocks/client/plugin/index.d.ts.map +1 -1
- package/dist/features/blocks/client/plugin/index.js.map +1 -1
- package/dist/features/blocks/server/index.d.ts +1 -2
- package/dist/features/blocks/server/index.d.ts.map +1 -1
- package/dist/features/blocks/server/index.js +5 -8
- package/dist/features/blocks/server/index.js.map +1 -1
- package/dist/features/blocks/server/linesFromMatchToContentAndPropsString.d.ts +22 -0
- package/dist/features/blocks/server/linesFromMatchToContentAndPropsString.d.ts.map +1 -0
- package/dist/features/blocks/server/linesFromMatchToContentAndPropsString.js +136 -0
- package/dist/features/blocks/server/linesFromMatchToContentAndPropsString.js.map +1 -0
- package/dist/features/blocks/server/markdownTransformer.d.ts +22 -0
- package/dist/features/blocks/server/markdownTransformer.d.ts.map +1 -0
- package/dist/features/blocks/server/markdownTransformer.js +400 -0
- package/dist/features/blocks/server/markdownTransformer.js.map +1 -0
- package/dist/features/experimental_table/client/index.d.ts.map +1 -1
- package/dist/features/experimental_table/client/index.js +2 -0
- package/dist/features/experimental_table/client/index.js.map +1 -1
- package/dist/features/experimental_table/markdownTransformer.d.ts +5 -0
- package/dist/features/experimental_table/markdownTransformer.d.ts.map +1 -0
- package/dist/features/experimental_table/markdownTransformer.js +127 -0
- package/dist/features/experimental_table/markdownTransformer.js.map +1 -0
- package/dist/features/experimental_table/server/index.d.ts.map +1 -1
- package/dist/features/experimental_table/server/index.js +2 -0
- package/dist/features/experimental_table/server/index.js.map +1 -1
- package/dist/features/typesClient.d.ts +11 -2
- package/dist/features/typesClient.d.ts.map +1 -1
- package/dist/features/typesClient.js.map +1 -1
- package/dist/features/typesServer.d.ts +6 -2
- package/dist/features/typesServer.d.ts.map +1 -1
- package/dist/features/typesServer.js.map +1 -1
- package/dist/field/Field.d.ts.map +1 -1
- package/dist/field/Field.js +68 -164
- package/dist/field/Field.js.map +1 -1
- package/dist/field/bundled.css +1 -1
- package/dist/field/index.d.ts.map +1 -1
- package/dist/field/index.js +23 -14
- package/dist/field/index.js.map +1 -1
- package/dist/index.d.ts +4 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -1
- package/dist/index.js.map +1 -1
- package/dist/lexical/config/client/loader.d.ts +6 -1
- package/dist/lexical/config/client/loader.d.ts.map +1 -1
- package/dist/lexical/config/client/loader.js +6 -0
- package/dist/lexical/config/client/loader.js.map +1 -1
- package/dist/lexical/config/client/sanitize.d.ts.map +1 -1
- package/dist/lexical/config/client/sanitize.js +15 -2
- package/dist/lexical/config/client/sanitize.js.map +1 -1
- package/dist/lexical/config/server/sanitize.d.ts.map +1 -1
- package/dist/lexical/config/server/sanitize.js +15 -2
- package/dist/lexical/config/server/sanitize.js.map +1 -1
- package/dist/lexical/nodes/index.d.ts +4 -0
- package/dist/lexical/nodes/index.d.ts.map +1 -1
- package/dist/lexical/nodes/index.js +8 -1
- package/dist/lexical/nodes/index.js.map +1 -1
- package/dist/lexical-proxy/@lexical-headless.d.ts +2 -0
- package/dist/lexical-proxy/@lexical-headless.d.ts.map +1 -0
- package/dist/lexical-proxy/@lexical-headless.js +2 -0
- package/dist/lexical-proxy/@lexical-headless.js.map +1 -0
- package/dist/lexical-proxy/@lexical-link.d.ts +2 -0
- package/dist/lexical-proxy/@lexical-link.d.ts.map +1 -0
- package/dist/lexical-proxy/@lexical-link.js +2 -0
- package/dist/lexical-proxy/@lexical-link.js.map +1 -0
- package/dist/lexical-proxy/@lexical-list.d.ts +2 -0
- package/dist/lexical-proxy/@lexical-list.d.ts.map +1 -0
- package/dist/lexical-proxy/@lexical-list.js +2 -0
- package/dist/lexical-proxy/@lexical-list.js.map +1 -0
- package/dist/lexical-proxy/@lexical-mark.d.ts +2 -0
- package/dist/lexical-proxy/@lexical-mark.d.ts.map +1 -0
- package/dist/lexical-proxy/@lexical-mark.js +2 -0
- package/dist/lexical-proxy/@lexical-mark.js.map +1 -0
- package/dist/lexical-proxy/@lexical-markdown.d.ts +2 -0
- package/dist/lexical-proxy/@lexical-markdown.d.ts.map +1 -0
- package/dist/lexical-proxy/@lexical-markdown.js +2 -0
- package/dist/lexical-proxy/@lexical-markdown.js.map +1 -0
- package/dist/lexical-proxy/@lexical-react/LexicalAutoEmbedPlugin.d.ts +2 -0
- package/dist/lexical-proxy/@lexical-react/LexicalAutoEmbedPlugin.d.ts.map +1 -0
- package/dist/lexical-proxy/@lexical-react/LexicalAutoEmbedPlugin.js +2 -0
- package/dist/lexical-proxy/@lexical-react/LexicalAutoEmbedPlugin.js.map +1 -0
- package/dist/lexical-proxy/@lexical-react/LexicalAutoFocusPlugin.d.ts +2 -0
- package/dist/lexical-proxy/@lexical-react/LexicalAutoFocusPlugin.d.ts.map +1 -0
- package/dist/lexical-proxy/@lexical-react/LexicalAutoFocusPlugin.js +2 -0
- package/dist/lexical-proxy/@lexical-react/LexicalAutoFocusPlugin.js.map +1 -0
- package/dist/lexical-proxy/@lexical-react/LexicalAutoLinkPlugin.d.ts +2 -0
- package/dist/lexical-proxy/@lexical-react/LexicalAutoLinkPlugin.d.ts.map +1 -0
- package/dist/lexical-proxy/@lexical-react/LexicalAutoLinkPlugin.js +2 -0
- package/dist/lexical-proxy/@lexical-react/LexicalAutoLinkPlugin.js.map +1 -0
- package/dist/lexical-proxy/@lexical-react/LexicalBlockWithAlignableContents.d.ts +2 -0
- package/dist/lexical-proxy/@lexical-react/LexicalBlockWithAlignableContents.d.ts.map +1 -0
- package/dist/lexical-proxy/@lexical-react/LexicalBlockWithAlignableContents.js +2 -0
- package/dist/lexical-proxy/@lexical-react/LexicalBlockWithAlignableContents.js.map +1 -0
- package/dist/lexical-proxy/@lexical-react/LexicalCharacterLimitPlugin.d.ts +2 -0
- package/dist/lexical-proxy/@lexical-react/LexicalCharacterLimitPlugin.d.ts.map +1 -0
- package/dist/lexical-proxy/@lexical-react/LexicalCharacterLimitPlugin.js +2 -0
- package/dist/lexical-proxy/@lexical-react/LexicalCharacterLimitPlugin.js.map +1 -0
- package/dist/lexical-proxy/@lexical-react/LexicalCheckListPlugin.d.ts +2 -0
- package/dist/lexical-proxy/@lexical-react/LexicalCheckListPlugin.d.ts.map +1 -0
- package/dist/lexical-proxy/@lexical-react/LexicalCheckListPlugin.js +2 -0
- package/dist/lexical-proxy/@lexical-react/LexicalCheckListPlugin.js.map +1 -0
- package/dist/lexical-proxy/@lexical-react/LexicalClearEditorPlugin.d.ts +2 -0
- package/dist/lexical-proxy/@lexical-react/LexicalClearEditorPlugin.d.ts.map +1 -0
- package/dist/lexical-proxy/@lexical-react/LexicalClearEditorPlugin.js +2 -0
- package/dist/lexical-proxy/@lexical-react/LexicalClearEditorPlugin.js.map +1 -0
- package/dist/lexical-proxy/@lexical-react/LexicalClickableLinkPlugin.d.ts +2 -0
- package/dist/lexical-proxy/@lexical-react/LexicalClickableLinkPlugin.d.ts.map +1 -0
- package/dist/lexical-proxy/@lexical-react/LexicalClickableLinkPlugin.js +2 -0
- package/dist/lexical-proxy/@lexical-react/LexicalClickableLinkPlugin.js.map +1 -0
- package/dist/lexical-proxy/@lexical-react/LexicalCollaborationContext.d.ts +2 -0
- package/dist/lexical-proxy/@lexical-react/LexicalCollaborationContext.d.ts.map +1 -0
- package/dist/lexical-proxy/@lexical-react/LexicalCollaborationContext.js +2 -0
- package/dist/lexical-proxy/@lexical-react/LexicalCollaborationContext.js.map +1 -0
- package/dist/lexical-proxy/@lexical-react/LexicalCollaborationPlugin.d.ts +2 -0
- package/dist/lexical-proxy/@lexical-react/LexicalCollaborationPlugin.d.ts.map +1 -0
- package/dist/lexical-proxy/@lexical-react/LexicalCollaborationPlugin.js +2 -0
- package/dist/lexical-proxy/@lexical-react/LexicalCollaborationPlugin.js.map +1 -0
- package/dist/lexical-proxy/@lexical-react/LexicalComposer.d.ts +2 -0
- package/dist/lexical-proxy/@lexical-react/LexicalComposer.d.ts.map +1 -0
- package/dist/lexical-proxy/@lexical-react/LexicalComposer.js +2 -0
- package/dist/lexical-proxy/@lexical-react/LexicalComposer.js.map +1 -0
- package/dist/lexical-proxy/@lexical-react/LexicalComposerContext.d.ts +2 -0
- package/dist/lexical-proxy/@lexical-react/LexicalComposerContext.d.ts.map +1 -0
- package/dist/lexical-proxy/@lexical-react/LexicalComposerContext.js +2 -0
- package/dist/lexical-proxy/@lexical-react/LexicalComposerContext.js.map +1 -0
- package/dist/lexical-proxy/@lexical-react/LexicalContentEditable.d.ts +2 -0
- package/dist/lexical-proxy/@lexical-react/LexicalContentEditable.d.ts.map +1 -0
- package/dist/lexical-proxy/@lexical-react/LexicalContentEditable.js +2 -0
- package/dist/lexical-proxy/@lexical-react/LexicalContentEditable.js.map +1 -0
- package/dist/lexical-proxy/@lexical-react/LexicalContextMenuPlugin.d.ts +2 -0
- package/dist/lexical-proxy/@lexical-react/LexicalContextMenuPlugin.d.ts.map +1 -0
- package/dist/lexical-proxy/@lexical-react/LexicalContextMenuPlugin.js +2 -0
- package/dist/lexical-proxy/@lexical-react/LexicalContextMenuPlugin.js.map +1 -0
- package/dist/lexical-proxy/@lexical-react/LexicalDecoratorBlockNode.d.ts +2 -0
- package/dist/lexical-proxy/@lexical-react/LexicalDecoratorBlockNode.d.ts.map +1 -0
- package/dist/lexical-proxy/@lexical-react/LexicalDecoratorBlockNode.js +2 -0
- package/dist/lexical-proxy/@lexical-react/LexicalDecoratorBlockNode.js.map +1 -0
- package/dist/lexical-proxy/@lexical-react/LexicalDraggableBlockPlugin.d.ts +2 -0
- package/dist/lexical-proxy/@lexical-react/LexicalDraggableBlockPlugin.d.ts.map +1 -0
- package/dist/lexical-proxy/@lexical-react/LexicalDraggableBlockPlugin.js +2 -0
- package/dist/lexical-proxy/@lexical-react/LexicalDraggableBlockPlugin.js.map +1 -0
- package/dist/lexical-proxy/@lexical-react/LexicalEditorRefPlugin.d.ts +2 -0
- package/dist/lexical-proxy/@lexical-react/LexicalEditorRefPlugin.d.ts.map +1 -0
- package/dist/lexical-proxy/@lexical-react/LexicalEditorRefPlugin.js +2 -0
- package/dist/lexical-proxy/@lexical-react/LexicalEditorRefPlugin.js.map +1 -0
- package/dist/lexical-proxy/@lexical-react/LexicalErrorBoundary.d.ts +2 -0
- package/dist/lexical-proxy/@lexical-react/LexicalErrorBoundary.d.ts.map +1 -0
- package/dist/lexical-proxy/@lexical-react/LexicalErrorBoundary.js +2 -0
- package/dist/lexical-proxy/@lexical-react/LexicalErrorBoundary.js.map +1 -0
- package/dist/lexical-proxy/@lexical-react/LexicalHashtagPlugin.d.ts +2 -0
- package/dist/lexical-proxy/@lexical-react/LexicalHashtagPlugin.d.ts.map +1 -0
- package/dist/lexical-proxy/@lexical-react/LexicalHashtagPlugin.js +2 -0
- package/dist/lexical-proxy/@lexical-react/LexicalHashtagPlugin.js.map +1 -0
- package/dist/lexical-proxy/@lexical-react/LexicalHistoryPlugin.d.ts +2 -0
- package/dist/lexical-proxy/@lexical-react/LexicalHistoryPlugin.d.ts.map +1 -0
- package/dist/lexical-proxy/@lexical-react/LexicalHistoryPlugin.js +2 -0
- package/dist/lexical-proxy/@lexical-react/LexicalHistoryPlugin.js.map +1 -0
- package/dist/lexical-proxy/@lexical-react/LexicalHorizontalRuleNode.d.ts +2 -0
- package/dist/lexical-proxy/@lexical-react/LexicalHorizontalRuleNode.d.ts.map +1 -0
- package/dist/lexical-proxy/@lexical-react/LexicalHorizontalRuleNode.js +2 -0
- package/dist/lexical-proxy/@lexical-react/LexicalHorizontalRuleNode.js.map +1 -0
- package/dist/lexical-proxy/@lexical-react/LexicalHorizontalRulePlugin.d.ts +2 -0
- package/dist/lexical-proxy/@lexical-react/LexicalHorizontalRulePlugin.d.ts.map +1 -0
- package/dist/lexical-proxy/@lexical-react/LexicalHorizontalRulePlugin.js +2 -0
- package/dist/lexical-proxy/@lexical-react/LexicalHorizontalRulePlugin.js.map +1 -0
- package/dist/lexical-proxy/@lexical-react/LexicalLinkPlugin.d.ts +2 -0
- package/dist/lexical-proxy/@lexical-react/LexicalLinkPlugin.d.ts.map +1 -0
- package/dist/lexical-proxy/@lexical-react/LexicalLinkPlugin.js +2 -0
- package/dist/lexical-proxy/@lexical-react/LexicalLinkPlugin.js.map +1 -0
- package/dist/lexical-proxy/@lexical-react/LexicalListPlugin.d.ts +2 -0
- package/dist/lexical-proxy/@lexical-react/LexicalListPlugin.d.ts.map +1 -0
- package/dist/lexical-proxy/@lexical-react/LexicalListPlugin.js +2 -0
- package/dist/lexical-proxy/@lexical-react/LexicalListPlugin.js.map +1 -0
- package/dist/lexical-proxy/@lexical-react/LexicalMarkdownShortcutPlugin.d.ts +2 -0
- package/dist/lexical-proxy/@lexical-react/LexicalMarkdownShortcutPlugin.d.ts.map +1 -0
- package/dist/lexical-proxy/@lexical-react/LexicalMarkdownShortcutPlugin.js +2 -0
- package/dist/lexical-proxy/@lexical-react/LexicalMarkdownShortcutPlugin.js.map +1 -0
- package/dist/lexical-proxy/@lexical-react/LexicalNestedComposer.d.ts +2 -0
- package/dist/lexical-proxy/@lexical-react/LexicalNestedComposer.d.ts.map +1 -0
- package/dist/lexical-proxy/@lexical-react/LexicalNestedComposer.js +2 -0
- package/dist/lexical-proxy/@lexical-react/LexicalNestedComposer.js.map +1 -0
- package/dist/lexical-proxy/@lexical-react/LexicalNodeEventPlugin.d.ts +2 -0
- package/dist/lexical-proxy/@lexical-react/LexicalNodeEventPlugin.d.ts.map +1 -0
- package/dist/lexical-proxy/@lexical-react/LexicalNodeEventPlugin.js +2 -0
- package/dist/lexical-proxy/@lexical-react/LexicalNodeEventPlugin.js.map +1 -0
- package/dist/lexical-proxy/@lexical-react/LexicalNodeMenuPlugin.d.ts +2 -0
- package/dist/lexical-proxy/@lexical-react/LexicalNodeMenuPlugin.d.ts.map +1 -0
- package/dist/lexical-proxy/@lexical-react/LexicalNodeMenuPlugin.js +2 -0
- package/dist/lexical-proxy/@lexical-react/LexicalNodeMenuPlugin.js.map +1 -0
- package/dist/lexical-proxy/@lexical-react/LexicalOnChangePlugin.d.ts +2 -0
- package/dist/lexical-proxy/@lexical-react/LexicalOnChangePlugin.d.ts.map +1 -0
- package/dist/lexical-proxy/@lexical-react/LexicalOnChangePlugin.js +2 -0
- package/dist/lexical-proxy/@lexical-react/LexicalOnChangePlugin.js.map +1 -0
- package/dist/lexical-proxy/@lexical-react/LexicalPlainTextPlugin.d.ts +2 -0
- package/dist/lexical-proxy/@lexical-react/LexicalPlainTextPlugin.d.ts.map +1 -0
- package/dist/lexical-proxy/@lexical-react/LexicalPlainTextPlugin.js +2 -0
- package/dist/lexical-proxy/@lexical-react/LexicalPlainTextPlugin.js.map +1 -0
- package/dist/lexical-proxy/@lexical-react/LexicalRichTextPlugin.d.ts +2 -0
- package/dist/lexical-proxy/@lexical-react/LexicalRichTextPlugin.d.ts.map +1 -0
- package/dist/lexical-proxy/@lexical-react/LexicalRichTextPlugin.js +2 -0
- package/dist/lexical-proxy/@lexical-react/LexicalRichTextPlugin.js.map +1 -0
- package/dist/lexical-proxy/@lexical-react/LexicalTabIndentationPlugin.d.ts +2 -0
- package/dist/lexical-proxy/@lexical-react/LexicalTabIndentationPlugin.d.ts.map +1 -0
- package/dist/lexical-proxy/@lexical-react/LexicalTabIndentationPlugin.js +2 -0
- package/dist/lexical-proxy/@lexical-react/LexicalTabIndentationPlugin.js.map +1 -0
- package/dist/lexical-proxy/@lexical-react/LexicalTableOfContents.d.ts +2 -0
- package/dist/lexical-proxy/@lexical-react/LexicalTableOfContents.d.ts.map +1 -0
- package/dist/lexical-proxy/@lexical-react/LexicalTableOfContents.js +2 -0
- package/dist/lexical-proxy/@lexical-react/LexicalTableOfContents.js.map +1 -0
- package/dist/lexical-proxy/@lexical-react/LexicalTableOfContentsPlugin.d.ts +2 -0
- package/dist/lexical-proxy/@lexical-react/LexicalTableOfContentsPlugin.d.ts.map +1 -0
- package/dist/lexical-proxy/@lexical-react/LexicalTableOfContentsPlugin.js +2 -0
- package/dist/lexical-proxy/@lexical-react/LexicalTableOfContentsPlugin.js.map +1 -0
- package/dist/lexical-proxy/@lexical-react/LexicalTablePlugin.d.ts +2 -0
- package/dist/lexical-proxy/@lexical-react/LexicalTablePlugin.d.ts.map +1 -0
- package/dist/lexical-proxy/@lexical-react/LexicalTablePlugin.js +2 -0
- package/dist/lexical-proxy/@lexical-react/LexicalTablePlugin.js.map +1 -0
- package/dist/lexical-proxy/@lexical-react/LexicalTreeView.d.ts +2 -0
- package/dist/lexical-proxy/@lexical-react/LexicalTreeView.d.ts.map +1 -0
- package/dist/lexical-proxy/@lexical-react/LexicalTreeView.js +2 -0
- package/dist/lexical-proxy/@lexical-react/LexicalTreeView.js.map +1 -0
- package/dist/lexical-proxy/@lexical-react/LexicalTypeaheadMenuPlugin.d.ts +2 -0
- package/dist/lexical-proxy/@lexical-react/LexicalTypeaheadMenuPlugin.d.ts.map +1 -0
- package/dist/lexical-proxy/@lexical-react/LexicalTypeaheadMenuPlugin.js +2 -0
- package/dist/lexical-proxy/@lexical-react/LexicalTypeaheadMenuPlugin.js.map +1 -0
- package/dist/lexical-proxy/@lexical-react/useLexicalEditable.d.ts +2 -0
- package/dist/lexical-proxy/@lexical-react/useLexicalEditable.d.ts.map +1 -0
- package/dist/lexical-proxy/@lexical-react/useLexicalEditable.js +2 -0
- package/dist/lexical-proxy/@lexical-react/useLexicalEditable.js.map +1 -0
- package/dist/lexical-proxy/@lexical-react/useLexicalIsTextContentEmpty.d.ts +2 -0
- package/dist/lexical-proxy/@lexical-react/useLexicalIsTextContentEmpty.d.ts.map +1 -0
- package/dist/lexical-proxy/@lexical-react/useLexicalIsTextContentEmpty.js +2 -0
- package/dist/lexical-proxy/@lexical-react/useLexicalIsTextContentEmpty.js.map +1 -0
- package/dist/lexical-proxy/@lexical-react/useLexicalNodeSelection.d.ts +2 -0
- package/dist/lexical-proxy/@lexical-react/useLexicalNodeSelection.d.ts.map +1 -0
- package/dist/lexical-proxy/@lexical-react/useLexicalNodeSelection.js +2 -0
- package/dist/lexical-proxy/@lexical-react/useLexicalNodeSelection.js.map +1 -0
- package/dist/lexical-proxy/@lexical-react/useLexicalSubscription.d.ts +2 -0
- package/dist/lexical-proxy/@lexical-react/useLexicalSubscription.d.ts.map +1 -0
- package/dist/lexical-proxy/@lexical-react/useLexicalSubscription.js +2 -0
- package/dist/lexical-proxy/@lexical-react/useLexicalSubscription.js.map +1 -0
- package/dist/lexical-proxy/@lexical-react/useLexicalTextEntity.d.ts +2 -0
- package/dist/lexical-proxy/@lexical-react/useLexicalTextEntity.d.ts.map +1 -0
- package/dist/lexical-proxy/@lexical-react/useLexicalTextEntity.js +2 -0
- package/dist/lexical-proxy/@lexical-react/useLexicalTextEntity.js.map +1 -0
- package/dist/lexical-proxy/@lexical-rich-text.d.ts +2 -0
- package/dist/lexical-proxy/@lexical-rich-text.d.ts.map +1 -0
- package/dist/lexical-proxy/@lexical-rich-text.js +2 -0
- package/dist/lexical-proxy/@lexical-rich-text.js.map +1 -0
- package/dist/lexical-proxy/@lexical-selection.d.ts +2 -0
- package/dist/lexical-proxy/@lexical-selection.d.ts.map +1 -0
- package/dist/lexical-proxy/@lexical-selection.js +2 -0
- package/dist/lexical-proxy/@lexical-selection.js.map +1 -0
- package/dist/lexical-proxy/@lexical-utils.d.ts +2 -0
- package/dist/lexical-proxy/@lexical-utils.d.ts.map +1 -0
- package/dist/lexical-proxy/@lexical-utils.js +2 -0
- package/dist/lexical-proxy/@lexical-utils.js.map +1 -0
- package/dist/lexical-proxy/lexical.d.ts +2 -0
- package/dist/lexical-proxy/lexical.d.ts.map +1 -0
- package/dist/lexical-proxy/lexical.js +2 -0
- package/dist/lexical-proxy/lexical.js.map +1 -0
- package/dist/utilities/createClientFeature.d.ts +5 -0
- package/dist/utilities/createClientFeature.d.ts.map +1 -1
- package/dist/utilities/createClientFeature.js +6 -0
- package/dist/utilities/createClientFeature.js.map +1 -1
- package/dist/utilities/initLexicalFeatures.d.ts.map +1 -1
- package/dist/utilities/initLexicalFeatures.js +3 -2
- package/dist/utilities/initLexicalFeatures.js.map +1 -1
- package/dist/utilities/jsx/collectTopLevelJSXInLines.d.ts +52 -0
- package/dist/utilities/jsx/collectTopLevelJSXInLines.d.ts.map +1 -0
- package/dist/utilities/jsx/collectTopLevelJSXInLines.js +79 -0
- package/dist/utilities/jsx/collectTopLevelJSXInLines.js.map +1 -0
- package/dist/utilities/jsx/extractPropsFromJSXPropsString.d.ts +12 -0
- package/dist/utilities/jsx/extractPropsFromJSXPropsString.d.ts.map +1 -0
- package/dist/utilities/jsx/extractPropsFromJSXPropsString.js +125 -0
- package/dist/utilities/jsx/extractPropsFromJSXPropsString.js.map +1 -0
- package/dist/utilities/jsx/jsx.d.ts +26 -0
- package/dist/utilities/jsx/jsx.d.ts.map +1 -0
- package/dist/utilities/jsx/jsx.js +105 -0
- package/dist/utilities/jsx/jsx.js.map +1 -0
- package/dist/utilities/jsx/jsx.spec.d.ts +2 -0
- package/dist/utilities/jsx/jsx.spec.d.ts.map +1 -0
- package/dist/utilities/jsx/jsx.spec.js +142 -0
- package/dist/utilities/jsx/jsx.spec.js.map +1 -0
- package/dist/utilities/jsx/lexicalMarkdownCopy.d.ts +11 -0
- package/dist/utilities/jsx/lexicalMarkdownCopy.d.ts.map +1 -0
- package/dist/utilities/jsx/lexicalMarkdownCopy.js +61 -0
- package/dist/utilities/jsx/lexicalMarkdownCopy.js.map +1 -0
- package/package.json +284 -7
- package/dist/exports/client/Field-S5G27AVI.js +0 -2
- package/dist/exports/client/Field-S5G27AVI.js.map +0 -7
- package/dist/exports/client/chunk-OOBB5GCO.js +0 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"initLexicalFeatures.js","names":["
|
|
1
|
+
{"version":3,"file":"initLexicalFeatures.js","names":["createClientFields","deepCopyObjectSimple","getFromImportMap","initLexicalFeatures","args","clientFeatures","fieldSchemaMap","Object","fromEntries","Map","resolvedFeatureMapArray","Array","from","sanitizedEditorConfig","resolvedFeatureMap","entries","sort","a","b","order","featureClientSchemaMap","featureKey","resolvedFeature","ClientFeaturePayloadComponent","ClientFeature","clientFeatureProvider","importMap","payload","PayloadComponent","schemaPath","silent","clientFeatureProps","key","clientProps","generateSchemaMap","featureSchemaPath","split","join","featurePath","path","featureSchemaMap","state","startsWith","clientFields","fields","defaultIDType","config","db","disableAddingID","i18n"],"sources":["../../src/utilities/initLexicalFeatures.ts"],"sourcesContent":["import type { I18nClient } from '@payloadcms/translations'\n\nimport {\n type ClientField,\n createClientFields,\n deepCopyObjectSimple,\n type FieldSchemaMap,\n type Payload,\n} from 'payload'\nimport { getFromImportMap } from 'payload/shared'\n\nimport type { FeatureProviderProviderClient } from '../features/typesClient.js'\nimport type { SanitizedServerEditorConfig } from '../lexical/config/types.js'\nimport type { FeatureClientSchemaMap, LexicalRichTextFieldProps } from '../types.js'\ntype Args = {\n fieldSchemaMap: FieldSchemaMap\n i18n: I18nClient\n path: string\n payload: Payload\n sanitizedEditorConfig: SanitizedServerEditorConfig\n schemaPath: string\n}\n\nexport function initLexicalFeatures(args: Args): {\n clientFeatures: LexicalRichTextFieldProps['clientFeatures']\n featureClientSchemaMap: FeatureClientSchemaMap\n} {\n const clientFeatures: LexicalRichTextFieldProps['clientFeatures'] = {}\n\n const fieldSchemaMap = Object.fromEntries(new Map(args.fieldSchemaMap))\n //&const value = deepCopyObjectSimple(args.fieldState.value)\n\n // turn args.resolvedFeatureMap into an array of [key, value] pairs, ordered by value.order, lowest order first:\n const resolvedFeatureMapArray = Array.from(\n args.sanitizedEditorConfig.resolvedFeatureMap.entries(),\n ).sort((a, b) => a[1].order - b[1].order)\n\n const featureClientSchemaMap: FeatureClientSchemaMap = {}\n\n for (const [featureKey, resolvedFeature] of resolvedFeatureMapArray) {\n clientFeatures[featureKey] = {}\n\n /**\n * Handle client features\n */\n const ClientFeaturePayloadComponent = resolvedFeature.ClientFeature\n\n if (ClientFeaturePayloadComponent) {\n const clientFeatureProvider = getFromImportMap<FeatureProviderProviderClient>({\n importMap: args.payload.importMap,\n PayloadComponent: ClientFeaturePayloadComponent,\n schemaPath: 'lexical-clientComponent',\n silent: true,\n })\n\n if (!clientFeatureProvider) {\n continue\n }\n\n const clientFeatureProps = resolvedFeature.clientFeatureProps ?? {}\n clientFeatureProps.featureKey = resolvedFeature.key\n clientFeatureProps.order = resolvedFeature.order\n if (\n typeof ClientFeaturePayloadComponent === 'object' &&\n ClientFeaturePayloadComponent.clientProps\n ) {\n clientFeatureProps.clientProps = ClientFeaturePayloadComponent.clientProps\n }\n\n // As clientFeatureProvider is a client function, we cannot execute it on the server here. Thus, the client will have to execute clientFeatureProvider with its props\n clientFeatures[featureKey] = { clientFeatureProps, clientFeatureProvider }\n }\n\n /**\n * Handle sub-fields (formstate of those)ttt\n */\n // The args.fieldSchemaMap generated before in buildFormState should contain all of lexical features' sub-field schemas\n // as well, as it already called feature.generateSchemaMap for each feature.\n // We will check for the existance resolvedFeature.generateSchemaMap to skip unnecessary loops for constructing featureSchemaMap, but we don't run it here\n if (resolvedFeature.generateSchemaMap) {\n const featureSchemaPath = [\n ...args.schemaPath.split('.'),\n 'lexical_internal_feature',\n featureKey,\n ].join('.')\n\n const featurePath = [...args.path.split('.'), 'lexical_internal_feature', featureKey].join(\n '.',\n )\n\n // Like args.fieldSchemaMap, we only want to include the sub-fields of the current feature\n const featureSchemaMap: typeof fieldSchemaMap = {}\n for (const key in fieldSchemaMap) {\n const state = fieldSchemaMap[key]\n\n if (key.startsWith(featureSchemaPath)) {\n featureSchemaMap[key] = state\n }\n }\n\n featureClientSchemaMap[featureKey] = {}\n\n for (const key in featureSchemaMap) {\n const state = featureSchemaMap[key]\n\n const clientFields = createClientFields({\n clientFields: ('fields' in state\n ? deepCopyObjectSimple(state.fields)\n : [deepCopyObjectSimple(state)]) as ClientField[],\n defaultIDType: args.payload.config.db.defaultIDType,\n disableAddingID: true,\n fields: 'fields' in state ? state.fields : [state],\n i18n: args.i18n,\n importMap: args.payload.importMap,\n })\n featureClientSchemaMap[featureKey][key] = clientFields\n }\n\n /*\n This is for providing an initial form state. Right now we only want to provide the clientfields though\n const schemaMap: {\n [key: string]: FieldState\n } = {}\n\n const lexicalDeepIterate = (editorState) => {\n console.log('STATE', editorState)\n\n if (\n editorState &&\n typeof editorState === 'object' &&\n 'children' in editorState &&\n Array.isArray(editorState.children)\n ) {\n for (const childKey in editorState.children) {\n const childState = editorState.children[childKey]\n\n if (childState && typeof childState === 'object') {\n lexicalDeepIterate(childState)\n }\n }\n }\n }\n\n lexicalDeepIterate(value.root)*/\n }\n }\n return {\n clientFeatures,\n featureClientSchemaMap,\n }\n}\n"],"mappings":"AAEA,SAEEA,kBAAkB,EAClBC,oBAAoB,QAGf;AACP,SAASC,gBAAgB,QAAQ;AAcjC,OA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MAEA;;;;;;;;;;;;;;;;;;;;;;IA0BF;EACF;EACA,OAAO;IACLtC,cAAA;IACAe;EACF;AACF","ignoreList":[]}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Helpful utility for parsing out all matching top-level JSX tags in a given string.
|
|
3
|
+
* This will collect them in a list, that contains the content of the JSX tag and the props string.
|
|
4
|
+
*
|
|
5
|
+
* While this is not used within payload, this can be used for certain payload blocks that need to
|
|
6
|
+
* be serializable and deserializable to and from JSX.
|
|
7
|
+
*
|
|
8
|
+
* @example:
|
|
9
|
+
*
|
|
10
|
+
* Say you have Steps block that contains a steps array. Its JSX representation may look like this:
|
|
11
|
+
*
|
|
12
|
+
* <Steps>
|
|
13
|
+
* <Step title="Step1">
|
|
14
|
+
* <h1>Step 1</h1>
|
|
15
|
+
* </Step>
|
|
16
|
+
* <Step title="Step2">
|
|
17
|
+
* <h1>Step 2</h1>
|
|
18
|
+
* </Step>
|
|
19
|
+
* </Steps>
|
|
20
|
+
*
|
|
21
|
+
* In this case, the Steps block would have the following content as its children string:
|
|
22
|
+
* <Step title="Step1">
|
|
23
|
+
* <h1>Step 1</h1>
|
|
24
|
+
* </Step>
|
|
25
|
+
* <Step title="Step2">
|
|
26
|
+
* <h1>Step 2</h1>
|
|
27
|
+
* </Step>
|
|
28
|
+
*
|
|
29
|
+
* It could then use this function to collect all the top-level JSX tags (= the steps):
|
|
30
|
+
*
|
|
31
|
+
* collectTopLevelJSXInLines(children.split('\n'), 'Step')
|
|
32
|
+
*
|
|
33
|
+
* This will return:
|
|
34
|
+
*
|
|
35
|
+
* [
|
|
36
|
+
* {
|
|
37
|
+
* content: '<h1>Step 1</h1>',
|
|
38
|
+
* propsString: 'title="Step1"',
|
|
39
|
+
* },
|
|
40
|
+
* {
|
|
41
|
+
* content: '<h1>Step 2</h1>',
|
|
42
|
+
* propsString: 'title="Step2"',
|
|
43
|
+
* },
|
|
44
|
+
* ]
|
|
45
|
+
*
|
|
46
|
+
* You can then map this data to construct the data for this blocks array field.
|
|
47
|
+
*/
|
|
48
|
+
export declare function collectTopLevelJSXInLines(lines: Array<string>, jsxToMatch: string): {
|
|
49
|
+
content: string;
|
|
50
|
+
propsString: string;
|
|
51
|
+
}[];
|
|
52
|
+
//# sourceMappingURL=collectTopLevelJSXInLines.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"collectTopLevelJSXInLines.d.ts","sourceRoot":"","sources":["../../../src/utilities/jsx/collectTopLevelJSXInLines.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8CG;AACH,wBAAgB,yBAAyB,CACvC,KAAK,EAAE,KAAK,CAAC,MAAM,CAAC,EACpB,UAAU,EAAE,MAAM,GACjB;IACD,OAAO,EAAE,MAAM,CAAA;IACf,WAAW,EAAE,MAAM,CAAA;CACpB,EAAE,CAiCF"}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { linesFromStartToContentAndPropsString } from '../../features/blocks/server/linesFromMatchToContentAndPropsString.js';
|
|
2
|
+
import { createTagRegexes } from '../../features/blocks/server/markdownTransformer.js';
|
|
3
|
+
/**
|
|
4
|
+
* Helpful utility for parsing out all matching top-level JSX tags in a given string.
|
|
5
|
+
* This will collect them in a list, that contains the content of the JSX tag and the props string.
|
|
6
|
+
*
|
|
7
|
+
* While this is not used within payload, this can be used for certain payload blocks that need to
|
|
8
|
+
* be serializable and deserializable to and from JSX.
|
|
9
|
+
*
|
|
10
|
+
* @example:
|
|
11
|
+
*
|
|
12
|
+
* Say you have Steps block that contains a steps array. Its JSX representation may look like this:
|
|
13
|
+
*
|
|
14
|
+
* <Steps>
|
|
15
|
+
* <Step title="Step1">
|
|
16
|
+
* <h1>Step 1</h1>
|
|
17
|
+
* </Step>
|
|
18
|
+
* <Step title="Step2">
|
|
19
|
+
* <h1>Step 2</h1>
|
|
20
|
+
* </Step>
|
|
21
|
+
* </Steps>
|
|
22
|
+
*
|
|
23
|
+
* In this case, the Steps block would have the following content as its children string:
|
|
24
|
+
* <Step title="Step1">
|
|
25
|
+
* <h1>Step 1</h1>
|
|
26
|
+
* </Step>
|
|
27
|
+
* <Step title="Step2">
|
|
28
|
+
* <h1>Step 2</h1>
|
|
29
|
+
* </Step>
|
|
30
|
+
*
|
|
31
|
+
* It could then use this function to collect all the top-level JSX tags (= the steps):
|
|
32
|
+
*
|
|
33
|
+
* collectTopLevelJSXInLines(children.split('\n'), 'Step')
|
|
34
|
+
*
|
|
35
|
+
* This will return:
|
|
36
|
+
*
|
|
37
|
+
* [
|
|
38
|
+
* {
|
|
39
|
+
* content: '<h1>Step 1</h1>',
|
|
40
|
+
* propsString: 'title="Step1"',
|
|
41
|
+
* },
|
|
42
|
+
* {
|
|
43
|
+
* content: '<h1>Step 2</h1>',
|
|
44
|
+
* propsString: 'title="Step2"',
|
|
45
|
+
* },
|
|
46
|
+
* ]
|
|
47
|
+
*
|
|
48
|
+
* You can then map this data to construct the data for this blocks array field.
|
|
49
|
+
*/
|
|
50
|
+
export function collectTopLevelJSXInLines(lines, jsxToMatch) {
|
|
51
|
+
const finds = [];
|
|
52
|
+
const regex = createTagRegexes(jsxToMatch);
|
|
53
|
+
const linesLength = lines.length;
|
|
54
|
+
for (let i = 0; i < linesLength; i++) {
|
|
55
|
+
const startMatch = lines[i].match(regex.regExpStart);
|
|
56
|
+
if (!startMatch) {
|
|
57
|
+
continue; // Try next transformer
|
|
58
|
+
}
|
|
59
|
+
const {
|
|
60
|
+
content,
|
|
61
|
+
endLineIndex,
|
|
62
|
+
propsString
|
|
63
|
+
} = linesFromStartToContentAndPropsString({
|
|
64
|
+
isEndOptional: false,
|
|
65
|
+
lines,
|
|
66
|
+
regexpEndRegex: regex.regExpEnd,
|
|
67
|
+
startLineIndex: i,
|
|
68
|
+
startMatch
|
|
69
|
+
});
|
|
70
|
+
finds.push({
|
|
71
|
+
content,
|
|
72
|
+
propsString
|
|
73
|
+
});
|
|
74
|
+
i = endLineIndex;
|
|
75
|
+
continue;
|
|
76
|
+
}
|
|
77
|
+
return finds;
|
|
78
|
+
}
|
|
79
|
+
//# sourceMappingURL=collectTopLevelJSXInLines.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"collectTopLevelJSXInLines.js","names":["linesFromStartToContentAndPropsString","createTagRegexes","collectTopLevelJSXInLines","lines","jsxToMatch","finds","regex","linesLength","length","i","startMatch","match","regExpStart","content","endLineIndex","propsString","isEndOptional","regexpEndRegex","regExpEnd","startLineIndex","push"],"sources":["../../../src/utilities/jsx/collectTopLevelJSXInLines.ts"],"sourcesContent":["import { linesFromStartToContentAndPropsString } from '../../features/blocks/server/linesFromMatchToContentAndPropsString.js'\nimport { createTagRegexes } from '../../features/blocks/server/markdownTransformer.js'\n\n/**\n * Helpful utility for parsing out all matching top-level JSX tags in a given string.\n * This will collect them in a list, that contains the content of the JSX tag and the props string.\n *\n * While this is not used within payload, this can be used for certain payload blocks that need to\n * be serializable and deserializable to and from JSX.\n *\n * @example:\n *\n * Say you have Steps block that contains a steps array. Its JSX representation may look like this:\n *\n * <Steps>\n * <Step title=\"Step1\">\n * <h1>Step 1</h1>\n * </Step>\n * <Step title=\"Step2\">\n * <h1>Step 2</h1>\n * </Step>\n * </Steps>\n *\n * In this case, the Steps block would have the following content as its children string:\n * <Step title=\"Step1\">\n * <h1>Step 1</h1>\n * </Step>\n * <Step title=\"Step2\">\n * <h1>Step 2</h1>\n * </Step>\n *\n * It could then use this function to collect all the top-level JSX tags (= the steps):\n *\n * collectTopLevelJSXInLines(children.split('\\n'), 'Step')\n *\n * This will return:\n *\n * [\n * {\n * content: '<h1>Step 1</h1>',\n * propsString: 'title=\"Step1\"',\n * },\n * {\n * content: '<h1>Step 2</h1>',\n * propsString: 'title=\"Step2\"',\n * },\n * ]\n *\n * You can then map this data to construct the data for this blocks array field.\n */\nexport function collectTopLevelJSXInLines(\n lines: Array<string>,\n jsxToMatch: string,\n): {\n content: string\n propsString: string\n}[] {\n const finds: {\n content: string\n propsString: string\n }[] = []\n const regex = createTagRegexes(jsxToMatch)\n\n const linesLength = lines.length\n\n for (let i = 0; i < linesLength; i++) {\n const startMatch = lines[i].match(regex.regExpStart)\n if (!startMatch) {\n continue // Try next transformer\n }\n\n const { content, endLineIndex, propsString } = linesFromStartToContentAndPropsString({\n isEndOptional: false,\n lines,\n regexpEndRegex: regex.regExpEnd,\n startLineIndex: i,\n startMatch,\n })\n\n finds.push({\n content,\n propsString,\n })\n\n i = endLineIndex\n continue\n }\n\n return finds\n}\n"],"mappings":"AAAA,SAASA,qCAAqC,QAAQ;AACtD,SAASC,gBAAgB,QAAQ;AAEjC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+CA,OAAO,SAASC,0BACdC,KAAoB,EACpBC,UAAkB;EAKlB,MAAMC,KAAA,GAGA,EAAE;EACR,MAAMC,KAAA,GAAQL,gBAAA,CAAiBG,UAAA;EAE/B,MAAMG,WAAA,GAAcJ,KAAA,CAAMK,MAAM;EAEhC,KAAK,IAAIC,CAAA,GAAI,GAAGA,CAAA,GAAIF,WAAA,EAAaE,CAAA,IAAK;IACpC,MAAMC,UAAA,GAAaP,KAAK,CAACM,CAAA,CAAE,CAACE,KAAK,CAACL,KAAA,CAAMM,WAAW;IACnD,IAAI,CAACF,UAAA,EAAY;MACf,UAAS;IACX;IAEA,MAAM;MAAEG,OAAO;MAAEC,YAAY;MAAEC;IAAW,CAAE,GAAGf,qCAAA,CAAsC;MACnFgB,aAAA,EAAe;MACfb,KAAA;MACAc,cAAA,EAAgBX,KAAA,CAAMY,SAAS;MAC/BC,cAAA,EAAgBV,CAAA;MAChBC;IACF;IAEAL,KAAA,CAAMe,IAAI,CAAC;MACTP,OAAA;MACAE;IACF;IAEAN,CAAA,GAAIK,YAAA;IACJ;EACF;EAEA,OAAOT,KAAA;AACT","ignoreList":[]}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Turns a JSX props string into an object.
|
|
3
|
+
*
|
|
4
|
+
* @example
|
|
5
|
+
*
|
|
6
|
+
* Input: type="info" hello={{heyyy: 'test', someNumber: 2}}
|
|
7
|
+
* Output: { type: 'info', hello: { heyyy: 'test', someNumber: 2 } }
|
|
8
|
+
*/
|
|
9
|
+
export declare function extractPropsFromJSXPropsString({ propsString, }: {
|
|
10
|
+
propsString: string;
|
|
11
|
+
}): Record<string, any>;
|
|
12
|
+
//# sourceMappingURL=extractPropsFromJSXPropsString.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"extractPropsFromJSXPropsString.d.ts","sourceRoot":"","sources":["../../../src/utilities/jsx/extractPropsFromJSXPropsString.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,wBAAgB,8BAA8B,CAAC,EAC7C,WAAW,GACZ,EAAE;IACD,WAAW,EAAE,MAAM,CAAA;CACpB,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAmCtB"}
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Turns a JSX props string into an object.
|
|
3
|
+
*
|
|
4
|
+
* @example
|
|
5
|
+
*
|
|
6
|
+
* Input: type="info" hello={{heyyy: 'test', someNumber: 2}}
|
|
7
|
+
* Output: { type: 'info', hello: { heyyy: 'test', someNumber: 2 } }
|
|
8
|
+
*/export function extractPropsFromJSXPropsString({
|
|
9
|
+
propsString
|
|
10
|
+
}) {
|
|
11
|
+
const props = {};
|
|
12
|
+
let key = '';
|
|
13
|
+
let collectingKey = true;
|
|
14
|
+
for (let i = 0; i < propsString.length; i++) {
|
|
15
|
+
const char = propsString[i];
|
|
16
|
+
if (collectingKey) {
|
|
17
|
+
if (char === '=' || char === ' ') {
|
|
18
|
+
if (key) {
|
|
19
|
+
if (char === ' ') {
|
|
20
|
+
props[key] = true;
|
|
21
|
+
key = '';
|
|
22
|
+
} else {
|
|
23
|
+
collectingKey = false;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
} else {
|
|
27
|
+
key += char;
|
|
28
|
+
}
|
|
29
|
+
} else {
|
|
30
|
+
const result = handleValue(propsString, i);
|
|
31
|
+
props[key] = result.value;
|
|
32
|
+
i = result.newIndex;
|
|
33
|
+
key = '';
|
|
34
|
+
collectingKey = true;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
if (key) {
|
|
38
|
+
props[key] = true;
|
|
39
|
+
}
|
|
40
|
+
return props;
|
|
41
|
+
}
|
|
42
|
+
function handleValue(propsString, startIndex) {
|
|
43
|
+
const char = propsString[startIndex];
|
|
44
|
+
if (char === '"') {
|
|
45
|
+
return handleQuotedString(propsString, startIndex);
|
|
46
|
+
} else if (char === '{') {
|
|
47
|
+
return handleObject(propsString, startIndex);
|
|
48
|
+
} else if (char === '[') {
|
|
49
|
+
return handleArray(propsString, startIndex);
|
|
50
|
+
} else {
|
|
51
|
+
return handleUnquotedString(propsString, startIndex);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
function handleArray(propsString, startIndex) {
|
|
55
|
+
let bracketCount = 1;
|
|
56
|
+
let value = '';
|
|
57
|
+
let i = startIndex + 1;
|
|
58
|
+
while (i < propsString.length && bracketCount > 0) {
|
|
59
|
+
if (propsString[i] === '[') {
|
|
60
|
+
bracketCount++;
|
|
61
|
+
} else if (propsString[i] === ']') {
|
|
62
|
+
bracketCount--;
|
|
63
|
+
}
|
|
64
|
+
if (bracketCount > 0) {
|
|
65
|
+
value += propsString[i];
|
|
66
|
+
}
|
|
67
|
+
i++;
|
|
68
|
+
}
|
|
69
|
+
return {
|
|
70
|
+
newIndex: i,
|
|
71
|
+
value: JSON.parse(`[${value}]`)
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
function handleQuotedString(propsString, startIndex) {
|
|
75
|
+
let value = '';
|
|
76
|
+
let i = startIndex + 1;
|
|
77
|
+
while (i < propsString.length && (propsString[i] !== '"' || propsString[i - 1] === '\\')) {
|
|
78
|
+
value += propsString[i];
|
|
79
|
+
i++;
|
|
80
|
+
}
|
|
81
|
+
return {
|
|
82
|
+
newIndex: i,
|
|
83
|
+
value
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
function handleObject(propsString, startIndex) {
|
|
87
|
+
let bracketCount = 1;
|
|
88
|
+
let value = '';
|
|
89
|
+
let i = startIndex + 1;
|
|
90
|
+
while (i < propsString.length && bracketCount > 0) {
|
|
91
|
+
if (propsString[i] === '{') {
|
|
92
|
+
bracketCount++;
|
|
93
|
+
} else if (propsString[i] === '}') {
|
|
94
|
+
bracketCount--;
|
|
95
|
+
}
|
|
96
|
+
if (bracketCount > 0) {
|
|
97
|
+
value += propsString[i];
|
|
98
|
+
}
|
|
99
|
+
i++;
|
|
100
|
+
}
|
|
101
|
+
return {
|
|
102
|
+
newIndex: i,
|
|
103
|
+
value: parseObject(value)
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
function parseObject(objString) {
|
|
107
|
+
if (objString[0] !== '{') {
|
|
108
|
+
return JSON.parse(objString);
|
|
109
|
+
}
|
|
110
|
+
const result = JSON.parse(objString.replace(/(\w+):/g, '"$1":'));
|
|
111
|
+
return result;
|
|
112
|
+
}
|
|
113
|
+
function handleUnquotedString(propsString, startIndex) {
|
|
114
|
+
let value = '';
|
|
115
|
+
let i = startIndex;
|
|
116
|
+
while (i < propsString.length && propsString[i] !== ' ') {
|
|
117
|
+
value += propsString[i];
|
|
118
|
+
i++;
|
|
119
|
+
}
|
|
120
|
+
return {
|
|
121
|
+
newIndex: i - 1,
|
|
122
|
+
value
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
//# sourceMappingURL=extractPropsFromJSXPropsString.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"extractPropsFromJSXPropsString.js","names":["extractPropsFromJSXPropsString","propsString","props","key","collectingKey","i","length","char","result","handleValue","value","newIndex","startIndex","handleQuotedString","handleObject","handleArray","handleUnquotedString","bracketCount","JSON","parse","parseObject","objString","replace"],"sources":["../../../src/utilities/jsx/extractPropsFromJSXPropsString.ts"],"sourcesContent":["/**\n * Turns a JSX props string into an object.\n *\n * @example\n *\n * Input: type=\"info\" hello={{heyyy: 'test', someNumber: 2}}\n * Output: { type: 'info', hello: { heyyy: 'test', someNumber: 2 } }\n */\nexport function extractPropsFromJSXPropsString({\n propsString,\n}: {\n propsString: string\n}): Record<string, any> {\n const props: Record<string, any> = {}\n let key = ''\n let collectingKey = true\n\n for (let i = 0; i < propsString.length; i++) {\n const char = propsString[i]\n\n if (collectingKey) {\n if (char === '=' || char === ' ') {\n if (key) {\n if (char === ' ') {\n props[key] = true\n key = ''\n } else {\n collectingKey = false\n }\n }\n } else {\n key += char\n }\n } else {\n const result = handleValue(propsString, i)\n props[key] = result.value\n i = result.newIndex\n key = ''\n collectingKey = true\n }\n }\n\n if (key) {\n props[key] = true\n }\n\n return props\n}\n\nfunction handleValue(propsString: string, startIndex: number): { newIndex: number; value: any } {\n const char = propsString[startIndex]\n\n if (char === '\"') {\n return handleQuotedString(propsString, startIndex)\n } else if (char === '{') {\n return handleObject(propsString, startIndex)\n } else if (char === '[') {\n return handleArray(propsString, startIndex)\n } else {\n return handleUnquotedString(propsString, startIndex)\n }\n}\n\nfunction handleArray(propsString: string, startIndex: number): { newIndex: number; value: any } {\n let bracketCount = 1\n let value = ''\n let i = startIndex + 1\n\n while (i < propsString.length && bracketCount > 0) {\n if (propsString[i] === '[') {\n bracketCount++\n } else if (propsString[i] === ']') {\n bracketCount--\n }\n if (bracketCount > 0) {\n value += propsString[i]\n }\n i++\n }\n\n return { newIndex: i, value: JSON.parse(`[${value}]`) }\n}\n\nfunction handleQuotedString(\n propsString: string,\n startIndex: number,\n): { newIndex: number; value: string } {\n let value = ''\n let i = startIndex + 1\n while (i < propsString.length && (propsString[i] !== '\"' || propsString[i - 1] === '\\\\')) {\n value += propsString[i]\n i++\n }\n return { newIndex: i, value }\n}\n\nfunction handleObject(propsString: string, startIndex: number): { newIndex: number; value: any } {\n let bracketCount = 1\n let value = ''\n let i = startIndex + 1\n\n while (i < propsString.length && bracketCount > 0) {\n if (propsString[i] === '{') {\n bracketCount++\n } else if (propsString[i] === '}') {\n bracketCount--\n }\n if (bracketCount > 0) {\n value += propsString[i]\n }\n i++\n }\n\n return { newIndex: i, value: parseObject(value) }\n}\n\nfunction parseObject(objString: string): Record<string, any> {\n if (objString[0] !== '{') {\n return JSON.parse(objString)\n }\n\n const result = JSON.parse(objString.replace(/(\\w+):/g, '\"$1\":'))\n\n return result\n}\n\nfunction handleUnquotedString(\n propsString: string,\n startIndex: number,\n): { newIndex: number; value: string } {\n let value = ''\n let i = startIndex\n while (i < propsString.length && propsString[i] !== ' ') {\n value += propsString[i]\n i++\n }\n return { newIndex: i - 1, value }\n}\n"],"mappings":"AAAA;;;;;;;GAQA,OAAO,SAASA,+BAA+B;EAC7CC;AAAW,CAGZ;EACC,MAAMC,KAAA,GAA6B,CAAC;EACpC,IAAIC,GAAA,GAAM;EACV,IAAIC,aAAA,GAAgB;EAEpB,KAAK,IAAIC,CAAA,GAAI,GAAGA,CAAA,GAAIJ,WAAA,CAAYK,MAAM,EAAED,CAAA,IAAK;IAC3C,MAAME,IAAA,GAAON,WAAW,CAACI,CAAA,CAAE;IAE3B,IAAID,aAAA,EAAe;MACjB,IAAIG,IAAA,KAAS,OAAOA,IAAA,KAAS,KAAK;QAChC,IAAIJ,GAAA,EAAK;UACP,IAAII,IAAA,KAAS,KAAK;YAChBL,KAAK,CAACC,GAAA,CAAI,GAAG;YACbA,GAAA,GAAM;UACR,OAAO;YACLC,aAAA,GAAgB;UAClB;QACF;MACF,OAAO;QACLD,GAAA,IAAOI,IAAA;MACT;IACF,OAAO;MACL,MAAMC,MAAA,GAASC,WAAA,CAAYR,WAAA,EAAaI,CAAA;MACxCH,KAAK,CAACC,GAAA,CAAI,GAAGK,MAAA,CAAOE,KAAK;MACzBL,CAAA,GAAIG,MAAA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CAAA,CAAE;IACvBA,CAAA;EACF;EACA,OAAO;IAAEM,QAAA,EAAUN,CAAA,GAAI;IAAGK;EAAM;AAClC","ignoreList":[]}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Converts an object of props to a JSX props string.
|
|
3
|
+
*
|
|
4
|
+
* This function is the inverse of `extractPropsFromJSXPropsString`.
|
|
5
|
+
*/
|
|
6
|
+
export declare function propsToJSXString({ props }: {
|
|
7
|
+
props: Record<string, any>;
|
|
8
|
+
}): string;
|
|
9
|
+
/**
|
|
10
|
+
* Converts a frontmatter string to an object.
|
|
11
|
+
*/
|
|
12
|
+
export declare function frontmatterToObject(frontmatter: string): Record<string, any>;
|
|
13
|
+
/**
|
|
14
|
+
* Converts an object to a frontmatter string.
|
|
15
|
+
*/
|
|
16
|
+
export declare function objectToFrontmatter(obj: Record<string, any>): null | string;
|
|
17
|
+
/**
|
|
18
|
+
* Takes an MDX content string and extracts the frontmatter and content.
|
|
19
|
+
*
|
|
20
|
+
* The resulting object contains the mdx content without the frontmatter and the frontmatter itself.
|
|
21
|
+
*/
|
|
22
|
+
export declare function extractFrontmatter(mdxContent: string): {
|
|
23
|
+
content: string;
|
|
24
|
+
frontmatter: string;
|
|
25
|
+
};
|
|
26
|
+
//# sourceMappingURL=jsx.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jsx.d.ts","sourceRoot":"","sources":["../../../src/utilities/jsx/jsx.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,EAAE,KAAK,EAAE,EAAE;IAAE,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;CAAE,GAAG,MAAM,CA0BlF;AAeD;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAoB5E;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,IAAI,GAAG,MAAM,CAgB3E;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,UAAU,EAAE,MAAM;;;EAmBpD"}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Converts an object of props to a JSX props string.
|
|
3
|
+
*
|
|
4
|
+
* This function is the inverse of `extractPropsFromJSXPropsString`.
|
|
5
|
+
*/export function propsToJSXString({
|
|
6
|
+
props
|
|
7
|
+
}) {
|
|
8
|
+
const propsArray = [];
|
|
9
|
+
for (const [key, value] of Object.entries(props)) {
|
|
10
|
+
if (typeof value === 'string') {
|
|
11
|
+
// Handle simple string props
|
|
12
|
+
propsArray.push(`${key}="${escapeQuotes(value)}"`);
|
|
13
|
+
} else if (typeof value === 'number') {
|
|
14
|
+
// Handle number and boolean props
|
|
15
|
+
propsArray.push(`${key}={${value}}`);
|
|
16
|
+
} else if (typeof value === 'boolean') {
|
|
17
|
+
if (value) {
|
|
18
|
+
propsArray.push(`${key}`);
|
|
19
|
+
}
|
|
20
|
+
} else if (value !== null && typeof value === 'object') {
|
|
21
|
+
if (Array.isArray(value)) {
|
|
22
|
+
// Handle array props
|
|
23
|
+
propsArray.push(`${key}={[${value.map(v => JSON.stringify(v, replacer)).join(', ')}]}`);
|
|
24
|
+
} else {
|
|
25
|
+
// Handle complex object props
|
|
26
|
+
propsArray.push(`${key}={${JSON.stringify(value, replacer)}}`);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
return propsArray.join(' ');
|
|
31
|
+
}
|
|
32
|
+
// Helper function to escape quotes in string values
|
|
33
|
+
function escapeQuotes(str) {
|
|
34
|
+
return str.replace(/"/g, '"');
|
|
35
|
+
}
|
|
36
|
+
// Custom replacer function for JSON.stringify to handle single quotes
|
|
37
|
+
function replacer(key, value) {
|
|
38
|
+
if (typeof value === 'string') {
|
|
39
|
+
return value.replace(/'/g, "\\'");
|
|
40
|
+
}
|
|
41
|
+
return value;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Converts a frontmatter string to an object.
|
|
45
|
+
*/
|
|
46
|
+
export function frontmatterToObject(frontmatter) {
|
|
47
|
+
const lines = frontmatter.trim().split('\n');
|
|
48
|
+
const result = {};
|
|
49
|
+
let inFrontmatter = false;
|
|
50
|
+
for (const line of lines) {
|
|
51
|
+
if (line.trim() === '---') {
|
|
52
|
+
inFrontmatter = !inFrontmatter;
|
|
53
|
+
continue;
|
|
54
|
+
}
|
|
55
|
+
if (inFrontmatter) {
|
|
56
|
+
const [key, ...valueParts] = line.split(':');
|
|
57
|
+
const value = valueParts.join(':').trim();
|
|
58
|
+
result[key.trim()] = value;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
return result;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Converts an object to a frontmatter string.
|
|
65
|
+
*/
|
|
66
|
+
export function objectToFrontmatter(obj) {
|
|
67
|
+
if (!Object.entries(obj)?.length) {
|
|
68
|
+
return null;
|
|
69
|
+
}
|
|
70
|
+
let frontmatter = '---\n';
|
|
71
|
+
for (const [key, value] of Object.entries(obj)) {
|
|
72
|
+
if (Array.isArray(value)) {
|
|
73
|
+
frontmatter += `${key}: ${value.join(', ')}\n`;
|
|
74
|
+
} else {
|
|
75
|
+
frontmatter += `${key}: ${value}\n`;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
frontmatter += '---\n';
|
|
79
|
+
return frontmatter;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Takes an MDX content string and extracts the frontmatter and content.
|
|
83
|
+
*
|
|
84
|
+
* The resulting object contains the mdx content without the frontmatter and the frontmatter itself.
|
|
85
|
+
*/
|
|
86
|
+
export function extractFrontmatter(mdxContent) {
|
|
87
|
+
// eslint-disable-next-line regexp/no-super-linear-backtracking
|
|
88
|
+
const frontmatterRegex = /^---\s*\n[\s\S]*?\n---\s*\n/;
|
|
89
|
+
const match = mdxContent.match(frontmatterRegex);
|
|
90
|
+
if (match) {
|
|
91
|
+
const frontmatter = match[0];
|
|
92
|
+
const contentWithoutFrontmatter = mdxContent.slice(frontmatter.length).trim();
|
|
93
|
+
return {
|
|
94
|
+
content: contentWithoutFrontmatter,
|
|
95
|
+
frontmatter: frontmatter.trim()
|
|
96
|
+
};
|
|
97
|
+
} else {
|
|
98
|
+
// If no frontmatter is found, return the original content
|
|
99
|
+
return {
|
|
100
|
+
content: mdxContent.trim(),
|
|
101
|
+
frontmatter: ''
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
//# sourceMappingURL=jsx.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jsx.js","names":["propsToJSXString","props","propsArray","key","value","Object","entries","push","escapeQuotes","Array","isArray","map","v","JSON","stringify","replacer","join","str","replace","frontmatterToObject","frontmatter","lines","trim","split","result","inFrontmatter","line","valueParts","objectToFrontmatter","obj","length","extractFrontmatter","mdxContent","frontmatterRegex","match","contentWithoutFrontmatter","slice","content"],"sources":["../../../src/utilities/jsx/jsx.ts"],"sourcesContent":["/**\n * Converts an object of props to a JSX props string.\n *\n * This function is the inverse of `extractPropsFromJSXPropsString`.\n */\nexport function propsToJSXString({ props }: { props: Record<string, any> }): string {\n const propsArray: string[] = []\n\n for (const [key, value] of Object.entries(props)) {\n if (typeof value === 'string') {\n // Handle simple string props\n propsArray.push(`${key}=\"${escapeQuotes(value)}\"`)\n } else if (typeof value === 'number') {\n // Handle number and boolean props\n propsArray.push(`${key}={${value}}`)\n } else if (typeof value === 'boolean') {\n if (value) {\n propsArray.push(`${key}`)\n }\n } else if (value !== null && typeof value === 'object') {\n if (Array.isArray(value)) {\n // Handle array props\n propsArray.push(`${key}={[${value.map((v) => JSON.stringify(v, replacer)).join(', ')}]}`)\n } else {\n // Handle complex object props\n propsArray.push(`${key}={${JSON.stringify(value, replacer)}}`)\n }\n }\n }\n\n return propsArray.join(' ')\n}\n\n// Helper function to escape quotes in string values\nfunction escapeQuotes(str: string): string {\n return str.replace(/\"/g, '"')\n}\n\n// Custom replacer function for JSON.stringify to handle single quotes\nfunction replacer(key: string, value: any): any {\n if (typeof value === 'string') {\n return value.replace(/'/g, \"\\\\'\")\n }\n return value\n}\n\n/**\n * Converts a frontmatter string to an object.\n */\nexport function frontmatterToObject(frontmatter: string): Record<string, any> {\n const lines = frontmatter.trim().split('\\n')\n const result = {}\n let inFrontmatter = false\n\n for (const line of lines) {\n if (line.trim() === '---') {\n inFrontmatter = !inFrontmatter\n continue\n }\n\n if (inFrontmatter) {\n const [key, ...valueParts] = line.split(':')\n const value = valueParts.join(':').trim()\n\n result[key.trim()] = value\n }\n }\n\n return result\n}\n\n/**\n * Converts an object to a frontmatter string.\n */\nexport function objectToFrontmatter(obj: Record<string, any>): null | string {\n if (!Object.entries(obj)?.length) {\n return null\n }\n let frontmatter = '---\\n'\n\n for (const [key, value] of Object.entries(obj)) {\n if (Array.isArray(value)) {\n frontmatter += `${key}: ${value.join(', ')}\\n`\n } else {\n frontmatter += `${key}: ${value}\\n`\n }\n }\n\n frontmatter += '---\\n'\n return frontmatter\n}\n\n/**\n * Takes an MDX content string and extracts the frontmatter and content.\n *\n * The resulting object contains the mdx content without the frontmatter and the frontmatter itself.\n */\nexport function extractFrontmatter(mdxContent: string) {\n // eslint-disable-next-line regexp/no-super-linear-backtracking\n const frontmatterRegex = /^---\\s*\\n[\\s\\S]*?\\n---\\s*\\n/\n const match = mdxContent.match(frontmatterRegex)\n\n if (match) {\n const frontmatter = match[0]\n const contentWithoutFrontmatter = mdxContent.slice(frontmatter.length).trim()\n return {\n content: contentWithoutFrontmatter,\n frontmatter: frontmatter.trim(),\n }\n } else {\n // If no frontmatter is found, return the original content\n return {\n content: mdxContent.trim(),\n frontmatter: '',\n }\n }\n}\n"],"mappings":"AAAA;;;;GAKA,OAAO,SAASA,iBAAiB;EAAEC;AAAK,CA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cc,KAAK,CAAC,EAAE;IAC5B,MAAMC,yBAAA,GAA4BH,UAAA,CAAWI,KAAK,CAAChB,WAAA,CAAYU,MAAM,EAAER,IAAI;IAC3E,OAAO;MACLe,OAAA,EAASF,yBAAA;MACTf,WAAA,EAAaA,WAAA,CAAYE,IAAI;IAC/B;EACF,OAAO;IACL;IACA,OAAO;MACLe,OAAA,EAASL,UAAA,CAAWV,IAAI;MACxBF,WAAA,EAAa;IACf;EACF;AACF","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jsx.spec.d.ts","sourceRoot":"","sources":["../../../src/utilities/jsx/jsx.spec.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import { extractPropsFromJSXPropsString } from './extractPropsFromJSXPropsString.js';
|
|
2
|
+
import { propsToJSXString } from './jsx.js';
|
|
3
|
+
describe('jsx', () => {
|
|
4
|
+
describe('prop string to object', () => {
|
|
5
|
+
const INPUT_AND_OUTPUT = [{
|
|
6
|
+
input: 'key="value"',
|
|
7
|
+
output: {
|
|
8
|
+
key: 'value'
|
|
9
|
+
}
|
|
10
|
+
}, {
|
|
11
|
+
input: 'key={[1, 2, 3]}',
|
|
12
|
+
output: {
|
|
13
|
+
key: [1, 2, 3]
|
|
14
|
+
}
|
|
15
|
+
}, {
|
|
16
|
+
input: 'key={[1, 2, 3, [1, 2]]}',
|
|
17
|
+
output: {
|
|
18
|
+
key: [1, 2, 3, [1, 2]]
|
|
19
|
+
}
|
|
20
|
+
}, {
|
|
21
|
+
input: 'object={4}',
|
|
22
|
+
output: {
|
|
23
|
+
object: 4
|
|
24
|
+
}
|
|
25
|
+
}, {
|
|
26
|
+
input: 'object={{"test": 1}}',
|
|
27
|
+
output: {
|
|
28
|
+
object: {
|
|
29
|
+
test: 1
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}, {
|
|
33
|
+
input: 'object={[1, 2, 3, [1, 2]]}',
|
|
34
|
+
output: {
|
|
35
|
+
object: [1, 2, 3, [1, 2]]
|
|
36
|
+
}
|
|
37
|
+
}, {
|
|
38
|
+
input: 'object={[1, 2]}',
|
|
39
|
+
output: {
|
|
40
|
+
object: [1, 2]
|
|
41
|
+
}
|
|
42
|
+
}, {
|
|
43
|
+
input: 'key="value" object={{key: "value"}}',
|
|
44
|
+
inputFromOutput: 'key="value" object={{"key": "value"}}',
|
|
45
|
+
output: {
|
|
46
|
+
key: 'value',
|
|
47
|
+
object: {
|
|
48
|
+
key: 'value'
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}, {
|
|
52
|
+
input: 'global packageId="myId" uniqueId="some unique id!" update',
|
|
53
|
+
output: {
|
|
54
|
+
global: true,
|
|
55
|
+
packageId: 'myId',
|
|
56
|
+
uniqueId: 'some unique id!',
|
|
57
|
+
update: true
|
|
58
|
+
}
|
|
59
|
+
}, {
|
|
60
|
+
input: 'global key="value" object={{key: "value", something: "test", hello: 1}} packageId="myId" uniqueId="some unique id!" update',
|
|
61
|
+
inputFromOutput: 'global key="value" object={{"hello": 1, "key": "value", "something": "test"}} packageId="myId" uniqueId="some unique id!" update',
|
|
62
|
+
output: {
|
|
63
|
+
global: true,
|
|
64
|
+
key: 'value',
|
|
65
|
+
object: {
|
|
66
|
+
hello: 1,
|
|
67
|
+
key: 'value',
|
|
68
|
+
something: 'test'
|
|
69
|
+
},
|
|
70
|
+
packageId: 'myId',
|
|
71
|
+
uniqueId: 'some unique id!',
|
|
72
|
+
update: true
|
|
73
|
+
}
|
|
74
|
+
}, {
|
|
75
|
+
input: 'object={{hello: 1, key: "value", nested: { key: "value" }, something: "test", test: [1, 2, 3]}}',
|
|
76
|
+
inputFromOutput: 'object={{"hello": 1, "key": "value", "nested": {"key": "value"}, "something": "test", "test": [1, 2, 3]}}',
|
|
77
|
+
output: {
|
|
78
|
+
object: {
|
|
79
|
+
hello: 1,
|
|
80
|
+
key: 'value',
|
|
81
|
+
nested: {
|
|
82
|
+
key: 'value'
|
|
83
|
+
},
|
|
84
|
+
something: 'test',
|
|
85
|
+
test: [1, 2, 3]
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}, {
|
|
89
|
+
input: 'global key="value" object={{hello: 1, key: "value", nested: { key: "value" }, something: "test", test: [1, 2, 3]}} packageId="myId" uniqueId="some unique id!" update',
|
|
90
|
+
inputFromOutput: 'global key="value" object={{"hello": 1, "key": "value", "nested": { "key": "value" }, "something": "test", "test": [1, 2, 3]}} packageId="myId" uniqueId="some unique id!" update',
|
|
91
|
+
output: {
|
|
92
|
+
global: true,
|
|
93
|
+
key: 'value',
|
|
94
|
+
object: {
|
|
95
|
+
hello: 1,
|
|
96
|
+
key: 'value',
|
|
97
|
+
nested: {
|
|
98
|
+
key: 'value'
|
|
99
|
+
},
|
|
100
|
+
something: 'test',
|
|
101
|
+
test: [1, 2, 3]
|
|
102
|
+
},
|
|
103
|
+
packageId: 'myId',
|
|
104
|
+
uniqueId: 'some unique id!',
|
|
105
|
+
update: true
|
|
106
|
+
}
|
|
107
|
+
}];
|
|
108
|
+
for (const {
|
|
109
|
+
input,
|
|
110
|
+
output
|
|
111
|
+
} of INPUT_AND_OUTPUT) {
|
|
112
|
+
it(`can correctly convert to object: "${input.replace(/\n/g, '\\n')}"`, () => {
|
|
113
|
+
const propsObject = extractPropsFromJSXPropsString({
|
|
114
|
+
propsString: input
|
|
115
|
+
});
|
|
116
|
+
console.log({
|
|
117
|
+
output,
|
|
118
|
+
propsObject
|
|
119
|
+
});
|
|
120
|
+
expect(propsObject).toStrictEqual(output);
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
for (const {
|
|
124
|
+
input: originalInput,
|
|
125
|
+
inputFromOutput,
|
|
126
|
+
output
|
|
127
|
+
} of INPUT_AND_OUTPUT) {
|
|
128
|
+
const input = inputFromOutput || originalInput;
|
|
129
|
+
it(`can correctly convert from object: "${input.replace(/\n/g, '\\n')}"`, () => {
|
|
130
|
+
const propsString = propsToJSXString({
|
|
131
|
+
props: output
|
|
132
|
+
});
|
|
133
|
+
console.log({
|
|
134
|
+
input,
|
|
135
|
+
propsString
|
|
136
|
+
});
|
|
137
|
+
expect(propsString.replaceAll(' ', '')).toBe(input.replaceAll(' ', ''));
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
});
|
|
141
|
+
});
|
|
142
|
+
//# sourceMappingURL=jsx.spec.js.map
|