UNPKG

@atlaskit/editor-core

Version:

A package contains Atlassian editor core functionality

105 lines (104 loc) 4.91 kB
import { MarkType, Node, NodeType, ResolvedPos, Selection, Transaction, EditorView, EditorState, Slice } from '../prosemirror'; import { JSONDocNode, JSONNode } from '../renderer/json'; export { default as ErrorReporter, ErrorReportingHandler } from './error-reporter'; export { JSONDocNode, JSONNode }; export { filterContentByType } from './filter'; export declare function canMoveUp(state: EditorState<any>): boolean; export declare function canMoveDown(state: EditorState<any>): boolean; export declare function atTheEndOfDoc(state: EditorState<any>): boolean; export declare function atTheBeginningOfDoc(state: EditorState<any>): boolean; export declare function atTheEndOfBlock(state: EditorState<any>): boolean; export declare function atTheBeginningOfBlock(state: EditorState<any>): boolean; export declare function startPositionOfParent(resolvedPos: ResolvedPos): number; export declare function endPositionOfParent(resolvedPos: ResolvedPos): number; /** * Check if a mark is allowed at the current position based on a given state. * This method looks both at the currently active marks as well as the node and marks * at the current position to determine if the given mark type is allowed. * If there's a non-empty selection, the current position corresponds to the start * of the selection. */ export declare function isMarkTypeAllowedAtCurrentPosition(markType: MarkType, state: EditorState<any>): boolean; /** * Step through block-nodes between $from and $to and returns false if a node is * found that isn't of the specified type */ export declare function isRangeOfType(doc: any, $from: ResolvedPos, $to: ResolvedPos, nodeType: NodeType): boolean; export declare function createSliceWithContent(content: string, state: EditorState<any>): Slice; /** * Determines if content inside a selection can be joined with the next block. * We need this check since the built-in method for "joinDown" will join a orderedList with bulletList. */ export declare function canJoinDown(selection: Selection, doc: any, nodeType: NodeType): boolean; export declare const setNodeSelection: (view: EditorView, pos: number) => void; export declare function setTextSelection(view: EditorView, anchor: number, head?: number): void; export declare function moveCursorToTheEnd(view: EditorView): void; /** * Determines if content inside a selection can be joined with the previous block. * We need this check since the built-in method for "joinUp" will join a orderedList with bulletList. */ export declare function canJoinUp(selection: Selection, doc: any, nodeType: NodeType): boolean; /** * Returns all top-level ancestor-nodes between $from and $to */ export declare function getAncestorNodesBetween(doc: any, $from: ResolvedPos, $to: ResolvedPos): Node[]; /** * Finds all "selection-groups" within a range. A selection group is based on ancestors. * * Example: * Given the following document and selection ({<} = start of selection and {>} = end) * doc * blockquote * ul * li * li{<} * li * p * p{>} * * The output will be two selection-groups. One within the ul and one with the two paragraphs. */ export declare function getGroupsInRange(doc: any, $from: ResolvedPos, $to: ResolvedPos, isNodeValid?: (node: Node) => boolean): Array<{ $from: ResolvedPos; $to: ResolvedPos; }>; /** * Traverse the document until an "ancestor" is found. Any nestable block can be an ancestor. */ export declare function findAncestorPosition(doc: Node, pos: any): any; /** * Determine if two positions have a common ancestor. */ export declare function hasCommonAncestor(doc: any, $from: ResolvedPos, $to: ResolvedPos): boolean; /** * Takes a selection $from and $to and lift all text nodes from their parents to document-level */ export declare function liftSelection(tr: any, doc: any, $from: ResolvedPos, $to: ResolvedPos): { tr: any; $from: any; $to: any; }; /** * Lift nodes in block to one level above. */ export declare function liftSiblingNodes(view: EditorView): void; /** * Lift sibling nodes to document-level and select them. */ export declare function liftAndSelectSiblingNodes(view: EditorView): Transaction; export declare function wrapIn(nodeType: NodeType, tr: Transaction, $from: ResolvedPos, $to: ResolvedPos): Transaction; export declare function toJSON(node: Node): JSONDocNode; /** * Repeating string for multiple times */ export declare function stringRepeat(text: string, length: number): string; /** * A replacement for `Array.from` until it becomes widely implemented. */ export declare function arrayFrom(obj: any): any[]; export declare function moveLeft(view: EditorView): void; /** * Function will check if changing block types: Paragraph, Heading is enabled. */ export declare function areBlockTypesDisabled(state: EditorState<any>): boolean; export declare const isTemporary: (id: string) => boolean;