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

prosemirror-view

Package Overview
Dependencies
Maintainers
0
Versions
283
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.36.0 to 1.37.0

38

dist/index.d.ts

@@ -241,2 +241,13 @@ import { EditorState, Transaction, Selection, Plugin } from 'prosemirror-state';

/**
A ViewMutationRecord represents a DOM
[mutation](https://developer.mozilla.org/en-US/docs/Web/API/MutationObserver)
or a selection change happens within the view. When the change is
a selection change, the record will have a `type` property of
`"selection"` (which doesn't occur for native mutation records).
*/
type ViewMutationRecord = MutationRecord | {
type: "selection";
target: DOMNode;
};
/**
By default, document nodes are rendered using the result of the

@@ -312,12 +323,7 @@ [`toDOM`](https://prosemirror.net/docs/ref/#model.NodeSpec.toDOM) method of their spec, and managed

/**
Called when a DOM
[mutation](https://developer.mozilla.org/en-US/docs/Web/API/MutationObserver)
or a selection change happens within the view. When the change is
a selection change, the record will have a `type` property of
`"selection"` (which doesn't occur for native mutation records).
Return false if the editor should re-read the selection or
re-parse the range around the mutation, true if it can safely be
ignored.
Called when a [mutation](https://prosemirror.net/docs/ref/#view.ViewMutationRecord) happens within the
view. Return false if the editor should re-read the selection or re-parse
the range around the mutation, true if it can safely be ignored.
*/
ignoreMutation?: (mutation: MutationRecord) => boolean;
ignoreMutation?: (mutation: ViewMutationRecord) => boolean;
/**

@@ -349,2 +355,8 @@ Called when the node view is removed from the editor or the whole

/**
Called when a [mutation](https://prosemirror.net/docs/ref/#view.ViewMutationRecord) happens within the
view. Return false if the editor should re-read the selection or re-parse
the range around the mutation, true if it can safely be ignored.
*/
ignoreMutation?: (mutation: ViewMutationRecord) => boolean;
/**
Called when the mark view is removed from the editor or the whole

@@ -397,4 +409,4 @@ editor is destroyed.

domAfterPos(pos: number): DOMNode;
setSelection(anchor: number, head: number, root: Document | ShadowRoot, force?: boolean): void;
ignoreMutation(mutation: MutationRecord): boolean;
setSelection(anchor: number, head: number, view: EditorView, force?: boolean): void;
ignoreMutation(mutation: ViewMutationRecord): boolean;
get contentLost(): boolean | null;

@@ -448,3 +460,3 @@ markDirty(from: number, to: number): void;

localPosFromDOM(dom: DOMNode, offset: number, bias: number): number;
ignoreMutation(mutation: MutationRecord): boolean;
ignoreMutation(mutation: ViewMutationRecord): boolean;
slice(from: number, to: number, view: EditorView): TextViewDesc;

@@ -963,2 +975,2 @@ markDirty(from: number, to: number): void;

export { type DOMEventMap, Decoration, type DecorationAttrs, DecorationSet, type DecorationSource, type DirectEditorProps, type EditorProps, EditorView, type MarkView, type MarkViewConstructor, type NodeView, type NodeViewConstructor };
export { type DOMEventMap, Decoration, type DecorationAttrs, DecorationSet, type DecorationSource, type DirectEditorProps, type EditorProps, EditorView, type MarkView, type MarkViewConstructor, type NodeView, type NodeViewConstructor, type ViewMutationRecord };
{
"name": "prosemirror-view",
"version": "1.36.0",
"version": "1.37.0",
"description": "ProseMirror's view component",

@@ -5,0 +5,0 @@ "type": "module",

@@ -154,4 +154,4 @@ import {Selection} from "prosemirror-state"

type: "selection",
target: container!.nodeType == 3 ? container!.parentNode : container
} as any)) {
target: container!.nodeType == 3 ? container!.parentNode! : container!
})) {
this.setCurSelection()

@@ -158,0 +158,0 @@ return true

@@ -17,3 +17,3 @@ import {NodeSelection, EditorState, Plugin, PluginView, Transaction, Selection} from "prosemirror-state"

export {Decoration, DecorationSet, DecorationAttrs, DecorationSource} from "./decoration"
export {NodeView, MarkView} from "./viewdesc"
export {NodeView, MarkView, ViewMutationRecord} from "./viewdesc"

@@ -20,0 +20,0 @@ // Exported for testing

@@ -23,2 +23,4 @@ ProseMirror's view module displays a given [editor

@ViewMutationRecord
@DOMEventMap

@@ -25,0 +27,0 @@

@@ -87,3 +87,3 @@ import {TextSelection, NodeSelection, Selection} from "prosemirror-state"

}
view.docView.setSelection(anchor, head, view.root, force)
view.docView.setSelection(anchor, head, view, force)
if (brokenSelectBetweenUneditable) {

@@ -90,0 +90,0 @@ if (resetEditableFrom) resetEditable(resetEditableFrom)

@@ -13,2 +13,9 @@ import {DOMSerializer, Fragment, Mark, Node, TagParseRule} from "prosemirror-model"

/// A ViewMutationRecord represents a DOM
/// [mutation](https://developer.mozilla.org/en-US/docs/Web/API/MutationObserver)
/// or a selection change happens within the view. When the change is
/// a selection change, the record will have a `type` property of
/// `"selection"` (which doesn't occur for native mutation records).
export type ViewMutationRecord = MutationRecord | { type: "selection", target: DOMNode }
/// By default, document nodes are rendered using the result of the

@@ -74,11 +81,6 @@ /// [`toDOM`](#model.NodeSpec.toDOM) method of their spec, and managed

/// Called when a DOM
/// [mutation](https://developer.mozilla.org/en-US/docs/Web/API/MutationObserver)
/// or a selection change happens within the view. When the change is
/// a selection change, the record will have a `type` property of
/// `"selection"` (which doesn't occur for native mutation records).
/// Return false if the editor should re-read the selection or
/// re-parse the range around the mutation, true if it can safely be
/// ignored.
ignoreMutation?: (mutation: MutationRecord) => boolean
/// Called when a [mutation](#view.ViewMutationRecord) happens within the
/// view. Return false if the editor should re-read the selection or re-parse
/// the range around the mutation, true if it can safely be ignored.
ignoreMutation?: (mutation: ViewMutationRecord) => boolean

@@ -104,2 +106,8 @@ /// Called when the node view is removed from the editor or the whole

contentDOM?: HTMLElement | null
/// Called when a [mutation](#view.ViewMutationRecord) happens within the
/// view. Return false if the editor should re-read the selection or re-parse
/// the range around the mutation, true if it can safely be ignored.
ignoreMutation?: (mutation: ViewMutationRecord) => boolean

@@ -393,3 +401,3 @@ /// Called when the mark view is removed from the editor or the whole

// case we just use whatever domFromPos produces as a best effort.
setSelection(anchor: number, head: number, root: Document | ShadowRoot, force = false): void {
setSelection(anchor: number, head: number, view: EditorView, force = false): void {
// If the selection falls entirely in a child, give it to that child

@@ -400,3 +408,3 @@ let from = Math.min(anchor, head), to = Math.max(anchor, head)

if (from > offset && to < end)
return child.setSelection(anchor - offset - child.border, head - offset - child.border, root, force)
return child.setSelection(anchor - offset - child.border, head - offset - child.border, view, force)
offset = end

@@ -407,3 +415,4 @@ }

let headDOM = head == anchor ? anchorDOM : this.domFromPos(head, head ? -1 : 1)
let domSel = (root as Document).getSelection()!
let domSel = (view.root as Document).getSelection()!
let selRange = view.domSelectionRange()

@@ -438,4 +447,4 @@ let brKludge = false

// uneditable node. See #1163 and https://bugzilla.mozilla.org/show_bug.cgi?id=1709536
if (browser.gecko && domSel.focusNode && domSel.focusNode != headDOM.node && domSel.focusNode.nodeType == 1) {
let after = domSel.focusNode.childNodes[domSel.focusOffset]
if (browser.gecko && selRange.focusNode && selRange.focusNode != headDOM.node && selRange.focusNode.nodeType == 1) {
let after = selRange.focusNode.childNodes[selRange.focusOffset]
if (after && (after as HTMLElement).contentEditable == "false") force = true

@@ -445,4 +454,4 @@ }

if (!(force || brKludge && browser.safari) &&
isEquivalentPosition(anchorDOM.node, anchorDOM.offset, domSel.anchorNode!, domSel.anchorOffset) &&
isEquivalentPosition(headDOM.node, headDOM.offset, domSel.focusNode!, domSel.focusOffset))
isEquivalentPosition(anchorDOM.node, anchorDOM.offset, selRange.anchorNode!, selRange.anchorOffset) &&
isEquivalentPosition(headDOM.node, headDOM.offset, selRange.focusNode!, selRange.focusOffset))
return

@@ -479,4 +488,4 @@

ignoreMutation(mutation: MutationRecord): boolean {
return !this.contentDOM && (mutation.type as any) != "selection"
ignoreMutation(mutation: ViewMutationRecord): boolean {
return !this.contentDOM && mutation.type != "selection"
}

@@ -560,4 +569,4 @@

ignoreMutation(mutation: MutationRecord) {
return (mutation.type as any) != "selection" || this.widget.spec.ignoreSelection
ignoreMutation(mutation: ViewMutationRecord) {
return mutation.type != "selection" || this.widget.spec.ignoreSelection
}

@@ -591,3 +600,3 @@

ignoreMutation(mut: MutationRecord) {
ignoreMutation(mut: ViewMutationRecord) {
return mut.type === 'characterData' && mut.target.nodeValue == mut.oldValue

@@ -643,2 +652,6 @@ }

ignoreMutation(mutation: ViewMutationRecord) {
return this.spec.ignoreMutation ? this.spec.ignoreMutation(mutation) : super.ignoreMutation(mutation)
}
destroy() {

@@ -939,4 +952,4 @@ if (this.spec.destroy) this.spec.destroy()

ignoreMutation(mutation: MutationRecord) {
return mutation.type != "characterData" && (mutation.type as any) != "selection"
ignoreMutation(mutation: ViewMutationRecord) {
return mutation.type != "characterData" && mutation.type != "selection"
}

@@ -1003,5 +1016,5 @@

setSelection(anchor: number, head: number, root: Document | ShadowRoot, force: boolean) {
this.spec.setSelection ? this.spec.setSelection(anchor, head, root)
: super.setSelection(anchor, head, root, force)
setSelection(anchor: number, head: number, view: EditorView, force: boolean) {
this.spec.setSelection ? this.spec.setSelection(anchor, head, view.root)
: super.setSelection(anchor, head, view, force)
}

@@ -1018,3 +1031,3 @@

ignoreMutation(mutation: MutationRecord) {
ignoreMutation(mutation: ViewMutationRecord) {
return this.spec.ignoreMutation ? this.spec.ignoreMutation(mutation) : super.ignoreMutation(mutation)

@@ -1021,0 +1034,0 @@ }

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 not supported yet

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

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