@payloadcms/richtext-lexical 3.59.0-internal.cb85185 → 3.59.0-internal.cf8cc72

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 (205) hide show
  1. package/dist/exports/client/Field-EHRBYNHO.js +2 -0
  2. package/dist/exports/client/Field-EHRBYNHO.js.map +7 -0
  3. package/dist/exports/client/RelationshipComponent-APF3CN47.js +2 -0
  4. package/dist/exports/client/RelationshipComponent-APF3CN47.js.map +7 -0
  5. package/dist/exports/client/bundled.css +1 -1
  6. package/dist/exports/client/{chunk-TLQLXR6Q.js → chunk-2Y72RT72.js} +2 -2
  7. package/dist/exports/client/chunk-3BY5IZJD.js +2 -0
  8. package/dist/exports/client/chunk-3BY5IZJD.js.map +7 -0
  9. package/dist/exports/client/chunk-CYLMY5ZJ.js +2 -0
  10. package/dist/exports/client/chunk-CYLMY5ZJ.js.map +7 -0
  11. package/dist/exports/client/component-VDJI45F2.js +2 -0
  12. package/dist/exports/client/component-VDJI45F2.js.map +7 -0
  13. package/dist/exports/client/componentInline-7TPI7ZBC.js +2 -0
  14. package/dist/exports/client/index.d.ts +0 -3
  15. package/dist/exports/client/index.d.ts.map +1 -1
  16. package/dist/exports/client/index.js +10 -35
  17. package/dist/exports/client/index.js.map +4 -4
  18. package/dist/features/align/server/i18n.d.ts.map +1 -1
  19. package/dist/features/align/server/i18n.js +6 -0
  20. package/dist/features/align/server/i18n.js.map +1 -1
  21. package/dist/features/blockquote/server/i18n.d.ts.map +1 -1
  22. package/dist/features/blockquote/server/i18n.js +3 -0
  23. package/dist/features/blockquote/server/i18n.js.map +1 -1
  24. package/dist/features/blocks/client/component/BlockContent.d.ts +27 -52
  25. package/dist/features/blocks/client/component/BlockContent.d.ts.map +1 -1
  26. package/dist/features/blocks/client/component/BlockContent.js +51 -48
  27. package/dist/features/blocks/client/component/BlockContent.js.map +1 -1
  28. package/dist/features/blocks/client/component/components/BlockCollapsible.d.ts +9 -2
  29. package/dist/features/blocks/client/component/components/BlockCollapsible.d.ts.map +1 -1
  30. package/dist/features/blocks/client/component/components/BlockCollapsible.js +25 -7
  31. package/dist/features/blocks/client/component/components/BlockCollapsible.js.map +1 -1
  32. package/dist/features/blocks/client/component/index.d.ts.map +1 -1
  33. package/dist/features/blocks/client/component/index.js +56 -71
  34. package/dist/features/blocks/client/component/index.js.map +1 -1
  35. package/dist/features/blocks/client/componentInline/index.d.ts.map +1 -1
  36. package/dist/features/blocks/client/componentInline/index.js +11 -13
  37. package/dist/features/blocks/client/componentInline/index.js.map +1 -1
  38. package/dist/features/blocks/client/index.d.ts.map +1 -1
  39. package/dist/features/blocks/client/index.js +0 -5
  40. package/dist/features/blocks/client/index.js.map +1 -1
  41. package/dist/features/blocks/client/markdownTransformer.d.ts +17 -0
  42. package/dist/features/blocks/client/markdownTransformer.d.ts.map +1 -0
  43. package/dist/features/blocks/client/markdownTransformer.js +144 -0
  44. package/dist/features/blocks/client/markdownTransformer.js.map +1 -0
  45. package/dist/features/blocks/server/i18n.d.ts.map +1 -1
  46. package/dist/features/blocks/server/i18n.js +47 -38
  47. package/dist/features/blocks/server/i18n.js.map +1 -1
  48. package/dist/features/blocks/server/index.js +1 -1
  49. package/dist/features/blocks/server/index.js.map +1 -1
  50. package/dist/features/blocks/server/linesFromMatchToContentAndPropsString.d.ts.map +1 -0
  51. package/dist/features/blocks/server/linesFromMatchToContentAndPropsString.js.map +1 -0
  52. package/dist/features/blocks/server/markdownTransformer.d.ts +22 -0
  53. package/dist/features/blocks/server/markdownTransformer.d.ts.map +1 -0
  54. package/dist/features/blocks/server/{markdown/markdownTransformer.js → markdownTransformer.js} +48 -6
  55. package/dist/features/blocks/server/markdownTransformer.js.map +1 -0
  56. package/dist/features/experimental_table/client/plugins/TableHoverActionsPlugin/index.d.ts.map +1 -1
  57. package/dist/features/experimental_table/client/plugins/TableHoverActionsPlugin/index.js +3 -5
  58. package/dist/features/experimental_table/client/plugins/TableHoverActionsPlugin/index.js.map +1 -1
  59. package/dist/features/heading/server/i18n.d.ts.map +1 -1
  60. package/dist/features/heading/server/i18n.js +3 -0
  61. package/dist/features/heading/server/i18n.js.map +1 -1
  62. package/dist/features/horizontalRule/server/i18n.d.ts.map +1 -1
  63. package/dist/features/horizontalRule/server/i18n.js +3 -0
  64. package/dist/features/horizontalRule/server/i18n.js.map +1 -1
  65. package/dist/features/indent/server/i18n.d.ts.map +1 -1
  66. package/dist/features/indent/server/i18n.js +4 -0
  67. package/dist/features/indent/server/i18n.js.map +1 -1
  68. package/dist/features/link/client/plugins/floatingLinkEditor/LinkEditor/index.d.ts.map +1 -1
  69. package/dist/features/link/client/plugins/floatingLinkEditor/LinkEditor/index.js +1 -3
  70. package/dist/features/link/client/plugins/floatingLinkEditor/LinkEditor/index.js.map +1 -1
  71. package/dist/features/link/server/i18n.d.ts.map +1 -1
  72. package/dist/features/link/server/i18n.js +4 -0
  73. package/dist/features/link/server/i18n.js.map +1 -1
  74. package/dist/features/lists/checklist/server/i18n.d.ts.map +1 -1
  75. package/dist/features/lists/checklist/server/i18n.js +3 -0
  76. package/dist/features/lists/checklist/server/i18n.js.map +1 -1
  77. package/dist/features/lists/orderedList/server/i18n.d.ts.map +1 -1
  78. package/dist/features/lists/orderedList/server/i18n.js +3 -0
  79. package/dist/features/lists/orderedList/server/i18n.js.map +1 -1
  80. package/dist/features/lists/unorderedList/server/i18n.d.ts.map +1 -1
  81. package/dist/features/lists/unorderedList/server/i18n.js +3 -0
  82. package/dist/features/lists/unorderedList/server/i18n.js.map +1 -1
  83. package/dist/features/paragraph/server/i18n.d.ts.map +1 -1
  84. package/dist/features/paragraph/server/i18n.js +4 -0
  85. package/dist/features/paragraph/server/i18n.js.map +1 -1
  86. package/dist/features/relationship/client/components/RelationshipComponent.d.ts.map +1 -1
  87. package/dist/features/relationship/client/components/RelationshipComponent.js +9 -5
  88. package/dist/features/relationship/client/components/RelationshipComponent.js.map +1 -1
  89. package/dist/features/relationship/server/i18n.d.ts.map +1 -1
  90. package/dist/features/relationship/server/i18n.js +3 -0
  91. package/dist/features/relationship/server/i18n.js.map +1 -1
  92. package/dist/features/textState/i18n.d.ts.map +1 -1
  93. package/dist/features/textState/i18n.js +3 -0
  94. package/dist/features/textState/i18n.js.map +1 -1
  95. package/dist/features/toolbars/fixed/client/Toolbar/index.d.ts.map +1 -1
  96. package/dist/features/toolbars/fixed/client/Toolbar/index.js +1 -7
  97. package/dist/features/toolbars/fixed/client/Toolbar/index.js.map +1 -1
  98. package/dist/features/toolbars/inline/client/Toolbar/index.d.ts.map +1 -1
  99. package/dist/features/toolbars/inline/client/Toolbar/index.js +1 -3
  100. package/dist/features/toolbars/inline/client/Toolbar/index.js.map +1 -1
  101. package/dist/features/upload/client/component/index.d.ts.map +1 -1
  102. package/dist/features/upload/client/component/index.js +5 -6
  103. package/dist/features/upload/client/component/index.js.map +1 -1
  104. package/dist/features/upload/server/i18n.d.ts.map +1 -1
  105. package/dist/features/upload/server/i18n.js +3 -0
  106. package/dist/features/upload/server/i18n.js.map +1 -1
  107. package/dist/field/bundled.css +1 -1
  108. package/dist/field/rscEntry.d.ts.map +1 -1
  109. package/dist/field/rscEntry.js +0 -2
  110. package/dist/field/rscEntry.js.map +1 -1
  111. package/dist/i18n.d.ts.map +1 -1
  112. package/dist/i18n.js +6 -0
  113. package/dist/i18n.js.map +1 -1
  114. package/dist/index.d.ts +0 -1
  115. package/dist/index.d.ts.map +1 -1
  116. package/dist/index.js +0 -1
  117. package/dist/index.js.map +1 -1
  118. package/dist/lexical/LexicalEditor.d.ts.map +1 -1
  119. package/dist/lexical/LexicalEditor.js +8 -10
  120. package/dist/lexical/LexicalEditor.js.map +1 -1
  121. package/dist/lexical/ui/icons/CodeBlock/index.d.ts.map +1 -1
  122. package/dist/lexical/ui/icons/CodeBlock/index.js +15 -10
  123. package/dist/lexical/ui/icons/CodeBlock/index.js.map +1 -1
  124. package/dist/utilities/buildInitialState.d.ts +0 -1
  125. package/dist/utilities/buildInitialState.d.ts.map +1 -1
  126. package/dist/utilities/buildInitialState.js +0 -1
  127. package/dist/utilities/buildInitialState.js.map +1 -1
  128. package/dist/utilities/fieldsDrawer/DrawerContent.d.ts.map +1 -1
  129. package/dist/utilities/fieldsDrawer/DrawerContent.js +3 -7
  130. package/dist/utilities/fieldsDrawer/DrawerContent.js.map +1 -1
  131. package/dist/utilities/jsx/collectTopLevelJSXInLines.js +2 -2
  132. package/dist/utilities/jsx/collectTopLevelJSXInLines.js.map +1 -1
  133. package/package.json +6 -6
  134. package/dist/exports/client/Field-RQHCQRLV.js +0 -2
  135. package/dist/exports/client/Field-RQHCQRLV.js.map +0 -7
  136. package/dist/exports/client/RelationshipComponent-TSIENULZ.js +0 -2
  137. package/dist/exports/client/RelationshipComponent-TSIENULZ.js.map +0 -7
  138. package/dist/exports/client/chunk-BQCXN3B4.js +0 -2
  139. package/dist/exports/client/chunk-BQCXN3B4.js.map +0 -7
  140. package/dist/exports/client/chunk-XNERFY6G.js +0 -2
  141. package/dist/exports/client/chunk-XNERFY6G.js.map +0 -7
  142. package/dist/exports/client/component-CYFKY3IL.js +0 -2
  143. package/dist/exports/client/component-CYFKY3IL.js.map +0 -7
  144. package/dist/exports/client/componentInline-NGTRUSGB.js +0 -2
  145. package/dist/features/blocks/client/markdown/getLexicalToMarkdown.d.ts +0 -6
  146. package/dist/features/blocks/client/markdown/getLexicalToMarkdown.d.ts.map +0 -1
  147. package/dist/features/blocks/client/markdown/getLexicalToMarkdown.js +0 -24
  148. package/dist/features/blocks/client/markdown/getLexicalToMarkdown.js.map +0 -1
  149. package/dist/features/blocks/client/markdown/getMarkdownToLexical.d.ts +0 -6
  150. package/dist/features/blocks/client/markdown/getMarkdownToLexical.d.ts.map +0 -1
  151. package/dist/features/blocks/client/markdown/getMarkdownToLexical.js +0 -20
  152. package/dist/features/blocks/client/markdown/getMarkdownToLexical.js.map +0 -1
  153. package/dist/features/blocks/client/markdown/markdownTransformer.d.ts +0 -12
  154. package/dist/features/blocks/client/markdown/markdownTransformer.d.ts.map +0 -1
  155. package/dist/features/blocks/client/markdown/markdownTransformer.js +0 -348
  156. package/dist/features/blocks/client/markdown/markdownTransformer.js.map +0 -1
  157. package/dist/features/blocks/premade/CodeBlock/Component/Block.d.ts +0 -5
  158. package/dist/features/blocks/premade/CodeBlock/Component/Block.d.ts.map +0 -1
  159. package/dist/features/blocks/premade/CodeBlock/Component/Block.js +0 -156
  160. package/dist/features/blocks/premade/CodeBlock/Component/Block.js.map +0 -1
  161. package/dist/features/blocks/premade/CodeBlock/Component/Code.d.ts +0 -61
  162. package/dist/features/blocks/premade/CodeBlock/Component/Code.d.ts.map +0 -1
  163. package/dist/features/blocks/premade/CodeBlock/Component/Code.js +0 -99
  164. package/dist/features/blocks/premade/CodeBlock/Component/Code.js.map +0 -1
  165. package/dist/features/blocks/premade/CodeBlock/Component/Collapse/index.d.ts +0 -4
  166. package/dist/features/blocks/premade/CodeBlock/Component/Collapse/index.d.ts.map +0 -1
  167. package/dist/features/blocks/premade/CodeBlock/Component/Collapse/index.js +0 -17
  168. package/dist/features/blocks/premade/CodeBlock/Component/Collapse/index.js.map +0 -1
  169. package/dist/features/blocks/premade/CodeBlock/Component/FloatingCollapse/index.d.ts +0 -4
  170. package/dist/features/blocks/premade/CodeBlock/Component/FloatingCollapse/index.d.ts.map +0 -1
  171. package/dist/features/blocks/premade/CodeBlock/Component/FloatingCollapse/index.js +0 -26
  172. package/dist/features/blocks/premade/CodeBlock/Component/FloatingCollapse/index.js.map +0 -1
  173. package/dist/features/blocks/premade/CodeBlock/converter.d.ts +0 -7
  174. package/dist/features/blocks/premade/CodeBlock/converter.d.ts.map +0 -1
  175. package/dist/features/blocks/premade/CodeBlock/converter.js +0 -46
  176. package/dist/features/blocks/premade/CodeBlock/converter.js.map +0 -1
  177. package/dist/features/blocks/premade/CodeBlock/converterClient.d.ts +0 -2
  178. package/dist/features/blocks/premade/CodeBlock/converterClient.d.ts.map +0 -1
  179. package/dist/features/blocks/premade/CodeBlock/converterClient.js +0 -4
  180. package/dist/features/blocks/premade/CodeBlock/converterClient.js.map +0 -1
  181. package/dist/features/blocks/premade/CodeBlock/index.d.ts +0 -7
  182. package/dist/features/blocks/premade/CodeBlock/index.d.ts.map +0 -1
  183. package/dist/features/blocks/premade/CodeBlock/index.js +0 -52
  184. package/dist/features/blocks/premade/CodeBlock/index.js.map +0 -1
  185. package/dist/features/blocks/server/markdown/getLexicalToMarkdown.d.ts +0 -6
  186. package/dist/features/blocks/server/markdown/getLexicalToMarkdown.d.ts.map +0 -1
  187. package/dist/features/blocks/server/markdown/getLexicalToMarkdown.js +0 -27
  188. package/dist/features/blocks/server/markdown/getLexicalToMarkdown.js.map +0 -1
  189. package/dist/features/blocks/server/markdown/getMarkdownToLexical.d.ts +0 -7
  190. package/dist/features/blocks/server/markdown/getMarkdownToLexical.d.ts.map +0 -1
  191. package/dist/features/blocks/server/markdown/getMarkdownToLexical.js +0 -22
  192. package/dist/features/blocks/server/markdown/getMarkdownToLexical.js.map +0 -1
  193. package/dist/features/blocks/server/markdown/linesFromMatchToContentAndPropsString.d.ts.map +0 -1
  194. package/dist/features/blocks/server/markdown/linesFromMatchToContentAndPropsString.js.map +0 -1
  195. package/dist/features/blocks/server/markdown/markdownTransformer.d.ts +0 -15
  196. package/dist/features/blocks/server/markdown/markdownTransformer.d.ts.map +0 -1
  197. package/dist/features/blocks/server/markdown/markdownTransformer.js.map +0 -1
  198. package/dist/lexical/ui/icons/Collapse/index.d.ts +0 -3
  199. package/dist/lexical/ui/icons/Collapse/index.d.ts.map +0 -1
  200. package/dist/lexical/ui/icons/Collapse/index.js +0 -18
  201. package/dist/lexical/ui/icons/Collapse/index.js.map +0 -1
  202. /package/dist/exports/client/{chunk-TLQLXR6Q.js.map → chunk-2Y72RT72.js.map} +0 -0
  203. /package/dist/exports/client/{componentInline-NGTRUSGB.js.map → componentInline-7TPI7ZBC.js.map} +0 -0
  204. /package/dist/features/blocks/server/{markdown/linesFromMatchToContentAndPropsString.d.ts → linesFromMatchToContentAndPropsString.d.ts} +0 -0
  205. /package/dist/features/blocks/server/{markdown/linesFromMatchToContentAndPropsString.js → linesFromMatchToContentAndPropsString.js} +0 -0
