Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

binding editor HTML #25

Open
ak5 opened this issue Aug 16, 2020 · 4 comments
Open

binding editor HTML #25

ak5 opened this issue Aug 16, 2020 · 4 comments

Comments

@ak5
Copy link

ak5 commented Aug 16, 2020

First off, thanks for this! Super useful!

I am using svelte also and found myself wanting do something like <Editor bind:html height={"200"} />, but had to do this:

<script>
  import Editor from "cl-editor/src/Editor.svelte"

  let html = '<h3>hello</h3>'
  let editor

  $: editor && editor.$on('change', () => html = editor.getHtml())
</script>

{@html html}
<Editor bind:this={editor} {html} height={"200"} />

I'm probably missing something, but the simpler, more idiomatic version with bind:html did not work for me.

Even then, the $on('change') doesn't seem to fire when editing raw html

Am I doing it wrong? very likely xD

@dagalti
Copy link

dagalti commented Oct 23, 2020

Try this. its working for me.

<Editor {html} on:change={(e)=>html = e.detail} height={"200px"} />

@acoyfellow
Copy link

This still seems to be an issue for me.. neither of the above techniques trigger a change when editing HTML:

https://svelte.dev/repl/209dd0724c1d440bb5d9950985627f8a?version=3.55.1

@acoyfellow
Copy link

acoyfellow commented Jan 24, 2023

It seems that we're missing an on:input event on the <textarea/> element within Editor.svelte.

Modifying this line to:

<textarea
  bind:this={$references.raw}
  on:input={(event) => _onChange(event.target.value)}
  class="cl-textarea"
  style="max-height: {height}; min-height: {height}"
/>

And it behaves as I'd expect.

@djplaner
Copy link

Thank you @acoyfellow your solution worked for my problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants