@atlaskit/editor-common
Version:
A package that contains common classes and components for editor and renderer
30 lines (29 loc) • 1.92 kB
TypeScript
import type { CodeBlockAttrs } from '@atlaskit/adf-schema';
import type { Node as PmNode, Schema, Slice } from '@atlaskit/editor-prosemirror/model';
import type { EditorState } from '@atlaskit/editor-prosemirror/state';
import type { NodeWithPos } from '@atlaskit/editor-prosemirror/utils';
export declare const defaultWordWrapState = false;
export declare const codeBlockWrappedStates: WeakMap<PmNode, boolean | undefined>;
type OptionalCodeBlockAttrs = CodeBlockAttrs | undefined;
export declare const getDefaultCodeBlockAttrs: (attrs?: CodeBlockAttrs) => OptionalCodeBlockAttrs;
export declare const defaultWrapForMarkdownCodeBlocksInSlice: (slice: Slice, schema: Schema) => Slice;
export interface FoldRange {
from: number;
to: number;
}
export declare const isCodeBlockWordWrapEnabled: (codeBlockNode: PmNode) => boolean;
export declare const areCodeBlockLineNumbersHidden: (codeBlockNode: PmNode) => boolean;
export declare const areCodeBlockLineNumbersVisible: (codeBlockNode: PmNode) => boolean;
export declare const getCodeBlockFoldState: (codeBlockNode: PmNode) => FoldRange[];
export declare const setCodeBlockFoldState: (codeBlockNode: PmNode, foldRanges: FoldRange[]) => void;
/**
* Swap the old node key with the new node key in the wrapped states WeakMap.
*/
export declare const transferCodeBlockWrappedValue: (oldCodeBlockNode: PmNode, newCodeBlockNode: PmNode) => void;
/**
* As the code block node is used as the wrapped state key, there is instances where the node will be destroyed & recreated and is no longer a valid key.
* In these instances, we must get the value from that old node and set it to the value of the new node.
* This function takes all the given nodes, finds their old nodes from the old state and updates these old node keys.
*/
export declare const updateCodeBlockWrappedStateNodeKeys: (newCodeBlockNodes: NodeWithPos[], oldState: EditorState) => void;
export {};