How to use the medium-editor.MediumEditor.getEditorFromElement function in medium-editor

To help you get started, we’ve selected a few medium-editor examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ticktackim / ticktack-workplan / app / page / blogNew.js View on Github external
filesById[file.link] = file

    const isImage = file.type.match(/^image/)

    var content

    if (isImage) {
      content = h('img', {
        src: `http://localhost:8989/blobs/get/${encodeURIComponent(file.link)}`,
        alt: file.name
      })
    } else {
      content = h('a', { href: file.link }, file.name)
    }
    // TODO - insert where the mouse is yo
    var editor = MediumEditor.getEditorFromElement(composer)
    composer.insertBefore(
      h('p', content),
      editor.currentEl || null
    )

    saveDraft({ composer, meta, api })

    console.log('added:', file)
  })