@tiptap/core
Advanced tools
Comparing version 2.10.4 to 2.11.0
@@ -49,4 +49,5 @@ export * from './combineTransactionSteps.js'; | ||
export * from './resolveFocusPosition.js'; | ||
export * from './rewriteUnknownContent.js'; | ||
export * from './selectionToInsertionEnd.js'; | ||
export * from './splitExtensions.js'; | ||
//# sourceMappingURL=index.d.ts.map |
{ | ||
"name": "@tiptap/core", | ||
"description": "headless rich text editor", | ||
"version": "2.10.4", | ||
"version": "2.11.0", | ||
"homepage": "https://tiptap.dev", | ||
@@ -35,3 +35,3 @@ "keywords": [ | ||
"devDependencies": { | ||
"@tiptap/pm": "^2.10.4" | ||
"@tiptap/pm": "^2.11.0" | ||
}, | ||
@@ -38,0 +38,0 @@ "peerDependencies": { |
import { isTextSelection } from '../helpers/isTextSelection.js' | ||
import { resolveFocusPosition } from '../helpers/resolveFocusPosition.js' | ||
import { FocusPosition, RawCommands } from '../types.js' | ||
import { isiOS } from '../utilities/isiOS.js' | ||
@@ -46,7 +45,3 @@ declare module '@tiptap/core' { | ||
const delayedFocus = () => { | ||
// focus within `requestAnimationFrame` breaks focus on iOS | ||
// so we have to call this | ||
if (isiOS()) { | ||
(view.dom as HTMLElement).focus() | ||
} | ||
(view.dom as HTMLElement).focus() | ||
@@ -53,0 +48,0 @@ // For React we have to focus asynchronously. Otherwise wild things happen. |
@@ -0,1 +1,3 @@ | ||
import { AllSelection } from '@tiptap/pm/state' | ||
import { RawCommands } from '../types.js' | ||
@@ -15,7 +17,10 @@ | ||
export const selectAll: RawCommands['selectAll'] = () => ({ tr, commands }) => { | ||
return commands.setTextSelection({ | ||
from: 0, | ||
to: tr.doc.content.size, | ||
}) | ||
export const selectAll: RawCommands['selectAll'] = () => ({ tr, dispatch }) => { | ||
if (dispatch) { | ||
const selection = new AllSelection(tr.doc) | ||
tr.setSelection(selection) | ||
} | ||
return true | ||
} |
@@ -49,3 +49,4 @@ export * from './combineTransactionSteps.js' | ||
export * from './resolveFocusPosition.js' | ||
export * from './rewriteUnknownContent.js' | ||
export * from './selectionToInsertionEnd.js' | ||
export * from './splitExtensions.js' |
@@ -154,7 +154,7 @@ import { NodeSelection } from '@tiptap/pm/state' | ||
// this fix prevents that | ||
if (!isDraggable && isSelectable && isDragEvent) { | ||
if (!isDraggable && isSelectable && isDragEvent && event.target === this.dom) { | ||
event.preventDefault() | ||
} | ||
if (isDraggable && isDragEvent && !isDragging) { | ||
if (isDraggable && isDragEvent && !isDragging && event.target === this.dom) { | ||
event.preventDefault() | ||
@@ -161,0 +161,0 @@ return false |
@@ -165,2 +165,5 @@ import { Fragment, Node as ProseMirrorNode } from '@tiptap/pm/model' | ||
// When dragging across editors, must get another editor instance to delete selection content. | ||
let tiptapDragFromOtherEditor: Editor | null = null | ||
const createClipboardPasteEvent = (text: string) => { | ||
@@ -246,5 +249,16 @@ const event = new ClipboardEvent('paste', { | ||
: null | ||
if (dragSourceElement) { | ||
tiptapDragFromOtherEditor = editor | ||
} | ||
} | ||
const handleDragend = () => { | ||
if (tiptapDragFromOtherEditor) { | ||
tiptapDragFromOtherEditor = null | ||
} | ||
} | ||
window.addEventListener('dragstart', handleDragstart) | ||
window.addEventListener('dragend', handleDragend) | ||
@@ -254,2 +268,3 @@ return { | ||
window.removeEventListener('dragstart', handleDragstart) | ||
window.removeEventListener('dragend', handleDragend) | ||
}, | ||
@@ -265,2 +280,16 @@ } | ||
if (!isDroppedFromProseMirror) { | ||
const dragFromOtherEditor = tiptapDragFromOtherEditor | ||
if (dragFromOtherEditor) { | ||
// setTimeout to avoid the wrong content after drop, timeout arg can't be empty or 0 | ||
setTimeout(() => { | ||
const selection = dragFromOtherEditor.state.selection | ||
if (selection) { | ||
dragFromOtherEditor.commands.deleteRange({ from: selection.from, to: selection.to }) | ||
} | ||
}, 10) | ||
} | ||
} | ||
return false | ||
@@ -267,0 +296,0 @@ }, |
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 not supported yet
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
Sorry, the diff of this file is not supported yet
2540390
500
29110