@payloadcms/richtext-lexical 4.0.0-internal.ea6e8f8 → 4.0.0-internal.ee5d8bd
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-334JNLRF.js +2 -0
- package/dist/exports/client/Field-334JNLRF.js.map +7 -0
- package/dist/exports/client/{RelationshipComponent-YCPAKOL7.js → RelationshipComponent-TVK6I4W4.js} +2 -2
- package/dist/exports/client/chunk-BEKGION5.js +2 -0
- package/dist/exports/client/chunk-BEKGION5.js.map +7 -0
- package/dist/exports/client/{chunk-WSAPGI3Z.js → chunk-EA5BHQ2T.js} +1 -1
- package/dist/exports/client/{chunk-WSAPGI3Z.js.map → chunk-EA5BHQ2T.js.map} +1 -1
- package/dist/exports/client/chunk-FAJJXXCW.js +2 -0
- package/dist/exports/client/{chunk-3LRZDIIG.js.map → chunk-FAJJXXCW.js.map} +2 -2
- package/dist/exports/client/{chunk-5VIL27GI.js → chunk-IYBYNEKX.js} +1 -1
- package/dist/exports/client/{chunk-5VIL27GI.js.map → chunk-IYBYNEKX.js.map} +1 -1
- package/dist/exports/client/chunk-SE5IITBK.js +2 -0
- package/dist/exports/client/chunk-SE5IITBK.js.map +7 -0
- package/dist/exports/client/{component-6DQLENIE.js → component-QENB4QTS.js} +2 -2
- package/dist/exports/client/componentInline-AU7IBNY7.js +2 -0
- package/dist/exports/client/index.js +26 -26
- package/dist/exports/client/index.js.map +4 -4
- package/dist/features/align/client/index.js.map +1 -1
- package/dist/features/blocks/client/component/BlockContent.js.map +1 -1
- package/dist/features/blocks/client/component/components/BlockCollapsible.js.map +1 -1
- package/dist/features/blocks/client/component/components/BlockEditButton.js.map +1 -1
- package/dist/features/blocks/client/component/components/BlockRemoveButton.js.map +1 -1
- package/dist/features/blocks/client/component/index.d.ts.map +1 -1
- package/dist/features/blocks/client/component/index.js +38 -16
- package/dist/features/blocks/client/component/index.js.map +1 -1
- package/dist/features/blocks/client/componentInline/components/InlineBlockContainer.js.map +1 -1
- package/dist/features/blocks/client/componentInline/components/InlineBlockEditButton.js.map +1 -1
- package/dist/features/blocks/client/componentInline/components/InlineBlockLabel.js.map +1 -1
- package/dist/features/blocks/client/componentInline/components/InlineBlockRemoveButton.js.map +1 -1
- package/dist/features/blocks/client/componentInline/index.d.ts.map +1 -1
- package/dist/features/blocks/client/componentInline/index.js +5 -11
- package/dist/features/blocks/client/componentInline/index.js.map +1 -1
- package/dist/features/blocks/client/getCachedFormStateIfDataMatches.js.map +1 -1
- package/dist/features/blocks/client/plugin/index.js.map +1 -1
- package/dist/features/blocks/premade/CodeBlock/Component/Block.js +121 -78
- package/dist/features/blocks/premade/CodeBlock/Component/Block.js.map +1 -1
- package/dist/features/blocks/premade/CodeBlock/Component/Code.js +142 -87
- package/dist/features/blocks/premade/CodeBlock/Component/Code.js.map +1 -1
- package/dist/features/converters/lexicalToHtml/sync/types.d.ts.map +1 -1
- package/dist/features/converters/lexicalToHtml/sync/types.js.map +1 -1
- package/dist/features/debug/jsxConverter/client/plugin/index.js.map +1 -1
- package/dist/features/debug/testRecorder/client/plugin/index.js.map +1 -1
- package/dist/features/debug/treeView/client/plugin/index.js.map +1 -1
- package/dist/features/heading/client/index.js.map +1 -1
- package/dist/features/horizontalRule/client/plugin/index.js.map +1 -1
- package/dist/features/indent/client/index.d.ts.map +1 -1
- package/dist/features/indent/client/index.js +0 -2
- package/dist/features/indent/client/index.js.map +1 -1
- package/dist/features/indent/server/i18n.d.ts.map +1 -1
- package/dist/features/indent/server/i18n.js.map +1 -1
- package/dist/features/link/client/plugins/autoLink/index.js.map +1 -1
- package/dist/features/link/client/plugins/floatingLinkEditor/LinkEditor/index.d.ts.map +1 -1
- package/dist/features/link/client/plugins/floatingLinkEditor/LinkEditor/index.js +10 -2
- package/dist/features/link/client/plugins/floatingLinkEditor/LinkEditor/index.js.map +1 -1
- package/dist/features/link/client/plugins/link/index.js.map +1 -1
- package/dist/features/link/markdownTransformer.js +2 -2
- package/dist/features/link/markdownTransformer.js.map +1 -1
- package/dist/features/link/server/baseFields.js.map +1 -1
- package/dist/features/lists/shared/schema.d.ts.map +1 -1
- package/dist/features/lists/shared/schema.js.map +1 -1
- package/dist/features/relationship/client/drawer/index.js.map +1 -1
- package/dist/features/relationship/client/plugins/index.js.map +1 -1
- package/dist/features/relationship/client/utils/useEnabledRelationships.js.map +1 -1
- package/dist/features/table/client/plugins/TableActionMenuPlugin/index.css +1 -1
- package/dist/features/table/client/plugins/TableActionMenuPlugin/index.js.map +1 -1
- package/dist/features/table/client/plugins/TableCellResizerPlugin/index.js +6 -6
- package/dist/features/table/client/plugins/TableCellResizerPlugin/index.js.map +1 -1
- package/dist/features/table/client/plugins/TableHoverActionsPlugin/index.js.map +1 -1
- package/dist/features/table/client/plugins/TablePlugin/index.js +54 -18
- package/dist/features/table/client/plugins/TablePlugin/index.js.map +1 -1
- package/dist/features/table/client/utils/useDebounce.js.map +1 -1
- package/dist/features/textState/defaultColors.js +1 -1
- package/dist/features/textState/defaultColors.js.map +1 -1
- package/dist/features/toolbars/fixed/client/Toolbar/horizontalWheelScroll.js.map +1 -1
- package/dist/features/toolbars/fixed/client/Toolbar/index.d.ts.map +1 -1
- package/dist/features/toolbars/fixed/client/Toolbar/index.js +141 -70
- package/dist/features/toolbars/fixed/client/Toolbar/index.js.map +1 -1
- package/dist/features/toolbars/inline/client/Toolbar/index.d.ts.map +1 -1
- package/dist/features/toolbars/inline/client/Toolbar/index.js +82 -35
- package/dist/features/toolbars/inline/client/Toolbar/index.js.map +1 -1
- package/dist/features/toolbars/shared/ToolbarButton/index.d.ts.map +1 -1
- package/dist/features/toolbars/shared/ToolbarButton/index.js +26 -2
- package/dist/features/toolbars/shared/ToolbarButton/index.js.map +1 -1
- package/dist/features/toolbars/shared/ToolbarDropdown/DropDown.js +137 -72
- package/dist/features/toolbars/shared/ToolbarDropdown/DropDown.js.map +1 -1
- package/dist/features/toolbars/shared/ToolbarDropdown/index.d.ts.map +1 -1
- package/dist/features/toolbars/shared/ToolbarDropdown/index.js +22 -6
- package/dist/features/toolbars/shared/ToolbarDropdown/index.js.map +1 -1
- package/dist/features/toolbars/shared/useToolbarKeyboardNavigation.d.ts +5 -0
- package/dist/features/toolbars/shared/useToolbarKeyboardNavigation.d.ts.map +1 -0
- package/dist/features/toolbars/shared/useToolbarKeyboardNavigation.js +109 -0
- package/dist/features/toolbars/shared/useToolbarKeyboardNavigation.js.map +1 -0
- package/dist/features/upload/client/drawer/index.js.map +1 -1
- package/dist/features/upload/client/plugin/index.js.map +1 -1
- package/dist/field/RenderLexical/index.js.map +1 -1
- package/dist/field/ViewSelector.js +12 -4
- package/dist/field/ViewSelector.js.map +1 -1
- package/dist/field/bundled.css +1 -1
- package/dist/field/index.js.map +1 -1
- package/dist/field/rscEntry.d.ts +2 -2
- package/dist/field/rscEntry.d.ts.map +1 -1
- package/dist/field/rscEntry.js.map +1 -1
- package/dist/i18n.d.ts.map +1 -1
- package/dist/i18n.js +44 -0
- package/dist/i18n.js.map +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/lexical/LexicalEditor.js.map +1 -1
- package/dist/lexical/plugins/ClipboardPlugin/index.js.map +1 -1
- package/dist/lexical/plugins/DecoratorPlugin/index.js.map +1 -1
- package/dist/lexical/plugins/InsertParagraphAtEnd/index.js.map +1 -1
- package/dist/lexical/plugins/MarkdownShortcut/index.js.map +1 -1
- package/dist/lexical/plugins/NodeViewOverridePlugin/index.js.map +1 -1
- package/dist/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/LexicalMenu.js +234 -87
- package/dist/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/LexicalMenu.js.map +1 -1
- package/dist/lexical/plugins/SlashMenu/useMenuTriggerMatch.js.map +1 -1
- package/dist/lexical/plugins/TextPlugin/index.js.map +1 -1
- package/dist/lexical/plugins/handles/AddBlockHandlePlugin/index.js.map +1 -1
- package/dist/lexical/plugins/handles/DraggableBlockPlugin/index.css +16 -0
- package/dist/lexical/plugins/handles/DraggableBlockPlugin/index.d.ts.map +1 -1
- package/dist/lexical/plugins/handles/DraggableBlockPlugin/index.js +126 -38
- package/dist/lexical/plugins/handles/DraggableBlockPlugin/index.js.map +1 -1
- package/dist/lexical/plugins/handles/DraggableBlockPlugin/moveBlock.d.ts +7 -0
- package/dist/lexical/plugins/handles/DraggableBlockPlugin/moveBlock.d.ts.map +1 -0
- package/dist/lexical/plugins/handles/DraggableBlockPlugin/moveBlock.js +15 -0
- package/dist/lexical/plugins/handles/DraggableBlockPlugin/moveBlock.js.map +1 -0
- package/dist/lexical/plugins/handles/DraggableBlockPlugin/useKeyboardReordering.d.ts.map +1 -1
- package/dist/lexical/plugins/handles/DraggableBlockPlugin/useKeyboardReordering.js +9 -12
- package/dist/lexical/plugins/handles/DraggableBlockPlugin/useKeyboardReordering.js.map +1 -1
- package/dist/lexical/ui/ContentEditable.d.ts.map +1 -1
- package/dist/lexical/ui/ContentEditable.js +16 -9
- package/dist/lexical/ui/ContentEditable.js.map +1 -1
- package/dist/lexical/utils/nodeFormat.d.ts.map +1 -1
- package/dist/lexical/utils/nodeFormat.js +0 -2
- package/dist/lexical/utils/nodeFormat.js.map +1 -1
- package/dist/lexical/utils/url.d.ts.map +1 -1
- package/dist/lexical/utils/url.js +1 -1
- package/dist/lexical/utils/url.js.map +1 -1
- package/dist/populateGraphQL/populate.d.ts.map +1 -1
- package/dist/populateGraphQL/populate.js +1 -2
- package/dist/populateGraphQL/populate.js.map +1 -1
- package/dist/types/index.d.ts +1 -4
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js.map +1 -1
- package/dist/utilities/buildEditorState.d.ts.map +1 -1
- package/dist/utilities/buildEditorState.js.map +1 -1
- package/dist/utilities/fieldsDrawer/Drawer.js +36 -36
- package/dist/utilities/fieldsDrawer/Drawer.js.map +1 -1
- package/dist/utilities/fieldsDrawer/DrawerContent.d.ts.map +1 -1
- package/dist/utilities/fieldsDrawer/DrawerContent.js +6 -9
- package/dist/utilities/fieldsDrawer/DrawerContent.js.map +1 -1
- package/dist/utilities/fieldsDrawer/useDrawerSubmit.js.map +1 -1
- package/dist/utilities/fieldsDrawer/useLexicalDocumentDrawer.js.map +1 -1
- package/dist/utilities/fieldsDrawer/useLexicalDrawer.js.map +1 -1
- package/dist/utilities/fieldsDrawer/useLexicalListDrawer.js.map +1 -1
- package/dist/utilities/generateImportMap.d.ts +2 -2
- package/dist/utilities/generateImportMap.d.ts.map +1 -1
- package/dist/utilities/generateImportMap.js.map +1 -1
- package/dist/utilities/initLexicalFeatures.d.ts.map +1 -1
- package/dist/utilities/initLexicalFeatures.js +38 -4
- package/dist/utilities/initLexicalFeatures.js.map +1 -1
- package/dist/utilities/useLexicalFeature.js +15 -6
- package/dist/utilities/useLexicalFeature.js.map +1 -1
- package/dist/utilities/useRunDeprioritized.js.map +1 -1
- package/package.json +32 -35
- package/dist/exports/client/Field-MT4FK3IP.js +0 -2
- package/dist/exports/client/Field-MT4FK3IP.js.map +0 -7
- package/dist/exports/client/chunk-3LRZDIIG.js +0 -2
- package/dist/exports/client/chunk-E6LSRRP2.js +0 -2
- package/dist/exports/client/chunk-E6LSRRP2.js.map +0 -7
- package/dist/exports/client/chunk-ZQX5HXUL.js +0 -2
- package/dist/exports/client/chunk-ZQX5HXUL.js.map +0 -7
- package/dist/exports/client/componentInline-HNE5G4TE.js +0 -2
- /package/dist/exports/client/{RelationshipComponent-YCPAKOL7.js.map → RelationshipComponent-TVK6I4W4.js.map} +0 -0
- /package/dist/exports/client/{component-6DQLENIE.js.map → component-QENB4QTS.js.map} +0 -0
- /package/dist/exports/client/{componentInline-HNE5G4TE.js.map → componentInline-AU7IBNY7.js.map} +0 -0
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["checkDependencies","deepMergeSimple","convertLexicalToMarkdown","convertMarkdownToLexical","getLexicalHooks","i18n","defaultEditorFeatures","populateLexicalPopulationPromises","getLLMInstructionsFeatures","getFieldToJSONSchema","featuresInputToEditorConfig","getGenerateImportMap","getGenerateSchemaMap","getDefaultSanitizedEditorConfig","richTextValidateHOC","checkedDependencies","lexicalTargetVersion","lexicalEditor","args","process","env","NODE_ENV","PAYLOAD_DISABLE_DEPENDENCY_CHECKER","dependencyGroups","name","dependencies","targetVersion","config","isRoot","parentIsLocalized","features","resolvedFeatureMap","finalSanitizedEditorConfig","lexical","result","sanitizedConfig","featureI18n","supportedLanguages","supportedLanguagesToMerge","_lang","lang","lexicalI18nForLang","general","translations","CellComponent","converters","fromMarkdown","markdown","editorConfig","toMarkdown","data","DiffComponent","FieldComponent","path","serverProps","admin","views","generateImportMap","lexicalEditorArgs","generateSchemaMap","graphQLPopulationPromises","context","currentDepth","depth","draft","field","fieldPromises","findMany","flattenLocales","overrideAccess","populationPromises","req","showHiddenFields","siblingDoc","size","editorPopulationPromises","hooks","jsonSchema","presets","llmInstructions","presetArgs","validate","AlignFeature","BlockquoteFeature","CodeBlock","BlocksFeature","$createServerBlockNode","$isServerBlockNode","ServerBlockNode","$createServerInlineBlockNode","$isServerInlineBlockNode","ServerInlineBlockNode","convertHTMLToLexical","lexicalHTMLField","getPayloadPopulateFn","getRestPopulateFn","DebugJsxConverterFeature","TestRecorderFeature","TreeViewFeature","BoldFeature","InlineCodeFeature","ItalicFeature","StrikethroughFeature","SubscriptFeature","SuperscriptFeature","UnderlineFeature","HeadingFeature","HorizontalRuleFeature","IndentFeature","$createAutoLinkNode","$isAutoLinkNode","AutoLinkNode","$createLinkNode","$isLinkNode","LinkNode","LinkFeature","ChecklistFeature","OrderedListFeature","UnorderedListFeature","ParagraphFeature","RelationshipFeature","RelationshipServerNode","TableFeature","defaultColors","TextStateFeature","FixedToolbarFeature","InlineToolbarFeature","createNode","UploadFeature","UploadServerNode","defaultEditorConfig","defaultEditorLexicalConfig","loadFeatures","sortFeaturesForOptimalLoading","sanitizeServerEditorConfig","sanitizeServerFeatures","getEnabledNodes","getEnabledNodesFromServerNodes","$convertFromMarkdownString","DETAIL_TYPE_TO_DETAIL","DOUBLE_LINE_BREAK","ELEMENT_FORMAT_TO_TYPE","ELEMENT_TYPE_TO_FORMAT","IS_ALL_FORMATTING","LTR_REGEX","NodeFormat","NON_BREAKING_SPACE","RTL_REGEX","TEXT_MODE_TO_TYPE","TEXT_TYPE_TO_FORMAT","TEXT_TYPE_TO_MODE","sanitizeUrl","validateUrl","defaultRichTextValue","populate","buildDefaultEditorState","buildEditorState","createServerFeature","editorConfigFactory","extractPropsFromJSXPropsString","extractFrontmatter","frontmatterToObject","objectToFrontmatter","propsToJSXString","upgradeLexicalData"],"sources":["../src/index.ts"],"sourcesContent":["import type { GenericLanguages, GenericTranslationsObject } from '@payloadcms/translations'\n\nimport { checkDependencies, deepMergeSimple } from 'payload'\n\nimport type { FeatureProviderServer, ResolvedServerFeatureMap } from './features/typesServer.js'\nimport type { SanitizedServerEditorConfig } from './lexical/config/types.js'\nimport type {\n AdapterProps,\n LexicalEditorProps,\n LexicalRichTextAdapterProvider,\n} from './types/index.js'\n\nimport { convertLexicalToMarkdown } from './features/converters/lexicalToMarkdown/index.js'\nimport { convertMarkdownToLexical } from './features/converters/markdownToLexical/index.js'\nimport { getLexicalHooks } from './hooks.js'\nimport { i18n } from './i18n.js'\nimport { defaultEditorFeatures } from './lexical/config/server/default.js'\nimport { populateLexicalPopulationPromises } from './populateGraphQL/populateLexicalPopulationPromises.js'\nimport { getLLMInstructionsFeatures } from './presets/llmInstructions.js'\nimport { getFieldToJSONSchema } from './types/schema.js'\nimport { featuresInputToEditorConfig } from './utilities/editorConfigFactory.js'\nimport { getGenerateImportMap } from './utilities/generateImportMap.js'\nimport { getGenerateSchemaMap } from './utilities/generateSchemaMap.js'\nimport { getDefaultSanitizedEditorConfig } from './utilities/getDefaultSanitizedEditorConfig.js'\nimport { richTextValidateHOC } from './validate/index.js'\n\nlet checkedDependencies = false\n\nexport const lexicalTargetVersion = '0.52.0'\n\nexport function lexicalEditor(args?: LexicalEditorProps): LexicalRichTextAdapterProvider {\n if (\n process.env.NODE_ENV !== 'production' &&\n process.env.PAYLOAD_DISABLE_DEPENDENCY_CHECKER !== 'true' &&\n !checkedDependencies\n ) {\n checkedDependencies = true\n void checkDependencies({\n dependencyGroups: [\n {\n name: 'lexical',\n dependencies: [\n 'lexical',\n '@lexical/headless',\n '@lexical/link',\n '@lexical/list',\n '@lexical/mark',\n '@lexical/markdown',\n '@lexical/react',\n '@lexical/rich-text',\n '@lexical/selection',\n '@lexical/utils',\n ],\n targetVersion: lexicalTargetVersion,\n },\n ],\n })\n }\n return ({ config, isRoot, parentIsLocalized }) => {\n let features: FeatureProviderServer<unknown, unknown, unknown>[] = []\n let resolvedFeatureMap: ResolvedServerFeatureMap\n\n let finalSanitizedEditorConfig: SanitizedServerEditorConfig // For server only\n if (!args || (!args.features && !args.lexical)) {\n finalSanitizedEditorConfig = getDefaultSanitizedEditorConfig({\n config,\n parentIsLocalized,\n })\n\n features = defaultEditorFeatures\n\n resolvedFeatureMap = finalSanitizedEditorConfig.resolvedFeatureMap\n } else {\n const result = featuresInputToEditorConfig({\n config,\n features: args?.features,\n isRoot,\n lexical: args?.lexical,\n parentIsLocalized,\n })\n finalSanitizedEditorConfig = result.sanitizedConfig\n features = result.features\n resolvedFeatureMap = result.resolvedFeatureMap\n }\n\n const featureI18n: Partial<GenericLanguages> = finalSanitizedEditorConfig.features.i18n\n const supportedLanguages = config.i18n?.supportedLanguages\n const supportedLanguagesToMerge: Partial<GenericLanguages> = {}\n for (const _lang in supportedLanguages) {\n if (!(_lang in i18n)) {\n if (featureI18n[_lang as keyof typeof i18n]) {\n supportedLanguagesToMerge[_lang as keyof typeof i18n] =\n featureI18n[_lang as keyof typeof i18n]\n }\n continue\n }\n const lang = _lang as keyof typeof i18n\n const lexicalI18nForLang = ((featureI18n[lang] ??= {}).lexical ??=\n {}) as GenericTranslationsObject\n\n lexicalI18nForLang.general = i18n[lang] ?? {}\n supportedLanguagesToMerge[lang] = featureI18n[lang]\n }\n\n config.i18n.translations = deepMergeSimple(config.i18n.translations, supportedLanguagesToMerge)\n\n return {\n CellComponent: '@payloadcms/richtext-lexical/rsc#RscEntryLexicalCell',\n converters: {\n fromMarkdown: ({ markdown }) =>\n convertMarkdownToLexical({ editorConfig: finalSanitizedEditorConfig, markdown }),\n toMarkdown: ({ data }) =>\n convertLexicalToMarkdown({ data, editorConfig: finalSanitizedEditorConfig }),\n },\n DiffComponent: '@payloadcms/richtext-lexical/rsc#LexicalDiffComponent',\n editorConfig: finalSanitizedEditorConfig,\n features,\n FieldComponent: {\n path: '@payloadcms/richtext-lexical/rsc#RscEntryLexicalField',\n serverProps: {\n admin: args?.admin,\n views: args?.views,\n },\n },\n generateImportMap: getGenerateImportMap({\n lexicalEditorArgs: args,\n resolvedFeatureMap,\n }),\n generateSchemaMap: getGenerateSchemaMap({\n resolvedFeatureMap,\n }),\n graphQLPopulationPromises({\n context,\n currentDepth,\n depth,\n draft,\n field,\n fieldPromises,\n findMany,\n flattenLocales,\n overrideAccess,\n parentIsLocalized,\n populationPromises,\n req,\n showHiddenFields,\n siblingDoc,\n }) {\n // check if there are any features with nodes which have populationPromises for this field\n if (finalSanitizedEditorConfig?.features?.graphQLPopulationPromises?.size) {\n populateLexicalPopulationPromises({\n context,\n currentDepth: currentDepth ?? 0,\n depth,\n draft,\n editorPopulationPromises: finalSanitizedEditorConfig.features.graphQLPopulationPromises,\n field,\n fieldPromises,\n findMany,\n flattenLocales,\n overrideAccess,\n parentIsLocalized,\n populationPromises,\n req,\n showHiddenFields,\n siblingDoc,\n })\n }\n },\n hooks: getLexicalHooks({\n editorConfig: finalSanitizedEditorConfig,\n }),\n jsonSchema: getFieldToJSONSchema({ editorConfig: finalSanitizedEditorConfig }),\n presets: {\n llmInstructions: (presetArgs) =>\n lexicalEditor({ features: getLLMInstructionsFeatures })(presetArgs),\n },\n validate: richTextValidateHOC({\n editorConfig: finalSanitizedEditorConfig,\n }),\n }\n }\n}\n\nexport { AlignFeature } from './features/align/server/index.js'\nexport { BlockquoteFeature } from './features/blockquote/server/index.js'\nexport { CodeBlock } from './features/blocks/premade/CodeBlock/index.js'\nexport { BlocksFeature } from './features/blocks/server/index.js'\nexport type {\n BlocksFeatureProps,\n LexicalBlockClientProps,\n LexicalBlockLabelClientProps,\n LexicalBlockLabelServerProps,\n LexicalBlockServerProps,\n LexicalInlineBlockClientProps,\n LexicalInlineBlockLabelClientProps,\n LexicalInlineBlockLabelServerProps,\n LexicalInlineBlockServerProps,\n} from './features/blocks/server/index.js'\n\nexport {\n $createServerBlockNode,\n $isServerBlockNode,\n ServerBlockNode,\n} from './features/blocks/server/nodes/BlocksNode.js'\nexport {\n $createServerInlineBlockNode,\n $isServerInlineBlockNode,\n ServerInlineBlockNode,\n} from './features/blocks/server/nodes/InlineBlocksNode.js'\n\nexport type { BlockFields, InlineBlockFields } from './features/blocks/server/schema.js'\n\nexport { convertHTMLToLexical } from './features/converters/htmlToLexical/index.js'\n\nexport { lexicalHTMLField } from './features/converters/lexicalToHtml/async/field/index.js'\n\nexport { convertLexicalToMarkdown } from './features/converters/lexicalToMarkdown/index.js'\nexport { convertMarkdownToLexical } from './features/converters/markdownToLexical/index.js'\nexport { getPayloadPopulateFn } from './features/converters/utilities/payloadPopulateFn.js'\n\nexport { getRestPopulateFn } from './features/converters/utilities/restPopulateFn.js'\nexport { DebugJsxConverterFeature } from './features/debug/jsxConverter/server/index.js'\nexport { TestRecorderFeature } from './features/debug/testRecorder/server/index.js'\nexport { TreeViewFeature } from './features/debug/treeView/server/index.js'\nexport { BoldFeature } from './features/format/bold/feature.server.js'\nexport { InlineCodeFeature } from './features/format/inlineCode/feature.server.js'\nexport { ItalicFeature } from './features/format/italic/feature.server.js'\n\nexport { StrikethroughFeature } from './features/format/strikethrough/feature.server.js'\nexport { SubscriptFeature } from './features/format/subscript/feature.server.js'\nexport { SuperscriptFeature } from './features/format/superscript/feature.server.js'\nexport { UnderlineFeature } from './features/format/underline/feature.server.js'\nexport { HeadingFeature, type HeadingFeatureProps } from './features/heading/server/index.js'\nexport { HorizontalRuleFeature } from './features/horizontalRule/server/index.js'\nexport { IndentFeature } from './features/indent/server/index.js'\n\nexport {\n $createAutoLinkNode,\n $isAutoLinkNode,\n AutoLinkNode,\n} from './features/link/nodes/AutoLinkNode.js'\nexport { $createLinkNode, $isLinkNode, LinkNode } from './features/link/nodes/LinkNode.js'\nexport { LinkFeature, type LinkFeatureServerProps } from './features/link/server/index.js'\n\nexport type { LinkFields } from './features/link/server/schema.js'\nexport { ChecklistFeature } from './features/lists/checklist/server/index.js'\n\nexport { OrderedListFeature } from './features/lists/orderedList/server/index.js'\nexport { UnorderedListFeature } from './features/lists/unorderedList/server/index.js'\n\nexport { ParagraphFeature } from './features/paragraph/server/index.js'\n\nexport {\n RelationshipFeature,\n type RelationshipFeatureProps,\n} from './features/relationship/server/index.js'\n\nexport { RelationshipServerNode } from './features/relationship/server/nodes/RelationshipNode.js'\n\nexport type { RelationshipData } from './features/relationship/server/schema.js'\nexport { TableFeature } from './features/table/server/index.js'\nexport { defaultColors } from './features/textState/defaultColors.js'\nexport { TextStateFeature } from './features/textState/feature.server.js'\n\nexport { FixedToolbarFeature } from './features/toolbars/fixed/server/index.js'\n\nexport { InlineToolbarFeature } from './features/toolbars/inline/server/index.js'\nexport type { ToolbarGroup, ToolbarGroupItem } from './features/toolbars/types.js'\nexport type {\n BaseClientFeatureProps,\n ClientFeature,\n ClientFeatureProviderMap,\n FeatureProviderClient,\n FeatureProviderProviderClient,\n PluginComponent,\n PluginComponentWithAnchor,\n ResolvedClientFeature,\n ResolvedClientFeatureMap,\n SanitizedClientFeatures,\n SanitizedPlugin,\n} from './features/typesClient.js'\n\nexport type {\n AfterChangeNodeHook,\n AfterChangeNodeHookArgs,\n AfterReadNodeHook,\n AfterReadNodeHookArgs,\n BaseNodeHookArgs,\n BeforeChangeNodeHook,\n BeforeChangeNodeHookArgs,\n BeforeValidateNodeHook,\n BeforeValidateNodeHookArgs,\n FeatureProviderProviderServer,\n FeatureProviderServer,\n NodeValidation,\n NodeWithHooks,\n PopulationPromise,\n ResolvedServerFeature,\n ResolvedServerFeatureMap,\n SanitizedServerFeatures,\n ServerFeature,\n ServerFeatureProviderMap,\n} from './features/typesServer.js'\n\nexport { createNode } from './features/typeUtilities.js' // Only useful in feature.server.ts\n\nexport { UploadFeature } from './features/upload/server/index.js'\nexport type { UploadFeatureProps } from './features/upload/server/index.js'\n\nexport { UploadServerNode } from './features/upload/server/nodes/UploadNode.js'\nexport type { UploadData } from './features/upload/server/schema.js'\nexport type { EditorConfigContextType } from './lexical/config/client/EditorConfigProvider.js'\n\nexport {\n defaultEditorConfig,\n defaultEditorFeatures,\n defaultEditorLexicalConfig,\n} from './lexical/config/server/default.js'\nexport { loadFeatures, sortFeaturesForOptimalLoading } from './lexical/config/server/loader.js'\n\nexport {\n sanitizeServerEditorConfig,\n sanitizeServerFeatures,\n} from './lexical/config/server/sanitize.js'\nexport type {\n ClientEditorConfig,\n SanitizedClientEditorConfig,\n SanitizedServerEditorConfig,\n ServerEditorConfig,\n} from './lexical/config/types.js'\nexport type { AdapterProps }\n\nexport { getEnabledNodes, getEnabledNodesFromServerNodes } from './lexical/nodes/index.js'\n\nexport type {\n SlashMenuGroup,\n SlashMenuItem,\n} from './lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/types.js'\nexport { $convertFromMarkdownString } from './lexical/utils/markdown/convertFromMarkdownString.js'\n\nexport {\n DETAIL_TYPE_TO_DETAIL,\n DOUBLE_LINE_BREAK,\n ELEMENT_FORMAT_TO_TYPE,\n ELEMENT_TYPE_TO_FORMAT,\n IS_ALL_FORMATTING,\n LTR_REGEX,\n NodeFormat,\n NON_BREAKING_SPACE,\n RTL_REGEX,\n TEXT_MODE_TO_TYPE,\n TEXT_TYPE_TO_FORMAT,\n TEXT_TYPE_TO_MODE,\n} from './lexical/utils/nodeFormat.js'\n\nexport { sanitizeUrl, validateUrl } from './lexical/utils/url.js'\n\nexport { defaultRichTextValue } from './populateGraphQL/defaultValue.js'\nexport { populate } from './populateGraphQL/populate.js'\nexport type {\n ClientFeaturesMap,\n LexicalEditorNodeMap,\n LexicalEditorProps,\n LexicalEditorViewMap,\n LexicalFieldAdminProps,\n LexicalRichTextAdapter,\n NodeMapValue,\n SerializedNodeBase,\n ViewMapBlockComponentProps,\n} from './types/index.js'\n\nexport type * from './types/nodeTypes.js'\n\nexport { buildDefaultEditorState, buildEditorState } from './utilities/buildEditorState.js'\nexport { createServerFeature } from './utilities/createServerFeature.js'\n\nexport { editorConfigFactory } from './utilities/editorConfigFactory.js'\nexport type { FieldsDrawerProps } from './utilities/fieldsDrawer/Drawer.js'\n\nexport { extractPropsFromJSXPropsString } from './utilities/jsx/extractPropsFromJSXPropsString.js'\n\nexport {\n extractFrontmatter,\n frontmatterToObject,\n objectToFrontmatter,\n propsToJSXString,\n} from './utilities/jsx/jsx.js'\nexport { upgradeLexicalData } from './utilities/upgradeLexicalData/index.js'\n"],"mappings":"AAEA,SAASA,iBAAiB,EAAEC,eAAe,QAAQ;AAUnD,SAASC,wBAAwB,QAAQ;AACzC,SAASC,wBAAwB,QAAQ;AACzC,SAASC,eAAe,QAAQ;AAChC,SAASC,IAAI,QAAQ;AACrB,SAASC,qBAAqB,QAAQ;AACtC,SAASC,iCAAiC,QAAQ;AAClD,SAASC,0BAA0B,QAAQ;AAC3C,SAASC,oBAAoB,QAAQ;AACrC,SAASC,2BAA2B,QAAQ;AAC5C,SAASC,oBAAoB,QAAQ;AACrC,SAASC,oBAAoB,QAAQ;AACrC,SAASC,+BAA+B,QAAQ;AAChD,SAASC,mBAAmB,QAAQ;AAEpC,IAAIC,mBAAA,GAAsB;AAE1B,OAAO,MAAMC,oBAAA,GAAuB;AAEpC,OAAO,SAASC,cAAcC,IAAyB;EACrD,IACEC,OAAA,CAAQC,GAAG,CAACC,QAAQ,KAAK,gBACzBF,OAAA,CAAQC,GAAG,CAACE,kCAAkC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W,QAAQ;AAEzC,SAASC,oBAAoB,QAAQ;AACrC,SAASC,QAAQ,QAAQ;AAezB,SAASC,uBAAuB,EAAEC,gBAAgB,QAAQ;AAC1D,SAASC,mBAAmB,QAAQ;AAEpC,SAASC,mBAAmB,QAAQ;AAGpC,SAASC,8BAA8B,QAAQ;AAE/C,SACEC,kBAAkB,EAClBC,mBAAmB,EACnBC,mBAAmB,EACnBC,gBAAgB,QACX;AACP,SAASC,kBAAkB,QAAQ","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"index.js","names":["checkDependencies","deepMergeSimple","convertLexicalToMarkdown","convertMarkdownToLexical","getLexicalHooks","i18n","defaultEditorFeatures","populateLexicalPopulationPromises","getLLMInstructionsFeatures","getFieldToJSONSchema","featuresInputToEditorConfig","getGenerateImportMap","getGenerateSchemaMap","getDefaultSanitizedEditorConfig","richTextValidateHOC","checkedDependencies","lexicalTargetVersion","lexicalEditor","args","process","env","NODE_ENV","PAYLOAD_DISABLE_DEPENDENCY_CHECKER","dependencyGroups","name","dependencies","targetVersion","config","isRoot","parentIsLocalized","features","resolvedFeatureMap","finalSanitizedEditorConfig","lexical","result","sanitizedConfig","featureI18n","supportedLanguages","supportedLanguagesToMerge","_lang","lang","lexicalI18nForLang","general","translations","CellComponent","converters","fromMarkdown","markdown","editorConfig","toMarkdown","data","DiffComponent","FieldComponent","path","serverProps","admin","views","generateImportMap","lexicalEditorArgs","generateSchemaMap","graphQLPopulationPromises","context","currentDepth","depth","draft","field","fieldPromises","findMany","flattenLocales","overrideAccess","populationPromises","req","showHiddenFields","siblingDoc","size","editorPopulationPromises","hooks","jsonSchema","presets","llmInstructions","presetArgs","validate","AlignFeature","BlockquoteFeature","CodeBlock","BlocksFeature","$createServerBlockNode","$isServerBlockNode","ServerBlockNode","$createServerInlineBlockNode","$isServerInlineBlockNode","ServerInlineBlockNode","convertHTMLToLexical","lexicalHTMLField","getPayloadPopulateFn","getRestPopulateFn","DebugJsxConverterFeature","TestRecorderFeature","TreeViewFeature","BoldFeature","InlineCodeFeature","ItalicFeature","StrikethroughFeature","SubscriptFeature","SuperscriptFeature","UnderlineFeature","HeadingFeature","HorizontalRuleFeature","IndentFeature","$createAutoLinkNode","$isAutoLinkNode","AutoLinkNode","$createLinkNode","$isLinkNode","LinkNode","LinkFeature","ChecklistFeature","OrderedListFeature","UnorderedListFeature","ParagraphFeature","RelationshipFeature","RelationshipServerNode","TableFeature","defaultColors","TextStateFeature","FixedToolbarFeature","InlineToolbarFeature","createNode","UploadFeature","UploadServerNode","defaultEditorConfig","defaultEditorLexicalConfig","loadFeatures","sortFeaturesForOptimalLoading","sanitizeServerEditorConfig","sanitizeServerFeatures","getEnabledNodes","getEnabledNodesFromServerNodes","$convertFromMarkdownString","DETAIL_TYPE_TO_DETAIL","DOUBLE_LINE_BREAK","ELEMENT_FORMAT_TO_TYPE","ELEMENT_TYPE_TO_FORMAT","IS_ALL_FORMATTING","LTR_REGEX","NodeFormat","NON_BREAKING_SPACE","RTL_REGEX","TEXT_MODE_TO_TYPE","TEXT_TYPE_TO_FORMAT","TEXT_TYPE_TO_MODE","sanitizeUrl","validateUrl","defaultRichTextValue","populate","buildDefaultEditorState","buildEditorState","createServerFeature","editorConfigFactory","extractPropsFromJSXPropsString","extractFrontmatter","frontmatterToObject","objectToFrontmatter","propsToJSXString","upgradeLexicalData"],"sources":["../src/index.ts"],"sourcesContent":["import type { GenericLanguages, GenericTranslationsObject } from '@payloadcms/translations'\n\nimport { checkDependencies, deepMergeSimple } from 'payload'\n\nimport type { FeatureProviderServer, ResolvedServerFeatureMap } from './features/typesServer.js'\nimport type { SanitizedServerEditorConfig } from './lexical/config/types.js'\nimport type {\n AdapterProps,\n LexicalEditorArgs,\n LexicalRichTextAdapterProvider,\n} from './types/index.js'\n\nimport { convertLexicalToMarkdown } from './features/converters/lexicalToMarkdown/index.js'\nimport { convertMarkdownToLexical } from './features/converters/markdownToLexical/index.js'\nimport { getLexicalHooks } from './hooks.js'\nimport { i18n } from './i18n.js'\nimport { defaultEditorFeatures } from './lexical/config/server/default.js'\nimport { populateLexicalPopulationPromises } from './populateGraphQL/populateLexicalPopulationPromises.js'\nimport { getLLMInstructionsFeatures } from './presets/llmInstructions.js'\nimport { getFieldToJSONSchema } from './types/schema.js'\nimport { featuresInputToEditorConfig } from './utilities/editorConfigFactory.js'\nimport { getGenerateImportMap } from './utilities/generateImportMap.js'\nimport { getGenerateSchemaMap } from './utilities/generateSchemaMap.js'\nimport { getDefaultSanitizedEditorConfig } from './utilities/getDefaultSanitizedEditorConfig.js'\nimport { richTextValidateHOC } from './validate/index.js'\n\nlet checkedDependencies = false\n\nexport const lexicalTargetVersion = '0.52.0'\n\nexport function lexicalEditor(args?: LexicalEditorArgs): LexicalRichTextAdapterProvider {\n if (\n process.env.NODE_ENV !== 'production' &&\n process.env.PAYLOAD_DISABLE_DEPENDENCY_CHECKER !== 'true' &&\n !checkedDependencies\n ) {\n checkedDependencies = true\n void checkDependencies({\n dependencyGroups: [\n {\n name: 'lexical',\n dependencies: [\n 'lexical',\n '@lexical/headless',\n '@lexical/link',\n '@lexical/list',\n '@lexical/mark',\n '@lexical/markdown',\n '@lexical/react',\n '@lexical/rich-text',\n '@lexical/selection',\n '@lexical/utils',\n ],\n targetVersion: lexicalTargetVersion,\n },\n ],\n })\n }\n return ({ config, isRoot, parentIsLocalized }) => {\n let features: FeatureProviderServer<unknown, unknown, unknown>[] = []\n let resolvedFeatureMap: ResolvedServerFeatureMap\n\n let finalSanitizedEditorConfig: SanitizedServerEditorConfig // For server only\n if (!args || (!args.features && !args.lexical)) {\n finalSanitizedEditorConfig = getDefaultSanitizedEditorConfig({\n config,\n parentIsLocalized,\n })\n\n features = defaultEditorFeatures\n\n resolvedFeatureMap = finalSanitizedEditorConfig.resolvedFeatureMap\n } else {\n const result = featuresInputToEditorConfig({\n config,\n features: args?.features,\n isRoot,\n lexical: args?.lexical,\n parentIsLocalized,\n })\n finalSanitizedEditorConfig = result.sanitizedConfig\n features = result.features\n resolvedFeatureMap = result.resolvedFeatureMap\n }\n\n const featureI18n: Partial<GenericLanguages> = finalSanitizedEditorConfig.features.i18n\n const supportedLanguages = config.i18n?.supportedLanguages\n const supportedLanguagesToMerge: Partial<GenericLanguages> = {}\n for (const _lang in supportedLanguages) {\n if (!(_lang in i18n)) {\n if (featureI18n[_lang as keyof typeof i18n]) {\n supportedLanguagesToMerge[_lang as keyof typeof i18n] =\n featureI18n[_lang as keyof typeof i18n]\n }\n continue\n }\n const lang = _lang as keyof typeof i18n\n const lexicalI18nForLang = ((featureI18n[lang] ??= {}).lexical ??=\n {}) as GenericTranslationsObject\n\n lexicalI18nForLang.general = i18n[lang] ?? {}\n supportedLanguagesToMerge[lang] = featureI18n[lang]\n }\n\n config.i18n.translations = deepMergeSimple(config.i18n.translations, supportedLanguagesToMerge)\n\n return {\n CellComponent: '@payloadcms/richtext-lexical/rsc#RscEntryLexicalCell',\n converters: {\n fromMarkdown: ({ markdown }) =>\n convertMarkdownToLexical({ editorConfig: finalSanitizedEditorConfig, markdown }),\n toMarkdown: ({ data }) =>\n convertLexicalToMarkdown({ data, editorConfig: finalSanitizedEditorConfig }),\n },\n DiffComponent: '@payloadcms/richtext-lexical/rsc#LexicalDiffComponent',\n editorConfig: finalSanitizedEditorConfig,\n features,\n FieldComponent: {\n path: '@payloadcms/richtext-lexical/rsc#RscEntryLexicalField',\n serverProps: {\n admin: args?.admin,\n views: args?.views,\n },\n },\n generateImportMap: getGenerateImportMap({\n lexicalEditorArgs: args,\n resolvedFeatureMap,\n }),\n generateSchemaMap: getGenerateSchemaMap({\n resolvedFeatureMap,\n }),\n graphQLPopulationPromises({\n context,\n currentDepth,\n depth,\n draft,\n field,\n fieldPromises,\n findMany,\n flattenLocales,\n overrideAccess,\n parentIsLocalized,\n populationPromises,\n req,\n showHiddenFields,\n siblingDoc,\n }) {\n // check if there are any features with nodes which have populationPromises for this field\n if (finalSanitizedEditorConfig?.features?.graphQLPopulationPromises?.size) {\n populateLexicalPopulationPromises({\n context,\n currentDepth: currentDepth ?? 0,\n depth,\n draft,\n editorPopulationPromises: finalSanitizedEditorConfig.features.graphQLPopulationPromises,\n field,\n fieldPromises,\n findMany,\n flattenLocales,\n overrideAccess,\n parentIsLocalized,\n populationPromises,\n req,\n showHiddenFields,\n siblingDoc,\n })\n }\n },\n hooks: getLexicalHooks({\n editorConfig: finalSanitizedEditorConfig,\n }),\n jsonSchema: getFieldToJSONSchema({ editorConfig: finalSanitizedEditorConfig }),\n presets: {\n llmInstructions: (presetArgs) =>\n lexicalEditor({ features: getLLMInstructionsFeatures })(presetArgs),\n },\n validate: richTextValidateHOC({\n editorConfig: finalSanitizedEditorConfig,\n }),\n }\n }\n}\n\nexport { AlignFeature } from './features/align/server/index.js'\nexport { BlockquoteFeature } from './features/blockquote/server/index.js'\nexport { CodeBlock } from './features/blocks/premade/CodeBlock/index.js'\nexport { BlocksFeature } from './features/blocks/server/index.js'\nexport type {\n BlocksFeatureProps,\n LexicalBlockClientProps,\n LexicalBlockLabelClientProps,\n LexicalBlockLabelServerProps,\n LexicalBlockServerProps,\n LexicalInlineBlockClientProps,\n LexicalInlineBlockLabelClientProps,\n LexicalInlineBlockLabelServerProps,\n LexicalInlineBlockServerProps,\n} from './features/blocks/server/index.js'\n\nexport {\n $createServerBlockNode,\n $isServerBlockNode,\n ServerBlockNode,\n} from './features/blocks/server/nodes/BlocksNode.js'\nexport {\n $createServerInlineBlockNode,\n $isServerInlineBlockNode,\n ServerInlineBlockNode,\n} from './features/blocks/server/nodes/InlineBlocksNode.js'\n\nexport type { BlockFields, InlineBlockFields } from './features/blocks/server/schema.js'\n\nexport { convertHTMLToLexical } from './features/converters/htmlToLexical/index.js'\n\nexport { lexicalHTMLField } from './features/converters/lexicalToHtml/async/field/index.js'\n\nexport { convertLexicalToMarkdown } from './features/converters/lexicalToMarkdown/index.js'\nexport { convertMarkdownToLexical } from './features/converters/markdownToLexical/index.js'\nexport { getPayloadPopulateFn } from './features/converters/utilities/payloadPopulateFn.js'\n\nexport { getRestPopulateFn } from './features/converters/utilities/restPopulateFn.js'\nexport { DebugJsxConverterFeature } from './features/debug/jsxConverter/server/index.js'\nexport { TestRecorderFeature } from './features/debug/testRecorder/server/index.js'\nexport { TreeViewFeature } from './features/debug/treeView/server/index.js'\nexport { BoldFeature } from './features/format/bold/feature.server.js'\nexport { InlineCodeFeature } from './features/format/inlineCode/feature.server.js'\nexport { ItalicFeature } from './features/format/italic/feature.server.js'\n\nexport { StrikethroughFeature } from './features/format/strikethrough/feature.server.js'\nexport { SubscriptFeature } from './features/format/subscript/feature.server.js'\nexport { SuperscriptFeature } from './features/format/superscript/feature.server.js'\nexport { UnderlineFeature } from './features/format/underline/feature.server.js'\nexport { HeadingFeature, type HeadingFeatureProps } from './features/heading/server/index.js'\nexport { HorizontalRuleFeature } from './features/horizontalRule/server/index.js'\nexport { IndentFeature } from './features/indent/server/index.js'\n\nexport {\n $createAutoLinkNode,\n $isAutoLinkNode,\n AutoLinkNode,\n} from './features/link/nodes/AutoLinkNode.js'\nexport { $createLinkNode, $isLinkNode, LinkNode } from './features/link/nodes/LinkNode.js'\nexport { LinkFeature, type LinkFeatureServerProps } from './features/link/server/index.js'\n\nexport type { LinkFields } from './features/link/server/schema.js'\nexport { ChecklistFeature } from './features/lists/checklist/server/index.js'\n\nexport { OrderedListFeature } from './features/lists/orderedList/server/index.js'\nexport { UnorderedListFeature } from './features/lists/unorderedList/server/index.js'\n\nexport { ParagraphFeature } from './features/paragraph/server/index.js'\n\nexport {\n RelationshipFeature,\n type RelationshipFeatureProps,\n} from './features/relationship/server/index.js'\n\nexport { RelationshipServerNode } from './features/relationship/server/nodes/RelationshipNode.js'\n\nexport type { RelationshipData } from './features/relationship/server/schema.js'\nexport { TableFeature } from './features/table/server/index.js'\nexport { defaultColors } from './features/textState/defaultColors.js'\nexport { TextStateFeature } from './features/textState/feature.server.js'\n\nexport { FixedToolbarFeature } from './features/toolbars/fixed/server/index.js'\n\nexport { InlineToolbarFeature } from './features/toolbars/inline/server/index.js'\nexport type { ToolbarGroup, ToolbarGroupItem } from './features/toolbars/types.js'\nexport type {\n BaseClientFeatureProps,\n ClientFeature,\n ClientFeatureProviderMap,\n FeatureProviderClient,\n FeatureProviderProviderClient,\n PluginComponent,\n PluginComponentWithAnchor,\n ResolvedClientFeature,\n ResolvedClientFeatureMap,\n SanitizedClientFeatures,\n SanitizedPlugin,\n} from './features/typesClient.js'\n\nexport type {\n AfterChangeNodeHook,\n AfterChangeNodeHookArgs,\n AfterReadNodeHook,\n AfterReadNodeHookArgs,\n BaseNodeHookArgs,\n BeforeChangeNodeHook,\n BeforeChangeNodeHookArgs,\n BeforeValidateNodeHook,\n BeforeValidateNodeHookArgs,\n FeatureProviderProviderServer,\n FeatureProviderServer,\n NodeValidation,\n NodeWithHooks,\n PopulationPromise,\n ResolvedServerFeature,\n ResolvedServerFeatureMap,\n SanitizedServerFeatures,\n ServerFeature,\n ServerFeatureProviderMap,\n} from './features/typesServer.js'\n\nexport { createNode } from './features/typeUtilities.js' // Only useful in feature.server.ts\n\nexport { UploadFeature } from './features/upload/server/index.js'\nexport type { UploadFeatureProps } from './features/upload/server/index.js'\n\nexport { UploadServerNode } from './features/upload/server/nodes/UploadNode.js'\nexport type { UploadData } from './features/upload/server/schema.js'\nexport type { EditorConfigContextType } from './lexical/config/client/EditorConfigProvider.js'\n\nexport {\n defaultEditorConfig,\n defaultEditorFeatures,\n defaultEditorLexicalConfig,\n} from './lexical/config/server/default.js'\nexport { loadFeatures, sortFeaturesForOptimalLoading } from './lexical/config/server/loader.js'\n\nexport {\n sanitizeServerEditorConfig,\n sanitizeServerFeatures,\n} from './lexical/config/server/sanitize.js'\nexport type {\n ClientEditorConfig,\n SanitizedClientEditorConfig,\n SanitizedServerEditorConfig,\n ServerEditorConfig,\n} from './lexical/config/types.js'\nexport type { AdapterProps }\n\nexport { getEnabledNodes, getEnabledNodesFromServerNodes } from './lexical/nodes/index.js'\n\nexport type {\n SlashMenuGroup,\n SlashMenuItem,\n} from './lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/types.js'\nexport { $convertFromMarkdownString } from './lexical/utils/markdown/convertFromMarkdownString.js'\n\nexport {\n DETAIL_TYPE_TO_DETAIL,\n DOUBLE_LINE_BREAK,\n ELEMENT_FORMAT_TO_TYPE,\n ELEMENT_TYPE_TO_FORMAT,\n IS_ALL_FORMATTING,\n LTR_REGEX,\n NodeFormat,\n NON_BREAKING_SPACE,\n RTL_REGEX,\n TEXT_MODE_TO_TYPE,\n TEXT_TYPE_TO_FORMAT,\n TEXT_TYPE_TO_MODE,\n} from './lexical/utils/nodeFormat.js'\n\nexport { sanitizeUrl, validateUrl } from './lexical/utils/url.js'\n\nexport { defaultRichTextValue } from './populateGraphQL/defaultValue.js'\nexport { populate } from './populateGraphQL/populate.js'\nexport type {\n ClientFeaturesMap,\n LexicalEditorArgs,\n LexicalEditorNodeMap,\n LexicalEditorViewMap,\n LexicalFieldAdminProps,\n LexicalRichTextAdapter,\n NodeMapValue,\n SerializedNodeBase,\n ViewMapBlockComponentProps,\n} from './types/index.js'\n\nexport type * from './types/nodeTypes.js'\n\nexport { buildDefaultEditorState, buildEditorState } from './utilities/buildEditorState.js'\nexport { createServerFeature } from './utilities/createServerFeature.js'\n\nexport { editorConfigFactory } from './utilities/editorConfigFactory.js'\nexport type { FieldsDrawerProps } from './utilities/fieldsDrawer/Drawer.js'\n\nexport { extractPropsFromJSXPropsString } from './utilities/jsx/extractPropsFromJSXPropsString.js'\n\nexport {\n extractFrontmatter,\n frontmatterToObject,\n objectToFrontmatter,\n propsToJSXString,\n} from './utilities/jsx/jsx.js'\nexport { upgradeLexicalData } from './utilities/upgradeLexicalData/index.js'\n"],"mappings":"AAEA,SAASA,iBAAiB,EAAEC,eAAe,QAAQ;AAUnD,SAASC,wBAAwB,QAAQ;AACzC,SAASC,wBAAwB,QAAQ;AACzC,SAASC,eAAe,QAAQ;AAChC,SAASC,IAAI,QAAQ;AACrB,SAASC,qBAAqB,QAAQ;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B,EACnB5H,qBAAqB,EACrB6H,0BAA0B,QACrB;AACP,SAASC,YAAY,EAAEC,6BAA6B,QAAQ;AAE5D,SACEC,0BAA0B,EAC1BC,sBAAsB,QACjB;AASP,SAASC,eAAe,EAAEC,8BAA8B,QAAQ;AAMhE,SAASC,0BAA0B,QAAQ;AAE3C,SACEC,qBAAqB,EACrBC,iBAAiB,EACjBC,sBAAsB,EACtBC,sBAAsB,EACtBC,iBAAiB,EACjBC,SAAS,EACTC,UAAU,EACVC,kBAAkB,EAClBC,SAAS,EACTC,iBAAiB,EACjBC,mBAAmB,EACnBC,iBAAiB,QACZ;AAEP,SAASC,WAAW,EAAEC,WAAW,QAAQ;AAEzC,SAASC,oBAAoB,QAAQ;AACrC,SAASC,QAAQ,QAAQ;AAezB,SAASC,uBAAuB,EAAEC,gBAAgB,QAAQ;AAC1D,SAASC,mBAAmB,QAAQ;AAEpC,SAASC,mBAAmB,QAAQ;AAGpC,SAASC,8BAA8B,QAAQ;AAE/C,SACEC,kBAAkB,EAClBC,mBAAmB,EACnBC,mBAAmB,EACnBC,gBAAgB,QACX;AACP,SAASC,kBAAkB,QAAQ","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LexicalEditor.js","names":["c","_c","useLexicalComposerContext","LexicalErrorBoundary","HistoryPlugin","OnChangePlugin","RichTextPlugin","useLexicalEditable","useTranslation","BLUR_COMMAND","COMMAND_PRIORITY_LOW","FOCUS_COMMAND","React","useEffect","useState","useEditorConfigContext","EditorPlugin","ClipboardPlugin","DecoratorPlugin","AddBlockHandlePlugin","DraggableBlockPlugin","InsertParagraphAtEndPlugin","MarkdownShortcutPlugin","NodeViewOverridePlugin","NormalizeSelectionPlugin","SelectAllPlugin","SlashMenuPlugin","TextPlugin","LexicalContentEditable","LexicalEditor","props","$","editorConfig","editorContainerRef","isSmallWidthViewport","onChange","rtl","editorConfigContext","editor","isEditable","t","instructionsID","useId","hasTabIndentation","features","enabledFeatures","includes","floatingAnchorElem","setFloatingAnchorElem","t0","Symbol","for","_floatingAnchorElem","onRef","t1","t2","uuid","console","error","parentEditor","registerChild","handleFocus","focusEditor","handleBlur","blurEditor","unregisterFocus","registerCommand","unregisterBlur","unregisterChild","_jsxs","Fragment","children","plugins","map","_temp","className","dir","undefined","ref","_temp2","_jsx","contentEditable","ignoreSelectionChange","editorState","editor_0","tags","has","size","admin","hideDraggableBlockElement","anchorElem","hideAddBlockButton","plugin_1","plugin","position","desktopOnly","clientProps","key","markdownTransformers","length","_temp3","_temp4","id","_temp5","plugin_0","plugin_2","plugin_3","plugin_4"],"sources":["../../src/lexical/LexicalEditor.tsx"],"sourcesContent":["'use client'\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext.js'\nimport { LexicalErrorBoundary } from '@lexical/react/LexicalErrorBoundary.js'\nimport { HistoryPlugin } from '@lexical/react/LexicalHistoryPlugin.js'\nimport { OnChangePlugin } from '@lexical/react/LexicalOnChangePlugin.js'\nimport { RichTextPlugin } from '@lexical/react/LexicalRichTextPlugin.js'\nimport { useLexicalEditable } from '@lexical/react/useLexicalEditable'\nimport { useTranslation } from '@payloadcms/ui'\nimport { BLUR_COMMAND, COMMAND_PRIORITY_LOW, FOCUS_COMMAND } from 'lexical'\nimport * as React from 'react'\nimport { useEffect, useState } from 'react'\n\nimport type { LexicalProviderProps } from './LexicalProvider.js'\n\nimport { useEditorConfigContext } from './config/client/EditorConfigProvider.js'\nimport './LexicalEditor.css'\nimport { EditorPlugin } from './EditorPlugin.js'\nimport { ClipboardPlugin } from './plugins/ClipboardPlugin/index.js'\nimport { DecoratorPlugin } from './plugins/DecoratorPlugin/index.js'\nimport { AddBlockHandlePlugin } from './plugins/handles/AddBlockHandlePlugin/index.js'\nimport { DraggableBlockPlugin } from './plugins/handles/DraggableBlockPlugin/index.js'\nimport { InsertParagraphAtEndPlugin } from './plugins/InsertParagraphAtEnd/index.js'\nimport { MarkdownShortcutPlugin } from './plugins/MarkdownShortcut/index.js'\nimport { NodeViewOverridePlugin } from './plugins/NodeViewOverridePlugin/index.js'\nimport { NormalizeSelectionPlugin } from './plugins/NormalizeSelection/index.js'\nimport { SelectAllPlugin } from './plugins/SelectAllPlugin/index.js'\nimport { SlashMenuPlugin } from './plugins/SlashMenu/index.js'\nimport { TextPlugin } from './plugins/TextPlugin/index.js'\nimport { LexicalContentEditable } from './ui/ContentEditable.js'\n\nexport const LexicalEditor: React.FC<\n {\n editorContainerRef: React.RefObject<HTMLDivElement | null>\n isSmallWidthViewport: boolean\n } & Pick<LexicalProviderProps, 'editorConfig' | 'onChange' | 'rtl'>\n> = (props) => {\n const { editorConfig, editorContainerRef, isSmallWidthViewport, onChange, rtl } = props\n const editorConfigContext = useEditorConfigContext()\n const [editor] = useLexicalComposerContext()\n const isEditable = useLexicalEditable()\n const { t } = useTranslation<Record<string, never>, string>()\n const instructionsID = React.useId()\n const hasTabIndentation = isEditable && editorConfig.features.enabledFeatures.includes('indent')\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 useEffect(() => {\n if (!editorConfigContext?.uuid) {\n console.error('Lexical Editor must be used within an EditorConfigProvider')\n return\n }\n if (editorConfigContext?.parentEditor?.uuid) {\n editorConfigContext.parentEditor?.registerChild(editorConfigContext.uuid, editorConfigContext)\n }\n\n const handleFocus = () => {\n editorConfigContext.focusEditor(editorConfigContext)\n }\n\n const handleBlur = () => {\n editorConfigContext.blurEditor(editorConfigContext)\n }\n\n const unregisterFocus = editor.registerCommand(\n FOCUS_COMMAND,\n () => {\n handleFocus()\n return true\n },\n COMMAND_PRIORITY_LOW,\n )\n\n const unregisterBlur = editor.registerCommand(\n BLUR_COMMAND,\n () => {\n handleBlur()\n return true\n },\n COMMAND_PRIORITY_LOW,\n )\n\n return () => {\n unregisterFocus()\n unregisterBlur()\n editorConfigContext.parentEditor?.unregisterChild?.(editorConfigContext.uuid)\n }\n }, [editor, editorConfigContext])\n\n return (\n <React.Fragment>\n {editorConfig.features.plugins?.map((plugin) => {\n if (plugin.position === 'aboveContainer') {\n return <EditorPlugin clientProps={plugin.clientProps} key={plugin.key} plugin={plugin} />\n }\n })}\n <div className=\"editor-container\" dir={rtl ? 'rtl' : undefined} ref={editorContainerRef}>\n {editorConfig.features.plugins?.map((plugin) => {\n if (plugin.position === 'top') {\n return (\n <EditorPlugin clientProps={plugin.clientProps} key={plugin.key} plugin={plugin} />\n )\n }\n })}\n <RichTextPlugin\n contentEditable={\n <div className=\"editor-scroller\">\n <div className=\"editor\" ref={onRef}>\n <LexicalContentEditable\n editorConfig={editorConfig}\n instructionsID={hasTabIndentation ? instructionsID : undefined}\n />\n </div>\n </div>\n }\n ErrorBoundary={LexicalErrorBoundary}\n />\n <NormalizeSelectionPlugin />\n {isEditable && <InsertParagraphAtEndPlugin />}\n <DecoratorPlugin />\n <ClipboardPlugin />\n <TextPlugin features={editorConfig.features} />\n <SelectAllPlugin />\n <NodeViewOverridePlugin />\n {isEditable && (\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) {\n onChange(editorState, editor, tags)\n }\n }\n }}\n />\n )}\n {floatingAnchorElem && (\n <React.Fragment>\n {!isSmallWidthViewport && isEditable && (\n <React.Fragment>\n {editorConfig.admin?.hideDraggableBlockElement ? null : (\n <DraggableBlockPlugin anchorElem={floatingAnchorElem} />\n )}\n {editorConfig.admin?.hideAddBlockButton ? null : (\n <AddBlockHandlePlugin anchorElem={floatingAnchorElem} />\n )}\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\n anchorElem={floatingAnchorElem}\n clientProps={plugin.clientProps}\n key={plugin.key}\n plugin={plugin}\n />\n )\n }\n })}\n {isEditable && (\n <React.Fragment>\n <SlashMenuPlugin anchorElem={floatingAnchorElem} />\n </React.Fragment>\n )}\n </React.Fragment>\n )}\n {isEditable && (\n <React.Fragment>\n <HistoryPlugin />\n {editorConfig?.features?.markdownTransformers?.length > 0 && <MarkdownShortcutPlugin />}\n </React.Fragment>\n )}\n {editorConfig.features.plugins?.map((plugin) => {\n if (plugin.position === 'normal') {\n return (\n <EditorPlugin clientProps={plugin.clientProps} key={plugin.key} plugin={plugin} />\n )\n }\n })}\n {editorConfig.features.plugins?.map((plugin) => {\n if (plugin.position === 'bottom') {\n return (\n <EditorPlugin clientProps={plugin.clientProps} key={plugin.key} plugin={plugin} />\n )\n }\n })}\n </div>\n {hasTabIndentation && (\n <p className=\"ContentEditable__keyboard-hint\" id={instructionsID}>\n {t('lexical:indent:keyboardHint')}\n </p>\n )}\n {editorConfig.features.plugins?.map((plugin) => {\n if (plugin.position === 'belowContainer') {\n return <EditorPlugin clientProps={plugin.clientProps} key={plugin.key} plugin={plugin} />\n }\n })}\n </React.Fragment>\n )\n}\n"],"mappings":"AAAA;;AAAA,SAAAA,CAAA,IAAAC,EAAA;;AACA,SAASC,yBAAyB,QAAQ;AAC1C,SAASC,oBAAoB,QAAQ;AACrC,SAASC,aAAa,QAAQ;AAC9B,SAASC,cAAc,QAAQ;AAC/B,SAASC,cAAc,QAAQ;AAC/B,SAASC,kBAAkB,QAAQ;AACnC,SAASC,cAAc,QAAQ;AAC/B,SAASC,YAAY,EAAEC,oBAAoB,EAAEC,aAAa,QAAQ;AAClE,YAAYC,KAAA,MAAW;AACvB,SAASC,SAAS,EAAEC,QAAQ,QAAQ;AAIpC,SAASC,sBAAsB,QAAQ;AACvC,OAAO;AACP,SAASC,YAAY,QAAQ;AAC7B,SAASC,eAAe,QAAQ;A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AA,EAA2BH,MAAA,CAAAG,WAAA;MAAAH;IAAA,GAAyBA,MAAA,CAAAI,GAAU;EAAA;AAAA;AA9D3E,SAAAlB,OAAAyB,QAAA;EAAA,IAmEUX,QAAA,CAAAC,QAAA,KAAoB;IAAA,OAEpBd,IAAA,CAAAhE,YAAA;MAAAgF,WAAA,EAA2BH,QAAA,CAAAG,WAAA;MAAAH,MAAA,EAA6CA;IAAA,GAApBA,QAAA,CAAAI,GAAU;EAAA;AAAA;AArExE,SAAAG,OAAAK,QAAA;EAAA,IAsJUZ,QAAA,CAAAC,QAAA,KAAoB;IAAA,OAEpBd,IAAA,CAAAhE,YAAA;MAAAgF,WAAA,EAA2BH,QAAA,CAAAG,WAAA;MAAAH,MAAA,EAA6CA;IAAA,GAApBA,QAAA,CAAAI,GAAU;EAAA;AAAA;AAxJxE,SAAAI,OAAAK,QAAA;EAAA,IA6JUb,QAAA,CAAAC,QAAA,KAAoB;IAAA,OAEpBd,IAAA,CAAAhE,YAAA;MAAAgF,WAAA,EAA2BH,QAAA,CAAAG,WAAA;MAAAH,MAAA,EAA6CA;IAAA,GAApBA,QAAA,CAAAI,GAAU;EAAA;AAAA;AA/JxE,SAAAM,OAAAI,QAAA;EAAA,IA0KQd,QAAA,CAAAC,QAAA,KAAoB;IAAA,OACfd,IAAA,CAAAhE,YAAA;MAAAgF,WAAA,EAA2BH,QAAA,CAAAG,WAAA;MAAAH,MAAA,EAA6CA;IAAA,GAApBA,QAAA,CAAAI,GAAU;EAAA;AAAA","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"LexicalEditor.js","names":["c","_c","useLexicalComposerContext","LexicalErrorBoundary","HistoryPlugin","OnChangePlugin","RichTextPlugin","useLexicalEditable","useTranslation","BLUR_COMMAND","COMMAND_PRIORITY_LOW","FOCUS_COMMAND","React","useEffect","useState","useEditorConfigContext","EditorPlugin","ClipboardPlugin","DecoratorPlugin","AddBlockHandlePlugin","DraggableBlockPlugin","InsertParagraphAtEndPlugin","MarkdownShortcutPlugin","NodeViewOverridePlugin","NormalizeSelectionPlugin","SelectAllPlugin","SlashMenuPlugin","TextPlugin","LexicalContentEditable","LexicalEditor","props","$","editorConfig","editorContainerRef","isSmallWidthViewport","onChange","rtl","editorConfigContext","editor","isEditable","t","instructionsID","useId","hasTabIndentation","features","enabledFeatures","includes","floatingAnchorElem","setFloatingAnchorElem","t0","Symbol","for","_floatingAnchorElem","onRef","t1","t2","uuid","console","error","parentEditor","registerChild","handleFocus","focusEditor","handleBlur","blurEditor","unregisterFocus","registerCommand","unregisterBlur","unregisterChild","_jsxs","Fragment","children","plugins","map","_temp","className","dir","undefined","ref","_temp2","_jsx","contentEditable","ignoreSelectionChange","editorState","editor_0","tags","has","size","admin","hideDraggableBlockElement","anchorElem","hideAddBlockButton","plugin_1","plugin","position","desktopOnly","clientProps","key","markdownTransformers","length","_temp3","_temp4","id","_temp5","plugin_0","plugin_2","plugin_3","plugin_4"],"sources":["../../src/lexical/LexicalEditor.tsx"],"sourcesContent":["'use client'\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext.js'\nimport { LexicalErrorBoundary } from '@lexical/react/LexicalErrorBoundary.js'\nimport { HistoryPlugin } from '@lexical/react/LexicalHistoryPlugin.js'\nimport { OnChangePlugin } from '@lexical/react/LexicalOnChangePlugin.js'\nimport { RichTextPlugin } from '@lexical/react/LexicalRichTextPlugin.js'\nimport { useLexicalEditable } from '@lexical/react/useLexicalEditable'\nimport { useTranslation } from '@payloadcms/ui'\nimport { BLUR_COMMAND, COMMAND_PRIORITY_LOW, FOCUS_COMMAND } from 'lexical'\nimport * as React from 'react'\nimport { useEffect, useState } from 'react'\n\nimport type { LexicalProviderProps } from './LexicalProvider.js'\n\nimport { useEditorConfigContext } from './config/client/EditorConfigProvider.js'\nimport './LexicalEditor.css'\nimport { EditorPlugin } from './EditorPlugin.js'\nimport { ClipboardPlugin } from './plugins/ClipboardPlugin/index.js'\nimport { DecoratorPlugin } from './plugins/DecoratorPlugin/index.js'\nimport { AddBlockHandlePlugin } from './plugins/handles/AddBlockHandlePlugin/index.js'\nimport { DraggableBlockPlugin } from './plugins/handles/DraggableBlockPlugin/index.js'\nimport { InsertParagraphAtEndPlugin } from './plugins/InsertParagraphAtEnd/index.js'\nimport { MarkdownShortcutPlugin } from './plugins/MarkdownShortcut/index.js'\nimport { NodeViewOverridePlugin } from './plugins/NodeViewOverridePlugin/index.js'\nimport { NormalizeSelectionPlugin } from './plugins/NormalizeSelection/index.js'\nimport { SelectAllPlugin } from './plugins/SelectAllPlugin/index.js'\nimport { SlashMenuPlugin } from './plugins/SlashMenu/index.js'\nimport { TextPlugin } from './plugins/TextPlugin/index.js'\nimport { LexicalContentEditable } from './ui/ContentEditable.js'\n\nexport const LexicalEditor: React.FC<\n {\n editorContainerRef: React.RefObject<HTMLDivElement | null>\n isSmallWidthViewport: boolean\n } & Pick<LexicalProviderProps, 'editorConfig' | 'onChange' | 'rtl'>\n> = (props) => {\n const { editorConfig, editorContainerRef, isSmallWidthViewport, onChange, rtl } = props\n const editorConfigContext = useEditorConfigContext()\n const [editor] = useLexicalComposerContext()\n const isEditable = useLexicalEditable()\n const { t } = useTranslation<Record<string, never>, string>()\n const instructionsID = React.useId()\n const hasTabIndentation = isEditable && editorConfig.features.enabledFeatures.includes('indent')\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 useEffect(() => {\n if (!editorConfigContext?.uuid) {\n console.error('Lexical Editor must be used within an EditorConfigProvider')\n return\n }\n if (editorConfigContext?.parentEditor?.uuid) {\n editorConfigContext.parentEditor?.registerChild(editorConfigContext.uuid, editorConfigContext)\n }\n\n const handleFocus = () => {\n editorConfigContext.focusEditor(editorConfigContext)\n }\n\n const handleBlur = () => {\n editorConfigContext.blurEditor(editorConfigContext)\n }\n\n const unregisterFocus = editor.registerCommand(\n FOCUS_COMMAND,\n () => {\n handleFocus()\n return true\n },\n COMMAND_PRIORITY_LOW,\n )\n\n const unregisterBlur = editor.registerCommand(\n BLUR_COMMAND,\n () => {\n handleBlur()\n return true\n },\n COMMAND_PRIORITY_LOW,\n )\n\n return () => {\n unregisterFocus()\n unregisterBlur()\n editorConfigContext.parentEditor?.unregisterChild?.(editorConfigContext.uuid)\n }\n }, [editor, editorConfigContext])\n\n return (\n <React.Fragment>\n {editorConfig.features.plugins?.map((plugin) => {\n if (plugin.position === 'aboveContainer') {\n return <EditorPlugin clientProps={plugin.clientProps} key={plugin.key} plugin={plugin} />\n }\n })}\n <div className=\"editor-container\" dir={rtl ? 'rtl' : undefined} ref={editorContainerRef}>\n {editorConfig.features.plugins?.map((plugin) => {\n if (plugin.position === 'top') {\n return (\n <EditorPlugin clientProps={plugin.clientProps} key={plugin.key} plugin={plugin} />\n )\n }\n })}\n <RichTextPlugin\n contentEditable={\n <div className=\"editor-scroller\">\n <div className=\"editor\" ref={onRef}>\n <LexicalContentEditable\n editorConfig={editorConfig}\n instructionsID={hasTabIndentation ? instructionsID : undefined}\n />\n </div>\n </div>\n }\n ErrorBoundary={LexicalErrorBoundary}\n />\n <NormalizeSelectionPlugin />\n {isEditable && <InsertParagraphAtEndPlugin />}\n <DecoratorPlugin />\n <ClipboardPlugin />\n <TextPlugin features={editorConfig.features} />\n <SelectAllPlugin />\n <NodeViewOverridePlugin />\n {isEditable && (\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) {\n onChange(editorState, editor, tags)\n }\n }\n }}\n />\n )}\n {floatingAnchorElem && (\n <React.Fragment>\n {!isSmallWidthViewport && isEditable && (\n <React.Fragment>\n {editorConfig.admin?.hideDraggableBlockElement ? null : (\n <DraggableBlockPlugin anchorElem={floatingAnchorElem} />\n )}\n {editorConfig.admin?.hideAddBlockButton ? null : (\n <AddBlockHandlePlugin anchorElem={floatingAnchorElem} />\n )}\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\n anchorElem={floatingAnchorElem}\n clientProps={plugin.clientProps}\n key={plugin.key}\n plugin={plugin}\n />\n )\n }\n })}\n {isEditable && (\n <React.Fragment>\n <SlashMenuPlugin anchorElem={floatingAnchorElem} />\n </React.Fragment>\n )}\n </React.Fragment>\n )}\n {isEditable && (\n <React.Fragment>\n <HistoryPlugin />\n {editorConfig?.features?.markdownTransformers?.length > 0 && <MarkdownShortcutPlugin />}\n </React.Fragment>\n )}\n {editorConfig.features.plugins?.map((plugin) => {\n if (plugin.position === 'normal') {\n return (\n <EditorPlugin clientProps={plugin.clientProps} key={plugin.key} plugin={plugin} />\n )\n }\n })}\n {editorConfig.features.plugins?.map((plugin) => {\n if (plugin.position === 'bottom') {\n return (\n <EditorPlugin clientProps={plugin.clientProps} key={plugin.key} plugin={plugin} />\n )\n }\n })}\n </div>\n {hasTabIndentation && (\n <p className=\"ContentEditable__keyboard-hint\" id={instructionsID}>\n {t('lexical:indent:keyboardHint')}\n </p>\n )}\n {editorConfig.features.plugins?.map((plugin) => {\n if (plugin.position === 'belowContainer') {\n return <EditorPlugin clientProps={plugin.clientProps} key={plugin.key} plugin={plugin} />\n }\n })}\n </React.Fragment>\n )\n}\n"],"mappings":"AAAA;;AAAA,SAAAA,CAAA,IAAAC,EAAA;;AACA,SAASC,yBAAyB,QAAQ;AAC1C,SAASC,oBAAoB,QAAQ;AACrC,SAASC,aAAa,QAAQ;AAC9B,SAASC,cAAc,QAAQ;AAC/B,SAASC,cAAc,QAAQ;AAC/B,SAASC,kBAAkB,QAAQ;AACnC,SAASC,cAAc,QAAQ;AAC/B,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/C/B,CAAA,CAAE;QAGNR,YAAA,CAAAY,QAAqB,CAAA4B,OAAU,EAAAC,GAIhC,CAJoC8B,MAIpC;;CAGN;AAhLI,SAAA7B,MAAAmB,MAAA;EA6DI,IAAIA,MAAA,CAAAC,QAAe,KAAK;IAAA,OACfd,IAAA,CAAChE,YAAA;MAAAgF,WAAA,EAA0BH,MAAA,CAAAG,WAAkB;MAAAH;OAAOA,MAAA,CAAAI,GAAU;EAAA;AACvE;AA/DJ,SAAAlB,OAAAyB,QAAA;EAmEM,IAAIX,QAAA,CAAAC,QAAe,KAAK;IAAA,OAEpBd,IAAA,CAAChE,YAAA;MAAAgF,WAAA,EAA0BH,QAAA,CAAAG,WAAkB;MAAAH,MAAA,EAA2BA;OAApBA,QAAA,CAAAI,GAAU;EAAA;AAElE;AAvEN,SAAAG,OAAAK,QAAA;EAsJM,IAAIZ,QAAA,CAAAC,QAAe,KAAK;IAAA,OAEpBd,IAAA,CAAChE,YAAA;MAAAgF,WAAA,EAA0BH,QAAA,CAAAG,WAAkB;MAAAH,MAAA,EAA2BA;OAApBA,QAAA,CAAAI,GAAU;EAAA;AAElE;AA1JN,SAAAI,OAAAK,QAAA;EA6JM,IAAIb,QAAA,CAAAC,QAAe,KAAK;IAAA,OAEpBd,IAAA,CAAChE,YAAA;MAAAgF,WAAA,EAA0BH,QAAA,CAAAG,WAAkB;MAAAH,MAAA,EAA2BA;OAApBA,QAAA,CAAAI,GAAU;EAAA;AAElE;AAjKN,SAAAM,OAAAI,QAAA;EA0KI,IAAId,QAAA,CAAAC,QAAe,KAAK;IAAA,OACfd,IAAA,CAAChE,YAAA;MAAAgF,WAAA,EAA0BH,QAAA,CAAAG,WAAkB;MAAAH,MAAA,EAA2BA;OAApBA,QAAA,CAAAI,GAAU;EAAA;AACvE","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["c","_c","copyToClipboard","useLexicalComposerContext","objectKlassEquals","ObjectID","$getSelection","$isNodeSelection","COMMAND_PRIORITY_LOW","COPY_COMMAND","useEffect","changeIds","node","fields","id","default","toHexString","children","child","ClipboardPlugin","$","editor","t0","t1","registerCommand","event","selection","getNodes","serializedNode","exportJSON","deepCloneSerializedNode","JSON","parse","stringify","lexicalClipboardData","namespace","_config","nodes","stringifiedLexicalClipboardData","catch","_temp","ClipboardEvent","then","clipboardData","Error","lexicalStringified","getData","lexical","node_0","stringified","setData","error_0","error"],"sources":["../../../../src/lexical/plugins/ClipboardPlugin/index.tsx"],"sourcesContent":["'use client'\n\nimport { copyToClipboard } from '@lexical/clipboard'\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext.js'\nimport { objectKlassEquals } from '@lexical/utils'\nimport ObjectID from 'bson-objectid'\nimport { $getSelection, $isNodeSelection, COMMAND_PRIORITY_LOW, COPY_COMMAND } from 'lexical'\nimport { useEffect } from 'react'\n\ntype SerializedUnknownLexicalNode = {\n children?: SerializedUnknownLexicalNode[]\n type: string\n}\n\ntype LexicalClipboardData = {\n namespace: string\n nodes: SerializedUnknownLexicalNode[]\n}\n\nconst changeIds = (node: SerializedUnknownLexicalNode) => {\n if (\n 'fields' in node &&\n typeof node.fields === 'object' &&\n node.fields !== null &&\n 'id' in node.fields\n ) {\n node.fields.id = new ObjectID.default().toHexString()\n } else if ('id' in node) {\n node.id = new ObjectID.default().toHexString()\n }\n\n if (node.children) {\n for (const child of node.children) {\n changeIds(child)\n }\n }\n}\n\nexport function ClipboardPlugin() {\n const [editor] = useLexicalComposerContext()\n\n useEffect(() => {\n // Remove duplicated ids from clipboard. We do it here because:\n // 1. Browsers do not allow setting the clipboardData in paste event for security reasons.\n // 2. If you cut instead of paste, the id will be kept, which is a good thing.\n return editor.registerCommand(\n COPY_COMMAND,\n (event) => {\n // Handle decorator node case\n const selection = $getSelection()\n if ($isNodeSelection(selection)) {\n const node = selection.getNodes()[0]\n\n const serializedNode = node?.exportJSON() as SerializedUnknownLexicalNode\n const deepCloneSerializedNode = JSON.parse(JSON.stringify(serializedNode))\n changeIds(deepCloneSerializedNode)\n\n const lexicalClipboardData: LexicalClipboardData = {\n namespace: editor._config.namespace,\n nodes: [deepCloneSerializedNode],\n }\n\n const stringifiedLexicalClipboardData = JSON.stringify(lexicalClipboardData)\n\n copyToClipboard(editor, null, {\n 'application/x-lexical-editor': stringifiedLexicalClipboardData,\n 'text/plain': '',\n }).catch((error) => {\n throw error\n })\n return true\n }\n\n // Handle range selection case\n copyToClipboard(editor, objectKlassEquals(event, ClipboardEvent) ? event : null)\n .then(() => {\n if (!(event instanceof ClipboardEvent) || !event.clipboardData) {\n throw new Error('No clipboard event')\n }\n const lexicalStringified = event.clipboardData.getData('application/x-lexical-editor')\n if (!lexicalStringified) {\n return true\n }\n\n const lexical = JSON.parse(lexicalStringified) as {\n nodes: SerializedUnknownLexicalNode[]\n }\n\n for (const node of lexical.nodes) {\n changeIds(node)\n }\n const stringified = JSON.stringify(lexical)\n event.clipboardData.setData('application/x-lexical-editor', stringified)\n })\n .catch((error) => {\n if (event instanceof ClipboardEvent) {\n event.clipboardData?.setData('application/x-lexical-editor', '')\n }\n throw error\n })\n return true\n },\n COMMAND_PRIORITY_LOW,\n )\n }, [editor])\n\n return null\n}\n"],"mappings":"AAAA;;AAAA,SAAAA,CAAA,IAAAC,EAAA;AAEA,SAASC,eAAe,QAAQ;AAChC,SAASC,yBAAyB,QAAQ;AAC1C,SAASC,iBAAiB,QAAQ;AAClC,OAAOC,QAAA,MAAc;AACrB,SAASC,aAAa,EAAEC,gBAAgB,EAAEC,oBAAoB,EAAEC,YAAY,QAAQ;AACpF,SAASC,SAAS,QAAQ;AAY1B,MAAMC,SAAA,GAAaC,IAAA;EACjB,IACE,YAAYA,IAAA,IACZ,OAAOA,IAAA,CAAKC,MAAM,KAAK,YACvBD,IAAA,CAAKC,MAAM,KAAK,QAChB,QAAQD,IAAA,CAAKC,MAAM,EACnB;IACAD,IAAA,CAAKC,MAAM,CAACC,EAAE,GAAG,IAAIT,QAAA,CAASU,OAAO,GAAGC,WAAW;EACrD,OAAO,IAAI,QAAQJ,IAAA,EAAM;IACvBA,IAAA,CAAKE,EAAE,GAAG,IAAIT,QAAA,CAASU,OAAO,GAAGC,WAAW;EAC9C;EAEA,IAAIJ,IAAA,CAAKK,QAAQ,EAAE;IACjB,KAAK,MAAMC,KAAA,IAASN,IAAA,CAAKK,QAAQ,EAAE;MACjCN,SAAA,CAAUO,KAAA;IACZ;EACF;AACF;AAEA,OAAO,SAAAC,gBAAA;EAAA,MAAAC,CAAA,GAAAnB,EAAA;EACL,OAAAoB,MAAA,IAAiBlB,yBAAA;EAAA,IAAAmB,EAAA;EAAA,IAAAC,EAAA;EAAA,IAAAH,CAAA,QAAAC,MAAA;IAEPC,EAAA,GAAAA,CAAA,KAIDD,MAAA,CAAAG,
|
|
1
|
+
{"version":3,"file":"index.js","names":["c","_c","copyToClipboard","useLexicalComposerContext","objectKlassEquals","ObjectID","$getSelection","$isNodeSelection","COMMAND_PRIORITY_LOW","COPY_COMMAND","useEffect","changeIds","node","fields","id","default","toHexString","children","child","ClipboardPlugin","$","editor","t0","t1","registerCommand","event","selection","getNodes","serializedNode","exportJSON","deepCloneSerializedNode","JSON","parse","stringify","lexicalClipboardData","namespace","_config","nodes","stringifiedLexicalClipboardData","catch","_temp","ClipboardEvent","then","clipboardData","Error","lexicalStringified","getData","lexical","node_0","stringified","setData","error_0","error"],"sources":["../../../../src/lexical/plugins/ClipboardPlugin/index.tsx"],"sourcesContent":["'use client'\n\nimport { copyToClipboard } from '@lexical/clipboard'\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext.js'\nimport { objectKlassEquals } from '@lexical/utils'\nimport ObjectID from 'bson-objectid'\nimport { $getSelection, $isNodeSelection, COMMAND_PRIORITY_LOW, COPY_COMMAND } from 'lexical'\nimport { useEffect } from 'react'\n\ntype SerializedUnknownLexicalNode = {\n children?: SerializedUnknownLexicalNode[]\n type: string\n}\n\ntype LexicalClipboardData = {\n namespace: string\n nodes: SerializedUnknownLexicalNode[]\n}\n\nconst changeIds = (node: SerializedUnknownLexicalNode) => {\n if (\n 'fields' in node &&\n typeof node.fields === 'object' &&\n node.fields !== null &&\n 'id' in node.fields\n ) {\n node.fields.id = new ObjectID.default().toHexString()\n } else if ('id' in node) {\n node.id = new ObjectID.default().toHexString()\n }\n\n if (node.children) {\n for (const child of node.children) {\n changeIds(child)\n }\n }\n}\n\nexport function ClipboardPlugin() {\n const [editor] = useLexicalComposerContext()\n\n useEffect(() => {\n // Remove duplicated ids from clipboard. We do it here because:\n // 1. Browsers do not allow setting the clipboardData in paste event for security reasons.\n // 2. If you cut instead of paste, the id will be kept, which is a good thing.\n return editor.registerCommand(\n COPY_COMMAND,\n (event) => {\n // Handle decorator node case\n const selection = $getSelection()\n if ($isNodeSelection(selection)) {\n const node = selection.getNodes()[0]\n\n const serializedNode = node?.exportJSON() as SerializedUnknownLexicalNode\n const deepCloneSerializedNode = JSON.parse(JSON.stringify(serializedNode))\n changeIds(deepCloneSerializedNode)\n\n const lexicalClipboardData: LexicalClipboardData = {\n namespace: editor._config.namespace,\n nodes: [deepCloneSerializedNode],\n }\n\n const stringifiedLexicalClipboardData = JSON.stringify(lexicalClipboardData)\n\n copyToClipboard(editor, null, {\n 'application/x-lexical-editor': stringifiedLexicalClipboardData,\n 'text/plain': '',\n }).catch((error) => {\n throw error\n })\n return true\n }\n\n // Handle range selection case\n copyToClipboard(editor, objectKlassEquals(event, ClipboardEvent) ? event : null)\n .then(() => {\n if (!(event instanceof ClipboardEvent) || !event.clipboardData) {\n throw new Error('No clipboard event')\n }\n const lexicalStringified = event.clipboardData.getData('application/x-lexical-editor')\n if (!lexicalStringified) {\n return true\n }\n\n const lexical = JSON.parse(lexicalStringified) as {\n nodes: SerializedUnknownLexicalNode[]\n }\n\n for (const node of lexical.nodes) {\n changeIds(node)\n }\n const stringified = JSON.stringify(lexical)\n event.clipboardData.setData('application/x-lexical-editor', stringified)\n })\n .catch((error) => {\n if (event instanceof ClipboardEvent) {\n event.clipboardData?.setData('application/x-lexical-editor', '')\n }\n throw error\n })\n return true\n },\n COMMAND_PRIORITY_LOW,\n )\n }, [editor])\n\n return null\n}\n"],"mappings":"AAAA;;AAAA,SAAAA,CAAA,IAAAC,EAAA;AAEA,SAASC,eAAe,QAAQ;AAChC,SAASC,yBAAyB,QAAQ;AAC1C,SAASC,iBAAiB,QAAQ;AAClC,OAAOC,QAAA,MAAc;AACrB,SAASC,aAAa,EAAEC,gBAAgB,EAAEC,oBAAoB,EAAEC,YAAY,QAAQ;AACpF,SAASC,SAAS,QAAQ;AAY1B,MAAMC,SAAA,GAAaC,IAAA;EACjB,IACE,YAAYA,IAAA,IACZ,OAAOA,IAAA,CAAKC,MAAM,KAAK,YACvBD,IAAA,CAAKC,MAAM,KAAK,QAChB,QAAQD,IAAA,CAAKC,MAAM,EACnB;IACAD,IAAA,CAAKC,MAAM,CAACC,EAAE,GAAG,IAAIT,QAAA,CAASU,OAAO,GAAGC,WAAW;EACrD,OAAO,IAAI,QAAQJ,IAAA,EAAM;IACvBA,IAAA,CAAKE,EAAE,GAAG,IAAIT,QAAA,CAASU,OAAO,GAAGC,WAAW;EAC9C;EAEA,IAAIJ,IAAA,CAAKK,QAAQ,EAAE;IACjB,KAAK,MAAMC,KAAA,IAASN,IAAA,CAAKK,QAAQ,EAAE;MACjCN,SAAA,CAAUO,KAAA;IACZ;EACF;AACF;AAEA,OAAO,SAAAC,gBAAA;EAAA,MAAAC,CAAA,GAAAnB,EAAA;EACL,OAAAoB,MAAA,IAAiBlB,yBAAA;EAAA,IAAAmB,EAAA;EAAA,IAAAC,EAAA;EAAA,IAAAH,CAAA,QAAAC,MAAA;IAEPC,EAAA,GAAAA,CAAA,KAIDD,MAAA,CAAAG,eAAsB,CAC3Bf,YAAA,EACAgB,KAAA;MAEE,MAAAC,SAAA,GAAkBpB,aAAA;MAClB,IAAIC,gBAAA,CAAiBmB,SAAA;QACnB,MAAAd,IAAA,GAAac,SAAA,CAAAC,QAAkB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AqB,EAAAO,OAAwC,CAAhC,gCAAgC;QAAA;QAE/D,MAAME,OAAA;MAAA,CACR;MAAA,OACK;IAAA,CACT,EACA5C,oBAAA,CAEJ;IAAGe,EAAA,IAACF,MAAA,CAAO;IAAAD,CAAA,MAAAC,MAAA;IAAAD,CAAA,MAAAE,EAAA;IAAAF,CAAA,MAAAG,EAAA;EAAA;IAAAD,EAAA,GAAAF,CAAA;IAAAG,EAAA,GAAAH,CAAA;EAAA;EA/DXV,SAAA,CAAUY,EA+DV,EAAGC,EAAQ;EAAA,OAEJ;AAAA;AApEF,SAAAiB,MAAAY,KAAA;EA8BK,MAAMA,KAAA;AAAA","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["c","_c","useLexicalComposerContext","$findMatchingParent","mergeRegister","$createNodeSelection","$getEditor","$getNearestNodeFromDOMNode","$getSelection","$isDecoratorNode","$isElementNode","$isLineBreakNode","$isNodeSelection","$isRangeSelection","$isRootOrShadowRoot","$isTextNode","$onUpdate","$setSelection","CLICK_COMMAND","COMMAND_PRIORITY_LOW","KEY_ARROW_DOWN_COMMAND","KEY_ARROW_UP_COMMAND","KEY_BACKSPACE_COMMAND","KEY_DELETE_COMMAND","SELECTION_CHANGE_COMMAND","useEffect","DecoratorPlugin","$","editor","$onDelete","_temp2","t0","t1","registerCommand","_temp3","_","activeEditor","hasSelectedDecorator","Boolean","$getSelectedDecorator","read","decorator_0","document","querySelector","classList","remove","decorator","getElementByKey","getKey","add","_temp5","_temp7","event_2","selection_1","selection","event","preventDefault","nextSibling","getNodes","getNextSibling","element_0","element","$selectDecorator","firstDescendant","getFirstDescendant","block_0","INTERNAL_$isBlock","block","selectEnd","lastPoint","isBackward","anchor","focus","lastNode","getNode","lastSelectedBlock","_temp6","nextBlock","findLaterSiblingBlock","nextBlockElement","node","node_1","event_1","selection_0","prevSibling","getPreviousSibling","lastDescendant","getLastDescendant","selectStart","firstPoint","firstNode","firstSelectedBlock","_temp4","prevBlock","findFirstSiblingBlock","prevBlockElement","node_0","event_0","$getDecoratorByMouseEvent","target","isInteractive","HTMLElement","isContentEditable","closest","forEach","_temp","undefined","nodes","length","scrollIntoView","behavior","isInline","firstChild","getFirstChild","isLeafElement","canBeEmpty","current"],"sources":["../../../../src/lexical/plugins/DecoratorPlugin/index.tsx"],"sourcesContent":["'use client'\n\nimport type { DecoratorNode, ElementNode, LexicalNode } from 'lexical'\n\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext'\nimport { $findMatchingParent, mergeRegister } from '@lexical/utils'\nimport {\n $createNodeSelection,\n $getEditor,\n $getNearestNodeFromDOMNode,\n $getSelection,\n $isDecoratorNode,\n $isElementNode,\n $isLineBreakNode,\n $isNodeSelection,\n $isRangeSelection,\n $isRootOrShadowRoot,\n $isTextNode,\n $onUpdate,\n $setSelection,\n CLICK_COMMAND,\n COMMAND_PRIORITY_LOW,\n KEY_ARROW_DOWN_COMMAND,\n KEY_ARROW_UP_COMMAND,\n KEY_BACKSPACE_COMMAND,\n KEY_DELETE_COMMAND,\n SELECTION_CHANGE_COMMAND,\n} from 'lexical'\nimport { useEffect } from 'react'\n\nimport './index.css'\n\n// TODO: This should ideally be fixed in Lexical. See\n// https://github.com/facebook/lexical/pull/7072\nexport function DecoratorPlugin() {\n const [editor] = useLexicalComposerContext()\n\n const $onDelete = (event: KeyboardEvent) => {\n const selection = $getSelection()\n if (!$isNodeSelection(selection)) {\n return false\n }\n event.preventDefault()\n selection.getNodes().forEach((node) => {\n node.remove()\n })\n return true\n }\n\n useEffect(() => {\n return mergeRegister(\n editor.registerCommand(\n CLICK_COMMAND,\n (event) => {\n document.querySelector('.decorator-selected')?.classList.remove('decorator-selected')\n const decorator = $getDecoratorByMouseEvent(event)\n if (!decorator) {\n return true\n }\n const { target } = event\n const isInteractive =\n !(target instanceof HTMLElement) ||\n target.isContentEditable ||\n target.closest(\n 'button, textarea, input, .react-select, .code-editor, .no-select-decorator, [role=\"button\"]',\n )\n if (isInteractive) {\n $setSelection(null)\n } else {\n $selectDecorator(decorator)\n }\n return true\n },\n COMMAND_PRIORITY_LOW,\n ),\n editor.registerCommand(KEY_DELETE_COMMAND, $onDelete, COMMAND_PRIORITY_LOW),\n editor.registerCommand(KEY_BACKSPACE_COMMAND, $onDelete, COMMAND_PRIORITY_LOW),\n editor.registerCommand(\n SELECTION_CHANGE_COMMAND,\n (_, activeEditor) => {\n // Nested editors reconcile independently and update their own highlight.\n if (activeEditor !== editor) {\n return false\n }\n const hasSelectedDecorator = Boolean($getSelectedDecorator())\n $onUpdate(() => {\n activeEditor.read('latest', () => {\n const decorator = $getSelectedDecorator()\n document.querySelector('.decorator-selected')?.classList.remove('decorator-selected')\n if (decorator) {\n activeEditor\n .getElementByKey(decorator.getKey())\n ?.classList.add('decorator-selected')\n }\n })\n })\n return hasSelectedDecorator\n },\n COMMAND_PRIORITY_LOW,\n ),\n editor.registerCommand(\n KEY_ARROW_UP_COMMAND,\n (event) => {\n // CASE 1: Node selection\n const selection = $getSelection()\n if ($isNodeSelection(selection)) {\n const prevSibling = selection.getNodes()[0]?.getPreviousSibling()\n if ($isDecoratorNode(prevSibling)) {\n const element = $getEditor().getElementByKey(prevSibling.getKey())\n if (element) {\n $selectDecorator({ element, node: prevSibling })\n event.preventDefault()\n return true\n }\n return false\n }\n if (!$isElementNode(prevSibling)) {\n return false\n }\n const lastDescendant = prevSibling.getLastDescendant() ?? prevSibling\n if (!lastDescendant) {\n return false\n }\n const block = $findMatchingParent(lastDescendant, INTERNAL_$isBlock)\n block?.selectStart()\n event.preventDefault()\n return true\n }\n if (!$isRangeSelection(selection)) {\n return false\n }\n\n // CASE 2: Range selection\n // Get first selected block\n const firstPoint = selection.isBackward() ? selection.anchor : selection.focus\n const firstNode = firstPoint.getNode()\n const firstSelectedBlock = $findMatchingParent(firstNode, (node) => {\n return findFirstSiblingBlock(node) !== null\n })\n const prevBlock = firstSelectedBlock?.getPreviousSibling()\n if (!firstSelectedBlock || prevBlock !== findFirstSiblingBlock(firstSelectedBlock)) {\n return false\n }\n\n if ($isDecoratorNode(prevBlock)) {\n const prevBlockElement = $getEditor().getElementByKey(prevBlock.getKey())\n if (prevBlockElement) {\n $selectDecorator({ element: prevBlockElement, node: prevBlock })\n event.preventDefault()\n return true\n }\n }\n\n return false\n },\n COMMAND_PRIORITY_LOW,\n ),\n editor.registerCommand(\n KEY_ARROW_DOWN_COMMAND,\n (event) => {\n // CASE 1: Node selection\n const selection = $getSelection()\n if ($isNodeSelection(selection)) {\n event.preventDefault()\n const nextSibling = selection.getNodes()[0]?.getNextSibling()\n if ($isDecoratorNode(nextSibling)) {\n const element = $getEditor().getElementByKey(nextSibling.getKey())\n if (element) {\n $selectDecorator({ element, node: nextSibling })\n }\n return true\n }\n if (!$isElementNode(nextSibling)) {\n return true\n }\n const firstDescendant = nextSibling.getFirstDescendant() ?? nextSibling\n if (!firstDescendant) {\n return true\n }\n const block = $findMatchingParent(firstDescendant, INTERNAL_$isBlock)\n block?.selectEnd()\n event.preventDefault()\n return true\n }\n if (!$isRangeSelection(selection)) {\n return false\n }\n\n // CASE 2: Range selection\n // Get last selected block\n const lastPoint = selection.isBackward() ? selection.anchor : selection.focus\n const lastNode = lastPoint.getNode()\n const lastSelectedBlock = $findMatchingParent(lastNode, (node) => {\n return findLaterSiblingBlock(node) !== null\n })\n const nextBlock = lastSelectedBlock?.getNextSibling()\n if (!lastSelectedBlock || nextBlock !== findLaterSiblingBlock(lastSelectedBlock)) {\n return false\n }\n\n if ($isDecoratorNode(nextBlock)) {\n const nextBlockElement = $getEditor().getElementByKey(nextBlock.getKey())\n if (nextBlockElement) {\n $selectDecorator({ element: nextBlockElement, node: nextBlock })\n event.preventDefault()\n return true\n }\n }\n\n return false\n },\n COMMAND_PRIORITY_LOW,\n ),\n )\n }, [editor])\n\n return null\n}\n\nfunction $getDecoratorByMouseEvent(\n event: MouseEvent,\n): { element: HTMLElement; node: DecoratorNode<unknown> } | undefined {\n if (!(event.target instanceof HTMLElement)) {\n return undefined\n }\n const element = event.target.closest('[data-lexical-decorator=\"true\"]')\n if (!(element instanceof HTMLElement)) {\n return undefined\n }\n const node = $getNearestNodeFromDOMNode(element)\n return $isDecoratorNode(node) ? { element, node } : undefined\n}\n\nfunction $getSelectedDecorator() {\n const selection = $getSelection()\n if (!$isNodeSelection(selection)) {\n return undefined\n }\n const nodes = selection.getNodes()\n if (nodes.length !== 1) {\n return undefined\n }\n const node = nodes[0]\n return $isDecoratorNode(node) ? node : undefined\n}\n\nfunction $selectDecorator({\n element,\n node,\n}: {\n element: HTMLElement\n node: DecoratorNode<unknown>\n}) {\n document.querySelector('.decorator-selected')?.classList.remove('decorator-selected')\n const selection = $createNodeSelection()\n selection.add(node.getKey())\n $setSelection(selection)\n element.scrollIntoView({ behavior: 'smooth', block: 'nearest' })\n element.classList.add('decorator-selected')\n}\n\n/**\n * Copied from https://github.com/facebook/lexical/blob/main/packages/lexical/src/LexicalUtils.ts\n *\n * This function returns true for a DecoratorNode that is not inline OR\n * an ElementNode that is:\n * - not a root or shadow root\n * - not inline\n * - can't be empty\n * - has no children or an inline first child\n */\nexport function INTERNAL_$isBlock(node: LexicalNode): node is DecoratorNode<unknown> | ElementNode {\n if ($isDecoratorNode(node) && !node.isInline()) {\n return true\n }\n if (!$isElementNode(node) || $isRootOrShadowRoot(node)) {\n return false\n }\n\n const firstChild = node.getFirstChild()\n const isLeafElement =\n firstChild === null ||\n $isLineBreakNode(firstChild) ||\n $isTextNode(firstChild) ||\n firstChild.isInline()\n\n return !node.isInline() && node.canBeEmpty() !== false && isLeafElement\n}\n\nfunction findLaterSiblingBlock(node: LexicalNode): LexicalNode | null {\n let current = node.getNextSibling()\n while (current !== null) {\n if (INTERNAL_$isBlock(current)) {\n return current\n }\n current = current.getNextSibling()\n }\n return null\n}\n\nfunction findFirstSiblingBlock(node: LexicalNode): LexicalNode | null {\n let current = node.getPreviousSibling()\n while (current !== null) {\n if (INTERNAL_$isBlock(current)) {\n return current\n }\n current = current.get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IACAA,OAAA,GAAUA,OAAA,CAAQzD,cAAc;EAClC;EACA,OAAO;AACT;AAEA,SAASmC,sBAAsBd,IAAiB;EAC9C,IAAIoC,OAAA,GAAUpC,IAAA,CAAKK,kBAAkB;EACrC,OAAO+B,OAAA,KAAY,MAAM;IACvB,IAAIlD,iBAAA,CAAkBkD,OAAA,GAAU;MAC9B,OAAOA,OAAA;IACT;IACAA,OAAA,GAAUA,OAAA,CAAQ/B,kBAAkB;EACtC;EACA,OAAO;AACT","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"index.js","names":["c","_c","useLexicalComposerContext","$findMatchingParent","mergeRegister","$createNodeSelection","$getEditor","$getNearestNodeFromDOMNode","$getSelection","$isDecoratorNode","$isElementNode","$isLineBreakNode","$isNodeSelection","$isRangeSelection","$isRootOrShadowRoot","$isTextNode","$onUpdate","$setSelection","CLICK_COMMAND","COMMAND_PRIORITY_LOW","KEY_ARROW_DOWN_COMMAND","KEY_ARROW_UP_COMMAND","KEY_BACKSPACE_COMMAND","KEY_DELETE_COMMAND","SELECTION_CHANGE_COMMAND","useEffect","DecoratorPlugin","$","editor","$onDelete","_temp2","t0","t1","registerCommand","_temp3","_","activeEditor","hasSelectedDecorator","Boolean","$getSelectedDecorator","read","decorator_0","document","querySelector","classList","remove","decorator","getElementByKey","getKey","add","_temp5","_temp7","event_2","selection_1","selection","event","preventDefault","nextSibling","getNodes","getNextSibling","element_0","element","$selectDecorator","firstDescendant","getFirstDescendant","block_0","INTERNAL_$isBlock","block","selectEnd","lastPoint","isBackward","anchor","focus","lastNode","getNode","lastSelectedBlock","_temp6","nextBlock","findLaterSiblingBlock","nextBlockElement","node","node_1","event_1","selection_0","prevSibling","getPreviousSibling","lastDescendant","getLastDescendant","selectStart","firstPoint","firstNode","firstSelectedBlock","_temp4","prevBlock","findFirstSiblingBlock","prevBlockElement","node_0","event_0","$getDecoratorByMouseEvent","target","isInteractive","HTMLElement","isContentEditable","closest","forEach","_temp","undefined","nodes","length","scrollIntoView","behavior","isInline","firstChild","getFirstChild","isLeafElement","canBeEmpty","current"],"sources":["../../../../src/lexical/plugins/DecoratorPlugin/index.tsx"],"sourcesContent":["'use client'\n\nimport type { DecoratorNode, ElementNode, LexicalNode } from 'lexical'\n\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext'\nimport { $findMatchingParent, mergeRegister } from '@lexical/utils'\nimport {\n $createNodeSelection,\n $getEditor,\n $getNearestNodeFromDOMNode,\n $getSelection,\n $isDecoratorNode,\n $isElementNode,\n $isLineBreakNode,\n $isNodeSelection,\n $isRangeSelection,\n $isRootOrShadowRoot,\n $isTextNode,\n $onUpdate,\n $setSelection,\n CLICK_COMMAND,\n COMMAND_PRIORITY_LOW,\n KEY_ARROW_DOWN_COMMAND,\n KEY_ARROW_UP_COMMAND,\n KEY_BACKSPACE_COMMAND,\n KEY_DELETE_COMMAND,\n SELECTION_CHANGE_COMMAND,\n} from 'lexical'\nimport { useEffect } from 'react'\n\nimport './index.css'\n\n// TODO: This should ideally be fixed in Lexical. See\n// https://github.com/facebook/lexical/pull/7072\nexport function DecoratorPlugin() {\n const [editor] = useLexicalComposerContext()\n\n const $onDelete = (event: KeyboardEvent) => {\n const selection = $getSelection()\n if (!$isNodeSelection(selection)) {\n return false\n }\n event.preventDefault()\n selection.getNodes().forEach((node) => {\n node.remove()\n })\n return true\n }\n\n useEffect(() => {\n return mergeRegister(\n editor.registerCommand(\n CLICK_COMMAND,\n (event) => {\n document.querySelector('.decorator-selected')?.classList.remove('decorator-selected')\n const decorator = $getDecoratorByMouseEvent(event)\n if (!decorator) {\n return true\n }\n const { target } = event\n const isInteractive =\n !(target instanceof HTMLElement) ||\n target.isContentEditable ||\n target.closest(\n 'button, textarea, input, .react-select, .code-editor, .no-select-decorator, [role=\"button\"]',\n )\n if (isInteractive) {\n $setSelection(null)\n } else {\n $selectDecorator(decorator)\n }\n return true\n },\n COMMAND_PRIORITY_LOW,\n ),\n editor.registerCommand(KEY_DELETE_COMMAND, $onDelete, COMMAND_PRIORITY_LOW),\n editor.registerCommand(KEY_BACKSPACE_COMMAND, $onDelete, COMMAND_PRIORITY_LOW),\n editor.registerCommand(\n SELECTION_CHANGE_COMMAND,\n (_, activeEditor) => {\n // Nested editors reconcile independently and update their own highlight.\n if (activeEditor !== editor) {\n return false\n }\n const hasSelectedDecorator = Boolean($getSelectedDecorator())\n $onUpdate(() => {\n activeEditor.read('latest', () => {\n const decorator = $getSelectedDecorator()\n document.querySelector('.decorator-selected')?.classList.remove('decorator-selected')\n if (decorator) {\n activeEditor\n .getElementByKey(decorator.getKey())\n ?.classList.add('decorator-selected')\n }\n })\n })\n return hasSelectedDecorator\n },\n COMMAND_PRIORITY_LOW,\n ),\n editor.registerCommand(\n KEY_ARROW_UP_COMMAND,\n (event) => {\n // CASE 1: Node selection\n const selection = $getSelection()\n if ($isNodeSelection(selection)) {\n const prevSibling = selection.getNodes()[0]?.getPreviousSibling()\n if ($isDecoratorNode(prevSibling)) {\n const element = $getEditor().getElementByKey(prevSibling.getKey())\n if (element) {\n $selectDecorator({ element, node: prevSibling })\n event.preventDefault()\n return true\n }\n return false\n }\n if (!$isElementNode(prevSibling)) {\n return false\n }\n const lastDescendant = prevSibling.getLastDescendant() ?? prevSibling\n if (!lastDescendant) {\n return false\n }\n const block = $findMatchingParent(lastDescendant, INTERNAL_$isBlock)\n block?.selectStart()\n event.preventDefault()\n return true\n }\n if (!$isRangeSelection(selection)) {\n return false\n }\n\n // CASE 2: Range selection\n // Get first selected block\n const firstPoint = selection.isBackward() ? selection.anchor : selection.focus\n const firstNode = firstPoint.getNode()\n const firstSelectedBlock = $findMatchingParent(firstNode, (node) => {\n return findFirstSiblingBlock(node) !== null\n })\n const prevBlock = firstSelectedBlock?.getPreviousSibling()\n if (!firstSelectedBlock || prevBlock !== findFirstSiblingBlock(firstSelectedBlock)) {\n return false\n }\n\n if ($isDecoratorNode(prevBlock)) {\n const prevBlockElement = $getEditor().getElementByKey(prevBlock.getKey())\n if (prevBlockElement) {\n $selectDecorator({ element: prevBlockElement, node: prevBlock })\n event.preventDefault()\n return true\n }\n }\n\n return false\n },\n COMMAND_PRIORITY_LOW,\n ),\n editor.registerCommand(\n KEY_ARROW_DOWN_COMMAND,\n (event) => {\n // CASE 1: Node selection\n const selection = $getSelection()\n if ($isNodeSelection(selection)) {\n event.preventDefault()\n const nextSibling = selection.getNodes()[0]?.getNextSibling()\n if ($isDecoratorNode(nextSibling)) {\n const element = $getEditor().getElementByKey(nextSibling.getKey())\n if (element) {\n $selectDecorator({ element, node: nextSibling })\n }\n return true\n }\n if (!$isElementNode(nextSibling)) {\n return true\n }\n const firstDescendant = nextSibling.getFirstDescendant() ?? nextSibling\n if (!firstDescendant) {\n return true\n }\n const block = $findMatchingParent(firstDescendant, INTERNAL_$isBlock)\n block?.selectEnd()\n event.preventDefault()\n return true\n }\n if (!$isRangeSelection(selection)) {\n return false\n }\n\n // CASE 2: Range selection\n // Get last selected block\n const lastPoint = selection.isBackward() ? selection.anchor : selection.focus\n const lastNode = lastPoint.getNode()\n const lastSelectedBlock = $findMatchingParent(lastNode, (node) => {\n return findLaterSiblingBlock(node) !== null\n })\n const nextBlock = lastSelectedBlock?.getNextSibling()\n if (!lastSelectedBlock || nextBlock !== findLaterSiblingBlock(lastSelectedBlock)) {\n return false\n }\n\n if ($isDecoratorNode(nextBlock)) {\n const nextBlockElement = $getEditor().getElementByKey(nextBlock.getKey())\n if (nextBlockElement) {\n $selectDecorator({ element: nextBlockElement, node: nextBlock })\n event.preventDefault()\n return true\n }\n }\n\n return false\n },\n COMMAND_PRIORITY_LOW,\n ),\n )\n }, [editor])\n\n return null\n}\n\nfunction $getDecoratorByMouseEvent(\n event: MouseEvent,\n): { element: HTMLElement; node: DecoratorNode<unknown> } | undefined {\n if (!(event.target instanceof HTMLElement)) {\n return undefined\n }\n const element = event.target.closest('[data-lexical-decorator=\"true\"]')\n if (!(element instanceof HTMLElement)) {\n return undefined\n }\n const node = $getNearestNodeFromDOMNode(element)\n return $isDecoratorNode(node) ? { element, node } : undefined\n}\n\nfunction $getSelectedDecorator() {\n const selection = $getSelection()\n if (!$isNodeSelection(selection)) {\n return undefined\n }\n const nodes = selection.getNodes()\n if (nodes.length !== 1) {\n return undefined\n }\n const node = nodes[0]\n return $isDecoratorNode(node) ? node : undefined\n}\n\nfunction $selectDecorator({\n element,\n node,\n}: {\n element: HTMLElement\n node: DecoratorNode<unknown>\n}) {\n document.querySelector('.decorator-selected')?.classList.remove('decorator-selected')\n const selection = $createNodeSelection()\n selection.add(node.getKey())\n $setSelection(selection)\n element.scrollIntoView({ behavior: 'smooth', block: 'nearest' })\n element.classList.add('decorator-selected')\n}\n\n/**\n * Copied from https://github.com/facebook/lexical/blob/main/packages/lexical/src/LexicalUtils.ts\n *\n * This function returns true for a DecoratorNode that is not inline OR\n * an ElementNode that is:\n * - not a root or shadow root\n * - not inline\n * - can't be empty\n * - has no children or an inline first child\n */\nexport function INTERNAL_$isBlock(node: LexicalNode): node is DecoratorNode<unknown> | ElementNode {\n if ($isDecoratorNode(node) && !node.isInline()) {\n return true\n }\n if (!$isElementNode(node) || $isRootOrShadowRoot(node)) {\n return false\n }\n\n const firstChild = node.getFirstChild()\n const isLeafElement =\n firstChild === null ||\n $isLineBreakNode(firstChild) ||\n $isTextNode(firstChild) ||\n firstChild.isInline()\n\n return !node.isInline() && node.canBeEmpty() !== false && isLeafElement\n}\n\nfunction findLaterSiblingBlock(node: LexicalNode): LexicalNode | null {\n let current = node.getNextSibling()\n while (current !== null) {\n if (INTERNAL_$isBlock(current)) {\n return current\n }\n current = current.getNextSibling()\n }\n return null\n}\n\nfunction findFirstSiblingBlock(node: LexicalNode): LexicalNode | null {\n let current = node.getPreviousSibling()\n while (current !== null) {\n if (INTERNAL_$isBlock(current)) {\n return current\n }\n current = current.getPreviousSibling()\n }\n return null\n}\n"],"mappings":"AAAA;;AAAA,SAAAA,CAAA,IAAAC,EAAA;AAIA,SAASC,yBAAyB,QAAQ;AAC1C,SAASC,mBAA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AQzD,cAAc;EAClC;EACA,OAAO;AACT;AAEA,SAASmC,sBAAsBd,IAAiB;EAC9C,IAAIoC,OAAA,GAAUpC,IAAA,CAAKK,kBAAkB;EACrC,OAAO+B,OAAA,KAAY,MAAM;IACvB,IAAIlD,iBAAA,CAAkBkD,OAAA,GAAU;MAC9B,OAAOA,OAAA;IACT;IACAA,OAAA,GAAUA,OAAA,CAAQ/B,kBAAkB;EACtC;EACA,OAAO;AACT","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["c","_c","useLexicalComposerContext","useTranslation","$createParagraphNode","$getRoot","React","useEditorConfigContext","AddIcon","baseClass","InsertParagraphAtEndPlugin","$","editor","editorConfig","t","admin","hideInsertParagraphAtEnd","t0","update","_temp","onClick","t1","_jsx","className","type","children","size","paragraphNode","append","select"],"sources":["../../../../src/lexical/plugins/InsertParagraphAtEnd/index.tsx"],"sourcesContent":["'use client'\n\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext'\nimport { useTranslation } from '@payloadcms/ui'\nimport { $createParagraphNode, $getRoot } from 'lexical'\nimport React from 'react'\n\nimport './index.css'\nimport { useEditorConfigContext } from '../../config/client/EditorConfigProvider.js'\nimport { AddIcon } from '../../ui/icons/Add/index.js'\nconst baseClass = 'insert-paragraph-at-end'\n\nexport const InsertParagraphAtEndPlugin: React.FC = () => {\n const [editor] = useLexicalComposerContext()\n const { editorConfig } = useEditorConfigContext()\n const { t } = useTranslation<{}, string>()\n\n if (editorConfig?.admin?.hideInsertParagraphAtEnd) {\n return null\n }\n\n const onClick = () => {\n editor.update(() => {\n const paragraphNode = $createParagraphNode()\n $getRoot().append(paragraphNode)\n paragraphNode.select()\n })\n }\n\n return (\n <button\n aria-label={t('lexical:general:insertParagraph')}\n className={baseClass}\n onClick={onClick}\n type=\"button\"\n >\n <span className={`${baseClass}-inside`}>\n <AddIcon size={16} />\n </span>\n </button>\n )\n}\n"],"mappings":"AAAA;;AAAA,SAAAA,CAAA,IAAAC,EAAA;;AAEA,SAASC,yBAAyB,QAAQ;AAC1C,SAASC,cAAc,QAAQ;AAC/B,SAASC,oBAAoB,EAAEC,QAAQ,QAAQ;AAC/C,OAAOC,KAAA,MAAW;AAElB,OAAO;AACP,SAASC,sBAAsB,QAAQ;AACvC,SAASC,OAAO,QAAQ;AACxB,MAAMC,SAAA,GAAY;AAElB,OAAO,MAAMC,0BAAA,GAAuCA,CAAA;EAAA,MAAAC,CAAA,GAAAV,EAAA;EAClD,OAAAW,MAAA,IAAiBV,yBAAA;EACjB;IAAAW;EAAA,IAAyBN,sBAAA;EACzB;IAAAO;EAAA,IAAcX,cAAA;
|
|
1
|
+
{"version":3,"file":"index.js","names":["c","_c","useLexicalComposerContext","useTranslation","$createParagraphNode","$getRoot","React","useEditorConfigContext","AddIcon","baseClass","InsertParagraphAtEndPlugin","$","editor","editorConfig","t","admin","hideInsertParagraphAtEnd","t0","update","_temp","onClick","t1","_jsx","className","type","children","size","paragraphNode","append","select"],"sources":["../../../../src/lexical/plugins/InsertParagraphAtEnd/index.tsx"],"sourcesContent":["'use client'\n\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext'\nimport { useTranslation } from '@payloadcms/ui'\nimport { $createParagraphNode, $getRoot } from 'lexical'\nimport React from 'react'\n\nimport './index.css'\nimport { useEditorConfigContext } from '../../config/client/EditorConfigProvider.js'\nimport { AddIcon } from '../../ui/icons/Add/index.js'\nconst baseClass = 'insert-paragraph-at-end'\n\nexport const InsertParagraphAtEndPlugin: React.FC = () => {\n const [editor] = useLexicalComposerContext()\n const { editorConfig } = useEditorConfigContext()\n const { t } = useTranslation<{}, string>()\n\n if (editorConfig?.admin?.hideInsertParagraphAtEnd) {\n return null\n }\n\n const onClick = () => {\n editor.update(() => {\n const paragraphNode = $createParagraphNode()\n $getRoot().append(paragraphNode)\n paragraphNode.select()\n })\n }\n\n return (\n <button\n aria-label={t('lexical:general:insertParagraph')}\n className={baseClass}\n onClick={onClick}\n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B,oBAAA;EACtBC,QAAA,GAAAuB,MAAiB,CAACD,aAAA;EAClBA,aAAA,CAAAE,MAAoB;AAAA","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["c","_c","registerMarkdownShortcuts","useLexicalComposerContext","React","useEditorConfigContext","MarkdownShortcutPlugin","$","editorConfig","editor","t0","t1","features","markdownTransformers","useEffect"],"sources":["../../../../src/lexical/plugins/MarkdownShortcut/index.tsx"],"sourcesContent":["'use client'\n\nimport { registerMarkdownShortcuts } from '@lexical/markdown'\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext'\nimport * as React from 'react'\n\nimport { useEditorConfigContext } from '../../config/client/EditorConfigProvider.js'\n\nexport const MarkdownShortcutPlugin: React.FC = () => {\n const { editorConfig } = useEditorConfigContext()\n const [editor] = useLexicalComposerContext()\n\n React.useEffect(() => {\n return registerMarkdownShortcuts(editor, editorConfig.features.markdownTransformers ?? [])\n }, [editor, editorConfig.features.markdownTransformers])\n\n return null\n}\n"],"mappings":"AAAA;;AAAA,SAAAA,CAAA,IAAAC,EAAA;AAEA,SAASC,yBAAyB,QAAQ;AAC1C,SAASC,yBAAyB,QAAQ;AAC1C,YAAYC,KAAA,MAAW;AAEvB,SAASC,sBAAsB,QAAQ;AAEvC,OAAO,MAAMC,sBAAA,GAAmCA,CAAA;EAAA,MAAAC,CAAA,GAAAN,EAAA;EAC9C;IAAAO;EAAA,IAAyBH,sBAAA;EACzB,OAAAI,MAAA,IAAiBN,yBAAA;EAAA,IAAAO,EAAA;EAAA,IAAAC,EAAA;EAAA,IAAAJ,CAAA,QAAAE,MAAA,IAAAF,CAAA,QAAAC,YAAA,CAAAI,QAAA,CAAAC,oBAAA;IAEDH,EAAA,GAAAA,CAAA,KACPR,yBAAA,CAA0BO,MAAA,EAAQD,YAAA,CAAAI,
|
|
1
|
+
{"version":3,"file":"index.js","names":["c","_c","registerMarkdownShortcuts","useLexicalComposerContext","React","useEditorConfigContext","MarkdownShortcutPlugin","$","editorConfig","editor","t0","t1","features","markdownTransformers","useEffect"],"sources":["../../../../src/lexical/plugins/MarkdownShortcut/index.tsx"],"sourcesContent":["'use client'\n\nimport { registerMarkdownShortcuts } from '@lexical/markdown'\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext'\nimport * as React from 'react'\n\nimport { useEditorConfigContext } from '../../config/client/EditorConfigProvider.js'\n\nexport const MarkdownShortcutPlugin: React.FC = () => {\n const { editorConfig } = useEditorConfigContext()\n const [editor] = useLexicalComposerContext()\n\n React.useEffect(() => {\n return registerMarkdownShortcuts(editor, editorConfig.features.markdownTransformers ?? [])\n }, [editor, editorConfig.features.markdownTransformers])\n\n return null\n}\n"],"mappings":"AAAA;;AAAA,SAAAA,CAAA,IAAAC,EAAA;AAEA,SAASC,yBAAyB,QAAQ;AAC1C,SAASC,yBAAyB,QAAQ;AAC1C,YAAYC,KAAA,MAAW;AAEvB,SAASC,sBAAsB,QAAQ;AAEvC,OAAO,MAAMC,sBAAA,GAAmCA,CAAA;EAAA,MAAAC,CAAA,GAAAN,EAAA;EAC9C;IAAAO;EAAA,IAAyBH,sBAAA;EACzB,OAAAI,MAAA,IAAiBN,yBAAA;EAAA,IAAAO,EAAA;EAAA,IAAAC,EAAA;EAAA,IAAAJ,CAAA,QAAAE,MAAA,IAAAF,CAAA,QAAAC,YAAA,CAAAI,QAAA,CAAAC,oBAAA;IAEDH,EAAA,GAAAA,CAAA,KACPR,yBAAA,CAA0BO,MAAA,EAAQD,YAAA,CAAAI,QAAqB,CAAAC,oBAA2B,IAAhD,EAAgD,CAC3F;IAAGF,EAAA,IAACF,MAAA,EAAQD,YAAA,CAAAI,QAAqB,CAAAC,oBAAqB,CAAC;IAAAN,CAAA,MAAAE,MAAA;IAAAF,CAAA,MAAAC,YAAA,CAAAI,QAAA,CAAAC,oBAAA;IAAAN,CAAA,MAAAG,EAAA;IAAAH,CAAA,MAAAI,EAAA;EAAA;IAAAD,EAAA,GAAAH,CAAA;IAAAI,EAAA,GAAAJ,CAAA;EAAA;EAFvDH,KAAA,CAAAU,SAAe,CAACJ,EAEhB,EAAGC,EAAoD;EAAA,OAEhD;AAAA,CACT","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["c","_c","useLexicalComposerContext","$getRoot","useEffect","useRichTextView","clearEditorNodeViews","registerEditorNodeViews","refreshBlockDecorators","editor","update","walk","node","type","getType","markDirty","getChildren","child","NodeViewOverridePlugin","$","currentView","views","t0","t1","default","nodes"],"sources":["../../../../src/lexical/plugins/NodeViewOverridePlugin/index.tsx"],"sourcesContent":["'use client'\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext.js'\nimport { $getRoot, type LexicalNode } from 'lexical'\nimport { useEffect } from 'react'\n\nimport { useRichTextView } from '../../../field/RichTextViewProvider.js'\nimport { clearEditorNodeViews, registerEditorNodeViews } from '../../nodes/index.js'\n\n// `LexicalComposer` re-mounts with a new `editor` whenever `currentView` changes,\n// so decorator nodes run their initial `decorate()` before this effect registers the view's overrides.\n// Mark existing block decorators dirty after registering so they re-decorate with the resolved custom `Block` component.\nfunction refreshBlockDecorators(editor: ReturnType<typeof useLexicalComposerContext>[0]): void {\n editor.update(() => {\n const walk = (node: LexicalNode): void => {\n const type = node.getType()\n if (type === 'block' || type === 'inlineBlock') {\n node.markDirty()\n }\n if ('getChildren' in node && typeof node.getChildren === 'function') {\n for (const child of node.getChildren() as LexicalNode[]) {\n walk(child)\n }\n }\n }\n walk($getRoot())\n })\n}\n\nexport function NodeViewOverridePlugin(): null {\n const [editor] = useLexicalComposerContext()\n const { currentView, views } = useRichTextView()\n\n useEffect(() => {\n if (!views) {\n return\n }\n\n if (currentView === 'default') {\n if (views.default) {\n registerEditorNodeViews(editor, views.default?.nodes)\n } else {\n clearEditorNodeViews(editor)\n }\n } else if (views[currentView]) {\n clearEditorNodeViews(editor)\n registerEditorNodeViews(editor, views[currentView]?.nodes)\n }\n\n refreshBlockDecorators(editor)\n }, [editor, views, currentView])\n\n return null\n}\n"],"mappings":"AAAA;;AAAA,SAAAA,CAAA,IAAAC,EAAA;AACA,SAASC,yBAAyB,QAAQ;AAC1C,SAASC,QAAQ,QAA0B;AAC3C,SAASC,SAAS,QAAQ;AAE1B,SAASC,eAAe,QAAQ;AAChC,SAASC,oBAAoB,EAAEC,uBAAuB,QAAQ;AAE9D;AACA;AACA;AACA,SAASC,uBAAuBC,MAAuD;EACrFA,MAAA,CAAOC,MAAM,CAAC;IACZ,MAAMC,IAAA,GAAQC,IAAA;MACZ,MAAMC,IAAA,GAAOD,IAAA,CAAKE,OAAO;MACzB,IAAID,IAAA,KAAS,WAAWA,IAAA,KAAS,eAAe;QAC9CD,IAAA,CAAKG,SAAS;MAChB;MACA,IAAI,iBAAiBH,IAAA,IAAQ,OAAOA,IAAA,CAAKI,WAAW,KAAK,YAAY;QACnE,KAAK,MAAMC,KAAA,IAASL,IAAA,CAAKI,WAAW,IAAqB;UACvDL,IAAA,CAAKM,KAAA;QACP;MACF;IACF;IACAN,IAAA,CAAKR,QAAA;EACP;AACF;AAEA,OAAO,SAAAe,uBAAA;EAAA,MAAAC,CAAA,GAAAlB,EAAA;EACL,OAAAQ,MAAA,IAAiBP,yBAAA;EACjB;IAAAkB,WAAA;IAAAC;EAAA,IAA+BhB,eAAA;EAAA,IAAAiB,EAAA;EAAA,IAAAC,EAAA;EAAA,IAAAJ,CAAA,QAAAC,WAAA,IAAAD,CAAA,QAAAV,MAAA,IAAAU,CAAA,QAAAE,KAAA;IAErBC,EAAA,GAAAA,CAAA;
|
|
1
|
+
{"version":3,"file":"index.js","names":["c","_c","useLexicalComposerContext","$getRoot","useEffect","useRichTextView","clearEditorNodeViews","registerEditorNodeViews","refreshBlockDecorators","editor","update","walk","node","type","getType","markDirty","getChildren","child","NodeViewOverridePlugin","$","currentView","views","t0","t1","default","nodes"],"sources":["../../../../src/lexical/plugins/NodeViewOverridePlugin/index.tsx"],"sourcesContent":["'use client'\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext.js'\nimport { $getRoot, type LexicalNode } from 'lexical'\nimport { useEffect } from 'react'\n\nimport { useRichTextView } from '../../../field/RichTextViewProvider.js'\nimport { clearEditorNodeViews, registerEditorNodeViews } from '../../nodes/index.js'\n\n// `LexicalComposer` re-mounts with a new `editor` whenever `currentView` changes,\n// so decorator nodes run their initial `decorate()` before this effect registers the view's overrides.\n// Mark existing block decorators dirty after registering so they re-decorate with the resolved custom `Block` component.\nfunction refreshBlockDecorators(editor: ReturnType<typeof useLexicalComposerContext>[0]): void {\n editor.update(() => {\n const walk = (node: LexicalNode): void => {\n const type = node.getType()\n if (type === 'block' || type === 'inlineBlock') {\n node.markDirty()\n }\n if ('getChildren' in node && typeof node.getChildren === 'function') {\n for (const child of node.getChildren() as LexicalNode[]) {\n walk(child)\n }\n }\n }\n walk($getRoot())\n })\n}\n\nexport function NodeViewOverridePlugin(): null {\n const [editor] = useLexicalComposerContext()\n const { currentView, views } = useRichTextView()\n\n useEffect(() => {\n if (!views) {\n return\n }\n\n if (currentView === 'default') {\n if (views.default) {\n registerEditorNodeViews(editor, views.default?.nodes)\n } else {\n clearEditorNodeViews(editor)\n }\n } else if (views[currentView]) {\n clearEditorNodeViews(editor)\n registerEditorNodeViews(editor, views[currentView]?.nodes)\n }\n\n refreshBlockDecorators(editor)\n }, [editor, views, currentView])\n\n return null\n}\n"],"mappings":"AAAA;;AAAA,SAAAA,CAAA,IAAAC,EAAA;AACA,SAASC,yBAAyB,QAAQ;AAC1C,SAASC,QAAQ,QAA0B;AAC3C,SAASC,SAAS,QAAQ;AAE1B,SAASC,eAAe,QAAQ;AAChC,SAASC,oBAAoB,EAAEC,uBAAuB,QAAQ;AAE9D;AACA;AACA;AACA,SAASC,uBAAuBC,MAAuD;EACrFA,MAAA,CAAOC,MAAM,CAAC;IACZ,MAAMC,IAAA,GAAQC,IAAA;MACZ,MAAMC,IAAA,GAAOD,IAAA,CAAKE,OAAO;MACz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