New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

prosemirror-view

Package Overview
Dependencies
Maintainers
1
Versions
287
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.17.8 to 1.18.0

10

CHANGELOG.md

@@ -0,1 +1,11 @@

## 1.18.0 (2021-03-04)
### Bug fixes
Fix a crash in `posAtDOM`.
### New features
Node view constructors and `update` methods are now passed the inner decorations of the node.
## 1.17.8 (2021-02-26)

@@ -2,0 +12,0 @@

2

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

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

@@ -219,3 +219,4 @@ function compareObjs(a, b) {

// ::- A collection of [decorations](#view.Decoration), organized in
// :: class extends DecorationSource
// A collection of [decorations](#view.Decoration), organized in
// such a way that the drawing algorithm can efficiently use and

@@ -417,2 +418,7 @@ // compare them. This is a persistent data structure—it is not

// DecorationSource:: interface
// An object that can [provide](#view.EditorProps.decorations)
// decorations. Implemented by [`DecorationSet`](#view.DecorationSet),
// and passed to [node views](#view.EditorProps.nodeViews).
const empty = new DecorationSet()

@@ -419,0 +425,0 @@

@@ -543,3 +543,3 @@ import {NodeSelection} from "prosemirror-state"

//
// nodeViews:: ?Object<(node: Node, view: EditorView, getPos: () → number, decorations: [Decoration]) → NodeView>
// nodeViews:: ?Object<(node: Node, view: EditorView, getPos: () → number, decorations: [Decoration], innerDecorations: DecorationSource) → NodeView>
// Allows you to pass custom rendering and behavior logic for nodes

@@ -560,2 +560,9 @@ // and marks. Should map node and mark names to constructor

//
// `innerDecorations` holds the decorations for the node's content.
// You can safely ignore this if your view has no content or a
// `contentDOM` property, since the editor will draw the decorations
// on the content. But if you, for example, want to create a nested
// editor with the content, it may make sense to provide it with the
// inner decorations.
//
// clipboardSerializer:: ?DOMSerializer

@@ -573,3 +580,3 @@ // The DOM serializer to use when putting content onto the

//
// decorations:: ?(state: EditorState) → ?DecorationSet
// decorations:: ?(state: EditorState) → ?DecorationSource
// A set of [document decorations](#view.Decoration) to show in the

@@ -576,0 +583,0 @@ // view.

@@ -27,1 +27,3 @@ ProseMirror's view module displays a given [editor

@DecorationSet
@DecorationSource

@@ -33,11 +33,13 @@ import {DOMSerializer, Fragment, Mark} from "prosemirror-model"

//
// update:: ?(node: Node, decorations: [Decoration]) → bool
// update:: ?(node: Node, decorations: [Decoration], innerDecorations: DecorationSource) → bool
// When given, this will be called when the view is updating itself.
// It will be given a node (possibly of a different type), and an
// array of active decorations (which are automatically drawn, and
// the node view may ignore if it isn't interested in them), and
// should return true if it was able to update to that node, and
// false otherwise. If the node view has a `contentDOM` property (or
// no `dom` property), updating its child nodes will be handled by
// ProseMirror.
// It will be given a node (possibly of a different type), an array
// of active decorations around the node (which are automatically
// drawn, and the node view may ignore if it isn't interested in
// them), and a [decoration source](#view.DecorationSource) that
// represents any decorations that apply to the content of the node
// (which again may be ignored). It should return true if it was
// able to update to that node, and false otherwise. If the node
// view has a `contentDOM` property (or no `dom` property), updating
// its child nodes will be handled by ProseMirror.
//

@@ -203,3 +205,3 @@ // selectNode:: ?()

let atEnd
if (dom == this.dom) {
if (dom == this.dom && this.contentDOM) {
atEnd = offset > domIndex(this.contentDOM)

@@ -584,3 +586,3 @@ } else if (this.contentDOM && this.contentDOM != this.dom && this.dom.contains(this.contentDOM)) {

class NodeViewDesc extends ViewDesc {
// : (?ViewDesc, Node, [Decoration], DecorationSet, dom.Node, ?dom.Node, EditorView)
// : (?ViewDesc, Node, [Decoration], DecorationSource, dom.Node, ?dom.Node, EditorView)
constructor(parent, node, outerDeco, innerDeco, dom, contentDOM, nodeDOM, view, pos) {

@@ -611,3 +613,3 @@ super(parent, node.isLeaf ? nothing : [], dom, contentDOM)

if (descObj.parent) return descObj.parent.posBeforeChild(descObj)
}, outerDeco)
}, outerDeco, innerDeco)

@@ -741,3 +743,3 @@ let dom = spec && spec.dom, contentDOM = spec && spec.contentDOM

// : (Node, [Decoration], DecorationSet, EditorView) → bool
// : (Node, [Decoration], DecorationSource, EditorView) → bool
// If this desc be updated to match the given node decoration,

@@ -859,3 +861,3 @@ // do so and return true.

class CustomNodeViewDesc extends NodeViewDesc {
// : (?ViewDesc, Node, [Decoration], DecorationSet, dom.Node, ?dom.Node, NodeView, EditorView)
// : (?ViewDesc, Node, [Decoration], DecorationSource, dom.Node, ?dom.Node, NodeView, EditorView)
constructor(parent, node, outerDeco, innerDeco, dom, contentDOM, nodeDOM, spec, view, pos) {

@@ -872,3 +874,3 @@ super(parent, node, outerDeco, innerDeco, dom, contentDOM, nodeDOM, view, pos)

if (this.spec.update) {
let result = this.spec.update(node, outerDeco)
let result = this.spec.update(node, outerDeco, innerDeco)
if (result) this.updateInner(node, outerDeco, innerDeco, view)

@@ -1115,3 +1117,3 @@ return result

// : (Node, [Decoration], DecorationSet) → bool
// : (Node, [Decoration], DecorationSource) → bool
// Try to find a node desc matching the given data. Skip over it and

@@ -1138,3 +1140,3 @@ // return true when successful.

// : (Node, [Decoration], DecorationSet, EditorView, Fragment, number) → bool
// : (Node, [Decoration], DecorationSource, EditorView, Fragment, number) → bool
// Try to update the next node, if any, to the given data. Checks

@@ -1168,3 +1170,3 @@ // pre-matches to avoid overwriting nodes that could still be used.

// : (Node, [Decoration], DecorationSet, EditorView)
// : (Node, [Decoration], DecorationSource, EditorView)
// Insert the node as a newly created node desc.

@@ -1227,3 +1229,3 @@ addNode(node, outerDeco, innerDeco, view, pos) {

// : (ViewDesc, DecorationSet, (Decoration, number), (Node, [Decoration], DecorationSet, number))
// : (ViewDesc, DecorationSource, (Decoration, number), (Node, [Decoration], DecorationSource, number))
// This function abstracts iterating over the nodes and decorations in

@@ -1230,0 +1232,0 @@ // a fragment. Calls `onNode` for each node, with its local and child

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

Sorry, the diff of this file is not supported yet

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