From eae8572bf6df9380698d176a8a5c82cb6761e50f Mon Sep 17 00:00:00 2001
From: Patrick Simmelbauer
Date: Thu, 21 Jun 2018 15:43:19 +0200
Subject: [PATCH 1/4] Update prosemirror-view typings to 1.3
---
types/prosemirror-view/index.d.ts | 61 +++++++++++++++++++++++++++++--
1 file changed, 57 insertions(+), 4 deletions(-)
diff --git a/types/prosemirror-view/index.d.ts b/types/prosemirror-view/index.d.ts
index dba4fb8aec..a539be4593 100644
--- a/types/prosemirror-view/index.d.ts
+++ b/types/prosemirror-view/index.d.ts
@@ -1,4 +1,4 @@
-// Type definitions for prosemirror-view 1.2
+// Type definitions for prosemirror-view 1.3
// Project: https://github.com/ProseMirror/prosemirror-view
// Definitions by: Bradley Ayers
// David Hahn
@@ -41,14 +41,46 @@ export class Decoration {
spec: { [key: string]: any };
/**
* Creates a widget decoration, which is a DOM node that's shown in
- * the document at the given position.
+ * the document at the given position. It is recommended that you
+ * delay rendering the widget by passing a function that will be
+ * called when the widget is actually drawn in a view, but you can
+ * also directly pass a DOM node. getPos can be used to find the
+ * widget's current document position.
+ *
+ * @param spec These options are supported:
+ * @param spec.side Controls which side of the document position
+ * this widget is associated with. When negative, it is drawn before
+ * a cursor at its position, and content inserted at that position
+ * ends up after the widget. When zero (the default) or positive, the
+ * widget is drawn after the cursor and content inserted there ends
+ * up before the widget.
+ *
+ * When there are multiple widgets at a given position, their side
+ * values determine the order in which they appear. Those with lower
+ * values appear first. The ordering of widgets with the same side
+ * value is unspecified.
+ *
+ * When marks is null, side also determines the marks that the widget
+ * is wrapped in—those of the node before when negative, those of
+ * the node after when positive.
+ * @param spec.marks The precise set of marks to draw around the widget.
+ * @param spec.stopEvent Can be used to control which DOM events, when
+ * they bubble out of this widget, the editor view should ignore.
+ * @param spec.key When comparing decorations of this type (in order to
+ * decide whether it needs to be redrawn), ProseMirror will by default
+ * compare the widget DOM node by identity. If you pass a key, that key
+ * will be compared instead, which can be useful when you generate
+ * decorations on the fly and don't want to store and reuse DOM nodes.
+ * Make sure that any widgets with the same key are interchangeable—if
+ * widgets differ in, for example, the behavior of some event handler,
+ * they should get different keys.
*/
static widget(
pos: number,
- dom: Node,
+ toDOM: ((view: EditorView, getPos: () => number) => Node) | Node,
spec?: {
side?: number | null;
- marks?: Mark[];
+ marks?: Mark[] | null;
stopEvent?: ((event: Event) => boolean) | null;
key?: string | null;
}
@@ -251,6 +283,27 @@ export class EditorView {
* necessary).
*/
domAtPos(pos: number): { node: Node; offset: number };
+ /**
+ * Find the DOM node that represents the document node after the
+ * given position. May return null when the position doesn't point
+ * in front of a node or if the node is inside an opaque node view.
+ *
+ * This is intended to be able to call things like getBoundingClientRect
+ * on that DOM node. Do not mutate the editor DOM directly, or add
+ * styling this way, since that will be immediately overriden by the
+ * editor as it redraws the node.
+ */
+ nodeDOM(pos: number): Node | null | undefined;
+ /**
+ * Find the document position that corresponds to a given DOM position.
+ * (Whenever possible, it is preferable to inspect the document structure
+ * directly, rather than poking around in the DOM, but sometimes—for
+ * example when interpreting an event target—you don't have a choice.)
+ *
+ * The bias (default: -1) parameter can be used to influence which side of
+ * a DOM node to use when the position is inside a leaf node.
+ */
+ posAtDOM(node: Node, offset: number, bias?: number | null): number;
/**
* Find out whether the selection is at the end of a textblock when
* moving in a given direction. When, for example, given `"left"`,
From e9cb8886fb3a6a599f7ce2a84b82fb54ac40d383 Mon Sep 17 00:00:00 2001
From: Patrick Simmelbauer
Date: Thu, 21 Jun 2018 15:43:41 +0200
Subject: [PATCH 2/4] Update prosemirror-model typings to 1.5
---
types/prosemirror-model/index.d.ts | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/types/prosemirror-model/index.d.ts b/types/prosemirror-model/index.d.ts
index 095b88f3ba..aa02f9b770 100644
--- a/types/prosemirror-model/index.d.ts
+++ b/types/prosemirror-model/index.d.ts
@@ -1,4 +1,4 @@
-// Type definitions for prosemirror-model 1.4
+// Type definitions for prosemirror-model 1.5
// Project: https://github.com/ProseMirror/prosemirror-model
// Definitions by: Bradley Ayers
// David Hahn
@@ -246,7 +246,7 @@ export interface ParseOptions {
* A value that describes how to parse a given DOM node or inline
* style as a ProseMirror node or mark.
*/
-export interface ParseRule {
+export interface ParseRule {
/**
* A CSS selector describing the kind of DOM elements to match. A
* single rule should have _either_ a `tag` or a `style` property.
@@ -341,7 +341,7 @@ export interface ParseRule {
* present, instead of parsing the node's child nodes, the result of
* this function is used.
*/
- getContent?: ((p: Node) => Fragment) | null;
+ getContent?: ((p: Node, schema: S) => Fragment) | null;
/**
* Controls whether whitespace should be preserved when parsing the
* content inside the matched element. `false` means whitespace may
@@ -361,7 +361,7 @@ export class DOMParser {
* Create a parser that targets the given schema, using the given
* parsing rules.
*/
- constructor(schema: S, rules: Array>);
+ constructor(schema: S, rules: ParseRule[]);
/**
* The schema into which the parser parses.
*/
@@ -370,7 +370,7 @@ export class DOMParser {
* The set of [parse rules](#model.ParseRule) that the parser
* uses, in order of precedence.
*/
- rules: Array>;
+ rules: ParseRule[];
/**
* Parse a document from the content of a DOM node.
*/
From 4c3173665b5c27f87a1a81ad506dcd2f05031898 Mon Sep 17 00:00:00 2001
From: Patrick Simmelbauer
Date: Thu, 21 Jun 2018 15:44:01 +0200
Subject: [PATCH 3/4] Update prosemirror-state typings to 1.2
---
types/prosemirror-state/index.d.ts | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/types/prosemirror-state/index.d.ts b/types/prosemirror-state/index.d.ts
index db5a16e9d3..7ecf0f3c13 100644
--- a/types/prosemirror-state/index.d.ts
+++ b/types/prosemirror-state/index.d.ts
@@ -1,4 +1,4 @@
-// Type definitions for prosemirror-state 1.1
+// Type definitions for prosemirror-state 1.2
// Project: https://github.com/ProseMirror/prosemirror-state
// Definitions by: Bradley Ayers
// David Hahn
@@ -479,6 +479,7 @@ export class EditorState {
schema?: S | null;
doc?: ProsemirrorNode | null;
selection?: Selection | null;
+ storedMarks?: Mark[] | null;
plugins?: Array> | null;
}): EditorState;
/**
From d00d68af9c34ef2a05fefe468354fab0ff557da7 Mon Sep 17 00:00:00 2001
From: Patrick Simmelbauer
Date: Thu, 21 Jun 2018 15:44:44 +0200
Subject: [PATCH 4/4] Update prosemirror-transform typings to 1.1
---
types/prosemirror-transform/index.d.ts | 20 +++++++++++++++++++-
1 file changed, 19 insertions(+), 1 deletion(-)
diff --git a/types/prosemirror-transform/index.d.ts b/types/prosemirror-transform/index.d.ts
index 88f97ff9e4..974a6e8475 100644
--- a/types/prosemirror-transform/index.d.ts
+++ b/types/prosemirror-transform/index.d.ts
@@ -1,4 +1,4 @@
-// Type definitions for prosemirror-transform 1.0
+// Type definitions for prosemirror-transform 1.1
// Project: https://github.com/ProseMirror/prosemirror-transform
// Definitions by: Bradley Ayers
// David Hahn
@@ -143,6 +143,12 @@ export class Mapping implements Mappable {
* mirroring information).
*/
appendMapping(mapping: Mapping): void;
+ /**
+ * 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: number): number | undefined | null;
/**
* Append the inverse of the given mapping to this one.
*/
@@ -550,3 +556,15 @@ export function insertPoint(
pos: number,
nodeType: NodeType
): number | null | undefined;
+/**
+ * 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: ProsemirrorNode,
+ pos: number,
+ slice: Slice
+): number | null | undefined;