@payloadcms/richtext-lexical 3.16.0 → 3.16.1-canary.9004205

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (123) hide show
  1. package/dist/exports/client/Field-F5XP4HL4.js +2 -0
  2. package/dist/exports/client/Field-F5XP4HL4.js.map +7 -0
  3. package/dist/exports/client/{RelationshipComponent-N4C5MX3U.js → RelationshipComponent-AAFBGDZ5.js} +2 -2
  4. package/dist/exports/client/bundled.css +1 -1
  5. package/dist/exports/client/chunk-3LGFOM34.js +2 -0
  6. package/dist/exports/client/chunk-3LGFOM34.js.map +7 -0
  7. package/dist/exports/client/chunk-7XFF5VOE.js +12 -0
  8. package/dist/exports/client/chunk-7XFF5VOE.js.map +7 -0
  9. package/dist/exports/client/{chunk-JRIUM7SP.js → chunk-CGFQWJ56.js} +2 -2
  10. package/dist/exports/client/{chunk-422FRG7Z.js → chunk-XI5JV5QT.js} +2 -2
  11. package/dist/exports/client/{chunk-HTQL4HTC.js → chunk-XXNV22UZ.js} +2 -2
  12. package/dist/exports/client/{component-TYBPYPLA.js → component-NUQPQ2MC.js} +2 -2
  13. package/dist/exports/client/componentInline-KDFOWBR5.js +2 -0
  14. package/dist/exports/client/index.js +9 -11
  15. package/dist/exports/client/index.js.map +4 -4
  16. package/dist/features/blocks/client/getBlockImageComponent.d.ts +3 -0
  17. package/dist/features/blocks/client/getBlockImageComponent.d.ts.map +1 -0
  18. package/dist/features/blocks/client/getBlockImageComponent.js +18 -0
  19. package/dist/features/blocks/client/getBlockImageComponent.js.map +1 -0
  20. package/dist/features/blocks/client/index.d.ts.map +1 -1
  21. package/dist/features/blocks/client/index.js +4 -3
  22. package/dist/features/blocks/client/index.js.map +1 -1
  23. package/dist/features/blocks/client/markdownTransformer.d.ts.map +1 -1
  24. package/dist/features/blocks/client/markdownTransformer.js +1 -2
  25. package/dist/features/blocks/client/markdownTransformer.js.map +1 -1
  26. package/dist/features/blocks/server/markdownTransformer.d.ts.map +1 -1
  27. package/dist/features/blocks/server/markdownTransformer.js +1 -2
  28. package/dist/features/blocks/server/markdownTransformer.js.map +1 -1
  29. package/dist/features/debug/testRecorder/client/plugin/index.js +4 -4
  30. package/dist/features/debug/testRecorder/client/plugin/index.js.map +1 -1
  31. package/dist/features/experimental_table/client/plugins/TableActionMenuPlugin/index.d.ts.map +1 -1
  32. package/dist/features/experimental_table/client/plugins/TableActionMenuPlugin/index.js +84 -41
  33. package/dist/features/experimental_table/client/plugins/TableActionMenuPlugin/index.js.map +1 -1
  34. package/dist/features/experimental_table/client/plugins/TableCellResizerPlugin/index.d.ts.map +1 -1
  35. package/dist/features/experimental_table/client/plugins/TableCellResizerPlugin/index.js +37 -41
  36. package/dist/features/experimental_table/client/plugins/TableCellResizerPlugin/index.js.map +1 -1
  37. package/dist/features/experimental_table/client/plugins/TableHoverActionsPlugin/index.d.ts.map +1 -1
  38. package/dist/features/experimental_table/client/plugins/TableHoverActionsPlugin/index.js +29 -23
  39. package/dist/features/experimental_table/client/plugins/TableHoverActionsPlugin/index.js.map +1 -1
  40. package/dist/features/experimental_table/client/plugins/TablePlugin/index.d.ts.map +1 -1
  41. package/dist/features/experimental_table/client/plugins/TablePlugin/index.js +2 -1
  42. package/dist/features/experimental_table/client/plugins/TablePlugin/index.js.map +1 -1
  43. package/dist/features/experimental_table/markdownTransformer.d.ts.map +1 -1
  44. package/dist/features/experimental_table/markdownTransformer.js +1 -2
  45. package/dist/features/experimental_table/markdownTransformer.js.map +1 -1
  46. package/dist/features/link/client/plugins/floatingLinkEditor/LinkEditor/index.d.ts.map +1 -1
  47. package/dist/features/link/client/plugins/floatingLinkEditor/LinkEditor/index.js +9 -9
  48. package/dist/features/link/client/plugins/floatingLinkEditor/LinkEditor/index.js.map +1 -1
  49. package/dist/features/toolbars/inline/client/Toolbar/index.d.ts.map +1 -1
  50. package/dist/features/toolbars/inline/client/Toolbar/index.js +3 -3
  51. package/dist/features/toolbars/inline/client/Toolbar/index.js.map +1 -1
  52. package/dist/features/typesClient.d.ts +2 -2
  53. package/dist/features/typesClient.d.ts.map +1 -1
  54. package/dist/features/typesClient.js.map +1 -1
  55. package/dist/field/Field.d.ts.map +1 -1
  56. package/dist/field/Field.js +17 -2
  57. package/dist/field/Field.js.map +1 -1
  58. package/dist/field/bundled.css +1 -1
  59. package/dist/field/rscEntry.d.ts.map +1 -1
  60. package/dist/field/rscEntry.js +13 -1
  61. package/dist/field/rscEntry.js.map +1 -1
  62. package/dist/index.d.ts +1 -1
  63. package/dist/index.d.ts.map +1 -1
  64. package/dist/index.js +1 -1
  65. package/dist/index.js.map +1 -1
  66. package/dist/lexical/LexicalEditor.d.ts +1 -0
  67. package/dist/lexical/LexicalEditor.d.ts.map +1 -1
  68. package/dist/lexical/LexicalEditor.js +32 -56
  69. package/dist/lexical/LexicalEditor.js.map +1 -1
  70. package/dist/lexical/LexicalProvider.d.ts +1 -0
  71. package/dist/lexical/LexicalProvider.d.ts.map +1 -1
  72. package/dist/lexical/LexicalProvider.js +8 -1
  73. package/dist/lexical/LexicalProvider.js.map +1 -1
  74. package/dist/lexical/config/client/EditorConfigProvider.d.ts +1 -0
  75. package/dist/lexical/config/client/EditorConfigProvider.d.ts.map +1 -1
  76. package/dist/lexical/config/client/EditorConfigProvider.js +5 -2
  77. package/dist/lexical/config/client/EditorConfigProvider.js.map +1 -1
  78. package/dist/lexical/config/client/sanitize.d.ts +2 -2
  79. package/dist/lexical/config/client/sanitize.d.ts.map +1 -1
  80. package/dist/lexical/config/client/sanitize.js.map +1 -1
  81. package/dist/lexical/config/types.d.ts +2 -2
  82. package/dist/lexical/config/types.d.ts.map +1 -1
  83. package/dist/lexical/config/types.js.map +1 -1
  84. package/dist/lexical/plugins/InsertParagraphAtEnd/index.d.ts +4 -0
  85. package/dist/lexical/plugins/InsertParagraphAtEnd/index.d.ts.map +1 -0
  86. package/dist/lexical/plugins/InsertParagraphAtEnd/index.js +55 -0
  87. package/dist/lexical/plugins/InsertParagraphAtEnd/index.js.map +1 -0
  88. package/dist/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/index.d.ts.map +1 -1
  89. package/dist/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/index.js +2 -2
  90. package/dist/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/index.js.map +1 -1
  91. package/dist/lexical/plugins/TextPlugin/index.js +0 -4
  92. package/dist/lexical/plugins/TextPlugin/index.js.map +1 -1
  93. package/dist/lexical/theme/EditorTheme.d.ts.map +1 -1
  94. package/dist/lexical/theme/EditorTheme.js +2 -4
  95. package/dist/lexical/theme/EditorTheme.js.map +1 -1
  96. package/dist/packages/@lexical/markdown/MarkdownTransformers.d.ts +1 -1
  97. package/dist/packages/@lexical/markdown/MarkdownTransformers.d.ts.map +1 -1
  98. package/dist/packages/@lexical/markdown/MarkdownTransformers.js +26 -8
  99. package/dist/packages/@lexical/markdown/MarkdownTransformers.js.map +1 -1
  100. package/dist/packages/@lexical/markdown/index.d.ts.map +1 -1
  101. package/dist/packages/@lexical/markdown/index.js +1 -1
  102. package/dist/packages/@lexical/markdown/index.js.map +1 -1
  103. package/dist/types.d.ts +10 -3
  104. package/dist/types.d.ts.map +1 -1
  105. package/dist/types.js.map +1 -1
  106. package/package.json +28 -28
  107. package/dist/exports/client/Field-VBZQOYLK.js +0 -2
  108. package/dist/exports/client/Field-VBZQOYLK.js.map +0 -7
  109. package/dist/exports/client/chunk-BB2LUWM3.js +0 -2
  110. package/dist/exports/client/chunk-BB2LUWM3.js.map +0 -7
  111. package/dist/exports/client/chunk-PZPNMC5Y.js +0 -12
  112. package/dist/exports/client/chunk-PZPNMC5Y.js.map +0 -7
  113. package/dist/exports/client/componentInline-VR5HF5DY.js +0 -2
  114. package/dist/utilities/jsx/lexicalMarkdownCopy.d.ts +0 -11
  115. package/dist/utilities/jsx/lexicalMarkdownCopy.d.ts.map +0 -1
  116. package/dist/utilities/jsx/lexicalMarkdownCopy.js +0 -66
  117. package/dist/utilities/jsx/lexicalMarkdownCopy.js.map +0 -1
  118. /package/dist/exports/client/{RelationshipComponent-N4C5MX3U.js.map → RelationshipComponent-AAFBGDZ5.js.map} +0 -0
  119. /package/dist/exports/client/{chunk-JRIUM7SP.js.map → chunk-CGFQWJ56.js.map} +0 -0
  120. /package/dist/exports/client/{chunk-422FRG7Z.js.map → chunk-XI5JV5QT.js.map} +0 -0
  121. /package/dist/exports/client/{chunk-HTQL4HTC.js.map → chunk-XXNV22UZ.js.map} +0 -0
  122. /package/dist/exports/client/{component-TYBPYPLA.js.map → component-NUQPQ2MC.js.map} +0 -0
  123. /package/dist/exports/client/{componentInline-VR5HF5DY.js.map → componentInline-KDFOWBR5.js.map} +0 -0
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["c","_c","useLexicalComposerContext","TEXT_TYPE_TO_FORMAT","TextNode","useEffect","TextPlugin","t0","$","features","editor","t1","enabledFormats","disabledFormats","getDisabledFormats","length","registerNodeTransform","textNode","forEach","disabledFormat","hasFormat","toggleFormat","t2","highlight","allFormats","Object","keys","enabledSet","Set","filter","format","has"],"sources":["../../../../src/lexical/plugins/TextPlugin/index.tsx"],"sourcesContent":["'use client'\nimport type { TextFormatType } from 'lexical'\n\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext'\nimport { TEXT_TYPE_TO_FORMAT, TextNode } from 'lexical'\nimport { useEffect } from 'react'\n\nimport type { SanitizedClientFeatures } from '../../../features/typesClient.js'\n\nexport function TextPlugin({ features }: { features: SanitizedClientFeatures }) {\n const [editor] = useLexicalComposerContext()\n\n useEffect(() => {\n const disabledFormats = getDisabledFormats(features.enabledFormats as TextFormatType[])\n if (disabledFormats.length === 0) {\n return\n }\n // Ideally override the TextNode with our own TextNode (changing its setFormat or toggleFormat methods),\n // would be more performant. If we find a noticeable perf regression we can switch to that option.\n // Overriding the FORMAT_TEXT_COMMAND and PASTE_COMMAND commands is not an option I considered because\n // there might be other forms of mutation that we might not be considering. For example:\n // browser extensions or Payload/Lexical plugins that have their own commands.\n return editor.registerNodeTransform(TextNode, (textNode) => {\n disabledFormats.forEach((disabledFormat) => {\n if (textNode.hasFormat(disabledFormat)) {\n textNode.toggleFormat(disabledFormat)\n }\n })\n })\n }, [editor, features])\n\n return null\n}\n\nfunction getDisabledFormats(enabledFormats: TextFormatType[]): TextFormatType[] {\n // not sure why Lexical added highlight as TextNode format.\n // see https://github.com/facebook/lexical/pull/3583\n // We are going to implement it in other way to support multiple colors\n delete TEXT_TYPE_TO_FORMAT.highlight\n const allFormats = Object.keys(TEXT_TYPE_TO_FORMAT) as TextFormatType[]\n const enabledSet = new Set(enabledFormats)\n\n return allFormats.filter((format) => !enabledSet.has(format))\n}\n"],"mappings":"AAAA;;AAAA,SAAAA,CAAA,IAAAC,EAAA;AAGA,SAASC,yBAAyB,QAAQ;AAC1C,SAASC,mBAAmB,EAAEC,QAAQ,QAAQ;AAC9C,SAASC,SAAS,QAAQ;AAI1B,OAAO,SAAAC,WAAAC,EAAA;EAAA,MAAAC,CAAA,GAAAP,EAAA;EAAoB;IAAAQ;EAAA,IAAAF,EAAmD;EAC5E,OAAAG,MAAA,IAAiBR,yBAAA;EAAA,IAAAS,EAAA;EAAA,IAAAH,CAAA,QAAAE,MAAA,IAAAF,CAAA,QAAAC,QAAA,CAAAG,cAAA;IAEPD,EAAA,GAAAA,CAAA;MACR,MAAAE,eAAA,GAAwBC,kBAAA,CAAmBL,QAAA,CAAAG,cAAuB;MAAA,IAC9DC,eAAA,CAAAE,MAAA,MAA2B;QAAA;MAAA;MAAA,OAQxBL,MAAA,CAAAM,qBAAA,CAAAZ,QAAA,EAAAa,QAAA;QACLJ,eAAA,CAAAK,OAAA,CAAAC,cAAA;UAAA,IACMF,QAAA,CAAAG,SAAA,CAAmBD,cAAA;YACrBF,QAAA,CAAAI,YAAA,CAAsBF,cAAA;UAAA;QAAA,CAE1B;MAAA,CACF;IAAA;IACFX,CAAA,MAAAE,MAAA;IAAAF,CAAA,MAAAC,QAAA,CAAAG,cAAA;IAAAJ,CAAA,MAAAG,EAAA;EAAA;IAAAA,EAAA,GAAAH,CAAA;EAAA;EAAA,IAAAc,EAAA;EAAA,IAAAd,CAAA,QAAAE,MAAA,IAAAF,CAAA,QAAAC,QAAA;IAAGa,EAAA,IAACZ,MAAA,EAAQD,QAAA;IAASD,CAAA,MAAAE,MAAA;IAAAF,CAAA,MAAAC,QAAA;IAAAD,CAAA,MAAAc,EAAA;EAAA;IAAAA,EAAA,GAAAd,CAAA;EAAA;EAjBrBH,SAAA,CAAUM,EAiBV,EAAGW,EAAkB;EAAA;AAAA;AAKvB,SAASR,mBAAmBF,cAAgC;EAC1D;EACA;EACA;EACA,OAAOT,mBAAA,CAAoBoB,SAAS;EACpC,MAAMC,UAAA,GAAaC,MAAA,CAAOC,IAAI,CAACvB,mBAAA;EAC/B,MAAMwB,UAAA,GAAa,IAAIC,GAAA,CAAIhB,cAAA;EAE3B,OAAOY,UAAA,CAAWK,MAAM,CAAEC,MAAA,IAAW,CAACH,UAAA,CAAWI,GAAG,CAACD,MAAA;AACvD","ignoreList":[]}
1
+ {"version":3,"file":"index.js","names":["c","_c","useLexicalComposerContext","TEXT_TYPE_TO_FORMAT","TextNode","useEffect","TextPlugin","t0","$","features","editor","t1","enabledFormats","disabledFormats","getDisabledFormats","length","registerNodeTransform","textNode","forEach","disabledFormat","hasFormat","toggleFormat","t2","allFormats","Object","keys","enabledSet","Set","filter","format","has"],"sources":["../../../../src/lexical/plugins/TextPlugin/index.tsx"],"sourcesContent":["'use client'\nimport type { TextFormatType } from 'lexical'\n\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext'\nimport { TEXT_TYPE_TO_FORMAT, TextNode } from 'lexical'\nimport { useEffect } from 'react'\n\nimport type { SanitizedClientFeatures } from '../../../features/typesClient.js'\n\nexport function TextPlugin({ features }: { features: SanitizedClientFeatures }) {\n const [editor] = useLexicalComposerContext()\n\n useEffect(() => {\n const disabledFormats = getDisabledFormats(features.enabledFormats as TextFormatType[])\n if (disabledFormats.length === 0) {\n return\n }\n // Ideally override the TextNode with our own TextNode (changing its setFormat or toggleFormat methods),\n // would be more performant. If we find a noticeable perf regression we can switch to that option.\n // Overriding the FORMAT_TEXT_COMMAND and PASTE_COMMAND commands is not an option I considered because\n // there might be other forms of mutation that we might not be considering. For example:\n // browser extensions or Payload/Lexical plugins that have their own commands.\n return editor.registerNodeTransform(TextNode, (textNode) => {\n disabledFormats.forEach((disabledFormat) => {\n if (textNode.hasFormat(disabledFormat)) {\n textNode.toggleFormat(disabledFormat)\n }\n })\n })\n }, [editor, features])\n\n return null\n}\n\nfunction getDisabledFormats(enabledFormats: TextFormatType[]): TextFormatType[] {\n const allFormats = Object.keys(TEXT_TYPE_TO_FORMAT) as TextFormatType[]\n const enabledSet = new Set(enabledFormats)\n\n return allFormats.filter((format) => !enabledSet.has(format))\n}\n"],"mappings":"AAAA;;AAAA,SAAAA,CAAA,IAAAC,EAAA;AAGA,SAASC,yBAAyB,QAAQ;AAC1C,SAASC,mBAAmB,EAAEC,QAAQ,QAAQ;AAC9C,SAASC,SAAS,QAAQ;AAI1B,OAAO,SAAAC,WAAAC,EAAA;EAAA,MAAAC,CAAA,GAAAP,EAAA;EAAoB;IAAAQ;EAAA,IAAAF,EAAmD;EAC5E,OAAAG,MAAA,IAAiBR,yBAAA;EAAA,IAAAS,EAAA;EAAA,IAAAH,CAAA,QAAAE,MAAA,IAAAF,CAAA,QAAAC,QAAA,CAAAG,cAAA;IAEPD,EAAA,GAAAA,CAAA;MACR,MAAAE,eAAA,GAAwBC,kBAAA,CAAmBL,QAAA,CAAAG,cAAuB;MAAA,IAC9DC,eAAA,CAAAE,MAAA,MAA2B;QAAA;MAAA;MAAA,OAQxBL,MAAA,CAAAM,qBAAA,CAAAZ,QAAA,EAAAa,QAAA;QACLJ,eAAA,CAAAK,OAAA,CAAAC,cAAA;UAAA,IACMF,QAAA,CAAAG,SAAA,CAAmBD,cAAA;YACrBF,QAAA,CAAAI,YAAA,CAAsBF,cAAA;UAAA;QAAA,CAE1B;MAAA,CACF;IAAA;IACFX,CAAA,MAAAE,MAAA;IAAAF,CAAA,MAAAC,QAAA,CAAAG,cAAA;IAAAJ,CAAA,MAAAG,EAAA;EAAA;IAAAA,EAAA,GAAAH,CAAA;EAAA;EAAA,IAAAc,EAAA;EAAA,IAAAd,CAAA,QAAAE,MAAA,IAAAF,CAAA,QAAAC,QAAA;IAAGa,EAAA,IAACZ,MAAA,EAAQD,QAAA;IAASD,CAAA,MAAAE,MAAA;IAAAF,CAAA,MAAAC,QAAA;IAAAD,CAAA,MAAAc,EAAA;EAAA;IAAAA,EAAA,GAAAd,CAAA;EAAA;EAjBrBH,SAAA,CAAUM,EAiBV,EAAGW,EAAkB;EAAA;AAAA;AAKvB,SAASR,mBAAmBF,cAAgC;EAC1D,MAAMW,UAAA,GAAaC,MAAA,CAAOC,IAAI,CAACtB,mBAAA;EAC/B,MAAMuB,UAAA,GAAa,IAAIC,GAAA,CAAIf,cAAA;EAE3B,OAAOW,UAAA,CAAWK,MAAM,CAAEC,MAAA,IAAW,CAACH,UAAA,CAAWI,GAAG,CAACD,MAAA;AACvD","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"EditorTheme.d.ts","sourceRoot":"","sources":["../../../src/lexical/theme/EditorTheme.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAA;AAEjD,eAAO,MAAM,kBAAkB,EAAE,kBAwGhC,CAAA"}
1
+ {"version":3,"file":"EditorTheme.d.ts","sourceRoot":"","sources":["../../../src/lexical/theme/EditorTheme.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAA;AAEjD,eAAO,MAAM,kBAAkB,EAAE,kBAsGhC,CAAA"}
@@ -76,15 +76,13 @@ export const LexicalEditorTheme = {
76
76
  tableCell: 'LexicalEditorTheme__tableCell',
77
77
  tableCellActionButton: 'LexicalEditorTheme__tableCellActionButton',
78
78
  tableCellActionButtonContainer: 'LexicalEditorTheme__tableCellActionButtonContainer',
79
- tableCellEditing: 'LexicalEditorTheme__tableCellEditing',
80
79
  tableCellHeader: 'LexicalEditorTheme__tableCellHeader',
81
- tableCellPrimarySelected: 'LexicalEditorTheme__tableCellPrimarySelected',
82
80
  tableCellResizer: 'LexicalEditorTheme__tableCellResizer',
83
81
  tableCellSelected: 'LexicalEditorTheme__tableCellSelected',
84
- tableCellSortedIndicator: 'LexicalEditorTheme__tableCellSortedIndicator',
85
- tableResizeRuler: 'LexicalEditorTheme__tableCellResizeRuler',
86
82
  tableRowStriping: 'LexicalEditorTheme__tableRowStriping',
83
+ tableScrollableWrapper: 'LexicalEditorTheme__tableScrollableWrapper',
87
84
  tableSelected: 'LexicalEditorTheme__tableSelected',
85
+ tableSelection: 'LexicalEditorTheme__tableSelection',
88
86
  text: {
89
87
  bold: 'LexicalEditorTheme__textBold',
90
88
  code: 'LexicalEditorTheme__textCode',
@@ -1 +1 @@
1
- {"version":3,"file":"EditorTheme.js","names":["LexicalEditorTheme","block","blockCursor","characterLimit","code","codeHighlight","atrule","attr","boolean","builtin","cdata","char","class","comment","constant","deleted","doctype","entity","function","important","inserted","keyword","namespace","number","operator","prolog","property","punctuation","regex","selector","string","symbol","tag","url","variable","embedBlock","base","focus","hashtag","heading","h1","h2","h3","h4","h5","h6","hr","indent","inlineImage","link","list","checklist","listitem","listitemChecked","listitemUnchecked","nested","olDepth","ul","ltr","mark","markOverlap","paragraph","quote","relationship","rtl","table","tableAddColumns","tableAddRows","tableCell","tableCellActionButton","tableCellActionButtonContainer","tableCellEditing","tableCellHeader","tableCellPrimarySelected","tableCellResizer","tableCellSelected","tableCellSortedIndicator","tableResizeRuler","tableRowStriping","tableSelected","text","bold","italic","strikethrough","subscript","superscript","underline","underlineStrikethrough","upload"],"sources":["../../../src/lexical/theme/EditorTheme.tsx"],"sourcesContent":["import type { EditorThemeClasses } from 'lexical'\n\nexport const LexicalEditorTheme: EditorThemeClasses = {\n block: 'LexicalEditorTheme__block',\n blockCursor: 'LexicalEditorTheme__blockCursor',\n characterLimit: 'LexicalEditorTheme__characterLimit',\n code: 'LexicalEditorTheme__code',\n codeHighlight: {\n atrule: 'LexicalEditorTheme__tokenAttr',\n attr: 'LexicalEditorTheme__tokenAttr',\n boolean: 'LexicalEditorTheme__tokenProperty',\n builtin: 'LexicalEditorTheme__tokenSelector',\n cdata: 'LexicalEditorTheme__tokenComment',\n char: 'LexicalEditorTheme__tokenSelector',\n class: 'LexicalEditorTheme__tokenFunction',\n 'class-name': 'LexicalEditorTheme__tokenFunction',\n comment: 'LexicalEditorTheme__tokenComment',\n constant: 'LexicalEditorTheme__tokenProperty',\n deleted: 'LexicalEditorTheme__tokenProperty',\n doctype: 'LexicalEditorTheme__tokenComment',\n entity: 'LexicalEditorTheme__tokenOperator',\n function: 'LexicalEditorTheme__tokenFunction',\n important: 'LexicalEditorTheme__tokenVariable',\n inserted: 'LexicalEditorTheme__tokenSelector',\n keyword: 'LexicalEditorTheme__tokenAttr',\n namespace: 'LexicalEditorTheme__tokenVariable',\n number: 'LexicalEditorTheme__tokenProperty',\n operator: 'LexicalEditorTheme__tokenOperator',\n prolog: 'LexicalEditorTheme__tokenComment',\n property: 'LexicalEditorTheme__tokenProperty',\n punctuation: 'LexicalEditorTheme__tokenPunctuation',\n regex: 'LexicalEditorTheme__tokenVariable',\n selector: 'LexicalEditorTheme__tokenSelector',\n string: 'LexicalEditorTheme__tokenSelector',\n symbol: 'LexicalEditorTheme__tokenProperty',\n tag: 'LexicalEditorTheme__tokenProperty',\n url: 'LexicalEditorTheme__tokenOperator',\n variable: 'LexicalEditorTheme__tokenVariable',\n },\n embedBlock: {\n base: 'LexicalEditorTheme__embedBlock',\n focus: 'LexicalEditorTheme__embedBlockFocus',\n },\n hashtag: 'LexicalEditorTheme__hashtag',\n heading: {\n h1: 'LexicalEditorTheme__h1',\n h2: 'LexicalEditorTheme__h2',\n h3: 'LexicalEditorTheme__h3',\n h4: 'LexicalEditorTheme__h4',\n h5: 'LexicalEditorTheme__h5',\n h6: 'LexicalEditorTheme__h6',\n },\n hr: 'LexicalEditorTheme__hr',\n indent: 'LexicalEditorTheme__indent',\n inlineImage: 'LexicalEditor__inline-image',\n link: 'LexicalEditorTheme__link',\n list: {\n checklist: 'LexicalEditorTheme__checklist',\n listitem: 'LexicalEditorTheme__listItem',\n listitemChecked: 'LexicalEditorTheme__listItemChecked',\n listitemUnchecked: 'LexicalEditorTheme__listItemUnchecked',\n nested: {\n listitem: 'LexicalEditorTheme__nestedListItem',\n },\n olDepth: [\n 'LexicalEditorTheme__ol1',\n 'LexicalEditorTheme__ol2',\n 'LexicalEditorTheme__ol3',\n 'LexicalEditorTheme__ol4',\n 'LexicalEditorTheme__ol5',\n ],\n ul: 'LexicalEditorTheme__ul',\n },\n ltr: 'LexicalEditorTheme__ltr',\n mark: 'LexicalEditorTheme__mark',\n markOverlap: 'LexicalEditorTheme__markOverlap',\n paragraph: 'LexicalEditorTheme__paragraph',\n quote: 'LexicalEditorTheme__quote',\n relationship: 'LexicalEditorTheme__relationship',\n rtl: 'LexicalEditorTheme__rtl',\n table: 'LexicalEditorTheme__table',\n tableAddColumns: 'LexicalEditorTheme__tableAddColumns',\n tableAddRows: 'LexicalEditorTheme__tableAddRows',\n tableCell: 'LexicalEditorTheme__tableCell',\n tableCellActionButton: 'LexicalEditorTheme__tableCellActionButton',\n tableCellActionButtonContainer: 'LexicalEditorTheme__tableCellActionButtonContainer',\n tableCellEditing: 'LexicalEditorTheme__tableCellEditing',\n tableCellHeader: 'LexicalEditorTheme__tableCellHeader',\n tableCellPrimarySelected: 'LexicalEditorTheme__tableCellPrimarySelected',\n tableCellResizer: 'LexicalEditorTheme__tableCellResizer',\n tableCellSelected: 'LexicalEditorTheme__tableCellSelected',\n tableCellSortedIndicator: 'LexicalEditorTheme__tableCellSortedIndicator',\n tableResizeRuler: 'LexicalEditorTheme__tableCellResizeRuler',\n tableRowStriping: 'LexicalEditorTheme__tableRowStriping',\n tableSelected: 'LexicalEditorTheme__tableSelected',\n text: {\n bold: 'LexicalEditorTheme__textBold',\n code: 'LexicalEditorTheme__textCode',\n italic: 'LexicalEditorTheme__textItalic',\n strikethrough: 'LexicalEditorTheme__textStrikethrough',\n subscript: 'LexicalEditorTheme__textSubscript',\n superscript: 'LexicalEditorTheme__textSuperscript',\n underline: 'LexicalEditorTheme__textUnderline',\n underlineStrikethrough: 'LexicalEditorTheme__textUnderlineStrikethrough',\n },\n upload: 'editor-upload',\n}\n"],"mappings":"AAEA,OAAO,MAAMA,kBAAA,GAAyC;EACpDC,KAAA,EAAO;EACPC,WAAA,EAAa;EACbC,cAAA,EAAgB;EAChBC,IAAA,EAAM;EACNC,aAAA,EAAe;IACbC,MAAA,EAAQ;IACRC,IAAA,EAAM;IACNC,OAAA,EAAS;IACTC,OAAA,EAAS;IACTC,KAAA,EAAO;IACPC,IAAA,EAAM;IACNC,KAAA,EAAO;IACP,cAAc;IACdC,OAAA,EAAS;IACTC,QAAA,EAAU;IACVC,OAAA,EAAS;IACTC,OAAA,EAAS;IACTC,MAAA,EAAQ;IACRC,QAAA,EAAU;IACVC,SAAA,EAAW;IACXC,QAAA,EAAU;IACVC,OAAA,EAAS;IACTC,SAAA,EAAW;IACXC,MAAA,EAAQ;IACRC,QAAA,EAAU;IACVC,MAAA,EAAQ;IACRC,QAAA,EAAU;IACVC,WAAA,EAAa;IACbC,KAAA,EAAO;IACPC,QAAA,EAAU;IACVC,MAAA,EAAQ;IACRC,MAAA,EAAQ;IACRC,GAAA,EAAK;IACLC,GAAA,EAAK;IACLC,QAAA,EAAU;EACZ;EACAC,UAAA,EAAY;IACVC,IAAA,EAAM;IACNC,KAAA,EAAO;EACT;EACAC,OAAA,EAAS;EACTC,OAAA,EAAS;IACPC,EAAA,EAAI;IACJC,EAAA,EAAI;IACJC,EAAA,EAAI;IACJC,EAAA,EAAI;IACJC,EAAA,EAAI;IACJC,EAAA,EAAI;EACN;EACAC,EAAA,EAAI;EACJC,MAAA,EAAQ;EACRC,WAAA,EAAa;EACbC,IAAA,EAAM;EACNC,IAAA,EAAM;IACJC,SAAA,EAAW;IACXC,QAAA,EAAU;IACVC,eAAA,EAAiB;IACjBC,iBAAA,EAAmB;IACnBC,MAAA,EAAQ;MACNH,QAAA,EAAU;IACZ;IACAI,OAAA,EAAS,CACP,2BACA,2BACA,2BACA,2BACA,0BACD;IACDC,EAAA,EAAI;EACN;EACAC,GAAA,EAAK;EACLC,IAAA,EAAM;EACNC,WAAA,EAAa;EACbC,SAAA,EAAW;EACXC,KAAA,EAAO;EACPC,YAAA,EAAc;EACdC,GAAA,EAAK;EACLC,KAAA,EAAO;EACPC,eAAA,EAAiB;EACjBC,YAAA,EAAc;EACdC,SAAA,EAAW;EACXC,qBAAA,EAAuB;EACvBC,8BAAA,EAAgC;EAChCC,gBAAA,EAAkB;EAClBC,eAAA,EAAiB;EACjBC,wBAAA,EAA0B;EAC1BC,gBAAA,EAAkB;EAClBC,iBAAA,EAAmB;EACnBC,wBAAA,EAA0B;EAC1BC,gBAAA,EAAkB;EAClBC,gBAAA,EAAkB;EAClBC,aAAA,EAAe;EACfC,IAAA,EAAM;IACJC,IAAA,EAAM;IACN7E,IAAA,EAAM;IACN8E,MAAA,EAAQ;IACRC,aAAA,EAAe;IACfC,SAAA,EAAW;IACXC,WAAA,EAAa;IACbC,SAAA,EAAW;IACXC,sBAAA,EAAwB;EAC1B;EACAC,MAAA,EAAQ;AACV","ignoreList":[]}
1
+ {"version":3,"file":"EditorTheme.js","names":["LexicalEditorTheme","block","blockCursor","characterLimit","code","codeHighlight","atrule","attr","boolean","builtin","cdata","char","class","comment","constant","deleted","doctype","entity","function","important","inserted","keyword","namespace","number","operator","prolog","property","punctuation","regex","selector","string","symbol","tag","url","variable","embedBlock","base","focus","hashtag","heading","h1","h2","h3","h4","h5","h6","hr","indent","inlineImage","link","list","checklist","listitem","listitemChecked","listitemUnchecked","nested","olDepth","ul","ltr","mark","markOverlap","paragraph","quote","relationship","rtl","table","tableAddColumns","tableAddRows","tableCell","tableCellActionButton","tableCellActionButtonContainer","tableCellHeader","tableCellResizer","tableCellSelected","tableRowStriping","tableScrollableWrapper","tableSelected","tableSelection","text","bold","italic","strikethrough","subscript","superscript","underline","underlineStrikethrough","upload"],"sources":["../../../src/lexical/theme/EditorTheme.tsx"],"sourcesContent":["import type { EditorThemeClasses } from 'lexical'\n\nexport const LexicalEditorTheme: EditorThemeClasses = {\n block: 'LexicalEditorTheme__block',\n blockCursor: 'LexicalEditorTheme__blockCursor',\n characterLimit: 'LexicalEditorTheme__characterLimit',\n code: 'LexicalEditorTheme__code',\n codeHighlight: {\n atrule: 'LexicalEditorTheme__tokenAttr',\n attr: 'LexicalEditorTheme__tokenAttr',\n boolean: 'LexicalEditorTheme__tokenProperty',\n builtin: 'LexicalEditorTheme__tokenSelector',\n cdata: 'LexicalEditorTheme__tokenComment',\n char: 'LexicalEditorTheme__tokenSelector',\n class: 'LexicalEditorTheme__tokenFunction',\n 'class-name': 'LexicalEditorTheme__tokenFunction',\n comment: 'LexicalEditorTheme__tokenComment',\n constant: 'LexicalEditorTheme__tokenProperty',\n deleted: 'LexicalEditorTheme__tokenProperty',\n doctype: 'LexicalEditorTheme__tokenComment',\n entity: 'LexicalEditorTheme__tokenOperator',\n function: 'LexicalEditorTheme__tokenFunction',\n important: 'LexicalEditorTheme__tokenVariable',\n inserted: 'LexicalEditorTheme__tokenSelector',\n keyword: 'LexicalEditorTheme__tokenAttr',\n namespace: 'LexicalEditorTheme__tokenVariable',\n number: 'LexicalEditorTheme__tokenProperty',\n operator: 'LexicalEditorTheme__tokenOperator',\n prolog: 'LexicalEditorTheme__tokenComment',\n property: 'LexicalEditorTheme__tokenProperty',\n punctuation: 'LexicalEditorTheme__tokenPunctuation',\n regex: 'LexicalEditorTheme__tokenVariable',\n selector: 'LexicalEditorTheme__tokenSelector',\n string: 'LexicalEditorTheme__tokenSelector',\n symbol: 'LexicalEditorTheme__tokenProperty',\n tag: 'LexicalEditorTheme__tokenProperty',\n url: 'LexicalEditorTheme__tokenOperator',\n variable: 'LexicalEditorTheme__tokenVariable',\n },\n embedBlock: {\n base: 'LexicalEditorTheme__embedBlock',\n focus: 'LexicalEditorTheme__embedBlockFocus',\n },\n hashtag: 'LexicalEditorTheme__hashtag',\n heading: {\n h1: 'LexicalEditorTheme__h1',\n h2: 'LexicalEditorTheme__h2',\n h3: 'LexicalEditorTheme__h3',\n h4: 'LexicalEditorTheme__h4',\n h5: 'LexicalEditorTheme__h5',\n h6: 'LexicalEditorTheme__h6',\n },\n hr: 'LexicalEditorTheme__hr',\n indent: 'LexicalEditorTheme__indent',\n inlineImage: 'LexicalEditor__inline-image',\n link: 'LexicalEditorTheme__link',\n list: {\n checklist: 'LexicalEditorTheme__checklist',\n listitem: 'LexicalEditorTheme__listItem',\n listitemChecked: 'LexicalEditorTheme__listItemChecked',\n listitemUnchecked: 'LexicalEditorTheme__listItemUnchecked',\n nested: {\n listitem: 'LexicalEditorTheme__nestedListItem',\n },\n olDepth: [\n 'LexicalEditorTheme__ol1',\n 'LexicalEditorTheme__ol2',\n 'LexicalEditorTheme__ol3',\n 'LexicalEditorTheme__ol4',\n 'LexicalEditorTheme__ol5',\n ],\n ul: 'LexicalEditorTheme__ul',\n },\n ltr: 'LexicalEditorTheme__ltr',\n mark: 'LexicalEditorTheme__mark',\n markOverlap: 'LexicalEditorTheme__markOverlap',\n paragraph: 'LexicalEditorTheme__paragraph',\n quote: 'LexicalEditorTheme__quote',\n relationship: 'LexicalEditorTheme__relationship',\n rtl: 'LexicalEditorTheme__rtl',\n table: 'LexicalEditorTheme__table',\n tableAddColumns: 'LexicalEditorTheme__tableAddColumns',\n tableAddRows: 'LexicalEditorTheme__tableAddRows',\n tableCell: 'LexicalEditorTheme__tableCell',\n tableCellActionButton: 'LexicalEditorTheme__tableCellActionButton',\n tableCellActionButtonContainer: 'LexicalEditorTheme__tableCellActionButtonContainer',\n tableCellHeader: 'LexicalEditorTheme__tableCellHeader',\n tableCellResizer: 'LexicalEditorTheme__tableCellResizer',\n tableCellSelected: 'LexicalEditorTheme__tableCellSelected',\n tableRowStriping: 'LexicalEditorTheme__tableRowStriping',\n tableScrollableWrapper: 'LexicalEditorTheme__tableScrollableWrapper',\n tableSelected: 'LexicalEditorTheme__tableSelected',\n tableSelection: 'LexicalEditorTheme__tableSelection',\n text: {\n bold: 'LexicalEditorTheme__textBold',\n code: 'LexicalEditorTheme__textCode',\n italic: 'LexicalEditorTheme__textItalic',\n strikethrough: 'LexicalEditorTheme__textStrikethrough',\n subscript: 'LexicalEditorTheme__textSubscript',\n superscript: 'LexicalEditorTheme__textSuperscript',\n underline: 'LexicalEditorTheme__textUnderline',\n underlineStrikethrough: 'LexicalEditorTheme__textUnderlineStrikethrough',\n },\n upload: 'editor-upload',\n}\n"],"mappings":"AAEA,OAAO,MAAMA,kBAAA,GAAyC;EACpDC,KAAA,EAAO;EACPC,WAAA,EAAa;EACbC,cAAA,EAAgB;EAChBC,IAAA,EAAM;EACNC,aAAA,EAAe;IACbC,MAAA,EAAQ;IACRC,IAAA,EAAM;IACNC,OAAA,EAAS;IACTC,OAAA,EAAS;IACTC,KAAA,EAAO;IACPC,IAAA,EAAM;IACNC,KAAA,EAAO;IACP,cAAc;IACdC,OAAA,EAAS;IACTC,QAAA,EAAU;IACVC,OAAA,EAAS;IACTC,OAAA,EAAS;IACTC,MAAA,EAAQ;IACRC,QAAA,EAAU;IACVC,SAAA,EAAW;IACXC,QAAA,EAAU;IACVC,OAAA,EAAS;IACTC,SAAA,EAAW;IACXC,MAAA,EAAQ;IACRC,QAAA,EAAU;IACVC,MAAA,EAAQ;IACRC,QAAA,EAAU;IACVC,WAAA,EAAa;IACbC,KAAA,EAAO;IACPC,QAAA,EAAU;IACVC,MAAA,EAAQ;IACRC,MAAA,EAAQ;IACRC,GAAA,EAAK;IACLC,GAAA,EAAK;IACLC,QAAA,EAAU;EACZ;EACAC,UAAA,EAAY;IACVC,IAAA,EAAM;IACNC,KAAA,EAAO;EACT;EACAC,OAAA,EAAS;EACTC,OAAA,EAAS;IACPC,EAAA,EAAI;IACJC,EAAA,EAAI;IACJC,EAAA,EAAI;IACJC,EAAA,EAAI;IACJC,EAAA,EAAI;IACJC,EAAA,EAAI;EACN;EACAC,EAAA,EAAI;EACJC,MAAA,EAAQ;EACRC,WAAA,EAAa;EACbC,IAAA,EAAM;EACNC,IAAA,EAAM;IACJC,SAAA,EAAW;IACXC,QAAA,EAAU;IACVC,eAAA,EAAiB;IACjBC,iBAAA,EAAmB;IACnBC,MAAA,EAAQ;MACNH,QAAA,EAAU;IACZ;IACAI,OAAA,EAAS,CACP,2BACA,2BACA,2BACA,2BACA,0BACD;IACDC,EAAA,EAAI;EACN;EACAC,GAAA,EAAK;EACLC,IAAA,EAAM;EACNC,WAAA,EAAa;EACbC,SAAA,EAAW;EACXC,KAAA,EAAO;EACPC,YAAA,EAAc;EACdC,GAAA,EAAK;EACLC,KAAA,EAAO;EACPC,eAAA,EAAiB;EACjBC,YAAA,EAAc;EACdC,SAAA,EAAW;EACXC,qBAAA,EAAuB;EACvBC,8BAAA,EAAgC;EAChCC,eAAA,EAAiB;EACjBC,gBAAA,EAAkB;EAClBC,iBAAA,EAAmB;EACnBC,gBAAA,EAAkB;EAClBC,sBAAA,EAAwB;EACxBC,aAAA,EAAe;EACfC,cAAA,EAAgB;EAChBC,IAAA,EAAM;IACJC,IAAA,EAAM;IACN3E,IAAA,EAAM;IACN4E,MAAA,EAAQ;IACRC,aAAA,EAAe;IACfC,SAAA,EAAW;IACXC,WAAA,EAAa;IACbC,SAAA,EAAW;IACXC,sBAAA,EAAwB;EAC1B;EACAC,MAAA,EAAQ;AACV","ignoreList":[]}
@@ -143,5 +143,5 @@ export declare const BOLD_UNDERSCORE: TextFormatTransformer;
143
143
  export declare const STRIKETHROUGH: TextFormatTransformer;
144
144
  export declare const ITALIC_STAR: TextFormatTransformer;
145
145
  export declare const ITALIC_UNDERSCORE: TextFormatTransformer;
146
- export declare function normalizeMarkdown(input: string, shouldMergeAdjacentLines?: boolean): string;
146
+ export declare function normalizeMarkdown(input: string, shouldMergeAdjacentLines: boolean): string;
147
147
  //# sourceMappingURL=MarkdownTransformers.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"MarkdownTransformers.d.ts","sourceRoot":"","sources":["../../../../src/packages/@lexical/markdown/MarkdownTransformers.ts"],"names":[],"mappings":"AACA;;;;;;GAMG;AAIH,OAAO,KAAK,EAAE,WAAW,EAAE,KAAK,EAAE,WAAW,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAA;AAoBxF,MAAM,MAAM,WAAW,GACnB,kBAAkB,GAClB,2BAA2B,GAC3B,qBAAqB,GACrB,oBAAoB,CAAA;AAExB,MAAM,MAAM,kBAAkB,GAAG;IAC/B,YAAY,EAAE,KAAK,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC,CAAA;IACvC;;;;OAIG;IACH,MAAM,EAAE,CACN,IAAI,EAAE,WAAW,EAEjB,gBAAgB,EAAE,CAAC,IAAI,EAAE,WAAW,KAAK,MAAM,KAC5C,IAAI,GAAG,MAAM,CAAA;IAClB,MAAM,EAAE,MAAM,CAAA;IACd;;;;OAIG;IACH,OAAO,EAAE,CACP,UAAU,EAAE,WAAW,EACvB,QAAQ,EAAE,KAAK,CAAC,WAAW,CAAC,EAC5B,KAAK,EAAE,KAAK,CAAC,MAAM,CAAC;IACpB;;OAEG;IACH,QAAQ,EAAE,OAAO,KACd,OAAO,GAAG,IAAI,CAAA;IACnB,IAAI,EAAE,SAAS,CAAA;CAChB,CAAA;AAED,MAAM,MAAM,2BAA2B,GAAG;IACxC,YAAY,EAAE,KAAK,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC,CAAA;IACvC;;;;OAIG;IACH,MAAM,CAAC,EAAE,CACP,IAAI,EAAE,WAAW,EAEjB,gBAAgB,EAAE,CAAC,IAAI,EAAE,WAAW,KAAK,MAAM,KAC5C,IA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ED,eAAO,MAAM,iBAAiB,EAAE,qBAK/B,CAAA;AAED,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,MAAM,EAAE,wBAAwB,UAAQ,GAAG,MAAM,CAmDzF"}
1
+ {"version":3,"file":"MarkdownTransformers.d.ts","sourceRoot":"","sources":["../../../../src/packages/@lexical/markdown/MarkdownTransformers.ts"],"names":[],"mappings":"AACA;;;;;;GAMG;AAIH,OAAO,KAAK,EAAE,WAAW,EAAE,KAAK,EAAE,WAAW,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAA;AAoBxF,MAAM,MAAM,WAAW,GACnB,kBAAkB,GAClB,2BAA2B,GAC3B,qBAAqB,GACrB,oBAAoB,CAAA;AAExB,MAAM,MAAM,kBAAkB,GAAG;IAC/B,YAAY,EAAE,KAAK,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC,CAAA;IACvC;;;;OAIG;IACH,MAAM,EAAE,CACN,IAAI,EAAE,WAAW,EAEjB,gBAAgB,EAAE,CAAC,IAAI,EAAE,WAAW,KAAK,MAAM,KAC5C,IAAI,GAAG,MAAM,CAAA;IAClB,MAAM,EAAE,MAAM,CAAA;IACd;;;;OAIG;IACH,OAAO,EAAE,CACP,UAAU,EAAE,WAAW,EACvB,QAAQ,EAAE,KAAK,CAAC,WAAW,CAAC,EAC5B,KAAK,EAAE,KAAK,CAAC,MAAM,CAAC;IACpB;;OAEG;IACH,QAAQ,EAAE,OAAO,KACd,OAAO,GAAG,IAAI,CAAA;IACnB,IAAI,EAAE,SAAS,CAAA;CAChB,CAAA;AAED,MAAM,MAAM,2BAA2B,GAAG;IACxC,YAAY,EAAE,KAAK,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC,CAAA;IACvC;;;;OAIG;IACH,MAAM,CAAC,EAAE,CACP,IAAI,EAAE,WAAW,EAEjB,gBAAgB,EAAE,CAAC,IAAI,EAAE,WAAW,KAAK,MAAM,KAC5C,IAAI,GAAG,MAAM,CAAA;IAClB;;;;;OA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B,CAAA;AAED,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,MAAM,EAAE,wBAAwB,EAAE,OAAO,GAAG,MAAM,CAwE1F"}
@@ -7,16 +7,19 @@
7
7
  */import { $createListItemNode, $createListNode, $isListItemNode, $isListNode, ListItemNode, ListNode } from '@lexical/list';
8
8
  import { $createHeadingNode, $createQuoteNode, $isHeadingNode, $isQuoteNode, HeadingNode, QuoteNode } from '@lexical/rich-text';
9
9
  import { $createLineBreakNode } from 'lexical';
10
+ const EMPTY_OR_WHITESPACE_ONLY = /^[\t ]*$/;
10
11
  const ORDERED_LIST_REGEX = /^(\s*)(\d+)\.\s/;
11
12
  const UNORDERED_LIST_REGEX = /^(\s*)[-*+]\s/;
12
13
  const CHECK_LIST_REGEX = /^(\s*)(?:-\s)?\s?(\[(\s|x)?\])\s/i;
13
14
  const HEADING_REGEX = /^(#{1,6})\s/;
14
15
  const QUOTE_REGEX = /^>\s/;
15
- const CODE_START_REGEX = /^[ \t]*```(\w+)?/;
16
- const CODE_END_REGEX = /[ \t]*```$/;
16
+ const CODE_START_REGEX = /^[ \t]*(\\`\\`\\`|```)(\w+)?/;
17
+ const CODE_END_REGEX = /[ \t]*(\\`\\`\\`|```)$/;
17
18
  const CODE_SINGLE_LINE_REGEX = /^[ \t]*```[^`]+(?:(?:`{1,2}|`{4,})[^`]+)*```(?:[^`]|$)/;
18
19
  const TABLE_ROW_REG_EXP = /^\|(.+)\|\s?$/;
19
20
  const TABLE_ROW_DIVIDER_REG_EXP = /^(\| ?:?-*:? ?)+\|\s?$/;
21
+ const TAG_START_REGEX = /^[ \t]*<[a-z_][\w-]*(?:\s[^<>]*)?\/?>/i;
22
+ const TAG_END_REGEX = /^[ \t]*<\/[a-z_][\w-]*\s*>/i;
20
23
  const createBlockNode = createNode => {
21
24
  return (parentNode, children, match) => {
22
25
  const node = createNode(match);
@@ -214,10 +217,11 @@ export const ITALIC_UNDERSCORE = {
214
217
  intraword: false,
215
218
  tag: '_'
216
219
  };
217
- export function normalizeMarkdown(input, shouldMergeAdjacentLines = false) {
220
+ export function normalizeMarkdown(input, shouldMergeAdjacentLines) {
218
221
  const lines = input.split('\n');
219
222
  let inCodeBlock = false;
220
223
  const sanitizedLines = [];
224
+ let nestedDeepCodeBlock = 0;
221
225
  for (let i = 0; i < lines.length; i++) {
222
226
  const line = lines[i];
223
227
  const lastLine = sanitizedLines[sanitizedLines.length - 1];
@@ -226,9 +230,23 @@ export function normalizeMarkdown(input, shouldMergeAdjacentLines = false) {
226
230
  sanitizedLines.push(line);
227
231
  continue;
228
232
  }
229
- // Detect the start or end of a code block
230
- if (CODE_START_REGEX.test(line) || CODE_END_REGEX.test(line)) {
231
- inCodeBlock = !inCodeBlock;
233
+ if (CODE_END_REGEX.test(line)) {
234
+ if (nestedDeepCodeBlock === 0) {
235
+ inCodeBlock = true;
236
+ }
237
+ if (nestedDeepCodeBlock === 1) {
238
+ inCodeBlock = false;
239
+ }
240
+ if (nestedDeepCodeBlock > 0) {
241
+ nestedDeepCodeBlock--;
242
+ }
243
+ sanitizedLines.push(line);
244
+ continue;
245
+ }
246
+ // Toggle inCodeBlock state when encountering start or end of a code block
247
+ if (CODE_START_REGEX.test(line)) {
248
+ inCodeBlock = true;
249
+ nestedDeepCodeBlock++;
232
250
  sanitizedLines.push(line);
233
251
  continue;
234
252
  }
@@ -239,10 +257,10 @@ export function normalizeMarkdown(input, shouldMergeAdjacentLines = false) {
239
257
  }
240
258
  // In markdown the concept of "empty paragraphs" does not exist.
241
259
  // Blocks must be separated by an empty line. Non-empty adjacent lines must be merged.
242
- if (line === '' || lastLine === '' || !lastLine || HEADING_REGEX.test(lastLine) || HEADING_REGEX.test(line) || QUOTE_REGEX.test(line) || ORDERED_LIST_REGEX.test(line) || UNORDERED_LIST_REGEX.test(line) || CHECK_LIST_REGEX.test(line) || TABLE_ROW_REG_EXP.test(line) || TABLE_ROW_DIVIDER_REG_EXP.test(line) || !shouldMergeAdjacentLines) {
260
+ if (EMPTY_OR_WHITESPACE_ONLY.test(line) || EMPTY_OR_WHITESPACE_ONLY.test(lastLine) || !lastLine || HEADING_REGEX.test(lastLine) || HEADING_REGEX.test(line) || QUOTE_REGEX.test(line) || ORDERED_LIST_REGEX.test(line) || UNORDERED_LIST_REGEX.test(line) || CHECK_LIST_REGEX.test(line) || TABLE_ROW_REG_EXP.test(line) || TABLE_ROW_DIVIDER_REG_EXP.test(line) || !shouldMergeAdjacentLines || TAG_START_REGEX.test(line) || TAG_END_REGEX.test(line) || TAG_START_REGEX.test(lastLine) || TAG_END_REGEX.test(lastLine) || CODE_END_REGEX.test(lastLine)) {
243
261
  sanitizedLines.push(line);
244
262
  } else {
245
- sanitizedLines[sanitizedLines.length - 1] = lastLine + line;
263
+ sanitizedLines[sanitizedLines.length - 1] = lastLine + ' ' + line.trim();
246
264
  }
247
265
  }
248
266
  return sanitizedLines.join('\n');
@@ -1 +1 @@
1
- {"version":3,"file":"MarkdownTransformers.js","names":["$createListItemNode","$createListNode","$isListItemNode","$isListNode","ListItemNode","ListNode","$createHeadingNode","$createQuoteNode","$isHeadingNode","$isQuoteNode","HeadingNode","QuoteNode","$createLineBreakNode","ORDERED_LIST_REGEX","UNORDERED_LIST_REGEX","CHECK_LIST_REGEX","HEADING_REGEX","QUOTE_REGEX","CODE_START_REGEX","CODE_END_REGEX","CODE_SINGLE_LINE_REGEX","TABLE_ROW_REG_EXP","TABLE_ROW_DIVIDER_REG_EXP","createBlockNode","createNode","parentNode","children","match","node","append","replace","select","LIST_INDENT_SIZE","getIndent","whitespaces","tabs","spaces","indent","length","Math","floor","listReplace","listType","previousNode","getPreviousSibling","nextNode","getNextSibling","listItem","undefined","getListType","firstChild","getFirstChild","insertBefore","remove","list","Number","setIndent","listExport","listNode","exportChildren","depth","output","getChildren","index","listItemNode","getChildrenSize","push","repeat","prefix","getStart","getChecked","join","HEADING","type","dependencies","export","level","getTag","slice","regExp","tag","QUOTE","lines","split","line","_match","isImport","splice","UNORDERED_LIST","CHECK_LIST","ORDERED_LIST","INLINE_CODE","format","HIGHLIGHT","BOLD_ITALIC_STAR","BOLD_ITALIC_UNDERSCORE","intraword","BOLD_STAR","BOLD_UNDERSCORE","STRIKETHROUGH","ITALIC_STAR","ITALIC_UNDERSCORE","normalizeMarkdown","input","shouldMergeAdjacentLines","inCodeBlock","sanitizedLines","i","lastLine","test"],"sources":["../../../../src/packages/@lexical/markdown/MarkdownTransformers.ts"],"sourcesContent":["/* eslint-disable regexp/no-unused-capturing-group */\n/**\n * Copyright (c) Meta Platforms, Inc. and affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n *\n */\n\nimport type { ListType } from '@lexical/list'\nimport type { HeadingTagType } from '@lexical/rich-text'\nimport type { ElementNode, Klass, LexicalNode, TextFormatType, TextNode } from 'lexical'\n\nimport {\n $createListItemNode,\n $createListNode,\n $isListItemNode,\n $isListNode,\n ListItemNode,\n ListNode,\n} from '@lexical/list'\nimport {\n $createHeadingNode,\n $createQuoteNode,\n $isHeadingNode,\n $isQuoteNode,\n HeadingNode,\n QuoteNode,\n} from '@lexical/rich-text'\nimport { $createLineBreakNode } from 'lexical'\n\nexport type Transformer =\n | ElementTransformer\n | MultilineElementTransformer\n | TextFormatTransformer\n | TextMatchTransformer\n\nexport type ElementTransformer = {\n dependencies: Array<Klass<LexicalNode>>\n /**\n * `export` is called when the `$convertToMarkdownString` is called to convert the editor state into markdown.\n *\n * @return return null to cancel the export, even though the regex matched. Lexical will then search for the next transformer.\n */\n export: (\n node: LexicalNode,\n\n traverseChildren: (node: ElementNode) => string,\n ) => null | string\n regExp: RegExp\n /**\n * `replace` is called when markdown is imported or typed in the editor\n *\n * @return return false to cancel the transform, even though the regex matched. Lexical will then search for the next transformer.\n */\n replace: (\n parentNode: ElementNode,\n children: Array<LexicalNode>,\n match: Array<string>,\n /**\n * Whether the match is from an import operation (e.g. through `$convertFromMarkdownString`) or not (e.g. through typing in the editor).\n */\n isImport: boolean,\n ) => boolean | void\n type: 'element'\n}\n\nexport type MultilineElementTransformer = {\n dependencies: Array<Klass<LexicalNode>>\n /**\n * `export` is called when the `$convertToMarkdownString` is called to convert the editor state into markdown.\n *\n * @return return null to cancel the export, even though the regex matched. Lexical will then search for the next transformer.\n */\n export?: (\n node: LexicalNode,\n\n traverseChildren: (node: ElementNode) => string,\n ) => null | string\n /**\n * Use this function to manually handle the import process, once the `regExpStart` has matched successfully.\n * Without providing this function, the default behavior is to match until `regExpEnd` is found, or until the end of the document if `regExpEnd.optional` is true.\n *\n * @returns a tuple or null. The first element of the returned tuple is a boolean indicating if a multiline element was imported. The second element is the index of the last line that was processed. If null is returned, the next multilineElementTransformer will be tried. If undefined is returned, the default behavior will be used.\n */\n handleImportAfterStartMatch?: (args: {\n lines: Array<string>\n rootNode: ElementNode\n startLineIndex: number\n startMatch: RegExpMatchArray\n transformer: MultilineElementTransformer\n }) => [boolean, number] | null | undefined\n /**\n * This regex determines when to stop matching. Anything in between regExpStart and regExpEnd will be matched\n */\n regExpEnd?:\n | {\n /**\n * Whether the end match is optional. If true, the end match is not required to match for the transformer to be triggered.\n * The entire text from regexpStart to the end of the document will then be matched.\n */\n optional?: true\n regExp: RegExp\n }\n | RegExp\n /**\n * This regex determines when to start matching\n */\n regExpStart: RegExp\n /**\n * `replace` is called only when markdown is imported in the editor, not when it's typed\n *\n * @return return false to cancel the transform, even though the regex matched. Lexical will then search for the next transformer.\n */\n replace: (\n rootNode: ElementNode,\n /**\n * During markdown shortcut transforms, children nodes may be provided to the transformer. If this is the case, no `linesInBetween` will be provided and\n * the children nodes should be used instead of the `linesInBetween` to create the new node.\n */\n children: Array<LexicalNode> | null,\n startMatch: Array<string>,\n endMatch: Array<string> | null,\n /**\n * linesInBetween includes the text between the start & end matches, split up by lines, not including the matches themselves.\n * This is null when the transformer is triggered through markdown shortcuts (by typing in the editor)\n */\n linesInBetween: Array<string> | null,\n /**\n * Whether the match is from an import operation (e.g. through `$convertFromMarkdownString`) or not (e.g. through typing in the editor).\n */\n isImport: boolean,\n ) => boolean | void\n type: 'multiline-element'\n}\n\nexport type TextFormatTransformer = Readonly<{\n format: ReadonlyArray<TextFormatType>\n intraword?: boolean\n tag: string\n type: 'text-format'\n}>\n\nexport type TextMatchTransformer = Readonly<{\n dependencies: Array<Klass<LexicalNode>>\n /**\n * Determines how a node should be exported to markdown\n */\n export?: (\n node: LexicalNode,\n\n exportChildren: (node: ElementNode) => string,\n\n exportFormat: (node: TextNode, textContent: string) => string,\n ) => null | string\n /**\n * For import operations, this function can be used to determine the end index of the match, after `importRegExp` has matched.\n * Without this function, the end index will be determined by the length of the match from `importRegExp`. Manually determining the end index can be useful if\n * the match from `importRegExp` is not the entire text content of the node. That way, `importRegExp` can be used to match only the start of the node, and `getEndIndex`\n * can be used to match the end of the node.\n *\n * @returns The end index of the match, or false if the match was unsuccessful and a different transformer should be tried.\n */\n getEndIndex?: (node: TextNode, match: RegExpMatchArray) => false | number\n /**\n * This regex determines what text is matched during markdown imports\n */\n importRegExp?: RegExp\n /**\n * This regex determines what text is matched for markdown shortcuts while typing in the editor\n */\n regExp: RegExp\n /**\n * Determines how the matched markdown text should be transformed into a node during the markdown import process\n *\n * @returns nothing, or a TextNode that may be a child of the new node that is created.\n * If a TextNode is returned, text format matching will be applied to it (e.g. bold, italic, etc.)\n */\n replace?: (node: TextNode, match: RegExpMatchArray) => TextNode | void\n /**\n * Single character that allows the transformer to trigger when typed in the editor. This does not affect markdown imports outside of the markdown shortcut plugin.\n * If the trigger is matched, the `regExp` will be used to match the text in the second step.\n */\n trigger?: string\n type: 'text-match'\n}>\n\nconst ORDERED_LIST_REGEX = /^(\\s*)(\\d+)\\.\\s/\nconst UNORDERED_LIST_REGEX = /^(\\s*)[-*+]\\s/\nconst CHECK_LIST_REGEX = /^(\\s*)(?:-\\s)?\\s?(\\[(\\s|x)?\\])\\s/i\nconst HEADING_REGEX = /^(#{1,6})\\s/\nconst QUOTE_REGEX = /^>\\s/\nconst CODE_START_REGEX = /^[ \\t]*```(\\w+)?/\nconst CODE_END_REGEX = /[ \\t]*```$/\nconst CODE_SINGLE_LINE_REGEX = /^[ \\t]*```[^`]+(?:(?:`{1,2}|`{4,})[^`]+)*```(?:[^`]|$)/\nconst TABLE_ROW_REG_EXP = /^\\|(.+)\\|\\s?$/\nconst TABLE_ROW_DIVIDER_REG_EXP = /^(\\| ?:?-*:? ?)+\\|\\s?$/\n\nconst createBlockNode = (\n createNode: (match: Array<string>) => ElementNode,\n): ElementTransformer['replace'] => {\n return (parentNode, children, match) => {\n const node = createNode(match)\n node.append(...children)\n parentNode.replace(node)\n node.select(0, 0)\n }\n}\n\n// Amount of spaces that define indentation level\n// TODO: should be an option\nconst LIST_INDENT_SIZE = 4\n\nfunction getIndent(whitespaces: string): number {\n const tabs = whitespaces.match(/\\t/g)\n const spaces = whitespaces.match(/ /g)\n\n let indent = 0\n\n if (tabs) {\n indent += tabs.length\n }\n\n if (spaces) {\n indent += Math.floor(spaces.length / LIST_INDENT_SIZE)\n }\n\n return indent\n}\n\nconst listReplace = (listType: ListType): ElementTransformer['replace'] => {\n return (parentNode, children, match) => {\n const previousNode = parentNode.getPreviousSibling()\n const nextNode = parentNode.getNextSibling()\n const listItem = $createListItemNode(listType === 'check' ? match[3] === 'x' : undefined)\n if ($isListNode(nextNode) && nextNode.getListType() === listType) {\n const firstChild = nextNode.getFirstChild()\n if (firstChild !== null) {\n firstChild.insertBefore(listItem)\n } else {\n // should never happen, but let's handle gracefully, just in case.\n nextNode.append(listItem)\n }\n parentNode.remove()\n } else if ($isListNode(previousNode) && previousNode.getListType() === listType) {\n previousNode.append(listItem)\n parentNode.remove()\n } else {\n const list = $createListNode(listType, listType === 'number' ? Number(match[2]) : undefined)\n list.append(listItem)\n parentNode.replace(list)\n }\n listItem.append(...children)\n listItem.select(0, 0)\n const indent = getIndent(match[1])\n if (indent) {\n listItem.setIndent(indent)\n }\n }\n}\n\nconst listExport = (\n listNode: ListNode,\n exportChildren: (node: ElementNode) => string,\n depth: number,\n): string => {\n const output: string[] = []\n const children = listNode.getChildren()\n let index = 0\n for (const listItemNode of children) {\n if ($isListItemNode(listItemNode)) {\n if (listItemNode.getChildrenSize() === 1) {\n const firstChild = listItemNode.getFirstChild()\n if ($isListNode(firstChild)) {\n output.push(listExport(firstChild, exportChildren, depth + 1))\n continue\n }\n }\n const indent = ' '.repeat(depth * LIST_INDENT_SIZE)\n const listType = listNode.getListType()\n const prefix =\n listType === 'number'\n ? `${listNode.getStart() + index}. `\n : listType === 'check'\n ? `- [${listItemNode.getChecked() ? 'x' : ' '}] `\n : '- '\n output.push(indent + prefix + exportChildren(listItemNode))\n index++\n }\n }\n\n return output.join('\\n')\n}\n\nexport const HEADING: ElementTransformer = {\n type: 'element',\n dependencies: [HeadingNode],\n export: (node, exportChildren) => {\n if (!$isHeadingNode(node)) {\n return null\n }\n const level = Number(node.getTag().slice(1))\n return '#'.repeat(level) + ' ' + exportChildren(node)\n },\n regExp: HEADING_REGEX,\n replace: createBlockNode((match) => {\n const tag = ('h' + match[1].length) as HeadingTagType\n return $createHeadingNode(tag)\n }),\n}\n\nexport const QUOTE: ElementTransformer = {\n type: 'element',\n dependencies: [QuoteNode],\n export: (node, exportChildren) => {\n if (!$isQuoteNode(node)) {\n return null\n }\n\n const lines = exportChildren(node).split('\\n')\n const output: string[] = []\n for (const line of lines) {\n output.push('> ' + line)\n }\n return output.join('\\n')\n },\n regExp: QUOTE_REGEX,\n replace: (parentNode, children, _match, isImport) => {\n if (isImport) {\n const previousNode = parentNode.getPreviousSibling()\n if ($isQuoteNode(previousNode)) {\n previousNode.splice(previousNode.getChildrenSize(), 0, [\n $createLineBreakNode(),\n ...children,\n ])\n previousNode.select(0, 0)\n parentNode.remove()\n return\n }\n }\n\n const node = $createQuoteNode()\n node.append(...children)\n parentNode.replace(node)\n node.select(0, 0)\n },\n}\n\nexport const UNORDERED_LIST: ElementTransformer = {\n type: 'element',\n dependencies: [ListNode, ListItemNode],\n export: (node, exportChildren) => {\n return $isListNode(node) ? listExport(node, exportChildren, 0) : null\n },\n regExp: UNORDERED_LIST_REGEX,\n replace: listReplace('bullet'),\n}\n\nexport const CHECK_LIST: ElementTransformer = {\n type: 'element',\n dependencies: [ListNode, ListItemNode],\n export: (node, exportChildren) => {\n return $isListNode(node) ? listExport(node, exportChildren, 0) : null\n },\n regExp: CHECK_LIST_REGEX,\n replace: listReplace('check'),\n}\n\nexport const ORDERED_LIST: ElementTransformer = {\n type: 'element',\n dependencies: [ListNode, ListItemNode],\n export: (node, exportChildren) => {\n return $isListNode(node) ? listExport(node, exportChildren, 0) : null\n },\n regExp: ORDERED_LIST_REGEX,\n replace: listReplace('number'),\n}\n\nexport const INLINE_CODE: TextFormatTransformer = {\n type: 'text-format',\n format: ['code'],\n tag: '`',\n}\n\nexport const HIGHLIGHT: TextFormatTransformer = {\n type: 'text-format',\n format: ['highlight'],\n tag: '==',\n}\n\nexport const BOLD_ITALIC_STAR: TextFormatTransformer = {\n type: 'text-format',\n format: ['bold', 'italic'],\n tag: '***',\n}\n\nexport const BOLD_ITALIC_UNDERSCORE: TextFormatTransformer = {\n type: 'text-format',\n format: ['bold', 'italic'],\n intraword: false,\n tag: '___',\n}\n\nexport const BOLD_STAR: TextFormatTransformer = {\n type: 'text-format',\n format: ['bold'],\n tag: '**',\n}\n\nexport const BOLD_UNDERSCORE: TextFormatTransformer = {\n type: 'text-format',\n format: ['bold'],\n intraword: false,\n tag: '__',\n}\n\nexport const STRIKETHROUGH: TextFormatTransformer = {\n type: 'text-format',\n format: ['strikethrough'],\n tag: '~~',\n}\n\nexport const ITALIC_STAR: TextFormatTransformer = {\n type: 'text-format',\n format: ['italic'],\n tag: '*',\n}\n\nexport const ITALIC_UNDERSCORE: TextFormatTransformer = {\n type: 'text-format',\n format: ['italic'],\n intraword: false,\n tag: '_',\n}\n\nexport function normalizeMarkdown(input: string, shouldMergeAdjacentLines = false): string {\n const lines = input.split('\\n')\n let inCodeBlock = false\n const sanitizedLines: string[] = []\n\n for (let i = 0; i < lines.length; i++) {\n const line = lines[i]\n const lastLine = sanitizedLines[sanitizedLines.length - 1]\n\n // Code blocks of ```single line``` don't toggle the inCodeBlock flag\n if (CODE_SINGLE_LINE_REGEX.test(line)) {\n sanitizedLines.push(line)\n continue\n }\n\n // Detect the start or end of a code block\n if (CODE_START_REGEX.test(line) || CODE_END_REGEX.test(line)) {\n inCodeBlock = !inCodeBlock\n sanitizedLines.push(line)\n continue\n }\n\n // If we are inside a code block, keep the line unchanged\n if (inCodeBlock) {\n sanitizedLines.push(line)\n continue\n }\n\n // In markdown the concept of \"empty paragraphs\" does not exist.\n // Blocks must be separated by an empty line. Non-empty adjacent lines must be merged.\n if (\n line === '' ||\n lastLine === '' ||\n !lastLine ||\n HEADING_REGEX.test(lastLine) ||\n HEADING_REGEX.test(line) ||\n QUOTE_REGEX.test(line) ||\n ORDERED_LIST_REGEX.test(line) ||\n UNORDERED_LIST_REGEX.test(line) ||\n CHECK_LIST_REGEX.test(line) ||\n TABLE_ROW_REG_EXP.test(line) ||\n TABLE_ROW_DIVIDER_REG_EXP.test(line) ||\n !shouldMergeAdjacentLines\n ) {\n sanitizedLines.push(line)\n } else {\n sanitizedLines[sanitizedLines.length - 1] = lastLine + line\n }\n }\n\n return sanitizedLines.join('\\n')\n}\n"],"mappings":"AAAA,sDACA;;;;;;wDAYA,SACEA,mBAAmB,EACnBC,eAAe,EACfC,eAAe,EACfC,WAAW,EACXC,YAAY,EACZC,QAAQ,QACH;AACP,SACEC,kBAAkB,EAClBC,gBAAgB,EAChBC,cAAc,EACdC,YAAY,EACZC,WAAW,EACXC,SAAS,QACJ;AACP,SAASC,oBAAoB,QAAQ;AA8JrC,MAAMC,kBAAA,GAAqB;AAC3B,MAAMC,oBAAA,GAAuB;AAC7B,MAAMC,gBAAA,GAAmB;AACzB,MAAMC,aAAA,GAAgB;AACtB,MAAMC,WAAA,GAAc;AACpB,MAAMC,gBAAA,GAAmB;AACzB,MAAMC,cAAA,GAAiB;AACvB,MAAMC,sBAAA,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BAAA,CAAmBgG,IAAI,CAACzB,IAAA,KACxBtE,oBAAA,CAAqB+F,IAAI,CAACzB,IAAA,KAC1BrE,gBAAA,CAAiB8F,IAAI,CAACzB,IAAA,KACtB/D,iBAAA,CAAkBwF,IAAI,CAACzB,IAAA,KACvB9D,yBAAA,CAA0BuF,IAAI,CAACzB,IAAA,KAC/B,CAACoB,wBAAA,EACD;MACAE,cAAA,CAAexC,IAAI,CAACkB,IAAA;IACtB,OAAO;MACLsB,cAAc,CAACA,cAAA,CAAepE,MAAM,GAAG,EAAE,GAAGsE,QAAA,GAAWxB,IAAA;IACzD;EACF;EAEA,OAAOsB,cAAA,CAAenC,IAAI,CAAC;AAC7B","ignoreList":[]}
1
+ {"version":3,"file":"MarkdownTransformers.js","names":["$createListItemNode","$createListNode","$isListItemNode","$isListNode","ListItemNode","ListNode","$createHeadingNode","$createQuoteNode","$isHeadingNode","$isQuoteNode","HeadingNode","QuoteNode","$createLineBreakNode","EMPTY_OR_WHITESPACE_ONLY","ORDERED_LIST_REGEX","UNORDERED_LIST_REGEX","CHECK_LIST_REGEX","HEADING_REGEX","QUOTE_REGEX","CODE_START_REGEX","CODE_END_REGEX","CODE_SINGLE_LINE_REGEX","TABLE_ROW_REG_EXP","TABLE_ROW_DIVIDER_REG_EXP","TAG_START_REGEX","TAG_END_REGEX","createBlockNode","createNode","parentNode","children","match","node","append","replace","select","LIST_INDENT_SIZE","getIndent","whitespaces","tabs","spaces","indent","length","Math","floor","listReplace","listType","previousNode","getPreviousSibling","nextNode","getNextSibling","listItem","undefined","getListType","firstChild","getFirstChild","insertBefore","remove","list","Number","setIndent","listExport","listNode","exportChildren","depth","output","getChildren","index","listItemNode","getChildrenSize","push","repeat","prefix","getStart","getChecked","join","HEADING","type","dependencies","export","level","getTag","slice","regExp","tag","QUOTE","lines","split","line","_match","isImport","splice","UNORDERED_LIST","CHECK_LIST","ORDERED_LIST","INLINE_CODE","format","HIGHLIGHT","BOLD_ITALIC_STAR","BOLD_ITALIC_UNDERSCORE","intraword","BOLD_STAR","BOLD_UNDERSCORE","STRIKETHROUGH","ITALIC_STAR","ITALIC_UNDERSCORE","normalizeMarkdown","input","shouldMergeAdjacentLines","inCodeBlock","sanitizedLines","nestedDeepCodeBlock","i","lastLine","test","trim"],"sources":["../../../../src/packages/@lexical/markdown/MarkdownTransformers.ts"],"sourcesContent":["/* eslint-disable regexp/no-unused-capturing-group */\n/**\n * Copyright (c) Meta Platforms, Inc. and affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n *\n */\n\nimport type { ListType } from '@lexical/list'\nimport type { HeadingTagType } from '@lexical/rich-text'\nimport type { ElementNode, Klass, LexicalNode, TextFormatType, TextNode } from 'lexical'\n\nimport {\n $createListItemNode,\n $createListNode,\n $isListItemNode,\n $isListNode,\n ListItemNode,\n ListNode,\n} from '@lexical/list'\nimport {\n $createHeadingNode,\n $createQuoteNode,\n $isHeadingNode,\n $isQuoteNode,\n HeadingNode,\n QuoteNode,\n} from '@lexical/rich-text'\nimport { $createLineBreakNode } from 'lexical'\n\nexport type Transformer =\n | ElementTransformer\n | MultilineElementTransformer\n | TextFormatTransformer\n | TextMatchTransformer\n\nexport type ElementTransformer = {\n dependencies: Array<Klass<LexicalNode>>\n /**\n * `export` is called when the `$convertToMarkdownString` is called to convert the editor state into markdown.\n *\n * @return return null to cancel the export, even though the regex matched. Lexical will then search for the next transformer.\n */\n export: (\n node: LexicalNode,\n\n traverseChildren: (node: ElementNode) => string,\n ) => null | string\n regExp: RegExp\n /**\n * `replace` is called when markdown is imported or typed in the editor\n *\n * @return return false to cancel the transform, even though the regex matched. Lexical will then search for the next transformer.\n */\n replace: (\n parentNode: ElementNode,\n children: Array<LexicalNode>,\n match: Array<string>,\n /**\n * Whether the match is from an import operation (e.g. through `$convertFromMarkdownString`) or not (e.g. through typing in the editor).\n */\n isImport: boolean,\n ) => boolean | void\n type: 'element'\n}\n\nexport type MultilineElementTransformer = {\n dependencies: Array<Klass<LexicalNode>>\n /**\n * `export` is called when the `$convertToMarkdownString` is called to convert the editor state into markdown.\n *\n * @return return null to cancel the export, even though the regex matched. Lexical will then search for the next transformer.\n */\n export?: (\n node: LexicalNode,\n\n traverseChildren: (node: ElementNode) => string,\n ) => null | string\n /**\n * Use this function to manually handle the import process, once the `regExpStart` has matched successfully.\n * Without providing this function, the default behavior is to match until `regExpEnd` is found, or until the end of the document if `regExpEnd.optional` is true.\n *\n * @returns a tuple or null. The first element of the returned tuple is a boolean indicating if a multiline element was imported. The second element is the index of the last line that was processed. If null is returned, the next multilineElementTransformer will be tried. If undefined is returned, the default behavior will be used.\n */\n handleImportAfterStartMatch?: (args: {\n lines: Array<string>\n rootNode: ElementNode\n startLineIndex: number\n startMatch: RegExpMatchArray\n transformer: MultilineElementTransformer\n }) => [boolean, number] | null | undefined\n /**\n * This regex determines when to stop matching. Anything in between regExpStart and regExpEnd will be matched\n */\n regExpEnd?:\n | {\n /**\n * Whether the end match is optional. If true, the end match is not required to match for the transformer to be triggered.\n * The entire text from regexpStart to the end of the document will then be matched.\n */\n optional?: true\n regExp: RegExp\n }\n | RegExp\n /**\n * This regex determines when to start matching\n */\n regExpStart: RegExp\n /**\n * `replace` is called only when markdown is imported in the editor, not when it's typed\n *\n * @return return false to cancel the transform, even though the regex matched. Lexical will then search for the next transformer.\n */\n replace: (\n rootNode: ElementNode,\n /**\n * During markdown shortcut transforms, children nodes may be provided to the transformer. If this is the case, no `linesInBetween` will be provided and\n * the children nodes should be used instead of the `linesInBetween` to create the new node.\n */\n children: Array<LexicalNode> | null,\n startMatch: Array<string>,\n endMatch: Array<string> | null,\n /**\n * linesInBetween includes the text between the start & end matches, split up by lines, not including the matches themselves.\n * This is null when the transformer is triggered through markdown shortcuts (by typing in the editor)\n */\n linesInBetween: Array<string> | null,\n /**\n * Whether the match is from an import operation (e.g. through `$convertFromMarkdownString`) or not (e.g. through typing in the editor).\n */\n isImport: boolean,\n ) => boolean | void\n type: 'multiline-element'\n}\n\nexport type TextFormatTransformer = Readonly<{\n format: ReadonlyArray<TextFormatType>\n intraword?: boolean\n tag: string\n type: 'text-format'\n}>\n\nexport type TextMatchTransformer = Readonly<{\n dependencies: Array<Klass<LexicalNode>>\n /**\n * Determines how a node should be exported to markdown\n */\n export?: (\n node: LexicalNode,\n\n exportChildren: (node: ElementNode) => string,\n\n exportFormat: (node: TextNode, textContent: string) => string,\n ) => null | string\n /**\n * For import operations, this function can be used to determine the end index of the match, after `importRegExp` has matched.\n * Without this function, the end index will be determined by the length of the match from `importRegExp`. Manually determining the end index can be useful if\n * the match from `importRegExp` is not the entire text content of the node. That way, `importRegExp` can be used to match only the start of the node, and `getEndIndex`\n * can be used to match the end of the node.\n *\n * @returns The end index of the match, or false if the match was unsuccessful and a different transformer should be tried.\n */\n getEndIndex?: (node: TextNode, match: RegExpMatchArray) => false | number\n /**\n * This regex determines what text is matched during markdown imports\n */\n importRegExp?: RegExp\n /**\n * This regex determines what text is matched for markdown shortcuts while typing in the editor\n */\n regExp: RegExp\n /**\n * Determines how the matched markdown text should be transformed into a node during the markdown import process\n *\n * @returns nothing, or a TextNode that may be a child of the new node that is created.\n * If a TextNode is returned, text format matching will be applied to it (e.g. bold, italic, etc.)\n */\n replace?: (node: TextNode, match: RegExpMatchArray) => TextNode | void\n /**\n * Single character that allows the transformer to trigger when typed in the editor. This does not affect markdown imports outside of the markdown shortcut plugin.\n * If the trigger is matched, the `regExp` will be used to match the text in the second step.\n */\n trigger?: string\n type: 'text-match'\n}>\n\nconst EMPTY_OR_WHITESPACE_ONLY = /^[\\t ]*$/\nconst ORDERED_LIST_REGEX = /^(\\s*)(\\d+)\\.\\s/\nconst UNORDERED_LIST_REGEX = /^(\\s*)[-*+]\\s/\nconst CHECK_LIST_REGEX = /^(\\s*)(?:-\\s)?\\s?(\\[(\\s|x)?\\])\\s/i\nconst HEADING_REGEX = /^(#{1,6})\\s/\nconst QUOTE_REGEX = /^>\\s/\nconst CODE_START_REGEX = /^[ \\t]*(\\\\`\\\\`\\\\`|```)(\\w+)?/\nconst CODE_END_REGEX = /[ \\t]*(\\\\`\\\\`\\\\`|```)$/\nconst CODE_SINGLE_LINE_REGEX = /^[ \\t]*```[^`]+(?:(?:`{1,2}|`{4,})[^`]+)*```(?:[^`]|$)/\nconst TABLE_ROW_REG_EXP = /^\\|(.+)\\|\\s?$/\nconst TABLE_ROW_DIVIDER_REG_EXP = /^(\\| ?:?-*:? ?)+\\|\\s?$/\nconst TAG_START_REGEX = /^[ \\t]*<[a-z_][\\w-]*(?:\\s[^<>]*)?\\/?>/i\nconst TAG_END_REGEX = /^[ \\t]*<\\/[a-z_][\\w-]*\\s*>/i\n\nconst createBlockNode = (\n createNode: (match: Array<string>) => ElementNode,\n): ElementTransformer['replace'] => {\n return (parentNode, children, match) => {\n const node = createNode(match)\n node.append(...children)\n parentNode.replace(node)\n node.select(0, 0)\n }\n}\n\n// Amount of spaces that define indentation level\n// TODO: should be an option\nconst LIST_INDENT_SIZE = 4\n\nfunction getIndent(whitespaces: string): number {\n const tabs = whitespaces.match(/\\t/g)\n const spaces = whitespaces.match(/ /g)\n\n let indent = 0\n\n if (tabs) {\n indent += tabs.length\n }\n\n if (spaces) {\n indent += Math.floor(spaces.length / LIST_INDENT_SIZE)\n }\n\n return indent\n}\n\nconst listReplace = (listType: ListType): ElementTransformer['replace'] => {\n return (parentNode, children, match) => {\n const previousNode = parentNode.getPreviousSibling()\n const nextNode = parentNode.getNextSibling()\n const listItem = $createListItemNode(listType === 'check' ? match[3] === 'x' : undefined)\n if ($isListNode(nextNode) && nextNode.getListType() === listType) {\n const firstChild = nextNode.getFirstChild()\n if (firstChild !== null) {\n firstChild.insertBefore(listItem)\n } else {\n // should never happen, but let's handle gracefully, just in case.\n nextNode.append(listItem)\n }\n parentNode.remove()\n } else if ($isListNode(previousNode) && previousNode.getListType() === listType) {\n previousNode.append(listItem)\n parentNode.remove()\n } else {\n const list = $createListNode(listType, listType === 'number' ? Number(match[2]) : undefined)\n list.append(listItem)\n parentNode.replace(list)\n }\n listItem.append(...children)\n listItem.select(0, 0)\n const indent = getIndent(match[1])\n if (indent) {\n listItem.setIndent(indent)\n }\n }\n}\n\nconst listExport = (\n listNode: ListNode,\n exportChildren: (node: ElementNode) => string,\n depth: number,\n): string => {\n const output: string[] = []\n const children = listNode.getChildren()\n let index = 0\n for (const listItemNode of children) {\n if ($isListItemNode(listItemNode)) {\n if (listItemNode.getChildrenSize() === 1) {\n const firstChild = listItemNode.getFirstChild()\n if ($isListNode(firstChild)) {\n output.push(listExport(firstChild, exportChildren, depth + 1))\n continue\n }\n }\n const indent = ' '.repeat(depth * LIST_INDENT_SIZE)\n const listType = listNode.getListType()\n const prefix =\n listType === 'number'\n ? `${listNode.getStart() + index}. `\n : listType === 'check'\n ? `- [${listItemNode.getChecked() ? 'x' : ' '}] `\n : '- '\n output.push(indent + prefix + exportChildren(listItemNode))\n index++\n }\n }\n\n return output.join('\\n')\n}\n\nexport const HEADING: ElementTransformer = {\n type: 'element',\n dependencies: [HeadingNode],\n export: (node, exportChildren) => {\n if (!$isHeadingNode(node)) {\n return null\n }\n const level = Number(node.getTag().slice(1))\n return '#'.repeat(level) + ' ' + exportChildren(node)\n },\n regExp: HEADING_REGEX,\n replace: createBlockNode((match) => {\n const tag = ('h' + match[1].length) as HeadingTagType\n return $createHeadingNode(tag)\n }),\n}\n\nexport const QUOTE: ElementTransformer = {\n type: 'element',\n dependencies: [QuoteNode],\n export: (node, exportChildren) => {\n if (!$isQuoteNode(node)) {\n return null\n }\n\n const lines = exportChildren(node).split('\\n')\n const output: string[] = []\n for (const line of lines) {\n output.push('> ' + line)\n }\n return output.join('\\n')\n },\n regExp: QUOTE_REGEX,\n replace: (parentNode, children, _match, isImport) => {\n if (isImport) {\n const previousNode = parentNode.getPreviousSibling()\n if ($isQuoteNode(previousNode)) {\n previousNode.splice(previousNode.getChildrenSize(), 0, [\n $createLineBreakNode(),\n ...children,\n ])\n previousNode.select(0, 0)\n parentNode.remove()\n return\n }\n }\n\n const node = $createQuoteNode()\n node.append(...children)\n parentNode.replace(node)\n node.select(0, 0)\n },\n}\n\nexport const UNORDERED_LIST: ElementTransformer = {\n type: 'element',\n dependencies: [ListNode, ListItemNode],\n export: (node, exportChildren) => {\n return $isListNode(node) ? listExport(node, exportChildren, 0) : null\n },\n regExp: UNORDERED_LIST_REGEX,\n replace: listReplace('bullet'),\n}\n\nexport const CHECK_LIST: ElementTransformer = {\n type: 'element',\n dependencies: [ListNode, ListItemNode],\n export: (node, exportChildren) => {\n return $isListNode(node) ? listExport(node, exportChildren, 0) : null\n },\n regExp: CHECK_LIST_REGEX,\n replace: listReplace('check'),\n}\n\nexport const ORDERED_LIST: ElementTransformer = {\n type: 'element',\n dependencies: [ListNode, ListItemNode],\n export: (node, exportChildren) => {\n return $isListNode(node) ? listExport(node, exportChildren, 0) : null\n },\n regExp: ORDERED_LIST_REGEX,\n replace: listReplace('number'),\n}\n\nexport const INLINE_CODE: TextFormatTransformer = {\n type: 'text-format',\n format: ['code'],\n tag: '`',\n}\n\nexport const HIGHLIGHT: TextFormatTransformer = {\n type: 'text-format',\n format: ['highlight'],\n tag: '==',\n}\n\nexport const BOLD_ITALIC_STAR: TextFormatTransformer = {\n type: 'text-format',\n format: ['bold', 'italic'],\n tag: '***',\n}\n\nexport const BOLD_ITALIC_UNDERSCORE: TextFormatTransformer = {\n type: 'text-format',\n format: ['bold', 'italic'],\n intraword: false,\n tag: '___',\n}\n\nexport const BOLD_STAR: TextFormatTransformer = {\n type: 'text-format',\n format: ['bold'],\n tag: '**',\n}\n\nexport const BOLD_UNDERSCORE: TextFormatTransformer = {\n type: 'text-format',\n format: ['bold'],\n intraword: false,\n tag: '__',\n}\n\nexport const STRIKETHROUGH: TextFormatTransformer = {\n type: 'text-format',\n format: ['strikethrough'],\n tag: '~~',\n}\n\nexport const ITALIC_STAR: TextFormatTransformer = {\n type: 'text-format',\n format: ['italic'],\n tag: '*',\n}\n\nexport const ITALIC_UNDERSCORE: TextFormatTransformer = {\n type: 'text-format',\n format: ['italic'],\n intraword: false,\n tag: '_',\n}\n\nexport function normalizeMarkdown(input: string, shouldMergeAdjacentLines: boolean): string {\n const lines = input.split('\\n')\n let inCodeBlock = false\n const sanitizedLines: string[] = []\n let nestedDeepCodeBlock = 0\n\n for (let i = 0; i < lines.length; i++) {\n const line = lines[i]\n const lastLine = sanitizedLines[sanitizedLines.length - 1]\n\n // Code blocks of ```single line``` don't toggle the inCodeBlock flag\n if (CODE_SINGLE_LINE_REGEX.test(line)) {\n sanitizedLines.push(line)\n continue\n }\n\n if (CODE_END_REGEX.test(line)) {\n if (nestedDeepCodeBlock === 0) {\n inCodeBlock = true\n }\n if (nestedDeepCodeBlock === 1) {\n inCodeBlock = false\n }\n if (nestedDeepCodeBlock > 0) {\n nestedDeepCodeBlock--\n }\n sanitizedLines.push(line)\n continue\n }\n\n // Toggle inCodeBlock state when encountering start or end of a code block\n if (CODE_START_REGEX.test(line)) {\n inCodeBlock = true\n nestedDeepCodeBlock++\n sanitizedLines.push(line)\n continue\n }\n\n // If we are inside a code block, keep the line unchanged\n if (inCodeBlock) {\n sanitizedLines.push(line)\n continue\n }\n\n // In markdown the concept of \"empty paragraphs\" does not exist.\n // Blocks must be separated by an empty line. Non-empty adjacent lines must be merged.\n if (\n EMPTY_OR_WHITESPACE_ONLY.test(line) ||\n EMPTY_OR_WHITESPACE_ONLY.test(lastLine) ||\n !lastLine ||\n HEADING_REGEX.test(lastLine) ||\n HEADING_REGEX.test(line) ||\n QUOTE_REGEX.test(line) ||\n ORDERED_LIST_REGEX.test(line) ||\n UNORDERED_LIST_REGEX.test(line) ||\n CHECK_LIST_REGEX.test(line) ||\n TABLE_ROW_REG_EXP.test(line) ||\n TABLE_ROW_DIVIDER_REG_EXP.test(line) ||\n !shouldMergeAdjacentLines ||\n TAG_START_REGEX.test(line) ||\n TAG_END_REGEX.test(line) ||\n TAG_START_REGEX.test(lastLine) ||\n TAG_END_REGEX.test(lastLine) ||\n CODE_END_REGEX.test(lastLine)\n ) {\n sanitizedLines.push(line)\n } else {\n sanitizedLines[sanitizedLines.length - 1] = lastLine + ' ' + line.trim()\n }\n }\n\n return sanitizedLines.join('\\n')\n}\n"],"mappings":"AAAA,sDACA;;;;;;wDAYA,SACEA,mBAAmB,EACnBC,eAAe,EACfC,eAAe,EACfC,WAAW,EACXC,YAAY,EACZC,QAAQ,QACH;AACP,SACEC,kBAAkB,EAClBC,gBAAgB,EAChBC,cAAc,EACdC,YAAY,EACZC,WAAW,EACXC,SAAS,QACJ;AACP,SAASC,oBAAoB,QAAQ;AA8JrC,MAAMC,wBAAA,GAA2B;AACjC,MAAMC,kBAAA,GAAqB;AAC3B,MAAMC,oBAAA,GAAuB;AAC7B,MAAMC,gBAAA,GAAmB;AACzB,MAAMC,aAAA,GAAgB;AACtB,MAAMC,WAAA,GAAc;AACpB,MAAMC,gBAAA,GAAmB;AACzB,MAAMC,cAAA,GAAiB;AACvB,MAAMC,sBAAA,GAAyB;AAC/B,MAAMC,iBAAA,GAAoB;AAC1B,MAAMC,yBAAA,GAA4B;AAClC,MAAMC,eAAA,GAAkB;AACxB,MAAMC,aAAA,GAAgB;AAEtB,MAAMC,eAAA,GACJC,UAAA;EAEA,OAAO,CAACC,UAAA,EAAYC,QAAA,EAAUC,KAAA;IAC5B,MAAMC,IAAA,GAAOJ,UAAA,CAAWG,KAAA;IACxBC,IAAA,CAAKC,MAAM,IAAIH,QAAA;IACfD,UAAA,CAAWK,OAAO,CAACF,IAAA;IACnBA,IAAA,CAAKG,MAAM,CAAC,GAAG;EACjB;AACF;AAEA;AACA;AACA,MAAMC,gBAAA,GAAmB;AAEzB,SAASC,UAAUC,WAAmB;EACpC,MAAMC,IAAA,GAAOD,WAAA,CAAYP,KAAK,CAAC;EAC/B,MAAMS,MAAA,GAASF,WAAA,CAAYP,KAAK,CAAC;EAEjC,IAAIU,MAAA,GAAS;EAEb,IAAIF,IAAA,EAAM;IACRE,MAAA,IAAUF,IAAA,CAAKG,MAAM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IAAI,CAAC1B,IAAA,KACrB9D,aAAA,CAAcwF,IAAI,CAAC1B,IAAA,KACnB/D,eAAA,CAAgByF,IAAI,CAACD,QAAA,KACrBvF,aAAA,CAAcwF,IAAI,CAACD,QAAA,KACnB5F,cAAA,CAAe6F,IAAI,CAACD,QAAA,GACpB;MACAH,cAAA,CAAexC,IAAI,CAACkB,IAAA;IACtB,OAAO;MACLsB,cAAc,CAACA,cAAA,CAAepE,MAAM,GAAG,EAAE,GAAGuE,QAAA,GAAW,MAAMzB,IAAA,CAAK2B,IAAI;IACxE;EACF;EAEA,OAAOL,cAAA,CAAenC,IAAI,CAAC;AAC7B","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/packages/@lexical/markdown/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAA;AAE1C,OAAO,KAAK,EACV,kBAAkB,EAClB,2BAA2B,EAC3B,qBAAqB,EACrB,oBAAoB,EACpB,WAAW,EACZ,MAAM,2BAA2B,CAAA;AAIlC,OAAO,EAAE,yBAAyB,EAAE,MAAM,wBAAwB,CAAA;AAClE,OAAO,EACL,gBAAgB,EAChB,sBAAsB,EACtB,SAAS,EACT,eAAe,EACf,UAAU,EACV,OAAO,EACP,SAAS,EACT,WAAW,EACX,WAAW,EACX,iBAAiB,EAEjB,YAAY,EACZ,KAAK,EACL,aAAa,EACb,cAAc,EACf,MAAM,2BAA2B,CAAA;AAElC,QAAA,MAAM,oBAAoB,EAAE,KAAK,CAAC,kBAAkB,CAKnD,CAAA;AAED,QAAA,MAAM,8BAA8B,EAAE,KAAK,CAAC,2BAA2B,CAAM,CAAA;AAM7E,QAAA,MAAM,wBAAwB,EAAE,KAAK,CAAC,qBAAqB,CAU1D,CAAA;AAED,QAAA,MAAM,uBAAuB,EAAE,KAAK,CAAC,oBAAoB,CAAM,CAAA;AAE/D,QAAA,MAAM,YAAY,EAAE,KAAK,CAAC,WAAW,CAKpC,CAAA;AAED;;;;;GAKG;AACH,iBAAS,0BAA0B,CACjC,QAAQ,EAAE,MAAM,EAChB,YAAY,GAAE,KAAK,CAAC,WAAW,CAAgB,EAC/C,IAAI,CAAC,EAAE,WAAW,EAClB,sBAAsB,UAAQ,EAC9B,wBAAwB,UAAQ,GAC/B,IAAI,CAMN;AAED;;GAEG;AACH,iBAAS,wBAAwB,CAC/B,YAAY,GAAE,KAAK,CAAC,WAAW,CAAgB,EAC/C,IAAI,CAAC,EAAE,WAAW,EAClB,sBAAsB,GAAE,OAAe,GACtC,MAAM,CAGR;AAED,OAAO,EACL,0BAA0B,EAC1B,wBAAwB,EACxB,gBAAgB,EAChB,sBAAsB,EACtB,SAAS,EACT,eAAe,EACf,UAAU,EACV,oBAAoB,EACpB,KAAK,kBAAkB,EACvB,OAAO,EACP,SAAS,EACT,WAAW,EACX,WAAW,EACX,iBAAiB,EACjB,8BAA8B,EAC9B,KAAK,2BAA2B,EAChC,YAAY,EACZ,KAAK,EACL,yBAAyB,EACzB,aAAa,EACb,wBAAwB,EACxB,uBAAuB,EACvB,KAAK,qBAAqB,EAC1B,KAAK,oBAAoB,EACzB,KAAK,WAAW,EAChB,YAAY,EACZ,cAAc,GACf,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/packages/@lexical/markdown/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAA;AAE1C,OAAO,KAAK,EACV,kBAAkB,EAClB,2BAA2B,EAC3B,qBAAqB,EACrB,oBAAoB,EACpB,WAAW,EACZ,MAAM,2BAA2B,CAAA;AAIlC,OAAO,EAAE,yBAAyB,EAAE,MAAM,wBAAwB,CAAA;AAClE,OAAO,EACL,gBAAgB,EAChB,sBAAsB,EACtB,SAAS,EACT,eAAe,EACf,UAAU,EACV,OAAO,EACP,SAAS,EACT,WAAW,E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MULTILINE_ELEMENT_TRANSFORMERS
23
23
  * @param {boolean} [shouldPreserveNewLines] By setting this to true, new lines will be preserved between conversions
24
24
  * @param {boolean} [shouldMergeAdjacentLines] By setting this to true, adjacent non empty lines will be merged according to commonmark spec: https://spec.commonmark.org/0.24/#example-177. Not applicable if shouldPreserveNewLines = true.
25
25
  */
26
- function $convertFromMarkdownString(markdown, transformers = TRANSFORMERS, node, shouldPreserveNewLines = false, shouldMergeAdjacentLines = false) {
26
+ function $convertFromMarkdownString(markdown, transformers = TRANSFORMERS, node, shouldPreserveNewLines = false, shouldMergeAdjacentLines = true) {
27
27
  const sanitizedMarkdown = shouldPreserveNewLines ? markdown : normalizeMarkdown(markdown, shouldMergeAdjacentLines);
28
28
  const importMarkdown = createMarkdownImport(transformers, shouldPreserveNewLines);
29
29
  return importMarkdown(sanitizedMarkdown, node);
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["createMarkdownExport","createMarkdownImport","registerMarkdownShortcuts","BOLD_ITALIC_STAR","BOLD_ITALIC_UNDERSCORE","BOLD_STAR","BOLD_UNDERSCORE","CHECK_LIST","HEADING","HIGHLIGHT","INLINE_CODE","ITALIC_STAR","ITALIC_UNDERSCORE","normalizeMarkdown","ORDERED_LIST","QUOTE","STRIKETHROUGH","UNORDERED_LIST","ELEMENT_TRANSFORMERS","MULTILINE_ELEMENT_TRANSFORMERS","TEXT_FORMAT_TRANSFORMERS","TEXT_MATCH_TRANSFORMERS","TRANSFORMERS","$convertFromMarkdownString","markdown","transformers","node","shouldPreserveNewLines","shouldMergeAdjacentLines","sanitizedMarkdown","importMarkdown","$convertToMarkdownString","exportMarkdown"],"sources":["../../../../src/packages/@lexical/markdown/index.ts"],"sourcesContent":["/**\n * Copyright (c) Meta Platforms, Inc. and affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n *\n */\n\nimport type { ElementNode } from 'lexical'\n\nimport type {\n ElementTransformer,\n MultilineElementTransformer,\n TextFormatTransformer,\n TextMatchTransformer,\n Transformer,\n} from './MarkdownTransformers.js'\n\nimport { createMarkdownExport } from './MarkdownExport.js'\nimport { createMarkdownImport } from './MarkdownImport.js'\nimport { registerMarkdownShortcuts } from './MarkdownShortcuts.js'\nimport {\n BOLD_ITALIC_STAR,\n BOLD_ITALIC_UNDERSCORE,\n BOLD_STAR,\n BOLD_UNDERSCORE,\n CHECK_LIST,\n HEADING,\n HIGHLIGHT,\n INLINE_CODE,\n ITALIC_STAR,\n ITALIC_UNDERSCORE,\n normalizeMarkdown,\n ORDERED_LIST,\n QUOTE,\n STRIKETHROUGH,\n UNORDERED_LIST,\n} from './MarkdownTransformers.js'\n\nconst ELEMENT_TRANSFORMERS: Array<ElementTransformer> = [\n HEADING,\n QUOTE,\n UNORDERED_LIST,\n ORDERED_LIST,\n]\n\nconst MULTILINE_ELEMENT_TRANSFORMERS: Array<MultilineElementTransformer> = []\n\n// Order of text format transformers matters:\n//\n// - code should go first as it prevents any transformations inside\n// - then longer tags match (e.g. ** or __ should go before * or _)\nconst TEXT_FORMAT_TRANSFORMERS: Array<TextFormatTransformer> = [\n INLINE_CODE,\n BOLD_ITALIC_STAR,\n BOLD_ITALIC_UNDERSCORE,\n BOLD_STAR,\n BOLD_UNDERSCORE,\n HIGHLIGHT,\n ITALIC_STAR,\n ITALIC_UNDERSCORE,\n STRIKETHROUGH,\n]\n\nconst TEXT_MATCH_TRANSFORMERS: Array<TextMatchTransformer> = []\n\nconst TRANSFORMERS: Array<Transformer> = [\n ...ELEMENT_TRANSFORMERS,\n ...MULTILINE_ELEMENT_TRANSFORMERS,\n ...TEXT_FORMAT_TRANSFORMERS,\n ...TEXT_MATCH_TRANSFORMERS,\n]\n\n/**\n * Renders markdown from a string. The selection is moved to the start after the operation.\n *\n * @param {boolean} [shouldPreserveNewLines] By setting this to true, new lines will be preserved between conversions\n * @param {boolean} [shouldMergeAdjacentLines] By setting this to true, adjacent non empty lines will be merged according to commonmark spec: https://spec.commonmark.org/0.24/#example-177. Not applicable if shouldPreserveNewLines = true.\n */\nfunction $convertFromMarkdownString(\n markdown: string,\n transformers: Array<Transformer> = TRANSFORMERS,\n node?: ElementNode,\n shouldPreserveNewLines = false,\n shouldMergeAdjacentLines = false,\n): void {\n const sanitizedMarkdown = shouldPreserveNewLines\n ? markdown\n : normalizeMarkdown(markdown, shouldMergeAdjacentLines)\n const importMarkdown = createMarkdownImport(transformers, shouldPreserveNewLines)\n return importMarkdown(sanitizedMarkdown, node)\n}\n\n/**\n * Renders string from markdown. The selection is moved to the start after the operation.\n */\nfunction $convertToMarkdownString(\n transformers: Array<Transformer> = TRANSFORMERS,\n node?: ElementNode,\n shouldPreserveNewLines: boolean = false,\n): string {\n const exportMarkdown = createMarkdownExport(transformers, shouldPreserveNewLines)\n return exportMarkdown(node)\n}\n\nexport {\n $convertFromMarkdownString,\n $convertToMarkdownString,\n BOLD_ITALIC_STAR,\n BOLD_ITALIC_UNDERSCORE,\n BOLD_STAR,\n BOLD_UNDERSCORE,\n CHECK_LIST,\n ELEMENT_TRANSFORMERS,\n type ElementTransformer,\n HEADING,\n HIGHLIGHT,\n INLINE_CODE,\n ITALIC_STAR,\n ITALIC_UNDERSCORE,\n MULTILINE_ELEMENT_TRANSFORMERS,\n type MultilineElementTransformer,\n ORDERED_LIST,\n QUOTE,\n registerMarkdownShortcuts,\n STRIKETHROUGH,\n TEXT_FORMAT_TRANSFORMERS,\n TEXT_MATCH_TRANSFORMERS,\n type TextFormatTransformer,\n type TextMatchTransformer,\n type Transformer,\n TRANSFORMERS,\n UNORDERED_LIST,\n}\n"],"mappings":"AAAA;;;;;;GAkBA,SAASA,oBAAoB,QAAQ;AACrC,SAASC,oBAAoB,QAAQ;AACrC,SAASC,yBAAyB,QAAQ;AAC1C,SACEC,gBAAgB,EAChBC,sBAAsB,EACtBC,SAAS,EACTC,eAAe,EACfC,UAAU,EACVC,OAAO,EACPC,SAAS,EACTC,WAAW,EACXC,WAAW,EACXC,iBAAiB,EACjBC,iBAAi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AY,EACZC,KAAK,EACLb,yBAAyB,EACzBc,aAAa,EACbI,wBAAwB,EACxBC,uBAAuB,EAIvBC,YAAY,EACZL,cAAc","ignoreList":[]}
1
+ {"version":3,"file":"index.js","names":["createMarkdownExport","createMarkdownImport","registerMarkdownShortcuts","BOLD_ITALIC_STAR","BOLD_ITALIC_UNDERSCORE","BOLD_STAR","BOLD_UNDERSCORE","CHECK_LIST","HEADING","HIGHLIGHT","INLINE_CODE","ITALIC_STAR","ITALIC_UNDERSCORE","normalizeMarkdown","ORDERED_LIST","QUOTE","STRIKETHROUGH","UNORDERED_LIST","ELEMENT_TRANSFORMERS","MULTILINE_ELEMENT_TRANSFORMERS","TEXT_FORMAT_TRANSFORMERS","TEXT_MATCH_TRANSFORMERS","TRANSFORMERS","$convertFromMarkdownString","markdown","transformers","node","shouldPreserveNewLines","shouldMergeAdjacentLines","sanitizedMarkdown","importMarkdown","$convertToMarkdownString","exportMarkdown"],"sources":["../../../../src/packages/@lexical/markdown/index.ts"],"sourcesContent":["/**\n * Copyright (c) Meta Platforms, Inc. and affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n *\n */\n\nimport type { ElementNode } from 'lexical'\n\nimport type {\n ElementTransformer,\n MultilineElementTransformer,\n TextFormatTransformer,\n TextMatchTransformer,\n Transformer,\n} from './MarkdownTransformers.js'\n\nimport { createMarkdownExport } from './MarkdownExport.js'\nimport { createMarkdownImport } from './MarkdownImport.js'\nimport { registerMarkdownShortcuts } from './MarkdownShortcuts.js'\nimport {\n BOLD_ITALIC_STAR,\n BOLD_ITALIC_UNDERSCORE,\n BOLD_STAR,\n BOLD_UNDERSCORE,\n CHECK_LIST,\n HEADING,\n HIGHLIGHT,\n INLINE_CODE,\n ITALIC_STAR,\n ITALIC_UNDERSCORE,\n normalizeMarkdown,\n ORDERED_LIST,\n QUOTE,\n STRIKETHROUGH,\n UNORDERED_LIST,\n} from './MarkdownTransformers.js'\n\nconst ELEMENT_TRANSFORMERS: Array<ElementTransformer> = [\n HEADING,\n QUOTE,\n UNORDERED_LIST,\n ORDERED_LIST,\n]\n\nconst MULTILINE_ELEMENT_TRANSFORMERS: Array<MultilineElementTransformer> = []\n\n// Order of text format transformers matters:\n//\n// - code should go first as it prevents any transformations inside\n// - then longer tags match (e.g. ** or __ should go before * or _)\nconst TEXT_FORMAT_TRANSFORMERS: Array<TextFormatTransformer> = [\n INLINE_CODE,\n BOLD_ITALIC_STAR,\n BOLD_ITALIC_UNDERSCORE,\n BOLD_STAR,\n BOLD_UNDERSCORE,\n HIGHLIGHT,\n ITALIC_STAR,\n ITALIC_UNDERSCORE,\n STRIKETHROUGH,\n]\n\nconst TEXT_MATCH_TRANSFORMERS: Array<TextMatchTransformer> = []\n\nconst TRANSFORMERS: Array<Transformer> = [\n ...ELEMENT_TRANSFORMERS,\n ...MULTILINE_ELEMENT_TRANSFORMERS,\n ...TEXT_FORMAT_TRANSFORMERS,\n ...TEXT_MATCH_TRANSFORMERS,\n]\n\n/**\n * Renders markdown from a string. The selection is moved to the start after the operation.\n *\n * @param {boolean} [shouldPreserveNewLines] By setting this to true, new lines will be preserved between conversions\n * @param {boolean} [shouldMergeAdjacentLines] By setting this to true, adjacent non empty lines will be merged according to commonmark spec: https://spec.commonmark.org/0.24/#example-177. Not applicable if shouldPreserveNewLines = true.\n */\nfunction $convertFromMarkdownString(\n markdown: string,\n transformers: Array<Transformer> = TRANSFORMERS,\n node?: ElementNode,\n shouldPreserveNewLines = false,\n shouldMergeAdjacentLines = true,\n): void {\n const sanitizedMarkdown = shouldPreserveNewLines\n ? markdown\n : normalizeMarkdown(markdown, shouldMergeAdjacentLines)\n const importMarkdown = createMarkdownImport(transformers, shouldPreserveNewLines)\n return importMarkdown(sanitizedMarkdown, node)\n}\n\n/**\n * Renders string from markdown. The selection is moved to the start after the operation.\n */\nfunction $convertToMarkdownString(\n transformers: Array<Transformer> = TRANSFORMERS,\n node?: ElementNode,\n shouldPreserveNewLines: boolean = false,\n): string {\n const exportMarkdown = createMarkdownExport(transformers, shouldPreserveNewLines)\n return exportMarkdown(node)\n}\n\nexport {\n $convertFromMarkdownString,\n $convertToMarkdownString,\n BOLD_ITALIC_STAR,\n BOLD_ITALIC_UNDERSCORE,\n BOLD_STAR,\n BOLD_UNDERSCORE,\n CHECK_LIST,\n ELEMENT_TRANSFORMERS,\n type ElementTransformer,\n HEADING,\n HIGHLIGHT,\n INLINE_CODE,\n ITALIC_STAR,\n ITALIC_UNDERSCORE,\n MULTILINE_ELEMENT_TRANSFORMERS,\n type MultilineElementTransformer,\n ORDERED_LIST,\n QUOTE,\n registerMarkdownShortcuts,\n STRIKETHROUGH,\n TEXT_FORMAT_TRANSFORMERS,\n TEXT_MATCH_TRANSFORMERS,\n type TextFormatTransformer,\n type TextMatchTransformer,\n type Transformer,\n TRANSFORMERS,\n UNORDERED_LIST,\n}\n"],"mappings":"AAAA;;;;;;GAkBA,SAASA,oBAAoB,QAAQ;AACrC,SAASC,oBAAoB,QAAQ;AACrC,SAASC,yBAAyB,QAAQ;AAC1C,SACEC,gBAAgB,EAChBC,sBAAsB,EACtBC,SAAS,EACTC,eAAe,EACfC,UAAU,EACVC,OAAO,EACPC,SAAS,EACTC,WAAW,EACXC,WAAW,EACXC,iBAAiB,EACjBC,iBAAiB,EACjBC,YAAY,EACZC,KAAK,EACLC,aAAa,EACbC,cAAc,QACT;AAEP,MAAMC,oBAAA,GAAkD,CACtDV,OAAA,EACAO,KAAA,EACAE,cAAA,EACAH,YAAA,CACD;AAED,MAAMK,8BAAA,GAAqE,EAAE;AAE7E;AACA;AACA;AACA;AACA,MAAMC,wBAAA,GAAyD,CAC7DV,WAAA,EACAP,gBAAA,EACAC,sBAAA,EACAC,SAAA,EACAC,eAAA,EACAG,SAAA,EACAE,WAAA,EACAC,iBAAA,EACAI,aAAA,CACD;AAED,MAAMK,uBAAA,GAAuD,EAAE;AAE/D,MAAMC,YAAA,GAAmC,C,GACpCJ,oBAAA,E,GACAC,8BAAA,E,GACAC,wBAAA,E,GACAC,uBAAA,CACJ;AAED;;;;;;AAMA,SAASE,2BACPC,QAAgB,EAChBC,YAAA,GAAmCH,YAAY,EAC/CI,IAAkB,EAClBC,sBAAA,GAAyB,KAAK,EAC9BC,wBAAA,GAA2B,IAAI;EAE/B,MAAMC,iBAAA,GAAoBF,sBAAA,GACtBH,QAAA,GACAX,iBAAA,CAAkBW,QAAA,EAAUI,wBAAA;EAChC,MAAME,cAAA,GAAiB7B,oBAAA,CAAqBwB,YAAA,EAAcE,sBAAA;EAC1D,OAAOG,cAAA,CAAeD,iBAAA,EAAmBH,IAAA;AAC3C;AAEA;;;AAGA,SAASK,yBACPN,YAAA,GAAmCH,YAAY,EAC/CI,IAAkB,EAClBC,sBAAA,GAAkC,KAAK;EAEvC,MAAMK,cAAA,GAAiBhC,oBAAA,CAAqByB,YAAA,EAAcE,sBAAA;EAC1D,OAAOK,cAAA,CAAeN,IAAA;AACxB;AAEA,SACEH,0BAA0B,EAC1BQ,wBAAwB,EACxB5B,gBAAgB,EAChBC,sBAAsB,EACtBC,SAAS,EACTC,eAAe,EACfC,UAAU,EACVW,oBAAoB,EAEpBV,OAAO,EACPC,SAAS,EACTC,WAAW,EACXC,WAAW,EACXC,iBAAiB,EACjBO,8BAA8B,EAE9BL,YAAY,EACZC,KAAK,EACLb,yBAAyB,EACzBc,aAAa,EACbI,wBAAwB,EACxBC,uBAAuB,EAIvBC,YAAY,EACZL,cAAc","ignoreList":[]}
package/dist/types.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import type { EditorConfig as LexicalEditorConfig, SerializedEditorState } from 'lexical';
2
- import type { ClientField, DefaultCellComponentProps, RichTextAdapter, RichTextFieldClient, RichTextFieldClientProps, SanitizedConfig, ServerFieldBase } from 'payload';
2
+ import type { ClientField, DefaultCellComponentProps, LabelFunction, RichTextAdapter, RichTextFieldClient, RichTextFieldClientProps, SanitizedConfig, ServerFieldBase, StaticLabel } from 'payload';
3
3
  import type { BaseClientFeatureProps, FeatureProviderProviderClient } from './features/typesClient.js';
4
4
  import type { FeatureProviderServer } from './features/typesServer.js';
5
5
  import type { SanitizedServerEditorConfig } from './lexical/config/types.js';
@@ -9,11 +9,18 @@ export type LexicalFieldAdminProps = {
9
9
  * Controls if the gutter (padding to the left & gray vertical line) should be hidden. @default false
10
10
  */
11
11
  hideGutter?: boolean;
12
+ /**
13
+ * Controls if the insert paragraph at the end button should be hidden. @default false
14
+ */
15
+ hideInsertParagraphAtEnd?: boolean;
12
16
  /**
13
17
  * Changes the placeholder text in the editor if no content is present.
14
18
  */
15
- placeholder?: string;
19
+ placeholder?: LabelFunction | StaticLabel;
16
20
  };
21
+ export type LexicalFieldAdminClientProps = {
22
+ placeholder?: string;
23
+ } & Omit<LexicalFieldAdminProps, 'placeholder'>;
17
24
  export type LexicalEditorProps = {
18
25
  admin?: LexicalFieldAdminProps;
19
26
  features?: (({ defaultFeatures, rootFeatures, }: {
@@ -65,7 +72,7 @@ export type FeatureClientSchemaMap = {
65
72
  [featureKey: string]: SingleFeatureClientSchemaMap;
66
73
  };
67
74
  export type LexicalRichTextFieldProps = {
68
- admin: LexicalFieldAdminProps;
75
+ admin?: LexicalFieldAdminClientProps;
69
76
  clientFeatures: {
70
77
  [featureKey: string]: {
71
78
  clientFeatureProps?: object;
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,IAAI,mBAAmB,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAA;AACzF,OAAO,KAAK,EACV,WAAW,EACX,yBAAyB,EACzB,eAAe,EACf,mBAAmB,EACnB,wBAAwB,EACxB,eAAe,EACf,eAAe,EAChB,MAAM,SAAS,CAAA;AAEhB,OAAO,KAAK,EACV,sBAAsB,EACtB,6BAA6B,EAC9B,MAAM,2BAA2B,CAAA;AAClC,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAA;AACtE,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,CAAC,EAChE,qBAAqB,CACtB,CAAA;AAED,MAAM,MAAM,YAAY,GAAG;IACzB,YAAY,EAAE,2BAA2B,CAAA;CAC1C,CAAA;AAED,MAAM,MAAM,iCAAiC,GAAG;IAC9C,aAAa,EAAE,6BAA6B,CAAC,GAAG,EAAE,GAAG,CAAC,CAAA;IACtD,kBAAkB,EAAE,sBAAsB,CAAC,MAAM,CAAC,CAAA;CACnD,CAAA"}
package/dist/types.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","names":[],"sources":["../src/types.ts"],"sourcesContent":["import type { EditorConfig as LexicalEditorConfig, SerializedEditorState } from 'lexical'\nimport type {\n ClientField,\n DefaultCellComponentProps,\n RichTextAdapter,\n RichTextFieldClient,\n RichTextFieldClientProps,\n SanitizedConfig,\n ServerFieldBase,\n} from 'payload'\n\nimport type {\n BaseClientFeatureProps,\n FeatureProviderProviderClient,\n} from './features/typesClient.js'\nimport type { FeatureProviderServer } from './features/typesServer.js'\nimport type { SanitizedServerEditorConfig } from './lexical/config/types.js'\nimport type { InitialLexicalFormState } from './utilities/buildInitialState.js'\n\nexport type LexicalFieldAdminProps = {\n /**\n * Controls if the gutter (padding to the left & gray vertical line) should be hidden. @default false\n */\n hideGutter?: boolean\n /**\n * Changes the placeholder text in the editor if no content is present.\n */\n placeholder?: string\n}\n\nexport type LexicalEditorProps = {\n admin?: LexicalFieldAdminProps\n features?:\n | (({\n defaultFeatures,\n rootFeatures,\n }: {\n /**\n * This opinionated array contains all \"recommended\" default features.\n *\n * @Example\n *\n * ```ts\n * editor: lexicalEditor({\n * features: ({ defaultFeatures }) => [...defaultFeatures, FixedToolbarFeature()],\n * })\n * ```\n */\n defaultFeatures: FeatureProviderServer<any, any, any>[]\n /**\n * This array contains all features that are enabled in the root richText editor (the one defined in the payload.config.ts).\n * If this field is the root richText editor, or if the root richText editor is not a lexical editor, this array will be empty.\n *\n * @Example\n *\n * ```ts\n * editor: lexicalEditor({\n * features: ({ rootFeatures }) => [...rootFeatures, FixedToolbarFeature()],\n * })\n * ```\n */\n rootFeatures: FeatureProviderServer<any, any, any>[]\n }) => FeatureProviderServer<any, any, any>[])\n | FeatureProviderServer<any, any, any>[]\n lexical?: LexicalEditorConfig\n}\n\nexport type LexicalRichTextAdapter = {\n editorConfig: SanitizedServerEditorConfig\n features: FeatureProviderServer<any, any, any>[]\n} & RichTextAdapter<SerializedEditorState, AdapterProps>\n\nexport type LexicalRichTextAdapterProvider =\n /**\n * This is being called during the payload sanitization process\n */\n ({\n config,\n isRoot,\n parentIsLocalized,\n }: {\n config: SanitizedConfig\n isRoot?: boolean\n parentIsLocalized: boolean\n }) => Promise<LexicalRichTextAdapter>\n\nexport type SingleFeatureClientSchemaMap = {\n [key: string]: ClientField[]\n}\nexport type FeatureClientSchemaMap = {\n [featureKey: string]: SingleFeatureClientSchemaMap\n}\n\nexport type LexicalRichTextFieldProps = {\n admin: LexicalFieldAdminProps\n // clientFeatures is added through the rsc field\n clientFeatures: {\n [featureKey: string]: {\n clientFeatureProps?: object\n clientFeatureProvider?: FeatureProviderProviderClient<any, any>\n }\n }\n featureClientSchemaMap: FeatureClientSchemaMap\n initialLexicalFormState: InitialLexicalFormState\n lexicalEditorConfig: LexicalEditorConfig | undefined // Undefined if default lexical editor config should be used\n} & Pick<ServerFieldBase, 'permissions'> &\n RichTextFieldClientProps<SerializedEditorState, AdapterProps, object>\n\nexport type LexicalRichTextCellProps = DefaultCellComponentProps<\n RichTextFieldClient<SerializedEditorState, AdapterProps, object>,\n SerializedEditorState\n>\n\nexport type AdapterProps = {\n editorConfig: SanitizedServerEditorConfig\n}\n\nexport type GeneratedFeatureProviderComponent = {\n clientFeature: FeatureProviderProviderClient<any, any>\n clientFeatureProps: BaseClientFeatureProps<object>\n}\n"],"mappings":"AAqHA","ignoreList":[]}
1
+ {"version":3,"file":"types.js","names":[],"sources":["../src/types.ts"],"sourcesContent":["import type { EditorConfig as LexicalEditorConfig, SerializedEditorState } from 'lexical'\nimport type {\n ClientField,\n DefaultCellComponentProps,\n LabelFunction,\n RichTextAdapter,\n RichTextFieldClient,\n RichTextFieldClientProps,\n SanitizedConfig,\n ServerFieldBase,\n StaticLabel,\n} from 'payload'\n\nimport type {\n BaseClientFeatureProps,\n FeatureProviderProviderClient,\n} from './features/typesClient.js'\nimport type { FeatureProviderServer } from './features/typesServer.js'\nimport type { SanitizedServerEditorConfig } from './lexical/config/types.js'\nimport type { InitialLexicalFormState } from './utilities/buildInitialState.js'\n\nexport type LexicalFieldAdminProps = {\n /**\n * Controls if the gutter (padding to the left & gray vertical line) should be hidden. @default false\n */\n hideGutter?: boolean\n /**\n * Controls if the insert paragraph at the end button should be hidden. @default false\n */\n hideInsertParagraphAtEnd?: boolean\n /**\n * Changes the placeholder text in the editor if no content is present.\n */\n placeholder?: LabelFunction | StaticLabel\n}\n\nexport type LexicalFieldAdminClientProps = {\n placeholder?: string\n} & Omit<LexicalFieldAdminProps, 'placeholder'>\n\nexport type LexicalEditorProps = {\n admin?: LexicalFieldAdminProps\n features?:\n | (({\n defaultFeatures,\n rootFeatures,\n }: {\n /**\n * This opinionated array contains all \"recommended\" default features.\n *\n * @Example\n *\n * ```ts\n * editor: lexicalEditor({\n * features: ({ defaultFeatures }) => [...defaultFeatures, FixedToolbarFeature()],\n * })\n * ```\n */\n defaultFeatures: FeatureProviderServer<any, any, any>[]\n /**\n * This array contains all features that are enabled in the root richText editor (the one defined in the payload.config.ts).\n * If this field is the root richText editor, or if the root richText editor is not a lexical editor, this array will be empty.\n *\n * @Example\n *\n * ```ts\n * editor: lexicalEditor({\n * features: ({ rootFeatures }) => [...rootFeatures, FixedToolbarFeature()],\n * })\n * ```\n */\n rootFeatures: FeatureProviderServer<any, any, any>[]\n }) => FeatureProviderServer<any, any, any>[])\n | FeatureProviderServer<any, any, any>[]\n lexical?: LexicalEditorConfig\n}\n\nexport type LexicalRichTextAdapter = {\n editorConfig: SanitizedServerEditorConfig\n features: FeatureProviderServer<any, any, any>[]\n} & RichTextAdapter<SerializedEditorState, AdapterProps>\n\nexport type LexicalRichTextAdapterProvider =\n /**\n * This is being called during the payload sanitization process\n */\n ({\n config,\n isRoot,\n parentIsLocalized,\n }: {\n config: SanitizedConfig\n isRoot?: boolean\n parentIsLocalized: boolean\n }) => Promise<LexicalRichTextAdapter>\n\nexport type SingleFeatureClientSchemaMap = {\n [key: string]: ClientField[]\n}\nexport type FeatureClientSchemaMap = {\n [featureKey: string]: SingleFeatureClientSchemaMap\n}\n\nexport type LexicalRichTextFieldProps = {\n admin?: LexicalFieldAdminClientProps\n // clientFeatures is added through the rsc field\n clientFeatures: {\n [featureKey: string]: {\n clientFeatureProps?: object\n clientFeatureProvider?: FeatureProviderProviderClient<any, any>\n }\n }\n featureClientSchemaMap: FeatureClientSchemaMap\n initialLexicalFormState: InitialLexicalFormState\n lexicalEditorConfig: LexicalEditorConfig | undefined // Undefined if default lexical editor config should be used\n} & Pick<ServerFieldBase, 'permissions'> &\n RichTextFieldClientProps<SerializedEditorState, AdapterProps, object>\n\nexport type LexicalRichTextCellProps = DefaultCellComponentProps<\n RichTextFieldClient<SerializedEditorState, AdapterProps, object>,\n SerializedEditorState\n>\n\nexport type AdapterProps = {\n editorConfig: SanitizedServerEditorConfig\n}\n\nexport type GeneratedFeatureProviderComponent = {\n clientFeature: FeatureProviderProviderClient<any, any>\n clientFeatureProps: BaseClientFeatureProps<object>\n}\n"],"mappings":"AA+HA","ignoreList":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@payloadcms/richtext-lexical",
3
- "version": "3.16.0",
3
+ "version": "3.16.1-canary.9004205",
4
4
  "description": "The officially supported Lexical richtext adapter for Payload",
5
5
  "homepage": "https://payloadcms.com",
6
6
  "repository": {
@@ -330,30 +330,30 @@
330
330
  ]
331
331
  },
332
332
  "dependencies": {
333
- "@lexical/headless": "0.20.0",
334
- "@lexical/html": "0.20.0",
335
- "@lexical/link": "0.20.0",
336
- "@lexical/list": "0.20.0",
337
- "@lexical/mark": "0.20.0",
338
- "@lexical/react": "0.20.0",
339
- "@lexical/rich-text": "0.20.0",
340
- "@lexical/selection": "0.20.0",
341
- "@lexical/utils": "0.20.0",
333
+ "@lexical/headless": "0.21.0",
334
+ "@lexical/html": "0.21.0",
335
+ "@lexical/link": "0.21.0",
336
+ "@lexical/list": "0.21.0",
337
+ "@lexical/mark": "0.21.0",
338
+ "@lexical/react": "0.21.0",
339
+ "@lexical/rich-text": "0.21.0",
340
+ "@lexical/selection": "0.21.0",
341
+ "@lexical/utils": "0.21.0",
342
342
  "@types/uuid": "10.0.0",
343
343
  "acorn": "8.12.1",
344
344
  "bson-objectid": "2.0.4",
345
345
  "dequal": "2.0.3",
346
346
  "escape-html": "1.0.3",
347
347
  "jsox": "1.2.121",
348
- "lexical": "0.20.0",
348
+ "lexical": "0.21.0",
349
349
  "mdast-util-from-markdown": "2.0.2",
350
350
  "mdast-util-mdx-jsx": "3.1.3",
351
351
  "micromark-extension-mdx-jsx": "3.0.1",
352
352
  "react-error-boundary": "4.1.2",
353
353
  "ts-essentials": "10.0.3",
354
354
  "uuid": "10.0.0",
355
- "@payloadcms/translations": "3.16.0",
356
- "@payloadcms/ui": "3.16.0"
355
+ "@payloadcms/translations": "3.16.1-canary.9004205",
356
+ "@payloadcms/ui": "3.16.1-canary.9004205"
357
357
  },
358
358
  "devDependencies": {
359
359
  "@babel/cli": "7.25.9",
@@ -361,7 +361,7 @@
361
361
  "@babel/preset-env": "7.26.0",
362
362
  "@babel/preset-react": "7.25.9",
363
363
  "@babel/preset-typescript": "7.26.0",
364
- "@lexical/eslint-plugin": "0.20.0",
364
+ "@lexical/eslint-plugin": "0.21.0",
365
365
  "@types/escape-html": "1.0.4",
366
366
  "@types/json-schema": "7.0.15",
367
367
  "@types/node": "22.5.4",
@@ -374,26 +374,26 @@
374
374
  "eslint-plugin-react-compiler": "19.0.0-beta-df7b47d-20241124",
375
375
  "swc-plugin-transform-remove-imports": "2.0.0",
376
376
  "@payloadcms/eslint-config": "3.9.0",
377
- "payload": "3.16.0"
377
+ "payload": "3.16.1-canary.9004205"
378
378
  },
379
379
  "peerDependencies": {
380
380
  "@faceless-ui/modal": "3.0.0-beta.2",
381
381
  "@faceless-ui/scroll-info": "2.0.0-beta.0",
382
- "@lexical/headless": "0.20.0",
383
- "@lexical/html": "0.20.0",
384
- "@lexical/link": "0.20.0",
385
- "@lexical/list": "0.20.0",
386
- "@lexical/mark": "0.20.0",
387
- "@lexical/react": "0.20.0",
388
- "@lexical/rich-text": "0.20.0",
389
- "@lexical/selection": "0.20.0",
390
- "@lexical/table": "0.20.0",
391
- "@lexical/utils": "0.20.0",
392
- "lexical": "0.20.0",
382
+ "@lexical/headless": "0.21.0",
383
+ "@lexical/html": "0.21.0",
384
+ "@lexical/link": "0.21.0",
385
+ "@lexical/list": "0.21.0",
386
+ "@lexical/mark": "0.21.0",
387
+ "@lexical/react": "0.21.0",
388
+ "@lexical/rich-text": "0.21.0",
389
+ "@lexical/selection": "0.21.0",
390
+ "@lexical/table": "0.21.0",
391
+ "@lexical/utils": "0.21.0",
392
+ "lexical": "0.21.0",
393
393
  "react": "^19.0.0 || ^19.0.0-rc-65a56d0e-20241020",
394
394
  "react-dom": "^19.0.0 || ^19.0.0-rc-65a56d0e-20241020",
395
- "@payloadcms/next": "3.16.0",
396
- "payload": "3.16.0"
395
+ "@payloadcms/next": "3.16.1-canary.9004205",
396
+ "payload": "3.16.1-canary.9004205"
397
397
  },
398
398
  "engines": {
399
399
  "node": "^18.20.2 || >=20.9.0"