Skip to content

Binding the value #3

Description

@frantic0

Hi @jcfisher007 (@FormBucketSupport ),

also related to #2

I was expecting to be able to bind the CodeMirror's value like so

<script>
  let value = "fooo";
  let cm2;
</script>
<div class="codemirror-container flex">
  <CodeMirror bind:this={cm1} bind:value={value} />
  <br>
  <CodeMirror bind:this={cm2} {value} />
  <br>
  <button on:click="{ () => { value += value + '1'; cm2.update(value); console.log(value); }}" >Press me!</button>
</div>

But then I found your comment

// We have to expose set and update methods, rather
// than making this state-driven through props,
// because it's difficult to update an editor
// without resetting scroll otherwise

Correct me if I'm wrong, but this means that it is the parent component's responsibility to import and subscribe on:change, as well as set and update?

Many thanks,
F

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions