Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

prosemirror-view

Package Overview
Dependencies
Maintainers
1
Versions
284
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

prosemirror-view - npm Package Compare versions

Comparing version 1.0.2 to 1.0.3

2

package.json
{
"name": "prosemirror-view",
"version": "1.0.2",
"version": "1.0.3",
"description": "ProseMirror's view component",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

@@ -214,4 +214,14 @@ import {Fragment, DOMParser} from "prosemirror-model"

let doc = oldState.doc, compare = doc.slice(parse.from, parse.to)
let change = findDiff(compare.content, parse.doc.content, parse.from, oldState.selection.from)
let preferredPos, preferredSide
// Prefer anchoring to end when Backspace is pressed
if (view.lastKeyCode === 8 && Date.now() - 100 < view.lastKeyCodeTime) {
preferredPos = oldState.selection.to
preferredSide = "end"
} else {
preferredPos = oldState.selection.from
preferredSide = "start"
}
view.lastKeyCode = null
let change = findDiff(compare.content, parse.doc.content, parse.from, preferredPos, preferredSide)
if (!change) {

@@ -347,8 +357,12 @@ if (allowTypeOver) {

function findDiff(a, b, pos, preferedStart) {
function findDiff(a, b, pos, preferredPos, preferredSide) {
let start = a.findDiffStart(b, pos)
if (start == null) return null
let {a: endA, b: endB} = a.findDiffEnd(b, pos + a.size, pos + b.size)
if (preferredSide == "end") {
let adjust = Math.max(0, start - Math.min(endA, endB))
preferredPos -= endA + adjust - start
}
if (endA < start && a.size < b.size) {
let move = preferedStart <= start && preferedStart >= endA ? start - preferedStart : 0
let move = preferredPos <= start && preferredPos >= endA ? start - preferredPos : 0
start -= move

@@ -358,3 +372,3 @@ endB = start + (endB - endA)

} else if (endB < start) {
let move = preferedStart <= start && preferedStart >= endB ? start - preferedStart : 0
let move = preferredPos <= start && preferredPos >= endB ? start - preferredPos : 0
start -= move

@@ -361,0 +375,0 @@ endA = start + (endA - endB)

@@ -18,2 +18,4 @@ import {Selection, NodeSelection, TextSelection} from "prosemirror-state"

view.inDOMChange = null
view.lastKeyCode = null
view.lastKeyCodeTime = 0
view.domObserver = new DOMObserver(view)

@@ -74,2 +76,4 @@ view.domObserver.start()

if (view.inDOMChange) return
view.lastKeyCode = event.keyCode
view.lastKeyCodeTime = Date.now()
if (view.someProp("handleKeyDown", f => f(view, event)) || captureKeyDown(view, event))

@@ -76,0 +80,0 @@ event.preventDefault()

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc