question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Bytemd 1.12.4 svelte does not seem to work

See original GitHub issue

Somehow adding the Editor (see component code below) does not work, and breaks any page with the editor included:

<script>
  import { Editor } from "bytemd";
  import gfm from "@bytemd/plugin-gfm";
  import bytemdLocaleDe from "bytemd/lib/locales/de.json";
  import bytemdLocaleEn from "bytemd/lib/locales/en.json";
  import { get } from "svelte/store";
  import { stores } from "@sapper/app";
  const { session } = stores();

  const plugins = [gfm()];

  function handleChange(e) {
    content = e.detail.value;
  }

  function changeLocale(locale) {
    if (locale === "de") {
      return bytemdLocaleDe;
    }
    return bytemdLocaleEn;
  }

  $: currentLocale = changeLocale(get(session).locale);

  export let content;

  let tempContent;

  function initContent() {
    if (content && content !== tempContent) {
      tempContent = content;
    }
  }

  $: initContent(content);
</script>

<div class="mb-3">
  <Editor
    value={tempContent}
    plugins={plugins}
    on:change={handleChange}
    locale={currentLocale}
  />
</div>

This error is shown in the console output

TypeError: Cannot read properties of undefined (reading '$$')
    at init$1 (index.esm.js:258:46)
    at new Editor (index.esm.js:35629:5)
    at create_fragment (index.esm.js:4897:1)

we use:

  • svelte 3.46.4
  • sapper 0.29.3
  • rollup 2.70.1

Issue Analytics

  • State:open
  • Created a year ago
  • Comments:11 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
vujovicigorcommented, Sep 28, 2022

Solution for me was to import it directly from node_modules:

    //import { Editor } from 'bytemd';
    import Editor from '../node_modules/bytemd/svelte/editor.svelte';
0reactions
dbradleyflcommented, Nov 18, 2022

@vujovicigor thanks for the workaround. Same issue for me.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Cant get this working in Svelte Kit #96 - bytedance/bytemd
Hi I can't seem to get this working in Svelte Kit. Like all my other modules: [vite] Error when evaluating SSR module ...
Read more >
SvelteKit + ByteMD : r/sveltejs - Reddit
But, I have an error when trying to use ByteMD: Uncaught (in… ... The problem seems to be just on SvelteKit, so do...
Read more >
bytemd - npm
ByteMD is a Markdown editor component built with Svelte. ... You can also write your own plugin if these ones don't meet your...
Read more >
Simple Markdown Editor • REPL • Svelte
import sanitizeHtml from 'https://cdnjs.cloudflare.com/ajax/libs/sanitize-html/1.27.5/sanitize-html-es2015.min.js';. 4.
Read more >
bytemd - bytemeta
bytemd repo issues. ... @bytemd/plugin-highlight-ssr插件无法高亮代码 ... Bytemd 1.12.4 svelte does not seem to work. goodforever. goodforever CLOSED.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found