Socket
Socket
Sign inDemoInstall

prosemirror-transform

Package Overview
Dependencies
Maintainers
1
Versions
71
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

prosemirror-transform - npm Package Compare versions

Comparing version 1.0.10 to 1.1.0

8

CHANGELOG.md

@@ -0,1 +1,9 @@

## 1.1.0 (2018-06-20)
### New features
[`Transform.getMirror`](https://prosemirror.net/docs/ref/#transform.Transform.getMirror), usable in obscure circumstances for inspecting the mirroring structure or a transform, is now a public method.
New utility function [`dropPoint`](https://prosemirror.net/docs/ref/#transform.dropPoint), which tries to find a valid position for dropping a slice near a given document position.
## 1.0.10 (2018-04-15)

@@ -2,0 +10,0 @@

2

package.json
{
"name": "prosemirror-transform",
"version": "1.0.10",
"version": "1.1.0",
"description": "ProseMirror document transformations",

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

export {Transform, TransformError} from "./transform"
export {Step, StepResult} from "./step"
export {joinPoint, canJoin, canSplit, insertPoint, liftTarget, findWrapping} from "./structure"
export {joinPoint, canJoin, canSplit, insertPoint, dropPoint, liftTarget, findWrapping} from "./structure"
export {StepMap, MapResult, Mapping} from "./map"

@@ -5,0 +5,0 @@ export {AddMarkStep, RemoveMarkStep} from "./mark_step"

@@ -177,12 +177,2 @@ // Mappable:: interface

getMirror(n) {
if (this.mirror) for (let i = 0; i < this.mirror.length; i++)
if (this.mirror[i] == n) return this.mirror[i + (i % 2 ? -1 : 1)]
}
setMirror(n, m) {
if (!this.mirror) this.mirror = []
this.mirror.push(n, m)
}
// :: (StepMap, ?number)

@@ -207,2 +197,16 @@ // Add a step map to the end of this mapping. If `mirrors` is

// :: (number) → ?number
// Finds the offset of the step map that mirrors the map at the
// given offset, in this mapping (as per the second argument to
// `appendMap`).
getMirror(n) {
if (this.mirror) for (let i = 0; i < this.mirror.length; i++)
if (this.mirror[i] == n) return this.mirror[i + (i % 2 ? -1 : 1)]
}
setMirror(n, m) {
if (!this.mirror) this.mirror = []
this.mirror.push(n, m)
}
// :: (Mapping)

@@ -209,0 +213,0 @@ // Append the inverse of the given mapping to this one.

@@ -262,1 +262,24 @@ import {Slice, Fragment} from "prosemirror-model"

}
// :: (Node, number, Slice) → ?number
// Finds a position at or around the given position where the given
// slice can be inserted. Will look at parent nodes' nearest boundary
// and try there, even if the original position wasn't directly at the
// start or end of that node. Returns null when no position was found.
export function dropPoint(doc, pos, slice) {
let $pos = doc.resolve(pos)
if (!slice.content.size) return pos
let content = slice.content
for (let i = 0; i < slice.openStart; i++) content = content.firstChild.content
for (let pass = 1; pass <= (slice.openStart == 0 && slice.length ? 2 : 1); pass++) {
for (let d = $pos.depth; d >= 0; d--) {
let bias = d == $pos.depth ? 0 : $pos.pos <= ($pos.start(d + 1) + $pos.end(d + 1)) / 2 ? -1 : 1
let insertPos = $pos.index(d) + (bias > 0 ? 1 : 0)
if (pass == 1
? $pos.node(d).canReplace(insertPos, insertPos, content)
: $pos.node(d).contentMatchAt(insertPos).findWrapping(content.firstChild))
return bias == 0 ? $pos.pos : bias < 0 ? $pos.before(d + 1) : $pos.after(d + 1)
}
}
return null
}

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