cl-editor
cl-editor copied to clipboard
Provide example for usage within svelte
Eventually I found this comment so I could get it to work as follows:
<script>
import Editor from "cl-editor/dist";
import { onMount } from "svelte";
let editArea;
onMount(async () => {
const editor = new Editor({
target: editArea
});
});
</script>
<h1>cl-editor</h1>
<div bind:this={editArea} />
I'm not sure if this is the best way and why I'm getting TypeError: $references.editor is undefined when importing from "cl-editor" rather than "cl-editor/dict" some doucmentation on how to use cl-editor within svelte would be appreciated.
I tried your example and it worked, but there is indeed a better way for those who are using svelte:
<script>
import Editor from "cl-editor/src/Editor.svelte";
// Read the source of the file above to see what gets exported and could be used as a parameter
let html = "<b>some rich content</b>";
</script>
<Editor
actions={["b", "i", "u", "h2", "ul", "left", "center", "justify", "forecolor"]}
{html}
height={"200px"} />
I tried your example and it worked, but there is indeed a better way for those who are using svelte:
<script> import Editor from "cl-editor/src/Editor.svelte"; // Read the source of the file above to see what gets exported and could be used as a parameter let html = "<b>some rich content</b>"; </script> <Editor actions={["b", "i", "u", "h2", "ul", "left", "center", "justify", "forecolor"]} {html} height={"200px"} />
Do you have any issues with pressing certain keys?
I can't get space and asd keys get worked
Hello, thanks for cl-editor and this example. I would like to be able to validate via an external button the text of the editor in order to save it, do you have an example to allow me to do that? Thank you and happy new year