@atlaskit/adf-schema
Version:
Shared package that contains the ADF-schema (json) and ProseMirror node/mark specs
115 lines (114 loc) • 4.1 kB
TypeScript
import { Node as PmNode, NodeSpec } from 'prosemirror-model';
import { CellAttributes } from '@atlaskit/editor-tables/types';
import { PanelDefinition as Panel } from './panel';
import { ParagraphDefinition as Paragraph, ParagraphWithAlignmentDefinition as ParagraphWithMarks } from './paragraph';
import { BlockQuoteDefinition as Blockquote } from './blockquote';
import { OrderedListDefinition as OrderedList } from './types/list';
import { BulletListDefinition as BulletList } from './types/list';
import { RuleDefinition as Rule } from './rule';
import { HeadingDefinition as Heading, HeadingWithMarksDefinition as HeadingWithMarks } from './heading';
import { CodeBlockDefinition as CodeBlock } from './code-block';
import { MediaGroupDefinition as MediaGroup } from './media-group';
import { MediaSingleDefinition as MediaSingle } from './media-single';
import { DecisionListDefinition as DecisionList } from './decision-list';
import { TaskListDefinition as TaskList } from './task-list';
import { ExtensionDefinition as Extension } from './extension';
import { BlockCardDefinition as BlockCard } from './block-card';
import { EmbedCardDefinition as EmbedCard } from './embed-card';
import { NestedExpandDefinition as NestedExpand } from './nested-expand';
import { FragmentDefinition } from '../marks/fragment';
export type { CellAttributes };
export declare const tablePrefixSelector = "pm-table";
export declare const tableCellSelector: string;
export declare const tableHeaderSelector: string;
export declare const tableCellContentWrapperSelector: string;
export declare const tableCellContentDomSelector: string;
export declare const getCellAttrs: (dom: HTMLElement, defaultValues?: CellAttributes) => {
colspan: number;
rowspan: number;
colwidth: number[] | null;
background: string | null;
};
export declare type CellDomAttrs = {
colspan?: string;
rowspan?: string;
style?: string;
colorname?: string;
'data-colwidth'?: string;
'data-cell-background'?: string;
class?: string;
};
/**
* gets cell dom attributes based on node attributes
* @returns CellDomAttrs
*/
export declare const getCellDomAttrs: (node: PmNode) => CellDomAttrs;
export declare const tableBackgroundColorPalette: Map<string, string>;
export declare const tableBackgroundBorderColor: string;
export declare const tableBackgroundColorNames: Map<string, string>;
export declare type Layout = 'default' | 'full-width' | 'wide';
export interface TableAttributes {
isNumberColumnEnabled?: boolean;
layout?: Layout;
__autoSize?: boolean;
/**
* @minLength 1
*/
localId?: string;
}
/**
* @name table_node
*/
export interface TableDefinition {
type: 'table';
attrs?: TableAttributes;
/**
* @minItems 1
*/
content: Array<TableRow>;
marks?: Array<FragmentDefinition>;
}
/**
* @name table_row_node
*/
export interface TableRow {
type: 'tableRow';
content: Array<TableHeader | TableCell>;
}
/**
* @name table_cell_content
* @minItems 1
* @allowUnsupportedBlock true
*/
export declare type TableCellContent = Array<Panel | Paragraph | ParagraphWithMarks | Blockquote | OrderedList | BulletList | Rule | Heading | HeadingWithMarks | CodeBlock | MediaGroup | MediaSingle | DecisionList | TaskList | Extension | BlockCard | NestedExpand | EmbedCard>;
/**
* @name table_cell_node
*/
export interface TableCell {
type: 'tableCell';
attrs?: CellAttributes;
content: TableCellContent;
}
/**
* @name table_header_node
*/
export interface TableHeader {
type: 'tableHeader';
attrs?: CellAttributes;
content: TableCellContent;
}
export declare const table: NodeSpec;
export declare const tableToJSON: (node: PmNode) => {
attrs: {
[key: string]: any;
};
};
export declare const tableRow: NodeSpec;
export declare const tableCell: NodeSpec;
export declare const toJSONTableCell: (node: PmNode) => {
attrs: Record<string, any>;
};
export declare const tableHeader: NodeSpec;
export declare const toJSONTableHeader: (node: PmNode) => {
attrs: Record<string, any>;
};