How to get selected text

In previous version following code was doing what expected. Anyhow since pm.doc.sliceBetween doesn’t seem to exist, what is official way to grab selected text to i.e. wrap it?

Twitterable.register('command', 'insert', {
    label: 'Wrap the selection in a block quote',
    run(pm) {
        let content = pm.doc.sliceBetween(pm.selection.from,,
            node = this.create(null, content.content);
    menuGroup: 'block(46)',

You can call pm.doc.cut(pm.selection.from, to get a fragment of the document.

(Note that your approach to wrapping something in a blockquote has the disadvantage of completely replacing the whole range, which would work poorly when doing collaborative editing, since it’ll nullify all concurrent changes in that range. Some combination of Transform.split and Transform.wrap would prevent this.)

1 Like

Thanks. That should be enough. We don’t pick collab editing yet.