prosemirror-view
Advanced tools
Comparing version 1.27.2 to 1.28.0
@@ -704,2 +704,7 @@ import { EditorState, Transaction, Selection, Plugin } from 'prosemirror-state'; | ||
/** | ||
Can be used to transform copied or cut content before it is | ||
serialized to the clipboard. | ||
*/ | ||
transformCopied?: (this: P, slice: Slice) => Slice; | ||
/** | ||
Allows you to pass custom rendering and behavior logic for | ||
@@ -706,0 +711,0 @@ nodes. Should map node names to constructor functions that |
{ | ||
"name": "prosemirror-view", | ||
"version": "1.27.2", | ||
"version": "1.28.0", | ||
"description": "ProseMirror's view component", | ||
@@ -5,0 +5,0 @@ "type": "module", |
@@ -6,2 +6,4 @@ import {Slice, Fragment, DOMParser, DOMSerializer, ResolvedPos, NodeType, Node} from "prosemirror-model" | ||
export function serializeForClipboard(view: EditorView, slice: Slice) { | ||
view.someProp("transformCopied", f => { slice = f(slice!) }) | ||
let context = [], {content, openStart, openEnd} = slice | ||
@@ -8,0 +10,0 @@ while (openStart > 1 && openEnd > 1 && content.childCount == 1 && content.firstChild!.childCount == 1) { |
@@ -295,2 +295,17 @@ import {NodeSelection, EditorState, Plugin, PluginView, Transaction, Selection} from "prosemirror-state" | ||
hasFocus() { | ||
// Work around IE not handling focus correctly if resize handles are shown. | ||
// If the cursor is inside an element with resize handles, activeElement | ||
// will be that element instead of this.dom. | ||
if (browser.ie) { | ||
// If activeElement is within this.dom, and there are no other elements | ||
// setting `contenteditable` to false in between, treat it as focused. | ||
let node = this.root.activeElement | ||
if (node == this.dom) return true | ||
if (!node || !this.dom.contains(node)) return false | ||
while (node && this.dom != node && this.dom.contains(node)) { | ||
if ((node as HTMLElement).contentEditable == 'false') return false | ||
node = node.parentElement | ||
} | ||
return true | ||
} | ||
return this.root.activeElement == this.dom | ||
@@ -640,2 +655,6 @@ } | ||
/// Can be used to transform copied or cut content before it is | ||
/// serialized to the clipboard. | ||
transformCopied?: (this: P, slice: Slice) => Slice | ||
/// Allows you to pass custom rendering and behavior logic for | ||
@@ -642,0 +661,0 @@ /// nodes. Should map node names to constructor functions that |
@@ -391,3 +391,3 @@ import {Selection, NodeSelection, TextSelection} from "prosemirror-state" | ||
// works around that. | ||
(browser.chrome && !(this.view.state.selection instanceof TextSelection) && | ||
(browser.chrome && !this.view.state.selection.visible && | ||
Math.min(Math.abs(pos.pos - this.view.state.selection.from), | ||
@@ -394,0 +394,0 @@ Math.abs(pos.pos - this.view.state.selection.to)) <= 2))) { |
@@ -184,3 +184,3 @@ import {TextSelection, NodeSelection, Selection} from "prosemirror-state" | ||
export function hasFocusAndSelection(view: EditorView) { | ||
if (view.editable && view.root.activeElement != view.dom) return false | ||
if (view.editable && !view.hasFocus()) return false | ||
return hasSelection(view) | ||
@@ -187,0 +187,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 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
755449
16225