cl-editor icon indicating copy to clipboard operation
cl-editor copied to clipboard

Provide example for usage within svelte

Open retog opened this issue 5 years ago • 3 comments

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.

retog avatar Apr 29 '20 13:04 retog

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"} />

datio avatar May 27 '20 12:05 datio

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

gerald-dotcom avatar Aug 29 '20 23:08 gerald-dotcom

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

llorenteeric avatar Dec 28 '20 00:12 llorenteeric