-
Notifications
You must be signed in to change notification settings - Fork 583
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(app-headless-cms): add folder selector to new entry dialog (#3485)
- Loading branch information
Showing
30 changed files
with
404 additions
and
466 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 37 additions & 20 deletions
57
packages/app-headless-cms/src/admin/components/LexicalCmsEditor/LexicalCmsEditor.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,53 @@ | ||
import React from "react"; | ||
import React, { useCallback } from "react"; | ||
import { StaticToolbar } from "@webiny/lexical-editor"; | ||
import { RichTextEditorProps } from "@webiny/lexical-editor/types"; | ||
import { CompositionScope } from "@webiny/react-composition"; | ||
import { LexicalEditor } from "@webiny/app-admin/components/LexicalEditor"; | ||
|
||
const placeholderStyles: React.CSSProperties = { position: "absolute", top: 40, left: 25 }; | ||
|
||
const contentEditableStyles: React.CSSProperties = { | ||
minHeight: 200, | ||
display: "block", | ||
padding: 10 | ||
}; | ||
|
||
const styles: React.CSSProperties = { | ||
backgroundColor: "#fff", | ||
border: "1px solid #e1e1e1", | ||
padding: "10px 14px", | ||
minHeight: 200, | ||
maxHeight: 350 | ||
}; | ||
|
||
const toolbar = ( | ||
<CompositionScope name={"cms"}> | ||
<StaticToolbar /> | ||
</CompositionScope> | ||
); | ||
|
||
export const LexicalCmsEditor = (props: Omit<RichTextEditorProps, "theme">) => { | ||
const onChange = useCallback( | ||
(jsonString: string) => { | ||
if (props?.onChange) { | ||
props?.onChange(JSON.parse(jsonString)); | ||
} | ||
}, | ||
[props?.onChange] | ||
); | ||
|
||
return ( | ||
<LexicalEditor | ||
{...props} | ||
focus={true} | ||
value={JSON.stringify(props.value)} | ||
onChange={(jsonString: string) => { | ||
if (props?.onChange) { | ||
props?.onChange(JSON.parse(jsonString)); | ||
} | ||
}} | ||
staticToolbar={ | ||
<CompositionScope name={"cms"}> | ||
<StaticToolbar /> | ||
</CompositionScope> | ||
} | ||
onChange={onChange} | ||
staticToolbar={toolbar} | ||
tag={"p"} | ||
placeholder={props?.placeholder || "Enter your text here..."} | ||
placeholderStyles={{ position: "absolute", top: 90, left: 25 }} | ||
contentEditableStyles={{ minHeight: 200, display: "block", padding: 10 }} | ||
styles={{ | ||
backgroundColor: "#fff", | ||
border: "1px solid #e1e1e1", | ||
padding: "10px 14px", | ||
minHeight: 200, | ||
maxHeight: 350 | ||
}} | ||
placeholderStyles={placeholderStyles} | ||
contentEditableStyles={contentEditableStyles} | ||
styles={styles} | ||
/> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
128 changes: 0 additions & 128 deletions
128
...cms/src/admin/plugins/fieldRenderers/ref/advanced/components/NewReferencedEntryDialog.tsx
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.