@atlaskit/editor-plugin-block-type
Version:
BlockType plugin for @atlaskit/editor-core
54 lines (53 loc) • 2.84 kB
TypeScript
import type { InputRuleWrapper } from '@atlaskit/editor-common/types';
import type { NodeType, Node as PMNode } from '@atlaskit/editor-prosemirror/model';
import type { EditorState, Transaction } from '@atlaskit/editor-prosemirror/state';
import type { BlockType } from './types';
export declare const isNodeAWrappingBlockNode: (node?: PMNode | null) => boolean;
export declare const createJoinNodesRule: (match: RegExp, nodeType: NodeType) => InputRuleWrapper;
type WrappingTextRuleProps = {
getAttrs?: Record<string, any> | ((matchResult: RegExpExecArray) => Record<string, any>);
match: RegExp;
nodeType: NodeType;
};
export declare const createWrappingTextBlockRule: ({ match, nodeType, getAttrs, }: WrappingTextRuleProps) => InputRuleWrapper;
/**
* Function will check if changing block types: Paragraph, Heading is enabled.
*/
export declare function areBlockTypesDisabled(state: EditorState, allowFontSize?: boolean): boolean;
/**
* Checks if the current selection is inside a list node (bulletList, orderedList, or taskList).
* Used to determine which text styles should be enabled when the small font size experiment is active.
*/
export declare function isSelectionInsideListNode(state: EditorState): boolean;
export declare function isSelectionInsideBlockquote(state: EditorState): boolean;
export declare const checkFormattingIsPresent: (state: EditorState) => boolean;
export declare const hasBlockQuoteInOptions: (dropdownOptions: BlockType[]) => boolean;
/**
* Returns a { from, to } range that extends the selection boundaries outward
* to include the entirety of any list nodes at either end. If the selection
* start is inside a list, `from` is pulled back to the list's start; if the
* selection end is inside a list, `to` is pushed forward to the list's end.
* Non-list content in the middle is included as-is.
*/
export declare function getSelectionRangeExpandedToLists(tr: Transaction): {
from: number;
to: number;
};
/**
* Converts all taskItem nodes within the given range to blockTaskItem nodes.
*
* taskItem nodes contain inline content directly, which cannot hold block-level
* marks like fontSize. blockTaskItem nodes wrap content in paragraphs, which can
* hold block marks. This conversion is needed when applying small text formatting
* to task lists.
*
* The inline content of each taskItem is wrapped in a paragraph node, and the
* taskItem is replaced with a blockTaskItem that preserves the original attributes
* (localId, state).
*
* Collects taskItem positions in a forward pass over the unmutated document,
* then applies replacements in reverse document order so positions remain valid
* without needing remapping or doc snapshots.
*/
export declare function convertTaskItemsToBlockTaskItems(tr: Transaction, from: number, to: number): void;
export {};