@atlaskit/editor-common
Version:
A package that contains common classes and components for editor and renderer
36 lines (35 loc) • 1.88 kB
TypeScript
import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
/**
* Returns true if any cell in the first row of the table has a colwidth attribute set.
*
* Used by both the editor (as `hasTableColumnBeenResized`) and the renderer (as `hasColWidths`)
* to determine whether a table has had its columns manually resized.
*/
export declare const hasTableColumnBeenResized: (tableNode: PMNode) => boolean;
/**
* Returns true if the table has been explicitly resized — either the table itself has a width
* attribute set, or any column has been individually resized (colwidth present on cells).
*/
export declare const hasTableBeenResized: (tableNode: PMNode) => boolean;
/**
* Determines whether a table should render in content mode.
*
* Content mode tables have no fixed column widths — the browser sizes columns to fit their
* content (`table-layout: auto`). This is the shared core predicate used by both the editor
* and the renderer. Each consumer is responsible for computing `isSupported` from its own
* feature flags / props before calling this function.
*
* A table is in content mode when ALL of the following are true:
* 1. The `platform_editor_table_fit_to_content_auto_convert` experiment is enabled
* 2. `isSupported` is true (caller has verified resizing is allowed and appearance is full-page)
* 3. The table is not nested inside another table or block node
* 4. The table node exists
* 5. The table has not been explicitly resized (`width === null` and no `colwidth` on cells)
* 6. The table's layout is `'align-start'`
*/
export declare const isTableInContentMode: ({ tableNode, isSupported, isTableNested, }: {
/** Whether the current environment supports content mode (resizing enabled, full-page appearance). */
isSupported: boolean;
isTableNested?: boolean;
tableNode: PMNode | undefined;
}) => boolean;