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
282
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.29.2 to 1.30.0

src/#domcoords.ts#

57

dist/index.d.ts

@@ -322,3 +322,4 @@ import { EditorState, Transaction, Selection, Plugin } from 'prosemirror-state';

localPosFromDOM(dom: DOMNode, offset: number, bias: number): number;
nearestDesc(dom: DOMNode, onlyNodes?: boolean): ViewDesc | undefined;
nearestDesc(dom: DOMNode): ViewDesc | undefined;
nearestDesc(dom: DOMNode, onlyNodes: true): NodeViewDesc | undefined;
getDesc(dom: DOMNode): ViewDesc | undefined;

@@ -349,2 +350,46 @@ posFromDOM(dom: DOMNode, offset: number, bias: number): number;

}
declare class NodeViewDesc extends ViewDesc {
node: Node;
outerDeco: readonly Decoration[];
innerDeco: DecorationSource;
readonly nodeDOM: DOMNode;
constructor(parent: ViewDesc | undefined, node: Node, outerDeco: readonly Decoration[], innerDeco: DecorationSource, dom: DOMNode, contentDOM: HTMLElement | null, nodeDOM: DOMNode, view: EditorView, pos: number);
static create(parent: ViewDesc | undefined, node: Node, outerDeco: readonly Decoration[], innerDeco: DecorationSource, view: EditorView, pos: number): NodeViewDesc | TextViewDesc;
parseRule(): ParseRule | null;
matchesNode(node: Node, outerDeco: readonly Decoration[], innerDeco: DecorationSource): boolean;
get size(): number;
get border(): 1 | 0;
updateChildren(view: EditorView, pos: number): void;
localCompositionInfo(view: EditorView, pos: number): {
node: Text;
pos: number;
text: string;
} | null;
protectLocalComposition(view: EditorView, { node, pos, text }: {
node: Text;
pos: number;
text: string;
}): void;
update(node: Node, outerDeco: readonly Decoration[], innerDeco: DecorationSource, view: EditorView): boolean;
updateInner(node: Node, outerDeco: readonly Decoration[], innerDeco: DecorationSource, view: EditorView): void;
updateOuterDeco(outerDeco: readonly Decoration[]): void;
selectNode(): void;
deselectNode(): void;
get domAtom(): boolean;
}
declare class TextViewDesc extends NodeViewDesc {
constructor(parent: ViewDesc | undefined, node: Node, outerDeco: readonly Decoration[], innerDeco: DecorationSource, dom: DOMNode, nodeDOM: DOMNode, view: EditorView);
parseRule(): ParseRule;
update(node: Node, outerDeco: readonly Decoration[], innerDeco: DecorationSource, view: EditorView): boolean;
inParent(): boolean;
domFromPos(pos: number): {
node: globalThis.Node;
offset: number;
};
localPosFromDOM(dom: DOMNode, offset: number, bias: number): number;
ignoreMutation(mutation: MutationRecord): boolean;
slice(from: number, to: number, view: EditorView): TextViewDesc;
markDirty(from: number, to: number): void;
get domAtom(): boolean;
}

