-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
build: add an editor to svelte-lexical route pages for testing
- Loading branch information
Showing
100 changed files
with
2,648 additions
and
9 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,32 @@ | ||
<h1>Welcome to svelte-lexical library</h1> | ||
<p> | ||
Create your package using @sveltejs/package and preview/showcase your work | ||
with SvelteKit | ||
</p> | ||
<p> | ||
Visit <a href="https://kit.svelte.dev">kit.svelte.dev</a> | ||
to read the documentation | ||
</p> | ||
<script> | ||
import RichTextComposer from './RichTextComposer.svelte'; | ||
import '../global.css'; | ||
</script> | ||
|
||
<main> | ||
<img src="images/logo.svg" alt="Svelte Lexical!" /> | ||
<p> | ||
Welcome to <a href="https://github.com/umaranis/svelte-lexical/"> | ||
svelte-lexical | ||
</a> | ||
demo built using | ||
<a href="https://kit.svelte.dev">SvelteKit</a> | ||
</p> | ||
<div style="text-align: left;"> | ||
<RichTextComposer /> | ||
</div> | ||
</main> | ||
|
||
<style> | ||
main { | ||
text-align: center; | ||
padding: 1em; | ||
max-width: none; | ||
margin: 0 auto; | ||
} | ||
img { | ||
margin: 2em; | ||
max-width: 800px; | ||
} | ||
</style> |
83 changes: 83 additions & 0 deletions
83
packages/svelte-lexical/src/routes/RichTextComposer.svelte
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,83 @@ | ||
<script lang="ts"> | ||
import { | ||
Composer, | ||
ContentEditable, | ||
ToolbarRichText, | ||
ActionBar, | ||
RichTextPlugin, | ||
HistoryPlugin, | ||
ListPlugin, | ||
CheckListPlugin, | ||
HorizontalRulePlugin, | ||
ImagePlugin, | ||
} from '$lib/index.js'; | ||
import { | ||
HeadingNode, | ||
QuoteNode, | ||
ListNode, | ||
ListItemNode, | ||
HorizontalRuleNode, | ||
ImageNode, | ||
} from '$lib/index.js'; | ||
import PlaygroundEditorTheme from './themes/PlaygroundEditorTheme.js'; | ||
import { | ||
$getRoot as getRoot, | ||
$createTextNode as createTextNode, | ||
$createParagraphNode as createParagraphNode, | ||
} from '$lib/index.js'; | ||
import MarkdownShortcutPlugin from '$lib/core/plugins/MardownShortcut/MarkdownShortcutPlugin.svelte'; | ||
const initialConfig = { | ||
theme: PlaygroundEditorTheme, | ||
namespace: 'pg_sveltekit', | ||
nodes: [ | ||
HeadingNode, | ||
ListNode, | ||
ListItemNode, | ||
QuoteNode, | ||
HorizontalRuleNode, | ||
ImageNode, | ||
], | ||
onError: (error: Error) => { | ||
throw error; | ||
}, | ||
editorState: () => { | ||
const root = getRoot(); | ||
if (root.getFirstChild() === null) { | ||
const paragraph = createParagraphNode(); | ||
paragraph.append( | ||
createTextNode('This demo environment is built with '), | ||
createTextNode('svelte-lexical').toggleFormat('code'), | ||
createTextNode('.'), | ||
createTextNode(' Try typing in '), | ||
createTextNode('some text').toggleFormat('bold'), | ||
createTextNode(' with '), | ||
createTextNode('different').toggleFormat('italic'), | ||
createTextNode(' formats.'), | ||
); | ||
root.append(paragraph); | ||
} | ||
}, | ||
}; | ||
</script> | ||
|
||
<Composer {initialConfig}> | ||
<div class="editor-shell"> | ||
<ToolbarRichText /> | ||
<div class="editor-container"> | ||
<div class="editor-scroller"> | ||
<div class="editor"> | ||
<ContentEditable /> | ||
</div> | ||
</div> | ||
<RichTextPlugin /> | ||
<HistoryPlugin /> | ||
<ListPlugin /> | ||
<CheckListPlugin /> | ||
<HorizontalRulePlugin /> | ||
<ImagePlugin /> | ||
|
||
<ActionBar /> | ||
</div> | ||
</div> | ||
</Composer> |
13 changes: 13 additions & 0 deletions
13
packages/svelte-lexical/src/routes/themes/CommentEditorTheme.css
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,13 @@ | ||
/** | ||
* 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. | ||
* | ||
* | ||
*/ | ||
|
||
.CommentEditorTheme__paragraph { | ||
margin: 0; | ||
position: 'relative'; | ||
} |
18 changes: 18 additions & 0 deletions
18
packages/svelte-lexical/src/routes/themes/CommentEditorTheme.js
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,18 @@ | ||
/** | ||
* 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 './CommentEditorTheme.css'; | ||
|
||
import baseTheme from './PlaygroundEditorTheme'; | ||
|
||
const theme = { | ||
...baseTheme, | ||
paragraph: 'CommentEditorTheme__paragraph', | ||
}; | ||
|
||
export default theme; |
Oops, something went wrong.