Possible to embed a TextEditor within a TextEditor?


#1

Hello,

When writing tutorials or READMEs, writers often interleave code into markdown files:

// tutorial.md
## How do I translate a DNA or RNA Sequence or SymbolList to Protein?

First, instantiate a new `Bio::Sequence::NA` object:

```ruby
#!/usr/bin/env ruby
 
require 'bio'
 
# create a DNA sequence
seq = Bio::Sequence::NA.new("atggccattgaatga")

Ideally, code would live in its own file. This way, it could easily be linted and tested:

    $ ls -1
    code.rb
    tutorial.md

I've experimented with writing a markdown post-processor that "pulls in" code off of the disk and inserts it into the markdown document. It leaves much to be desired.

Ideally, I'm able to just write a special declaration inside of my markdown file. Atom would then pop-open a mini-editor inside of the markdown document at some fixed height. That mini-editor would be for the other file, `code.rb`:

<img src="/uploads/github_atom/original/3X/b/4/b406396ed9b3ba3d4c407e9b9361fbf40954c35c.png" width="690" height="267">

This inner-editor has its own scrollbar. It _could_ be read-only but it would be great if it could be edited and saved all the same.

Note how this doesn't affect the markdown document — it just has this line:

    {file=code.rb,line-start=1,line-end=6}

I'd still use a post-processor to generate the "completed" markdown with the code in-line. However, Atom would enable me to both see and edit this file in-line with my markdown.

I want to write this package, but I don't even know how feasible this is with the Atom Package API? I _think_ what I'm trying to do is insert a TextEditor within a TextEditor, but I'm not sure. Any direction or comments on feasibility would be much appreciated.

Thank you!

#2

If it is possible at all, it would be because of the Block Decorations API that was just released. Realistically, I don’t think that the Block Decorations API is designed to handle editable elements. And I don’t believe that the TextEditor component is built in a way that it can be inserted in an arbitrary point in the DOM, yet.


#3

This looks great, leedohm! You’re right, not quite an editor, but I think this would still be a huge leap forward.


#4

I’m not sure that’s true. The markdown preview does this, if I remember correctly. Wherever there is code preview it puts in a real editor to use the syntax highlighting built in.