Skip to content

Commit

Permalink
ref(selection): separate @lexical/selection/index into multiple files (
Browse files Browse the repository at this point in the history
  • Loading branch information
huytran46 authored Oct 12, 2022
1 parent c6bf5bf commit 8596d66
Show file tree
Hide file tree
Showing 7 changed files with 1,321 additions and 1,151 deletions.
8 changes: 8 additions & 0 deletions packages/lexical-selection/src/constants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*/
export const CSS_TO_STYLES: Map<string, Record<string, string>> = new Map();
29 changes: 29 additions & 0 deletions packages/lexical-selection/src/grid-selection.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*/

import type {ICloneSelectionContent} from './lexical-node';
import type {GridSelection, LexicalNode, NodeKey} from 'lexical';

import {$cloneWithProperties} from './lexical-node';

export function $cloneGridSelectionContent(
selection: GridSelection,
): ICloneSelectionContent {
const nodeMap = selection.getNodes().map<[NodeKey, LexicalNode]>((node) => {
const nodeKey = node.getKey();

const clone = $cloneWithProperties<LexicalNode>(node);

return [nodeKey, clone];
});

return {
nodeMap,
range: [selection.gridKey],
};
}
Loading

0 comments on commit 8596d66

Please sign in to comment.