forked from facebook/lexical
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
32 changed files
with
3,383 additions
and
2 deletions.
There are no files selected for viewing
36 changes: 36 additions & 0 deletions
36
scripts/__tests__/integration/fixtures/lexical-esm-nextjs/.gitignore
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 |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files. | ||
|
||
# dependencies | ||
/node_modules | ||
/.pnp | ||
.pnp.js | ||
.yarn/install-state.gz | ||
|
||
# testing | ||
/coverage | ||
|
||
# next.js | ||
/.next/ | ||
/out/ | ||
|
||
# production | ||
/build | ||
|
||
# misc | ||
.DS_Store | ||
*.pem | ||
|
||
# debug | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
|
||
# local env files | ||
.env*.local | ||
|
||
# vercel | ||
.vercel | ||
|
||
# typescript | ||
*.tsbuildinfo | ||
next-env.d.ts |
36 changes: 36 additions & 0 deletions
36
scripts/__tests__/integration/fixtures/lexical-esm-nextjs/README.md
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 |
---|---|---|
@@ -0,0 +1,36 @@ | ||
This is a [Next.js](https://nextjs.org/) project bootstrapped with [`create-next-app`](https://github.com/vercel/next.js/tree/canary/packages/create-next-app). | ||
|
||
## Getting Started | ||
|
||
First, run the development server: | ||
|
||
```bash | ||
npm run dev | ||
# or | ||
yarn dev | ||
# or | ||
pnpm dev | ||
# or | ||
bun dev | ||
``` | ||
|
||
Open [http://localhost:3000](http://localhost:3000) with your browser to see the result. | ||
|
||
You can start editing the page by modifying `app/page.tsx`. The page auto-updates as you edit the file. | ||
|
||
This project uses [`next/font`](https://nextjs.org/docs/basic-features/font-optimization) to automatically optimize and load Inter, a custom Google Font. | ||
|
||
## Learn More | ||
|
||
To learn more about Next.js, take a look at the following resources: | ||
|
||
- [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API. | ||
- [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial. | ||
|
||
You can check out [the Next.js GitHub repository](https://github.com/vercel/next.js/) - your feedback and contributions are welcome! | ||
|
||
## Deploy on Vercel | ||
|
||
The easiest way to deploy your Next.js app is to use the [Vercel Platform](https://vercel.com/new?utm_medium=default-template&filter=next.js&utm_source=create-next-app&utm_campaign=create-next-app-readme) from the creators of Next.js. | ||
|
||
Check out our [Next.js deployment documentation](https://nextjs.org/docs/deployment) for more details. |
79 changes: 79 additions & 0 deletions
79
scripts/__tests__/integration/fixtures/lexical-esm-nextjs/app/EditorUseClient.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 |
---|---|---|
@@ -0,0 +1,79 @@ | ||
"use client"; | ||
/** | ||
* Copyright (c) Meta Platforms, Inc. and affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
* | ||
*/ | ||
import { AutoFocusPlugin } from "@lexical/react/LexicalAutoFocusPlugin"; | ||
import { LexicalComposer } from "@lexical/react/LexicalComposer"; | ||
import { ContentEditable } from "@lexical/react/LexicalContentEditable"; | ||
import LexicalErrorBoundary from "@lexical/react/LexicalErrorBoundary"; | ||
import { HistoryPlugin } from "@lexical/react/LexicalHistoryPlugin"; | ||
import { RichTextPlugin } from "@lexical/react/LexicalRichTextPlugin"; | ||
import { | ||
CodeHighlightNode, | ||
CodeNode, | ||
getCodeLanguages, | ||
registerCodeHighlighting, | ||
} from "@lexical/code"; | ||
|
||
import * as React from 'react'; | ||
|
||
import ExampleTheme from "./ExampleTheme"; | ||
import ToolbarPlugin from "./plugins/ToolbarPlugin"; | ||
import TreeViewPlugin from "./plugins/TreeViewPlugin"; | ||
import { useEffect } from "react"; | ||
import { useLexicalComposerContext } from "@lexical/react/LexicalComposerContext"; | ||
import { $getRoot } from "lexical"; | ||
|
||
function Placeholder() { | ||
return <div className="editor-placeholder">Enter some rich text...</div>; | ||
} | ||
|
||
const editorConfig = { | ||
namespace: "React.js Demo", | ||
nodes: [CodeNode, CodeHighlightNode], | ||
// Handling of errors during update | ||
onError(error: Error) { | ||
throw error; | ||
}, | ||
// The editor theme | ||
theme: ExampleTheme, | ||
}; | ||
|
||
function CodeHighlightingPlugin() { | ||
const [editor] = useLexicalComposerContext(); | ||
useEffect(() => { | ||
registerCodeHighlighting(editor); | ||
editor.update(() => { | ||
$getRoot() | ||
.clear() | ||
.selectEnd() | ||
.insertRawText(["Registered:", ...getCodeLanguages()].join("\n")); | ||
}); | ||
}, [editor]); | ||
return null; | ||
} | ||
|
||
export default function App() { | ||
return ( | ||
<LexicalComposer initialConfig={editorConfig}> | ||
<div className="editor-container"> | ||
<ToolbarPlugin /> | ||
<div className="editor-inner"> | ||
<RichTextPlugin | ||
contentEditable={<ContentEditable className="editor-input" />} | ||
placeholder={<Placeholder />} | ||
ErrorBoundary={LexicalErrorBoundary} | ||
/> | ||
<HistoryPlugin /> | ||
<AutoFocusPlugin /> | ||
<TreeViewPlugin /> | ||
<CodeHighlightingPlugin /> | ||
</div> | ||
</div> | ||
</LexicalComposer> | ||
); | ||
} |
42 changes: 42 additions & 0 deletions
42
scripts/__tests__/integration/fixtures/lexical-esm-nextjs/app/ExampleTheme.ts
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 |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/** | ||
* Copyright (c) Meta Platforms, Inc. and affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
* | ||
*/ | ||
export default { | ||
code: 'editor-code', | ||
heading: { | ||
h1: 'editor-heading-h1', | ||
h2: 'editor-heading-h2', | ||
h3: 'editor-heading-h3', | ||
h4: 'editor-heading-h4', | ||
h5: 'editor-heading-h5', | ||
}, | ||
image: 'editor-image', | ||
link: 'editor-link', | ||
list: { | ||
listitem: 'editor-listitem', | ||
nested: { | ||
listitem: 'editor-nested-listitem', | ||
}, | ||
ol: 'editor-list-ol', | ||
ul: 'editor-list-ul', | ||
}, | ||
ltr: 'ltr', | ||
paragraph: 'editor-paragraph', | ||
placeholder: 'editor-placeholder', | ||
quote: 'editor-quote', | ||
rtl: 'rtl', | ||
text: { | ||
bold: 'editor-text-bold', | ||
code: 'editor-text-code', | ||
hashtag: 'editor-text-hashtag', | ||
italic: 'editor-text-italic', | ||
overflowed: 'editor-text-overflowed', | ||
strikethrough: 'editor-text-strikethrough', | ||
underline: 'editor-text-underline', | ||
underlineStrikethrough: 'editor-text-underlineStrikethrough', | ||
}, | ||
}; |
Binary file added
BIN
+25.3 KB
scripts/__tests__/integration/fixtures/lexical-esm-nextjs/app/favicon.ico
Binary file not shown.
19 changes: 19 additions & 0 deletions
19
scripts/__tests__/integration/fixtures/lexical-esm-nextjs/app/layout.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 |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import type { Metadata } from "next"; | ||
import "./styles.css"; | ||
|
||
export const metadata: Metadata = { | ||
title: "Create Next App", | ||
description: "Generated by create next app", | ||
}; | ||
|
||
export default function RootLayout({ | ||
children, | ||
}: Readonly<{ | ||
children: React.ReactNode; | ||
}>) { | ||
return ( | ||
<html lang="en"> | ||
<body>{children}</body> | ||
</html> | ||
); | ||
} |
12 changes: 12 additions & 0 deletions
12
scripts/__tests__/integration/fixtures/lexical-esm-nextjs/app/page.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 |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import EditorUseClient from "./EditorUseClient"; | ||
|
||
export const dynamic = 'force-dynamic'; | ||
|
||
export default function Home() { | ||
return ( | ||
<main> | ||
<h1>Next.js Rich Text Lexical Example</h1> | ||
<EditorUseClient /> | ||
</main> | ||
); | ||
} |
Oops, something went wrong.