@payloadcms/richtext-lexical 3.59.0-internal.8435f3c → 3.59.0-internal.917c03d
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/exports/client/Field-CJFETHA3.js +2 -0
- package/dist/exports/client/Field-CJFETHA3.js.map +7 -0
- package/dist/exports/client/RelationshipComponent-TSIENULZ.js +2 -0
- package/dist/exports/client/RelationshipComponent-TSIENULZ.js.map +7 -0
- package/dist/exports/client/bundled.css +1 -1
- package/dist/exports/client/chunk-BQCXN3B4.js +2 -0
- package/dist/exports/client/chunk-BQCXN3B4.js.map +7 -0
- package/dist/exports/client/{chunk-2Y72RT72.js → chunk-TLQLXR6Q.js} +2 -2
- package/dist/exports/client/chunk-XNERFY6G.js +2 -0
- package/dist/exports/client/chunk-XNERFY6G.js.map +7 -0
- package/dist/exports/client/component-CYFKY3IL.js +2 -0
- package/dist/exports/client/component-CYFKY3IL.js.map +7 -0
- package/dist/exports/client/componentInline-NGTRUSGB.js +2 -0
- package/dist/exports/client/index.d.ts +3 -0
- package/dist/exports/client/index.d.ts.map +1 -1
- package/dist/exports/client/index.js +35 -10
- package/dist/exports/client/index.js.map +4 -4
- package/dist/features/blocks/client/component/BlockContent.d.ts +52 -27
- package/dist/features/blocks/client/component/BlockContent.d.ts.map +1 -1
- package/dist/features/blocks/client/component/BlockContent.js +48 -51
- package/dist/features/blocks/client/component/BlockContent.js.map +1 -1
- package/dist/features/blocks/client/component/components/BlockCollapsible.d.ts +2 -9
- package/dist/features/blocks/client/component/components/BlockCollapsible.d.ts.map +1 -1
- package/dist/features/blocks/client/component/components/BlockCollapsible.js +7 -25
- package/dist/features/blocks/client/component/components/BlockCollapsible.js.map +1 -1
- package/dist/features/blocks/client/component/index.d.ts.map +1 -1
- package/dist/features/blocks/client/component/index.js +71 -56
- package/dist/features/blocks/client/component/index.js.map +1 -1
- package/dist/features/blocks/client/componentInline/index.d.ts.map +1 -1
- package/dist/features/blocks/client/componentInline/index.js +13 -11
- package/dist/features/blocks/client/componentInline/index.js.map +1 -1
- package/dist/features/blocks/client/index.d.ts.map +1 -1
- package/dist/features/blocks/client/index.js +5 -0
- package/dist/features/blocks/client/index.js.map +1 -1
- package/dist/features/blocks/client/markdown/getLexicalToMarkdown.d.ts +6 -0
- package/dist/features/blocks/client/markdown/getLexicalToMarkdown.d.ts.map +1 -0
- package/dist/features/blocks/client/markdown/getLexicalToMarkdown.js +24 -0
- package/dist/features/blocks/client/markdown/getLexicalToMarkdown.js.map +1 -0
- package/dist/features/blocks/client/markdown/getMarkdownToLexical.d.ts +6 -0
- package/dist/features/blocks/client/markdown/getMarkdownToLexical.d.ts.map +1 -0
- package/dist/features/blocks/client/markdown/getMarkdownToLexical.js +20 -0
- package/dist/features/blocks/client/markdown/getMarkdownToLexical.js.map +1 -0
- package/dist/features/blocks/client/markdown/markdownTransformer.d.ts +12 -0
- package/dist/features/blocks/client/markdown/markdownTransformer.d.ts.map +1 -0
- package/dist/features/blocks/client/markdown/markdownTransformer.js +348 -0
- package/dist/features/blocks/client/markdown/markdownTransformer.js.map +1 -0
- package/dist/features/blocks/premade/CodeBlock/Component/Block.d.ts +5 -0
- package/dist/features/blocks/premade/CodeBlock/Component/Block.d.ts.map +1 -0
- package/dist/features/blocks/premade/CodeBlock/Component/Block.js +156 -0
- package/dist/features/blocks/premade/CodeBlock/Component/Block.js.map +1 -0
- package/dist/features/blocks/premade/CodeBlock/Component/Code.d.ts +61 -0
- package/dist/features/blocks/premade/CodeBlock/Component/Code.d.ts.map +1 -0
- package/dist/features/blocks/premade/CodeBlock/Component/Code.js +99 -0
- package/dist/features/blocks/premade/CodeBlock/Component/Code.js.map +1 -0
- package/dist/features/blocks/premade/CodeBlock/Component/Collapse/index.d.ts +4 -0
- package/dist/features/blocks/premade/CodeBlock/Component/Collapse/index.d.ts.map +1 -0
- package/dist/features/blocks/premade/CodeBlock/Component/Collapse/index.js +17 -0
- package/dist/features/blocks/premade/CodeBlock/Component/Collapse/index.js.map +1 -0
- package/dist/features/blocks/premade/CodeBlock/Component/FloatingCollapse/index.d.ts +4 -0
- package/dist/features/blocks/premade/CodeBlock/Component/FloatingCollapse/index.d.ts.map +1 -0
- package/dist/features/blocks/premade/CodeBlock/Component/FloatingCollapse/index.js +26 -0
- package/dist/features/blocks/premade/CodeBlock/Component/FloatingCollapse/index.js.map +1 -0
- package/dist/features/blocks/premade/CodeBlock/converter.d.ts +7 -0
- package/dist/features/blocks/premade/CodeBlock/converter.d.ts.map +1 -0
- package/dist/features/blocks/premade/CodeBlock/converter.js +46 -0
- package/dist/features/blocks/premade/CodeBlock/converter.js.map +1 -0
- package/dist/features/blocks/premade/CodeBlock/converterClient.d.ts +2 -0
- package/dist/features/blocks/premade/CodeBlock/converterClient.d.ts.map +1 -0
- package/dist/features/blocks/premade/CodeBlock/converterClient.js +4 -0
- package/dist/features/blocks/premade/CodeBlock/converterClient.js.map +1 -0
- package/dist/features/blocks/premade/CodeBlock/index.d.ts +7 -0
- package/dist/features/blocks/premade/CodeBlock/index.d.ts.map +1 -0
- package/dist/features/blocks/premade/CodeBlock/index.js +52 -0
- package/dist/features/blocks/premade/CodeBlock/index.js.map +1 -0
- package/dist/features/blocks/server/i18n.js +38 -38
- package/dist/features/blocks/server/i18n.js.map +1 -1
- package/dist/features/blocks/server/index.js +1 -1
- package/dist/features/blocks/server/index.js.map +1 -1
- package/dist/features/blocks/server/markdown/getLexicalToMarkdown.d.ts +6 -0
- package/dist/features/blocks/server/markdown/getLexicalToMarkdown.d.ts.map +1 -0
- package/dist/features/blocks/server/markdown/getLexicalToMarkdown.js +27 -0
- package/dist/features/blocks/server/markdown/getLexicalToMarkdown.js.map +1 -0
- package/dist/features/blocks/server/markdown/getMarkdownToLexical.d.ts +7 -0
- package/dist/features/blocks/server/markdown/getMarkdownToLexical.d.ts.map +1 -0
- package/dist/features/blocks/server/markdown/getMarkdownToLexical.js +22 -0
- package/dist/features/blocks/server/markdown/getMarkdownToLexical.js.map +1 -0
- package/dist/features/blocks/server/markdown/linesFromMatchToContentAndPropsString.d.ts.map +1 -0
- package/dist/features/blocks/server/markdown/linesFromMatchToContentAndPropsString.js.map +1 -0
- package/dist/features/blocks/server/markdown/markdownTransformer.d.ts +15 -0
- package/dist/features/blocks/server/markdown/markdownTransformer.d.ts.map +1 -0
- package/dist/features/blocks/server/{markdownTransformer.js → markdown/markdownTransformer.js} +6 -48
- package/dist/features/blocks/server/markdown/markdownTransformer.js.map +1 -0
- package/dist/features/experimental_table/client/plugins/TableHoverActionsPlugin/index.d.ts.map +1 -1
- package/dist/features/experimental_table/client/plugins/TableHoverActionsPlugin/index.js +5 -3
- package/dist/features/experimental_table/client/plugins/TableHoverActionsPlugin/index.js.map +1 -1
- package/dist/features/link/client/plugins/floatingLinkEditor/LinkEditor/index.d.ts.map +1 -1
- package/dist/features/link/client/plugins/floatingLinkEditor/LinkEditor/index.js +3 -1
- package/dist/features/link/client/plugins/floatingLinkEditor/LinkEditor/index.js.map +1 -1
- package/dist/features/relationship/client/components/RelationshipComponent.d.ts.map +1 -1
- package/dist/features/relationship/client/components/RelationshipComponent.js +5 -9
- package/dist/features/relationship/client/components/RelationshipComponent.js.map +1 -1
- package/dist/features/toolbars/fixed/client/Toolbar/index.d.ts.map +1 -1
- package/dist/features/toolbars/fixed/client/Toolbar/index.js +7 -1
- package/dist/features/toolbars/fixed/client/Toolbar/index.js.map +1 -1
- package/dist/features/toolbars/inline/client/Toolbar/index.d.ts.map +1 -1
- package/dist/features/toolbars/inline/client/Toolbar/index.js +3 -1
- package/dist/features/toolbars/inline/client/Toolbar/index.js.map +1 -1
- package/dist/features/upload/client/component/index.d.ts.map +1 -1
- package/dist/features/upload/client/component/index.js +6 -5
- package/dist/features/upload/client/component/index.js.map +1 -1
- package/dist/field/RenderLexical/index.d.ts.map +1 -1
- package/dist/field/RenderLexical/index.js +1 -0
- package/dist/field/RenderLexical/index.js.map +1 -1
- package/dist/field/bundled.css +1 -1
- package/dist/field/rscEntry.d.ts.map +1 -1
- package/dist/field/rscEntry.js +2 -0
- package/dist/field/rscEntry.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/lexical/LexicalEditor.d.ts.map +1 -1
- package/dist/lexical/LexicalEditor.js +20 -26
- package/dist/lexical/LexicalEditor.js.map +1 -1
- package/dist/lexical/ui/icons/CodeBlock/index.d.ts.map +1 -1
- package/dist/lexical/ui/icons/CodeBlock/index.js +10 -15
- package/dist/lexical/ui/icons/CodeBlock/index.js.map +1 -1
- package/dist/lexical/ui/icons/Collapse/index.d.ts +3 -0
- package/dist/lexical/ui/icons/Collapse/index.d.ts.map +1 -0
- package/dist/lexical/ui/icons/Collapse/index.js +18 -0
- package/dist/lexical/ui/icons/Collapse/index.js.map +1 -0
- package/dist/utilities/buildInitialState.d.ts +1 -0
- package/dist/utilities/buildInitialState.d.ts.map +1 -1
- package/dist/utilities/buildInitialState.js +1 -0
- package/dist/utilities/buildInitialState.js.map +1 -1
- package/dist/utilities/fieldsDrawer/DrawerContent.d.ts.map +1 -1
- package/dist/utilities/fieldsDrawer/DrawerContent.js +7 -3
- package/dist/utilities/fieldsDrawer/DrawerContent.js.map +1 -1
- package/dist/utilities/jsx/collectTopLevelJSXInLines.js +2 -2
- package/dist/utilities/jsx/collectTopLevelJSXInLines.js.map +1 -1
- package/package.json +7 -7
- package/dist/exports/client/Field-EHRBYNHO.js +0 -2
- package/dist/exports/client/Field-EHRBYNHO.js.map +0 -7
- package/dist/exports/client/RelationshipComponent-APF3CN47.js +0 -2
- package/dist/exports/client/RelationshipComponent-APF3CN47.js.map +0 -7
- package/dist/exports/client/chunk-3BY5IZJD.js +0 -2
- package/dist/exports/client/chunk-3BY5IZJD.js.map +0 -7
- package/dist/exports/client/chunk-CYLMY5ZJ.js +0 -2
- package/dist/exports/client/chunk-CYLMY5ZJ.js.map +0 -7
- package/dist/exports/client/component-VDJI45F2.js +0 -2
- package/dist/exports/client/component-VDJI45F2.js.map +0 -7
- package/dist/exports/client/componentInline-7TPI7ZBC.js +0 -2
- package/dist/features/blocks/client/markdownTransformer.d.ts +0 -17
- package/dist/features/blocks/client/markdownTransformer.d.ts.map +0 -1
- package/dist/features/blocks/client/markdownTransformer.js +0 -144
- package/dist/features/blocks/client/markdownTransformer.js.map +0 -1
- package/dist/features/blocks/server/linesFromMatchToContentAndPropsString.d.ts.map +0 -1
- package/dist/features/blocks/server/linesFromMatchToContentAndPropsString.js.map +0 -1
- package/dist/features/blocks/server/markdownTransformer.d.ts +0 -22
- package/dist/features/blocks/server/markdownTransformer.d.ts.map +0 -1
- package/dist/features/blocks/server/markdownTransformer.js.map +0 -1
- /package/dist/exports/client/{chunk-2Y72RT72.js.map → chunk-TLQLXR6Q.js.map} +0 -0
- /package/dist/exports/client/{componentInline-7TPI7ZBC.js.map → componentInline-NGTRUSGB.js.map} +0 -0
- /package/dist/features/blocks/server/{linesFromMatchToContentAndPropsString.d.ts → markdown/linesFromMatchToContentAndPropsString.d.ts} +0 -0
- /package/dist/features/blocks/server/{linesFromMatchToContentAndPropsString.js → markdown/linesFromMatchToContentAndPropsString.js} +0 -0
|
@@ -0,0 +1,61 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
|
@@ -0,0 +1,99 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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":[]}
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
|
@@ -0,0 +1,17 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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":[]}
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
|
@@ -0,0 +1,26 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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":[]}
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
|
@@ -0,0 +1,46 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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":[]}
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
|
@@ -0,0 +1 @@
|
|
|
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":[]}
|
|
@@ -0,0 +1,7 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
|
@@ -0,0 +1,52 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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":[]}
|
|
@@ -2,9 +2,9 @@ export const i18n = {
|
|
|
2
2
|
ar: {
|
|
3
3
|
inlineBlocks: {
|
|
4
4
|
create: 'أنشئ {{label}}',
|
|
5
|
-
edit: 'تحرير {{
|
|
5
|
+
edit: 'تحرير {{label}}',
|
|
6
6
|
label: 'الكتل الداخلية',
|
|
7
|
-
remove: 'إزالة {{
|
|
7
|
+
remove: 'إزالة {{label}}'
|
|
8
8
|
},
|
|
9
9
|
label: 'كتل'
|
|
10
10
|
},
|
|
@@ -19,16 +19,16 @@ export const i18n = {
|
|
|
19
19
|
},
|
|
20
20
|
bg: {
|
|
21
21
|
inlineBlocks: {
|
|
22
|
-
create: 'Създайте {{
|
|
23
|
-
edit: 'Редактирай {{
|
|
22
|
+
create: 'Създайте {{label}}',
|
|
23
|
+
edit: 'Редактирай {{label}}',
|
|
24
24
|
label: 'Вградени блокове',
|
|
25
|
-
remove: 'Премахнете {{
|
|
25
|
+
remove: 'Премахнете {{label}}'
|
|
26
26
|
},
|
|
27
27
|
label: 'Блокове'
|
|
28
28
|
},
|
|
29
29
|
cs: {
|
|
30
30
|
inlineBlocks: {
|
|
31
|
-
create: 'Vytvořte {{
|
|
31
|
+
create: 'Vytvořte {{label}}',
|
|
32
32
|
edit: 'Upravit {{label}}',
|
|
33
33
|
label: 'Inline bloky',
|
|
34
34
|
remove: 'Odstraňte {{label}}'
|
|
@@ -64,8 +64,8 @@ export const i18n = {
|
|
|
64
64
|
},
|
|
65
65
|
es: {
|
|
66
66
|
inlineBlocks: {
|
|
67
|
-
create: 'Crear {{
|
|
68
|
-
edit: 'Editar {{
|
|
67
|
+
create: 'Crear {{label}}',
|
|
68
|
+
edit: 'Editar {{label}}',
|
|
69
69
|
label: 'Bloques en línea',
|
|
70
70
|
remove: 'Eliminar {{label}}'
|
|
71
71
|
},
|
|
@@ -82,10 +82,10 @@ export const i18n = {
|
|
|
82
82
|
},
|
|
83
83
|
fa: {
|
|
84
84
|
inlineBlocks: {
|
|
85
|
-
create: 'ایجاد {{
|
|
86
|
-
edit: 'ویرایش {{
|
|
85
|
+
create: 'ایجاد {{label}}',
|
|
86
|
+
edit: 'ویرایش {{label}}',
|
|
87
87
|
label: 'بلوکهای درون خطی',
|
|
88
|
-
remove: 'حذف {{
|
|
88
|
+
remove: 'حذف {{label}}'
|
|
89
89
|
},
|
|
90
90
|
label: 'بلوک ها'
|
|
91
91
|
},
|
|
@@ -100,26 +100,26 @@ export const i18n = {
|
|
|
100
100
|
},
|
|
101
101
|
he: {
|
|
102
102
|
inlineBlocks: {
|
|
103
|
-
create: 'צור {{
|
|
104
|
-
edit: 'ערוך {{
|
|
103
|
+
create: 'צור {{label}}',
|
|
104
|
+
edit: 'ערוך {{label}}',
|
|
105
105
|
label: 'בלוקים משורשרים',
|
|
106
|
-
remove: 'הסר {{
|
|
106
|
+
remove: 'הסר {{label}}'
|
|
107
107
|
},
|
|
108
108
|
label: 'חסימות'
|
|
109
109
|
},
|
|
110
110
|
hr: {
|
|
111
111
|
inlineBlocks: {
|
|
112
|
-
create: 'Stvori {{
|
|
112
|
+
create: 'Stvori {{label}}',
|
|
113
113
|
edit: 'Uredi {{label}}',
|
|
114
114
|
label: 'Unutrašnji blokovi',
|
|
115
|
-
remove: 'Ukloni {{
|
|
115
|
+
remove: 'Ukloni {{label}}'
|
|
116
116
|
},
|
|
117
117
|
label: 'Blokovi'
|
|
118
118
|
},
|
|
119
119
|
hu: {
|
|
120
120
|
inlineBlocks: {
|
|
121
|
-
create: 'Hozzon létre {{
|
|
122
|
-
edit: 'Szerkesztés {{
|
|
121
|
+
create: 'Hozzon létre {{label}}',
|
|
122
|
+
edit: 'Szerkesztés {{label}}',
|
|
123
123
|
label: 'Beágyazott blokkok',
|
|
124
124
|
remove: 'Távolítsa el a {{label}}'
|
|
125
125
|
},
|
|
@@ -127,7 +127,7 @@ export const i18n = {
|
|
|
127
127
|
},
|
|
128
128
|
it: {
|
|
129
129
|
inlineBlocks: {
|
|
130
|
-
create: 'Crea {{
|
|
130
|
+
create: 'Crea {{label}}',
|
|
131
131
|
edit: 'Modifica {{label}}',
|
|
132
132
|
label: 'Blocchi in linea',
|
|
133
133
|
remove: 'Rimuovi {{label}}'
|
|
@@ -139,7 +139,7 @@ export const i18n = {
|
|
|
139
139
|
create: '{{label}}を作成する',
|
|
140
140
|
edit: '{{label}}を編集する',
|
|
141
141
|
label: 'インラインブロック',
|
|
142
|
-
remove: '{{
|
|
142
|
+
remove: '{{label}}を削除します'
|
|
143
143
|
},
|
|
144
144
|
label: 'ブロック'
|
|
145
145
|
},
|
|
@@ -182,9 +182,9 @@ export const i18n = {
|
|
|
182
182
|
pl: {
|
|
183
183
|
inlineBlocks: {
|
|
184
184
|
create: 'Utwórz {{label}}',
|
|
185
|
-
edit: 'Edytuj {{
|
|
185
|
+
edit: 'Edytuj {{label}}',
|
|
186
186
|
label: 'Blokowanie w linii',
|
|
187
|
-
remove: 'Usuń {{
|
|
187
|
+
remove: 'Usuń {{label}}'
|
|
188
188
|
},
|
|
189
189
|
label: 'Bloki'
|
|
190
190
|
},
|
|
@@ -199,10 +199,10 @@ export const i18n = {
|
|
|
199
199
|
},
|
|
200
200
|
ro: {
|
|
201
201
|
inlineBlocks: {
|
|
202
|
-
create: 'Creează {{
|
|
203
|
-
edit: 'Editați {{
|
|
202
|
+
create: 'Creează {{label}}',
|
|
203
|
+
edit: 'Editați {{label}}',
|
|
204
204
|
label: 'Blocuri in linie',
|
|
205
|
-
remove: 'Ștergeți {{
|
|
205
|
+
remove: 'Ștergeți {{label}}'
|
|
206
206
|
},
|
|
207
207
|
label: 'Blocuri'
|
|
208
208
|
},
|
|
@@ -220,22 +220,22 @@ export const i18n = {
|
|
|
220
220
|
create: 'Kreiraj {{label}}',
|
|
221
221
|
edit: 'Izmeni {{label}}',
|
|
222
222
|
label: 'Umetnuti blokovi',
|
|
223
|
-
remove: 'Ukloni {{
|
|
223
|
+
remove: 'Ukloni {{label}}'
|
|
224
224
|
},
|
|
225
225
|
label: 'Blokovi'
|
|
226
226
|
},
|
|
227
227
|
ru: {
|
|
228
228
|
inlineBlocks: {
|
|
229
229
|
create: 'Создать {{label}}',
|
|
230
|
-
edit: 'Изменить {{
|
|
230
|
+
edit: 'Изменить {{label}}',
|
|
231
231
|
label: 'Встроенные блоки',
|
|
232
|
-
remove: 'Удалить {{
|
|
232
|
+
remove: 'Удалить {{label}}'
|
|
233
233
|
},
|
|
234
234
|
label: 'Блоки'
|
|
235
235
|
},
|
|
236
236
|
sk: {
|
|
237
237
|
inlineBlocks: {
|
|
238
|
-
create: 'Vytvorte {{
|
|
238
|
+
create: 'Vytvorte {{label}}',
|
|
239
239
|
edit: 'Upraviť {{label}}',
|
|
240
240
|
label: 'Inline bloky',
|
|
241
241
|
remove: 'Odstráňte {{label}}'
|
|
@@ -244,7 +244,7 @@ export const i18n = {
|
|
|
244
244
|
},
|
|
245
245
|
sl: {
|
|
246
246
|
inlineBlocks: {
|
|
247
|
-
create: 'Ustvari {{
|
|
247
|
+
create: 'Ustvari {{label}}',
|
|
248
248
|
edit: 'Uredi {{label}}',
|
|
249
249
|
label: 'Vrstični bloki',
|
|
250
250
|
remove: 'Odstrani {{label}}'
|
|
@@ -254,9 +254,9 @@ export const i18n = {
|
|
|
254
254
|
sv: {
|
|
255
255
|
inlineBlocks: {
|
|
256
256
|
create: 'Skapa {{label}}',
|
|
257
|
-
edit: 'Redigera {{
|
|
257
|
+
edit: 'Redigera {{label}}',
|
|
258
258
|
label: 'Inline-blockar',
|
|
259
|
-
remove: 'Ta bort {{
|
|
259
|
+
remove: 'Ta bort {{label}}'
|
|
260
260
|
},
|
|
261
261
|
label: 'Block'
|
|
262
262
|
},
|
|
@@ -280,10 +280,10 @@ export const i18n = {
|
|
|
280
280
|
},
|
|
281
281
|
tr: {
|
|
282
282
|
inlineBlocks: {
|
|
283
|
-
create: '{{
|
|
284
|
-
edit: "{{
|
|
283
|
+
create: '{{label}} oluşturun',
|
|
284
|
+
edit: "{{label}}'i düzenleyin",
|
|
285
285
|
label: 'Satır İçi Bloklar',
|
|
286
|
-
remove: '{{
|
|
286
|
+
remove: '{{label}} kaldırın'
|
|
287
287
|
},
|
|
288
288
|
label: 'Bloklar'
|
|
289
289
|
},
|
|
@@ -292,16 +292,16 @@ export const i18n = {
|
|
|
292
292
|
create: 'Створити {{label}}',
|
|
293
293
|
edit: 'Редагувати {{label}}',
|
|
294
294
|
label: 'Вбудовані блоки',
|
|
295
|
-
remove: 'Видалити {{
|
|
295
|
+
remove: 'Видалити {{label}}'
|
|
296
296
|
},
|
|
297
297
|
label: 'Блоки'
|
|
298
298
|
},
|
|
299
299
|
vi: {
|
|
300
300
|
inlineBlocks: {
|
|
301
301
|
create: 'Tạo {{label}}',
|
|
302
|
-
edit: 'Chỉnh sửa {{
|
|
302
|
+
edit: 'Chỉnh sửa {{label}}',
|
|
303
303
|
label: 'Khối nội tuyến',
|
|
304
|
-
remove: 'Xóa {{
|
|
304
|
+
remove: 'Xóa {{label}}'
|
|
305
305
|
},
|
|
306
306
|
label: 'Khối'
|
|
307
307
|
},
|