@tiptap/core
Advanced tools
Comparing version 2.1.10 to 2.1.11
@@ -21,2 +21,4 @@ import { EditorState, Plugin } from '@tiptap/pm/state'; | ||
can: () => CanCommands; | ||
pasteEvent: ClipboardEvent; | ||
dropEvent: DragEvent; | ||
}) => void | null; | ||
@@ -26,8 +28,10 @@ constructor(config: { | ||
handler: (props: { | ||
can: () => CanCommands; | ||
chain: () => ChainedCommands; | ||
commands: SingleCommands; | ||
dropEvent: DragEvent; | ||
match: ExtendedRegExpMatchArray; | ||
pasteEvent: ClipboardEvent; | ||
range: Range; | ||
state: EditorState; | ||
range: Range; | ||
match: ExtendedRegExpMatchArray; | ||
commands: SingleCommands; | ||
chain: () => ChainedCommands; | ||
can: () => CanCommands; | ||
}) => void | null; | ||
@@ -34,0 +38,0 @@ }); |
@@ -11,3 +11,3 @@ import { MarkType } from '@tiptap/pm/model'; | ||
type: MarkType; | ||
getAttributes?: Record<string, any> | ((match: ExtendedRegExpMatchArray) => Record<string, any>) | false | null; | ||
getAttributes?: Record<string, any> | ((match: ExtendedRegExpMatchArray, event: ClipboardEvent) => Record<string, any>) | false | null; | ||
}): PasteRule; |
@@ -11,3 +11,3 @@ import { NodeType } from '@tiptap/pm/model'; | ||
type: NodeType; | ||
getAttributes?: Record<string, any> | ((match: ExtendedRegExpMatchArray) => Record<string, any>) | false | null; | ||
getAttributes?: Record<string, any> | ((match: ExtendedRegExpMatchArray, event: ClipboardEvent) => Record<string, any>) | false | null; | ||
}): PasteRule; |
{ | ||
"name": "@tiptap/core", | ||
"description": "headless rich text editor", | ||
"version": "2.1.10", | ||
"version": "2.1.11", | ||
"homepage": "https://tiptap.dev", | ||
@@ -35,3 +35,3 @@ "keywords": [ | ||
"devDependencies": { | ||
"@tiptap/pm": "^2.1.10" | ||
"@tiptap/pm": "^2.1.11" | ||
}, | ||
@@ -38,0 +38,0 @@ "peerDependencies": { |
@@ -36,2 +36,4 @@ import { EditorState, Plugin } from '@tiptap/pm/state' | ||
can: () => CanCommands | ||
pasteEvent: ClipboardEvent | ||
dropEvent: DragEvent | ||
}) => void | null | ||
@@ -42,8 +44,10 @@ | ||
handler: (props: { | ||
can: () => CanCommands | ||
chain: () => ChainedCommands | ||
commands: SingleCommands | ||
dropEvent: DragEvent | ||
match: ExtendedRegExpMatchArray | ||
pasteEvent: ClipboardEvent | ||
range: Range | ||
state: EditorState | ||
range: Range | ||
match: ExtendedRegExpMatchArray | ||
commands: SingleCommands | ||
chain: () => ChainedCommands | ||
can: () => CanCommands | ||
}) => void | null | ||
@@ -97,5 +101,7 @@ }) { | ||
rule: PasteRule | ||
pasteEvent: ClipboardEvent | ||
dropEvent: DragEvent | ||
}): boolean { | ||
const { | ||
editor, state, from, to, rule, | ||
editor, state, from, to, rule, pasteEvent, dropEvent, | ||
} = config | ||
@@ -140,2 +146,4 @@ | ||
can, | ||
pasteEvent, | ||
dropEvent, | ||
}) | ||
@@ -162,2 +170,4 @@ | ||
let isDroppedFromProseMirror = false | ||
let pasteEvent = new ClipboardEvent('paste') | ||
let dropEvent = new DragEvent('drop') | ||
@@ -185,4 +195,5 @@ const plugins = rules.map(rule => { | ||
handleDOMEvents: { | ||
drop: view => { | ||
drop: (view, event: Event) => { | ||
isDroppedFromProseMirror = dragSourceElement === view.dom.parentElement | ||
dropEvent = event as DragEvent | ||
@@ -192,5 +203,7 @@ return false | ||
paste: (view, event: Event) => { | ||
paste: (_view, event: Event) => { | ||
const html = (event as ClipboardEvent).clipboardData?.getData('text/html') | ||
pasteEvent = event as ClipboardEvent | ||
isPastedFromProseMirror = !!html?.includes('data-pm-slice') | ||
@@ -234,2 +247,4 @@ | ||
rule, | ||
pasteEvent, | ||
dropEvent, | ||
}) | ||
@@ -242,2 +257,5 @@ | ||
dropEvent = new DragEvent('drop') | ||
pasteEvent = new ClipboardEvent('paste') | ||
return tr | ||
@@ -244,0 +262,0 @@ }, |
@@ -17,3 +17,3 @@ import { MarkType } from '@tiptap/pm/model' | ||
| Record<string, any> | ||
| ((match: ExtendedRegExpMatchArray) => Record<string, any>) | ||
| ((match: ExtendedRegExpMatchArray, event: ClipboardEvent) => Record<string, any>) | ||
| false | ||
@@ -24,4 +24,6 @@ | null | ||
find: config.find, | ||
handler: ({ state, range, match }) => { | ||
const attributes = callOrReturn(config.getAttributes, undefined, match) | ||
handler: ({ | ||
state, range, match, pasteEvent, | ||
}) => { | ||
const attributes = callOrReturn(config.getAttributes, undefined, match, pasteEvent) | ||
@@ -28,0 +30,0 @@ if (attributes === false || attributes === null) { |
@@ -16,3 +16,3 @@ import { NodeType } from '@tiptap/pm/model' | ||
| Record<string, any> | ||
| ((match: ExtendedRegExpMatchArray) => Record<string, any>) | ||
| ((match: ExtendedRegExpMatchArray, event: ClipboardEvent) => Record<string, any>) | ||
| false | ||
@@ -23,4 +23,6 @@ | null | ||
find: config.find, | ||
handler({ match, chain, range }) { | ||
const attributes = callOrReturn(config.getAttributes, undefined, match) | ||
handler({ | ||
match, chain, range, pasteEvent, | ||
}) { | ||
const attributes = callOrReturn(config.getAttributes, undefined, match, pasteEvent) | ||
@@ -27,0 +29,0 @@ if (attributes === false || attributes === null) { |
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
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
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
1953249
22940