-
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.
refactor: more control to user library user in composing the editor w…
…ith plugins and controls
- Loading branch information
Showing
20 changed files
with
384 additions
and
194 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<script> | ||
import { | ||
Composer, | ||
ContentEditable, | ||
ActionBar, | ||
PlainTextPlugin, | ||
HistoryPlugin, | ||
} from 'svelte-lexical'; | ||
import PlaygroundEditorTheme from './themes/PlaygroundEditorTheme'; | ||
const config = { | ||
theme: PlaygroundEditorTheme, | ||
nodes: [], | ||
onError: (error) => { | ||
throw error; | ||
}, | ||
}; | ||
</script> | ||
|
||
<Composer {config}> | ||
<div class="editor-shell"> | ||
<div class="editor-container"> | ||
<div class="editor-scroller"> | ||
<div class="editor"> | ||
<ContentEditable /> | ||
</div> | ||
</div> | ||
<PlainTextPlugin /> | ||
<HistoryPlugin /> | ||
|
||
<ActionBar /> | ||
</div> | ||
</div> | ||
</Composer> |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
<script lang="ts"> | ||
import { | ||
Composer, | ||
ContentEditable, | ||
ToolbarRichText, | ||
ActionBar, | ||
RichTextPlugin, | ||
HistoryPlugin, | ||
ListPlugin, | ||
CheckListPlugin, | ||
HorizontalRulePlugin, | ||
ImagePlugin, | ||
//TreeViewPlugin, | ||
} from 'svelte-lexical'; | ||
import { | ||
HeadingNode, | ||
QuoteNode, | ||
ListNode, | ||
ListItemNode, | ||
HorizontalRuleNode, | ||
ImageNode, | ||
} from 'svelte-lexical'; | ||
import PlaygroundEditorTheme from './themes/PlaygroundEditorTheme'; | ||
const config = { | ||
theme: PlaygroundEditorTheme, | ||
nodes: [ | ||
HeadingNode, | ||
ListNode, | ||
ListItemNode, | ||
QuoteNode, | ||
HorizontalRuleNode, | ||
ImageNode, | ||
], | ||
onError: (error) => { | ||
throw error; | ||
}, | ||
}; | ||
</script> | ||
|
||
<Composer {config}> | ||
<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> | ||
<!--<TreeViewPlugin />--> | ||
</div> | ||
</Composer> |
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
39 changes: 39 additions & 0 deletions
39
demos/richtext-editor-basic/src/RichTextBasicComposer.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,39 @@ | ||
<script> | ||
import { | ||
Composer, | ||
ContentEditable, | ||
ToolbarRichText, | ||
ActionBar, | ||
RichTextPlugin, | ||
HistoryPlugin, | ||
ListPlugin, | ||
} from 'svelte-lexical'; | ||
import {HeadingNode, QuoteNode, ListNode, ListItemNode} from 'svelte-lexical'; | ||
import PlaygroundEditorTheme from './themes/PlaygroundEditorTheme'; | ||
const config = { | ||
theme: PlaygroundEditorTheme, | ||
nodes: [HeadingNode, ListNode, ListItemNode, QuoteNode], | ||
onError: (error) => { | ||
throw error; | ||
}, | ||
}; | ||
</script> | ||
|
||
<Composer {config}> | ||
<div class="editor-shell"> | ||
<ToolbarRichText /> | ||
<div class="editor-container"> | ||
<div class="editor-scroller"> | ||
<div class="editor"> | ||
<ContentEditable /> | ||
</div> | ||
</div> | ||
<RichTextPlugin /> | ||
<HistoryPlugin /> | ||
<ListPlugin /> | ||
|
||
<ActionBar /> | ||
</div> | ||
</div> | ||
</Composer> |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
<script lang="ts"> | ||
import { | ||
Composer, | ||
ContentEditable, | ||
ToolbarRichText, | ||
ActionBar, | ||
RichTextPlugin, | ||
HistoryPlugin, | ||
ListPlugin, | ||
CheckListPlugin, | ||
HorizontalRulePlugin, | ||
ImagePlugin, | ||
} from 'svelte-lexical'; | ||
import { | ||
HeadingNode, | ||
QuoteNode, | ||
ListNode, | ||
ListItemNode, | ||
HorizontalRuleNode, | ||
ImageNode, | ||
} from 'svelte-lexical'; | ||
import PlaygroundEditorTheme from './themes/PlaygroundEditorTheme'; | ||
const config = { | ||
theme: PlaygroundEditorTheme, | ||
nodes: [ | ||
HeadingNode, | ||
ListNode, | ||
ListItemNode, | ||
QuoteNode, | ||
HorizontalRuleNode, | ||
ImageNode, | ||
], | ||
onError: (error) => { | ||
throw error; | ||
}, | ||
}; | ||
</script> | ||
|
||
<Composer {config}> | ||
<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> |
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,59 @@ | ||
<script> | ||
import { | ||
Composer, | ||
ContentEditable, | ||
ToolbarRichText, | ||
ActionBar, | ||
RichTextPlugin, | ||
HistoryPlugin, | ||
ListPlugin, | ||
CheckListPlugin, | ||
HorizontalRulePlugin, | ||
ImagePlugin, | ||
} from 'svelte-lexical'; | ||
import { | ||
HeadingNode, | ||
QuoteNode, | ||
ListNode, | ||
ListItemNode, | ||
HorizontalRuleNode, | ||
ImageNode, | ||
} from 'svelte-lexical'; | ||
import PlaygroundEditorTheme from './themes/PlaygroundEditorTheme'; | ||
const config = { | ||
theme: PlaygroundEditorTheme, | ||
nodes: [ | ||
HeadingNode, | ||
ListNode, | ||
ListItemNode, | ||
QuoteNode, | ||
HorizontalRuleNode, | ||
ImageNode, | ||
], | ||
onError: (error) => { | ||
throw error; | ||
}, | ||
}; | ||
</script> | ||
|
||
<Composer {config}> | ||
<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> |
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,2 @@ | ||
//TODO: initializeEditor references `document` which causes the server-side-rendering to fail | ||
export const ssr = false; |
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,8 +1,11 @@ | ||
<script> | ||
import { RichTextComposer } from 'svelte-lexical'; | ||
import PlaygroundEditorTheme from '../themes/PlaygroundEditorTheme'; | ||
import '../global.css'; | ||
import RichTextComposer from './../RichTextComposer.svelte'; | ||
import '../global.css'; | ||
</script> | ||
|
||
<h1>Welcome to SvelteKit</h1> | ||
<p>Visit <a href="https://kit.svelte.dev">kit.svelte.dev</a> to read the documentation</p> | ||
<RichTextComposer theme={PlaygroundEditorTheme}/> | ||
<p> | ||
Visit <a href="https://kit.svelte.dev">kit.svelte.dev</a> | ||
to read the documentation | ||
</p> | ||
<RichTextComposer /> |
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.