prosemirror-view
Advanced tools
Comparing version 1.28.3 to 1.29.0
@@ -676,3 +676,3 @@ import { EditorState, Transaction, Selection, Plugin } from 'prosemirror-state'; | ||
*/ | ||
transformPastedHTML?: (this: P, html: string) => string; | ||
transformPastedHTML?: (this: P, html: string, view: EditorView) => string; | ||
/** | ||
@@ -688,3 +688,3 @@ The [parser](https://prosemirror.net/docs/ref/#model.DOMParser) to use when reading content from | ||
*/ | ||
transformPastedText?: (this: P, text: string, plain: boolean) => string; | ||
transformPastedText?: (this: P, text: string, plain: boolean, view: EditorView) => string; | ||
/** | ||
@@ -699,3 +699,3 @@ A function to parse text from the clipboard into a document | ||
*/ | ||
clipboardTextParser?: (this: P, text: string, $context: ResolvedPos, plain: boolean) => Slice; | ||
clipboardTextParser?: (this: P, text: string, $context: ResolvedPos, plain: boolean, view: EditorView) => Slice; | ||
/** | ||
@@ -705,3 +705,3 @@ Can be used to transform pasted or dragged-and-dropped content | ||
*/ | ||
transformPasted?: (this: P, slice: Slice) => Slice; | ||
transformPasted?: (this: P, slice: Slice, view: EditorView) => Slice; | ||
/** | ||
@@ -711,3 +711,3 @@ Can be used to transform copied or cut content before it is | ||
*/ | ||
transformCopied?: (this: P, slice: Slice) => Slice; | ||
transformCopied?: (this: P, slice: Slice, view: EditorView) => Slice; | ||
/** | ||
@@ -767,3 +767,3 @@ Allows you to pass custom rendering and behavior logic for | ||
*/ | ||
clipboardTextSerializer?: (this: P, content: Slice) => string; | ||
clipboardTextSerializer?: (this: P, content: Slice, view: EditorView) => string; | ||
/** | ||
@@ -770,0 +770,0 @@ A set of [document decorations](https://prosemirror.net/docs/ref/#view.Decoration) to show in the |
{ | ||
"name": "prosemirror-view", | ||
"version": "1.28.3", | ||
"version": "1.29.0", | ||
"description": "ProseMirror's view component", | ||
@@ -5,0 +5,0 @@ "type": "module", |
# prosemirror-view | ||
[ [**WEBSITE**](https://prosemirror.net) | [**ISSUES**](https://github.com/prosemirror/prosemirror/issues) | [**FORUM**](https://discuss.prosemirror.net) | [**GITTER**](https://gitter.im/ProseMirror/prosemirror) | [**CHANGELOG**](https://github.com/ProseMirror/prosemirror-view/blob/master/CHANGELOG.md) ] | ||
[ [**WEBSITE**](https://prosemirror.net) | [**ISSUES**](https://github.com/prosemirror/prosemirror/issues) | [**FORUM**](https://discuss.prosemirror.net) | [**CHANGELOG**](https://github.com/ProseMirror/prosemirror-view/blob/master/CHANGELOG.md) ] | ||
@@ -5,0 +5,0 @@ This is a [core module](https://prosemirror.net/docs/ref/#view) of [ProseMirror](https://prosemirror.net). |
@@ -6,3 +6,3 @@ 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!) }) | ||
view.someProp("transformCopied", f => { slice = f(slice!, view) }) | ||
@@ -37,3 +37,3 @@ let context = [], {content, openStart, openEnd} = slice | ||
let text = view.someProp("clipboardTextSerializer", f => f(slice)) || | ||
let text = view.someProp("clipboardTextSerializer", f => f(slice, view)) || | ||
slice.content.textBetween(0, slice.content.size, "\n\n") | ||
@@ -51,5 +51,5 @@ | ||
if (asText) { | ||
view.someProp("transformPastedText", f => { text = f(text, inCode || plainText) }) | ||
view.someProp("transformPastedText", f => { text = f(text, inCode || plainText, view) }) | ||
if (inCode) return text ? new Slice(Fragment.from(view.state.schema.text(text.replace(/\r\n?/g, "\n"))), 0, 0) : Slice.empty | ||
let parsed = view.someProp("clipboardTextParser", f => f(text, $context, plainText)) | ||
let parsed = view.someProp("clipboardTextParser", f => f(text, $context, plainText, view)) | ||
if (parsed) { | ||
@@ -67,3 +67,3 @@ slice = parsed | ||
} else { | ||
view.someProp("transformPastedHTML", f => { html = f(html!) }) | ||
view.someProp("transformPastedHTML", f => { html = f(html!, view) }) | ||
dom = readHTML(html!) | ||
@@ -75,4 +75,8 @@ if (browser.webkit) restoreReplacedSpaces(dom) | ||
let sliceData = contextNode && /^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(contextNode.getAttribute("data-pm-slice") || "") | ||
if (sliceData && sliceData[3]) for (let i = +sliceData[3]; i > 0 && dom!.firstChild; i--) | ||
dom = dom!.firstChild as HTMLElement | ||
if (sliceData && sliceData[3]) for (let i = +sliceData[3]; i > 0; i--) { | ||
let child = dom!.firstChild | ||
while (child && child.nodeType != 1) child = child.nextSibling | ||
if (!child) break | ||
dom = child as HTMLElement | ||
} | ||
@@ -105,3 +109,3 @@ if (!slice) { | ||
view.someProp("transformPasted", f => { slice = f(slice!) }) | ||
view.someProp("transformPasted", f => { slice = f(slice!, view) }) | ||
return slice | ||
@@ -108,0 +112,0 @@ } |
@@ -114,3 +114,3 @@ import {Fragment, DOMParser, ParseRule, Node, Mark, ResolvedPos} from "prosemirror-model" | ||
if ((browser.ios && view.input.lastIOSEnter > Date.now() - 225 || browser.android) && | ||
addedNodes.some(n => n.nodeName == "DIV" || n.nodeName == "P") && | ||
addedNodes.some(n => n.nodeName == "DIV" || n.nodeName == "P" || n.nodeName == "LI") && | ||
(!change || change.endA >= change.endB) && | ||
@@ -117,0 +117,0 @@ view.someProp("handleKeyDown", f => f(view, keyEvent(13, "Enter")))) { |
@@ -641,3 +641,3 @@ import {NodeSelection, EditorState, Plugin, PluginView, Transaction, Selection} from "prosemirror-state" | ||
/// for example to clean it up. | ||
transformPastedHTML?: (this: P, html: string) => string | ||
transformPastedHTML?: (this: P, html: string, view: EditorView) => string | ||
@@ -651,3 +651,3 @@ /// The [parser](#model.DOMParser) to use when reading content from | ||
/// the text is pasted as plain text. | ||
transformPastedText?: (this: P, text: string, plain: boolean) => string | ||
transformPastedText?: (this: P, text: string, plain: boolean, view: EditorView) => string | ||
@@ -661,11 +661,11 @@ /// A function to parse text from the clipboard into a document | ||
/// The `plain` flag will be true when the text is pasted as plain text. | ||
clipboardTextParser?: (this: P, text: string, $context: ResolvedPos, plain: boolean) => Slice | ||
clipboardTextParser?: (this: P, text: string, $context: ResolvedPos, plain: boolean, view: EditorView) => Slice | ||
/// Can be used to transform pasted or dragged-and-dropped content | ||
/// before it is applied to the document. | ||
transformPasted?: (this: P, slice: Slice) => Slice | ||
transformPasted?: (this: P, slice: Slice, view: EditorView) => Slice | ||
/// Can be used to transform copied or cut content before it is | ||
/// serialized to the clipboard. | ||
transformCopied?: (this: P, slice: Slice) => Slice | ||
transformCopied?: (this: P, slice: Slice, view: EditorView) => Slice | ||
@@ -717,3 +717,3 @@ /// Allows you to pass custom rendering and behavior logic for | ||
/// selected range. | ||
clipboardTextSerializer?: (this: P, content: Slice) => string | ||
clipboardTextSerializer?: (this: P, content: Slice, view: EditorView) => string | ||
@@ -720,0 +720,0 @@ /// A set of [document decorations](#view.Decoration) to show in the |
@@ -669,3 +669,3 @@ import {Selection, NodeSelection, TextSelection} from "prosemirror-state" | ||
if (slice) { | ||
view.someProp("transformPasted", f => { slice = f(slice!) }) | ||
view.someProp("transformPasted", f => { slice = f(slice!, view) }) | ||
} else { | ||
@@ -672,0 +672,0 @@ slice = parseFromClipboard(view, event.dataTransfer.getData(brokenClipboardAPI ? "Text" : "text/plain"), |
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
765409
16406