GithubHelp home page GithubHelp logo

Comments (4)

amirhhashemi avatar amirhhashemi commented on June 16, 2024 1

Hi @thisunravisara

Thank you for reporting this.

I'm looking into it and will let you know when I found a solution.

I spent a couple of hours to find the issue but it doesn't seem to be a bug in my plugin. The default behaviour of ProseMirror is to remove all marks from the previous line when entering a new like, as you can see in their basic example. Maybe TipTap is doing something that I'm not aware of.

from tiptap-text-direction.

amirhhashemi avatar amirhhashemi commented on June 16, 2024 1

@thisunravisara I can't find any documentation pointing setNodeAttribute resets marks. But your solution works. Thank you.

I released 0.3.1 to fix this issue.

from tiptap-text-direction.

thisunravisara avatar thisunravisara commented on June 16, 2024

Hi @amirhhashemi

Thanks a lot for the speedy reply!

You can find out the problem by toggling the extension on and off over here: StackBlitz Link.

Yeah, it appears that Tiptap has indeed enhanced the default behaviour of ProseMirror.

from tiptap-text-direction.

thisunravisara avatar thisunravisara commented on June 16, 2024

Hi @amirhhashemi

Have to preserve and restore marks after updating node attributes

addProseMirrorPlugins: function( this ) {
                        return [
                            new Plugin({
                                appendTransaction: ( transactions, oldState, newState ) => {
                                    const docChanges = transactions.some( transaction => transaction.docChanged,
                                    );
                                    if ( !docChanges ) {
                                      return;
                                    }
                                    let modified = false;
                                    const tr = newState.tr;
                                    newState.doc.descendants(( node, pos ) => {
                                      if ( this.options.types.includes( node.type.name )) {
                                        if ( node.attrs.dir !== null && node.textContent.length > 0 ) {
                                          return;
                                        }
                                        const marks = tr.storedMarks || [];
                                        tr.setNodeAttribute( pos, 'dir', getTextDirection( node.textContent ));
                                        marks.forEach( mark => {
                                          tr.addStoredMark( mark );
                                        });
                                        modified = true;
                                      }
                                    });
                                    return modified ? tr : null;
                                }}),
                        ];

from tiptap-text-direction.

Related Issues (5)

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.