@atlaskit/editor-common
Version:
A package that contains common classes and components for editor and renderer
39 lines (38 loc) • 1.94 kB
TypeScript
import type { NodeType } from '@atlaskit/editor-prosemirror/model';
import { Fragment, Node } from '@atlaskit/editor-prosemirror/model';
import type { EditorState, Transaction } from '@atlaskit/editor-prosemirror/state';
export type InsertableContent = Node | Fragment;
export declare enum LookDirection {
Before = "before",
After = "after"
}
export declare const normaliseNestedLayout: ({ selection, doc }: EditorState | Transaction, node: Node) => Node;
export declare const safeInsert: (content: InsertableContent, position?: number) => (tr: Transaction) => Transaction | null;
/**
* Method extracted from typeahead plugin to be shared with the element browser on handling element insertion.
*/
export declare const insertSelectedItem: (maybeNode?: Node | Object | string | Fragment, opts?: {
selectInlineNode?: boolean;
}) => (state: EditorState, tr: Transaction, start: number) => Transaction;
/**
* ED-14584: Util to check if the destination node is a paragraph & the
* content being inserted is a valid child of the grandparent node.
* In this case, the destination node should split
*/
export declare const shouldSplitSelectedNodeOnNodeInsertion: ({ parentNodeType, grandParentNodeType, content, }: {
content: Node;
grandParentNodeType: NodeType;
parentNodeType: NodeType;
}) => boolean;
/**
* Check if the current selection contains any nodes that are not permitted
* as codeBlock child nodes. Note that this allows paragraphs and inline nodes
* as we extract their text content.
*/
export declare function contentAllowedInCodeBlock(state: EditorState): boolean;
/**
* Check if a fragment contains a particular node by iterating through all the nodes in the fragment.
* If the node type is found will stop looking and return true.
* If the node type is not found, it will return false.
*/
export declare function fragmentContainsNodeType(fragment: Fragment, nodeType: NodeType): boolean;