@@ -1,156 +0,0 @@
1
- 'use client';
2
-
3
- import { c as _c } from "react/compiler-runtime";
4
- import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
5
- import { useLexicalEditable } from '@lexical/react/useLexicalEditable';
6
- import { ChevronIcon, CopyToClipboard, Popup, PopupList, RenderFields, useForm, useFormFields } from '@payloadcms/ui';
7
- import React from 'react';
8
- import { CodeBlockIcon } from '../../../../../lexical/ui/icons/CodeBlock/index.js';
9
- import { useBlockComponentContext } from '../../../client/component/BlockContent.js';
10
- import { Collapse } from './Collapse/index.js';
11
- import { FloatingCollapse } from './FloatingCollapse/index.js';
12
- const baseClass = 'payload-richtext-code-block';
13
- export const CodeBlockBlockComponent = args => {
14
- const $ = _c(15);
15
- const {
16
- languages
17
- } = args;
18
- const {
19
- BlockCollapsible,
20
- formSchema,
21
- RemoveButton
22
- } = useBlockComponentContext();
23
- const {
24
- setModified
25
- } = useForm();
26
- const {
27
- codeField
28
- } = useFormFields(_temp);
29
- let t0;
30
- if ($[0] !== setModified) {
31
- t0 = t1 => {
32
- const [fields_0, dispatch] = t1;
33
- return {
34
- selectedLanguageField: fields_0?.language,
35
- setSelectedLanguage: language => {
36
- dispatch({
37
- type: "UPDATE",
38
- path: "language",
39
- value: language
40
- });
41
- setModified(true);
42
- }
43
- };
44
- };
45
- $[0] = setModified;
46
- $[1] = t0;
47
- } else {
48
- t0 = $[1];
49
- }
50
- const {
51
- selectedLanguageField,
52
- setSelectedLanguage
53
- } = useFormFields(t0);
54
- const selectedLanguageLabel = languages[selectedLanguageField?.value];
55
- const isEditable = useLexicalEditable();
56
- const t1 = selectedLanguageField?.value;
57
- let t2;
58
- if ($[2] !== BlockCollapsible || $[3] !== RemoveButton || $[4] !== codeField?.value || $[5] !== formSchema || $[6] !== isEditable || $[7] !== languages || $[8] !== selectedLanguageLabel || $[9] !== setSelectedLanguage || $[10] !== t1) {
59
- let t3;
60
- if ($[12] !== languages || $[13] !== setSelectedLanguage) {
61
- t3 = t4 => {
62
- const {
63
- close
64
- } = t4;
65
- return _jsx(PopupList.ButtonGroup, {
66
- children: Object.entries(languages).map(t5 => {
67
- const [languageCode, languageLabel] = t5;
68
- return _jsx(PopupList.Button, {
69
- active: false,
70
- disabled: false,
71
- onClick: () => {
72
- setSelectedLanguage(languageCode);
73
- close();
74
- },
75
- children: _jsx("span", {
76
- className: `${baseClass}__language-code`,
77
- "data-language": languageCode,
78
- children: languageLabel
79
- })
80
- }, languageCode);
81
- })
82
- });
83
- };
84
- $[12] = languages;
85
- $[13] = setSelectedLanguage;
86
- $[14] = t3;
87
- } else {
88
- t3 = $[14];
89
- }
90
- t2 = _jsx(BlockCollapsible, {
91
- Actions: _jsxs("div", {
92
- className: `${baseClass}__actions`,
93
- children: [_jsx(Popup, {
94
- button: _jsxs("div", {
95
- className: `${baseClass}__language-selector-button`,
96
- "data-selected-language": t1,
97
- children: [_jsx("span", {
98
- children: selectedLanguageLabel
99
- }), _jsx(ChevronIcon, {
100
- className: `${baseClass}__chevron`
101
- })]
102
- }),
103
- className: `${baseClass}__language-selector`,
104
- disabled: !isEditable,
105
- horizontalAlign: "right",
106
- render: t3,
107
- showScrollbar: true,
108
- size: "large"
109
- }), _jsx(CopyToClipboard, {
110
- value: codeField?.value ?? ""
111
- }), _jsx(Collapse, {}), isEditable && _jsx(RemoveButton, {})]
112
- }),
113
- className: baseClass,
114
- collapsibleProps: {
115
- AfterCollapsible: _jsx(FloatingCollapse, {}),
116
- disableHeaderToggle: true,
117
- disableToggleIndicator: true
118
- },
119
- Pill: _jsx("div", {
120
- className: `${baseClass}__pill`,
121
- children: _jsx(CodeBlockIcon, {})
122
- }),
123
- children: _jsx(_Fragment, {
124
- children: _jsx(RenderFields, {
125
- fields: formSchema,
126
- forceRender: true,
127
- parentIndexPath: "",
128
- parentPath: "",
129
- parentSchemaPath: "",
130
- permissions: true,
131
- readOnly: !isEditable
132
- })
133
- })
134
- });
135
- $[2] = BlockCollapsible;
136
- $[3] = RemoveButton;
137
- $[4] = codeField?.value;
138
- $[5] = formSchema;
139
- $[6] = isEditable;
140
- $[7] = languages;
141
- $[8] = selectedLanguageLabel;
142
- $[9] = setSelectedLanguage;
143
- $[10] = t1;
144
- $[11] = t2;
145
- } else {
146
- t2 = $[11];
147
- }
148
- return t2;
149
- };
150
- function _temp(t0) {
151
- const [fields] = t0;
152
- return {
153
- codeField: fields?.code
154
- };
155
- }
156
- //# sourceMappingURL=Block.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Block.js","names":["c","_c","useLexicalEditable","ChevronIcon","CopyToClipboard","Popup","PopupList","RenderFields","useForm","useFormFields","React","CodeBlockIcon","useBlockComponentContext","Collapse","FloatingCollapse","baseClass","CodeBlockBlockComponent","args","$","languages","BlockCollapsible","formSchema","RemoveButton","setModified","codeField","_temp","t0","t1","fields_0","dispatch","selectedLanguageField","fields","language","setSelectedLanguage","type","path","value","selectedLanguageLabel","isEditable","t2","t3","t4","close","_jsx","ButtonGroup","children","Object","entries","map","t5","languageCode","languageLabel","Button","active","disabled","onClick","className","Actions","_jsxs","button","horizontalAlign","render","disableHeaderToggle","disableToggleIndicator","Pill","_Fragment","forceRender","parentIndexPath","parentPath","parentSchemaPath","permissions","readOnly","code"],"sources":["../../../../../../src/features/blocks/premade/CodeBlock/Component/Block.tsx"],"sourcesContent":["'use client'\nimport type {} from 'payload'\n\nimport { useLexicalEditable } from '@lexical/react/useLexicalEditable'\n\nimport './index.scss'\n\nimport {\n ChevronIcon,\n CopyToClipboard,\n Popup,\n PopupList,\n RenderFields,\n useForm,\n useFormFields,\n} from '@payloadcms/ui'\nimport React from 'react'\n\nimport type { AdditionalCodeComponentProps } from './Code.js'\n\nimport { CodeBlockIcon } from '../../../../../lexical/ui/icons/CodeBlock/index.js'\nimport { useBlockComponentContext } from '../../../client/component/BlockContent.js'\nimport { Collapse } from './Collapse/index.js'\nimport { FloatingCollapse } from './FloatingCollapse/index.js'\n\nconst baseClass = 'payload-richtext-code-block'\nexport const CodeBlockBlockComponent: React.FC<\n Required<Pick<AdditionalCodeComponentProps, 'languages'>>\n> = (args) => {\n const { languages } = args\n const { BlockCollapsible, formSchema, RemoveButton } = useBlockComponentContext()\n const { setModified } = useForm()\n\n const { codeField } = useFormFields(([fields]) => ({\n codeField: fields?.code,\n }))\n\n const { selectedLanguageField, setSelectedLanguage } = useFormFields(([fields, dispatch]) => ({\n selectedLanguageField: fields?.language,\n setSelectedLanguage: (language: string) => {\n dispatch({\n type: 'UPDATE',\n path: 'language',\n value: language,\n })\n setModified(true)\n },\n }))\n\n const selectedLanguageLabel = languages[selectedLanguageField?.value as keyof typeof languages]\n\n const isEditable = useLexicalEditable()\n\n return (\n <BlockCollapsible\n Actions={\n <div className={`${baseClass}__actions`}>\n <Popup\n button={\n <div\n className={`${baseClass}__language-selector-button`}\n data-selected-language={selectedLanguageField?.value}\n >\n <span>{selectedLanguageLabel}</span>\n <ChevronIcon className={`${baseClass}__chevron`} />\n </div>\n }\n className={`${baseClass}__language-selector`}\n disabled={!isEditable}\n horizontalAlign=\"right\"\n render={({ close }) => (\n <PopupList.ButtonGroup>\n {Object.entries(languages).map(([languageCode, languageLabel]) => {\n return (\n <PopupList.Button\n active={false}\n disabled={false}\n key={languageCode}\n onClick={() => {\n setSelectedLanguage(languageCode)\n close()\n }}\n >\n <span className={`${baseClass}__language-code`} data-language={languageCode}>\n {languageLabel}\n </span>\n </PopupList.Button>\n )\n })}\n </PopupList.ButtonGroup>\n )}\n showScrollbar\n size=\"large\"\n />\n <CopyToClipboard value={(codeField?.value as string) ?? ''} />\n\n <Collapse />\n\n {isEditable && <RemoveButton />}\n </div>\n }\n className={baseClass}\n collapsibleProps={{\n AfterCollapsible: <FloatingCollapse />,\n disableHeaderToggle: true,\n disableToggleIndicator: true,\n }}\n Pill={\n <div className={`${baseClass}__pill`}>\n <CodeBlockIcon />\n </div>\n }\n >\n <>\n <RenderFields\n fields={formSchema}\n forceRender={true}\n parentIndexPath=\"\"\n parentPath={''}\n parentSchemaPath=\"\"\n permissions={true}\n readOnly={!isEditable}\n />\n </>\n </BlockCollapsible>\n )\n}\n"],"mappings":"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","ignoreList":[]}
@@ -1,61 +0,0 @@
1
- import type { CodeFieldClientProps } from 'payload';
2
- import React from 'react';
3
- export type AdditionalCodeComponentProps = {
4
- /**
5
- * @default first key of the `languages` prop
6
- */
7
- defaultLanguage?: string;
8
- /**
9
- * @default
10
- * {
11
- * js: 'JavaScript',
12
- * plaintext: 'Plain Text',
13
- * ts: 'TypeScript',
14
- * }
15
- */
16
- languages?: Record<string, string>;
17
- /**
18
- * Override the name of the block.
19
- *
20
- * @default 'Code'
21
- */
22
- slug?: string;
23
- /**
24
- * Configure typescript settings for the editor
25
- */
26
- typescript?: {
27
- /**
28
- * By default, the editor will not perform semantic validation. This means that
29
- * while syntax errors will be highlighted, other issues like missing imports or incorrect
30
- * types will not be.
31
- *
32
- * @default false
33
- */
34
- enableSemanticValidation?: boolean;
35
- /**
36
- * Additional types to fetch and include in the editor for autocompletion.
37
- *
38
- * For example, to include types for payload, you would set this to
39
- *
40
- * [{ url: 'https://unpkg.com/payload@latest/dist/index.d.ts', filePath: 'file:///node_modules/payload/index.d.ts' }]
41
- */
42
- fetchTypes?: Array<{
43
- filePath: string;
44
- url: string;
45
- }>;
46
- /**
47
- * @default undefined
48
- */
49
- paths?: Record<string, string[]>;
50
- /**
51
- * @default "ESNext"
52
- */
53
- target?: string;
54
- /**
55
- * @default ['node_modules/@types']
56
- */
57
- typeRoots?: string[];
58
- };
59
- };
60
- export declare const CodeComponent: React.FC<AdditionalCodeComponentProps & CodeFieldClientProps>;
61
- //# sourceMappingURL=Code.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Code.d.ts","sourceRoot":"","sources":["../../../../../../src/features/blocks/premade/CodeBlock/Component/Code.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAmB,oBAAoB,EAAE,MAAM,SAAS,CAAA;AAGpE,OAAO,KAAkB,MAAM,OAAO,CAAA;AAEtC,MAAM,MAAM,4BAA4B,GAAG;IACzC;;OAEG;IACH,eAAe,CAAC,EAAE,MAAM,CAAA;IACxB;;;;;;;OAOG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAClC;;;;OAIG;IACH,IAAI,CAAC,EAAE,MAAM,CAAA;IACb;;OAEG;IACH,UAAU,CAAC,EAAE;QACX;;;;;;WAMG;QACH,wBAAwB,CAAC,EAAE,OAAO,CAAA;QAClC;;;;;;WAMG;QACH,UAAU,CAAC,EAAE,KAAK,CAAC;YACjB,QAAQ,EAAE,MAAM,CAAA;YAChB,GAAG,EAAE,MAAM,CAAA;SACZ,CAAC,CAAA;QACF;;WAEG;QACH,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAA;QAChC;;WAEG;QACH,MAAM,CAAC,EAAE,MAAM,CAAA;QACf;;WAEG;QACH,SAAS,CAAC,EAAE,MAAM,EAAE,CAAA;KACrB,CAAA;CACF,CAAA;AAED,eAAO,MAAM,aAAa,EAAE,KAAK,CAAC,EAAE,CAAC,4BAA4B,GAAG,oBAAoB,CAwHvF,CAAA"}
@@ -1,99 +0,0 @@
1
- 'use client';
2
-
3
- import { jsx as _jsx } from "react/jsx-runtime";
4
- import { CodeField, useFormFields } from '@payloadcms/ui';
5
- import React, { useMemo } from 'react';
6
- export const CodeComponent = ({
7
- autoComplete,
8
- field,
9
- forceRender,
10
- languages = {
11
- js: 'JavaScript',
12
- plaintext: 'Plain Text',
13
- ts: 'TypeScript'
14
- },
15
- path,
16
- permissions,
17
- readOnly,
18
- renderedBlocks,
19
- schemaPath,
20
- typescript,
21
- validate
22
- }) => {
23
- const languageField = useFormFields(([fields]) => fields['language']);
24
- const language = languageField?.value || languageField?.initialValue || 'typescript';
25
- const label = languages[language];
26
- const props = useMemo(() => ({
27
- ...field,
28
- type: 'code',
29
- admin: {
30
- ...field.admin,
31
- editorOptions: {},
32
- editorProps: {
33
- // If typescript is set, @monaco-editor/react needs to set the URI to a .ts or .tsx file when it calls createModel().
34
- // This is done through the `defaultPath` prop.
35
- defaultPath: language === 'ts' ? 'file.tsx' : undefined
36
- },
37
- language
38
- }
39
- }), [field, language]);
40
- const key = `${field.name}-${language}-${label}`;
41
- return props && /*#__PURE__*/_jsx(CodeField, {
42
- autoComplete: autoComplete,
43
- field: props,
44
- forceRender: forceRender,
45
- onMount: (_editor, monaco) => {
46
- monaco.editor.defineTheme('vs-dark', {
47
- base: 'vs-dark',
48
- colors: {
49
- 'editor.background': '#222222'
50
- },
51
- inherit: true,
52
- rules: []
53
- });
54
- monaco.editor.defineTheme('vs', {
55
- base: 'vs',
56
- colors: {
57
- 'editor.background': '#f5f5f5'
58
- },
59
- inherit: true,
60
- rules: []
61
- });
62
- monaco.languages.typescript.typescriptDefaults.setCompilerOptions({
63
- allowNonTsExtensions: true,
64
- // Set module resolution to NodeJs to enable autocompletion
65
- allowJs: true,
66
- allowSyntheticDefaultImports: true,
67
- esModuleInterop: true,
68
- jsx: monaco.languages.typescript.JsxEmit.React,
69
- moduleResolution: monaco.languages.typescript.ModuleResolutionKind.NodeJs,
70
- noEmit: true,
71
- paths: typescript?.paths,
72
- reactNamespace: 'React',
73
- target: monaco.languages.typescript.ScriptTarget[typescript?.target ?? 'ESNext'],
74
- typeRoots: typescript?.typeRoots ?? ['node_modules/@types']
75
- });
76
- monaco.languages.typescript.typescriptDefaults.setDiagnosticsOptions({
77
- noSemanticValidation: typescript?.enableSemanticValidation ? false : true,
78
- noSyntaxValidation: false
79
- });
80
- const run = async () => {
81
- if (typescript?.fetchTypes && Array.isArray(typescript.fetchTypes) && typescript.fetchTypes.length > 0) {
82
- await Promise.all(typescript.fetchTypes.map(async type => {
83
- const types = await fetch(type.url);
84
- const typesText = await types.text();
85
- monaco.languages.typescript.typescriptDefaults.addExtraLib(typesText, type.filePath);
86
- }));
87
- }
88
- };
89
- void run();
90
- },
91
- path: path,
92
- permissions: permissions,
93
- readOnly: readOnly,
94
- renderedBlocks: renderedBlocks,
95
- schemaPath: schemaPath,
96
- validate: validate
97
- }, key);
98
- };
99
- //# sourceMappingURL=Code.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Code.js","names":["CodeField","useFormFields","React","useMemo","CodeComponent","autoComplete","field","forceRender","languages","js","plaintext","ts","path","permissions","readOnly","renderedBlocks","schemaPath","typescript","validate","languageField","fields","language","value","initialValue","label","props","type","admin","editorOptions","editorProps","defaultPath","undefined","key","name","_jsx","onMount","_editor","monaco","editor","defineTheme","base","colors","inherit","rules","typescriptDefaults","setCompilerOptions","allowNonTsExtensions","allowJs","allowSyntheticDefaultImports","esModuleInterop","jsx","JsxEmit","moduleResolution","ModuleResolutionKind","NodeJs","noEmit","paths","reactNamespace","target","ScriptTarget","typeRoots","setDiagnosticsOptions","noSemanticValidation","enableSemanticValidation","noSyntaxValidation","run","fetchTypes","Array","isArray","length","Promise","all","map","types","fetch","url","typesText","text","addExtraLib","filePath"],"sources":["../../../../../../src/features/blocks/premade/CodeBlock/Component/Code.tsx"],"sourcesContent":["'use client'\n\nimport type { CodeFieldClient, CodeFieldClientProps } from 'payload'\n\nimport { CodeField, useFormFields } from '@payloadcms/ui'\nimport React, { useMemo } from 'react'\n\nexport type AdditionalCodeComponentProps = {\n /**\n * @default first key of the `languages` prop\n */\n defaultLanguage?: string\n /**\n * @default\n * {\n * js: 'JavaScript',\n * plaintext: 'Plain Text',\n * ts: 'TypeScript',\n * }\n */\n languages?: Record<string, string>\n /**\n * Override the name of the block.\n *\n * @default 'Code'\n */\n slug?: string\n /**\n * Configure typescript settings for the editor\n */\n typescript?: {\n /**\n * By default, the editor will not perform semantic validation. This means that\n * while syntax errors will be highlighted, other issues like missing imports or incorrect\n * types will not be.\n *\n * @default false\n */\n enableSemanticValidation?: boolean\n /**\n * Additional types to fetch and include in the editor for autocompletion.\n *\n * For example, to include types for payload, you would set this to\n *\n * [{ url: 'https://unpkg.com/payload@latest/dist/index.d.ts', filePath: 'file:///node_modules/payload/index.d.ts' }]\n */\n fetchTypes?: Array<{\n filePath: string\n url: string\n }>\n /**\n * @default undefined\n */\n paths?: Record<string, string[]>\n /**\n * @default \"ESNext\"\n */\n target?: string\n /**\n * @default ['node_modules/@types']\n */\n typeRoots?: string[]\n }\n}\n\nexport const CodeComponent: React.FC<AdditionalCodeComponentProps & CodeFieldClientProps> = ({\n autoComplete,\n field,\n forceRender,\n languages = {\n js: 'JavaScript',\n plaintext: 'Plain Text',\n ts: 'TypeScript',\n },\n path,\n permissions,\n readOnly,\n renderedBlocks,\n schemaPath,\n typescript,\n validate,\n}) => {\n const languageField = useFormFields(([fields]) => fields['language'])\n\n const language: string =\n (languageField?.value as string) || (languageField?.initialValue as string) || 'typescript'\n\n const label = languages[language]\n\n const props: CodeFieldClient = useMemo<CodeFieldClient>(\n () => ({\n ...field,\n type: 'code',\n admin: {\n ...field.admin,\n editorOptions: {},\n editorProps: {\n // If typescript is set, @monaco-editor/react needs to set the URI to a .ts or .tsx file when it calls createModel().\n // This is done through the `defaultPath` prop.\n defaultPath: language === 'ts' ? 'file.tsx' : undefined,\n },\n language,\n },\n }),\n [field, language],\n )\n\n const key = `${field.name}-${language}-${label}`\n\n return (\n props && (\n <CodeField\n autoComplete={autoComplete}\n field={props}\n forceRender={forceRender}\n key={key}\n onMount={(_editor, monaco) => {\n monaco.editor.defineTheme('vs-dark', {\n base: 'vs-dark',\n colors: {\n 'editor.background': '#222222',\n },\n inherit: true,\n rules: [],\n })\n\n monaco.editor.defineTheme('vs', {\n base: 'vs',\n colors: {\n 'editor.background': '#f5f5f5',\n },\n inherit: true,\n rules: [],\n })\n monaco.languages.typescript.typescriptDefaults.setCompilerOptions({\n allowNonTsExtensions: true,\n // Set module resolution to NodeJs to enable autocompletion\n allowJs: true,\n allowSyntheticDefaultImports: true,\n esModuleInterop: true,\n jsx: monaco.languages.typescript.JsxEmit.React,\n moduleResolution: monaco.languages.typescript.ModuleResolutionKind.NodeJs,\n noEmit: true,\n paths: typescript?.paths,\n reactNamespace: 'React',\n target: monaco.languages.typescript.ScriptTarget[\n typescript?.target ?? ('ESNext' as any)\n ] as any,\n typeRoots: typescript?.typeRoots ?? ['node_modules/@types'],\n })\n\n monaco.languages.typescript.typescriptDefaults.setDiagnosticsOptions({\n noSemanticValidation: typescript?.enableSemanticValidation ? false : true,\n noSyntaxValidation: false,\n })\n\n const run = async () => {\n if (\n typescript?.fetchTypes &&\n Array.isArray(typescript.fetchTypes) &&\n typescript.fetchTypes.length > 0\n ) {\n await Promise.all(\n typescript.fetchTypes.map(async (type) => {\n const types = await fetch(type.url)\n const typesText = await types.text()\n monaco.languages.typescript.typescriptDefaults.addExtraLib(\n typesText,\n type.filePath,\n )\n }),\n )\n }\n }\n void run()\n }}\n path={path}\n permissions={permissions}\n readOnly={readOnly}\n renderedBlocks={renderedBlocks}\n schemaPath={schemaPath}\n validate={validate}\n />\n )\n )\n}\n"],"mappings":"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","ignoreList":[]}
@@ -1,4 +0,0 @@
1
- import React from 'react';
2
- import './index.scss';
3
- export declare const Collapse: React.FC;
4
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../../src/features/blocks/premade/CodeBlock/Component/Collapse/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,OAAO,cAAc,CAAA;AAOrB,eAAO,MAAM,QAAQ,EAAE,KAAK,CAAC,EAO5B,CAAA"}
@@ -1,17 +0,0 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- import React from 'react';
3
- const baseClass = 'code-block-collapse-button';
4
- import { useCollapsible } from '@payloadcms/ui';
5
- import { CollapseIcon } from '../../../../../../lexical/ui/icons/Collapse/index.js';
6
- export const Collapse = () => {
7
- const {
8
- toggle
9
- } = useCollapsible();
10
- return /*#__PURE__*/_jsx("button", {
11
- className: baseClass,
12
- onClick: toggle,
13
- type: "button",
14
- children: /*#__PURE__*/_jsx(CollapseIcon, {})
15
- });
16
- };
17
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","names":["React","baseClass","useCollapsible","CollapseIcon","Collapse","toggle","_jsx","className","onClick","type"],"sources":["../../../../../../../src/features/blocks/premade/CodeBlock/Component/Collapse/index.tsx"],"sourcesContent":["import React from 'react'\n\nimport './index.scss'\n\nconst baseClass = 'code-block-collapse-button'\nimport { useCollapsible } from '@payloadcms/ui'\n\nimport { CollapseIcon } from '../../../../../../lexical/ui/icons/Collapse/index.js'\n\nexport const Collapse: React.FC = () => {\n const { toggle } = useCollapsible()\n return (\n <button className={baseClass} onClick={toggle} type=\"button\">\n <CollapseIcon />\n </button>\n )\n}\n"],"mappings":";AAAA,OAAOA,KAAA,MAAW;AAIlB,MAAMC,SAAA,GAAY;AAClB,SAASC,cAAc,QAAQ;AAE/B,SAASC,YAAY,QAAQ;AAE7B,OAAO,MAAMC,QAAA,GAAqBA,CAAA;EAChC,MAAM;IAAEC;EAAM,CAAE,GAAGH,cAAA;EACnB,oBACEI,IAAA,CAAC;IAAOC,SAAA,EAAWN,SAAA;IAAWO,OAAA,EAASH,MAAA;IAAQI,IAAA,EAAK;cAClD,aAAAH,IAAA,CAACH,YAAA;;AAGP","ignoreList":[]}
@@ -1,4 +0,0 @@
1
- import React from 'react';
2
- import './index.scss';
3
- export declare const FloatingCollapse: React.FC;
4
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../../src/features/blocks/premade/CodeBlock/Component/FloatingCollapse/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,OAAO,cAAc,CAAA;AAOrB,eAAO,MAAM,gBAAgB,EAAE,KAAK,CAAC,EAcpC,CAAA"}
@@ -1,26 +0,0 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import React from 'react';
3
- const baseClass = 'code-block-floating-collapse-button';
4
- import { useCollapsible, useTranslation } from '@payloadcms/ui';
5
- import { CollapseIcon } from '../../../../../../lexical/ui/icons/Collapse/index.js';
6
- export const FloatingCollapse = () => {
7
- const {
8
- isCollapsed,
9
- toggle
10
- } = useCollapsible();
11
- const {
12
- t
13
- } = useTranslation();
14
- if (!isCollapsed) {
15
- return null;
16
- }
17
- return /*#__PURE__*/_jsxs("button", {
18
- className: baseClass,
19
- onClick: toggle,
20
- type: "button",
21
- children: [/*#__PURE__*/_jsx("span", {
22
- children: t('general:collapse')
23
- }), /*#__PURE__*/_jsx(CollapseIcon, {})]
24
- });
25
- };
26
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","names":["React","baseClass","useCollapsible","useTranslation","CollapseIcon","FloatingCollapse","isCollapsed","toggle","t","_jsxs","className","onClick","type","_jsx"],"sources":["../../../../../../../src/features/blocks/premade/CodeBlock/Component/FloatingCollapse/index.tsx"],"sourcesContent":["import React from 'react'\n\nimport './index.scss'\n\nconst baseClass = 'code-block-floating-collapse-button'\nimport { useCollapsible, useTranslation } from '@payloadcms/ui'\n\nimport { CollapseIcon } from '../../../../../../lexical/ui/icons/Collapse/index.js'\n\nexport const FloatingCollapse: React.FC = () => {\n const { isCollapsed, toggle } = useCollapsible()\n const { t } = useTranslation()\n\n if (!isCollapsed) {\n return null\n }\n\n return (\n <button className={baseClass} onClick={toggle} type=\"button\">\n <span>{t('general:collapse')}</span>\n <CollapseIcon />\n </button>\n )\n}\n"],"mappings":";AAAA,OAAOA,KAAA,MAAW;AAIlB,MAAMC,SAAA,GAAY;AAClB,SAASC,cAAc,EAAEC,cAAc,QAAQ;AAE/C,SAASC,YAAY,QAAQ;AAE7B,OAAO,MAAMC,gBAAA,GAA6BA,CAAA;EACxC,MAAM;IAAEC,WAAW;IAAEC;EAAM,CAAE,GAAGL,cAAA;EAChC,MAAM;IAAEM;EAAC,CAAE,GAAGL,cAAA;EAEd,IAAI,CAACG,WAAA,EAAa;IAChB,OAAO;EACT;EAEA,oBACEG,KAAA,CAAC;IAAOC,SAAA,EAAWT,SAAA;IAAWU,OAAA,EAASJ,MAAA;IAAQK,IAAA,EAAK;4BAClDC,IAAA,CAAC;gBAAML,CAAA,CAAE;qBACTK,IAAA,CAACT,YAAA;;AAGP","ignoreList":[]}
@@ -1,7 +0,0 @@
1
- import type { BlockJSX } from 'payload';
2
- /**
3
- * @internal
4
- * @experimental - API may change in minor releases
5
- */
6
- export declare const codeConverter: BlockJSX;
7
- //# sourceMappingURL=converter.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"converter.d.ts","sourceRoot":"","sources":["../../../../../src/features/blocks/premade/CodeBlock/converter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAA;AAEvC;;;GAGG;AACH,eAAO,MAAM,aAAa,EAAE,QAyC3B,CAAA"}
@@ -1,46 +0,0 @@
1
- /**
2
- * @internal
3
- * @experimental - API may change in minor releases
4
- */export const codeConverter = {
5
- customEndRegex: {
6
- optional: true,
7
- regExp: /[ \t]*```$/
8
- },
9
- customStartRegex: /^[ \t]*```(\w+)?/,
10
- doNotTrimChildren: true,
11
- export: ({
12
- fields
13
- }) => {
14
- const isSingleLine = !fields.code.includes('\n') && !fields.language?.length;
15
- if (isSingleLine) {
16
- return '```' + fields.code + '```';
17
- }
18
- return '```' + (fields.language || '') + (fields.code ? '\n' + fields.code : '') + '\n' + '```';
19
- },
20
- import: ({
21
- children,
22
- closeMatch,
23
- openMatch
24
- }) => {
25
- const language = openMatch?.[1];
26
- // Removed first and last \n from children if present
27
- if (children.startsWith('\n')) {
28
- children = children.slice(1);
29
- }
30
- if (children.endsWith('\n')) {
31
- children = children.slice(0, -1);
32
- }
33
- const isSingleLineAndComplete = !!closeMatch && !children.includes('\n') && openMatch?.input?.trim() !== '```' + language;
34
- if (isSingleLineAndComplete) {
35
- return {
36
- code: language + (children?.length ? children : ''),
37
- language: ''
38
- };
39
- }
40
- return {
41
- code: children,
42
- language
43
- };
44
- }
45
- };
46
- //# sourceMappingURL=converter.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"converter.js","names":["codeConverter","customEndRegex","optional","regExp","customStartRegex","doNotTrimChildren","export","fields","isSingleLine","code","includes","language","length","import","children","closeMatch","openMatch","startsWith","slice","endsWith","isSingleLineAndComplete","input","trim"],"sources":["../../../../../src/features/blocks/premade/CodeBlock/converter.ts"],"sourcesContent":["import type { BlockJSX } from 'payload'\n\n/**\n * @internal\n * @experimental - API may change in minor releases\n */\nexport const codeConverter: BlockJSX = {\n customEndRegex: {\n optional: true,\n regExp: /[ \\t]*```$/,\n },\n customStartRegex: /^[ \\t]*```(\\w+)?/,\n doNotTrimChildren: true,\n export: ({ fields }) => {\n const isSingleLine = !fields.code.includes('\\n') && !fields.language?.length\n if (isSingleLine) {\n return '```' + fields.code + '```'\n }\n\n return '```' + (fields.language || '') + (fields.code ? '\\n' + fields.code : '') + '\\n' + '```'\n },\n import: ({ children, closeMatch, openMatch }) => {\n const language = openMatch?.[1]\n\n // Removed first and last \\n from children if present\n if (children.startsWith('\\n')) {\n children = children.slice(1)\n }\n if (children.endsWith('\\n')) {\n children = children.slice(0, -1)\n }\n\n const isSingleLineAndComplete =\n !!closeMatch && !children.includes('\\n') && openMatch?.input?.trim() !== '```' + language\n\n if (isSingleLineAndComplete) {\n return {\n code: language + (children?.length ? children : ''), // No need to add space to children as they are not trimmed\n language: '',\n }\n }\n\n return {\n code: children,\n language,\n }\n },\n}\n"],"mappings":"AAEA;;;GAIA,OAAO,MAAMA,aAAA,GAA0B;EACrCC,cAAA,EAAgB;IACdC,QAAA,EAAU;IACVC,MAAA,EAAQ;EACV;EACAC,gBAAA,EAAkB;EAClBC,iBAAA,EAAmB;EACnBC,MAAA,EAAQA,CAAC;IAAEC;EAAM,CAAE;IACjB,MAAMC,YAAA,GAAe,CAACD,MAAA,CAAOE,IAAI,CAACC,QAAQ,CAAC,SAAS,CAACH,MAAA,CAAOI,QAAQ,EAAEC,MAAA;IACtE,IAAIJ,YAAA,EAAc;MAChB,OAAO,QAAQD,MAAA,CAAOE,IAAI,GAAG;IAC/B;IAEA,OAAO,SAASF,MAAA,CAAOI,QAAQ,IAAI,EAAC,KAAMJ,MAAA,CAAOE,IAAI,GAAG,OAAOF,MAAA,CAAOE,IAAI,GAAG,EAAC,IAAK,OAAO;EAC5F;EACAI,MAAA,EAAQA,CAAC;IAAEC,QAAQ;IAAEC,UAAU;IAAEC;EAAS,CAAE;IAC1C,MAAML,QAAA,GAAWK,SAAA,GAAY,EAAE;IAE/B;IACA,IAAIF,QAAA,CAASG,UAAU,CAAC,OAAO;MAC7BH,QAAA,GAAWA,QAAA,CAASI,KAAK,CAAC;IAC5B;IACA,IAAIJ,QAAA,CAASK,QAAQ,CAAC,OAAO;MAC3BL,QAAA,GAAWA,QAAA,CAASI,KAAK,CAAC,GAAG,CAAC;IAChC;IAEA,MAAME,uBAAA,GACJ,CAAC,CAACL,UAAA,IAAc,CAACD,QAAA,CAASJ,QAAQ,CAAC,SAASM,SAAA,EAAWK,KAAA,EAAOC,IAAA,OAAW,QAAQX,QAAA;IAEnF,IAAIS,uBAAA,EAAyB;MAC3B,OAAO;QACLX,IAAA,EAAME,QAAA,IAAYG,QAAA,EAAUF,MAAA,GAASE,QAAA,GAAW,EAAC;QACjDH,QAAA,EAAU;MACZ;IACF;IAEA,OAAO;MACLF,IAAA,EAAMK,QAAA;MACNH;IACF;EACF;AACF","ignoreList":[]}
@@ -1,2 +0,0 @@
1
- export { codeConverter as codeConverterClient } from './converter.js';
2
- //# sourceMappingURL=converterClient.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"converterClient.d.ts","sourceRoot":"","sources":["../../../../../src/features/blocks/premade/CodeBlock/converterClient.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,IAAI,mBAAmB,EAAE,MAAM,gBAAgB,CAAA"}
@@ -1,4 +0,0 @@
1
- 'use client';
2
-
3
- export { codeConverter as codeConverterClient } from './converter.js';
4
- //# sourceMappingURL=converterClient.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"converterClient.js","names":["codeConverter","codeConverterClient"],"sources":["../../../../../src/features/blocks/premade/CodeBlock/converterClient.ts"],"sourcesContent":["'use client'\n\nexport { codeConverter as codeConverterClient } from './converter.js'\n"],"mappings":"AAAA;;AAEA,SAASA,aAAA,IAAiBC,mBAAmB,QAAQ","ignoreList":[]}
@@ -1,7 +0,0 @@
1
- import type { Block } from 'payload';
2
- import type { AdditionalCodeComponentProps } from './Component/Code.js';
3
- /**
4
- * @experimental - this API may change in future, minor releases
5
- */
6
- export declare const CodeBlock: (args?: AdditionalCodeComponentProps) => Block;
7
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/features/blocks/premade/CodeBlock/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;AAEpC,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,qBAAqB,CAAA;AAIvE;;GAEG;AACH,eAAO,MAAM,SAAS,EAAE,CAAC,IAAI,CAAC,EAAE,4BAA4B,KAAK,KAkDhE,CAAA"}
@@ -1,52 +0,0 @@
1
- import { codeConverter } from './converter.js';
2
- /**
3
- * @experimental - this API may change in future, minor releases
4
- */
5
- export const CodeBlock = args => {
6
- const languages = args?.languages || {
7
- js: 'JavaScript',
8
- plaintext: 'Plain Text',
9
- ts: 'TypeScript'
10
- };
11
- return {
12
- slug: args?.slug || 'Code',
13
- admin: {
14
- components: {
15
- Block: {
16
- clientProps: {
17
- languages
18
- },
19
- path: '@payloadcms/richtext-lexical/client#CodeBlockBlockComponent'
20
- }
21
- },
22
- jsx: '@payloadcms/richtext-lexical/client#codeConverterClient'
23
- },
24
- fields: [{
25
- name: 'language',
26
- type: 'select',
27
- admin: {
28
- // We'll manually render this field into the block component header
29
- hidden: true
30
- },
31
- defaultValue: args?.defaultLanguage || Object.keys(languages)[0],
32
- options: Object.entries(languages).map(([key, value]) => ({
33
- label: value,
34
- value: key
35
- }))
36
- }, {
37
- name: 'code',
38
- type: 'code',
39
- admin: {
40
- components: {
41
- Field: {
42
- clientProps: args,
43
- path: '@payloadcms/richtext-lexical/client#CodeComponent'
44
- }
45
- }
46
- },
47
- label: ''
48
- }],
49
- jsx: codeConverter
50
- };
51
- };
52
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","names":["codeConverter","CodeBlock","args","languages","js","plaintext","ts","slug","admin","components","Block","clientProps","path","jsx","fields","name","type","hidden","defaultValue","defaultLanguage","Object","keys","options","entries","map","key","value","label","Field"],"sources":["../../../../../src/features/blocks/premade/CodeBlock/index.ts"],"sourcesContent":["import type { Block } from 'payload'\n\nimport type { AdditionalCodeComponentProps } from './Component/Code.js'\n\nimport { codeConverter } from './converter.js'\n\n/**\n * @experimental - this API may change in future, minor releases\n */\nexport const CodeBlock: (args?: AdditionalCodeComponentProps) => Block = (args) => {\n const languages = args?.languages || {\n js: 'JavaScript',\n plaintext: 'Plain Text',\n ts: 'TypeScript',\n }\n\n return {\n slug: args?.slug || 'Code',\n admin: {\n components: {\n Block: {\n clientProps: {\n languages,\n },\n path: '@payloadcms/richtext-lexical/client#CodeBlockBlockComponent',\n },\n },\n jsx: '@payloadcms/richtext-lexical/client#codeConverterClient',\n },\n fields: [\n {\n name: 'language',\n type: 'select',\n admin: {\n // We'll manually render this field into the block component header\n hidden: true,\n },\n defaultValue: args?.defaultLanguage || Object.keys(languages)[0],\n options: Object.entries(languages).map(([key, value]) => ({\n label: value,\n value: key,\n })),\n },\n {\n name: 'code',\n type: 'code',\n admin: {\n components: {\n Field: {\n clientProps: args,\n path: '@payloadcms/richtext-lexical/client#CodeComponent',\n },\n },\n },\n label: '',\n },\n ],\n jsx: codeConverter,\n }\n}\n"],"mappings":"AAIA,SAASA,aAAa,QAAQ;AAE9B;;;AAGA,OAAO,MAAMC,SAAA,GAA6DC,IAAA;EACxE,MAAMC,SAAA,GAAYD,IAAA,EAAMC,SAAA,IAAa;IACnCC,EAAA,EAAI;IACJC,SAAA,EAAW;IACXC,EAAA,EAAI;EACN;EAEA,OAAO;IACLC,IAAA,EAAML,IAAA,EAAMK,IAAA,IAAQ;IACpBC,KAAA,EAAO;MACLC,UAAA,EAAY;QACVC,KAAA,EAAO;UACLC,WAAA,EAAa;YACXR;UACF;UACAS,IAAA,EAAM;QACR;MACF;MACAC,GAAA,EAAK;IACP;IACAC,MAAA,EAAQ,CACN;MACEC,IAAA,EAAM;MACNC,IAAA,EAAM;MACNR,KAAA,EAAO;QACL;QACAS,MAAA,EAAQ;MACV;MACAC,YAAA,EAAchB,IAAA,EAAMiB,eAAA,IAAmBC,MAAA,CAAOC,IAAI,CAAClB,SAAA,CAAU,CAAC,EAAE;MAChEmB,OAAA,EAASF,MAAA,CAAOG,OAAO,CAACpB,SAAA,EAAWqB,GAAG,CAAC,CAAC,CAACC,GAAA,EAAKC,KAAA,CAAM,MAAM;QACxDC,KAAA,EAAOD,KAAA;QACPA,KAAA,EAAOD;MACT;IACF,GACA;MACEV,IAAA,EAAM;MACNC,IAAA,EAAM;MACNR,KAAA,EAAO;QACLC,UAAA,EAAY;UACVmB,KAAA,EAAO;YACLjB,WAAA,EAAaT,IAAA;YACbU,IAAA,EAAM;UACR;QACF;MACF;MACAe,KAAA,EAAO;IACT,EACD;IACDd,GAAA,EAAKb;EACP;AACF","ignoreList":[]}
@@ -1,6 +0,0 @@
1
- import type { NodeWithHooks } from '../../../typesServer.js';
2
- import { type Transformer } from '../../../../packages/@lexical/markdown/index.js';
3
- export declare function getLexicalToMarkdown(allNodes: Array<NodeWithHooks>, allTransformers: Transformer[]): (args: {
4
- editorState: Record<string, any>;
5
- }) => string;
6
- //# sourceMappingURL=getLexicalToMarkdown.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"getLexicalToMarkdown.d.ts","sourceRoot":"","sources":["../../../../../src/features/blocks/server/markdown/getLexicalToMarkdown.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAA;AAG5D,OAAO,EAEL,KAAK,WAAW,EACjB,MAAM,iDAAiD,CAAA;AACxD,wBAAgB,oBAAoB,CAClC,QAAQ,EAAE,KAAK,CAAC,aAAa,CAAC,EAC9B,eAAe,EAAE,WAAW,EAAE,GAC7B,CAAC,IAAI,EAAE;IAAE,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;CAAE,KAAK,MAAM,CAsBxD"}
@@ -1,27 +0,0 @@
1
- import { createHeadlessEditor } from '@lexical/headless';
2
- import { getEnabledNodesFromServerNodes } from '../../../../lexical/nodes/index.js';
3
- import { $convertToMarkdownString } from '../../../../packages/@lexical/markdown/index.js';
4
- export function getLexicalToMarkdown(allNodes, allTransformers) {
5
- const lexicalToMarkdown = ({
6
- editorState
7
- }) => {
8
- const headlessEditor = createHeadlessEditor({
9
- nodes: getEnabledNodesFromServerNodes({
10
- nodes: allNodes
11
- })
12
- });
13
- try {
14
- headlessEditor.setEditorState(headlessEditor.parseEditorState(editorState)) // This should commit the editor state immediately
15
- ;
16
- } catch (e) {
17
- console.error('getLexicalToMarkdown: ERROR parsing editor state', e);
18
- }
19
- let markdown = '';
20
- headlessEditor.getEditorState().read(() => {
21
- markdown = $convertToMarkdownString(allTransformers);
22
- });
23
- return markdown;
24
- };
25
- return lexicalToMarkdown;
26
- }
27
- //# sourceMappingURL=getLexicalToMarkdown.js.map