Giter Club home page Giter Club logo

Comments (3)

giamir avatar giamir commented on August 16, 2024 1

For our internal use cases we don't need to support embedded base64 images. The default behavior of the editor consider data urls (e.g. data:image/png;base64,<base64>) invalid links. To change that behavior you can pass your own link validator:
https://github.com/StackExchange/Stacks-Editor/blob/main/src/shared/view.ts#L99
Passing the following stacks editor configuration will make all text a valid link (including data urls). This will instruct the editor to parse embed images as you expect to.

{
  parserFeatures: {
    validateLink: () => true
  }
}

from stacks-editor.

giamir avatar giamir commented on August 16, 2024

Thanks for raising this issue.

The problem you are describing is related to how the image upload handler has been setup in the editor playground.
https://github.com/StackExchange/Stacks-Editor/blob/main/site/index.ts#L92
In the playground we don't upload images in any 3rd party services and instead we have a couple of dummy solutions which allow us to keep the image in browser memory.
The first solution is using a service worker that intercept requests to a specific domain and store/serve images. This solution is currently working locally but not in the deployed playground (we will look into why that's the case).
The other workaround is reading and translating an image to a data url (which is what's happening in the playground).
As I said those solutions are dummy examples, most times you want to setup your image upload handler so that it pushes the files to an hosting solution (not store them in the user browser).

Here is the interface for the image upload plugin options interface:
https://github.com/StackExchange/Stacks-Editor/blob/main/src/shared/prosemirror-plugins/image-upload.ts#L31

I am going to close this issue since it is not really a problem with the editor itself but rather with the way the image upload handler is setup in the playground.

from stacks-editor.

mdobreva avatar mdobreva commented on August 16, 2024

Hello @giamir, I am afraid you misunderstand my issue. In my particular use case, I do not want to upload the image to a hosting solution. In stead, I want the image to be embedded into the markdown content as BASE64 encoded. So far this works as expected, and if I convert the markdown content to HTML with this embedded BASE64 content, the generated HTML works, too.

The problem here is that Stacks Editor does not render the image from embedded BASE64 content, if the markdown with such embedded images is loaded into the editor.

from stacks-editor.

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.