Giter Site home page Giter Site logo

svelte example fails about hashmd HOT 11 CLOSED

pd4d10 avatar pd4d10 commented on August 20, 2024
svelte example fails

from hashmd.

Comments (11)

pd4d10 avatar pd4d10 commented on August 20, 2024 1

It is recommended to save Markdown text instead of HTML, because Markdown can be transformed to HTML losslessly, while the reverse can not.

from hashmd.

pd4d10 avatar pd4d10 commented on August 20, 2024

I just ran npm i

Did you run it at examples/svelte folder? The examples are not included in the monorepo.

from hashmd.

amalshaji avatar amalshaji commented on August 20, 2024

Yes, I downloaded the example/svelte folder, cd and ran npm i

from hashmd.

pd4d10 avatar pd4d10 commented on August 20, 2024

Oh, it seems the package bytemd and plugins are not listed in the dependencies of the example.

The temporary solutions is to run yarn && yarn devat the root folder, which would link all packages to the root node_modules, which the example could access too.

from hashmd.

amalshaji avatar amalshaji commented on August 20, 2024

It worked, except the .flat() wasn't supported by the browser, wrote one in rollup.config.json

from hashmd.

pd4d10 avatar pd4d10 commented on August 20, 2024

.flat() wasn't supported

Upgrade the Node.js version should solve this problem

from hashmd.

amalshaji avatar amalshaji commented on August 20, 2024
node --version
v15.1.0

Image uploaded to the editor is not working

no image

from hashmd.

pd4d10 avatar pd4d10 commented on August 20, 2024

Yeah, it is because the upload option is to simply convert image to base64, while the data: scheme is not allowed by default.

https://github.com/bytedance/bytemd/blob/cdb89e016eb58eca0e32519d21c445d1f80d5450/examples/svelte/src/App.svelte#L69-L73

There are two ways to solve this problem:

  1. Change the upload option to uploading the image files to the server then return a URL (Recommended)
       importImage({ 
         upload(files) { 
           return uploadFilesToServer(files) // return ['https://xxx']
         }, 
       }), 
  1. Customize sanitize schema to allow data: scheme:
<Editor sanitize={(schema) => {
  schema.protocols.src.push('data')
  return schema
}} />

from hashmd.

amalshaji avatar amalshaji commented on August 20, 2024

Thanks for replying patiently. Now I feel the image doubt was pretty stupid; I should've gone through the source code.

from hashmd.

amalshaji avatar amalshaji commented on August 20, 2024

How do I access the rendered HTML in the svelte example?

from hashmd.

pd4d10 avatar pd4d10 commented on August 20, 2024
import { getProcessor } from 'bytemd'
const html = getProcessor({ plugins: [/*add your plugins*/] }).processSync('# markdown text').toString()

from hashmd.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.