@atlaskit/adf-schema
Version:
Shared package that contains the ADF-schema (json) and ProseMirror node/mark specs
152 lines (151 loc) • 5.77 kB
TypeScript
import { Node as PmNode } from '@atlaskit/editor-prosemirror/model';
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 interface CellAttributes {
colspan?: number;
rowspan?: number;
colwidth?: number[];
background?: string;
}
export declare const tablePrefixSelector = "pm-table";
export declare const tableCellSelector = "pm-table-cell-content-wrap";
export declare const tableHeaderSelector = "pm-table-header-content-wrap";
export declare const tableCellContentWrapperSelector = "pm-table-cell-nodeview-wrapper";
export declare const tableCellContentDomSelector = "pm-table-cell-nodeview-content-dom";
export declare const getCellAttrs: (dom: HTMLElement, defaultValues?: CellAttributes) => {
colspan: number;
rowspan: number;
colwidth: number[] | null;
background: string | null;
};
export type CellDomAttrs = {
colspan?: string;
rowspan?: string;
style?: string;
colorname?: string;
'data-colwidth'?: string;
'data-cell-background'?: string;
class?: string;
};
export declare const setGlobalTheme: (theme: string) => void;
/**
* 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 type DisplayMode = 'default' | 'fixed';
export type Layout = 'default' | 'full-width' | 'wide' | 'center' | 'align-start' | 'align-end';
export interface TableAttributes {
isNumberColumnEnabled?: boolean;
layout?: Layout;
__autoSize?: boolean;
/**
* @minLength 1
*/
localId?: string;
width?: number;
displayMode?: DisplayMode;
}
/**
* @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 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 interface TableWithNestedTableDefinition {
type: 'table';
attrs?: TableAttributes;
/**
* @minItems 1
*/
content: Array<TableRow>;
marks?: Array<FragmentDefinition>;
}
export interface TableRowWithNestedTableDefinition {
type: 'tableRow';
content: Array<TableHeader | TableCell>;
}
export interface TableCellWithNestedTableDefinition {
type: 'tableCell';
attrs?: CellAttributes;
content: TableCellContent | TableDefinition;
}
export interface TableHeaderWithNestedTableDefinition {
type: 'tableHeader';
attrs?: CellAttributes;
content: TableCellContent | TableDefinition;
}
/** Includes table width attribute */
export declare const table: import("prosemirror-model").NodeSpec;
/** @deprecated Do not use, instead use the regular `table` export */
export declare const tableWithCustomWidth: import("prosemirror-model").NodeSpec;
export declare const tableStage0: import("prosemirror-model").NodeSpec;
export declare const tableToJSON: (node: PmNode) => {
attrs: import("prosemirror-model").Attrs;
};
export declare const tableRow: import("prosemirror-model").NodeSpec;
export declare const tableCell: import("prosemirror-model").NodeSpec;
export declare const toJSONTableCell: (node: PmNode) => {
attrs: Record<string, any>;
};
export declare const tableHeader: import("prosemirror-model").NodeSpec;
export declare const toJSONTableHeader: (node: PmNode) => {
attrs: Record<string, any>;
};
export declare const tableWithNestedTable: import("prosemirror-model").NodeSpec;
export declare const tableRowWithNestedTable: import("prosemirror-model").NodeSpec;
export declare const tableCellWithNestedTable: import("prosemirror-model").NodeSpec;
export declare const tableHeaderWithNestedTable: import("prosemirror-model").NodeSpec;