Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Block editor: try direct drag (outside text editable) #67305

Merged
merged 29 commits into from
Nov 29, 2024
Merged
Changes from 1 commit
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
e833f64
block editor: try direct drag if no text selection
ellatrix Nov 26, 2024
7df944f
Fix Safari issue
ellatrix Nov 26, 2024
7e48854
simplify condition
ellatrix Nov 27, 2024
60218be
Disable for multi-selection
ellatrix Nov 27, 2024
910a9bc
Add drap chip
ellatrix Nov 27, 2024
9ea2fe1
Disable when CE and draggable are the same element
ellatrix Nov 27, 2024
d08aabe
Set drag item in store
ellatrix Nov 27, 2024
dda0ad3
Fix spacer
ellatrix Nov 27, 2024
f076e3d
Disable drag when child is selected
ellatrix Nov 27, 2024
7b7871a
fix multi selection issue
ellatrix Nov 27, 2024
fd1d795
Hide toolbar when dragging
ellatrix Nov 27, 2024
1914df1
make resize handles focusable
ellatrix Nov 27, 2024
40b99ab
Hide toolbar differently
ellatrix Nov 27, 2024
31f04d6
Add grabbing for ff
ellatrix Nov 27, 2024
a7f0617
Add comment
ellatrix Nov 28, 2024
6012f63
Add changelog
ellatrix Nov 28, 2024
589fd6e
fix changelog
ellatrix Nov 28, 2024
b7ad95f
Fix firefox drag image
ellatrix Nov 28, 2024
a9cd7be
Remove drag if block can't be moved
ellatrix Nov 28, 2024
77b8603
Fix iframe drag
ellatrix Nov 28, 2024
40574f1
fix custom sources tests
ellatrix Nov 28, 2024
a0c1a6b
Improve image drag rule
ellatrix Nov 28, 2024
81266c6
disable drag on normal svgs
ellatrix Nov 28, 2024
3af4d30
ff compat
ellatrix Nov 28, 2024
a3071ae
Restore hasChildSelected condition
ellatrix Nov 28, 2024
720b9d5
Add e2e test
ellatrix Nov 28, 2024
fbcf496
Improve comment
ellatrix Nov 28, 2024
766e34e
oopsie
ellatrix Nov 28, 2024
76f61df
add ff comment
ellatrix Nov 29, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
simplify condition
  • Loading branch information
ellatrix committed Nov 29, 2024
commit 7e48854ae48a74d20c32858d29308fdd1ddffd04
Original file line number Diff line number Diff line change
Expand Up @@ -76,23 +76,7 @@ export function useEventHandlers( { clientId, isSelected } ) {
* @param {DragEvent} event Drag event.
*/
function onDragStart( event ) {
const { ownerDocument } = node;
const { defaultView } = ownerDocument;
const selection = defaultView.getSelection();
let { anchorNode, focusNode } = selection;
if ( anchorNode !== anchorNode.ELEMENT_NODE ) {
anchorNode = anchorNode.parentElement;
}
if ( focusNode !== focusNode.ELEMENT_NODE ) {
focusNode = focusNode.parentElement;
}
if (
node !== event.target ||
( node.contains( anchorNode ) &&
anchorNode.isContentEditable ) ||
( node.contains( focusNode ) &&
focusNode.isContentEditable )
) {
if ( node !== event.target || node.isContentEditable ) {
event.preventDefault();
return;
}
ellatrix marked this conversation as resolved.
Show resolved Hide resolved
Expand All @@ -103,6 +87,9 @@ export function useEventHandlers( { clientId, isSelected } ) {
} );
event.dataTransfer.clearData();
event.dataTransfer.setData( 'wp-blocks', data );
const { ownerDocument } = node;
const { defaultView } = ownerDocument;
const selection = defaultView.getSelection();
selection.removeAllRanges();
}

Expand Down