prosemirror-commands
Advanced tools
Comparing version
@@ -0,1 +1,7 @@ | ||
## 1.1.6 (2021-02-10) | ||
### Bug fixes | ||
Improve behavior of enter when the entire document is selected. | ||
## 1.1.5 (2021-01-14) | ||
@@ -2,0 +8,0 @@ |
@@ -278,7 +278,7 @@ import { liftTarget, canJoin, joinPoint, canSplit, ReplaceAroundStep, findWrapping } from 'prosemirror-transform'; | ||
function createParagraphNear(state, dispatch) { | ||
var ref = state.selection; | ||
var $from = ref.$from; | ||
var $to = ref.$to; | ||
if ($from.parent.inlineContent || $to.parent.inlineContent) { return false } | ||
var type = defaultBlockAt($from.parent.contentMatchAt($to.indexAfter())); | ||
var sel = state.selection; | ||
var $from = sel.$from; | ||
var $to = sel.$to; | ||
if (!(sel instanceof NodeSelection) || $from.parent.inlineContent) { return false } | ||
var type = defaultBlockAt($to.parent.contentMatchAt($to.indexAfter())); | ||
if (!type || !type.isTextblock) { return false } | ||
@@ -332,3 +332,3 @@ if (dispatch) { | ||
var tr = state.tr; | ||
if (state.selection instanceof TextSelection) { tr.deleteSelection(); } | ||
if (state.selection instanceof TextSelection || state.selection instanceof AllSelection) { tr.deleteSelection(); } | ||
var deflt = $from.depth == 0 ? null : defaultBlockAt($from.node(-1).contentMatchAt($from.indexAfter(-1))); | ||
@@ -335,0 +335,0 @@ var types = atEnd && deflt ? [{type: deflt}] : null; |
@@ -282,7 +282,7 @@ 'use strict'; | ||
function createParagraphNear(state, dispatch) { | ||
var ref = state.selection; | ||
var $from = ref.$from; | ||
var $to = ref.$to; | ||
if ($from.parent.inlineContent || $to.parent.inlineContent) { return false } | ||
var type = defaultBlockAt($from.parent.contentMatchAt($to.indexAfter())); | ||
var sel = state.selection; | ||
var $from = sel.$from; | ||
var $to = sel.$to; | ||
if (!(sel instanceof prosemirrorState.NodeSelection) || $from.parent.inlineContent) { return false } | ||
var type = defaultBlockAt($to.parent.contentMatchAt($to.indexAfter())); | ||
if (!type || !type.isTextblock) { return false } | ||
@@ -336,3 +336,3 @@ if (dispatch) { | ||
var tr = state.tr; | ||
if (state.selection instanceof prosemirrorState.TextSelection) { tr.deleteSelection(); } | ||
if (state.selection instanceof prosemirrorState.TextSelection || state.selection instanceof prosemirrorState.AllSelection) { tr.deleteSelection(); } | ||
var deflt = $from.depth == 0 ? null : defaultBlockAt($from.node(-1).contentMatchAt($from.indexAfter(-1))); | ||
@@ -339,0 +339,0 @@ var types = atEnd && deflt ? [{type: deflt}] : null; |
{ | ||
"name": "prosemirror-commands", | ||
"version": "1.1.5", | ||
"version": "1.1.6", | ||
"description": "Editing commands for ProseMirror", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -263,5 +263,5 @@ import {joinPoint, canJoin, findWrapping, liftTarget, canSplit, ReplaceAroundStep} from "prosemirror-transform" | ||
export function createParagraphNear(state, dispatch) { | ||
let {$from, $to} = state.selection | ||
if ($from.parent.inlineContent || $to.parent.inlineContent) return false | ||
let type = defaultBlockAt($from.parent.contentMatchAt($to.indexAfter())) | ||
let sel = state.selection, {$from, $to} = sel | ||
if (!(sel instanceof NodeSelection) || $from.parent.inlineContent) return false | ||
let type = defaultBlockAt($to.parent.contentMatchAt($to.indexAfter())) | ||
if (!type || !type.isTextblock) return false | ||
@@ -312,3 +312,3 @@ if (dispatch) { | ||
let tr = state.tr | ||
if (state.selection instanceof TextSelection) tr.deleteSelection() | ||
if (state.selection instanceof TextSelection || state.selection instanceof AllSelection) tr.deleteSelection() | ||
let deflt = $from.depth == 0 ? null : defaultBlockAt($from.node(-1).contentMatchAt($from.indexAfter(-1))) | ||
@@ -315,0 +315,0 @@ let types = atEnd && deflt ? [{type: deflt}] : null |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
201842
0.25%