Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
570 views
in Technique[技术] by (71.8m points)

Tiptap how to create a paragraph (p) on Shift-Enter, instead of a br?

Using TipTap, I'm trying to avoid adding a <br />, but create a <p></p> instead, with the focus inside that <p>|</p> when the user hit shift-Enter but I can't make it work.

Here's what I did so far:

new (class extends Extension {
    keys () {
        return {
            'Shift-Enter' (state, dispatch, view) {
                const { schema, tr } = view.state
                const paragraph = schema.nodes.paragraph

                console.log(tr.storedMarks)
                const transaction = tr.deleteSelection().replaceSelectionWith(paragraph.create(), true).scrollIntoView()
                view.dispatch(transaction)
                return true
            }
        }
    }
})()

How can I do?

Thanks in advance.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share
...