mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-06-04 19:42:46 +08:00
Adding definitions for prosemirror-table
This commit is contained in:
21
types/prosemirror-tables/dom.d.ts
vendored
Normal file
21
types/prosemirror-tables/dom.d.ts
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
export type DOMDataTransfer = DataTransfer;
|
||||
export type DOMDocument = Document;
|
||||
export type DOMElement = HTMLElement;
|
||||
export type DOMEvent = Event;
|
||||
export type DOMFragment = DocumentFragment;
|
||||
export type DOMKeyboardEvent = KeyboardEvent;
|
||||
export type DOMMouseEvent = MouseEvent;
|
||||
export type DOMMutationRecord = MutationRecord;
|
||||
export type DOMNode = Node;
|
||||
|
||||
export {
|
||||
DOMDataTransfer as DataTransfer,
|
||||
DOMDocument as Document,
|
||||
DOMElement as Element,
|
||||
DOMEvent as Event,
|
||||
DOMFragment as DocumentFragment,
|
||||
DOMKeyboardEvent as KeyboardEvent,
|
||||
DOMMouseEvent as MouseEvent,
|
||||
DOMMutationRecord as MutationRecord,
|
||||
DOMNode as Node,
|
||||
};
|
||||
125
types/prosemirror-tables/index.d.ts
vendored
Normal file
125
types/prosemirror-tables/index.d.ts
vendored
Normal file
@@ -0,0 +1,125 @@
|
||||
// Type definitions for prosemirror-tables 0.1
|
||||
// Project: https://github.com/ProseMirror/prosemirror-tables
|
||||
// Definitions by: Oscar Wallhult <https://github.com/superchu>
|
||||
// Eduard Shvedai <https://github.com/eshvedai>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.3
|
||||
import { EditorState, Plugin, SelectionRange, Transaction } from 'prosemirror-state';
|
||||
import { Node, NodeSpec, Slice, ResolvedPos } from 'prosemirror-model';
|
||||
import * as dom from './dom';
|
||||
|
||||
export interface TableNodesOptions {
|
||||
tableGroup?: string;
|
||||
cellContent: string;
|
||||
cellAttributes: { [key: string]: CellAttributes };
|
||||
}
|
||||
|
||||
export type getFromDOM = (dom: dom.DOMElement) => any;
|
||||
export type setDOMAttr = (value: any, attrs: any) => any;
|
||||
|
||||
export interface CellAttributes {
|
||||
default: any;
|
||||
getFromDOM?: getFromDOM;
|
||||
setDOMAttr?: setDOMAttr;
|
||||
}
|
||||
|
||||
export interface TableNodes {
|
||||
table: NodeSpec;
|
||||
table_row: NodeSpec;
|
||||
table_cell: NodeSpec;
|
||||
table_header: NodeSpec;
|
||||
}
|
||||
|
||||
export function tableNodes(options: TableNodesOptions): TableNodes;
|
||||
|
||||
export interface CellSelectionJSON {
|
||||
type: string;
|
||||
anchor: number;
|
||||
head: number;
|
||||
}
|
||||
|
||||
export class CellSelection {
|
||||
constructor($anchorCell: ResolvedPos, $headCell?: ResolvedPos);
|
||||
|
||||
from: number;
|
||||
to: number;
|
||||
$from: ResolvedPos;
|
||||
$to: ResolvedPos;
|
||||
anchor: number;
|
||||
head: number;
|
||||
$anchor: ResolvedPos;
|
||||
$head: ResolvedPos;
|
||||
$anchorCell: ResolvedPos;
|
||||
$headCell: ResolvedPos;
|
||||
empty: boolean;
|
||||
ranges: SelectionRange[];
|
||||
|
||||
map(doc: Node, mapping: any): any;
|
||||
content(): Slice;
|
||||
replace(tr: Transaction, content: Slice): void;
|
||||
replaceWith(tr: Transaction, node: Node): void;
|
||||
forEachCell(f: (node: Node, pos: number) => void): void;
|
||||
isRowSelection(): boolean;
|
||||
isColSelection(): boolean;
|
||||
eq(other: any): boolean;
|
||||
toJSON(): CellSelectionJSON;
|
||||
getBookmark(): {anchor: number, head: number};
|
||||
|
||||
static colSelection(anchorCell: ResolvedPos, headCell?: ResolvedPos): CellSelection;
|
||||
static rowSelection(anchorCell: ResolvedPos, headCell?: ResolvedPos): CellSelection;
|
||||
static create(doc: Node, anchorCell: number, headCell?: number): CellSelection;
|
||||
static fromJSON(doc: Node, json: CellSelectionJSON): CellSelection;
|
||||
}
|
||||
|
||||
export interface Rect {
|
||||
left: number;
|
||||
top: number;
|
||||
right: number;
|
||||
bottom: number;
|
||||
}
|
||||
|
||||
export class TableMap {
|
||||
width: number;
|
||||
height: number;
|
||||
map: number[];
|
||||
problems?: object[];
|
||||
|
||||
findCell(pos: number): Rect;
|
||||
colCount(pos: number): number;
|
||||
nextCell(pos: number, axis: string, dir: number): number;
|
||||
rectBetween(a: number, b: number): Rect;
|
||||
cellsInRect(rect: Rect): number[];
|
||||
positionAt(row: number, col: number, table: Node): number;
|
||||
|
||||
static get(table: Node): TableMap;
|
||||
}
|
||||
|
||||
export function tableEditing(): Plugin;
|
||||
|
||||
export function deleteTable(state: EditorState, dispatch?: (tr: Transaction) => void): boolean;
|
||||
|
||||
export function goToNextCell(direction: number): (state: EditorState, dispatch?: (tr: Transaction) => void) => boolean;
|
||||
|
||||
export function toggleHeaderCell(state: EditorState, dispatch?: (tr: Transaction) => void): boolean;
|
||||
|
||||
export function toggleHeaderColumn(state: EditorState, dispatch?: (tr: Transaction) => void): boolean;
|
||||
|
||||
export function toggleHeaderRow(state: EditorState, dispatch?: (tr: Transaction) => void): boolean;
|
||||
|
||||
export function setCellAttr(name: string, value: any): (state: EditorState, dispatch?: (tr: Transaction) => void) => boolean;
|
||||
|
||||
export function splitCell(state: EditorState, dispatch?: (tr: Transaction) => void): boolean;
|
||||
|
||||
export function mergeCells(state: EditorState, dispatch?: (tr: Transaction) => void): boolean;
|
||||
|
||||
export function deleteRow(state: EditorState, dispatch?: (tr: Transaction) => void): boolean;
|
||||
|
||||
export function addRowAfter(state: EditorState, dispatch?: (tr: Transaction) => void): boolean;
|
||||
|
||||
export function addRowBefore(state: EditorState, dispatch?: (tr: Transaction) => void): boolean;
|
||||
|
||||
export function deleteColumn(state: EditorState, dispatch?: (tr: Transaction) => void): boolean;
|
||||
|
||||
export function addColumnAfter(state: EditorState, dispatch?: (tr: Transaction) => void): boolean;
|
||||
|
||||
export function addColumnBefore(state: EditorState, dispatch?: (tr: Transaction) => void): boolean;
|
||||
3
types/prosemirror-tables/prosemirror-tables-tests.ts
Normal file
3
types/prosemirror-tables/prosemirror-tables-tests.ts
Normal file
@@ -0,0 +1,3 @@
|
||||
import * as tables from 'prosemirror-tables';
|
||||
|
||||
const table = tables.tableEditing();
|
||||
23
types/prosemirror-tables/tsconfig.json
Normal file
23
types/prosemirror-tables/tsconfig.json
Normal file
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6",
|
||||
"dom"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"prosemirror-tables-tests.ts"
|
||||
]
|
||||
}
|
||||
1
types/prosemirror-tables/tslint.json
Normal file
1
types/prosemirror-tables/tslint.json
Normal file
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Reference in New Issue
Block a user