prosemirror-view
Advanced tools
Comparing version 1.33.9 to 1.33.10
{ | ||
"name": "prosemirror-view", | ||
"version": "1.33.9", | ||
"version": "1.33.10", | ||
"description": "ProseMirror's view component", | ||
@@ -5,0 +5,0 @@ "type": "module", |
@@ -205,2 +205,3 @@ import {Selection, NodeSelection, TextSelection, AllSelection, EditorState} from "prosemirror-state" | ||
let sel = view.domSelection() | ||
if (!sel) return | ||
if (selectionCollapsed(sel)) { | ||
@@ -207,0 +208,0 @@ let range = document.createRange() |
@@ -468,3 +468,4 @@ import {EditorState} from "prosemirror-state" | ||
let offset = $head.parentOffset, atStart = !offset, atEnd = offset == $head.parent.content.size | ||
let sel = view.domSelection() | ||
let sel: Selection = view.domSelection()! | ||
if (!sel) return $head.pos == $head.start() || $head.pos == $head.end() | ||
// If the textblock is all LTR, or the browser doesn't support | ||
@@ -471,0 +472,0 @@ // Selection.modify (Edge), fall back to a primitive approach |
@@ -492,2 +492,3 @@ import {NodeSelection, EditorState, Plugin, PluginView, Transaction, Selection} from "prosemirror-state" | ||
let sel = this.domSelection() | ||
if (!sel) return {focusNode: null, focusOffset: 0, anchorNode: null, anchorOffset: 0} | ||
return browser.safari && this.root.nodeType === 11 && | ||
@@ -498,4 +499,4 @@ deepActiveElement(this.dom.ownerDocument) == this.dom && safariShadowSelectionRange(this, sel) || sel | ||
/// @internal | ||
domSelection(): DOMSelection { | ||
return (this.root as Document).getSelection()! | ||
domSelection(): DOMSelection | null { | ||
return (this.root as Document).getSelection() | ||
} | ||
@@ -531,3 +532,3 @@ } | ||
dom.setAttribute("alt", "") | ||
view.cursorWrapper = {dom, deco: Decoration.widget(view.state.selection.head, | ||
view.cursorWrapper = {dom, deco: Decoration.widget(view.state.selection.from, | ||
dom, {raw: true, marks: view.markCursor} as any)} | ||
@@ -534,0 +535,0 @@ } else { |
@@ -186,2 +186,3 @@ import {Selection, NodeSelection, TextSelection} from "prosemirror-state" | ||
if (!view.focused) view.focus() | ||
if (view.state.selection.eq(selection)) return | ||
let tr = view.state.tr.setSelection(selection) | ||
@@ -457,4 +458,4 @@ if (origin == "pointer") tr.setMeta("pointer", true) | ||
view.domObserver.flush() | ||
let {state} = view, $pos = state.selection.$from | ||
if (state.selection.empty && | ||
let {state} = view, $pos = state.selection.$to | ||
if (state.selection instanceof TextSelection && | ||
(state.storedMarks || | ||
@@ -477,3 +478,4 @@ (!$pos.textOffset && $pos.parentOffset && $pos.nodeBefore!.marks.some(m => m.type.spec.inclusive === false)))) { | ||
if (before.nodeType == 3) { | ||
view.domSelection().collapse(before, before.nodeValue!.length) | ||
let sel = view.domSelection() | ||
if (sel) sel.collapse(before, before.nodeValue!.length) | ||
break | ||
@@ -480,0 +482,0 @@ } else { |
@@ -139,6 +139,13 @@ import {TextSelection, NodeSelection, Selection} from "prosemirror-state" | ||
let domSel = view.domSelection(), range = document.createRange() | ||
if (!domSel) return | ||
let node = view.cursorWrapper!.dom, img = node.nodeName == "IMG" | ||
if (img) range.setEnd(node.parentNode!, domIndex(node) + 1) | ||
else range.setEnd(node, 0) | ||
range.collapse(false) | ||
if (img) range.setStart(node.parentNode!, domIndex(node) + 1) | ||
else range.setStart(node, 0) | ||
let sel = view.state.selection | ||
if (sel.empty) { | ||
range.collapse(true) | ||
} else { | ||
let end = view.domAtPos(sel.to) | ||
range.setEnd(end.node, end.offset) | ||
} | ||
domSel.removeAllRanges() | ||
@@ -145,0 +152,0 @@ domSel.addRange(range) |
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
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
860862
17387