@@ -525,2 +570,12 @@ /**

/**
Run the editor's paste logic with the given HTML string. The
`event`, if given, will be passed to the
[`handlePaste`](https://prosemirror.net/docs/ref/#view.EditorProps.handlePaste) hook.
*/
pasteHTML(html: string, event?: ClipboardEvent): boolean;
/**
Run the editor's paste logic with the given plain-text input.
*/
pasteText(text: string, event?: ClipboardEvent): boolean;
/**
Removes the editor from the DOM and destroys all [node

@@ -527,0 +582,0 @@ views](https://prosemirror.net/docs/ref/#view.NodeView).

2

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

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

@@ -5,3 +5,2 @@ import {EditorState} from "prosemirror-state"

import {EditorView} from "./index"
import {NodeViewDesc} from "./viewdesc"

@@ -220,3 +219,3 @@ export type Rect = {left: number, right: number, top: number, bottom: number}

if (!desc) return null
if ((desc as NodeViewDesc).node.isBlock && desc.parent) {
if (desc.node.isBlock && desc.parent) {
let rect = (desc.dom as HTMLElement).getBoundingClientRect()

@@ -418,3 +417,3 @@ if (rect.left > coords.left || rect.top > coords.top) outside = desc.posBefore

if (!nearest) break
if (nearest.node!.isBlock) { dom = nearest.contentDOM || nearest.dom; break }
if (nearest.node.isBlock) { dom = nearest.contentDOM || nearest.dom; break }
dom = nearest.dom.parentNode!

@@ -421,0 +420,0 @@ }

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

import {docViewDesc, ViewDesc, NodeView, NodeViewDesc} from "./viewdesc"
import {initInput, destroyInput, dispatchEvent, ensureListeners, clearComposition, InputState} from "./input"
import {initInput, destroyInput, dispatchEvent, ensureListeners, clearComposition, InputState, doPaste} from "./input"
import {selectionToDOM, anchorInRightPlace, syncNodeSelection} from "./selection"

@@ -413,2 +413,14 @@ import {Decoration, viewDecorations, DecorationSource} from "./decoration"

/// Run the editor's paste logic with the given HTML string. The
/// `event`, if given, will be passed to the
/// [`handlePaste`](#view.EditorProps.handlePaste) hook.
pasteHTML(html: string, event?: ClipboardEvent) {
return doPaste(this, "", html, false, event || new ClipboardEvent("paste"))
}
/// Run the editor's paste logic with the given plain-text input.
pasteText(text: string, event?: ClipboardEvent) {
return doPaste(this, text, null, true, event || new ClipboardEvent("paste"))
}
/// Removes the editor from the DOM and destroys all [node

@@ -415,0 +427,0 @@ /// views](#view.NodeView).

@@ -586,9 +586,9 @@ import {Selection, NodeSelection, TextSelection} from "prosemirror-state"

if (target.parentNode) target.parentNode.removeChild(target)
if (plainText) doPaste(view, (target as HTMLTextAreaElement).value, null, event)
else doPaste(view, target.textContent!, target.innerHTML, event)
if (plainText) doPaste(view, (target as HTMLTextAreaElement).value, null, view.input.shiftKey, event)
else doPaste(view, target.textContent!, target.innerHTML, view.input.shiftKey, event)
}, 50)
}
function doPaste(view: EditorView, text: string, html: string | null, event: ClipboardEvent) {
let slice = parseFromClipboard(view, text, html, view.input.shiftKey, view.state.selection.$from)
export function doPaste(view: EditorView, text: string, html: string | null, preferPlain: boolean, event: ClipboardEvent) {
let slice = parseFromClipboard(view, text, html, preferPlain, view.state.selection.$from)
if (view.someProp("handlePaste", f => f(view, event, slice || Slice.empty))) return true

@@ -613,4 +613,6 @@ if (!slice) return false

let data = brokenClipboardAPI ? null : event.clipboardData
if (data && doPaste(view, data.getData("text/plain"), data.getData("text/html"), event)) event.preventDefault()
else capturePaste(view, event)
if (data && doPaste(view, data.getData("text/plain"), data.getData("text/html"), view.input.shiftKey, event))
event.preventDefault()
else
capturePaste(view, event)
}

@@ -638,3 +640,3 @@

let desc = view.docView.nearestDesc(event.target as HTMLElement, true)
if (desc && desc.node!.type.spec.draggable && desc != view.docView)
if (desc && desc.node.type.spec.draggable && desc != view.docView)
view.dispatch(view.state.tr.setSelection(NodeSelection.create(view.state.doc, desc.posBefore)))

@@ -641,0 +643,0 @@ }

@@ -224,2 +224,4 @@ import {DOMSerializer, Fragment, Mark, Node, ParseRule} from "prosemirror-model"

// this one.
nearestDesc(dom: DOMNode): ViewDesc | undefined
nearestDesc(dom: DOMNode, onlyNodes: true): NodeViewDesc | undefined
nearestDesc(dom: DOMNode, onlyNodes: boolean = false) {

@@ -226,0 +228,0 @@ for (let first = true, cur: DOMNode | null = dom; cur; cur = cur.parentNode) {

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

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