prosemirror-view
Advanced tools
Comparing version 1.31.7 to 1.31.8
@@ -5,5 +5,5 @@ import { EditorState, Transaction, Selection, Plugin } from 'prosemirror-state'; | ||
declare type DOMNode = InstanceType<typeof window.Node>; | ||
type DOMNode = InstanceType<typeof window.Node>; | ||
declare type WidgetConstructor = ((view: EditorView, getPos: () => number | undefined) => DOMNode) | DOMNode; | ||
type WidgetConstructor = ((view: EditorView, getPos: () => number | undefined) => DOMNode) | DOMNode; | ||
/** | ||
@@ -129,3 +129,3 @@ Decoration objects can be provided to the view through the | ||
*/ | ||
declare type DecorationAttrs = { | ||
type DecorationAttrs = { | ||
/** | ||
@@ -171,3 +171,4 @@ When non-null, the target node is wrapped in a DOM element of | ||
Create a set of decorations, using the structure of the given | ||
document. | ||
document. This will consume (modify) the `decorations` array, so | ||
you must make a copy if you want need to preserve that. | ||
*/ | ||
@@ -199,4 +200,5 @@ static create(doc: Node, decorations: Decoration[]): DecorationSet; | ||
Add the given array of decorations to the ones in the set, | ||
producing a new set. Needs access to the current document to | ||
create the appropriate tree structure. | ||
producing a new set. Consumes the `decorations` array. Needs | ||
access to the current document to create the appropriate tree | ||
structure. | ||
*/ | ||
@@ -363,3 +365,3 @@ add(doc: Node, decorations: Decoration[]): DecorationSet; | ||
get size(): number; | ||
get border(): 1 | 0; | ||
get border(): 0 | 1; | ||
updateChildren(view: EditorView, pos: number): void; | ||
@@ -612,3 +614,3 @@ localCompositionInfo(view: EditorView, pos: number): { | ||
*/ | ||
declare type NodeViewConstructor = (node: Node, view: EditorView, getPos: () => number | undefined, decorations: readonly Decoration[], innerDecorations: DecorationSource) => NodeView; | ||
type NodeViewConstructor = (node: Node, view: EditorView, getPos: () => number | undefined, decorations: readonly Decoration[], innerDecorations: DecorationSource) => NodeView; | ||
/** | ||
@@ -618,3 +620,3 @@ The function types [used](https://prosemirror.net/docs/ref/#view.EditorProps.markViews) to create | ||
*/ | ||
declare type MarkViewConstructor = (mark: Mark, view: EditorView, inline: boolean) => { | ||
type MarkViewConstructor = (mark: Mark, view: EditorView, inline: boolean) => { | ||
dom: HTMLElement; | ||
@@ -621,0 +623,0 @@ contentDOM?: HTMLElement; |
{ | ||
"name": "prosemirror-view", | ||
"version": "1.31.7", | ||
"version": "1.31.8", | ||
"description": "ProseMirror's view component", | ||
@@ -5,0 +5,0 @@ "type": "module", |
@@ -57,6 +57,6 @@ import {Selection, NodeSelection, TextSelection, AllSelection, EditorState} from "prosemirror-state" | ||
function isIgnorable(dom: Node) { | ||
function isIgnorable(dom: Node, dir: number) { | ||
if ((dom as HTMLElement).contentEditable == "false") return true | ||
let desc = dom.pmViewDesc | ||
return desc && desc.size == 0 && (dom.nextSibling || dom.nodeName != "BR") | ||
return desc && desc.size == 0 && (dir < 0 || dom.nextSibling || dom.nodeName != "BR") | ||
} | ||
@@ -78,3 +78,3 @@ | ||
// node if possible. Issue prosemirror/prosemirror#832. | ||
if (browser.gecko && node.nodeType == 1 && offset < nodeLen(node) && isIgnorable(node.childNodes[offset])) force = true | ||
if (browser.gecko && node.nodeType == 1 && offset < nodeLen(node) && isIgnorable(node.childNodes[offset], -1)) force = true | ||
for (;;) { | ||
@@ -86,3 +86,3 @@ if (offset > 0) { | ||
let before = node.childNodes[offset - 1] | ||
if (isIgnorable(before)) { | ||
if (isIgnorable(before, -1)) { | ||
moveNode = node | ||
@@ -99,3 +99,3 @@ moveOffset = --offset | ||
let prev = node.previousSibling | ||
while (prev && isIgnorable(prev)) { | ||
while (prev && isIgnorable(prev, -1)) { | ||
moveNode = node.parentNode | ||
@@ -131,3 +131,3 @@ moveOffset = domIndex(prev) | ||
let after = node.childNodes[offset] | ||
if (isIgnorable(after)) { | ||
if (isIgnorable(after, 1)) { | ||
moveNode = node | ||
@@ -141,3 +141,3 @@ moveOffset = ++offset | ||
let next = node.nextSibling | ||
while (next && isIgnorable(next)) { | ||
while (next && isIgnorable(next, 1)) { | ||
moveNode = next.parentNode | ||
@@ -172,4 +172,6 @@ moveOffset = domIndex(next) + 1 | ||
while (node && offset < node.childNodes.length) { | ||
node = node.childNodes[offset] | ||
if (node.nodeType == 3) return node as Text | ||
let next = node.childNodes[offset] | ||
if (next.nodeType == 3) return next as Text | ||
if (next.nodeType == 1 && (next as HTMLElement).contentEditable == "false") break | ||
node = next | ||
offset = 0 | ||
@@ -185,4 +187,6 @@ } | ||
while (node && offset) { | ||
node = node.childNodes[offset - 1] | ||
if (node.nodeType == 3) return node as Text | ||
let next = node.childNodes[offset - 1] | ||
if (next.nodeType == 3) return next as Text | ||
if (next.nodeType == 1 && (next as HTMLElement).contentEditable == "false") break | ||
node = next | ||
offset = node.childNodes.length | ||
@@ -338,3 +342,3 @@ } | ||
} else if (code == 40 || (browser.mac && code == 78 && mods == "c")) { // Down arrow, Ctrl-n on Mac | ||
return safariDownArrowBug(view) || selectVertically(view, 1, mods) || skipIgnoredNodesAfter(view) | ||
return safariDownArrowBug(view) || selectVertically(view, 1, mods) || skipIgnoredNodes(view, 1) | ||
} else if (mods == (browser.mac ? "m" : "c") && | ||
@@ -341,0 +345,0 @@ (code == 66 || code == 73 || code == 89 || code == 90)) { // Mod-[biyz] |
@@ -226,2 +226,5 @@ import {Node, Mark} from "prosemirror-model" | ||
get inline() { return this.type instanceof InlineType } | ||
/// @internal | ||
get widget() { return this.type instanceof WidgetType } | ||
} | ||
@@ -282,3 +285,4 @@ | ||
/// Create a set of decorations, using the structure of the given | ||
/// document. | ||
/// document. This will consume (modify) the `decorations` array, so | ||
/// you must make a copy if you want need to preserve that. | ||
static create(doc: Node, decorations: Decoration[]) { | ||
@@ -307,3 +311,3 @@ return decorations.length ? buildTree(decorations, doc, 0, noSpec) : empty | ||
for (let i = 0; i < this.children.length; i += 3) { | ||
if (this.children[i] < end && this.children[i + 1] > start) { | ||
if ((this.children[i] as number) < end && (this.children[i + 1] as number) > start) { | ||
let childOff = (this.children[i] as number) + 1 | ||
@@ -346,4 +350,5 @@ ;(this.children[i + 2] as DecorationSet).findInner(start - childOff, end - childOff, | ||
/// Add the given array of decorations to the ones in the set, | ||
/// producing a new set. Needs access to the current document to | ||
/// create the appropriate tree structure. | ||
/// producing a new set. Consumes the `decorations` array. Needs | ||
/// access to the current document to create the appropriate tree | ||
/// structure. | ||
add(doc: Node, decorations: Decoration[]) { | ||
@@ -362,3 +367,3 @@ if (!decorations.length) return this | ||
if (!children) children = this.children.slice() | ||
while (childIndex < children.length && children[childIndex] < childOffset) childIndex += 3 | ||
while (childIndex < children.length && (children[childIndex] as number) < childOffset) childIndex += 3 | ||
if (children[childIndex] == childOffset) | ||
@@ -422,3 +427,3 @@ children[childIndex + 2] = (children[childIndex + 2] as DecorationSet).addInner(childNode, found, baseOffset + 1) | ||
let child, local: Decoration[] | undefined | ||
for (let i = 0; i < this.children.length; i += 3) if (this.children[i] >= offset) { | ||
for (let i = 0; i < this.children.length; i += 3) if ((this.children[i] as number) >= offset) { | ||
if (this.children[i] == offset) child = this.children[i + 2] as DecorationSet | ||
@@ -585,3 +590,3 @@ break | ||
let mustRebuild = false | ||
for (let i = 0; i < children.length; i += 3) if (children[i + 1] < 0) { // Touched nodes | ||
for (let i = 0; i < children.length; i += 3) if ((children[i + 1] as number) < 0) { // Touched nodes | ||
if (children[i + 1] == -2) { | ||
@@ -623,3 +628,3 @@ mustRebuild = true | ||
newLocal = built.local as Decoration[] | ||
for (let i = 0; i < children.length; i += 3) if (children[i + 1] < 0) { | ||
for (let i = 0; i < children.length; i += 3) if ((children[i + 1] as number) < 0) { | ||
children.splice(i, 3) | ||
@@ -626,0 +631,0 @@ i -= 3 |
@@ -390,3 +390,3 @@ import {DOMSerializer, Fragment, Mark, Node, ParseRule} from "prosemirror-model" | ||
if (brKludge && offset == node.nodeValue!.length) { | ||
for (let scan: DOMNode | null = node, after; scan; scan = scan.parentNode) { | ||
for (let scan: DOMNode | null = node, after; scan; scan = scan.parentNode) { | ||
if (after = scan.nextSibling) { | ||
@@ -1248,5 +1248,7 @@ if (after.nodeName == "BR") | ||
this.top.children[this.index] = updated | ||
updated.dirty = CONTENT_DIRTY | ||
updated.updateChildren(view, pos + 1) | ||
updated.dirty = NOT_DIRTY | ||
if (updated.contentDOM) { | ||
updated.dirty = CONTENT_DIRTY | ||
updated.updateChildren(view, pos + 1) | ||
updated.dirty = NOT_DIRTY | ||
} | ||
this.changed = true | ||
@@ -1269,8 +1271,8 @@ this.index++ | ||
let wrapper = NodeViewDesc.create(this.top, node, outerDeco, innerDeco, view, pos) | ||
if (!wrapper.contentDOM) return null | ||
wrapper.children = next.children | ||
next.children = [] | ||
if (wrapper.contentDOM) { | ||
wrapper.children = next.children | ||
next.children = [] | ||
for (let ch of wrapper.children) ch.parent = wrapper | ||
} | ||
next.destroy() | ||
for (let ch of wrapper.children) ch.parent = wrapper | ||
return wrapper | ||
@@ -1409,6 +1411,11 @@ } | ||
for (let parentIndex = 0;;) { | ||
if (decoIndex < locals.length && locals[decoIndex].to == offset) { | ||
let widget = locals[decoIndex++], widgets | ||
while (decoIndex < locals.length && locals[decoIndex].to == offset) | ||
(widgets || (widgets = [widget])).push(locals[decoIndex++]) | ||
let widget, widgets | ||
while (decoIndex < locals.length && locals[decoIndex].to == offset) { | ||
let next = locals[decoIndex++] | ||
if (next.widget) { | ||
if (!widget) widget = next | ||
else (widgets || (widgets = [widget])).push(next) | ||
} | ||
} | ||
if (widget) { | ||
if (widgets) { | ||
@@ -1415,0 +1422,0 @@ widgets.sort(compareSide) |
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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
836684
17028