UNPKG

@atlaskit/adf-schema

Version:

Shared package that contains the ADF-schema (json) and ProseMirror node/mark specs

31 lines (28 loc) 770 B
import { TableMap } from '@atlaskit/editor-tables/table-map'; /** * Util to get the table rect from the docs * @param doc * @param tablePos */ export function getTableRectFromDoc(doc, tablePos) { var table = doc.nodeAt(tablePos); // Check for table existence if (!table || table.type.name !== 'table') { throw new Error("No table at position \"".concat(tablePos, "\".")); } // Create transform base on the doc var map = TableMap.get(table); var $table = doc.resolve(tablePos); // Nested tables start position might differ from the original position var start = $table.start($table.depth + 1); return { map: map, table: table, tableStart: start, // Default to zero bottom: 0, left: 0, right: 0, top: 0 }; }