Code Monkey home page Code Monkey logo

Comments (9)

moughxyz avatar moughxyz commented on July 1, 2024

We use CodeMirror for most MD editors, so if they allow this, we can add it. Haven't seen it done before though.

from minimal-markdown-editor.

pawelniegowski avatar pawelniegowski commented on July 1, 2024

Seems like switching CM's mode to Github-flavored will do that out of the box https://codemirror.net/mode/gfm/index.html .

from minimal-markdown-editor.

bschlagel avatar bschlagel commented on July 1, 2024

Came here to post this exact same request! After signing up for an extended account I spent a few hours playing around with all the editors, and the biggest thing I immediately found missing vs. Simplenote was the lack of clickable hyperlinks, something I use probably dozens of times per day, in all sorts of notes.

@mobitar if as the above comment suggests this could be supported with 'GFM Mode' in CodeMirror, hopefully this would be doable, and an enormously helpful enhancement. Ideally could be enabled for all the different Markdown editor options…must admit I'm not totally sure all the differences between 'em but if they're all based on CodeMirror, may as well :)

from minimal-markdown-editor.

moughxyz avatar moughxyz commented on July 1, 2024

Links don't appear to be clickable in the GFM mode demo above.

from minimal-markdown-editor.

bschlagel avatar bschlagel commented on July 1, 2024

Ah darn, yeah I see that now. It does seem to be properly parsing the links though and adding markup to show them blue highlighted/underlined…just not making them clickable!

When I inspect the example there, looks like link are getting wrapped in a special class, e.g.:
<span class="cm-link">http://github.github.com/github-flavored-markdown/</span>

So it seems all it would take to make them clickable would be to wrap any such elements in an a tag e.g.:
<a href="http://github.github.com/github-flavored-markdown/"><span class="cm-link">http://github.github.com/github-flavored-markdown/</span></a>

(Where the href value = identical to the text within the span.cm-link)

Does that seem like something that would be possible to add?

from minimal-markdown-editor.

moughxyz avatar moughxyz commented on July 1, 2024

I'm not sure, but even if it were, overriding CodeMirror behavior is outside the scope of my experience. Would happily welcome a PR though if it were possible.

from minimal-markdown-editor.

bschlagel avatar bschlagel commented on July 1, 2024

Gotcha. I also have no experience mucking around with overriding CodeMirror and not sure how feasible that would be. May be a little above my pay grade but does seem worth exploring :)

Any downside to enabling "GFM mode" in CodeMirror anyway so it at least highlights the links? Might make it easier to then add an extension to make them clickable, since the parsing would already be done at least?

I'd also be happy for this functionality (clickable hyperlinks) to work with the basic default editor, if that seems like a possibility. Not sure if that might be simpler than extending the CodeMirror functionality, guessing probably not…

I'm happy to look into this more at some point, just want to make sure I start in the right direction. Thanks!

from minimal-markdown-editor.

bschlagel avatar bschlagel commented on July 1, 2024

Update: found this reference which seems to address basically how this could be done—

https://stackoverflow.com/questions/26933344/codemirror-detect-and-create-links-inside-editor

Sounds like the first step, an "overlay mode" recognizing links, might already be taken care of by the GFM mode, which adds the cm-link class.

So then would basically need to:

  • Add a click listener, detect if target has cm-link class
  • Use coordsChar to get clicked position in the doc + extract the link

Idk if that's the best solution but sounds like one approach at least.

from minimal-markdown-editor.

moughxyz avatar moughxyz commented on July 1, 2024

Hmm interesting. Yeah a little too custom for my liking. But we can leave this open to see if anyone would be interested in working on it.

from minimal-markdown-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.