Skip to content

Commit

Permalink
Merge pull request #465 from melvsparks/u/melvsparks/tableresize2
Browse files Browse the repository at this point in the history
U/melvsparks/tableresize2
  • Loading branch information
melvsparks authored Aug 12, 2020
2 parents 0b8efb4 + 289614d commit 775a8a0
Show file tree
Hide file tree
Showing 5 changed files with 419 additions and 234 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,4 +69,4 @@
"pre-commit": "pretty-quick --staged"
}
}
}
}
1 change: 1 addition & 0 deletions packages/roosterjs-editor-dom/lib/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ export { getNextLeafSibling, getPreviousLeafSibling } from './utils/getLeafSibli
export { getFirstLeafNode, getLastLeafNode } from './utils/getLeafNode';
export { default as getTextContent } from './utils/getTextContent';
export { default as splitTextNode } from './utils/splitTextNode';
export { default as normalizeRect } from './utils/normalizeRect';
export { default as toArray } from './utils/toArray';

export { default as VTable, VCell } from './table/VTable';
Expand Down
15 changes: 1 addition & 14 deletions packages/roosterjs-editor-dom/lib/selection/getPositionRect.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import createRange from './createRange';
import normalizeRect from '../utils/normalizeRect';
import { NodePosition, NodeType, Rect } from 'roosterjs-editor-types';

/**
Expand Down Expand Up @@ -52,17 +53,3 @@ export default function getPositionRect(position: NodePosition): Rect {

return null;
}

function normalizeRect(clientRect: ClientRect): Rect {
// A ClientRect of all 0 is possible. i.e. chrome returns a ClientRect of 0 when the cursor is on an empty p
// We validate that and only return a rect when the passed in ClientRect is valid
let { left, right, top, bottom } = clientRect || <ClientRect>{};
return left + right + top + bottom > 0
? {
left: Math.round(left),
right: Math.round(right),
top: Math.round(top),
bottom: Math.round(bottom),
}
: null;
}
18 changes: 18 additions & 0 deletions packages/roosterjs-editor-dom/lib/utils/normalizeRect.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { Rect } from 'roosterjs-editor-types';

/**
* A ClientRect of all 0 is possible. i.e. chrome returns a ClientRect of 0 when the cursor is on an empty p
* We validate that and only return a rect when the passed in ClientRect is valid
*/
export default function normalizeRect(clientRect: ClientRect): Rect {
let { left, right, top, bottom } =
clientRect || <ClientRect>{ left: 0, right: 0, top: 0, bottom: 0 };
return left + right + top + bottom > 0
? {
left: Math.round(left),
right: Math.round(right),
top: Math.round(top),
bottom: Math.round(bottom),
}
: null;
}
Loading

0 comments on commit 775a8a0

Please sign in to comment.