Coder Social home page Coder Social logo

Comments (8)

marijnh avatar marijnh commented on August 23, 2024

The approach to tables that uses a width attribute is likely to be deprecated in the future, in favor of using a plugin with an appendTransaction function to ensure rectangular shape instead of schema-level restrictions (which makes things like colspan and rowspan possible), and such an approach wouldn't have this problem. Maybe you can build your tables like that?

from prosemirror-markdown.

mhuebert avatar mhuebert commented on August 23, 2024

Hmm. Markdown tables don't support colspan, so maybe it makes sense to enforce it at the schema level, but I haven't written any plugins yet so I will have to learn more about transactions to know how that would work. Do you know offhand any plugins that have a similar appendTransaction function that would be worth look at?

from prosemirror-markdown.

marijnh avatar marijnh commented on August 23, 2024

The new-style table implementation hasn't been open-sourced yet, but in effect, what it does is scan the document for tables, and for those that aren't rectangular, append a transaction that inserts cells to make them rectangular.

from prosemirror-markdown.

mhuebert avatar mhuebert commented on August 23, 2024

OK. Does that mean on every transaction it is scanning the whole doc to find and validate all the tables? (or is there a way to only scan things that were edited in the last transaction?)

from prosemirror-markdown.

marijnh avatar marijnh commented on August 23, 2024

You can write a helper (but it's not part of the library yet) that recursively descends two documents (the one before the transaction and the one after) and skips nodes that are the same in both, in order to make scanning huge document for this kind of consistency issues cheap.

from prosemirror-markdown.

mhuebert avatar mhuebert commented on August 23, 2024

OK, that makes sense.

I do like the behavior that comes with schema constraints; when deleting the contents of a cell, the cell remains in place, and the cursor jumps to the previous cell. Without schema constraints, the cell itself is deleted, meaning the neighbouring cell gets shifted to a different column. Example: https://www.youtube.com/watch?v=JBVVCt_C7tw

from prosemirror-markdown.

marijnh avatar marijnh commented on August 23, 2024

Deleting the whole cell when you delete its contents shouldn't happen. How exactly are you deleting it?

I agree that the schema-constraint formulation of table shape is attractive, but it's a pain to parse cleanly (as you found), doesn't generalize well at all, and basically feels like a hack, so I'm not happy with it.

from prosemirror-markdown.

mhuebert avatar mhuebert commented on August 23, 2024

I was deleting the cell contents via backspace. However, I just realized the isolating key was only added in 0.21.0, and I hadn't seen the update - now the behavior is great.

Even without a plugin / appendTransaction function, I think this should be ok for now - I don't see any obvious ways that a user will end up with an imbalanced table.

Table row-count was only issue so far where I needed lower-level access in the parser so I'll close this now.

from prosemirror-markdown.

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.