Skip to content

[Feature Request] Smart table editing #627

Closed

Description

@piperdeck

When editing tables, it can be nice to have the editor automatically add padding to make the columns line up. The following implements this behaviour in a way that works flawlessly, without being intrusive or diverging from vanilla markdown:

https://github.com/susisu/mte-kernel?tab=readme-ov-file

TLDR, you can start a table by typing | and then typing the first column title, then press Tab, Shift-Tab, Return, and Shift-Return to move focus around the table, and it automatically creates new rows and columns, and adds or removes padding. The table manipulation only happens when you press certain keys to navigate the table, not in real time while you're typing. There's also no UI, so it doesn't add any clutter.

Back when I used Obsidian, I used a plugin that implemented this kernel, and it was a complete game changer. Is this the kind of thing you would consider adopting?

Activity

  1. cyanzhong commented on Sep 5, 2024

    @cyanzhong
    Contributor

    Thank you for your feedback. This is not a bad idea.

    In my opinion, table editing in Markdown is frustrating and should not have been invented..

    The ITextEditor protocol looks interesting to me, I am thinking about if conforming to that interface would let you integrate a built mte-kernel JS lib with the existing https://github.com/MarkEdit-app/MarkEdit/wiki/Customization mechanism.

    However, its documentation is no longer available: https://doc.esdoc.org/github.com/susisu/mte-kernel/class/lib/text-editor.js~ITextEditor.html. I also have concerns since it's no longer being maintained.

    Do you know where I can find sample code for this protocol?

  2. piperdeck commented on Sep 5, 2024

    @piperdeck
    Author

    There's an implementation for the defunct Atom text editor, I think these are the relevant code samples:

    https://github.com/susisu/atom-markdown-table-editor/tree/master/lib

    There's also the code for the mte-kernel demo:

    https://github.com/susisu/mte-demo/blob/master/src/main.js

    There is also a fork of the original repo that is still maintained, but it's been converted to Typescript and has more spreadsheet features added to it, which I suspect takes it somewhat out of the intended scope of MarkEdit. I think the relevant code sample from that repo is this one:

    https://github.com/tgrosinger/md-advanced-tables/blob/main/src/text-editor.ts

    That's all I could find, but hopefully it helps

  3. cyanzhong commented on Sep 9, 2024

    @cyanzhong
    Contributor

    I am making a bunch of changes in order to support this:

    Related but not required, I've made the preview button of tables a bit nicer:

  4. piperdeck commented on Sep 10, 2024

    @piperdeck
    Author

    Amazing! Super looking forward to this!

  5. cyanzhong commented on Oct 3, 2024

    @cyanzhong
    Contributor

    It has been released and I've just updated the extension to include "format" and "format all" as well: MarkEdit-app/MarkEdit-mte@7c676cb.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions