Skip to content

A fully open source & end-to-end encrypted note taking alternative to Evernote.

editor: multiple tables in 1 note should not freeze the editor (#1228)

Dylan57658beb1c8c
diff --git a/packages/editor/src/utils/position.ts b/packages/editor/src/utils/position.ts
index 40117f66e..fb9ace3bd 100644
--- a/packages/editor/src/utils/position.ts
+++ b/packages/editor/src/utils/position.ts
@@ -46,9 +46,18 @@ export type PositionOptions = {
parent?: HTMLElement | Element;
};
export function getPosition(
- element: HTMLElement,
+ node: Node,
options: PositionOptions
): { top: number; left: number } {
+ let element: HTMLElement;
+ if (node instanceof HTMLElement) {
+ element = node;
+ } else if (node.parentElement !== null) {
+ element = node.parentElement;
+ } else {
+ throw new Error(`Unsupported node type ${node.nodeType}`);
+ }
+
const {
target = "mouse",
isTargetAbsolute = false,