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

Add Inline Source Support #11

Open
evanplaice opened this issue Jul 1, 2020 · 3 comments
Open

Add Inline Source Support #11

evanplaice opened this issue Jul 1, 2020 · 3 comments
Labels
enhancement New feature or request

Comments

@evanplaice
Copy link
Member

Add the ability to load the source from an inline <script> tag

<wc-monaco-editor language="javascript">
  <script type="wc-content">
      function myGoodPerson(){
        return "what can I do for you ?"
      }
  </script>
</wc-monaco-editor>
@evanplaice evanplaice added the enhancement New feature or request label Jul 1, 2020
@swyxio
Copy link

swyxio commented Jun 4, 2021

just swimming by here! i tried to use the value attribute but it didnt seem to work:

<wc-monaco-editor language="javascript" value="let foo = 123">
</wc-monaco-editor>

was this the intended use? is inline source support something different?

@evanplaice
Copy link
Member Author

That doesn't work because 'value' is a property not an HTML attribute. It's only assignable via JavaScript.

To answer your question. Yes, the inline source feature is intended for declaratively defining the initial value of the editor declaratively in HTML.

Generally, I've found 4 useful strategies for setting complex data on a standard web component.

  • attributes (HTML)
  • properties (JS)
  • inline (HTML)
  • fetch

I just need to implement inline source support for this element. It makes a lot more sense for general use. Fetch works great but adds a lot of overhead, especially on pages with many instances of this component.

@swyxio
Copy link

swyxio commented Jun 6, 2021

ok think i got it. thank you!

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

No branches or pull requests

2 participants