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

[PR 3] Removed edge-cases of GridSelection #5291

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
cb65bd9
swap instance selection for base in most cases
Nov 23, 2023
ef8ddc9
Fixed unit tests
Nov 23, 2023
5ceb3fa
Flow fix
Nov 23, 2023
6367b99
unit tests to take RangeSelection instead of all
Nov 24, 2023
e5d17a1
cleanups
Nov 24, 2023
6c3b7f4
Merge branch '5276-feature-gridselection-separation-from-lexical-core…
Nov 24, 2023
8fe4a9d
amend
Nov 24, 2023
e0b4594
Merge branch 'main' into 5276-feature-gridselection-separation-from-l…
Nov 24, 2023
820c859
Merge branch '5276-feature-gridselection-separation-from-lexical-core…
Nov 24, 2023
fbc04c8
comment fix
Nov 27, 2023
c4d7bb2
Merge branch '5276-feature-gridselection-separation-from-lexical-core…
Nov 27, 2023
176575d
Units and interface fix
Nov 27, 2023
d23a95f
Removed edge-cases of GridSelection
Nov 27, 2023
1d6411d
fix tables copy e2e
Nov 27, 2023
d93541e
e2e test
Nov 28, 2023
e0d6bcd
skip text for now
Nov 29, 2023
148b4aa
comment addressing
Dec 1, 2023
693f6e9
Merge branch '5276-feature-gridselection-separation-from-lexical-core…
Dec 1, 2023
17740c2
updates per comments
Dec 1, 2023
f241b3c
Merge branch '5276-feature-gridselection-separation-from-lexical-core…
Dec 1, 2023
00d9d60
unit
Dec 1, 2023
b9b9bfb
Merge branch '5276-feature-gridselection-separation-from-lexical-core…
Dec 1, 2023
198cc36
Merge branch '5276-feature-gridselection-separation-from-lexical-core…
Dec 1, 2023
d45cab1
merge
Dec 1, 2023
f61e117
Merge branch 'main' into 5276-feature-gridselection-separation-from-l…
Dec 5, 2023
972a909
comment update
Dec 8, 2023
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
1 change: 0 additions & 1 deletion packages/lexical-clipboard/flow/LexicalClipboard.js.flow
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import type {
BaseSelection,
LexicalEditor,
INTERNAL_PointSelection,
GridSelection,
RangeSelection,
LexicalNode,
} from 'lexical';
Expand Down
13 changes: 6 additions & 7 deletions packages/lexical-clipboard/src/clipboard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import {
$createTabNode,
$getRoot,
$getSelection,
$INTERNAL_isPointSelection,
$isElementNode,
$isRangeSelection,
$isTextNode,
Expand All @@ -30,13 +31,11 @@ import {
DEPRECATED_$isGridCellNode,
DEPRECATED_$isGridNode,
DEPRECATED_$isGridRowNode,
DEPRECATED_$isGridSelection,
DEPRECATED_GridNode,
GridSelection,
INTERNAL_PointSelection,
isSelectionWithinEditor,
LexicalEditor,
LexicalNode,
RangeSelection,
SELECTION_CHANGE_COMMAND,
SerializedTextNode,
} from 'lexical';
Expand Down Expand Up @@ -205,17 +204,17 @@ export function $insertGeneratedNodes(
nodes: Array<LexicalNode>,
selection: BaseSelection,
): void {
const isGridSelection = DEPRECATED_$isGridSelection(selection);
const isPointSelection = $INTERNAL_isPointSelection(selection);
const isRangeSelection = $isRangeSelection(selection);
const isSelectionInsideOfGrid =
isGridSelection ||
(isRangeSelection &&
$findMatchingParent(selection.anchor.getNode(), (n) =>
DEPRECATED_$isGridCellNode(n),
) !== null &&
$findMatchingParent(selection.focus.getNode(), (n) =>
DEPRECATED_$isGridCellNode(n),
) !== null);
) !== null) ||
(isPointSelection && !isRangeSelection);

if (
isSelectionInsideOfGrid &&
Expand All @@ -232,7 +231,7 @@ export function $insertGeneratedNodes(

function $mergeGridNodesStrategy(
nodes: LexicalNode[],
selection: RangeSelection | GridSelection,
selection: INTERNAL_PointSelection,
isFromLexical: boolean,
editor: LexicalEditor,
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,10 @@ test.describe('HTML Tables CopyAndPaste', () => {

test('Copy + paste - Merge Grids', async ({page, isPlainText, isCollab}) => {
test.skip(isPlainText);
test.fixme(
isCollab,
'Table selection styles are not properly selected/deselected',
);

await focusEditor(page);
await insertTable(page, 4, 4);
Expand Down
3 changes: 1 addition & 2 deletions packages/lexical-selection/src/lexical-node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import {
$setSelection,
BaseSelection,
DEPRECATED_$isGridCellNode,
DEPRECATED_$isGridSelection,
ElementNode,
INTERNAL_PointSelection,
LexicalEditor,
Expand Down Expand Up @@ -322,7 +321,7 @@ export function $patchStyleText(
const selectedNodes = selection.getNodes();
const selectedNodesLength = selectedNodes.length;

if (DEPRECATED_$isGridSelection(selection)) {
if (!$isRangeSelection(selection)) {
const cellSelection = $createRangeSelection();
const cellSelectionAnchor = cellSelection.anchor;
const cellSelectionFocus = cellSelection.focus;
Expand Down
16 changes: 0 additions & 16 deletions packages/lexical/src/LexicalSelection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -545,14 +545,6 @@ export class GridSelection extends INTERNAL_PointSelection {
this.gridKey = gridKey;
}

getCachedNodes(): LexicalNode[] | null {
return this._cachedNodes;
}

setCachedNodes(nodes: LexicalNode[] | null): void {
this._cachedNodes = nodes;
}

is(selection: null | BaseSelection): boolean {
if (!DEPRECATED_$isGridSelection(selection)) {
return false;
Expand Down Expand Up @@ -837,14 +829,6 @@ export class RangeSelection extends INTERNAL_PointSelection {
this.style = style;
}

getCachedNodes(): LexicalNode[] | null {
return this._cachedNodes;
}

setCachedNodes(nodes: LexicalNode[] | null): void {
this._cachedNodes = nodes;
}

/**
* Used to check if the provided selections is equal to this one by value,
* inluding anchor, focus, format, and style properties.
Expand Down
Loading